diff --git a/Dockerfile b/Dockerfile index 8f23b1df7f1..a948d9b45bc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,28 @@ -FROM ubuntu:24.04 AS build - +FROM ubuntu:24.04 ENV TZ=UTC ENV LANG=C.UTF-8 +ENV N64_GCCPREFIX=/opt/libdragon + +ADD https://github.com/DragonMinded/libdragon/releases/download/toolchain-continuous-prerelease/gcc-toolchain-mips64-x86_64.deb gcc-toolchain-mips64-x86_64.deb -RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && \ - apt-get update && \ - apt-get install -y \ - binutils-mips-linux-gnu \ +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone +RUN apt-get update +RUN apt-get install -y \ build-essential \ python3 \ python3-pip \ - python3-venv \ git \ curl \ - clang-tidy \ - clang-format \ - && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - + clang-tidy-14 \ + clang-format-14 +RUN apt-get install -y ./gcc-toolchain-mips64-x86_64.deb +RUN apt-get clean +RUN rm -rf /var/lib/apt/lists/* +RUN mkdir /oot WORKDIR /oot + RUN git config --global --add safe.directory /oot -CMD make -j $(nproc) setup && make -j $(nproc) && tail -f /dev/null +CMD ["/bin/sh", "-c", \ + "echo 'usage:\n docker run --rm --mount type=bind,source=\"$(pwd)\",destination=/oot oot make -j$(nproc) setup\n docker run --rm --mount type=bind,source=\"$(pwd)\",destination=/oot oot make -j$(nproc)'"] diff --git a/Doxyfile b/Doxyfile index 499b9061700..53ee04bdf13 100644 --- a/Doxyfile +++ b/Doxyfile @@ -187,7 +187,7 @@ SHORT_NAMES = NO # description.) # The default value is: NO. -JAVADOC_AUTOBRIEF = YES +JAVADOC_AUTOBRIEF = NO # If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first # line (until the first dot) of a Qt-style comment as the brief description. If diff --git a/Makefile b/Makefile index 8a2f552e695..2c774a1408b 100644 --- a/Makefile +++ b/Makefile @@ -40,7 +40,7 @@ COMPILER ?= ido # gc-jp-ce GameCube Japan (Collector's Edition disc) # ique-cn iQue Player (Simplified Chinese) VERSION ?= gc-eu-mq-dbg -# Number of threads to extract and compress with. +# Number of threads to extract assets and compress with. N_THREADS ?= $(shell nproc) # If DEBUG_OBJECTS is 1, produce additional debugging files such as objdump output or raw binaries for assets DEBUG_OBJECTS ?= 0 @@ -400,7 +400,7 @@ SFCFLAGS := --matching # Extra debugging steps ifeq ($(DEBUG_OBJECTS),1) - OBJDUMP_CMD = @$(OBJDUMP) $(OBJDUMP_FLAGS) $@ > $(@:.o=.s) + OBJDUMP_CMD = @$(OBJDUMP) -d $@ > $(@:.o=.s) OBJCOPY_CMD = @$(OBJCOPY) -O binary $@ $(@:.o=.bin) else OBJDUMP_CMD = @: @@ -454,8 +454,6 @@ else CC_CHECK = @: endif -OBJDUMP_FLAGS := -d -r -z -Mreg-names=32 - #### Files #### # ROM image @@ -611,13 +609,13 @@ else SEGMENT_FILES := OVL_SEGMENT_FILES := endif -OVL_RELOC_FILES := $(OVL_SEGMENT_FILES:.plf=.reloc.o) +RELOC_O_FILES := $(OVL_SEGMENT_FILES:.plf=.reloc.o) O_FILES := $(shell $(CPP) $(CPPFLAGS) -I. $(SPEC) | $(BUILD_DIR_REPLACE) | sed -n -E 's/^[ \t]*include[ \t]*"([a-zA-Z0-9/_.-]+\.o)"/\1/p') MAKEROM_O_FILES := $(BUILD_DIR)/src/makerom/rom_header.o $(BUILD_DIR)/src/makerom/ipl3.o $(BUILD_DIR)/src/makerom/entry.o # Automatic dependency files -DEP_FILES := $(O_FILES:.o=.d) $(O_FILES:.o=.asmproc.d) $(OVL_RELOC_FILES:.o=.d) $(BUILD_DIR)/spec.d $(MAKEROM_O_FILES:.o=.d) +DEP_FILES := $(O_FILES:.o=.d) $(O_FILES:.o=.asmproc.d) $(RELOC_O_FILES:.o=.d) $(BUILD_DIR)/spec.d $(MAKEROM_O_FILES:.o=.d) $(BUILD_DIR)/src/boot/build.o: CPP_DEFINES += -DBUILD_CREATOR="\"$(BUILD_CREATOR)\"" -DBUILD_DATE="\"$(BUILD_DATE)\"" -DBUILD_TIME="\"$(BUILD_TIME)\"" @@ -689,7 +687,7 @@ $(BUILD_DIR)/src/libc/%.o: CFLAGS := $(EGCS_CFLAGS) -mno-abicalls $(BUILD_DIR)/src/libc/%.o: CCASFLAGS := $(EGCS_CCASFLAGS) $(BUILD_DIR)/src/libc/%.o: OPTFLAGS := -O1 $(BUILD_DIR)/src/libc/%.o: MIPS_VERSION := -$(BUILD_DIR)/src/libc/memmove.o: MIPS_VERSION := -mips2 +$(BUILD_DIR)/src/libc/code_801068B0.o: MIPS_VERSION := -mips2 else ifeq ($(DEBUG_FEATURES),1) $(BUILD_DIR)/src/libc/%.o: OPTFLAGS := -g $(BUILD_DIR)/src/libc/%.o: ASOPTFLAGS := -g @@ -884,13 +882,13 @@ disasm: $(RM) -r $(EXPECTED_DIR) VERSION=$(VERSION) DISASM_BASEROM=$(BASEROM_DIR)/baserom-decompressed.z64 DISASM_DIR=$(EXPECTED_DIR) PYTHON=$(PYTHON) AS_CMD='$(AS) $(ASFLAGS)' LD=$(LD) ./tools/disasm/do_disasm.sh +resources: $(ASSET_FILES_OUT) run: $(ROM) ifeq ($(N64_EMULATOR),) $(error Emulator path not set. Set N64_EMULATOR in the Makefile or define it as an environment variable) endif $(N64_EMULATOR) $< - .PHONY: all rom compress clean assetclean distclean venv setup disasm run .DEFAULT_GOAL := rom @@ -915,7 +913,7 @@ $(ROMC): $(ROM) $(ELF) $(BUILD_DIR)/compress_ranges.txt LDFLAGS := -T $(LDSCRIPT) -T $(BUILD_DIR)/linker_scripts/makerom.ld -T $(BUILD_DIR)/undefined_syms.txt --emit-relocs -Map $(MAP) -$(ELF): $(TEXTURE_FILES_OUT) $(ASSET_FILES_OUT) $(SEGMENT_FILES) $(OVL_RELOC_FILES) $(LDSCRIPT) $(MAKEROM_O_FILES) \ +$(ELF): $(TEXTURE_FILES_OUT) $(ASSET_FILES_OUT) $(SEGMENT_FILES) $(RELOC_O_FILES) $(LDSCRIPT) $(MAKEROM_O_FILES) \ $(BUILD_DIR)/linker_scripts/makerom.ld $(BUILD_DIR)/undefined_syms.txt \ $(SAMPLEBANK_O_FILES) $(SOUNDFONT_O_FILES) $(SEQUENCE_O_FILES) \ $(BUILD_DIR)/assets/audio/sequence_font_table.o $(BUILD_DIR)/assets/audio/audiobank_padding.o @@ -924,17 +922,9 @@ $(ELF): $(TEXTURE_FILES_OUT) $(ASSET_FILES_OUT) $(SEGMENT_FILES) $(OVL_RELOC_FIL $(BUILD_DIR)/linker_scripts/makerom.ld: linker_scripts/makerom.ld $(CPP) -I include $(CPPFLAGS) $< > $@ -## 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 +$(RELOC_O_FILES): | o_files +.PHONY: o_files $(BUILD_DIR)/spec: $(SPEC) $(SPEC_INCLUDES) $(CPP) $(CPPFLAGS) -MD -MP -MF $@.d -MT $@ -I. $< | $(BUILD_DIR_REPLACE) > $@ @@ -956,13 +946,13 @@ $(SEGMENTS_DIR)/%.reloc.o: $(SEGMENTS_DIR)/%.plf $(AS) $(ASFLAGS) $(@:.o=.s) -o $@ $(BUILD_DIR)/undefined_syms.txt: undefined_syms.txt - $(CPP) $(CPPFLAGS) $< > $@ + $(CPP) $(CPPFLAGS) $< > $(BUILD_DIR)/undefined_syms.txt $(BUILD_DIR)/baserom/%.o: $(EXTRACTED_DIR)/baserom/% $(OBJCOPY) -I binary -O $(LD_OFORMAT) $< $@ $(BUILD_DIR)/data/%.o: data/%.s - $(CPP) $(CPPFLAGS) -MD -MP -MF $(@:.o=.d) -MT $@ -Iinclude $< | $(AS) $(ASFLAGS) -o $@ + $(CPP) $(CPPFLAGS) -MD -MP -MF $(@:.o=.d) -MT $@ -Iinclude $< | iconv --from UTF-8 --to EUC-JP | $(AS) $(ASFLAGS) -o $@ ifeq ($(PLATFORM),IQUE) NES_CHARMAP := assets/text/charmap.chn.txt diff --git a/README.md b/README.md index 89c87b13db5..0564d5917a5 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,8 @@ the codebase can drastically change at any time. Also note that some parts of th 'shiftable' yet, so modifying them could be difficult at this point. ``` -This is a WIP **decompilation** of ***The Legend of Zelda: Ocarina of Time***. The purpose of the project is to recreate a source code base for the game from scratch, using information found inside the game along with static and/or dynamic analysis. **It is not producing a PC port.** For more information you can get in touch with the team on our [Discord server][discord]. +This is a WIP decompilation of The Legend of Zelda: Ocarina of Time. +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 builds the following versions: @@ -56,24 +57,37 @@ The default version is `gc-eu-mq-dbg`, i.e. the GameCube Europe/PAL Master Quest ## Installation -We recommend using WSL on Windows, or native Linux, which the rest of this readme describes. We currently have instructions for - -* [Windows](#Windows), with and without WSL -* [macOS](docs/BUILDING_MACOS.md) -* [Linux](#Linux-Native-or-under-WSL--VM), natively or using WSL / VM -* [Docker](docs/BUILDING_DOCKER.md) - -(These will also depend on the Linux instructions.) -Some of these may also be out of date or unmaintained; usually our contributors use WSL, Linux, and macOS, so these instructions should be up to date. - ### Windows For Windows 10 or 11, install WSL and a distribution by following this [WSL Installation Guide](https://learn.microsoft.com/en-us/windows/wsl/install). -We recommend using Ubuntu as the Linux distribution. +We recommend using Debian or Ubuntu Linux distributions. + +For older versions of Windows, install a Linux VM or refer to [Docker](docs/building/docker.md) instructions. + +### macOS + +For macOS, use homebrew to install the following dependencies: -For older versions of Windows, install a Linux VM or refer to [Docker](docs/BUILDING_DOCKER.md) instructions. +* coreutils +* make +* python3 +* md5sha1sum +* libiconv + +You can install them with the following commands: + +```bash +brew update +brew install coreutils make python3 md5sha1sum libiconv +``` +You'll also need to [build and install mips-linux-binutils](docs/BUILDING_BINUTILS_MACOS.md). + +Going forward in this guide, please use `gmake` whenever you encounter a `make` command. +The `make` that comes with macOS behaves differently than GNU make and is incompatible with this project. + +You should now be able to continue from [step 2](#2-clone-the-repository) of the Linux instructions. ### Linux (Native or under WSL / VM) @@ -110,21 +124,12 @@ If you are using GCC as the compiler for Ocarina of Time, you will also need the #### 2. Clone the repository -**N.B.** If using WSL, we strongly encourage you to clone into WSL's Linux filesystem using Linux's `git`. -Cloning into the Windows filesystem will result in much slower read/write speeds, and often causes issues when Windows copies the files with the wrong line endings, which the compiler IDO cannot handle correctly. - Clone `https://github.com/zeldaret/oot.git` where you wish to have the project, with a command such as: ```bash git clone https://github.com/zeldaret/oot.git ``` -This will copy the GitHub repository contents into a new folder in the current directory called `oot`. Change into this directory before doing anything else: - -```bash -cd oot -``` - #### 3. Prepare a base ROM First, pick the version of the game you want to build. @@ -180,13 +185,6 @@ md5sum: WARNING: 1 computed checksum did NOT match This means that the built ROM isn't the same as the base one, so something went wrong or some part of the code doesn't match. -**NOTE:** to speed up the build, you can either: - -* pass `-jN` to `make setup` and `make`, where N is the number of threads to use in the build. The generally-accepted wisdom is to use the number of virtual cores your computer has. -* pass `-j` to `make setup` and `make`, to use as many threads as possible, but beware that this can use too much memory on lower-end systems. - -Both of these have the disadvantage that the ordering of the terminal output is scrambled, so for debugging it is best to stick to one thread (i.e. not pass `-j` or `-jN`). - ## Changing build options By default, if you don't specify a version to build with `VERSION=` in the make commands, the `gc-eu-mq-dbg` version is used. diff --git a/assets/objects/object_triforce_spot/object_triforce_spot.c b/assets/objects/object_triforce_spot/object_triforce_spot.c deleted file mode 100644 index 49729e7253f..00000000000 --- a/assets/objects/object_triforce_spot/object_triforce_spot.c +++ /dev/null @@ -1,30 +0,0 @@ -#include "object_triforce_spot.h" -#include "gfx.h" - -Vtx gTriforceVtx[] = { -#include "assets/objects/object_triforce_spot/gTriforceVtx.inc.c" -}; - -Vtx gTriforceLightColumnVtx[] = { -#include "assets/objects/object_triforce_spot/gTriforceLightColumnVtx.inc.c" -}; - -Gfx gTriforceDL[72] = { -#include "assets/objects/object_triforce_spot/gTriforceDL.inc.c" -}; - -Gfx gTriforceLightColumnDL[26] = { -#include "assets/objects/object_triforce_spot/gTriforceLightColumnDL.inc.c" -}; - -u64 gTriforceTex[TEX_LEN(u64, gTriforceTex_WIDTH, gTriforceTex_HEIGHT, 8)] = { -#include "assets/objects/object_triforce_spot/gTriforceTex.i8.inc.c" -}; - -u64 gTriforceColumnSide1Tex[TEX_LEN(u64, gTriforceColumnSide1Tex_WIDTH, gTriforceColumnSide1Tex_HEIGHT, 8)] = { -#include "assets/objects/object_triforce_spot/gTriforceColumnSide1Tex.i8.inc.c" -}; - -u64 gTriforceColumnSide2Tex[TEX_LEN(u64, gTriforceColumnSide2Tex_WIDTH, gTriforceColumnSide2Tex_HEIGHT, 8)] = { -#include "assets/objects/object_triforce_spot/gTriforceColumnSide2Tex.i8.inc.c" -}; diff --git a/assets/objects/object_triforce_spot/object_triforce_spot.h b/assets/objects/object_triforce_spot/object_triforce_spot.h deleted file mode 100644 index 7db44851fc3..00000000000 --- a/assets/objects/object_triforce_spot/object_triforce_spot.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef OBJECT_TRIFORCE_SPOT_H -#define OBJECT_TRIFORCE_SPOT_H - -#include "ultra64.h" -#include "tex_len.h" - -extern Vtx gTriforceVtx[]; -extern Gfx gTriforceDL[72]; - -extern Gfx gTriforceLightColumnDL[26]; - -#define gTriforceTex_WIDTH 64 -#define gTriforceTex_HEIGHT 64 -extern u64 gTriforceTex[TEX_LEN(u64, gTriforceTex_WIDTH, gTriforceTex_HEIGHT, 8)]; - -#define gTriforceColumnSide1Tex_WIDTH 64 -#define gTriforceColumnSide1Tex_HEIGHT 32 -extern u64 gTriforceColumnSide1Tex[TEX_LEN(u64, gTriforceColumnSide1Tex_WIDTH, gTriforceColumnSide1Tex_HEIGHT, 8)]; - -#define gTriforceColumnSide2Tex_WIDTH 64 -#define gTriforceColumnSide2Tex_HEIGHT 32 -extern u64 gTriforceColumnSide2Tex[TEX_LEN(u64, gTriforceColumnSide2Tex_WIDTH, gTriforceColumnSide2Tex_HEIGHT, 8)]; - -#endif diff --git a/assets/xml/n64dd/error_textures.xml b/assets/xml/misc/n64dd_error_textures.xml similarity index 100% rename from assets/xml/n64dd/error_textures.xml rename to assets/xml/misc/n64dd_error_textures.xml diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 17b456b1b40..87788a8bab1 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -26,7 +26,6 @@ - diff --git a/assets/xml/objects/object_efc_crystal_light.xml b/assets/xml/objects/object_efc_crystal_light.xml index dbd09361918..e28a7698cc8 100644 --- a/assets/xml/objects/object_efc_crystal_light.xml +++ b/assets/xml/objects/object_efc_crystal_light.xml @@ -1,9 +1,9 @@ - - + + - + diff --git a/assets/xml/objects/object_efc_fire_ball.xml b/assets/xml/objects/object_efc_fire_ball.xml index 2c9ec2cab96..7b1b16bbd53 100644 --- a/assets/xml/objects/object_efc_fire_ball.xml +++ b/assets/xml/objects/object_efc_fire_ball.xml @@ -1,10 +1,10 @@ - + - - - + + + diff --git a/assets/xml/objects/object_efc_lgt_shower.xml b/assets/xml/objects/object_efc_lgt_shower.xml index 81d3d5e17d6..b5119206cb1 100644 --- a/assets/xml/objects/object_efc_lgt_shower.xml +++ b/assets/xml/objects/object_efc_lgt_shower.xml @@ -1,9 +1,9 @@ - - + + - + diff --git a/assets/xml/objects/object_efc_tw.xml b/assets/xml/objects/object_efc_tw.xml index cfc539111fd..f8f0d06d4e8 100644 --- a/assets/xml/objects/object_efc_tw.xml +++ b/assets/xml/objects/object_efc_tw.xml @@ -1,13 +1,13 @@ - - - - - + + - - + + + + + diff --git a/assets/xml/objects/object_ge1.xml b/assets/xml/objects/object_ge1.xml index 0aaaf59b7b6..d43fcd99290 100644 --- a/assets/xml/objects/object_ge1.xml +++ b/assets/xml/objects/object_ge1.xml @@ -1,134 +1,114 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + - + - + + + + + + diff --git a/assets/xml/objects/object_geldb.xml b/assets/xml/objects/object_geldb.xml index a0d05bea492..124eddcdd59 100644 --- a/assets/xml/objects/object_geldb.xml +++ b/assets/xml/objects/object_geldb.xml @@ -21,126 +21,126 @@ - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_gi_jewel.xml b/assets/xml/objects/object_gi_jewel.xml index 1d919b6ef66..b8a8adba2a2 100644 --- a/assets/xml/objects/object_gi_jewel.xml +++ b/assets/xml/objects/object_gi_jewel.xml @@ -1,34 +1,29 @@ - - - - - + + - - - - + + - - + + diff --git a/assets/xml/objects/object_god_lgt.xml b/assets/xml/objects/object_god_lgt.xml index 66acbf59e9b..ceb29cb60ad 100644 --- a/assets/xml/objects/object_god_lgt.xml +++ b/assets/xml/objects/object_god_lgt.xml @@ -1,16 +1,16 @@ - + - - - - - + + + + + - + diff --git a/assets/xml/objects/object_hata.xml b/assets/xml/objects/object_hata.xml index 7a8beff3a44..f44028dabc0 100644 --- a/assets/xml/objects/object_hata.xml +++ b/assets/xml/objects/object_hata.xml @@ -1,79 +1,66 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - + + - + + - + + - + + - + + - + + - + + - + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_horse.xml b/assets/xml/objects/object_horse.xml index e4b2a067e30..f190e3b49c8 100644 --- a/assets/xml/objects/object_horse.xml +++ b/assets/xml/objects/object_horse.xml @@ -50,10 +50,10 @@ - - - - + + + + diff --git a/assets/xml/objects/object_ik.xml b/assets/xml/objects/object_ik.xml index 55b4a6ff76b..f73477b0350 100644 --- a/assets/xml/objects/object_ik.xml +++ b/assets/xml/objects/object_ik.xml @@ -8,47 +8,47 @@ - - + + - - - - - - - - - - - - + + + + + + + + + + + + - + - + - - - - + + + + - - - - + + + + - + @@ -115,18 +115,18 @@ - - - + + + - - - + + + @@ -136,22 +136,22 @@ - + - + - + - + - - - + + + @@ -185,13 +185,13 @@ - + - + @@ -206,8 +206,8 @@ - - + + diff --git a/assets/xml/objects/object_light_ring.xml b/assets/xml/objects/object_light_ring.xml index b2183f32fc6..6c8b1411fc4 100644 --- a/assets/xml/objects/object_light_ring.xml +++ b/assets/xml/objects/object_light_ring.xml @@ -1,9 +1,9 @@ - + - - + + diff --git a/assets/xml/objects/object_mir_ray.xml b/assets/xml/objects/object_mir_ray.xml index 90d93a999c2..988cea9adee 100644 --- a/assets/xml/objects/object_mir_ray.xml +++ b/assets/xml/objects/object_mir_ray.xml @@ -1,21 +1,15 @@ - - - + - + + + + - - - - - - - - - + + diff --git a/assets/xml/objects/object_sk2.xml b/assets/xml/objects/object_sk2.xml index 9ee3768863c..d49d3cb5dab 100644 --- a/assets/xml/objects/object_sk2.xml +++ b/assets/xml/objects/object_sk2.xml @@ -1,34 +1,33 @@ - + - - + - + - + - + - + - + - + - + @@ -37,7 +36,7 @@ - + @@ -49,7 +48,7 @@ - + @@ -61,144 +60,68 @@ - + - + - - - - - - + + + + - - + + - - + + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_skb.xml b/assets/xml/objects/object_skb.xml index a7d5798c61b..400feedf99e 100644 --- a/assets/xml/objects/object_skb.xml +++ b/assets/xml/objects/object_skb.xml @@ -1,46 +1,38 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - + - + - + @@ -49,7 +41,7 @@ - + @@ -58,7 +50,7 @@ - + @@ -67,7 +59,7 @@ - + @@ -76,47 +68,44 @@ - - - + - - + + - + - + - + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_triforce_spot.xml b/assets/xml/objects/object_triforce_spot.xml index f645f2859f6..6008dade955 100644 --- a/assets/xml/objects/object_triforce_spot.xml +++ b/assets/xml/objects/object_triforce_spot.xml @@ -1,16 +1,15 @@ - + - + - - - - - - + + + + + diff --git a/assets/xml/overlays/ovl_En_Ganon_Organ.xml b/assets/xml/overlays/ovl_En_Ganon_Organ.xml index 6668b85fd00..438e046c934 100644 --- a/assets/xml/overlays/ovl_En_Ganon_Organ.xml +++ b/assets/xml/overlays/ovl_En_Ganon_Organ.xml @@ -1,25 +1,12 @@ - - - - - - - - - - - - - - + - - + + - + diff --git a/assets/xml/textures/nes_font_static.xml b/assets/xml/textures/nes_font_static.xml index 9561fb1036f..850e63590a3 100644 --- a/assets/xml/textures/nes_font_static.xml +++ b/assets/xml/textures/nes_font_static.xml @@ -1,144 +1,143 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/textures/nes_font_static_v2.xml b/assets/xml/textures/nes_font_static_v2.xml index 9e037d45bc2..6c8384e277e 100644 --- a/assets/xml/textures/nes_font_static_v2.xml +++ b/assets/xml/textures/nes_font_static_v2.xml @@ -1,145 +1,144 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/baseroms/ntsc-1.0/config.yml b/baseroms/ntsc-1.0/config.yml index e164590c399..f55ef8b46d4 100644 --- a/baseroms/ntsc-1.0/config.yml +++ b/baseroms/ntsc-1.0/config.yml @@ -67,8 +67,8 @@ assets: xml_path: assets/xml/code/fbdemo_wipe1.xml start_offset: 0xEB600 end_offset: 0xEC088 -- name: n64dd/error_textures - xml_path: assets/xml/n64dd/error_textures.xml +- name: misc/n64dd_error_textures + xml_path: assets/xml/misc/n64dd_error_textures.xml start_offset: 0xC160 end_offset: 0x11D60 - name: misc/link_animetion diff --git a/baseroms/ntsc-1.1/config.yml b/baseroms/ntsc-1.1/config.yml index ee27b55df99..e18ac07d3ed 100644 --- a/baseroms/ntsc-1.1/config.yml +++ b/baseroms/ntsc-1.1/config.yml @@ -67,8 +67,8 @@ assets: xml_path: assets/xml/code/fbdemo_wipe1.xml start_offset: 0xEB7C0 end_offset: 0xEC248 -- name: n64dd/error_textures - xml_path: assets/xml/n64dd/error_textures.xml +- name: misc/n64dd_error_textures + xml_path: assets/xml/misc/n64dd_error_textures.xml start_offset: 0xC140 end_offset: 0x11D40 - name: misc/link_animetion diff --git a/baseroms/ntsc-1.2/config.yml b/baseroms/ntsc-1.2/config.yml index b0c8b18bee1..7db790b9f93 100644 --- a/baseroms/ntsc-1.2/config.yml +++ b/baseroms/ntsc-1.2/config.yml @@ -67,8 +67,8 @@ assets: xml_path: assets/xml/code/fbdemo_wipe1.xml start_offset: 0xEB610 end_offset: 0xEC098 -- name: n64dd/error_textures - xml_path: assets/xml/n64dd/error_textures.xml +- name: misc/n64dd_error_textures + xml_path: assets/xml/misc/n64dd_error_textures.xml start_offset: 0xC120 end_offset: 0x11D20 - name: misc/link_animetion diff --git a/baseroms/pal-1.0/config.yml b/baseroms/pal-1.0/config.yml index 2602ed0e7c2..c7522d5c742 100644 --- a/baseroms/pal-1.0/config.yml +++ b/baseroms/pal-1.0/config.yml @@ -73,8 +73,8 @@ assets: xml_path: assets/xml/code/fbdemo_wipe1.xml start_offset: 0xE8F20 end_offset: 0xE99A8 -- name: n64dd/error_textures - xml_path: assets/xml/n64dd/error_textures.xml +- name: misc/n64dd_error_textures + xml_path: assets/xml/misc/n64dd_error_textures.xml start_offset: 0xC0E0 end_offset: 0x11CE0 - name: misc/link_animetion diff --git a/baseroms/pal-1.1/config.yml b/baseroms/pal-1.1/config.yml index 4001c620514..9c368020da5 100644 --- a/baseroms/pal-1.1/config.yml +++ b/baseroms/pal-1.1/config.yml @@ -73,8 +73,8 @@ assets: xml_path: assets/xml/code/fbdemo_wipe1.xml start_offset: 0xE8F60 end_offset: 0xE99E8 -- name: n64dd/error_textures - xml_path: assets/xml/n64dd/error_textures.xml +- name: misc/n64dd_error_textures + xml_path: assets/xml/misc/n64dd_error_textures.xml start_offset: 0xC0E0 end_offset: 0x11CE0 - name: misc/link_animetion diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 8f0a30b137f..00000000000 --- a/docker-compose.yml +++ /dev/null @@ -1,9 +0,0 @@ -services: - oot: - build: - context: . - dockerfile: Dockerfile - volumes: - - ./:/oot - tty: true - stdin_open: true diff --git a/docs/BUILDING_MACOS.md b/docs/BUILDING_BINUTILS_MACOS.md similarity index 60% rename from docs/BUILDING_MACOS.md rename to docs/BUILDING_BINUTILS_MACOS.md index 23e5d136a39..b72db420a67 100644 --- a/docs/BUILDING_MACOS.md +++ b/docs/BUILDING_BINUTILS_MACOS.md @@ -1,30 +1,6 @@ -# Building on macOS +# Building mips-linux-binutils on MacOS -## 1. Dependencies - -For macOS, use Homebrew to install the following dependencies: - -* coreutils -* make -* python3 -* bash -* clang-format -* libxml2 -* libiconv - -You can install them with the following commands: - -```bash -brew update -brew install coreutils make python3 bash clang-format libxml2 libiconv -``` - -(The repository expects Homebrew-installed programs to be either linked correctly in `$PATH` etc. or in their default locations.) - - -## 2. 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. +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 @@ -43,7 +19,7 @@ curl -O https://ftp.gnu.org/gnu/binutils/binutils-2.46.0.tar.xz tar xjf binutils-2.46.0.tar.xz ``` -Create and enter a build directory +Create and enter build dir ```bash mkdir build-binutils cd build-binutils @@ -60,27 +36,17 @@ make -j$(nproc) sudo make install ``` -Edit your `~/.bash_profile`/`~/.zprofile` (or whichever shell you use) to add the new binutils binaries to the system PATH +Edit your ~/.bash_profile 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) +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`. - - -## 3. Final note - -Apple's version of `make` is very out-of-date, so you should use the brew-installed `gmake` in place of `make` in this repo from now on. - -You should now be able to continue from [step 2](../README.md#2-clone-the-repository) of the Linux instructions. - - -## 4. Building GCC (optional) +## Building GCC (optional) If you'd like to compile with GCC instead of IDO (e.g. for modding), you can build it from source similarly to how we built binutils: diff --git a/docs/BUILDING_DOCKER.md b/docs/BUILDING_DOCKER.md deleted file mode 100644 index 60f54c1686a..00000000000 --- a/docs/BUILDING_DOCKER.md +++ /dev/null @@ -1,27 +0,0 @@ -# Building using Docker - -## 1. Setup requirements - -To use Docker, you'll need either Docker Desktop or Docker Toolbox installed and setup based on your system. - -On Ubuntu, Docker and required tools can be installed with: `sudo apt install docker.io docker-compose docker-buildx` - -You'll also need to prepare a local version of the project with a copied base ROM (see steps [2](../README.md#2-clone-the-repository) and [3](../README.md#3-prepare-a-base-rom) of the Linux instructions). - -## 2. Create and start the Docker image build - -From the root of your local project, run the following command: - -```bash -docker-compose up --build -``` - -This should immediately begin steps [4](../README.md#4-setup-the-rom-and-build-process) and [5](../README.md#5-build-the-rom) within the Docker container. - -## 3. Shell into the 'oot' container - -To exec into the oot Docker image at any time, run the following command either during or after the build: - -```bash -docker-compose exec oot bash -``` diff --git a/docs/building/docker.md b/docs/building/docker.md new file mode 100644 index 00000000000..1bac008fbcf --- /dev/null +++ b/docs/building/docker.md @@ -0,0 +1,29 @@ +# Building with Docker + +## 1. Setup requirements + +To use Docker, you'll need either Docker Desktop or Docker Toolbox installed and setup based on your system. + +On Ubuntu, Docker and required tools can be installed with: `sudo apt install docker.io docker-compose docker-buildx` + +You'll also need to prepare a local version of the project with a copied base ROM (see steps [2](/README.md#2-clone-the-repository) and [3](/README.md#3-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 oot +``` + +## 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=/oot oot /bin/bash +``` + +## 4. Setup and Build the ROM + +Once inside the container, you can follow steps [4](/README.md#4-setup-the-rom-and-build-process) and [5](/README.md#5-build-the-rom) of the Linux instructions to setup and build the ROM, or run any other command you need. diff --git a/docs/vscode.md b/docs/vscode.md deleted file mode 100644 index 4262d0beaef..00000000000 --- a/docs/vscode.md +++ /dev/null @@ -1,94 +0,0 @@ -# VSCode - -A lot of people on this project use VSCode as their coding environment. - -## Extensions - -There are a number of useful extensions available to make work more efficient: - -- C/C++ IntelliSense -- Clang-Format -- HexInspector (hover on numbers for float and other info) -- NumberMonger (convert hex to decimal and vice versa) -- Better MIPS Support - - - - -## Useful keyboard shortcuts - -- 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. -- Shift + Alt + Up/Down (Linux: Ctrl + Shift + Alt + Up/Down) copies lines up/down. -- Ctrl + P offers a box to use to search for and open files. -- Ctrl + Shift + P offers a box for commands like editing settings or reloading the window. - -- Make use of VSCode's search/search-and-replace features. - - Ctrl + Click goes to a definition. - - Ctrl + F for search in current file - - Ctrl + H for replace in current file - - Ctrl + Shift + F for search in all files - - Ctrl + Shift + H for replace in all files - - F2 for Rename symbol - -Many of VS Code's other shortcuts can be found on [its getting started page](https://code.visualstudio.com/docs/getstarted/keybindings), which also has links to OS-specific PDFs. - -## C/C++ configuration - -You can create a `.vscode/c_cpp_properties.json` file with `C/C++: Edit Configurations (JSON)` in the command box to customise how IntelliSense reads the repository (stuff like where to look for includes, flags, compiler defines, etc.) to make VSCode's IntelliSense plugin better able to understand the structure of the repository. - -Below is a good default one to use for this project's repository, for the oot-gc-eu-mq-dbg version specifically. - -A more complete `c_cpp_properties.json` with configurations for all supported versions [can be found here](c_cpp_properties.json). - -```jsonc -{ - "configurations": [ - { - "name": "oot-gc-eu-mq-dbg", - "compilerArgs": [ - "-m32" // Removes integer truncation warnings with gbi macros - ], - "includePath": [ // Matches makefile's includes - "include", - "include/libc", - "src", - "build/gc-eu-mq-dbg", - ".", - "extracted/gc-eu-mq-dbg" - ], - "defines": [ - "_LANGUAGE_C", // For gbi.h - // Version-specific - "OOT_VERSION=GC_EU_MQ_DBG", - "OOT_REGION=REGION_EU", - "PLATFORM_N64=0", - "PLATFORM_GC=1", - "DEBUG_FEATURES=1", - "F3DEX_GBI_2", - "F3DEX_GBI_PL", - "GBI_DOWHILE", - "GBI_DEBUG" - ], - "cStandard": "gnu89", // C89 + some GNU extensions from C99 like C++ comments - } - ], - "version": 4 -} -``` - -## Settings - -Add the following to (or create) the `.vscode/settings.json` file for VSCode to search the gitignored asset files by default: - -```jsonc -{ - "search.useIgnoreFiles": false, - "search.exclude": { - "**/.git": true, - "baseroms/**": true, - "build/**": true, - "expected/**": true, - }, -} -``` diff --git a/include/actor.h b/include/actor.h index 103a3a21884..4068443065f 100644 --- a/include/actor.h +++ b/include/actor.h @@ -800,15 +800,15 @@ void Gfx_DrawDListXlu(struct PlayState* play, Gfx* dlist); Actor* Actor_FindNearby(struct PlayState* play, Actor* refActor, s16 actorId, u8 actorCategory, f32 range); s32 func_800354B4(struct PlayState* play, Actor* actor, f32 range, s16 arg3, s16 arg4, s16 arg5); -void func_8003555C(struct PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel); -void func_800355B8(struct PlayState* play, Vec3f* pos); +void func_8003555C(struct PlayState* play, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3); +void func_800355B8(struct PlayState* play, Vec3f* arg1); u8 func_800355E4(struct PlayState* play, Collider* collider); u8 Actor_ApplyDamage(Actor* actor); void Actor_SetDropFlag(Actor* actor, ColliderElement* elem, s32 freezeFlag); void Actor_SetDropFlagJntSph(Actor* actor, ColliderJntSph* jntSph, s32 freezeFlag); void func_80035844(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, s32 arg3); -Actor* func_800358DC(Actor* actor, Vec3f* spawnPos, Vec3s* spawnRot, f32* arg3, s32 timer, s16* arg5, - struct PlayState* play, s16 params, Gfx* dList); +struct EnPart* func_800358DC(Actor* actor, Vec3f* spawnPos, Vec3s* spawnRot, f32* arg3, s32 timer, s16* arg5, + struct PlayState* play, s16 params, Gfx* dList); void func_800359B8(Actor* actor, s16 arg1, Vec3s* arg2); s32 Flags_GetEventChkInf(s32 flag); void Flags_SetEventChkInf(s32 flag); diff --git a/include/animation_curve.h b/include/animation_curve.h new file mode 100644 index 00000000000..1c2217899c5 --- /dev/null +++ b/include/animation_curve.h @@ -0,0 +1,69 @@ +#ifndef ANIMATION_CURVE_H +#define ANIMATION_CURVE_H + +#include "ultra64.h" +#include "z_math.h" + +struct Actor; +struct PlayState; + +// fcurve_skelanime structs +typedef struct TransformData { + /* 0x0000 */ u16 unk_00; // appears to be flags + /* 0x0002 */ s16 unk_02; + /* 0x0004 */ s16 unk_04; + /* 0x0006 */ s16 unk_06; + /* 0x0008 */ f32 unk_08; +} TransformData; // size = 0xC + +typedef struct TransformUpdateIndex { + /* 0x0000 */ u8* refIndex; + /* 0x0004 */ TransformData* transformData; + /* 0x0008 */ s16* copyValues; + /* 0x000C */ s16 unk_0C; + /* 0x000E */ s16 unk_0E; +} TransformUpdateIndex; // size = 0x10 + +typedef struct SkelCurveLimb { + /* 0x0000 */ u8 firstChildIdx; + /* 0x0001 */ u8 nextLimbIdx; + /* 0x0004 */ Gfx* dList[2]; +} SkelCurveLimb; // size = 0xC + +typedef struct SkelCurveLimbList { + /* 0x0000 */ SkelCurveLimb** limbs; + /* 0x0004 */ u8 limbCount; +} SkelCurveLimbList; // size = 0x8 + +typedef struct LimbTransform { + /* 0x0000 */ Vec3s scale; + /* 0x0006 */ Vec3s rot; + /* 0x000C */ Vec3s pos; +} LimbTransform; // size = 0x12 + +typedef struct SkelAnimeCurve { + /* 0x0000 */ u8 limbCount; + /* 0x0004 */ SkelCurveLimb** limbList; + /* 0x0008 */ TransformUpdateIndex* transUpdIdx; + /* 0x000C */ f32 unk_0C; // seems to be unused + /* 0x0010 */ f32 animFinalFrame; + /* 0x0014 */ f32 animSpeed; + /* 0x0018 */ f32 animCurFrame; + /* 0x001C */ LimbTransform* transforms; +} SkelAnimeCurve; // size = 0x20 + +typedef s32 (*OverrideCurveLimbDraw)(struct PlayState* play, SkelAnimeCurve* skelCurve, s32 limbIndex, void*); +typedef void (*PostCurveLimbDraw)(struct PlayState* play, SkelAnimeCurve* skelCurve, s32 limbIndex, void*); + +f32 func_8006C5A8(f32 target, TransformData* transData, s32 refIdx); +void SkelCurve_Clear(SkelAnimeCurve* skelCurve); +s32 SkelCurve_Init(struct PlayState* play, SkelAnimeCurve* skelCurve, SkelCurveLimbList* limbListSeg, + TransformUpdateIndex* transUpdIdx); +void SkelCurve_Destroy(struct PlayState* play, SkelAnimeCurve* skelCurve); +void SkelCurve_SetAnim(SkelAnimeCurve* skelCurve, TransformUpdateIndex* transUpdIdx, f32 arg2, f32 animFinalFrame, + f32 animCurFrame, f32 animSpeed); +s32 SkelCurve_Update(struct PlayState* play, SkelAnimeCurve* skelCurve); +void SkelCurve_Draw(struct Actor* actor, struct PlayState* play, SkelAnimeCurve* skelCurve, + OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, void* data); + +#endif diff --git a/include/audio.h b/include/audio.h index 412a5ecdd63..4daa86a1b60 100644 --- a/include/audio.h +++ b/include/audio.h @@ -1168,7 +1168,7 @@ void func_800F436C(Vec3f* pos, u16 sfxId, f32 arg2); void func_800F4414(Vec3f* pos, u16 sfxId, f32); void func_800F44EC(s8 arg0, s8 arg1); void func_800F4524(Vec3f* pos, u16 sfxId, s8 arg2); -void Audio_PlaySwordChargeSfx(Vec3f* pos, u8 level); +void Audio_PlaySwordChargeSfx(Vec3f*, u8); void Audio_PlaySfxRiver(Vec3f* pos, f32 freqScale); void Audio_PlaySfxWaterfall(Vec3f* pos, f32 freqScale); void Audio_SetBgmVolumeOffDuringFanfare(void); diff --git a/include/bgcheck.h b/include/bgcheck.h index aa85efc57ff..c208262feb6 100644 --- a/include/bgcheck.h +++ b/include/bgcheck.h @@ -472,9 +472,8 @@ s32 func_800427B4(CollisionPoly* polyA, CollisionPoly* polyB, Vec3f* pointA, Vec void BgCheck_DrawDynaCollision(struct PlayState*, CollisionContext*); void BgCheck_DrawStaticCollision(struct PlayState*, CollisionContext*); #endif - void func_80043334(CollisionContext* colCtx, struct Actor* actor, s32 bgId); -s32 DynaPolyActor_TransformCarriedActor(CollisionContext* colCtx, s32 bgId, struct Actor* carriedActor); +s32 DynaPolyActor_TransformActorOnTop(CollisionContext* colCtx, s32 bgId, struct Actor* actor); void DynaPolyActor_Init(struct DynaPolyActor* dynaActor, s32 transformFlags); void DynaPolyActor_UnsetAllInteractFlags(struct DynaPolyActor* dynaActor); void DynaPolyActor_SetActorOnTop(struct DynaPolyActor* dynaActor); diff --git a/include/curve.h b/include/curve.h deleted file mode 100644 index 8779b04b47a..00000000000 --- a/include/curve.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef CURVE_H -#define CURVE_H - -#include "ultra64.h" - -struct PlayState; -struct Actor; - -typedef struct CurveInterpKnot { - /* 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 CurveAnimationHeader { - /* 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 SkelCurveLimb { - /* 0x0 */ u8 child; - /* 0x1 */ u8 sibling; - /* 0x4 */ Gfx* dList[2]; -} SkelCurveLimb; // size = 0xC - -typedef struct CurveSkeletonHeader { - /* 0x0 */ SkelCurveLimb** limbs; - /* 0x4 */ u8 limbCount; -} CurveSkeletonHeader; // size = 0x8 - -typedef struct SkelCurve { - /* 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, void* thisx); -typedef void (*PostCurveLimbDraw)(struct PlayState* play, SkelCurve* skelCuve, s32 limbIndex, void* thisx); - -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(struct Actor* actor, struct PlayState* play, SkelCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw, - PostCurveLimbDraw postLimbDraw, s32 lod, void* data); - -#endif diff --git a/include/effect.h b/include/effect.h index 97412e2f33c..2cd1ec26126 100644 --- a/include/effect.h +++ b/include/effect.h @@ -101,10 +101,10 @@ typedef struct EffectBlure { /* 0x188 */ u16 flags; /* 0x18A */ s16 addAngleChange; /* 0x18C */ s16 addAngle; - /* 0x18E */ u8 p1StartColor[4]; - /* 0x192 */ u8 p2StartColor[4]; - /* 0x196 */ u8 p1EndColor[4]; - /* 0x19A */ u8 p2EndColor[4]; + /* 0x18E */ Color_RGBA8 p1StartColor; + /* 0x192 */ Color_RGBA8 p2StartColor; + /* 0x196 */ Color_RGBA8 p1EndColor; + /* 0x19A */ Color_RGBA8 p2EndColor; /* 0x19E */ u8 numElements; // "now_edge_num" /* 0x19F */ u8 elemDuration; /* 0x1A0 */ u8 unkFlag; diff --git a/include/gfx.h b/include/gfx.h index 01a33f974b6..35643d105ec 100644 --- a/include/gfx.h +++ b/include/gfx.h @@ -65,7 +65,7 @@ Gfx* Gfx_SetFog(Gfx* gfx, s32 r, s32 g, s32 b, s32 a, s32 near, s32 far); Gfx* Gfx_SetFogWithSync(Gfx* gfx, s32 r, s32 g, s32 b, s32 a, s32 near, s32 far); Gfx* Gfx_SetFog2(Gfx* gfx, s32 r, s32 g, s32 b, s32 a, s32 near, s32 far); -Gfx* Gfx_BranchTexScroll(Gfx** gfxP, u32 x, u32 y, s32 width, s32 height); +Gfx* Gfx_BranchTexScroll(Gfx** gfxp, u32 x, u32 y, s32 width, s32 height); Gfx* func_80094E78(GraphicsContext* gfxCtx, u32 x, u32 y); Gfx* Gfx_TexScroll(GraphicsContext* gfxCtx, u32 x, u32 y, s32 width, s32 height); Gfx* Gfx_TwoTexScroll(GraphicsContext* gfxCtx, s32 tile1, u32 x1, u32 y1, s32 width1, s32 height1, s32 tile2, u32 x2, diff --git a/include/gfx_setupdl.h b/include/gfx_setupdl.h index 1ba9ba06f51..73ca7425c56 100644 --- a/include/gfx_setupdl.h +++ b/include/gfx_setupdl.h @@ -96,15 +96,15 @@ Gfx* Gfx_SetupDL_64(Gfx* gfx); Gfx* Gfx_SetupDL_34(Gfx* gfx); void Gfx_SetupDL_44Xlu(struct GraphicsContext* gfxCtx); void Gfx_SetupDL_36Opa(struct GraphicsContext* gfxCtx); -void Gfx_SetupDL_28Opa(struct GraphicsContext* gfxCtx); Gfx* Gfx_SetupDL_28(Gfx* gfx); +void Gfx_SetupDL_28Opa(struct GraphicsContext* gfxCtx); void Gfx_SetupDL_38Xlu(struct GraphicsContext* gfxCtx); void Gfx_SetupDL_4Xlu(struct GraphicsContext* gfxCtx); void Gfx_SetupDL_37Opa(struct GraphicsContext* gfxCtx); Gfx* Gfx_SetupDL_39(Gfx* gfx); void Gfx_SetupDL_39Opa(struct GraphicsContext* gfxCtx); void Gfx_SetupDL_39Overlay(struct GraphicsContext* gfxCtx); -void Gfx_SetupDL_39Ptr(Gfx** gfxP); +void Gfx_SetupDL_39Ptr(Gfx** gfxp); void Gfx_SetupDL_40Opa(struct GraphicsContext* gfxCtx); void Gfx_SetupDL_41Opa(struct GraphicsContext* gfxCtx); void Gfx_SetupDL_47Xlu(struct GraphicsContext* gfxCtx); @@ -117,6 +117,6 @@ void Gfx_SetupDL_27Xlu(struct GraphicsContext* gfxCtx); void Gfx_SetupDL_60NoCDXlu(struct GraphicsContext* gfxCtx); void Gfx_SetupDL_61Xlu(struct GraphicsContext* gfxCtx); void Gfx_SetupDL_56Opa(struct GraphicsContext* gfxCtx); -void Gfx_SetupDL_56Ptr(Gfx** gfxP); +void Gfx_SetupDL_56Ptr(Gfx** gfxp); #endif diff --git a/include/gfxalloc.h b/include/gfxalloc.h index 158a2a9f589..06e8a80be18 100644 --- a/include/gfxalloc.h +++ b/include/gfxalloc.h @@ -5,6 +5,6 @@ Gfx* Gfx_Open(Gfx* gfx); Gfx* Gfx_Close(Gfx* gfx, Gfx* dst); -void* Gfx_Alloc(Gfx** gfxP, u32 size); +void* Gfx_Alloc(Gfx** gfx, u32 size); #endif diff --git a/include/libc/string.h b/include/libc/string.h index 3e2e6be592a..fa4ababe87f 100644 --- a/include/libc/string.h +++ b/include/libc/string.h @@ -7,7 +7,10 @@ char* strchr(const char*, int); size_t strlen(const char*); void* memcpy(void*, const void*, size_t); -void* memmove(void* dest, const void* src, size_t len); -void* memset(void* dest, int val, size_t len); +#ifdef BBPLAYER +#define func_80106860 memset +#endif +void* func_80106860(void* ptr, int val, size_t size); +void* func_801068B0(void* dst, void* src, size_t size); #endif diff --git a/include/n64dd.h b/include/n64dd.h index f0028750ced..8b699694d1e 100644 --- a/include/n64dd.h +++ b/include/n64dd.h @@ -2,7 +2,6 @@ #define N64DD_H #include "ultra64.h" -#include "ultra64/leo.h" #include "pause.h" #include "scene.h" #include "map_mark.h" @@ -68,35 +67,6 @@ typedef struct n64ddStruct_80121220 { s32 (*unk_78)(struct PlayState*, void*, void*); } n64ddStruct_80121220; // size = ? -typedef struct struct_801E0D18 { - /* 0x00 */ LEOCmd unk_00; - /* 0x1C */ OSMesgQueue unk_1C; - /* 0x38 */ LEODiskID diskId; - /* 0x58 */ s32 unk_58; - /* 0x5C */ s32 unk_5C; - /* 0x60 */ u32 unk_60; - /* 0x64 */ u8 unk_64; - /* 0x65 */ u8 unk_65; - /* 0x66 */ u8 unk_66; - /* 0x68 */ s32 unk_68; - /* 0x6C */ s32 unk_6C; -} struct_801E0D18; // size = 0x70 - -typedef struct struct_801D9D50 { - /* 0x00 */ u8 unk_00; // command enum - /* 0x04 */ s32 unk_04; - /* 0x08 */ u8 unk_08; - /* 0x0C */ void (*unk_0C)(void*, void*, void*); - /* 0x10 */ s32 unk_10; - /* 0x14 */ void (*unk_14)(void*, uintptr_t, size_t); - /* 0x18 */ void* unk_18; - /* 0x1C */ void* unk_1C; // either OSMesgQueue* (command 0) or integer LBA (commands 2 and 3) - /* 0x20 */ void* unk_20; // either OSMesgQueue* (command 0) or integer byte size (commands 3 and 4) - /* 0x24 */ OSId unk_24; - /* 0x28 */ void* unk_28; - /* 0x2C */ OSPri unk_2C; -} struct_801D9D50; // size = 0x30 - void func_800AD410(void); void func_800AD488(void); n64ddStruct_80121220* func_800AD4C0(n64ddStruct_80121220* arg0); @@ -115,35 +85,6 @@ void func_801C7C1C(void* dest, s32 offset, s32 size); void func_801C7E78(void); void n64dd_SetDiskVersion(s32 arg0); -s32 func_801C8000(struct_801D9D50* arg0); -s32 func_801C81C4(void); -void func_801C81EC(struct_801E0D18* arg0); -void func_801C8298(struct_801E0D18* arg0); -void func_801C82E0(struct_801E0D18* arg0); -void func_801C832C(struct_801E0D18* arg0); -void func_801C83A0(struct_801E0D18* arg0); -void func_801C8414(struct_801E0D18* arg0); -s32 func_801C873C(struct_801E0D18* arg0); - -void func_801C8AA8(void); -s32 func_801C91E0(struct_801E0D18*); -s32 func_801C9260(struct_801E0D18*); -s32 func_801C9334(struct_801E0D18*); -s32 func_801C93C4(struct_801E0D18*); - -void func_801C94F8(u8* arg0, u16 arg1); -void func_801C9A10(u8* arg0, s32 arg1, u8* str); -void func_801C9B50(s32 arg0, void (*arg1)(void*, uintptr_t, size_t)); - -u8* func_801C9E28(s32 errorNum); -u8* func_801C9EC0(void); -u8* func_801C9F90(s32 errorNum); -u8* func_801C9FFC(void); -u8* func_801CA030(s32 errorNum); -u8* func_801CA070(void); - -void func_801CA1F0(void* charTexBuf, s32 posX, s32 posY, s32 dx, s32 dy, s32 cy, void* frameBuf, s32 screenWidth); - extern n64ddStruct_800FEE70_pointers D_800FEE70; extern n64ddStruct_80121220* B_80121220; @@ -153,25 +94,4 @@ extern u8 D_80121212; extern vu8 D_80121213; extern vu8 D_80121214; -extern s32 (*D_801D2E54)(struct_801E0D18*); - -extern u8 gN64DDDiskReadTemporaryBuffer[]; - -extern s32 D_801D2E90; -extern OSMesgQueue* B_801E0D10[2]; - -extern s32 D_801D2EA0; -extern s32 D_801D2EA8; -extern s32 B_801E0F60; -extern s32 B_801E0F64; -extern void (*D_801D2EB4)(void*, void*, void*); - -// Error messages -extern const char* gN64DDLocalizedErrorNumberHeaders[]; // "Error Number " array -extern const char* D_801D2EE0[2][8][4]; // Array of error message strings - -// Error textures -extern u64 gN64DDError41Texs[2][0x600 / sizeof(u64)]; -extern u64 gN64DDPleaseReadManualTexs[2][0x2800 / sizeof(u64)]; - #endif diff --git a/include/n64dd_internal.h b/include/n64dd_internal.h new file mode 100644 index 00000000000..015c46085b8 --- /dev/null +++ b/include/n64dd_internal.h @@ -0,0 +1,104 @@ +#ifndef N64DD_INTERNAL_H +#define N64DD_INTERNAL_H + +#define BADCASTP (void*) +#define BADCASTI (u32) + +#include "ultra64.h" +#include "n64dd.h" +#include "stack.h" +#include "irqmgr.h" + +extern IrqMgr gIrqMgr; // from main.c + +typedef struct struct_801DA5D0 { + /* 0x00 */ u8 unk0; + /* 0x01 */ char pad1[3]; + /* 0x04 */ s32 unk4; + /* 0x08 */ s8 unk8; + /* 0x09 */ char pad9[3]; + /* 0x0C */ void (*unkC)(s32, s32, s32); + /* 0x10 */ s32 unk10; + /* 0x14 */ void (*unk14)(void*, uintptr_t, size_t); + /* 0x18 */ void* unk18; + union { // different substruct based on struct_801DA5D0.unk0 ? see func_801C8860 + struct { + /* 0x1C */ OSMesgQueue* unk1C; + /* 0x20 */ OSMesgQueue* unk20; + /* 0x24 */ s32 unk24; + /* 0x28 */ void* unk28; + /* 0x2C */ s32 unk2C; + } unk1C_1; + struct { + /* 0x1C */ s32 unk1C; + /* 0x20 */ s32 unk20; + } unk1C_3_4; + }; +} struct_801DA5D0; // size >= 0x30 + +typedef struct struct_801E1598 { + /* 0x00 */ LEOCmd unk0; + /* 0x1C */ OSMesgQueue unk1C; + /* 0x34 */ char pad34[4]; + /* 0x38 */ LEODiskID unk38; + /* 0x58 */ void* unk58; + /* 0x5C */ s32 unk5C; + /* 0x60 */ s32 unk60; + /* 0x64 */ s8 unk64; + /* 0x65 */ s8 unk65; + /* 0x66 */ u8 unk66; + /* 0x67 */ char pad67[1]; + /* 0x68 */ s32 unk68; // OSMesg + /* 0x6C */ s32 unk6C; +} struct_801E1598; // size >= 0x70 + +s32 func_801C8860(struct_801DA5D0*); +s32 func_801C8A24(void); +void func_801CAA60(u8*, UNK_TYPE, UNK_TYPE, UNK_TYPE, s32, s32, s16*, s32); +void func_801C9318(void); +void func_801CA3C0(s32, void (*)(void*, uintptr_t, size_t)); +s32 func_801C8F9C(struct_801E1598*); + +typedef struct struct_801DA5C8 { + /* 0x000 */ s32 unk0; + /* 0x004 */ s32 unk4; + /* 0x008 */ void* unk8; + /* 0x00C */ void* unkC; + /* 0x010 */ n64ddStruct_80121220* unk10; + /* 0x014 */ char pad14[0x104]; +} struct_801DA5C8; // size = 0x118 +extern s32 D_801D3728; +extern s32 D_801E17E0; +extern s32 D_801E17E4; +typedef struct struct_801C79DC { + /* 0x00 */ OSMesg unk0[30]; + /* 0x78 */ OSMesgQueue unk78; + /* 0x90 */ IrqMgrClient unk90; + /* 0x98 */ IrqMgr* unk98; +} struct_801C79DC; // size >= 0x9C +extern s32 D_801D3720; +typedef struct struct_801E1590 { + /* 0x0 */ OSMesgQueue* unk0; + /* 0x4 */ OSMesgQueue* unk4; +} struct_801E1590; // size >= 8 +extern void (*D_801D3734)(UNK_PTR, UNK_PTR, UNK_PTR); +extern s32 D_801D3710; +void func_801C8B40(struct_801E1598*); +void func_801C8AF8(struct_801E1598*); +UNK_PTR func_801CA800(s32); +UNK_PTR func_801CA698(s32); +UNK_PTR func_801CA86C(void); +UNK_PTR func_801CA8A0(s32); +UNK_PTR func_801CA8E0(void); +UNK_PTR func_801CA730(void); +extern s32 (*D_801D36D4)(struct_801E1598*); +s32 func_801C9BA4(struct_801E1598*); +void func_801CA280(UNK_PTR, UNK_TYPE, const char*); +extern const char* gN64DDLocalizedErrorNumberHeaders[2]; +void func_801C9D68(char*, u16); + +extern u8 gN64DDDiskReadTemporaryBuffer[]; + +extern struct_801E1590 D_801E1590; + +#endif diff --git a/include/player.h b/include/player.h index 63c9d25b658..94d87c0185c 100644 --- a/include/player.h +++ b/include/player.h @@ -706,7 +706,7 @@ typedef struct WeaponInfo { #define LEDGE_DIST_MAX 399.96002f #define PLAYER_STATE1_0 (1 << 0) -#define PLAYER_STATE1_SWINGING_BOTTLE (1 << 1) // Bottle is swung; Bottle is active and can catch things +#define PLAYER_STATE1_1 (1 << 1) // Bottle is swung; Bottle is active and can catch things #define PLAYER_STATE1_2 (1 << 2) #define PLAYER_STATE1_3 (1 << 3) #define PLAYER_STATE1_HOSTILE_LOCK_ON (1 << 4) // Currently locked onto a hostile actor. Triggers a "battle" variant of many actions. @@ -916,7 +916,7 @@ typedef struct Player { s8 startedAnim; // Player_Action_TimeTravelEnd: Started playing the animation that was previously frozen s8 facingUpSlope; // Player_Action_SlideOnSlope: Facing uphill when sliding on a slope s8 isLakeHyliaCs; // Player_Action_BlueWarpArrive: In Lake Hylia CS after Water Temple. Floating down is delayed until a specific point in the cutscene. - s8 bottleCatchType; // Player_Action_SwingBottle: entry type for `sBottleCatchInfo`, corresponds to actor caught in a bottle + s8 bottleCatchType; // Player_Action_SwingBottle: entry type for `D_80854A04`, corresponds to actor caught in a bottle } av1; // "Action Variable 1": context dependent variable that has different meanings depending on what action is currently running /* 0x0850 */ union { @@ -954,7 +954,7 @@ typedef struct Player { /* 0x0890 */ u8 unk_890; /* 0x0891 */ u8 bodyShockTimer; /* 0x0892 */ u8 unk_892; - /* 0x0893 */ u8 hoverBootsTimer; + /* 0x0893 */ u8 unk_893; /* 0x0894 */ s16 fallStartHeight; // last truncated Y position before falling /* 0x0896 */ s16 fallDistance; // truncated Y distance the player has fallen so far (positive is down) /* 0x0898 */ s16 floorPitch; // angle of the floor slope in the direction of current world yaw (positive for ascending slope) diff --git a/include/prerender.h b/include/prerender.h index 0674fac020a..9aedbb81fce 100644 --- a/include/prerender.h +++ b/include/prerender.h @@ -30,15 +30,15 @@ void PreRender_SetValuesSave(PreRender* this, u32 width, u32 height, void* fbuf, void PreRender_Init(PreRender* this); void PreRender_SetValues(PreRender* this, u32 width, u32 height, void* fbuf, void* zbuf); void PreRender_Destroy(PreRender* this); -void func_800C170C(PreRender* this, Gfx** gfxP, void* buf, void* bufSave, u32 r, u32 g, u32 b, u32 a); -void func_800C1AE8(PreRender* this, Gfx** gfxP, void* fbuf, void* fbufSave); -void PreRender_SaveZBuffer(PreRender* this, Gfx** gfxP); -void PreRender_SaveFramebuffer(PreRender* this, Gfx** gfxP); -void PreRender_DrawCoverage(PreRender* this, Gfx** gfxP); -void PreRender_RestoreZBuffer(PreRender* this, Gfx** gfxP); -void func_800C213C(PreRender* this, Gfx** gfxP); -void PreRender_RestoreFramebuffer(PreRender* this, Gfx** gfxP); -void PreRender_CopyImageRegion(PreRender* this, Gfx** gfxP); +void func_800C170C(PreRender* this, Gfx** gfxp, void* buf, void* bufSave, u32 r, u32 g, u32 b, u32 a); +void func_800C1AE8(PreRender* this, Gfx** gfxp, void* fbuf, void* fbufSave); +void PreRender_SaveZBuffer(PreRender* this, Gfx** gfxp); +void PreRender_SaveFramebuffer(PreRender* this, Gfx** gfxp); +void PreRender_DrawCoverage(PreRender* this, Gfx** gfxp); +void PreRender_RestoreZBuffer(PreRender* this, Gfx** gfxp); +void func_800C213C(PreRender* this, Gfx** gfxp); +void PreRender_RestoreFramebuffer(PreRender* this, Gfx** gfxp); +void PreRender_CopyImageRegion(PreRender* this, Gfx** gfxp); void PreRender_ApplyFilters(PreRender* this); #endif diff --git a/include/save.h b/include/save.h index 195e7de3912..c0be732dc48 100644 --- a/include/save.h +++ b/include/save.h @@ -602,7 +602,7 @@ typedef enum LinkAge { #define EVENTCHKINF_5C 0x5C #define EVENTCHKINF_65 0x65 #define EVENTCHKINF_DRAINED_WELL 0x67 -#define EVENTCHKINF_68 0x68 +#define EVENTCHKINF_HORSEBACK_ARCHERY_EXPLAINED 0x68 #define EVENTCHKINF_RESTORED_LAKE_HYLIA 0x69 #define EVENTCHKINF_TALON_WOKEN_IN_KAKARIKO 0x6A @@ -743,7 +743,7 @@ typedef enum LinkAge { #define ITEMGETINF_0C 0x0C #define ITEMGETINF_0D 0x0D #define ITEMGETINF_0E 0x0E -#define ITEMGETINF_0F 0x0F +#define ITEMGETINF_HORSEBACK_ARCHERY_QUIVER 0x0F #define ITEMGETINF_10 0x10 #define ITEMGETINF_BOWLING_BOMB_BAG 0x11 #define ITEMGETINF_BOWLING_HEART_PIECE 0x12 @@ -913,7 +913,7 @@ typedef enum LinkAge { #define INFTABLE_178 0x178 #define INFTABLE_17C 0x17C #define INFTABLE_17F 0x17F -#define INFTABLE_190 0x190 +#define INFTABLE_HORSEBACK_ARCHERY_GOT_HEART_PIECE 0x190 #define INFTABLE_191 0x191 #define INFTABLE_HAS_DEKU_STICK_UPGRADE 0x192 #define INFTABLE_HAS_DEKU_NUT_UPGRADE 0x193 diff --git a/include/ultra64.h b/include/ultra64.h index af38a354af2..8d0b721d461 100644 --- a/include/ultra64.h +++ b/include/ultra64.h @@ -42,6 +42,8 @@ #include "ultra64/version.h" // IWYU pragma: end_exports +#include "ultra64/leo.h" + union uObjBg; void __osPiCreateAccessQueue(void); diff --git a/include/ultra64/leo.h b/include/ultra64/leo.h index 3bc8a1dd6e4..7e28ccf45b6 100644 --- a/include/ultra64/leo.h +++ b/include/ultra64/leo.h @@ -1,140 +1,178 @@ -#ifndef ULTRA64_LEO_H -#define ULTRA64_LEO_H + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. + + $RCSfile: leo.h,v $ + $Revision: 1.29 $ + $Date: 1998/12/21 07:30:15 $ + *---------------------------------------------------------------------*/ + +#ifndef _LEO_H_ +#define _LEO_H_ #ifdef _LANGUAGE_C_PLUS_PLUS extern "C" { #endif -#include "pi.h" #include "leoappli.h" #if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) -typedef u32 LEOError; - -typedef u8 LEOSpdlMode; - -typedef u8 LEOStatus; - -typedef struct LEOVersion { - /* 0x0 */ u8 driver; // version of sw - /* 0x1 */ u8 drive; // version of hw - /* 0x2 */ u8 deviceType; // dev type, always 00 - /* 0x3 */ u8 nDevices; // # of devices, always 01 -} LEOVersion; // size = 0x4 - -typedef struct LEOCapacity { - /* 0x0 */ u32 startLBA; - /* 0x4 */ u32 endLBA; - /* 0x8 */ u32 nbytes; -} LEOCapacity; // size = 0xC - -typedef struct LEODiskTime { - /* 0x0 */ u8 pad; - /* 0x1 */ u8 yearhi; - /* 0x2 */ u8 yearlo; - /* 0x3 */ u8 month; - /* 0x4 */ u8 day; - /* 0x5 */ u8 hour; - /* 0x6 */ u8 minute; - /* 0x7 */ u8 second; -} LEODiskTime; // size = 0x8 - -typedef struct LEOSerialNum { - /* 0x0 */ u64 lineNumber; - /* 0x8 */ LEODiskTime time; -} LEOSerialNum; // size = 0x10 - -typedef struct LEODiskID { - /* 0x0 */ u8 gameName[4]; - /* 0x4 */ u8 gameVersion; - /* 0x5 */ u8 diskNumber; - /* 0x6 */ u8 ramUsage; - /* 0x7 */ u8 diskUsage; - /* 0x8 */ LEOSerialNum serialNumber; - /* 0x18 */ u8 company[2]; - /* 0x1A */ u8 freeArea[6]; -} LEODiskID; // size = 0x20 - -// Not attempting to number this struct until required since it's scary -typedef struct LEOCmd { - /* 0x00 */ LEOCmdHeader header; - union { - struct { - /* 0x0C */ u32 lba; - /* 0x10 */ u32 transferBlks; - /* 0x14 */ void* buffPtr; - /* 0x18 */ u32 rwBytes; +/************************************************************************** + * + * Type definitions + * + */ +typedef u32 LEOError; + +typedef u8 LEOSpdlMode; + +typedef u8 LEOStatus; + +typedef struct +{ + u8 drive; /* version of hw */ + u8 driver; /* version of sw */ + u8 deviceType; /* dev type, always 00 */ + u8 ndevices; /* # of devices, always 01 */ +} LEOVersion; + +typedef struct +{ + u32 startLBA; + u32 endLBA; + u32 nbytes; +} LEOCapacity; + +typedef struct +{ + u8 pad; + u8 yearhi; + u8 yearlo; + u8 month; + u8 day; + u8 hour; + u8 minute; + u8 second; +} LEODiskTime; + +typedef struct +{ + u64 lineNumber; + LEODiskTime time; +} LEOSerialNum; + +typedef struct +{ + u8 gameName[4]; + u8 gameVersion; + u8 diskNumber; + u8 ramUsage; + u8 diskUsage; + LEOSerialNum serialNumber; + u8 company[2]; + u8 freeArea[6]; +} LEODiskID; + +typedef struct +{ + LEOCmdHeader header; + union + { + struct + { + u32 lba; + u32 xfer_blks; + void *buff_ptr; + u32 rw_bytes; #ifdef _LONGCMD - /* 0x1C */ u32 size; + u32 size; #endif - } readWrite; - struct { - /* 0x0C */ u32 lba; - } seek; - struct { - /* 0x0C */ void* bufferPointer; - } readdiskid; - /* 0x0C */ LEODiskTime time; - struct { - /* 0x0C */ u8 reserve1; - /* 0x0D */ u8 reserve2; - /* 0x0E */ u8 standbyTime; - /* 0x0F */ u8 sleepTime; - /* 0x10 */ u32 reserve3; - } modeSelect; - } data; -} LEOCmd; // size = 0x1C + } readwrite; + struct + { + u32 lba; + } seek; + struct + { + void *buffer_pointer; + } readdiskid; + LEODiskTime time; + struct + { + u8 reserve1; + u8 reserve2; + u8 standby_time; + u8 sleep_time; + u32 reserve3; + } modeselect; + } data; -#define _nbytes readwrite.rwBytes -#define _result header.status +} LEOCmd; -#endif // defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) +#define _nbytes readwrite.rw_bytes +#define _result header.status -#define LEO_SW_VERSION 6 // This will be returned by LeoInquiry command -#define OS_PRIORITY_LEOMGR OS_PRIORITY_PIMGR -#define DDROM_FONT_START 0x000A0000 -#define DDROM_WAVEDATA_START 0x00140000 +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/************************************************************************** + * + * Global definitions + * + */ +#define LEO_SW_VERSION 6 /* This will be returned by */ + /* LeoInquiry command */ + +#define OS_PRIORITY_LEOMGR OS_PRIORITY_PIMGR + +/* + * Drive Rom offset address + */ +#define DDROM_FONT_START 0x000a0000 +#define DDROM_WAVEDATA_START 0x00140000 /* * Definition for osLeoSpdlMotor() */ -#define ACTIVE 0 -#define STANDBY 1 -#define SLEEP 2 -#define BRAKE 4 - -#define LEO_MOTOR_ACTIVE 0 -#define LEO_MOTOR_STANDBY 1 -#define LEO_MOTOR_SLEEP 2 -#define LEO_MOTOR_BRAKE 4 - -#define NUM_LBAS 4292 - -#define BLK_SIZE_ZONE0 19720 -#define BLK_SIZE_ZONE1 18360 -#define BLK_SIZE_ZONE2 17680 -#define BLK_SIZE_ZONE3 16320 -#define BLK_SIZE_ZONE4 14960 -#define BLK_SIZE_ZONE5 13600 -#define BLK_SIZE_ZONE6 12240 -#define BLK_SIZE_ZONE7 10880 -#define BLK_SIZE_ZONE8 9520 - -#define MAX_BLK_SIZE BLK_SIZE_ZONE0 -#define MIN_BLK_SIZE BLK_SIZE_ZONE8 - -#define LEO_ERROR_GOOD 0 -#define LEO_ERROR_DRIVE_NOT_READY 1 -#define LEO_ERROR_DIAGNOSTIC_FAILURE 2 -#define LEO_ERROR_COMMAND_PHASE_ERROR 3 -#define LEO_ERROR_DATA_PHASE_ERROR 4 -#define LEO_ERROR_REAL_TIME_CLOCK_FAILURE 5 -#define LEO_ERROR_BUSY 8 +#define ACTIVE 0 +#define STANDBY 1 +#define SLEEP 2 +#define BRAKE 4 + +#define LEO_MOTOR_ACTIVE 0 +#define LEO_MOTOR_STANDBY 1 +#define LEO_MOTOR_SLEEP 2 +#define LEO_MOTOR_BRAKE 4 + +#define NUM_LBAS 4292 /* total number of LBAs */ + +#define BLK_SIZE_ZONE0 19720 +#define BLK_SIZE_ZONE1 18360 +#define BLK_SIZE_ZONE2 17680 +#define BLK_SIZE_ZONE3 16320 +#define BLK_SIZE_ZONE4 14960 +#define BLK_SIZE_ZONE5 13600 +#define BLK_SIZE_ZONE6 12240 +#define BLK_SIZE_ZONE7 10880 +#define BLK_SIZE_ZONE8 9520 + +#define MAX_BLK_SIZE BLK_SIZE_ZONE0 +#define MIN_BLK_SIZE BLK_SIZE_ZONE8 + +/* + * Error codes + */ +#define LEO_ERROR_GOOD 0 +#define LEO_ERROR_DRIVE_NOT_READY 1 +#define LEO_ERROR_DIAGNOSTIC_FAILURE 2 +#define LEO_ERROR_COMMAND_PHASE_ERROR 3 +#define LEO_ERROR_DATA_PHASE_ERROR 4 +#define LEO_ERROR_REAL_TIME_CLOCK_FAILURE 5 +#define LEO_ERROR_BUSY 8 #define LEO_ERROR_INCOMPATIBLE_MEDIUM_INSTALLED 11 #define LEO_ERROR_UNKNOWN_FORMAT 11 #define LEO_ERROR_NO_SEEK_COMPLETE 21 @@ -150,65 +188,92 @@ typedef struct LEOCmd { #define LEO_ERROR_COMMAND_TERMINATED 34 #define LEO_ERROR_QUEUE_FULL 35 #define LEO_ERROR_ILLEGAL_TIMER_VALUE 36 -#define LEO_ERROR_WAITING_NMI 37 +#define LEO_ERROR_WAITING_NMI 37 #define LEO_ERROR_DEVICE_COMMUNICATION_FAILURE 41 #define LEO_ERROR_MEDIUM_NOT_PRESENT 42 #define LEO_ERROR_POWERONRESET_DEVICERESET_OCCURED 43 -#define LEO_ERROR_RAMPACK_NOT_CONNECTED 44 +#define LEO_ERROR_RAMPACK_NOT_CONNECTED 44 #define LEO_ERROR_MEDIUM_MAY_HAVE_CHANGED 47 -#define LEO_ERROR_EJECTED_ILLEGALLY_RESUME 49 +#define LEO_ERROR_EJECTED_ILLEGALLY_RESUME 49 -#define LEO_ERROR_NOT_BOOTED_DISK 45 +/* + * Reserved + */ +#define LEO_ERROR_NOT_BOOTED_DISK 45 #define LEO_ERROR_DIDNOT_CHANGED_DISK_AS_EXPECTED 46 -#define LEO_ERROR_RTC_NOT_SET_CORRECTLY 48 -#define LEO_ERROR_DIAGNOSTIC_FAILURE_RESET 50 -#define LEO_ERROR_EJECTED_ILLEGALLY_RESET 51 +/* + * Error codes only used in IPL + */ +#define LEO_ERROR_RTC_NOT_SET_CORRECTLY 48 +#define LEO_ERROR_DIAGNOSTIC_FAILURE_RESET 50 +#define LEO_ERROR_EJECTED_ILLEGALLY_RESET 51 #if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) +/************************************************************************** + * + * Macro definitions + * + */ #define GET_ERROR(x) ((x).header.sense) -extern LEODiskID leoBootID; -extern OSPiHandle* __osDiskHandle; // For exceptasm to get disk info - -// Initialize routine -s32 LeoCreateLeoManager(OSPri comPri, OSPri intPri, OSMesg* cmdBuf, s32 cmdMsgCnt); -s32 LeoCJCreateLeoManager(OSPri comPri, OSPri intPri, OSMesg* cmdBuf, s32 cmdMsgCnt); -s32 LeoCACreateLeoManager(OSPri comPri, OSPri intPri, OSMesg* cmdBuf, s32 cmdMsgCnt); -u32 LeoDriveExist(void); - -// Synchronous functions -s32 LeoClearQueue(void); -s32 LeoByteToLBA(s32 startlba, u32 nbytes, s32* lba); -s32 LeoLBAToByte(s32 startlba, u32 nlbas, s32* bytes); -s32 LeoReadCapacity(LEOCapacity* cap, s32 dir); -s32 LeoInquiry(LEOVersion* ver); -s32 LeoTestUnitReady(LEOStatus* status); - -// Asynchronous functions -s32 LeoSpdlMotor(LEOCmd* cmdBlock, LEOSpdlMode mode, OSMesgQueue* mq); -s32 LeoSeek(LEOCmd* cmdBlock, u32 lba, OSMesgQueue* mq); -s32 LeoRezero(LEOCmd* cmdBlock, OSMesgQueue* mq); -s32 LeoReadWrite(LEOCmd* cmdBlock, s32 direction, u32 LBA, void* vAddr, u32 nLBAs, OSMesgQueue* mq); -s32 LeoReadDiskID(LEOCmd* cmdBlock, LEODiskID* vaddr, OSMesgQueue* mq); -s32 LeoSetRTC(LEOCmd* cmdBlock, LEODiskTime* RTCdata, OSMesgQueue* mq); -s32 LeoReadRTC(LEOCmd* cmdBlock, OSMesgQueue* mq); -s32 LeoModeSelectAsync(LEOCmd* cmdBlock, u32 standby, u32 sleep, OSMesgQueue* mq); - -// Font routines -int LeoGetKAdr(int sjis); -int LeoGetAAdr(int code, int* dx, int* dy, int* cy); -int LeoGetAAdr2(u32 ccode, int* dx, int* dy, int* cy); - -// Boot function -void LeoBootGame(void* entry); - -#endif // defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Extern variables + * + */ +extern LEODiskID leoBootID; +extern OSPiHandle *__osDiskHandle; /* For exceptasm to get disk info*/ + + +/************************************************************************** + * + * Function prototypes + * + */ +/* Initialize routine */ +extern s32 LeoCreateLeoManager(OSPri comPri, OSPri intPri, + OSMesg *cmdBuf, s32 cmdMsgCnt); +extern s32 LeoCJCreateLeoManager(OSPri comPri, OSPri intPri, + OSMesg *cmdBuf, s32 cmdMsgCnt); +extern s32 LeoCACreateLeoManager(OSPri comPri, OSPri intPri, + OSMesg *cmdBuf, s32 cmdMsgCnt); +extern u32 LeoDriveExist(void); + +/* Synchronous functions */ +extern s32 LeoClearQueue(void); +extern s32 LeoByteToLBA(s32 startlba, u32 nbytes, s32* lba); +extern s32 LeoLBAToByte(s32 startlba, u32 nlbas, s32* bytes); +extern s32 LeoReadCapacity(LEOCapacity *cap, s32 dir); +extern s32 LeoInquiry(LEOVersion *ver); +extern s32 LeoTestUnitReady(LEOStatus *status); + +/* Asynchronous functions */ +extern s32 LeoSpdlMotor(LEOCmd *cmdBlock, LEOSpdlMode mode, OSMesgQueue *mq); +extern s32 LeoSeek(LEOCmd *cmdBlock, u32 lba, OSMesgQueue *mq); +extern s32 LeoRezero(LEOCmd *cmdBlock, OSMesgQueue *mq); +extern s32 LeoReadWrite(LEOCmd *cmdBlock, s32 direction, + u32 LBA, void *vAddr, u32 nLBAs, OSMesgQueue *mq); +extern s32 LeoReadDiskID(LEOCmd *cmdBlock, LEODiskID *vaddr, OSMesgQueue *mq); +extern s32 LeoSetRTC(LEOCmd *cmdBlock, LEODiskTime *RTCdata, OSMesgQueue *mq); +extern s32 LeoReadRTC(LEOCmd *cmdBlock, OSMesgQueue *mq); +extern s32 LeoModeSelectAsync(LEOCmd *cmdBlock, u32 standby, + u32 sleep, OSMesgQueue *mq); + +/* Font routines */ +extern int LeoGetKAdr(int sjis); +extern int LeoGetAAdr(int code,int *dx,int *dy, int *cy); +extern int LeoGetAAdr2(u32 ccode,int *dx,int *dy, int *cy); + +/* Boot function */ +extern void LeoBootGame(void *entry); + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ #ifdef _LANGUAGE_C_PLUS_PLUS } #endif -#endif - +#endif /* !_LEO_H */ diff --git a/include/ultra64/leo_internal.h b/include/ultra64/leo_internal.h new file mode 100644 index 00000000000..eae087776e1 --- /dev/null +++ b/include/ultra64/leo_internal.h @@ -0,0 +1,133 @@ +#ifndef LEO_INTERNAL_H +#define LEO_INTERNAL_H + +#include "ultra64.h" +#include "stack.h" + +#define STATIC + +extern OSPiHandle* LEOPiInfo; +void leointerrupt(void*); +void leomain(void*); +void leoClr_queue(void); +u8 leoChk_asic_ready(u32); +void leoDrive_reset(void); +extern s32 __leoActive; +typedef struct tgt_param_form { + /* 0x0 */ u16 lba; + /* 0x2 */ u16 cylinder; + /* 0x4 */ u16 blk_bytes; + /* 0x6 */ u8 sec_bytes; + /* 0x7 */ u8 head; + /* 0x8 */ u8 zone; + /* 0x9 */ u8 rdwr_blocks; + /* 0xA */ u8 start_block; +} tgt_param_form; +s32 __leoSetReset(void); +s32 __osLeoInterrupt(void); +OSPiHandle* osLeoDiskInit(void); +extern LEOVersion __leoVersion; +extern STACK(leoDiskStack, 0x1000); +extern const u16 LEOBYTE_TBL2[]; +extern const u16 LEOVZONE_TBL[][0x10]; +extern const u8 LEOVZONE_PZONEHD_TBL[][0x10]; +u16 leoLba_to_vzone(u32 lba); +u16 leoLba_to_phys(u32 lba); +u8 leoSeek_i(u16 rwmode); +extern OSMesgQueue LEOc2ctrl_que; +u32 leoChkUnit_atten(void); +u8 leoChk_cur_drvmode(void); +void leoClrUA_RESET(void); +void leoInitUnit_atten(void); +u8 leoRead_system_area(void); +u32 leoRetUnit_atten(void); +u8 leoSend_asic_cmd_w(u32 asic_cmd, u32 asic_data); +extern OSIoMesg LEOPiDmaParam; +extern s32 currentCommand; +typedef union leo_sys_form { + /* 0x00 */ struct { + /* 0x00 */ u32 country; + /* 0x04 */ u8 fmt_type; + /* 0x05 */ u8 disk_type; + /* 0x06 */ u16 ipl_load_len; + /* 0x08 */ u8 defect_num[20]; + /* 0x1C */ void* loadptr; + /* 0x20 */ u8 defect_data[192]; + /* 0xE0 */ u16 rom_end_lba; + /* 0xE2 */ u16 ram_start_lba; + /* 0xE4 */ u16 ram_end_lba; + } param; + /* 0x00 */ u64 u64_data[29]; +} leo_sys_form; // size = 0xE8 +void leoRead_common(unsigned int offset); +u32 leoChk_err_retry(u32 sense); +typedef struct block_param_form { + /* 0x0 */ u8* pntr; + /* 0x4 */ u8* c2buff_e; + /* 0x8 */ u8 err_pos[4]; + /* 0xC */ u8 err_num; + /* 0xD */ u8 bytes; + /* 0xE */ u16 blkbytes; +} block_param_form; // size = 0x10 +extern u8 LEOC2_Syndrome[2][0xE8 * 4]; +extern block_param_form LEOc2_param; +void leoSet_mseq(u16 rwmode); +u8 leoDetect_index_w(void); +extern const u16 LEOZONE_SCYL_TBL[]; +extern const u16 LEOZONE_OUTERCYL_TBL[]; +extern const u8 LEOBYTE_TBL1[]; +int leoC2_Correction(void); +u8 leoSend_asic_cmd_w_nochkDiskChange(u32 asic_cmd, u32 asic_data); +u8 leoChk_done_status(u32 asic_cmd); +u8 leoWait_mecha_cmd_done(u32 asic_cmd); +u8 leoRecal_w(void); +u8 leoSeek_w(void); +void leoClrUA_MEDIUM_CHANGED(void); +void leoSetUA_MEDIUM_CHANGED(void); +u8 leoAnalize_asic_status(void); +void leoMode_sel(void); +extern u8 LEO_TempBuffer[0xE8]; +void leoTest_unit_rdy(void); +void leoSeek(void); +void leoRd_capacity(void); +extern const u16 LEORAM_START_LBA[]; +extern const u32 LEORAM_BYTE[]; + +void leoClr_reset(void); +void leoInquiry(void); +void leoRead(void); +void leoReadDiskId(void); +void leoReadTimer(void); +void leoRezero(void); +void leoSetTimer(void); +void leoStart_stop(void); +void leoTranslate(void); +void leoWrite(void); + +extern leo_sys_form LEO_sys_data; + +extern OSThread LEOcommandThread; +extern OSThread LEOinterruptThread; +extern STACK(LEOcommandThreadStack, 0x400); +extern STACK(LEOinterruptThreadStack, 0x400); +extern OSMesgQueue LEOcommand_que; +extern OSMesgQueue LEOevent_que; +extern OSMesgQueue LEOcontrol_que; +extern OSMesgQueue LEOdma_que; +extern OSMesgQueue LEOblock_que; +extern OSMesg LEOevent_que_buf; +extern OSMesg LEOcontrol_que_buf; +extern OSMesg LEOdma_que_buf[2]; +extern OSMesg LEOblock_que_buf; +extern u8* LEOwrite_pointer; +extern LEOCmd* LEOcur_command; +extern u32 LEOasic_bm_ctl_shadow; +extern u32 LEOasic_seq_ctl_shadow; +extern u8 LEOdrive_flag; +extern vu8 LEOclr_que_flag; +// extern u16 LEOrw_flags; +extern tgt_param_form LEOtgt_param; +extern u8 LEOdisk_type; +extern u32 LEO_country_code; + +#endif diff --git a/include/ultra64/leoappli.h b/include/ultra64/leoappli.h index ef526ee5a54..31ae29d58ee 100644 --- a/include/ultra64/leoappli.h +++ b/include/ultra64/leoappli.h @@ -1,72 +1,101 @@ -#ifndef ULTRA64_LEOAPPLI_H -#define ULTRA64_LEOAPPLI_H - -#include "thread.h" -#include "message.h" - -#define LEO_DISK_TYPE_MIN 0 -#define LEO_DISK_TYPE_MAX 6 - -#define LEO_LBA_MIN 0 -#define LEO_LBA_MAX 4291 - -#define LEO_LBA_ROM_TOP LEO_LBA_MIN -#define LEO_LBA_ROM_END0 1417 -#define LEO_LBA_ROM_END1 1965 -#define LEO_LBA_ROM_END2 2513 -#define LEO_LBA_ROM_END3 3061 -#define LEO_LBA_ROM_END4 3609 -#define LEO_LBA_ROM_END5 4087 -#define LEO_LBA_ROM_END6 LEO_LBA_MAX -#define LEO_LBA_RAM_TOP0 (LEO_LBA_ROM_END0+1) -#define LEO_LBA_RAM_TOP1 (LEO_LBA_ROM_END1+1) -#define LEO_LBA_RAM_TOP2 (LEO_LBA_ROM_END2+1) -#define LEO_LBA_RAM_TOP3 (LEO_LBA_ROM_END3+1) -#define LEO_LBA_RAM_TOP4 (LEO_LBA_ROM_END4+1) -#define LEO_LBA_RAM_TOP5 (LEO_LBA_ROM_END5+1) -#define LEO_LBA_RAM_TOP6 (LEO_LBA_ROM_END6+1) -#define LEO_LBA_RAM_END6 LEO_LBA_MAX - -void leoInitialize(OSPri compri, OSPri intpri, OSMesg* command_que_buf, u32 cmd_buff_size); -void leoCommand(void* cmd_blk_addr); -void LeoReset(void); -s32 LeoResetClear(void); - -#define LEO_PRIORITY_WRK (OS_PRIORITY_PIMGR-1) -#define LEO_PRIORITY_INT OS_PRIORITY_PIMGR - -#define LEO_COMMAND_CLEAR_QUE 0x01 -#define LEO_COMMAND_INQUIRY 0x02 -#define LEO_COMMAND_TEST_UNIT_READY 0x03 -#define LEO_COMMAND_REZERO 0x04 -#define LEO_COMMAND_READ 0x05 -#define LEO_COMMAND_WRITE 0x06 -#define LEO_COMMAND_SEEK 0x07 -#define LEO_COMMAND_START_STOP 0x08 -#define LEO_COMMAND_READ_CAPACITY 0x09 -#define LEO_COMMAND_TRANSLATE 0x0A -#define LEO_COMMAND_MODE_SELECT 0x0B -#define LEO_COMMAND_READ_DISK_ID 0x0C -#define LEO_COMMAND_READ_TIMER 0x0D -#define LEO_COMMAND_SET_TIMER 0x0E -// should be -// #define LEO_COMMAND_CLEAR_RESET 0x0F - -#define LEO_CONTROL_POST 0x80 // ENABLE POST QUEUE -#define LEO_CONTROL_START 0x01 // START COMMAND -#define LEO_CONTROL_STBY 0x02 // STAND-BY MODE(NOT SLEEP MODE) -#define LEO_CONTROL_WRT 0x01 // READ RE-WRITE-ABLE CAPACITY -#define LEO_CONTROL_TBL 0x01 // TRANSLATE BYTE TO LBA -#define LEO_CONTROL_BRAKE 0x04 // SLEEP MODE(BRAKE ON) - -#define LEO_TEST_UNIT_MR 0x01 // MEDIUM REMOVED -#define LEO_TEST_UNIT_RE 0x02 // HEAD RETRACTED -#define LEO_TEST_UNIT_SS 0x04 // SPINDLE STOPPED - -#define LEO_STATUS_GOOD 0x00 -#define LEO_STATUS_CHECK_CONDITION 0x02 -#define LEO_STATUS_BUSY 0x08 +/* + * F i l e N a m e : l e o a p p l i . h + * + **************************************************************************** + * (C) Copyright ALPS Electric Co., Ltd. 1995-1997 + **************************************************************************** + * Version + * + * ver Date + * ---- -------- + * 1.01 '97-11-18 Add MOTOR BRAKE definition for control bit. + **************************************************************************** +*/ +/*-----------------------------------*/ +/* DRIVE PARAMETER */ +/*-----------------------------------*/ +#define LEO_DISK_TYPE_MIN 0 +#define LEO_DISK_TYPE_MAX 6 +#define LEO_LBA_MIN 0 +#define LEO_LBA_MAX 4291 + +#define LEO_LBA_ROM_TOP LEO_LBA_MIN +#define LEO_LBA_ROM_END0 1417 +#define LEO_LBA_ROM_END1 1965 +#define LEO_LBA_ROM_END2 2513 +#define LEO_LBA_ROM_END3 3061 +#define LEO_LBA_ROM_END4 3609 +#define LEO_LBA_ROM_END5 4087 +#define LEO_LBA_ROM_END6 LEO_LBA_MAX +#define LEO_LBA_RAM_TOP0 (LEO_LBA_ROM_END0+1) +#define LEO_LBA_RAM_TOP1 (LEO_LBA_ROM_END1+1) +#define LEO_LBA_RAM_TOP2 (LEO_LBA_ROM_END2+1) +#define LEO_LBA_RAM_TOP3 (LEO_LBA_ROM_END3+1) +#define LEO_LBA_RAM_TOP4 (LEO_LBA_ROM_END4+1) +#define LEO_LBA_RAM_TOP5 (LEO_LBA_ROM_END5+1) +#define LEO_LBA_RAM_TOP6 (LEO_LBA_ROM_END6+1) +#define LEO_LBA_RAM_END6 LEO_LBA_MAX + +/*-----------------------------------*/ +/* LEO FUNCTION DEFINITIONS */ +/*-----------------------------------*/ +extern void leoInitialize(OSPri compri, OSPri intpri, OSMesg* command_que_buf, u32 cmd_buff_size); +extern void leoCommand(void* cmd_blk_addr); +extern void LeoReset(void); +extern s32 LeoResetClear(void); + +/*-----------------------------------*/ +/* THREAD PRIORITY */ +/*-----------------------------------*/ +#define LEO_PRIORITY_WRK (OS_PRIORITY_PIMGR-1) +#define LEO_PRIORITY_INT OS_PRIORITY_PIMGR + +/*-----------------------------------*/ +/* COMMAND CODE */ +/*-----------------------------------*/ +#define LEO_COMMAND_CLEAR_QUE 0x01 +#define LEO_COMMAND_INQUIRY 0x02 +#define LEO_COMMAND_TEST_UNIT_READY 0x03 +#define LEO_COMMAND_REZERO 0x04 +#define LEO_COMMAND_READ 0x05 +#define LEO_COMMAND_WRITE 0x06 +#define LEO_COMMAND_SEEK 0x07 +#define LEO_COMMAND_START_STOP 0x08 +#define LEO_COMMAND_READ_CAPACITY 0x09 +#define LEO_COMMAND_TRANSLATE 0x0a +#define LEO_COMMAND_MODE_SELECT 0x0b +#define LEO_COMMAND_READ_DISK_ID 0x0c +#define LEO_COMMAND_READ_TIMER 0x0d +#define LEO_COMMAND_SET_TIMER 0x0e + +/*-----------------------------------*/ +/* CONTROL BIT */ +/*-----------------------------------*/ +#define LEO_CONTROL_POST 0x80 /* ENABLE POST QUEUE */ +#define LEO_CONTROL_START 0x01 /* START COMMAND */ +#define LEO_CONTROL_STBY 0x02 /* STAND-BY MODE(NOT SLEEP MODE) */ +#define LEO_CONTROL_WRT 0x01 /* READ RE-WRITE-ABLE CAPACITY */ +#define LEO_CONTROL_TBL 0x01 /* TRANSLATE BYTE TO LBA */ +#define LEO_CONTROL_BRAKE 0x04 /* SLEEP MODE(BRAKE ON) */ + +/*-----------------------------------*/ +/* BIT FIELD PARAMETER */ +/*-----------------------------------*/ +#define LEO_TEST_UNIT_MR 0x01 /* MEDIUM REMOVED */ +#define LEO_TEST_UNIT_RE 0x02 /* HEAD RETRACTED */ +#define LEO_TEST_UNIT_SS 0x04 /* SPINDLE STOPPED */ + +/*-----------------------------------*/ +/* STATUS */ +/*-----------------------------------*/ +#define LEO_STATUS_GOOD 0x00 +#define LEO_STATUS_CHECK_CONDITION 0x02 +#define LEO_STATUS_BUSY 0x08 + +/*-----------------------------------*/ +/* SENSE CODE */ +/*-----------------------------------*/ #define LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION 00 #define LEO_SENSE_DRIVE_NOT_READY 01 #define LEO_SENSE_DIAGNOSTIC_FAILURE 02 @@ -94,105 +123,152 @@ s32 LeoResetClear(void); #define LEO_SENSE_MEDIUM_MAY_HAVE_CHANGED 47 #define LEO_SENSE_EJECTED_ILLEGALLY_RESUME 49 -typedef struct LEOCmdHeader { - /* 0x0 */ u8 command; - /* 0x1 */ u8 reserve1; - /* 0x2 */ u8 control; - /* 0x3 */ u8 reserve3; - /* 0x4 */ u8 status; - /* 0x5 */ u8 sense; - /* 0x6 */ u8 reserve6; - /* 0x7 */ u8 reserve7; - /* 0x8 */ OSMesgQueue* post; -} LEOCmdHeader; // 0xC - -typedef struct LEOCmdClearQueue { - /* 0x0 */ LEOCmdHeader header; -} LEOCmdClearQueue; // 0xC - -typedef struct LEOCmdInquiry { - /* 0x00 */ LEOCmdHeader header; - /* 0x0C */ u8 devType; - /* 0x0D */ u8 version; - /* 0x0E */ u8 devNum; - /* 0x0F */ u8 leoBiosVer; - /* 0x10 */ u32 reserve5; -} LEOCmdInquiry; // size = 0x14 - -typedef struct LEOCmdTestUnitReady { - /* 0x0 */ LEOCmdHeader header; - /* 0xC */ u8 test; - /* 0xD */ u8 reserve2; - /* 0xE */ u8 reserve3; - /* 0xF */ u8 reserve4; -} LEOCmdTestUnitReady; // size = 0x10 - -typedef struct LEOCmdRezero { - /* 0x0 */ LEOCmdHeader header; -} LEOCmdRezero; // size = 0xC - -typedef struct LEOCmdRead { - /* 0x00 */ LEOCmdHeader header; - /* 0x0C */ u32 lba; - /* 0x10 */ u32 transferBlks; - /* 0x14 */ void* buffPtr; - /* 0x18 */ u32 rwBytes; -} LEOCmdRead; // size = 0x1C +/*-----------------------------------*/ +/* Command Block Header */ +/*-----------------------------------*/ +typedef struct{ + u8 command; + u8 reserve1; + u8 control; + u8 reserve3; + u8 status; + u8 sense; + u8 reserve6; + u8 reserve7; + OSMesgQueue *post; +} LEOCmdHeader; + +/*-----------------------------------*/ +/* CLEAR QUEUE(01H) command */ +/*-----------------------------------*/ +typedef struct { + LEOCmdHeader header; +} LEOCmdClearQue; + +/*-----------------------------------*/ +/* INQUIRY(02H) command */ +/*-----------------------------------*/ +typedef struct { + LEOCmdHeader header; + u8 dev_type; + u8 version; + u8 dev_num; + u8 leo_bios_ver; + u32 reserve5; +} LEOCmdInquiry; + +/*-----------------------------------*/ +/* TEST UNIT READY(03H) command */ +/*-----------------------------------*/ +typedef struct { + LEOCmdHeader header; + u8 test; + u8 reserve2; + u8 reserve3; + u8 reserve4; +} LEOCmdTestUnitReady; +/*-----------------------------------*/ +/* REZERO(04H) command */ +/*-----------------------------------*/ +typedef struct { + LEOCmdHeader header; +} LEOCmdRezero; + +/*-----------------------------------*/ +/* READ(05H) command */ +/*-----------------------------------*/ +typedef struct { + LEOCmdHeader header; + u32 lba; + u32 xfer_blks; + void *buff_ptr; + u32 rw_bytes; +} LEOCmdRead; + +/*-----------------------------------*/ +/* WRITE(06H) command */ +/*-----------------------------------*/ typedef LEOCmdRead LEOCmdWrite; -typedef struct LEOCmdSeek { - /* 0x0 */ LEOCmdHeader header; - /* 0xC */ u32 lba; -} LEOCmdSeek; // size = 0x10 - -typedef struct LEOCmdStartStop { - /* 0x0 */ LEOCmdHeader header; -} LEOCmdStartStop; // size = 0xC - -typedef struct LEOCmdReadCapacity { - /* 0x00 */ LEOCmdHeader header; - /* 0x0C */ u32 startLba; - /* 0x10 */ u32 endLba; - /* 0x14 */ u32 capaBytes; -} LEOCmdReadCapacity; // size = 0x18 - -typedef struct LEOCmdTranslate { - /* 0x00 */ LEOCmdHeader header; - /* 0x0C */ u32 startLba; - /* 0x10 */ u32 inParam; - /* 0x14 */ u32 outParam; -} LEOCmdTranslate; // size = 0x18 - -typedef struct LEOCmdModeSelect { - /* 0x00 */ LEOCmdHeader header; - /* 0x0C */ u8 pageCode; - /* 0x0D */ u8 reserve1; - /* 0x0E */ u8 standbyTime; - /* 0x0F */ u8 sleepTime; - /* 0x10 */ u8 ledOnTime; - /* 0x11 */ u8 ledOffTime; - /* 0x12 */ u8 reserve18; - /* 0x13 */ u8 reserve19; -} LEOCmdModeSelect; // size = 0x14 - -typedef struct LEOCmdReadDiskId { - /* 0x0 */ LEOCmdHeader header; - /* 0xC */ void* bufferPointer; -} LEOCmdReadDiskId; // size = 0x10 - -typedef struct LEOCmdReadTimer { - /* 0x00 */ LEOCmdHeader header; - /* 0x0C */ u8 reserve12; - /* 0x0D */ u8 reserve13; - /* 0x0E */ u8 year; - /* 0x0F */ u8 month; - /* 0x10 */ u8 day; - /* 0x11 */ u8 hour; - /* 0x12 */ u8 minute; - /* 0x13 */ u8 second; -} LEOCmdReadTimer; // size = 0x14 +/*-----------------------------------*/ +/* SEEK(07H) command */ +/*-----------------------------------*/ +typedef struct { + LEOCmdHeader header; + u32 lba; +} LEOCmdSeek; + +/*-----------------------------------*/ +/* START/STOP(08H) command */ +/*-----------------------------------*/ +typedef struct { + LEOCmdHeader header; +} LEOCmdStartStop; + +/*-----------------------------------*/ +/* READ CAPACITY(09H) command */ +/*-----------------------------------*/ +typedef struct { + LEOCmdHeader header; + u32 start_lba; + u32 end_lba; + u32 capa_bytes; +} LEOCmdReadCapacity; + +/*-----------------------------------*/ +/* TRANSLATE(0AH) command */ +/*-----------------------------------*/ +typedef struct { + LEOCmdHeader header; + u32 start_lba; + u32 in_param; + u32 out_param; +} LEOCmdTranslate; +/*-----------------------------------*/ +/* MODE SELECT(0BH) command */ +/*-----------------------------------*/ +typedef struct { + LEOCmdHeader header; + u8 page_code; + u8 reserve1; + u8 standby_time; + u8 sleep_time; + u8 led_on_time; + u8 led_off_time; + u8 reserve18; + u8 reserve19; +} LEOCmdModeSelect; + +/*-----------------------------------*/ +/* READ DISK ID(0CH) command */ +/*-----------------------------------*/ +typedef struct { + LEOCmdHeader header; + void *buffer_pointer; +} LEOCmdReadDiskId; + +/*-----------------------------------*/ +/* READ TIMER(0DH) command */ +/*-----------------------------------*/ +typedef struct { + LEOCmdHeader header; + u8 reserve12; + u8 reserve13; + u8 year; + u8 month; + u8 day; + u8 hour; + u8 minute; + u8 second; +} LEOCmdReadTimer; + +/*-----------------------------------*/ +/* SET TIMER(0EH) command */ +/*-----------------------------------*/ typedef LEOCmdReadTimer LEOCmdSetTimer; -#endif +/*-------end of leoappli.h--------------------------*/ + + diff --git a/include/ultra64/leodrive.h b/include/ultra64/leodrive.h index fbbbef8e0f2..36b28f4b9ed 100644 --- a/include/ultra64/leodrive.h +++ b/include/ultra64/leodrive.h @@ -1,14 +1,7 @@ #ifndef ULTRA64_LEODRIVE_H #define ULTRA64_LEODRIVE_H -#include "leo.h" -#include "leoappli.h" -#include "message.h" -#include "pi.h" #include "rcp.h" -#include "stack.h" -#include "thread.h" -#include "ultratypes.h" #define ASIC_BASE PI_DOM2_ADDR1 @@ -51,144 +44,4 @@ // ASIC_STATUS read bits #define LEO_STATUS_MECHANIC_INTR 0x02000000 // Mechanic Interrupt Raised -typedef union { - /* 0x0 */ u8 u8_data[4]; - /* 0x0 */ u16 u16_data[2]; - /* 0x0 */ u32 u32_data; -} data_trans_form; // size = 0x4 - -typedef struct { - /* 0x00 */ u8* pntr; - /* 0x04 */ u8* c2buff_e; - /* 0x08 */ u8 err_pos[4]; - /* 0x0C */ u8 err_num; - /* 0x0D */ u8 bytes; - /* 0x0E */ u16 blkbytes; -} block_param_form; // size = 0x10 - -typedef struct { - /* 0x0 */ u16 lba; - /* 0x2 */ u16 cylinder; - /* 0x4 */ u16 blk_bytes; - /* 0x6 */ u8 sec_bytes; - /* 0x7 */ u8 head; - /* 0x8 */ u8 zone; - /* 0x9 */ u8 rdwr_blocks; - /* 0xA */ u8 start_block; -} tgt_param_form; // size = 0xC - -typedef union { - /* 0x00 */ struct { - /* 0x00 */ u32 country; - /* 0x04 */ u8 fmt_type; - /* 0x05 */ u8 disk_type; - /* 0x06 */ u16 ipl_load_len; - /* 0x08 */ u8 defect_num[20]; - /* 0x1C */ void* loadptr; - /* 0x20 */ u8 defect_data[192]; - /* 0xE0 */ u16 rom_end_lba; - /* 0xE2 */ u16 ram_start_lba; - /* 0xE4 */ u16 ram_end_lba; - } param; - /* 0x00 */ u64 u64_data[29]; -} leo_sys_form; // size = 0xE8 - -void leomain(void* arg); -void leointerrupt(void* arg); - -OSPiHandle* osLeoDiskInit(void); -s32 __osLeoInterrupt(void); - -void leoClr_queue(void); -void leoInquiry(void); -void leoTest_unit_rdy(void); -void leoRezero(void); -void leoRead(void); -void leoWrite(void); -void leoSeek(void); -void leoStart_stop(void); -void leoRd_capacity(void); -void leoTranslate(); -void leoMode_sel(void); -void leoReadDiskId(void); -void leoReadTimer(void); -void leoSetTimer(void); -void leoClr_reset(void); - -u16 leoLba_to_phys(u32 lba); -u16 leoLba_to_vzone(u32 lba); - -u8 leoAnalize_asic_status(void); -u8 leoChk_asic_ready(u32 asic_cmd); -u8 leoChk_done_status(u32 asic_cmd); -u8 leoSend_asic_cmd_i(u32 asic_cmd, u32 asic_data); -u8 leoWait_mecha_cmd_done(u32 asic_cmd); -u8 leoSend_asic_cmd_w(u32 asic_cmd, u32 asic_data); -u8 leoSend_asic_cmd_w_nochkDiskChange(u32 asic_cmd, u32 asic_data); -u8 leoDetect_index_w(void); -u8 leoRecal_i(void); -u8 leoRecal_w(void); -u8 leoSeek_i(u16 rwmode); -u8 leoSeek_w(void); -u8 leoRecv_event_mesg(s32 control); -u32 leoChk_err_retry(u32 sense); -u8 leoChk_cur_drvmode(void); -void leoDrive_reset(void); -u32 leoChkUnit_atten(void); -u32 leoRetUnit_atten(void); -void leoClrUA_RESET(void); -void leoClrUA_MEDIUM_CHANGED(void); -void leoSetUA_MEDIUM_CHANGED(void); -void leoInitUnit_atten(void); - -s32 __leoSetReset(void); - -void leoRead_common(unsigned int offset); - -int leoC2_Correction(void); - -void leoSet_mseq(u16 rwmode); - -extern leo_sys_form LEO_sys_data; -extern OSThread LEOcommandThread; -extern OSThread LEOinterruptThread; -extern STACK(LEOcommandThreadStack, 0x400); -extern STACK(LEOinterruptThreadStack, 0x400); -extern OSMesgQueue LEOcommand_que; -extern OSMesgQueue LEOevent_que; -extern OSMesgQueue LEOcontrol_que; -extern OSMesgQueue LEOdma_que; -extern OSMesgQueue LEOblock_que; -extern OSMesg LEOevent_que_buf[1]; -extern OSMesg LEOcontrol_que_buf[1]; -extern OSMesg LEOdma_que_buf[2]; -extern OSMesg LEOblock_que_buf[1]; -extern u8* LEOwrite_pointer; -extern LEOCmd* LEOcur_command; -extern u32 LEOasic_bm_ctl_shadow; -extern u32 LEOasic_seq_ctl_shadow; -extern u8 LEOdrive_flag; -extern vu8 LEOclr_que_flag; -// needs to not be volatile in some files -// extern vu16 LEOrw_flags; -extern u8 LEOdisk_type; -extern tgt_param_form LEOtgt_param; -extern u32 LEO_country_code; - -extern const char LEOfirmware_rev[]; -extern const u8 LEOBYTE_TBL1[]; -extern const u16 LEOBYTE_TBL2[]; -extern const u16 LEOVZONE_TBL[][0x10]; -extern const u16 LEOZONE_SCYL_TBL[]; -extern const u8 LEOVZONE_PZONEHD_TBL[][0x10]; -extern const u16 LEOZONE_OUTERCYL_TBL[]; -extern const u16 LEORAM_START_LBA[]; -extern const s32 LEORAM_BYTE[]; - -extern s32 __leoActive; -extern LEOVersion __leoVersion; -extern STACK(leoDiskStack, 0x1000); - -extern OSPiHandle* LEOPiInfo; - #endif diff --git a/include/view.h b/include/view.h index b2dadd3db4e..5ca3410da6b 100644 --- a/include/view.h +++ b/include/view.h @@ -92,7 +92,7 @@ s32 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, s32 mask, Gfx** gfxP); +s32 View_ApplyTo(View* view, s32 mask, Gfx** gfxp); #if DEBUG_FEATURES s32 View_ErrorCheckEyePosition(f32 eyeX, f32 eyeY, f32 eyeZ); #endif diff --git a/include/z_lib.h b/include/z_lib.h index c2e36e7cc3a..e0c89e7965a 100644 --- a/include/z_lib.h +++ b/include/z_lib.h @@ -6,7 +6,7 @@ #include "z_math.h" #include "color.h" -void Lib_MemSet(u8* dest, size_t len, u8 val); +void Lib_MemSet(u8* dest, size_t size, u8 val); f32 Math_CosS(s16 angle); f32 Math_SinS(s16 angle); s32 Math_ScaledStepToS(s16* pValue, s16 target, s16 step); diff --git a/requirements.txt b/requirements.txt index bea2fe176c1..49e1bda597e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -19,4 +19,4 @@ toml mapfile-parser>=2.3.5,<3.0.0 pyelftools==0.30 rabbitizer>=1.0.0,<2.0.0 -spimdisasm>=1.28.1,<2.0.0 +spimdisasm==1.35.0 diff --git a/retail_progress.py b/retail_progress.py index cf6a623c4ae..49264882598 100755 --- a/retail_progress.py +++ b/retail_progress.py @@ -320,6 +320,9 @@ def print_summary(version: str, csv: bool, only_not_ok: bool): expected_object_files, comparison_data_list ): c_path = expected_object.relative_to(expected_dir).with_suffix(".c") + if not c_path.exists(): + c_path = c_path.with_suffix(".s") + assert c_path.exists() data = data_async.get() insts1 = data.insts1 diff --git a/spec/spec b/spec/spec index d526bef51c4..12d44653dc4 100644 --- a/spec/spec +++ b/spec/spec @@ -111,8 +111,8 @@ beginseg // Functions that GCC-compiled code may depend on, placed in boot so they will always be loaded #ifdef COMPILER_GCC include "$(BUILD_DIR)/src/libultra/libc/string.o" - include "$(BUILD_DIR)/src/libc/memset.o" - include "$(BUILD_DIR)/src/libc/memmove.o" + include "$(BUILD_DIR)/src/libc/code_80106860.o" + include "$(BUILD_DIR)/src/libc/code_801068B0.o" include "$(BUILD_DIR)/src/gcc_fix/missing_gcc_functions.o" #endif @@ -548,7 +548,7 @@ beginseg include "$(BUILD_DIR)/src/code/z_elf_message.o" include "$(BUILD_DIR)/src/code/z_face_reaction.o" include "$(BUILD_DIR)/src/code/z_env_flags.o" - include "$(BUILD_DIR)/src/code/z_fcurve_data.o" + include "$(BUILD_DIR)/src/code/code_8006C510.o" include "$(BUILD_DIR)/src/code/z_fcurve_data_skelanime.o" include "$(BUILD_DIR)/src/code/z_game_dlftbls.o" include "$(BUILD_DIR)/src/code/z_horse.o" @@ -781,17 +781,17 @@ beginseg #if PLATFORM_N64 include "$(BUILD_DIR)/src/libc/sqrt.o" include "$(BUILD_DIR)/src/libc/fmodf.o" - include "$(BUILD_DIR)/src/libc/memset.o" - include "$(BUILD_DIR)/src/libc/memmove.o" + include "$(BUILD_DIR)/src/libc/code_80106860.o" + include "$(BUILD_DIR)/src/libc/code_801068B0.o" #elif PLATFORM_GC include "$(BUILD_DIR)/src/libc/sqrt.o" include "$(BUILD_DIR)/src/libc/fabsf.o" include "$(BUILD_DIR)/src/libc/fmodf.o" - include "$(BUILD_DIR)/src/libc/memset.o" - include "$(BUILD_DIR)/src/libc/memmove.o" + include "$(BUILD_DIR)/src/libc/code_80106860.o" + include "$(BUILD_DIR)/src/libc/code_801068B0.o" #elif PLATFORM_IQUE include "$(BUILD_DIR)/src/libc/fmodf.o" - include "$(BUILD_DIR)/src/libc/memmove.o" + include "$(BUILD_DIR)/src/libc/code_801068B0.o" include "$(BUILD_DIR)/src/libc/fabsf.o" include "$(BUILD_DIR)/src/libc/sqrt.o" #endif @@ -861,16 +861,14 @@ beginseg name "n64dd" compress align 0x40 - include "$(BUILD_DIR)/src/n64dd/z_n64dd.o" - include "$(BUILD_DIR)/src/n64dd/n64dd_data_buffer.o" - include "$(BUILD_DIR)/src/n64dd/n64dd_801C8000.o" - include "$(BUILD_DIR)/src/n64dd/n64dd_801C8940.o" - include "$(BUILD_DIR)/src/n64dd/n64dd_801C9440.o" - include "$(BUILD_DIR)/src/n64dd/n64dd_801C9B70.o" - include "$(BUILD_DIR)/src/n64dd/n64dd_error_headers.o" - include "$(BUILD_DIR)/src/n64dd/n64dd_error_bodies.o" - include "$(BUILD_DIR)/src/n64dd/n64dd_error_textures.o" - include "$(BUILD_DIR)/src/n64dd/n64dd_801CA0B0.o" + include "$(BUILD_DIR)/src/n64dd/n64dd_0.o" + include "$(BUILD_DIR)/src/n64dd/n64dd_1.o" + include "$(BUILD_DIR)/src/n64dd/n64dd_2.o" + include "$(BUILD_DIR)/src/n64dd/n64dd_3.o" + include "$(BUILD_DIR)/src/n64dd/n64dd_4.o" + include "$(BUILD_DIR)/src/n64dd/n64dd_5.o" + include "$(BUILD_DIR)/src/n64dd/n64dd_6.o" + include "$(BUILD_DIR)/src/n64dd/n64dd_7.o" include "$(BUILD_DIR)/src/libleo/api/readwrite.o" include "$(BUILD_DIR)/src/libleo/leo/leofunc.o" include "$(BUILD_DIR)/src/libleo/leo/leoram.o" @@ -880,16 +878,17 @@ beginseg include "$(BUILD_DIR)/src/libleo/leo/leoread.o" include "$(BUILD_DIR)/src/libleo/api/lbatobyte.o" include "$(BUILD_DIR)/src/libleo/leo/leoinquiry.o" - include "$(BUILD_DIR)/src/libleo/leo/leodiskinit.o" - include "$(BUILD_DIR)/src/libleo/api/seek.o" + include "$(BUILD_DIR)/src/libleo/api/leodiskinit.o" + include "$(BUILD_DIR)/src/libleo/api/readdiskid.o" include "$(BUILD_DIR)/src/libleo/leo/leord_diskid.o" include "$(BUILD_DIR)/src/libleo/leo/leomecha.o" - include "$(BUILD_DIR)/src/libleo/api/spdlmotor.o" - include "$(BUILD_DIR)/src/libleo/leo/leo_tbl.o" include "$(BUILD_DIR)/src/libleo/leo/leotempbuffer.o" include "$(BUILD_DIR)/src/libleo/leo/leoc2_syndrome.o" + include "$(BUILD_DIR)/src/libleo/leo/leo_tbl.o" + include "$(BUILD_DIR)/src/libleo/api/spdlmotor.o" include "$(BUILD_DIR)/src/libleo/leo/leoc2ecc.o" include "$(BUILD_DIR)/src/libleo/leo/leomseq_tbl.o" + include "$(BUILD_DIR)/src/libleo/api/leoglobals.o" include "$(BUILD_DIR)/src/libleo/leo/leomotor.o" include "$(BUILD_DIR)/src/libleo/api/driveexist.o" include "$(BUILD_DIR)/src/libleo/leo/leomode_sel.o" @@ -903,10 +902,9 @@ beginseg include "$(BUILD_DIR)/src/libleo/leo/leotimer.o" include "$(BUILD_DIR)/src/libleo/api/getkadr.o" include "$(BUILD_DIR)/src/libleo/api/getaadr.o" - include "$(BUILD_DIR)/src/libleo/leo/leoglobals.o" include "$(BUILD_DIR)/src/libleo/leo/leowrite.o" include "$(BUILD_DIR)/src/libleo/api/cjcreateleomanager.o" - include "$(BUILD_DIR)/src/libleo/leo/leointerrupt.o" + include "$(BUILD_DIR)/src/libleo/api/leointerrupt.o" include "$(BUILD_DIR)/src/libleo/api/cacreateleomanager.o" include "$(BUILD_DIR)/src/libleo/api/testunitready.o" include "$(BUILD_DIR)/src/libleo/leo/leotestunit.o" diff --git a/src/audio/internal/effects.c b/src/audio/internal/effects.c index 066c62a3d69..08e19ec3630 100644 --- a/src/audio/internal/effects.c +++ b/src/audio/internal/effects.c @@ -273,8 +273,8 @@ f32 Audio_AdsrUpdate(AdsrState* adsr) { case ADSR_STATE_START_LOOP: adsr->envIndex = 0; adsr->action.s.state = ADSR_STATE_LOOP; - retry:; FALLTHROUGH; + retry:; case ADSR_STATE_LOOP: adsr->delay = adsr->envelope[adsr->envIndex].delay; switch (adsr->delay) { diff --git a/src/audio/internal/heap.c b/src/audio/internal/heap.c index 6b56fc67029..a865f95761b 100644 --- a/src/audio/internal/heap.c +++ b/src/audio/internal/heap.c @@ -1206,7 +1206,7 @@ void* AudioHeap_AllocPermanent(s32 tableType, s32 id, u32 size) { gAudioCtx.permanentCache[index].size = size; //! @bug UB: missing return. "ramAddr" is in v0 at this point, but doing an - //! explicit return uses an additional register. + // explicit return uses an additional register. #ifdef AVOID_UB return ramAddr; #endif diff --git a/src/boot/is_debug.c b/src/boot/is_debug.c index 1f903997e59..b4a5fdfd760 100644 --- a/src/boot/is_debug.c +++ b/src/boot/is_debug.c @@ -34,8 +34,6 @@ void osSyncPrintfUnused(const char* fmt, ...) { #if DEBUG_FEATURES _Printf(is_proutSyncPrintf, NULL, fmt, args); #endif - - va_end(args); } void osSyncPrintf(const char* fmt, ...) { @@ -45,8 +43,6 @@ void osSyncPrintf(const char* fmt, ...) { #if DEBUG_FEATURES _Printf(is_proutSyncPrintf, NULL, fmt, args); #endif - - va_end(args); } // assumption @@ -57,8 +53,6 @@ void rmonPrintf(const char* fmt, ...) { #if DEBUG_FEATURES _Printf(is_proutSyncPrintf, NULL, fmt, args); #endif - - va_end(args); } #if OOT_VERSION < PAL_1_0 diff --git a/src/boot/yaz0.c b/src/boot/yaz0.c index f3dcfc5f3ec..7a4da2a52d7 100644 --- a/src/boot/yaz0.c +++ b/src/boot/yaz0.c @@ -5,8 +5,8 @@ #include "ultra64.h" #include "dma.h" -#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ntsc-1.2:128" \ - "pal-1.1:128" +#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ntsc-1.2:0" \ + "pal-1.1:0" ALIGNED(16) u8 sYaz0DataBuffer[0x400]; u8* sYaz0DataBufferEnd; diff --git a/src/boot/z_std_dma.c b/src/boot/z_std_dma.c index b121c9427d0..2400b3e3486 100644 --- a/src/boot/z_std_dma.c +++ b/src/boot/z_std_dma.c @@ -46,8 +46,8 @@ #include "dma.h" #include "thread.h" -#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ntsc-1.2:82" \ - "pal-1.0:80 pal-1.1:80" +#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ntsc-1.2:102" \ + "pal-1.0:100 pal-1.1:100" StackEntry sDmaMgrStackInfo; OSMesgQueue sDmaMgrMsgQueue; @@ -339,7 +339,7 @@ const char* DmaMgr_FindFileName(UNUSED_NDEBUG uintptr_t vrom) { name++; } //! @bug Since there is no return, in case the file isn't found, the return value will be a pointer to the end - // of gDmaDataTable + //! of gDmaDataTable #ifdef AVOID_UB return ""; #endif diff --git a/src/buffers/gfxbuffers.c b/src/buffers/gfxbuffers.c index 1806570ae4a..83386e41268 100644 --- a/src/buffers/gfxbuffers.c +++ b/src/buffers/gfxbuffers.c @@ -3,6 +3,8 @@ #include "gfx.h" #include "ultra64.h" +#pragma increment_block_number "" + ALIGNED(16) u64 gGfxSPTaskOutputBuffer[0x3000]; ALIGNED(16) u64 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE / sizeof(u64)]; diff --git a/src/code/PreRender.c b/src/code/PreRender.c index 4e4525b27be..7d357a0a992 100644 --- a/src/code/PreRender.c +++ b/src/code/PreRender.c @@ -49,19 +49,19 @@ void PreRender_Destroy(PreRender* this) { /** * Copies RGBA16 image `img` to `imgDst` * - * @param gfxP Display list pointer + * @param gfxp Display list pointer * @param img Image to copy from * @param imgDst Buffer to copy to */ -void PreRender_CopyImage(PreRender* this, Gfx** gfxP, void* img, void* imgDst) { +void PreRender_CopyImage(PreRender* this, Gfx** gfxp, void* img, void* imgDst) { Gfx* gfx; s32 rowsRemaining; s32 curRow; s32 nRows; LOG_UTILS_CHECK_NULL_POINTER("this", this, "../PreRender.c", 215); - LOG_UTILS_CHECK_NULL_POINTER("glistpp", gfxP, "../PreRender.c", 216); - gfx = *gfxP; + LOG_UTILS_CHECK_NULL_POINTER("glistpp", gfxp, "../PreRender.c", 216); + gfx = *gfxp; LOG_UTILS_CHECK_NULL_POINTER("glistp", gfx, "../PreRender.c", 218); gDPPipeSync(gfx++); @@ -109,22 +109,22 @@ void PreRender_CopyImage(PreRender* this, Gfx** gfxP, void* img, void* imgDst) { gDPPipeSync(gfx++); gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->width, this->fbuf); - *gfxP = gfx; + *gfxp = gfx; } /** * Copies part of `this->fbufSave` in the region (this->ulx, this->uly), (this->lrx, this->lry) to the same location in * `this->fbuf`. */ -void PreRender_CopyImageRegionImpl(PreRender* this, Gfx** gfxP) { +void PreRender_CopyImageRegionImpl(PreRender* this, Gfx** gfxp) { Gfx* gfx; s32 rowsRemaining; s32 curRow; s32 nRows; LOG_UTILS_CHECK_NULL_POINTER("this", this, "../PreRender.c", 278); - LOG_UTILS_CHECK_NULL_POINTER("glistpp", gfxP, "../PreRender.c", 279); - gfx = *gfxP; + LOG_UTILS_CHECK_NULL_POINTER("glistpp", gfxp, "../PreRender.c", 279); + gfx = *gfxp; LOG_UTILS_CHECK_NULL_POINTER("glistp", gfx, "../PreRender.c", 281); gDPPipeSync(gfx++); @@ -176,22 +176,22 @@ void PreRender_CopyImageRegionImpl(PreRender* this, Gfx** gfxP) { gDPPipeSync(gfx++); gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->width, this->fbuf); gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, this->width, this->height); - *gfxP = gfx; + *gfxp = gfx; } /** * Copies `buf` to `bufSave`, discarding the alpha channel and modulating the RGB channel by * the color ('r', 'g', 'b', 'a') */ -void func_800C170C(PreRender* this, Gfx** gfxP, void* buf, void* bufSave, u32 r, u32 g, u32 b, u32 a) { +void func_800C170C(PreRender* this, Gfx** gfxp, void* buf, void* bufSave, u32 r, u32 g, u32 b, u32 a) { Gfx* gfx; s32 rowsRemaining; s32 curRow; s32 nRows; LOG_UTILS_CHECK_NULL_POINTER("this", this, "../PreRender.c", 343); - LOG_UTILS_CHECK_NULL_POINTER("glistpp", gfxP, "../PreRender.c", 344); - gfx = *gfxP; + LOG_UTILS_CHECK_NULL_POINTER("glistpp", gfxp, "../PreRender.c", 344); + gfx = *gfxp; LOG_UTILS_CHECK_NULL_POINTER("glistp", gfx, "../PreRender.c", 346); gDPPipeSync(gfx++); @@ -246,33 +246,33 @@ void func_800C170C(PreRender* this, Gfx** gfxP, void* buf, void* bufSave, u32 r, gDPPipeSync(gfx++); gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->width, this->fbuf); - *gfxP = gfx; + *gfxp = gfx; } /** * Copies `fbuf` to `fbufSave`, discarding the alpha channel and leaving the rgb channel unchanged */ -void func_800C1AE8(PreRender* this, Gfx** gfxP, void* fbuf, void* fbufSave) { - func_800C170C(this, gfxP, fbuf, fbufSave, 255, 255, 255, 255); +void func_800C1AE8(PreRender* this, Gfx** gfxp, void* fbuf, void* fbufSave) { + func_800C170C(this, gfxp, fbuf, fbufSave, 255, 255, 255, 255); } /** * Reads the coverage values stored in the RGBA16 format `img` with dimensions `this->width`, `this->height` and * converts it to an 8-bpp intensity image. * - * @param gfxP Display list pointer + * @param gfxp Display list pointer * @param img Image to read coverage from * @param cvgDst Buffer to store coverage into */ -void PreRender_CoverageRgba16ToI8(PreRender* this, Gfx** gfxP, void* img, void* cvgDst) { +void PreRender_CoverageRgba16ToI8(PreRender* this, Gfx** gfxp, void* img, void* cvgDst) { Gfx* gfx; s32 rowsRemaining; s32 curRow; s32 nRows; LOG_UTILS_CHECK_NULL_POINTER("this", this, "../PreRender.c", 422); - LOG_UTILS_CHECK_NULL_POINTER("glistpp", gfxP, "../PreRender.c", 423); - gfx = *gfxP; + LOG_UTILS_CHECK_NULL_POINTER("glistpp", gfxp, "../PreRender.c", 423); + gfx = *gfxp; LOG_UTILS_CHECK_NULL_POINTER("glistp", gfx, "../PreRender.c", 425); gDPPipeSync(gfx++); @@ -342,30 +342,30 @@ void PreRender_CoverageRgba16ToI8(PreRender* this, Gfx** gfxP, void* img, void* // Reset the color image to the current framebuffer gDPPipeSync(gfx++); gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->width, this->fbuf); - *gfxP = gfx; + *gfxp = gfx; } /** * Saves zbuf to zbufSave */ -void PreRender_SaveZBuffer(PreRender* this, Gfx** gfxP) { +void PreRender_SaveZBuffer(PreRender* this, Gfx** gfxp) { LOG_UTILS_CHECK_NULL_POINTER("this->zbuf_save", this->zbufSave, "../PreRender.c", 481); LOG_UTILS_CHECK_NULL_POINTER("this->zbuf", this->zbuf, "../PreRender.c", 482); if ((this->zbufSave != NULL) && (this->zbuf != NULL)) { - PreRender_CopyImage(this, gfxP, this->zbuf, this->zbufSave); + PreRender_CopyImage(this, gfxp, this->zbuf, this->zbufSave); } } /** * Saves fbuf to fbufSave */ -void PreRender_SaveFramebuffer(PreRender* this, Gfx** gfxP) { +void PreRender_SaveFramebuffer(PreRender* this, Gfx** gfxp) { LOG_UTILS_CHECK_NULL_POINTER("this->fbuf_save", this->fbufSave, "../PreRender.c", 495); LOG_UTILS_CHECK_NULL_POINTER("this->fbuf", this->fbuf, "../PreRender.c", 496); if ((this->fbufSave != NULL) && (this->fbuf != NULL)) { - func_800C1AE8(this, gfxP, this->fbuf, this->fbufSave); + func_800C1AE8(this, gfxp, this->fbuf, this->fbufSave); } } @@ -373,8 +373,8 @@ void PreRender_SaveFramebuffer(PreRender* this, Gfx** gfxP) { * Fetches the coverage of the current framebuffer into an image of the same format as the current color image, storing * it over the framebuffer in memory. */ -void PreRender_FetchFbufCoverage(PreRender* this, Gfx** gfxP) { - Gfx* gfx = *gfxP; +void PreRender_FetchFbufCoverage(PreRender* this, Gfx** gfxp) { + Gfx* gfx = *gfxp; gDPPipeSync(gfx++); // Set the blend color to full white and set maximum depth. @@ -408,26 +408,26 @@ void PreRender_FetchFbufCoverage(PreRender* this, Gfx** gfxP) { gDPFillRectangle(gfx++, 0, 0, this->width, this->height); gDPPipeSync(gfx++); - *gfxP = gfx; + *gfxp = gfx; } /** * Draws the coverage of the current framebuffer `this->fbuf` to an I8 image at `this->cvgSave`. Overwrites * `this->fbuf` in the process. */ -void PreRender_DrawCoverage(PreRender* this, Gfx** gfxP) { - PreRender_FetchFbufCoverage(this, gfxP); +void PreRender_DrawCoverage(PreRender* this, Gfx** gfxp) { + PreRender_FetchFbufCoverage(this, gfxp); LOG_UTILS_CHECK_NULL_POINTER("this->cvg_save", this->cvgSave, "../PreRender.c", 532); if (this->cvgSave != NULL) { - PreRender_CoverageRgba16ToI8(this, gfxP, this->fbuf, this->cvgSave); + PreRender_CoverageRgba16ToI8(this, gfxp, this->fbuf, this->cvgSave); } } /** * Restores zbufSave to zbuf */ -void PreRender_RestoreZBuffer(PreRender* this, Gfx** gfxP) { - PreRender_CopyImage(this, gfxP, this->zbufSave, this->zbuf); +void PreRender_RestoreZBuffer(PreRender* this, Gfx** gfxp) { + PreRender_CopyImage(this, gfxp, this->zbufSave, this->zbuf); } /** @@ -435,7 +435,7 @@ void PreRender_RestoreZBuffer(PreRender* this, Gfx** gfxP) { * the alpha channel from `this->cvgSave` modulated by environment color. The alpha channel becomes the framebuffer's * coverage content. */ -void func_800C213C(PreRender* this, Gfx** gfxP) { +void func_800C213C(PreRender* this, Gfx** gfxp) { Gfx* gfx; s32 rowsRemaining; s32 curRow; @@ -444,8 +444,8 @@ void func_800C213C(PreRender* this, Gfx** gfxP) { if (this->cvgSave != NULL) { LOG_UTILS_CHECK_NULL_POINTER("this", this, "../PreRender.c", 563); - LOG_UTILS_CHECK_NULL_POINTER("glistpp", gfxP, "../PreRender.c", 564); - gfx = *gfxP; + LOG_UTILS_CHECK_NULL_POINTER("glistpp", gfxp, "../PreRender.c", 564); + gfx = *gfxp; LOG_UTILS_CHECK_NULL_POINTER("glistp", gfx, "../PreRender.c", 566); gDPPipeSync(gfx++); @@ -511,23 +511,23 @@ void func_800C213C(PreRender* this, Gfx** gfxP) { #undef FB_ROWS gDPPipeSync(gfx++); - *gfxP = gfx; + *gfxp = gfx; } } /** * Copies fbufSave to fbuf */ -void PreRender_RestoreFramebuffer(PreRender* this, Gfx** gfxP) { - PreRender_CopyImage(this, gfxP, this->fbufSave, this->fbuf); +void PreRender_RestoreFramebuffer(PreRender* this, Gfx** gfxp) { + PreRender_CopyImage(this, gfxp, this->fbufSave, this->fbuf); } /** * Copies part of `this->fbufSave` in the region (this->ulx, this->uly), (this->lrx, this->lry) to the same location in * `this->fbuf`. */ -void PreRender_CopyImageRegion(PreRender* this, Gfx** gfxP) { - PreRender_CopyImageRegionImpl(this, gfxP); +void PreRender_CopyImageRegion(PreRender* this, Gfx** gfxp) { + PreRender_CopyImageRegionImpl(this, gfxp); } /** diff --git a/src/code/code_8006C510.c b/src/code/code_8006C510.c new file mode 100644 index 00000000000..76db897a4d9 --- /dev/null +++ b/src/code/code_8006C510.c @@ -0,0 +1,43 @@ +#include "ultra64.h" +#include "animation_curve.h" +#include "math.h" +#include "stack_pad.h" + +f32 func_8006C510(f32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5) { + STACK_PADS(s32, 7); + f32 sq = SQ(arg0); + f32 cube = sq * arg0; + + return (((cube + cube) - sq * 3.0f) + 1.0f) * arg2 + (sq * 3.0f - (cube + cube)) * arg3 + + ((cube - (sq + sq)) + arg0) * arg4 * arg1 + (cube - sq) * arg5 * arg1; +} + +f32 func_8006C5A8(f32 target, TransformData* transData, s32 refIdx) { + s32 i; + s32 j; + + if (target <= transData->unk_02) { + return transData->unk_08; + } + if (target >= transData[refIdx - 1].unk_02) { + return transData[refIdx - 1].unk_08; + } + + for (i = 0;; i++) { + j = i + 1; + if (transData[j].unk_02 > target) { + if (transData[i].unk_00 & 1) { + return transData[i].unk_08; + } else if (transData[i].unk_00 & 2) { + return transData[i].unk_08 + + ((target - (f32)transData[i].unk_02) / ((f32)transData[j].unk_02 - (f32)transData[i].unk_02)) * + (transData[j].unk_08 - transData[i].unk_08); + } else { + f32 diff = (f32)transData[j].unk_02 - (f32)transData[i].unk_02; + return func_8006C510((target - transData[i].unk_02) / ((f32)transData[j].unk_02 - transData[i].unk_02), + diff * (1.0f / 30.0f), transData[i].unk_08, transData[j].unk_08, + transData[i].unk_06, transData[j].unk_04); + } + } + } +} diff --git a/src/code/fault_gc.c b/src/code/fault_gc.c index e9586a8ddb8..efc1c9503a6 100644 --- a/src/code/fault_gc.c +++ b/src/code/fault_gc.c @@ -13,7 +13,7 @@ * When entering this button combination, buttons that are &'d together must all be pressed together. * The L & R presses and B & A presses may be interchanged in the order they are pressed. * - * "Clients" may be registered with the crash screen to extend its functionality. There are + * "Clients" may be registered with the crash screen to extend it's functionality. There are * two kinds of client, "Client" and "AddressConverterClient". Clients contribute one or * more pages to the crash debugger, while Address Converter Clients allow the crash screen to look up * the virtual addresses of dynamically allocated overlays. @@ -26,7 +26,7 @@ * be displayed next to the floating-point status register. * - Stack Trace * This page displays a full backtrace from the crashing function back to the start of the thread. It - * displays the Program Counter for each function and, if applicable, the Virtual Program Counter + * displays both the Program Counter for each function and if applicable the Virtual Program Counter * for relocated functions in overlays. * - Client Pages * After the stack trace page, currently registered clients are processed and their pages are displayed. @@ -41,8 +41,8 @@ * DPad-Down disables sending fault pages over osSyncPrintf. */ -#pragma increment_block_number "gc-eu:160 gc-eu-dbg:160 gc-eu-dbg-2:160 gc-eu-mq:160 gc-eu-mq-dbg:160 gc-jp:160" \ - "gc-jp-ce:160 gc-jp-mq:160 gc-us:160 gc-us-mq:160 ique-cn:160" +#pragma increment_block_number "gc-eu:96 gc-eu-dbg:96 gc-eu-dbg-2:96 gc-eu-mq:96 gc-eu-mq-dbg:96 gc-jp:96 gc-jp-ce:96" \ + "gc-jp-mq:96 gc-us:96 gc-us-mq:96 ique-cn:64" #include "libc64/sleep.h" #include "attributes.h" @@ -1024,7 +1024,7 @@ void Fault_WalkStack(uintptr_t* spPtr, uintptr_t* pcPtr, uintptr_t* raPtr) { return; } - // ensure pc is aligned and a valid pointer, if not a stack trace cannot + // ensure pc is aligned and a valid pointer, if not a tack trace cannot // be generated if (pc % 4 != 0 || !IS_KSEG0(pc)) { *pcPtr = ra; @@ -1157,7 +1157,7 @@ void Fault_DisplayFrameBuffer(void) { } /** - * Runs all registered fault clients. Each fault client displays a page + * Runs all registered fault client. Each fault client displays a page * on the crash screen. */ void Fault_ProcessClients(void) { diff --git a/src/code/fault_gc_drawer.c b/src/code/fault_gc_drawer.c index 9c2470b9b84..d08730d4f82 100644 --- a/src/code/fault_gc_drawer.c +++ b/src/code/fault_gc_drawer.c @@ -312,8 +312,6 @@ s32 Fault_Printf(const char* fmt, ...) { va_start(args, fmt); ret = Fault_VPrintf(fmt, args); - - va_end(args); return ret; } @@ -323,8 +321,6 @@ void Fault_DrawText(s32 x, s32 y, const char* fmt, ...) { Fault_SetCursor(x, y); Fault_VPrintf(fmt, args); - - va_end(args); } void Fault_SetDrawerFB(void* fb, u16 w, u16 h) { diff --git a/src/code/fault_n64.c b/src/code/fault_n64.c index d09c43196fe..e1bba7bf155 100644 --- a/src/code/fault_n64.c +++ b/src/code/fault_n64.c @@ -14,7 +14,7 @@ #include "thread.h" #include "translation.h" -#pragma increment_block_number "ntsc-1.0:144 ntsc-1.1:144 ntsc-1.2:144 pal-1.0:144 pal-1.1:144" +#pragma increment_block_number "ntsc-1.0:96 ntsc-1.1:96 ntsc-1.2:96 pal-1.0:96 pal-1.1:96" typedef struct FaultMgr { OSThread thread; diff --git a/src/code/game.c b/src/code/game.c index d5631508265..3b4be799926 100644 --- a/src/code/game.c +++ b/src/code/game.c @@ -161,7 +161,7 @@ void func_800C4344(UNUSED_NDEBUG GameState* gameState) { } #if DEBUG_FEATURES -void GameState_DrawInputDisplay(u16 input, Gfx** gfxP) { +void GameState_DrawInputDisplay(u16 input, Gfx** gfx) { static const u16 sInpDispBtnColors[] = { GPACK_RGBA5551(255, 255, 0, 1), GPACK_RGBA5551(255, 255, 0, 1), GPACK_RGBA5551(255, 255, 0, 1), GPACK_RGBA5551(255, 255, 0, 1), GPACK_RGBA5551(120, 120, 120, 1), GPACK_RGBA5551(120, 120, 120, 1), @@ -171,10 +171,10 @@ void GameState_DrawInputDisplay(u16 input, Gfx** gfxP) { GPACK_RGBA5551(0, 0, 255, 1), }; s32 i, j, k; - Gfx* gfx = *gfxP; + Gfx* gfxP = *gfx; - gDPPipeSync(gfx++); - gDPSetOtherMode(gfx++, + gDPPipeSync(gfxP++); + gDPSetOtherMode(gfxP++, 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_FILL | G_PM_NPRIMITIVE, G_AC_NONE | G_ZS_PIXEL | G_RM_NOOP | G_RM_NOOP2); @@ -182,14 +182,14 @@ void GameState_DrawInputDisplay(u16 input, Gfx** gfxP) { for (i = 0; i < 16; i++) { j = i; if (input & (1 << i)) { - gDPSetFillColor(gfx++, (sInpDispBtnColors[i] << 0x10) | sInpDispBtnColors[i]); + gDPSetFillColor(gfxP++, (sInpDispBtnColors[i] << 0x10) | sInpDispBtnColors[i]); k = i + 1; - gDPFillRectangle(gfx++, (j * 4) + 226, 220, (k * 4) + 225, 223); - gDPPipeSync(gfx++); + gDPFillRectangle(gfxP++, (j * 4) + 226, 220, (k * 4) + 225, 223); + gDPPipeSync(gfxP++); } } - *gfxP = gfx; + *gfx = gfxP; } #endif diff --git a/src/code/gfxalloc.c b/src/code/gfxalloc.c index 3b4d72f0574..82fb1d3bba0 100644 --- a/src/code/gfxalloc.c +++ b/src/code/gfxalloc.c @@ -10,17 +10,17 @@ Gfx* Gfx_Close(Gfx* gfx, Gfx* dst) { return dst; } -void* Gfx_Alloc(Gfx** gfxP, u32 size) { +void* Gfx_Alloc(Gfx** gfx, u32 size) { u8* ptr; Gfx* dst; size = ALIGN8(size); - ptr = (u8*)(*gfxP + 1); + ptr = (u8*)(*gfx + 1); dst = (Gfx*)(ptr + size); - gSPBranchList(*gfxP, dst); + gSPBranchList(*gfx, dst); - *gfxP = dst; + *gfx = dst; return ptr; } diff --git a/src/code/graph.c b/src/code/graph.c index 439220b11a1..e2fa1ba1875 100644 --- a/src/code/graph.c +++ b/src/code/graph.c @@ -35,8 +35,8 @@ #define GFXPOOL_HEAD_MAGIC 0x1234 #define GFXPOOL_TAIL_MAGIC 0x5678 -#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ique-cn:128" \ - "ntsc-1.0:224 ntsc-1.1:224 ntsc-1.2:224 pal-1.0:224 pal-1.1:224" +#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ique-cn:0" \ + "ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128" /** * The time at which the previous `Graph_Update` ended. diff --git a/src/code/main.c b/src/code/main.c index f693a5c4992..832b169f708 100644 --- a/src/code/main.c +++ b/src/code/main.c @@ -2,14 +2,14 @@ #include "ultra64.h" #include "versions.h" -#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ique-cn:0 ntsc-1.0:0 ntsc-1.1:0 ntsc-1.2:0 pal-1.0:0 pal-1.1:0" +#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ique-cn:0" \ + "ntsc-1.0:0 ntsc-1.1:0 ntsc-1.2:0 pal-1.0:0 pal-1.1:0" // Declared before including other headers for BSS ordering extern uintptr_t gSegments[NUM_SEGMENTS]; #pragma increment_block_number "gc-eu:252 gc-eu-mq:252 gc-jp:252 gc-jp-ce:252 gc-jp-mq:252 gc-us:252 gc-us-mq:252" \ - "ique-cn:252 ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128" + "ique-cn:252 ntsc-1.0:192 ntsc-1.1:192 ntsc-1.2:192 pal-1.0:192 pal-1.1:192" extern struct PreNmiBuff* gAppNmiBufferPtr; extern struct Scheduler gScheduler; @@ -44,7 +44,7 @@ extern struct IrqMgr gIrqMgr; #include "thread.h" #pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ique-cn:0 ntsc-1.0:51 ntsc-1.1:51 ntsc-1.2:51 pal-1.0:49 pal-1.1:49" + "ique-cn:128 ntsc-1.0:82 ntsc-1.1:82 ntsc-1.2:82 pal-1.0:80 pal-1.1:80" extern u8 _buffersSegmentEnd[]; diff --git a/src/code/sched.c b/src/code/sched.c index 9b9977742c0..7327b4a7c70 100644 --- a/src/code/sched.c +++ b/src/code/sched.c @@ -59,7 +59,7 @@ #define RDP_DONE_MSG 668 #define NOTIFY_MSG 670 // original name: ENTRY_MSG -#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" +#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0" OSTime sRSPGfxTimeStart; OSTime sRSPAudioTimeStart; diff --git a/src/code/sys_math3d.c b/src/code/sys_math3d.c index 70fe669a8ec..b9e3abe2cf4 100644 --- a/src/code/sys_math3d.c +++ b/src/code/sys_math3d.c @@ -8,8 +8,8 @@ #include "z_lib.h" #include "z_math.h" -#pragma increment_block_number "gc-eu:76 gc-eu-mq:76 gc-jp:76 gc-jp-ce:76 gc-jp-mq:76 gc-us:76 gc-us-mq:76 ique-cn:66" \ - "ntsc-1.0:64 ntsc-1.1:64 ntsc-1.2:64 pal-1.0:64 pal-1.1:64" +#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ique-cn:246" \ + "ntsc-1.0:240 ntsc-1.1:240 ntsc-1.2:240 pal-1.0:240 pal-1.1:240" s32 Math3D_LineVsLineClosestTwoPoints(Vec3f* lineAPointA, Vec3f* lineAPointB, Vec3f* lineBPointA, Vec3f* lineBPointB, Vec3f* lineAClosestToB, Vec3f* lineBClosestToA); diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 243dc7fbb75..d4026497d95 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -1444,7 +1444,7 @@ void Actor_UpdateBgCheckInfo(PlayState* play, Actor* actor, f32 wallCheckHeight, floorBgId = actor->floorBgId; if ((floorBgId != BGCHECK_SCENE) && (actor->bgCheckFlags & BGCHECKFLAG_GROUND)) { - DynaPolyActor_TransformCarriedActor(&play->colCtx, floorBgId, actor); + DynaPolyActor_TransformActorOnTop(&play->colCtx, floorBgId, actor); } if (flags & UPDBGCHECKINFO_FLAG_0) { @@ -4699,7 +4699,7 @@ s32 func_800354B4(PlayState* play, Actor* actor, f32 range, s16 arg3, s16 arg4, } } -void func_8003555C(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { +void func_8003555C(PlayState* play, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3) { Color_RGBA8 color1; Color_RGBA8 color2; @@ -4712,7 +4712,7 @@ void func_8003555C(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { color2.b = 50; //! @bug color1 and color2 alpha components not set before being passed on - EffectSsKiraKira_SpawnSmall(play, pos, velocity, accel, &color1, &color2); + EffectSsKiraKira_SpawnSmall(play, arg1, arg2, arg3, &color1, &color2); } Vec3f D_80116268 = { 0.0f, -1.5f, 0.0f }; @@ -4724,8 +4724,8 @@ Gfx gActorSetupXluDL[] = { gsSPEndDisplayList(), }; -void func_800355B8(PlayState* play, Vec3f* pos) { - func_8003555C(play, pos, &D_80116268, &D_80116274); +void func_800355B8(PlayState* play, Vec3f* arg1) { + func_8003555C(play, arg1, &D_80116268, &D_80116274); } u8 func_800355E4(PlayState* play, Collider* collider) { @@ -4831,8 +4831,8 @@ void func_80035844(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, s32 arg3) { /** * Spawns En_Part (Dissipating Flames) actor as a child of the given actor. */ -Actor* func_800358DC(Actor* actor, Vec3f* spawnPos, Vec3s* spawnRot, f32* arg3, s32 timer, UNUSED s16* arg5, - PlayState* play, s16 params, Gfx* dList) { +EnPart* func_800358DC(Actor* actor, Vec3f* spawnPos, Vec3s* spawnRot, f32* arg3, s32 timer, UNUSED s16* arg5, + PlayState* play, s16 params, Gfx* dList) { EnPart* spawnedEnPart; spawnedEnPart = (EnPart*)Actor_SpawnAsChild(&play->actorCtx, actor, play, ACTOR_EN_PART, spawnPos->x, spawnPos->y, @@ -4845,7 +4845,7 @@ Actor* func_800358DC(Actor* actor, Vec3f* spawnPos, Vec3s* spawnRot, f32* arg3, spawnedEnPart->timer = timer; spawnedEnPart->rotZ = arg3[1]; spawnedEnPart->rotZSpeed = arg3[2]; - return &spawnedEnPart->actor; + return spawnedEnPart; } return NULL; diff --git a/src/code/z_bg_collect.c b/src/code/z_bg_collect.c index 01114d835af..3fddb7d84de 100644 --- a/src/code/z_bg_collect.c +++ b/src/code/z_bg_collect.c @@ -8,9 +8,9 @@ #include "skin_matrix.h" /** - * Update the `carriedActor`'s position based on the dynapoly actor identified by `bgId`. + * Update the `actor`'s position based on the dynapoly actor identified by `bgId`. */ -void DynaPolyActor_UpdateCarriedActorPos(CollisionContext* colCtx, s32 bgId, Actor* carriedActor) { +void DynaPolyActor_UpdatePositionOnTop(CollisionContext* colCtx, s32 bgId, Actor* actor) { MtxF prevTransform; MtxF prevTransformInv; MtxF curTransform; @@ -35,12 +35,12 @@ void DynaPolyActor_UpdateCarriedActorPos(CollisionContext* colCtx, s32 bgId, Act colCtx->dyna.bgActors[bgId].curTransform.rot.z, colCtx->dyna.bgActors[bgId].curTransform.pos.x, colCtx->dyna.bgActors[bgId].curTransform.pos.y, colCtx->dyna.bgActors[bgId].curTransform.pos.z); - // Apply the movement of the dynapoly actor `bgId` over the last frame to the `carriedActor` position + // Apply the movement of the dynapoly actor `bgId` over the last frame to the `actor` position // pos = curTransform * prevTransformInv * pos // Note (curTransform * prevTransformInv) represents the transform relative to the previous frame - SkinMatrix_Vec3fMtxFMultXYZ(&prevTransformInv, &carriedActor->world.pos, &tempPos); + SkinMatrix_Vec3fMtxFMultXYZ(&prevTransformInv, &actor->world.pos, &tempPos); SkinMatrix_Vec3fMtxFMultXYZ(&curTransform, &tempPos, &pos); - carriedActor->world.pos = pos; + actor->world.pos = pos; #if DEBUG_FEATURES if (BGCHECK_XYZ_ABSMAX <= pos.x || pos.x <= -BGCHECK_XYZ_ABSMAX || BGCHECK_XYZ_ABSMAX <= pos.y || @@ -61,18 +61,18 @@ void DynaPolyActor_UpdateCarriedActorPos(CollisionContext* colCtx, s32 bgId, Act } /** - * Update the `carriedActor`'s Y rotation based on the dynapoly actor identified by `bgId`. + * Update the `actor`'s Y rotation based on the dynapoly actor identified by `bgId`. */ -void DynaPolyActor_UpdateCarriedActorRotY(CollisionContext* colCtx, s32 bgId, Actor* carriedActor) { +void DynaPolyActor_UpdateRotYOnTop(CollisionContext* colCtx, s32 bgId, Actor* actor) { if (DynaPoly_IsBgIdBgActor(bgId)) { s16 rotY = colCtx->dyna.bgActors[bgId].curTransform.rot.y - colCtx->dyna.bgActors[bgId].prevTransform.rot.y; - if (carriedActor->id == ACTOR_PLAYER) { - ((Player*)carriedActor)->yaw += rotY; + if (actor->id == ACTOR_PLAYER) { + ((Player*)actor)->yaw += rotY; } - carriedActor->shape.rot.y += rotY; - carriedActor->world.rot.y += rotY; + actor->shape.rot.y += rotY; + actor->world.rot.y += rotY; } } @@ -90,10 +90,10 @@ void func_80043334(CollisionContext* colCtx, Actor* actor, s32 bgId) { } /** - * Update the `carriedActor`'s position and Y rotation based on the dynapoly actor identified by `bgId`, according to + * Update the `actor`'s position and Y rotation based on the dynapoly actor identified by `bgId`, according to * the dynapoly actor's move flags (see `DYNA_TRANSFORM_POS` and `DYNA_TRANSFORM_ROT_Y`). */ -s32 DynaPolyActor_TransformCarriedActor(CollisionContext* colCtx, s32 bgId, Actor* carriedActor) { +s32 DynaPolyActor_TransformActorOnTop(CollisionContext* colCtx, s32 bgId, Actor* actor) { s32 result = false; DynaPolyActor* dynaActor; @@ -112,12 +112,12 @@ s32 DynaPolyActor_TransformCarriedActor(CollisionContext* colCtx, s32 bgId, Acto } if (dynaActor->transformFlags & DYNA_TRANSFORM_POS) { - DynaPolyActor_UpdateCarriedActorPos(colCtx, bgId, carriedActor); + DynaPolyActor_UpdatePositionOnTop(colCtx, bgId, actor); result = true; } if (dynaActor->transformFlags & DYNA_TRANSFORM_ROT_Y) { - DynaPolyActor_UpdateCarriedActorRotY(colCtx, bgId, carriedActor); + DynaPolyActor_UpdateRotYOnTop(colCtx, bgId, actor); result = true; } diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index a10f46184f7..4e36c90f15c 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -15,7 +15,8 @@ #include "player.h" #include "skin_matrix.h" -#pragma increment_block_number "ntsc-1.0:136 ntsc-1.1:136 ntsc-1.2:136" +#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ + "ique-cn:128 ntsc-1.0:60 ntsc-1.1:60 ntsc-1.2:60" u16 DynaSSNodeList_GetNextNodeIdx(DynaSSNodeList* nodeList); void BgCheck_GetStaticLookupIndicesFromPos(CollisionContext* colCtx, Vec3f* pos, Vec3i* sector); diff --git a/src/code/z_camera.c b/src/code/z_camera.c index 72d0c80ff01..79cf83f0a10 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -27,8 +27,8 @@ #include "save.h" #include "src/overlays/actors/ovl_En_Horse/z_en_horse.h" -#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ique-cn:64 ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128" +#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ique-cn:0" \ + "ntsc-1.0:0 ntsc-1.1:0 ntsc-1.2:0 pal-1.0:0 pal-1.1:0" s16 Camera_RequestSettingImpl(Camera* camera, s16 requestedSetting, s16 flags); s32 Camera_RequestModeImpl(Camera* camera, s16 requestedMode, u8 forceModeChange); @@ -3661,7 +3661,7 @@ s32 Camera_KeepOn3(Camera* camera) { } #pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ique-cn:128 ntsc-1.0:72 ntsc-1.1:72 ntsc-1.2:72 pal-1.0:72 pal-1.1:72" + "ique-cn:128 ntsc-1.0:123 ntsc-1.1:123 ntsc-1.2:123 pal-1.0:123 pal-1.1:123" s32 Camera_KeepOn4(Camera* camera) { static Vec3f sAtTarget; @@ -3675,7 +3675,7 @@ s32 Camera_KeepOn4(Camera* camera) { f32 temp_f0_2; CollisionPoly* spC0; VecGeo vecGeo; - VecGeo atToEyeDir; + UNUSED VecGeo atToEyeDir; VecGeo atToEyeNextDir; s16* itemType = &camera->data2; s16 atToEyeBasePitch; @@ -7476,7 +7476,7 @@ void Camera_Init(Camera* camera, UNUSED View* view, UNUSED CollisionContext* col s16 curUID; s16 j; - memset(camera, 0, sizeof(Camera)); + func_80106860(camera, 0, sizeof(*camera)); if (sInitRegs) { UNUSED_NDEBUG s32 i; diff --git a/src/code/z_collision_check.c b/src/code/z_collision_check.c index 2567c3b8630..e673aa4713a 100644 --- a/src/code/z_collision_check.c +++ b/src/code/z_collision_check.c @@ -18,8 +18,8 @@ #include "src/overlays/effects/ovl_Effect_Ss_HitMark/z_eff_ss_hitmark.h" #include "z_lib.h" -#pragma increment_block_number "gc-eu:192 gc-eu-mq:192 gc-jp:192 gc-jp-ce:192 gc-jp-mq:192 gc-us:192 gc-us-mq:192" \ - "ique-cn:192 ntsc-1.0:152 ntsc-1.1:152 ntsc-1.2:152 pal-1.0:152 pal-1.1:152" +#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ + "ique-cn:128 ntsc-1.0:80 ntsc-1.1:80 ntsc-1.2:80 pal-1.0:80 pal-1.1:80" typedef s32 (*ColChkResetFunc)(PlayState*, Collider*); typedef void (*ColChkApplyFunc)(PlayState*, CollisionCheckContext*, Collider*); diff --git a/src/code/z_demo.c b/src/code/z_demo.c index d9646fe323d..a4392d30c1f 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -1,5 +1,5 @@ -#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ique-cn:0" \ - "ntsc-1.0:0 ntsc-1.1:0 ntsc-1.2:0 pal-1.0:0 pal-1.1:0" +#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ + "ique-cn:128 ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128" #include "cutscene.h" @@ -167,7 +167,7 @@ u16 gCamEyePointAppliedFrame; u16 gCamAtPointAppliedFrame; #pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ique-cn:128 ntsc-1.0:0 ntsc-1.1:0 ntsc-1.2:0 pal-1.0:0 pal-1.1:0" + "ique-cn:128 ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128" // Cam ID to return to when a scripted cutscene is finished s16 sReturnToCamId; diff --git a/src/code/z_eff_blure.c b/src/code/z_eff_blure.c index 54ecb2233c2..1516c112d34 100644 --- a/src/code/z_eff_blure.c +++ b/src/code/z_eff_blure.c @@ -132,17 +132,23 @@ void EffectBlure_Init1(void* thisx, void* initParamsx) { EffectBlureInit1* initParams = (EffectBlureInit1*)initParamsx; if ((this != NULL) && (initParams != NULL)) { - s32 i; - EffectBlure_InitElements(this); - - for (i = 0; i < 4; i++) { - this->p1StartColor[i] = initParams->p1StartColor[i]; - this->p2StartColor[i] = initParams->p2StartColor[i]; - this->p1EndColor[i] = initParams->p1EndColor[i]; - this->p2EndColor[i] = initParams->p2EndColor[i]; - } - + this->p1StartColor.r = initParams->p1StartColor[0]; + this->p2StartColor.r = initParams->p2StartColor[0]; + this->p1EndColor.r = initParams->p1EndColor[0]; + this->p2EndColor.r = initParams->p2EndColor[0]; + this->p1StartColor.g = initParams->p1StartColor[1]; + this->p2StartColor.g = initParams->p2StartColor[1]; + this->p1EndColor.g = initParams->p1EndColor[1]; + this->p2EndColor.g = initParams->p2EndColor[1]; + this->p1StartColor.b = initParams->p1StartColor[2]; + this->p2StartColor.b = initParams->p2StartColor[2]; + this->p1EndColor.b = initParams->p1EndColor[2]; + this->p2EndColor.b = initParams->p2EndColor[2]; + this->p1StartColor.a = initParams->p1StartColor[3]; + this->p2StartColor.a = initParams->p2StartColor[3]; + this->p1EndColor.a = initParams->p1EndColor[3]; + this->p2EndColor.a = initParams->p2EndColor[3]; this->elemDuration = initParams->elemDuration; this->unkFlag = initParams->unkFlag; this->calcMode = initParams->calcMode; @@ -167,17 +173,23 @@ void EffectBlure_Init2(void* thisx, void* initParamsx) { EffectBlureInit2* initParams = (EffectBlureInit2*)initParamsx; if ((this != NULL) && (initParams != NULL)) { - s32 i; - EffectBlure_InitElements(this); - - for (i = 0; i < 4; i++) { - this->p1StartColor[i] = initParams->p1StartColor[i]; - this->p2StartColor[i] = initParams->p2StartColor[i]; - this->p1EndColor[i] = initParams->p1EndColor[i]; - this->p2EndColor[i] = initParams->p2EndColor[i]; - } - + this->p1StartColor.r = initParams->p1StartColor[0]; + this->p2StartColor.r = initParams->p2StartColor[0]; + this->p1EndColor.r = initParams->p1EndColor[0]; + this->p2EndColor.r = initParams->p2EndColor[0]; + this->p1StartColor.g = initParams->p1StartColor[1]; + this->p2StartColor.g = initParams->p2StartColor[1]; + this->p1EndColor.g = initParams->p1EndColor[1]; + this->p2EndColor.g = initParams->p2EndColor[1]; + this->p1StartColor.b = initParams->p1StartColor[2]; + this->p2StartColor.b = initParams->p2StartColor[2]; + this->p1EndColor.b = initParams->p1EndColor[2]; + this->p2EndColor.b = initParams->p2EndColor[2]; + this->p1StartColor.a = initParams->p1StartColor[3]; + this->p2StartColor.a = initParams->p2StartColor[3]; + this->p1EndColor.a = initParams->p1EndColor[3]; + this->p2EndColor.a = initParams->p2EndColor[3]; this->elemDuration = initParams->elemDuration; this->unkFlag = initParams->unkFlag; this->calcMode = initParams->calcMode; @@ -370,14 +382,14 @@ void EffectBlure_GetComputedValues(EffectBlure* this, s32 index, f32 ratio, Vec3 color1->r = color1->g = color1->b = color1->a = 255; color2->r = color2->g = color2->b = color2->a = 255; } else { - color1->r = EffectSs_LerpU8(this->p1StartColor[0], this->p1EndColor[0], ratio); - color1->g = EffectSs_LerpU8(this->p1StartColor[1], this->p1EndColor[1], ratio); - color1->b = EffectSs_LerpU8(this->p1StartColor[2], this->p1EndColor[2], ratio); - color1->a = EffectSs_LerpU8(this->p1StartColor[3], this->p1EndColor[3], ratio); - color2->r = EffectSs_LerpU8(this->p2StartColor[0], this->p2EndColor[0], ratio); - color2->g = EffectSs_LerpU8(this->p2StartColor[1], this->p2EndColor[1], ratio); - color2->b = EffectSs_LerpU8(this->p2StartColor[2], this->p2EndColor[2], ratio); - color2->a = EffectSs_LerpU8(this->p2StartColor[3], this->p2EndColor[3], ratio); + color1->r = EffectSs_LerpU8(this->p1StartColor.r, this->p1EndColor.r, ratio); + color1->g = EffectSs_LerpU8(this->p1StartColor.g, this->p1EndColor.g, ratio); + color1->b = EffectSs_LerpU8(this->p1StartColor.b, this->p1EndColor.b, ratio); + color1->a = EffectSs_LerpU8(this->p1StartColor.a, this->p1EndColor.a, ratio); + color2->r = EffectSs_LerpU8(this->p2StartColor.r, this->p2EndColor.r, ratio); + color2->g = EffectSs_LerpU8(this->p2StartColor.g, this->p2EndColor.g, ratio); + color2->b = EffectSs_LerpU8(this->p2StartColor.b, this->p2EndColor.b, ratio); + color2->a = EffectSs_LerpU8(this->p2StartColor.a, this->p2EndColor.a, ratio); } } @@ -1002,19 +1014,19 @@ void EffectBlure_Draw(void* thisx, GraphicsContext* gfxCtx) { vtx[j].v.flag = 0; vtx[j].v.tc[0] = 0; vtx[j].v.tc[1] = 0; - vtx[j].v.cn[0] = EffectSs_LerpU8(this->p1StartColor[0], this->p1EndColor[0], ratio); - vtx[j].v.cn[1] = EffectSs_LerpU8(this->p1StartColor[1], this->p1EndColor[1], ratio); - vtx[j].v.cn[2] = EffectSs_LerpU8(this->p1StartColor[2], this->p1EndColor[2], ratio); - vtx[j].v.cn[3] = EffectSs_LerpU8(this->p1StartColor[3], this->p1EndColor[3], ratio); + vtx[j].v.cn[0] = EffectSs_LerpU8(this->p1StartColor.r, this->p1EndColor.r, ratio); + vtx[j].v.cn[1] = EffectSs_LerpU8(this->p1StartColor.g, this->p1EndColor.g, ratio); + vtx[j].v.cn[2] = EffectSs_LerpU8(this->p1StartColor.b, this->p1EndColor.b, ratio); + vtx[j].v.cn[3] = EffectSs_LerpU8(this->p1StartColor.a, this->p1EndColor.a, ratio); j++; vtx[j].v.flag = 0; vtx[j].v.tc[0] = 0; vtx[j].v.tc[1] = 0; - vtx[j].v.cn[0] = EffectSs_LerpU8(this->p2StartColor[0], this->p2EndColor[0], ratio); - vtx[j].v.cn[1] = EffectSs_LerpU8(this->p2StartColor[1], this->p2EndColor[1], ratio); - vtx[j].v.cn[2] = EffectSs_LerpU8(this->p2StartColor[2], this->p2EndColor[2], ratio); - vtx[j].v.cn[3] = EffectSs_LerpU8(this->p2StartColor[3], this->p2EndColor[3], ratio); + vtx[j].v.cn[0] = EffectSs_LerpU8(this->p2StartColor.r, this->p2EndColor.r, ratio); + vtx[j].v.cn[1] = EffectSs_LerpU8(this->p2StartColor.g, this->p2EndColor.g, ratio); + vtx[j].v.cn[2] = EffectSs_LerpU8(this->p2StartColor.b, this->p2EndColor.b, ratio); + vtx[j].v.cn[3] = EffectSs_LerpU8(this->p2StartColor.a, this->p2EndColor.a, ratio); j++; } } diff --git a/src/code/z_fcurve_data.c b/src/code/z_fcurve_data.c deleted file mode 100644 index 774f4137f77..00000000000 --- a/src/code/z_fcurve_data.c +++ /dev/null @@ -1,84 +0,0 @@ -/** - * File: z_fcurve_data.c - * Description: Interpolation functions for use with Curve SkelAnime - */ -#include "curve.h" - -#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 - -/** - * 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 512314d7762..d05468f57c5 100644 --- a/src/code/z_fcurve_data_skelanime.c +++ b/src/code/z_fcurve_data_skelanime.c @@ -1,30 +1,5 @@ -/** - * @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 "animation.h" +#include "animation_curve.h" #include "gfx.h" #include "attributes.h" #include "printf.h" @@ -35,127 +10,96 @@ #include "translation.h" #include "zelda_arena.h" #include "actor.h" -#include "curve.h" #include "play_state.h" -void SkelCurve_Clear(SkelCurve* skelCurve) { +void SkelCurve_Clear(SkelAnimeCurve* skelCurve) { skelCurve->limbCount = 0; - skelCurve->skeleton = NULL; - skelCurve->animation = NULL; - skelCurve->curFrame = 0.0f; - skelCurve->playSpeed = 0.0f; - skelCurve->endFrame = 0.0f; + skelCurve->limbList = NULL; + skelCurve->transUpdIdx = NULL; + skelCurve->animCurFrame = 0.0f; + skelCurve->animSpeed = 0.0f; + skelCurve->animFinalFrame = 0.0f; skelCurve->unk_0C = 0.0f; - skelCurve->jointTable = NULL; + skelCurve->transforms = NULL; } -/** - * Initialises the SkelCurve struct and mallocs the joint table. - * - * @return bool always true - */ -s32 SkelCurve_Init(UNUSED PlayState* play, SkelCurve* skelCurve, CurveSkeletonHeader* skeletonHeaderSeg, - UNUSED CurveAnimationHeader* animation) { +s32 SkelCurve_Init(UNUSED PlayState* play, SkelAnimeCurve* skelCurve, SkelCurveLimbList* limbListSeg, + UNUSED TransformUpdateIndex* transUpdIdx) { STACK_PAD(s32); - CurveSkeletonHeader* skeletonHeader = SEGMENTED_TO_VIRTUAL(skeletonHeaderSeg); + SkelCurveLimbList* limbList = SEGMENTED_TO_VIRTUAL(limbListSeg); - skelCurve->limbCount = skeletonHeader->limbCount; - skelCurve->skeleton = SEGMENTED_TO_VIRTUAL(skeletonHeader->limbs); + skelCurve->limbCount = limbList->limbCount; + skelCurve->limbList = SEGMENTED_TO_VIRTUAL(limbList->limbs); - skelCurve->jointTable = - ZELDA_ARENA_MALLOC(sizeof(*skelCurve->jointTable) * skelCurve->limbCount, "../z_fcurve_data_skelanime.c", 125); - ASSERT(skelCurve->jointTable != NULL, "this->now_joint != NULL", "../z_fcurve_data_skelanime.c", 127); - skelCurve->curFrame = 0.0f; - return true; + skelCurve->transforms = + ZELDA_ARENA_MALLOC(sizeof(*skelCurve->transforms) * skelCurve->limbCount, "../z_fcurve_data_skelanime.c", 125); + ASSERT(skelCurve->transforms != NULL, "this->now_joint != NULL", "../z_fcurve_data_skelanime.c", 127); + skelCurve->animCurFrame = 0.0f; + return 1; } -/** - * Frees the joint table. - */ -void SkelCurve_Destroy(UNUSED PlayState* play, SkelCurve* skelCurve) { - if (skelCurve->jointTable != NULL) { - ZELDA_ARENA_FREE(skelCurve->jointTable, "../z_fcurve_data_skelanime.c", 146); +void SkelCurve_Destroy(UNUSED PlayState* play, SkelAnimeCurve* skelCurve) { + if (skelCurve->transforms != NULL) { + ZELDA_ARENA_FREE(skelCurve->transforms, "../z_fcurve_data_skelanime.c", 146); } } -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; +void SkelCurve_SetAnim(SkelAnimeCurve* skelCurve, TransformUpdateIndex* transUpdIdx, f32 arg2, f32 animFinalFrame, + f32 animCurFrame, f32 animSpeed) { + skelCurve->unk_0C = arg2 - skelCurve->animSpeed; + skelCurve->animFinalFrame = animFinalFrame; + skelCurve->animCurFrame = animCurFrame; + skelCurve->animSpeed = animSpeed; + skelCurve->transUpdIdx = transUpdIdx; } -typedef enum SkelCurveVecType { - /* 0 */ SKELCURVE_VEC_TYPE_SCALE, - /* 1 */ SKELCURVE_VEC_TYPE_ROTATION, - /* 2 */ SKELCURVE_VEC_TYPE_POSIITON, - /* 3 */ SKELCURVE_VEC_TYPE_MAX -} SkelCurveVecType; - -#define SKELCURVE_SCALE_SCALE 1024.0f -#define SKELCURVE_SCALE_POSITION 100 - -/** - * The only animation updating function. - * - * @return bool true when the animation has finished. - */ -s32 SkelCurve_Update(UNUSED PlayState* play, SkelCurve* skelCurve) { - s16* jointData; - u8* knotCounts; - CurveAnimationHeader* animation; - u16* constantData; - s32 curLimb; - s32 ret = false; - s32 coord; - CurveInterpKnot* startKnot; - s32 vecType; - - animation = SEGMENTED_TO_VIRTUAL(skelCurve->animation); - knotCounts = SEGMENTED_TO_VIRTUAL(animation->knotCounts); - startKnot = SEGMENTED_TO_VIRTUAL(animation->interpolationData); - constantData = SEGMENTED_TO_VIRTUAL(animation->constantData); - jointData = *skelCurve->jointTable; - - skelCurve->curFrame += skelCurve->playSpeed * R_UPDATE_RATE * 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; +s32 SkelCurve_Update(UNUSED PlayState* play, SkelAnimeCurve* skelCurve) { + s16* transforms; + u8* transformRefIdx; + TransformUpdateIndex* transformIndex; + u16* transformCopyValues; + s32 i; + s32 ret = 0; + s32 k; + TransformData* transData; + s32 j; + + transformIndex = SEGMENTED_TO_VIRTUAL(skelCurve->transUpdIdx); + transformRefIdx = SEGMENTED_TO_VIRTUAL(transformIndex->refIndex); + transData = SEGMENTED_TO_VIRTUAL(transformIndex->transformData); + transformCopyValues = SEGMENTED_TO_VIRTUAL(transformIndex->copyValues); + transforms = (s16*)skelCurve->transforms; + + skelCurve->animCurFrame += skelCurve->animSpeed * R_UPDATE_RATE * 0.5f; + + if ((skelCurve->animSpeed >= 0.0f && skelCurve->animCurFrame > skelCurve->animFinalFrame) || + (skelCurve->animSpeed < 0.0f && skelCurve->animCurFrame < skelCurve->animFinalFrame)) { + skelCurve->animCurFrame = skelCurve->animFinalFrame; + ret = 1; } - 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++) { + for (i = 0; i < skelCurve->limbCount; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 3; k++) { f32 transformValue; - if (*knotCounts == 0) { - transformValue = *constantData; - *jointData = transformValue; - constantData++; + if (*transformRefIdx == 0) { + transformValue = *transformCopyValues; + *transforms = transformValue; + transformCopyValues++; } else { - 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; + transformValue = func_8006C5A8(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; } } - knotCounts++; - jointData++; + transformRefIdx++; + transforms++; } } } @@ -163,36 +107,32 @@ s32 SkelCurve_Update(UNUSED PlayState* play, SkelCurve* skelCurve) { return ret; } -/** - * Recursively draws limbs with appropriate properties. - */ -void SkelCurve_DrawLimb(PlayState* play, s32 limbIndex, SkelCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw, - PostCurveLimbDraw postLimbDraw, s32 lod, void* data) { - SkelCurveLimb* limb = SEGMENTED_TO_VIRTUAL(skelCurve->skeleton[limbIndex]); +void SkelCurve_DrawLimb(PlayState* play, s32 limbIndex, SkelAnimeCurve* skelCurve, + OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, void* data) { + SkelCurveLimb* limb = SEGMENTED_TO_VIRTUAL(skelCurve->limbList[limbIndex]); OPEN_DISPS(play->state.gfxCtx, "../z_fcurve_data_skelanime.c", 279); Matrix_Push(); - if ((overrideLimbDraw == NULL) || - ((overrideLimbDraw != NULL) && overrideLimbDraw(play, skelCurve, limbIndex, data))) { + if (overrideLimbDraw == NULL || (overrideLimbDraw != NULL && overrideLimbDraw(play, skelCurve, limbIndex, data))) { Vec3f scale; Vec3s rot; Vec3f pos; Gfx* dList; - s16* jointData = skelCurve->jointTable[limbIndex]; - - 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]; + Vec3s* transform = (Vec3s*)&skelCurve->transforms[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; Matrix_TranslateRotateZYX(&pos, &rot); Matrix_Scale(scale.x, scale.y, scale.z, MTXMODE_APPLY); @@ -227,22 +167,22 @@ void SkelCurve_DrawLimb(PlayState* play, s32 limbIndex, SkelCurve* skelCurve, Ov postLimbDraw(play, skelCurve, limbIndex, data); } - if (limb->child != LIMB_DONE) { - SkelCurve_DrawLimb(play, limb->child, skelCurve, overrideLimbDraw, postLimbDraw, lod, data); + if (limb->firstChildIdx != LIMB_DONE) { + SkelCurve_DrawLimb(play, limb->firstChildIdx, skelCurve, overrideLimbDraw, postLimbDraw, lod, data); } Matrix_Pop(); - if (limb->sibling != LIMB_DONE) { - SkelCurve_DrawLimb(play, limb->sibling, skelCurve, overrideLimbDraw, postLimbDraw, lod, data); + if (limb->nextLimbIdx != LIMB_DONE) { + SkelCurve_DrawLimb(play, limb->nextLimbIdx, skelCurve, overrideLimbDraw, postLimbDraw, lod, data); } CLOSE_DISPS(play->state.gfxCtx, "../z_fcurve_data_skelanime.c", 371); } -void SkelCurve_Draw(UNUSED Actor* actor, PlayState* play, SkelCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw, - PostCurveLimbDraw postLimbDraw, s32 lod, void* data) { - if (skelCurve->jointTable != NULL) { +void SkelCurve_Draw(UNUSED Actor* actor, PlayState* play, SkelAnimeCurve* skelCurve, + OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, void* data) { + if (skelCurve->transforms != NULL) { SkelCurve_DrawLimb(play, 0, skelCurve, overrideLimbDraw, postLimbDraw, lod, data); } } diff --git a/src/code/z_kaleido_scope_call.c b/src/code/z_kaleido_scope_call.c index 406d384064a..f61b56fef0a 100644 --- a/src/code/z_kaleido_scope_call.c +++ b/src/code/z_kaleido_scope_call.c @@ -1,5 +1,5 @@ -#pragma increment_block_number "gc-eu:64 gc-eu-mq:64 gc-jp:64 gc-jp-ce:64 gc-jp-mq:64 gc-us:64 gc-us-mq:64 ique-cn:64" \ - "ntsc-1.0:80 ntsc-1.1:80 ntsc-1.2:80 pal-1.0:80 pal-1.1:80" +#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ique-cn:240" \ + "ntsc-1.0:0 ntsc-1.1:0 ntsc-1.2:0 pal-1.0:0 pal-1.1:0" #include "libu64/debug.h" #include "kaleido_manager.h" diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c index 5f1ff092c94..36ef1248374 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.c @@ -1,5 +1,5 @@ -#pragma increment_block_number "gc-eu:224 gc-eu-mq:224 gc-jp:224 gc-jp-ce:224 gc-jp-mq:224 gc-us:224 gc-us-mq:224" \ - "ique-cn:224 ntsc-1.0:0 ntsc-1.1:0 ntsc-1.2:0 pal-1.0:240 pal-1.1:240" +#pragma increment_block_number "gc-eu:160 gc-eu-mq:160 gc-jp:160 gc-jp-ce:160 gc-jp-mq:160 gc-us:160 gc-us-mq:160" \ + "ique-cn:160 ntsc-1.0:160 ntsc-1.1:160 ntsc-1.2:160 pal-1.0:160 pal-1.1:160" #include "libc64/qrand.h" #include "libu64/gfxprint.h" @@ -245,8 +245,8 @@ s16 sLightningFlashAlpha; s16 sSunDepthTestX; s16 sSunDepthTestY; -#pragma increment_block_number "gc-eu:224 gc-eu-mq:224 gc-jp:224 gc-jp-ce:224 gc-jp-mq:224 gc-us:224 gc-us-mq:224" \ - "ique-cn:224 ntsc-1.0:208 ntsc-1.1:208 ntsc-1.2:208 pal-1.0:224 pal-1.1:224" +#pragma increment_block_number "gc-eu:208 gc-eu-mq:208 gc-jp:208 gc-jp-ce:208 gc-jp-mq:208 gc-us:208 gc-us-mq:208" \ + "ique-cn:208 ntsc-1.0:224 ntsc-1.1:224 ntsc-1.2:224 pal-1.0:224 pal-1.1:224" LightNode* sNGameOverLightNode; LightInfo sNGameOverLightInfo; diff --git a/src/code/z_lib.c b/src/code/z_lib.c index b9aa15ca4bf..666198a2725 100644 --- a/src/code/z_lib.c +++ b/src/code/z_lib.c @@ -7,26 +7,11 @@ #include "rand.h" #include "sfx.h" -/** - * memset: sets `len` bytes to `val` starting at address `dest`. - * - * Unlike normal memset, - * - `dest` is a `u8*` already, - * - does not return `dest`, - * - the arguments are in a different order, - * - `val` is a `u8` instead of the standard `s32`. - * - * @see There are two other memsets in this codebase, memset(), MemSet() - * - * @param dest address to start at - * @param len number of bytes to write - * @param val value to write - */ -void Lib_MemSet(u8* dest, size_t len, u8 val) { - size_t i; +void Lib_MemSet(u8* dest, size_t size, u8 val) { + u32 i; // clang-format off - for (i = 0; i < len; i++) { *dest++ = val; } + for (i = 0; i < size; i++) { *dest++ = val; } // clang-format on } diff --git a/src/code/z_message.c b/src/code/z_message.c index bb7c7dbf452..cc85b49e5cc 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -27,8 +27,8 @@ #include "assets/textures/parameter_static/parameter_static.h" -#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ntsc-1.0:16" \ - "ntsc-1.1:16 ntsc-1.2:16 pal-1.0:0 pal-1.1:0" +#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ + "ntsc-1.0:32 ntsc-1.1:32 ntsc-1.2:32 pal-1.0:0 pal-1.1:0" #if !PLATFORM_IQUE #define MSG_BUF_DECODED (msgCtx->msgBufDecoded) diff --git a/src/code/z_play.c b/src/code/z_play.c index 91a4c9bf99e..c6c7d3c6866 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -82,7 +82,7 @@ #include #pragma increment_block_number "gc-eu:171 gc-eu-mq:171 gc-jp:171 gc-jp-ce:171 gc-jp-mq:171 gc-us:171 gc-us-mq:171" \ - "ique-cn:171 ntsc-1.0:50 ntsc-1.1:50 ntsc-1.2:50 pal-1.0:50 pal-1.1:50" + "ique-cn:171 ntsc-1.0:145 ntsc-1.1:145 ntsc-1.2:145 pal-1.0:145 pal-1.1:145" TransitionTile gTransitionTile; s32 gTransitionTileState; diff --git a/src/code/z_player_call.c b/src/code/z_player_call.c index 5838188ab6a..51cdc2374cf 100644 --- a/src/code/z_player_call.c +++ b/src/code/z_player_call.c @@ -9,7 +9,7 @@ ACTOR_FLAG_DRAW_CULLING_DISABLED | ACTOR_FLAG_UPDATE_DURING_OCARINA | ACTOR_FLAG_CAN_PRESS_SWITCHES) #pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ntsc-1.2:128 pal-1.1:128" + "ntsc-1.2:0 pal-1.1:0" void (*sPlayerCallInitFunc)(Actor* thisx, PlayState* play); void (*sPlayerCallDestroyFunc)(Actor* thisx, PlayState* play); diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index e76edd52d17..c8854417107 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -20,8 +20,8 @@ #include "assets/objects/object_link_boy/object_link_boy.h" #include "assets/objects/object_link_child/object_link_child.h" -#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 pal-1.0:0" \ - "pal-1.1:0" +#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ique-cn:128" \ + "pal-1.0:0 pal-1.1:0" typedef struct BowSlingshotStringData { /* 0x00 */ Gfx* dList; diff --git a/src/code/z_quake.c b/src/code/z_quake.c index 2f41f01664e..81c66002f20 100644 --- a/src/code/z_quake.c +++ b/src/code/z_quake.c @@ -176,7 +176,7 @@ QuakeRequest* Quake_RequestImpl(Camera* camera, u32 type) { s16 index = Quake_GetFreeIndex(); QuakeRequest* req = &sQuakeRequests[index]; - memset(req, 0, sizeof(QuakeRequest)); + func_80106860(req, 0, sizeof(QuakeRequest)); // memset req->cam = camera; req->camId = camera->camId; diff --git a/src/code/z_rcp.c b/src/code/z_rcp.c index 389b534557d..fa34a57caa2 100644 --- a/src/code/z_rcp.c +++ b/src/code/z_rcp.c @@ -952,8 +952,8 @@ Gfx* Gfx_SetupDL(Gfx* gfx, u32 i) { return Gfx_SetupDLImpl(gfx, i); } -void Gfx_SetupDLAtPtr(Gfx** gfxP, u32 i) { - *gfxP = Gfx_SetupDL(*gfxP, i); +void Gfx_SetupDLAtPtr(Gfx** gfxp, u32 i) { + *gfxp = Gfx_SetupDL(*gfxp, i); } Gfx* Gfx_SetupDL_57(Gfx* gfx) { @@ -1238,11 +1238,11 @@ void Gfx_SetupDL_39Overlay(GraphicsContext* gfxCtx) { CLOSE_DISPS(gfxCtx, "../z_rcp.c", 1811); } -void Gfx_SetupDL_39Ptr(Gfx** gfxP) { - Gfx* gfx = *gfxP; +void Gfx_SetupDL_39Ptr(Gfx** gfxp) { + Gfx* gfx = *gfxp; gSPDisplayList(gfx++, sSetupDL[SETUPDL_39]); - *gfxP = gfx; + *gfxp = gfx; } void Gfx_SetupDL_40Opa(GraphicsContext* gfxCtx) { @@ -1400,12 +1400,12 @@ void Gfx_SetupDL_56Opa(GraphicsContext* gfxCtx) { CLOSE_DISPS(gfxCtx, "../z_rcp.c", 2090); } -void Gfx_SetupDL_56Ptr(Gfx** gfxP) { - Gfx* gfx = *gfxP; +void Gfx_SetupDL_56Ptr(Gfx** gfxp) { + Gfx* gfx = *gfxp; gSPDisplayList(gfx++, sSetupDL[SETUPDL_56]); - *gfxP = gfx; + *gfxp = gfx; } void Gfx_SetupDL_59Opa(GraphicsContext* gfxCtx) { @@ -1416,8 +1416,8 @@ void Gfx_SetupDL_59Opa(GraphicsContext* gfxCtx) { CLOSE_DISPS(gfxCtx, "../z_rcp.c", 2116); } -Gfx* Gfx_BranchTexScroll(Gfx** gfxP, u32 x, u32 y, s32 width, s32 height) { - Gfx* displayList = Gfx_Alloc(gfxP, 3 * sizeof(Gfx)); +Gfx* Gfx_BranchTexScroll(Gfx** gfxp, u32 x, u32 y, s32 width, s32 height) { + Gfx* displayList = Gfx_Alloc(gfxp, 3 * sizeof(Gfx)); gDPTileSync(displayList); gDPSetTileSize(displayList + 1, G_TX_RENDERTILE, x, y, x + ((width - 1) << 2), y + ((height - 1) << 2)); @@ -1426,8 +1426,8 @@ Gfx* Gfx_BranchTexScroll(Gfx** gfxP, u32 x, u32 y, s32 width, s32 height) { return displayList; } -Gfx* func_80094E54(Gfx** gfxP, u32 x, u32 y) { - return Gfx_BranchTexScroll(gfxP, x, y, 0, 0); +Gfx* func_80094E54(Gfx** gfxp, u32 x, u32 y) { + return Gfx_BranchTexScroll(gfxp, x, y, 0, 0); } Gfx* func_80094E78(GraphicsContext* gfxCtx, u32 x, u32 y) { diff --git a/src/code/z_room.c b/src/code/z_room.c index be7806f3d09..31e44eeb2ba 100644 --- a/src/code/z_room.c +++ b/src/code/z_room.c @@ -120,7 +120,7 @@ typedef enum RoomCullableDebugMode { typedef struct RoomShapeCullableEntryLinked { /* 0x00 */ RoomShapeCullableEntry* entry; - /* 0x04 */ f32 boundsNearZ; + /* 0x04 */ f32 startZ; /* 0x08 */ struct RoomShapeCullableEntryLinked* prev; /* 0x0C */ struct RoomShapeCullableEntryLinked* next; } RoomShapeCullableEntryLinked; // size = 0x10 @@ -129,10 +129,10 @@ typedef struct RoomShapeCullableEntryLinked { * Handle room drawing for the "cullable" type of room shape. * * Each entry referenced by the room shape struct is attached to display lists, and a position and radius indicating the - * bounding sphere for the geometry drawn. - * The first step Z-sorts the entries, and excludes the entries with a bounding sphere that is entirely before or + * volume those display lists take. + * The first step is Z-sorting the entries, also excluding the entries which bounding sphere is entirely before or * beyond the rendered depth range. - * The second step draws the entries that remain, from nearest to furthest. + * The second step is drawing the entries that remain, in ascending depth. */ void Room_DrawCullable(PlayState* play, Room* room, u32 flags) { RoomShapeCullable* roomShape; @@ -151,7 +151,7 @@ void Room_DrawCullable(PlayState* play, Room* room, u32 flags) { STACK_PAD(s32); RoomShapeCullableEntry* roomShapeCullableEntries; RoomShapeCullableEntry* roomShapeCullableEntryIter; - f32 entryBoundsNearZ; + f32 entryStartZ; OPEN_DISPS(play->state.gfxCtx, "../z_room.c", 287); @@ -189,27 +189,27 @@ void Room_DrawCullable(PlayState* play, Room* room, u32 flags) { pos.z = roomShapeCullableEntry->boundsSphereCenter.z; SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &pos, &projectedPos, &projectedW); - // If the entry bounding sphere isn't fully before the rendered depth range + // If the entry isn't fully before the rendered depth range if (-(f32)roomShapeCullableEntry->boundsSphereRadius < projectedPos.z) { - // Compute the depth of the nearest point in the entry's bounding sphere - entryBoundsNearZ = projectedPos.z - roomShapeCullableEntry->boundsSphereRadius; + // Compute the depth at which this entry starts + entryStartZ = projectedPos.z - roomShapeCullableEntry->boundsSphereRadius; - // If the entry bounding sphere isn't fully beyond the rendered depth range - if (entryBoundsNearZ < play->lightCtx.zFar) { + // If the entry isn't fully beyond the rendered depth range + if (entryStartZ < play->lightCtx.zFar) { // This entry will be rendered insert->entry = roomShapeCullableEntry; - insert->boundsNearZ = entryBoundsNearZ; + insert->startZ = entryStartZ; - // Insert into the linked list, ordered by ascending depth of the nearest point in the bounding sphere + // Insert into the linked list, ordered by ascending start depth iter = head; if (iter == NULL) { head = tail = insert; insert->prev = insert->next = NULL; } else { do { - if (insert->boundsNearZ < iter->boundsNearZ) { + if (insert->startZ < iter->startZ) { break; } iter = iter->next; @@ -421,10 +421,9 @@ void Room_DrawImageSingle(PlayState* play, Room* room, u32 flags) { isFixedCamera = (activeCam->setting == CAM_SET_PREREND_FIXED); roomShape = &room->roomShape->image.single; entry = SEGMENTED_TO_VIRTUAL(roomShape->base.entry); - drawBackground = (flags & ROOM_DRAW_OPA) && isFixedCamera && (roomShape->source != NULL) && - !(R_ROOM_IMAGE_NODRAW_FLAGS & ROOM_IMAGE_NODRAW_BACKGROUND); - drawOpa = (flags & ROOM_DRAW_OPA) && (entry->opa != NULL) && !(R_ROOM_IMAGE_NODRAW_FLAGS & ROOM_IMAGE_NODRAW_OPA); - drawXlu = (flags & ROOM_DRAW_XLU) && (entry->xlu != NULL) && !(R_ROOM_IMAGE_NODRAW_FLAGS & ROOM_IMAGE_NODRAW_XLU); + drawBackground = (flags & 1) && isFixedCamera && (roomShape->source != NULL) && !(SREG(25) & 1); + drawOpa = (flags & 1) && entry->opa != NULL && !(SREG(25) & 2); + drawXlu = (flags & 2) && entry->xlu != NULL && !(SREG(25) & 4); if (drawOpa || drawBackground) { gSPSegment(POLY_OPA_DISP++, 0x03, room->segment); @@ -711,7 +710,7 @@ s32 Room_RequestNewRoom(PlayState* play, RoomContext* roomCtx, s32 roomNum) { ASSERT(roomNum < play->roomList.count, "read_room_ID < game_play->room_rom_address.num", "../z_room.c", 1009); size = play->roomList.romFiles[roomNum].vromEnd - play->roomList.romFiles[roomNum].vromStart; - roomCtx->roomRequestAddr = (void*)ALIGN16((uintptr_t)roomCtx->bufPtrs[roomCtx->activeBufPage] - + roomCtx->roomRequestAddr = (void*)ALIGN16((intptr_t)roomCtx->bufPtrs[roomCtx->activeBufPage] - ((size + 8) * roomCtx->activeBufPage + 7)); osCreateMesgQueue(&roomCtx->loadQueue, &roomCtx->loadMsg, 1); diff --git a/src/code/z_view.c b/src/code/z_view.c index f996f8f78bf..2d3e435e476 100644 --- a/src/code/z_view.c +++ b/src/code/z_view.c @@ -42,7 +42,7 @@ View* View_New(GraphicsContext* gfxCtx) { View* view = SYSTEM_ARENA_MALLOC(sizeof(View), "../z_view.c", 285); if (view != NULL) { - memset(view, 0, sizeof(View)); + func_80106860(view, 0, sizeof(View)); // memset View_Init(view, gfxCtx); } @@ -570,8 +570,8 @@ s32 View_UpdateViewingMatrix(View* view) { return 1; } -s32 View_ApplyTo(View* view, s32 mask, Gfx** gfxP) { - Gfx* gfx = *gfxP; +s32 View_ApplyTo(View* view, s32 mask, Gfx** gfxp) { + Gfx* gfx = *gfxp; GraphicsContext* gfxCtx = view->gfxCtx; s32 width; s32 height; @@ -638,7 +638,7 @@ s32 View_ApplyTo(View* view, s32 mask, Gfx** gfxP) { } view->flags = 0; - *gfxP = gfx; + *gfxp = gfx; return 1; } diff --git a/src/code/z_vr_box_draw.c b/src/code/z_vr_box_draw.c index 8f41ca6002b..90ccd0f6210 100644 --- a/src/code/z_vr_box_draw.c +++ b/src/code/z_vr_box_draw.c @@ -23,9 +23,9 @@ void Skybox_Draw(SkyboxContext* skyboxCtx, GraphicsContext* gfxCtx, s16 skyboxId Gfx_SetupDL_40Opa(gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x7, skyboxCtx->staticSegments[0]); - gSPSegment(POLY_OPA_DISP++, 0x8, skyboxCtx->staticSegments[1]); - gSPSegment(POLY_OPA_DISP++, 0x9, skyboxCtx->palettes); + gSPSegment(POLY_OPA_DISP++, 7, skyboxCtx->staticSegments[0]); + gSPSegment(POLY_OPA_DISP++, 8, skyboxCtx->staticSegments[1]); + gSPSegment(POLY_OPA_DISP++, 9, skyboxCtx->palettes); gDPSetPrimColor(POLY_OPA_DISP++, 0x00, 0x00, 0, 0, 0, blend); gSPTexture(POLY_OPA_DISP++, 0x8000, 0x8000, 0, G_TX_RENDERTILE, G_ON); diff --git a/src/libc/code_80106860.c b/src/libc/code_80106860.c new file mode 100644 index 00000000000..5c8fee0d831 --- /dev/null +++ b/src/libc/code_80106860.c @@ -0,0 +1,12 @@ +#include "string.h" + +// memset used in __osMalloc, z_quake, z_view, and z_camera +void* func_80106860(void* ptr, int val, size_t size) { + char* sp4 = ptr; + register int a3; + + for (a3 = size--; a3 != 0; a3 = size--) { + *sp4++ = val; + } + return ptr; +} diff --git a/src/libc/code_801068B0.c b/src/libc/code_801068B0.c new file mode 100644 index 00000000000..397389577ec --- /dev/null +++ b/src/libc/code_801068B0.c @@ -0,0 +1,23 @@ +#include "string.h" + +// memmove used in __osMalloc.c +void* func_801068B0(void* dst, void* src, size_t size) { + char* spC = dst; + char* sp8 = src; + + if (spC == sp8) { + return dst; + } + if (spC < sp8) { + while (size--) { + *spC++ = *sp8++; + } + } else { + spC += size - 1; + sp8 += size - 1; + while (size--) { + *spC-- = *sp8--; + } + } + return dst; +} diff --git a/src/libc/fmodf.c b/src/libc/fmodf.c index 4ebec43bdc1..e414ba2b623 100644 --- a/src/libc/fmodf.c +++ b/src/libc/fmodf.c @@ -1,27 +1,12 @@ #include "ultra64.h" -/** - * Computes one `x` modulo `y` for floats. - * - * Acts like the standard C fmodf except does not handle Infinity. See https://en.cppreference.com/w/c/numeric/math/fmod - * for the details. It summarizes this function as follows: - * "The floating-point remainder of the division operation x/y calculated by this function is exactly the value x - n*y, - * where n is x/y with its fractional part truncated. - * - * The returned value has the same sign as x and is less or equal to y in magnitude." - * - * @param x dividend - * @param y modulus - * - * @return f32 0.0f if y is 0.0f, or x modulo y otherwise - */ f32 fmodf(f32 x, f32 y) { - s32 n; + s32 quot; if (y == 0.0f) { return 0.0f; } - n = x / y; + quot = x / y; - return x - (n * y); + return x - (quot * y); } diff --git a/src/libc/memmove.c b/src/libc/memmove.c deleted file mode 100644 index 302981f5801..00000000000 --- a/src/libc/memmove.c +++ /dev/null @@ -1,33 +0,0 @@ -#include "string.h" - -/** - * memmove: copies `len` bytes from memory starting at `src` to memory starting at `dest`. - * - * Unlike memcpy(), the regions of memory may overlap. - * - * @param dest address of start of buffer to write to - * @param src address of start of buffer to read from - * @param len number of bytes to copy. - * - * @return dest - */ -void* memmove(void* dest, const void* src, size_t len) { - char* d = dest; - const char* s = src; - - if (d == s) { - return dest; - } - if (d < s) { - while (len--) { - *d++ = *s++; - } - } else { - d += len - 1; - s += len - 1; - while (len--) { - *d-- = *s--; - } - } - return dest; -} diff --git a/src/libc/memset.c b/src/libc/memset.c deleted file mode 100644 index 31dba02ed89..00000000000 --- a/src/libc/memset.c +++ /dev/null @@ -1,21 +0,0 @@ -#include "string.h" - -/** - * memset: sets `len` bytes to `val` starting at address `dest`. - * - * @see There are two other memsets in this codebase, Lib_MemSet(), MemSet() - * - * @param dest address to start at - * @param val value to write (int, but interpreted as u8) - * @param len number of bytes to write - * - * @return dest - */ -void* memset(void* dest, int val, size_t len) { - char* ptr = dest; - - while (len--) { - *ptr++ = val; - } - return dest; -} diff --git a/src/libc64/__osMalloc_gc.c b/src/libc64/__osMalloc_gc.c index a1619e90a3c..57814870b92 100644 --- a/src/libc64/__osMalloc_gc.c +++ b/src/libc64/__osMalloc_gc.c @@ -30,19 +30,19 @@ #define SET_DEBUG_INFO(node, file, line, arena) ArenaImpl_SetDebugInfo(node, file, line, arena) -#define FILL_UNINIT_BLOCK(arena, node, size) memset(node, BLOCK_UNINIT_MAGIC, size) +#define FILL_UNINIT_BLOCK(arena, node, size) func_80106860(node, BLOCK_UNINIT_MAGIC, size) // memset #define FILL_ALLOC_BLOCK(arena, alloc, size) \ if ((arena)->flag & FILL_ALLOC_BLOCK_FLAG) \ - memset(alloc, BLOCK_ALLOC_MAGIC, size) + func_80106860(alloc, BLOCK_ALLOC_MAGIC, size) #define FILL_FREE_BLOCK_HEADER(arena, node) \ if ((arena)->flag & FILL_FREE_BLOCK_FLAG) \ - memset(node, BLOCK_FREE_MAGIC, sizeof(ArenaNode)) + func_80106860(node, BLOCK_FREE_MAGIC, sizeof(ArenaNode)) #define FILL_FREE_BLOCK_CONTENTS(arena, node) \ if ((arena)->flag & FILL_FREE_BLOCK_FLAG) \ - memset((void*)((u32)(node) + sizeof(ArenaNode)), BLOCK_FREE_MAGIC, (node)->size) + func_80106860((void*)((u32)(node) + sizeof(ArenaNode)), BLOCK_FREE_MAGIC, (node)->size) #define CHECK_FREE_BLOCK(arena, node) \ if ((arena)->flag & CHECK_FREE_BLOCK_FLAG) \ @@ -224,7 +224,7 @@ void ArenaImpl_RemoveAllBlocks(Arena* arena) { iter = arena->head; while (iter != NULL) { next = NODE_GET_NEXT(iter); - memset(iter, BLOCK_UNINIT_MAGIC, iter->size + sizeof(ArenaNode)); + func_80106860(iter, BLOCK_UNINIT_MAGIC, iter->size + sizeof(ArenaNode)); // memset iter = next; } @@ -655,7 +655,7 @@ void* __osRealloc(Arena* arena, void* ptr, u32 newSize) { } node->next = newNext; node->size = newSize; - memmove(node->next, next, sizeof(ArenaNode)); + func_801068B0(node->next, next, sizeof(ArenaNode)); // memcpy } else { osSyncPrintf(T("新たにメモリブロックを確保して内容を移動します\n", "Allocate a new memory block and move the contents\n")); diff --git a/src/libc64/__osMalloc_n64.c b/src/libc64/__osMalloc_n64.c index 6b81212963d..0d154db8cd1 100644 --- a/src/libc64/__osMalloc_n64.c +++ b/src/libc64/__osMalloc_n64.c @@ -404,7 +404,7 @@ void* __osRealloc(Arena* arena, void* ptr, u32 newSize) { } node->next = newNext; node->size = newSize; - memmove(node->next, next, sizeof(ArenaNode)); + func_801068B0(node->next, next, sizeof(ArenaNode)); } else { newAlloc = __osMalloc(arena, newSize); if (newAlloc != NULL) { diff --git a/src/libc64/aprintf.c b/src/libc64/aprintf.c index 44cedac9757..73f3622734b 100644 --- a/src/libc64/aprintf.c +++ b/src/libc64/aprintf.c @@ -6,13 +6,8 @@ s32 PrintUtils_VPrintf(PrintCallback* pfn, const char* fmt, va_list args) { } s32 PrintUtils_Printf(PrintCallback* pfn, const char* fmt, ...) { - s32 ret; va_list args; va_start(args, fmt); - ret = PrintUtils_VPrintf(pfn, fmt, args); - - va_end(args); - - return ret; + return PrintUtils_VPrintf(pfn, fmt, args); } diff --git a/src/libc64/sprintf.c b/src/libc64/sprintf.c index 12286697c99..6b5010c0e85 100644 --- a/src/libc64/sprintf.c +++ b/src/libc64/sprintf.c @@ -30,8 +30,5 @@ int sprintf(char* dst, const char* fmt, ...) { if (ret > -1) { dst[ret] = '\0'; } - - va_end(args); - return ret; } diff --git a/src/libleo/api/bytetolba.c b/src/libleo/api/bytetolba.c index 9b25ac840f0..4e6db7bca84 100644 --- a/src/libleo/api/bytetolba.c +++ b/src/libleo/api/bytetolba.c @@ -1,7 +1,5 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" s32 LeoByteToLBA(s32 startlba, u32 nbytes, s32* lba) { u32 reslba; diff --git a/src/libleo/api/cacreateleomanager.c b/src/libleo/api/cacreateleomanager.c index 41464938739..ce17f460fca 100644 --- a/src/libleo/api/cacreateleomanager.c +++ b/src/libleo/api/cacreateleomanager.c @@ -1,83 +1,66 @@ +#include "ultra64.h" #include "ultra64/asm.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" -#include "stdint.h" +#include "ultra64/leo_internal.h" #include "attributes.h" -#include "ultra64.h" - -s32 LeoCACreateLeoManager(s32 comPri, s32 intPri, OSMesg* cmdBuf, s32 cmdMsgCnt) { +s32 LeoCACreateLeoManager(s32 comPri, s32 intPri, void** cmdBuf, s32 cmdMsgCnt) { OSPiHandle* driveRomHandle; UNUSED OSPiHandle* leoDiskHandle; volatile LEOCmdInquiry cmdBlockInq; UNUSED volatile LEOCmd cmdBlockID; UNUSED LEODiskID thisID; - u32 stat; + UNUSED u32 stat; u32 data; if (__leoActive) { return LEO_ERROR_GOOD; } - - if (!LeoDriveExist()) { + if (LeoDriveExist() == 0) { return LEO_ERROR_DEVICE_COMMUNICATION_FAILURE; } - - leoDiskHandle = osLeoDiskInit(); + osLeoDiskInit(); driveRomHandle = osDriveRomInit(); __leoActive = true; - - __osSetHWIntrRoutine(OS_INTR_CART, __osLeoInterrupt, (u8*)STACK_TOP(leoDiskStack) - FRAMESZ(SZREG * NARGSAVE)); - leoInitialize(comPri, intPri, cmdBuf, cmdMsgCnt); - - if (osResetType == 1) { // NMI + __osSetHWIntrRoutine(OS_INTR_CART, __osLeoInterrupt, STACK_TOP(leoDiskStack) - FRAMESZ(SZREG * NARGSAVE)); + leoInitialize(comPri, intPri, cmdBuf, (u32)cmdMsgCnt); + if (osResetType == 1) { __leoSetReset(); } - - cmdBlockInq.header.command = 2; + cmdBlockInq.header.command = LEO_COMMAND_INQUIRY; cmdBlockInq.header.reserve1 = 0; cmdBlockInq.header.control = 0; cmdBlockInq.header.reserve3 = 0; leoCommand((void*)&cmdBlockInq); - { - volatile s32 dummy = (uintptr_t)__osSetHWIntrRoutine & 0xA48D3C; + vs32 dummy = (u32)__osSetHWIntrRoutine & 0xA48D3C; while (dummy < 0xE00000) { - dummy += (((uintptr_t)leoCommand & 0xFF) | 0x8A) << 0x10; + dummy += (((s32)leoCommand & 0xFF) | 0x8A) << 16; } } - - while (cmdBlockInq.header.status == 8) {} - + while (cmdBlockInq.header.status == LEO_STATUS_BUSY) {} if (cmdBlockInq.header.status != 0) { - return GET_ERROR(cmdBlockInq); + return cmdBlockInq.header.sense; } - - __leoVersion.driver = cmdBlockInq.version; - __leoVersion.drive = 6; - __leoVersion.deviceType = cmdBlockInq.devType; - __leoVersion.nDevices = cmdBlockInq.devNum; - - stat = __leoVersion.driver & 0xF; - if (stat == 4) { + __leoVersion.drive = cmdBlockInq.version; + __leoVersion.driver = 6; + __leoVersion.deviceType = cmdBlockInq.dev_type; + __leoVersion.ndevices = cmdBlockInq.dev_num; + if ((__leoVersion.drive & 0xF) == 4) { LEO_country_code = 0; - } else if ((stat == 3) || (stat == 1)) { - volatile u32 dummy; + } else if (((__leoVersion.drive & 0xF) == 3) || ((__leoVersion.drive & 0xF) == 1)) { + vu32 dummy; osEPiReadIo(driveRomHandle, 0x9FF00, &data); - data = (data & 0xFF000000) >> 24; + data = ((data & 0xFF000000) >> 24); if (data != 4) { while (true) {} } - dummy = 0x32F8EB20; LEO_country_code = 0x2263EE56; - dummy += (uintptr_t)&__leoActive; + dummy += (u32)&__leoActive; } else { while (true) {} } - return LEO_ERROR_GOOD; } diff --git a/src/libleo/api/cjcreateleomanager.c b/src/libleo/api/cjcreateleomanager.c index 5ab8af37a28..59701597c42 100644 --- a/src/libleo/api/cjcreateleomanager.c +++ b/src/libleo/api/cjcreateleomanager.c @@ -1,84 +1,67 @@ +#include "ultra64.h" #include "ultra64/asm.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" -#include "stdint.h" +#include "ultra64/leo_internal.h" #include "attributes.h" -#include "ultra64.h" - -s32 LeoCJCreateLeoManager(s32 comPri, s32 intPri, OSMesg* cmdBuf, s32 cmdMsgCnt) { +s32 LeoCJCreateLeoManager(s32 comPri, s32 intPri, void** cmdBuf, s32 cmdMsgCnt) { OSPiHandle* driveRomHandle; UNUSED OSPiHandle* leoDiskHandle; volatile LEOCmdInquiry cmdBlockInq; UNUSED volatile LEOCmd cmdBlockID; UNUSED LEODiskID thisID; - u32 stat; + UNUSED u32 stat; u32 data; if (__leoActive) { return LEO_ERROR_GOOD; } - - if (!LeoDriveExist()) { + if (LeoDriveExist() == 0) { return LEO_ERROR_DEVICE_COMMUNICATION_FAILURE; } - - leoDiskHandle = osLeoDiskInit(); + osLeoDiskInit(); driveRomHandle = osDriveRomInit(); __leoActive = true; - - __osSetHWIntrRoutine(OS_INTR_CART, __osLeoInterrupt, (u8*)STACK_TOP(leoDiskStack) - FRAMESZ(SZREG * NARGSAVE)); - leoInitialize(comPri, intPri, cmdBuf, cmdMsgCnt); - - if (osResetType == 1) { // NMI + __osSetHWIntrRoutine(OS_INTR_CART, __osLeoInterrupt, STACK_TOP(leoDiskStack) - FRAMESZ(SZREG * NARGSAVE)); + leoInitialize(comPri, intPri, cmdBuf, (u32)cmdMsgCnt); + if (osResetType == 1) { __leoSetReset(); } - - cmdBlockInq.header.command = 2; + cmdBlockInq.header.command = LEO_COMMAND_INQUIRY; cmdBlockInq.header.reserve1 = 0; cmdBlockInq.header.control = 0; cmdBlockInq.header.reserve3 = 0; leoCommand((void*)&cmdBlockInq); - { - volatile s32 dummy = (uintptr_t)&cmdBlockInq & 0xFFFFFF; + vs32 dummy = (u32)&cmdBlockInq & 0xFFFFFF; while (dummy > 0) { - dummy -= ((uintptr_t)__leoSetReset & 0xFFFFFF) | 0x403DF4; + dummy -= ((s32)__leoSetReset & 0xFFFFFF) | 0x403DF4; } } - - while (cmdBlockInq.header.status == 8) {} - + while (cmdBlockInq.header.status == LEO_STATUS_BUSY) {} if (cmdBlockInq.header.status != 0) { - return GET_ERROR(cmdBlockInq); + return cmdBlockInq.header.sense; } - - __leoVersion.driver = cmdBlockInq.version; - __leoVersion.drive = 6; - __leoVersion.deviceType = cmdBlockInq.devType; - __leoVersion.nDevices = cmdBlockInq.devNum; - - stat = __leoVersion.driver & 0xF; - if (stat == 4) { + __leoVersion.drive = cmdBlockInq.version; + __leoVersion.driver = 6; + __leoVersion.deviceType = cmdBlockInq.dev_type; + __leoVersion.ndevices = cmdBlockInq.dev_num; + if ((__leoVersion.drive & 0xF) == 4) { LEO_country_code = 0; - } else if ((stat == 3) || (stat == 1)) { - volatile u32 dummy; + } else if (((__leoVersion.drive & 0xF) == 3) || ((__leoVersion.drive & 0xF) == 1)) { + vu32 dummy; osEPiReadIo(driveRomHandle, 0x9FF00, &data); - data = (data & 0xFF000000) >> 24; + data = ((u32)(data & 0xFF000000) >> 24); dummy = 0x3ED98F23; if (data != 0xC3) { while (true) {} } - dummy *= data; - dummy -= (uintptr_t)&cmdBlockInq; + dummy -= (u32)&cmdBlockInq; LEO_country_code = 0xE848D316; } else { while (true) {} } - return LEO_ERROR_GOOD; } diff --git a/src/libleo/api/clearqueue.c b/src/libleo/api/clearqueue.c index 1972b6080f6..e665b54491a 100644 --- a/src/libleo/api/clearqueue.c +++ b/src/libleo/api/clearqueue.c @@ -1,20 +1,16 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" s32 LeoClearQueue(void) { - LEOCmdClearQueue cmdBlock; + LEOCmdClearQue cmdBlock; if (!__leoActive) { return -1; } - - cmdBlock.header.command = 1; + cmdBlock.header.command = LEO_COMMAND_CLEAR_QUE; cmdBlock.header.reserve1 = 0; cmdBlock.header.control = 0; cmdBlock.header.reserve3 = 0; - leoCommand(&cmdBlock); return LEO_ERROR_GOOD; } diff --git a/src/libleo/api/driveexist.c b/src/libleo/api/driveexist.c index b75e4dbdeee..5699094cc26 100644 --- a/src/libleo/api/driveexist.c +++ b/src/libleo/api/driveexist.c @@ -1,7 +1,5 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" #include "attributes.h" u32 LeoDriveExist(void) { @@ -14,29 +12,23 @@ u32 LeoDriveExist(void) { u32 relDuration; __osPiGetAccess(); - - while ((stat = IO_READ(PI_STATUS_REG)) & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) {} - + while (((stat = IO_READ(PI_STATUS_REG)) & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) != 0) {} latency = IO_READ(PI_BSD_DOM1_LAT_REG); pageSize = IO_READ(PI_BSD_DOM1_PGS_REG); relDuration = IO_READ(PI_BSD_DOM1_RLS_REG); pulse = IO_READ(PI_BSD_DOM1_PWD_REG); - IO_WRITE(PI_BSD_DOM1_LAT_REG, 0xFF); IO_WRITE(PI_BSD_DOM1_PGS_REG, 0); IO_WRITE(PI_BSD_DOM1_RLS_REG, 3); IO_WRITE(PI_BSD_DOM1_PWD_REG, 0xFF); - - data = IO_READ(0x06001010); // Something in the n64dd address space? - + data = IO_READ(0x06001010); IO_WRITE(PI_BSD_DOM1_LAT_REG, latency); IO_WRITE(PI_BSD_DOM1_PGS_REG, pageSize); IO_WRITE(PI_BSD_DOM1_RLS_REG, relDuration); IO_WRITE(PI_BSD_DOM1_PWD_REG, pulse); - __osPiRelAccess(); if (data == 0x2129FFF8) { - return true; + return 1; } - return false; + return 0; } diff --git a/src/libleo/api/getaadr.s b/src/libleo/api/getaadr.s index 95c1cfb14d6..ea3cc38049e 100644 --- a/src/libleo/api/getaadr.s +++ b/src/libleo/api/getaadr.s @@ -4,10 +4,10 @@ .text LEAF(LeoGetAAdr) - bltz a0, .out_of_range - bge a0, 0x908, .out_of_range + bltz a0, .L801D0498 + bge a0, 0x908, .L801D0498 sll t0, a0, 2 - la v1, asc2tbl + la v1, D_801D04A0 add t1, t0, v1 lbu t8, 2(t1) lhu t9, 0(t1) @@ -25,299 +25,2322 @@ LEAF(LeoGetAAdr) sw v1, (a3) add v0, v0, 0x7EE80 jr ra -.out_of_range: + .L801D0498: li v0, -1 jr ra END(LeoGetAAdr) -DATA(asc2tbl) -.word 0x00009D14, 0x00232A14, 0x00296314, 0x002F8A14, 0x00457E18, 0x0063CA14, 0x0084AA14, 0x00A03314 -.word 0x00A45E14, 0x00BB4E14, 0x00CA6514, 0x00D3770E, 0x00E33302, 0x00E78108, 0x00EB2102, 0x00EC6C14 -.word 0x01008A14, 0x01163A14, 0x01217A14, 0x01377A14, 0x014D8A14, 0x01638A14, 0x01798A14, 0x018F7A14 -.word 0x01A58A14, 0x01BB8A14, 0x01D1170E, 0x01D5490E, 0x01DF770E, 0x01EF740A, 0x01F9770E, 0x02097A14 -.word 0x021FDC16, 0x024DBA14, 0x026E7A14, 0x0284BA14, 0x02A59A14, 0x02C16A14, 0x02D26A14, 0x02E3BA14 -.word 0x03048A14, 0x031A1A14, 0x03206A14, 0x03318A14, 0x03476A14, 0x0358CA14, 0x03799A14, 0x0395CA14 -.word 0x03B67A14, 0x03CCCA14, 0x03ED8A14, 0x04037A14, 0x04196A14, 0x042A8A14, 0x0440AA14, 0x045CDA14 -.word 0x04839A14, 0x049F9A14, 0x04BB7A14, 0x04D14D14, 0x04DF5C14, 0x04F33D14, 0x05015216, 0x050681FA -.word 0x050A9D14, 0x052D9810, 0x05449A14, 0x05609810, 0x05779A14, 0x05939810, 0x05AA5A14, 0x05BB9C10 -.word 0x05DC7A14, 0x05F22A14, 0x05F83D14, 0x06067A14, 0x061C2A14, 0x0622D810, 0x06427810, 0x06549810 -.word 0x066B9B10, 0x06899B10, 0x06A74810, 0x06B06810, 0x06BE5A14, 0x06CF770E, 0x06DF870E, 0x06EFB70E -.word 0x0707670E, 0x07138A0E, 0x0729670E, 0x07356D14, 0x074A1F16, 0x07526D14, 0x07675216, 0x076C9D14 -.word 0x078F9D14, 0x07B22A0E, 0x07B88B14, 0x07D08A14, 0x07E69816, 0x07FD9A14, 0x08193F16, 0x08296C14 -.word 0x083D5114, 0x0840CA14, 0x08616614, 0x086C650C, 0x0875830A, 0x087D9D14, 0x08A0CA14, 0x08C14114 -.word 0x08C35318, 0x08C98810, 0x08DB9D14, 0x08FE9D14, 0x09213216, 0x09249A0E, 0x09407A14, 0x0956440E -.word 0x095B3302, 0x095F9D14, 0x09826614, 0x098D650C, 0x09960A15, 0x09C2C514, 0x09D4070F, 0x09F47A0E -.word 0x0A0ABE1C, 0x0A37BE1C, 0x0A64BE1C, 0x0A91BD1A, 0x0ABBBD1A, 0x0AE5BE1C, 0x0B12FA14, 0x0B3EBE14 -.word 0x0B6B7E1C, 0x0B897E1C, 0x0BA77E1C, 0x0BC57D1A, 0x0BE13E1C, 0x0BF04E1C, 0x0BFF4E1C, 0x0C0E5D1A -.word 0x0C239D14, 0x0C469D1A, 0x0C69BE1C, 0x0C96BE1C, 0x0CC3BE1C, 0x0CF0BD1A, 0x0D1ABD1A, 0x0D44770E -.word 0x0D54CC16, 0x0D7B8E1C, 0x0D998E1C, 0x0DB77E1C, 0x0DD57D1A, 0x0DF19D14, 0x0E149D14, 0x0E379A14 -.word 0x0E539B16, 0x0E719B16, 0x0E8F9B16, 0x0EAD9B16, 0x0ECB9A14, 0x0EE79B16, 0x0F050811, 0x0F299B10 -.word 0x0F479B16, 0x0F659B16, 0x0F839B16, 0x0FA19A14, 0x0FBD3B16, 0x0FC93A16, 0x0FD44B16, 0x0FE04A14 -.word 0x0FEB7912, 0x0FFF8B16, 0x10179B16, 0x10359B16, 0x10539B16, 0x10719B16, 0x108F9A14, 0x10AB760C -.word 0x10B99910, 0x10D28B16, 0x10EA8B16, 0x11028B16, 0x111A8A14, 0x11309D14, 0x11539D14, 0x11769D14 -.word 0x11996F18, 0x11B13A14, 0x11BC7514, 0x11C88912, 0x11DC9D16, 0x11FFEA14, 0x1226CA14, 0x12474514 -.word 0x124D4D14, 0x125B4D14, 0x12696614, 0x1274870E, 0x12843404, 0x12899108, 0x128E4204, 0x12916C14 -.word 0x12A5AA14, 0x12C17A14, 0x12D79A14, 0x12F3AA14, 0x130FAA14, 0x132B9B16, 0x1349AA14, 0x1365AA14 -.word 0x1381AA14, 0x139DAA14, 0x13B9370E, 0x13C1390E, 0x13CB770E, 0x13DB750C, 0x13E7770E, 0x13F79A14 -.word 0x1413CC14, 0x143ACA14, 0x145BBA14, 0x147CBA14, 0x149DBA14, 0x14BEBA14, 0x14DFBA14, 0x1500BA14 -.word 0x1521CA14, 0x15426A14, 0x1553AA14, 0x156FCA14, 0x1590AA14, 0x15ACFA14, 0x15D8CA14, 0x15F9BA14 -.word 0x161AAA14, 0x1636CE14, 0x1663CA14, 0x16849A14, 0x16A0CA14, 0x16C1BA14, 0x16E2CA14, 0x1703EA14 -.word 0x172ACA14, 0x174BCA14, 0x176CAA14, 0x17883D14, 0x17966C14, 0x17AA3D14, 0x17B85214, 0x17BD92FC -.word 0x17C55F1A, 0x17DD870E, 0x17EDAA14, 0x1809870E, 0x18199A14, 0x1835970E, 0x18497A14, 0x185F9C10 -.word 0x1880BA14, 0x18A15A14, 0x18B26E14, 0x18C9AA14, 0x18E55A14, 0x18F6F70E, 0x1916A70E, 0x192A970E -.word 0x193EAB0E, 0x195C9B0E, 0x197A770E, 0x198A770E, 0x199A6912, 0x19A9A70E, 0x19BDA60E, 0x19CFD70E -.word 0x19EBA70E, 0x19FFAB0E, 0x1A1D870E, 0x1A2D6D14, 0x1A423F16, 0x1A526D14, 0x1A675214, 0x1A6C6F18 -.word 0x1A846F16, 0x1A9C3A0E, 0x1AA78B14, 0x1ABFAA14, 0x1ADB8614, 0x1AE9BA14, 0x1B0A2F16, 0x1B128A14 -.word 0x1B285214, 0x1B2DBB14, 0x1B516614, 0x1B5C860C, 0x1B6A730A, 0x1B726E16, 0x1B89BB14, 0x1BAD5012 -.word 0x1BAF5316, 0x1BB58910, 0x1BC95F18, 0x1BE15F18, 0x1BF95316, 0x1BFFA90C, 0x1C188A14, 0x1C2E540E -.word 0x1C363404, 0x1C3B6D14, 0x1C506614, 0x1C5B860C, 0x1C690913, 0x1C91C512, 0x1CA3D70E, 0x1CBF9A0E -.word 0x1CDBCD1A, 0x1D05CD1A, 0x1D2FCD1A, 0x1D59CD1A, 0x1D83CD1A, 0x1DADCE1C, 0x1DDA2A15, 0x1E0CBD14 -.word 0x1E36BD1A, 0x1E60BD1A, 0x1E8ABD1A, 0x1EB4BC18, 0x1EDB6D1A, 0x1EF06D1A, 0x1F056D1A, 0x1F1A6D1A -.word 0x1F2F5F1A, 0x1F47BD1A, 0x1F71CD1A, 0x1F9BCD1A, 0x1FC5CD1A, 0x1FEFCD1A, 0x2019CD1A, 0x2043970E -.word 0x2057CB14, 0x207BAD1A, 0x209EBD1A, 0x20C8BD1A, 0x20F2BD1A, 0x211C6F1A, 0x21345F1A, 0x214CAA14 -.word 0x21689B16, 0x21869B16, 0x21A49A14, 0x21C0AA14, 0x21DC9A14, 0x21F89B16, 0x2216D70E, 0x22329B0E -.word 0x22508B16, 0x22689B16, 0x22869A14, 0x22A29A14, 0x22BE5B16, 0x22D05B16, 0x22E25A14, 0x22F35A14 -.word 0x23048912, 0x2318AA14, 0x23349B16, 0x23529B16, 0x23709A14, 0x238C9A14, 0x23A89A14, 0x23C49910 -.word 0x23DD9A10, 0x23F9AB16, 0x2417AB16, 0x2435AA14, 0x2451AA14, 0x246D5F18, 0x24855F18, 0x249DAE14 -.word 0x24C39D14, 0x24E62A14, 0x24EC5314, 0x24F28912, 0x25068D16, 0x2522CA14, 0x2543CA14, 0x25642314 -.word 0x25663C14, 0x25733C14, 0x25806514, 0x2589770E, 0x25993302, 0x259D9006, 0x25A03102, 0x25A26C14 -.word 0x25B69A14, 0x25D26A14, 0x25E38A14, 0x25F99A14, 0x26159A14, 0x26318A14, 0x26478A14, 0x265D9912 -.word 0x26769A14, 0x26928A14, 0x26A8260C, 0x26AC480C, 0x26B5870E, 0x26C5740A, 0x26CF770E, 0x26DF8A14 -.word 0x26F5DC14, 0x2723CA14, 0x2744A912, 0x275DAA14, 0x2779B912, 0x2797A912, 0x27B0A912, 0x27C9BA14 -.word 0x27EAC912, 0x28085912, 0x28179912, 0x2830B912, 0x284E9912, 0x2867D912, 0x288AB912, 0x28A8CA14 -.word 0x28C99912, 0x28E2CD14, 0x290CB912, 0x292A9A14, 0x2946A912, 0x295FB912, 0x297DC912, 0x299B0913 -.word 0x29C3C912, 0x29E1B912, 0x29FF9912, 0x2A183B12, 0x2A246C14, 0x2A383B12, 0x2A445214, 0x2A4981FA -.word 0x2A4D9D14, 0x2A70970E, 0x2A849A14, 0x2AA0770E, 0x2AB09A14, 0x2ACC870E, 0x2ADC6A14, 0x2AED9C10 -.word 0x2B0E9A14, 0x2B2A4912, 0x2B346D12, 0x2B499A14, 0x2B655A14, 0x2B76F70E, 0x2B96A70E, 0x2BAA970E -.word 0x2BBE9B0E, 0x2BDCAB0E, 0x2BFA770E, 0x2C0A770E, 0x2C1A6912, 0x2C29A70E, 0x2C3D970E, 0x2C51C70E -.word 0x2C69A70E, 0x2C7D9B0E, 0x2C9B770E, 0x2CAB5C12, 0x2CBF2F16, 0x2CC76C12, 0x2CDB5214, 0x2CE08D14 -.word 0x2CFC9D14, 0x2D1F2A0E, 0x2D257B14, 0x2D3D9A14, 0x2D599714, 0x2D6DB912, 0x2D8B2F16, 0x2D937A14 -.word 0x2DA95112, 0x2DACCB14, 0x2DD07714, 0x2DE0760C, 0x2DEE730A, 0x2DF69D14, 0x2E19BB14, 0x2E3D5112 -.word 0x2E405316, 0x2E468810, 0x2E589D14, 0x2E7B9D14, 0x2E9E4214, 0x2EA19A0C, 0x2EBD7A14, 0x2ED3440E -.word 0x2ED82302, 0x2EDA8D14, 0x2EF66714, 0x2F02760C, 0x2F100A15, 0x2F3CC614, 0x2F51C70E, 0x2F698A0E -.word 0x2F7FCD1A, 0x2FA9CD1A, 0x2FD3BD1A, 0x2FFDCD1A, 0x3027CC18, 0x304ECE1C, 0x307B0913, 0x30A3BD14 -.word 0x30CDAD1A, 0x30F0BD1A, 0x311ABD1A, 0x3144AC18, 0x31654D1A, 0x31734D1A, 0x31814D1A, 0x318F5C18 -.word 0x31A39D14, 0x31C6BD1A, 0x31F0CD1A, 0x321ACD1A, 0x3244CD1A, 0x326ECD1A, 0x3298CC18, 0x32BFA70E -.word 0x32D3BB14, 0x32F7BD1A, 0x3321CD1A, 0x334BBD1A, 0x3375BC18, 0x339C8D14, 0x33B88D14, 0x33D49A14 -.word 0x33F09A14, 0x340C9A14, 0x34289A14, 0x34449A14, 0x34609912, 0x34799B16, 0x3497C70E, 0x34AF7A0E -.word 0x34C58A14, 0x34DB8A14, 0x34F17A14, 0x35077912, 0x351B5A14, 0x352C5A14, 0x353D5A14, 0x354E6912 -.word 0x355D7912, 0x35719A14, 0x358D8A14, 0x35A38A14, 0x35B98A14, 0x35CF8A14, 0x35E58912, 0x35F9870E -.word 0x36099910, 0x3622AA14, 0x363EAA14, 0x365AAA14, 0x36769912, 0x368F8D14, 0x36AB8D14, 0x36C79D12 -.word 0x36EA6F18, 0x37024912, 0x370C7412, 0x37166B14, 0x37288C14, 0x37427912, 0x37568810, 0x37684412 -.word 0x376D5C12, 0x37815C12, 0x37957612, 0x37A39710, 0x37B74404, 0x37BCA108, 0x37C13306, 0x37C57B14 -.word 0x37DD8912, 0x37F17912, 0x38057912, 0x38198912, 0x382D8912, 0x38417912, 0x38557912, 0x38697912 -.word 0x387D8912, 0x38918912, 0x38A5370E, 0x38AD480C, 0x38B69710, 0x38CA940E, 0x38D79710, 0x38EB7912 -.word 0x38FF8B14, 0x3917A912, 0x39309912, 0x39498912, 0x395D8912, 0x39719912, 0x398A9912, 0x39A39912 -.word 0x39BC9912, 0x39D57912, 0x39E99912, 0x3A029912, 0x3A1B9912, 0x3A34A912, 0x3A4D9912, 0x3A669912 -.word 0x3A7F8912, 0x3A939B12, 0x3AB19912, 0x3ACA8912, 0x3ADE8912, 0x3AF29912, 0x3B0B9912, 0x3B24A912 -.word 0x3B3D8912, 0x3B518912, 0x3B657912, 0x3B794C12, 0x3B867B14, 0x3B9E4C12, 0x3BAB6214, 0x3BB0A2FC -.word 0x3BB85F1A, 0x3BD0870E, 0x3BE09912, 0x3BF9870E, 0x3C098912, 0x3C1D870E, 0x3C2D8912, 0x3C419A0E -.word 0x3C5D8912, 0x3C718A14, 0x3C877D14, 0x3CA39912, 0x3CBC8912, 0x3CD0A70E, 0x3CE4970E, 0x3CF8970E -.word 0x3D0C9B0E, 0x3D2AAB0E, 0x3D48970E, 0x3D5C770E, 0x3D6C8912, 0x3D80970E, 0x3D94970E, 0x3DA8A70E -.word 0x3DBC870E, 0x3DCC9A0E, 0x3DE8770E, 0x3DF86D12, 0x3E0D2F16, 0x3E156D12, 0x3E2A6212, 0x3E2F6F16 -.word 0x3E476F16, 0x3E5F4912, 0x3E697A14, 0x3E7F7912, 0x3E938612, 0x3EA19912, 0x3EBA3F16, 0x3ECA8A12 -.word 0x3EE06112, 0x3EE3A812, 0x3EFA7712, 0x3F0A550C, 0x3F13950E, 0x3F226E16, 0x3F399812, 0x3F506112 -.word 0x3F534316, 0x3F578812, 0x3F695F18, 0x3F815F18, 0x3F995214, 0x3F9E9A0E, 0x3FBA7912, 0x3FCE320C -.word 0x3FD14404, 0x3FD66D14, 0x3FEB7712, 0x3FFB650C, 0x40048710, 0x40148310, 0x401C860E, 0x402A7912 -.word 0x403EAC18, 0x405FAC18, 0x4080AC18, 0x40A1AB16, 0x40BFAB16, 0x40DDAD1A, 0x4100B912, 0x411E8C12 -.word 0x41388C18, 0x41529C18, 0x41739C18, 0x41948B16, 0x41AC7C18, 0x41C67C18, 0x41E07C18, 0x41FA7B16 -.word 0x42125F1A, 0x422AAB16, 0x42489C18, 0x42699C18, 0x428A9C18, 0x42AB9B16, 0x42C99B16, 0x42E7870E -.word 0x42F79A12, 0x43139C18, 0x43349C18, 0x4355AC18, 0x4376AB16, 0x43946F1A, 0x43AC5F1A, 0x43C48912 -.word 0x43D88A14, 0x43EE8A14, 0x44049A14, 0x44209912, 0x44398912, 0x444D8B16, 0x4465970E, 0x44798A0E -.word 0x448F8A14, 0x44A58A14, 0x44BB9A14, 0x44D79912, 0x44F08A14, 0x45068A14, 0x451C7A14, 0x45327912 -.word 0x45468912, 0x455A9912, 0x45738A14, 0x45898A14, 0x459F9912, 0x45B89912, 0x45D19912, 0x45EAA912 -.word 0x46039910, 0x461C9A14, 0x46389A14, 0x46548A14, 0x466A9912, 0x46835F18, 0x469B5F18, 0x46B38C12 -.word 0x46CD3C16, 0x46DA3C16, 0x46E77516, 0x46F39A14, 0x470F7E18, 0x472DDC16, 0x475BBC16, 0x47824516 -.word 0x47884F18, 0x47984F18, 0x47A85516, 0x47B1870E, 0x47C15504, 0x47CA810A, 0x47CE4304, 0x47D28F18 -.word 0x47F29C16, 0x48134B16, 0x481F8B16, 0x48378C16, 0x48519B16, 0x486F8C16, 0x48898C16, 0x48A38B16 -.word 0x48BB8C16, 0x48D58C16, 0x48EF380E, 0x48F84A0E, 0x4903970E, 0x4917850C, 0x4923870E, 0x49337C16 -.word 0x494DCC16, 0x4974BB16, 0x49988B16, 0x49B09C16, 0x49D1AB16, 0x49EF7B16, 0x4A077B16, 0x4A1FBC16 -.word 0x4A46AB16, 0x4A643B16, 0x4A706C16, 0x4A849B16, 0x4AA26B16, 0x4AB4DC16, 0x4AE2AC16, 0x4B03CC16 -.word 0x4B2A8B16, 0x4B42CC16, 0x4B698B16, 0x4B818C16, 0x4B9B7B16, 0x4BB39C16, 0x4BD4BC16, 0x4BFBFC16 -.word 0x4C2FAB16, 0x4C4DAB16, 0x4C6B9B16, 0x4C893E18, 0x4C988C18, 0x4CB24E18, 0x4CC16316, 0x4CC781FC -.word 0x4CCB3C16, 0x4CD8880E, 0x4CEA8D18, 0x4D06680E, 0x4D149D18, 0x4D37880E, 0x4D495C18, 0x4D5D8B0E -.word 0x4D757C18, 0x4D8F3B16, 0x4D9B3F16, 0x4DAB8C18, 0x4DC53C18, 0x4DD2B70E, 0x4DEA770E, 0x4DFA980E -.word 0x4E119B0E, 0x4E2F9B0E, 0x4E4D670E, 0x4E59680E, 0x4E674912, 0x4E71780E, 0x4E83980E, 0x4E9AD80E -.word 0x4EBAA70E, 0x4ECE9B0E, 0x4EEC770E, 0x4EFC5F18, 0x4F142C18, 0x4F1B4F18, 0x4F2B7114, 0x4F2F3C16 -.word 0x4F3C3C10, 0x4F493B0E, 0x4F556A14, 0x4F669C16, 0x4F879810, 0x4F9E9B16, 0x4FBC2C18, 0x4FC38E18 -.word 0x4FE16216, 0x4FE6DC16, 0x50146616, 0x501F7710, 0x502F840C, 0x50393C1A, 0x5046DC16, 0x50747116 -.word 0x50784316, 0x507C8912, 0x50903C14, 0x509D3C14, 0x50AA4316, 0x50AE7B0E, 0x50C6AE16, 0x50EC6610 -.word 0x50F75504, 0x51003C18, 0x510D6616, 0x51188710, 0x5128FC16, 0x515CE616, 0x5175D80E, 0x51958B0E -.word 0x51ADCC18, 0x51D4BC18, 0x51FBBC18, 0x5222BC18, 0x5249CC18, 0x5270BC18, 0x5297FB16, 0x52C79E16 -.word 0x52ED6C18, 0x53016C18, 0x53157C18, 0x532F7C18, 0x53494C18, 0x53564C18, 0x53636C18, 0x53777C18 -.word 0x53913C18, 0x539EAD18, 0x53C1CD18, 0x53EBCD18, 0x5415CD18, 0x543FCD18, 0x5469CC18, 0x5490970E -.word 0x54A4CC16, 0x54CB9D18, 0x54EE9D18, 0x55119D18, 0x55349D18, 0x55573C18, 0x55643C18, 0x55719D18 -.word 0x55948C16, 0x55AE9C16, 0x55CF8C16, 0x55E99B14, 0x56078C16, 0x56219C16, 0x5642C80E, 0x565D6A0E -.word 0x566E8C16, 0x56887C16, 0x56A28C16, 0x56BC7C16, 0x56D64B16, 0x56E24B16, 0x56EE6B16, 0x57007B16 -.word 0x57187B16, 0x57307A14, 0x57469C16, 0x57678C16, 0x57818C16, 0x579B9B14, 0x57B99C16, 0x57DA880E -.word 0x57EC980E, 0x58038C16, 0x581D8C16, 0x58378C16, 0x58518C16, 0x586B3C16, 0x58783C16, 0x58859F16 -.word 0x58AD6F18, 0x58C55C16, 0x58D98516, 0x58E59B14, 0x59038E18, 0x5921BC16, 0x5948AC16, 0x59695516 -.word 0x59724F18, 0x59825F18, 0x599A6516, 0x59A3970E, 0x59B75504, 0x59C0810A, 0x59C43304, 0x59C8AF18 -.word 0x59F09C16, 0x5A115B16, 0x5A239B16, 0x5A418C16, 0x5A5B9B16, 0x5A799C16, 0x5A9A9C16, 0x5ABBAC16 -.word 0x5ADC8C16, 0x5AF69C16, 0x5B17480E, 0x5B206A0E, 0x5B31970E, 0x5B45950C, 0x5B54970E, 0x5B687C16 -.word 0x5B82CC16, 0x5BA9BB16, 0x5BCD9B16, 0x5BEB9C16, 0x5C0CBB16, 0x5C309B16, 0x5C4E9B16, 0x5C6CBC16 -.word 0x5C93BB16, 0x5CB75B16, 0x5CC98C16, 0x5CE3BB16, 0x5D077B16, 0x5D1FDC16, 0x5D4DCC16, 0x5D74DC16 -.word 0x5DA29B16, 0x5DC0CC16, 0x5DE79B16, 0x5E059C16, 0x5E268B16, 0x5E3EAC16, 0x5E5FBC16, 0x5E860C17 -.word 0x5EBABB16, 0x5EDEAB16, 0x5EFCBB16, 0x5F205E18, 0x5F376E18, 0x5F4E6E18, 0x5F655316, 0x5F6B91FC -.word 0x5F706F1A, 0x5F88980E, 0x5F9F9D18, 0x5FC2680E, 0x5FD0AD18, 0x5FF3880E, 0x60056C18, 0x60199B0E -.word 0x60378C18, 0x60515B16, 0x60636F16, 0x607B9C18, 0x609C5C18, 0x60B0C70E, 0x60C8870E, 0x60D8880E -.word 0x60EA9B0E, 0x61089B0E, 0x6126770E, 0x6136680E, 0x61446912, 0x6153780E, 0x6165980E, 0x617CD80E -.word 0x619CA70E, 0x61B0AB0E, 0x61CEA70E, 0x61E26F18, 0x61FA4C18, 0x62076F18, 0x621F7114, 0x62236F18 -.word 0x623B6F16, 0x62534B0E, 0x625F7A14, 0x6275AC16, 0x6296A810, 0x62ADAB16, 0x62CB4C18, 0x62D88E18 -.word 0x62F66216, 0x62FBDC16, 0x63297616, 0x63378710, 0x6347940C, 0x63546F18, 0x636CDC16, 0x639A6116 -.word 0x639D4316, 0x63A19912, 0x63BA6F18, 0x63D26F18, 0x63EA5316, 0x63F09B0E, 0x640E9E16, 0x64346610 -.word 0x643F5504, 0x64486F18, 0x64607616, 0x646E8710, 0x647EFA14, 0x64AAD514, 0x64BFC60C, 0x64D47B0E -.word 0x64ECCC18, 0x6513BC18, 0x653ABC18, 0x6561CC18, 0x6588CC18, 0x65AFBC18, 0x65D6FB16, 0x6606AE16 -.word 0x662C8C18, 0x66468C18, 0x66609C18, 0x66819C18, 0x66A25C18, 0x66B66C18, 0x66CA7C18, 0x66E47C18 -.word 0x66FE6F1A, 0x6716CD18, 0x6740DD18, 0x6771CD18, 0x679BCD18, 0x67C5CD18, 0x67EFDD18, 0x6820A70E -.word 0x6834FC16, 0x6868AD18, 0x688BAD18, 0x68AEAD18, 0x68D1AD18, 0x68F46F1A, 0x690C6F1A, 0x69249D18 -.word 0x69479C16, 0x69689C16, 0x69899C16, 0x69AA9B14, 0x69C89C16, 0x69E99C16, 0x6A0AD80E, 0x6A2A7A0E -.word 0x6A408C16, 0x6A5A8C16, 0x6A748C16, 0x6A8E8C16, 0x6AA85B16, 0x6ABA5B16, 0x6ACC6B16, 0x6ADE6B16 -.word 0x6AF07B16, 0x6B089A14, 0x6B248C16, 0x6B3E9C16, 0x6B5F9C16, 0x6B808B14, 0x6B988C16, 0x6BB2980E -.word 0x6BC9980E, 0x6BE08C16, 0x6BFA8C16, 0x6C148C16, 0x6C2E8C16, 0x6C486F18, 0x6C606F18, 0x6C78AF16 -.word 0x6CA06F18, 0x6CB82A14, 0x6CBE4314, 0x6CC29A14, 0x6CDE8D16, 0x6CFADB14, 0x6D249B14, 0x6D422314 -.word 0x6D445D14, 0x6D594D14, 0x6D675414, 0x6D6F870E, 0x6D7F2402, 0x6D829108, 0x6D872102, 0x6D885A14 -.word 0x6D998B14, 0x6DB15A14, 0x6DC28A14, 0x6DD88B14, 0x6DF08A14, 0x6E068B14, 0x6E1E8B14, 0x6E368A14 -.word 0x6E4C8B14, 0x6E648B14, 0x6E7C270E, 0x6E802A0E, 0x6E86970E, 0x6E9A850C, 0x6EA6970E, 0x6EBA7A14 -.word 0x6ED0DB14, 0x6EFAAA14, 0x6F169A14, 0x6F32AB14, 0x6F509A14, 0x6F6C9A14, 0x6F889A14, 0x6FA4AB14 -.word 0x6FC2AA14, 0x6FDE2A14, 0x6FE47B14, 0x6FFC9A14, 0x70188A14, 0x702EBA14, 0x704F9A14, 0x706BBB14 -.word 0x708F9A14, 0x70ABBB14, 0x70CF9A14, 0x70EB9B14, 0x7109AA14, 0x71259B14, 0x7143AA14, 0x715FEA14 -.word 0x7186AA14, 0x71A2AA14, 0x71BE9A14, 0x71DA3D14, 0x71E87A14, 0x71FE4D14, 0x720C5214, 0x721190FC -.word 0x72145F1A, 0x722C8910, 0x72408B14, 0x72588910, 0x726C7C16, 0x72868910, 0x729A6A14, 0x72AB8C10 -.word 0x72C57A14, 0x72DB2A14, 0x72E14E14, 0x72F07A14, 0x73062A14, 0x730CB810, 0x73277810, 0x73398910 -.word 0x734D8C10, 0x73678C10, 0x73815810, 0x738F7910, 0x73A34A12, 0x73AE780E, 0x73C0870E, 0x73D0B70E -.word 0x73E8770E, 0x73F88B0E, 0x7410770E, 0x74205D14, 0x74352A14, 0x743B6D14, 0x74506114, 0x74536F18 -.word 0x746B6F16, 0x74832A0E, 0x74898B12, 0x74A18B14, 0x74B98710, 0x74C99A14, 0x74E52A14, 0x74EB7E14 -.word 0x75094114, 0x750BBA14, 0x752C5414, 0x7534650C, 0x753D840A, 0x75476E16, 0x755EBA14, 0x757F6114 -.word 0x75823316, 0x7586870E, 0x75965F18, 0x75AE5F18, 0x75C64214, 0x75C99B0E, 0x75E78D14, 0x7603430C -.word 0x76072402, 0x760A6D14, 0x761F5414, 0x7627550C, 0x7630FB14, 0x7660C514, 0x7672E80E, 0x76928A0E -.word 0x76A8AD1A, 0x76CBAD1A, 0x76EEAD1A, 0x7711AD1A, 0x7734AD1A, 0x7757AE1C, 0x777DFA14, 0x77A9AD14 -.word 0x77CC8D1A, 0x77E88D1A, 0x78048D1A, 0x78208C18, 0x783A4D1A, 0x78483D1A, 0x78565D1A, 0x786B5D1A -.word 0x78805F1A, 0x7898AD1A, 0x78BBCE1A, 0x78E8BE1A, 0x7915BE1A, 0x7942BE1A, 0x796FCD18, 0x7999870E -.word 0x79A9BB14, 0x79CD9E1A, 0x79F39E1A, 0x7A199E1A, 0x7A3FAE1A, 0x7A656F1A, 0x7A7D5F1A, 0x7A958B14 -.word 0x7AAD8C16, 0x7AC78C16, 0x7AE18C16, 0x7AFB8B14, 0x7B138B14, 0x7B2B8C16, 0x7B45D910, 0x7B687C10 -.word 0x7B828C16, 0x7B9C8C16, 0x7BB68C16, 0x7BD08B14, 0x7BE84B16, 0x7BF44B16, 0x7C005B16, 0x7C124B16 -.word 0x7C1E7B14, 0x7C367A14, 0x7C4C8C16, 0x7C668C16, 0x7C808C16, 0x7C9A8B14, 0x7CB28B14, 0x7CCA870E -.word 0x7CDA8910, 0x7CEE7C16, 0x7D088C16, 0x7D227C16, 0x7D3C7B14, 0x7D545F18, 0x7D6C5F18, 0x7D848E14 -.word 0x7DA26F16, 0x7DBA3A14, 0x7DC56414, 0x7DCD9A14, 0x7DE98D16, 0x7E05EB14, 0x7E2FBB14, 0x7E533414 -.word 0x7E584D14, 0x7E664D14, 0x7E746414, 0x7E7C870E, 0x7E8C3402, 0x7E91920A, 0x7E993102, 0x7E9B7A14 -.word 0x7EB18B14, 0x7EC95A14, 0x7EDA8A14, 0x7EF08B14, 0x7F088A14, 0x7F1E8B14, 0x7F368B14, 0x7F4E8A14 -.word 0x7F648B14, 0x7F7C9B14, 0x7F9A370E, 0x7FA23A0E, 0x7FADA80E, 0x7FC4960C, 0x7FD6980E, 0x7FED9A14 -.word 0x8009DC16, 0x8037BA14, 0x8058AA14, 0x8074BB14, 0x8098AA14, 0x80B49A14, 0x80D09A14, 0x80ECBB14 -.word 0x8110AA14, 0x812C3A14, 0x81378B14, 0x814FAA14, 0x816B9A14, 0x8187BA14, 0x81A8AA14, 0x81C4BB14 -.word 0x81E89A14, 0x8204BB14, 0x8228AA14, 0x8244AB14, 0x8262AA14, 0x827E9B14, 0x829CAA14, 0x82B8FA14 -.word 0x82E4AA14, 0x8300AA14, 0x831C9A14, 0x83384D14, 0x83466A14, 0x83575D14, 0x836C6216, 0x837190FC -.word 0x83745F18, 0x838C8910, 0x83A09B14, 0x83BE8910, 0x83D29B14, 0x83F09910, 0x84095A14, 0x841A8C10 -.word 0x84348A14, 0x844A3A14, 0x84554E14, 0x84648A14, 0x847A2A14, 0x8480C810, 0x849B8810, 0x84AD9910 -.word 0x84C68C10, 0x84E09C10, 0x85015810, 0x850F8910, 0x85235A14, 0x8534880E, 0x8546870E, 0x8556C70E -.word 0x856E870E, 0x857E8B0E, 0x8596870E, 0x85A65D14, 0x85BB3A14, 0x85C66D14, 0x85DB7216, 0x85E16F18 -.word 0x85F96F14, 0x86113A0E, 0x861C8B12, 0x86348B14, 0x864C8710, 0x865C9A14, 0x86783A14, 0x86838D14 -.word 0x869F6114, 0x86A2BA14, 0x86C36514, 0x86CC750C, 0x86D8950C, 0x86E75F16, 0x86FFBA14, 0x87206114 -.word 0x87234318, 0x8727970E, 0x873B5F16, 0x87535F16, 0x876B4114, 0x876DAB0E, 0x878B9D14, 0x87AE430C -.word 0x87B23402, 0x87B76F16, 0x87CF6514, 0x87D8650C, 0x87E1EC14, 0x880FC512, 0x8821E90E, 0x88448A0E -.word 0x885AAD1A, 0x887DBD1A, 0x88A7BD1A, 0x88D1BD1A, 0x88FBAD1A, 0x891EBE1C, 0x894BFA14, 0x8977AE14 -.word 0x899D9D1A, 0x89C09D1A, 0x89E39D1A, 0x8A069D1A, 0x8A294D1A, 0x8A374D1A, 0x8A456D1A, 0x8A5A6D1A -.word 0x8A6F5F18, 0x8A87AD1A, 0x8AAABE1A, 0x8AD7BE1A, 0x8B04BE1A, 0x8B31BE1A, 0x8B5EBE1A, 0x8B8B870E -.word 0x8B9BBB14, 0x8BBF9E1A, 0x8BE59E1A, 0x8C0BAE1A, 0x8C31AE1A, 0x8C575F18, 0x8C6F5F18, 0x8C878B14 -.word 0x8C9F8B14, 0x8CB79B14, 0x8CD58C16, 0x8CEF8C16, 0x8D098B14, 0x8D219D18, 0x8D44D910, 0x8D678C10 -.word 0x8D818B14, 0x8D999B14, 0x8DB79C16, 0x8DD88B14, 0x8DF05A14, 0x8E015A14, 0x8E125A14, 0x8E236A14 -.word 0x8E348B14, 0x8E4C8B16, 0x8E649B14, 0x8E829B14, 0x8EA09C16, 0x8EC19C16, 0x8EE29B14, 0x8F00870E -.word 0x8F10A910, 0x8F298B14, 0x8F418B14, 0x8F598C16, 0x8F738C16, 0x8F8D5F18, 0x8FA55F18, 0x8FBD8F16 -.word 0x8FDD6F16, 0x8FF54A12, 0x90004312, 0x90049A12, 0x90209C14, 0x9041BA12, 0x90628A12, 0x90782312 -.word 0x907A6C12, 0x908E5C12, 0x90A25412, 0x90AA870C, 0x90BA3300, 0x90BE8006, 0x90C02100, 0x90C17A12 -.word 0x90D78A12, 0x90ED5A12, 0x90FE9A12, 0x911A8A12, 0x91308A12, 0x91469A12, 0x91628A12, 0x91788A12 -.word 0x918E8A12, 0x91A47A12, 0x91BA370E, 0x91C24A0E, 0x91CD980E, 0x91E4940A, 0x91F1980E, 0x92087A12 -.word 0x921ECB14, 0x9242AA12, 0x925E9A12, 0x927ABB14, 0x929EAA12, 0x92BABA12, 0x92DBAA12, 0x92F7BB14 -.word 0x931BBA12, 0x933C4A12, 0x93478A12, 0x935DBA12, 0x937E8A12, 0x9394CA12, 0x93B5AA12, 0x93D1BB14 -.word 0x93F5AA12, 0x9411BB14, 0x9435AA12, 0x94519B14, 0x946F9A12, 0x948BAA12, 0x94A7AA12, 0x94C3DA12 -.word 0x94EABA12, 0x950B9A12, 0x9527BA12, 0x95485C12, 0x955C3A12, 0x95675C12, 0x957B5112, 0x957E80FC -.word 0x95803F18, 0x9590780E, 0x95A29A12, 0x95BE880E, 0x95D09A12, 0x95EC880E, 0x95FE5A12, 0x960F9B0E -.word 0x962D8A12, 0x96434A12, 0x964E6D12, 0x96638A12, 0x96794A12, 0x9684C80E, 0x969F880E, 0x96B1880E -.word 0x96C39B0E, 0x96E18B0E, 0x96F9680E, 0x9707780E, 0x97195A12, 0x972A880E, 0x973C880E, 0x974EA80E -.word 0x9765980E, 0x977C9B0E, 0x979A880E, 0x97AC7C12, 0x97C63A12, 0x97D16C12, 0x97E56112, 0x97E86F18 -.word 0x98004F14, 0x98104A0E, 0x981B8A10, 0x98319A12, 0x984D860E, 0x985B9A12, 0x98774A12, 0x98827D12 -.word 0x989E5112, 0x98A1BA12, 0x98C25514, 0x98CB740A, 0x98D5840A, 0x98DF5F14, 0x98F7BA12, 0x99185112 -.word 0x991B3214, 0x991E870C, 0x992E5F16, 0x99465F16, 0x995E3112, 0x9960BB0E, 0x99848C12, 0x999E330C -.word 0x99A22300, 0x99A46F16, 0x99BC5514, 0x99C5640A, 0x99CDFB14, 0x99FDB412, 0x9A0CD80E, 0x9A2C7A0E -.word 0x9A42AD18, 0x9A65AD18, 0x9A889D18, 0x9AABAD18, 0x9ACEAD18, 0x9AF1AE1A, 0x9B17FA12, 0x9B43BE14 -.word 0x9B70BD18, 0x9B9AAD18, 0x9BBDAD18, 0x9BE0AD18, 0x9C035D18, 0x9C186D18, 0x9C2D6D18, 0x9C426D18 -.word 0x9C573F18, 0x9C67BD18, 0x9C91BD18, 0x9CBBBD18, 0x9CE5BD18, 0x9D0FBD18, 0x9D39BD18, 0x9D63980E -.word 0x9D7ADB14, 0x9DA4AD18, 0x9DC7AD18, 0x9DEAAD18, 0x9E0DAD18, 0x9E305F18, 0x9E485F18, 0x9E608A12 -.word 0x9E768B14, 0x9E8E8B14, 0x9EA68B14, 0x9EBE8B14, 0x9ED68A12, 0x9EEC8C16, 0x9F06D80E, 0x9F267B0E -.word 0x9F3E8B14, 0x9F567B14, 0x9F6E8B14, 0x9F868A12, 0x9F9C3B14, 0x9FA85B14, 0x9FBA5B14, 0x9FCC5A12 -.word 0x9FDD8A12, 0x9FF38B14, 0xA00B8B14, 0xA0238B14, 0xA03B8B14, 0xA0538B14, 0xA06B8A12, 0xA081860C -.word 0xA08F980E, 0xA0A67B14, 0xA0BE8B14, 0xA0D68B14, 0xA0EE8A12, 0xA1045E16, 0xA11B5E16, 0xA1329D12 -.word 0xA1556F1A, 0xA16D1B16, 0xA1735316, 0xA1797B16, 0xA1915D18, 0xA1A67B16, 0xA1BE5B16, 0xA1D02316 -.word 0xA1D22F18, 0xA1DA2F18, 0xA1E23316, 0xA1E6540C, 0xA1EE2404, 0xA1F15008, 0xA1F31204, 0xA1F53A16 -.word 0xA2004B16, 0xA20C2B16, 0xA2124B16, 0xA21E5B16, 0xA2304B16, 0xA23C5B16, 0xA24E4B16, 0xA25A5B16 -.word 0xA26C4B16, 0xA2785B16, 0xA28A1710, 0xA28E280E, 0xA2936810, 0xA2A1530C, 0xA2A75810, 0xA2B54B16 -.word 0xA2C17C18, 0xA2DB5B16, 0xA2ED4B16, 0xA2F96C18, 0xA30D5B16, 0xA31F5B16, 0xA3315C18, 0xA3456C18 -.word 0xA3595B16, 0xA36B2A16, 0xA3714B16, 0xA37D6B16, 0xA38F5B16, 0xA3A17B16, 0xA3B96B16, 0xA3CB6C18 -.word 0xA3DF5B16, 0xA3F16D18, 0xA4065C18, 0xA41A6C18, 0xA42E6A16, 0xA43F5B16, 0xA4516B16, 0xA4638C18 -.word 0xA47D5B16, 0xA48F5B16, 0xA4A15B16, 0xA4B32E16, 0xA4BB3A16, 0xA4C62E16, 0xA4CE531A, 0xA4D470FC -.word 0xA4D65F1C, 0xA4EE4810, 0xA4F75B16, 0xA5095912, 0xA5185B16, 0xA52A5810, 0xA5383C18, 0xA5454B10 -.word 0xA5514B16, 0xA55D2B16, 0xA5632E16, 0xA56B4B16, 0xA5772B16, 0xA57D6810, 0xA58B4810, 0xA5945912 -.word 0xA5A34B10, 0xA5AF5B10, 0xA5C13810, 0xA5CA5912, 0xA5D93A14, 0xA5E44810, 0xA5ED5810, 0xA5FB6810 -.word 0xA6094810, 0xA6125B10, 0xA6245810, 0xA6324E16, 0xA6412E16, 0xA6494E16, 0xA6586116, 0xA65B6C18 -.word 0xA66F5E16, 0xA6862B10, 0xA68C5C14, 0xA6A04B16, 0xA6AC5712, 0xA6B84A16, 0xA6C32B16, 0xA6C94E16 -.word 0xA6D83116, 0xA6DA7B16, 0xA6F23618, 0xA6F9650E, 0xA702440C, 0xA7076B16, 0xA7197B16, 0xA7317016 -.word 0xA7332218, 0xA735570E, 0xA7415F1A, 0xA7595F1A, 0xA7712116, 0xA7725B10, 0xA7845E16, 0xA79B230E -.word 0xA79D2300, 0xA79F6D16, 0xA7B43618, 0xA7BB640C, 0xA7C38B16, 0xA7DB7516, 0xA7E78810, 0xA7F95B10 -.word 0xA80B5E1C, 0xA8225E1C, 0xA8395E1C, 0xA8506E1C, 0xA8675D1A, 0xA87C5F1E, 0xA8948B16, 0xA8AC6F18 -.word 0xA8C45F1E, 0xA8DC5E1C, 0xA8F35F1E, 0xA90B5D1A, 0xA9202E1C, 0xA9282E1C, 0xA9305F1E, 0xA9484D1A -.word 0xA9565F1C, 0xA96E6E1C, 0xA9857E1C, 0xA9A37E1C, 0xA9C17F1E, 0xA9E17E1C, 0xA9FF7D1A, 0xAA1B4810 -.word 0xAA246C18, 0xAA386E1C, 0xAA4F6E1C, 0xAA666F1E, 0xAA7E6D1A, 0xAA936F1C, 0xAAAB5F1C, 0xAAC34B16 -.word 0xAACF5B16, 0xAAE15B16, 0xAAF35C18, 0xAB076B16, 0xAB194A14, 0xAB245C18, 0xAB387810, 0xAB4A4B10 -.word 0xAB565B16, 0xAB685B16, 0xAB7A5C18, 0xAB8E4A14, 0xAB992B16, 0xAB9F2B16, 0xABA55B16, 0xABB74A14 -.word 0xABC24B16, 0xABCE6B16, 0xABE05B16, 0xABF25B16, 0xAC045C18, 0xAC186B16, 0xAC2A4A14, 0xAC35560E -.word 0xAC405810, 0xAC4E5B16, 0xAC604B16, 0xAC6C5C18, 0xAC804A14, 0xAC8B5F1A, 0xACA36F1A, 0xACBB4D14 -.word 0xACC96F1A, 0xACE12C18, 0xACE85318, 0xACEE8C18, 0xAD087E18, 0xAD266B16, 0xAD388C18, 0xAD522318 -.word 0xAD543F18, 0xAD643F18, 0xAD745318, 0xAD7A8710, 0xAD8A2302, 0xAD8C710A, 0xAD902102, 0xAD915E1A -.word 0xADA85B16, 0xADBA4B16, 0xADC65B16, 0xADD85B16, 0xADEA7B16, 0xAE025B16, 0xAE145B16, 0xAE267B16 -.word 0xAE3E5B16, 0xAE505B16, 0xAE622710, 0xAE662910, 0xAE6B7A12, 0xAE81740C, 0xAE8B7A12, 0xAEA16C18 -.word 0xAEB58C18, 0xAECF7C18, 0xAEE96C18, 0xAEFD6C18, 0xAF116C18, 0xAF255C18, 0xAF395C18, 0xAF4D6C18 -.word 0xAF616C18, 0xAF752C18, 0xAF7C6C18, 0xAF908C18, 0xAFAA5C18, 0xAFBE8C18, 0xAFD87C18, 0xAFF26C18 -.word 0xB0066C18, 0xB01A7C18, 0xB0346C18, 0xB0486C18, 0xB05C6C18, 0xB0706C18, 0xB0847C18, 0xB09EAC18 -.word 0xB0BF8C18, 0xB0D98C18, 0xB0F36C18, 0xB1073F1C, 0xB1175E1A, 0xB12E3F1C, 0xB13E5216, 0xB14380FC -.word 0xB1455F1C, 0xB15D5912, 0xB16C5C18, 0xB1805810, 0xB18E5C18, 0xB1A25912, 0xB1B14C18, 0xB1BE5C12 -.word 0xB1D25C18, 0xB1E62C18, 0xB1ED4F18, 0xB1FD6C18, 0xB2112C18, 0xB2187912, 0xB22C5912, 0xB23B5912 -.word 0xB24A5C12, 0xB25E5C12, 0xB2725912, 0xB2815A14, 0xB2924B16, 0xB29E5810, 0xB2AC7810, 0xB2BE8810 -.word 0xB2D07810, 0xB2E27A10, 0xB2F85810, 0xB3065E16, 0xB31D1C18, 0xB3245E16, 0xB33B6116, 0xB33E6C18 -.word 0xB3525E16, 0xB3692B10, 0xB36F6C14, 0xB3837B16, 0xB39B7914, 0xB3AF8B16, 0xB3C71C18, 0xB3CE7D16 -.word 0xB3EA4016, 0xB3EB7B16, 0xB4033618, 0xB40AA912, 0xB423820C, 0xB4296B16, 0xB43B7B16, 0xB4538016 -.word 0xB4553218, 0xB4588A14, 0xB46E3418, 0xB4733418, 0xB4783118, 0xB47A8A10, 0xB4906E16, 0xB4A7430E -.word 0xB4AB2302, 0xB4AD3418, 0xB4B23618, 0xB4B9A912, 0xB4D28B16, 0xB4EA8216, 0xB4F08910, 0xB5046B10 -.word 0xB5167E1C, 0xB5347E1C, 0xB5527F1E, 0xB5727E1C, 0xB5907E1C, 0xB5AE7F1E, 0xB5CE8C18, 0xB5E86E18 -.word 0xB5FF5F1E, 0xB6175F1E, 0xB62F5F1E, 0xB6475E1C, 0xB65E3F1E, 0xB66E3F1E, 0xB67E5F1E, 0xB6964E1C -.word 0xB6A57C18, 0xB6BF7E1C, 0xB6DD6F1E, 0xB6F56F1E, 0xB70D6F1E, 0xB7256F1E, 0xB73D6E1C, 0xB7547812 -.word 0xB7668C18, 0xB7806E1C, 0xB7976E1C, 0xB7AE6E1C, 0xB7C56D1A, 0xB7DA8D1A, 0xB7F68E1C, 0xB8146D1A -.word 0xB8295B16, 0xB83B5B16, 0xB84D5C18, 0xB8616B16, 0xB8735A14, 0xB8845C18, 0xB8988912, 0xB8AC5D12 -.word 0xB8C15B16, 0xB8D35B16, 0xB8E55B16, 0xB8F75A14, 0xB9083B16, 0xB9143B16, 0xB9205B16, 0xB9324A14 -.word 0xB93D5B16, 0xB94F6B16, 0xB9615B16, 0xB9735B16, 0xB9855C18, 0xB9996B16, 0xB9AB5A14, 0xB9BC8710 -.word 0xB9CC7B14, 0xB9E45B16, 0xB9F65B16, 0xBA085B16, 0xBA1A5A14, 0xBA2B7C16, 0xBA455C16, 0xBA597B14 -.word 0xBA716F18, 0xBA893B16, 0xBA956414, 0xBA9D6912, 0xBAAC6D16, 0xBAC17B14, 0xBAD97B14, 0xBAF14414 -.word 0xBAF64D16, 0xBB043D16, 0xBB127912, 0xBB266912, 0xBB353302, 0xBB39610A, 0xBB3C3202, 0xBB3F8D16 -.word 0xBB5B6B16, 0xBB6D5B16, 0xBB7F7B16, 0xBB976B16, 0xBBA97B16, 0xBBC17B16, 0xBBD97B16, 0xBBF16B16 -.word 0xBC037B16, 0xBC1B7B16, 0xBC333810, 0xBC3C3910, 0xBC467C18, 0xBC60730E, 0xBC687C18, 0xBC826B16 -.word 0xBC947B16, 0xBCAC7B16, 0xBCC47B16, 0xBCDC6B16, 0xBCEE7B16, 0xBD067B16, 0xBD1E7B16, 0xBD367B16 -.word 0xBD4E8B16, 0xBD665B16, 0xBD786B16, 0xBD8A8B16, 0xBDA27B16, 0xBDBA7B16, 0xBDD27B16, 0xBDEA6B16 -.word 0xBDFC8B16, 0xBE147C16, 0xBE2E7B16, 0xBE466B16, 0xBE587B16, 0xBE707B16, 0xBE887B16, 0xBEA08B16 -.word 0xBEB87B16, 0xBED07B16, 0xBEE87B16, 0xBF003D18, 0xBF0E8D16, 0xBF2A3D18, 0xBF387114, 0xBF3CA0FA -.word 0xBF3F6F1A, 0xBF577810, 0xBF69AB16, 0xBF878810, 0xBF997B16, 0xBFB17810, 0xBFC36B16, 0xBFD58910 -.word 0xBFE97B16, 0xC0015B16, 0xC0134C16, 0xC0208B16, 0xC0384B16, 0xC0447810, 0xC0567810, 0xC0686810 -.word 0xC0767910, 0xC08A7910, 0xC09E6810, 0xC0AC6810, 0xC0BA5A14, 0xC0CB7810, 0xC0DD7810, 0xC0EF8810 -.word 0xC1018810, 0xC1137910, 0xC1276810, 0xC1354D18, 0xC1432D18, 0xC14A4D18, 0xC1585116, 0xC15B6F1C -.word 0xC2276F16, 0xC23F6F16, 0xC1738A16, 0xC189AB16, 0xC2576F16, 0xC1A7C914, 0xC1C52D16, 0xC1CC6A16 -.word 0xC1DD6116, 0xC26F6F16, 0xC2876F16, 0xC1E07D18, 0xC1FCC40C, 0xC20B7D18, 0xC29F6F16, 0xC2B76F16 -.word 0xC2CF4318, 0xC2D3A914, 0xC2ECA912, 0xC305AB16, 0xC4126F18, 0xC323A910, 0xC33C8914, 0xC350430E -.word 0xC3543404, 0xC359DB14, 0xC383A016, 0xC386DB16, 0xC3B0ED18, 0xC3E1ED18, 0xC42A6F18, 0xC4426F18 -.word 0xC45AA20E, 0xC4624306, 0xC4666D18, 0xC47BA810, 0xC4925A18, 0xC4A35A12, 0xC4B46A18, 0xC4C57A12 -.word 0xC4DB5D18, 0xC4F05D18, 0xC5055D18, 0xC51A6D18, 0xC52FD914, 0xC552D914, 0xC575B914, 0xC593E510 -.word 0xC5A8F50E, 0xC5C07D16, 0xC5DC6D16, 0xC5F1EB14, 0xC61BEB14, 0xC645D912, 0xC668D912, 0xC68BAD16 -.word 0xC6AEAD16, 0xC6D1FA14, 0xC6FD9C16, 0xC71E6F16, 0xC7366F16, 0xC74E6F16, 0xC7666F16, 0xC77E6F16 -.word 0xC796E612, 0xC7AFA810, 0xC7C65118, 0xC7C96318, 0xC7CF3418, 0xC7D44810, 0xC7DDD30E, 0xC7EBA30E -.word 0xC7F55D18, 0xC80AC20E, 0xC8138B16, 0xC82BB912, 0xC8496F1A, 0xC8616F1A, 0xC8796F1A, 0xC8916F1A -.word 0xC8A90F17, 0xC8E9960E, 0xC8FB7810, 0xC90D960E, 0xC91F7810, 0xC9319E14, 0xC957F810, 0xC97B9E16 -.word 0xC9A1F810, 0xC9C5CC14, 0xC9ECDC16, 0xCA1ADC14, 0xCA48DC14, 0xCA76EF16, 0xCAAE070F, 0xCACE070F -.word 0xCAEE8F16, 0xCB0EED14, 0xCB3FED14, 0xCB70ED14, 0xCBA1EF16, 0xCBD9CB12, 0xCBFDCB12, 0xCC21CB12 -ENDDATA(asc2tbl) +DATA(D_801D04A0) + .word 0x00009D14 + .word 0x00232A14 + .word 0x00296314 + .word 0x002F8A14 + .word 0x00457E18 + .word 0x0063CA14 + .word 0x0084AA14 + .word 0x00A03314 + .word 0x00A45E14 + .word 0x00BB4E14 + .word 0x00CA6514 + .word 0x00D3770E + .word 0x00E33302 + .word 0x00E78108 + .word 0x00EB2102 + .word 0x00EC6C14 + .word 0x01008A14 + .word 0x01163A14 + .word 0x01217A14 + .word 0x01377A14 + .word 0x014D8A14 + .word 0x01638A14 + .word 0x01798A14 + .word 0x018F7A14 + .word 0x01A58A14 + .word 0x01BB8A14 + .word 0x01D1170E + .word 0x01D5490E + .word 0x01DF770E + .word 0x01EF740A + .word 0x01F9770E + .word 0x02097A14 + .word 0x021FDC16 + .word 0x024DBA14 + .word 0x026E7A14 + .word 0x0284BA14 + .word 0x02A59A14 + .word 0x02C16A14 + .word 0x02D26A14 + .word 0x02E3BA14 + .word 0x03048A14 + .word 0x031A1A14 + .word 0x03206A14 + .word 0x03318A14 + .word 0x03476A14 + .word 0x0358CA14 + .word 0x03799A14 + .word 0x0395CA14 + .word 0x03B67A14 + .word 0x03CCCA14 + .word 0x03ED8A14 + .word 0x04037A14 + .word 0x04196A14 + .word 0x042A8A14 + .word 0x0440AA14 + .word 0x045CDA14 + .word 0x04839A14 + .word 0x049F9A14 + .word 0x04BB7A14 + .word 0x04D14D14 + .word 0x04DF5C14 + .word 0x04F33D14 + .word 0x05015216 + .word 0x050681FA + .word 0x050A9D14 + .word 0x052D9810 + .word 0x05449A14 + .word 0x05609810 + .word 0x05779A14 + .word 0x05939810 + .word 0x05AA5A14 + .word 0x05BB9C10 + .word 0x05DC7A14 + .word 0x05F22A14 + .word 0x05F83D14 + .word 0x06067A14 + .word 0x061C2A14 + .word 0x0622D810 + .word 0x06427810 + .word 0x06549810 + .word 0x066B9B10 + .word 0x06899B10 + .word 0x06A74810 + .word 0x06B06810 + .word 0x06BE5A14 + .word 0x06CF770E + .word 0x06DF870E + .word 0x06EFB70E + .word 0x0707670E + .word 0x07138A0E + .word 0x0729670E + .word 0x07356D14 + .word 0x074A1F16 + .word 0x07526D14 + .word 0x07675216 + .word 0x076C9D14 + .word 0x078F9D14 + .word 0x07B22A0E + .word 0x07B88B14 + .word 0x07D08A14 + .word 0x07E69816 + .word 0x07FD9A14 + .word 0x08193F16 + .word 0x08296C14 + .word 0x083D5114 + .word 0x0840CA14 + .word 0x08616614 + .word 0x086C650C + .word 0x0875830A + .word 0x087D9D14 + .word 0x08A0CA14 + .word 0x08C14114 + .word 0x08C35318 + .word 0x08C98810 + .word 0x08DB9D14 + .word 0x08FE9D14 + .word 0x09213216 + .word 0x09249A0E + .word 0x09407A14 + .word 0x0956440E + .word 0x095B3302 + .word 0x095F9D14 + .word 0x09826614 + .word 0x098D650C + .word 0x09960A15 + .word 0x09C2C514 + .word 0x09D4070F + .word 0x09F47A0E + .word 0x0A0ABE1C + .word 0x0A37BE1C + .word 0x0A64BE1C + .word 0x0A91BD1A + .word 0x0ABBBD1A + .word 0x0AE5BE1C + .word 0x0B12FA14 + .word 0x0B3EBE14 + .word 0x0B6B7E1C + .word 0x0B897E1C + .word 0x0BA77E1C + .word 0x0BC57D1A + .word 0x0BE13E1C + .word 0x0BF04E1C + .word 0x0BFF4E1C + .word 0x0C0E5D1A + .word 0x0C239D14 + .word 0x0C469D1A + .word 0x0C69BE1C + .word 0x0C96BE1C + .word 0x0CC3BE1C + .word 0x0CF0BD1A + .word 0x0D1ABD1A + .word 0x0D44770E + .word 0x0D54CC16 + .word 0x0D7B8E1C + .word 0x0D998E1C + .word 0x0DB77E1C + .word 0x0DD57D1A + .word 0x0DF19D14 + .word 0x0E149D14 + .word 0x0E379A14 + .word 0x0E539B16 + .word 0x0E719B16 + .word 0x0E8F9B16 + .word 0x0EAD9B16 + .word 0x0ECB9A14 + .word 0x0EE79B16 + .word 0x0F050811 + .word 0x0F299B10 + .word 0x0F479B16 + .word 0x0F659B16 + .word 0x0F839B16 + .word 0x0FA19A14 + .word 0x0FBD3B16 + .word 0x0FC93A16 + .word 0x0FD44B16 + .word 0x0FE04A14 + .word 0x0FEB7912 + .word 0x0FFF8B16 + .word 0x10179B16 + .word 0x10359B16 + .word 0x10539B16 + .word 0x10719B16 + .word 0x108F9A14 + .word 0x10AB760C + .word 0x10B99910 + .word 0x10D28B16 + .word 0x10EA8B16 + .word 0x11028B16 + .word 0x111A8A14 + .word 0x11309D14 + .word 0x11539D14 + .word 0x11769D14 + .word 0x11996F18 + .word 0x11B13A14 + .word 0x11BC7514 + .word 0x11C88912 + .word 0x11DC9D16 + .word 0x11FFEA14 + .word 0x1226CA14 + .word 0x12474514 + .word 0x124D4D14 + .word 0x125B4D14 + .word 0x12696614 + .word 0x1274870E + .word 0x12843404 + .word 0x12899108 + .word 0x128E4204 + .word 0x12916C14 + .word 0x12A5AA14 + .word 0x12C17A14 + .word 0x12D79A14 + .word 0x12F3AA14 + .word 0x130FAA14 + .word 0x132B9B16 + .word 0x1349AA14 + .word 0x1365AA14 + .word 0x1381AA14 + .word 0x139DAA14 + .word 0x13B9370E + .word 0x13C1390E + .word 0x13CB770E + .word 0x13DB750C + .word 0x13E7770E + .word 0x13F79A14 + .word 0x1413CC14 + .word 0x143ACA14 + .word 0x145BBA14 + .word 0x147CBA14 + .word 0x149DBA14 + .word 0x14BEBA14 + .word 0x14DFBA14 + .word 0x1500BA14 + .word 0x1521CA14 + .word 0x15426A14 + .word 0x1553AA14 + .word 0x156FCA14 + .word 0x1590AA14 + .word 0x15ACFA14 + .word 0x15D8CA14 + .word 0x15F9BA14 + .word 0x161AAA14 + .word 0x1636CE14 + .word 0x1663CA14 + .word 0x16849A14 + .word 0x16A0CA14 + .word 0x16C1BA14 + .word 0x16E2CA14 + .word 0x1703EA14 + .word 0x172ACA14 + .word 0x174BCA14 + .word 0x176CAA14 + .word 0x17883D14 + .word 0x17966C14 + .word 0x17AA3D14 + .word 0x17B85214 + .word 0x17BD92FC + .word 0x17C55F1A + .word 0x17DD870E + .word 0x17EDAA14 + .word 0x1809870E + .word 0x18199A14 + .word 0x1835970E + .word 0x18497A14 + .word 0x185F9C10 + .word 0x1880BA14 + .word 0x18A15A14 + .word 0x18B26E14 + .word 0x18C9AA14 + .word 0x18E55A14 + .word 0x18F6F70E + .word 0x1916A70E + .word 0x192A970E + .word 0x193EAB0E + .word 0x195C9B0E + .word 0x197A770E + .word 0x198A770E + .word 0x199A6912 + .word 0x19A9A70E + .word 0x19BDA60E + .word 0x19CFD70E + .word 0x19EBA70E + .word 0x19FFAB0E + .word 0x1A1D870E + .word 0x1A2D6D14 + .word 0x1A423F16 + .word 0x1A526D14 + .word 0x1A675214 + .word 0x1A6C6F18 + .word 0x1A846F16 + .word 0x1A9C3A0E + .word 0x1AA78B14 + .word 0x1ABFAA14 + .word 0x1ADB8614 + .word 0x1AE9BA14 + .word 0x1B0A2F16 + .word 0x1B128A14 + .word 0x1B285214 + .word 0x1B2DBB14 + .word 0x1B516614 + .word 0x1B5C860C + .word 0x1B6A730A + .word 0x1B726E16 + .word 0x1B89BB14 + .word 0x1BAD5012 + .word 0x1BAF5316 + .word 0x1BB58910 + .word 0x1BC95F18 + .word 0x1BE15F18 + .word 0x1BF95316 + .word 0x1BFFA90C + .word 0x1C188A14 + .word 0x1C2E540E + .word 0x1C363404 + .word 0x1C3B6D14 + .word 0x1C506614 + .word 0x1C5B860C + .word 0x1C690913 + .word 0x1C91C512 + .word 0x1CA3D70E + .word 0x1CBF9A0E + .word 0x1CDBCD1A + .word 0x1D05CD1A + .word 0x1D2FCD1A + .word 0x1D59CD1A + .word 0x1D83CD1A + .word 0x1DADCE1C + .word 0x1DDA2A15 + .word 0x1E0CBD14 + .word 0x1E36BD1A + .word 0x1E60BD1A + .word 0x1E8ABD1A + .word 0x1EB4BC18 + .word 0x1EDB6D1A + .word 0x1EF06D1A + .word 0x1F056D1A + .word 0x1F1A6D1A + .word 0x1F2F5F1A + .word 0x1F47BD1A + .word 0x1F71CD1A + .word 0x1F9BCD1A + .word 0x1FC5CD1A + .word 0x1FEFCD1A + .word 0x2019CD1A + .word 0x2043970E + .word 0x2057CB14 + .word 0x207BAD1A + .word 0x209EBD1A + .word 0x20C8BD1A + .word 0x20F2BD1A + .word 0x211C6F1A + .word 0x21345F1A + .word 0x214CAA14 + .word 0x21689B16 + .word 0x21869B16 + .word 0x21A49A14 + .word 0x21C0AA14 + .word 0x21DC9A14 + .word 0x21F89B16 + .word 0x2216D70E + .word 0x22329B0E + .word 0x22508B16 + .word 0x22689B16 + .word 0x22869A14 + .word 0x22A29A14 + .word 0x22BE5B16 + .word 0x22D05B16 + .word 0x22E25A14 + .word 0x22F35A14 + .word 0x23048912 + .word 0x2318AA14 + .word 0x23349B16 + .word 0x23529B16 + .word 0x23709A14 + .word 0x238C9A14 + .word 0x23A89A14 + .word 0x23C49910 + .word 0x23DD9A10 + .word 0x23F9AB16 + .word 0x2417AB16 + .word 0x2435AA14 + .word 0x2451AA14 + .word 0x246D5F18 + .word 0x24855F18 + .word 0x249DAE14 + .word 0x24C39D14 + .word 0x24E62A14 + .word 0x24EC5314 + .word 0x24F28912 + .word 0x25068D16 + .word 0x2522CA14 + .word 0x2543CA14 + .word 0x25642314 + .word 0x25663C14 + .word 0x25733C14 + .word 0x25806514 + .word 0x2589770E + .word 0x25993302 + .word 0x259D9006 + .word 0x25A03102 + .word 0x25A26C14 + .word 0x25B69A14 + .word 0x25D26A14 + .word 0x25E38A14 + .word 0x25F99A14 + .word 0x26159A14 + .word 0x26318A14 + .word 0x26478A14 + .word 0x265D9912 + .word 0x26769A14 + .word 0x26928A14 + .word 0x26A8260C + .word 0x26AC480C + .word 0x26B5870E + .word 0x26C5740A + .word 0x26CF770E + .word 0x26DF8A14 + .word 0x26F5DC14 + .word 0x2723CA14 + .word 0x2744A912 + .word 0x275DAA14 + .word 0x2779B912 + .word 0x2797A912 + .word 0x27B0A912 + .word 0x27C9BA14 + .word 0x27EAC912 + .word 0x28085912 + .word 0x28179912 + .word 0x2830B912 + .word 0x284E9912 + .word 0x2867D912 + .word 0x288AB912 + .word 0x28A8CA14 + .word 0x28C99912 + .word 0x28E2CD14 + .word 0x290CB912 + .word 0x292A9A14 + .word 0x2946A912 + .word 0x295FB912 + .word 0x297DC912 + .word 0x299B0913 + .word 0x29C3C912 + .word 0x29E1B912 + .word 0x29FF9912 + .word 0x2A183B12 + .word 0x2A246C14 + .word 0x2A383B12 + .word 0x2A445214 + .word 0x2A4981FA + .word 0x2A4D9D14 + .word 0x2A70970E + .word 0x2A849A14 + .word 0x2AA0770E + .word 0x2AB09A14 + .word 0x2ACC870E + .word 0x2ADC6A14 + .word 0x2AED9C10 + .word 0x2B0E9A14 + .word 0x2B2A4912 + .word 0x2B346D12 + .word 0x2B499A14 + .word 0x2B655A14 + .word 0x2B76F70E + .word 0x2B96A70E + .word 0x2BAA970E + .word 0x2BBE9B0E + .word 0x2BDCAB0E + .word 0x2BFA770E + .word 0x2C0A770E + .word 0x2C1A6912 + .word 0x2C29A70E + .word 0x2C3D970E + .word 0x2C51C70E + .word 0x2C69A70E + .word 0x2C7D9B0E + .word 0x2C9B770E + .word 0x2CAB5C12 + .word 0x2CBF2F16 + .word 0x2CC76C12 + .word 0x2CDB5214 + .word 0x2CE08D14 + .word 0x2CFC9D14 + .word 0x2D1F2A0E + .word 0x2D257B14 + .word 0x2D3D9A14 + .word 0x2D599714 + .word 0x2D6DB912 + .word 0x2D8B2F16 + .word 0x2D937A14 + .word 0x2DA95112 + .word 0x2DACCB14 + .word 0x2DD07714 + .word 0x2DE0760C + .word 0x2DEE730A + .word 0x2DF69D14 + .word 0x2E19BB14 + .word 0x2E3D5112 + .word 0x2E405316 + .word 0x2E468810 + .word 0x2E589D14 + .word 0x2E7B9D14 + .word 0x2E9E4214 + .word 0x2EA19A0C + .word 0x2EBD7A14 + .word 0x2ED3440E + .word 0x2ED82302 + .word 0x2EDA8D14 + .word 0x2EF66714 + .word 0x2F02760C + .word 0x2F100A15 + .word 0x2F3CC614 + .word 0x2F51C70E + .word 0x2F698A0E + .word 0x2F7FCD1A + .word 0x2FA9CD1A + .word 0x2FD3BD1A + .word 0x2FFDCD1A + .word 0x3027CC18 + .word 0x304ECE1C + .word 0x307B0913 + .word 0x30A3BD14 + .word 0x30CDAD1A + .word 0x30F0BD1A + .word 0x311ABD1A + .word 0x3144AC18 + .word 0x31654D1A + .word 0x31734D1A + .word 0x31814D1A + .word 0x318F5C18 + .word 0x31A39D14 + .word 0x31C6BD1A + .word 0x31F0CD1A + .word 0x321ACD1A + .word 0x3244CD1A + .word 0x326ECD1A + .word 0x3298CC18 + .word 0x32BFA70E + .word 0x32D3BB14 + .word 0x32F7BD1A + .word 0x3321CD1A + .word 0x334BBD1A + .word 0x3375BC18 + .word 0x339C8D14 + .word 0x33B88D14 + .word 0x33D49A14 + .word 0x33F09A14 + .word 0x340C9A14 + .word 0x34289A14 + .word 0x34449A14 + .word 0x34609912 + .word 0x34799B16 + .word 0x3497C70E + .word 0x34AF7A0E + .word 0x34C58A14 + .word 0x34DB8A14 + .word 0x34F17A14 + .word 0x35077912 + .word 0x351B5A14 + .word 0x352C5A14 + .word 0x353D5A14 + .word 0x354E6912 + .word 0x355D7912 + .word 0x35719A14 + .word 0x358D8A14 + .word 0x35A38A14 + .word 0x35B98A14 + .word 0x35CF8A14 + .word 0x35E58912 + .word 0x35F9870E + .word 0x36099910 + .word 0x3622AA14 + .word 0x363EAA14 + .word 0x365AAA14 + .word 0x36769912 + .word 0x368F8D14 + .word 0x36AB8D14 + .word 0x36C79D12 + .word 0x36EA6F18 + .word 0x37024912 + .word 0x370C7412 + .word 0x37166B14 + .word 0x37288C14 + .word 0x37427912 + .word 0x37568810 + .word 0x37684412 + .word 0x376D5C12 + .word 0x37815C12 + .word 0x37957612 + .word 0x37A39710 + .word 0x37B74404 + .word 0x37BCA108 + .word 0x37C13306 + .word 0x37C57B14 + .word 0x37DD8912 + .word 0x37F17912 + .word 0x38057912 + .word 0x38198912 + .word 0x382D8912 + .word 0x38417912 + .word 0x38557912 + .word 0x38697912 + .word 0x387D8912 + .word 0x38918912 + .word 0x38A5370E + .word 0x38AD480C + .word 0x38B69710 + .word 0x38CA940E + .word 0x38D79710 + .word 0x38EB7912 + .word 0x38FF8B14 + .word 0x3917A912 + .word 0x39309912 + .word 0x39498912 + .word 0x395D8912 + .word 0x39719912 + .word 0x398A9912 + .word 0x39A39912 + .word 0x39BC9912 + .word 0x39D57912 + .word 0x39E99912 + .word 0x3A029912 + .word 0x3A1B9912 + .word 0x3A34A912 + .word 0x3A4D9912 + .word 0x3A669912 + .word 0x3A7F8912 + .word 0x3A939B12 + .word 0x3AB19912 + .word 0x3ACA8912 + .word 0x3ADE8912 + .word 0x3AF29912 + .word 0x3B0B9912 + .word 0x3B24A912 + .word 0x3B3D8912 + .word 0x3B518912 + .word 0x3B657912 + .word 0x3B794C12 + .word 0x3B867B14 + .word 0x3B9E4C12 + .word 0x3BAB6214 + .word 0x3BB0A2FC + .word 0x3BB85F1A + .word 0x3BD0870E + .word 0x3BE09912 + .word 0x3BF9870E + .word 0x3C098912 + .word 0x3C1D870E + .word 0x3C2D8912 + .word 0x3C419A0E + .word 0x3C5D8912 + .word 0x3C718A14 + .word 0x3C877D14 + .word 0x3CA39912 + .word 0x3CBC8912 + .word 0x3CD0A70E + .word 0x3CE4970E + .word 0x3CF8970E + .word 0x3D0C9B0E + .word 0x3D2AAB0E + .word 0x3D48970E + .word 0x3D5C770E + .word 0x3D6C8912 + .word 0x3D80970E + .word 0x3D94970E + .word 0x3DA8A70E + .word 0x3DBC870E + .word 0x3DCC9A0E + .word 0x3DE8770E + .word 0x3DF86D12 + .word 0x3E0D2F16 + .word 0x3E156D12 + .word 0x3E2A6212 + .word 0x3E2F6F16 + .word 0x3E476F16 + .word 0x3E5F4912 + .word 0x3E697A14 + .word 0x3E7F7912 + .word 0x3E938612 + .word 0x3EA19912 + .word 0x3EBA3F16 + .word 0x3ECA8A12 + .word 0x3EE06112 + .word 0x3EE3A812 + .word 0x3EFA7712 + .word 0x3F0A550C + .word 0x3F13950E + .word 0x3F226E16 + .word 0x3F399812 + .word 0x3F506112 + .word 0x3F534316 + .word 0x3F578812 + .word 0x3F695F18 + .word 0x3F815F18 + .word 0x3F995214 + .word 0x3F9E9A0E + .word 0x3FBA7912 + .word 0x3FCE320C + .word 0x3FD14404 + .word 0x3FD66D14 + .word 0x3FEB7712 + .word 0x3FFB650C + .word 0x40048710 + .word 0x40148310 + .word 0x401C860E + .word 0x402A7912 + .word 0x403EAC18 + .word 0x405FAC18 + .word 0x4080AC18 + .word 0x40A1AB16 + .word 0x40BFAB16 + .word 0x40DDAD1A + .word 0x4100B912 + .word 0x411E8C12 + .word 0x41388C18 + .word 0x41529C18 + .word 0x41739C18 + .word 0x41948B16 + .word 0x41AC7C18 + .word 0x41C67C18 + .word 0x41E07C18 + .word 0x41FA7B16 + .word 0x42125F1A + .word 0x422AAB16 + .word 0x42489C18 + .word 0x42699C18 + .word 0x428A9C18 + .word 0x42AB9B16 + .word 0x42C99B16 + .word 0x42E7870E + .word 0x42F79A12 + .word 0x43139C18 + .word 0x43349C18 + .word 0x4355AC18 + .word 0x4376AB16 + .word 0x43946F1A + .word 0x43AC5F1A + .word 0x43C48912 + .word 0x43D88A14 + .word 0x43EE8A14 + .word 0x44049A14 + .word 0x44209912 + .word 0x44398912 + .word 0x444D8B16 + .word 0x4465970E + .word 0x44798A0E + .word 0x448F8A14 + .word 0x44A58A14 + .word 0x44BB9A14 + .word 0x44D79912 + .word 0x44F08A14 + .word 0x45068A14 + .word 0x451C7A14 + .word 0x45327912 + .word 0x45468912 + .word 0x455A9912 + .word 0x45738A14 + .word 0x45898A14 + .word 0x459F9912 + .word 0x45B89912 + .word 0x45D19912 + .word 0x45EAA912 + .word 0x46039910 + .word 0x461C9A14 + .word 0x46389A14 + .word 0x46548A14 + .word 0x466A9912 + .word 0x46835F18 + .word 0x469B5F18 + .word 0x46B38C12 + .word 0x46CD3C16 + .word 0x46DA3C16 + .word 0x46E77516 + .word 0x46F39A14 + .word 0x470F7E18 + .word 0x472DDC16 + .word 0x475BBC16 + .word 0x47824516 + .word 0x47884F18 + .word 0x47984F18 + .word 0x47A85516 + .word 0x47B1870E + .word 0x47C15504 + .word 0x47CA810A + .word 0x47CE4304 + .word 0x47D28F18 + .word 0x47F29C16 + .word 0x48134B16 + .word 0x481F8B16 + .word 0x48378C16 + .word 0x48519B16 + .word 0x486F8C16 + .word 0x48898C16 + .word 0x48A38B16 + .word 0x48BB8C16 + .word 0x48D58C16 + .word 0x48EF380E + .word 0x48F84A0E + .word 0x4903970E + .word 0x4917850C + .word 0x4923870E + .word 0x49337C16 + .word 0x494DCC16 + .word 0x4974BB16 + .word 0x49988B16 + .word 0x49B09C16 + .word 0x49D1AB16 + .word 0x49EF7B16 + .word 0x4A077B16 + .word 0x4A1FBC16 + .word 0x4A46AB16 + .word 0x4A643B16 + .word 0x4A706C16 + .word 0x4A849B16 + .word 0x4AA26B16 + .word 0x4AB4DC16 + .word 0x4AE2AC16 + .word 0x4B03CC16 + .word 0x4B2A8B16 + .word 0x4B42CC16 + .word 0x4B698B16 + .word 0x4B818C16 + .word 0x4B9B7B16 + .word 0x4BB39C16 + .word 0x4BD4BC16 + .word 0x4BFBFC16 + .word 0x4C2FAB16 + .word 0x4C4DAB16 + .word 0x4C6B9B16 + .word 0x4C893E18 + .word 0x4C988C18 + .word 0x4CB24E18 + .word 0x4CC16316 + .word 0x4CC781FC + .word 0x4CCB3C16 + .word 0x4CD8880E + .word 0x4CEA8D18 + .word 0x4D06680E + .word 0x4D149D18 + .word 0x4D37880E + .word 0x4D495C18 + .word 0x4D5D8B0E + .word 0x4D757C18 + .word 0x4D8F3B16 + .word 0x4D9B3F16 + .word 0x4DAB8C18 + .word 0x4DC53C18 + .word 0x4DD2B70E + .word 0x4DEA770E + .word 0x4DFA980E + .word 0x4E119B0E + .word 0x4E2F9B0E + .word 0x4E4D670E + .word 0x4E59680E + .word 0x4E674912 + .word 0x4E71780E + .word 0x4E83980E + .word 0x4E9AD80E + .word 0x4EBAA70E + .word 0x4ECE9B0E + .word 0x4EEC770E + .word 0x4EFC5F18 + .word 0x4F142C18 + .word 0x4F1B4F18 + .word 0x4F2B7114 + .word 0x4F2F3C16 + .word 0x4F3C3C10 + .word 0x4F493B0E + .word 0x4F556A14 + .word 0x4F669C16 + .word 0x4F879810 + .word 0x4F9E9B16 + .word 0x4FBC2C18 + .word 0x4FC38E18 + .word 0x4FE16216 + .word 0x4FE6DC16 + .word 0x50146616 + .word 0x501F7710 + .word 0x502F840C + .word 0x50393C1A + .word 0x5046DC16 + .word 0x50747116 + .word 0x50784316 + .word 0x507C8912 + .word 0x50903C14 + .word 0x509D3C14 + .word 0x50AA4316 + .word 0x50AE7B0E + .word 0x50C6AE16 + .word 0x50EC6610 + .word 0x50F75504 + .word 0x51003C18 + .word 0x510D6616 + .word 0x51188710 + .word 0x5128FC16 + .word 0x515CE616 + .word 0x5175D80E + .word 0x51958B0E + .word 0x51ADCC18 + .word 0x51D4BC18 + .word 0x51FBBC18 + .word 0x5222BC18 + .word 0x5249CC18 + .word 0x5270BC18 + .word 0x5297FB16 + .word 0x52C79E16 + .word 0x52ED6C18 + .word 0x53016C18 + .word 0x53157C18 + .word 0x532F7C18 + .word 0x53494C18 + .word 0x53564C18 + .word 0x53636C18 + .word 0x53777C18 + .word 0x53913C18 + .word 0x539EAD18 + .word 0x53C1CD18 + .word 0x53EBCD18 + .word 0x5415CD18 + .word 0x543FCD18 + .word 0x5469CC18 + .word 0x5490970E + .word 0x54A4CC16 + .word 0x54CB9D18 + .word 0x54EE9D18 + .word 0x55119D18 + .word 0x55349D18 + .word 0x55573C18 + .word 0x55643C18 + .word 0x55719D18 + .word 0x55948C16 + .word 0x55AE9C16 + .word 0x55CF8C16 + .word 0x55E99B14 + .word 0x56078C16 + .word 0x56219C16 + .word 0x5642C80E + .word 0x565D6A0E + .word 0x566E8C16 + .word 0x56887C16 + .word 0x56A28C16 + .word 0x56BC7C16 + .word 0x56D64B16 + .word 0x56E24B16 + .word 0x56EE6B16 + .word 0x57007B16 + .word 0x57187B16 + .word 0x57307A14 + .word 0x57469C16 + .word 0x57678C16 + .word 0x57818C16 + .word 0x579B9B14 + .word 0x57B99C16 + .word 0x57DA880E + .word 0x57EC980E + .word 0x58038C16 + .word 0x581D8C16 + .word 0x58378C16 + .word 0x58518C16 + .word 0x586B3C16 + .word 0x58783C16 + .word 0x58859F16 + .word 0x58AD6F18 + .word 0x58C55C16 + .word 0x58D98516 + .word 0x58E59B14 + .word 0x59038E18 + .word 0x5921BC16 + .word 0x5948AC16 + .word 0x59695516 + .word 0x59724F18 + .word 0x59825F18 + .word 0x599A6516 + .word 0x59A3970E + .word 0x59B75504 + .word 0x59C0810A + .word 0x59C43304 + .word 0x59C8AF18 + .word 0x59F09C16 + .word 0x5A115B16 + .word 0x5A239B16 + .word 0x5A418C16 + .word 0x5A5B9B16 + .word 0x5A799C16 + .word 0x5A9A9C16 + .word 0x5ABBAC16 + .word 0x5ADC8C16 + .word 0x5AF69C16 + .word 0x5B17480E + .word 0x5B206A0E + .word 0x5B31970E + .word 0x5B45950C + .word 0x5B54970E + .word 0x5B687C16 + .word 0x5B82CC16 + .word 0x5BA9BB16 + .word 0x5BCD9B16 + .word 0x5BEB9C16 + .word 0x5C0CBB16 + .word 0x5C309B16 + .word 0x5C4E9B16 + .word 0x5C6CBC16 + .word 0x5C93BB16 + .word 0x5CB75B16 + .word 0x5CC98C16 + .word 0x5CE3BB16 + .word 0x5D077B16 + .word 0x5D1FDC16 + .word 0x5D4DCC16 + .word 0x5D74DC16 + .word 0x5DA29B16 + .word 0x5DC0CC16 + .word 0x5DE79B16 + .word 0x5E059C16 + .word 0x5E268B16 + .word 0x5E3EAC16 + .word 0x5E5FBC16 + .word 0x5E860C17 + .word 0x5EBABB16 + .word 0x5EDEAB16 + .word 0x5EFCBB16 + .word 0x5F205E18 + .word 0x5F376E18 + .word 0x5F4E6E18 + .word 0x5F655316 + .word 0x5F6B91FC + .word 0x5F706F1A + .word 0x5F88980E + .word 0x5F9F9D18 + .word 0x5FC2680E + .word 0x5FD0AD18 + .word 0x5FF3880E + .word 0x60056C18 + .word 0x60199B0E + .word 0x60378C18 + .word 0x60515B16 + .word 0x60636F16 + .word 0x607B9C18 + .word 0x609C5C18 + .word 0x60B0C70E + .word 0x60C8870E + .word 0x60D8880E + .word 0x60EA9B0E + .word 0x61089B0E + .word 0x6126770E + .word 0x6136680E + .word 0x61446912 + .word 0x6153780E + .word 0x6165980E + .word 0x617CD80E + .word 0x619CA70E + .word 0x61B0AB0E + .word 0x61CEA70E + .word 0x61E26F18 + .word 0x61FA4C18 + .word 0x62076F18 + .word 0x621F7114 + .word 0x62236F18 + .word 0x623B6F16 + .word 0x62534B0E + .word 0x625F7A14 + .word 0x6275AC16 + .word 0x6296A810 + .word 0x62ADAB16 + .word 0x62CB4C18 + .word 0x62D88E18 + .word 0x62F66216 + .word 0x62FBDC16 + .word 0x63297616 + .word 0x63378710 + .word 0x6347940C + .word 0x63546F18 + .word 0x636CDC16 + .word 0x639A6116 + .word 0x639D4316 + .word 0x63A19912 + .word 0x63BA6F18 + .word 0x63D26F18 + .word 0x63EA5316 + .word 0x63F09B0E + .word 0x640E9E16 + .word 0x64346610 + .word 0x643F5504 + .word 0x64486F18 + .word 0x64607616 + .word 0x646E8710 + .word 0x647EFA14 + .word 0x64AAD514 + .word 0x64BFC60C + .word 0x64D47B0E + .word 0x64ECCC18 + .word 0x6513BC18 + .word 0x653ABC18 + .word 0x6561CC18 + .word 0x6588CC18 + .word 0x65AFBC18 + .word 0x65D6FB16 + .word 0x6606AE16 + .word 0x662C8C18 + .word 0x66468C18 + .word 0x66609C18 + .word 0x66819C18 + .word 0x66A25C18 + .word 0x66B66C18 + .word 0x66CA7C18 + .word 0x66E47C18 + .word 0x66FE6F1A + .word 0x6716CD18 + .word 0x6740DD18 + .word 0x6771CD18 + .word 0x679BCD18 + .word 0x67C5CD18 + .word 0x67EFDD18 + .word 0x6820A70E + .word 0x6834FC16 + .word 0x6868AD18 + .word 0x688BAD18 + .word 0x68AEAD18 + .word 0x68D1AD18 + .word 0x68F46F1A + .word 0x690C6F1A + .word 0x69249D18 + .word 0x69479C16 + .word 0x69689C16 + .word 0x69899C16 + .word 0x69AA9B14 + .word 0x69C89C16 + .word 0x69E99C16 + .word 0x6A0AD80E + .word 0x6A2A7A0E + .word 0x6A408C16 + .word 0x6A5A8C16 + .word 0x6A748C16 + .word 0x6A8E8C16 + .word 0x6AA85B16 + .word 0x6ABA5B16 + .word 0x6ACC6B16 + .word 0x6ADE6B16 + .word 0x6AF07B16 + .word 0x6B089A14 + .word 0x6B248C16 + .word 0x6B3E9C16 + .word 0x6B5F9C16 + .word 0x6B808B14 + .word 0x6B988C16 + .word 0x6BB2980E + .word 0x6BC9980E + .word 0x6BE08C16 + .word 0x6BFA8C16 + .word 0x6C148C16 + .word 0x6C2E8C16 + .word 0x6C486F18 + .word 0x6C606F18 + .word 0x6C78AF16 + .word 0x6CA06F18 + .word 0x6CB82A14 + .word 0x6CBE4314 + .word 0x6CC29A14 + .word 0x6CDE8D16 + .word 0x6CFADB14 + .word 0x6D249B14 + .word 0x6D422314 + .word 0x6D445D14 + .word 0x6D594D14 + .word 0x6D675414 + .word 0x6D6F870E + .word 0x6D7F2402 + .word 0x6D829108 + .word 0x6D872102 + .word 0x6D885A14 + .word 0x6D998B14 + .word 0x6DB15A14 + .word 0x6DC28A14 + .word 0x6DD88B14 + .word 0x6DF08A14 + .word 0x6E068B14 + .word 0x6E1E8B14 + .word 0x6E368A14 + .word 0x6E4C8B14 + .word 0x6E648B14 + .word 0x6E7C270E + .word 0x6E802A0E + .word 0x6E86970E + .word 0x6E9A850C + .word 0x6EA6970E + .word 0x6EBA7A14 + .word 0x6ED0DB14 + .word 0x6EFAAA14 + .word 0x6F169A14 + .word 0x6F32AB14 + .word 0x6F509A14 + .word 0x6F6C9A14 + .word 0x6F889A14 + .word 0x6FA4AB14 + .word 0x6FC2AA14 + .word 0x6FDE2A14 + .word 0x6FE47B14 + .word 0x6FFC9A14 + .word 0x70188A14 + .word 0x702EBA14 + .word 0x704F9A14 + .word 0x706BBB14 + .word 0x708F9A14 + .word 0x70ABBB14 + .word 0x70CF9A14 + .word 0x70EB9B14 + .word 0x7109AA14 + .word 0x71259B14 + .word 0x7143AA14 + .word 0x715FEA14 + .word 0x7186AA14 + .word 0x71A2AA14 + .word 0x71BE9A14 + .word 0x71DA3D14 + .word 0x71E87A14 + .word 0x71FE4D14 + .word 0x720C5214 + .word 0x721190FC + .word 0x72145F1A + .word 0x722C8910 + .word 0x72408B14 + .word 0x72588910 + .word 0x726C7C16 + .word 0x72868910 + .word 0x729A6A14 + .word 0x72AB8C10 + .word 0x72C57A14 + .word 0x72DB2A14 + .word 0x72E14E14 + .word 0x72F07A14 + .word 0x73062A14 + .word 0x730CB810 + .word 0x73277810 + .word 0x73398910 + .word 0x734D8C10 + .word 0x73678C10 + .word 0x73815810 + .word 0x738F7910 + .word 0x73A34A12 + .word 0x73AE780E + .word 0x73C0870E + .word 0x73D0B70E + .word 0x73E8770E + .word 0x73F88B0E + .word 0x7410770E + .word 0x74205D14 + .word 0x74352A14 + .word 0x743B6D14 + .word 0x74506114 + .word 0x74536F18 + .word 0x746B6F16 + .word 0x74832A0E + .word 0x74898B12 + .word 0x74A18B14 + .word 0x74B98710 + .word 0x74C99A14 + .word 0x74E52A14 + .word 0x74EB7E14 + .word 0x75094114 + .word 0x750BBA14 + .word 0x752C5414 + .word 0x7534650C + .word 0x753D840A + .word 0x75476E16 + .word 0x755EBA14 + .word 0x757F6114 + .word 0x75823316 + .word 0x7586870E + .word 0x75965F18 + .word 0x75AE5F18 + .word 0x75C64214 + .word 0x75C99B0E + .word 0x75E78D14 + .word 0x7603430C + .word 0x76072402 + .word 0x760A6D14 + .word 0x761F5414 + .word 0x7627550C + .word 0x7630FB14 + .word 0x7660C514 + .word 0x7672E80E + .word 0x76928A0E + .word 0x76A8AD1A + .word 0x76CBAD1A + .word 0x76EEAD1A + .word 0x7711AD1A + .word 0x7734AD1A + .word 0x7757AE1C + .word 0x777DFA14 + .word 0x77A9AD14 + .word 0x77CC8D1A + .word 0x77E88D1A + .word 0x78048D1A + .word 0x78208C18 + .word 0x783A4D1A + .word 0x78483D1A + .word 0x78565D1A + .word 0x786B5D1A + .word 0x78805F1A + .word 0x7898AD1A + .word 0x78BBCE1A + .word 0x78E8BE1A + .word 0x7915BE1A + .word 0x7942BE1A + .word 0x796FCD18 + .word 0x7999870E + .word 0x79A9BB14 + .word 0x79CD9E1A + .word 0x79F39E1A + .word 0x7A199E1A + .word 0x7A3FAE1A + .word 0x7A656F1A + .word 0x7A7D5F1A + .word 0x7A958B14 + .word 0x7AAD8C16 + .word 0x7AC78C16 + .word 0x7AE18C16 + .word 0x7AFB8B14 + .word 0x7B138B14 + .word 0x7B2B8C16 + .word 0x7B45D910 + .word 0x7B687C10 + .word 0x7B828C16 + .word 0x7B9C8C16 + .word 0x7BB68C16 + .word 0x7BD08B14 + .word 0x7BE84B16 + .word 0x7BF44B16 + .word 0x7C005B16 + .word 0x7C124B16 + .word 0x7C1E7B14 + .word 0x7C367A14 + .word 0x7C4C8C16 + .word 0x7C668C16 + .word 0x7C808C16 + .word 0x7C9A8B14 + .word 0x7CB28B14 + .word 0x7CCA870E + .word 0x7CDA8910 + .word 0x7CEE7C16 + .word 0x7D088C16 + .word 0x7D227C16 + .word 0x7D3C7B14 + .word 0x7D545F18 + .word 0x7D6C5F18 + .word 0x7D848E14 + .word 0x7DA26F16 + .word 0x7DBA3A14 + .word 0x7DC56414 + .word 0x7DCD9A14 + .word 0x7DE98D16 + .word 0x7E05EB14 + .word 0x7E2FBB14 + .word 0x7E533414 + .word 0x7E584D14 + .word 0x7E664D14 + .word 0x7E746414 + .word 0x7E7C870E + .word 0x7E8C3402 + .word 0x7E91920A + .word 0x7E993102 + .word 0x7E9B7A14 + .word 0x7EB18B14 + .word 0x7EC95A14 + .word 0x7EDA8A14 + .word 0x7EF08B14 + .word 0x7F088A14 + .word 0x7F1E8B14 + .word 0x7F368B14 + .word 0x7F4E8A14 + .word 0x7F648B14 + .word 0x7F7C9B14 + .word 0x7F9A370E + .word 0x7FA23A0E + .word 0x7FADA80E + .word 0x7FC4960C + .word 0x7FD6980E + .word 0x7FED9A14 + .word 0x8009DC16 + .word 0x8037BA14 + .word 0x8058AA14 + .word 0x8074BB14 + .word 0x8098AA14 + .word 0x80B49A14 + .word 0x80D09A14 + .word 0x80ECBB14 + .word 0x8110AA14 + .word 0x812C3A14 + .word 0x81378B14 + .word 0x814FAA14 + .word 0x816B9A14 + .word 0x8187BA14 + .word 0x81A8AA14 + .word 0x81C4BB14 + .word 0x81E89A14 + .word 0x8204BB14 + .word 0x8228AA14 + .word 0x8244AB14 + .word 0x8262AA14 + .word 0x827E9B14 + .word 0x829CAA14 + .word 0x82B8FA14 + .word 0x82E4AA14 + .word 0x8300AA14 + .word 0x831C9A14 + .word 0x83384D14 + .word 0x83466A14 + .word 0x83575D14 + .word 0x836C6216 + .word 0x837190FC + .word 0x83745F18 + .word 0x838C8910 + .word 0x83A09B14 + .word 0x83BE8910 + .word 0x83D29B14 + .word 0x83F09910 + .word 0x84095A14 + .word 0x841A8C10 + .word 0x84348A14 + .word 0x844A3A14 + .word 0x84554E14 + .word 0x84648A14 + .word 0x847A2A14 + .word 0x8480C810 + .word 0x849B8810 + .word 0x84AD9910 + .word 0x84C68C10 + .word 0x84E09C10 + .word 0x85015810 + .word 0x850F8910 + .word 0x85235A14 + .word 0x8534880E + .word 0x8546870E + .word 0x8556C70E + .word 0x856E870E + .word 0x857E8B0E + .word 0x8596870E + .word 0x85A65D14 + .word 0x85BB3A14 + .word 0x85C66D14 + .word 0x85DB7216 + .word 0x85E16F18 + .word 0x85F96F14 + .word 0x86113A0E + .word 0x861C8B12 + .word 0x86348B14 + .word 0x864C8710 + .word 0x865C9A14 + .word 0x86783A14 + .word 0x86838D14 + .word 0x869F6114 + .word 0x86A2BA14 + .word 0x86C36514 + .word 0x86CC750C + .word 0x86D8950C + .word 0x86E75F16 + .word 0x86FFBA14 + .word 0x87206114 + .word 0x87234318 + .word 0x8727970E + .word 0x873B5F16 + .word 0x87535F16 + .word 0x876B4114 + .word 0x876DAB0E + .word 0x878B9D14 + .word 0x87AE430C + .word 0x87B23402 + .word 0x87B76F16 + .word 0x87CF6514 + .word 0x87D8650C + .word 0x87E1EC14 + .word 0x880FC512 + .word 0x8821E90E + .word 0x88448A0E + .word 0x885AAD1A + .word 0x887DBD1A + .word 0x88A7BD1A + .word 0x88D1BD1A + .word 0x88FBAD1A + .word 0x891EBE1C + .word 0x894BFA14 + .word 0x8977AE14 + .word 0x899D9D1A + .word 0x89C09D1A + .word 0x89E39D1A + .word 0x8A069D1A + .word 0x8A294D1A + .word 0x8A374D1A + .word 0x8A456D1A + .word 0x8A5A6D1A + .word 0x8A6F5F18 + .word 0x8A87AD1A + .word 0x8AAABE1A + .word 0x8AD7BE1A + .word 0x8B04BE1A + .word 0x8B31BE1A + .word 0x8B5EBE1A + .word 0x8B8B870E + .word 0x8B9BBB14 + .word 0x8BBF9E1A + .word 0x8BE59E1A + .word 0x8C0BAE1A + .word 0x8C31AE1A + .word 0x8C575F18 + .word 0x8C6F5F18 + .word 0x8C878B14 + .word 0x8C9F8B14 + .word 0x8CB79B14 + .word 0x8CD58C16 + .word 0x8CEF8C16 + .word 0x8D098B14 + .word 0x8D219D18 + .word 0x8D44D910 + .word 0x8D678C10 + .word 0x8D818B14 + .word 0x8D999B14 + .word 0x8DB79C16 + .word 0x8DD88B14 + .word 0x8DF05A14 + .word 0x8E015A14 + .word 0x8E125A14 + .word 0x8E236A14 + .word 0x8E348B14 + .word 0x8E4C8B16 + .word 0x8E649B14 + .word 0x8E829B14 + .word 0x8EA09C16 + .word 0x8EC19C16 + .word 0x8EE29B14 + .word 0x8F00870E + .word 0x8F10A910 + .word 0x8F298B14 + .word 0x8F418B14 + .word 0x8F598C16 + .word 0x8F738C16 + .word 0x8F8D5F18 + .word 0x8FA55F18 + .word 0x8FBD8F16 + .word 0x8FDD6F16 + .word 0x8FF54A12 + .word 0x90004312 + .word 0x90049A12 + .word 0x90209C14 + .word 0x9041BA12 + .word 0x90628A12 + .word 0x90782312 + .word 0x907A6C12 + .word 0x908E5C12 + .word 0x90A25412 + .word 0x90AA870C + .word 0x90BA3300 + .word 0x90BE8006 + .word 0x90C02100 + .word 0x90C17A12 + .word 0x90D78A12 + .word 0x90ED5A12 + .word 0x90FE9A12 + .word 0x911A8A12 + .word 0x91308A12 + .word 0x91469A12 + .word 0x91628A12 + .word 0x91788A12 + .word 0x918E8A12 + .word 0x91A47A12 + .word 0x91BA370E + .word 0x91C24A0E + .word 0x91CD980E + .word 0x91E4940A + .word 0x91F1980E + .word 0x92087A12 + .word 0x921ECB14 + .word 0x9242AA12 + .word 0x925E9A12 + .word 0x927ABB14 + .word 0x929EAA12 + .word 0x92BABA12 + .word 0x92DBAA12 + .word 0x92F7BB14 + .word 0x931BBA12 + .word 0x933C4A12 + .word 0x93478A12 + .word 0x935DBA12 + .word 0x937E8A12 + .word 0x9394CA12 + .word 0x93B5AA12 + .word 0x93D1BB14 + .word 0x93F5AA12 + .word 0x9411BB14 + .word 0x9435AA12 + .word 0x94519B14 + .word 0x946F9A12 + .word 0x948BAA12 + .word 0x94A7AA12 + .word 0x94C3DA12 + .word 0x94EABA12 + .word 0x950B9A12 + .word 0x9527BA12 + .word 0x95485C12 + .word 0x955C3A12 + .word 0x95675C12 + .word 0x957B5112 + .word 0x957E80FC + .word 0x95803F18 + .word 0x9590780E + .word 0x95A29A12 + .word 0x95BE880E + .word 0x95D09A12 + .word 0x95EC880E + .word 0x95FE5A12 + .word 0x960F9B0E + .word 0x962D8A12 + .word 0x96434A12 + .word 0x964E6D12 + .word 0x96638A12 + .word 0x96794A12 + .word 0x9684C80E + .word 0x969F880E + .word 0x96B1880E + .word 0x96C39B0E + .word 0x96E18B0E + .word 0x96F9680E + .word 0x9707780E + .word 0x97195A12 + .word 0x972A880E + .word 0x973C880E + .word 0x974EA80E + .word 0x9765980E + .word 0x977C9B0E + .word 0x979A880E + .word 0x97AC7C12 + .word 0x97C63A12 + .word 0x97D16C12 + .word 0x97E56112 + .word 0x97E86F18 + .word 0x98004F14 + .word 0x98104A0E + .word 0x981B8A10 + .word 0x98319A12 + .word 0x984D860E + .word 0x985B9A12 + .word 0x98774A12 + .word 0x98827D12 + .word 0x989E5112 + .word 0x98A1BA12 + .word 0x98C25514 + .word 0x98CB740A + .word 0x98D5840A + .word 0x98DF5F14 + .word 0x98F7BA12 + .word 0x99185112 + .word 0x991B3214 + .word 0x991E870C + .word 0x992E5F16 + .word 0x99465F16 + .word 0x995E3112 + .word 0x9960BB0E + .word 0x99848C12 + .word 0x999E330C + .word 0x99A22300 + .word 0x99A46F16 + .word 0x99BC5514 + .word 0x99C5640A + .word 0x99CDFB14 + .word 0x99FDB412 + .word 0x9A0CD80E + .word 0x9A2C7A0E + .word 0x9A42AD18 + .word 0x9A65AD18 + .word 0x9A889D18 + .word 0x9AABAD18 + .word 0x9ACEAD18 + .word 0x9AF1AE1A + .word 0x9B17FA12 + .word 0x9B43BE14 + .word 0x9B70BD18 + .word 0x9B9AAD18 + .word 0x9BBDAD18 + .word 0x9BE0AD18 + .word 0x9C035D18 + .word 0x9C186D18 + .word 0x9C2D6D18 + .word 0x9C426D18 + .word 0x9C573F18 + .word 0x9C67BD18 + .word 0x9C91BD18 + .word 0x9CBBBD18 + .word 0x9CE5BD18 + .word 0x9D0FBD18 + .word 0x9D39BD18 + .word 0x9D63980E + .word 0x9D7ADB14 + .word 0x9DA4AD18 + .word 0x9DC7AD18 + .word 0x9DEAAD18 + .word 0x9E0DAD18 + .word 0x9E305F18 + .word 0x9E485F18 + .word 0x9E608A12 + .word 0x9E768B14 + .word 0x9E8E8B14 + .word 0x9EA68B14 + .word 0x9EBE8B14 + .word 0x9ED68A12 + .word 0x9EEC8C16 + .word 0x9F06D80E + .word 0x9F267B0E + .word 0x9F3E8B14 + .word 0x9F567B14 + .word 0x9F6E8B14 + .word 0x9F868A12 + .word 0x9F9C3B14 + .word 0x9FA85B14 + .word 0x9FBA5B14 + .word 0x9FCC5A12 + .word 0x9FDD8A12 + .word 0x9FF38B14 + .word 0xA00B8B14 + .word 0xA0238B14 + .word 0xA03B8B14 + .word 0xA0538B14 + .word 0xA06B8A12 + .word 0xA081860C + .word 0xA08F980E + .word 0xA0A67B14 + .word 0xA0BE8B14 + .word 0xA0D68B14 + .word 0xA0EE8A12 + .word 0xA1045E16 + .word 0xA11B5E16 + .word 0xA1329D12 + .word 0xA1556F1A + .word 0xA16D1B16 + .word 0xA1735316 + .word 0xA1797B16 + .word 0xA1915D18 + .word 0xA1A67B16 + .word 0xA1BE5B16 + .word 0xA1D02316 + .word 0xA1D22F18 + .word 0xA1DA2F18 + .word 0xA1E23316 + .word 0xA1E6540C + .word 0xA1EE2404 + .word 0xA1F15008 + .word 0xA1F31204 + .word 0xA1F53A16 + .word 0xA2004B16 + .word 0xA20C2B16 + .word 0xA2124B16 + .word 0xA21E5B16 + .word 0xA2304B16 + .word 0xA23C5B16 + .word 0xA24E4B16 + .word 0xA25A5B16 + .word 0xA26C4B16 + .word 0xA2785B16 + .word 0xA28A1710 + .word 0xA28E280E + .word 0xA2936810 + .word 0xA2A1530C + .word 0xA2A75810 + .word 0xA2B54B16 + .word 0xA2C17C18 + .word 0xA2DB5B16 + .word 0xA2ED4B16 + .word 0xA2F96C18 + .word 0xA30D5B16 + .word 0xA31F5B16 + .word 0xA3315C18 + .word 0xA3456C18 + .word 0xA3595B16 + .word 0xA36B2A16 + .word 0xA3714B16 + .word 0xA37D6B16 + .word 0xA38F5B16 + .word 0xA3A17B16 + .word 0xA3B96B16 + .word 0xA3CB6C18 + .word 0xA3DF5B16 + .word 0xA3F16D18 + .word 0xA4065C18 + .word 0xA41A6C18 + .word 0xA42E6A16 + .word 0xA43F5B16 + .word 0xA4516B16 + .word 0xA4638C18 + .word 0xA47D5B16 + .word 0xA48F5B16 + .word 0xA4A15B16 + .word 0xA4B32E16 + .word 0xA4BB3A16 + .word 0xA4C62E16 + .word 0xA4CE531A + .word 0xA4D470FC + .word 0xA4D65F1C + .word 0xA4EE4810 + .word 0xA4F75B16 + .word 0xA5095912 + .word 0xA5185B16 + .word 0xA52A5810 + .word 0xA5383C18 + .word 0xA5454B10 + .word 0xA5514B16 + .word 0xA55D2B16 + .word 0xA5632E16 + .word 0xA56B4B16 + .word 0xA5772B16 + .word 0xA57D6810 + .word 0xA58B4810 + .word 0xA5945912 + .word 0xA5A34B10 + .word 0xA5AF5B10 + .word 0xA5C13810 + .word 0xA5CA5912 + .word 0xA5D93A14 + .word 0xA5E44810 + .word 0xA5ED5810 + .word 0xA5FB6810 + .word 0xA6094810 + .word 0xA6125B10 + .word 0xA6245810 + .word 0xA6324E16 + .word 0xA6412E16 + .word 0xA6494E16 + .word 0xA6586116 + .word 0xA65B6C18 + .word 0xA66F5E16 + .word 0xA6862B10 + .word 0xA68C5C14 + .word 0xA6A04B16 + .word 0xA6AC5712 + .word 0xA6B84A16 + .word 0xA6C32B16 + .word 0xA6C94E16 + .word 0xA6D83116 + .word 0xA6DA7B16 + .word 0xA6F23618 + .word 0xA6F9650E + .word 0xA702440C + .word 0xA7076B16 + .word 0xA7197B16 + .word 0xA7317016 + .word 0xA7332218 + .word 0xA735570E + .word 0xA7415F1A + .word 0xA7595F1A + .word 0xA7712116 + .word 0xA7725B10 + .word 0xA7845E16 + .word 0xA79B230E + .word 0xA79D2300 + .word 0xA79F6D16 + .word 0xA7B43618 + .word 0xA7BB640C + .word 0xA7C38B16 + .word 0xA7DB7516 + .word 0xA7E78810 + .word 0xA7F95B10 + .word 0xA80B5E1C + .word 0xA8225E1C + .word 0xA8395E1C + .word 0xA8506E1C + .word 0xA8675D1A + .word 0xA87C5F1E + .word 0xA8948B16 + .word 0xA8AC6F18 + .word 0xA8C45F1E + .word 0xA8DC5E1C + .word 0xA8F35F1E + .word 0xA90B5D1A + .word 0xA9202E1C + .word 0xA9282E1C + .word 0xA9305F1E + .word 0xA9484D1A + .word 0xA9565F1C + .word 0xA96E6E1C + .word 0xA9857E1C + .word 0xA9A37E1C + .word 0xA9C17F1E + .word 0xA9E17E1C + .word 0xA9FF7D1A + .word 0xAA1B4810 + .word 0xAA246C18 + .word 0xAA386E1C + .word 0xAA4F6E1C + .word 0xAA666F1E + .word 0xAA7E6D1A + .word 0xAA936F1C + .word 0xAAAB5F1C + .word 0xAAC34B16 + .word 0xAACF5B16 + .word 0xAAE15B16 + .word 0xAAF35C18 + .word 0xAB076B16 + .word 0xAB194A14 + .word 0xAB245C18 + .word 0xAB387810 + .word 0xAB4A4B10 + .word 0xAB565B16 + .word 0xAB685B16 + .word 0xAB7A5C18 + .word 0xAB8E4A14 + .word 0xAB992B16 + .word 0xAB9F2B16 + .word 0xABA55B16 + .word 0xABB74A14 + .word 0xABC24B16 + .word 0xABCE6B16 + .word 0xABE05B16 + .word 0xABF25B16 + .word 0xAC045C18 + .word 0xAC186B16 + .word 0xAC2A4A14 + .word 0xAC35560E + .word 0xAC405810 + .word 0xAC4E5B16 + .word 0xAC604B16 + .word 0xAC6C5C18 + .word 0xAC804A14 + .word 0xAC8B5F1A + .word 0xACA36F1A + .word 0xACBB4D14 + .word 0xACC96F1A + .word 0xACE12C18 + .word 0xACE85318 + .word 0xACEE8C18 + .word 0xAD087E18 + .word 0xAD266B16 + .word 0xAD388C18 + .word 0xAD522318 + .word 0xAD543F18 + .word 0xAD643F18 + .word 0xAD745318 + .word 0xAD7A8710 + .word 0xAD8A2302 + .word 0xAD8C710A + .word 0xAD902102 + .word 0xAD915E1A + .word 0xADA85B16 + .word 0xADBA4B16 + .word 0xADC65B16 + .word 0xADD85B16 + .word 0xADEA7B16 + .word 0xAE025B16 + .word 0xAE145B16 + .word 0xAE267B16 + .word 0xAE3E5B16 + .word 0xAE505B16 + .word 0xAE622710 + .word 0xAE662910 + .word 0xAE6B7A12 + .word 0xAE81740C + .word 0xAE8B7A12 + .word 0xAEA16C18 + .word 0xAEB58C18 + .word 0xAECF7C18 + .word 0xAEE96C18 + .word 0xAEFD6C18 + .word 0xAF116C18 + .word 0xAF255C18 + .word 0xAF395C18 + .word 0xAF4D6C18 + .word 0xAF616C18 + .word 0xAF752C18 + .word 0xAF7C6C18 + .word 0xAF908C18 + .word 0xAFAA5C18 + .word 0xAFBE8C18 + .word 0xAFD87C18 + .word 0xAFF26C18 + .word 0xB0066C18 + .word 0xB01A7C18 + .word 0xB0346C18 + .word 0xB0486C18 + .word 0xB05C6C18 + .word 0xB0706C18 + .word 0xB0847C18 + .word 0xB09EAC18 + .word 0xB0BF8C18 + .word 0xB0D98C18 + .word 0xB0F36C18 + .word 0xB1073F1C + .word 0xB1175E1A + .word 0xB12E3F1C + .word 0xB13E5216 + .word 0xB14380FC + .word 0xB1455F1C + .word 0xB15D5912 + .word 0xB16C5C18 + .word 0xB1805810 + .word 0xB18E5C18 + .word 0xB1A25912 + .word 0xB1B14C18 + .word 0xB1BE5C12 + .word 0xB1D25C18 + .word 0xB1E62C18 + .word 0xB1ED4F18 + .word 0xB1FD6C18 + .word 0xB2112C18 + .word 0xB2187912 + .word 0xB22C5912 + .word 0xB23B5912 + .word 0xB24A5C12 + .word 0xB25E5C12 + .word 0xB2725912 + .word 0xB2815A14 + .word 0xB2924B16 + .word 0xB29E5810 + .word 0xB2AC7810 + .word 0xB2BE8810 + .word 0xB2D07810 + .word 0xB2E27A10 + .word 0xB2F85810 + .word 0xB3065E16 + .word 0xB31D1C18 + .word 0xB3245E16 + .word 0xB33B6116 + .word 0xB33E6C18 + .word 0xB3525E16 + .word 0xB3692B10 + .word 0xB36F6C14 + .word 0xB3837B16 + .word 0xB39B7914 + .word 0xB3AF8B16 + .word 0xB3C71C18 + .word 0xB3CE7D16 + .word 0xB3EA4016 + .word 0xB3EB7B16 + .word 0xB4033618 + .word 0xB40AA912 + .word 0xB423820C + .word 0xB4296B16 + .word 0xB43B7B16 + .word 0xB4538016 + .word 0xB4553218 + .word 0xB4588A14 + .word 0xB46E3418 + .word 0xB4733418 + .word 0xB4783118 + .word 0xB47A8A10 + .word 0xB4906E16 + .word 0xB4A7430E + .word 0xB4AB2302 + .word 0xB4AD3418 + .word 0xB4B23618 + .word 0xB4B9A912 + .word 0xB4D28B16 + .word 0xB4EA8216 + .word 0xB4F08910 + .word 0xB5046B10 + .word 0xB5167E1C + .word 0xB5347E1C + .word 0xB5527F1E + .word 0xB5727E1C + .word 0xB5907E1C + .word 0xB5AE7F1E + .word 0xB5CE8C18 + .word 0xB5E86E18 + .word 0xB5FF5F1E + .word 0xB6175F1E + .word 0xB62F5F1E + .word 0xB6475E1C + .word 0xB65E3F1E + .word 0xB66E3F1E + .word 0xB67E5F1E + .word 0xB6964E1C + .word 0xB6A57C18 + .word 0xB6BF7E1C + .word 0xB6DD6F1E + .word 0xB6F56F1E + .word 0xB70D6F1E + .word 0xB7256F1E + .word 0xB73D6E1C + .word 0xB7547812 + .word 0xB7668C18 + .word 0xB7806E1C + .word 0xB7976E1C + .word 0xB7AE6E1C + .word 0xB7C56D1A + .word 0xB7DA8D1A + .word 0xB7F68E1C + .word 0xB8146D1A + .word 0xB8295B16 + .word 0xB83B5B16 + .word 0xB84D5C18 + .word 0xB8616B16 + .word 0xB8735A14 + .word 0xB8845C18 + .word 0xB8988912 + .word 0xB8AC5D12 + .word 0xB8C15B16 + .word 0xB8D35B16 + .word 0xB8E55B16 + .word 0xB8F75A14 + .word 0xB9083B16 + .word 0xB9143B16 + .word 0xB9205B16 + .word 0xB9324A14 + .word 0xB93D5B16 + .word 0xB94F6B16 + .word 0xB9615B16 + .word 0xB9735B16 + .word 0xB9855C18 + .word 0xB9996B16 + .word 0xB9AB5A14 + .word 0xB9BC8710 + .word 0xB9CC7B14 + .word 0xB9E45B16 + .word 0xB9F65B16 + .word 0xBA085B16 + .word 0xBA1A5A14 + .word 0xBA2B7C16 + .word 0xBA455C16 + .word 0xBA597B14 + .word 0xBA716F18 + .word 0xBA893B16 + .word 0xBA956414 + .word 0xBA9D6912 + .word 0xBAAC6D16 + .word 0xBAC17B14 + .word 0xBAD97B14 + .word 0xBAF14414 + .word 0xBAF64D16 + .word 0xBB043D16 + .word 0xBB127912 + .word 0xBB266912 + .word 0xBB353302 + .word 0xBB39610A + .word 0xBB3C3202 + .word 0xBB3F8D16 + .word 0xBB5B6B16 + .word 0xBB6D5B16 + .word 0xBB7F7B16 + .word 0xBB976B16 + .word 0xBBA97B16 + .word 0xBBC17B16 + .word 0xBBD97B16 + .word 0xBBF16B16 + .word 0xBC037B16 + .word 0xBC1B7B16 + .word 0xBC333810 + .word 0xBC3C3910 + .word 0xBC467C18 + .word 0xBC60730E + .word 0xBC687C18 + .word 0xBC826B16 + .word 0xBC947B16 + .word 0xBCAC7B16 + .word 0xBCC47B16 + .word 0xBCDC6B16 + .word 0xBCEE7B16 + .word 0xBD067B16 + .word 0xBD1E7B16 + .word 0xBD367B16 + .word 0xBD4E8B16 + .word 0xBD665B16 + .word 0xBD786B16 + .word 0xBD8A8B16 + .word 0xBDA27B16 + .word 0xBDBA7B16 + .word 0xBDD27B16 + .word 0xBDEA6B16 + .word 0xBDFC8B16 + .word 0xBE147C16 + .word 0xBE2E7B16 + .word 0xBE466B16 + .word 0xBE587B16 + .word 0xBE707B16 + .word 0xBE887B16 + .word 0xBEA08B16 + .word 0xBEB87B16 + .word 0xBED07B16 + .word 0xBEE87B16 + .word 0xBF003D18 + .word 0xBF0E8D16 + .word 0xBF2A3D18 + .word 0xBF387114 + .word 0xBF3CA0FA + .word 0xBF3F6F1A + .word 0xBF577810 + .word 0xBF69AB16 + .word 0xBF878810 + .word 0xBF997B16 + .word 0xBFB17810 + .word 0xBFC36B16 + .word 0xBFD58910 + .word 0xBFE97B16 + .word 0xC0015B16 + .word 0xC0134C16 + .word 0xC0208B16 + .word 0xC0384B16 + .word 0xC0447810 + .word 0xC0567810 + .word 0xC0686810 + .word 0xC0767910 + .word 0xC08A7910 + .word 0xC09E6810 + .word 0xC0AC6810 + .word 0xC0BA5A14 + .word 0xC0CB7810 + .word 0xC0DD7810 + .word 0xC0EF8810 + .word 0xC1018810 + .word 0xC1137910 + .word 0xC1276810 + .word 0xC1354D18 + .word 0xC1432D18 + .word 0xC14A4D18 + .word 0xC1585116 + .word 0xC15B6F1C + .word 0xC2276F16 + .word 0xC23F6F16 + .word 0xC1738A16 + .word 0xC189AB16 + .word 0xC2576F16 + .word 0xC1A7C914 + .word 0xC1C52D16 + .word 0xC1CC6A16 + .word 0xC1DD6116 + .word 0xC26F6F16 + .word 0xC2876F16 + .word 0xC1E07D18 + .word 0xC1FCC40C + .word 0xC20B7D18 + .word 0xC29F6F16 + .word 0xC2B76F16 + .word 0xC2CF4318 + .word 0xC2D3A914 + .word 0xC2ECA912 + .word 0xC305AB16 + .word 0xC4126F18 + .word 0xC323A910 + .word 0xC33C8914 + .word 0xC350430E + .word 0xC3543404 + .word 0xC359DB14 + .word 0xC383A016 + .word 0xC386DB16 + .word 0xC3B0ED18 + .word 0xC3E1ED18 + .word 0xC42A6F18 + .word 0xC4426F18 + .word 0xC45AA20E + .word 0xC4624306 + .word 0xC4666D18 + .word 0xC47BA810 + .word 0xC4925A18 + .word 0xC4A35A12 + .word 0xC4B46A18 + .word 0xC4C57A12 + .word 0xC4DB5D18 + .word 0xC4F05D18 + .word 0xC5055D18 + .word 0xC51A6D18 + .word 0xC52FD914 + .word 0xC552D914 + .word 0xC575B914 + .word 0xC593E510 + .word 0xC5A8F50E + .word 0xC5C07D16 + .word 0xC5DC6D16 + .word 0xC5F1EB14 + .word 0xC61BEB14 + .word 0xC645D912 + .word 0xC668D912 + .word 0xC68BAD16 + .word 0xC6AEAD16 + .word 0xC6D1FA14 + .word 0xC6FD9C16 + .word 0xC71E6F16 + .word 0xC7366F16 + .word 0xC74E6F16 + .word 0xC7666F16 + .word 0xC77E6F16 + .word 0xC796E612 + .word 0xC7AFA810 + .word 0xC7C65118 + .word 0xC7C96318 + .word 0xC7CF3418 + .word 0xC7D44810 + .word 0xC7DDD30E + .word 0xC7EBA30E + .word 0xC7F55D18 + .word 0xC80AC20E + .word 0xC8138B16 + .word 0xC82BB912 + .word 0xC8496F1A + .word 0xC8616F1A + .word 0xC8796F1A + .word 0xC8916F1A + .word 0xC8A90F17 + .word 0xC8E9960E + .word 0xC8FB7810 + .word 0xC90D960E + .word 0xC91F7810 + .word 0xC9319E14 + .word 0xC957F810 + .word 0xC97B9E16 + .word 0xC9A1F810 + .word 0xC9C5CC14 + .word 0xC9ECDC16 + .word 0xCA1ADC14 + .word 0xCA48DC14 + .word 0xCA76EF16 + .word 0xCAAE070F + .word 0xCACE070F + .word 0xCAEE8F16 + .word 0xCB0EED14 + .word 0xCB3FED14 + .word 0xCB70ED14 + .word 0xCBA1EF16 + .word 0xCBD9CB12 + .word 0xCBFDCB12 + .word 0xCC21CB12 +ENDDATA(D_801D04A0) diff --git a/src/libleo/api/getkadr.s b/src/libleo/api/getkadr.s index d71719525a2..85169a26f97 100644 --- a/src/libleo/api/getkadr.s +++ b/src/libleo/api/getkadr.s @@ -3,210 +3,703 @@ .text -/** - * int LeoGetKAdr(int sjis); - * - * Returns the storage offset address into the N64 Disk Drive mask ROM for - * a kanji character corresponding to a given 2-byte Shift-JIS codepoint. - * An error value -1 will be returned if `sjis` is outside the range 0x8140 to 0x9872. - * - * A nice Shift-JIS codepoint table: https://uic.io/en/charset/show/shift_jis/ - * The Mask ROM contains the 'Level 1' kanji (0x889F-0x9872), and a reworked - * version of the non-kanji section that includes extra English and Hylian glyphs. - * - * @param sjis Shift-JIS Codepoint of glyph. - * @return int Storage offset address into the N64 Disk Drive mask ROM. - */ LEAF(LeoGetKAdr) - /* Check if the codepoint is in the range 0x8140 to 0x9872. */ - blt a0, 0x8140, .out_of_range - bge a0, 0x9873, .out_of_range - /* Characters with codepoints >= 0x8800 are kanji. Arrangement is regular, - * so convert index directly. */ + blt a0, 0x8140, .L801CF9E0 + bge a0, 0x9873, .L801CF9E0 li a2, 0xBC - blt a0, 0x8800, .nonkanji - /* 0xBC is number of glyphs in one block in the `kanji` file: - * 0x100 possible codepoints with the same byte1 - * - 0x40 unused at beginning - * - 1 unused at 0x7F - * - 3 unused at 0xFD, 0xFE, 0xFF */ - /* Get byte1 and adjust so starts at 0 */ + blt a0, 0x8800, .L801CF994 srl a1, a0, 8 addi a1, a1, -0x88 mul a2, a2, a1 - /* Get byte2 and adjust so starts at 0 */ andi a3, a0, 0xFF addi a3, a3, -0x40 - /* 0x__7F is always empty and elided in the file, so decrement if larger */ - blt a3, 0x40, .kanji_lower_halfblock + blt a3, 0x40, .L801CF984 addi a3, a3, -1 -.kanji_lower_halfblock: + .L801CF984: mflo a2 addi a3, a3, 0x30A add a3, a3, a2 - sll v0, a3, 7 + sll v0, a3, 7 jr ra - /* returns (0x30A + (adjusted byte2) + (adjusted byte1) * 0xBC) * FONT_CHAR_TEX_SIZE */ - -/* Non-kanji are arranged with irregular gaps, use the lookup table. */ -.nonkanji: - /* Get byte1 and adjust so starts at 0 */ + .L801CF994: srl a1, a0, 8 addi a1, a1, -0x81 mul a2, a2, a1 - /* Get byte2 and adjust so starts at 0 */ andi a3, a0, 0xFF addi a3, a3, -0x40 - /* 0x__7F is always empty and elided in the file, so decrement if larger */ - blt a3, 0x40, .nonkanji_lower_halfblock + blt a3, 0x40, .L801CF9C0 addi a3, a3, -1 -.nonkanji_lower_halfblock: + .L801CF9C0: mflo a2 add a3, a3, a2 sll a3, a3, 1 - la a2, kantbl + la a2, D_801CF9E8 add a3, a3, a2 lh a2, (a3) sll v0, a2, 7 jr ra - /* returns kantbl[(adjusted byte2) + (adjusted byte1) * 0xBC] * FONT_CHAR_TEX_SIZE */ -.out_of_range: + .L801CF9E0: li v0, -1 jr ra END(LeoGetKAdr) -/** - * Nearly equivalent C code (Equivalent for all valid input, will behave differently on overflow due to the use of `add` in the original): - * - * extern u16 kantbl[]; - * - * int LeoGetKAdr(int sjis) { - * u32 byte1; - * u32 byte2; - * - * if (sjis < 0x8140 || sjis > 0x9872) { - * return -1; - * } - * - * byte1 = (u32)sjis >> 8; - * byte2 = sjis & 0xFF; - * - * byte2 -= 0x40; - * if (byte2 >= 0x40) { - * byte2--; - * } - * - * if (sjis >= 0x8800) { - * byte1 -= 0x88; - * return (0x30A + byte2 + byte1 * 0xBC) * FONT_CHAR_TEX_SIZE; - * } else { - * byte1 -= 0x81; - * return kantbl[byte2 + byte1 * 0xBC] * FONT_CHAR_TEX_SIZE; - * } - * } - */ - -/** - * Index table, formatting follows conventional Shift-JIS character table layout, - * with space for the missing 0x__7F,0x__FD,0x__FE,0x__FF entries, and split - * into blocks by high byte. - */ -DATA(kantbl) -/* 0x___0 0x___1 0x___2 0x___3 0x___4 0x___5 0x___6 0x___7 0x___8 0x___9 0x___A 0x___B 0x___C 0x___D 0x___E 0x___F */ -/* 0x814_ */ .half 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F -/* 0x815_ */ .half 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F -/* 0x816_ */ .half 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F -/* 0x817_ */ .half 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E -/* 0x818_ */ .half 0x003F, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E -/* 0x819_ */ .half 0x004F, 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E -/* 0x81A_ */ .half 0x005F, 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006A, 0x006B, 0x0000, 0x0000, 0x0000 -/* 0x81B_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x006C, 0x006D, 0x006E, 0x006F, 0x0070, 0x0071, 0x0072, 0x0073 -/* 0x81C_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007A, 0x0000 -/* 0x81D_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F -/* 0x81E_ */ .half 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x81F_ */ .half 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, 0x0090, 0x0000, 0x0000, 0x0000, 0x0000, 0x0091 - -/* 0x___0 0x___1 0x___2 0x___3 0x___4 0x___5 0x___6 0x___7 0x___8 0x___9 0x___A 0x___B 0x___C 0x___D 0x___E 0x___F */ -/* 0x824_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0092 -/* 0x825_ */ .half 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, 0x0098, 0x0099, 0x009A, 0x009B, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x826_ */ .half 0x009C, 0x009D, 0x009E, 0x009F, 0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, 0x00A8, 0x00A9, 0x00AA, 0x00AB -/* 0x827_ */ .half 0x00AC, 0x00AD, 0x00AE, 0x00AF, 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x828_ */ .half 0x0000, 0x00B6, 0x00B7, 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF, 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4 -/* 0x829_ */ .half 0x00C5, 0x00C6, 0x00C7, 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, 0x0000, 0x0000, 0x0000, 0x0000, 0x00D0 -/* 0x82A_ */ .half 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7, 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF, 0x00E0 -/* 0x82B_ */ .half 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, 0x00F0 -/* 0x82C_ */ .half 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF, 0x0100 -/* 0x82D_ */ .half 0x0101, 0x0102, 0x0103, 0x0104, 0x0105, 0x0106, 0x0107, 0x0108, 0x0109, 0x010A, 0x010B, 0x010C, 0x010D, 0x010E, 0x010F, 0x0110 -/* 0x82E_ */ .half 0x0111, 0x0112, 0x0113, 0x0114, 0x0115, 0x0116, 0x0117, 0x0118, 0x0119, 0x011A, 0x011B, 0x011C, 0x011D, 0x011E, 0x011F, 0x0120 -/* 0x82F_ */ .half 0x0121, 0x0122, 0x0123, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 - -/* 0x___0 0x___1 0x___2 0x___3 0x___4 0x___5 0x___6 0x___7 0x___8 0x___9 0x___A 0x___B 0x___C 0x___D 0x___E 0x___F */ -/* 0x834_ */ .half 0x0124, 0x0125, 0x0126, 0x0127, 0x0128, 0x0129, 0x012A, 0x012B, 0x012C, 0x012D, 0x012E, 0x012F, 0x0130, 0x0131, 0x0132, 0x0133 -/* 0x835_ */ .half 0x0134, 0x0135, 0x0136, 0x0137, 0x0138, 0x0139, 0x013A, 0x013B, 0x013C, 0x013D, 0x013E, 0x013F, 0x0140, 0x0141, 0x0142, 0x0143 -/* 0x836_ */ .half 0x0144, 0x0145, 0x0146, 0x0147, 0x0148, 0x0149, 0x014A, 0x014B, 0x014C, 0x014D, 0x014E, 0x014F, 0x0150, 0x0151, 0x0152, 0x0153 -/* 0x837_ */ .half 0x0154, 0x0155, 0x0156, 0x0157, 0x0158, 0x0159, 0x015A, 0x015B, 0x015C, 0x015D, 0x015E, 0x015F, 0x0160, 0x0161, 0x0162 -/* 0x838_ */ .half 0x0163, 0x0164, 0x0165, 0x0166, 0x0167, 0x0168, 0x0169, 0x016A, 0x016B, 0x016C, 0x016D, 0x016E, 0x016F, 0x0170, 0x0171, 0x0172 -/* 0x839_ */ .half 0x0173, 0x0174, 0x0175, 0x0176, 0x0177, 0x0178, 0x0179, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x017A -/* 0x83A_ */ .half 0x017B, 0x017C, 0x017D, 0x017E, 0x017F, 0x0180, 0x0181, 0x0182, 0x0183, 0x0184, 0x0185, 0x0186, 0x0187, 0x0188, 0x0189, 0x018A -/* 0x83B_ */ .half 0x018B, 0x018C, 0x018D, 0x018E, 0x018F, 0x0190, 0x0191, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0192 -/* 0x83C_ */ .half 0x0193, 0x0194, 0x0195, 0x0196, 0x0197, 0x0198, 0x0199, 0x019A, 0x019B, 0x019C, 0x019D, 0x019E, 0x019F, 0x01A0, 0x01A1, 0x01A2 -/* 0x83D_ */ .half 0x01A3, 0x01A4, 0x01A5, 0x01A6, 0x01A7, 0x01A8, 0x01A9, 0x01AA, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x83E_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x83F_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 - -/* 0x___0 0x___1 0x___2 0x___3 0x___4 0x___5 0x___6 0x___7 0x___8 0x___9 0x___A 0x___B 0x___C 0x___D 0x___E 0x___F */ -/* 0x844_ */ .half 0x01AB, 0x01AC, 0x01AD, 0x01AE, 0x01AF, 0x01B0, 0x01B1, 0x01B2, 0x01B3, 0x01B4, 0x01B5, 0x01B6, 0x01B7, 0x01B8, 0x01B9, 0x01BA -/* 0x845_ */ .half 0x01BB, 0x01BC, 0x01BD, 0x01BE, 0x01BF, 0x01C0, 0x01C1, 0x01C2, 0x01C3, 0x01C4, 0x01C5, 0x01C6, 0x01C7, 0x01C8, 0x01C9, 0x01CA -/* 0x846_ */ .half 0x01CB, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x847_ */ .half 0x01CC, 0x01CD, 0x01CE, 0x01CF, 0x01D0, 0x01D1, 0x01D2, 0x01D3, 0x01D4, 0x01D5, 0x01D6, 0x01D7, 0x01D8, 0x01D9, 0x01DA -/* 0x848_ */ .half 0x01DB, 0x01DC, 0x01DD, 0x01DE, 0x01DF, 0x01E0, 0x01E1, 0x01E2, 0x01E3, 0x01E4, 0x01E5, 0x01E6, 0x01E7, 0x01E8, 0x01E9, 0x01EA -/* 0x849_ */ .half 0x01EB, 0x01EC, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x01ED -/* 0x84A_ */ .half 0x01EE, 0x01EF, 0x01F0, 0x01F1, 0x01F2, 0x01F3, 0x01F4, 0x01F5, 0x01F6, 0x01F7, 0x01F8, 0x01F9, 0x01FA, 0x01FB, 0x01FC, 0x01FD -/* 0x84B_ */ .half 0x01FE, 0x01FF, 0x0200, 0x0201, 0x0202, 0x0203, 0x0204, 0x0205, 0x0206, 0x0207, 0x0208, 0x0209, 0x020A, 0x020B, 0x020C, 0x020D -/* 0x84C_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x84D_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x84E_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x84F_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 - -/* 0x___0 0x___1 0x___2 0x___3 0x___4 0x___5 0x___6 0x___7 0x___8 0x___9 0x___A 0x___B 0x___C 0x___D 0x___E 0x___F */ -/* 0x854_ */ .half 0x020E, 0x020F, 0x0210, 0x0211, 0x0212, 0x0213, 0x0214, 0x0215, 0x0216, 0x0217, 0x0218, 0x0219, 0x021A, 0x021B, 0x021C, 0x021D -/* 0x855_ */ .half 0x021E, 0x021F, 0x0220, 0x0221, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0222, 0x0223 -/* 0x856_ */ .half 0x0224, 0x0225, 0x0226, 0x0227, 0x0228, 0x0229, 0x022A, 0x022B, 0x022C, 0x022D, 0x022E, 0x022F, 0x0230, 0x0231, 0x0232, 0x0233 -/* 0x857_ */ .half 0x0234, 0x0235, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0236, 0x0237, 0x0238 -/* 0x858_ */ .half 0x0239, 0x023A, 0x023B, 0x023C, 0x023D, 0x023E, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x859_ */ .half 0x0000, 0x023F, 0x0240, 0x0241, 0x0242, 0x0243, 0x0244, 0x0245, 0x0246, 0x0247, 0x0248, 0x0000, 0x0000, 0x0000, 0x0000, 0x0249 -/* 0x85A_ */ .half 0x024A, 0x024B, 0x024C, 0x024D, 0x024E, 0x024F, 0x0250, 0x0251, 0x0252, 0x0253, 0x0254, 0x0255, 0x0256, 0x0257, 0x0000, 0x0000 -/* 0x85B_ */ .half 0x0000, 0x0000, 0x0000, 0x0258, 0x0259, 0x025A, 0x025B, 0x025C, 0x025D, 0x025E, 0x025F, 0x0260, 0x0261, 0x0262, 0x0263, 0x0264 -/* 0x85C_ */ .half 0x0265, 0x0266, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x85D_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0267, 0x0268, 0x0269, 0x026A, 0x026B -/* 0x85E_ */ .half 0x026C, 0x026D, 0x026E, 0x026F, 0x0270, 0x0271, 0x0272, 0x0273, 0x0274, 0x0275, 0x0276, 0x0277, 0x0278, 0x0279, 0x027A, 0x027B -/* 0x85F_ */ .half 0x027C, 0x027D, 0x027E, 0x027F, 0x0280, 0x0281, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 - -/* 0x___0 0x___1 0x___2 0x___3 0x___4 0x___5 0x___6 0x___7 0x___8 0x___9 0x___A 0x___B 0x___C 0x___D 0x___E 0x___F */ -/* 0x864_ */ .half 0x0282, 0x0283, 0x0284, 0x0285, 0x0286, 0x0287, 0x0288, 0x0289, 0x028A, 0x028B, 0x028C, 0x028D, 0x028E, 0x028F, 0x0290, 0x0291 -/* 0x865_ */ .half 0x0292, 0x0293, 0x0294, 0x0295, 0x0296, 0x0297, 0x0298, 0x0299, 0x029A, 0x029B, 0x029C, 0x029D, 0x029E, 0x029F, 0x0000, 0x0000 -/* 0x866_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x867_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x868_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x869_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x02A0, 0x02A1, 0x02A2, 0x02A3, 0x02A4 -/* 0x86A_ */ .half 0x02A5, 0x02A6, 0x02A7, 0x02A8, 0x02A9, 0x02AA, 0x02AB, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x86B_ */ .half 0x0000, 0x0000, 0x0000, 0x02AC, 0x02AD, 0x02AE, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x86C_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x02AF, 0x02B0, 0x02B1, 0x02B2, 0x02B3, 0x02B4, 0x02B5, 0x02B6, 0x02B7 -/* 0x86D_ */ .half 0x02B8, 0x02B9, 0x02BA, 0x02BB, 0x02BC, 0x02BD, 0x02BE, 0x02BF, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x86E_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x86F_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 - -/* 0x___0 0x___1 0x___2 0x___3 0x___4 0x___5 0x___6 0x___7 0x___8 0x___9 0x___A 0x___B 0x___C 0x___D 0x___E 0x___F */ -/* 0x874_ */ .half 0x02C0, 0x02C1, 0x02C2, 0x02C3, 0x02C4, 0x02C5, 0x02C6, 0x02C7, 0x02C8, 0x02C9, 0x02CA, 0x02CB, 0x02CC, 0x02CD, 0x02CE, 0x02CF -/* 0x875_ */ .half 0x02D0, 0x02D1, 0x02D2, 0x02D3, 0x02D4, 0x02D5, 0x02D6, 0x02D7, 0x02D8, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x876_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x877_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x878_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x879_ */ .half 0x0000, 0x02D9, 0x02DA, 0x02DB, 0x02DC, 0x02DD, 0x02DE, 0x02DF, 0x02E0, 0x02E1, 0x02E2, 0x02E3, 0x02E4, 0x02E5, 0x02E6, 0x02E7 -/* 0x87A_ */ .half 0x02E8, 0x02E9, 0x02EA, 0x02EB, 0x02EC, 0x02ED, 0x02EE, 0x02EF, 0x02F0, 0x02F1, 0x02F2, 0x02F3, 0x02F4, 0x02F5, 0x02F6, 0x02F7 -/* 0x87B_ */ .half 0x02F8, 0x02F9, 0x02FA, 0x02FB, 0x02FC, 0x02FD, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x02FE, 0x02FF, 0x0300 -/* 0x87C_ */ .half 0x0301, 0x0302, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x87D_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x87E_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0303, 0x0304, 0x0305, 0x0306, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x87F_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0307, 0x0308, 0x0309 -ENDDATA(kantbl) +DATA(D_801CF9E8) + .word 0x00000001 + .word 0x00020003 + .word 0x00040005 + .word 0x00060007 + .word 0x00080009 + .word 0x000A000B + .word 0x000C000D + .word 0x000E000F + .word 0x00100011 + .word 0x00120013 + .word 0x00140015 + .word 0x00160017 + .word 0x00180019 + .word 0x001A001B + .word 0x001C001D + .word 0x001E001F + .word 0x00200021 + .word 0x00220023 + .word 0x00240025 + .word 0x00260027 + .word 0x00280029 + .word 0x002A002B + .word 0x002C002D + .word 0x002E002F + .word 0x00300031 + .word 0x00320033 + .word 0x00340035 + .word 0x00360037 + .word 0x00380039 + .word 0x003A003B + .word 0x003C003D + .word 0x003E003F + .word 0x00400041 + .word 0x00420043 + .word 0x00440045 + .word 0x00460047 + .word 0x00480049 + .word 0x004A004B + .word 0x004C004D + .word 0x004E004F + .word 0x00500051 + .word 0x00520053 + .word 0x00540055 + .word 0x00560057 + .word 0x00580059 + .word 0x005A005B + .word 0x005C005D + .word 0x005E005F + .word 0x00600061 + .word 0x00620063 + .word 0x00640065 + .word 0x00660067 + .word 0x00680069 + .word 0x006A006B + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x0000006C + .word 0x006D006E + .word 0x006F0070 + .word 0x00710072 + .word 0x00730000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000074 + .word 0x00750076 + .word 0x00770078 + .word 0x0079007A + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x007B007C + .word 0x007D007E + .word 0x007F0080 + .word 0x00810082 + .word 0x00830084 + .word 0x00850086 + .word 0x00870088 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000089 + .word 0x008A008B + .word 0x008C008D + .word 0x008E008F + .word 0x00900000 + .word 0x00000000 + .word 0x00000091 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000092 + .word 0x00930094 + .word 0x00950096 + .word 0x00970098 + .word 0x0099009A + .word 0x009B0000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x009C009D + .word 0x009E009F + .word 0x00A000A1 + .word 0x00A200A3 + .word 0x00A400A5 + .word 0x00A600A7 + .word 0x00A800A9 + .word 0x00AA00AB + .word 0x00AC00AD + .word 0x00AE00AF + .word 0x00B000B1 + .word 0x00B200B3 + .word 0x00B400B5 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00B600B7 + .word 0x00B800B9 + .word 0x00BA00BB + .word 0x00BC00BD + .word 0x00BE00BF + .word 0x00C000C1 + .word 0x00C200C3 + .word 0x00C400C5 + .word 0x00C600C7 + .word 0x00C800C9 + .word 0x00CA00CB + .word 0x00CC00CD + .word 0x00CE00CF + .word 0x00000000 + .word 0x00000000 + .word 0x00D000D1 + .word 0x00D200D3 + .word 0x00D400D5 + .word 0x00D600D7 + .word 0x00D800D9 + .word 0x00DA00DB + .word 0x00DC00DD + .word 0x00DE00DF + .word 0x00E000E1 + .word 0x00E200E3 + .word 0x00E400E5 + .word 0x00E600E7 + .word 0x00E800E9 + .word 0x00EA00EB + .word 0x00EC00ED + .word 0x00EE00EF + .word 0x00F000F1 + .word 0x00F200F3 + .word 0x00F400F5 + .word 0x00F600F7 + .word 0x00F800F9 + .word 0x00FA00FB + .word 0x00FC00FD + .word 0x00FE00FF + .word 0x01000101 + .word 0x01020103 + .word 0x01040105 + .word 0x01060107 + .word 0x01080109 + .word 0x010A010B + .word 0x010C010D + .word 0x010E010F + .word 0x01100111 + .word 0x01120113 + .word 0x01140115 + .word 0x01160117 + .word 0x01180119 + .word 0x011A011B + .word 0x011C011D + .word 0x011E011F + .word 0x01200121 + .word 0x01220123 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x01240125 + .word 0x01260127 + .word 0x01280129 + .word 0x012A012B + .word 0x012C012D + .word 0x012E012F + .word 0x01300131 + .word 0x01320133 + .word 0x01340135 + .word 0x01360137 + .word 0x01380139 + .word 0x013A013B + .word 0x013C013D + .word 0x013E013F + .word 0x01400141 + .word 0x01420143 + .word 0x01440145 + .word 0x01460147 + .word 0x01480149 + .word 0x014A014B + .word 0x014C014D + .word 0x014E014F + .word 0x01500151 + .word 0x01520153 + .word 0x01540155 + .word 0x01560157 + .word 0x01580159 + .word 0x015A015B + .word 0x015C015D + .word 0x015E015F + .word 0x01600161 + .word 0x01620163 + .word 0x01640165 + .word 0x01660167 + .word 0x01680169 + .word 0x016A016B + .word 0x016C016D + .word 0x016E016F + .word 0x01700171 + .word 0x01720173 + .word 0x01740175 + .word 0x01760177 + .word 0x01780179 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x017A017B + .word 0x017C017D + .word 0x017E017F + .word 0x01800181 + .word 0x01820183 + .word 0x01840185 + .word 0x01860187 + .word 0x01880189 + .word 0x018A018B + .word 0x018C018D + .word 0x018E018F + .word 0x01900191 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x01920193 + .word 0x01940195 + .word 0x01960197 + .word 0x01980199 + .word 0x019A019B + .word 0x019C019D + .word 0x019E019F + .word 0x01A001A1 + .word 0x01A201A3 + .word 0x01A401A5 + .word 0x01A601A7 + .word 0x01A801A9 + .word 0x01AA0000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x01AB01AC + .word 0x01AD01AE + .word 0x01AF01B0 + .word 0x01B101B2 + .word 0x01B301B4 + .word 0x01B501B6 + .word 0x01B701B8 + .word 0x01B901BA + .word 0x01BB01BC + .word 0x01BD01BE + .word 0x01BF01C0 + .word 0x01C101C2 + .word 0x01C301C4 + .word 0x01C501C6 + .word 0x01C701C8 + .word 0x01C901CA + .word 0x01CB0000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x01CC01CD + .word 0x01CE01CF + .word 0x01D001D1 + .word 0x01D201D3 + .word 0x01D401D5 + .word 0x01D601D7 + .word 0x01D801D9 + .word 0x01DA01DB + .word 0x01DC01DD + .word 0x01DE01DF + .word 0x01E001E1 + .word 0x01E201E3 + .word 0x01E401E5 + .word 0x01E601E7 + .word 0x01E801E9 + .word 0x01EA01EB + .word 0x01EC0000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x01ED01EE + .word 0x01EF01F0 + .word 0x01F101F2 + .word 0x01F301F4 + .word 0x01F501F6 + .word 0x01F701F8 + .word 0x01F901FA + .word 0x01FB01FC + .word 0x01FD01FE + .word 0x01FF0200 + .word 0x02010202 + .word 0x02030204 + .word 0x02050206 + .word 0x02070208 + .word 0x0209020A + .word 0x020B020C + .word 0x020D0000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x020E020F + .word 0x02100211 + .word 0x02120213 + .word 0x02140215 + .word 0x02160217 + .word 0x02180219 + .word 0x021A021B + .word 0x021C021D + .word 0x021E021F + .word 0x02200221 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x02220223 + .word 0x02240225 + .word 0x02260227 + .word 0x02280229 + .word 0x022A022B + .word 0x022C022D + .word 0x022E022F + .word 0x02300231 + .word 0x02320233 + .word 0x02340235 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x02360237 + .word 0x02380239 + .word 0x023A023B + .word 0x023C023D + .word 0x023E0000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x023F0240 + .word 0x02410242 + .word 0x02430244 + .word 0x02450246 + .word 0x02470248 + .word 0x00000000 + .word 0x00000000 + .word 0x0249024A + .word 0x024B024C + .word 0x024D024E + .word 0x024F0250 + .word 0x02510252 + .word 0x02530254 + .word 0x02550256 + .word 0x02570000 + .word 0x00000000 + .word 0x00000000 + .word 0x02580259 + .word 0x025A025B + .word 0x025C025D + .word 0x025E025F + .word 0x02600261 + .word 0x02620263 + .word 0x02640265 + .word 0x02660000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x02670268 + .word 0x0269026A + .word 0x026B026C + .word 0x026D026E + .word 0x026F0270 + .word 0x02710272 + .word 0x02730274 + .word 0x02750276 + .word 0x02770278 + .word 0x0279027A + .word 0x027B027C + .word 0x027D027E + .word 0x027F0280 + .word 0x02810000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x02820283 + .word 0x02840285 + .word 0x02860287 + .word 0x02880289 + .word 0x028A028B + .word 0x028C028D + .word 0x028E028F + .word 0x02900291 + .word 0x02920293 + .word 0x02940295 + .word 0x02960297 + .word 0x02980299 + .word 0x029A029B + .word 0x029C029D + .word 0x029E029F + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x02A002A1 + .word 0x02A202A3 + .word 0x02A402A5 + .word 0x02A602A7 + .word 0x02A802A9 + .word 0x02AA02AB + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x02AC02AD + .word 0x02AE0000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x02AF02B0 + .word 0x02B102B2 + .word 0x02B302B4 + .word 0x02B502B6 + .word 0x02B702B8 + .word 0x02B902BA + .word 0x02BB02BC + .word 0x02BD02BE + .word 0x02BF0000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x02C002C1 + .word 0x02C202C3 + .word 0x02C402C5 + .word 0x02C602C7 + .word 0x02C802C9 + .word 0x02CA02CB + .word 0x02CC02CD + .word 0x02CE02CF + .word 0x02D002D1 + .word 0x02D202D3 + .word 0x02D402D5 + .word 0x02D602D7 + .word 0x02D80000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x02D902DA + .word 0x02DB02DC + .word 0x02DD02DE + .word 0x02DF02E0 + .word 0x02E102E2 + .word 0x02E302E4 + .word 0x02E502E6 + .word 0x02E702E8 + .word 0x02E902EA + .word 0x02EB02EC + .word 0x02ED02EE + .word 0x02EF02F0 + .word 0x02F102F2 + .word 0x02F302F4 + .word 0x02F502F6 + .word 0x02F702F8 + .word 0x02F902FA + .word 0x02FB02FC + .word 0x02FD0000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x02FE02FF + .word 0x03000301 + .word 0x03020000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x03030304 + .word 0x03050306 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000307 + .word 0x03080309 +ENDDATA(D_801CF9E8) diff --git a/src/libleo/api/lbatobyte.c b/src/libleo/api/lbatobyte.c index e260fced18c..e705b46dc3c 100644 --- a/src/libleo/api/lbatobyte.c +++ b/src/libleo/api/lbatobyte.c @@ -1,7 +1,5 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" s32 LeoLBAToByte(s32 startlba, u32 nlbas, s32* bytes) { u32 resbytes; diff --git a/src/libleo/leo/leodiskinit.c b/src/libleo/api/leodiskinit.c similarity index 73% rename from src/libleo/leo/leodiskinit.c rename to src/libleo/api/leodiskinit.c index 92020029eaf..733857a6e94 100644 --- a/src/libleo/leo/leodiskinit.c +++ b/src/libleo/api/leodiskinit.c @@ -1,10 +1,7 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" +#include "ultra64/leo_internal.h" #include "ultra64/leodrive.h" -extern OSPiHandle* __osPiTable; - OSPiHandle __LeoDiskHandle; OSPiHandle* __osDiskHandle; @@ -12,22 +9,18 @@ OSPiHandle* osLeoDiskInit(void) { u32 saveMask; __LeoDiskHandle.type = DEVICE_TYPE_64DD; - __LeoDiskHandle.baseAddress = (u32)OS_PHYSICAL_TO_K1(ASIC_C2_BUFF); + __LeoDiskHandle.baseAddress = PHYS_TO_K1(ASIC_BASE); __LeoDiskHandle.latency = 3; __LeoDiskHandle.pulse = 6; __LeoDiskHandle.pageSize = 6; __LeoDiskHandle.relDuration = 2; __LeoDiskHandle.domain = PI_DOMAIN2; __LeoDiskHandle.speed = 0; - - bzero(&__LeoDiskHandle.transferInfo, sizeof(__OSTranxInfo)); + bzero(&__LeoDiskHandle.transferInfo, sizeof(__LeoDiskHandle.transferInfo)); saveMask = __osDisableInt(); - __LeoDiskHandle.next = __osPiTable; __osPiTable = &__LeoDiskHandle; __osDiskHandle = &__LeoDiskHandle; - __osRestoreInt(saveMask); - return &__LeoDiskHandle; } diff --git a/src/libleo/api/leoglobals.c b/src/libleo/api/leoglobals.c new file mode 100644 index 00000000000..377c6e87590 --- /dev/null +++ b/src/libleo/api/leoglobals.c @@ -0,0 +1,5 @@ +#include "ultra64.h" +#include "ultra64/leo_internal.h" + +s32 __leoActive = 0; +LEOVersion __leoVersion; diff --git a/src/libleo/api/leointerrupt.c b/src/libleo/api/leointerrupt.c new file mode 100644 index 00000000000..74c1a6ae61a --- /dev/null +++ b/src/libleo/api/leointerrupt.c @@ -0,0 +1,194 @@ +#include "ultra64.h" +#include "ultra64/leo_internal.h" +#include "ultra64/leodrive.h" +#include "ultra64/internal.h" +#include "ultra64/pi.h" + +void __osLeoAbnormalResume(void); +void __osLeoResume(void); + +STACK(leoDiskStack, 0x1000); + +s32 __osLeoInterrupt(void) { + u32 stat; + volatile u32 pi_stat; + u32 bm_stat; + __OSTranxInfo* info; + __OSBlockInfo* blockInfo; + + info = &__osDiskHandle->transferInfo; + blockInfo = &info->block[info->blockNum]; + pi_stat = IO_READ(PI_STATUS_REG); + if (pi_stat & PI_STATUS_DMA_BUSY) { + __OSGlobalIntMask &= ~(OS_IM_CART & ~OS_IM_RCP); + blockInfo->errStatus = 29; + __osLeoResume(); + return 1; + } + pi_stat = IO_READ(PI_STATUS_REG); + while ((pi_stat & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) != 0) { + pi_stat = IO_READ(PI_STATUS_REG); + } + stat = IO_READ(ASIC_STATUS); + if (stat & LEO_STATUS_MECHANIC_INTR) { + pi_stat = IO_READ(PI_STATUS_REG); + while ((pi_stat & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) != 0) { + pi_stat = IO_READ(PI_STATUS_REG); + } + IO_WRITE(ASIC_BM_CTL, info->bmCtlShadow | LEO_BM_CLR_MECHANIC_INTR); + blockInfo->errStatus = LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; + return 0; + } + if (info->cmdType == 2) { + return 1; + } + if (stat & 0x08000000) { + pi_stat = IO_READ(PI_STATUS_REG); + while ((pi_stat & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) != 0) { + pi_stat = IO_READ(PI_STATUS_REG); + } + IO_READ(ASIC_STATUS); + blockInfo->errStatus = LEO_SENSE_WRITE_FAULT; + __osLeoResume(); + IO_WRITE(PI_STATUS_REG, PI_STATUS_CLR_INTR); + __OSGlobalIntMask |= OS_IM_PI; + return 1; + } + if (info->cmdType == 1) { + if (!(stat & 0x40000000)) { + if ((info->sectorNum + 1) != (info->transferMode * 0x55)) { + blockInfo->errStatus = LEO_SENSE_NO_REFERENCE_POSITION_FOUND; + __osLeoAbnormalResume(); + } else { + IO_WRITE(PI_STATUS_REG, PI_STATUS_CLR_INTR); + __OSGlobalIntMask |= OS_IM_PI; + blockInfo->errStatus = LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; + __osLeoResume(); + } + } else { + blockInfo->dramAddr = (u8*)blockInfo->dramAddr + blockInfo->sectorSize; + info->sectorNum += 1; + __osEPiRawStartDma(__osDiskHandle, OS_WRITE, ASIC_SECTOR_BUFF, blockInfo->dramAddr, blockInfo->sectorSize); + } + return 1; + } + if (info->cmdType == 0) { + if (info->transferMode == 3) { + if ((s32)(blockInfo->C1ErrNum + 0x11) < info->sectorNum) { + blockInfo->errStatus = LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; + __osLeoAbnormalResume(); + return 1; + } + if (!(stat & 0x40000000)) { + blockInfo->errStatus = LEO_SENSE_UNRECOVERED_READ_ERROR; + __osLeoAbnormalResume(); + return 1; + } + } else { + blockInfo->dramAddr = (u8*)blockInfo->dramAddr + blockInfo->sectorSize; + } + bm_stat = IO_READ(ASIC_BM_STATUS); + if (((bm_stat & 0x00200000) && (bm_stat & 0x00400000)) || (bm_stat & 0x02000000)) { + if (blockInfo->C1ErrNum >= 4) { + if ((info->transferMode != 3) || (info->sectorNum >= 0x53)) { + blockInfo->errStatus = LEO_SENSE_UNRECOVERED_READ_ERROR; + __osLeoAbnormalResume(); + return 1; + } + } else { + int errNum; + + errNum = blockInfo->C1ErrNum; + blockInfo->C1ErrSector[errNum] = info->sectorNum + 1; + } + blockInfo->C1ErrNum += 1; + } + if (stat & 0x10000000) { + if (info->sectorNum != 0x57) { + blockInfo->errStatus = LEO_SENSE_NO_REFERENCE_POSITION_FOUND; + __osLeoAbnormalResume(); + } else { + if ((info->transferMode == 2) && (info->blockNum == 0)) { + info->blockNum = 1; + info->sectorNum = -1; + info->block[1].dramAddr = (u8*)info->block[1].dramAddr - info->block[1].sectorSize; + blockInfo->errStatus = LEO_SENSE_WRITE_FAULT; + } else { + IO_WRITE(PI_STATUS_REG, PI_STATUS_CLR_INTR); + __OSGlobalIntMask |= OS_IM_PI; + info->cmdType = 2; + blockInfo->errStatus = LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; + } + __osEPiRawStartDma(__osDiskHandle, OS_READ, ASIC_C2_BUFF, blockInfo->C2Addr, blockInfo->sectorSize * 4); + } + return 1; + } + if ((info->sectorNum == -1) && (info->transferMode == 2) && (info->blockNum == 1)) { + __OSBlockInfo* bptr = info->block; + + if (info->block[0].C1ErrNum == 0) { + if ((((u32*)bptr->C2Addr)[0] | ((u32*)bptr->C2Addr)[1] | ((u32*)bptr->C2Addr)[2] | + ((u32*)bptr->C2Addr)[3]) != 0) { + bptr->errStatus = LEO_SENSE_UNRECOVERED_READ_ERROR; + __osLeoAbnormalResume(); + return 1; + } + } + info->block[0].errStatus = LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; + __osLeoResume(); + } + info->sectorNum += 1; + if (stat & 0x40000000) { + if (info->sectorNum >= 0x55) { + blockInfo->errStatus = LEO_SENSE_NO_REFERENCE_POSITION_FOUND; + __osLeoAbnormalResume(); + return 1; + } + __osEPiRawStartDma(__osDiskHandle, OS_READ, ASIC_SECTOR_BUFF, blockInfo->dramAddr, blockInfo->sectorSize); + blockInfo->errStatus = LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; + return 1; + } + if (info->sectorNum < 0x55) { + blockInfo->errStatus = LEO_SENSE_NO_REFERENCE_POSITION_FOUND; + __osLeoAbnormalResume(); + return 1; + } + return 1; + } + blockInfo->errStatus = LEO_SENSE_DATA_PHASE_ERROR; + __osLeoAbnormalResume(); + return 1; +} + +void __osLeoAbnormalResume(void) { + __OSTranxInfo* info; + u32 pi_stat; + + info = &__osDiskHandle->transferInfo; + while (((pi_stat = IO_READ(PI_STATUS_REG)) & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) != 0) {} + IO_WRITE(ASIC_BM_CTL, info->bmCtlShadow | LEO_BM_RESET); + while (((pi_stat = IO_READ(PI_STATUS_REG)) & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) != 0) {} + IO_WRITE(ASIC_BM_CTL, info->bmCtlShadow); + __osLeoResume(); + IO_WRITE(PI_STATUS_REG, PI_STATUS_CLR_INTR); + __OSGlobalIntMask |= OS_IM_PI; +} + +void __osLeoResume(void) { + __OSEventState* es; + OSMesgQueue* mq; + s32 last; + + es = &__osEventStateTab[OS_EVENT_PI]; + mq = es->queue; + if (mq != NULL) { + if (mq->validCount < mq->msgCount) { + last = (mq->first + mq->validCount) % mq->msgCount; + mq->msg[last] = es->msg; + mq->validCount++; + if (mq->mtqueue->next != NULL) { + __osEnqueueThread(&__osRunQueue, __osPopThread(&mq->mtqueue)); + } + } + } +} diff --git a/src/libleo/api/seek.c b/src/libleo/api/readdiskid.c similarity index 63% rename from src/libleo/api/seek.c rename to src/libleo/api/readdiskid.c index 8abbb0f0a56..1200c5f6aa4 100644 --- a/src/libleo/api/seek.c +++ b/src/libleo/api/readdiskid.c @@ -1,24 +1,19 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" -s32 LeoSeek(LEOCmd* cmdBlock, u32 lba, OSMesgQueue* mq) { +s32 LeoReadDiskID(LEOCmd* cmdBlock, LEODiskID* vaddr, OSMesgQueue* mq) { if (!__leoActive) { return -1; } - cmdBlock->header.command = LEO_COMMAND_READ_DISK_ID; cmdBlock->header.reserve1 = 0; cmdBlock->header.control = 0; cmdBlock->header.reserve3 = 0; - cmdBlock->data.readWrite.lba = lba; - + cmdBlock->data.readdiskid.buffer_pointer = vaddr; if (mq != NULL) { cmdBlock->header.control |= LEO_CONTROL_POST; cmdBlock->header.post = mq; } - leoCommand(cmdBlock); - return LEO_ERROR_GOOD; + return 0; } diff --git a/src/libleo/api/readwrite.c b/src/libleo/api/readwrite.c index 570b94b203a..c92839e3151 100644 --- a/src/libleo/api/readwrite.c +++ b/src/libleo/api/readwrite.c @@ -1,33 +1,26 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" s32 LeoReadWrite(LEOCmd* cmdBlock, s32 direction, u32 LBA, void* vAddr, u32 nLBAs, OSMesgQueue* mq) { if (!__leoActive) { return -1; } - if (direction == OS_READ) { - cmdBlock->header.command = 5; + cmdBlock->header.command = LEO_COMMAND_READ; } else { - cmdBlock->header.command = 6; + cmdBlock->header.command = LEO_COMMAND_WRITE; } - cmdBlock->header.reserve1 = 0; - if (mq != NULL) { - cmdBlock->header.control = 0x80; + cmdBlock->header.control = LEO_CONTROL_POST; } else { cmdBlock->header.control = 0; } - cmdBlock->header.reserve3 = 0; cmdBlock->header.post = mq; - cmdBlock->data.readWrite.lba = LBA; - cmdBlock->data.readWrite.transferBlks = nLBAs; - cmdBlock->data.readWrite.buffPtr = vAddr; - + cmdBlock->data.readwrite.lba = LBA; + cmdBlock->data.readwrite.xfer_blks = nLBAs; + cmdBlock->data.readwrite.buff_ptr = vAddr; leoCommand(cmdBlock); - return LEO_ERROR_GOOD; + return 0; } diff --git a/src/libleo/api/spdlmotor.c b/src/libleo/api/spdlmotor.c index 21ef2b02235..94f487f3899 100644 --- a/src/libleo/api/spdlmotor.c +++ b/src/libleo/api/spdlmotor.c @@ -1,38 +1,31 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" s32 LeoSpdlMotor(LEOCmd* cmdBlock, u8 mode, OSMesgQueue* mq) { if (!__leoActive) { return -1; } - - cmdBlock->header.command = 8; + cmdBlock->header.command = LEO_COMMAND_START_STOP; cmdBlock->header.reserve1 = 0; - switch (mode) { - case LEO_MOTOR_ACTIVE: + case 0: cmdBlock->header.control = 1; break; - case LEO_MOTOR_STANDBY: - cmdBlock->header.control = 2; + case 1: + cmdBlock->header.control = LEO_CONTROL_STBY; break; - case LEO_MOTOR_SLEEP: + case 2: cmdBlock->header.control = 0; break; - case LEO_MOTOR_BRAKE: - cmdBlock->header.control = 4; + case 4: + cmdBlock->header.control = LEO_CONTROL_BRAKE; break; } - cmdBlock->header.reserve3 = 0; - if (mq != NULL) { cmdBlock->header.post = mq; - cmdBlock->header.control |= 0x80; + cmdBlock->header.control |= LEO_CONTROL_POST; } - leoCommand(cmdBlock); - return LEO_ERROR_GOOD; + return 0; } diff --git a/src/libleo/api/testunitready.c b/src/libleo/api/testunitready.c index 2116bc9e2af..e7f6b4519b0 100644 --- a/src/libleo/api/testunitready.c +++ b/src/libleo/api/testunitready.c @@ -1,28 +1,21 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" -s32 LeoTestUnitReady(u8* status) { +s32 LeoTestUnitReady(LEOStatus* status) { volatile LEOCmdTestUnitReady cmdBlock; if (!__leoActive) { return -1; } - if (IO_READ(PI_STATUS_REG) & PI_STATUS_DMA_BUSY) { return LEO_ERROR_BUSY; } - - cmdBlock.header.command = 3; + cmdBlock.header.command = LEO_COMMAND_TEST_UNIT_READY; cmdBlock.header.reserve1 = 0; cmdBlock.header.control = 0; cmdBlock.header.reserve3 = 0; - leoCommand((void*)&cmdBlock); - - while (cmdBlock.header.status == 8) {} - + while (cmdBlock.header.status == LEO_STATUS_BUSY) {} *status = cmdBlock.test; - return GET_ERROR(cmdBlock); + return cmdBlock.header.sense; } diff --git a/src/libleo/leo/leo_tbl.c b/src/libleo/leo/leo_tbl.c index 083fabb728c..280dbfaa144 100644 --- a/src/libleo/leo/leo_tbl.c +++ b/src/libleo/leo/leo_tbl.c @@ -1,58 +1,29 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" const char LEOfirmware_rev[] = "B014A26"; -const u8 LEOBYTE_TBL1[] = { - 0xE8, 0xD8, 0xD0, 0xC0, 0xB0, 0xA0, 0x90, 0x80, 0x70, +const u8 LEOBYTE_TBL1[0xC] = { 0xE8, 0xD8, 0xD0, 0xC0, 0xB0, 0xA0, 0x90, 0x80, 0x70, 0, 0, 0 }; +const u16 LEOBYTE_TBL2[9] = { 0x4D08, 0x47B8, 0x4510, 0x3FC0, 0x3A70, 0x3520, 0x2FD0, 0x2A80, 0x2530 }; +const u16 LEOVZONE_TBL[7][0x10] = { + { 0x124, 0x248, 0x35A, 0x47E, 0x5A2, 0x6B4, 0x7C6, 0x8D8, 0x9EA, 0xAB6, 0xB82, 0xC94, 0xDA6, 0xEB8, 0xFCA, 0x10DC }, + { 0x124, 0x248, 0x35A, 0x46C, 0x57E, 0x6A2, 0x7C6, 0x8D8, 0x9EA, 0xAFC, 0xBC8, 0xC94, 0xDA6, 0xEB8, 0xFCA, 0x10DC }, + { 0x124, 0x248, 0x35A, 0x46C, 0x57E, 0x690, 0x7A2, 0x8C6, 0x9EA, 0xAFC, 0xC0E, 0xCDA, 0xDA6, 0xEB8, 0xFCA, 0x10DC }, + { 0x124, 0x248, 0x35A, 0x46C, 0x57E, 0x690, 0x7A2, 0x8B4, 0x9C6, 0xAEA, 0xC0E, 0xD20, 0xDEC, 0xEB8, 0xFCA, 0x10DC }, + { 0x124, 0x248, 0x35A, 0x46C, 0x57E, 0x690, 0x7A2, 0x8B4, 0x9C6, 0xAD8, 0xBEA, 0xD0E, 0xE32, 0xEFE, 0xFCA, 0x10DC }, + { 0x124, 0x248, 0x35A, 0x46C, 0x57E, 0x690, 0x7A2, 0x86E, 0x980, 0xA92, 0xBA4, 0xCB6, 0xDC8, 0xEEC, 0x1010, + 0x10DC }, + { 0x124, 0x248, 0x35A, 0x46C, 0x57E, 0x690, 0x7A2, 0x86E, 0x93A, 0xA4C, 0xB5E, 0xC70, 0xD82, 0xE94, 0xFB8, 0x10DC }, +}; +const u16 LEOZONE_SCYL_TBL[0x10] = { + 0, 0x9E, 0x13C, 0x1D1, 0x266, 0x2FB, 0x390, 0x425, 0x91, 0x12F, 0x1C4, 0x259, 0x2EE, 0x383, 0x418, 0x48A, }; - -const u16 LEOBYTE_TBL2[] = { - 0x4D08, 0x47B8, 0x4510, 0x3FC0, 0x3A70, 0x3520, 0x2FD0, 0x2A80, 0x2530, -}; - -const u16 LEOVZONE_TBL[][0x10] = { - { 0x0124, 0x0248, 0x035A, 0x047E, 0x05A2, 0x06B4, 0x07C6, 0x08D8, 0x09EA, 0x0AB6, 0x0B82, 0x0C94, 0x0DA6, 0x0EB8, - 0x0FCA, 0x10DC }, - { 0x0124, 0x0248, 0x035A, 0x046C, 0x057E, 0x06A2, 0x07C6, 0x08D8, 0x09EA, 0x0AFC, 0x0BC8, 0x0C94, 0x0DA6, 0x0EB8, - 0x0FCA, 0x10DC }, - { 0x0124, 0x0248, 0x035A, 0x046C, 0x057E, 0x0690, 0x07A2, 0x08C6, 0x09EA, 0x0AFC, 0x0C0E, 0x0CDA, 0x0DA6, 0x0EB8, - 0x0FCA, 0x10DC }, - { 0x0124, 0x0248, 0x035A, 0x046C, 0x057E, 0x0690, 0x07A2, 0x08B4, 0x09C6, 0x0AEA, 0x0C0E, 0x0D20, 0x0DEC, 0x0EB8, - 0x0FCA, 0x10DC }, - { 0x0124, 0x0248, 0x035A, 0x046C, 0x057E, 0x0690, 0x07A2, 0x08B4, 0x09C6, 0x0AD8, 0x0BEA, 0x0D0E, 0x0E32, 0x0EFE, - 0x0FCA, 0x10DC }, - { 0x0124, 0x0248, 0x035A, 0x046C, 0x057E, 0x0690, 0x07A2, 0x086E, 0x0980, 0x0A92, 0x0BA4, 0x0CB6, 0x0DC8, 0x0EEC, - 0x1010, 0x10DC }, - { 0x0124, 0x0248, 0x035A, 0x046C, 0x057E, 0x0690, 0x07A2, 0x086E, 0x093A, 0x0A4C, 0x0B5E, 0x0C70, 0x0D82, 0x0E94, - 0x0FB8, 0x10DC }, -}; - -const u16 LEOZONE_SCYL_TBL[] = { - 0x0000, 0x009E, 0x013C, 0x01D1, 0x0266, 0x02FB, 0x0390, 0x0425, - 0x0091, 0x012F, 0x01C4, 0x0259, 0x02EE, 0x0383, 0x0418, 0x048A, -}; - const u8 LEOVZONE_PZONEHD_TBL[][0x10] = { - { 0x00, 0x01, 0x02, 0x09, 0x08, 0x03, 0x04, 0x05, 0x06, 0x07, 0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A }, - { 0x00, 0x01, 0x02, 0x03, 0x0A, 0x09, 0x08, 0x04, 0x05, 0x06, 0x07, 0x0F, 0x0E, 0x0D, 0x0C, 0x0B }, - { 0x00, 0x01, 0x02, 0x03, 0x04, 0x0B, 0x0A, 0x09, 0x08, 0x05, 0x06, 0x07, 0x0F, 0x0E, 0x0D, 0x0C }, - { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x0C, 0x0B, 0x0A, 0x09, 0x08, 0x06, 0x07, 0x0F, 0x0E, 0x0D }, - { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08, 0x07, 0x0F, 0x0E }, - { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08, 0x0F }, - { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08 }, -}; - -const u16 LEOZONE_OUTERCYL_TBL[] = { - 0x0000, 0x009E, 0x013C, 0x01D1, 0x0266, 0x02FB, 0x0390, 0x0425, -}; - -const u16 LEORAM_START_LBA[] = { - 0x05A2, 0x07C6, 0x09EA, 0x0C0E, 0x0E32, 0x1010, 0x10DC, -}; - -const s32 LEORAM_BYTE[] = { - 0x024A9DC0, 0x01C226C0, 0x01450F00, 0x00D35680, 0x006CFD40, 0x001DA240, 0x00000000, -}; + { 0, 1, 2, 9, 8, 3, 4, 5, 6, 7, 15, 14, 13, 12, 11, 10 }, { 0, 1, 2, 3, 10, 9, 8, 4, 5, 6, 7, 15, 14, 13, 12, 11 }, + { 0, 1, 2, 3, 4, 11, 10, 9, 8, 5, 6, 7, 15, 14, 13, 12 }, { 0, 1, 2, 3, 4, 5, 12, 11, 10, 9, 8, 6, 7, 15, 14, 13 }, + { 0, 1, 2, 3, 4, 5, 6, 13, 12, 11, 10, 9, 8, 7, 15, 14 }, { 0, 1, 2, 3, 4, 5, 6, 7, 14, 13, 12, 11, 10, 9, 8, 15 }, + { 0, 1, 2, 3, 4, 5, 6, 7, 15, 14, 13, 12, 11, 10, 9, 8 }, +}; +const u16 LEOZONE_OUTERCYL_TBL[8] = { 0, 0x9E, 0x13C, 0x1D1, 0x266, 0x2FB, 0x390, 0x425 }; +const u16 LEORAM_START_LBA[8] = { 0x5A2, 0x7C6, 0x9EA, 0xC0E, 0xE32, 0x1010, 0x10DC, 0 }; +const u32 LEORAM_BYTE[0xA] = { 0x024A9DC0, 0x01C226C0, 0x01450F00, 0xD35680, 0x6CFD40, 0x1DA240, 0, 0, 0, 0 }; diff --git a/src/libleo/leo/leoc2_syndrome.c b/src/libleo/leo/leoc2_syndrome.c index fe72a3e89ef..cf0dec7805e 100644 --- a/src/libleo/leo/leoc2_syndrome.c +++ b/src/libleo/leo/leoc2_syndrome.c @@ -1,3 +1,4 @@ -#include "n64dd.h" +#include "ultra64.h" +#include "ultra64/leo_internal.h" u8 LEOC2_Syndrome[2][0xE8 * 4]; diff --git a/src/libleo/leo/leoc2ecc.c b/src/libleo/leo/leoc2ecc.c index 5b770b138db..573fdf543b1 100644 --- a/src/libleo/leo/leoc2ecc.c +++ b/src/libleo/leo/leoc2ecc.c @@ -1,7 +1,5 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" void leoC2_single_ecc(void); void leoC2_double_ecc(void); @@ -10,8 +8,6 @@ void leoC2_4_ecc(void); int leoAlpha_mult(int i, int k); int leoAlpha_div(int i, int k); -extern u8 LEO_TempBuffer[0xE8]; - const u8 ganlog[512] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1D, 0x3A, 0x74, 0xE8, 0xCD, 0x87, 0x13, 0x26, 0x4C, 0x98, 0x2D, 0x5A, 0xB4, 0x75, 0xEA, 0xC9, 0x8F, 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0x9D, 0x27, 0x4E, 0x9C, 0x25, 0x4A, @@ -96,8 +92,7 @@ int leoC2_Correction(void) { return 0; } -// static -void leoC2_single_ecc(void) { +STATIC void leoC2_single_ecc(void) { u8* pointer; unsigned int byte; u8* p_s; @@ -113,8 +108,7 @@ void leoC2_single_ecc(void) { } } -// static -void leoC2_double_ecc(void) { +STATIC void leoC2_double_ecc(void) { unsigned int s0; unsigned int error_k; u8* pointer1; @@ -140,7 +134,6 @@ void leoC2_double_ecc(void) { goto c2_2_1; } return; - c2_2_2: pointer2 = &LEOc2_param.pntr[(LEOc2_param.err_pos[1] + 1) * byte]; c2_2_1: @@ -167,8 +160,7 @@ void leoC2_double_ecc(void) { } while (--byte != 0); } -// static -void leoC2_3_ecc(void) { +STATIC void leoC2_3_ecc(void) { unsigned int s0; unsigned int error_i; unsigned int error_j; @@ -235,7 +227,6 @@ void leoC2_3_ecc(void) { goto c2_3_1; } return; - c2_3_3: pointer3 = &LEOc2_param.pntr[(LEOc2_param.err_pos[2] + 1) * byte]; c2_3_2: @@ -284,8 +275,7 @@ void leoC2_3_ecc(void) { } while (--byte != 0); } -// static -void leoC2_4_ecc(void) { +STATIC void leoC2_4_ecc(void) { unsigned int s0; unsigned int R0; unsigned int R1; @@ -478,16 +468,14 @@ void leoC2_4_ecc(void) { } while (--byte != 0); } -// static -int leoAlpha_mult(int i, int k) { +STATIC int leoAlpha_mult(int i, int k) { if (i == 0 || k == 0) { return 0; } return ganlog[glog[i] + glog[k]]; } -// static -int leoAlpha_div(int i, int k) { +STATIC int leoAlpha_div(int i, int k) { if (i == 0 || k == 0) { return 0; } diff --git a/src/libleo/leo/leocmdex.c b/src/libleo/leo/leocmdex.c index 851abd343b2..2d7c180c4b5 100644 --- a/src/libleo/leo/leocmdex.c +++ b/src/libleo/leo/leocmdex.c @@ -1,31 +1,24 @@ -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" +#include "ultra64.h" +#include "ultra64/leo_internal.h" #include "ultra64/leodrive.h" #include "attributes.h" -#include "ultra64.h" - -extern vu16 LEOrw_flags; +extern u16 LEOrw_flags; -static void (*cmd_tbl[16])(void) = { +void (*cmd_tbl[])(void) = { NULL, leoClr_queue, leoInquiry, leoTest_unit_rdy, leoRezero, leoRead, leoWrite, leoSeek, leoStart_stop, leoRd_capacity, leoTranslate, leoMode_sel, leoReadDiskId, leoReadTimer, leoSetTimer, leoClr_reset, }; +const LEOCmdRead system_read_cmd = { { LEO_COMMAND_READ, 0, 0, 0, 0, 0, 0, 0, NULL }, 0xC, 1, NULL, 0 }; -static LEOCmdRead system_read_cmd = { - { LEO_COMMAND_READ, 0, 0, 0, 0, 0, 0, 0, 0 }, 12, 1, 0, 0, -}; - -static const u8 system_lba[8] = { 0, 1, 8, 9, 0, 0, 0, 0 }; +const u8 system_lba[] = { 0, 1, 8, 9, 0, 0, 0, 0 }; OSPiHandle* LEOPiInfo; OSIoMesg LEOPiDmaParam; s32 currentCommand; -u8 leoRead_system_area(void); - -void leomain(UNUSED void* arg0) { +void leomain(void* arg0) { u32 cur_status; u32 sense_code; UNUSED u8 disktype_bak; @@ -44,8 +37,10 @@ void leomain(UNUSED void* arg0) { LEOPiDmaParam.hdr.pri = 1; LEOPiDmaParam.hdr.retQueue = &LEOdma_que; osEPiReadIo(LEOPiInfo, ASIC_STATUS, &cur_status); - if (!(cur_status & 0x400000) && (cur_status & 0x06800000)) { - leoDrive_reset(); + if (!(cur_status & 0x400000)) { + if ((cur_status & 0x06800000) != 0) { + leoDrive_reset(); + } } while (true) { @@ -62,19 +57,19 @@ void leomain(UNUSED void* arg0) { do { if (cur_status == 0) { - if (sense_code == 0) { + if (sense_code == LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { continue; } } else { switch (sense_code) { - case 3: - case 37: - case 41: - case 43: + case LEO_SENSE_COMMAND_PHASE_ERROR: + case LEO_SENSE_WAITING_NMI: + case LEO_SENSE_DEVICE_COMMUNICATION_FAILURE: + case LEO_SENSE_POWERONRESET_DEVICERESET_OCCURED: break; - case 49: - if (leoRetUnit_atten() == 43) { - sense_code = 43; + case LEO_SENSE_EJECTED_ILLEGALLY_RESUME: + if (leoRetUnit_atten() == LEO_SENSE_POWERONRESET_DEVICERESET_OCCURED) { + sense_code = LEO_SENSE_POWERONRESET_DEVICERESET_OCCURED; } break; default: @@ -83,38 +78,38 @@ void leomain(UNUSED void* arg0) { } switch (sense_code) { - case 47: + case LEO_SENSE_MEDIUM_MAY_HAVE_CHANGED: switch (LEOcur_command->header.command) { - case 2: - case 8: - case 11: - case 12: - case 13: - case 14: - case 15: + case LEO_COMMAND_INQUIRY: + case LEO_COMMAND_START_STOP: + case LEO_COMMAND_MODE_SELECT: + case LEO_COMMAND_READ_DISK_ID: + case LEO_COMMAND_READ_TIMER: + case LEO_COMMAND_SET_TIMER: + case 0xF: continue; } break; - case 49: + case LEO_SENSE_EJECTED_ILLEGALLY_RESUME: switch (LEOcur_command->header.command) { - case 2: - case 11: - case 13: - case 14: - case 15: + case LEO_COMMAND_INQUIRY: + case LEO_COMMAND_MODE_SELECT: + case LEO_COMMAND_READ_TIMER: + case LEO_COMMAND_SET_TIMER: + case 0xF: continue; default: sense_code = 42; } break; - case 43: + case LEO_SENSE_POWERONRESET_DEVICERESET_OCCURED: switch (LEOcur_command->header.command) { - case 15: + case 0xF: leoClrUA_RESET(); FALLTHROUGH; - case 2: - case 13: - case 14: + case LEO_COMMAND_INQUIRY: + case LEO_COMMAND_READ_TIMER: + case LEO_COMMAND_SET_TIMER: continue; } break; @@ -122,23 +117,23 @@ void leomain(UNUSED void* arg0) { /* empty */; } - if (LEOcur_command->header.command == 3) { - LEOcur_command->data.modeSelect.reserve1 = leoChk_cur_drvmode(); + if (LEOcur_command->header.command == LEO_COMMAND_TEST_UNIT_READY) { + LEOcur_command->data.modeselect.reserve1 = leoChk_cur_drvmode(); } LEOcur_command->header.sense = sense_code; - LEOcur_command->header.status = 2; + LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; goto post_exe; } while (0); if (LEOdrive_flag == 0) { switch (LEOcur_command->header.command) { - case 2: - case 3: - case 8: - case 11: - case 13: - case 14: - case 15: + case LEO_COMMAND_INQUIRY: + case LEO_COMMAND_TEST_UNIT_READY: + case LEO_COMMAND_START_STOP: + case LEO_COMMAND_MODE_SELECT: + case LEO_COMMAND_READ_TIMER: + case LEO_COMMAND_SET_TIMER: + case 0xF: break; default: if (LEO_country_code == 0) { @@ -149,13 +144,14 @@ void leomain(UNUSED void* arg0) { } if (leoRead_system_area() != 0) { - LEOcur_command->header.status = 2; + LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; goto post_exe; } if ((LEOcur_command->header.sense = - leoSend_asic_cmd_w(0xB0001, LEO_sys_data.param.disk_type << 16)) != 0) { - LEOcur_command->header.status = 2; + leoSend_asic_cmd_w(0xB0001, LEO_sys_data.param.disk_type << 16)) != + LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { + LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; goto post_exe; } @@ -163,11 +159,11 @@ void leomain(UNUSED void* arg0) { goto invalid_disktype; } - LEOdisk_type = (LEO_sys_data.param.disk_type & 0xF); + LEOdisk_type = LEO_sys_data.param.disk_type & 0xF; if (LEOdisk_type >= 7) { invalid_disktype: - LEOcur_command->header.sense = 0xBU; - LEOcur_command->header.status = 2; + LEOcur_command->header.sense = 11; + LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; goto post_exe; } @@ -178,8 +174,8 @@ void leomain(UNUSED void* arg0) { cmd_tbl[LEOcur_command->header.command](); post_exe: - if (LEOcur_command->header.control & 0x80) { - osSendMesg(LEOcur_command->header.post, (void*)(s32)LEOcur_command->header.sense, OS_MESG_BLOCK); + if (LEOcur_command->header.control & LEO_CONTROL_POST) { + osSendMesg(LEOcur_command->header.post, (OSMesg)(s32)LEOcur_command->header.sense, OS_MESG_BLOCK); } if (LEOclr_que_flag != 0) { leoClr_queue(); @@ -204,7 +200,7 @@ u8 leoRead_system_area(void) { LEO_sys_data.param.defect_num[0] = 0; LEOrw_flags = 0x3000; dummy_cmd = system_read_cmd; - dummy_cmd.buffPtr = &LEO_sys_data; + dummy_cmd.buff_ptr = &LEO_sys_data; if (read_mode == 0) { // read System LBA 12 (+0, this is an offset value for leoRead_common) @@ -242,10 +238,10 @@ u8 leoRead_system_area(void) { } system_retry: - if (leoChk_err_retry(dummy_cmd.header.sense) != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { + if (leoChk_err_retry(dummy_cmd.header.sense) != 0) { break; } - if (retry_cntr++ >= 0x40U) { + if (retry_cntr++ >= 64) { break; } if ((retry_cntr & 7) == 0) { @@ -260,5 +256,5 @@ u8 leoRead_system_area(void) { sys_read_end: LEOcur_command = backup_pointer; LEOcur_command->header.sense = dummy_cmd.header.sense; - return GET_ERROR(*LEOcur_command); + return LEOcur_command->header.sense; } diff --git a/src/libleo/leo/leofunc.c b/src/libleo/leo/leofunc.c index 35ba14005f5..a01ba5326c7 100644 --- a/src/libleo/leo/leofunc.c +++ b/src/libleo/leo/leofunc.c @@ -1,14 +1,14 @@ +#include "ultra64.h" #include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" #include "array_count.h" -#include "ultra64.h" +#include "ultra64/message.h" -static s32 __leoResetCalled = false; -static s32 __leoQueuesCreated = false; +s32 __leoResetCalled = 0; +s32 __leoQueuesCreated = 0; -static OSMesgQueue LEOpost_que; -static OSMesg LEOpost_que_buf[1]; +OSMesgQueue LEOpost_que; +OSMesg LEOpost_que_buf; void leoInitialize(OSPri compri, OSPri intpri, OSMesg* command_que_buf, u32 cmd_buff_size) { u32 savedMask; @@ -21,87 +21,81 @@ void leoInitialize(OSPri compri, OSPri intpri, OSMesg* command_que_buf, u32 cmd_ } else { pri = intpri; } - oldPri = -1; - myPri = osGetThreadPri(NULL); if (myPri < pri) { oldPri = myPri; osSetThreadPri(NULL, pri); } - savedMask = __osDisableInt(); - - __leoQueuesCreated = true; + __leoQueuesCreated = 1; osCreateMesgQueue(&LEOcommand_que, command_que_buf, cmd_buff_size); - osCreateMesgQueue(&LEOcontrol_que, LEOcontrol_que_buf, ARRAY_COUNT(LEOcontrol_que_buf)); - osCreateMesgQueue(&LEOevent_que, LEOevent_que_buf, ARRAY_COUNT(LEOevent_que_buf)); + osCreateMesgQueue(&LEOcontrol_que, &LEOcontrol_que_buf, 1); + osCreateMesgQueue(&LEOevent_que, &LEOevent_que_buf, 1); osCreateMesgQueue(&LEOdma_que, LEOdma_que_buf, ARRAY_COUNT(LEOdma_que_buf)); - osCreateMesgQueue(&LEOblock_que, LEOblock_que_buf, ARRAY_COUNT(LEOblock_que_buf)); - osCreateMesgQueue(&LEOpost_que, LEOpost_que_buf, ARRAY_COUNT(LEOpost_que_buf)); + osCreateMesgQueue(&LEOblock_que, &LEOblock_que_buf, 1); + osCreateMesgQueue(&LEOpost_que, &LEOpost_que_buf, 1); osCreateThread(&LEOcommandThread, 1, leomain, NULL, STACK_TOP(LEOcommandThreadStack), compri); osStartThread(&LEOcommandThread); osCreateThread(&LEOinterruptThread, 1, leointerrupt, NULL, STACK_TOP(LEOinterruptThreadStack), intpri); osStartThread(&LEOinterruptThread); - osSetEventMesg(2, &LEOevent_que, (OSMesg)0x30000); + osSetEventMesg(OS_EVENT_CART, &LEOevent_que, (OSMesg)0x30000); osSendMesg(&LEOblock_que, NULL, OS_MESG_NOBLOCK); __osRestoreInt(savedMask); - if (oldPri != -1) { osSetThreadPri(NULL, oldPri); } } void leoCommand(void* cmd_blk_addr) { + LEOCmdHeader* header = cmd_blk_addr; + if (__leoResetCalled != 0) { - ((LEOCmd*)cmd_blk_addr)->header.status = LEO_STATUS_CHECK_CONDITION; - ((LEOCmd*)cmd_blk_addr)->header.sense = LEO_SENSE_WAITING_NMI; - if ((((LEOCmd*)cmd_blk_addr)->header.control & LEO_CONTROL_POST) != 0) { - osSendMesg(((LEOCmd*)cmd_blk_addr)->header.post, (OSMesg)LEO_SENSE_WAITING_NMI, OS_MESG_BLOCK); + header->status = LEO_STATUS_CHECK_CONDITION; + header->sense = LEO_SENSE_WAITING_NMI; + if (header->control & LEO_CONTROL_POST) { + osSendMesg(header->post, (OSMesg)LEO_ERROR_WAITING_NMI, OS_MESG_BLOCK); } - return; - } - osRecvMesg(&LEOblock_que, NULL, OS_MESG_BLOCK); - ((LEOCmd*)cmd_blk_addr)->header.status = LEO_STATUS_BUSY; - ((LEOCmd*)cmd_blk_addr)->header.sense = LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; - - switch (((LEOCmd*)cmd_blk_addr)->header.command) { - case 1: - LEOclr_que_flag = 0xFF; - leoClr_queue(); - LEOclr_que_flag = 0; - ((LEOCmd*)cmd_blk_addr)->header.status = LEO_STATUS_GOOD; - if (((LEOCmd*)cmd_blk_addr)->header.control & LEO_CONTROL_POST) { - osSendMesg(((LEOCmd*)cmd_blk_addr)->header.post, (OSMesg)0, OS_MESG_BLOCK); - } - break; - - case 5: - case 6: - ((LEOCmd*)cmd_blk_addr)->data.readWrite.rwBytes = 0; - goto cmd_queing; - - default: - if ((u32)(((LEOCmd*)cmd_blk_addr)->header.command - 1) >= 0xE) { - ((LEOCmd*)cmd_blk_addr)->header.sense = LEO_SENSE_INVALID_COMMAND_OPERATION_CODE; - ((LEOCmd*)cmd_blk_addr)->header.status = LEO_STATUS_CHECK_CONDITION; + } else { + osRecvMesg(&LEOblock_que, NULL, OS_MESG_BLOCK); + header->status = LEO_STATUS_BUSY; + header->sense = LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; + switch (header->command) { + case LEO_COMMAND_CLEAR_QUE: + LEOclr_que_flag = 0xFF; + leoClr_queue(); + LEOclr_que_flag = 0; + header->status = LEO_STATUS_GOOD; + if (header->control & LEO_CONTROL_POST) { + osSendMesg(header->post, (OSMesg)LEO_ERROR_GOOD, OS_MESG_BLOCK); + } break; - } - - cmd_queing: - if (osSendMesg(&LEOcommand_que, (OSMesg)cmd_blk_addr, OS_MESG_NOBLOCK) != 0) { - ((LEOCmd*)cmd_blk_addr)->header.sense = LEO_SENSE_QUEUE_FULL; - ((LEOCmd*)cmd_blk_addr)->header.status = LEO_STATUS_CHECK_CONDITION; - } + case LEO_COMMAND_READ: + case LEO_COMMAND_WRITE: + ((LEOCmdRead*)cmd_blk_addr)->rw_bytes = 0; + goto cmd_queing; + default: + if ((u32)(header->command - 1) >= 0xE) { + header->sense = LEO_SENSE_INVALID_COMMAND_OPERATION_CODE; + header->status = LEO_STATUS_CHECK_CONDITION; + } else { + cmd_queing: + if (osSendMesg(&LEOcommand_que, cmd_blk_addr, OS_MESG_NOBLOCK) != 0) { + header->sense = LEO_SENSE_QUEUE_FULL; + header->status = LEO_STATUS_CHECK_CONDITION; + } + } + break; + } + osSendMesg(&LEOblock_que, NULL, OS_MESG_BLOCK); } - osSendMesg(&LEOblock_que, (OSMesg)0, OS_MESG_BLOCK); } -static const u8 zero[] = { 0 }; +const u8 zero[] = { 0 }; void LeoReset(void) { - __leoResetCalled = true; - if (__leoQueuesCreated) { + __leoResetCalled = 1; + if (__leoQueuesCreated != 0) { LEOclr_que_flag = 0xFF; leoClr_queue(); LEOclr_que_flag = 0; @@ -116,20 +110,20 @@ s32 __leoSetReset(void) { return 0; } -// SENSE or ERROR? s32 LeoResetClear(void) { LEOCmdHeader resetclear; resetclear.command = 0xF; resetclear.control = LEO_CONTROL_POST; - resetclear.status = 0; + resetclear.status = LEO_STATUS_GOOD; resetclear.post = &LEOpost_que; - if (osSendMesg(&LEOcommand_que, &resetclear.command, OS_MESG_NOBLOCK) != 0) { + if (osSendMesg(&LEOcommand_que, &resetclear, OS_MESG_NOBLOCK) != 0) { return LEO_SENSE_QUEUE_FULL; } osRecvMesg(&LEOpost_que, NULL, OS_MESG_BLOCK); if (resetclear.status == LEO_STATUS_GOOD) { return LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; + } else { + return resetclear.sense; } - return resetclear.sense; } diff --git a/src/libleo/leo/leoglobals.c b/src/libleo/leo/leoglobals.c deleted file mode 100644 index 28a99f626d2..00000000000 --- a/src/libleo/leo/leoglobals.c +++ /dev/null @@ -1,8 +0,0 @@ -#include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" - -s32 __leoActive = false; - -LEOVersion __leoVersion; diff --git a/src/libleo/leo/leoinquiry.c b/src/libleo/leo/leoinquiry.c index b23a9ab4548..8dac7892115 100644 --- a/src/libleo/leo/leoinquiry.c +++ b/src/libleo/leo/leoinquiry.c @@ -1,6 +1,5 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" +#include "ultra64/leo_internal.h" #include "ultra64/leodrive.h" void leoInquiry(void) { @@ -8,16 +7,15 @@ void leoInquiry(void) { u32 asic_data; osEPiReadIo(LEOPiInfo, ASIC_ID_REG, &asic_id); - if (leoSend_asic_cmd_w(0x1B0000, 0) == 0) { + if (leoSend_asic_cmd_w(0x1B0000, 0) == LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { osEPiReadIo(LEOPiInfo, ASIC_DATA, &asic_data); if (asic_data & 0x10000) { asic_id |= 0x100000; } } - - ((LEOCmdInquiry*)LEOcur_command)->devType = 0; - ((LEOCmdInquiry*)LEOcur_command)->version = asic_id >> 0x10; - ((LEOCmdInquiry*)LEOcur_command)->devNum = 1; - ((LEOCmdInquiry*)LEOcur_command)->leoBiosVer = 0; + LEOcur_command->data.time.pad = 0; + LEOcur_command->data.time.yearhi = (u8)(asic_id >> 16); + LEOcur_command->data.time.yearlo = 1; + LEOcur_command->data.time.month = 0; LEOcur_command->header.status = LEO_STATUS_GOOD; } diff --git a/src/libleo/leo/leoint.c b/src/libleo/leo/leoint.c index 1dd2a42fbb7..5922d10e630 100644 --- a/src/libleo/leo/leoint.c +++ b/src/libleo/leo/leoint.c @@ -1,33 +1,28 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" +#include "ultra64/leo_internal.h" #include "ultra64/leodrive.h" -#include "attributes.h" +#include "ultra64/pi.h" extern vu16 LEOrw_flags; -extern u8 LEOC2_Syndrome[2][0xE8 * 4]; -extern OSIoMesg LEOPiDmaParam; -extern block_param_form LEOc2_param; - -u8 LEOc2ctrl_que_buf[8]; -OSMesgQueue LEOc2ctrl_que; - u32 read_write_track(void); u32 leoChk_mecha_int(void); void leosetup_BM(void); u32 leochk_err_reg(void); -void leointerrupt(UNUSED void* arg) { +OSMesg LEOc2ctrl_que_buf; +OSMesgQueue LEOc2ctrl_que; + +void leointerrupt(void* arg) { u32 result; u32 tg_blocks; - osCreateMesgQueue(&LEOc2ctrl_que, (OSMesg*)&LEOc2ctrl_que_buf, 1); + osCreateMesgQueue(&LEOc2ctrl_que, &LEOc2ctrl_que_buf, 1); - while (true) { + while (1) { osStopThread(&LEOinterruptThread); - tg_blocks = LEOcur_command->data.readWrite.transferBlks; - LEOwrite_pointer = LEOcur_command->data.readWrite.buffPtr; + tg_blocks = LEOcur_command->data.readwrite.xfer_blks; + LEOwrite_pointer = LEOcur_command->data.readwrite.buff_ptr; do { leoLba_to_phys(LEOtgt_param.lba); @@ -36,11 +31,9 @@ void leointerrupt(UNUSED void* arg) { } else { result = leoSeek_i(0); } - - if (result != 0) { + if (result != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { goto complete; } - if (LEOrw_flags & 0x2000) { LEOtgt_param.rdwr_blocks = 1; } else if (LEOtgt_param.rdwr_blocks > tg_blocks) { @@ -49,20 +42,19 @@ void leointerrupt(UNUSED void* arg) { LEOtgt_param.lba += LEOtgt_param.rdwr_blocks; tg_blocks -= LEOtgt_param.rdwr_blocks; result = read_write_track(); - if (result != 0) { + if (result != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { goto complete; } - - LEOcur_command->data.readWrite.rwBytes = LEOwrite_pointer - (u8*)LEOcur_command->data.readWrite.buffPtr; + LEOcur_command->data.readwrite.rw_bytes = + (uintptr_t)LEOwrite_pointer - (uintptr_t)LEOcur_command->data.readwrite.buff_ptr; } while (tg_blocks != 0); - result = 0x90000; // Inaccessible? + result = 0x90000; complete: osSendMesg(&LEOcontrol_que, (OSMesg)result, OS_MESG_BLOCK); } } -// static u32 read_write_track(void) { u32 message; u32 block; @@ -97,7 +89,7 @@ u32 read_write_track(void) { LEOPiInfo->transferInfo.block[1] = LEOPiInfo->transferInfo.block[0]; LEOPiInfo->transferInfo.block[1].C2Addr = &LEOC2_Syndrome[1]; LEOPiInfo->transferInfo.block[1].dramAddr = - ((u8*)LEOPiInfo->transferInfo.block[1].dramAddr + block_param.blkbytes); + (u8*)LEOPiInfo->transferInfo.block[1].dramAddr + block_param.blkbytes; } message = leoChk_mecha_int(); if (message == 0) { @@ -116,13 +108,13 @@ u32 read_write_track(void) { LEOPiInfo->transferInfo.cmdType = 1; osWritebackDCache(block_param.pntr, block_param.blkbytes * LEOtgt_param.rdwr_blocks); - osEPiStartDma(LEOPiInfo, &LEOPiDmaParam, 1); + osEPiStartDma(LEOPiInfo, &LEOPiDmaParam, OS_WRITE); osRecvMesg(&LEOdma_que, NULL, OS_MESG_BLOCK); LEOasic_bm_ctl_shadow = LEOPiInfo->transferInfo.bmCtlShadow; LEOasic_seq_ctl_shadow = LEOPiInfo->transferInfo.seqCtlShadow; bnum = LEOPiInfo->transferInfo.blockNum; message = LEOPiInfo->transferInfo.block[bnum].errStatus; - if (message == 0) { + if (message == LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { return message; } goto track_end; @@ -133,7 +125,7 @@ u32 read_write_track(void) { } LEOPiInfo->transferInfo.cmdType = 0; osInvalDCache(block_param.pntr, block_param.blkbytes * LEOtgt_param.rdwr_blocks); - osEPiStartDma(LEOPiInfo, &LEOPiDmaParam, 0); + osEPiStartDma(LEOPiInfo, &LEOPiDmaParam, OS_READ); block = 0; while (LEOtgt_param.rdwr_blocks != 0) { osRecvMesg(&LEOdma_que, NULL, OS_MESG_BLOCK); @@ -154,7 +146,7 @@ u32 read_write_track(void) { if (LEOtgt_param.rdwr_blocks == 1) { osEPiReadIo(LEOPiInfo, ASIC_ERR_SECTOR, &message); if (message & 0x10000000) { - message = 4; + message = LEO_SENSE_DATA_PHASE_ERROR; goto track_end; } } @@ -181,7 +173,7 @@ u32 read_write_track(void) { if (LEOtgt_param.rdwr_blocks == 1) { if ((*(u32*)&LEOC2_Syndrome[block][0x00] | *(u32*)&LEOC2_Syndrome[block][0x04] | *(u32*)&LEOC2_Syndrome[block][0x08] | *(u32*)&LEOC2_Syndrome[block][0x0C]) != 0) { - message = 0x17; + message = LEO_SENSE_UNRECOVERED_READ_ERROR; goto track_end; } } @@ -195,22 +187,23 @@ u32 read_write_track(void) { return 0; } track_end: - if (message == 0x16) { + if (message == LEO_SENSE_WRITE_FAULT) { message = leochk_err_reg(); } do_retry: - if (leoChk_err_retry(message) || (LEOrw_flags & 0x1000) || retry_cntr++ == 0x40) { + if ((leoChk_err_retry(message) != 0) || (LEOrw_flags & 0x1000) || (retry_cntr++ == 64)) { break; } if ((retry_cntr & 7) == 0) { message = leoSend_asic_cmd_w(0x30001, 0); - if (message != 0) { + if (message != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { goto do_retry; } } - if (message == 0x18 || (message == 0x17 && retry_cntr == 0x20)) { + if ((message == LEO_SENSE_NO_REFERENCE_POSITION_FOUND) || + ((message == LEO_SENSE_UNRECOVERED_READ_ERROR) && (retry_cntr == 32))) { message = leoDetect_index_w(); - if (message != 0) { + if (message != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { goto do_retry; } } @@ -219,81 +212,69 @@ u32 read_write_track(void) { } else { message = leoSeek_i(0); } - if (message != 0) { + if (message != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { goto do_retry; } } return message; } -// static u32 leoChk_mecha_int(void) { - u32 stat = leoWait_mecha_cmd_done(0x10001); + u32 stat; u32 index_stat; - if (stat == 0) { + stat = leoWait_mecha_cmd_done(0x10001); + if (stat == LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { osEPiReadIo(LEOPiInfo, ASIC_CUR_TK, &index_stat); if ((index_stat & 0x60000000) != 0x60000000) { - stat = 0x18; + stat = LEO_SENSE_NO_REFERENCE_POSITION_FOUND; } } return stat; } -// static void leosetup_BM(void) { - osEPiWriteIo(LEOPiInfo, ASIC_BM_CTL, LEOasic_bm_ctl_shadow | 0x10000000); - osEPiWriteIo(LEOPiInfo, ASIC_BM_CTL, LEOasic_bm_ctl_shadow); - + osEPiWriteIo(LEOPiInfo, ASIC_BM_CTL, LEOasic_bm_ctl_shadow | LEO_BM_RESET); + osEPiWriteIo(LEOPiInfo, ASIC_BM_CTL, (u32)LEOasic_bm_ctl_shadow); if (LEOtgt_param.start_block != 0) { - LEOasic_bm_ctl_shadow = 0x5A0000; + LEOasic_bm_ctl_shadow = 0x005A0000; } else { LEOasic_bm_ctl_shadow = 0; } - if (!(LEOrw_flags & 0x8000)) { - LEOasic_bm_ctl_shadow |= 0x40000000; + LEOasic_bm_ctl_shadow |= LEO_BM_MODE; } - if (LEOtgt_param.rdwr_blocks == 2) { - LEOasic_bm_ctl_shadow |= 0x02000000; + LEOasic_bm_ctl_shadow |= LEO_BM_XFER_BLOCK; } - - osEPiWriteIo(LEOPiInfo, ASIC_BM_CTL, LEOasic_bm_ctl_shadow); + osEPiWriteIo(LEOPiInfo, ASIC_BM_CTL, (u32)LEOasic_bm_ctl_shadow); } -// static u32 leochk_err_reg(void) { u32 sense; u32 index_status; osEPiReadIo(LEOPiInfo, ASIC_ERR_SECTOR, &sense); - osEPiWriteIo(LEOPiInfo, ASIC_BM_CTL, LEOasic_bm_ctl_shadow | 0x10000000); - osEPiWriteIo(LEOPiInfo, ASIC_BM_CTL, LEOasic_bm_ctl_shadow); - + osEPiWriteIo(LEOPiInfo, ASIC_BM_CTL, LEOasic_bm_ctl_shadow | LEO_BM_RESET); + osEPiWriteIo(LEOPiInfo, ASIC_BM_CTL, (u32)LEOasic_bm_ctl_shadow); if (sense & 0x04000000) { - return LEO_ERROR_EJECTED_ILLEGALLY_RESUME; + return LEO_SENSE_EJECTED_ILLEGALLY_RESUME; } - if (sense & 0x10000000) { - return LEO_ERROR_DATA_PHASE_ERROR; + return LEO_SENSE_DATA_PHASE_ERROR; } - - if (sense & (0x40000000 | 0x2000000)) { + if (sense & 0x42000000) { if (LEOrw_flags & 0x8000) { - return LEO_ERROR_WRITE_FAULT; + return LEO_SENSE_WRITE_FAULT; } - return LEO_ERROR_UNRECOVERED_READ_ERROR; + return LEO_SENSE_UNRECOVERED_READ_ERROR; } - if (sense & 0x80000000) { - return LEO_ERROR_NO_REFERENCE_POSITION_FOUND; + return LEO_SENSE_NO_REFERENCE_POSITION_FOUND; } - osEPiReadIo(LEOPiInfo, ASIC_CUR_TK, &index_status); if ((index_status & 0x60000000) == 0x60000000) { - return LEO_ERROR_TRACK_FOLLOWING_ERROR; + return LEO_SENSE_TRACK_FOLLOWING_ERROR; } - - return LEO_ERROR_NO_REFERENCE_POSITION_FOUND; + return LEO_SENSE_NO_REFERENCE_POSITION_FOUND; } diff --git a/src/libleo/leo/leointerrupt.c b/src/libleo/leo/leointerrupt.c deleted file mode 100644 index fc547cfd5c7..00000000000 --- a/src/libleo/leo/leointerrupt.c +++ /dev/null @@ -1,208 +0,0 @@ -#include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" -#include "ultra64/internal.h" - -extern OSThread* __osRunQueue; -extern OSIntMask __OSGlobalIntMask; -void __osLeoAbnormalResume(void); -void __osLeoResume(void); - -STACK(leoDiskStack, 0x1000); - -s32 __osLeoInterrupt(void) { - u32 stat = 0; - volatile u32 pi_stat; - u32 bm_stat; - __OSTranxInfo* info = &__osDiskHandle->transferInfo; - __OSBlockInfo* blockInfo = &info->block[info->blockNum]; - - pi_stat = IO_READ(PI_STATUS_REG); - if (pi_stat & PI_STATUS_DMA_BUSY) { - __OSGlobalIntMask &= ~0x800; - blockInfo->errStatus = 0x1D; - __osLeoResume(); - return 1; - } - - pi_stat = IO_READ(PI_STATUS_REG); - while (pi_stat & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) { - pi_stat = IO_READ(PI_STATUS_REG); - } - - stat = IO_READ(ASIC_STATUS); - if (stat & 0x2000000) { - pi_stat = IO_READ(PI_STATUS_REG); - while (pi_stat & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) { - pi_stat = IO_READ(PI_STATUS_REG); - } - - IO_WRITE(ASIC_BM_CTL, info->bmCtlShadow | 0x1000000); - blockInfo->errStatus = 0; - return 0; - } - if (info->cmdType == 2) { - return 1; - } - if (stat & 0x8000000) { - pi_stat = IO_READ(PI_STATUS_REG); - while (pi_stat & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) { - pi_stat = IO_READ(PI_STATUS_REG); - } - - stat = IO_READ(ASIC_STATUS); - blockInfo->errStatus = 0x16; - __osLeoResume(); - IO_WRITE(PI_STATUS_REG, 2); - __OSGlobalIntMask |= 0x100401; - return 1; - } - if (info->cmdType == 1) { - if (!(stat & 0x40000000)) { - if ((info->sectorNum + 1) != (info->transferMode * 0x55)) { - blockInfo->errStatus = 0x18; - __osLeoAbnormalResume(); - return 1; - } - IO_WRITE(PI_STATUS_REG, 2); - __OSGlobalIntMask |= 0x100401; - blockInfo->errStatus = 0; - __osLeoResume(); - return 1; - } else { - blockInfo->dramAddr = (u8*)(blockInfo->dramAddr) + blockInfo->sectorSize; - info->sectorNum++; - __osEPiRawStartDma(__osDiskHandle, 1, ASIC_SECTOR_BUFF, blockInfo->dramAddr, blockInfo->sectorSize); - return 1; - } - } else if (info->cmdType == 0) { - if (info->transferMode == 3) { - if (((s32)blockInfo->C1ErrNum + 0x11) < info->sectorNum) { - blockInfo->errStatus = 0; - __osLeoAbnormalResume(); - return 1; - } - if ((stat & 0x40000000) == 0) { - blockInfo->errStatus = 0x17; - __osLeoAbnormalResume(); - return 1; - } - } else { - blockInfo->dramAddr = (u8*)(blockInfo->dramAddr) + blockInfo->sectorSize; - } - - bm_stat = IO_READ(ASIC_BM_STATUS); - if (((bm_stat & 0x200000) && (bm_stat & 0x400000)) || (bm_stat & 0x2000000)) { - if (blockInfo->C1ErrNum >= 4) { - if ((info->transferMode != 3) || (info->sectorNum >= 0x53)) { - blockInfo->errStatus = 0x17; - __osLeoAbnormalResume(); - return 1; - } - } else { - int errNum = blockInfo->C1ErrNum; - - blockInfo->C1ErrSector[errNum] = info->sectorNum + 1; - } - blockInfo->C1ErrNum++; - } - - if (stat & 0x10000000) { - if (info->sectorNum != 0x57) { - blockInfo->errStatus = 0x18; - __osLeoAbnormalResume(); - return 1; - } - if ((info->transferMode == 2) && (info->blockNum == 0)) { - info->blockNum = 1; - info->sectorNum = -1; - info->block[1].dramAddr = (u8*)(info->block[1].dramAddr) - info->block[1].sectorSize; - blockInfo->errStatus = 0x16; - } else { - IO_WRITE(PI_STATUS_REG, 2); - __OSGlobalIntMask |= 0x100401; - info->cmdType = 2; - blockInfo->errStatus = 0; - } - __osEPiRawStartDma(__osDiskHandle, 0, ASIC_C2_BUFF, blockInfo->C2Addr, blockInfo->sectorSize * 4); - return 1; - } - if ((info->sectorNum == -1) && (info->transferMode == 2) && (info->blockNum == 1)) { - __OSBlockInfo* bptr = info->block; - - if (bptr->C1ErrNum == 0) { - if (((u32*)bptr->C2Addr)[0] | ((u32*)bptr->C2Addr)[1] | ((u32*)bptr->C2Addr)[2] | - ((u32*)bptr->C2Addr)[3]) { - bptr->errStatus = 0x17; - __osLeoAbnormalResume(); - return 1; - } - } - bptr->errStatus = 0; - __osLeoResume(); - } - info->sectorNum++; - if (stat & 0x40000000) { - if (info->sectorNum >= 0x55) { - blockInfo->errStatus = 0x18; - __osLeoAbnormalResume(); - return 1; - } - __osEPiRawStartDma(__osDiskHandle, 0, ASIC_SECTOR_BUFF, blockInfo->dramAddr, blockInfo->sectorSize); - blockInfo->errStatus = 0; - return 1; - } else if (info->sectorNum < 0x55) { - blockInfo->errStatus = 0x18; - __osLeoAbnormalResume(); - return 1; - } - return 1; - } else { - blockInfo->errStatus = 4; - __osLeoAbnormalResume(); - return 1; - } -} - -// static -void __osLeoAbnormalResume(void) { - __OSTranxInfo* info; - u32 pi_stat; - - info = &__osDiskHandle->transferInfo; - pi_stat = IO_READ(PI_STATUS_REG); - while (pi_stat & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) { - pi_stat = IO_READ(PI_STATUS_REG); - } - - IO_WRITE(ASIC_BM_CTL, info->bmCtlShadow | 0x10000000); - pi_stat = IO_READ(PI_STATUS_REG); - while (pi_stat & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) { - pi_stat = IO_READ(PI_STATUS_REG); - } - - IO_WRITE(ASIC_BM_CTL, info->bmCtlShadow); - __osLeoResume(); - IO_WRITE(PI_STATUS_REG, 2); - __OSGlobalIntMask |= 0x100401; -} - -// static -void __osLeoResume(void) { - __OSEventState* es; - OSMesgQueue* mq; - s32 last; - - es = &__osEventStateTab[8]; - mq = es->queue; - if ((mq == 0) || (mq->validCount >= mq->msgCount)) { - return; - } - last = (mq->first + mq->validCount) % mq->msgCount; - mq->msg[last] = es->msg; - mq->validCount++; - if (mq->mtqueue->next != NULL) { - __osEnqueueThread(&__osRunQueue, __osPopThread(&mq->mtqueue)); - } -} diff --git a/src/libleo/leo/leomecha.c b/src/libleo/leo/leomecha.c index d0804f033c2..5b436c1812b 100644 --- a/src/libleo/leo/leomecha.c +++ b/src/libleo/leo/leomecha.c @@ -1,194 +1,179 @@ -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" +#include "ultra64.h" +#include "ultra64/leo_internal.h" #include "ultra64/leodrive.h" #include "attributes.h" -#include "ultra64.h" - -extern s32 currentCommand; +u8 leoRecv_event_mesg(s32 control); -static u32 asic_cur_status; -static u32 unit_atten; +u32 asic_cur_status; +u32 unit_atten; u8 leoAnalize_asic_status(void) { u32 curr_stat; osEPiReadIo(LEOPiInfo, ASIC_STATUS, &asic_cur_status); - curr_stat = asic_cur_status ^ 0x1000000; - - // 0xFE3C0000? - if (curr_stat & 0x1C3FFFF) { - // 0xFE3E0000? - if (curr_stat & 0x1C1FFFF) { + curr_stat = asic_cur_status ^ 0x01000000; + if ((curr_stat & 0x01C3FFFF) != 0) { + if ((curr_stat & 0x01C1FFFF) != 0) { LEOdrive_flag = 0; } if (curr_stat & 0xFFFF) { - return 41; + return LEO_SENSE_DEVICE_COMMUNICATION_FAILURE; } - if ((curr_stat & 0xC00000) == 0x800000) { - return 3; + if ((curr_stat & 0x00C00000) == 0x00800000) { + return LEO_SENSE_COMMAND_PHASE_ERROR; } - if (curr_stat & 0x400000) { + if (curr_stat & 0x00400000) { unit_atten |= 2; - return 43; + return LEO_SENSE_POWERONRESET_DEVICERESET_OCCURED; } - if (curr_stat & 0x1000000) { - return 49; + if (curr_stat & 0x01000000) { + return LEO_SENSE_EJECTED_ILLEGALLY_RESUME; } - if (curr_stat & 0x10000) { + if (curr_stat & 0x00010000) { unit_atten |= 1; - return 47; + return LEO_SENSE_MEDIUM_MAY_HAVE_CHANGED; } - if (curr_stat & 0x20000) { - return 21; + if (curr_stat & 0x00020000) { + return LEO_SENSE_NO_SEEK_COMPLETE; } } - return 0; + return LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; } u8 leoChk_asic_ready(u32 asic_cmd) { - u32 sense_code = leoAnalize_asic_status(); + u32 sense_code; + sense_code = leoAnalize_asic_status(); switch (sense_code) { - case 47: + case LEO_SENSE_MEDIUM_MAY_HAVE_CHANGED: if (asic_cmd == 0x80000) { - return 0; + return LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; } FALLTHROUGH; - case 43: + case LEO_SENSE_POWERONRESET_DEVICERESET_OCCURED: if (!(asic_cur_status & 0x800000)) { if (asic_cmd == 0x90000) { - return 0; + return LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; } if (leoRecv_event_mesg(OS_MESG_NOBLOCK) != 0) { - return 37; + return LEO_SENSE_WAITING_NMI; } osEPiWriteIo(LEOPiInfo, ASIC_CMD, 0x90000); if (leoRecv_event_mesg(OS_MESG_BLOCK) != 0) { - return 37; + return LEO_SENSE_WAITING_NMI; } } - FALLTHROUGH; - default: break; - - case 49: + case LEO_SENSE_EJECTED_ILLEGALLY_RESUME: if (asic_cmd & 1) { break; } FALLTHROUGH; - case 21: + case LEO_SENSE_NO_SEEK_COMPLETE: return 0; + default: + break; } return sense_code; } -// Which of LEO_ERROR or LEO_SENSE should be used where? u8 leoChk_done_status(u32 asic_cmd) { u32 asic_data; - u32 code = leoAnalize_asic_status(); + u32 code; + code = leoAnalize_asic_status(); switch (code) { - case 43: - case 47: - if (!(asic_cur_status & 0x800000)) { + case LEO_SENSE_POWERONRESET_DEVICERESET_OCCURED: + case LEO_SENSE_MEDIUM_MAY_HAVE_CHANGED: + if (!(asic_cur_status & 0x00800000)) { if (leoRecv_event_mesg(OS_MESG_NOBLOCK) != 0) { - return 37; + return LEO_SENSE_WAITING_NMI; } - - osEPiWriteIo(LEOPiInfo, ASIC_CMD, 0x90000); + osEPiWriteIo(LEOPiInfo, ASIC_CMD, 0x00090000); if (leoRecv_event_mesg(OS_MESG_BLOCK) != 0) { - return 37; + return LEO_SENSE_WAITING_NMI; } } break; - - case 49: - if (asic_cmd & 1) { - break; + default: + break; + case LEO_SENSE_EJECTED_ILLEGALLY_RESUME: + if (!(asic_cmd & 1)) { + return LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; } - return 0; - - case 21: + break; + case LEO_SENSE_NO_SEEK_COMPLETE: osEPiWriteIo(LEOPiInfo, ASIC_DATA, 0); if (leoRecv_event_mesg(OS_MESG_NOBLOCK) != 0) { - return 37; + return LEO_SENSE_WAITING_NMI; } - - osEPiWriteIo(LEOPiInfo, ASIC_CMD, 0xC0000); + osEPiWriteIo(LEOPiInfo, ASIC_CMD, 0x000C0000); if (leoRecv_event_mesg(OS_MESG_BLOCK) != 0) { - return 37; + return LEO_SENSE_WAITING_NMI; } - osEPiReadIo(LEOPiInfo, ASIC_DATA, &asic_data); - code = leoChk_asic_ready(0xC0000); - if (code != 0) { + code = leoChk_asic_ready(0x000C0000); + if (code != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { return code; } - if (asic_data & 0x10000) { - return 2; + return LEO_SENSE_DIAGNOSTIC_FAILURE; } if (asic_data & 0x20000) { - return 24; + return LEO_SENSE_NO_REFERENCE_POSITION_FOUND; } if (asic_data & 0x40000) { - return 1; + return LEO_SENSE_DRIVE_NOT_READY; } if (asic_data & 0x80000) { - return 21; + return LEO_SENSE_NO_SEEK_COMPLETE; } if (asic_data & 0x200000) { return 11; } - return 41; - - default: - break; + return LEO_SENSE_DEVICE_COMMUNICATION_FAILURE; } - return code; } u8 leoSend_asic_cmd_i(u32 asic_cmd, u32 asic_data) { - u8 status = leoChk_asic_ready(asic_cmd); + u8 status; - if (status != 0) { - return LEOcur_command->header.sense = status; + status = leoChk_asic_ready(asic_cmd); + if (status != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { + LEOcur_command->header.sense = status; + return LEOcur_command->header.sense; } - osEPiWriteIo(LEOPiInfo, ASIC_DATA, asic_data); if (leoRecv_event_mesg(OS_MESG_NOBLOCK) != 0) { - return LEOcur_command->header.sense = 37; + LEOcur_command->header.sense = LEO_SENSE_WAITING_NMI; + return LEOcur_command->header.sense; } - osEPiWriteIo(LEOPiInfo, ASIC_CMD, asic_cmd); - return 0; + return LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; } -// Is this using the sense defines? u8 leoWait_mecha_cmd_done(u32 asic_cmd) { u32 done_stat; - if (leoRecv_event_mesg(OS_MESG_BLOCK)) { - return 37; + if (leoRecv_event_mesg(OS_MESG_BLOCK) != 0) { + return LEO_SENSE_WAITING_NMI; } - done_stat = leoChk_done_status(asic_cmd); - if (done_stat != 0) { + if (done_stat != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { return done_stat; } - - return 0; + return LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; } u8 leoSend_asic_cmd_w(u32 asic_cmd, u32 asic_data) { - u32 wstatus = leoSend_asic_cmd_i(asic_cmd, asic_data); + u32 wstatus; + wstatus = leoSend_asic_cmd_i(asic_cmd, asic_data); if (wstatus != 0) { return wstatus; } - return leoWait_mecha_cmd_done(asic_cmd); } @@ -197,26 +182,24 @@ u8 leoSend_asic_cmd_w_nochkDiskChange(u32 asic_cmd, u32 asic_data) { u32 done_stat; status = leoChk_asic_ready(asic_cmd); - if ((status != 0x2F) && (status != 0)) { - return LEOcur_command->header.sense = status; + if ((status != LEO_SENSE_MEDIUM_MAY_HAVE_CHANGED) && (status != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION)) { + LEOcur_command->header.sense = status; + return LEOcur_command->header.sense; } - osEPiWriteIo(LEOPiInfo, ASIC_DATA, asic_data); if (leoRecv_event_mesg(OS_MESG_NOBLOCK) != 0) { - return LEOcur_command->header.sense = 0x25; + LEOcur_command->header.sense = LEO_SENSE_WAITING_NMI; + return LEOcur_command->header.sense; } - osEPiWriteIo(LEOPiInfo, ASIC_CMD, asic_cmd); if (leoRecv_event_mesg(OS_MESG_BLOCK) != 0) { - return 0x25; + return LEO_SENSE_WAITING_NMI; } - done_stat = leoChk_done_status(asic_cmd); - if ((done_stat != 0x2F) && (done_stat != 0)) { + if ((done_stat != LEO_SENSE_MEDIUM_MAY_HAVE_CHANGED) && (done_stat != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION)) { return done_stat; } - - return 0; + return LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; } u8 leoDetect_index_w(void) { @@ -232,35 +215,32 @@ u8 leoRecal_w(void) { } u8 leoSeek_i(u16 rwmode) { - u32 tgt_tk = ((LEOtgt_param.head << 0xC) + LEOtgt_param.cylinder) << 0x10; + s32 tgt_tk; - if (rwmode == 0) { + tgt_tk = ((LEOtgt_param.head << 12) + LEOtgt_param.cylinder) << 16; + if (!rwmode) { return leoSend_asic_cmd_i(0x10001, tgt_tk); - } else { - return leoSend_asic_cmd_i(0x20001, tgt_tk); } + return leoSend_asic_cmd_i(0x20001, tgt_tk); } u8 leoSeek_w(void) { - u8 sksense = leoSeek_i(0); + u8 sksense; + sksense = leoSeek_i(0); if (sksense != 0) { return sksense; } - return leoWait_mecha_cmd_done(0x10001); } u8 leoRecv_event_mesg(s32 control) { - u32 done_mesg; + OSMesg done_mesg; - if (osRecvMesg(&LEOevent_que, (OSMesg*)&done_mesg, control) == 0) { - if (done_mesg == 0xA0000) { - leoDrive_reset(); - return -1; - } + if ((osRecvMesg(&LEOevent_que, &done_mesg, control) == 0) && (done_mesg == (OSMesg)0xA0000)) { + leoDrive_reset(); + return 0xFF; } - return 0; } @@ -277,7 +257,9 @@ u32 leoChk_err_retry(u32 sense) { case LEO_SENSE_MEDIUM_NOT_PRESENT: case LEO_SENSE_EJECTED_ILLEGALLY_RESUME: LEOdrive_flag = 0; - return -1; + return -1U; + default: + break; } } else { switch (sense) { @@ -294,17 +276,19 @@ u32 leoChk_err_retry(u32 sense) { case LEO_SENSE_MEDIUM_NOT_PRESENT: case LEO_SENSE_EJECTED_ILLEGALLY_RESUME: LEOdrive_flag = 0; - return -1; + return -1U; + default: + break; } } - return 0; } u8 leoChk_cur_drvmode(void) { - u8 devstat = 0; + u8 devstat; - if (!(asic_cur_status & 0x1000000)) { + devstat = 0; + if (!(asic_cur_status & 0x01000000)) { devstat |= 1; } if (asic_cur_status & 0x80000) { @@ -316,7 +300,7 @@ u8 leoChk_cur_drvmode(void) { return devstat; } -void leoDrive_reset() { +void leoDrive_reset(void) { osEPiWriteIo(LEOPiInfo, ASIC_HARD_RESET, 0xAAAA0000); } @@ -326,12 +310,12 @@ u32 leoChkUnit_atten(void) { u32 leoRetUnit_atten(void) { if (unit_atten & 2) { - return 43; + return LEO_SENSE_POWERONRESET_DEVICERESET_OCCURED; } if (unit_atten & 1) { - return 47; + return LEO_SENSE_MEDIUM_MAY_HAVE_CHANGED; } - return 0; + return LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; } void leoClrUA_RESET(void) { diff --git a/src/libleo/leo/leomode_sel.c b/src/libleo/leo/leomode_sel.c index fe36bc16afc..09d607c1ce8 100644 --- a/src/libleo/leo/leomode_sel.c +++ b/src/libleo/leo/leomode_sel.c @@ -1,27 +1,19 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" void leoMode_sel(void) { - u32 sense; + u8 sense; - sense = leoSend_asic_cmd_w_nochkDiskChange(0x60000, LEOcur_command->data.time.yearlo << 0x10); - if (sense != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { - goto mselerror; - } - sense = leoSend_asic_cmd_w_nochkDiskChange(0x70000, LEOcur_command->data.time.month << 0x10); - if (sense != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { - goto mselerror; - } - sense = leoSend_asic_cmd_w_nochkDiskChange(0x150000, LEOcur_command->data.readWrite.transferBlks); - if (sense != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { - mselerror: + sense = leoSend_asic_cmd_w_nochkDiskChange(0x60000, LEOcur_command->data.time.yearlo << 16); + if ((sense != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) || + (sense = leoSend_asic_cmd_w_nochkDiskChange(0x70000, LEOcur_command->data.time.month << 16), + (sense != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION)) || + (sense = leoSend_asic_cmd_w_nochkDiskChange(0x150000, LEOcur_command->data.readwrite.xfer_blks), + (sense != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION))) { LEOcur_command->header.sense = sense; LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; return; } - LEOcur_command->header.sense = sense; LEOcur_command->header.status = LEO_STATUS_GOOD; } diff --git a/src/libleo/leo/leomotor.c b/src/libleo/leo/leomotor.c index 652b626ee05..6455306d531 100644 --- a/src/libleo/leo/leomotor.c +++ b/src/libleo/leo/leomotor.c @@ -1,36 +1,34 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" void leoStart_stop(void) { u32 send_cmd; u8 sense_code; - u8 retry_cntr = 8; + u8 retry_cntr; u32 send_data; + retry_cntr = 8; do { send_data = 0; - if ((LEOcur_command->header.control & 1)) { + if (LEOcur_command->header.control & 1) { send_cmd = 0x50001; - } else if ((LEOcur_command->header.control & 2)) { + } else if (LEOcur_command->header.control & LEO_CONTROL_STBY) { send_cmd = 0xD0000; } else { - if ((LEOcur_command->header.control & 4)) { + if (LEOcur_command->header.control & LEO_CONTROL_BRAKE) { send_data = 0x10000; } send_cmd = 0x40000; } sense_code = leoSend_asic_cmd_w_nochkDiskChange(send_cmd, send_data); - if (sense_code == 0) { - LEOcur_command->header.status = 0; + if (sense_code == LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { + LEOcur_command->header.status = LEO_STATUS_GOOD; return; } - if (leoChk_err_retry(sense_code)) { + if (leoChk_err_retry(sense_code) != 0) { break; } } while (retry_cntr--); - LEOcur_command->header.sense = sense_code; - LEOcur_command->header.status = 2; + LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; } diff --git a/src/libleo/leo/leomseq_tbl.c b/src/libleo/leo/leomseq_tbl.c index f94979f623c..1bf0a391d47 100644 --- a/src/libleo/leo/leomseq_tbl.c +++ b/src/libleo/leo/leomseq_tbl.c @@ -1,22 +1,18 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" +#include "ultra64/leo_internal.h" #include "ultra64/leodrive.h" -extern OSIoMesg LEOPiDmaParam; extern vu16 LEOrw_flags; -// bss -static u32 mseq_tbl[0x10]; +STATIC s32 mseq_tbl[0x10]; -// rodata -static const u32 rd_mseq_code[0x10] = { - 0x00010000, 0x00020200, 0x80030100, 0x82040000, 0xA8050000, 0xA0060600, 0x31760000, 0x00020300, - 0, 0, 0, 0, 0, 0, 0, 0x4060000, +STATIC const u32 rd_mseq_code[0x10] = { + 0x10000, 0x20200, 0x80030100, 0x82040000, 0xA8050000, 0xA0060600, 0x31760000, 0x20300, + 0, 0, 0, 0, 0, 0, 0, 0x04060000, }; -static const u32 wt_mseq_code[0x10] = { - 0x40020000, 0x00020000, 0x40130B00, 0x42140100, 0x68050000, 0x50060600, 0x401702FF, 0x01870000, - 0x40020000, 0, 0, 0, 0, 0, 0, 0x40F0000, +STATIC const u32 wt_mseq_code[0x10] = { + 0x40020000, 0x20000, 0x40130B00, 0x42140100, 0x68050000, 0x50060600, 0x401702FF, 0x01870000, + 0x40020000, 0, 0, 0, 0, 0, 0, 0x040F0000, }; void leoSet_mseq(u16 rwmode) { @@ -25,7 +21,7 @@ void leoSet_mseq(u16 rwmode) { u32 sct_byte_u; u8 i; - LEOasic_seq_ctl_shadow &= 0xBFFFFFFF; + LEOasic_seq_ctl_shadow &= ~0x40000000; osEPiWriteIo(LEOPiInfo, ASIC_SEQ_CTL, LEOasic_seq_ctl_shadow); if (rwmode == 1) { tbl = wt_mseq_code; @@ -35,25 +31,21 @@ void leoSet_mseq(u16 rwmode) { for (i = 0; i < 0x10; i++, tbl++) { mseq_tbl[i] = *tbl; } - sct_byte_x = sct_byte_u = LEOtgt_param.sec_bytes - 1; sct_byte_u += 7; sct_byte_x <<= 8; mseq_tbl[4] |= sct_byte_x; - osWritebackDCache(mseq_tbl, 0x40); LEOPiDmaParam.dramAddr = mseq_tbl; LEOPiDmaParam.devAddr = MSEQ_RAM_ADDR; LEOPiDmaParam.size = 0x40; LEOPiInfo->transferInfo.cmdType = 2; - osEPiStartDma(LEOPiInfo, &LEOPiDmaParam, 1); + osEPiStartDma(LEOPiInfo, &LEOPiDmaParam, OS_WRITE); osRecvMesg(&LEOdma_que, NULL, OS_MESG_BLOCK); - osEPiWriteIo(LEOPiInfo, ASIC_SEC_BYTE, (sct_byte_u | 0x5900) << 0x10); - + osEPiWriteIo(LEOPiInfo, ASIC_SEC_BYTE, (sct_byte_u | 0x5900) << 16); if (LEOrw_flags & 0x800) { sct_byte_x += 0x100; } - osEPiWriteIo(LEOPiInfo, ASIC_HOST_SECBYTE, sct_byte_x << 8); LEOasic_seq_ctl_shadow |= 0x40000000; osEPiWriteIo(LEOPiInfo, ASIC_SEQ_CTL, LEOasic_seq_ctl_shadow); diff --git a/src/libleo/leo/leoram.c b/src/libleo/leo/leoram.c index 159aaaae279..e295d472a57 100644 --- a/src/libleo/leo/leoram.c +++ b/src/libleo/leo/leoram.c @@ -1,41 +1,29 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" +// should be in another file leosysdata.c but alignment prevents that leo_sys_form LEO_sys_data; OSThread LEOcommandThread; OSThread LEOinterruptThread; - STACK(LEOcommandThreadStack, 0x400); STACK(LEOinterruptThreadStack, 0x400); - OSMesgQueue LEOcommand_que; OSMesgQueue LEOevent_que; OSMesgQueue LEOcontrol_que; OSMesgQueue LEOdma_que; OSMesgQueue LEOblock_que; - -OSMesg LEOevent_que_buf[1]; -OSMesg LEOcontrol_que_buf[1]; +OSMesg LEOevent_que_buf; +OSMesg LEOcontrol_que_buf; OSMesg LEOdma_que_buf[2]; -OSMesg LEOblock_que_buf[1]; - +OSMesg LEOblock_que_buf; u8* LEOwrite_pointer; LEOCmd* LEOcur_command; - u32 LEOasic_bm_ctl_shadow; u32 LEOasic_seq_ctl_shadow; - u8 LEOdrive_flag; vu8 LEOclr_que_flag; - -// volatile? -vu16 LEOrw_flags; - +u16 LEOrw_flags; u8 LEOdisk_type; - tgt_param_form LEOtgt_param; - u32 LEO_country_code; diff --git a/src/libleo/leo/leord_capa.c b/src/libleo/leo/leord_capa.c index 86b71ac903e..7dc0c3ddb47 100644 --- a/src/libleo/leo/leord_capa.c +++ b/src/libleo/leo/leord_capa.c @@ -1,17 +1,15 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" void leoRd_capacity(void) { - if (LEOcur_command->header.control & LEO_CONTROL_WRT) { // Possibly LEO_CONTROL_TBL - LEOcur_command->data.readWrite.lba = LEORAM_START_LBA[LEOdisk_type] - 0x18; - LEOcur_command->data.readWrite.transferBlks = 0x10C3; - LEOcur_command->data.readWrite.buffPtr = (void*)LEORAM_BYTE[LEOdisk_type]; + if (LEOcur_command->header.control & 1) { + LEOcur_command->data.readwrite.lba = LEORAM_START_LBA[LEOdisk_type] - 0x18; + LEOcur_command->data.readwrite.xfer_blks = 0x10C3; + LEOcur_command->data.readwrite.buff_ptr = (void*)LEORAM_BYTE[LEOdisk_type]; } else { - LEOcur_command->data.readWrite.lba = 0; - LEOcur_command->data.readWrite.transferBlks = 0x10C3; - LEOcur_command->data.readWrite.buffPtr = (void*)0x3D78F40; // Total capacity, approx. 64.45 MB + LEOcur_command->data.readwrite.lba = 0; + LEOcur_command->data.readwrite.xfer_blks = 0x10C3; + LEOcur_command->data.readwrite.buff_ptr = (void*)0x03D78F40; } LEOcur_command->header.status = LEO_STATUS_GOOD; } diff --git a/src/libleo/leo/leord_diskid.c b/src/libleo/leo/leord_diskid.c index df4d6bf24b9..715723a850b 100644 --- a/src/libleo/leo/leord_diskid.c +++ b/src/libleo/leo/leord_diskid.c @@ -1,16 +1,11 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" extern vu16 LEOrw_flags; -extern u8 LEO_TempBuffer[0xE8]; -const u8 leo_disk_id_lba[] = { 14, 15 }; +STATIC const LEOCmdRead read_id_cmd = { { LEO_COMMAND_READ, 0, 0, 0, 0, 0, 0, 0, NULL }, 0xE, 1, LEO_TempBuffer, 0 }; -LEOCmdRead read_id_cmd = { - { LEO_COMMAND_READ, 0, 0, 0, 0, 0, 0, 0, 0 }, 14, 1, LEO_TempBuffer, 0, -}; +STATIC const u8 leo_disk_id_lba[2] = { 0xE, 0xF }; void leoReadDiskId(void) { LEOCmdRead dummy_cmd; @@ -22,7 +17,7 @@ void leoReadDiskId(void) { // Read Disk ID to Temp Buffer LEOcur_command = (LEOCmd*)&dummy_cmd; - for (cntr = 0; cntr < (sizeof(leo_disk_id_lba)); cntr++) { + for (cntr = 0; cntr < 2; cntr++) { LEOrw_flags = 0x2000; dummy_cmd = read_id_cmd; dummy_cmd.lba = leo_disk_id_lba[cntr]; @@ -36,7 +31,7 @@ void leoReadDiskId(void) { LEOcur_command = (LEOCmd*)temp_pointer; // Copy Disk ID to buffer pointed by ReadDiskID command - temp_pointer = (u8*)LEOcur_command->data.readdiskid.bufferPointer; + temp_pointer = (u8*)LEOcur_command->data.readdiskid.buffer_pointer; for (cntr = 0; cntr < (sizeof(LEODiskID)); cntr += sizeof(u32)) { *(u32*)temp_pointer = *((u32*)&LEO_TempBuffer[cntr]); temp_pointer += sizeof(u32); diff --git a/src/libleo/leo/leoread.c b/src/libleo/leo/leoread.c index f3f52b4bfcc..07b0a86e95b 100644 --- a/src/libleo/leo/leoread.c +++ b/src/libleo/leo/leoread.c @@ -1,7 +1,5 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" #include "attributes.h" extern vu16 LEOrw_flags; @@ -11,26 +9,24 @@ void leoRead(void) { leoRead_common(0x18); } -extern OSMesgQueue LEOc2ctrl_que; - void leoRead_common(unsigned int offset) { - u32 tg_lba = LEOcur_command->data.readWrite.lba; - u32 tg_blocks = LEOcur_command->data.readWrite.transferBlks; + u32 tg_lba; + u32 tg_blocks; u32 message; UNUSED u16 retry_cnt; - if ((tg_lba | tg_blocks) & 0xFFFF0000) { + tg_lba = LEOcur_command->data.readwrite.lba; + tg_blocks = LEOcur_command->data.readwrite.xfer_blks; + if (((tg_lba | tg_blocks) & 0xFFFF0000) != 0) { goto invalid_lba; } - tg_lba += offset; - if ((tg_lba + tg_blocks) > 0x10DC) { // Unclear what this number represents + if ((tg_lba + tg_blocks) >= 0x10DD) { invalid_lba: LEOcur_command->header.sense = LEO_SENSE_LBA_OUT_OF_RANGE; LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; return; } - if (tg_blocks == 0) { if (tg_lba >= 0x10DC) { goto invalid_lba; @@ -39,32 +35,28 @@ void leoRead_common(unsigned int offset) { LEOcur_command->header.status = LEO_STATUS_GOOD; return; } - LEOtgt_param.lba = tg_lba; LEOrw_flags &= ~0xC000; osSendMesg(&LEOc2ctrl_que, NULL, OS_MESG_NOBLOCK); osStartThread(&LEOinterruptThread); - for (;;) { + while (1) { osRecvMesg(&LEOcontrol_que, (OSMesg*)&message, OS_MESG_BLOCK); - switch (message) { case 0x90000: goto read_complete; - case 0x80000: leoC2_Correction(); LEOrw_flags &= ~0x4000; + if (LEOcur_command) {} osSendMesg(&LEOc2ctrl_que, NULL, OS_MESG_NOBLOCK); break; - default: - LEOcur_command->header.sense = message; + LEOcur_command->header.sense = (u8)message; LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; return; } } - read_complete: LEOcur_command->header.sense = LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; LEOcur_command->header.status = LEO_STATUS_GOOD; diff --git a/src/libleo/leo/leoreset.c b/src/libleo/leo/leoreset.c index 40eb56482c5..db3a427aacc 100644 --- a/src/libleo/leo/leoreset.c +++ b/src/libleo/leo/leoreset.c @@ -1,25 +1,24 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" void leoClr_queue(void) { OSMesg clr_cmd; while (osRecvMesg(&LEOcommand_que, &clr_cmd, OS_MESG_NOBLOCK) == 0) { - ((LEOCmd*)clr_cmd)->header.sense = LEO_SENSE_COMMAND_TERMINATED; - ((LEOCmd*)clr_cmd)->header.status = LEO_STATUS_CHECK_CONDITION; - if (((LEOCmd*)clr_cmd)->header.control & LEO_CONTROL_POST) { - osSendMesg(((LEOCmd*)clr_cmd)->header.post, (OSMesg)LEO_SENSE_COMMAND_TERMINATED, OS_MESG_BLOCK); + ((LEOCmdHeader*)clr_cmd)->sense = LEO_SENSE_COMMAND_TERMINATED; + ((LEOCmdHeader*)clr_cmd)->status = LEO_STATUS_CHECK_CONDITION; + if (((LEOCmdHeader*)clr_cmd)->control & LEO_CONTROL_POST) { + osSendMesg(((LEOCmdHeader*)clr_cmd)->post, (OSMesg)LEO_ERROR_COMMAND_TERMINATED, OS_MESG_BLOCK); } } } void leoClr_reset(void) { - u32 code = leoAnalize_asic_status(); + u32 code; - if ((code == LEO_SENSE_COMMAND_PHASE_ERROR) || (code == LEO_SENSE_DEVICE_COMMUNICATION_FAILURE) || - (code == LEO_SENSE_POWERONRESET_DEVICERESET_OCCURED)) { + code = leoAnalize_asic_status(); + if (code == LEO_SENSE_COMMAND_PHASE_ERROR || code == LEO_SENSE_DEVICE_COMMUNICATION_FAILURE || + code == LEO_SENSE_POWERONRESET_DEVICERESET_OCCURED) { LEOcur_command->header.sense = code; LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; } else { diff --git a/src/libleo/leo/leorezero.c b/src/libleo/leo/leorezero.c index 9e28bf13a3c..ebbf6899280 100644 --- a/src/libleo/leo/leorezero.c +++ b/src/libleo/leo/leorezero.c @@ -1,7 +1,5 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" void leoRezero(void) { u8 sense_code; @@ -9,7 +7,6 @@ void leoRezero(void) { do { sense_code = leoRecal_w(); - if (sense_code == LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { LEOtgt_param.cylinder = 0; LEOtgt_param.head = 0; @@ -17,12 +14,10 @@ void leoRezero(void) { LEOcur_command->header.status = LEO_STATUS_GOOD; return; } - if (leoChk_err_retry(sense_code) != 0) { break; } } while (retry_cntr--); - LEOcur_command->header.sense = sense_code; LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; } diff --git a/src/libleo/leo/leoseek.c b/src/libleo/leo/leoseek.c index 78d2ecfa0aa..7f552a4c3de 100644 --- a/src/libleo/leo/leoseek.c +++ b/src/libleo/leo/leoseek.c @@ -1,7 +1,5 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" #include "attributes.h" void leoSeek(void) { @@ -9,26 +7,22 @@ void leoSeek(void) { u8 sense_code; u8 retry_cntr = 20; - if (LEOcur_command->data.seek.lba > LEO_LBA_MAX) { + if (LEOcur_command->data.readwrite.lba >= 0x10C4) { LEOcur_command->header.sense = LEO_SENSE_LBA_OUT_OF_RANGE; LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; return; } - - leoLba_to_phys(LEOcur_command->data.seek.lba + 0x18); - + leoLba_to_phys(LEOcur_command->data.readwrite.lba + 0x18); do { sense_code = leoSeek_w(); if (sense_code == LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { LEOcur_command->header.status = LEO_STATUS_GOOD; return; } - if (leoChk_err_retry(sense_code) != 0) { break; } } while (retry_cntr--); - LEOcur_command->header.sense = sense_code; - LEOcur_command->header.status = LEO_SENSE_DIAGNOSTIC_FAILURE; + LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; } diff --git a/src/libleo/leo/leotempbuffer.c b/src/libleo/leo/leotempbuffer.c index 5016051caff..2115409c43b 100644 --- a/src/libleo/leo/leotempbuffer.c +++ b/src/libleo/leo/leotempbuffer.c @@ -1,3 +1,4 @@ -#include "n64dd.h" +#include "ultra64.h" +#include "ultra64/leo_internal.h" u8 LEO_TempBuffer[0xE8]; diff --git a/src/libleo/leo/leotestunit.c b/src/libleo/leo/leotestunit.c index 4c81d7970a4..88a045f3e4c 100644 --- a/src/libleo/leo/leotestunit.c +++ b/src/libleo/leo/leotestunit.c @@ -1,10 +1,8 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" void leoTest_unit_rdy(void) { - ((LEOCmdTestUnitReady*)LEOcur_command)->test = leoChk_cur_drvmode(); + LEOcur_command->data.time.pad = leoChk_cur_drvmode(); LEOcur_command->header.sense = LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; LEOcur_command->header.status = LEO_STATUS_GOOD; } diff --git a/src/libleo/leo/leotimer.c b/src/libleo/leo/leotimer.c index e2433c431b8..6d54c5d56fe 100644 --- a/src/libleo/leo/leotimer.c +++ b/src/libleo/leo/leotimer.c @@ -1,10 +1,8 @@ -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" +#include "ultra64.h" +#include "ultra64/leo_internal.h" #include "ultra64/leodrive.h" #include "attributes.h" -#include "ultra64.h" - typedef struct { /* 0x0 */ u8 year; /* 0x1 */ u8 month; @@ -12,13 +10,14 @@ typedef struct { /* 0x3 */ u8 hour; /* 0x4 */ u8 minute; /* 0x5 */ u8 second; -} __LOCTime; +} __LOCTime; // size = 0x6 u8 __locReadTimer(__LOCTime* time); u8 __locSetTimer(__LOCTime* time); -static const u8 ymdupper[6] = { 99, 12, 31, 23, 59, 59 }; -static const u8 dayupper[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; +STATIC const u8 ymdupper[] = { 99, 12, 31, 23, 59, 59 }; + +STATIC const u8 dayupper[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; void leoReadTimer(void) { UNUSED u8* rdparam; @@ -33,17 +32,17 @@ void leoReadTimer(void) { LEOcur_command->data.time.hour = time.hour; LEOcur_command->data.time.minute = time.minute; LEOcur_command->data.time.second = time.second; - if (sense_code != 0) { + if (sense_code != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { LEOcur_command->header.sense = sense_code; LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; return; } - if ((u8)LEOcur_command->data.time.yearlo >= 0x96U) { + if (LEOcur_command->data.time.yearlo >= 0x96U) { LEOcur_command->data.time.yearhi = 0x19; } else { LEOcur_command->data.time.yearhi = 0x20; } - LEOcur_command->header.status = 0; + LEOcur_command->header.status = LEO_STATUS_GOOD; } void leoSetTimer(void) { @@ -115,7 +114,7 @@ void leoSetTimer(void) { // Set the new time result = __locSetTimer(&time); - if (result != 0) { + if (result != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { LEOcur_command->header.sense = result; LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; return; @@ -138,55 +137,55 @@ void leoSetTimer(void) { LEOcur_command->header.status = LEO_STATUS_GOOD; } -// static -u8 __locReadTimer(__LOCTime* time) { +STATIC u8 __locReadTimer(__LOCTime* time) { u32 data; u8 sense_code; - sense_code = leoSend_asic_cmd_w_nochkDiskChange(0x140000, 0U); + sense_code = leoSend_asic_cmd_w_nochkDiskChange(0x140000, 0); if (sense_code != 0) { return sense_code; } osEPiReadIo(LEOPiInfo, ASIC_DATA, &data); - time->minute = (u8)((u32)(data & 0xFF000000) >> 0x18); - time->second = (s8)((u32)(data & 0xFF0000) >> 0x10); - sense_code = leoSend_asic_cmd_w_nochkDiskChange(0x130000, 0U); - if (sense_code != 0) { - time->minute = (u8)(time->minute & 0xFF7F); + time->minute = (u8)((u32)(data & 0xFF000000) >> 24); + time->second = (s8)((u32)(data & 0xFF0000) >> 16); + sense_code = leoSend_asic_cmd_w_nochkDiskChange(0x130000, 0); + if (sense_code != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { + time->minute &= ~0x80; return sense_code; } osEPiReadIo(LEOPiInfo, ASIC_DATA, &data); - time->day = (s8)((u32)(data & 0xFF000000) >> 0x18); - time->hour = (s8)((u32)(data & 0xFF0000) >> 0x10); - sense_code = leoSend_asic_cmd_w_nochkDiskChange(0x120000, 0U); - if (sense_code != 0) { - time->minute = (u8)(time->minute & 0xFF7F); + time->day = (s8)((u32)(data & 0xFF000000) >> 24); + time->hour = (s8)((u32)(data & 0xFF0000) >> 16); + sense_code = leoSend_asic_cmd_w_nochkDiskChange(0x120000, 0); + if (sense_code != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { + time->minute &= ~0x80; return sense_code; } osEPiReadIo(LEOPiInfo, ASIC_DATA, &data); - sense_code = time->minute; - time->year = (s8)((u32)(data & 0xFF000000) >> 0x18); - time->month = (s8)((u32)(data & 0xFF0000) >> 0x10); - if (sense_code & 0x80) { - time->minute = (u8)(sense_code & 0xFF7F); - return 5; + time->year = (s8)((u32)(data & 0xFF000000) >> 24); + time->month = (s8)((u32)(data & 0xFF0000) >> 16); + if (time->minute & 0x80) { + time->minute &= ~0x80; + return LEO_SENSE_REAL_TIME_CLOCK_FAILURE; } - return 0; + return LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; } -// static -u8 __locSetTimer(__LOCTime* time) { +STATIC u8 __locSetTimer(__LOCTime* time) { u32 YearMonthX10000h; u32 DayHourX10000h; u32 MinuteSecondX10000h; u8 result; - YearMonthX10000h = (time->year << 0x18) + (time->month << 0x10); - DayHourX10000h = (time->day << 0x18) + (time->hour << 0x10); - MinuteSecondX10000h = (time->minute << 0x18) + (time->second << 0x10); - if ((result = leoSend_asic_cmd_w_nochkDiskChange(0xF0000, YearMonthX10000h)) != 0 || - (result = leoSend_asic_cmd_w_nochkDiskChange(0x100000, DayHourX10000h)) != 0 || - (result = leoSend_asic_cmd_w_nochkDiskChange(0x110000, MinuteSecondX10000h)) != 0) { + YearMonthX10000h = (time->year << 24) + (time->month << 16); + DayHourX10000h = (time->day << 24) + (time->hour << 16); + MinuteSecondX10000h = (time->minute << 24) + (time->second << 16); + if ((result = leoSend_asic_cmd_w_nochkDiskChange(0xF0000, YearMonthX10000h)) != + LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION || + (result = leoSend_asic_cmd_w_nochkDiskChange(0x100000, DayHourX10000h)) != + LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION || + (result = leoSend_asic_cmd_w_nochkDiskChange(0x110000, MinuteSecondX10000h)) != + LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { return result; } return 0; diff --git a/src/libleo/leo/leotranslat.c b/src/libleo/leo/leotranslat.c index 6eb2011367b..e779b83c7f0 100644 --- a/src/libleo/leo/leotranslat.c +++ b/src/libleo/leo/leotranslat.c @@ -1,7 +1,5 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" void leoTranslate(void) { u32 lba; @@ -10,32 +8,28 @@ void leoTranslate(void) { u32 byte_p_blk; u16 zone; u16 vzone; - u8 flag; // boolean + u8 flag; - if (LEOcur_command->data.readWrite.lba >= NUM_LBAS) { + if (LEOcur_command->data.readwrite.lba >= 0x10C4) { LEOcur_command->header.sense = LEO_SENSE_LBA_OUT_OF_RANGE; LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; return; } - - lba = LEOcur_command->data.readWrite.lba + 0x18; + lba = LEOcur_command->data.readwrite.lba + 0x18; calc_blks = 0; calc_bytes = 0; flag = vzone = 1; - - if (LEOcur_command->header.control & LEO_CONTROL_TBL) { - calc_bytes = LEOcur_command->data.readWrite.transferBlks; - + if (LEOcur_command->header.control & 1) { + calc_bytes = LEOcur_command->data.readwrite.xfer_blks; while (calc_bytes != 0) { - if (flag || (LEOVZONE_TBL[LEOdisk_type][vzone] == lba)) { + if ((flag != 0) || (LEOVZONE_TBL[LEOdisk_type][vzone] == lba)) { vzone = leoLba_to_vzone(lba); zone = LEOVZONE_PZONEHD_TBL[LEOdisk_type][vzone]; - if (zone >= 8) { + if (zone > 7) { zone -= 7; } byte_p_blk = LEOBYTE_TBL2[zone]; } - if (calc_bytes < byte_p_blk) { calc_bytes = 0; } else { @@ -43,41 +37,36 @@ void leoTranslate(void) { } calc_blks++; lba++; - if ((calc_bytes != 0) && (lba >= 0x10DC)) { LEOcur_command->header.sense = LEO_SENSE_LBA_OUT_OF_RANGE; LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; return; } - flag = false; + flag = 0; } - LEOcur_command->data.readWrite.buffPtr = (void*)calc_blks; + LEOcur_command->data.readwrite.buff_ptr = (void*)calc_blks; } else { - calc_blks = LEOcur_command->data.readWrite.transferBlks; - + calc_blks = LEOcur_command->data.readwrite.xfer_blks; while (calc_blks != 0) { - if (flag || (LEOVZONE_TBL[LEOdisk_type][vzone] == lba)) { + if ((flag != 0) || (LEOVZONE_TBL[LEOdisk_type][vzone] == lba)) { vzone = leoLba_to_vzone(lba); zone = LEOVZONE_PZONEHD_TBL[LEOdisk_type][vzone]; - if (zone >= 8) { + if (zone > 7) { zone -= 7; } byte_p_blk = LEOBYTE_TBL2[zone]; } - calc_bytes += byte_p_blk; calc_blks--; lba++; - if ((calc_blks != 0) && (lba >= 0x10DC)) { LEOcur_command->header.sense = LEO_SENSE_LBA_OUT_OF_RANGE; LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; return; } - flag = false; + flag = 0; } - LEOcur_command->data.readWrite.buffPtr = (void*)calc_bytes; + LEOcur_command->data.readwrite.buff_ptr = (void*)calc_bytes; } - LEOcur_command->header.status = LEO_STATUS_GOOD; } diff --git a/src/libleo/leo/leoutil.c b/src/libleo/leo/leoutil.c index 76a7c34ce90..0eaff7b2606 100644 --- a/src/libleo/leo/leoutil.c +++ b/src/libleo/leo/leoutil.c @@ -1,9 +1,7 @@ -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64.h" +#include "ultra64/leo_internal.h" #include "array_count.h" #include "attributes.h" -#include "ultra64.h" u16 leoLba_to_phys(u32 lba) { u16 vzone_num; diff --git a/src/libleo/leo/leowrite.c b/src/libleo/leo/leowrite.c index 218ad228f42..f9ff9a30c50 100644 --- a/src/libleo/leo/leowrite.c +++ b/src/libleo/leo/leowrite.c @@ -1,55 +1,45 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" -#include "attributes.h" +#include "ultra64/leo_internal.h" -extern u16 LEOrw_flags; // N.B. NOT volatile in this file! +extern u16 LEOrw_flags; void leoWrite(void) { u32 message; u32 start_lba; u32 xfer_blk; - UNUSED u32 write_bytes = 0; - UNUSED u8 retry_count = 0; + u32 temp_v1; - start_lba = LEOcur_command->data.readWrite.lba; - xfer_blk = LEOcur_command->data.readWrite.transferBlks; - if (((start_lba | xfer_blk) & 0xFFFF0000) != 0) { + start_lba = LEOcur_command->data.readwrite.lba; + xfer_blk = LEOcur_command->data.readwrite.xfer_blks; + if ((((u32)(LEOcur_command->data.readwrite.lba | xfer_blk) >> 16) != 0)) { goto invalid_lba; } - - start_lba += 0x18; - if ((start_lba >= 0x10DC) || (start_lba + xfer_blk > 0x10DC)) { + temp_v1 = start_lba + 0x18; + if ((temp_v1 >= 0x10DC) || ((u32)(temp_v1 + xfer_blk) >= 0x10DD)) { invalid_lba: LEOcur_command->header.sense = LEO_SENSE_LBA_OUT_OF_RANGE; LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; return; } - - if (start_lba < LEORAM_START_LBA[LEOdisk_type]) { + if (temp_v1 < (u16)LEORAM_START_LBA[LEOdisk_type]) { LEOcur_command->header.sense = LEO_SENSE_WRITE_PROTECT_ERROR; LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; return; } - if (xfer_blk == 0) { LEOcur_command->header.sense = LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; LEOcur_command->header.status = LEO_STATUS_GOOD; return; } - LEOrw_flags = 0x8000; - LEOtgt_param.lba = start_lba; + LEOtgt_param.lba = temp_v1; osStartThread(&LEOinterruptThread); osRecvMesg(&LEOcontrol_que, (OSMesg*)&message, OS_MESG_BLOCK); - if (message != 0x90000) { - LEOcur_command->header.sense = message; + LEOcur_command->header.sense = (u8)message; LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; return; } - LEOcur_command->header.sense = LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; LEOcur_command->header.status = LEO_STATUS_GOOD; } diff --git a/src/libu64/gfxprint.c b/src/libu64/gfxprint.c index 06761f080a3..bf24864a427 100644 --- a/src/libu64/gfxprint.c +++ b/src/libu64/gfxprint.c @@ -410,13 +410,8 @@ s32 GfxPrint_VPrintf(GfxPrint* this, const char* fmt, va_list args) { } s32 GfxPrint_Printf(GfxPrint* this, const char* fmt, ...) { - s32 ret; va_list args; va_start(args, fmt); - ret = GfxPrint_VPrintf(this, fmt, args); - - va_end(args); - - return ret; + return GfxPrint_VPrintf(this, fmt, args); } diff --git a/src/libultra/io/devmgr.c b/src/libultra/io/devmgr.c index 7eb3197f81c..d271da1e239 100644 --- a/src/libultra/io/devmgr.c +++ b/src/libultra/io/devmgr.c @@ -62,14 +62,15 @@ void __osDevMgrMain(void* arg) { if (stat & LEO_STATUS_MECHANIC_INTR) { __osEPiRawWriteIo(ioMesg->piHandle, ASIC_BM_CTL, info->bmCtlShadow | LEO_BM_CLR_MECHANIC_INTR); } - blockInfo->errStatus = 4; + blockInfo->errStatus = LEO_SENSE_DATA_PHASE_ERROR; IO_WRITE(PI_STATUS_REG, PI_STATUS_CLR_INTR); __osSetGlobalIntMask(OS_IM_CART | OS_IM_PI); } osSendMesg(ioMesg->hdr.retQueue, (OSMesg)ioMesg, OS_MESG_NOBLOCK); - if (messageSend == 1 && ioMesg->piHandle->transferInfo.block[0].errStatus == 0) { + if (messageSend == 1 && + ioMesg->piHandle->transferInfo.block[0].errStatus == LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { // Run the above once more messageSend = 0; goto readblock1; diff --git a/src/n64dd/n64dd_0.c b/src/n64dd/n64dd_0.c new file mode 100644 index 00000000000..750bc86db1f --- /dev/null +++ b/src/n64dd/n64dd_0.c @@ -0,0 +1,553 @@ +#include "ultra64.h" +#include "n64dd.h" +#include "n64dd_internal.h" +#include "libc64/sleep.h" +#include "array_count.h" +#include "fault.h" +#include "gfx.h" +#include "stackcheck.h" +#include "sys_freeze.h" +#include "versions.h" +#include "audio.h" +#include "line_numbers.h" + +#pragma increment_block_number "ntsc-1.0:0 ntsc-1.1:0 ntsc-1.2:0 pal-1.0:0 pal-1.1:0" + +s32 func_801C8310(struct_801E1598* arg0); + +void* D_801D36D0 = gN64DDDiskReadTemporaryBuffer; +s32 (*D_801D36D4)(struct_801E1598*) = func_801C8310; + +struct_801C79DC D_801DA410; +struct_801DA5C8 D_801DA4B0; +struct_801DA5C8* D_801DA5C8; +struct_801DA5D0 D_801DA5D0; +OSMesgQueue D_801DA600; +OSMesgQueue D_801DA618; +OSMesg D_801DA630; +OSMesg D_801DA634; +vu8 D_801DA638; +volatile OSTime D_801DA640; +s32 D_801DA648; +s32 D_801DA64C; +s32 D_801DA650; +s32 D_801DA654; +OSThread D_801DA658; +STACK(D_801DA808, 0x1000); +StackEntry D_801DB808; +STACK(D_801DB828, 0x1000); +StackEntry D_801DC828; +s32 D_801DC844; + +u32 func_801C6E80(void) { +#if OOT_NTSC + return LeoDriveExist(); +#else + return 0; +#endif +} + +void func_801C6EA0(Gfx** gfxP) { +} + +void func_801C776C(void) { + if (D_80121214 == 0) { + func_800F6BDC(); + D_80121214 = 1; + } +} + +s32 func_801C77B0(void) { + return D_80121214 != 0; +} + +s32 func_801C77C8(void) { + if (D_80121214 != 0) { + return 1; + } + return 1; +} + +void func_801C77F0(void) { + func_801C776C(); + while (func_801C77C8() == 0) { + Sleep_Usec(1000000 / 60); + } +} + +void func_801C7838(void) { + if (D_80121214 != 0) { + D_80121214 = 0; + func_800F6B3C(); + } +} + +s32 func_801C786C(void) { + if (D_80121213 == 0) { + return 0; + } + D_80121213 = 0; + return 1; +} + +void func_801C7898(void) { + while (func_801C786C() == 0) { + Sleep_Usec(1000000 / 60); + } +} + +void func_801C78D8(void) { + if (D_80121213 != 0) { + Fault_AddHungupAndCrash("../z_n64dd.c", LN2(503, 551, 573)); + } + D_80121213 = 1; +} + +s32 func_801C7924(void) { + s32 (*p)(struct_801DA5D0*); + + D_801DA5D0.unk0 = 5; + p = func_801C8860; + return p(&D_801DA5D0); +} + +s32 func_801C7958(void) { + s32 sp1C; + s32 (*p)(struct_801DA5D0*); + +#if OOT_VERSION < PAL_1_0 + if (1) {} +#endif + + D_801DA5D0.unk0 = 0xA; + p = func_801C8860; + sp1C = p(&D_801DA5D0); + if (sp1C < 0) { + Freeze_CurrentThread(); + } + return sp1C; +} + +s32 func_801C79A4(void) { + return D_801DA648 == 1; +} + +s32 func_801C70FC(void) { + return func_801C79A4(); +} + +void func_801C79DC(void* arg) { + static void* D_801DC848; + + struct_801C79DC* arg0 = arg; + OSMesg sp58; + s32 var_s0; + void* temp_v0; + + sp58 = NULL; + arg0->unk98 = &gIrqMgr; + osCreateMesgQueue(&arg0->unk78, arg0->unk0, ARRAY_COUNT(arg0->unk0)); + IrqMgr_AddClient(arg0->unk98, &arg0->unk90, &arg0->unk78); + var_s0 = 0; + while (var_s0 == 0) { + osRecvMesg(&arg0->unk78, &sp58, OS_MESG_BLOCK); + switch (*(s16*)sp58) { + case 1: + temp_v0 = osViGetNextFramebuffer(); + if (D_801DC848 != temp_v0) { + D_801DC848 = temp_v0; + D_801DA638 = 1; + } + func_801C9318(); + break; + case 4: + LeoReset(); + break; + case 3: + var_s0 = 1; + break; + } + } + IrqMgr_RemoveClient(arg0->unk98, &arg0->unk90); +} + +LEODiskID D_801DC850; +s32 D_801DC870; + +#if OOT_VERSION >= NTSC_1_1 +void func_801C7B28(void) { + s32 temp_v1_2; + + if (D_801DA640 != 0) { + temp_v1_2 = OS_CYCLES_TO_USEC(osGetTime() - D_801DA640); + if ((1000000 - temp_v1_2) > 0) { + Sleep_Usec(1000000 - temp_v1_2); + } + } +} +#endif + +void func_801C7268(void) { + s32 pad; + s32 sp18; + + sp18 = func_801C77B0(); + if (sp18 == 0) { + func_801C77F0(); + } + D_801DA638 = 1; + D_801DA640 = 0; + if (func_801C7924() == 1) { + func_801C7958(); + } else if (D_801DA648 != 0) { + D_801DA648 = 0; + } +#if OOT_VERSION == NTSC_1_0 + if (D_801DA640 != 0) { + s32 temp_v1_2; + + temp_v1_2 = OS_CYCLES_TO_USEC(osGetTime() - D_801DA640); + + (void)(osGetTime() - D_801DA640); + (void)OS_CYCLES_TO_USEC(osGetTime() - D_801DA640); + (void)OS_CYCLES_TO_USEC(osGetTime() - D_801DA640); + + if ((1000000 - temp_v1_2) > 0) { + Sleep_Usec(1000000 - temp_v1_2); + } + } +#else + if ((D_801D3728 == 1) || (D_801E17E0 == 1) || (D_801E17E4 == 1)) { + D_801DA640 = osGetTime(); + } + func_801C7B28(); +#endif + if (sp18 == 0) { + func_801C7838(); + } +} + +void func_801C7CB8(u16* arg0) { + u16* var_v0; + + var_v0 = arg0; + while (var_v0 < (arg0 + (SCREEN_WIDTH * SCREEN_HEIGHT))) { + *var_v0 = 1; + var_v0++; + } +} + +void func_801C7CEC(s32 arg0, s32 arg1, s32 arg2) { + s32 sp2C; + + if ((arg0 != 0) || (arg1 != 0) || (arg2 != 0)) { + sp2C = (intptr_t)osViGetNextFramebuffer() + 0x20000000; + if ((sp2C & 0xFFFFFF) != 0) { + if (D_801DA638 != 0) { + D_801DA638 = 0; + func_801C7CB8((u16*)sp2C); + D_801DA640 = osGetTime(); + } + if (arg0 != 0) { + func_801CAA60(BADCASTP arg0, 0x60, 0x20, 0xC0, 0x10, 0xB, BADCASTP sp2C, 0x140); + } + if (arg1 != 0) { + func_801CAA60(BADCASTP arg1, 0, 0x50, 0x140, 0x40, 0xB, BADCASTP sp2C, 0x140); + } + if (arg2 != 0) { + func_801CAA60(BADCASTP arg2, 0, 0xB0, 0x140, 0x20, 0xB, BADCASTP sp2C, 0x140); + } +#if OOT_VERSION < PAL_1_0 + osViBlack(0); +#endif + } + } +} + +void func_801C7E34(s32 arg0, s32 arg1, s32 arg2) { + if ((arg0 == 0) && (arg1 == 0) && (arg2 == 0)) { + return; + } + if (D_801DA638) {} + if (arg0 != 0) { + D_801DA64C = arg0; + } + if (arg1 != 0) { + D_801DA650 = arg1; + } + if (arg2 != 0) { + D_801DA654 = arg2; + } + func_801C7CEC(arg0, arg1, arg2); +} + +void func_801C7E94(void) { + Sleep_Msec(100); + func_801C7CEC(D_801DA64C, D_801DA650, D_801DA654); +} + +s32 func_801C7658(void) { + if (D_80121212 != 0) { + return 0; + } +#if OOT_VERSION < PAL_1_0 + StackCheck_Init(&D_801DB808, D_801DA808, STACK_TOP(D_801DA808), 0, 0x100, "ddmsg"); + osCreateThread(&D_801DA658, 9, func_801C79DC, &D_801DA410, STACK_TOP(D_801DA808), 0xD); + osStartThread(&D_801DA658); +#endif + osCreateMesgQueue(&D_801DA600, &D_801DA630, 1); + osCreateMesgQueue(&D_801DA618, &D_801DA634, 1); + StackCheck_Init(&D_801DC828, D_801DB828, STACK_TOP(D_801DB828), 0, 0x100, "n64dd"); + D_801DA5D0.unk1C_1.unk1C = &D_801DA600; + D_801DA5D0.unk1C_1.unk20 = &D_801DA618; + D_801DA5D0.unk1C_1.unk24 = 8; + D_801DA5D0.unk1C_1.unk28 = STACK_TOP(D_801DB828); + D_801DA5D0.unk1C_1.unk2C = 0xD; + D_801DA5D0.unk0 = 1; + (&func_801C8860)(&D_801DA5D0); + D_80121213 = 1; + func_801C7898(); + D_801DA5D0.unk0 = 2; + D_801DA5D0.unk10 = 6; + D_801DA5D0.unk14 = DmaMgr_DmaFromDriveRom; + D_801DA5D0.unkC = func_801C7E34; + (&func_801C8860)(&D_801DA5D0); + D_801DA5D0.unk0 = 0xD; + (&func_801C8860)(&D_801DA5D0); +#if OOT_VERSION >= PAL_1_0 + StackCheck_Init(&D_801DB808, D_801DA808, STACK_TOP(D_801DA808), 0, 0x100, "ddmsg"); + osCreateThread(&D_801DA658, 9, func_801C79DC, &D_801DA410, STACK_TOP(D_801DA808), 0xD); + osStartThread(&D_801DA658); +#endif + return 0; +} + +s32 func_801C7818(void) { + s32 (*p)(struct_801DA5D0*) = func_801C8860; + +#if OOT_VERSION >= NTSC_1_1 + D_801DA638 = 1; + D_801DA640 = 0; +#endif + D_801DA5D0.unk0 = 0xC; + p(&D_801DA5D0); + while (func_801C8A24() == 0) { + Sleep_Usec(1000000 / 60); + } +#if OOT_VERSION >= NTSC_1_1 + if ((D_801D3728 == 1) || (D_801E17E0 == 1) || (D_801E17E4 == 1)) { + D_801DA640 = osGetTime(); + } + func_801C7B28(); +#endif + if (func_801C8A24() != 2) { + func_801C7E94(); + Freeze_CurrentThread(); + return -3; + } + func_801C78D8(); + D_80121212 = 1; + return 0; +} + +s32 func_801C81AC(void) { + s32 var_v1; + + var_v1 = func_801C7658(); + if (var_v1 == 0) { + var_v1 = func_801C7818(); + } + return var_v1; +} + +void func_801C81E4(void) { + D_801DA5D0.unk0 = 0; + (&func_801C8860)(&D_801DA5D0); +} + +void func_801C8214(s32 arg0, void* arg1, s32 arg2) { + s32 (*p)(struct_801DA5D0*) = func_801C8860; + + D_801DA5D0.unk18 = arg1; + D_801DA5D0.unk1C_3_4.unk1C = arg0; + D_801DA5D0.unk1C_3_4.unk20 = arg2; + D_801DA5D0.unk0 = 3; + p(&D_801DA5D0); + osGetTime(); + D_801DA5D0.unk0 = 6; + while (p(&D_801DA5D0) != 0) { + Sleep_Usec(1000000 / 60); + } + D_801DA5D0.unk0 = 7; + if (p(&D_801DA5D0) != 0) { + Freeze_CurrentThread(); + } +} + +void func_801C82C0(void* arg0, s32 arg1, s32 arg2) { + D_801DA5D0.unk18 = arg0; + D_801DA5D0.unk1C_3_4.unk1C = arg1; + D_801DA5D0.unk1C_3_4.unk20 = arg2; + D_801DA5D0.unk0 = 4; + (&func_801C8860)(&D_801DA5D0); +} + +void func_801C8304(LEODiskID* arg0) { +} + +s32 func_801C8310(struct_801E1598* arg0) { + func_801C8304(&arg0->unk38); + if (D_801DC870 == 0) { + if ( +#if OOT_NTSC + (bcmp(&arg0->unk38, "EZLJ", 4) == 0) || (bcmp(&arg0->unk38, "EZLE", 4) == 0) +#else + (bcmp(&arg0->unk38, "EZLP", 4) == 0) +#endif + ) { + D_801DC850 = arg0->unk38; + D_801DC870 = 1; + D_801DA648 = 1; + } else { + D_801DA648 = 2; + } + } else if (bcmp(&D_801DC850, &arg0->unk38, 0x20) == 0) { + D_801DA648 = 1; + } else { + D_801DA648 = 2; + } + return D_801DA648 == 1; +} + +s32 func_801C843C(s32 arg0, s32* arg1, s32* arg2) { + s32 sp2C; + s32 pad; + u32 sp24; + s32 sp20; + s32 v; + + v = LeoByteToLBA(1, arg0 + 1, &sp2C); + if (v != LEO_ERROR_GOOD) { + return v; + } + sp24 = sp2C - 1; + if (sp2C == 1) { + sp20 = 0; + } else { + v = LeoLBAToByte(1, sp24, &sp20); + if (v != LEO_ERROR_GOOD) { + return v; + } + } + *arg1 = sp24 + 1; + *arg2 = arg0 - sp20; + return LEO_ERROR_GOOD; +} + +s32 func_801C84E0(s32 arg0) { + s32 sp1C; + + if (LeoLBAToByte(arg0, 1, &sp1C) == LEO_ERROR_GOOD) { + return sp1C; + } else { + return 0; + } +} + +void func_801C7C1C(void* dest, s32 offset, s32 size) { + s32 sp44; + s32 sp40; + s32 sp3C; + s32 sp38; + void* sp34; + s32 temp_v0; + s32 var_s0; + s32 var_s1; + + func_801C7898(); + func_801C77F0(); + D_801DA638 = 1; + D_801DA640 = 0; + func_801C843C(offset, &sp44, &sp3C); + func_801C843C(offset + size, &sp40, &sp38); + sp34 = D_801D36D0; + if (sp44 == sp40) { + func_801C8214(sp44, sp34, func_801C84E0(sp44)); + bcopy((u8*)sp34 + sp3C, dest, size); + } else { + var_s1 = 0; + func_801C8214(sp44, sp34, func_801C84E0(sp44)); + bcopy((u8*)sp34 + sp3C, dest, func_801C84E0(sp44) - sp3C); + temp_v0 = sp44 + 1; + if (temp_v0 < sp40) { + var_s0 = temp_v0; + while (var_s0 < sp40) { + var_s1 += func_801C84E0(var_s0); + var_s0 += 1; + } + func_801C8214(sp44 + 1, (void*)((func_801C84E0(sp44) + (s32)dest) - sp3C), var_s1); + } + if (sp38 > 0) { + func_801C8214(sp40, sp34, func_801C84E0(sp40)); + bcopy(sp34, (void*)(((func_801C84E0(sp44) + (s32)dest) - sp3C) + var_s1), sp38); + } + } +#if OOT_VERSION == NTSC_1_0 + if (D_801DA640 != 0) { + s32 temp_v1_2; + + temp_v1_2 = OS_CYCLES_TO_USEC(osGetTime() - D_801DA640); + if ((1000000 - temp_v1_2) > 0) { + Sleep_Usec(1000000 - temp_v1_2); + } + } +#else + func_801C7B28(); +#endif + func_801C78D8(); + func_801C7838(); +} + +void func_801C7E78(void) { +} + +s32 func_801C86F8(void) { + s32 sp24; + s32 sp20; + s32 pad; + void* sp18; + + if (D_801DA5C8 != NULL) { + return -1; + } + D_801DA5C8 = &D_801DA4B0; + func_801C7C1C(D_801DA5C8, 0x1060, sizeof(*D_801DA5C8)); + sp24 = D_801DA5C8->unk4 - D_801DA5C8->unk0; + sp20 = (char*)D_801DA5C8->unkC - (char*)D_801DA5C8->unk8; + sp18 = (char*)D_801DA5C8->unk8 + sp24; + func_801C7C1C(D_801DA5C8->unk8, D_801DA5C8->unk0, sp24); + bzero(sp18, sp20 - sp24); + func_800AD4C0(D_801DA5C8->unk10); + return 0; +} + +s32 func_801C879C(void) { + if (D_801DA5C8 == NULL) { + return -1; + } + func_800AD51C(); + bzero(D_801DA5C8->unk8, (char*)D_801DA5C8->unkC - (char*)D_801DA5C8->unk8); + bzero(D_801DA5C8, sizeof(*D_801DA5C8)); + D_801DA5C8 = NULL; + return 0; +} + +void n64dd_SetDiskVersion(s32 arg0) { + if (arg0 != 0) { + if (D_801DA5C8 == 0) { + func_801C86F8(); + } + } else if (D_801DA5C8 != 0) { + func_801C879C(); + } +} diff --git a/src/n64dd/n64dd_data_buffer.c b/src/n64dd/n64dd_1.c similarity index 87% rename from src/n64dd/n64dd_data_buffer.c rename to src/n64dd/n64dd_1.c index 00a09a69b61..4b05443c758 100644 --- a/src/n64dd/n64dd_data_buffer.c +++ b/src/n64dd/n64dd_1.c @@ -1,4 +1,6 @@ +#include "ultra64.h" #include "n64dd.h" +#include "n64dd_internal.h" /** * Buffer used during the process of reading from the disk diff --git a/src/n64dd/n64dd_2.c b/src/n64dd/n64dd_2.c new file mode 100644 index 00000000000..823cc3d050a --- /dev/null +++ b/src/n64dd/n64dd_2.c @@ -0,0 +1,333 @@ +#include "ultra64.h" +#include "n64dd.h" +#include "n64dd_internal.h" +#include "array_count.h" +#include "region.h" +#include "z_locale.h" + +#pragma increment_block_number "" + +void func_801C8A4C(struct_801E1598*); +void func_801C8B8C(struct_801E1598*); +void func_801C8C00(struct_801E1598*); +void func_801C8C74(struct_801E1598*); +s32 func_801C9A50(struct_801E1598*); +s32 func_801C9AD0(struct_801E1598*); +s32 func_801C9C34(struct_801E1598*); +void func_801C8DB4(void); +void func_801C8DD8(OSMesgQueue*, OSMesgQueue*, s32, void*, s32); +void func_801C8E98(void (*)(s32, s32, s32), s32, void (*)(void*, uintptr_t, size_t)); +void func_801C8EEC(void*, s32, s32, u8); +s8 func_801C8FD0(void); +s32 func_801C9020(void); +s32 func_801C905C(void); +s32 func_801C90A4(void); +s32 func_801C90BC(void); +s32 func_801C9114(void); +s32 func_801C916C(void); + +s32 D_801D36E0 = 0; +s32 D_801D36E4 = 0; +struct { + void (*unk0)(struct_801E1598*); + s32 (*unk4)(struct_801E1598*); +} D_801D36E8[5] = { + { func_801C8A4C, func_801C9A50 }, { func_801C8B8C, func_801C9AD0 }, { func_801C8C00, func_801C9AD0 }, + { func_801C8C74, func_801C9BA4 }, { func_801C8C74, func_801C9C34 }, +}; +s32 D_801D3710 = 0; + +struct_801E1590 D_801E1590; +struct_801E1598 D_801E1598; +OSMesg D_801E1608; +OSMesg D_801E1610[8]; +OSThread D_801E1630; + +s32 func_801C8860(struct_801DA5D0* arg0) { + s32 temp_v0_2; + s8 temp_v0; + + switch (arg0->unk0) { + case 0: + if (func_801C90A4() != 0) { + return 1; + } + func_801C8DB4(); + return 0; + case 1: + func_801C8DD8(arg0->unk1C_1.unk1C, arg0->unk1C_1.unk20, arg0->unk1C_1.unk24, arg0->unk1C_1.unk28, + arg0->unk1C_1.unk2C); + return 0; + case 2: + func_801C8E98(arg0->unkC, arg0->unk10, arg0->unk14); + return 0; + case 3: + if (func_801C90A4() != 0) { + return 1; + } + func_801C8EEC(arg0->unk18, arg0->unk1C_3_4.unk1C, arg0->unk1C_3_4.unk20, 1); + return 0; + case 4: + if (func_801C90A4() != 0) { + return 1; + } + func_801C8EEC(arg0->unk18, arg0->unk1C_3_4.unk1C, arg0->unk1C_3_4.unk20, 2); + return 0; + case 5: + temp_v0 = func_801C8FD0(); + arg0->unk8 = temp_v0; + return temp_v0 & 0xFF; + case 7: + return func_801C905C(); + case 6: + return func_801C90A4(); + case 8: + temp_v0_2 = func_801C9020(); + arg0->unk4 = temp_v0_2; + return temp_v0_2; + case 9: + return func_801C90BC(); + case 10: + return func_801C9114(); + case 11: + return func_801C916C(); + case 12: + D_801D3720 = 0; + break; + case 13: + D_801D3720 = 1; + break; + } + return 0; +} + +void func_801C89FC(s32 arg0) { + if (arg0 != 0) { + D_801D36E0 = 1; + return; + } + D_801D36E0 = 2; +} + +s32 func_801C8A24(void) { + return D_801D36E0; +} + +s32 func_801C8A34(void) { + return D_801D36E4 == 1; +} + +void func_801C8A4C(struct_801E1598* arg0) { + osCreateMesgQueue(&arg0->unk1C, &D_801E1608, 1); + if (gCurrentRegion == REGION_JP) { + arg0->unk68 = LeoCJCreateLeoManager(149, 150, D_801E1610, ARRAY_COUNT(D_801E1610)); + } else { + arg0->unk68 = LeoCACreateLeoManager(149, 150, D_801E1610, ARRAY_COUNT(D_801E1610)); + } + if ((arg0->unk68 == LEO_ERROR_DEVICE_COMMUNICATION_FAILURE) || (arg0->unk68 == LEO_ERROR_GOOD)) { + D_801D36E4 = 1; + } +} + +void func_801C8AF8(struct_801E1598* arg0) { + LEOCmd sp1C; + + LeoReadDiskID(&sp1C, &arg0->unk38, &arg0->unk1C); + osRecvMesg(&arg0->unk1C, (OSMesg*)&arg0->unk68, OS_MESG_BLOCK); +} + +void func_801C8B40(struct_801E1598* arg0) { + LEOCmd sp1C; + + LeoSpdlMotor(&sp1C, 4, &arg0->unk1C); + osRecvMesg(&arg0->unk1C, (OSMesg*)&arg0->unk68, OS_MESG_BLOCK); +} + +void func_801C8B8C(struct_801E1598* arg0) { + s32 sp34; + s32 sp30; + OSMesgQueue* sp28; + + sp30 = arg0->unk5C; + if (LeoByteToLBA(sp30, (u32)arg0->unk60, &sp34) == 0) { + sp28 = &arg0->unk1C; + LeoReadWrite(&arg0->unk0, OS_READ, (u32)sp30, arg0->unk58, (u32)sp34, sp28); + osRecvMesg(sp28, (OSMesg*)&arg0->unk68, OS_MESG_BLOCK); + } +} + +void func_801C8C00(struct_801E1598* arg0) { + s32 sp34; + void* sp30; + OSMesgQueue* sp28; + + sp30 = arg0->unk58; + if (LeoByteToLBA((s32)sp30, (u32)arg0->unk60, &sp34) == LEO_ERROR_GOOD) { + sp28 = &arg0->unk1C; + LeoReadWrite(&arg0->unk0, OS_WRITE, (u32)sp30, (void*)arg0->unk5C, (u32)sp34, sp28); + osRecvMesg(sp28, (OSMesg*)&arg0->unk68, OS_MESG_BLOCK); + } +} + +void func_801C8C74(struct_801E1598* arg0) { + arg0->unk68 = 9; +} + +void func_801C8C84(struct_801E1598* arg0) { + s32 (*temp_s2)(struct_801E1598*); + s32 temp_v0_2; + void (*temp_s1)(struct_801E1598*); + + arg0->unk68 = -1; + if ((func_801C8A34() != 0) || ((u8)arg0->unk64 == 0)) { + arg0->unk66 = 1; + temp_s1 = D_801D36E8[(u8)arg0->unk64].unk0; + temp_s2 = D_801D36E8[(u8)arg0->unk64].unk4; + do { + temp_s1(arg0); + temp_v0_2 = temp_s2(arg0); + } while (temp_v0_2 == 2); + arg0->unk6C = temp_v0_2; + if ((u8)arg0->unk64 == 0) { + func_801C89FC(temp_v0_2); + } + arg0->unk66 = 0; + } +} + +void func_801C8D34(void* arg0) { + void* sp24; + + while (true) { + osRecvMesg(D_801E1590.unk0, &sp24, OS_MESG_BLOCK); + func_801C8C84(sp24); + osSendMesg(D_801E1590.unk4, NULL, OS_MESG_BLOCK); + } +} + +void func_801C8DB4(void) { + osDestroyThread(&D_801E1630); +} + +void func_801C8DD8(OSMesgQueue* arg0, OSMesgQueue* arg1, s32 arg2, void* arg3, s32 arg4) { + D_801E1590.unk0 = arg0; + D_801E1590.unk4 = arg1; + osCreateThread(&D_801E1630, arg2, func_801C8D34, NULL, arg3, arg4); + osStartThread(&D_801E1630); +} + +void func_801C8E50(struct_801E1598* arg0, s32 arg1) { + if (arg1 == 1) { + func_801C8C84(arg0); + return; + } + osSendMesg(D_801E1590.unk0, arg0, OS_MESG_BLOCK); +} + +void func_801C8E98(void (*arg0)(s32, s32, s32), s32 arg1, void (*arg2)(void*, uintptr_t, size_t)) { + struct_801E1598* ptr = &D_801E1598; + + func_801CA3C0(arg1, arg2); + D_801D3734 = BADCASTP arg0; + ptr->unk64 = 0; + ptr->unk65 = 0; + func_801C8E50(ptr, 0); +} + +void func_801C8EEC(void* arg0, s32 arg1, s32 arg2, u8 arg3) { + struct_801E1598* var = &D_801E1598; + + if (D_801D3710 == 1) { + D_801D3710 = 0; + var->unk64 = 4; + func_801C8E50(var, 1); + if ((D_801E1598.unk6C == 3) || (D_801E1598.unk6C == 4)) { + return; + } + } + var->unk58 = arg0; + var->unk5C = arg1; + var->unk60 = arg2; + var->unk64 = arg3; + func_801C8E50(var, 0); +} + +s32 func_801C8F9C(struct_801E1598* arg0) { + u8 sp1F; + + arg0->unk68 = LeoTestUnitReady(&sp1F); + return (sp1F & 1) == 0; +} + +s8 func_801C8FD0(void) { + s32 temp_v0; + + temp_v0 = func_801C8F9C(&D_801E1598); + if (D_801E1598.unk68 == LEO_ERROR_BUSY) { + return 0; + } + if (temp_v0 == 0) { + return 2; + } + return 1; +} + +s32 func_801C9020(void) { + if ((func_801C90A4() == 0) && (D_801E1598.unk68 != LEO_ERROR_GOOD)) { + return D_801E1598.unk68; + } + return -1; +} + +s32 func_801C905C(void) { + s32* new_var; + + new_var = &D_801E1598.unk6C; + if ((func_801C90A4() == 0) && ((*new_var == 3) || (*new_var == 4))) { + return D_801E1598.unk68; + } + return 0; +} + +s32 func_801C90A4(void) { + return D_801E1598.unk66 == 1; +} + +s32 func_801C90BC(void) { + D_801E1598.unk64 = 3; + func_801C8E50(&D_801E1598, 1); +#if OOT_VERSION >= NTSC_1_1 + D_801D3710 = 0; +#endif + if ((D_801E1598.unk6C == 3) || (D_801E1598.unk6C == 4)) { + return -1; + } else { + return D_801E1598.unk6C == 0; + } +} + +s32 func_801C9114(void) { + D_801E1598.unk64 = 4; + func_801C8E50(&D_801E1598, 1); +#if OOT_VERSION >= NTSC_1_1 + D_801D3710 = 0; +#endif + if ((D_801E1598.unk6C == 3) || (D_801E1598.unk6C == 4)) { + return -1; + } else { + return D_801E1598.unk6C == 0; + } +} + +s32 func_801C916C(void) { + s32 var_v1; + + if (LeoDriveExist() != 0) { + var_v1 = 8; + } else { + var_v1 = 0; + } + if (var_v1 == 0) {} + D_801E1598.unk68 = var_v1; + return var_v1 == 0; +} diff --git a/src/n64dd/n64dd_3.c b/src/n64dd/n64dd_3.c new file mode 100644 index 00000000000..11d90ae39c5 --- /dev/null +++ b/src/n64dd/n64dd_3.c @@ -0,0 +1,382 @@ +#include "ultra64.h" +#include "n64dd.h" +#include "n64dd_internal.h" +#include "libc64/sleep.h" +#include "attributes.h" + +s32 D_801D3720 = 0; +void* D_801D3724 = NULL; +s32 D_801D3728 = 0; +void* D_801D372C = NULL; +void* D_801D3730 = NULL; +void (*D_801D3734)(void*, void*, void*) = NULL; + +s32 D_801E17E0; +s32 D_801E17E4; + +void func_801C91B0(s32 arg0) { + D_801D3724 = func_801CA698(arg0); + D_801D3728 = 1; +} + +void func_801C91E4(void) { + if (D_801D3728 == 1) { + D_801D3724 = func_801CA730(); + D_801D3728 = 0; + } +} + +void func_801C9228(s32 arg0) { + D_801D372C = func_801CA800(arg0); + D_801E17E0 = 1; +} + +void func_801C925C(void) { + if (D_801E17E0 == 1) { + D_801D372C = func_801CA86C(); + D_801E17E0 = 0; + } +} + +void func_801C92A0(s32 arg0) { + D_801D3730 = func_801CA8A0(arg0); + D_801E17E4 = 1; +} + +void func_801C92D4(void) { + if (D_801E17E4 == 1) { + D_801D3730 = func_801CA8E0(); + D_801E17E4 = 0; + } +} + +void func_801C9318(void) { + u32 temp_v0; + UNK_PTR sp20; + UNK_PTR sp1C; + UNK_PTR sp18; + + osRecvMesg(D_801E1590.unk4, NULL, OS_MESG_NOBLOCK); + if ((D_801D3734 != NULL) && (D_801D3720 == 0)) { + temp_v0 = osSetIntMask(OS_IM_NONE); + sp20 = D_801D3724; + sp1C = D_801D372C; + sp18 = D_801D3730; + D_801D3724 = NULL; + D_801D372C = NULL; + D_801D3730 = NULL; + osSetIntMask(temp_v0); + D_801D3734(sp20, sp1C, sp18); + } +} + +void func_801C93C8(s32 arg0, s32 arg1, s32 arg2) { + func_801C91B0(arg0); + func_801C9228(arg1); + func_801C92A0(arg2); +} + +void func_801C9400(void) { + func_801C91E4(); + func_801C925C(); + func_801C92D4(); +} + +s32 func_801C9430(struct_801E1598* arg0) { + if (((arg0->unk68 <= LEO_ERROR_ILLEGAL_TIMER_VALUE) || (arg0->unk68 >= LEO_ERROR_DEVICE_COMMUNICATION_FAILURE)) && + (arg0->unk68 != LEO_ERROR_INVALID_COMMAND_OPERATION_CODE) && (arg0->unk68 != LEO_ERROR_LBA_OUT_OF_RANGE)) { + func_801C91B0(arg0->unk68); + func_801C9228(3); + } + LeoClearQueue(); + return 4; +} + +s32 func_801C948C(struct_801E1598* arg0) { + s32 var_s0; + + while (true) { + var_s0 = 0; + Sleep_Msec(60); + func_801C8B40(arg0); + switch (arg0->unk68) { + case LEO_ERROR_MEDIUM_NOT_PRESENT: + func_801C92D4(); + return 0; + case LEO_ERROR_COMMAND_TERMINATED: + func_801C92D4(); + LeoClearQueue(); + return 3; + case LEO_ERROR_GOOD: + func_801C92A0(6); + FALLTHROUGH; + case LEO_ERROR_QUEUE_FULL: + var_s0 = 1; + FALLTHROUGH; + default: + if (var_s0 == 0) { + func_801C92D4(); + return func_801C9430(arg0); + } + break; + } + var_s0 = 1; //! FAKE + } +} + +s32 func_801C955C(struct_801E1598* arg0) { + switch (arg0->unk68) { + case LEO_ERROR_COMMAND_TERMINATED: + func_801C9400(); + LeoClearQueue(); + return 3; + case LEO_ERROR_DIAGNOSTIC_FAILURE: + func_801C91B0(arg0->unk68); + func_801C92A0(5); + return 9; + case LEO_ERROR_GOOD: + func_801C9400(); + return 0; + case LEO_ERROR_POWERONRESET_DEVICERESET_OCCURED: + if ((u8)arg0->unk65 == 0) { + func_801C9400(); + arg0->unk65 = 2; + return 1; + } + FALLTHROUGH; + default: + func_801C9400(); + return func_801C9430(arg0); + case LEO_ERROR_QUEUE_FULL: + return 9; + } +} + +s32 func_801C9630(struct_801E1598* arg0) { + s32 temp_v0; + + while (true) { + func_801C8AF8(arg0); + switch (arg0->unk68) { + case LEO_ERROR_EJECTED_ILLEGALLY_RESUME: + func_801C91B0(arg0->unk68); + func_801C9228(2); + return 5; + case LEO_ERROR_MEDIUM_NOT_PRESENT: + func_801C9400(); + return 5; + default: + temp_v0 = func_801C955C(arg0); + if (temp_v0 != 9) { + return temp_v0; + } + Sleep_Msec(60); + break; + } + } +} + +s32 func_801C96E0(struct_801E1598* arg0) { + s32 temp_v0; + + while (true) { + Sleep_Msec(60); + func_801C8AF8(arg0); + switch (arg0->unk68) { + case LEO_ERROR_QUEUE_FULL: + continue; + case LEO_ERROR_EJECTED_ILLEGALLY_RESUME: + func_801C91B0(arg0->unk68); + func_801C9228(2); + FALLTHROUGH; + case LEO_ERROR_MEDIUM_NOT_PRESENT: + func_801C92A0(4); + continue; + } + temp_v0 = func_801C955C(arg0); + if (temp_v0 != 9) { + return temp_v0; + } + } +} + +s32 func_801C978C(struct_801E1598* arg0) { + if (D_801D36D4 != NULL) { + return D_801D36D4(arg0); + } + return 1; +} + +s32 func_801C97C8(struct_801E1598* arg0) { + s32 temp_v0; + s32 temp_v0_2; + + while (true) { + temp_v0_2 = func_801C96E0(arg0); + if ((temp_v0_2 == 3) || (temp_v0_2 == 4)) { + return temp_v0_2; + } else if ((temp_v0_2 & 0xFFFFFFFF) == 0) { + if (func_801C978C(arg0) != 0) { + return 2; + } + func_801C9228(1); + temp_v0 = func_801C948C(arg0); + if (temp_v0 != 0) { + return temp_v0; + } + func_801C925C(); + } + } +} + +s32 func_801C9870(struct_801E1598* arg0) { + s32 temp_v0_3; + s32 var_s0; + + while (true) { + var_s0 = func_801C96E0(arg0); + if ((var_s0 == 3) || (var_s0 == 4)) { + return var_s0; + } + + if ((var_s0 & 0xFFFFFFFF) == 0) { + func_801C9400(); + temp_v0_3 = func_801C978C(arg0); + if (temp_v0_3 != 0) { + return 2; + } + + if (var_s0 == 3) {} + if (var_s0 == 4) {} + if (var_s0 == 3) {} + if (var_s0 == 4) {} + func_801C9228(1); + + var_s0 = func_801C948C(arg0); + if (var_s0 != 0) { + return var_s0; + } + func_801C925C(); + if (temp_v0_3 != 0) { + return var_s0; + } + } + } +} + +s32 func_801C9934(struct_801E1598* arg0) { + func_801C91B0(arg0->unk68); + func_801C9228(2); + return func_801C9870(arg0); +} + +s32 func_801C996C(struct_801E1598* arg0) { + func_801C91B0(arg0->unk68); + return func_801C9870(arg0); +} + +s32 func_801C999C(struct_801E1598* arg0) { + s32 temp_v0; + s32 var_s0 = 0; + + while (true) { + LeoResetClear(); + temp_v0 = func_801C9630(arg0); + if ((temp_v0 == 3) || (temp_v0 == 4)) { + return temp_v0; + } + if (temp_v0 != 1) { + if (temp_v0 == 0) { + return temp_v0; + } + return temp_v0; + } + if (1) {} + Sleep_Msec(250); + if (var_s0++ < 0x1E) { + } else { + return func_801C9430(arg0); + } + } +} + +s32 func_801C9A50(struct_801E1598* arg0) { + if (arg0->unk68 == LEO_ERROR_DEVICE_COMMUNICATION_FAILURE) { + return func_801C9430(arg0); + } + if (osMemSize < 0x800000) { + func_801C93C8(0x2C, 0, 3); + return 4; + } + if (func_801C999C(arg0) == 0) { + D_801D3710 = 1; + } + return 0; +} + +s32 func_801C9AD0(struct_801E1598* arg0) { + s32 temp_v0; + + switch (arg0->unk68) { + case LEO_ERROR_UNRECOVERED_READ_ERROR: + func_801C8F9C(arg0); + temp_v0 = func_801C948C(arg0); + if (temp_v0 != 0) { + return temp_v0; + } + func_801C9400(); + return 2; + case LEO_ERROR_DIAGNOSTIC_FAILURE: + return func_801C97C8(arg0); + case LEO_ERROR_COMMAND_TERMINATED: + LeoClearQueue(); + return 3; + case LEO_ERROR_EJECTED_ILLEGALLY_RESUME: + return func_801C9934(arg0); + case LEO_ERROR_MEDIUM_MAY_HAVE_CHANGED: + return func_801C9870(arg0); + case LEO_ERROR_MEDIUM_NOT_PRESENT: + return func_801C996C(arg0); + case LEO_ERROR_GOOD: + return 0; + case LEO_ERROR_QUEUE_FULL: + return 2; + default: + return func_801C9430(arg0); + } +} + +s32 func_801C9BA4(struct_801E1598* arg0) { + s32 temp_v0; + + while (true) { + if (1) {} + temp_v0 = func_801C9630(arg0); + if ((temp_v0 == 3) || (temp_v0 == 4) || (temp_v0 == 5)) { + return temp_v0; + } + if ((temp_v0 & 0xFFFFFFFF) == 0) { + if (func_801C978C(arg0) != 0) { + return 0; + } + return 7; + } + } +} + +s32 func_801C9C34(struct_801E1598* arg0) { + s32 v; + + while (true) { + v = func_801C9BA4(arg0); + if (v != 7) { + return v; + } + func_801C9228(1); + v = func_801C948C(arg0); + if (v != 0) { + return v; + } + func_801C925C(); + } +} diff --git a/src/n64dd/n64dd_4.c b/src/n64dd/n64dd_4.c new file mode 100644 index 00000000000..1bbc413cce0 --- /dev/null +++ b/src/n64dd/n64dd_4.c @@ -0,0 +1,230 @@ +#include "ultra64.h" +#include "n64dd.h" +#include "n64dd_internal.h" + +void (*D_801D3740)(void*, uintptr_t, size_t) = NULL; + +s32 D_801E17F0; + +int func_801C9CB0(const char* arg0) { + if (((*arg0 >= 0x8E) && (*arg0 < 0xFF)) || ((*arg0 != 0x8F) && (*arg0 != 0xA0))) { + arg0++; + return (*arg0 >= 0xA0) && (*arg0 < 0xFF); + } + return 0; +} + +int func_801C9D04(u8* arg0) { + if (((*arg0 >= 0x81) && (*arg0 < 0xA0)) || ((*arg0 >= 0xE0) && (*arg0 < 0xFD))) { + arg0++; + return (*arg0 >= 0x40) && (*arg0 < 0xFD) && (*arg0 != 0x7F); + } + return 0; +} + +void func_801C9D68(char* arg0, u16 arg1) { + arg0[0] = arg1 >> 8; + arg0[1] = arg1 & 0xFF; +} + +u16 func_801C9D84(u16 arg0) { + return arg0 - 0x8080; +} + +u16 func_801C9DA4(u16 arg0) { + u8 temp_a2; + u8 temp_v0; + + temp_v0 = (arg0 >> 8) & 0xFF; + temp_a2 = arg0 & 0xFF; + if (temp_v0 & 1) { + temp_a2 += 0x1F; + if (temp_a2 >= 0x7F) { + temp_a2 += 1; + } + } else { + temp_a2 += 0x7E; + } + temp_v0 = ((temp_v0 - 0x21) / 2) + 0x81; + if (temp_v0 >= 0xA0) { + temp_v0 += 0x40; + } + return (temp_v0 << 8) + temp_a2; +} + +void func_801C9E30(void* arg0, uintptr_t arg1, size_t arg2) { + if (D_801D3740 != NULL) { + D_801D3740(arg0, arg1, arg2); + } +} + +s32 func_801C9E60(const char* arg0) { + return LeoGetKAdr(func_801C9DA4(func_801C9D84(((arg0[0] << 8) | arg0[1])))) + 0xA0000; +} + +s32 func_801C9EAC(s32* arg0, int* arg1, int* arg2, int* arg3, char arg4) { + u16 v; + s32 temp_v0; + + v = arg4 - 0x20; + v += D_801E17F0 * 0xC0; + temp_v0 = LeoGetAAdr(v, arg1, arg2, arg3); + *arg0 = (temp_v0 - (temp_v0 & 0xF)) + 0xA0000; + return temp_v0 & 0xF; +} + +s32 func_801C9F0C(void* arg0, int* arg1, int* arg2, int* arg3, const char* arg4) { + s32 sp24; + s32 var_v1; + + if (func_801C9CB0(arg4) != 0) { + sp24 = func_801C9E60(arg4); + *arg1 = 0x10; + var_v1 = 0; + *arg2 = 0x10; + *arg3 = 0xB; + } else { + var_v1 = func_801C9EAC(&sp24, arg1, arg2, arg3, *arg4); + } + func_801C9E30(arg0, sp24, 0x80); + return var_v1; +} + +s32 func_801C9FB0(u8* arg0, s32 arg1, u8 arg2) { + if (arg1 == 1) { + *arg0 = arg2 * 0x10; + return 0; + } else { + *arg0 |= arg2; + return 1; + } +} + +void* func_801C9FE8(void* arg0, s32* arg1, s32 arg2) { + arg0 = BADCASTP((uintptr_t)arg0 + (arg2 >> 1)); + if (((*arg1 == 1) && ((arg2 & 1) == 0)) || ((*arg1 == 0) && ((arg2 & 1) != 0))) { + arg0 = BADCASTP((uintptr_t)arg0 + (arg2 & 1)); + *arg1 = 1; + } else { + *arg1 = 0; + } + return arg0; +} + +s32 func_801CA034(void** arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, u8* arg5, s32 arg6, s32 arg7, s32 arg8) { + s32 var_s0; + s32 var_s1; + s32 var_s3; + void* var_fp; + s32 sp4C; + s32 var_s4; + s32 sp44; + + sp4C = arg2; + var_s4 = 1; + sp44 = arg6 + arg3 + arg4; + var_fp = func_801C9FE8(*arg0, &sp4C, arg3); + arg1 >>= 1; + var_fp = BADCASTP((s32)var_fp + ((0xB - arg8) * arg1)); + if (arg6 & 1) { + arg6 += 1; + } + + while (arg7--) { + var_s0 = BADCASTI var_fp; + var_s1 = sp4C; + + for (var_s3 = 0; var_s3 < arg6; var_s3++, var_s4 ^= 1, var_s1 ^= 1) { + if (var_s4 == 1) { + if (func_801C9FB0(BADCASTP var_s0, var_s1, (*arg5) >> 4) != 0) { + var_s0++; + } + } else { + if (func_801C9FB0(BADCASTP var_s0, var_s1, (*arg5) & 0xF) != 0) { + var_s0++; + } + arg5++; + } + } + var_fp = BADCASTP((s32)var_fp + arg1); + } + + *arg0 = func_801C9FE8(*arg0, &arg2, sp44); + return arg2; +} + +void func_801CA1C4(const char* arg0, s32* arg1, s32* arg2) { + char v1, v2; + + if (func_801C9CB0(arg0) != 0) { + *arg2 = 0; + *arg1 = 0; + return; + } + *arg2 = 0; + *arg1 = 0; + v1 = arg0[-1]; + v2 = arg0[1]; + switch ((u8)arg0[0]) { + case 0x20: + *arg2 = 0; + *arg1 = 0; + return; + case 0x49: + case 0x69: +#if OOT_NTSC + *arg2 = 2; + if (1) {} +#endif + *arg1 = 2; + *arg2 = 2; + if (v1 == 0x20) { + *arg1 = 0; + } + if (v2 == 0x20) { + *arg2 = 0; + } + return; + } +#if OOT_NTSC + *arg2 = 1; + if (1) {} +#endif + *arg1 = 1; + *arg2 = 1; +} + +void func_801CA280(void* arg0, s32 arg1, const char* arg2) { + u8 megatemp[0xA0]; + u8* temp_s1 = (u8*)(((((u32)megatemp + 0xF)) >> 4) << 4); // align to 0x10 on the stack + int sp78; + int sp74; + int sp70; + u8* var_s0; + s32 sp68; + s32 sp64; + s32 temp_v1; + s32 var_s2 = 1; + + if (arg2 == NULL) { + return; + } + + while (*arg2 != 0) { + func_801CA1C4(arg2, &sp68, &sp64); + temp_v1 = func_801C9F0C(temp_s1, &sp78, &sp74, &sp70, arg2); + if (sp78 & 1) { + sp78++; + } + var_s2 = func_801CA034(&arg0, arg1, var_s2, sp68, sp64, &temp_s1[temp_v1], sp78, sp74, sp70); + if (func_801C9CB0(arg2) != 0) { + arg2++; + } + arg2++; + } +} + +void func_801CA3C0(s32 arg0, void (*arg1)(void*, uintptr_t, size_t)) { + D_801E17F0 = arg0; + D_801D3740 = arg1; +} diff --git a/src/n64dd/n64dd_error_headers.c b/src/n64dd/n64dd_5.c similarity index 83% rename from src/n64dd/n64dd_error_headers.c rename to src/n64dd/n64dd_5.c index bac2f97b957..7630eebe666 100644 --- a/src/n64dd/n64dd_error_headers.c +++ b/src/n64dd/n64dd_5.c @@ -1,6 +1,6 @@ +#include "ultra64.h" #include "n64dd.h" - -// Padding in .rodata suggests that this array is in a separate file +#include "n64dd_internal.h" /** * Region-specific "error number" headers used in N64DD error handling. diff --git a/src/n64dd/n64dd_6.c b/src/n64dd/n64dd_6.c new file mode 100644 index 00000000000..9d373efd6ad --- /dev/null +++ b/src/n64dd/n64dd_6.c @@ -0,0 +1,271 @@ +#include "ultra64.h" +#include "n64dd.h" +#include "n64dd_internal.h" +#include "region.h" +#include "tex_len.h" +#include "z_locale.h" + +#pragma increment_block_number "" + +const char* D_801D3760[2][8][4] = { + { + { + "  メモリー拡張パックが正しく差し込", + "  んでありますか?        ", + NULL, + NULL, + }, + { + "  間違ったディスクが差し込まれてい", + "  る可能性があります。正しいディス", + "  クに交換してください。     ", + NULL, + }, + { + "  注意:アクセスランプ点滅中にディ", + "  スクを抜かないでください。詳しく", + "  は、取扱説明書をお読みください。", + NULL, + }, + { + "  詳しくは、取扱説明書をお読みくだ", + "  さい。             ", + NULL, + NULL, + }, + { + "   ディスクを差し込んでください。", + NULL, + NULL, + NULL, + }, + { + "  ディスクを差し込み直してください。", + NULL, + NULL, + NULL, + }, + { + "   ディスクを取り出してください。", + NULL, + NULL, + NULL, + }, + { + NULL, + NULL, + NULL, + NULL, + }, + }, + { + { + " Are you sure the Expansion", + " Pak is inserted correctly?", + NULL, + NULL, + }, + { + " Check to see if the proper", + " disk is inserted.", + " Please insert the disk the", + " correct disk.", + }, + { + " Do not remove the disk when", + " the access light is flashing.", + " Please read the instruction", + " manual for details.", + }, + { + " Please read the instruction", + " manual for details.", + NULL, + NULL, + }, + { + " Please insert a disk.", + NULL, + NULL, + NULL, + }, + { + " Please insert the disk again.", + NULL, + NULL, + NULL, + }, + { + " Please remove the disk.", + NULL, + NULL, + NULL, + }, + { + NULL, + NULL, + NULL, + NULL, + }, + }, +}; +u64 D_801D3860[2][TEX_LEN(u64, 192, 16, 4)] = { + { +#include "assets/misc/n64dd_error_textures/gN64DDError41JPNTex.i4.inc.c" + }, + { +#include "assets/misc/n64dd_error_textures/gN64DDError41ENGTex.i4.inc.c" + }, +}; +u64 D_801D4460[2][TEX_LEN(u64, 320, 64, 4)] = { + { +#include "assets/misc/n64dd_error_textures/gN64DDPleaseReadManualJPNTex.i4.inc.c" + }, + { +#include "assets/misc/n64dd_error_textures/gN64DDPleaseReadManualENGTex.i4.inc.c" + }, +}; + +u8 D_801E1800[0x600]; +u8 D_801E1E00[0x2800]; +u8 D_801E4600[0x1400]; + +s32 func_801CA3E0(s32 arg0) { + s32 temp_t6; + s32 var_a1; + s32 var_a2; + s32 var_a2_2; + s32 var_v0; + s32 var_v1; + + var_v0 = 0; + var_v1 = 0; + if (arg0 < 0xA) { + return arg0; + } + var_a1 = 1; + if (arg0 >= 0xA) { + var_a2_2 = 0xA; + do { + var_a1 = var_a2_2; + var_v0 += 1; + var_a2_2 *= 0xA; + } while (arg0 >= var_a2_2); + } + var_a2 = arg0; + while (var_v0--) { + temp_t6 = var_a2 / var_a1; + var_v1 = (var_v1 | temp_t6) * 0x10; + var_a2 = var_a2 % var_a1; + var_a1 = var_a1 / 10; + } + return var_v1 + var_a2; +} + +s32 func_801CA4B8(void) { + return gCurrentRegion == REGION_JP ? 0 : 1; +} + +void func_801CA4E4(u8* arg0, u8 arg1, s32 arg2) { + while (arg2--) { + *arg0++ = arg1; + } +} + +const char* func_801CA514(void) { + return gN64DDLocalizedErrorNumberHeaders[func_801CA4B8()]; +} + +void func_801CA544(const char* arg0, s32 arg1) { + s32 temp_v0; + u16 var_a1; + + temp_v0 = func_801CA3E0(arg1); + if (arg1 >= 0xA) { + var_a1 = ((temp_v0 >> 4) + 0xA3B0); + } else { + var_a1 = 0xA1A1; + } + func_801C9D68((char*)arg0, var_a1); + arg0 += 2; + func_801C9D68((char*)arg0, ((temp_v0 & 0xF) + 0xA3B0)); +} + +void func_801CA5C4(char* arg0, s32 arg1) { + s32 temp_v0; + + temp_v0 = func_801CA3E0(arg1); + if (arg1 >= 0xA) { + *arg0 = (temp_v0 >> 4) + 0x30; + } else { + *arg0 = 0x20; + } + arg0++; + *arg0 = (temp_v0 & 0xF) + 0x30; +} + +void func_801CA628(void* arg0, s32 arg1) { + const char* temp_v0; + + temp_v0 = func_801CA514(); + if (gCurrentRegion == REGION_JP) { + func_801CA544((char*)(temp_v0 + 0xC), arg1); + } else { + func_801CA5C4((char*)(temp_v0 + 0xD), arg1); + } + func_801CA280(arg0, 0xC0, temp_v0); +} + +void* func_801CA698(s32 arg0) { + func_801CA730(); + if (arg0 == LEO_ERROR_DEVICE_COMMUNICATION_FAILURE) { + return D_801D3860[func_801CA4B8()]; + } + if (((arg0 >= LEO_ERROR_WAITING_NMI) && (arg0 < LEO_ERROR_DEVICE_COMMUNICATION_FAILURE)) || + (arg0 == LEO_ERROR_INVALID_COMMAND_OPERATION_CODE) || (arg0 == LEO_ERROR_LBA_OUT_OF_RANGE)) { + return D_801E1800; + } else { + func_801CA628(D_801E1800, arg0); + return D_801E1800; + } +} + +void* func_801CA730(void) { + func_801CA4E4(D_801E1800, 0, sizeof(D_801E1800)); + return D_801E1800; +} + +void func_801CA764(void* arg0, s32 arg1, s32 arg2) { + s32 var_s0; + + for (var_s0 = 0; var_s0 < arg2; var_s0++) { + func_801CA280(arg0, 0x140, D_801D3760[func_801CA4B8()][arg1][var_s0]); + arg0 = (char*)arg0 + 0xA00; + if (1) {} + } +} + +void* func_801CA800(s32 arg0) { + func_801CA86C(); + if (arg0 == 3) { + return D_801D4460[func_801CA4B8()]; + } + func_801CA764(D_801E1E00, arg0, 4); + return D_801E1E00; +} + +void* func_801CA86C(void) { + func_801CA4E4(D_801E1E00, 0, sizeof(D_801E1E00)); + return D_801E1E00; +} + +UNK_PTR func_801CA8A0(s32 arg0) { + func_801CA8E0(); + func_801CA764(D_801E4600, arg0, 2); + return D_801E4600; +} + +void* func_801CA8E0(void) { + func_801CA4E4(D_801E4600, 0, sizeof(D_801E4600)); + return D_801E4600; +} diff --git a/src/n64dd/n64dd_7.c b/src/n64dd/n64dd_7.c new file mode 100644 index 00000000000..6c4244d6ee0 --- /dev/null +++ b/src/n64dd/n64dd_7.c @@ -0,0 +1,243 @@ +/** + * Some sort of GfxPrint like utility? + */ + +#include "ultra64.h" +#include "n64dd.h" +#include "n64dd_internal.h" +#include "libc64/aprintf.h" +#include "attributes.h" +#include "color.h" + +typedef struct struct_801CAF10 { + /* 0x00 */ PrintCallback callback; + /* 0x04 */ u8* unk4; + /* 0x08 */ u16 unk8; + /* 0x0A */ u16 posX; + /* 0x0C */ u16 posY; + /* 0x0E */ char padE[2]; + /* 0x10 */ Color_RGBA8_u32 color; + /* 0x14 */ u16 baseX; + /* 0x16 */ u16 baseY; + /* 0x18 */ u16 unk18; + /* 0x1A */ u16 unk1A; + /* 0x1C */ u8 unk1C; + /* 0x1D */ char pad1D[3]; + /* 0x20 */ s16* unk20; + /* 0x24 */ u16 unk24; + /* 0x26 */ u16 unk26; +} struct_801CAF10; /* size = 0x28 */ + +u32 D_801D9460[0x5F] = { + 0x9D14, 0x232A14, 0x296314, 0x2F8A14, 0x457E18, 0x63CA14, 0x84AA14, 0xA03314, 0xA45E14, + 0xBB4E14, 0xCA6514, 0xD3770E, 0xE33302, 0xE78108, 0xEB2102, 0xEC6C14, 0x01008A14, 0x01163A14, + 0x01217A14, 0x01377A14, 0x014D8A14, 0x01638A14, 0x01798A14, 0x018F7A14, 0x01A58A14, 0x01BB8A14, 0x01D1170E, + 0x01D5490E, 0x01DF770E, 0x01EF740A, 0x01F9770E, 0x02097A14, 0x021FDC16, 0x024DBA14, 0x026E7A14, 0x0284BA14, + 0x02A59A14, 0x02C16A14, 0x02D26A14, 0x02E3BA14, 0x03048A14, 0x031A1A14, 0x03206A14, 0x03318A14, 0x03476A14, + 0x0358CA14, 0x03799A14, 0x0395CA14, 0x03B67A14, 0x03CCCA14, 0x03ED8A14, 0x04037A14, 0x04196A14, 0x042A8A14, + 0x0440AA14, 0x045CDA14, 0x04839A14, 0x049F9A14, 0x04BB7A14, 0x04D14D14, 0x04DF5C14, 0x04F33D14, 0x05015216, + 0x050681FA, 0x050A9D14, 0x052D9810, 0x05449A14, 0x05609810, 0x05779A14, 0x05939810, 0x05AA5A14, 0x05BB9C10, + 0x05DC7A14, 0x05F22A14, 0x05F83D14, 0x06067A14, 0x061C2A14, 0x0622D810, 0x06427810, 0x06549810, 0x066B9B10, + 0x06899B10, 0x06A74810, 0x06B06810, 0x06BE5A14, 0x06CF770E, 0x06DF870E, 0x06EFB70E, 0x0707670E, 0x07138A0E, + 0x0729670E, 0x07356D14, 0x074A1F16, 0x07526D14, 0x07675216, +}; + +s32 func_801CA920(s32 arg0, u8* arg1, int* arg2, int* arg3, int* arg4) { + s32 var_s0; + OSPiHandle* sp58; + OSMesgQueue sp40; + void* sp3C; + OSIoMesg sp24; + + sp58 = osDriveRomInit(); + if ((arg0 >= 0x20) && (arg0 < 0x7F)) { + var_s0 = LeoGetAAdr2(D_801D9460[arg0 - 0x20], arg2, arg3, arg4); + } else if (arg0 >= 0x8140) { + var_s0 = LeoGetKAdr(arg0); + *arg2 = 0x10; + *arg3 = 0x10; + *arg4 = 0xB; + } else { + return -1; + } + osCreateMesgQueue(&sp40, &sp3C, 1); + // clang-format off + sp24.hdr.retQueue = &sp40; sp24.devAddr = var_s0 + 0xA0000; sp24.dramAddr = (void*)arg1; sp24.hdr.pri = 0; sp24.size = 0x80; + // clang-format on + sp58->transferInfo.cmdType = 2; + osEPiStartDma(sp58, &sp24, OS_READ); + osRecvMesg(&sp40, NULL, OS_MESG_BLOCK); + return 0; +} + +const u16 D_801D9C10[0x10] = { + 0x0001, 0x1085, 0x2109, 0x318D, 0x4211, 0x5295, 0x6319, 0x739D, + 0x8C63, 0x9CE7, 0xAD6B, 0xBDEF, 0xCE73, 0xDEF7, 0xEF7B, 0xFFFF, +}; + +u16 func_801CAA44(s32 arg0) { + return D_801D9C10[arg0 & 0xF]; +} + +void func_801CAA60(u8* arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s16* arg6, s32 arg7) { + s32 var_a0; + s32 var_s0; + u8* var_s1; + s32 var_s5; + s16* var_s2; + + var_s1 = arg0; + var_s2 = arg6; + for (var_s5 = 0; var_s5 < arg4; var_s5++) { + for (var_s0 = 0; var_s0 < arg3; var_s0++) { + if (!(var_s0 & 1)) { + var_a0 = (s32)*var_s1 >> 4; + } else { + var_a0 = *var_s1 & 0xF; + var_s1 += 1; + } + var_s2[arg1 + (((arg2 - arg5) + var_s5 + 0xB) * arg7) + var_s0] = func_801CAA44(var_a0); + } + if (arg3 & 1) { + var_s1 += 1; + } + } +} + +void func_801CAB68(struct_801CAF10* arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { + arg0->color.r = arg1; + arg0->color.g = arg2; + arg0->color.b = arg3; + arg0->color.a = arg4; +} + +void func_801CAB84(struct_801CAF10* arg0, s32 arg1, s32 arg2) { + arg0->posX = (s16)(arg0->baseX + arg1); + arg0->posY = (s16)(arg0->baseY + arg2); +} + +void func_801CABA4(struct_801CAF10* arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { + arg0->baseX = (u16)arg1; + arg0->baseY = (u16)arg2; + arg0->unk18 = (u16)arg3; + arg0->unk1A = (u16)arg4; +} + +void func_801CABC0(struct_801CAF10* arg0, s16* arg1, s32 arg2, s32 arg3) { + arg0->unk20 = (s16*)((uintptr_t)arg1 + 0x20000000); + arg0->unk24 = (u16)arg2; + arg0->unk26 = (u16)arg3; + func_801CABA4(arg0, 0, 0, arg2 - 1, arg3 - 1); +} + +void func_801CAC24(struct_801CAF10* arg0, u8* arg1, s32 arg2) { + arg0->unk4 = (u8*)((uintptr_t)arg1 + 0x20000000); + arg0->unk8 = arg2; +} + +void func_801CAC3C(struct_801CAF10* arg0, u8 arg1) { + s32 var_a0; + int sp48; + int sp44; + int sp40; + s32 var_v0; + + if (arg0->unk1C != 0) { + var_a0 = (arg0->unk1C << 8) | arg1; + } else { + if ((arg1 >= 0x80) && (arg1 < 0x99)) { + arg0->unk1C = (u8)arg1; + return; + } + var_a0 = arg1; + } + arg0->unk1C = 0; + if (func_801CA920(var_a0, arg0->unk4, &sp48, &sp44, &sp40) == 0) { + if ((s32)arg0->unk18 < (arg0->posX + sp48)) { + arg0->posX = arg0->baseX; + if ((s32)arg0->unk1A < arg0->posY + 0x10) { + arg0->posY = arg0->baseY; + } else { + arg0->posY = arg0->posY + 0x10; + } + } + func_801CAA60(arg0->unk4, arg0->posX, arg0->posY, sp48, sp44, sp40, arg0->unk20, (s32)arg0->unk24); + if (sp48 == 0x10) { + var_v0 = sp48; + } else { + var_v0 = sp48 + 2; + } + arg0->posX += var_v0; + } +} + +void func_801CAD64(struct_801CAF10* arg0, u8 arg1) { + if ((arg1 >= 0x20) && (arg1 < 0x100)) { + func_801CAC3C(arg0, arg1); + } else { + switch (arg1) { + case 0: + break; + case 0xA: + arg0->posY += 0x20; + FALLTHROUGH; + case 0xD: + arg0->posX = arg0->baseX; + break; + case 9: + do { + func_801CAC3C(arg0, 0x20); + } while ((arg0->posX - arg0->baseX) % 256); + break; + } + } +} + +void func_801CAE2C(struct_801CAF10* arg0, const char* arg1, s32 arg2, size_t arg3) { + const char* var_s0; + s32 var_s1; + + var_s0 = arg1; + for (var_s1 = arg2 * arg3; var_s1 != 0; var_s1--) { + func_801CAD64(arg0, *var_s0++); + } +} + +void func_801CAE88(struct_801CAF10* arg0, u8* arg1) { + while (*arg1 != 0) { + func_801CAD64(arg0, *arg1++); + } +} + +void* func_801CAEE0(void* arg0, const char* arg1, size_t arg2) { + func_801CAE2C(arg0, arg1, 1, arg2); + return arg0; +} + +void func_801CAF10(struct_801CAF10* arg0) { + arg0->callback = func_801CAEE0; + arg0->posX = 0; + arg0->posY = 0; + arg0->baseX = 0; + arg0->baseY = 0; + arg0->unk18 = 0; + arg0->unk1A = 0; + arg0->color.rgba = 0; + arg0->unk1C = 0; + arg0->unk4 = 0; +} + +void func_801CAF48(struct_801CAF10* arg0) { +} + +void func_801CAF54(struct_801CAF10* arg0, const char* arg1, va_list arg2) { + PrintUtils_VPrintf(&arg0->callback, arg1, arg2); +} + +void func_801CAF74(struct_801CAF10* arg0, const char* arg1, ...) { + va_list varargs; + + va_start(varargs, arg1); + func_801CAF54(arg0, arg1, varargs); + va_end(varargs); +} diff --git a/src/n64dd/n64dd_801C8000.c b/src/n64dd/n64dd_801C8000.c deleted file mode 100644 index f2f4201c0ca..00000000000 --- a/src/n64dd/n64dd_801C8000.c +++ /dev/null @@ -1,350 +0,0 @@ -// Does some command processing - -#include "n64dd.h" - -#include "array_count.h" -#include "attributes.h" -#include "stack_pad.h" -#include "versions.h" -#include "z_locale.h" - -void func_801C8554(void); -void func_801C8578(void* arg0, void* arg1, OSId id, void* sp, OSPri pri); -void func_801C8638(void (*arg0)(void*, void*, void*), s32 arg1, void (*arg2)(void*, uintptr_t, size_t)); -void func_801C868C(void* arg0, void* arg1, void* arg2, u8 arg3); -s8 func_801C8770(void); -s32 func_801C87C0(void); -s32 func_801C87FC(void); -s32 func_801C8844(void); -s32 func_801C885C(void); -s32 func_801C88AC(void); -s32 func_801C88FC(void); - -s32 D_801D2E60 = 0; -s32 D_801D2E64 = 0; - -typedef struct struct_801D2E68 { - /* 0x0 */ void (*unk_0)(struct_801E0D18*); - /* 0x4 */ s32 (*unk_4)(struct_801E0D18*); -} struct_801D2E68; // size = 0x8 - -struct_801D2E68 D_801D2E68[5] = { - { func_801C81EC, func_801C91E0 }, { func_801C832C, func_801C9260 }, { func_801C83A0, func_801C9260 }, - { func_801C8414, func_801C9334 }, { func_801C8414, func_801C93C4 }, -}; - -s32 D_801D2E90 = 0; - -OSMesgQueue* B_801E0D10[2]; -struct_801E0D18 B_801E0D18; -OSMesg B_801E0D88[1]; -OSMesg B_801E0D90[8]; -OSThread B_801E0DB0; - -s32 func_801C8000(struct_801D9D50* arg0) { - switch (arg0->unk_00) { - case 0: - if (func_801C8844() != 0) { - return 1; - } - func_801C8554(); - break; - case 1: - func_801C8578(arg0->unk_1C, arg0->unk_20, arg0->unk_24, arg0->unk_28, arg0->unk_2C); - break; - case 2: - func_801C8638(arg0->unk_0C, arg0->unk_10, arg0->unk_14); - break; - case 3: - if (func_801C8844() != 0) { - return 1; - } - func_801C868C(arg0->unk_18, arg0->unk_1C, arg0->unk_20, 1); - break; - case 4: - if (func_801C8844() != 0) { - return 1; - } - func_801C868C(arg0->unk_18, arg0->unk_1C, arg0->unk_20, 2); - break; - case 5: - arg0->unk_08 = func_801C8770(); - return arg0->unk_08; - case 7: - return func_801C87FC(); - case 6: - return func_801C8844(); - case 8: - arg0->unk_04 = func_801C87C0(); - return arg0->unk_04; - case 9: - return func_801C885C(); - case 10: - return func_801C88AC(); - case 11: - return func_801C88FC(); - case 12: - D_801D2EA0 = 0; - break; - case 13: - D_801D2EA0 = 1; - break; - } - return 0; -} - -void func_801C819C(s32 arg0) { - if (arg0 != 0) { - D_801D2E60 = 1; - } else { - D_801D2E60 = 2; - } -} - -s32 func_801C81C4(void) { - return D_801D2E60; -} - -s32 func_801C81D4(void) { - return D_801D2E64 == 1; -} - -void func_801C81EC(struct_801E0D18* arg0) { - osCreateMesgQueue(&arg0->unk_1C, B_801E0D88, ARRAY_COUNT(B_801E0D88)); - - if (gCurrentRegion == 1) { - arg0->unk_68 = LeoCJCreateLeoManager(LEO_PRIORITY_WRK, LEO_PRIORITY_INT, B_801E0D90, ARRAY_COUNT(B_801E0D90)); - } else { - arg0->unk_68 = LeoCACreateLeoManager(LEO_PRIORITY_WRK, LEO_PRIORITY_INT, B_801E0D90, ARRAY_COUNT(B_801E0D90)); - } - - if ((arg0->unk_68 == LEO_ERROR_DEVICE_COMMUNICATION_FAILURE) || (arg0->unk_68 == LEO_ERROR_GOOD)) { - D_801D2E64 = 1; - } -} - -void func_801C8298(struct_801E0D18* arg0) { - LEOCmd sp1C; - - // TODO: passing a pointer as a logical block address? - LeoSeek(&sp1C, (u32)&arg0->diskId, &arg0->unk_1C); - osRecvMesg(&arg0->unk_1C, (OSMesg*)&arg0->unk_68, OS_MESG_BLOCK); -} - -void func_801C82E0(struct_801E0D18* arg0) { - LEOCmd sp1C; - - LeoSpdlMotor(&sp1C, 4, &arg0->unk_1C); - osRecvMesg(&arg0->unk_1C, (OSMesg*)&arg0->unk_68, OS_MESG_BLOCK); -} - -void func_801C832C(struct_801E0D18* arg0) { - s32 sp34; - s32 startLBA = arg0->unk_5C; - - if (LeoByteToLBA(startLBA, arg0->unk_60, &sp34) == LEO_ERROR_GOOD) { - OSMesgQueue* sp28 = &arg0->unk_1C; - - LeoReadWrite(&arg0->unk_00, OS_READ, startLBA, (void*)arg0->unk_58, sp34, sp28); - osRecvMesg(sp28, (OSMesg*)&arg0->unk_68, OS_MESG_BLOCK); - } -} - -void func_801C83A0(struct_801E0D18* arg0) { - s32 sp34; - s32 startLBA = arg0->unk_58; - - if (LeoByteToLBA(startLBA, arg0->unk_60, &sp34) == LEO_ERROR_GOOD) { - OSMesgQueue* sp28 = &arg0->unk_1C; - - LeoReadWrite(&arg0->unk_00, OS_WRITE, startLBA, (void*)arg0->unk_5C, sp34, sp28); - osRecvMesg(sp28, (OSMesg*)&arg0->unk_68, OS_MESG_BLOCK); - } -} - -void func_801C8414(struct_801E0D18* arg0) { - arg0->unk_68 = 9; -} - -void func_801C8424(struct_801E0D18* arg0) { - struct_801D2E68* temp_v0; - s32 (*temp_s2)(struct_801E0D18*); - void (*aux)(struct_801E0D18*); - s32 temp_v0_2; - - arg0->unk_68 = -1; - if ((func_801C81D4() != 0) || (arg0->unk_64 == 0)) { - arg0->unk_66 = 1; - temp_v0 = &D_801D2E68[arg0->unk_64]; - aux = temp_v0->unk_0; - temp_s2 = temp_v0->unk_4; - do { - aux(arg0); - temp_v0_2 = temp_s2(arg0); - } while (temp_v0_2 == 2); - arg0->unk_6C = temp_v0_2; - if (arg0->unk_64 == 0) { - func_801C819C(temp_v0_2); - } - arg0->unk_66 = 0; - } -} - -void func_801C84D4(UNUSED void* arg) { - while (true) { - struct_801E0D18* sp24; - - osRecvMesg(B_801E0D10[0], (OSMesg*)&sp24, OS_MESG_BLOCK); - func_801C8424(sp24); - osSendMesg(B_801E0D10[1], NULL, OS_MESG_BLOCK); - } -} - -void func_801C8554(void) { - osDestroyThread(&B_801E0DB0); -} - -void func_801C8578(void* arg0, void* arg1, OSId id, void* sp, OSPri pri) { - B_801E0D10[0] = (OSMesgQueue*)arg0; - B_801E0D10[1] = (OSMesgQueue*)arg1; - osCreateThread(&B_801E0DB0, id, &func_801C84D4, NULL, sp, pri); - osStartThread(&B_801E0DB0); -} - -void func_801C85F0(struct_801E0D18* arg0, s32 arg1) { - if (arg1 == 1) { - func_801C8424(arg0); - } else { - osSendMesg(B_801E0D10[0], arg0, OS_MESG_BLOCK); - } -} - -void func_801C8638(void (*arg0)(void*, void*, void*), s32 arg1, void (*arg2)(void*, uintptr_t, size_t)) { - s32 var0 = 0; - - func_801C9B50(arg1, arg2); - D_801D2EB4 = arg0; - B_801E0D18.unk_64 = var0; - B_801E0D18.unk_65 = var0; - func_801C85F0(&B_801E0D18, 0); -} - -void func_801C868C(void* arg0, void* arg1, void* arg2, u8 arg3) { - s32 var0 = (s32)arg0; - s32 var1 = (s32)arg1; - s32 var2 = (s32)arg2; - s32 var3 = arg3; - s32 var4 = 4; - - if (D_801D2E90 == 1) { - D_801D2E90 = 0; - B_801E0D18.unk_64 = var4; - func_801C85F0(&B_801E0D18, 1); - if (B_801E0D18.unk_6C == 3 || B_801E0D18.unk_6C == 4) { - return; - } - } - - B_801E0D18.unk_58 = var0; - B_801E0D18.unk_5C = var1; - B_801E0D18.unk_60 = var2; - B_801E0D18.unk_64 = var3; - func_801C85F0(&B_801E0D18, 0); -} - -s32 func_801C873C(struct_801E0D18* arg0) { - u8 sp1F; - - arg0->unk_68 = LeoTestUnitReady(&sp1F); - return !(sp1F & LEO_TEST_UNIT_MR); -} - -s8 func_801C8770(void) { - s32 temp = func_801C873C(&B_801E0D18); - - if (B_801E0D18.unk_68 == LEO_ERROR_BUSY) { - return 0; - } - - if (!temp) { - return 2; - } - - return 1; -} - -s32 func_801C87C0(void) { - if (func_801C8844() == 0) { - if (B_801E0D18.unk_68 != 0) { - return B_801E0D18.unk_68; - } - } - - return -1; -} - -s32 func_801C87FC(void) { - s32* new_var = &B_801E0D18.unk_68; - s32 temp_v0; - - if (func_801C8844() == 0) { - temp_v0 = B_801E0D18.unk_6C; - - if ((temp_v0 == 3) || (temp_v0 == 4)) { - return *new_var; - } - } - - return 0; -} - -s32 func_801C8844(void) { - return B_801E0D18.unk_66 == 1; -} - -s32 func_801C885C(void) { - B_801E0D18.unk_64 = 3; - func_801C85F0(&B_801E0D18, 1); - -#if OOT_VERSION >= NTSC_1_1 - D_801D2E90 = 0; -#endif - - if ((B_801E0D18.unk_6C == 3) || (B_801E0D18.unk_6C == 4)) { - return -1; - } - return B_801E0D18.unk_6C == 0; -} - -s32 func_801C88AC(void) { - STACK_PAD(s32); - - B_801E0D18.unk_64 = 4; - func_801C85F0(&B_801E0D18, 1); - -#if OOT_VERSION >= NTSC_1_1 - D_801D2E90 = 0; -#endif - - if ((B_801E0D18.unk_6C == 3) || (B_801E0D18.unk_6C == 4)) { - return -1; - } - return B_801E0D18.unk_6C == 0; -} - -s32 func_801C88FC(void) { - s32 temp = 0; - s32 phi_v1; - - if (LeoDriveExist()) { - phi_v1 = 8; - } else { - phi_v1 = 0; - } - - temp = phi_v1 == temp; - - B_801E0D18.unk_68 = phi_v1; - - return temp; -} diff --git a/src/n64dd/n64dd_801C8940.c b/src/n64dd/n64dd_801C8940.c deleted file mode 100644 index 988e81de169..00000000000 --- a/src/n64dd/n64dd_801C8940.c +++ /dev/null @@ -1,401 +0,0 @@ -// Lower-level command processing in a background thread -#include "n64dd.h" - -#include "libc64/sleep.h" -#include "attributes.h" -#include "stack_pad.h" - -s32 D_801D2EA0 = 0; -u8* D_801D2EA4 = NULL; -s32 D_801D2EA8 = 0; -u8* D_801D2EAC = NULL; -u8* D_801D2EB0 = NULL; -void (*D_801D2EB4)(void*, void*, void*) = NULL; - -s32 B_801E0F60; -s32 B_801E0F64; - -// Set error message title texture? -void func_801C8940(s32 errorNum) { - D_801D2EA4 = func_801C9E28(errorNum); - D_801D2EA8 = 1; -} - -// Clear error message title texture? -void func_801C8974(void) { - if (D_801D2EA8 == 1) { - D_801D2EA4 = func_801C9EC0(); - D_801D2EA8 = 0; - } -} - -// Set error message something -void func_801C89B8(s32 errorNum) { - D_801D2EAC = func_801C9F90(errorNum); - B_801E0F60 = 1; -} - -// Clear error message something -void func_801C89EC(void) { - if (B_801E0F60 == 1) { - D_801D2EAC = func_801C9FFC(); - B_801E0F60 = 0; - } -} - -// Set error message something -void func_801C8A30(s32 errorNum) { - D_801D2EB0 = func_801CA030(errorNum); - B_801E0F64 = 1; -} - -// Clear error message something -void func_801C8A64(void) { - if (B_801E0F64 == 1) { - D_801D2EB0 = func_801CA070(); - B_801E0F64 = 0; - } -} - -void func_801C8AA8(void) { - osRecvMesg(B_801E0D10[1], NULL, OS_MESG_NOBLOCK); - - if ((D_801D2EB4 != NULL) && (D_801D2EA0 == 0)) { - u32 temp_v0 = osSetIntMask(OS_IM_NONE); - void* sp20 = D_801D2EA4; - void* sp1C = D_801D2EAC; - void* sp18 = D_801D2EB0; - - D_801D2EA4 = NULL; - D_801D2EAC = NULL; - D_801D2EB0 = NULL; - osSetIntMask(temp_v0); - D_801D2EB4(sp20, sp1C, sp18); - } -} - -void func_801C8B58(s32 arg0, s32 arg1, s32 arg2) { - func_801C8940(arg0); - func_801C89B8(arg1); - func_801C8A30(arg2); -} - -void func_801C8B90(void) { - func_801C8974(); - func_801C89EC(); - func_801C8A64(); -} - -s32 func_801C8BC0(struct_801E0D18* arg0) { - if ((arg0->unk_68 < 0x25) || (arg0->unk_68 >= 0x29)) { - if ((arg0->unk_68 != 0x1F) && (arg0->unk_68 != 0x20)) { - func_801C8940(arg0->unk_68); - func_801C89B8(3); - } - } - LeoClearQueue(); - return 4; -} - -s32 func_801C8C1C(struct_801E0D18* arg0) { - s32 var_s0; - - do { - var_s0 = 0; - Sleep_Msec(60); - func_801C82E0(arg0); - - switch (arg0->unk_68) { - case 0x2A: - func_801C8A64(); - return 0; - case 0x22: - func_801C8A64(); - LeoClearQueue(); - return 3; - case 0: - func_801C8A30(6); - FALLTHROUGH; - case 0x23: - var_s0 = 1; - break; - } - } while (var_s0 != 0); - - func_801C8A64(); - return func_801C8BC0(arg0); -} - -s32 func_801C8CEC(struct_801E0D18* arg0) { - switch (arg0->unk_68) { - case 0x22: - func_801C8B90(); - LeoClearQueue(); - return 3; - case 0x2: - func_801C8940(arg0->unk_68); - func_801C8A30(5); - return 9; - case 0x0: - func_801C8B90(); - return 0; - case 0x2B: - if (arg0->unk_65 == 0) { - func_801C8B90(); - arg0->unk_65 = 2; - return 1; - } - FALLTHROUGH; - default: - func_801C8B90(); - return func_801C8BC0(arg0); - case 0x23: - return 9; - } -} - -s32 func_801C8DC0(struct_801E0D18* arg0) { - s32 temp_v0; - - while (true) { - func_801C8298(arg0); - switch (arg0->unk_68) { - case 0x31: - func_801C8940(arg0->unk_68); - func_801C89B8(2); - return 5; - case 0x2A: - func_801C8B90(); - return 5; - } - temp_v0 = func_801C8CEC(arg0); - if (temp_v0 != 9) { - return temp_v0; - } - Sleep_Msec(60); - } -} - -s32 func_801C8E70(struct_801E0D18* arg0) { - STACK_PAD(s32); - s32 temp_v0; - - while (true) { - Sleep_Msec(60); - func_801C8298(arg0); - - switch (arg0->unk_68) { - case 0x23: - continue; - case 0x31: - func_801C8940(arg0->unk_68); - func_801C89B8(2); - FALLTHROUGH; - case 0x2A: - func_801C8A30(4); - continue; - } - - temp_v0 = func_801C8CEC(arg0); - if (temp_v0 != 9) { - return temp_v0; - } - } -} - -s32 func_801C8F1C(struct_801E0D18* arg0) { - if (D_801D2E54 != NULL) { - return D_801D2E54(arg0); - } - return 1; -} - -s32 func_801C8F58(struct_801E0D18* arg0) { - s32 temp_v0; - - while (true) { - temp_v0 = func_801C8E70(arg0); - if (temp_v0 == 3 || temp_v0 == 4) { - return temp_v0; - } - - // Fake match? - if ((temp_v0 & 0xFFFFFFFF) == 0) { - if (func_801C8F1C(arg0) != 0) { - return 2; - } - func_801C89B8(1); - temp_v0 = func_801C8C1C(arg0); - if (temp_v0 != 0) { - return temp_v0; - } - func_801C89EC(); - } - } -} - -s32 func_801C9000(struct_801E0D18* arg0) { - s32 phi_s0; - s32 temp_s4; - - while (true) { - phi_s0 = func_801C8E70(arg0); - if (phi_s0 == 3 || phi_s0 == 4) { - return phi_s0; - } - - // Fake match? - if ((phi_s0 & 0xFFFFFFFF) == 0) { - func_801C8B90(); - - temp_s4 = func_801C8F1C(arg0); - if (temp_s4 == 3 || temp_s4 == 4) {} - if (temp_s4 != 0) { - return 2; - } - - func_801C89B8(1); - - phi_s0 = func_801C8C1C(arg0); - if (phi_s0 == 3 || phi_s0 == 4) {} - if (phi_s0 != 0) { - return phi_s0; - } - - func_801C89EC(); - if (temp_s4 != 0) { - return phi_s0; - } - } - } -} - -s32 func_801C90C4(struct_801E0D18* arg0) { - func_801C8940(arg0->unk_68); - func_801C89B8(2); - return func_801C9000(arg0); -} - -s32 func_801C90FC(struct_801E0D18* arg0) { - func_801C8940(arg0->unk_68); - return func_801C9000(arg0); -} - -s32 func_801C912C(struct_801E0D18* arg0) { - s32 i = 0; - s32 temp_v0; - - do { - LeoResetClear(); - - temp_v0 = func_801C8DC0(arg0); - if (temp_v0 == 3 || temp_v0 == 4) { - return temp_v0; - } - if (temp_v0 != 1) { - if (temp_v0 == 0) { - return temp_v0; - } else { - return temp_v0; - } - } - - Sleep_Msec(250); - } while (i++ < 30); - - return func_801C8BC0(arg0); -} - -s32 func_801C91E0(struct_801E0D18* arg0) { - if (arg0->unk_68 == 0x29) { - return func_801C8BC0(arg0); - } - - if (osMemSize < 0x800000) { - // LEO_ERROR_RAMPACK_NOT_CONNECTED? - func_801C8B58(0x2C, 0, 3); - return 4; - } - - if (func_801C912C(arg0) == 0) { - D_801D2E90 = 1; - } - return 0; -} - -s32 func_801C9260(struct_801E0D18* arg0) { - s32 temp_v0; - - switch (arg0->unk_68) { - case 0x17: - func_801C873C(arg0); - temp_v0 = func_801C8C1C(arg0); - if (temp_v0 != 0) { - return temp_v0; - } - func_801C8B90(); - return 2; - - case 0x2: - return func_801C8F58(arg0); - - case 0x22: - LeoClearQueue(); - return 3; - - case 0x31: - return func_801C90C4(arg0); - - case 0x2F: - return func_801C9000(arg0); - - case 0x2A: - return func_801C90FC(arg0); - - case 0x0: - return 0; - - case 0x23: - return 2; - } - - return func_801C8BC0(arg0); -} - -s32 func_801C9334(struct_801E0D18* arg0) { - while (true) { - u32 temp_v0 = func_801C8DC0(arg0); - - if (temp_v0 == 3 || temp_v0 == 4 || temp_v0 == 5) { - return temp_v0; - } - - // Fake match? - if ((temp_v0 & 0xFFFFFFFF) == 0) { - if (func_801C8F1C(arg0) != 0) { - return 0; - } - return 7; - } - - if (1) {} - } -} - -s32 func_801C93C4(struct_801E0D18* arg0) { - s32 temp_v0; - s32 temp_v0_2; - - while (true) { - temp_v0_2 = func_801C9334(arg0); - if (temp_v0_2 != 7) { - return temp_v0_2; - } - func_801C89B8(1); - temp_v0 = func_801C8C1C(arg0); - if (temp_v0 != 0) { - return temp_v0; - } - func_801C89EC(); - } -} diff --git a/src/n64dd/n64dd_801C9440.c b/src/n64dd/n64dd_801C9440.c deleted file mode 100644 index ecab855d4ae..00000000000 --- a/src/n64dd/n64dd_801C9440.c +++ /dev/null @@ -1,263 +0,0 @@ -// Some text-handling functions -#include "n64dd.h" -#include "versions.h" - -void (*D_801D2EC0)(void*, uintptr_t, size_t) = NULL; - -s32 B_801E0F70; - -/** - * Seems to work out if a pair of bytes is a valid EUC-JP character, although there may be additions to the font that - * make the strange first check make more sense. - * - * @param bytes Array 2 bytes to test - * @return boolean - */ -int func_801C9440(u8* bytes) { - // This is every possible first byte. May make more sense what was intended with the font files? - if (((*bytes >= 0x8E) && (*bytes <= 0xFE)) || ((*bytes != 0x8F) && (*bytes != 0xA0))) { - bytes++; - return (*bytes >= 0xA0) && (*bytes <= 0xFE); - } - return false; -} - -/** - * A crude check for a valid 2-byte Shift-JIS character - * - * @param bytes Array containing a pair of bytes to test - * @return boolean - */ -int func_801C9494(u8* bytes) { - // Allowable first bytes. - if (((*bytes >= 0x81) && (*bytes <= 0x9F)) || ((*bytes >= 0xE0) && (*bytes <= 0xFC))) { - bytes++; - // Allowable second bytes. - return (*bytes >= 0x40) && (*bytes <= 0xFC) && *bytes != 0x7F; - } - return false; -} - -// Extracts 2 bytes from a bytepacked big-endian short. -void func_801C94F8(u8* arg0, u16 arg1) { - arg0[0] = arg1 >> 8; - arg0[1] = arg1 & 0xFF; -} - -// Convert EUC-JP to JIS X 0208 -u16 func_801C9514(u16 eucjpCh) { - return eucjpCh - 0x8080; -} - -/** - * Converts a JIS X 0208 codepoint to a Shift-JIS one. - * - * @param jisCodepoint Two bytes, each between 0x21 and 0x7E, packed big-endian into a short. - * @return u16 Shift-JIS character representation (expected to be big-endian) - */ -u16 func_801C9534(u16 jisCodepoint) { - u8 hiByte = (jisCodepoint >> 8) & 0xFF; - u8 loByte = jisCodepoint & 0xFF; - - if (hiByte & 1) { - loByte += 0x1F; - if (loByte >= 0x7F) { - loByte++; - } - } else { - loByte += 0x7E; - } - - hiByte = (hiByte - 0x21) / 2 + 0x81; - if (hiByte >= 0xA0) { - hiByte += 0x40; - } - - return (hiByte << 8) + loByte; -} - -void func_801C95C0(void* arg0, uintptr_t arg1, size_t arg2) { - if (D_801D2EC0 != NULL) { - D_801D2EC0(arg0, arg1, arg2); - } -} - -s32 func_801C95F0(u8* arg0) { - return LeoGetKAdr(func_801C9534(func_801C9514((arg0[0] << 8) | arg0[1]))) + DDROM_FONT_START; -} - -s32 func_801C963C(s32* arg0, int* dx, int* dy, int* cy, u8 arg4) { - s32 temp_v0; - s32 temp_v1; - - u16 temp = arg4 - 0x20; - temp += 0xC0 * B_801E0F70; - - temp_v0 = LeoGetAAdr(temp, dx, dy, cy); - temp_v1 = temp_v0 & 0xF; - *arg0 = (temp_v0 - temp_v1) + DDROM_FONT_START; - return temp_v1; -} - -s32 func_801C969C(void* arg0, int* dx, int* dy, int* cy, u8* arg4) { - s32 sp24; - s32 phi_v1; - - if (func_801C9440(arg4)) { - sp24 = func_801C95F0(arg4); - *dx = 16; - *dy = 16; - *cy = 11; - phi_v1 = 0; - } else { - phi_v1 = func_801C963C(&sp24, dx, dy, cy, *arg4); - } - - func_801C95C0(arg0, sp24, 0x80); - return phi_v1; -} - -// return boolean -s32 func_801C9740(u8* arg0, s32 arg1, u8 arg2) { - if (arg1 == 1) { - *arg0 = arg2 << 4; - return false; - } else { - *arg0 |= arg2; - return true; - } -} - -u8* func_801C9778(u8* arg0, s32* arg1, s32 arg2) { - arg0 += (arg2 >> 1); - - if (((*arg1 == 1) && !(arg2 & 1)) || ((*arg1 == 0) && (arg2 & 1))) { - arg0 += arg2 & 1; - *arg1 = 1; - } else { - *arg1 = 0; - } - return arg0; -} - -s32 func_801C97C4(u8** arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, u8* arg5, s32 dx, s32 dy, s32 cy) { - u8* var_fp; - u8* var_s0; - s32 var_s1; - s32 x; - s32 sp4C; - s32 var_s4; - s32 sp44; - - sp4C = arg2; - sp44 = dx + arg3 + arg4; - var_s4 = 1; - var_fp = func_801C9778(*arg0, &sp4C, arg3); - arg1 >>= 1; - var_fp += ((11 - cy) * arg1); - if (dx & 1) { - dx++; - } - while (dy--) { - var_s0 = var_fp; - var_s1 = sp4C; - for (x = 0; x < dx; x++) { - if (var_s4 == 1) { - if (func_801C9740(var_s0, var_s1, *arg5 >> 4)) { - var_s0++; - } - } else { - if (func_801C9740(var_s0, var_s1, *arg5 & 0xF)) { - var_s0++; - } - arg5++; - } - var_s4 ^= 1; - var_s1 ^= 1; - } - var_fp += arg1; - } - *arg0 = func_801C9778(*arg0, &arg2, sp44); - return arg2; -} - -void func_801C9954(u8* bytes, s32* arg1, s32* arg2) { - u8 prevCh; - u8 nextCh; - - if (func_801C9440(bytes)) { - *arg1 = *arg2 = 0; - return; - } - - *arg1 = *arg2 = 0; - - prevCh = bytes[-1]; - nextCh = bytes[1]; - - switch (bytes[0]) { - case ' ': - *arg1 = *arg2 = 0; - return; - - case 'I': - case 'i': -#if OOT_NTSC - *arg2 = 2; - if (1) {} -#endif - - *arg1 = 2; - *arg2 = 2; - - if (prevCh == ' ') { - *arg1 = 0; - } - if (nextCh == ' ') { - *arg2 = 0; - } - return; - } - -#if OOT_NTSC - *arg2 = 1; - if (1) {} -#endif - - *arg1 = 1; - *arg2 = 1; -} - -void func_801C9A10(u8* arg0, s32 arg1, u8* str) { - u8 sp80[0xA0]; - u8* temp_s1; - int dx; - int dy; - int cy; - s32 var_s2; - s32 sp68; - s32 sp64; - s32 temp_v1; - - temp_s1 = (u8*)((((uintptr_t)&sp80 + 0xF) / 0x10) * 0x10); - var_s2 = 1; - if (str != NULL) { - while (*str != '\0') { - func_801C9954(str, &sp68, &sp64); - temp_v1 = func_801C969C(temp_s1, &dx, &dy, &cy, str); - if (dx & 1) { - dx++; - } - var_s2 = func_801C97C4(&arg0, arg1, var_s2, sp68, sp64, &temp_s1[temp_v1], dx, dy, cy); - if (func_801C9440(str)) { - str++; - } - str++; - } - } -} - -void func_801C9B50(s32 arg0, void (*arg1)(void*, uintptr_t, size_t)) { - B_801E0F70 = arg0; - D_801D2EC0 = arg1; -} diff --git a/src/n64dd/n64dd_801C9B70.c b/src/n64dd/n64dd_801C9B70.c deleted file mode 100644 index d11a7b13f86..00000000000 --- a/src/n64dd/n64dd_801C9B70.c +++ /dev/null @@ -1,172 +0,0 @@ -// User-facing error handling -#include "n64dd.h" -#include "z_locale.h" - -u8 B_801E0F80[0x600]; -u8 B_801E1580[0x2800]; -u8 B_801E3D80[0x1400]; - -/** - * Converts a number in decimal to a hexadecimal number with the same digits, e.g. 1234 -> 0x1234. - * - * Will only work on nonnegative numbers. - * - * @param decNumber Number in decimal to convert, e.g. 1234 - * @return s32 Hexadecimal number with the same digits as decNumber, e.g. 0x1234 - */ -s32 func_801C9B70(s32 decNumber) { - s32 currPlaceValue; - s32 currExponent = 0; - s32 accumulatedHexDigits = 0; - s32 remainingDecDigits; - - // Nothing to do if only one digit. - if (decNumber < 10) { - return decNumber; - } - - // Find the place value / exponent of the most significant digit in decNumber. - for (currPlaceValue = 1; 10 * currPlaceValue <= decNumber; currPlaceValue *= 10) { - currExponent++; - } - - remainingDecDigits = decNumber; - - // Transfer the digits to hex one at a time. - while (currExponent--) { - // Place the most significant remaining digit at the end of the hex output. - accumulatedHexDigits |= remainingDecDigits / currPlaceValue; - accumulatedHexDigits *= 0x10; // Shift left one hex digit. - - remainingDecDigits %= currPlaceValue; // Remove most significant of the remaining digits. - - currPlaceValue /= 10; - } - - accumulatedHexDigits += remainingDecDigits; // Only one digit left in the remainingDecDigits. - return accumulatedHexDigits; -} - -// n64ddError_GetLanguage -s32 func_801C9C48(void) { - return (gCurrentRegion == 1) ? 0 : 1; -} - -// n64ddError_Memset -void func_801C9C74(u8* dest, u8 value, u32 count) { - while (count--) { - *dest++ = value; - } -} - -// n64ddError_GetErrorHeader -const char* func_801C9CA4(void) { - return gN64DDLocalizedErrorNumberHeaders[func_801C9C48()]; -} - -// n64ddError_WriteNumberJP -// Writes a 2-digit number to the char buffer provided -// Character indices for numbers in the error code (EUC-JP) -void func_801C9CD4(u8* buf, s32 number) { - s32 temp_v0 = func_801C9B70(number); - u16 character; - - if (number >= 10) { - character = ((temp_v0 >> 4) + 0xA3B0); // '0' - } else { - character = 0xA1A1; // ' ' - } - - func_801C94F8(buf, character); - buf += 2; - func_801C94F8(buf, ((temp_v0 & 0xF) + 0xA3B0)); // '0' -} - -// n64ddError_WriteNumberEN -// Writes a 2-digit number to the char buffer provided -// Character indices for numbers in the error code (ASCII) -void func_801C9D54(u8* buf, s32 number) { - s32 temp_v0 = func_801C9B70(number); - - if (number >= 10) { - *buf = (temp_v0 >> 4) + '0'; - } else { - *buf = ' '; - } - buf++; - *buf = (temp_v0 & 0xF) + '0'; -} - -void func_801C9DB8(u8* arg0, s32 errorNum) { - u8* errorHeader = (u8*)func_801C9CA4(); - - //! @bug both of these functions will write to the pointer target, but errorHeader points to a string literal, - //! which is meant to be const. - if (gCurrentRegion == 1) { - func_801C9CD4(&errorHeader[12], errorNum); - } else { - func_801C9D54(&errorHeader[13], errorNum); - } - func_801C9A10(arg0, 192, errorHeader); -} - -u8* func_801C9E28(s32 errorNum) { - func_801C9EC0(); - - if (errorNum == 41) { - return (u8*)gN64DDError41Texs[func_801C9C48()]; - } - - // 31,32, 37,38,39,40 - if (((errorNum >= 37) && (errorNum < 41)) || (errorNum == 31) || (errorNum == 32)) { - return B_801E0F80; - } else { - func_801C9DB8(B_801E0F80, errorNum); - return B_801E0F80; - } -} - -// Clear something -u8* func_801C9EC0(void) { - func_801C9C74(B_801E0F80, 0, 0x600); - return B_801E0F80; -} - -// Prints the error message body (?) -void func_801C9EF4(u8* arg0, s32 errorNum, s32 lineCount) { - s32 i; - - for (i = 0; i < lineCount; i++, arg0 += 0xA00) { - u8* line = (u8*)D_801D2EE0[func_801C9C48()][errorNum][i]; - - if (1) {} - func_801C9A10(arg0, 320, line); - } -} - -u8* func_801C9F90(s32 errorNum) { - func_801C9FFC(); - if (errorNum == 3) { - return (u8*)gN64DDPleaseReadManualTexs[func_801C9C48()]; - } - func_801C9EF4(B_801E1580, errorNum, 4); - return B_801E1580; -} - -// Clear something -u8* func_801C9FFC(void) { - func_801C9C74(B_801E1580, 0, 0x2800); - return B_801E1580; -} - -u8* func_801CA030(s32 errorNum) { - func_801CA070(); - func_801C9EF4(B_801E3D80, errorNum, 2); - return B_801E3D80; -} - -// Clear something -u8* func_801CA070(void) { - func_801C9C74(B_801E3D80, 0, 0x1400); - return B_801E3D80; -} diff --git a/src/n64dd/n64dd_801CA0B0.c b/src/n64dd/n64dd_801CA0B0.c deleted file mode 100644 index 52abf26e6aa..00000000000 --- a/src/n64dd/n64dd_801CA0B0.c +++ /dev/null @@ -1,247 +0,0 @@ -#include "n64dd.h" - -#include "libc64/aprintf.h" -#include "attributes.h" -#include "array_count.h" -#include "color.h" - -// Draws text to framebuffer -typedef struct struct_801CA704 { - /* 0x00 */ PrintCallback callback; - /* 0x04 */ void* charTexBuf; - /* 0x08 */ u16 unk_08; - /* 0x0A */ u16 posX; - /* 0x0C */ u16 posY; - /* 0x10 */ Color_RGBA8_u32 color; - /* 0x14 */ u16 baseX; - /* 0x16 */ u16 baseY; - /* 0x18 */ u16 endX; - /* 0x1A */ u16 endY; - /* 0x1C */ u8 sjisPrevByte; - /* 0x20 */ void* frameBuf; - /* 0x24 */ u16 screenWidth; - /* 0x26 */ u16 screenHeight; -} struct_801CA704; - -// clang-format off -u32 D_801D8BE0[0x5F] = { - 0x00009D14, 0x00232A14, 0x00296314, 0x002F8A14, 0x00457E18, 0x0063CA14, 0x0084AA14, 0x00A03314, - 0x00A45E14, 0x00BB4E14, 0x00CA6514, 0x00D3770E, 0x00E33302, 0x00E78108, 0x00EB2102, 0x00EC6C14, - 0x01008A14, 0x01163A14, 0x01217A14, 0x01377A14, 0x014D8A14, 0x01638A14, 0x01798A14, 0x018F7A14, - 0x01A58A14, 0x01BB8A14, 0x01D1170E, 0x01D5490E, 0x01DF770E, 0x01EF740A, 0x01F9770E, 0x02097A14, - 0x021FDC16, 0x024DBA14, 0x026E7A14, 0x0284BA14, 0x02A59A14, 0x02C16A14, 0x02D26A14, 0x02E3BA14, - 0x03048A14, 0x031A1A14, 0x03206A14, 0x03318A14, 0x03476A14, 0x0358CA14, 0x03799A14, 0x0395CA14, - 0x03B67A14, 0x03CCCA14, 0x03ED8A14, 0x04037A14, 0x04196A14, 0x042A8A14, 0x0440AA14, 0x045CDA14, - 0x04839A14, 0x049F9A14, 0x04BB7A14, 0x04D14D14, 0x04DF5C14, 0x04F33D14, 0x05015216, 0x050681FA, - 0x050A9D14, 0x052D9810, 0x05449A14, 0x05609810, 0x05779A14, 0x05939810, 0x05AA5A14, 0x05BB9C10, - 0x05DC7A14, 0x05F22A14, 0x05F83D14, 0x06067A14, 0x061C2A14, 0x0622D810, 0x06427810, 0x06549810, - 0x066B9B10, 0x06899B10, 0x06A74810, 0x06B06810, 0x06BE5A14, 0x06CF770E, 0x06DF870E, 0x06EFB70E, - 0x0707670E, 0x07138A0E, 0x0729670E, 0x07356D14, 0x074A1F16, 0x07526D14, 0x07675216, -}; -// clang-format on - -// Loads character texture to buffer -s32 func_801CA0B0(s32 charCode, void* charTexBuf, int* dx, int* dy, int* cy) { - s32 offset; - OSPiHandle* handle; - OSMesgQueue queue; - OSMesg msgBuf[1]; - OSIoMesg mesg; - - handle = osDriveRomInit(); - if (charCode >= 0x20 && charCode < 0x7F) { // ASCII - offset = LeoGetAAdr2(D_801D8BE0[charCode - 0x20], dx, dy, cy); - } else if (charCode >= 0x8140) { // Shift-JIS - offset = LeoGetKAdr(charCode); - *dx = 16; - *dy = 16; - *cy = 11; - } else { - return -1; - } - - osCreateMesgQueue(&queue, msgBuf, ARRAY_COUNT(msgBuf)); - - // clang-format off - mesg.hdr.retQueue = &queue; \ - mesg.devAddr = offset + DDROM_FONT_START; \ - mesg.dramAddr = charTexBuf; \ - mesg.size = 0x80; \ - mesg.hdr.pri = 0; - // clang-format on - - handle->transferInfo.cmdType = 2; - osEPiStartDma(handle, &mesg, 0); - osRecvMesg(&queue, NULL, OS_MESG_BLOCK); - - return 0; -} - -const u16 D_801D9390[16] = { - 0x0001, 0x1085, 0x2109, 0x318D, 0x4211, 0x5295, 0x6319, 0x739D, - 0x8C63, 0x9CE7, 0xAD6B, 0xBDEF, 0xCE73, 0xDEF7, 0xEF7B, 0xFFFF, -}; - -// Maps 4-bit intensity to a 16-bit color -u16 func_801CA1D4(u32 arg0) { - return D_801D9390[arg0 % ARRAY_COUNT(D_801D9390)]; -} - -void func_801CA1F0(void* charTexBuf, s32 posX, s32 posY, s32 dx, s32 dy, s32 cy, void* frameBuf, s32 screenWidth) { - s32 intensity; - s32 x; - s32 y; - u8* src = charTexBuf; - u16* dst = frameBuf; - - for (y = 0; y < dy; y++) { - for (x = 0; x < dx; x++) { - if (!(x & 1)) { - intensity = *src >> 4; - } else { - intensity = *src & 0xF; - src++; - } - dst[posX + x + ((posY + (11 - cy) + y) * screenWidth)] = func_801CA1D4(intensity); - } - if (dx & 1) { - src++; - } - } -} - -void func_801CA2F8(struct_801CA704* arg0, u32 r, u32 g, u32 b, u32 a) { - arg0->color.r = r; - arg0->color.g = g; - arg0->color.b = b; - arg0->color.a = a; -} - -void func_801CA314(struct_801CA704* arg0, s32 arg1, s32 arg2) { - arg0->posX = arg0->baseX + arg1; - arg0->posY = arg0->baseY + arg2; -} - -void func_801CA334(struct_801CA704* arg0, s32 baseX, s32 baseY, s32 endX, s32 endY) { - arg0->baseX = baseX; - arg0->baseY = baseY; - arg0->endX = endX; - arg0->endY = endY; -} - -void func_801CA350(struct_801CA704* arg0, void* frameBuf, s32 screenWidth, s32 screenHeight) { - arg0->frameBuf = (u8*)frameBuf + 0x20000000; - arg0->screenWidth = screenWidth; - arg0->screenHeight = screenHeight; - func_801CA334(arg0, 0, 0, screenWidth - 1, screenHeight - 1); -} - -void func_801CA3B4(struct_801CA704* arg0, void* charTexBuf, s32 arg2) { - arg0->charTexBuf = (u8*)charTexBuf + 0x20000000; - arg0->unk_08 = arg2; -} - -void func_801CA3CC(struct_801CA704* arg0, char c) { - s32 charCode; - int dx; - int dy; - int cy; - - if (arg0->sjisPrevByte != 0) { - charCode = (arg0->sjisPrevByte << 8) | c; - } else { - if (c >= 0x80 && c < 0x99) { - arg0->sjisPrevByte = c; - return; - } - charCode = c; - } - - arg0->sjisPrevByte = 0; - if (func_801CA0B0(charCode, arg0->charTexBuf, &dx, &dy, &cy) == 0) { - if (arg0->posX + dx > arg0->endX) { - arg0->posX = arg0->baseX; - if (arg0->posY + 16 > arg0->endY) { - arg0->posY = arg0->baseY; - } else { - arg0->posY += 16; - } - } - func_801CA1F0(arg0->charTexBuf, arg0->posX, arg0->posY, dx, dy, cy, arg0->frameBuf, arg0->screenWidth); - arg0->posX += (dx == 16 ? dx : dx + 2); - } -} - -void func_801CA4F4(struct_801CA704* arg0, char c) { - if (c >= ' ' && c <= 0xFF) { - func_801CA3CC(arg0, c); - } else { - switch (c) { - case '\n': - arg0->posY += 32; - FALLTHROUGH; - case '\r': - arg0->posX = arg0->baseX; - break; - case '\t': - do { - func_801CA3CC(arg0, ' '); - } while ((arg0->posX - arg0->baseX) % 256); - break; - case '\0': - break; - } - } -} - -void func_801CA5BC(struct_801CA704* arg0, const char* str, s32 arg2, size_t count) { - const char* s = str; - s32 n = arg2 * count; - - while (n != 0) { - func_801CA4F4(arg0, *s++); - n--; - } -} - -void func_801CA618(struct_801CA704* arg0, const char* str) { - while (*str != 0) { - func_801CA4F4(arg0, *str++); - } -} - -void* func_801CA670(void* arg, const char* str, size_t count) { - func_801CA5BC(arg, str, 1, count); - return arg; -} - -void func_801CA6A0(struct_801CA704* arg0) { - arg0->callback = &func_801CA670; - arg0->posX = 0; - arg0->posY = 0; - arg0->baseX = 0; - arg0->baseY = 0; - arg0->endX = 0; - arg0->endY = 0; - arg0->color.rgba = 0; - arg0->sjisPrevByte = 0; - arg0->charTexBuf = NULL; -} - -void func_801CA6D8(UNUSED struct_801CA704* arg0) { -} - -s32 func_801CA6E4(struct_801CA704* arg0, const char* fmt, va_list args) { - return PrintUtils_VPrintf(&arg0->callback, fmt, args); -} - -s32 func_801CA704(struct_801CA704* arg0, const char* fmt, ...) { - s32 ret; - va_list args; - - va_start(args, fmt); - ret = func_801CA6E4(arg0, fmt, args); - va_end(args); - - return ret; -} diff --git a/src/n64dd/n64dd_error_bodies.c b/src/n64dd/n64dd_error_bodies.c deleted file mode 100644 index 9c990d76bf0..00000000000 --- a/src/n64dd/n64dd_error_bodies.c +++ /dev/null @@ -1,46 +0,0 @@ -#include "n64dd.h" - -const char* D_801D2EE0[2][8][4] = { - { - { "  メモリー拡張パックが正しく差し込", "  んでありますか?        ", NULL, NULL }, - { "  間違ったディスクが差し込まれてい", "  る可能性があります。正しいディス", - "  クに交換してください。     ", NULL }, - { "  注意:アクセスランプ点滅中にディ", "  スクを抜かないでください。詳しく", - "  は、取扱説明書をお読みください。", NULL }, - { "  詳しくは、取扱説明書をお読みくだ", "  さい。             ", NULL, NULL }, - { "   ディスクを差し込んでください。", NULL, NULL, NULL }, - { "  ディスクを差し込み直してください。", NULL, NULL, NULL }, - { "   ディスクを取り出してください。", NULL, NULL, NULL }, - { NULL, NULL, NULL, NULL }, - }, - { - { - " Are you sure the Expansion", - " Pak is inserted correctly?", - NULL, - NULL, - }, - { - " Check to see if the proper", - " disk is inserted.", - " Please insert the disk the", - " correct disk.", - }, - { - " Do not remove the disk when", - " the access light is flashing.", - " Please read the instruction", - " manual for details.", - }, - { - " Please read the instruction", - " manual for details.", - NULL, - NULL, - }, - { " Please insert a disk.", NULL, NULL, NULL }, - { " Please insert the disk again.", NULL, NULL, NULL }, - { " Please remove the disk.", NULL, NULL, NULL }, - { NULL, NULL, NULL, NULL }, - }, -}; diff --git a/src/n64dd/n64dd_error_textures.c b/src/n64dd/n64dd_error_textures.c deleted file mode 100644 index 38b42de363e..00000000000 --- a/src/n64dd/n64dd_error_textures.c +++ /dev/null @@ -1,19 +0,0 @@ -#include "ultra64.h" - -u64 gN64DDError41Texs[2][0x600 / sizeof(u64)] = { - { -#include "assets/n64dd/error_textures/gN64DDError41JPNTex.i4.inc.c" - }, - { -#include "assets/n64dd/error_textures/gN64DDError41ENGTex.i4.inc.c" - }, -}; - -u64 gN64DDPleaseReadManualTexs[2][0x2800 / sizeof(u64)] = { - { -#include "assets/n64dd/error_textures/gN64DDPleaseReadManualJPNTex.i4.inc.c" - }, - { -#include "assets/n64dd/error_textures/gN64DDPleaseReadManualENGTex.i4.inc.c" - }, -}; diff --git a/src/n64dd/z_n64dd.c b/src/n64dd/z_n64dd.c deleted file mode 100644 index e0dd69cd6f2..00000000000 --- a/src/n64dd/z_n64dd.c +++ /dev/null @@ -1,592 +0,0 @@ -// Main interface for the 64DD from the rest of the game. Starts background -// threads and provides functions to submit commands to them. - -#include "n64dd.h" - -#include "libc64/sleep.h" -#include "array_count.h" -#include "fault.h" -#include "gfx.h" -#include "irqmgr.h" -#include "line_numbers.h" -#include "stack.h" -#include "stack_pad.h" -#include "stackcheck.h" -#include "sys_freeze.h" -#include "versions.h" -#include "audio.h" -#include "thread.h" - -#pragma increment_block_number "ntsc-1.0:64 ntsc-1.1:64 ntsc-1.2:64 pal-1.0:64 pal-1.1:64" - -typedef struct struct_801D9C30 { - /* 0x000 */ s32 unk_000; // disk start - /* 0x004 */ s32 unk_004; // disk end - /* 0x008 */ uintptr_t unk_008; // ram start - /* 0x00C */ uintptr_t unk_00C; // ram end - /* 0x010 */ UNK_PTR unk_010; - /* 0x014 */ char unk_014[0x104]; -} struct_801D9C30; // size = 0x118 - -typedef struct struct_801D9B90 { - /* 0x00 */ OSMesg unk_00[30]; - /* 0x78 */ OSMesgQueue unk_78; - /* 0x90 */ IrqMgrClient unk_90; - /* 0x98 */ IrqMgr* unk_98; -} struct_801D9B90; // size = 0x9C - -s32 func_801C7A1C(struct_801E0D18* arg0); - -void* D_801D2E50 = &gN64DDDiskReadTemporaryBuffer; -s32 (*D_801D2E54)(struct_801E0D18*) = func_801C7A1C; - -struct_801D9B90 B_801D9B90; -struct_801D9C30 B_801D9C30; -struct_801D9C30* B_801D9D48; -struct_801D9D50 B_801D9D50; -OSMesgQueue B_801D9D80; -OSMesgQueue B_801D9D98; -OSMesg B_801D9DB0[1]; -OSMesg B_801D9DB4[1]; -volatile u8 B_801D9DB8; -volatile OSTime B_801D9DC0; -s32 B_801D9DC8; // 1 if disk gameName is correct, 2 otherwise -void* B_801D9DCC; -void* B_801D9DD0; -void* B_801D9DD4; -OSThread B_801D9DD8; -STACK(B_801D9F88, 0x1000); -StackEntry B_801DAF88; -STACK(B_801DAFA8, 0x1000); -StackEntry B_801DBFA8; -UNUSED static s32 B_801DBFC4; - -u32 func_801C6E80(void) { -#if OOT_NTSC - return LeoDriveExist(); -#else - return 0; -#endif -} - -void func_801C6EA0(UNUSED Gfx** gfxP) { -} - -void func_801C6EAC(void) { - if (D_80121214 == 0) { - func_800F6BDC(); - D_80121214 = 1; - } -} - -s32 func_801C6EF0(void) { - return D_80121214 != 0; -} - -s32 func_801C6F08(void) { - if (D_80121214 != 0) { - return 1; - } - return 1; -} - -void func_801C6F30(void) { - func_801C6EAC(); - while (func_801C6F08() == 0) { - Sleep_Usec(16666); // 100000 / 6 - } -} - -void func_801C6F78(void) { - if (D_80121214 != 0) { - D_80121214 = 0; - func_800F6B3C(); - } -} - -// boolean -s32 func_801C6FAC(void) { - if (D_80121213 == 0) { - return false; - } else { - D_80121213 = 0; - return true; - } -} - -void func_801C6FD8(void) { - while (!func_801C6FAC()) { - Sleep_Usec(16666); // 100000 / 6 - } -} - -// Adds a HungupAndCrash -void func_801C7018(void) { - if (D_80121213 != 0) { - Fault_AddHungupAndCrash("../z_n64dd.c", LN2(503, 551, 573)); - } - - D_80121213 = 1; -} - -s32 func_801C7064(void) { - B_801D9D50.unk_00 = 5; - return (&func_801C8000)(&B_801D9D50); -} - -s32 func_801C7098(void) { - s32 phi_v1; - -#if OOT_VERSION < PAL_1_0 - if (0) {} -#endif - - B_801D9D50.unk_00 = 10; - phi_v1 = (&func_801C8000)(&B_801D9D50); - if (phi_v1 < 0) { - Freeze_CurrentThread(); - } - return phi_v1; -} - -s32 func_801C70E4(void) { - return B_801D9DC8 == 1; -} - -// Used by EnMag and FileChoose -s32 func_801C70FC(void) { - return func_801C70E4(); -} - -void func_801C711C(void* arg) { - static void* B_801DBFC8; - struct_801D9B90* arg0 = (struct_801D9B90*)arg; - s16* sp58; - s32 var_s0; - void* temp_v0; - - sp58 = NULL; - arg0->unk_98 = &gIrqMgr; - osCreateMesgQueue(&arg0->unk_78, arg0->unk_00, ARRAY_COUNT(arg0->unk_00)); - IrqMgr_AddClient(arg0->unk_98, &arg0->unk_90, &arg0->unk_78); - var_s0 = 0; - do { - osRecvMesg(&arg0->unk_78, (OSMesg*)&sp58, OS_MESG_BLOCK); - switch (*sp58) { - case 1: - temp_v0 = osViGetNextFramebuffer(); - if (B_801DBFC8 != temp_v0) { - B_801DBFC8 = temp_v0; - B_801D9DB8 = 1; - } - func_801C8AA8(); - break; - case 4: - LeoReset(); - break; - case 3: - var_s0 = 1; - break; - } - } while (var_s0 == 0); - IrqMgr_RemoveClient(arg0->unk_98, &arg0->unk_90); -} - -#if OOT_VERSION >= NTSC_1_1 -void func_801C7B28_ne2(void) { - s32 temp; - - if (B_801D9DC0 != 0) { - temp = (osGetTime() - B_801D9DC0) * 64 / 3000; - if (1000000 - temp > 0) { - Sleep_Usec(1000000 - temp); - } - } -} -#endif - -void func_801C7268(void) { - STACK_PAD(s32); - s32 sp20; - s32 sp1C; - - sp20 = func_801C6EF0(); - if (sp20 == 0) { - func_801C6F30(); - } - B_801D9DB8 = 1; - B_801D9DC0 = 0; - if (func_801C7064() == 1) { - func_801C7098(); - } else if (B_801D9DC8 != 0) { - B_801D9DC8 = 0; - } -#if OOT_VERSION < NTSC_1_1 - if (B_801D9DC0 != 0) { - sp1C = (osGetTime() - B_801D9DC0) * 64 / 3000; - - // Remnants from debug statements? - (void)(osGetTime() - B_801D9DC0); - (void)((osGetTime() - B_801D9DC0) * 64 / 3000); - (void)((osGetTime() - B_801D9DC0) * 64 / 3000); - - if (1000000 - sp1C > 0) { - Sleep_Usec(1000000 - sp1C); - } - } -#else - if (D_801D2EA8 == 1 || B_801E0F60 == 1 || B_801E0F64 == 1) { - B_801D9DC0 = osGetTime(); - } - func_801C7B28_ne2(); -#endif - if (sp20 == 0) { - func_801C6F78(); - } -} - -// Clears framebuffer -void func_801C7438(void* arg0) { - u16* var_v0; - - for (var_v0 = (u16*)arg0; var_v0 < (u16*)arg0 + SCREEN_WIDTH * SCREEN_HEIGHT; var_v0++) { - *var_v0 = 1; - } -} - -void func_801C746C(void* arg0, void* arg1, void* arg2) { - void* sp2C; - - if (arg0 != NULL || arg1 != NULL || arg2 != NULL) { - sp2C = (u8*)osViGetNextFramebuffer() + 0x20000000; - if ((u32)sp2C & 0xFFFFFF) { - if (B_801D9DB8 != 0) { - B_801D9DB8 = 0; - func_801C7438(sp2C); - B_801D9DC0 = osGetTime(); - } - if (arg0 != NULL) { - func_801CA1F0(arg0, 96, 32, 192, 16, 11, sp2C, SCREEN_WIDTH); - } - if (arg1 != NULL) { - func_801CA1F0(arg1, 0, 80, 320, 64, 11, sp2C, SCREEN_WIDTH); - } - if (arg2 != NULL) { - func_801CA1F0(arg2, 0, 176, 320, 32, 11, sp2C, SCREEN_WIDTH); - } -#if OOT_VERSION < PAL_1_0 - osViBlack(0); -#endif - } - } -} - -void func_801C75BC(void* arg0, void* arg1, void* arg2) { - STACK_PAD(s32); - - if (arg0 == NULL && arg1 == NULL && arg2 == NULL) { - return; - } - - if (B_801D9DB8) {} - - if (arg0 != 0) { - B_801D9DCC = arg0; - } - if (arg1 != 0) { - B_801D9DD0 = arg1; - } - if (arg2 != 0) { - B_801D9DD4 = arg2; - } - func_801C746C(arg0, arg1, arg2); -} - -void func_801C761C(void) { - Sleep_Msec(100); - func_801C746C(B_801D9DCC, B_801D9DD0, B_801D9DD4); -} - -s32 func_801C7658(void) { - if (D_80121212 != 0) { - return 0; - } - -#if OOT_VERSION < PAL_1_0 - StackCheck_Init(&B_801DAF88, B_801D9F88, STACK_TOP(B_801D9F88), 0, 0x100, "ddmsg"); - osCreateThread(&B_801D9DD8, THREAD_ID_DDMSG, &func_801C711C, &B_801D9B90, STACK_TOP(B_801D9F88), THREAD_PRI_DDMSG); - osStartThread(&B_801D9DD8); -#endif - - osCreateMesgQueue(&B_801D9D80, B_801D9DB0, ARRAY_COUNT(B_801D9DB0)); - osCreateMesgQueue(&B_801D9D98, B_801D9DB4, ARRAY_COUNT(B_801D9DB4)); - - StackCheck_Init(&B_801DBFA8, B_801DAFA8, STACK_TOP(B_801DAFA8), 0, 0x100, "n64dd"); - - B_801D9D50.unk_1C = &B_801D9D80; - B_801D9D50.unk_20 = &B_801D9D98; - B_801D9D50.unk_24 = THREAD_ID_N64DD; - B_801D9D50.unk_28 = STACK_TOP(B_801DAFA8); - B_801D9D50.unk_2C = THREAD_PRI_N64DD; - B_801D9D50.unk_00 = 1; - - (&func_801C8000)(&B_801D9D50); - - D_80121213 = 1; - func_801C6FD8(); - - B_801D9D50.unk_00 = 2; - B_801D9D50.unk_10 = 6; - B_801D9D50.unk_14 = &DmaMgr_DmaFromDriveRom; - B_801D9D50.unk_0C = &func_801C75BC; - (&func_801C8000)(&B_801D9D50); - - B_801D9D50.unk_00 = 13; - (&func_801C8000)(&B_801D9D50); - -#if OOT_VERSION >= PAL_1_0 - StackCheck_Init(&B_801DAF88, B_801D9F88, STACK_TOP(B_801D9F88), 0, 0x100, "ddmsg"); - osCreateThread(&B_801D9DD8, THREAD_ID_DDMSG, &func_801C711C, &B_801D9B90, STACK_TOP(B_801D9F88), THREAD_PRI_DDMSG); - osStartThread(&B_801D9DD8); -#endif - - return 0; -} - -s32 func_801C7818(void) { -#if OOT_VERSION >= NTSC_1_1 - B_801D9DB8 = 1; - B_801D9DC0 = 0; -#endif - - B_801D9D50.unk_00 = 12; - (&func_801C8000)(&B_801D9D50); - - while (func_801C81C4() == 0) { - // the number 16666 sounds like it could be 1 frame (at 60 frames per second) - Sleep_Usec(1000000 * 1 / 60); - } - -#if OOT_VERSION >= NTSC_1_1 - if (D_801D2EA8 == 1 || B_801E0F60 == 1 || B_801E0F64 == 1) { - B_801D9DC0 = osGetTime(); - } - func_801C7B28_ne2(); -#endif - - if (func_801C81C4() != 2) { - func_801C761C(); - Freeze_CurrentThread(); - return -3; - } - - func_801C7018(); - D_80121212 = 1; - return 0; -} - -s32 func_801C78B8(void) { - s32 phi_v1 = func_801C7658(); - - if (phi_v1 == 0) { - phi_v1 = func_801C7818(); - } - return phi_v1; -} - -s32 func_801C78F0(void) { - B_801D9D50.unk_00 = 0; - return (&func_801C8000)(&B_801D9D50); -} - -void func_801C7920(s32 arg0, void* arg1, s32 arg2) { - B_801D9D50.unk_18 = arg1; - B_801D9D50.unk_1C = (void*)arg0; - B_801D9D50.unk_20 = (void*)arg2; - B_801D9D50.unk_00 = 3; - (&func_801C8000)(&B_801D9D50); - osGetTime(); - B_801D9D50.unk_00 = 6; - while ((&func_801C8000)(&B_801D9D50) != 0) { - Sleep_Usec(16666); // 100000 / 6 - } - B_801D9D50.unk_00 = 7; - if ((&func_801C8000)(&B_801D9D50) != 0) { - Freeze_CurrentThread(); - } -} - -void func_801C79CC(void* arg0, s32 arg1, s32 arg2) { - B_801D9D50.unk_18 = arg0; - B_801D9D50.unk_1C = (void*)arg1; - B_801D9D50.unk_20 = (void*)arg2; - B_801D9D50.unk_00 = 4; - (&func_801C8000)(&B_801D9D50); -} - -void func_801C7A10(UNUSED LEODiskID* arg0) { -} - -// Checks diskId, sets B_801D9DC8 and returns true if diskId is correct -s32 func_801C7A1C(struct_801E0D18* arg0) { - static LEODiskID B_801DBFD0; - static s32 B_801DBFF0; // bool - - func_801C7A10(&arg0->diskId); - if (!B_801DBFF0) { -#if OOT_NTSC - if (bcmp(arg0->diskId.gameName, "EZLJ", 4) == 0 || bcmp(arg0->diskId.gameName, "EZLE", 4) == 0) -#else - if (bcmp(arg0->diskId.gameName, "EZLP", 4) == 0) -#endif - { - B_801DBFD0 = arg0->diskId; - B_801DBFF0 = true; - B_801D9DC8 = 1; - } else { - B_801D9DC8 = 2; - } - } else if (bcmp(&B_801DBFD0, &arg0->diskId, sizeof(LEODiskID)) == 0) { - B_801D9DC8 = 1; - } else { - B_801D9DC8 = 2; - } - return B_801D9DC8 == 1; -} - -// Translates byte position to LBA and byte offset -s32 func_801C7B48(s32 arg0, s32* arg1, s32* arg2) { - s32 sp2C; - s32 temp_v0_2; - s32 sp24; - s32 sp20; - s32 temp_v0; - - temp_v0_2 = LeoByteToLBA(1, arg0 + 1, &sp2C); - if (temp_v0_2 != LEO_ERROR_GOOD) { - return temp_v0_2; - } - sp24 = sp2C - 1; - if (sp2C == 1) { - sp20 = 0; - } else { - temp_v0 = LeoLBAToByte(1, sp24, &sp20); - if (temp_v0 != LEO_ERROR_GOOD) { - return temp_v0; - } - } - *arg1 = sp24 + 1; - *arg2 = arg0 - sp20; - return LEO_ERROR_GOOD; -} - -s32 func_801C7BEC(s32 startLBA) { - s32 bytes; - - if (LeoLBAToByte(startLBA, 1, &bytes) == LEO_ERROR_GOOD) { - return bytes; - } - return 0; -} - -// Copies bytes from disk to arg0 -void func_801C7C1C(void* dest, s32 offset, s32 size) { - s32 sp5C; - s32 sp58; - s32 sp54; - s32 sp50; - void* sp4C; - s32 var_s0; - s32 var_s1; - s32 temp_v1_2; - - func_801C6FD8(); - func_801C6F30(); - B_801D9DB8 = 1; - B_801D9DC0 = 0; - func_801C7B48(offset, &sp5C, &sp54); - func_801C7B48(offset + size, &sp58, &sp50); - sp4C = D_801D2E50; - if (sp5C == sp58) { - func_801C7920(sp5C, sp4C, func_801C7BEC(sp5C)); - bcopy((u8*)sp4C + sp54, dest, size); - } else { - var_s1 = 0; - func_801C7920(sp5C, sp4C, func_801C7BEC(sp5C)); - bcopy((u8*)sp4C + sp54, dest, func_801C7BEC(sp5C) - sp54); - if (sp5C + 1 < sp58) { - for (var_s0 = sp5C + 1; var_s0 < sp58; var_s0++) { - var_s1 += func_801C7BEC(var_s0); - } - func_801C7920(sp5C + 1, (u8*)dest + func_801C7BEC(sp5C) - sp54, var_s1); - } - if (sp50 > 0) { - func_801C7920(sp58, sp4C, func_801C7BEC(sp58)); - bcopy((u8*)sp4C, (u8*)dest + func_801C7BEC(sp5C) - sp54 + var_s1, sp50); - } - } -#if OOT_VERSION < NTSC_1_1 - if (B_801D9DC0 != 0) { - temp_v1_2 = (osGetTime() - B_801D9DC0) * 64 / 3000; - if (1000000 - temp_v1_2 > 0) { - Sleep_Usec(1000000 - temp_v1_2); - } - } -#else - func_801C7B28_ne2(); -#endif - func_801C7018(); - func_801C6F78(); -} - -void func_801C7E78(void) { -} - -s32 func_801C7E80(void) { - s32 sp24; - s32 sp20; - STACK_PAD(s32); - uintptr_t sp18; - - if (B_801D9D48 != NULL) { - return -1; - } - B_801D9D48 = &B_801D9C30; - func_801C7C1C(B_801D9D48, 0x1060, 0x118); - sp24 = B_801D9D48->unk_004 - B_801D9D48->unk_000; - sp20 = B_801D9D48->unk_00C - B_801D9D48->unk_008; - sp18 = B_801D9D48->unk_008 + sp24; - func_801C7C1C((void*)B_801D9D48->unk_008, B_801D9D48->unk_000, sp24); - bzero((void*)sp18, sp20 - sp24); - func_800AD4C0(B_801D9D48->unk_010); - return 0; -} - -s32 func_801C7F24(void) { - uintptr_t temp_a0; - struct_801D9C30* temp_v0; - - if (B_801D9D48 == 0) { - return -1; - } - - // Function from code - func_800AD51C(); - - temp_v0 = B_801D9D48; - temp_a0 = temp_v0->unk_008; - bzero((void*)temp_a0, temp_v0->unk_00C - temp_a0); - bzero(B_801D9D48, sizeof(struct_801D9C30)); - B_801D9D48 = 0; - return 0; -} - -void n64dd_SetDiskVersion(s32 arg0) { - if (arg0 != 0) { - if (B_801D9D48 == 0) { - func_801C7E80(); - } - } else if (B_801D9D48 != 0) { - func_801C7F24(); - } -} diff --git a/src/overlays/actors/ovl_Bg_Bdan_Objects/z_bg_bdan_objects.c b/src/overlays/actors/ovl_Bg_Bdan_Objects/z_bg_bdan_objects.c index 58797959d28..56635dfb893 100644 --- a/src/overlays/actors/ovl_Bg_Bdan_Objects/z_bg_bdan_objects.c +++ b/src/overlays/actors/ovl_Bg_Bdan_Objects/z_bg_bdan_objects.c @@ -136,8 +136,8 @@ void BgBdanObjects_SetProperty(BgBdanObjects* this, s32 arg1) { } void BgBdanObjects_Init(Actor* thisx, PlayState* play) { - STACK_PAD(s32); BgBdanObjects* this = (BgBdanObjects*)thisx; + STACK_PAD(s32); CollisionHeader* colHeader = NULL; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); @@ -154,7 +154,7 @@ void BgBdanObjects_Init(Actor* thisx, PlayState* play) { CollisionHeader_GetVirtual(&gJabuBigOctoPlatformCol, &colHeader); Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, &this->dyna.actor, &sCylinderInit); - thisx->world.pos.y += -79.0f; + thisx->world.pos.y = (f32)(thisx->world.pos.y + -79.0f); if (Flags_GetClear(play, thisx->room)) { Flags_SetSwitch(play, this->var.switchFlag); this->actionFunc = BgBdanObjects_SinkToFloorHeight; @@ -170,14 +170,14 @@ void BgBdanObjects_Init(Actor* thisx, PlayState* play) { thisx->world.pos.y = thisx->home.pos.y + -70.0f; } else { Flags_SetSwitch(play, this->var.switchFlag); - this->timer = 0; + this->unk_16A = 0; this->actionFunc = BgBdanObjects_OctoPlatform_WaitForRutoToStartCutscene; } } } else { if (thisx->params == JABU_OBJECTS_TYPE_SMALL_AUTO_ELEVATOR) { CollisionHeader_GetVirtual(&gJabuElevatorCol, &colHeader); - this->timer = 512; + this->unk_16A = 0x200; this->var.camChangeTimer = 0; this->actionFunc = BgBdanObjects_ElevatorOscillate; } else { // JABU_OBJECTS_TYPE_FALLING_PLATFORM @@ -212,19 +212,21 @@ void BgBdanObjects_OctoPlatform_WaitForRutoToStartCutscene(BgBdanObjects* this, if (BgBdanObjects_GetProperty(this, JABU_OBJECTS_GET_PROP_CAM_SETTING_NORMAL0)) { if (this->dyna.actor.xzDistToPlayer < 250.0f) { BgBdanObjects_SetProperty(this, JABU_OBJECTS_SET_PROP_CAM_SETTING_NORMAL1); - this->timer = 20; + this->unk_16A = 0x14; OnePointCutscene_Init(play, 3070, -99, &this->dyna.actor, CAM_ID_MAIN); player->actor.world.pos.x = -1130.0f; player->actor.world.pos.y = -1025.0f; player->actor.world.pos.z = -3300.0f; Rumble_Request(0.0f, 255, 20, 150); } - } else if (this->timer != 0) { - if (this->timer != 0) { - this->timer--; - } - if (this->timer == 0) { - this->actionFunc = BgBdanObjects_OctoPlatform_RaiseToUpperPosition; + } else { + if (this->unk_16A != 0) { + if (this->unk_16A != 0) { + this->unk_16A -= 1; + } + if (this->unk_16A == 0) { + this->actionFunc = BgBdanObjects_OctoPlatform_RaiseToUpperPosition; + } } } @@ -240,16 +242,16 @@ void BgBdanObjects_OctoPlatform_RaiseToUpperPosition(BgBdanObjects* this, PlaySt 0.1f) { Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BUYOSTAND_STOP_A); this->actionFunc = BgBdanObjects_OctoPlatform_WaitForRutoToAdvanceCutscene; - this->timer = 30; + this->unk_16A = 0x1E; BgBdanObjects_SetProperty(this, JABU_OBJECTS_SET_PROP_CAM_SETTING_DUNGEON0); Rumble_Request(0.0f, 255, 20, 150); } else { - if (this->timer != 0) { - this->timer--; + if (this->unk_16A != 0) { + this->unk_16A -= 1; } - if (this->timer == 0) { + if (this->unk_16A == 0) { Rumble_Request(0.0f, 120, 20, 10); - this->timer = 11; + this->unk_16A = 0xB; } Actor_PlaySfx_Flagged(&this->dyna.actor, NA_SE_EV_BUYOSTAND_RISING - SFX_FLAG); } @@ -262,9 +264,9 @@ void BgBdanObjects_OctoPlatform_RaiseToUpperPosition(BgBdanObjects* this, PlaySt void BgBdanObjects_OctoPlatform_WaitForRutoToAdvanceCutscene(BgBdanObjects* this, PlayState* play) { s32 quakeIndex; - if (this->timer != 0) { - this->timer--; - if (this->timer == 0) { + if (this->unk_16A != 0) { + this->unk_16A -= 1; + if (this->unk_16A == 0) { quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_1); Quake_SetSpeed(quakeIndex, 0x3A98); Quake_SetPerturbations(quakeIndex, 0, 1, 250, 1); @@ -277,7 +279,7 @@ void BgBdanObjects_OctoPlatform_WaitForRutoToAdvanceCutscene(BgBdanObjects* this this->dyna.actor.world.pos.y + 140.0f, this->dyna.actor.world.pos.z, 0, this->dyna.actor.shape.rot.y + 0x8000, 0, 0); BgBdanObjects_SetProperty(this, JABU_OBJECTS_SET_PROP_WATCHED_BIGOCTO_INTRO_CUTSCENE); - this->timer = 10; + this->unk_16A = 0xA; this->actionFunc = BgBdanObjects_OctoPlatform_PauseBeforeDescending; Camera_SetFinishedFlag(GET_ACTIVE_CAM(play)); } @@ -290,7 +292,7 @@ void BgBdanObjects_OctoPlatform_DescendWithBigOcto(BgBdanObjects* this, PlayStat if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + -70.0f, this->dyna.actor.velocity.y)) { this->dyna.actor.world.rot.y = 0; - this->timer = 60; + this->unk_16A = 0x3C; Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BUYOSTAND_STOP_U); this->dyna.actor.child->world.pos.y = this->dyna.actor.world.pos.y + 140.0f; this->actionFunc = BgBdanObjects_OctoPlatform_WaitForBigOctoToStartBattle; @@ -303,12 +305,12 @@ void BgBdanObjects_OctoPlatform_DescendWithBigOcto(BgBdanObjects* this, PlayStat Rumble_Request(0.0f, 255, 30, 150); } else { Actor_PlaySfx_Flagged(&this->dyna.actor, NA_SE_EV_BUYOSTAND_FALL - SFX_FLAG); - if (this->timer != 0) { - this->timer--; + if (this->unk_16A != 0) { + this->unk_16A -= 1; } - if (this->timer == 0) { + if (this->unk_16A == 0) { Rumble_Request(0.0f, 120, 20, 10); - this->timer = 11; + this->unk_16A = 0xB; } if (this->dyna.actor.child != NULL) { this->dyna.actor.child->world.pos.y = this->dyna.actor.world.pos.y + 140.0f; @@ -317,25 +319,27 @@ void BgBdanObjects_OctoPlatform_DescendWithBigOcto(BgBdanObjects* this, PlayStat } void BgBdanObjects_OctoPlatform_PauseBeforeDescending(BgBdanObjects* this, PlayState* play) { - this->timer--; + this->unk_16A -= 1; - if (this->timer == 0) { + if (this->unk_16A == 0) { Flags_UnsetSwitch(play, this->var.switchFlag); - } else if (this->timer == -40) { - this->timer = 0; + } else if (this->unk_16A == -0x28) { + this->unk_16A = 0; this->actionFunc = BgBdanObjects_OctoPlatform_DescendWithBigOcto; } } void BgBdanObjects_OctoPlatform_WaitForBigOctoToStartBattle(BgBdanObjects* this, PlayState* play) { - if (this->timer != 0) { - this->timer--; + if (this->unk_16A != 0) { + this->unk_16A -= 1; } - if ((this->timer == 0) && (this->dyna.actor.child != NULL)) { - if (this->dyna.actor.child->params == 2) { - this->actionFunc = BgBdanObjects_OctoPlatform_BattleInProgress; - } else if (this->dyna.actor.child->params == 0) { - this->dyna.actor.child->params = 1; + if (this->unk_16A == 0) { + if (this->dyna.actor.child != NULL) { + if (this->dyna.actor.child->params == 2) { + this->actionFunc = BgBdanObjects_OctoPlatform_BattleInProgress; + } else if (this->dyna.actor.child->params == 0) { + this->dyna.actor.child->params = 1; + } } } } @@ -387,8 +391,8 @@ void BgBdanObjects_DoNothing(BgBdanObjects* this, PlayState* play) { } void BgBdanObjects_ElevatorOscillate(BgBdanObjects* this, PlayState* play) { - if (this->timer != 0) { - this->timer--; + if (this->unk_16A != 0) { + this->unk_16A -= 1; } if (this->var.camChangeTimer == 0) { if (DynaPolyActor_IsPlayerOnTop(&this->dyna)) { @@ -401,31 +405,31 @@ void BgBdanObjects_ElevatorOscillate(BgBdanObjects* this, PlayState* play) { Camera_RequestSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_NORMAL2); if (!DynaPolyActor_IsPlayerOnTop(&this->dyna)) { if (this->var.camChangeTimer != 0) { - this->var.camChangeTimer--; + this->var.camChangeTimer -= 1; } } if (this->var.camChangeTimer == 0) { if (1) {} - Camera_RequestSetting(play->cameraPtrs[CAM_ID_MAIN], this->cameraSetting); + Camera_RequestSetting(play->cameraPtrs[CAM_ID_MAIN], (s16)this->cameraSetting); Camera_SetStateFlag(play->cameraPtrs[CAM_ID_MAIN], CAM_STATE_CHECK_BG); } } this->dyna.actor.world.pos.y = - this->dyna.actor.home.pos.y - (sinf(this->timer * (M_PI / 256.0f)) * 471.24f); // pi * 150 - if (this->timer == 0) { - this->timer = 512; + this->dyna.actor.home.pos.y - (sinf((f32)this->unk_16A * (M_PI / 256.0f)) * 471.24f); // pi * 150 + if (this->unk_16A == 0) { + this->unk_16A = 0x200; } } void BgBdanObjects_WaitForSwitch(BgBdanObjects* this, PlayState* play) { if (Flags_GetSwitch(play, this->var.switchFlag)) { - this->timer = 100; + this->unk_16A = 0x64; this->actionFunc = BgBdanObjects_ChangeWaterBoxLevel; } } void BgBdanObjects_ChangeWaterBoxLevel(BgBdanObjects* this, PlayState* play) { - if (this->timer == 0) { + if (this->unk_16A == 0) { if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 0.5f)) { Flags_UnsetSwitch(play, this->var.switchFlag); this->actionFunc = BgBdanObjects_WaitForSwitch; @@ -441,11 +445,11 @@ void BgBdanObjects_ChangeWaterBoxLevel(BgBdanObjects* this, PlayState* play) { } void BgBdanObjects_WaitForTimerExpired(BgBdanObjects* this, PlayState* play) { - if (this->timer != 0) { - this->timer--; + if (this->unk_16A != 0) { + this->unk_16A -= 1; } - Actor_PlaySfx_FlaggedTimer(&this->dyna.actor, this->timer); // play ticking sound effect - if (this->timer == 0) { + Actor_PlaySfx_FlaggedTimer(&this->dyna.actor, this->unk_16A); + if (this->unk_16A == 0) { this->actionFunc = BgBdanObjects_ChangeWaterBoxLevel; } } @@ -453,7 +457,7 @@ void BgBdanObjects_WaitForTimerExpired(BgBdanObjects* this, PlayState* play) { void BgBdanObjects_WaitForPlayerOnTop(BgBdanObjects* this, PlayState* play) { if (DynaPolyActor_IsPlayerOnTop(&this->dyna)) { Flags_SetSwitch(play, this->var.switchFlag); - this->timer = 50; + this->unk_16A = 0x32; this->actionFunc = BgBdanObjects_FallToLowerPos; this->dyna.actor.home.pos.y -= 200.0f; OnePointCutscene_Init(play, 3100, 51, &this->dyna.actor, CAM_ID_MAIN); @@ -461,13 +465,11 @@ void BgBdanObjects_WaitForPlayerOnTop(BgBdanObjects* this, PlayState* play) { } void BgBdanObjects_FallToLowerPos(BgBdanObjects* this, PlayState* play) { - if (this->timer != 0) { - this->timer--; + if (this->unk_16A != 0) { + this->unk_16A -= 1; } - - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y - (cosf(this->timer * (M_PI / 50.0f)) * 200.0f); - - if (this->timer == 0) { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y - (cosf(this->unk_16A * (M_PI / 50.0f)) * 200.0f); + if (this->unk_16A == 0) { Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BUYOSTAND_STOP_U); this->actionFunc = BgBdanObjects_DoNothing; // Using `CAM_ID_NONE` here defaults to the active camera diff --git a/src/overlays/actors/ovl_Bg_Bdan_Objects/z_bg_bdan_objects.h b/src/overlays/actors/ovl_Bg_Bdan_Objects/z_bg_bdan_objects.h index 72f2b7103c0..fd90fcc47d8 100644 --- a/src/overlays/actors/ovl_Bg_Bdan_Objects/z_bg_bdan_objects.h +++ b/src/overlays/actors/ovl_Bg_Bdan_Objects/z_bg_bdan_objects.h @@ -22,7 +22,7 @@ typedef struct BgBdanObjects { /* 0x0168 */ u8 switchFlag; /* 0x0168 */ u8 camChangeTimer; } var; - /* 0x016A */ s16 timer; + /* 0x016A */ s16 unk_16A; /* 0x016C */ ColliderCylinder collider; /* 0x01B8 */ s32 cameraSetting; } BgBdanObjects; // size = 0x01BC diff --git a/src/overlays/actors/ovl_Bg_Bdan_Switch/z_bg_bdan_switch.c b/src/overlays/actors/ovl_Bg_Bdan_Switch/z_bg_bdan_switch.c index a0c023ba60f..5fcb1a4ec15 100644 --- a/src/overlays/actors/ovl_Bg_Bdan_Switch/z_bg_bdan_switch.c +++ b/src/overlays/actors/ovl_Bg_Bdan_Switch/z_bg_bdan_switch.c @@ -1,6 +1,6 @@ /* * File: z_bg_bdan_switch.c - * Overlay: ovl_Bg_Bdan_Switch + * Overlay: Bg_Bdan_Switch * Description: Switches Inside Lord Jabu-Jabu */ diff --git a/src/overlays/actors/ovl_Bg_Ddan_Jd/z_bg_ddan_jd.c b/src/overlays/actors/ovl_Bg_Ddan_Jd/z_bg_ddan_jd.c index bc5c8ce4d8c..93dd7762247 100644 --- a/src/overlays/actors/ovl_Bg_Ddan_Jd/z_bg_ddan_jd.c +++ b/src/overlays/actors/ovl_Bg_Ddan_Jd/z_bg_ddan_jd.c @@ -43,10 +43,10 @@ static InitChainEntry sInitChain[] = { }; typedef enum BgDdanJdState { - /* 0 */ STATE_GO_BOTTOM, - /* 1 */ STATE_GO_MIDDLE_FROM_BOTTOM, - /* 2 */ STATE_GO_MIDDLE_FROM_TOP, - /* 3 */ STATE_GO_TOP + STATE_GO_BOTTOM, + STATE_GO_MIDDLE_FROM_BOTTOM, + STATE_GO_MIDDLE_FROM_TOP, + STATE_GO_TOP } BgDdanJdState; #define MOVE_HEIGHT_MIDDLE 140.0f @@ -60,14 +60,14 @@ typedef enum BgDdanJdState { #define SHORTCUT_Y_SPEED 5 void BgDdanJd_Init(Actor* thisx, PlayState* play) { - STACK_PAD(s32); BgDdanJd* this = (BgDdanJd*)thisx; + STACK_PAD(s32); CollisionHeader* colHeader = NULL; - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + Actor_ProcessInitChain(thisx, sInitChain); DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); CollisionHeader_GetVirtual(&gDodongoRisingPlatformCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, thisx, colHeader); this->idleTimer = IDLE_FRAMES; this->state = STATE_GO_BOTTOM; diff --git a/src/overlays/actors/ovl_Bg_Ddan_Kd/z_bg_ddan_kd.c b/src/overlays/actors/ovl_Bg_Ddan_Kd/z_bg_ddan_kd.c index 1e08acfdfbf..5d2025e2039 100644 --- a/src/overlays/actors/ovl_Bg_Ddan_Kd/z_bg_ddan_kd.c +++ b/src/overlays/actors/ovl_Bg_Ddan_Kd/z_bg_ddan_kd.c @@ -132,8 +132,9 @@ void BgDdanKd_CheckForExplosions(BgDdanKd* this, PlayState* play) { } void BgDdanKd_LowerStairs(BgDdanKd* this, PlayState* play) { - static Vec3f velocity = { 0.0f, 5.0f, 0.0f }; - static Vec3f accel = { 0.0f, -0.45f, 0.0f }; + static Vec3f D_808718FC = { 0.0f, 5.0f, 0.0f }; + static Vec3f D_80871908 = { 0.0f, -0.45f, 0.0f }; + UNUSED static Vec3f D_80871914 = { 0.0f, 0.0f, 0.0f }; Vec3f pos1; Vec3f pos2; f32 effectStrength; @@ -166,11 +167,11 @@ void BgDdanKd_LowerStairs(BgDdanKd* this, PlayState* play) { func_80033480(play, &pos1, 20.0f, 1, effectStrength * 135.0f, 60, 1); func_80033480(play, &pos2, 20.0f, 1, effectStrength * 135.0f, 60, 1); - velocity.x = Rand_CenteredFloat(3.0f); - velocity.z = Rand_CenteredFloat(3.0f); + D_808718FC.x = Rand_CenteredFloat(3.0f); + D_808718FC.z = Rand_CenteredFloat(3.0f); - func_8003555C(play, &pos1, &velocity, &accel); - func_8003555C(play, &pos2, &velocity, &accel); + func_8003555C(play, &pos1, &D_808718FC, &D_80871908); + func_8003555C(play, &pos2, &D_808718FC, &D_80871908); pos1 = this->dyna.actor.world.pos; pos1.z += 560.0f + Rand_ZeroOne() * 5.0f; @@ -178,7 +179,7 @@ void BgDdanKd_LowerStairs(BgDdanKd* this, PlayState* play) { pos1.y = Rand_ZeroOne() * 3.0f + (this->dyna.actor.floorHeight + 20.0f); func_80033480(play, &pos1, 20.0f, 1, effectStrength * 135.0f, 60, 1); - func_8003555C(play, &pos1, &velocity, &accel); + func_8003555C(play, &pos1, &D_808718FC, &D_80871908); } Camera_RequestQuake(&play->mainCamera, 0, effectStrength * 0.6f, 3); SFX_PLAY_AT_POS(&this->dyna.actor.projectedPos, NA_SE_EV_PILLAR_SINK - SFX_FLAG); diff --git a/src/overlays/actors/ovl_Bg_Gnd_Firemeiro/z_bg_gnd_firemeiro.c b/src/overlays/actors/ovl_Bg_Gnd_Firemeiro/z_bg_gnd_firemeiro.c index a563776d420..72d71d7b12c 100644 --- a/src/overlays/actors/ovl_Bg_Gnd_Firemeiro/z_bg_gnd_firemeiro.c +++ b/src/overlays/actors/ovl_Bg_Gnd_Firemeiro/z_bg_gnd_firemeiro.c @@ -19,14 +19,12 @@ #define FLAGS (ACTOR_FLAG_UPDATE_CULLING_DISABLED | ACTOR_FLAG_DRAW_CULLING_DISABLED) -void BgGndFiremeiro_Init(Actor* thisx, PlayState* play); +void BgGndFiremeiro_Init(Actor* thisx, PlayState* play2); void BgGndFiremeiro_Destroy(Actor* thisx, PlayState* play2); void BgGndFiremeiro_Update(Actor* thisx, PlayState* play); void BgGndFiremeiro_Draw(Actor* thisx, PlayState* play); -void BgGndFiremeiro_Sink(BgGndFiremeiro* this, PlayState* play); -void BgGndFiremeiro_Shake(BgGndFiremeiro* this, PlayState* play); -void BgGndFiremeiro_Rise(BgGndFiremeiro* this, PlayState* play); +void BgGndFiremeiro_RiseWaitAtTop(BgGndFiremeiro* this, PlayState* play); ActorProfile Bg_Gnd_Firemeiro_Profile = { /**/ ACTOR_BG_GND_FIREMEIRO, @@ -40,20 +38,19 @@ ActorProfile Bg_Gnd_Firemeiro_Profile = { /**/ BgGndFiremeiro_Draw, }; -void BgGndFiremeiro_Init(Actor* thisx, PlayState* play) { - STACK_PAD(s32); +void BgGndFiremeiro_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; BgGndFiremeiro* this = (BgGndFiremeiro*)thisx; CollisionHeader* colHeader = NULL; ActorShape_Init(&this->dyna.actor.shape, 0.0f, NULL, 0.0f); Actor_SetScale(&this->dyna.actor, 0.1f); - this->initPos = this->dyna.actor.world.pos; - + this->homePos = this->dyna.actor.world.pos; if (this->dyna.actor.params == 0) { DynaPolyActor_Init(&this->dyna, 0); CollisionHeader_GetVirtual(&gFireTrialPlatformCol, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); - this->actionFunc = BgGndFiremeiro_Rise; + this->actionFunc = BgGndFiremeiro_RiseWaitAtTop; } } @@ -64,80 +61,77 @@ void BgGndFiremeiro_Destroy(Actor* thisx, PlayState* play2) { if (this->dyna.actor.params != 0) { return; } - DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } -void BgGndFiremeiro_Sink(BgGndFiremeiro* this, PlayState* play) { - f32 sunkHeight = this->initPos.y - 150.0f; +void BgGndFIremeiro_Sink(BgGndFiremeiro* this, PlayState* play) { + f32 sinkTarget = this->homePos.y - 150.0f; - if (DynaPolyActor_IsPlayerOnTop(&this->dyna)) { + if (DynaPolyActor_IsPlayerOnTop(&this->dyna) != 0) { this->timer = 10; } - - if (sunkHeight < this->dyna.actor.world.pos.y) { + if (sinkTarget < this->dyna.actor.world.pos.y) { this->dyna.actor.world.pos.y -= 0.5f; - - if (this->dyna.actor.world.pos.y < sunkHeight) { - this->dyna.actor.world.pos.y = sunkHeight; + // I was not able to get this to be true in fire trial. + if (this->dyna.actor.world.pos.y < sinkTarget) { + this->dyna.actor.world.pos.y = sinkTarget; } - Actor_PlaySfx_FlaggedCentered2(&this->dyna.actor, NA_SE_EV_ROLL_STAND_2 - SFX_FLAG); } - if (this->timer > 0) { this->timer--; } else { - this->actionFunc = BgGndFiremeiro_Rise; + this->actionFunc = BgGndFiremeiro_RiseWaitAtTop; } } void BgGndFiremeiro_Shake(BgGndFiremeiro* this, PlayState* play) { STACK_PAD(s32); - f32 randSign; + f32 shakeOffset; - if (DynaPolyActor_IsPlayerOnTop(&this->dyna)) { + if (DynaPolyActor_IsPlayerOnTop(&this->dyna) != 0) { if (this->timer > 0) { this->timer--; - - randSign = ((this->timer & 1) ? 2.0f : -2.0f); - - this->dyna.actor.world.pos = this->initPos; - this->dyna.actor.world.pos.x += randSign * Math_SinS(this->timer * 0x2FFF); - this->dyna.actor.world.pos.z += randSign * Math_CosS(this->timer * 0x2FFF); + if ((this->timer % 2) != 0) { + shakeOffset = 2.0f; + } else { + shakeOffset = -2.0f; + } + this->dyna.actor.world.pos = this->homePos; + this->dyna.actor.world.pos.x += shakeOffset * Math_SinS(this->timer * 0x2FFF); + this->dyna.actor.world.pos.z += shakeOffset * Math_CosS(this->timer * 0x2FFF); this->dyna.actor.world.pos.y += Math_CosS(this->timer * 0x7FFF); - if (!(this->timer % 4)) { Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BLOCK_SHAKE); } } else { this->timer = 10; - this->dyna.actor.world.pos = this->initPos; - this->actionFunc = BgGndFiremeiro_Sink; + this->dyna.actor.world.pos = this->homePos; + this->actionFunc = BgGndFIremeiro_Sink; } } else { - this->dyna.actor.world.pos = this->initPos; - this->actionFunc = BgGndFiremeiro_Rise; + this->dyna.actor.world.pos = this->homePos; + this->actionFunc = BgGndFiremeiro_RiseWaitAtTop; } } -void BgGndFiremeiro_Rise(BgGndFiremeiro* this, PlayState* play) { +void BgGndFiremeiro_RiseWaitAtTop(BgGndFiremeiro* this, PlayState* play) { Player* player = GET_PLAYER(play); Actor* thisx = &this->dyna.actor; - if ((player->currentBoots != PLAYER_BOOTS_HOVER) && DynaPolyActor_IsPlayerOnTop(&this->dyna)) { - if (thisx->world.pos.y < this->initPos.y) { - this->actionFunc = BgGndFiremeiro_Sink; + if ((player->currentBoots != 2) && (DynaPolyActor_IsPlayerOnTop(&this->dyna) != 0)) { + if (thisx->world.pos.y < this->homePos.y) { + this->actionFunc = BgGndFIremeiro_Sink; this->timer = 20; } else { this->actionFunc = BgGndFiremeiro_Shake; this->timer = 20; } } else { - if (thisx->world.pos.y < this->initPos.y) { + if (thisx->world.pos.y < this->homePos.y) { thisx->world.pos.y += 2.0f; - if (this->initPos.y < thisx->world.pos.y) { - thisx->world.pos.y = this->initPos.y; + if (this->homePos.y < thisx->world.pos.y) { + thisx->world.pos.y = this->homePos.y; } } } @@ -151,8 +145,8 @@ void BgGndFiremeiro_Update(Actor* thisx, PlayState* play) { void BgGndFiremeiro_Draw(Actor* thisx, PlayState* play) { OPEN_DISPS(play->state.gfxCtx, "../z_bg_gnd_firemeiro.c", 280); - Gfx_SetupDL_37Opa(play->state.gfxCtx); + Gfx_SetupDL_37Opa(play->state.gfxCtx); MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx, "../z_bg_gnd_firemeiro.c", 282); gSPDisplayList(POLY_OPA_DISP++, gFireTrialPlatformDL); diff --git a/src/overlays/actors/ovl_Bg_Gnd_Firemeiro/z_bg_gnd_firemeiro.h b/src/overlays/actors/ovl_Bg_Gnd_Firemeiro/z_bg_gnd_firemeiro.h index a6092c9364c..9bb3196c4c2 100644 --- a/src/overlays/actors/ovl_Bg_Gnd_Firemeiro/z_bg_gnd_firemeiro.h +++ b/src/overlays/actors/ovl_Bg_Gnd_Firemeiro/z_bg_gnd_firemeiro.h @@ -10,7 +10,7 @@ typedef void (*BgGndFiremeiroActionFunc)(struct BgGndFiremeiro*, struct PlayStat typedef struct BgGndFiremeiro { /* 0x0000 */ DynaPolyActor dyna; - /* 0x0164 */ Vec3f initPos; + /* 0x0164 */ Vec3f homePos; /* 0x0170 */ u16 timer; /* 0x0174 */ BgGndFiremeiroActionFunc actionFunc; } BgGndFiremeiro; // size = 0x0178 diff --git a/src/overlays/actors/ovl_Bg_Haka_Huta/z_bg_haka_huta.c b/src/overlays/actors/ovl_Bg_Haka_Huta/z_bg_haka_huta.c index 1d0cffd13b7..45213f7c948 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Huta/z_bg_haka_huta.c +++ b/src/overlays/actors/ovl_Bg_Haka_Huta/z_bg_haka_huta.c @@ -229,7 +229,7 @@ void BgHakaHuta_Update(Actor* thisx, PlayState* play) { } void BgHakaHuta_Draw(Actor* thisx, PlayState* play) { - BgHakaHuta* this = (BgHakaHuta*)thisx; + STACK_PAD(s32); Gfx_DrawDListOpa(play, gBotwCoffinLidDL); } diff --git a/src/overlays/actors/ovl_Bg_Haka_Trap/z_bg_haka_trap.c b/src/overlays/actors/ovl_Bg_Haka_Trap/z_bg_haka_trap.c index 3132fc4fa13..927a6e2d01d 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Trap/z_bg_haka_trap.c +++ b/src/overlays/actors/ovl_Bg_Haka_Trap/z_bg_haka_trap.c @@ -506,7 +506,7 @@ void BgHakaTrap_FanBlade_FullGust(BgHakaTrap* this, PlayState* play) { void BgHakaTrap_Update(Actor* thisx, PlayState* play) { BgHakaTrap* this = (BgHakaTrap*)thisx; - s32 pad; + STACK_PAD(s32); this->actionFunc(this, play); diff --git a/src/overlays/actors/ovl_Bg_Haka_Tubo/z_bg_haka_tubo.c b/src/overlays/actors/ovl_Bg_Haka_Tubo/z_bg_haka_tubo.c index 50a8e06cd16..b0264fe802a 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Tubo/z_bg_haka_tubo.c +++ b/src/overlays/actors/ovl_Bg_Haka_Tubo/z_bg_haka_tubo.c @@ -5,6 +5,7 @@ */ #include "z_bg_haka_tubo.h" +#include "src/overlays/actors/ovl_En_Firefly/z_en_firefly.h" #include "libc64/qrand.h" #include "gfx.h" @@ -190,7 +191,7 @@ void BgHakaTubo_DropCollectible(BgHakaTubo* this, PlayState* play) { collectibleParams = -1; Actor_Spawn(&play->actorCtx, play, ACTOR_EN_FIREFLY, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 80.0f, this->dyna.actor.world.pos.z, 0, - this->dyna.actor.shape.rot.y, 0, 2); + this->dyna.actor.shape.rot.y, 0, EN_FIREFLY_TYPE_NORMAL); Sfx_PlaySfxCentered(NA_SE_SY_ERROR); } else { // Random rewards diff --git a/src/overlays/actors/ovl_Bg_Hidan_Fslift/z_bg_hidan_fslift.c b/src/overlays/actors/ovl_Bg_Hidan_Fslift/z_bg_hidan_fslift.c index bca19beba4a..f481ae834f3 100644 --- a/src/overlays/actors/ovl_Bg_Hidan_Fslift/z_bg_hidan_fslift.c +++ b/src/overlays/actors/ovl_Bg_Hidan_Fslift/z_bg_hidan_fslift.c @@ -1,6 +1,6 @@ /* * File: z_bg_hidan_fslift.c - * Overlay: ovl_Bg_Hidan_Fslift + * Overlay: Bg_Hidan_Fslift * Description: Hookshot Elevator */ @@ -45,32 +45,33 @@ static InitChainEntry sInitChain[] = { }; void BgHidanFslift_Init(Actor* thisx, PlayState* play) { - STACK_PAD(s32); BgHidanFslift* this = (BgHidanFslift*)thisx; + STACK_PAD(s32); CollisionHeader* colHeader = NULL; STACK_PAD(s32); - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + Actor_ProcessInitChain(thisx, sInitChain); DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); CollisionHeader_GetVirtual(&gFireTempleHookshotElevatorCol, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, thisx, colHeader); - if (Actor_SpawnAsChild(&play->actorCtx, &this->dyna.actor, play, ACTOR_OBJ_HSBLOCK, this->dyna.actor.world.pos.x, - this->dyna.actor.world.pos.y + 40.0f, this->dyna.actor.world.pos.z + -28.0f, 0, 0, 0, - 2) == NULL) { - Actor_Kill(&this->dyna.actor); + if (Actor_SpawnAsChild(&play->actorCtx, thisx, play, ACTOR_OBJ_HSBLOCK, thisx->world.pos.x, + thisx->world.pos.y + 40.0f, thisx->world.pos.z + -28.0f, 0, 0, 0, 2) == NULL) { + Actor_Kill(thisx); return; } this->actionFunc = BgHidanFslift_Idle; } void BgHidanFslift_SetHookshotTargetPos(BgHidanFslift* this) { - if (this->dyna.actor.child != NULL && this->dyna.actor.child->update != NULL) { - 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 + 40.0f; - this->dyna.actor.child->world.pos.z = this->dyna.actor.world.pos.z + -28.0f; - } else { - this->dyna.actor.child = NULL; + Actor* thisx = &this->dyna.actor; + + if (thisx->child != NULL && thisx->child->update != NULL) { + thisx->child->world.pos.x = thisx->world.pos.x; + thisx->child->world.pos.y = thisx->world.pos.y + 40.0f; + thisx->child->world.pos.z = thisx->world.pos.z + -28.0f; + return; } + thisx->child = NULL; } void BgHidanFslift_Destroy(Actor* thisx, PlayState* play) { @@ -80,47 +81,54 @@ void BgHidanFslift_Destroy(Actor* thisx, PlayState* play) { } void BgHidanFslift_SetupIdle(BgHidanFslift* this) { - this->timer = 40; + this->unk_168 = 0x28; this->actionFunc = BgHidanFslift_Idle; } void BgHidanFslift_Idle(BgHidanFslift* this, PlayState* play) { s32 nearHomePos; + Actor* thisx = &this->dyna.actor; - if (this->timer) { - this->timer--; - } + DECR(this->unk_168); - if (this->timer == 0) { + if (this->unk_168 == 0) { nearHomePos = false; - if ((this->dyna.actor.world.pos.y - this->dyna.actor.home.pos.y) < 0.5f) { + if ((thisx->world.pos.y - thisx->home.pos.y) < 0.5f) { nearHomePos = true; } - if (DynaPolyActor_IsPlayerAbove(&this->dyna) && nearHomePos) { - this->actionFunc = BgHidanFslift_Ascend; - } else if (!nearHomePos) { + if (DynaPolyActor_IsPlayerAbove(&this->dyna)) { + if (nearHomePos) { + this->actionFunc = BgHidanFslift_Ascend; + return; + } + } + if (!nearHomePos) { this->actionFunc = BgHidanFslift_Descend; } } } void BgHidanFslift_Descend(BgHidanFslift* this, PlayState* play) { - if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 4.0f)) { - Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + Actor* thisx = &this->dyna.actor; + + if (Math_StepToF(&thisx->world.pos.y, thisx->home.pos.y, 4.0f)) { + Actor_PlaySfx(thisx, NA_SE_EV_BLOCK_BOUND); BgHidanFslift_SetupIdle(this); } else { - Actor_PlaySfx_Flagged(&this->dyna.actor, NA_SE_EV_ELEVATOR_MOVE3 - SFX_FLAG); + Actor_PlaySfx_Flagged(thisx, NA_SE_EV_ELEVATOR_MOVE3 - SFX_FLAG); } BgHidanFslift_SetHookshotTargetPos(this); } void BgHidanFslift_Ascend(BgHidanFslift* this, PlayState* play) { + Actor* thisx = &this->dyna.actor; + if (DynaPolyActor_IsPlayerAbove(&this->dyna)) { - if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 790.0f, 4.0f)) { - Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + if (Math_StepToF(&thisx->world.pos.y, thisx->home.pos.y + 790.0f, 4.0f)) { + Actor_PlaySfx(thisx, NA_SE_EV_BLOCK_BOUND); BgHidanFslift_SetupIdle(this); } else { - Actor_PlaySfx_Flagged(&this->dyna.actor, NA_SE_EV_ELEVATOR_MOVE3 - SFX_FLAG); + Actor_PlaySfx_Flagged(thisx, NA_SE_EV_ELEVATOR_MOVE3 - SFX_FLAG); } } else { BgHidanFslift_SetupIdle(this); @@ -137,10 +145,8 @@ void BgHidanFslift_Update(Actor* thisx, PlayState* play) { this->cameraSetting = CAM_SET_DUNGEON0; } Camera_RequestSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_ELEVATOR_PLATFORM); - } else if (!DynaPolyActor_IsPlayerOnTop(&this->dyna)) { + } else if (DynaPolyActor_IsPlayerOnTop(&this->dyna) == 0) { if (this->cameraSetting != CAM_SET_NONE) { - // Given the values that get set to `cameraSetting`, it seems likely that it was intended to be - // passed to the function call below. But instead `CAM_SET_DUNGEON0` is used directly. Camera_RequestSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_DUNGEON0); } this->cameraSetting = CAM_SET_NONE; diff --git a/src/overlays/actors/ovl_Bg_Hidan_Fslift/z_bg_hidan_fslift.h b/src/overlays/actors/ovl_Bg_Hidan_Fslift/z_bg_hidan_fslift.h index 1f810b1c04e..9b4bf034298 100644 --- a/src/overlays/actors/ovl_Bg_Hidan_Fslift/z_bg_hidan_fslift.h +++ b/src/overlays/actors/ovl_Bg_Hidan_Fslift/z_bg_hidan_fslift.h @@ -11,7 +11,7 @@ typedef void (*BgHidanFsliftActionFunc)(struct BgHidanFslift*, struct PlayState* typedef struct BgHidanFslift { /* 0x0000 */ DynaPolyActor dyna; /* 0x0164 */ BgHidanFsliftActionFunc actionFunc; - /* 0x0168 */ s16 timer; + /* 0x0168 */ s16 unk_168; /* 0x016A */ s16 cameraSetting; } BgHidanFslift; // size = 0x016C diff --git a/src/overlays/actors/ovl_Bg_Hidan_Kousi/z_bg_hidan_kousi.c b/src/overlays/actors/ovl_Bg_Hidan_Kousi/z_bg_hidan_kousi.c index 454dcc7f154..39a9e1ef3aa 100644 --- a/src/overlays/actors/ovl_Bg_Hidan_Kousi/z_bg_hidan_kousi.c +++ b/src/overlays/actors/ovl_Bg_Hidan_Kousi/z_bg_hidan_kousi.c @@ -115,9 +115,10 @@ void func_80889ACC(BgHidanKousi* this) { Vec3s* rot = &this->dyna.actor.world.rot; f32 temp1 = D_80889E40[PARAMS_GET_U(this->dyna.actor.params, 0, 8)] * Math_SinS(rot->y); f32 temp2 = D_80889E40[PARAMS_GET_U(this->dyna.actor.params, 0, 8)] * Math_CosS(rot->y); + Vec3f* initPos = &this->dyna.actor.home.pos; - this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x + temp1; - this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z + temp2; + this->dyna.actor.world.pos.x = initPos->x + temp1; + this->dyna.actor.world.pos.z = initPos->z + temp2; } void func_80889B5C(BgHidanKousi* this, PlayState* play) { diff --git a/src/overlays/actors/ovl_Bg_Hidan_Rsekizou/z_bg_hidan_rsekizou.c b/src/overlays/actors/ovl_Bg_Hidan_Rsekizou/z_bg_hidan_rsekizou.c index 7f217026080..8046f278049 100644 --- a/src/overlays/actors/ovl_Bg_Hidan_Rsekizou/z_bg_hidan_rsekizou.c +++ b/src/overlays/actors/ovl_Bg_Hidan_Rsekizou/z_bg_hidan_rsekizou.c @@ -38,88 +38,33 @@ ActorProfile Bg_Hidan_Rsekizou_Profile = { /**/ BgHidanRsekizou_Draw, }; -static ColliderJntSphElementInit sJntSphElementsInit[] = { +static ColliderJntSphElementInit sJntSphElementsInit[6] = { { - { - ELEM_MATERIAL_UNK0, - { 0x20000000, HIT_SPECIAL_EFFECT_FIRE, 0x04 }, - { 0x00000000, HIT_BACKLASH_NONE, 0x00 }, - ATELEM_ON | ATELEM_SFX_NONE, - ACELEM_NONE, - OCELEM_NONE, - }, - { 1, { { 0, 30, 40 }, 25 }, 100 }, + { 0, { 0x20000000, 1, 4 }, { 0, 0, 0 }, 0x19, 0, 0 }, + { 1, { { 0, 0x1E, 0x28 }, 0x19 }, 0x64 }, }, { - { - ELEM_MATERIAL_UNK0, - { 0x20000000, HIT_SPECIAL_EFFECT_FIRE, 0x04 }, - { 0x00000000, HIT_BACKLASH_NONE, 0x00 }, - ATELEM_ON | ATELEM_SFX_NONE, - ACELEM_NONE, - OCELEM_NONE, - }, - { 1, { { -35, 32, 77 }, 32 }, 100 }, + { 0, { 0x20000000, 1, 4 }, { 0, 0, 0 }, 0x19, 0, 0 }, + { 1, { { -0x23, 0x20, 0x4D }, 0x20 }, 0x64 }, }, { - { - ELEM_MATERIAL_UNK0, - { 0x20000000, HIT_SPECIAL_EFFECT_FIRE, 0x04 }, - { 0x00000000, HIT_BACKLASH_NONE, 0x00 }, - ATELEM_ON | ATELEM_SFX_NONE, - ACELEM_NONE, - OCELEM_NONE, - }, - { 1, { { -80, 35, 130 }, 42 }, 100 }, + { 0, { 0x20000000, 1, 4 }, { 0, 0, 0 }, 0x19, 0, 0 }, + { 1, { { -0x50, 0x23, 0x82 }, 0x2A }, 0x64 }, }, { - { - ELEM_MATERIAL_UNK0, - { 0x20000000, HIT_SPECIAL_EFFECT_FIRE, 0x04 }, - { 0x00000000, HIT_BACKLASH_NONE, 0x00 }, - ATELEM_ON | ATELEM_SFX_NONE, - ACELEM_NONE, - OCELEM_NONE, - }, - { 1, { { 0, 30, -40 }, 25 }, 100 }, + { 0, { 0x20000000, 1, 4 }, { 0, 0, 0 }, 0x19, 0, 0 }, + { 1, { { 0, 0x1E, -0x28 }, 0x19 }, 0x64 }, }, { - { - ELEM_MATERIAL_UNK0, - { 0x20000000, HIT_SPECIAL_EFFECT_FIRE, 0x04 }, - { 0x00000000, HIT_BACKLASH_NONE, 0x00 }, - ATELEM_ON | ATELEM_SFX_NONE, - ACELEM_NONE, - OCELEM_NONE, - }, - { 1, { { 35, 32, -77 }, 32 }, 100 }, + { 0, { 0x20000000, 1, 4 }, { 0, 0, 0 }, 0x19, 0, 0 }, + { 1, { { 0x23, 0x20, -0x4D }, 0x20 }, 0x64 }, }, { - { - ELEM_MATERIAL_UNK0, - { 0x20000000, HIT_SPECIAL_EFFECT_FIRE, 0x04 }, - { 0x00000000, HIT_BACKLASH_NONE, 0x00 }, - ATELEM_ON | ATELEM_SFX_NONE, - ACELEM_NONE, - OCELEM_NONE, - }, - { 1, { { 80, 35, -130 }, 42 }, 100 }, + { 0, { 0x20000000, 1, 4 }, { 0, 0, 0 }, 0x19, 0, 0 }, + { 1, { { 0x50, 0x23, -0x82 }, 0x2A }, 0x64 }, }, }; - -static ColliderJntSphInit sJntSphInit = { - { - COL_MATERIAL_NONE, - AT_ON | AT_TYPE_ENEMY, - AC_NONE, - OC1_NONE, - OC2_TYPE_2, - COLSHAPE_JNTSPH, - }, - ARRAY_COUNT(sJntSphElementsInit), - sJntSphElementsInit, -}; - +static ColliderJntSphInit sJntSphInit = { { 0xA, 0x11, 0, 0, 0x20, 0 }, 6, sJntSphElementsInit }; static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(cullingVolumeScale, 400, ICHAIN_CONTINUE), @@ -135,20 +80,20 @@ void BgHidanRsekizou_Init(Actor* thisx, PlayState* play) { BgHidanRsekizou* this = (BgHidanRsekizou*)thisx; s32 i; STACK_PAD(s32); - CollisionHeader* colHeader; + CollisionHeader* sp30; - colHeader = NULL; + sp30 = NULL; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 0); - CollisionHeader_GetVirtual(&gFireTempleSpinningFlamethrowerCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + CollisionHeader_GetVirtual(&gFireTempleSpinningFlamethrowerCol, &sp30); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, sp30); Collider_InitJntSph(play, &this->collider); Collider_SetJntSph(play, &this->collider, &this->dyna.actor, &sJntSphInit, this->colliderElements); - for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { + for (i = 0; i < 6; i++) { this->collider.elements[i].dim.worldSphere.radius = this->collider.elements[i].dim.modelSphere.radius; } - this->burnFrame = 0; - this->bendFrame = 0; + this->unk166 = 0; + this->unk164 = 0; } void BgHidanRsekizou_Destroy(Actor* thisx, PlayState* play) { @@ -159,116 +104,100 @@ void BgHidanRsekizou_Destroy(Actor* thisx, PlayState* play) { } void BgHidanRsekizou_Update(Actor* thisx, PlayState* play) { - BgHidanRsekizou* this = (BgHidanRsekizou*)thisx; + STACK_PADS(s32, 4); + f32 sp24; s32 i; - ColliderJntSphElement* element; - STACK_PAD(s32); - f32 yawSine; - f32 yawCosine; - - this->burnFrame = (this->burnFrame + 1) % 8; + ColliderJntSphElement* temp_v0_2; + f32 temp_fv0; + BgHidanRsekizou* this = (BgHidanRsekizou*)thisx; - if (this->bendFrame != 0) { - this->bendFrame--; + this->unk166 = (this->unk166 + 1) % 8; + if (this->unk164 != 0) { + this->unk164--; } - - if (this->bendFrame == 0) { - this->bendFrame = 3; + if (this->unk164 == 0) { + this->unk164 = 3; } - - this->dyna.actor.shape.rot.y += 0x180; // Approximately 2 Degrees per Frame - yawSine = Math_SinS(this->dyna.actor.shape.rot.y); - yawCosine = Math_CosS(this->dyna.actor.shape.rot.y); - - for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { - element = &this->collider.elements[i]; - element->dim.worldSphere.center.x = this->dyna.actor.home.pos.x + - (yawCosine * element->dim.modelSphere.center.x) + - (yawSine * element->dim.modelSphere.center.z); - element->dim.worldSphere.center.y = (s16)this->dyna.actor.home.pos.y + element->dim.modelSphere.center.y; - element->dim.worldSphere.center.z = this->dyna.actor.home.pos.z - - (yawSine * element->dim.modelSphere.center.x) + - (yawCosine * element->dim.modelSphere.center.z); + this->dyna.actor.shape.rot.y += 0x180; + sp24 = Math_SinS(this->dyna.actor.shape.rot.y); + temp_fv0 = Math_CosS(this->dyna.actor.shape.rot.y); + for (i = 0; i < 6; i++) { + temp_v0_2 = &this->collider.elements[i]; + temp_v0_2->dim.worldSphere.center.x = this->dyna.actor.home.pos.x + + (temp_fv0 * temp_v0_2->dim.modelSphere.center.x) + + (sp24 * temp_v0_2->dim.modelSphere.center.z); + temp_v0_2->dim.worldSphere.center.y = (s16)this->dyna.actor.home.pos.y + temp_v0_2->dim.modelSphere.center.y; + temp_v0_2->dim.worldSphere.center.z = this->dyna.actor.home.pos.z - + (sp24 * temp_v0_2->dim.modelSphere.center.x) + + (temp_fv0 * temp_v0_2->dim.modelSphere.center.z); } - CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); - Actor_PlaySfx_Flagged(&this->dyna.actor, NA_SE_EV_FIRE_PILLAR - SFX_FLAG); + Actor_PlaySfx_Flagged(&this->dyna.actor, 0x2033U); } -Gfx* BgHidanRsekizou_DrawFireball(PlayState* play, BgHidanRsekizou* this, s16 frame, MtxF* mf, s32 a, - Gfx* displayList) { - f32 coss; - f32 sins; - s32 temp; - f32 fVar6; - f32 tmpf7; - - temp = (((this->burnFrame + frame) % 8) * 7) * (1.0f / 7.0f); - gSPSegment(displayList++, 0x09, SEGMENTED_TO_VIRTUAL(sFireballsTexs[temp])); - - frame++; - fVar6 = (frame != 4) ? frame + ((3 - this->bendFrame) * (1.0f / 3.0f)) : frame; - - gDPSetPrimColor(displayList++, 0, 1, 255, 255, 0, 150); - gDPSetEnvColor(displayList++, 255, 0, 0, 255); - - if (a == 0) { - sins = -Math_SinS(this->dyna.actor.shape.rot.y - (frame * 1500)); - coss = -Math_CosS(this->dyna.actor.shape.rot.y - (frame * 1500)); +Gfx* func_8088C70C(GraphicsContext** arg0, BgHidanRsekizou* arg1, s16 arg2, MtxF* arg3, s32 arg4, Gfx* arg5) { + s32 i; + f32 sp58; + f32 temp_fv1; + f32 var_fa1; + f32 var_fa0; + + i = (s32)(((arg1->unk166 + arg2) % 8) * 7 * 0.14285715f); + gSPSegment(arg5++, 9, SEGMENTED_TO_VIRTUAL(sFireballsTexs[i])); + arg2 = arg2 + 1; + if (arg2 != 4) { + var_fa1 = arg2 + ((3 - arg1->unk164) * 0.33333334f); } else { - sins = Math_SinS(this->dyna.actor.shape.rot.y - (frame * 1500)); - coss = Math_CosS(this->dyna.actor.shape.rot.y - (frame * 1500)); + var_fa1 = arg2; } - - mf->xx = mf->yy = mf->zz = (0.7f * fVar6) + 0.5f; - tmpf7 = (((((0.7f * fVar6) + 0.5f) * 10.0f) * fVar6) + 20.0f); - - mf->xw = (tmpf7 * sins) + this->dyna.actor.world.pos.x; - mf->yw = (this->dyna.actor.world.pos.y + 30.0f) + ((7.0f / 10.0f) * fVar6); - mf->zw = (tmpf7 * coss) + this->dyna.actor.world.pos.z; - - gSPMatrix(displayList++, - Matrix_MtxFToMtx(MATRIX_CHECK_FLOATS(mf, "../z_bg_hidan_rsekizou.c", 543), - GRAPH_ALLOC(play->state.gfxCtx, sizeof(Mtx))), + gDPSetPrimColor(arg5++, 0x00, 0x01, 255, 255, 0, 150); + gDPSetEnvColor(arg5++, 255, 0, 0, 255); + if (arg4 == 0) { + sp58 = -Math_SinS((s16)(arg1->dyna.actor.shape.rot.y - (arg2 * 0x5DC))); + var_fa0 = -Math_CosS((s16)(arg1->dyna.actor.shape.rot.y - (arg2 * 0x5DC))); + } else { + sp58 = Math_SinS((s16)(arg1->dyna.actor.shape.rot.y - (arg2 * 0x5DC))); + var_fa0 = Math_CosS((s16)(arg1->dyna.actor.shape.rot.y - (arg2 * 0x5DC))); + } + arg3->mf[0][0] = arg3->mf[1][1] = arg3->mf[2][2] = (0.7f * var_fa1) + 0.5f; + temp_fv1 = (((0.7f * var_fa1) + 0.5f) * 10.0f * var_fa1) + 20.0f; + arg3->mf[3][0] = (temp_fv1 * sp58) + arg1->dyna.actor.world.pos.x; + arg3->mf[3][1] = arg1->dyna.actor.world.pos.y + 30.0f + (0.70f * var_fa1); + arg3->mf[3][2] = (temp_fv1 * var_fa0) + arg1->dyna.actor.world.pos.z; + gSPMatrix(arg5++, + Matrix_MtxFToMtx(MATRIX_CHECK_FLOATS(arg3, "../z_bg_hidan_rsekizou.c", 543), GRAPH_ALLOC(*arg0, 0x40U)), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(displayList++, gFireTempleFireballDL); - - return displayList; + gSPDisplayList(arg5++, gFireTempleFireballDL); + return arg5; } void BgHidanRsekizou_Draw(Actor* thisx, PlayState* play) { BgHidanRsekizou* this = (BgHidanRsekizou*)thisx; - s32 i; STACK_PAD(s32); - MtxF mf; + s32 var_s0; + MtxF sp5C; OPEN_DISPS(play->state.gfxCtx, "../z_bg_hidan_rsekizou.c", 564); - Gfx_SetupDL_25Opa(play->state.gfxCtx); - MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx, "../z_bg_hidan_rsekizou.c", 568); gSPDisplayList(POLY_OPA_DISP++, gFireTempleSpinningFlamethrowerDL); - Matrix_MtxFCopy(&mf, &gIdentityMtxF); - + Matrix_MtxFCopy(&sp5C, &gIdentityMtxF); POLY_XLU_DISP = Gfx_SetupDL(POLY_XLU_DISP, SETUPDL_20); - - if ((s16)((Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) - this->dyna.actor.shape.rot.y) - 0x2E6C) >= 0) { - for (i = 3; i >= 0; i--) { - POLY_XLU_DISP = BgHidanRsekizou_DrawFireball(play, this, i, &mf, 0, POLY_XLU_DISP); + if ((s16)((Camera_GetCamDirYaw(play->cameraPtrs[play->activeCamId]) - this->dyna.actor.shape.rot.y) - 0x2E6C) >= + 0) { + for (var_s0 = 3; var_s0 >= 0; var_s0--) { + POLY_XLU_DISP = func_8088C70C(&play->state.gfxCtx, this, var_s0, &sp5C, 0, POLY_XLU_DISP); } - - for (i = 0; i < 4; i++) { - POLY_XLU_DISP = BgHidanRsekizou_DrawFireball(play, this, i, &mf, 1, POLY_XLU_DISP); + for (var_s0 = 0; var_s0 < 4; var_s0++) { + POLY_XLU_DISP = func_8088C70C(&play->state.gfxCtx, this, var_s0, &sp5C, 1, POLY_XLU_DISP); } } else { - for (i = 3; i >= 0; i--) { - POLY_XLU_DISP = BgHidanRsekizou_DrawFireball(play, this, i, &mf, 1, POLY_XLU_DISP); + for (var_s0 = 3; var_s0 >= 0; var_s0--) { + POLY_XLU_DISP = func_8088C70C(&play->state.gfxCtx, this, var_s0, &sp5C, 1, POLY_XLU_DISP); } - - for (i = 0; i < 4; i++) { - POLY_XLU_DISP = BgHidanRsekizou_DrawFireball(play, this, i, &mf, 0, POLY_XLU_DISP); + for (var_s0 = 0; var_s0 < 4; var_s0++) { + POLY_XLU_DISP = func_8088C70C(&play->state.gfxCtx, this, var_s0, &sp5C, 0, POLY_XLU_DISP); } } - CLOSE_DISPS(play->state.gfxCtx, "../z_bg_hidan_rsekizou.c", 600); } diff --git a/src/overlays/actors/ovl_Bg_Hidan_Rsekizou/z_bg_hidan_rsekizou.h b/src/overlays/actors/ovl_Bg_Hidan_Rsekizou/z_bg_hidan_rsekizou.h index 7810d0f4111..a4d7df1a162 100644 --- a/src/overlays/actors/ovl_Bg_Hidan_Rsekizou/z_bg_hidan_rsekizou.h +++ b/src/overlays/actors/ovl_Bg_Hidan_Rsekizou/z_bg_hidan_rsekizou.h @@ -7,11 +7,11 @@ struct BgHidanRsekizou; typedef struct BgHidanRsekizou { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x0164 */ s16 bendFrame; - /* 0x0166 */ s16 burnFrame; - /* 0x0168 */ ColliderJntSph collider; - /* 0x0188 */ ColliderJntSphElement colliderElements[6]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x164 */ s16 unk164; + /* 0x166 */ s16 unk166; + /* 0x168 */ ColliderJntSph collider; + /* 0x188 */ ColliderJntSphElement colliderElements[6]; } BgHidanRsekizou; // size = 0x0308 #endif diff --git a/src/overlays/actors/ovl_Bg_Hidan_Syoku/z_bg_hidan_syoku.c b/src/overlays/actors/ovl_Bg_Hidan_Syoku/z_bg_hidan_syoku.c index c13d692cd61..fd7435fe354 100644 --- a/src/overlays/actors/ovl_Bg_Hidan_Syoku/z_bg_hidan_syoku.c +++ b/src/overlays/actors/ovl_Bg_Hidan_Syoku/z_bg_hidan_syoku.c @@ -1,6 +1,6 @@ /* * File: z_bg_hidan_syoku.c - * Overlay: ovl_Bg_Hidan_Syoku + * Overlay: Bg_Hidan_Syoku * Description: Stone Elevator in the Fire Temple */ @@ -41,8 +41,8 @@ static InitChainEntry sInitChain[] = { }; void BgHidanSyoku_Init(Actor* thisx, PlayState* play) { - STACK_PAD(s32); BgHidanSyoku* this = (BgHidanSyoku*)thisx; + STACK_PAD(s32); CollisionHeader* colHeader = NULL; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); @@ -60,24 +60,24 @@ void BgHidanSyoku_Destroy(Actor* thisx, PlayState* play) { } void func_8088F47C(BgHidanSyoku* this) { - this->timer = 60; + this->unk_16A = 0x3C; Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); this->actionFunc = func_8088F62C; } void func_8088F4B8(BgHidanSyoku* this, PlayState* play) { if (Flags_GetClear(play, this->dyna.actor.room) && DynaPolyActor_IsPlayerOnTop(&this->dyna)) { - this->timer = 140; + this->unk_16A = 0x8C; this->actionFunc = func_8088F514; } } void func_8088F514(BgHidanSyoku* this, PlayState* play) { - if (this->timer != 0) { - this->timer--; + if (this->unk_16A != 0) { + this->unk_16A -= 1; } - this->dyna.actor.world.pos.y = (cosf(this->timer * (M_PI / 140)) * 540.0f) + this->dyna.actor.home.pos.y; - if (this->timer == 0) { + this->dyna.actor.world.pos.y = (cosf(this->unk_16A * (M_PI / 140)) * 540.0f) + this->dyna.actor.home.pos.y; + if (this->unk_16A == 0) { func_8088F47C(this); } else { Actor_PlaySfx_Flagged(&this->dyna.actor, NA_SE_EV_ELEVATOR_MOVE3 - SFX_FLAG); @@ -85,11 +85,11 @@ void func_8088F514(BgHidanSyoku* this, PlayState* play) { } void func_8088F5A0(BgHidanSyoku* this, PlayState* play) { - if (this->timer != 0) { - this->timer--; + if (this->unk_16A != 0) { + this->unk_16A -= 1; } - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y - (cosf(this->timer * (M_PI / 140)) * 540.0f); - if (this->timer == 0) { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y - (cosf(this->unk_16A * (M_PI / 140)) * 540.0f); + if (this->unk_16A == 0) { func_8088F47C(this); } else { Actor_PlaySfx_Flagged(&this->dyna.actor, NA_SE_EV_ELEVATOR_MOVE3 - SFX_FLAG); @@ -97,11 +97,11 @@ void func_8088F5A0(BgHidanSyoku* this, PlayState* play) { } void func_8088F62C(BgHidanSyoku* this, PlayState* play) { - if (this->timer != 0) { - this->timer--; + if (this->unk_16A != 0) { + this->unk_16A -= 1; } - if (this->timer == 0) { - this->timer = 140; + if (this->unk_16A == 0) { + this->unk_16A = 0x8c; if (this->dyna.actor.world.pos.y < this->dyna.actor.home.pos.y) { this->actionFunc = func_8088F514; } else { diff --git a/src/overlays/actors/ovl_Bg_Hidan_Syoku/z_bg_hidan_syoku.h b/src/overlays/actors/ovl_Bg_Hidan_Syoku/z_bg_hidan_syoku.h index 6b169810c86..41efb902a93 100644 --- a/src/overlays/actors/ovl_Bg_Hidan_Syoku/z_bg_hidan_syoku.h +++ b/src/overlays/actors/ovl_Bg_Hidan_Syoku/z_bg_hidan_syoku.h @@ -12,7 +12,7 @@ typedef struct BgHidanSyoku { /* 0x0000 */ DynaPolyActor dyna; /* 0x0164 */ BgHidanSyokuActionFunc actionFunc; /* 0x0168 */ s16 unk_168; - /* 0x016A */ s16 timer; + /* 0x016A */ s16 unk_16A; } BgHidanSyoku; // size = 0x016C #endif diff --git a/src/overlays/actors/ovl_Bg_Ice_Turara/z_bg_ice_turara.c b/src/overlays/actors/ovl_Bg_Ice_Turara/z_bg_ice_turara.c index e9d7f935b65..6c3de826217 100644 --- a/src/overlays/actors/ovl_Bg_Ice_Turara/z_bg_ice_turara.c +++ b/src/overlays/actors/ovl_Bg_Ice_Turara/z_bg_ice_turara.c @@ -24,11 +24,11 @@ void BgIceTurara_Destroy(Actor* thisx, PlayState* play); void BgIceTurara_Update(Actor* thisx, PlayState* play); void BgIceTurara_Draw(Actor* thisx, PlayState* play); -void BgIceTurara_Stalagmite(BgIceTurara* this, PlayState* play); -void BgIceTurara_Wait(BgIceTurara* this, PlayState* play); -void BgIceTurara_Shiver(BgIceTurara* this, PlayState* play); -void BgIceTurara_Fall(BgIceTurara* this, PlayState* play); -void BgIceTurara_Regrow(BgIceTurara* this, PlayState* play); +void func_80892220(BgIceTurara*, PlayState*); +void func_80892280(BgIceTurara*, PlayState*); +void func_808922B8(BgIceTurara*, PlayState*); +void func_80892424(BgIceTurara*, PlayState*); +void func_80892574(BgIceTurara*, PlayState*); static ColliderCylinderInit sCylinderInit = { { @@ -49,7 +49,6 @@ static ColliderCylinderInit sCylinderInit = { }, { 13, 120, 0, { 0, 0, 0 } }, }; - ActorProfile Bg_Ice_Turara_Profile = { /**/ ACTOR_BG_ICE_TURARA, /**/ ACTORCAT_PROP, @@ -61,32 +60,35 @@ ActorProfile Bg_Ice_Turara_Profile = { /**/ BgIceTurara_Update, /**/ BgIceTurara_Draw, }; - static InitChainEntry sInitChain[] = { ICHAIN_F32(cullingVolumeScale, 600, ICHAIN_CONTINUE), ICHAIN_F32(gravity, -3, ICHAIN_CONTINUE), ICHAIN_F32(minVelocityY, -30, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; +static Vec3f D_8089267C = { 0.0f, -1.0f, 0.0f }; +static Color_RGBA8 D_80892688 = { 0xAA, 0xFF, 0xFF, 0xFF }; +static Color_RGBA8 D_8089268C = { 0, 0x32, 0x64, 0xFF }; void BgIceTurara_Init(Actor* thisx, PlayState* play) { BgIceTurara* this = (BgIceTurara*)thisx; STACK_PAD(s32); - CollisionHeader* colHeader = NULL; + CollisionHeader* sp24; + sp24 = NULL; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 0); - CollisionHeader_GetVirtual(&object_ice_objects_Col_002594, &colHeader); + CollisionHeader_GetVirtual(&object_ice_objects_Col_002594, &sp24); Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, &this->dyna.actor, &sCylinderInit); Collider_UpdateCylinder(&this->dyna.actor, &this->collider); - this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); - if (this->dyna.actor.params == TURARA_STALAGMITE) { - this->actionFunc = BgIceTurara_Stalagmite; + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, sp24); + if (this->dyna.actor.params == 0) { + this->unk164 = func_80892220; } else { this->dyna.actor.shape.rot.x = -0x8000; this->dyna.actor.shape.yOffset = 1200.0f; - this->actionFunc = BgIceTurara_Wait; + this->unk164 = func_80892280; } } @@ -97,90 +99,94 @@ void BgIceTurara_Destroy(Actor* thisx, PlayState* play) { Collider_DestroyCylinder(play, &this->collider); } -void BgIceTurara_Break(BgIceTurara* 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 }; - Vec3f vel; - Vec3f pos; - s32 j; - s32 i; +void func_80892040(BgIceTurara* this, PlayState* play, f32 arg2) { + Vec3f sp9C; + Vec3f sp90; + s32 var_s0; + s32 sp88; SfxSource_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++) { - pos.x = this->dyna.actor.world.pos.x + Rand_CenteredFloat(8.0f); - pos.y = this->dyna.actor.world.pos.y + (Rand_ZeroOne() * arg2) + (i * arg2); - pos.z = this->dyna.actor.world.pos.z + Rand_CenteredFloat(8.0f); - - vel.x = Rand_CenteredFloat(7.0f); - vel.z = Rand_CenteredFloat(7.0f); - vel.y = (Rand_ZeroOne() * 4.0f) + 8.0f; - - EffectSsEnIce_Spawn(play, &pos, (Rand_ZeroOne() * 0.2f) + 0.1f, &vel, &accel, &primColor, &envColor, 30); + sp88 = 0; + do { + for (var_s0 = 0; var_s0 < 10; var_s0++) { + sp90.x = Rand_CenteredFloat(8.0f) + this->dyna.actor.world.pos.x; + sp90.y = (Rand_ZeroOne() * arg2) + this->dyna.actor.world.pos.y + (sp88 * arg2); + sp90.z = Rand_CenteredFloat(8.0f) + this->dyna.actor.world.pos.z; + sp9C.x = Rand_CenteredFloat(7.0f); + sp9C.z = Rand_CenteredFloat(7.0f); + sp9C.y = (Rand_ZeroOne() * 4.0f) + 8.0f; + EffectSsEnIce_Spawn(play, &sp90, (Rand_ZeroOne() * 0.2f) + 0.1f, &sp9C, &D_8089267C, &D_80892688, + &D_8089268C, 30); } - } + sp88 = sp88 + 1; + } while (sp88 != 2); } -void BgIceTurara_Stalagmite(BgIceTurara* this, PlayState* play) { +void func_80892220(BgIceTurara* this, PlayState* play) { if (this->collider.base.acFlags & AC_HIT) { - BgIceTurara_Break(this, play, 50.0f); + func_80892040(this, play, 50.0f); Actor_Kill(&this->dyna.actor); - return; + } else { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } - CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } -void BgIceTurara_Wait(BgIceTurara* this, PlayState* play) { +void func_80892280(BgIceTurara* this, PlayState* play) { if (this->dyna.actor.xzDistToPlayer < 60.0f) { - this->shiverTimer = 10; - this->actionFunc = BgIceTurara_Shiver; + this->unk168 = 0xA; + this->unk164 = func_808922B8; } } -void BgIceTurara_Shiver(BgIceTurara* this, PlayState* play) { - s16 phi_v0_3; - s16 phi_v0_2; +void func_808922B8(BgIceTurara* this, PlayState* play) { + s32 var_v0_2; f32 sp28; - if (this->shiverTimer != 0) { - this->shiverTimer--; + if (this->unk168 != 0) { + this->unk168 -= 1; } - if (!(this->shiverTimer % 4)) { + if (!(this->unk168 % 4)) { Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_ICE_SWING); } - if (this->shiverTimer == 0) { + if (this->unk168 == 0) { this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x; this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z; Collider_UpdateCylinder(&this->dyna.actor, &this->collider); CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); - this->actionFunc = BgIceTurara_Fall; + this->unk164 = func_80892424; } else { sp28 = Rand_ZeroOne(); - phi_v0_2 = (Rand_ZeroOne() < 0.5f ? -1 : 1); - this->dyna.actor.world.pos.x = (phi_v0_2 * ((0.5f * sp28) + 0.5f)) + this->dyna.actor.home.pos.x; + if (Rand_ZeroOne() < 0.5f) { + var_v0_2 = -1; + } else { + var_v0_2 = 1; + } + this->dyna.actor.world.pos.x = (var_v0_2 * ((0.5f * sp28) + 0.5f)) + this->dyna.actor.home.pos.x; sp28 = Rand_ZeroOne(); - phi_v0_3 = (Rand_ZeroOne() < 0.5f ? -1 : 1); - this->dyna.actor.world.pos.z = (phi_v0_3 * ((0.5f * sp28) + 0.5f)) + this->dyna.actor.home.pos.z; + if (Rand_ZeroOne() < 0.5f) { + var_v0_2 = -1; + } else { + var_v0_2 = 1; + } + this->dyna.actor.world.pos.z = (var_v0_2 * ((0.5f * sp28) + 0.5f)) + this->dyna.actor.home.pos.z; } } -void BgIceTurara_Fall(BgIceTurara* this, PlayState* play) { +void func_80892424(BgIceTurara* this, PlayState* play) { if ((this->collider.base.atFlags & AT_HIT) || (this->dyna.actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { this->collider.base.atFlags &= ~AT_HIT; this->dyna.actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; if (this->dyna.actor.world.pos.y < this->dyna.actor.floorHeight) { this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight; } - BgIceTurara_Break(this, play, 40.0f); - if (this->dyna.actor.params == TURARA_STALACTITE_REGROW) { + func_80892040(this, play, 40.0f); + if (this->dyna.actor.params == 2) { this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 120.0f; DynaPoly_EnableCollision(play, &play->colCtx.dyna, this->dyna.bgId); - this->actionFunc = BgIceTurara_Regrow; + this->unk164 = func_80892574; } else { Actor_Kill(&this->dyna.actor); - return; } } else { Actor_MoveXZGravity(&this->dyna.actor); @@ -192,9 +198,9 @@ void BgIceTurara_Fall(BgIceTurara* this, PlayState* play) { } } -void BgIceTurara_Regrow(BgIceTurara* this, PlayState* play) { +void func_80892574(BgIceTurara* this, PlayState* play) { if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 1.0f)) { - this->actionFunc = BgIceTurara_Wait; + this->unk164 = func_80892280; this->dyna.actor.velocity.y = 0.0f; } } @@ -202,9 +208,11 @@ void BgIceTurara_Regrow(BgIceTurara* this, PlayState* play) { void BgIceTurara_Update(Actor* thisx, PlayState* play) { BgIceTurara* this = (BgIceTurara*)thisx; - this->actionFunc(this, play); + this->unk164(this, play); } void BgIceTurara_Draw(Actor* thisx, PlayState* play) { + STACK_PAD(s32); + Gfx_DrawDListOpa(play, object_ice_objects_DL_0023D0); } diff --git a/src/overlays/actors/ovl_Bg_Ice_Turara/z_bg_ice_turara.h b/src/overlays/actors/ovl_Bg_Ice_Turara/z_bg_ice_turara.h index c8779247cbc..5d025bcfa4a 100644 --- a/src/overlays/actors/ovl_Bg_Ice_Turara/z_bg_ice_turara.h +++ b/src/overlays/actors/ovl_Bg_Ice_Turara/z_bg_ice_turara.h @@ -8,17 +8,12 @@ struct BgIceTurara; typedef void (*BgIceTuraraActionFunc)(struct BgIceTurara*, struct PlayState*); -typedef enum BgIceTuraraType { - /* 0 */ TURARA_STALAGMITE, - /* 1 */ TURARA_STALACTITE, - /* 2 */ TURARA_STALACTITE_REGROW -} BgIceTuraraType; - typedef struct BgIceTurara { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x0164 */ BgIceTuraraActionFunc actionFunc; - /* 0x0168 */ s16 shiverTimer; - /* 0x016C */ ColliderCylinder collider; + /* 0x000 */ DynaPolyActor dyna; + /* 0x164 */ BgIceTuraraActionFunc unk164; + /* 0x168 */ s16 unk168; + /* 0x16A */ char pad16A[2]; + /* 0x16C */ ColliderCylinder collider; } BgIceTurara; // size = 0x01B8 #endif diff --git a/src/overlays/actors/ovl_Bg_Jya_1flift/z_bg_jya_1flift.c b/src/overlays/actors/ovl_Bg_Jya_1flift/z_bg_jya_1flift.c index 444b4dbb102..fe3bf4ed86a 100644 --- a/src/overlays/actors/ovl_Bg_Jya_1flift/z_bg_jya_1flift.c +++ b/src/overlays/actors/ovl_Bg_Jya_1flift/z_bg_jya_1flift.c @@ -33,7 +33,7 @@ void BgJya1flift_SetupDoNothing(BgJya1flift* this); void BgJya1flift_ResetMoveDelay(BgJya1flift* this); void BgJya1flift_DelayMove(BgJya1flift* this, PlayState* play); -static u8 sIsSpawned = false; +static u8 sHasSpawned = false; ActorProfile Bg_Jya_1flift_Profile = { /**/ ACTOR_BG_JYA_1FLIFT, @@ -105,10 +105,11 @@ void BgJya1flift_InitCollision(Actor* thisx, PlayState* play) { void BgJya1flift_Init(Actor* thisx, PlayState* play) { BgJya1flift* this = (BgJya1flift*)thisx; - PRINTF(T("(1Fリフト)(flag %d)(room %d)\n", "(1F lift)(flag %d)(room %d)\n"), sIsSpawned, + + PRINTF(T("(1Fリフト)(flag %d)(room %d)\n", "(1F lift)(flag %d)(room %d)\n"), sHasSpawned, play->roomCtx.curRoom.num); this->hasInitialized = false; - if (sIsSpawned) { + if (sHasSpawned) { Actor_Kill(thisx); return; } @@ -121,7 +122,7 @@ void BgJya1flift_Init(Actor* thisx, PlayState* play) { BgJya1flift_SetupWaitForSwitch(this); } thisx->room = -1; - sIsSpawned = true; + sHasSpawned = true; this->hasInitialized = true; } @@ -129,7 +130,7 @@ void BgJya1flift_Destroy(Actor* thisx, PlayState* play) { BgJya1flift* this = (BgJya1flift*)thisx; if (this->hasInitialized) { - sIsSpawned = false; + sHasSpawned = false; Collider_DestroyCylinder(play, &this->collider); DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } diff --git a/src/overlays/actors/ovl_Bg_Jya_Bigmirror/z_bg_jya_bigmirror.c b/src/overlays/actors/ovl_Bg_Jya_Bigmirror/z_bg_jya_bigmirror.c index 23f5e88751c..9751e26dbca 100644 --- a/src/overlays/actors/ovl_Bg_Jya_Bigmirror/z_bg_jya_bigmirror.c +++ b/src/overlays/actors/ovl_Bg_Jya_Bigmirror/z_bg_jya_bigmirror.c @@ -1,9 +1,3 @@ -/* - * File: z_bg_jya_bigmirror.c - * Overlay: ovl_Bg_Jya_Bigmirror - * Description: Ceiling mirror and puzzle in Spirit Temple top rooms - */ - #include "z_bg_jya_bigmirror.h" #include "src/overlays/actors/ovl_Bg_Jya_Cobra/z_bg_jya_cobra.h" @@ -24,7 +18,13 @@ void BgJyaBigmirror_Destroy(Actor* thisx, PlayState* play); void BgJyaBigmirror_Update(Actor* thisx, PlayState* play); void BgJyaBigmirror_Draw(Actor* thisx, PlayState* play); -static u8 sIsSpawned = false; +void func_808936E0(BgJyaBigmirror* this, PlayState* play); +void func_80893750(BgJyaBigmirror* this2, PlayState* play); +void func_8089394C(BgJyaBigmirror* this, PlayState* play); +void func_8089399C(BgJyaBigmirror* this2, PlayState* play); +void func_80893C68(BgJyaBigmirror* this, PlayState* play); + +static u8 D_80893ED0 = 0; ActorProfile Bg_Jya_Bigmirror_Profile = { /**/ ACTOR_BG_JYA_BIGMIRROR, @@ -38,142 +38,130 @@ ActorProfile Bg_Jya_Bigmirror_Profile = { /**/ BgJyaBigmirror_Draw, }; -typedef struct BigMirrorDataEntry { - /* 0x00 */ Vec3f pos; - /* 0x0C */ s16 params; - /* 0x0E */ s16 solvedRotY; - /* 0x10 */ s16 initRotY; -} BigMirrorDataEntry; // size = 0x14 - -static BigMirrorDataEntry sCobraSpawnData[] = { - { { -560.0f, 1743.0f, -310.0f }, 0xFF01, 0x4000, 0x8000 }, - { { 60.0f, 1743.0f, -310.0f }, 0xFF02, 0x8000, 0xA000 }, +typedef struct struct_80893EF4 { + /* 0x00 */ Vec3f unk0; + /* 0x0C */ s16 unkC; + /* 0x0E */ s16 unkE; + /* 0x10 */ s16 unk10; +} struct_80893EF4; +static struct_80893EF4 D_80893EF4[2] = { + { { -560.0f, 1743.0f, -310.0f }, -0xFF, 0x4000, 0x8000 }, + { { 60.0f, 1743.0f, -310.0f }, -0xFE, 0x8000, 0xA000 }, }; +static u8 D_80893F1C[4] = { 1, 2, 0, 0 }; +static s16 D_80893F20[4] = { 5, 7, 8, 0 }; +static Vec3f D_80893F28[3] = { + { 60.0f, 1802.0f, -1102.0f }, + { -560.0f, 1800.0f, -310.0f }, + { 60.0f, 1800.0f, -310.0f }, +}; +static Vec3s D_80893F4C = { 0, 0, 0 }; -void BgJyaBigmirror_SetRoomFlag(Actor* thisx, PlayState* play) { - BgJyaBigmirror* this = (BgJyaBigmirror*)thisx; - - this->puzzleFlags &= - ~(BIGMIR_PUZZLE_IN_STATUE_ROOM | BIGMIR_PUZZLE_IN_1ST_TOP_ROOM | BIGMIR_PUZZLE_IN_2ND_TOP_ROOM); +void func_808936E0(BgJyaBigmirror* this, PlayState* play) { + this->unk15C &= ~0x38; if (play->roomCtx.curRoom.num == 5) { - this->puzzleFlags |= BIGMIR_PUZZLE_IN_STATUE_ROOM; + this->unk15C |= 8; } else if (play->roomCtx.curRoom.num == 0x19) { - this->puzzleFlags |= BIGMIR_PUZZLE_IN_1ST_TOP_ROOM; + this->unk15C |= 0x10; } else if (play->roomCtx.curRoom.num == 0x1A) { - this->puzzleFlags |= BIGMIR_PUZZLE_IN_2ND_TOP_ROOM; + this->unk15C |= 0x20; } } -void BgJyaBigmirror_HandleCobra(Actor* thisx, PlayState* play) { - static u8 cobraPuzzleFlags[] = { BIGMIR_PUZZLE_COBRA1_SOLVED, BIGMIR_PUZZLE_COBRA2_SOLVED }; - BgJyaBigmirror* this = (BgJyaBigmirror*)thisx; - BigMirrorDataEntry* curSpawnData; - BigmirrorCobra* curCobraInfo; +void func_80893750(BgJyaBigmirror* this2, PlayState* play) { s32 i; + BgJyaBigmirror_sub14C* new_var; + struct_80893EF4* new_var2; + BgJyaBigmirror* this = this2; - if (this->puzzleFlags & (BIGMIR_PUZZLE_IN_1ST_TOP_ROOM | BIGMIR_PUZZLE_IN_2ND_TOP_ROOM)) { + if (this->unk15C & 0x30) { for (i = 0; i < 2; i++) { - curSpawnData = &sCobraSpawnData[i]; - curCobraInfo = &this->cobraInfo[i]; - if (curCobraInfo->cobra != NULL) { - curCobraInfo->rotY = curCobraInfo->cobra->dyna.actor.shape.rot.y; - - if (curCobraInfo->rotY == curSpawnData->solvedRotY) { - this->puzzleFlags |= cobraPuzzleFlags[i]; + new_var2 = &D_80893EF4[i]; + new_var = &this->unk14C[i]; + if (new_var->unk0 != NULL) { + new_var->unk4 = new_var->unk0->shape.rot.y; + if (new_var->unk4 == new_var2->unkE) { + this->unk15C |= D_80893F1C[i]; } else { - this->puzzleFlags &= ~cobraPuzzleFlags[i]; + this->unk15C &= ~D_80893F1C[i]; } - #if DEBUG_FEATURES - if (curCobraInfo->cobra->dyna.actor.update == NULL) { - PRINTF(T("Error : コブラ削除された (%s %d)\n", "Error : Cobra deleted (%s %d)\n"), - "../z_bg_jya_bigmirror.c", 203); + if (new_var->unk0->update == NULL) { + PRINTF("Error : コブラ削除された (%s %d)\n", "../z_bg_jya_bigmirror.c", 203); } #endif } else { - curCobraInfo->cobra = (BgJyaCobra*)Actor_SpawnAsChild( - &play->actorCtx, &this->actor, play, ACTOR_BG_JYA_COBRA, curSpawnData->pos.x, curSpawnData->pos.y, - curSpawnData->pos.z, 0, curCobraInfo->rotY, 0, curSpawnData->params); + new_var->unk0 = + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_BG_JYA_COBRA, new_var2->unk0.x, + new_var2->unk0.y, new_var2->unk0.z, 0, new_var->unk4, 0, new_var2->unkC); this->actor.child = NULL; - - if (curCobraInfo->cobra == NULL) { - PRINTF(T("Error : コブラ発生失敗 (%s %d)\n", "Error : Cobra failed to spawn (%s %d)\n"), - "../z_bg_jya_bigmirror.c", 221); + if (new_var->unk0 == NULL) { + PRINTF("Error : コブラ発生失敗 (%s %d)\n", "../z_bg_jya_bigmirror.c", 221); } } } } else { - for (i = 0; i < 2; i++) { - curCobraInfo = &this->cobraInfo[i]; - if (curCobraInfo->cobra != NULL) { - if (curCobraInfo->cobra->dyna.actor.child != NULL) { - Actor_Kill(curCobraInfo->cobra->dyna.actor.child); - curCobraInfo->cobra->dyna.actor.child = NULL; + new_var = &this->unk14C[i]; + if (new_var->unk0 != NULL) { + if (new_var->unk0->child != NULL) { + Actor_Kill(new_var->unk0->child); + new_var->unk0->child = NULL; } - Actor_Kill(&curCobraInfo->cobra->dyna.actor); - curCobraInfo->cobra = NULL; + Actor_Kill(new_var->unk0); + new_var->unk0 = NULL; } } } } -void BgJyaBigmirror_SetBombiwaFlag(Actor* thisx, PlayState* play) { - BgJyaBigmirror* this = (BgJyaBigmirror*)thisx; - +void func_8089394C(BgJyaBigmirror* this, PlayState* play) { if (Flags_GetSwitch(play, 0x29)) { - this->puzzleFlags |= BIGMIR_PUZZLE_BOMBIWA_DESTROYED; + this->unk15C |= 4; } else { - this->puzzleFlags &= ~(BIGMIR_PUZZLE_BOMBIWA_DESTROYED); + this->unk15C &= ~4; } } -void BgJyaBigmirror_HandleMirRay(Actor* thisx, PlayState* play) { - static s16 sMirRayParamsVals[] = { 0x0005, 0x0007, 0x0008 }; - static Vec3f sMirRayPositions[] = { - { 60.0f, 1802.0f, -1102.0f }, - { -560.0f, 1800.0f, -310.0f }, - { 60.0f, 1800.0f, -310.0f }, - }; - BgJyaBigmirror* this = (BgJyaBigmirror*)thisx; - STACK_PAD(s32); - s32 lightBeamToggles[3]; - s32 i; +void func_8089399C(BgJyaBigmirror* this2, PlayState* play) { + s32 var_s1; + s32 var_v0; + s32 sp74[3]; + BgJyaBigmirror* this = this2; s32 mirRayObjectSlot; mirRayObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_MIR_RAY); - - if ((mirRayObjectSlot < 0) || (mirRayObjectSlot != this->mirRayObjectSlot)) { - this->lightBeams[2] = NULL; - this->lightBeams[1] = NULL; - this->lightBeams[0] = NULL; + if ((mirRayObjectSlot < 0) || ((mirRayObjectSlot != this->mirRayObjectSlot))) { + this->unk160[2] = NULL; + this->unk160[1] = NULL; + this->unk160[0] = NULL; } else { - // Only spawn if puzzle solved - lightBeamToggles[0] = (this->puzzleFlags & (BIGMIR_PUZZLE_IN_STATUE_ROOM | BIGMIR_PUZZLE_IN_1ST_TOP_ROOM)) && - (this->puzzleFlags & BIGMIR_PUZZLE_COBRA2_SOLVED) && - (this->puzzleFlags & BIGMIR_PUZZLE_COBRA1_SOLVED); - lightBeamToggles[1] = lightBeamToggles[2] = - this->puzzleFlags & (BIGMIR_PUZZLE_IN_1ST_TOP_ROOM | BIGMIR_PUZZLE_IN_2ND_TOP_ROOM); - - for (i = 0; i < 3; i++) { - if (lightBeamToggles[i]) { - if ((this->lightBeams[i] == NULL) && Object_IsLoaded(&play->objectCtx, mirRayObjectSlot)) { - - this->lightBeams[i] = - Actor_Spawn(&play->actorCtx, play, ACTOR_MIR_RAY, sMirRayPositions[i].x, sMirRayPositions[i].y, - sMirRayPositions[i].z, 0, 0, 0, sMirRayParamsVals[i]); - + var_v0 = (this->unk15C & 0x18) != 0; + if (var_v0 != 0) { + var_v0 = (this->unk15C & 2) != 0; + if (var_v0 != 0) { + var_v0 = (this->unk15C & 1) != 0; + } + } + sp74[0] = var_v0; + sp74[1] = sp74[2] = var_v0 = this->unk15C & 0x30; + + for (var_s1 = 0; var_s1 < 3; var_s1++) { + if (sp74[var_s1] != 0) { + if ((this->unk160[var_s1] == NULL) && (Object_IsLoaded(&play->objectCtx, mirRayObjectSlot) != 0)) { + this->unk160[var_s1] = + Actor_Spawn(&play->actorCtx, play, 0xB7, D_80893F28[var_s1].x, D_80893F28[var_s1].y, + D_80893F28[var_s1].z, 0, 0, 0, D_80893F20[var_s1]); #if DEBUG_FEATURES - if (this->lightBeams[i] == NULL) { - PRINTF(T("Error : Mir Ray 発生失敗 (%s %d)\n", "Error : Mir Ray failed to spawn (%s %d)\n"), - "../z_bg_jya_bigmirror.c", 310); + if (this->unk160[var_s1] == NULL) { + PRINTF("Error : Mir Ray 発生失敗 (%s %d)\n", "../z_bg_jya_bigmirror.c", 310); } #endif } } else { - if (this->lightBeams[i] != NULL) { - Actor_Kill(this->lightBeams[i]); - this->lightBeams[i] = NULL; + if (this->unk160[var_s1] != NULL) { + Actor_Kill(this->unk160[var_s1]); + this->unk160[var_s1] = NULL; } } } @@ -184,75 +172,69 @@ void BgJyaBigmirror_HandleMirRay(Actor* thisx, PlayState* play) { void BgJyaBigmirror_Init(Actor* thisx, PlayState* play) { BgJyaBigmirror* this = (BgJyaBigmirror*)thisx; - if (sIsSpawned) { + if (D_80893ED0 != 0) { Actor_Kill(&this->actor); return; } - Actor_SetScale(&this->actor, 0.1f); - this->cobraInfo[0].rotY = sCobraSpawnData[0].initRotY; - this->cobraInfo[1].rotY = sCobraSpawnData[1].initRotY; + this->unk14C[0].unk4 = D_80893EF4[0].unk10; + this->unk14C[1].unk4 = D_80893EF4[1].unk10; this->actor.room = -1; - sIsSpawned = true; - this->spawned = true; + D_80893ED0 = 1; + this->unk15D = 1; this->mirRayObjectSlot = -1; - - PRINTF(T("(jya 大鏡)(arg_data 0x%04x)\n", "(jya Big mirror)(arg_data 0x%04x)\n"), this->actor.params); + PRINTF("(jya 大鏡)(arg_data 0x%04x)\n", this->actor.params); } void BgJyaBigmirror_Destroy(Actor* thisx, PlayState* play) { BgJyaBigmirror* this = (BgJyaBigmirror*)thisx; - if (this->spawned) { - sIsSpawned = false; + if (this->unk15D != 0) { + D_80893ED0 = 0; } } void BgJyaBigmirror_Update(Actor* thisx, PlayState* play) { - BgJyaBigmirror_SetRoomFlag(thisx, play); - BgJyaBigmirror_HandleCobra(thisx, play); - BgJyaBigmirror_SetBombiwaFlag(thisx, play); - BgJyaBigmirror_HandleMirRay(thisx, play); + BgJyaBigmirror* this = (BgJyaBigmirror*)thisx; + + func_808936E0(this, play); + func_80893750(this, play); + func_8089394C(this, play); + func_8089399C(this, play); } -void BgJyaBigmirror_DrawLightBeam(Actor* thisx, PlayState* play) { - static Vec3s D_80893F4C = { 0, 0, 0 }; - BgJyaBigmirror* this = (BgJyaBigmirror*)thisx; - Actor* lift; +void func_80893C68(BgJyaBigmirror* this, PlayState* play) { + STACK_PAD(s32); + Actor* temp_v0; OPEN_DISPS(play->state.gfxCtx, "../z_bg_jya_bigmirror.c", 435); Gfx_SetupDL_25Xlu(play->state.gfxCtx); - lift = Actor_Find(&play->actorCtx, ACTOR_BG_JYA_LIFT, ACTORCAT_BG); - if (lift != NULL) { - this->liftHeight = lift->world.pos.y; + temp_v0 = Actor_Find(&play->actorCtx, ACTOR_BG_JYA_LIFT, ACTORCAT_BG); + if (temp_v0 != NULL) { + this->unk170 = temp_v0->world.pos.y; } Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, this->actor.world.pos.y + 40.0f, this->actor.world.pos.z, &this->actor.shape.rot); - Matrix_Scale(0.1f, (this->liftHeight * -(1.0f / 1280.0f)) + (1779.4f / 1280.0f), 0.1f, MTXMODE_APPLY); + Matrix_Scale(0.1f, (this->unk170 * -0.00078125f) + 1.3901563f, 0.1f, MTXMODE_APPLY); MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx, "../z_bg_jya_bigmirror.c", 457); gSPDisplayList(POLY_XLU_DISP++, gBigMirror1DL); - - if (lift != NULL) { - Matrix_SetTranslateRotateYXZ(lift->world.pos.x, lift->world.pos.y, lift->world.pos.z, &D_80893F4C); + if (temp_v0 != NULL) { + Matrix_SetTranslateRotateYXZ(temp_v0->world.pos.x, temp_v0->world.pos.y, temp_v0->world.pos.z, &D_80893F4C); Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx, "../z_bg_jya_bigmirror.c", 467); gSPDisplayList(POLY_XLU_DISP++, gBigMirror2DL); } - CLOSE_DISPS(play->state.gfxCtx, "../z_bg_jya_bigmirror.c", 476); } void BgJyaBigmirror_Draw(Actor* thisx, PlayState* play) { BgJyaBigmirror* this = (BgJyaBigmirror*)thisx; - if (this->puzzleFlags & BIGMIR_PUZZLE_IN_1ST_TOP_ROOM) { + if (this->unk15C & 0x10) { Gfx_DrawDListOpa(play, gBigMirror3DL); Gfx_DrawDListXlu(play, gBigMirror4DL); } - - if ((this->puzzleFlags & - (BIGMIR_PUZZLE_IN_STATUE_ROOM | BIGMIR_PUZZLE_IN_1ST_TOP_ROOM | BIGMIR_PUZZLE_IN_2ND_TOP_ROOM)) && - (this->puzzleFlags & BIGMIR_PUZZLE_COBRA2_SOLVED) && (this->puzzleFlags & BIGMIR_PUZZLE_COBRA1_SOLVED)) { - BgJyaBigmirror_DrawLightBeam(&this->actor, play); + if ((this->unk15C & 0x38) && (this->unk15C & 2) && (this->unk15C & 1)) { + func_80893C68(this, play); } } diff --git a/src/overlays/actors/ovl_Bg_Jya_Bigmirror/z_bg_jya_bigmirror.h b/src/overlays/actors/ovl_Bg_Jya_Bigmirror/z_bg_jya_bigmirror.h index 15bc7f83e4c..437c627980d 100644 --- a/src/overlays/actors/ovl_Bg_Jya_Bigmirror/z_bg_jya_bigmirror.h +++ b/src/overlays/actors/ovl_Bg_Jya_Bigmirror/z_bg_jya_bigmirror.h @@ -4,28 +4,22 @@ #include "ultra64.h" #include "actor.h" -#define BIGMIR_PUZZLE_COBRA1_SOLVED (1 << 0) -#define BIGMIR_PUZZLE_COBRA2_SOLVED (1 << 1) -#define BIGMIR_PUZZLE_BOMBIWA_DESTROYED (1 << 2) -#define BIGMIR_PUZZLE_IN_STATUE_ROOM (1 << 3) -#define BIGMIR_PUZZLE_IN_1ST_TOP_ROOM (1 << 4) -#define BIGMIR_PUZZLE_IN_2ND_TOP_ROOM (1 << 5) - struct BgJyaBigmirror; -typedef struct BigmirrorCobra { - /* 0x00 */ struct BgJyaCobra* cobra; - /* 0x04 */ s16 rotY; -} BigmirrorCobra; // size = 0x08 +typedef struct BgJyaBigmirror_sub14C { + Actor* unk0; + s16 unk4; +} BgJyaBigmirror_sub14C; typedef struct BgJyaBigmirror { - /* 0x0000 */ Actor actor; - /* 0x014C */ BigmirrorCobra cobraInfo[2]; - /* 0x015C */ u8 puzzleFlags; - /* 0x015D */ u8 spawned; - /* 0x0160 */ Actor* lightBeams[3]; - /* 0x016C */ s32 mirRayObjectSlot; - /* 0x0170 */ f32 liftHeight; -} BgJyaBigmirror; // size = 0x0174 + /* 0x000 */ Actor actor; + /* 0x14C */ BgJyaBigmirror_sub14C unk14C[2]; + /* 0x15C */ u8 unk15C; + /* 0x15D */ u8 unk15D; + /* 0x15E */ char pad15E[2]; /* maybe part of unk15D[3]? */ + /* 0x160 */ Actor* unk160[3]; + /* 0x16C */ s32 mirRayObjectSlot; + /* 0x170 */ f32 unk170; +} BgJyaBigmirror; // size = 0x174 #endif diff --git a/src/overlays/actors/ovl_Bg_Jya_Bombchuiwa/z_bg_jya_bombchuiwa.c b/src/overlays/actors/ovl_Bg_Jya_Bombchuiwa/z_bg_jya_bombchuiwa.c index 47edae4f9ab..ee24f45daa7 100644 --- a/src/overlays/actors/ovl_Bg_Jya_Bombchuiwa/z_bg_jya_bombchuiwa.c +++ b/src/overlays/actors/ovl_Bg_Jya_Bombchuiwa/z_bg_jya_bombchuiwa.c @@ -92,14 +92,14 @@ void BgJyaBombchuiwa_SetDrawFlags(BgJyaBombchuiwa* this, u8 drawFlags) { void BgJyaBombchuiwa_Init(Actor* thisx, PlayState* play) { BgJyaBombchuiwa* this = (BgJyaBombchuiwa*)thisx; - Actor_ProcessInitChain(&this->actor, sInitChain); + Actor_ProcessInitChain(thisx, sInitChain); BgJyaBombchuiwa_SetupCollider(this, play); - if (Flags_GetSwitch(play, PARAMS_GET_U(this->actor.params, 0, 6))) { + if (Flags_GetSwitch(play, PARAMS_GET_U(thisx->params, 0, 6))) { BgJyaBombchuiwa_SpawnLightRay(this, play); } else { BgJyaBombchuiwa_SetupWaitForExplosion(this, play); } - Actor_SetFocus(&this->actor, 0.0f); + Actor_SetFocus(thisx, 0.0f); } void BgJyaBombchuiwa_Destroy(Actor* thisx, PlayState* play2) { diff --git a/src/overlays/actors/ovl_Bg_Jya_Bombiwa/z_bg_jya_bombiwa.c b/src/overlays/actors/ovl_Bg_Jya_Bombiwa/z_bg_jya_bombiwa.c index 4da2cdee3e3..4bee0e70c18 100644 --- a/src/overlays/actors/ovl_Bg_Jya_Bombiwa/z_bg_jya_bombiwa.c +++ b/src/overlays/actors/ovl_Bg_Jya_Bombiwa/z_bg_jya_bombiwa.c @@ -1,9 +1,3 @@ -/* - * File: z_bg_jya_bombiwa.c - * Overlay: ovl_Bg_Jya_Bombiwa - * Description: Spirit Temple top room bombable wall - */ - #include "z_bg_jya_bombiwa.h" #include "src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.h" @@ -93,31 +87,31 @@ void BgJyaBombiwa_SetupDynaPoly(BgJyaBombiwa* this, PlayState* play, CollisionHe } void BgJyaBombiwa_InitCollider(BgJyaBombiwa* this, PlayState* play) { - STACK_PAD(s32); + Actor* thisx = &this->dyna.actor; Collider_InitJntSph(play, &this->collider); - Collider_SetJntSph(play, &this->collider, &this->dyna.actor, &sJntSphInit, this->colliderElements); + Collider_SetJntSph(play, &this->collider, thisx, &sJntSphInit, &this->colliderElements); } void BgJyaBombiwa_Init(Actor* thisx, PlayState* play) { BgJyaBombiwa* this = (BgJyaBombiwa*)thisx; - if (PARAMS_GET_U(this->dyna.actor.params, 0, 6) != 0x29) { + if (PARAMS_GET_U(thisx->params, 0, 6) != 0x29) { PRINTF_COLOR_WARNING(); PRINTF(T("Warning : Switch Number が変更された(%s %d)(SW %d)\n", "Warning : Switch Number has been changed (%s %d)(SW %d)\n"), - "../z_bg_jya_bombiwa.c", 218, PARAMS_GET_U(this->dyna.actor.params, 0, 6)); + "../z_bg_jya_bombiwa.c", 218, PARAMS_GET_U(thisx->params, 0, 6)); PRINTF_RST(); } BgJyaBombiwa_SetupDynaPoly(this, play, &gBombiwaCol, 0); BgJyaBombiwa_InitCollider(this, play); - if (Flags_GetSwitch(play, PARAMS_GET_U(this->dyna.actor.params, 0, 6))) { - Actor_Kill(&this->dyna.actor); + if (Flags_GetSwitch(play, PARAMS_GET_U(thisx->params, 0, 6))) { + Actor_Kill(thisx); } else { - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + Actor_ProcessInitChain(thisx, sInitChain); PRINTF(T("(jya 爆弾で破壊岩)(arg_data 0x%04x)\n", "(jya bomb destroys rocks)(arg_data 0x%04x)\n"), - this->dyna.actor.params); + thisx->params); } } diff --git a/src/overlays/actors/ovl_Bg_Jya_Bombiwa/z_bg_jya_bombiwa.h b/src/overlays/actors/ovl_Bg_Jya_Bombiwa/z_bg_jya_bombiwa.h index 8888d372d66..c1d564eea90 100644 --- a/src/overlays/actors/ovl_Bg_Jya_Bombiwa/z_bg_jya_bombiwa.h +++ b/src/overlays/actors/ovl_Bg_Jya_Bombiwa/z_bg_jya_bombiwa.h @@ -10,7 +10,7 @@ typedef struct BgJyaBombiwa { /* 0x0000 */ DynaPolyActor dyna; /* 0x0164 */ s32 unk_164; /* 0x0168 */ ColliderJntSph collider; - /* 0x0188 */ ColliderJntSphElement colliderElements[1]; + /* 0x0188 */ ColliderJntSphElement colliderElements; } BgJyaBombiwa; // size = 0x01C8 #endif diff --git a/src/overlays/actors/ovl_Bg_Jya_Cobra/z_bg_jya_cobra.c b/src/overlays/actors/ovl_Bg_Jya_Cobra/z_bg_jya_cobra.c index 51e6c623b86..65f06d44ae8 100644 --- a/src/overlays/actors/ovl_Bg_Jya_Cobra/z_bg_jya_cobra.c +++ b/src/overlays/actors/ovl_Bg_Jya_Cobra/z_bg_jya_cobra.c @@ -184,13 +184,13 @@ void func_80895A70(BgJyaCobra* this) { } break; case 1: - mirRay = (MirRay*)mirror->lightBeams[1]; + mirRay = (MirRay*)mirror->unk160[1]; if (mirRay == NULL) { return; } break; case 2: - mirRay = (MirRay*)mirror->lightBeams[2]; + mirRay = (MirRay*)mirror->unk160[2]; if (mirRay == NULL) { return; } @@ -198,19 +198,19 @@ void func_80895A70(BgJyaCobra* this) { } if (this->unk_18C <= 0.0f) { - mirRay->unLit = 1; + mirRay->unk2AE = 1; } else { Vec3f sp28; - mirRay->unLit = 0; - Math_Vec3f_Copy(&mirRay->sourcePt, &this->unk_180); + mirRay->unk2AE = 0; + Math_Vec3f_Copy(&mirRay->coneFrustumCenterTop, &this->unk_180); Matrix_RotateY(BINANG_TO_RAD(this->dyna.actor.shape.rot.y), MTXMODE_NEW); Matrix_RotateX(BINANG_TO_RAD(D_80897308[PARAMS_GET_U(this->dyna.actor.params, 0, 2)]), MTXMODE_APPLY); sp28.x = 0.0f; sp28.y = 0.0; sp28.z = this->unk_190 * 2800.0f; - Matrix_MultVec3f(&sp28, &mirRay->poolPt); - Math_Vec3f_Sum(&mirRay->sourcePt, &mirRay->poolPt, &mirRay->poolPt); + Matrix_MultVec3f(&sp28, &mirRay->coneFrustumCenterBase); + Math_Vec3f_Sum(&mirRay->coneFrustumCenterTop, &mirRay->coneFrustumCenterBase, &mirRay->coneFrustumCenterBase); } } @@ -231,9 +231,7 @@ void func_80895C74(BgJyaCobra* this, PlayState* play) { BgJyaBigmirror* mirror = (BgJyaBigmirror*)this->dyna.actor.parent; f32 phi_f0; - if (PARAMS_GET_U(params, 0, 2) == 2 && mirror != NULL && - (!(mirror->puzzleFlags & BIGMIR_PUZZLE_BOMBIWA_DESTROYED) || - !(mirror->puzzleFlags & BIGMIR_PUZZLE_COBRA1_SOLVED))) { + if (PARAMS_GET_U(params, 0, 2) == 2 && mirror != NULL && (!(mirror->unk15C & 4) || !(mirror->unk15C & 1))) { Math_StepToF(&this->unk_18C, 0.0f, 0.05f); } else { this->unk_18C = 1.0f; @@ -262,8 +260,7 @@ void func_80895C74(BgJyaCobra* this, PlayState* play) { phi_f0 = 0.34f; } else { phi_v0 = this->dyna.actor.shape.rot.y - 0x4000; - if (phi_v0 < 0x500 && phi_v0 > -0x500 && mirror != NULL && - (mirror->puzzleFlags & BIGMIR_PUZZLE_BOMBIWA_DESTROYED)) { + if (phi_v0 < 0x500 && phi_v0 > -0x500 && mirror != NULL && (mirror->unk15C & 4)) { phi_f0 = 0.34f; } } @@ -290,7 +287,7 @@ void BgJyaCobra_UpdateShadowFromSide(BgJyaCobra* this) { Vec3f spD4; Vec3f spC8; Vec3f spBC; - u8* shadowTex; + u8* temp_s2; s32 temp_x; s32 temp_z; s32 x; @@ -301,8 +298,8 @@ void BgJyaCobra_UpdateShadowFromSide(BgJyaCobra* this) { s32 l; s16 rotY; - shadowTex = COBRA_SHADOW_TEX_PTR(this); - Lib_MemSet(shadowTex, COBRA_SHADOW_TEX_SIZE, 0); + temp_s2 = (u8*)ALIGN16((s32)(&this->shadowTexture)); + Lib_MemSet(temp_s2, 0x1000, 0); Matrix_RotateX((M_PI / 4), MTXMODE_NEW); rotY = !PARAMS_GET_U(this->dyna.actor.params, 0, 2) ? (this->dyna.actor.shape.rot.y + 0x4000) @@ -333,7 +330,7 @@ void BgJyaCobra_UpdateShadowFromSide(BgJyaCobra* this) { if (temp_x & ~0x3F) { continue; } - shadowTex[temp_z + temp_x] |= D_8089731C[k][l]; + temp_s2[temp_z + temp_x] |= D_8089731C[k][l]; } } } @@ -362,20 +359,20 @@ void BgJyaCobra_UpdateShadowFromSide(BgJyaCobra* this) { if (temp_x & ~0x3F) { continue; } - shadowTex[temp_z + temp_x] |= D_80897398[k][l]; + temp_s2[temp_z + temp_x] |= D_80897398[k][l]; } } } } for (i = 0; i < 0x40; i++) { - shadowTex[0 * 0x40 + i] = 0; - shadowTex[0x3F * 0x40 + i] = 0; + temp_s2[0 * 0x40 + i] = 0; + temp_s2[0x3F * 0x40 + i] = 0; } for (j = 1; j < 0x3F; j++) { - shadowTex[j * 0x40 + 0] = 0; - shadowTex[j * 0x40 + 0x3F] = 0; + temp_s2[j * 0x40 + 0] = 0; + temp_s2[j * 0x40 + 0x3F] = 0; } } @@ -388,15 +385,15 @@ void BgJyaCobra_UpdateShadowFromTop(BgJyaCobra* this) { s32 j; s32 i_copy; s32 counter; - u8* shadowTex; + u8* temp_s0; u8* sp40; for (i = 0; i < 0x40; i++) { sp58[i] = SQ(i - 31.5f); } - sp40 = shadowTex = COBRA_SHADOW_TEX_PTR(this); - Lib_MemSet(shadowTex, COBRA_SHADOW_TEX_SIZE, 0); + sp40 = temp_s0 = (u8*)ALIGN16((u32)(&this->shadowTexture)); + Lib_MemSet(temp_s0, 0x1000, 0); for (i = 0; i != 0x40; i++) { f32 temp_f12 = sp58[i]; @@ -413,12 +410,12 @@ void BgJyaCobra_UpdateShadowFromTop(BgJyaCobra* this) { for (i_copy = 0x780, counter = 0; counter < 4; counter++, i_copy += 0x40) { i = i_copy; for (j = 4; j < 0x3C; j++) { - if (shadowTex[i_copy + j] < D_80897518[counter]) { - shadowTex[i_copy + j] = D_80897518[counter]; + if (temp_s0[i_copy + j] < D_80897518[counter]) { + temp_s0[i_copy + j] = D_80897518[counter]; } } - shadowTex[i + 0x3C] = 0x20; - shadowTex[i + 0x3] = 0x20; + temp_s0[i + 0x3C] = 0x20; + temp_s0[i + 0x3] = 0x20; } } @@ -448,7 +445,7 @@ void BgJyaCobra_Init(Actor* thisx, PlayState* play) { PRINTF(T("(jya コブラ)(arg_data 0x%04x)(act %x)(txt %x)(txt16 %x)\n", "(jya cobra)(arg_data 0x%04x)(act %x)(txt %x)(txt16 %x)\n"), - this->dyna.actor.params, this, &this->shadowTextureBuffer, COBRA_SHADOW_TEX_PTR(this)); + this->dyna.actor.params, this, &this->shadowTexture, ALIGN16((s32)(&this->shadowTexture))); } void BgJyaCobra_Destroy(Actor* thisx, PlayState* play) { @@ -616,9 +613,9 @@ void BgJyaCobra_DrawShadow(BgJyaCobra* this, PlayState* play) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 120); MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx, "../z_bg_jya_cobra.c", 994); - gDPLoadTextureBlock(POLY_XLU_DISP++, COBRA_SHADOW_TEX_PTR(this), G_IM_FMT_I, G_IM_SIZ_8b, COBRA_SHADOW_TEX_WIDTH, - COBRA_SHADOW_TEX_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); + gDPLoadTextureBlock(POLY_XLU_DISP++, ALIGN16((s32)(&this->shadowTexture)), G_IM_FMT_I, G_IM_SIZ_8b, 0x40, 0x40, 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); gSPDisplayList(POLY_XLU_DISP++, sShadowDL); @@ -638,8 +635,7 @@ void BgJyaCobra_Draw(Actor* thisx, PlayState* play) { if (PARAMS_GET_U(this->dyna.actor.params, 0, 2) == 2) { BgJyaBigmirror* mirror = (BgJyaBigmirror*)this->dyna.actor.parent; - if (mirror != NULL && (mirror->puzzleFlags & BIGMIR_PUZZLE_BOMBIWA_DESTROYED) && - (mirror->puzzleFlags & BIGMIR_PUZZLE_COBRA1_SOLVED)) { + if (mirror != NULL && (mirror->unk15C & 4) && (mirror->unk15C & 1)) { BgJyaCobra_DrawShadow(this, play); } } else { diff --git a/src/overlays/actors/ovl_Bg_Jya_Cobra/z_bg_jya_cobra.h b/src/overlays/actors/ovl_Bg_Jya_Cobra/z_bg_jya_cobra.h index 9f2a9d9f362..a050987240f 100644 --- a/src/overlays/actors/ovl_Bg_Jya_Cobra/z_bg_jya_cobra.h +++ b/src/overlays/actors/ovl_Bg_Jya_Cobra/z_bg_jya_cobra.h @@ -8,11 +8,6 @@ struct BgJyaCobra; typedef void (*BgJyaCobraActionFunc)(struct BgJyaCobra*, struct PlayState*); -#define COBRA_SHADOW_TEX_WIDTH 64 -#define COBRA_SHADOW_TEX_HEIGHT 64 -#define COBRA_SHADOW_TEX_SIZE (COBRA_SHADOW_TEX_WIDTH * COBRA_SHADOW_TEX_HEIGHT * G_IM_SIZ_8b_BYTES) -#define COBRA_SHADOW_TEX_PTR(this) (u8*)ALIGN16((uintptr_t)&(this)->shadowTextureBuffer) - typedef struct BgJyaCobra { /* 0x0000 */ DynaPolyActor dyna; /* 0x0164 */ BgJyaCobraActionFunc actionFunc; @@ -26,7 +21,7 @@ typedef struct BgJyaCobra { /* 0x0180 */ Vec3f unk_180; /* 0x018C */ f32 unk_18C; /* 0x0190 */ f32 unk_190; - /* 0x0194 */ u8 shadowTextureBuffer[COBRA_SHADOW_TEX_SIZE / sizeof(u8) + 0xF]; // Extra space to allow aligning actual texture to 0x10 + /* 0x0194 */ u8 shadowTexture[0x1010]; } BgJyaCobra; // size = 0x11A4 #endif diff --git a/src/overlays/actors/ovl_Bg_Jya_Goroiwa/z_bg_jya_goroiwa.c b/src/overlays/actors/ovl_Bg_Jya_Goroiwa/z_bg_jya_goroiwa.c index caa81e386dd..d6d61838708 100644 --- a/src/overlays/actors/ovl_Bg_Jya_Goroiwa/z_bg_jya_goroiwa.c +++ b/src/overlays/actors/ovl_Bg_Jya_Goroiwa/z_bg_jya_goroiwa.c @@ -157,7 +157,7 @@ void BgJyaGoroiwa_Move(BgJyaGoroiwa* this, PlayState* play) { this->collider.base.atFlags &= ~(AT_ON | AT_HIT); relYawTowardsPlayer = thisx->yawTowardsPlayer - thisx->world.rot.y; - if ((relYawTowardsPlayer > -0x4000) && (relYawTowardsPlayer < 0x4000)) { + if ((relYawTowardsPlayer >= -0x3FFF) && (relYawTowardsPlayer < 0x4000)) { thisx->world.rot.y += 0x8000; } @@ -203,10 +203,10 @@ void BgJyaGoroiwa_Wait(BgJyaGoroiwa* this, PlayState* play) { } void BgJyaGoroiwa_Update(Actor* thisx, PlayState* play) { + Player* player = GET_PLAYER(play); STACK_PAD(s32); BgJyaGoroiwa* this = (BgJyaGoroiwa*)thisx; - Player* player = GET_PLAYER(play); - s32 bgId; + s32 sp38; Vec3f checkPos; if (!(player->stateFlags1 & (PLAYER_STATE1_TALKING | PLAYER_STATE1_DEAD | PLAYER_STATE1_28 | PLAYER_STATE1_29))) { @@ -216,7 +216,7 @@ void BgJyaGoroiwa_Update(Actor* thisx, PlayState* play) { checkPos.y = this->actor.world.pos.y + 59.5f; checkPos.z = this->actor.world.pos.z; this->actor.floorHeight = - BgCheck_EntityRaycastDown4(&play->colCtx, &this->actor.floorPoly, &bgId, &this->actor, &checkPos); + BgCheck_EntityRaycastDown4(&play->colCtx, &this->actor.floorPoly, &sp38, &this->actor, &checkPos); BgJyaGoroiwa_UpdateCollider(this); if (this->collider.base.atFlags & AT_ON) { CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); diff --git a/src/overlays/actors/ovl_Bg_Jya_Haheniron/z_bg_jya_haheniron.c b/src/overlays/actors/ovl_Bg_Jya_Haheniron/z_bg_jya_haheniron.c index 7e91c89c794..b5d97bbb9cf 100644 --- a/src/overlays/actors/ovl_Bg_Jya_Haheniron/z_bg_jya_haheniron.c +++ b/src/overlays/actors/ovl_Bg_Jya_Haheniron/z_bg_jya_haheniron.c @@ -5,7 +5,6 @@ */ #include "z_bg_jya_haheniron.h" -#include "src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.h" #include "libc64/qrand.h" #include "array_count.h" @@ -25,12 +24,14 @@ void BgJyaHaheniron_Destroy(Actor* thisx, PlayState* play); void BgJyaHaheniron_Update(Actor* thisx, PlayState* play); void BgJyaHaheniron_Draw(Actor* thisx, PlayState* play); -void BgJyaHaheniron_SetupChairCrumble(BgJyaHaheniron* this); -void BgJyaHaheniron_ChairCrumble(BgJyaHaheniron* this, PlayState* play); -void BgJyaHaheniron_SetupPillarCrumble(BgJyaHaheniron* this); -void BgJyaHaheniron_PillarCrumble(BgJyaHaheniron* this, PlayState* play); -void BgJyaHaheniron_SetupRubbleCollide(BgJyaHaheniron* this); -void BgJyaHaheniron_RubbleCollide(BgJyaHaheniron* this, PlayState* play); +void func_808980C0(BgJyaHaheniron* this, PlayState* play); +void func_80898114(PlayState* play, Vec3f* arg1, Vec3f* arg2); +void func_8089843C(BgJyaHaheniron* this); +void func_8089844C(BgJyaHaheniron* this, PlayState* play); +void func_80898588(BgJyaHaheniron* this); +void func_80898598(BgJyaHaheniron* this, PlayState* play); +void func_8089861C(BgJyaHaheniron* this); +void func_8089862C(BgJyaHaheniron* this, PlayState* play); ActorProfile Bg_Jya_Haheniron_Profile = { /**/ ACTOR_BG_JYA_HAHENIRON, @@ -43,107 +44,81 @@ ActorProfile Bg_Jya_Haheniron_Profile = { /**/ BgJyaHaheniron_Update, /**/ BgJyaHaheniron_Draw, }; - -static ColliderJntSphElementInit sJntSphElementsInit[] = { - { - { - ELEM_MATERIAL_UNK0, - { 0xFFCFFFFF, HIT_SPECIAL_EFFECT_NONE, 0x04 }, - { 0x00000000, HIT_BACKLASH_NONE, 0x00 }, - ATELEM_ON | ATELEM_SFX_NORMAL, - ACELEM_NONE, - OCELEM_NONE, - }, - { 0, { { 0, 0, 0 }, 10 }, 100 }, - }, -}; - -static ColliderJntSphInit sJntSphInit = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - COL_MATERIAL_NONE, - AT_ON | AT_TYPE_ENEMY, - AC_ON, - OC1_NONE, - OC2_NONE, - COLSHAPE_JNTSPH, + { 0, { 0xFFCFFFFF, 0, 4 }, { 0, 0, 0 }, 1, 0, 0 }, + { 0, { { 0, 0, 0 }, 0xA }, 0x64 }, }, - ARRAY_COUNT(sJntSphElementsInit), - sJntSphElementsInit, }; - -static s16 sKakeraScales[] = { 5, 8, 11, 14, 17 }; - -static InitChainEntry sInitChain[] = { +static ColliderJntSphInit sJntSphInit = { { 0xA, 0x11, 1, 0, 0, 0 }, 1, sJntSphElementsInit }; +static s16 D_80898774[5] = { 5, 8, 0xB, 0xE, 0x11 }; +static InitChainEntry sInitChain[5] = { ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(minVelocityY, -15000, ICHAIN_CONTINUE), ICHAIN_F32(cullingVolumeDistance, 1000, ICHAIN_CONTINUE), ICHAIN_F32(cullingVolumeScale, 500, ICHAIN_CONTINUE), ICHAIN_F32(cullingVolumeDownward, 1000, ICHAIN_STOP), }; +static f32 D_80898794[3] = { 0.13f, 0.1f, 0.1f }; +static Vec3f D_808987A0 = { 0.0f, 14.0f, 0.0f }; +static Vec3f D_808987AC = { 0.0f, 8.0f, 0.0f }; +static Gfx* D_808987B8[] = { + gObjectJyaIronDL_000880, + gObjectJyaIronDL_000AE0, + gObjectJyaIronDL_000600, +}; -static f32 D_80898794[] = { 0.13f, 0.1f, 0.1f }; - -static Vec3f D_808987A0[] = { 0.0f, 14.0f, 0.0f }; - -static Vec3f D_808987AC[] = { 0.0f, 8.0f, 0.0f }; - -void BgJyaHaheniron_ColliderInit(BgJyaHaheniron* this, PlayState* play) { +void func_808980C0(BgJyaHaheniron* this, PlayState* play) { STACK_PAD(s32); Collider_InitJntSph(play, &this->collider); Collider_SetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); } -void BgJyaHaheniron_SpawnFragments(PlayState* play, Vec3f* vec1, Vec3f* vec2) { - Vec3f vel; - Vec3f pos; - s16 arg5; - s32 angle; - s32 i; - f32 rand1; - - for (angle = 0, i = 0; i < ARRAY_COUNT(sKakeraScales); i++) { - rand1 = Rand_ZeroOne() * 10.0f; - vel.x = (Math_SinS(angle) * rand1) + vec2->x; - vel.y = (Rand_ZeroOne() * 10.0f) + vec2->y; - vel.z = (Math_CosS(angle) * rand1) + vec2->z; - - rand1 = Rand_ZeroOne(); - if (rand1 < 0.2f) { - arg5 = 96; - } else if (rand1 < 0.8f) { - arg5 = 64; +void func_80898114(PlayState* play, Vec3f* arg1, Vec3f* arg2) { + Vec3f spB4; + Vec3f spA8; + f32 temp_fv0; + s32 var_s1; + s32 var_v0; + + for (var_s1 = 0; var_s1 < ARRAY_COUNT(D_80898774); var_s1++) { + temp_fv0 = Rand_ZeroOne() * 10.0f; + spB4.x = (Math_SinS(var_s1 * 0x3333) * temp_fv0) + arg2->x; + spB4.y = (Rand_ZeroOne() * 10.0f) + arg2->y; + spB4.z = (Math_CosS(var_s1 * 0x3333) * temp_fv0) + arg2->z; + temp_fv0 = Rand_ZeroOne(); + if (temp_fv0 < 0.2f) { + var_v0 = 0x60; + } else if (temp_fv0 < 0.8f) { + var_v0 = 0x40; } else { - arg5 = 32; + var_v0 = 0x20; } - - EffectSsKakera_Spawn(play, vec1, &vel, vec1, -350, arg5, 40, 4, 0, sKakeraScales[i], 0, 20, 40, - KAKERA_COLOR_NONE, OBJECT_JYA_IRON, gObjectJyaIronDL_000880); - angle += 0x3333; + EffectSsKakera_Spawn(play, arg1, &spB4, arg1, -350, (s16)var_v0, 0x28, 4, 0, D_80898774[var_s1], 0, 0x14, 40, + -1, OBJECT_JYA_IRON, gObjectJyaIronDL_000880); } - pos.x = vec1->x + (vec2->x * 5.0f); - pos.y = vec1->y + (vec2->y * 5.0f); - pos.z = vec1->z + (vec2->z * 5.0f); - func_80033480(play, &pos, 100.0f, 4, 100, 160, 1); + spA8.x = arg1->x + (arg2->x * 5.0f); + spA8.y = arg1->y + (arg2->y * 5.0f); + spA8.z = arg1->z + (arg2->z * 5.0f); + func_80033480(play, &spA8, 100.0f, 4, 0x64, 0xA0, 1U); } void BgJyaHaheniron_Init(Actor* thisx, PlayState* play) { - STACK_PAD(s32); BgJyaHaheniron* this = (BgJyaHaheniron*)thisx; Actor_ProcessInitChain(&this->actor, sInitChain); Actor_SetScale(&this->actor, D_80898794[this->actor.params]); if (this->actor.params == 0) { - BgJyaHaheniron_ColliderInit(this, play); - this->actor.shape.rot.z = (Rand_ZeroOne() * 65535.0f); - BgJyaHaheniron_SetupChairCrumble(this); + func_808980C0(this, play); + this->actor.shape.rot.z = (s16)(s32)(Rand_ZeroOne() * 65535.0f); + func_8089843C(this); } else if (this->actor.params == 1) { - BgJyaHaheniron_SetupPillarCrumble(this); + func_80898588(this); } else if (this->actor.params == 2) { - BgJyaHaheniron_SetupRubbleCollide(this); + func_8089861C(this); } } void BgJyaHaheniron_Destroy(Actor* thisx, PlayState* play) { - STACK_PAD(s32); BgJyaHaheniron* this = (BgJyaHaheniron*)thisx; if (this->actor.params == 0) { @@ -151,25 +126,25 @@ void BgJyaHaheniron_Destroy(Actor* thisx, PlayState* play) { } } -void BgJyaHaheniron_SetupChairCrumble(BgJyaHaheniron* this) { - this->actionFunc = BgJyaHaheniron_ChairCrumble; +void func_8089843C(BgJyaHaheniron* this) { + this->unk14C = func_8089844C; } -void BgJyaHaheniron_ChairCrumble(BgJyaHaheniron* this, PlayState* play) { - Vec3f vec; +void func_8089844C(BgJyaHaheniron* this, PlayState* play) { + Vec3f sp2C; Actor_MoveXZGravity(&this->actor); Actor_UpdateBgCheckInfo(play, &this->actor, 5.0f, 8.0f, 0.0f, UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_7); if ((this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_WALL)) || ((this->collider.base.atFlags & AT_HIT) && (this->collider.base.at != NULL) && - (this->collider.base.at->category == ACTORCAT_PLAYER))) { - vec.x = -Rand_ZeroOne() * this->actor.velocity.x; - vec.y = -Rand_ZeroOne() * this->actor.velocity.y; - vec.z = -Rand_ZeroOne() * this->actor.velocity.z; - BgJyaHaheniron_SpawnFragments(play, &this->actor.world.pos, &vec); + (this->collider.base.at->category == 2))) { + sp2C.x = -Rand_ZeroOne() * this->actor.velocity.x; + sp2C.y = -Rand_ZeroOne() * this->actor.velocity.y; + sp2C.z = -Rand_ZeroOne() * this->actor.velocity.z; + func_80898114(play, &this->actor.world.pos, &sp2C); Actor_Kill(&this->actor); - } else if (this->timer > 60) { + } else if (this->unk1B0 >= 0x3D) { Actor_Kill(&this->actor); } else { CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); @@ -178,52 +153,45 @@ void BgJyaHaheniron_ChairCrumble(BgJyaHaheniron* this, PlayState* play) { this->actor.shape.rot.x += 0xFA0; } -void BgJyaHaheniron_SetupPillarCrumble(BgJyaHaheniron* this) { - this->actionFunc = BgJyaHaheniron_PillarCrumble; +void func_80898588(BgJyaHaheniron* this) { + this->unk14C = func_80898598; } -void BgJyaHaheniron_PillarCrumble(BgJyaHaheniron* this, PlayState* play) { - if (this->timer >= 8) { +void func_80898598(BgJyaHaheniron* this, PlayState* play) { + if (this->unk1B0 >= 8) { Actor_MoveXZGravity(&this->actor); - } else if (this->timer >= 17) { - BgJyaHaheniron_SpawnFragments(play, &this->actor.world.pos, D_808987A0); + } else if (this->unk1B0 >= 0x11) { + func_80898114(play, &this->actor.world.pos, &D_808987A0); Actor_Kill(&this->actor); } this->actor.shape.rot.y += 0x258; this->actor.shape.rot.x += 0x3E8; } -void BgJyaHaheniron_SetupRubbleCollide(BgJyaHaheniron* this) { - this->actionFunc = BgJyaHaheniron_RubbleCollide; +void func_8089861C(BgJyaHaheniron* this) { + this->unk14C = func_8089862C; } -void BgJyaHaheniron_RubbleCollide(BgJyaHaheniron* this, PlayState* play) { - if (this->timer >= 17) { - BgJyaHaheniron_SpawnFragments(play, &this->actor.world.pos, D_808987AC); +void func_8089862C(BgJyaHaheniron* this, PlayState* play) { + if (this->unk1B0 >= 0x11) { + func_80898114(play, &this->actor.world.pos, &D_808987AC); SfxSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 80, NA_SE_EN_IRONNACK_BREAK_PILLAR2); Actor_Kill(&this->actor); } } void BgJyaHaheniron_Update(Actor* thisx, PlayState* play) { - STACK_PAD(s32); BgJyaHaheniron* this = (BgJyaHaheniron*)thisx; - this->timer++; - this->actionFunc(this, play); + this->unk1B0 += 1; + this->unk14C(this, play); } void BgJyaHaheniron_Draw(Actor* thisx, PlayState* play) { - static Gfx* dLists[] = { - gObjectJyaIronDL_000880, - gObjectJyaIronDL_000AE0, - gObjectJyaIronDL_000600, - }; - STACK_PAD(s32); BgJyaHaheniron* this = (BgJyaHaheniron*)thisx; if (this->actor.params == 0) { Collider_UpdateSpheres(0, &this->collider); } - Gfx_DrawDListOpa(play, dLists[this->actor.params]); + Gfx_DrawDListOpa(play, D_808987B8[this->actor.params]); } diff --git a/src/overlays/actors/ovl_Bg_Jya_Haheniron/z_bg_jya_haheniron.h b/src/overlays/actors/ovl_Bg_Jya_Haheniron/z_bg_jya_haheniron.h index ba4af700bf8..58dda603e13 100644 --- a/src/overlays/actors/ovl_Bg_Jya_Haheniron/z_bg_jya_haheniron.h +++ b/src/overlays/actors/ovl_Bg_Jya_Haheniron/z_bg_jya_haheniron.h @@ -9,11 +9,12 @@ struct BgJyaHaheniron; typedef void (*BgJyaHahenironActionFunc)(struct BgJyaHaheniron*, struct PlayState*); typedef struct BgJyaHaheniron { - /* 0x0000 */ Actor actor; - /* 0x014C */ BgJyaHahenironActionFunc actionFunc; - /* 0x0150 */ ColliderJntSph collider; - /* 0x0170 */ ColliderJntSphElement colliderElements[1]; - /* 0x01B0 */ s16 timer; + /* 0x000 */ Actor actor; + /* 0x14C */ BgJyaHahenironActionFunc unk14C; + /* 0x150 */ ColliderJntSph collider; + /* 0x170 */ ColliderJntSphElement colliderElements[1]; + /* 0x1B0 */ s16 unk1B0; + /* 0x1B2 */ char pad1B2[2]; } BgJyaHaheniron; // size = 0x01B4 #endif diff --git a/src/overlays/actors/ovl_Bg_Jya_Kanaami/z_bg_jya_kanaami.c b/src/overlays/actors/ovl_Bg_Jya_Kanaami/z_bg_jya_kanaami.c index 63cbf0c5d13..1f20adce461 100644 --- a/src/overlays/actors/ovl_Bg_Jya_Kanaami/z_bg_jya_kanaami.c +++ b/src/overlays/actors/ovl_Bg_Jya_Kanaami/z_bg_jya_kanaami.c @@ -1,7 +1,7 @@ /* * File: z_bg_jya_kanaami.c - * Overlay: ovl_Bg_Jya_Kanaami - * Description: Climbable grating/bridge (Spirit Temple) + * Overlay: Bg_Jya_Kanaami + * Description: Climbable Metal Grating (Fire Temple) */ #include "z_bg_jya_kanaami.h" diff --git a/src/overlays/actors/ovl_Bg_Jya_Lift/z_bg_jya_lift.c b/src/overlays/actors/ovl_Bg_Jya_Lift/z_bg_jya_lift.c index f7b1e469721..5b5c3741953 100644 --- a/src/overlays/actors/ovl_Bg_Jya_Lift/z_bg_jya_lift.c +++ b/src/overlays/actors/ovl_Bg_Jya_Lift/z_bg_jya_lift.c @@ -30,7 +30,7 @@ void BgJyaLift_DelayMove(BgJyaLift* this, PlayState* play); void BgJyaLift_SetupMove(BgJyaLift* this); void BgJyaLift_Move(BgJyaLift* this, PlayState* play); -static s16 sIsSpawned = false; +static s16 D_8089A020 = 0; ActorProfile Bg_Jya_Lift_Profile = { /**/ ACTOR_BG_JYA_LIFT, @@ -64,7 +64,7 @@ void BgJyaLift_Init(Actor* thisx, PlayState* play) { BgJyaLift* this = (BgJyaLift*)thisx; this->isSpawned = false; - if (sIsSpawned) { + if (D_8089A020) { Actor_Kill(thisx); return; } @@ -78,7 +78,7 @@ void BgJyaLift_Init(Actor* thisx, PlayState* play) { BgJyaLift_SetInitPosY(this); } thisx->room = -1; - sIsSpawned = true; + D_8089A020 = 1; this->isSpawned = true; } @@ -88,7 +88,7 @@ void BgJyaLift_Destroy(Actor* thisx, PlayState* play) { if (this->isSpawned) { PRINTF(T("女神リフト DT\n", "Goddess lift DT\n")); - sIsSpawned = false; + D_8089A020 = 0; DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } } @@ -145,7 +145,7 @@ void BgJyaLift_Update(Actor* thisx, PlayState* play2) { } if ((this->dyna.interactFlags & DYNA_INTERACT_PLAYER_ABOVE) && !(this->unk_16B & DYNA_INTERACT_PLAYER_ABOVE)) { Camera_RequestSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_DIRECTED_YAW); - } else if (!(this->dyna.interactFlags & DYNA_INTERACT_PLAYER_ABOVE) && + } else if (((this->dyna.interactFlags) & DYNA_INTERACT_PLAYER_ABOVE) == 0 && (this->unk_16B & DYNA_INTERACT_PLAYER_ABOVE) && (play->cameraPtrs[CAM_ID_MAIN]->setting == CAM_SET_DIRECTED_YAW)) { Camera_RequestSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_DUNGEON0); diff --git a/src/overlays/actors/ovl_Bg_Jya_Megami/z_bg_jya_megami.c b/src/overlays/actors/ovl_Bg_Jya_Megami/z_bg_jya_megami.c index cc88bcb0c38..ddc3f5a8fda 100644 --- a/src/overlays/actors/ovl_Bg_Jya_Megami/z_bg_jya_megami.c +++ b/src/overlays/actors/ovl_Bg_Jya_Megami/z_bg_jya_megami.c @@ -1,9 +1,3 @@ -/* - * File: z_bg_jya_megami.c - * Overlay: ovl_Bg_Jya_Megami - * Description: Face of Spirit Temple Goddess Statue - */ - #include "z_bg_jya_megami.h" #include "src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.h" diff --git a/src/overlays/actors/ovl_Bg_Mizu_Shutter/z_bg_mizu_shutter.c b/src/overlays/actors/ovl_Bg_Mizu_Shutter/z_bg_mizu_shutter.c index b9ec14406c7..9559efde469 100644 --- a/src/overlays/actors/ovl_Bg_Mizu_Shutter/z_bg_mizu_shutter.c +++ b/src/overlays/actors/ovl_Bg_Mizu_Shutter/z_bg_mizu_shutter.c @@ -15,6 +15,9 @@ #define FLAGS ACTOR_FLAG_UPDATE_CULLING_DISABLED +#define SIZE_PARAM PARAMS_GET_U((u16)this->dyna.actor.params, 12, 4) +#define TIMER_PARAM PARAMS_GET_U((u16)this->dyna.actor.params, 6, 6) + void BgMizuShutter_Init(Actor* thisx, PlayState* play); void BgMizuShutter_Destroy(Actor* thisx, PlayState* play); void BgMizuShutter_Update(Actor* thisx, PlayState* play); @@ -60,34 +63,30 @@ void BgMizuShutter_Init(Actor* thisx, PlayState* play) { STACK_PAD(s32); BgMizuShutter* this = (BgMizuShutter*)thisx; STACK_PAD(s32); - CollisionHeader* colHeader = NULL; + CollisionHeader* sp30 = NULL; STACK_PAD(s32); Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - this->displayList = sDisplayLists[BGMIZUSHUTTER_GET_SIZE(&this->dyna.actor)]; + this->displayList = sDisplayLists[SIZE_PARAM]; DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); - CollisionHeader_GetVirtual(sCollisionHeaders[BGMIZUSHUTTER_GET_SIZE(&this->dyna.actor)], &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); - - if ((BGMIZUSHUTTER_GET_SIZE(&this->dyna.actor) == BGMIZUSHUTTER_SMALL) || - (BGMIZUSHUTTER_GET_SIZE(&this->dyna.actor) == BGMIZUSHUTTER_LARGE)) { + CollisionHeader_GetVirtual(sCollisionHeaders[SIZE_PARAM], &sp30); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, sp30); + if ((SIZE_PARAM == BGMIZUSHUTTER_SMALL) || (SIZE_PARAM == BGMIZUSHUTTER_LARGE)) { this->closedPos = this->dyna.actor.world.pos; this->timer = 0; - this->timerMax = BGMIZUSHUTTER_GET_TIMER(&this->dyna.actor) * 20; - + this->timerMax = TIMER_PARAM * 20; Matrix_RotateY(BINANG_TO_RAD(this->dyna.actor.world.rot.y), MTXMODE_NEW); Matrix_RotateX(BINANG_TO_RAD(this->dyna.actor.world.rot.x), MTXMODE_APPLY); Matrix_RotateZ(BINANG_TO_RAD(this->dyna.actor.world.rot.z), MTXMODE_APPLY); - Matrix_MultVec3f(&sDisplacements[BGMIZUSHUTTER_GET_SIZE(&this->dyna.actor)], &this->openPos); + Matrix_MultVec3f(&sDisplacements[SIZE_PARAM], &this->openPos); this->openPos.x += this->dyna.actor.world.pos.x; this->openPos.y += this->dyna.actor.world.pos.y; this->openPos.z += this->dyna.actor.world.pos.z; - if (this->timerMax != 0x3F * 20) { - Flags_UnsetSwitch(play, BGMIZUSHUTTER_GET_SWITCH(&this->dyna.actor)); + Flags_UnsetSwitch(play, PARAMS_GET_U((u16)this->dyna.actor.params, 0, 6)); this->dyna.actor.world.pos = this->closedPos; } - if (Flags_GetSwitch(play, BGMIZUSHUTTER_GET_SWITCH(&this->dyna.actor))) { + if (Flags_GetSwitch(play, PARAMS_GET_U((u16)this->dyna.actor.params, 0, 6))) { this->dyna.actor.world.pos = this->openPos; this->actionFunc = BgMizuShutter_WaitForTimer; } else { @@ -104,7 +103,7 @@ void BgMizuShutter_Destroy(Actor* thisx, PlayState* play) { } void BgMizuShutter_WaitForSwitch(BgMizuShutter* this, PlayState* play) { - if (Flags_GetSwitch(play, BGMIZUSHUTTER_GET_SWITCH(&this->dyna.actor))) { + if (Flags_GetSwitch(play, PARAMS_GET_U((u16)this->dyna.actor.params, 0, 6))) { if (ABS(this->dyna.actor.world.rot.x) > 0x2C60) { OnePointCutscene_Init(play, 4510, -99, &this->dyna.actor, CAM_ID_MAIN); } else { @@ -123,7 +122,7 @@ void BgMizuShutter_WaitForCutscene(BgMizuShutter* this, PlayState* play) { } void BgMizuShutter_Move(BgMizuShutter* this, PlayState* play) { - if (Flags_GetSwitch(play, BGMIZUSHUTTER_GET_SWITCH(&this->dyna.actor))) { + if (Flags_GetSwitch(play, PARAMS_GET_U((u16)this->dyna.actor.params, 0, 6))) { Math_SmoothStepToF(&this->dyna.actor.world.pos.x, this->openPos.x, 1.0f, 4.0f, 0.1f); Math_SmoothStepToF(&this->dyna.actor.world.pos.y, this->openPos.y, 1.0f, 4.0f, 0.1f); Math_SmoothStepToF(&this->dyna.actor.world.pos.z, this->openPos.z, 1.0f, 4.0f, 0.1f); @@ -153,7 +152,7 @@ void BgMizuShutter_WaitForTimer(BgMizuShutter* this, PlayState* play) { Actor_PlaySfx_FlaggedTimer(&this->dyna.actor, this->timer); if (this->timer == 0) { Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_METALDOOR_CLOSE); - Flags_UnsetSwitch(play, BGMIZUSHUTTER_GET_SWITCH(&this->dyna.actor)); + Flags_UnsetSwitch(play, PARAMS_GET_U((u16)this->dyna.actor.params, 0, 6)); this->actionFunc = BgMizuShutter_Move; } } diff --git a/src/overlays/actors/ovl_Bg_Mizu_Shutter/z_bg_mizu_shutter.h b/src/overlays/actors/ovl_Bg_Mizu_Shutter/z_bg_mizu_shutter.h index a3f172393a3..86c8a725b0c 100644 --- a/src/overlays/actors/ovl_Bg_Mizu_Shutter/z_bg_mizu_shutter.h +++ b/src/overlays/actors/ovl_Bg_Mizu_Shutter/z_bg_mizu_shutter.h @@ -4,11 +4,7 @@ #include "ultra64.h" #include "actor.h" -#define BGMIZUSHUTTER_GET_SIZE(thisx) PARAMS_GET_U((u16)(thisx)->params, 12, 4) -#define BGMIZUSHUTTER_GET_TIMER(thisx) PARAMS_GET_U((u16)(thisx)->params, 6, 6) -#define BGMIZUSHUTTER_GET_SWITCH(thisx) PARAMS_GET_U((u16)(thisx)->params, 0, 6) - -#define BGMIZUSHUTTER_PARAMS(size, timer, switchFlag) (((size) << 12) | ((timer) << 6) | (switchFlag)) +#define BGMIZUSHUTTER_PARAM(size, timer, switchFlag) (size << 0xC) | (timer << 0x6) | switchFlag struct BgMizuShutter; diff --git a/src/overlays/actors/ovl_Bg_Mizu_Uzu/z_bg_mizu_uzu.c b/src/overlays/actors/ovl_Bg_Mizu_Uzu/z_bg_mizu_uzu.c index f0c415006b8..23c78cbc620 100644 --- a/src/overlays/actors/ovl_Bg_Mizu_Uzu/z_bg_mizu_uzu.c +++ b/src/overlays/actors/ovl_Bg_Mizu_Uzu/z_bg_mizu_uzu.c @@ -21,8 +21,6 @@ void BgMizuUzu_Destroy(Actor* thisx, PlayState* play); void BgMizuUzu_Update(Actor* thisx, PlayState* play); void BgMizuUzu_Draw(Actor* thisx, PlayState* play); -void func_8089F788(BgMizuUzu* this, PlayState* play); - ActorProfile Bg_Mizu_Uzu_Profile = { /**/ ACTOR_BG_MIZU_UZU, /**/ ACTORCAT_PROP, @@ -41,16 +39,18 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; +void func_8089F788(BgMizuUzu* this, PlayState* play); + void BgMizuUzu_Init(Actor* thisx, PlayState* play) { - STACK_PAD(s32); BgMizuUzu* this = (BgMizuUzu*)thisx; + STACK_PAD(s32); CollisionHeader* colHeader = NULL; STACK_PAD(s32); - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + Actor_ProcessInitChain(thisx, sInitChain); DynaPolyActor_Init(&this->dyna, 0); CollisionHeader_GetVirtual(&gObjectMizuObjectsUzuCol_0074EC, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, thisx, colHeader); this->actionFunc = func_8089F788; } diff --git a/src/overlays/actors/ovl_Bg_Mori_Elevator/z_bg_mori_elevator.c b/src/overlays/actors/ovl_Bg_Mori_Elevator/z_bg_mori_elevator.c index a844f781762..fa667ac2071 100644 --- a/src/overlays/actors/ovl_Bg_Mori_Elevator/z_bg_mori_elevator.c +++ b/src/overlays/actors/ovl_Bg_Mori_Elevator/z_bg_mori_elevator.c @@ -31,7 +31,7 @@ void func_808A2008(BgMoriElevator* this, PlayState* play); void BgMoriElevator_MoveIntoGround(BgMoriElevator* this, PlayState* play); void BgMoriElevator_MoveAboveGround(BgMoriElevator* this, PlayState* play); -static s16 sIsSpawned = false; +static s16 sIsSpawned = 0; ActorProfile Bg_Mori_Elevator_Profile = { /**/ ACTOR_BG_MORI_ELEVATOR, @@ -114,9 +114,9 @@ void BgMoriElevator_Init(Actor* thisx, PlayState* play) { #endif switch (sIsSpawned) { - case false: + case 0: PRINTF(T("森の神殿 elevator CT\n", "Forest Temple elevator CT\n")); - sIsSpawned = true; + sIsSpawned = 1; this->dyna.actor.room = -1; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); @@ -124,7 +124,7 @@ void BgMoriElevator_Init(Actor* thisx, PlayState* play) { this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, thisx, colHeader); BgMoriElevator_SetupWaitAfterInit(this); break; - case true: + case 1: Actor_Kill(thisx); break; } @@ -136,7 +136,7 @@ void BgMoriElevator_Destroy(Actor* thisx, PlayState* play) { if (this->unk_172 == 0) { PRINTF(T("森の神殿 elevator DT\n", "Forest Temple elevator DT\n")); DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); - sIsSpawned = false; + sIsSpawned = 0; } } diff --git a/src/overlays/actors/ovl_Bg_Mori_Hineri/z_bg_mori_hineri.c b/src/overlays/actors/ovl_Bg_Mori_Hineri/z_bg_mori_hineri.c index f5af2d41424..52cc4840738 100644 --- a/src/overlays/actors/ovl_Bg_Mori_Hineri/z_bg_mori_hineri.c +++ b/src/overlays/actors/ovl_Bg_Mori_Hineri/z_bg_mori_hineri.c @@ -14,7 +14,6 @@ #include "sys_matrix.h" #include "versions.h" #include "z_lib.h" -#include "curve.h" #include "play_state.h" #include "player.h" diff --git a/src/overlays/actors/ovl_Bg_Mori_Idomizu/z_bg_mori_idomizu.c b/src/overlays/actors/ovl_Bg_Mori_Idomizu/z_bg_mori_idomizu.c index 5ffe138fab6..93b10a28b52 100644 --- a/src/overlays/actors/ovl_Bg_Mori_Idomizu/z_bg_mori_idomizu.c +++ b/src/overlays/actors/ovl_Bg_Mori_Idomizu/z_bg_mori_idomizu.c @@ -31,7 +31,7 @@ void BgMoriIdomizu_WaitForMoriTex(BgMoriIdomizu* this, PlayState* play); void BgMoriIdomizu_SetupMain(BgMoriIdomizu* this); void BgMoriIdomizu_Main(BgMoriIdomizu* this, PlayState* play); -static s16 sIsSpawned = false; +static s16 sAlreadyLoaded = false; ActorProfile Bg_Mori_Idomizu_Profile = { /**/ ACTOR_BG_MORI_IDOMIZU, @@ -61,7 +61,7 @@ void BgMoriIdomizu_Init(Actor* thisx, PlayState* play) { STACK_PAD(s32); BgMoriIdomizu* this = (BgMoriIdomizu*)thisx; - if (sIsSpawned) { + if (sAlreadyLoaded) { Actor_Kill(&this->actor); return; } @@ -86,7 +86,7 @@ void BgMoriIdomizu_Init(Actor* thisx, PlayState* play) { return; } BgMoriIdomizu_SetupWaitForMoriTex(this); - sIsSpawned = true; + sAlreadyLoaded = true; this->isLoaded = true; this->actor.room = -1; PRINTF(T("(森の神殿 井戸水)(arg_data 0x%04x)\n", "(Forest Temple well water)(arg_data 0x%04x)\n"), @@ -98,7 +98,7 @@ void BgMoriIdomizu_Destroy(Actor* thisx, PlayState* play) { BgMoriIdomizu* this = (BgMoriIdomizu*)thisx; if (this->isLoaded) { - sIsSpawned = false; + sAlreadyLoaded = false; } } diff --git a/src/overlays/actors/ovl_Bg_Mori_Rakkatenjo/z_bg_mori_rakkatenjo.c b/src/overlays/actors/ovl_Bg_Mori_Rakkatenjo/z_bg_mori_rakkatenjo.c index 1f7cc0502a8..9cd9c5eb3ee 100644 --- a/src/overlays/actors/ovl_Bg_Mori_Rakkatenjo/z_bg_mori_rakkatenjo.c +++ b/src/overlays/actors/ovl_Bg_Mori_Rakkatenjo/z_bg_mori_rakkatenjo.c @@ -77,6 +77,7 @@ void BgMoriRakkatenjo_Init(Actor* thisx, PlayState* play) { PRINTF(T("Warning : セット位置が変更されています。プログラムを修正しましょう。\n", "Warning : The set position has been changed. Let's fix the program.\n")); } + //! @bug rot.y is a s16, it will never equal 0x8000 if (this->dyna.actor.home.rot.y != 0x8000) { PRINTF(T("Warning : セット Angle が変更されています。プログラムを修正しましょう。\n", "Warning : The set Angle has changed. Let's fix the program.\n")); diff --git a/src/overlays/actors/ovl_Bg_Po_Syokudai/z_bg_po_syokudai.c b/src/overlays/actors/ovl_Bg_Po_Syokudai/z_bg_po_syokudai.c index 6a50167accc..d0d0553ed9d 100644 --- a/src/overlays/actors/ovl_Bg_Po_Syokudai/z_bg_po_syokudai.c +++ b/src/overlays/actors/ovl_Bg_Po_Syokudai/z_bg_po_syokudai.c @@ -1,9 +1,3 @@ -/* - * File: z_bg_po_syokudai.c - * Overlay: ovl_Bg_Po_Syokudai - * Description: Golden Torch Stand (Poe Sisters) - */ - #include "z_bg_po_syokudai.h" #include "libc64/qrand.h" @@ -21,15 +15,6 @@ #define FLAGS 0 -typedef enum PoeFlameColor { - POE_FLAME_PURPLE, // Meg - POE_FLAME_RED, // Joelle - POE_FLAME_BLUE, // Beth - POE_FLAME_GREEN // Amy -} PoeFlameColor; - -#define POE_TORCH_FLAG 0x1C - void BgPoSyokudai_Init(Actor* thisx, PlayState* play); void BgPoSyokudai_Destroy(Actor* thisx, PlayState* play); void BgPoSyokudai_Update(Actor* thisx, PlayState* play); @@ -54,19 +39,17 @@ static ColliderCylinderInit sCylinderInit = { }, { 12, 60, 0, { 0, 0, 0 } }, }; - -static Color_RGBA8 sPrimColors[] = { - { 255, 170, 255, 255 }, - { 255, 200, 0, 255 }, - { 0, 170, 255, 255 }, - { 170, 255, 0, 255 }, +static Color_RGBA8 D_808A898C[4] = { + { 0xFF, 0xAA, 0xFF, 0xFF }, + { 0xFF, 0xC8, 0x00, 0xFF }, + { 0x00, 0xAA, 0xFF, 0xFF }, + { 0xAA, 0xFF, 0x00, 0xFF }, }; - -static Color_RGBA8 sEnvColors[] = { - { 100, 0, 255, 255 }, - { 255, 0, 0, 255 }, - { 0, 0, 255, 255 }, - { 0, 150, 0, 255 }, +static Color_RGBA8 D_808A899C[4] = { + { 0x64, 0x00, 0xFF, 0xFF }, + { 0xFF, 0x00, 0x00, 0xFF }, + { 0x00, 0x00, 0xFF, 0xFF }, + { 0x00, 0x96, 0x00, 0xFF }, }; ActorProfile Bg_Po_Syokudai_Profile = { @@ -89,51 +72,38 @@ void BgPoSyokudai_Init(Actor* thisx, PlayState* play) { BgPoSyokudai* this = (BgPoSyokudai*)thisx; STACK_PAD(s32); - Actor_ProcessInitChain(thisx, sInitChain); - - this->flameColor = PARAMS_GET_U(thisx->params, 8, 8); - thisx->params &= 0x3F; - - thisx->colChkInfo.mass = MASS_IMMOVABLE; - - this->lightNode = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfo); - Lights_PointGlowSetInfo(&this->lightInfo, thisx->world.pos.x, (s16)thisx->world.pos.y + 65, thisx->world.pos.z, 0, - 0, 0, 0); - + Actor_ProcessInitChain(&this->actor, sInitChain); + this->unk14C = PARAMS_GET_U(thisx->params, 8, 8); + this->actor.params &= 0x3F; + this->actor.colChkInfo.mass = 0xFF; + this->unk150 = LightContext_InsertLight(play, &play->lightCtx, &this->unk154); + Lights_PointGlowSetInfo(&this->unk154, this->actor.world.pos.x, (s16)this->actor.world.pos.y + 65, + this->actor.world.pos.z, 0, 0, 0, 0); Collider_InitCylinder(play, &this->collider); - Collider_SetCylinder(play, &this->collider, thisx, &sCylinderInit); - - this->collider.dim.pos.x = thisx->world.pos.x; - this->collider.dim.pos.y = thisx->world.pos.y; - this->collider.dim.pos.z = thisx->world.pos.z; - - if (this->flameColor == POE_FLAME_PURPLE && Flags_GetSwitch(play, POE_TORCH_FLAG + POE_FLAME_GREEN) && - Flags_GetSwitch(play, POE_TORCH_FLAG + POE_FLAME_BLUE) && - Flags_GetSwitch(play, POE_TORCH_FLAG + POE_FLAME_RED) && !Flags_GetSwitch(play, thisx->params)) { - - Actor_Spawn(&play->actorCtx, play, ACTOR_EN_PO_SISTERS, 119.0f, 225.0f, -1566.0f, 0, 0, 0, thisx->params); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + 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; + if ((this->unk14C == 0) && Flags_GetSwitch(play, 0x1F) && Flags_GetSwitch(play, 0x1E) && + Flags_GetSwitch(play, 0x1D) && !Flags_GetSwitch(play, this->actor.params)) { + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_PO_SISTERS, 119.0f, 225.0f, -1566.0f, 0, 0, 0, this->actor.params); + play->envCtx.lightSettingOverride = 4; + } else if (!Flags_GetSwitch(play, 0x1C) && !Flags_GetSwitch(play, 0x1B)) { + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_PO_SISTERS, this->actor.world.pos.x, + this->actor.world.pos.y + 52.0f, this->actor.world.pos.z, 0, 0, 0, + (this->unk14C << 8) + this->actor.params + 0x1000); + } else if (!Flags_GetSwitch(play, this->actor.params) && + (play->envCtx.lightSettingOverride == LIGHT_SETTING_OVERRIDE_NONE)) { play->envCtx.lightSettingOverride = 4; - - } else if (!Flags_GetSwitch(play, POE_TORCH_FLAG + POE_FLAME_PURPLE) && !Flags_GetSwitch(play, 0x1B)) { - - Actor_Spawn(&play->actorCtx, play, ACTOR_EN_PO_SISTERS, thisx->world.pos.x, thisx->world.pos.y + 52.0f, - thisx->world.pos.z, 0, 0, 0, (this->flameColor << 8) + thisx->params + 0x1000); - - } else if (!Flags_GetSwitch(play, thisx->params)) { - if (play->envCtx.lightSettingOverride == LIGHT_SETTING_OVERRIDE_NONE) { - play->envCtx.lightSettingOverride = 4; - } } - - this->flameTextureScroll = (s16)(Rand_ZeroOne() * 20.0f); + this->unk14E = Rand_ZeroOne() * 20.0f; } void BgPoSyokudai_Destroy(Actor* thisx, PlayState* play) { BgPoSyokudai* this = (BgPoSyokudai*)thisx; - LightContext_RemoveLight(play, &play->lightCtx, this->lightNode); + LightContext_RemoveLight(play, &play->lightCtx, this->unk150); Collider_DestroyCylinder(play, &this->collider); - if (play->envCtx.lightSettingOverride != LIGHT_SETTING_OVERRIDE_NONE) { play->envCtx.lightSettingOverride = LIGHT_SETTING_OVERRIDE_NONE; } @@ -148,48 +118,37 @@ void BgPoSyokudai_Update(Actor* thisx, PlayState* play) { if (Flags_GetSwitch(play, this->actor.params)) { Actor_PlaySfx_Flagged(&this->actor, NA_SE_EV_TORCH - SFX_FLAG); } - this->flameTextureScroll++; + this->unk14E += 1; } void BgPoSyokudai_Draw(Actor* thisx, PlayState* play) { BgPoSyokudai* this = (BgPoSyokudai*)thisx; - f32 lightBrightness; - u8 red; - u8 green; - u8 blue; + f32 temp_fv1; + STACK_PAD(s32); OPEN_DISPS(play->state.gfxCtx, "../z_bg_po_syokudai.c", 315); - Gfx_SetupDL_25Opa(play->state.gfxCtx); MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx, "../z_bg_po_syokudai.c", 319); gSPDisplayList(POLY_OPA_DISP++, gGoldenTorchDL); - if (Flags_GetSwitch(play, this->actor.params)) { - Color_RGBA8* primColor = &sPrimColors[this->flameColor]; - Color_RGBA8* envColor = &sEnvColors[this->flameColor]; - - lightBrightness = (0.3f * Rand_ZeroOne()) + 0.7f; - - red = (u8)(primColor->r * lightBrightness); - green = (u8)(primColor->g * lightBrightness); - blue = (u8)(primColor->b * lightBrightness); - - Lights_PointSetColorAndRadius(&this->lightInfo, red, green, blue, 200); + Color_RGBA8* sp64; + Color_RGBA8* sp60; + sp64 = &D_808A898C[this->unk14C]; + sp60 = &D_808A899C[this->unk14C]; + temp_fv1 = (Rand_ZeroOne() * 0.3f) + 0.7f; + Lights_PointSetColorAndRadius(&this->unk154, sp64->r * temp_fv1, sp64->g * temp_fv1, sp64->b * temp_fv1, 200); Gfx_SetupDL_25Xlu(play->state.gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, 0, 0, 32, 64, 1, 0, - (this->flameTextureScroll * -20) & 0x1FF, 32, 128)); - - gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, primColor->r, primColor->g, primColor->b, 255); - gDPSetEnvColor(POLY_XLU_DISP++, envColor->r, envColor->g, envColor->b, 255); - + (this->unk14E * -0x14) & 0x1FF, 32, 128)); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, sp64->r, sp64->g, sp64->b, 255); + gDPSetEnvColor(POLY_XLU_DISP++, sp60->r, sp60->g, sp60->b, 255); Matrix_Translate(0.0f, 52.0f, 0.0f, MTXMODE_APPLY); Matrix_RotateY( - BINANG_TO_RAD((s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) - this->actor.shape.rot.y + 0x8000)), + BINANG_TO_RAD((s16)((Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) - this->actor.shape.rot.y) + 0x8000)), MTXMODE_APPLY); Matrix_Scale(0.0027f, 0.0027f, 0.0027f, MTXMODE_APPLY); - MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx, "../z_bg_po_syokudai.c", 368); gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); } diff --git a/src/overlays/actors/ovl_Bg_Po_Syokudai/z_bg_po_syokudai.h b/src/overlays/actors/ovl_Bg_Po_Syokudai/z_bg_po_syokudai.h index 3c50d66794f..5f4e64a0fb1 100644 --- a/src/overlays/actors/ovl_Bg_Po_Syokudai/z_bg_po_syokudai.h +++ b/src/overlays/actors/ovl_Bg_Po_Syokudai/z_bg_po_syokudai.h @@ -8,12 +8,12 @@ struct BgPoSyokudai; typedef struct BgPoSyokudai { - /* 0x0000 */ Actor actor; - /* 0x014C */ u8 flameColor; - /* 0x014E */ s16 flameTextureScroll; - /* 0x0150 */ LightNode* lightNode; - /* 0x0154 */ LightInfo lightInfo; - /* 0x0164 */ ColliderCylinder collider; + /* 0x000 */ Actor actor; + /* 0x14C */ u8 unk14C; + /* 0x14E */ s16 unk14E; + /* 0x150 */ LightNode* unk150; + /* 0x154 */ LightInfo unk154; + /* 0x164 */ ColliderCylinder collider; } BgPoSyokudai; // size = 0x01B0 #endif diff --git a/src/overlays/actors/ovl_Bg_Pushbox/z_bg_pushbox.c b/src/overlays/actors/ovl_Bg_Pushbox/z_bg_pushbox.c index 13ac651fc78..ea370bb7cb8 100644 --- a/src/overlays/actors/ovl_Bg_Pushbox/z_bg_pushbox.c +++ b/src/overlays/actors/ovl_Bg_Pushbox/z_bg_pushbox.c @@ -47,16 +47,16 @@ void BgPushbox_SetupAction(BgPushbox* this, BgPushboxActionFunc actionFunc) { } void BgPushbox_Init(Actor* thisx, PlayState* play) { - STACK_PAD(s32); BgPushbox* this = (BgPushbox*)thisx; + STACK_PAD(s32); CollisionHeader* colHeader = NULL; STACK_PAD(s32); - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + Actor_ProcessInitChain(thisx, sInitChain); DynaPolyActor_Init(&this->dyna, 0); CollisionHeader_GetVirtual(&gBlockSmallCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); - ActorShape_Init(&this->dyna.actor.shape, 0.0f, NULL, 0.0f); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, thisx, colHeader); + ActorShape_Init(&thisx->shape, 0.0f, NULL, 0.0f); BgPushbox_SetupAction(this, BgPushbox_UpdateImpl); } @@ -67,12 +67,14 @@ void BgPushbox_Destroy(Actor* thisx, PlayState* play) { } void BgPushbox_UpdateImpl(BgPushbox* this, PlayState* play) { - this->dyna.actor.speed += this->dyna.unk_150 * 0.2f; - this->dyna.actor.speed = CLAMP(this->dyna.actor.speed, -1.0f, 1.0f); - Math_StepToF(&this->dyna.actor.speed, 0.0f, 0.2f); - this->dyna.actor.world.rot.y = this->dyna.unk_158; - Actor_MoveXZGravity(&this->dyna.actor); - Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 20.0f, 40.0f, 40.0f, + Actor* thisx = &this->dyna.actor; + + thisx->speed += this->dyna.unk_150 * 0.2f; + thisx->speed = (thisx->speed < -1.0f) ? -1.0f : ((thisx->speed > 1.0f) ? 1.0f : thisx->speed); + Math_StepToF(&thisx->speed, 0.0f, 0.2f); + thisx->world.rot.y = this->dyna.unk_158; + Actor_MoveXZGravity(thisx); + Actor_UpdateBgCheckInfo(play, thisx, 20.0f, 40.0f, 40.0f, UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_3 | UPDBGCHECKINFO_FLAG_4); } diff --git a/src/overlays/actors/ovl_Bg_Spot00_Hanebasi/z_bg_spot00_hanebasi.c b/src/overlays/actors/ovl_Bg_Spot00_Hanebasi/z_bg_spot00_hanebasi.c index a98a3b9ca4e..c341424a720 100644 --- a/src/overlays/actors/ovl_Bg_Spot00_Hanebasi/z_bg_spot00_hanebasi.c +++ b/src/overlays/actors/ovl_Bg_Spot00_Hanebasi/z_bg_spot00_hanebasi.c @@ -36,8 +36,8 @@ void BgSpot00Hanebasi_Destroy(Actor* thisx, PlayState* play); void BgSpot00Hanebasi_Update(Actor* thisx, PlayState* play); void BgSpot00Hanebasi_Draw(Actor* thisx, PlayState* play); -void BgSpot00Hanebasi_DrawbridgeWait(BgSpot00Hanebasi* this, PlayState* play); -void BgSpot00Hanebasi_DrawbridgeRiseAndFall(BgSpot00Hanebasi* this, PlayState* play); +void BgSpot00Hanebasi_DrawBridgeWait(BgSpot00Hanebasi* this, PlayState* play); +void BgSpot00Hanebasi_DrawBridgeRiseAndFall(BgSpot00Hanebasi* this, PlayState* play); void BgSpot00Hanebasi_SetTorchLightInfo(BgSpot00Hanebasi* this, PlayState* play); ActorProfile Bg_Spot00_Hanebasi_Profile = { @@ -115,7 +115,7 @@ void BgSpot00Hanebasi_Init(Actor* thisx, PlayState* play) { Actor_Kill(&this->dyna.actor); } - this->actionFunc = BgSpot00Hanebasi_DrawbridgeWait; + this->actionFunc = BgSpot00Hanebasi_DrawBridgeWait; this->destAngle = 40; } else if (this->dyna.actor.params == DT_CHAIN_1) { if (Actor_SpawnAsChild(&play->actorCtx, &this->dyna.actor, play, ACTOR_BG_SPOT00_HANEBASI, @@ -149,20 +149,19 @@ void BgSpot00Hanebasi_Destroy(Actor* thisx, PlayState* play) { } } -void BgSpot00Hanebasi_DrawbridgeWait(BgSpot00Hanebasi* this, PlayState* play) { +void BgSpot00Hanebasi_DrawBridgeWait(BgSpot00Hanebasi* this, PlayState* play) { BgSpot00Hanebasi* child = (BgSpot00Hanebasi*)this->dyna.actor.child; if (!IS_CUTSCENE_LAYER && CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD) && CHECK_QUEST_ITEM(QUEST_GORON_RUBY) && CHECK_QUEST_ITEM(QUEST_ZORA_SAPPHIRE) && !GET_EVENTCHKINF(EVENTCHKINF_ZELDA_FLED_CASTLE)) { return; } - if ((this->dyna.actor.shape.rot.x != 0) && (CutsceneFlags_Get(play, 0) || (!IS_CUTSCENE_LAYER && IS_DAY))) { - this->actionFunc = BgSpot00Hanebasi_DrawbridgeRiseAndFall; + this->actionFunc = BgSpot00Hanebasi_DrawBridgeRiseAndFall; this->destAngle = 0; child->destAngle = 0; } else if ((this->dyna.actor.shape.rot.x == 0) && !IS_CUTSCENE_LAYER && !LINK_IS_ADULT && !IS_DAY) { - this->actionFunc = BgSpot00Hanebasi_DrawbridgeRiseAndFall; + this->actionFunc = BgSpot00Hanebasi_DrawBridgeRiseAndFall; this->destAngle = -0x4000; child->destAngle = -0xFE0; } @@ -171,13 +170,13 @@ void BgSpot00Hanebasi_DrawbridgeWait(BgSpot00Hanebasi* this, PlayState* play) { void BgSpot00Hanebasi_DoNothing(BgSpot00Hanebasi* this, PlayState* play) { } -void BgSpot00Hanebasi_DrawbridgeRiseAndFall(BgSpot00Hanebasi* this, PlayState* play) { +void BgSpot00Hanebasi_DrawBridgeRiseAndFall(BgSpot00Hanebasi* this, PlayState* play) { BgSpot00Hanebasi* child; Actor* childsChild; s16 angle = 80; if (Math_ScaledStepToS(&this->dyna.actor.shape.rot.x, this->destAngle, 80)) { - this->actionFunc = BgSpot00Hanebasi_DrawbridgeWait; + this->actionFunc = BgSpot00Hanebasi_DrawBridgeWait; } if (this->dyna.actor.shape.rot.x >= -0x27D8) { @@ -189,13 +188,13 @@ void BgSpot00Hanebasi_DrawbridgeRiseAndFall(BgSpot00Hanebasi* this, PlayState* p } if (this->destAngle < 0) { - if (this->actionFunc == BgSpot00Hanebasi_DrawbridgeWait) { + if (this->actionFunc == BgSpot00Hanebasi_DrawBridgeWait) { Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BRIDGE_CLOSE_STOP); } else { Actor_PlaySfx_Flagged(&this->dyna.actor, NA_SE_EV_BRIDGE_CLOSE - SFX_FLAG); } } else { - if (this->actionFunc == BgSpot00Hanebasi_DrawbridgeWait) { + if (this->actionFunc == BgSpot00Hanebasi_DrawBridgeWait) { Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BRIDGE_OPEN_STOP); } else { Actor_PlaySfx_Flagged(&this->dyna.actor, NA_SE_EV_BRIDGE_OPEN - SFX_FLAG); diff --git a/src/overlays/actors/ovl_Bg_Spot01_Idosoko/z_bg_spot01_idosoko.c b/src/overlays/actors/ovl_Bg_Spot01_Idosoko/z_bg_spot01_idosoko.c index 2e13de506ee..e298a1c7ffd 100644 --- a/src/overlays/actors/ovl_Bg_Spot01_Idosoko/z_bg_spot01_idosoko.c +++ b/src/overlays/actors/ovl_Bg_Spot01_Idosoko/z_bg_spot01_idosoko.c @@ -1,6 +1,6 @@ /* * File: z_bg_spot01_idosoko.c - * Overlay: ovl_Bg_Spot01_Idosoko + * Overlay: Bg_Spot01_Idosoko * Description: Stone that blocks the entrance to Bottom of the Well */ @@ -46,17 +46,17 @@ void BgSpot01Idosoko_SetupAction(BgSpot01Idosoko* this, BgSpot01IdosokoActionFun } void BgSpot01Idosoko_Init(Actor* thisx, PlayState* play) { - STACK_PAD(s32); BgSpot01Idosoko* this = (BgSpot01Idosoko*)thisx; + STACK_PAD(s32); CollisionHeader* colHeader = NULL; STACK_PAD(s32); DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + Actor_ProcessInitChain(thisx, sInitChain); CollisionHeader_GetVirtual(&gKakarikoBOTWStoneCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, thisx, colHeader); if (!LINK_IS_ADULT) { - Actor_Kill(&this->dyna.actor); + Actor_Kill(thisx); } else { BgSpot01Idosoko_SetupAction(this, func_808ABF54); } diff --git a/src/overlays/actors/ovl_Bg_Spot05_Soko/z_bg_spot05_soko.c b/src/overlays/actors/ovl_Bg_Spot05_Soko/z_bg_spot05_soko.c index 59585303b48..be220995541 100644 --- a/src/overlays/actors/ovl_Bg_Spot05_Soko/z_bg_spot05_soko.c +++ b/src/overlays/actors/ovl_Bg_Spot05_Soko/z_bg_spot05_soko.c @@ -48,11 +48,12 @@ static Gfx* sDLists[] = { }; void BgSpot05Soko_Init(Actor* thisx, PlayState* play) { - STACK_PAD(s32); BgSpot05Soko* this = (BgSpot05Soko*)thisx; - CollisionHeader* colHeader = NULL; + STACK_PAD(s32); + CollisionHeader* colHeader; STACK_PAD(s32); + colHeader = NULL; Actor_ProcessInitChain(thisx, sInitChain); this->switchFlag = PARAMS_GET_U(thisx->params, 8, 8); thisx->params &= 0xFF; @@ -86,20 +87,23 @@ void func_808AE5A8(BgSpot05Soko* this, PlayState* play) { } void func_808AE5B4(BgSpot05Soko* this, PlayState* play) { + Actor* thisx = &this->dyna.actor; + if (Flags_GetSwitch(play, this->switchFlag)) { - SfxSource_PlaySfxAtFixedWorldPos(play, &this->dyna.actor.world.pos, 30, NA_SE_EV_METALDOOR_CLOSE); - Actor_SetFocus(&this->dyna.actor, 50.0f); + SfxSource_PlaySfxAtFixedWorldPos(play, &thisx->world.pos, 30, NA_SE_EV_METALDOOR_CLOSE); + Actor_SetFocus(thisx, 50.0f); OnePointCutscene_Attention(play, &this->dyna.actor); this->actionFunc = func_808AE630; - this->dyna.actor.speed = 0.5f; + thisx->speed = 0.5f; } } void func_808AE630(BgSpot05Soko* this, PlayState* play) { - this->dyna.actor.speed *= 1.5f; - if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y - 120.0f, this->dyna.actor.speed) != - 0) { - Actor_Kill(&this->dyna.actor); + Actor* thisx = &this->dyna.actor; + + thisx->speed *= 1.5f; + if (Math_StepToF(&thisx->world.pos.y, thisx->home.pos.y - 120.0f, thisx->speed) != 0) { + Actor_Kill(thisx); } } diff --git a/src/overlays/actors/ovl_Bg_Spot08_Iceblock/z_bg_spot08_iceblock.c b/src/overlays/actors/ovl_Bg_Spot08_Iceblock/z_bg_spot08_iceblock.c index 2695d08cce2..2c337ab0836 100644 --- a/src/overlays/actors/ovl_Bg_Spot08_Iceblock/z_bg_spot08_iceblock.c +++ b/src/overlays/actors/ovl_Bg_Spot08_Iceblock/z_bg_spot08_iceblock.c @@ -1,9 +1,3 @@ -/* - * File: z_bg_spot08_iceblock.c - * Overlay: ovl_Bg_Spot08_Iceblock - * Description: Floating ice platforms - */ - #include "z_bg_spot08_iceblock.h" #include "libc64/math64.h" @@ -13,7 +7,6 @@ #include "stack_pad.h" #include "sys_math3d.h" #include "sys_matrix.h" -#include "translation.h" #include "z_lib.h" #include "play_state.h" #include "player.h" @@ -28,13 +21,13 @@ void BgSpot08Iceblock_Destroy(Actor* thisx, PlayState* play); void BgSpot08Iceblock_Update(Actor* thisx, PlayState* play); void BgSpot08Iceblock_Draw(Actor* thisx, PlayState* play); -void BgSpot08Iceblock_SetupFloatNonrotating(BgSpot08Iceblock* this); -void BgSpot08Iceblock_FloatNonrotating(BgSpot08Iceblock* this, PlayState* play); -void BgSpot08Iceblock_SetupFloatRotating(BgSpot08Iceblock* this); -void BgSpot08Iceblock_FloatRotating(BgSpot08Iceblock* this, PlayState* play); -void BgSpot08Iceblock_SetupFloatOrbitingTwins(BgSpot08Iceblock* this); -void BgSpot08Iceblock_FloatOrbitingTwins(BgSpot08Iceblock* this, PlayState* play); -void BgSpot08Iceblock_SetupNoAction(BgSpot08Iceblock* this); +void BgSpot08Iceblock_SetupIcebergStatic(BgSpot08Iceblock* this); +void BgSpot08Iceblock_IcebergStatic(BgSpot08Iceblock* this, PlayState* play); +void BgSpot08Iceblock_SetupIcebergSpin(BgSpot08Iceblock* this); +void BgSpot08Iceblock_IcebergSpin(BgSpot08Iceblock* this, PlayState* play); +void BgSpot08Iceblock_SetupActionIcebergDuo(BgSpot08Iceblock* this); +void BgSpot08Iceblock_IcebergDuo(BgSpot08Iceblock* this, PlayState* play); +void BgSpot08Iceblock_SetupDoNothing(BgSpot08Iceblock* this); ActorProfile Bg_Spot08_Iceblock_Profile = { /**/ ACTOR_BG_SPOT08_ICEBLOCK, @@ -48,43 +41,49 @@ ActorProfile Bg_Spot08_Iceblock_Profile = { /**/ BgSpot08Iceblock_Draw, }; +static Vec3f sUpVec = { 0.0f, 1.0f, 0.0f }; +static Vec3f D_808B16BC = { 0.0f, 0.0f, 0.0f }; +static f32 D_808B16C8[3] = { 1.4285714e-8f, 5.714286e-9f, 1.4285715e-9f }; +static f32 D_808B16D4[3] = { 0.96f, 0.96f, 0.98f }; +static f32 D_808B16E0[3] = { 0.22495104f, 0.22495104f, 0.03489947f }; +static f32 D_808B16EC[3] = { 0.97437006f, 0.97437006f, 0.99939084f }; +static InitChainEntry sInitChain[] = { + ICHAIN_F32(cullingVolumeDistance, 3000, ICHAIN_CONTINUE), + ICHAIN_F32(cullingVolumeScale, 1000, ICHAIN_CONTINUE), + ICHAIN_F32(cullingVolumeDownward, 2200, ICHAIN_STOP), +}; + void BgSpot08Iceblock_SetupAction(BgSpot08Iceblock* this, BgSpot08IceblockActionFunc actionFunc) { this->actionFunc = actionFunc; } -void BgSpot08Iceblock_InitDynaPoly(BgSpot08Iceblock* this, PlayState* play, CollisionHeader* collision, s32 flags) { +void BgSpot08Iceblock_InitDynapoly(BgSpot08Iceblock* this, PlayState* play, CollisionHeader* colHeaderSeg, + s32 transformFlags) { STACK_PAD(s32); CollisionHeader* colHeader = NULL; - DynaPolyActor_Init(&this->dyna, flags); - CollisionHeader_GetVirtual(collision, &colHeader); + DynaPolyActor_Init(&this->dyna, transformFlags); + CollisionHeader_GetVirtual(colHeaderSeg, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); #if DEBUG_FEATURES if (this->dyna.bgId == BG_ACTOR_MAX) { STACK_PAD(s32); - PRINTF(T("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", - "Warning : move BG registration failed (%s %d)(name %d)(arg_data 0x%04x)\n"), - "../z_bg_spot08_iceblock.c", 0xD9, this->dyna.actor.id, this->dyna.actor.params); + PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_spot08_iceblock.c", 217, + this->dyna.actor.id, this->dyna.actor.params); } #endif } -// Sets params to 0x10 (medium, nonrotating) if not in the cases listed. void BgSpot08Iceblock_CheckParams(BgSpot08Iceblock* this) { switch (PARAMS_GET_U(this->dyna.actor.params, 0, 8)) { case 0xFF: this->dyna.actor.params = 0x10; break; - default: - PRINTF(T("Error : arg_data 設定ミスです。(%s %d)(arg_data 0x%04x)\n", - "Error : arg_data setting error. (%s %d)(arg_data 0x%04x)\n"), - "../z_bg_spot08_iceblock.c", 0xF6, this->dyna.actor.params); - this->dyna.actor.params = 0x10; - break; - case 1: - case 4: + + case 0x1: + case 0x4: case 0x10: case 0x11: case 0x12: @@ -93,14 +92,20 @@ void BgSpot08Iceblock_CheckParams(BgSpot08Iceblock* this) { case 0x23: case 0x24: break; + + default: + PRINTF("Error : arg_data 設定ミスです。(%s %d)(arg_data 0x%04x)\n", "../z_bg_spot08_iceblock.c", 0xF6, + this->dyna.actor.params); + this->dyna.actor.params = 0x10; + break; } } -void BgSpot08Iceblock_Bobbing(BgSpot08Iceblock* this) { - this->bobOffset = (Math_SinS(this->bobPhaseSlow) * 4.0f) + (Math_SinS(this->bobPhaseFast) * 3.0f); +void BgSpot08Iceblock_UpdateYOscillation(BgSpot08Iceblock* this) { + this->yOscillation = (Math_SinS(this->yOscillationPhase1) * 4.0f) + (Math_SinS(this->yOscillationPhase2) * 3.0f); } -void BgSpot08Iceblock_SinkUnderPlayer(BgSpot08Iceblock* this) { +void BgSpot08Iceblock_UpdateSinkHeight(BgSpot08Iceblock* this) { f32 target; f32 step; @@ -108,258 +113,214 @@ void BgSpot08Iceblock_SinkUnderPlayer(BgSpot08Iceblock* this) { case 0: step = 0.15f; break; + case 0x10: step = 0.2f; break; + case 0x20: step = 0.4f; break; } - - // Sink under an actor's weight if standing on it - target = (DynaPolyActor_IsActorOnTop(&this->dyna) ? -4.0f : 0.0f); - - Math_StepToF(&this->sinkOffset, target, step); + if (DynaPolyActor_IsActorOnTop(&this->dyna)) { + target = -4.0f; + } else { + target = 0.0f; + } + Math_StepToF(&this->sinkHeight, target, step); } -void BgSpot08Iceblock_SetWaterline(BgSpot08Iceblock* this) { - this->dyna.actor.world.pos.y = this->sinkOffset + this->bobOffset + this->dyna.actor.home.pos.y; +void BgSpot08Iceblock_UpdatePosY(BgSpot08Iceblock* this) { + this->dyna.actor.world.pos.y = this->sinkHeight + this->yOscillation + this->dyna.actor.home.pos.y; } -void BgSpot08Iceblock_MultVectorScalar(Vec3f* dest, Vec3f* v, f32 scale) { - dest->x = v->x * scale; - dest->y = v->y * scale; - dest->z = v->z * scale; +void BgSpot08Iceblock_VecScale(Vec3f* dest, Vec3f* src, f32 fac) { + dest->x = src->x * fac; + dest->y = src->y * fac; + dest->z = src->z * fac; } -void BgSpot08Iceblock_CrossProduct(Vec3f* dest, Vec3f* v1, Vec3f* v2) { - dest->x = (v1->y * v2->z) - (v1->z * v2->y); - dest->y = (v1->z * v2->x) - (v1->x * v2->z); - dest->z = (v1->x * v2->y) - (v1->y * v2->x); +void BgSpot08Iceblock_VecCross(Vec3f* dest, Vec3f* a, Vec3f* b) { + dest->x = (a->y * b->z) - (a->z * b->y); + dest->y = (a->z * b->x) - (a->x * b->z); + dest->z = (a->x * b->y) - (a->y * b->x); } -s32 BgSpot08Iceblock_NormalizeVector(Vec3f* dest, Vec3f* v) { - f32 magnitude; +s32 BgSpot08Iceblock_VecNormalize(Vec3f* dest, Vec3f* src) { + f32 len; + f32 invLen; - magnitude = Math3D_Vec3fMagnitude(v); - if (magnitude < 0.001f) { - dest->x = dest->y = 0.0f; + len = Math3D_Vec3fMagnitude(src); + if (len < 0.001f) { + dest->y = 0.0f; + dest->x = 0.0f; dest->z = 1.0f; return false; } else { - dest->x = v->x * (1.0f / magnitude); - dest->y = v->y * (1.0f / magnitude); - dest->z = v->z * (1.0f / magnitude); + invLen = 1.0f / len; + dest->x = src->x * invLen; + dest->y = src->y * invLen; + dest->z = src->z * invLen; return true; } } -static Vec3f sVerticalVector = { 0.0f, 1.0f, 0.0f }; -static Vec3f sZeroVector = { 0.0f, 0.0f, 0.0f }; -static f32 sInertias[] = { 1.0f / 70000000, 1.0f / 175000000, 1.0f / 700000000 }; -static f32 sDampingFactors[] = { 0.96f, 0.96f, 0.98f }; - -static f32 sRollSins[] = { - 0.22495104f, // sin(13 degrees) - 0.22495104f, // sin(13 degrees) - 0.03489947f, // sin(2 degrees) -}; - -static f32 sRollCoss[] = { - 0.97437006f, // cos(13 degrees) - 0.97437006f, // cos(13 degrees) - 0.99939084f, // cos(2 degrees) -}; - -/** - * Handles all the factors that influence rolling: inertia, random oscillations, and most significantly, player weight, - * and combines them to produce a matrix that rotates the actor to match the surface normal - */ -void BgSpot08Iceblock_Roll(BgSpot08Iceblock* this, PlayState* play) { - f32 deviationFromVertSq; - f32 stabilityCorrection; - Vec3f surfaceNormalHorizontal; - Vec3f playerCentroidDiff; - Vec3f playerMoment; - Vec3f surfaceNormalHorizontalScaled; - Vec3f randomNutation; - Vec3f tempVec; // reused with different meanings - Vec3f torqueDirection; - f32 playerCentroidDist; - s32 rollDataIndex; - MtxF mtx; - STACK_PAD(s32); +void BgSpot08Iceblock_UpdateSwaying(BgSpot08Iceblock* this, PlayState* play) { Player* player = GET_PLAYER(play); + STACK_PAD(s32); + Vec3f spD4; + Vec3f spC8; + Vec3f spBC; + Vec3f spB0; + Vec3f randVec; + Vec3f sp98; + Vec3f swayAxis; + f32 sp88; + s32 physicsSet; + MtxF mf; + f32 temp_fv0_2; + f32 temp_fv1; switch (PARAMS_GET_U(this->dyna.actor.params, 0, 8)) { - case 0x11: // Medium nonrotating - rollDataIndex = 0; + case 0x11: + physicsSet = 0; break; + case 1: - rollDataIndex = 1; // Large nonrotating + physicsSet = 1; break; + default: - rollDataIndex = 2; + physicsSet = 2; break; } - - Math_Vec3f_Diff(&player->actor.world.pos, &this->dyna.actor.world.pos, &playerCentroidDiff); - playerCentroidDiff.y -= (150.0f * this->dyna.actor.scale.y); - playerCentroidDist = Math3D_Vec3fMagnitude(&playerCentroidDiff); - - randomNutation.x = (Rand_ZeroOne() - 0.5f) * (1.0f / 625); - randomNutation.y = 0.0f; - randomNutation.z = (Rand_ZeroOne() - 0.5f) * (1.0f / 625); - - surfaceNormalHorizontal.x = this->surfaceNormal.x; - surfaceNormalHorizontal.y = 0.0f; - surfaceNormalHorizontal.z = this->surfaceNormal.z; - - // If player is standing on it or holding the edge - if (DynaPolyActor_IsPlayerOnTop(&this->dyna) && (playerCentroidDist > 3.0f)) { - Math_Vec3f_Diff(&playerCentroidDiff, &surfaceNormalHorizontal, &playerMoment); - BgSpot08Iceblock_MultVectorScalar(&playerMoment, &playerMoment, - (sInertias[rollDataIndex] * playerCentroidDist) / this->dyna.actor.scale.x); + Math_Vec3f_Diff(&player->actor.world.pos, &this->dyna.actor.world.pos, &spC8); + spC8.y -= 150.0f * this->dyna.actor.scale.y; + sp88 = Math3D_Vec3fMagnitude(&spC8); + randVec.x = (Rand_ZeroOne() - 0.5f) * 0.0016f; + randVec.y = 0.0f; + randVec.z = (Rand_ZeroOne() - 0.5f) * 0.0016f; + spD4.x = this->unk_168.x; + spD4.y = 0.0f; + spD4.z = this->unk_168.z; + if (DynaPolyActor_IsPlayerOnTop(&this->dyna) && (sp88 > 3.0f)) { + Math_Vec3f_Diff(&spC8, &spD4, &spBC); + BgSpot08Iceblock_VecScale(&spBC, &spBC, (D_808B16C8[physicsSet] * sp88) / this->dyna.actor.scale.x); } else { - playerMoment = sZeroVector; + spBC = D_808B16BC; } - - BgSpot08Iceblock_MultVectorScalar(&surfaceNormalHorizontalScaled, &surfaceNormalHorizontal, -0.01f); - - // Add all three deviations - Math_Vec3f_Sum(&this->normalDelta, &playerMoment, &this->normalDelta); - Math_Vec3f_Sum(&this->normalDelta, &surfaceNormalHorizontalScaled, &this->normalDelta); - Math_Vec3f_Sum(&this->normalDelta, &randomNutation, &this->normalDelta); - - this->normalDelta.y = 0.0f; - - Math_Vec3f_Sum(&this->surfaceNormal, &this->normalDelta, &tempVec); - - tempVec.x *= sDampingFactors[rollDataIndex]; - tempVec.z *= sDampingFactors[rollDataIndex]; - - // Set up roll axis and final new angle - if (BgSpot08Iceblock_NormalizeVector(&this->surfaceNormal, &tempVec)) { - deviationFromVertSq = Math3D_Dist1DSq(this->surfaceNormal.z, this->surfaceNormal.x); - - // Prevent overrolling - if (sRollSins[rollDataIndex] < deviationFromVertSq) { - stabilityCorrection = sRollSins[rollDataIndex] / deviationFromVertSq; - - this->surfaceNormal.x *= stabilityCorrection; - this->surfaceNormal.y = sRollCoss[rollDataIndex]; - this->surfaceNormal.z *= stabilityCorrection; + BgSpot08Iceblock_VecScale(&spB0, &spD4, -0.01f); + Math_Vec3f_Sum(&this->unk_174, &spBC, &this->unk_174); + Math_Vec3f_Sum(&this->unk_174, &spB0, &this->unk_174); + Math_Vec3f_Sum(&this->unk_174, &randVec, &this->unk_174); + this->unk_174.y = 0.0f; + Math_Vec3f_Sum(&this->unk_168, &this->unk_174, &sp98); + sp98.x *= D_808B16D4[physicsSet]; + sp98.z *= D_808B16D4[physicsSet]; + if (BgSpot08Iceblock_VecNormalize(&this->unk_168, &sp98)) { + temp_fv0_2 = Math3D_Dist1DSq(this->unk_168.z, this->unk_168.x); + if (D_808B16E0[physicsSet] < temp_fv0_2) { + temp_fv1 = D_808B16E0[physicsSet] / temp_fv0_2; + this->unk_168.x *= temp_fv1; + this->unk_168.y = D_808B16EC[physicsSet]; + this->unk_168.z *= temp_fv1; } - - BgSpot08Iceblock_CrossProduct(&tempVec, &sVerticalVector, &this->surfaceNormal); - - if (BgSpot08Iceblock_NormalizeVector(&torqueDirection, &tempVec)) { - this->rotationAxis = torqueDirection; + BgSpot08Iceblock_VecCross(&sp98, &sUpVec, &this->unk_168); + if (BgSpot08Iceblock_VecNormalize(&swayAxis, &sp98)) { + this->swayAxis = swayAxis; } } else { - this->surfaceNormal = sVerticalVector; + this->unk_168 = sUpVec; } - - // Rotation by the angle between surfaceNormal and the vertical about rotationAxis - Matrix_RotateAxis(Math_FAcosF(Math3D_Cos(&sVerticalVector, &this->surfaceNormal)), &this->rotationAxis, - MTXMODE_NEW); + Matrix_RotateAxis(Math_FAcosF(Math3D_Cos(&sUpVec, &this->unk_168)), &this->swayAxis, MTXMODE_NEW); Matrix_RotateY(BINANG_TO_RAD(this->dyna.actor.shape.rot.y), MTXMODE_APPLY); - Matrix_Get(&mtx); - Matrix_MtxFToYXZRotS(&mtx, &this->dyna.actor.shape.rot, 0); + Matrix_Get(&mf); + Matrix_MtxFToYXZRotS(&mf, &this->dyna.actor.shape.rot, 0); } -void BgSpot08Iceblock_SpawnTwinFloe(BgSpot08Iceblock* this, PlayState* play) { +void BgSpot08Iceblock_SetupIcebergDuo(BgSpot08Iceblock* this, PlayState* play) { STACK_PADS(s32, 2); - f32 sin; - f32 cos; - - sin = Math_SinS(this->dyna.actor.home.rot.y) * 100.0f; - cos = Math_CosS(this->dyna.actor.home.rot.y) * 100.0f; + f32 dx = Math_SinS(this->dyna.actor.home.rot.y) * 100.0f; + f32 dz = Math_CosS(this->dyna.actor.home.rot.y) * 100.0f; if (!PARAMS_GET_NOSHIFT(this->dyna.actor.params, 8, 1)) { Actor_SpawnAsChild(&play->actorCtx, &this->dyna.actor, play, ACTOR_BG_SPOT08_ICEBLOCK, this->dyna.actor.home.pos.x, this->dyna.actor.home.pos.y, this->dyna.actor.home.pos.z, this->dyna.actor.home.rot.x, this->dyna.actor.home.rot.y, this->dyna.actor.home.rot.z, 0x123); - - this->dyna.actor.world.pos.x += sin; - this->dyna.actor.world.pos.z += cos; + this->dyna.actor.world.pos.x += dx; + this->dyna.actor.world.pos.z += dz; } else { - this->dyna.actor.world.pos.x -= sin; - this->dyna.actor.world.pos.z -= cos; + this->dyna.actor.world.pos.x -= dx; + this->dyna.actor.world.pos.z -= dz; } - BgSpot08Iceblock_SetupFloatOrbitingTwins(this); + BgSpot08Iceblock_SetupActionIcebergDuo(this); } -static InitChainEntry sInitChain[] = { - ICHAIN_F32(cullingVolumeDistance, 3000, ICHAIN_CONTINUE), - ICHAIN_F32(cullingVolumeScale, 1000, ICHAIN_CONTINUE), - ICHAIN_F32(cullingVolumeDownward, 2200, ICHAIN_STOP), -}; - void BgSpot08Iceblock_Init(Actor* thisx, PlayState* play) { - BgSpot08Iceblock* this = (BgSpot08Iceblock*)thisx; + STACK_PAD(s32); CollisionHeader* colHeader; + s32 behaviorType; + BgSpot08Iceblock* this = (BgSpot08Iceblock*)thisx; - PRINTF(T("(spot08 流氷)(arg_data 0x%04x)\n", "(spot08 ice floe)(arg_data 0x%04x)\n"), this->dyna.actor.params); + PRINTF("(spot08 流氷)(arg_data 0x%04x)\n", this->dyna.actor.params); BgSpot08Iceblock_CheckParams(this); - switch (PARAMS_GET_NOSHIFT(this->dyna.actor.params, 9, 1)) { case 0: colHeader = &gZorasFountainIcebergCol; break; + case 0x200: colHeader = &gZorasFountainIceRampCol; break; } - - switch (PARAMS_GET_U(this->dyna.actor.params, 0, 4)) { - case 2: - case 3: - BgSpot08Iceblock_InitDynaPoly(this, play, colHeader, DYNA_TRANSFORM_POS | DYNA_TRANSFORM_ROT_Y); - break; - default: - BgSpot08Iceblock_InitDynaPoly(this, play, colHeader, 0); - break; + behaviorType = PARAMS_GET_U(this->dyna.actor.params, 0, 4); + if ((behaviorType == 2) || (behaviorType == 3)) { + BgSpot08Iceblock_InitDynapoly(this, play, colHeader, DYNA_TRANSFORM_POS | DYNA_TRANSFORM_ROT_Y); + } else { + BgSpot08Iceblock_InitDynapoly(this, play, colHeader, 0); } - if (LINK_AGE_IN_YEARS == YEARS_CHILD) { Actor_Kill(&this->dyna.actor); return; } - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - switch (PARAMS_GET_NOSHIFT(this->dyna.actor.params, 4, 4)) { case 0: Actor_SetScale(&this->dyna.actor, 0.2f); break; + case 0x10: Actor_SetScale(&this->dyna.actor, 0.1f); break; + case 0x20: Actor_SetScale(&this->dyna.actor, 0.05f); break; } - - this->bobPhaseSlow = (s32)(Rand_ZeroOne() * (0xFFFF + 0.5f)); - this->bobPhaseFast = (s32)(Rand_ZeroOne() * (0xFFFF + 0.5f)); - this->surfaceNormal.y = 1.0f; - this->rotationAxis.x = 1.0f; - + this->yOscillationPhase1 = TRUNCF_BINANG(Rand_ZeroOne() * 65535.5f); + this->yOscillationPhase2 = TRUNCF_BINANG(Rand_ZeroOne() * 65535.5f); + this->unk_168.y = 1.0f; + this->swayAxis.x = 1.0f; switch (PARAMS_GET_U(this->dyna.actor.params, 0, 4)) { case 0: case 1: - BgSpot08Iceblock_SetupFloatNonrotating(this); + BgSpot08Iceblock_SetupIcebergStatic(this); break; + case 2: - BgSpot08Iceblock_SetupFloatRotating(this); + BgSpot08Iceblock_SetupIcebergSpin(this); break; + case 3: - BgSpot08Iceblock_SpawnTwinFloe(this, play); + BgSpot08Iceblock_SetupIcebergDuo(this, play); break; + case 4: - BgSpot08Iceblock_SetupNoAction(this); + BgSpot08Iceblock_SetupDoNothing(this); + break; + + default: break; } } @@ -370,63 +331,58 @@ void BgSpot08Iceblock_Destroy(Actor* thisx, PlayState* play) { DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } -void BgSpot08Iceblock_SetupFloatNonrotating(BgSpot08Iceblock* this) { - BgSpot08Iceblock_SetupAction(this, BgSpot08Iceblock_FloatNonrotating); +void BgSpot08Iceblock_SetupIcebergStatic(BgSpot08Iceblock* this) { + BgSpot08Iceblock_SetupAction(this, BgSpot08Iceblock_IcebergStatic); } -void BgSpot08Iceblock_FloatNonrotating(BgSpot08Iceblock* this, PlayState* play) { - BgSpot08Iceblock_Bobbing(this); - BgSpot08Iceblock_SinkUnderPlayer(this); - BgSpot08Iceblock_SetWaterline(this); +void BgSpot08Iceblock_IcebergStatic(BgSpot08Iceblock* this, PlayState* play) { + BgSpot08Iceblock_UpdateYOscillation(this); + BgSpot08Iceblock_UpdateSinkHeight(this); + BgSpot08Iceblock_UpdatePosY(this); this->dyna.actor.shape.rot.y = this->dyna.actor.home.rot.y; - BgSpot08Iceblock_Roll(this, play); + BgSpot08Iceblock_UpdateSwaying(this, play); } -void BgSpot08Iceblock_SetupFloatRotating(BgSpot08Iceblock* this) { - BgSpot08Iceblock_SetupAction(this, BgSpot08Iceblock_FloatRotating); +void BgSpot08Iceblock_SetupIcebergSpin(BgSpot08Iceblock* this) { + BgSpot08Iceblock_SetupAction(this, BgSpot08Iceblock_IcebergSpin); } -void BgSpot08Iceblock_FloatRotating(BgSpot08Iceblock* this, PlayState* play) { - BgSpot08Iceblock_Bobbing(this); - BgSpot08Iceblock_SinkUnderPlayer(this); - BgSpot08Iceblock_SetWaterline(this); +void BgSpot08Iceblock_IcebergSpin(BgSpot08Iceblock* this, PlayState* play) { + BgSpot08Iceblock_UpdateYOscillation(this); + BgSpot08Iceblock_UpdateSinkHeight(this); + BgSpot08Iceblock_UpdatePosY(this); this->dyna.actor.world.rot.y += 0x190; this->dyna.actor.shape.rot.y = this->dyna.actor.world.rot.y; - BgSpot08Iceblock_Roll(this, play); + BgSpot08Iceblock_UpdateSwaying(this, play); } -void BgSpot08Iceblock_SetupFloatOrbitingTwins(BgSpot08Iceblock* this) { - BgSpot08Iceblock_SetupAction(this, BgSpot08Iceblock_FloatOrbitingTwins); +void BgSpot08Iceblock_SetupActionIcebergDuo(BgSpot08Iceblock* this) { + BgSpot08Iceblock_SetupAction(this, BgSpot08Iceblock_IcebergDuo); } -void BgSpot08Iceblock_FloatOrbitingTwins(BgSpot08Iceblock* this, PlayState* play) { - f32 cos; - f32 sin; +void BgSpot08Iceblock_IcebergDuo(BgSpot08Iceblock* this, PlayState* play) { + f32 dz; + f32 dx; - BgSpot08Iceblock_Bobbing(this); - BgSpot08Iceblock_SinkUnderPlayer(this); - BgSpot08Iceblock_SetWaterline(this); - - // parent handles rotations of both + BgSpot08Iceblock_UpdateYOscillation(this); + BgSpot08Iceblock_UpdateSinkHeight(this); + BgSpot08Iceblock_UpdatePosY(this); if (!PARAMS_GET_NOSHIFT(this->dyna.actor.params, 8, 1)) { this->dyna.actor.world.rot.y += 0x190; - sin = Math_SinS(this->dyna.actor.world.rot.y) * 100.0f; - cos = Math_CosS(this->dyna.actor.world.rot.y) * 100.0f; - - this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x + sin; - this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z + cos; - + dx = Math_SinS(this->dyna.actor.world.rot.y) * 100.0f; + dz = Math_CosS(this->dyna.actor.world.rot.y) * 100.0f; + this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x + dx; + this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z + dz; if (this->dyna.actor.child != NULL) { - this->dyna.actor.child->world.pos.x = this->dyna.actor.home.pos.x - sin; - this->dyna.actor.child->world.pos.z = this->dyna.actor.home.pos.z - cos; + this->dyna.actor.child->world.pos.x = this->dyna.actor.home.pos.x - dx; + this->dyna.actor.child->world.pos.z = this->dyna.actor.home.pos.z - dz; } } - this->dyna.actor.shape.rot.y = this->dyna.actor.home.rot.y; - BgSpot08Iceblock_Roll(this, play); + BgSpot08Iceblock_UpdateSwaying(this, play); } -void BgSpot08Iceblock_SetupNoAction(BgSpot08Iceblock* this) { +void BgSpot08Iceblock_SetupDoNothing(BgSpot08Iceblock* this) { BgSpot08Iceblock_SetupAction(this, NULL); } @@ -434,29 +390,28 @@ void BgSpot08Iceblock_Update(Actor* thisx, PlayState* play) { BgSpot08Iceblock* this = (BgSpot08Iceblock*)thisx; if (Rand_ZeroOne() < 0.05f) { - this->bobIncrSlow = Rand_S16Offset(300, 100); - this->bobIncrFast = Rand_S16Offset(800, 400); + this->yOscillationPulse1 = Rand_S16Offset(0x12C, 0x64); + this->yOscillationPulse2 = Rand_S16Offset(0x320, 0x190); } - - this->bobPhaseSlow += this->bobIncrSlow; - this->bobPhaseFast += this->bobIncrFast; + this->yOscillationPhase1 += this->yOscillationPulse1; + this->yOscillationPhase2 += this->yOscillationPulse2; if (this->actionFunc != NULL) { this->actionFunc(this, play); } } void BgSpot08Iceblock_Draw(Actor* thisx, PlayState* play) { - Gfx* dList; + Gfx* dl; BgSpot08Iceblock* this = (BgSpot08Iceblock*)thisx; switch (PARAMS_GET_NOSHIFT(this->dyna.actor.params, 9, 1)) { - case 0: - dList = gZorasFountainIcebergDL; + case 0x0: + dl = gZorasFountainIcebergDL; break; + case 0x200: - dList = gZorasFountainIceRampDL; + dl = gZorasFountainIceRampDL; break; } - - Gfx_DrawDListOpa(play, dList); + Gfx_DrawDListOpa(play, dl); } diff --git a/src/overlays/actors/ovl_Bg_Spot08_Iceblock/z_bg_spot08_iceblock.h b/src/overlays/actors/ovl_Bg_Spot08_Iceblock/z_bg_spot08_iceblock.h index 45c5976f37a..68da72ac519 100644 --- a/src/overlays/actors/ovl_Bg_Spot08_Iceblock/z_bg_spot08_iceblock.h +++ b/src/overlays/actors/ovl_Bg_Spot08_Iceblock/z_bg_spot08_iceblock.h @@ -9,44 +9,17 @@ struct BgSpot08Iceblock; typedef void (*BgSpot08IceblockActionFunc)(struct BgSpot08Iceblock*, struct PlayState*); typedef struct BgSpot08Iceblock { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x0164 */ BgSpot08IceblockActionFunc actionFunc; - /* 0x0168 */ Vec3f surfaceNormal; - /* 0x0170 */ Vec3f normalDelta; // y always 0 - /* 0x0180 */ Vec3f rotationAxis; - /* 0x018C */ s16 bobPhaseSlow; - /* 0x018E */ s16 bobPhaseFast; - /* 0x0190 */ s16 bobIncrSlow; - /* 0x0192 */ s16 bobIncrFast; - /* 0x0194 */ f32 sinkOffset; - /* 0x0198 */ f32 bobOffset; -} BgSpot08Iceblock; // size = 0x019C - -// Params -/** - * 0x200: Shape - * 0x200 is the ice ramp where Jabu is as child - */ - -/** - * 0x100: Twins - * 0x100 is the spawned twin platform - */ - -/** - * 0xF0: Size - * 0x00 is large - * 0x10 is medium - * 0x20 is small - */ - -/** - * 0xF: Action - * 0 Floating, nonrotating - * 1 same as 0, but does not roll as much (?) - * 2 Floating, rotating - * 3 Floating orbiting twins - * 4 Completely static, does nothing - */ + /* 0x000 */ DynaPolyActor dyna; + /* 0x164 */ BgSpot08IceblockActionFunc actionFunc; + /* 0x168 */ Vec3f unk_168; + /* 0x174 */ Vec3f unk_174; + /* 0x180 */ Vec3f swayAxis; + /* 0x18C */ s16 yOscillationPhase1; + /* 0x18E */ s16 yOscillationPhase2; + /* 0x190 */ s16 yOscillationPulse1; + /* 0x192 */ s16 yOscillationPulse2; + /* 0x194 */ f32 sinkHeight; + /* 0x198 */ f32 yOscillation; +} BgSpot08Iceblock; // size = 0x19C #endif diff --git a/src/overlays/actors/ovl_Bg_Spot09_Obj/z_bg_spot09_obj.c b/src/overlays/actors/ovl_Bg_Spot09_Obj/z_bg_spot09_obj.c index ca62a57b853..1c24cf8fc13 100644 --- a/src/overlays/actors/ovl_Bg_Spot09_Obj/z_bg_spot09_obj.c +++ b/src/overlays/actors/ovl_Bg_Spot09_Obj/z_bg_spot09_obj.c @@ -70,15 +70,16 @@ static Gfx* sDLists[] = { s32 func_808B1AE0(BgSpot09Obj* this, PlayState* play) { s32 carpentersRescued; + Actor* thisx = &this->dyna.actor; if (IS_CUTSCENE_LAYER) { - return this->dyna.actor.params == BG_SPOT09_OBJ_BRIDGE_SIDES; + return thisx->params == BG_SPOT09_OBJ_BRIDGE_SIDES; } carpentersRescued = GET_EVENTCHKINF_CARPENTERS_ALL_RESCUED(); if (LINK_AGE_IN_YEARS == YEARS_ADULT) { - switch (this->dyna.actor.params) { + switch (thisx->params) { case BG_SPOT09_OBJ_BRIDGE_SIDES: return false; case BG_SPOT09_OBJ_BRIDGE_BROKEN: @@ -89,32 +90,34 @@ s32 func_808B1AE0(BgSpot09Obj* this, PlayState* play) { return true; } } else { - return this->dyna.actor.params == BG_SPOT09_OBJ_BRIDGE_CHILD; + return thisx->params == BG_SPOT09_OBJ_BRIDGE_CHILD; } return false; } s32 func_808B1BA0(BgSpot09Obj* this, PlayState* play) { - if (this->dyna.actor.params == BG_SPOT09_OBJ_TENT) { - Actor_SetScale(&this->dyna.actor, 0.1f); + Actor* thisx = &this->dyna.actor; + + if (thisx->params == BG_SPOT09_OBJ_TENT) { + Actor_SetScale(thisx, 0.1f); } else { - Actor_SetScale(&this->dyna.actor, 1.0f); + Actor_SetScale(thisx, 1.0f); } return 1; } s32 func_808B1BEC(BgSpot09Obj* this, PlayState* play) { - STACK_PAD(s32); + Actor* thisx = &this->dyna.actor; CollisionHeader* colHeader = NULL; STACK_PADS(s32, 2); - if (D_808B1F90[this->dyna.actor.params] != NULL) { + if (D_808B1F90[thisx->params] != NULL) { DynaPolyActor_Init(&this->dyna, 0); - CollisionHeader_GetVirtual(D_808B1F90[this->dyna.actor.params], &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + CollisionHeader_GetVirtual(D_808B1F90[thisx->params], &colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, thisx, colHeader); } - return true; + return 1; } s32 func_808B1C70(BgSpot09Obj* this, PlayState* play) { @@ -122,20 +125,20 @@ s32 func_808B1C70(BgSpot09Obj* this, PlayState* play) { for (i = 0; i < ARRAY_COUNT(D_808B1FA4); i++) { if (!D_808B1FA4[i](this, play)) { - return false; + return 0; } } - return true; + return 1; } s32 func_808B1CEC(BgSpot09Obj* this, PlayState* play) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain1); - return true; + return 1; } s32 func_808B1D18(BgSpot09Obj* this, PlayState* play) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain2); - return true; + return 1; } s32 func_808B1D44(BgSpot09Obj* this, PlayState* play) { @@ -149,20 +152,18 @@ s32 func_808B1D44(BgSpot09Obj* this, PlayState* play) { void BgSpot09Obj_Init(Actor* thisx, PlayState* play) { BgSpot09Obj* this = (BgSpot09Obj*)thisx; - PRINTF(T("Spot09 Object [arg_data : 0x%04x](大工救出フラグ 0x%x)\n", - "Spot09 Object [arg_data : 0x%04x](Carpenter Rescue Flag 0x%x)\n"), - this->dyna.actor.params, GET_EVENTCHKINF_CARPENTERS_RESCUED_FLAGS()); - this->dyna.actor.params &= 0xFF; - if ((this->dyna.actor.params < 0) || (this->dyna.actor.params >= BG_SPOT09_OBJ_MAX)) { - PRINTF(T("Error : Spot 09 object の arg_data が判別出来ない(%s %d)(arg_data 0x%04x)\n", - "Error : Spot 09 object arg_data cannot be determined (%s %d)(arg_data 0x%04x)\n"), - "../z_bg_spot09_obj.c", 322, this->dyna.actor.params); + PRINTF("Spot09 Object [arg_data : 0x%04x](大工救出フラグ 0x%x)\n", thisx->params, + GET_EVENTCHKINF_CARPENTERS_RESCUED_FLAGS()); + thisx->params &= 0xFF; + if ((thisx->params < 0) || (thisx->params >= BG_SPOT09_OBJ_MAX)) { + PRINTF("Error : Spot 09 object の arg_data が判別出来ない(%s %d)(arg_data 0x%04x)\n", "../z_bg_spot09_obj.c", + 322, thisx->params); } if (!func_808B1C70(this, play)) { - Actor_Kill(&this->dyna.actor); + Actor_Kill(thisx); } else if (!func_808B1D44(this, play)) { - Actor_Kill(&this->dyna.actor); + Actor_Kill(thisx); } } @@ -170,7 +171,7 @@ void BgSpot09Obj_Destroy(Actor* thisx, PlayState* play) { DynaCollisionContext* dynaColCtx = &play->colCtx.dyna; BgSpot09Obj* this = (BgSpot09Obj*)thisx; - if (this->dyna.actor.params != BG_SPOT09_OBJ_BRIDGE_SIDES) { + if (thisx->params != BG_SPOT09_OBJ_BRIDGE_SIDES) { DynaPoly_DeleteBgActor(play, dynaColCtx, this->dyna.bgId); } } diff --git a/src/overlays/actors/ovl_Bg_Spot12_Gate/z_bg_spot12_gate.c b/src/overlays/actors/ovl_Bg_Spot12_Gate/z_bg_spot12_gate.c index 3e5b2ebedd3..08bad35428b 100644 --- a/src/overlays/actors/ovl_Bg_Spot12_Gate/z_bg_spot12_gate.c +++ b/src/overlays/actors/ovl_Bg_Spot12_Gate/z_bg_spot12_gate.c @@ -1,6 +1,6 @@ /* * File: z_bg_spot12_gate.c - * Overlay: ovl_Bg_Spot12_Gate + * Overlay: Bg_Spot12_Gate * Description: Haunted Wasteland Gate */ @@ -53,21 +53,20 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(cullingVolumeDownward, 1200, ICHAIN_STOP), }; -void BgSpot12Gate_InitDynaPoly(BgSpot12Gate* this, PlayState* play, CollisionHeader* collision, s32 flags) { - STACK_PAD(s32); +void func_808B2F90(BgSpot12Gate* this, PlayState* play, CollisionHeader* collision, s32 flags) { + Actor* thisx = &this->dyna.actor; CollisionHeader* colHeader = NULL; DynaPolyActor_Init(&this->dyna, flags); CollisionHeader_GetVirtual(collision, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, thisx, colHeader); #if DEBUG_FEATURES if (this->dyna.bgId == BG_ACTOR_MAX) { - STACK_PAD(s32); + STACK_PADS(s32, 2); - PRINTF(T("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", - "Warning : move BG registration failed (%s %d)(name %d)(arg_data 0x%04x)\n"), - "../z_bg_spot12_gate.c", 145, this->dyna.actor.id, this->dyna.actor.params); + PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_spot12_gate.c", 145, thisx->id, + thisx->params); } #endif } @@ -75,10 +74,10 @@ void BgSpot12Gate_InitDynaPoly(BgSpot12Gate* this, PlayState* play, CollisionHea void BgSpot12Gate_Init(Actor* thisx, PlayState* play) { BgSpot12Gate* this = (BgSpot12Gate*)thisx; - BgSpot12Gate_InitDynaPoly(this, play, &gGerudoFortressWastelandGateCol, 0); - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + func_808B2F90(this, play, &gGerudoFortressWastelandGateCol, 0); + Actor_ProcessInitChain(thisx, sInitChain); - if (Flags_GetSwitch(play, PARAMS_GET_U(this->dyna.actor.params, 0, 6))) { + if (Flags_GetSwitch(play, PARAMS_GET_U(thisx->params, 0, 6))) { func_808B3274(this); } else { func_808B30C0(this); @@ -92,20 +91,24 @@ void BgSpot12Gate_Destroy(Actor* thisx, PlayState* play) { } void func_808B30C0(BgSpot12Gate* this) { + Actor* thisx = &this->dyna.actor; + this->actionFunc = func_808B30D8; - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; + thisx->world.pos.y = thisx->home.pos.y; } void func_808B30D8(BgSpot12Gate* this, PlayState* play) { - if (Flags_GetSwitch(play, PARAMS_GET_U(this->dyna.actor.params, 0, 6))) { + Actor* thisx = &this->dyna.actor; + + if (Flags_GetSwitch(play, PARAMS_GET_U(thisx->params, 0, 6))) { func_808B3134(this); - OnePointCutscene_Init(play, 4160, -99, &this->dyna.actor, CAM_ID_MAIN); + OnePointCutscene_Init(play, 4160, -99, thisx, CAM_ID_MAIN); } } void func_808B3134(BgSpot12Gate* this) { this->actionFunc = func_808B314C; - this->unk_168 = 40; + this->unk_168 = 0x28; } void func_808B314C(BgSpot12Gate* this, PlayState* play) { @@ -119,11 +122,10 @@ void func_808B317C(BgSpot12Gate* this) { } void func_808B318C(BgSpot12Gate* this, PlayState* play) { - STACK_PAD(s32); + Actor* thisx = &this->dyna.actor; - Math_StepToF(&this->dyna.actor.velocity.y, 1.6f, 0.03f); - if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 200.0f, - this->dyna.actor.velocity.y)) { + Math_StepToF(&thisx->velocity.y, 1.6f, 0.03f); + if (Math_StepToF(&thisx->world.pos.y, thisx->home.pos.y + 200.0f, thisx->velocity.y)) { func_808B3274(this); { @@ -134,15 +136,17 @@ void func_808B318C(BgSpot12Gate* this, PlayState* play) { Quake_SetDuration(quakeIndex, 12); } - Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BRIDGE_OPEN_STOP); + Actor_PlaySfx(thisx, NA_SE_EV_BRIDGE_OPEN_STOP); } else { - Actor_PlaySfx_Flagged(&this->dyna.actor, NA_SE_EV_METALGATE_OPEN - SFX_FLAG); + Actor_PlaySfx_Flagged(thisx, NA_SE_EV_METALGATE_OPEN - SFX_FLAG); } } void func_808B3274(BgSpot12Gate* this) { + Actor* thisx = &this->dyna.actor; + this->actionFunc = func_808B3298; - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 200.0f; + thisx->world.pos.y = thisx->home.pos.y + 200.0f; } void func_808B3298(BgSpot12Gate* this, PlayState* play) { @@ -152,7 +156,7 @@ void BgSpot12Gate_Update(Actor* thisx, PlayState* play) { BgSpot12Gate* this = (BgSpot12Gate*)thisx; if (this->unk_168 > 0) { - this->unk_168--; + this->unk_168 -= 1; } this->actionFunc(this, play); } diff --git a/src/overlays/actors/ovl_Bg_Spot12_Saku/z_bg_spot12_saku.c b/src/overlays/actors/ovl_Bg_Spot12_Saku/z_bg_spot12_saku.c index c99153a191b..a72922a12aa 100644 --- a/src/overlays/actors/ovl_Bg_Spot12_Saku/z_bg_spot12_saku.c +++ b/src/overlays/actors/ovl_Bg_Spot12_Saku/z_bg_spot12_saku.c @@ -1,6 +1,6 @@ /* * File: z_bg_spot12_saku.c - * Overlay: ovl_Bg_Spot12_Saku + * Overlay: Bg_Spot12_Saku * Description: */ @@ -51,20 +51,19 @@ static InitChainEntry sInitChain[] = { }; void func_808B3420(BgSpot12Saku* this, PlayState* play, CollisionHeader* collision, s32 flags) { - STACK_PAD(s32); + Actor* thisx = &this->dyna.actor; CollisionHeader* colHeader = NULL; DynaPolyActor_Init(&this->dyna, flags); CollisionHeader_GetVirtual(collision, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, thisx, colHeader); #if DEBUG_FEATURES if (this->dyna.bgId == BG_ACTOR_MAX) { - STACK_PAD(s32); + STACK_PADS(s32, 2); - PRINTF(T("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", - "Warning : move BG registration failed (%s %d)(name %d)(arg_data 0x%04x)\n"), - "../z_bg_spot12_saku.c", 140, this->dyna.actor.id, this->dyna.actor.params); + PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_spot12_saku.c", 140, thisx->id, + thisx->params); } #endif } @@ -73,8 +72,8 @@ void BgSpot12Saku_Init(Actor* thisx, PlayState* play) { BgSpot12Saku* this = (BgSpot12Saku*)thisx; func_808B3420(this, play, &gGerudoFortressGTGShutterCol, 0); - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - if (Flags_GetSwitch(play, PARAMS_GET_U(this->dyna.actor.params, 0, 6))) { + Actor_ProcessInitChain(thisx, sInitChain); + if (Flags_GetSwitch(play, PARAMS_GET_U(thisx->params, 0, 6))) { func_808B3714(this); } else { func_808B3550(this); @@ -88,22 +87,26 @@ void BgSpot12Saku_Destroy(Actor* thisx, PlayState* play) { } void func_808B3550(BgSpot12Saku* this) { + Actor* thisx = &this->dyna.actor; + this->actionFunc = func_808B357C; - this->dyna.actor.scale.x = 0.1f; - this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x; - this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z; + thisx->scale.x = 0.1f; + thisx->world.pos.x = thisx->home.pos.x; + thisx->world.pos.z = thisx->home.pos.z; } void func_808B357C(BgSpot12Saku* this, PlayState* play) { - if (Flags_GetSwitch(play, PARAMS_GET_U(this->dyna.actor.params, 0, 6))) { + Actor* thisx = &this->dyna.actor; + + if (Flags_GetSwitch(play, PARAMS_GET_U(thisx->params, 0, 6))) { func_808B35E4(this); - this->timer = 20; - OnePointCutscene_Init(play, 4170, -99, &this->dyna.actor, CAM_ID_MAIN); + this->unk_168 = 0x14; + OnePointCutscene_Init(play, 4170, -99, thisx, CAM_ID_MAIN); } } void func_808B35E4(BgSpot12Saku* this) { - if (this->timer == 0) { + if (this->unk_168 == 0) { this->actionFunc = func_808B3604; } } @@ -125,12 +128,12 @@ void func_808B3604(BgSpot12Saku* this, PlayState* play) { } void func_808B3714(BgSpot12Saku* this) { + Actor* thisx = &this->dyna.actor; + this->actionFunc = func_808B37AC; - this->dyna.actor.scale.x = 0.001f / 0.14f; - this->dyna.actor.world.pos.x = - this->dyna.actor.home.pos.x - (Math_SinS(this->dyna.actor.shape.rot.y + 0x4000) * 78.0f); - this->dyna.actor.world.pos.z = - this->dyna.actor.home.pos.z - (Math_CosS(this->dyna.actor.shape.rot.y + 0x4000) * 78.0f); + thisx->scale.x = 0.001f / 0.14f; + thisx->world.pos.x = thisx->home.pos.x - (Math_SinS(thisx->shape.rot.y + 0x4000) * 78.0f); + thisx->world.pos.z = thisx->home.pos.z - (Math_CosS(thisx->shape.rot.y + 0x4000) * 78.0f); } void func_808B37AC(BgSpot12Saku* this, PlayState* play) { @@ -139,8 +142,8 @@ void func_808B37AC(BgSpot12Saku* this, PlayState* play) { void BgSpot12Saku_Update(Actor* thisx, PlayState* play) { BgSpot12Saku* this = (BgSpot12Saku*)thisx; - if (this->timer > 0) { - this->timer--; + if (this->unk_168 > 0) { + this->unk_168 -= 1; } this->actionFunc(this, play); } diff --git a/src/overlays/actors/ovl_Bg_Spot12_Saku/z_bg_spot12_saku.h b/src/overlays/actors/ovl_Bg_Spot12_Saku/z_bg_spot12_saku.h index 6c37ec6d977..3f42607a596 100644 --- a/src/overlays/actors/ovl_Bg_Spot12_Saku/z_bg_spot12_saku.h +++ b/src/overlays/actors/ovl_Bg_Spot12_Saku/z_bg_spot12_saku.h @@ -11,7 +11,7 @@ typedef void (*BgSpot12SakuActionFunc)(struct BgSpot12Saku*, struct PlayState*); typedef struct BgSpot12Saku { /* 0x0000 */ DynaPolyActor dyna; /* 0x0164 */ BgSpot12SakuActionFunc actionFunc; - /* 0x0168 */ s16 timer; + /* 0x0168 */ s16 unk_168; } BgSpot12Saku; // size = 0x016C #endif diff --git a/src/overlays/actors/ovl_Bg_Spot15_Rrbox/z_bg_spot15_rrbox.c b/src/overlays/actors/ovl_Bg_Spot15_Rrbox/z_bg_spot15_rrbox.c index cb9d19ae4b2..bd0f1f02d7d 100644 --- a/src/overlays/actors/ovl_Bg_Spot15_Rrbox/z_bg_spot15_rrbox.c +++ b/src/overlays/actors/ovl_Bg_Spot15_Rrbox/z_bg_spot15_rrbox.c @@ -1,9 +1,3 @@ -/* - * File: z_bg_spot15_rrbox.c - * Overlay: ovl_Bg_Spot15_Rrbox - * Description: Milk Crate - */ - #include "z_bg_spot15_rrbox.h" #include "array_count.h" @@ -100,9 +94,8 @@ void func_808B3A34(BgSpot15Rrbox* this) { s32 func_808B3A40(BgSpot15Rrbox* this, PlayState* play) { DynaPolyActor* dynaPolyActor = DynaPoly_GetActor(&play->colCtx, this->bgId); - if ((dynaPolyActor != NULL) && - Math3D_Dist2DSq(dynaPolyActor->actor.world.pos.x, dynaPolyActor->actor.world.pos.z, - this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.z) < 0.01f) { + if (dynaPolyActor != NULL && Math3D_Dist2DSq(dynaPolyActor->actor.world.pos.x, dynaPolyActor->actor.world.pos.z, + this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.z) < 0.01f) { return true; } return false; @@ -334,10 +327,9 @@ void func_808B43D0(BgSpot15Rrbox* this, PlayState* play) { Actor_MoveXZGravity(actor); - if (actor->world.pos.y <= BGCHECK_Y_MIN + 10.0f) { - PRINTF(T("Warning : ロンロン木箱落ちすぎた(%s %d)(arg_data 0x%04x)\n", - "Warning : Lon Lon Wooden Box fell too far (%s %d)(arg_data 0x%04x)\n"), - "../z_bg_spot15_rrbox.c", 599, actor->params); + if (actor->world.pos.y <= -31990.0f) { + PRINTF("Warning : ロンロン木箱落ちすぎた(%s %d)(arg_data 0x%04x)\n", "../z_bg_spot15_rrbox.c", 599, + actor->params); Actor_Kill(actor); diff --git a/src/overlays/actors/ovl_Bg_Spot15_Saku/z_bg_spot15_saku.c b/src/overlays/actors/ovl_Bg_Spot15_Saku/z_bg_spot15_saku.c index c151023887f..289b472fe9b 100644 --- a/src/overlays/actors/ovl_Bg_Spot15_Saku/z_bg_spot15_saku.c +++ b/src/overlays/actors/ovl_Bg_Spot15_Saku/z_bg_spot15_saku.c @@ -40,22 +40,21 @@ ActorProfile Bg_Spot15_Saku_Profile = { }; void BgSpot15Saku_Init(Actor* thisx, PlayState* play) { - STACK_PAD(s32); BgSpot15Saku* this = (BgSpot15Saku*)thisx; - STACK_PAD(s32); + STACK_PADS(s32, 2); CollisionHeader* colHeader = NULL; DynaPolyActor_Init(&this->dyna, 0); CollisionHeader_GetVirtual(&gLonLonCorralFenceCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); - this->dyna.actor.scale.x = 0.1f; - this->dyna.actor.scale.y = 0.1f; - this->dyna.actor.scale.z = 0.1f; - this->unk_170.x = this->dyna.actor.world.pos.x; - this->unk_170.y = this->dyna.actor.world.pos.y; - this->unk_170.z = this->dyna.actor.world.pos.z; + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, thisx, colHeader); + thisx->scale.x = 0.1f; + thisx->scale.y = 0.1f; + thisx->scale.z = 0.1f; + this->unk_170 = thisx->world.pos.x; + this->unk_174 = thisx->world.pos.y; + this->unk_178 = thisx->world.pos.z; if (GET_INFTABLE(INFTABLE_71)) { - this->dyna.actor.world.pos.z = 2659.0f; + thisx->world.pos.z = 2659.0f; } this->actionFunc = func_808B4930; } @@ -68,25 +67,26 @@ void BgSpot15Saku_Destroy(Actor* thisx, PlayState* play) { void func_808B4930(BgSpot15Saku* this, PlayState* play) { if (this->unk_168 && !GET_INFTABLE(INFTABLE_71)) { - this->timer = 2; + this->unk_17C = 2; this->actionFunc = func_808B4978; } } void func_808B4978(BgSpot15Saku* this, PlayState* play) { - if (this->timer == 0) { - Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_METALGATE_OPEN - SFX_FLAG); - this->dyna.actor.world.pos.z -= 2.0f; - if (this->dyna.actor.world.pos.z < 2660.0f) { - Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BRIDGE_OPEN_STOP); - this->timer = 30; + Actor* thisx = &this->dyna.actor; + if (!this->unk_17C) { + Actor_PlaySfx(thisx, NA_SE_EV_METALGATE_OPEN - SFX_FLAG); + thisx->world.pos.z -= 2.0f; + if (thisx->world.pos.z < 2660.0f) { + Actor_PlaySfx(thisx, NA_SE_EV_BRIDGE_OPEN_STOP); + this->unk_17C = 0x1E; this->actionFunc = func_808B4A04; } } } void func_808B4A04(BgSpot15Saku* this, PlayState* play) { - if (this->timer == 0) { + if (!this->unk_17C) { this->unk_168 = 0; this->actionFunc = func_808B4930; } @@ -95,10 +95,7 @@ void func_808B4A04(BgSpot15Saku* this, PlayState* play) { void BgSpot15Saku_Update(Actor* thisx, PlayState* play) { BgSpot15Saku* this = (BgSpot15Saku*)thisx; - if (this->timer != 0) { - this->timer--; - } - + DECR(this->unk_17C); this->actionFunc(this, play); } diff --git a/src/overlays/actors/ovl_Bg_Spot15_Saku/z_bg_spot15_saku.h b/src/overlays/actors/ovl_Bg_Spot15_Saku/z_bg_spot15_saku.h index 61118043184..a51214e393c 100644 --- a/src/overlays/actors/ovl_Bg_Spot15_Saku/z_bg_spot15_saku.h +++ b/src/overlays/actors/ovl_Bg_Spot15_Saku/z_bg_spot15_saku.h @@ -12,8 +12,10 @@ typedef struct BgSpot15Saku { /* 0x0000 */ DynaPolyActor dyna; /* 0x0164 */ BgSpot15SakuActionFunc actionFunc; /* 0x0168 */ u64 unk_168; - /* 0x0170 */ Vec3f unk_170; - /* 0x017C */ s16 timer; + /* 0x0170 */ f32 unk_170; + /* 0x0174 */ f32 unk_174; + /* 0x0174 */ f32 unk_178; + /* 0x017C */ s16 unk_17C; } BgSpot15Saku; // size = 0x0180 #endif diff --git a/src/overlays/actors/ovl_Bg_Spot16_Bombstone/z_bg_spot16_bombstone.c b/src/overlays/actors/ovl_Bg_Spot16_Bombstone/z_bg_spot16_bombstone.c index 8b99b352000..3a3ef82d942 100644 --- a/src/overlays/actors/ovl_Bg_Spot16_Bombstone/z_bg_spot16_bombstone.c +++ b/src/overlays/actors/ovl_Bg_Spot16_Bombstone/z_bg_spot16_bombstone.c @@ -323,7 +323,7 @@ void func_808B5240(BgSpot16Bombstone* this, PlayState* play) { if (1) {} while (true) { - if ((u32)this->unk_158 >= ARRAY_COUNTU(D_808B5EB0) || this->unk_154 < D_808B5EB0[this->unk_158][0]) { + if (this->unk_158 >= ARRAY_COUNTU(D_808B5EB0) || this->unk_154 < D_808B5EB0[this->unk_158][0]) { break; } diff --git a/src/overlays/actors/ovl_Bg_Spot18_Basket/z_bg_spot18_basket.c b/src/overlays/actors/ovl_Bg_Spot18_Basket/z_bg_spot18_basket.c index dda3f1ad0a6..62053ce61c5 100644 --- a/src/overlays/actors/ovl_Bg_Spot18_Basket/z_bg_spot18_basket.c +++ b/src/overlays/actors/ovl_Bg_Spot18_Basket/z_bg_spot18_basket.c @@ -151,37 +151,36 @@ static InitChainEntry sInitChain[] = { }; void BgSpot18Basket_Init(Actor* thisx, PlayState* play) { - STACK_PAD(s32); BgSpot18Basket* this = (BgSpot18Basket*)thisx; + Actor* actor = &this->dyna.actor; CollisionHeader* colHeader = NULL; DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS | DYNA_TRANSFORM_ROT_Y); BgSpot18Basket_InitColliderJntSph(&this->dyna.actor, play); CollisionHeader_GetVirtual(&gGoronCityVaseCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, actor, colHeader); - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - ActorShape_Init(&this->dyna.actor.shape, 0.0f, ActorShadow_DrawCircle, 15.0f); - this->dyna.actor.home.pos.y += 0.01f; - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; + Actor_ProcessInitChain(actor, sInitChain); + ActorShape_Init(&actor->shape, 0.0f, ActorShadow_DrawCircle, 15.0f); + actor->home.pos.y += 0.01f; + actor->world.pos.y = actor->home.pos.y; - if (Flags_GetSwitch(play, PARAMS_GET_U(this->dyna.actor.params, 8, 6))) { + if (Flags_GetSwitch(play, PARAMS_GET_U(actor->params, 8, 6))) { BgSpot18Basket_SetupSpinning(this); return; } BgSpot18Basket_SetupInactive(this); - Actor_SpawnAsChild(&play->actorCtx, &this->dyna.actor, play, ACTOR_BG_SPOT18_FUTA, 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 + 0x1555, this->dyna.actor.shape.rot.z, -1); + Actor_SpawnAsChild(&play->actorCtx, actor, play, ACTOR_BG_SPOT18_FUTA, actor->world.pos.x, actor->world.pos.y, + actor->world.pos.z, actor->shape.rot.x, actor->shape.rot.y + 0x1555, actor->shape.rot.z, -1); - if (this->dyna.actor.child == NULL) { + if (actor->child == NULL) { PRINTF_COLOR_RED(); PRINTF(T("Error : 変化壷蓋発生失敗(%s %d)\n", "Error : Failed to spawn the change pot cover (%s %d)\n"), "../z_bg_spot18_basket.c", 351); PRINTF_RST(); - Actor_Kill(&this->dyna.actor); + Actor_Kill(actor); } } @@ -449,13 +448,13 @@ void BgSpot18Basket_GivingPrize(BgSpot18Basket* this, PlayState* play) { } void BgSpot18Basket_Update(Actor* thisx, PlayState* play) { - STACK_PAD(s32); BgSpot18Basket* this = (BgSpot18Basket*)thisx; - s32 bgId; + STACK_PAD(s32); + s32 temp; this->timer++; this->actionFunc(this, play); - this->dyna.actor.floorHeight = BgCheck_EntityRaycastDown4(&play->colCtx, &this->dyna.actor.floorPoly, &bgId, + this->dyna.actor.floorHeight = BgCheck_EntityRaycastDown4(&play->colCtx, &this->dyna.actor.floorPoly, &temp, &this->dyna.actor, &this->dyna.actor.world.pos); if (this->actionFunc != BgSpot18Basket_Inactive) { CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliderJntSph.base); diff --git a/src/overlays/actors/ovl_Bg_Spot18_Futa/z_bg_spot18_futa.h b/src/overlays/actors/ovl_Bg_Spot18_Futa/z_bg_spot18_futa.h index a24b60f0939..376eb48f862 100644 --- a/src/overlays/actors/ovl_Bg_Spot18_Futa/z_bg_spot18_futa.h +++ b/src/overlays/actors/ovl_Bg_Spot18_Futa/z_bg_spot18_futa.h @@ -9,4 +9,5 @@ struct BgSpot18Futa; typedef struct BgSpot18Futa { /* 0x0000 */ DynaPolyActor dyna; } BgSpot18Futa; // size = 0x0164 + #endif diff --git a/src/overlays/actors/ovl_Bg_Spot18_Obj/z_bg_spot18_obj.c b/src/overlays/actors/ovl_Bg_Spot18_Obj/z_bg_spot18_obj.c index fcc2dd522aa..1032304fc5d 100644 --- a/src/overlays/actors/ovl_Bg_Spot18_Obj/z_bg_spot18_obj.c +++ b/src/overlays/actors/ovl_Bg_Spot18_Obj/z_bg_spot18_obj.c @@ -1,7 +1,7 @@ /* * File: z_bg_spot18_obj.c - * Overlay: ovl_Bg_Spot18_Obj + * Overlay: Bg_Spot18_Obj * Description: */ diff --git a/src/overlays/actors/ovl_Bg_Toki_Hikari/z_bg_toki_hikari.c b/src/overlays/actors/ovl_Bg_Toki_Hikari/z_bg_toki_hikari.c index acc231224eb..d55ce2047d8 100644 --- a/src/overlays/actors/ovl_Bg_Toki_Hikari/z_bg_toki_hikari.c +++ b/src/overlays/actors/ovl_Bg_Toki_Hikari/z_bg_toki_hikari.c @@ -1,9 +1,3 @@ -/* - * File: z_bg_toki_hikari.c - * Overlay: ovl_Toki_Hikari - * Description: Temple of Time Windows - */ - #include "z_bg_toki_hikari.h" #include "gfx.h" @@ -23,12 +17,12 @@ void BgTokiHikari_Destroy(Actor* thisx, PlayState* play); void BgTokiHikari_Update(Actor* thisx, PlayState* play); void BgTokiHikari_Draw(Actor* thisx, PlayState* play); -void BgTokiHikari_DoNothing(BgTokiHikari* this, PlayState* play); -void func_808BA018(Actor* thisx, PlayState* play); -void func_808BA204(BgTokiHikari* this, PlayState* play); -void func_808BA22C(BgTokiHikari* this, PlayState* play); -void func_808BA274(BgTokiHikari* this, PlayState* play); -void func_808BA2CC(Actor* thisx, PlayState* play); +void BgTokiHikari_WindowsAndLight_DoNothing(BgTokiHikari* this, PlayState* play); +void BgTokiHikari_WindowsAndLight_Draw(Actor* thisx, PlayState* play); +void BgTokiHikari_TriforceFlash_Wait(BgTokiHikari* this, PlayState* play); +void BgTokiHikari_TriforceFlash_Brighten(BgTokiHikari* this, PlayState* play); +void BgTokiHikari_TriforceFlash_FadeAway(BgTokiHikari* this, PlayState* play); +void BgTokiHikari_TriforceFlash_Draw(Actor* thisx, PlayState* play); ActorProfile Bg_Toki_Hikari_Profile = { /**/ ACTOR_BG_TOKI_HIKARI, @@ -50,14 +44,15 @@ void BgTokiHikari_Init(Actor* thisx, PlayState* play) { BgTokiHikari* this = (BgTokiHikari*)thisx; switch (this->actor.params) { - case 0: + case BG_TOKI_HIKARI_TYPE_WINDOWS_AND_LIGHT: Actor_ProcessInitChain(&this->actor, sInitChain); - this->actionFunc = BgTokiHikari_DoNothing; + this->actionFunc = BgTokiHikari_WindowsAndLight_DoNothing; break; - case 1: + + case BG_TOKI_HIKARI_TYPE_TRIFORCE_FLASH: if (!GET_EVENTCHKINF(EVENTCHKINF_OPENED_DOOR_OF_TIME)) { - this->actionFunc = func_808BA204; - this->unk_14C = 0.0f; + this->actionFunc = BgTokiHikari_TriforceFlash_Wait; + this->triforceFlashIntensity = 0.0f; } else { Actor_Kill(&this->actor); } @@ -66,9 +61,10 @@ void BgTokiHikari_Init(Actor* thisx, PlayState* play) { } void BgTokiHikari_Destroy(Actor* thisx, PlayState* play) { + STACK_PAD(s32); } -void BgTokiHikari_DoNothing(BgTokiHikari* this, PlayState* play) { +void BgTokiHikari_WindowsAndLight_DoNothing(BgTokiHikari* this, PlayState* play) { } void BgTokiHikari_Update(Actor* thisx, PlayState* play) { @@ -79,19 +75,21 @@ void BgTokiHikari_Update(Actor* thisx, PlayState* play) { void BgTokiHikari_Draw(Actor* thisx, PlayState* play) { switch (thisx->params) { - case 0: - func_808BA018(thisx, play); - break; - case 1: - func_808BA2CC(thisx, play); - break; + case BG_TOKI_HIKARI_TYPE_WINDOWS_AND_LIGHT: + BgTokiHikari_WindowsAndLight_Draw(thisx, play); + return; + + case BG_TOKI_HIKARI_TYPE_TRIFORCE_FLASH: + BgTokiHikari_TriforceFlash_Draw(thisx, play); + return; } } -void func_808BA018(Actor* thisx, PlayState* play) { - PlayState* play2 = (PlayState*)play; +void BgTokiHikari_WindowsAndLight_Draw(Actor* thisx, PlayState* play) { + PlayState* play2 = play; + + OPEN_DISPS(play->state.gfxCtx, "../z_bg_toki_hikari.c", 0xF6); - OPEN_DISPS(play->state.gfxCtx, "../z_bg_toki_hikari.c", 246); Gfx_SetupDL_25Opa(play->state.gfxCtx); MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx, "../z_bg_toki_hikari.c", 252); @@ -99,87 +97,86 @@ void func_808BA018(Actor* thisx, PlayState* play) { gSPDisplayList(POLY_OPA_DISP++, object_toki_objects_DL_008190); } else { gSPDisplayList(POLY_OPA_DISP++, object_toki_objects_DL_007E20); - Gfx_SetupDL_25Xlu(play->state.gfxCtx); - gSPSegment(POLY_XLU_DISP++, 8, Gfx_TexScroll(play->state.gfxCtx, 0, play2->gameplayFrames % 128, 64, 32)); - - gSPSegment(POLY_XLU_DISP++, 9, Gfx_TexScroll(play->state.gfxCtx, 0, play2->gameplayFrames % 128, 64, 32)); + Gfx_SetupDL_25Xlu(play->state.gfxCtx); + gSPSegment(POLY_XLU_DISP++, 8, Gfx_TexScroll(play->state.gfxCtx, 0, play2->gameplayFrames & 0x7F, 64, 32)); + gSPSegment(POLY_XLU_DISP++, 9, Gfx_TexScroll(play->state.gfxCtx, 0, play2->gameplayFrames & 0x7F, 64, 32)); MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx, "../z_bg_toki_hikari.c", 278); - gSPDisplayList(POLY_XLU_DISP++, object_toki_objects_DL_007EE0); } - CLOSE_DISPS(play->state.gfxCtx, "../z_bg_toki_hikari.c", 284); + + CLOSE_DISPS(play->state.gfxCtx, "../z_bg_toki_hikari.c", 0x11C); } -void func_808BA204(BgTokiHikari* this, PlayState* play) { +void BgTokiHikari_TriforceFlash_Wait(BgTokiHikari* this, PlayState* play) { if (play->roomCtx.drawParams[1] != 0) { - this->actionFunc = func_808BA22C; + this->actionFunc = BgTokiHikari_TriforceFlash_Brighten; } } -void func_808BA22C(BgTokiHikari* this, PlayState* play) { - if (this->unk_14C < 1.0f) { - this->unk_14C += 0.05f; +void BgTokiHikari_TriforceFlash_Brighten(BgTokiHikari* this, PlayState* play) { + if (this->triforceFlashIntensity < 1.0f) { + this->triforceFlashIntensity += 0.05f; } else { - this->unk_14C = 1.0f; - this->actionFunc = func_808BA274; + this->triforceFlashIntensity = 1.0f; + this->actionFunc = BgTokiHikari_TriforceFlash_FadeAway; } } -void func_808BA274(BgTokiHikari* this, PlayState* play) { - if (this->unk_14C > 0.2f) { - this->unk_14C -= 0.025f; +void BgTokiHikari_TriforceFlash_FadeAway(BgTokiHikari* this, PlayState* play) { + if (this->triforceFlashIntensity > 0.2f) { + this->triforceFlashIntensity -= 0.025f; } else { - this->unk_14C = 0.0f; + this->triforceFlashIntensity = 0.0f; Actor_Kill(&this->actor); } } -void func_808BA2CC(Actor* thisx, PlayState* play) { +void BgTokiHikari_TriforceFlash_Draw(Actor* thisx, PlayState* play) { BgTokiHikari* this = (BgTokiHikari*)thisx; STACK_PAD(s32); - OPEN_DISPS(play->state.gfxCtx, "../z_bg_toki_hikari.c", 350); + OPEN_DISPS(play->state.gfxCtx, "../z_bg_toki_hikari.c", 0x15E); + Matrix_Translate(0.0f, 276.0f, 1122.0f, MTXMODE_NEW); - Matrix_Scale(0.32f, 0.32f, this->unk_14C * 7.0f, MTXMODE_APPLY); + Matrix_Scale(0.32f, 0.32f, this->triforceFlashIntensity * 7.0f, MTXMODE_APPLY); Matrix_RotateZ(M_PI, MTXMODE_APPLY); + Gfx_SetupDL_25Opa(play->state.gfxCtx); + Matrix_Push(); gDPPipeSync(POLY_XLU_DISP++); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, this->unk_14C * 255.0f, (u8)(155.0f * this->unk_14C) + 100, - this->unk_14C * 255.0f, this->unk_14C * 255.0f); - - gDPSetEnvColor(POLY_XLU_DISP++, (u8)(this->unk_14C * 155.0f) + 100, (u8)(255.0f * this->unk_14C), 0, 128); - + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, (u8)(this->triforceFlashIntensity * 255.0f), + (u8)(155.0f * this->triforceFlashIntensity) + 100, (u8)(this->triforceFlashIntensity * 255.0f), + (u8)(this->triforceFlashIntensity * 255.0f)); + gDPSetEnvColor(POLY_XLU_DISP++, (u8)(this->triforceFlashIntensity * 155.0f) + 100, + (u8)(255.0f * this->triforceFlashIntensity), 0, 128); MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx, "../z_bg_toki_hikari.c", 382); - - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, -2 * (play->gameplayFrames & 0x7F), 0, 0x20, 0x40, - 1, (play->gameplayFrames & 0x7F) * 4, 0, 0x20, 0x40)); - + gSPSegment(POLY_XLU_DISP++, 8, + Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, (play->gameplayFrames & 0x7F) * -2, 0, 32, 64, 1, + (play->gameplayFrames & 0x7F) * 4, 0, 32, 64)); gSPDisplayList(POLY_XLU_DISP++, object_toki_objects_DL_000880); Matrix_Pop(); + Matrix_Push(); gDPPipeSync(POLY_XLU_DISP++); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)(this->unk_14C * 200.0f)); - - gDPSetEnvColor(POLY_XLU_DISP++, (u8)(this->unk_14C * 255.0f), (u8)(this->unk_14C * 255.0f), - (u8)(this->unk_14C * 255.0f), (u8)(200.0f * this->unk_14C)); - + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x00, 255, 255, 255, (u8)(this->triforceFlashIntensity * 200.0f)); + gDPSetEnvColor(POLY_XLU_DISP++, (u8)(this->triforceFlashIntensity * 255.0f), + (u8)(this->triforceFlashIntensity * 255.0f), (u8)(this->triforceFlashIntensity * 255.0f), + (u8)(200.0f * this->triforceFlashIntensity)); MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx, "../z_bg_toki_hikari.c", 415); - gSPDisplayList(POLY_XLU_DISP++, object_toki_objects_DL_0009C0); Matrix_Pop(); + Matrix_Push(); gDPPipeSync(POLY_XLU_DISP++); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)(this->unk_14C * 200.0f)); - - gDPSetEnvColor(POLY_XLU_DISP++, (u8)(this->unk_14C * 255.0f), (u8)(this->unk_14C * 255.0f), - (u8)(this->unk_14C * 255.0f), (u8)(200.0f * this->unk_14C)); - + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x00, 255, 255, 255, (u8)(this->triforceFlashIntensity * 200.0f)); + gDPSetEnvColor(POLY_XLU_DISP++, (u8)(this->triforceFlashIntensity * 255.0f), + (u8)(this->triforceFlashIntensity * 255.0f), (u8)(this->triforceFlashIntensity * 255.0f), + (u8)(200.0f * this->triforceFlashIntensity)); MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx, "../z_bg_toki_hikari.c", 437); - gSPDisplayList(POLY_XLU_DISP++, &object_toki_objects_DL_0009C0[10]); Matrix_Pop(); - CLOSE_DISPS(play->state.gfxCtx, "../z_bg_toki_hikari.c", 443); + + CLOSE_DISPS(play->state.gfxCtx, "../z_bg_toki_hikari.c", 0x1BB); } diff --git a/src/overlays/actors/ovl_Bg_Toki_Hikari/z_bg_toki_hikari.h b/src/overlays/actors/ovl_Bg_Toki_Hikari/z_bg_toki_hikari.h index 62f668f842d..9021f947f7a 100644 --- a/src/overlays/actors/ovl_Bg_Toki_Hikari/z_bg_toki_hikari.h +++ b/src/overlays/actors/ovl_Bg_Toki_Hikari/z_bg_toki_hikari.h @@ -4,14 +4,19 @@ #include "ultra64.h" #include "actor.h" +typedef enum BgTokiHikariType { + BG_TOKI_HIKARI_TYPE_WINDOWS_AND_LIGHT, + BG_TOKI_HIKARI_TYPE_TRIFORCE_FLASH +} BgTokiHikariType; + struct BgTokiHikari; typedef void (*BgTokiHikariActionFunc)(struct BgTokiHikari*, struct PlayState*); typedef struct BgTokiHikari { - /* 0x0000 */ Actor actor; - /* 0x014C */ f32 unk_14C; - /* 0x0150 */ BgTokiHikariActionFunc actionFunc; -} BgTokiHikari; // size = 0x0154 + /* 0x000 */ Actor actor; + /* 0x14C */ f32 triforceFlashIntensity; + /* 0x150 */ BgTokiHikariActionFunc actionFunc; +} BgTokiHikari; // size = 0x154 #endif diff --git a/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd.c b/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd.c index 1985fb401a6..60229167275 100644 --- a/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd.c +++ b/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd.c @@ -71,7 +71,7 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit sColChkInfoInit = { 10, 35, 100, MASS_IMMOVABLE }; static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 25, ICHAIN_STOP), + ICHAIN_VEC3F_DIV1000(scale, 0x19, ICHAIN_STOP), }; void BgTokiSwd_SetupAction(BgTokiSwd* this, BgTokiSwdActionFunc actionFunc) { @@ -79,15 +79,15 @@ void BgTokiSwd_SetupAction(BgTokiSwd* this, BgTokiSwdActionFunc actionFunc) { } void BgTokiSwd_Init(Actor* thisx, PlayState* play) { - STACK_PAD(s32); BgTokiSwd* this = (BgTokiSwd*)thisx; + STACK_PAD(s32); - Actor_ProcessInitChain(&this->actor, sInitChain); + Actor_ProcessInitChain(thisx, sInitChain); this->actor.shape.yOffset = 800.0f; BgTokiSwd_SetupAction(this, func_808BAF40); if (LINK_IS_ADULT) { - this->actor.draw = NULL; + thisx->draw = NULL; } if (gSaveContext.sceneLayer == 5) { @@ -96,8 +96,8 @@ void BgTokiSwd_Init(Actor* thisx, PlayState* play) { Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, thisx, &sCylinderInit); - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); + Collider_UpdateCylinder(thisx, &this->collider); + CollisionCheck_SetInfo(&thisx->colChkInfo, NULL, &sColChkInfoInit); } void BgTokiSwd_Destroy(Actor* thisx, PlayState* play) { 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 19ae238ff8a..8f2a42da3b0 100644 --- a/src/overlays/actors/ovl_Bg_Umajump/z_bg_umajump.c +++ b/src/overlays/actors/ovl_Bg_Umajump/z_bg_umajump.c @@ -38,8 +38,8 @@ static InitChainEntry sInitChain[] = { }; void BgUmaJump_Init(Actor* thisx, PlayState* play) { - STACK_PAD(s32); BgUmaJump* this = (BgUmaJump*)thisx; + STACK_PAD(s32); CollisionHeader* colHeader = NULL; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); diff --git a/src/overlays/actors/ovl_Bg_Ydan_Hasi/z_bg_ydan_hasi.c b/src/overlays/actors/ovl_Bg_Ydan_Hasi/z_bg_ydan_hasi.c index 453f5496d00..4f8239dd3a0 100644 --- a/src/overlays/actors/ovl_Bg_Ydan_Hasi/z_bg_ydan_hasi.c +++ b/src/overlays/actors/ovl_Bg_Ydan_Hasi/z_bg_ydan_hasi.c @@ -3,7 +3,6 @@ * Overlay: ovl_Bg_Ydan_Hasi * Description: Deku Tree Puzzle elements. Water plane and floating block in B1, and 3 blocks on 2F */ - #include "z_bg_ydan_hasi.h" #include "gfx.h" diff --git a/src/overlays/actors/ovl_Bg_Ydan_Maruta/z_bg_ydan_maruta.c b/src/overlays/actors/ovl_Bg_Ydan_Maruta/z_bg_ydan_maruta.c index 85a47db5cdb..c26c4af5889 100644 --- a/src/overlays/actors/ovl_Bg_Ydan_Maruta/z_bg_ydan_maruta.c +++ b/src/overlays/actors/ovl_Bg_Ydan_Maruta/z_bg_ydan_maruta.c @@ -139,7 +139,7 @@ void BgYdanMaruta_Destroy(Actor* thisx, PlayState* play) { BgYdanMaruta* this = (BgYdanMaruta*)thisx; Collider_DestroyTris(play, &this->collider); - if (this->dyna.actor.params == 1) { + if (thisx->params == 1) { DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } } @@ -208,9 +208,7 @@ void BgYdanMaruta_Update(Actor* thisx, PlayState* play) { } void BgYdanMaruta_Draw(Actor* thisx, PlayState* play) { - BgYdanMaruta* this = (BgYdanMaruta*)thisx; - - if (this->dyna.actor.params == 0) { + if (thisx->params == 0) { Gfx_DrawDListOpa(play, gDTRollingSpikeTrapDL); } else { Gfx_DrawDListOpa(play, gDTFallingLadderDL); diff --git a/src/overlays/actors/ovl_Bg_Zg/z_bg_zg.c b/src/overlays/actors/ovl_Bg_Zg/z_bg_zg.c index 0ee9fad7f70..0994b5bbd23 100644 --- a/src/overlays/actors/ovl_Bg_Zg/z_bg_zg.c +++ b/src/overlays/actors/ovl_Bg_Zg/z_bg_zg.c @@ -70,7 +70,8 @@ void func_808C0C50(BgZg* this) { } s32 func_808C0C98(BgZg* this, PlayState* play) { - s32 flag = PARAMS_GET_U(this->dyna.actor.params, 8, 8); + Actor* thisx = &this->dyna.actor; + s32 flag = PARAMS_GET_U(thisx->params, 8, 8); return Flags_GetSwitch(play, flag); } @@ -99,9 +100,11 @@ void func_808C0CD4(BgZg* this, PlayState* play) { } void func_808C0D08(BgZg* this, PlayState* play) { - this->dyna.actor.world.pos.y += (kREG(16) + 20.0f) * 1.2f; - if ((((kREG(17) + 200.0f) * 1.2f) + this->dyna.actor.home.pos.y) <= this->dyna.actor.world.pos.y) { - Actor_Kill(&this->dyna.actor); + Actor* thisx = &this->dyna.actor; + + thisx->world.pos.y += (kREG(16) + 20.0f) * 1.2f; + if ((((kREG(17) + 200.0f) * 1.2f) + thisx->home.pos.y) <= thisx->world.pos.y) { + Actor_Kill(thisx); } } @@ -118,25 +121,25 @@ void BgZg_Update(Actor* thisx, PlayState* play) { } void BgZg_Init(Actor* thisx, PlayState* play) { - STACK_PADS(s32, 2); BgZg* this = (BgZg*)thisx; + STACK_PADS(s32, 2); CollisionHeader* colHeader; - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + Actor_ProcessInitChain(thisx, sInitChain); DynaPolyActor_Init(&this->dyna, 0); colHeader = NULL; CollisionHeader_GetVirtual(&gTowerCollapseBarsCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, thisx, colHeader); if ((func_808C0CC8(this) == 8) || (func_808C0CC8(this) == 9)) { - this->dyna.actor.scale.x *= 1.3f; - this->dyna.actor.scale.z *= 1.3f; - this->dyna.actor.scale.y *= 1.2f; + thisx->scale.x *= 1.3f; + thisx->scale.z *= 1.3f; + thisx->scale.y *= 1.2f; } this->action = 0; this->drawConfig = 0; - if (func_808C0C98(this, play)) { - Actor_Kill(&this->dyna.actor); + if (func_808C0C98(this, play) != 0) { + Actor_Kill(thisx); } } diff --git a/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c b/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c index 851512e96a0..5ad77f6f61a 100644 --- a/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c +++ b/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c @@ -1128,7 +1128,7 @@ s32 BossDodongo_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Ve CLOSE_DISPS(play->state.gfxCtx, "../z_boss_dodongo.c", 3826); } - return true; + return 1; } void BossDodongo_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { diff --git a/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c b/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c index c83a227809d..fb2a9c9e4c2 100644 --- a/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c +++ b/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c @@ -126,15 +126,15 @@ static ColliderCylinderInit sLightBallCylinderInit = { static u8 D_808E4C58[] = { 0, 12, 10, 12, 14, 16, 12, 14, 16, 12, 14, 16, 12, 14, 16, 10, 16, 14 }; static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; -#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ique-cn:128 ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128" +#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ique-cn:0" \ + "ntsc-1.0:0 ntsc-1.1:0 ntsc-1.2:0 pal-1.0:0 pal-1.1:0" static EnGanonMant* sCape; // TODO: There's probably a way to match BSS ordering with less padding by spreading the variables out and moving // data around. It would be easier if we had more options for controlling BSS ordering in debug. -#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ique-cn:128 ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128" +#pragma increment_block_number "gc-eu:192 gc-eu-mq:192 gc-jp:192 gc-jp-ce:192 gc-jp-mq:192 gc-us:192 gc-us-mq:192" \ + "ique-cn:192 ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128" static s32 sSeed1; static s32 sSeed2; @@ -3956,7 +3956,7 @@ void BossGanon_LightBall_Update(Actor* thisx, PlayState* play2) { switch (this->unk_1C2) { case 0: - if ((player->stateFlags1 & PLAYER_STATE1_SWINGING_BOTTLE) && + if ((player->stateFlags1 & PLAYER_STATE1_1) && (ABS((s16)(player->actor.shape.rot.y - (s16)(ganondorf->actor.yawTowardsPlayer + 0x8000))) < 0x2000) && (sqrtf(SQ(xDistFromLink) + SQ(yDistFromLink) + SQ(zDistFromLink)) <= 25.0f)) { diff --git a/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c b/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c index 52dd4add3fe..e5c1a61ffa3 100644 --- a/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c +++ b/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c @@ -33,7 +33,7 @@ #include "assets/objects/gameplay_keep/gameplay_keep.h" #pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ique-cn:0 ntsc-1.0:0 ntsc-1.1:0 ntsc-1.2:0 pal-1.0:128 pal-1.1:128" + "ique-cn:128 ntsc-1.0:0 ntsc-1.1:0 ntsc-1.2:0 pal-1.0:128 pal-1.1:128" #define FLAGS \ (ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_HOSTILE | ACTOR_FLAG_UPDATE_CULLING_DISABLED | \ diff --git a/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c b/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c index 70132ef9fc7..5569e197e57 100644 --- a/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c +++ b/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c @@ -35,7 +35,7 @@ #include "assets/objects/gameplay_keep/gameplay_keep_0x173D0.h" #pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ique-cn:128 ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128" + "ique-cn:0 ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128" #define FLAGS \ (ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_HOSTILE | ACTOR_FLAG_UPDATE_CULLING_DISABLED | \ diff --git a/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c b/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c index 912229abada..dd26425675c 100644 --- a/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c +++ b/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c @@ -27,8 +27,8 @@ #include "assets/objects/gameplay_keep/shadow_circle.h" #include "assets/objects/object_tw/object_tw.h" -#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ique-cn:128" \ - "ntsc-1.0:0 ntsc-1.1:0 ntsc-1.2:0 pal-1.0:0 pal-1.1:0" +#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ + "ique-cn:128 ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128" #define FLAGS \ (ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_HOSTILE | ACTOR_FLAG_UPDATE_CULLING_DISABLED | \ diff --git a/src/overlays/actors/ovl_Boss_Va/z_boss_va.c b/src/overlays/actors/ovl_Boss_Va/z_boss_va.c index 9ae5021b005..f8b8ea8d85e 100644 --- a/src/overlays/actors/ovl_Boss_Va/z_boss_va.c +++ b/src/overlays/actors/ovl_Boss_Va/z_boss_va.c @@ -30,8 +30,8 @@ #include "assets/objects/gameplay_keep/gameplay_keep_0x55DB0.h" #include "assets/objects/object_bv/object_bv.h" -#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ntsc-1.0:0" \ - "ntsc-1.1:0 ntsc-1.2:0 pal-1.0:128 pal-1.1:128" +#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ique-cn:128" \ + "ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128" #define FLAGS \ (ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_HOSTILE | ACTOR_FLAG_UPDATE_CULLING_DISABLED | \ diff --git a/src/overlays/actors/ovl_Demo_Ec/z_demo_ec.c b/src/overlays/actors/ovl_Demo_Ec/z_demo_ec.c index 01b29b16d00..3cc2e59259e 100644 --- a/src/overlays/actors/ovl_Demo_Ec/z_demo_ec.c +++ b/src/overlays/actors/ovl_Demo_Ec/z_demo_ec.c @@ -726,7 +726,7 @@ void DemoEc_DrawCarpenter(DemoEc* this, PlayState* play) { void DemoEc_InitGerudo(DemoEc* this, PlayState* play) { DemoEc_UseDrawObject(this, play); - DemoEc_InitSkelAnime(this, play, &gGerudoWhiteSkel); + DemoEc_InitSkelAnime(this, play, &gObjectGe1Skel); DemoEc_UseAnimationObject(this, play); DemoEc_ChangeAnimation(this, &gDemoEcGerudoAnim, 0, 0.0f, false); func_8096D5D4(this, play); @@ -745,11 +745,11 @@ void DemoEc_UpdateGerudo(DemoEc* this, PlayState* play) { Gfx* DemoEc_GetGerudoPostLimbDList(DemoEc* this) { switch (this->actor.params) { case 16: - return gGerudoWhiteHairstyleBobDL; + return gObjectGe1HairStrandsDL; case 17: - return gGerudoWhiteHairstyleStraightFringeDL; + return gObjectGe1HairFringeDL; case 18: - return gGerudoWhiteHairstyleSpikyDL; + return gObjectGe1HairSpikyDL; default: PRINTF(VT_FGCOL(RED) T("かつらが無い!!!!!!!!!!!!!!!!\n", "No wig!!!!!!!!!!!!!!!!\n") VT_RST); return NULL; @@ -768,9 +768,9 @@ void DemoEc_GerudoPostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3 void DemoEc_DrawGerudo(DemoEc* this, PlayState* play) { static void* eyeTextures[] = { - gGerudoWhiteEyeOpenTex, - gGerudoWhiteEyeHalfTex, - gGerudoWhiteEyeClosedTex, + gObjectGe1EyeOpenTex, + gObjectGe1EyeHalfTex, + gObjectGe1EyeClosedTex, }; s32 eyeTexIndex = this->eyeTexIndex; void* eyeTexture = eyeTextures[eyeTexIndex]; 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 c5f427e04eb..f3af93b0894 100644 --- a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c +++ b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c @@ -2,6 +2,7 @@ #include "libc64/math64.h" #include "libc64/qrand.h" +#include "animation_curve.h" #include "attributes.h" #include "gfx.h" #include "gfx_setupdl.h" @@ -18,7 +19,6 @@ #include "versions.h" #include "z_lib.h" #include "audio.h" -#include "curve.h" #include "draw.h" #include "cutscene_flags.h" #include "effect.h" @@ -104,32 +104,32 @@ static s16 sSfxJewelId[] = { 0 }; // The object used by the effectType static s16 sEffectTypeObjects[] = { - /* 0x00 */ OBJECT_EFC_CRYSTAL_LIGHT, - /* 0x01 */ OBJECT_EFC_FIRE_BALL, - /* 0x02 */ OBJECT_GAMEPLAY_KEEP, - /* 0x03 */ OBJECT_EFC_LGT_SHOWER, - /* 0x04 */ OBJECT_GOD_LGT, - /* 0x05 */ OBJECT_GOD_LGT, - /* 0x06 */ OBJECT_GOD_LGT, - /* 0x07 */ OBJECT_LIGHT_RING, - /* 0x08 */ OBJECT_TRIFORCE_SPOT, - /* 0x09 */ OBJECT_GI_MEDAL, - /* 0x0A */ OBJECT_GI_MEDAL, - /* 0x0B */ OBJECT_GI_MEDAL, - /* 0x0C */ OBJECT_GI_MEDAL, - /* 0x0D */ OBJECT_GI_MEDAL, - /* 0x0E */ OBJECT_GI_MEDAL, - /* 0x0F */ OBJECT_EFC_TW, - /* 0x10 */ OBJECT_LIGHT_RING, - /* 0x11 */ OBJECT_LIGHT_RING, - /* 0x12 */ OBJECT_GAMEPLAY_KEEP, - /* 0x13 */ OBJECT_GI_JEWEL, - /* 0x14 */ OBJECT_GI_JEWEL, - /* 0x15 */ OBJECT_GI_JEWEL, - /* 0x16 */ OBJECT_GI_JEWEL, - /* 0x17 */ OBJECT_GI_M_ARROW, - /* 0x18 */ OBJECT_EFC_TW, - /* 0x19 */ OBJECT_EFC_TW, + OBJECT_EFC_CRYSTAL_LIGHT, // DEMO_EFFECT_CRYSTAL_LIGHT + OBJECT_EFC_FIRE_BALL, // DEMO_EFFECT_FIRE_BALL + OBJECT_GAMEPLAY_KEEP, // DEMO_EFFECT_BLUE_ORB + OBJECT_EFC_LGT_SHOWER, // DEMO_EFFECT_LGT_SHOWER + OBJECT_GOD_LGT, // DEMO_EFFECT_GOD_LGT_DIN + OBJECT_GOD_LGT, // DEMO_EFFECT_GOD_LGT_NAYRU + OBJECT_GOD_LGT, // DEMO_EFFECT_GOD_LGT_FARORE + OBJECT_LIGHT_RING, // DEMO_EFFECT_LIGHTRING_EXPANDING + OBJECT_TRIFORCE_SPOT, // DEMO_EFFECT_TRIFORCE_SPOT + OBJECT_GI_MEDAL, // DEMO_EFFECT_MEDAL_FIRE + OBJECT_GI_MEDAL, // DEMO_EFFECT_MEDAL_WATER + OBJECT_GI_MEDAL, // DEMO_EFFECT_MEDAL_FOREST + OBJECT_GI_MEDAL, // DEMO_EFFECT_MEDAL_SPIRIT + OBJECT_GI_MEDAL, // DEMO_EFFECT_MEDAL_SHADOW + OBJECT_GI_MEDAL, // DEMO_EFFECT_MEDAL_LIGHT + OBJECT_EFC_TW, // DEMO_EFFECT_TIMEWARP_MASTERSWORD + OBJECT_LIGHT_RING, // DEMO_EFFECT_LIGHTRING_SHRINKING + OBJECT_LIGHT_RING, // DEMO_EFFECT_LIGHTRING_TRIFORCE + OBJECT_GAMEPLAY_KEEP, // DEMO_EFFECT_LIGHT + OBJECT_GI_JEWEL, // DEMO_EFFECT_JEWEL_KOKIRI + OBJECT_GI_JEWEL, // DEMO_EFFECT_JEWEL_GORON + OBJECT_GI_JEWEL, // DEMO_EFFECT_JEWEL_ZORA + OBJECT_GI_JEWEL, // DEMO_EFFECT_DUST + OBJECT_GI_M_ARROW, // DEMO_EFFECT_LIGHTARROW + OBJECT_EFC_TW, // DEMO_EFFECT_TIMEWARP_TIMEBLOCK_LARGE + OBJECT_EFC_TW, // DEMO_EFFECT_TIMEWARP_TIMEBLOCK_SMALL }; static u8 sTimewarpVertexSizeIndices[] = { 1, 1, 2, 0, 1, 1, 2, 0, 1, 2, 0, 2, 1, 0, 1, 0, 2, 0, 2, 2, 0 }; @@ -483,24 +483,24 @@ void DemoEffect_Init(Actor* thisx, PlayState* play2) { break; case DEMO_EFFECT_JEWEL_KOKIRI: - this->jewelDisplayList = gGiKokiriEmeraldGemDL; - this->jewelHolderDisplayList = gGiKokiriEmeraldSettingDL; + this->jewelDisplayList = gGiKokiriEmeraldGem; + this->jewelHolderDisplayList = gGiKokiriEmeraldSetting; this->jewel.type = DEMO_EFFECT_JEWEL_KOKIRI; this->jewel.isPositionInit = 0; DemoEffect_InitJewel(play, this); break; case DEMO_EFFECT_JEWEL_GORON: - this->jewelDisplayList = gGiGoronRubyGemDL; - this->jewelHolderDisplayList = gGiGoronRubySettingDL; + this->jewelDisplayList = gGiGoronRubyGem; + this->jewelHolderDisplayList = gGiGoronRubySetting; this->jewel.type = DEMO_EFFECT_JEWEL_GORON; this->jewel.isPositionInit = 0; DemoEffect_InitJewel(play, this); break; case DEMO_EFFECT_JEWEL_ZORA: - this->jewelDisplayList = gGiZoraSapphireGemDL; - this->jewelHolderDisplayList = gGiZoraSapphireSettingDL; + this->jewelDisplayList = gGiZoraSapphireGem; + this->jewelHolderDisplayList = gGiZoraSapphireSetting; this->jewel.type = DEMO_EFFECT_JEWEL_ZORA; this->jewel.isPositionInit = 0; DemoEffect_InitJewel(play, this); @@ -688,12 +688,12 @@ void DemoEffect_UpdateGetItem(DemoEffect* this, PlayState* play) { void DemoEffect_InitTimeWarp(DemoEffect* this, PlayState* play) { s32 effectType = PARAMS_GET_S(this->actor.params, 0, 8); - if (!SkelCurve_Init(play, &this->skelCurve, &gTimeWarpSkel, &gTimeWarpAnim)) { + if (!SkelCurve_Init(play, &this->skelCurve, &object_efc_tw_0012E8_Skel, &object_efc_tw_000050_Anim)) { ASSERT(0, "0", "../z_demo_effect.c", 1283); } if (effectType == DEMO_EFFECT_TIMEWARP_TIMEBLOCK_LARGE || effectType == DEMO_EFFECT_TIMEWARP_TIMEBLOCK_SMALL) { - SkelCurve_SetAnim(&this->skelCurve, &gTimeWarpAnim, 1.0f, 59.0f, 1.0f, 1.7f); + SkelCurve_SetAnim(&this->skelCurve, &object_efc_tw_000050_Anim, 1.0f, 59.0f, 1.0f, 1.7f); SkelCurve_Update(play, &this->skelCurve); this->updateFunc = DemoEffect_InitTimeWarpTimeblock; @@ -704,12 +704,12 @@ void DemoEffect_InitTimeWarp(DemoEffect* this, PlayState* play) { } } else if (gSaveContext.sceneLayer == 5 || gSaveContext.sceneLayer == 4 || (gSaveContext.save.entranceIndex == ENTR_TEMPLE_OF_TIME_4 && !GET_EVENTCHKINF(EVENTCHKINF_C9))) { - SkelCurve_SetAnim(&this->skelCurve, &gTimeWarpAnim, 1.0f, 59.0f, 59.0f, 0.0f); + SkelCurve_SetAnim(&this->skelCurve, &object_efc_tw_000050_Anim, 1.0f, 59.0f, 59.0f, 0.0f); SkelCurve_Update(play, &this->skelCurve); this->updateFunc = DemoEffect_UpdateTimeWarpReturnFromChamberOfSages; PRINTF(VT_FGCOL(CYAN) T(" 縮むバージョン \n", " Shrinking version \n") VT_RST); } else { - SkelCurve_SetAnim(&this->skelCurve, &gTimeWarpAnim, 1.0f, 59.0f, 1.0f, 1.0f); + SkelCurve_SetAnim(&this->skelCurve, &object_efc_tw_000050_Anim, 1.0f, 59.0f, 1.0f, 1.0f); SkelCurve_Update(play, &this->skelCurve); this->updateFunc = DemoEffect_UpdateTimeWarpPullMasterSword; PRINTF(VT_FGCOL(CYAN) T(" 通常 バージョン \n", " Normal version \n") VT_RST); @@ -718,7 +718,7 @@ void DemoEffect_InitTimeWarp(DemoEffect* this, PlayState* play) { /** * Update function for the Timewarp Actor that is used when Link pulls the Mastersword - * It changes the Background Music and updates its SkelCurve animation. + * It changes the Background Music and updates it's SkelCurve animation. */ void DemoEffect_UpdateTimeWarpPullMasterSword(DemoEffect* this, PlayState* play) { if (CutsceneFlags_Get(play, 1)) { @@ -728,7 +728,7 @@ void DemoEffect_UpdateTimeWarpPullMasterSword(DemoEffect* this, PlayState* play) } if (SkelCurve_Update(play, &this->skelCurve)) { - SkelCurve_SetAnim(&this->skelCurve, &gTimeWarpAnim, 1.0f, 60.0f, 59.0f, 0.0f); + SkelCurve_SetAnim(&this->skelCurve, &object_efc_tw_000050_Anim, 1.0f, 60.0f, 59.0f, 0.0f); } } } @@ -743,7 +743,7 @@ void DemoEffect_TimewarpShrink(f32 size) { u8 sizes[3]; // This function uses the data in obj_efc_tw offset 0x0060 to 0x01B0 - vertices = SEGMENTED_TO_VIRTUAL(gTimeWarpVtx); + vertices = SEGMENTED_TO_VIRTUAL(object_efc_tw_000060_Vtx); sizes[0] = 0; sizes[1] = (s32)(202.0f * size); @@ -821,7 +821,7 @@ void DemoEffect_InitTimeWarpTimeblock(DemoEffect* this, PlayState* play) { Actor_PlaySfx_FlaggedCentered2(&this->actor, NA_SE_EV_TIMETRIP_LIGHT - SFX_FLAG); if (SkelCurve_Update(play, &this->skelCurve)) { - SkelCurve_SetAnim(&this->skelCurve, &gTimeWarpAnim, 1.0f, 60.0f, 59.0f, 0.0f); + SkelCurve_SetAnim(&this->skelCurve, &object_efc_tw_000050_Anim, 1.0f, 60.0f, 59.0f, 0.0f); this->updateFunc = DemoEffect_UpdateTimeWarpTimeblock; this->timeWarp.shrinkTimer = 0; } @@ -1739,21 +1739,21 @@ void DemoEffect_DrawCrystalLight(Actor* thisx, PlayState* play) { Matrix_RotateX(DEG_TO_RAD(11), MTXMODE_APPLY); Matrix_Translate(0.0f, 150.0f, 0.0f, MTXMODE_APPLY); MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx, "../z_demo_effect.c", 2661); - gSPDisplayList(POLY_XLU_DISP++, gCrystalLightDL); + gSPDisplayList(POLY_XLU_DISP++, object_efc_crystal_light_000980_DL); Matrix_Pop(); Matrix_Push(); Matrix_RotateY(DEG_TO_RAD(120), MTXMODE_APPLY); Matrix_RotateX(DEG_TO_RAD(11), MTXMODE_APPLY); Matrix_Translate(0.0f, 150.0f, 0.0f, MTXMODE_APPLY); MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx, "../z_demo_effect.c", 2672); - gSPDisplayList(POLY_XLU_DISP++, gCrystalLightDL); + gSPDisplayList(POLY_XLU_DISP++, object_efc_crystal_light_000980_DL); Matrix_Pop(); Matrix_Push(); Matrix_RotateY(DEG_TO_RAD(240), MTXMODE_APPLY); Matrix_RotateX(DEG_TO_RAD(11), MTXMODE_APPLY); Matrix_Translate(0.0f, 150.0f, 0.0f, MTXMODE_APPLY); MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx, "../z_demo_effect.c", 2683); - gSPDisplayList(POLY_XLU_DISP++, gCrystalLightDL); + gSPDisplayList(POLY_XLU_DISP++, object_efc_crystal_light_000980_DL); Matrix_Pop(); CLOSE_DISPS(play->state.gfxCtx, "../z_demo_effect.c", 2688); } @@ -1771,7 +1771,7 @@ void DemoEffect_DrawFireBall(Actor* thisx, PlayState* play) { gSPSegment(POLY_XLU_DISP++, 8, Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, 0, 0, 32, 32, 1, 0, 128 - ((frames * 20) % 128) - 1, 32, 32)); - gSPDisplayList(POLY_XLU_DISP++, gCreationFireBallDL); + gSPDisplayList(POLY_XLU_DISP++, object_efc_fire_ball_000040_DL); CLOSE_DISPS(play->state.gfxCtx, "../z_demo_effect.c", 2723); } @@ -1810,7 +1810,7 @@ void DemoEffect_DrawGodLgt(Actor* thisx, PlayState* play) { Gfx_SetupDL_25Xlu(play->state.gfxCtx); Matrix_Push(); MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx, "../z_demo_effect.c", 2801); - gSPDisplayList(POLY_XLU_DISP++, gGoldenGoddessAuraDL); + gSPDisplayList(POLY_XLU_DISP++, object_god_lgt_000330_DL); Gfx_SetupDL_25Opa(play->state.gfxCtx); func_8002EBCC(&this->actor, play, 0); Matrix_Pop(); @@ -1826,7 +1826,7 @@ void DemoEffect_DrawGodLgt(Actor* thisx, PlayState* play) { Matrix_Translate(0.0f, -140.0f, 0.0f, MTXMODE_APPLY); Matrix_Scale(0.03f, 0.03f, 0.03f, MTXMODE_APPLY); MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx, "../z_demo_effect.c", 2824); - gSPDisplayList(POLY_OPA_DISP++, gGoldenGoddessBodyDL); + gSPDisplayList(POLY_OPA_DISP++, object_god_lgt_003C50_DL); } CLOSE_DISPS(play->state.gfxCtx, "../z_demo_effect.c", 2829); @@ -1897,7 +1897,7 @@ void DemoEffect_DrawLgtShower(Actor* thisx, PlayState* play) { gSPSegment(POLY_XLU_DISP++, 8, Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, (frames * 5) % 1024, 0, 256, 64, 1, (frames * 10) % 128, 512 - ((frames * 50) % 512), 32, 16)); - gSPDisplayList(POLY_XLU_DISP++, gEnliveningLightDL); + gSPDisplayList(POLY_XLU_DISP++, object_efc_lgt_shower_0011D0_DL); CLOSE_DISPS(play->state.gfxCtx, "../z_demo_effect.c", 2942); } @@ -1915,7 +1915,7 @@ void DemoEffect_DrawLightRing(Actor* thisx, PlayState* play2) { gSPSegment(POLY_XLU_DISP++, 8, Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, (frames * 5) % 64, 512 - ((frames * 2) % 512) - 1, 16, 128, 1, 0, 0, 8, 1024)); - gSPDisplayList(POLY_XLU_DISP++, gGoldenGoddessLightRingDL); + gSPDisplayList(POLY_XLU_DISP++, object_light_ring_000190_DL); CLOSE_DISPS(play->state.gfxCtx, "../z_demo_effect.c", 2978); } @@ -1923,7 +1923,7 @@ void DemoEffect_DrawLightRing(Actor* thisx, PlayState* play2) { void DemoEffect_DrawTriforceSpot(Actor* thisx, PlayState* play) { DemoEffect* this = (DemoEffect*)thisx; STACK_PAD(s32); - Vtx* vertices = SEGMENTED_TO_VIRTUAL(gTriforceVtx); + Vtx* vertices = SEGMENTED_TO_VIRTUAL(object_triforce_spot_000000_Vtx); u32 frames = play->gameplayFrames; OPEN_DISPS(play->state.gfxCtx, "../z_demo_effect.c", 2994); @@ -1942,7 +1942,7 @@ void DemoEffect_DrawTriforceSpot(Actor* thisx, PlayState* play) { vertices[93].n.a = vertices[94].n.a = vertices[95].n.a = (s8)this->triforceSpot.lightColumnOpacity; gDPSetPrimColor(POLY_XLU_DISP++, 128, 128, 180, 255, 255, this->triforceSpot.lightColumnOpacity); gDPSetEnvColor(POLY_XLU_DISP++, 0, 255, 150, 255); - gSPDisplayList(POLY_XLU_DISP++, gTriforceLightColumnDL); + gSPDisplayList(POLY_XLU_DISP++, object_triforce_spot_000840_DL); Matrix_Pop(); } @@ -1960,7 +1960,7 @@ void DemoEffect_DrawTriforceSpot(Actor* thisx, PlayState* play) { Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, 0, 0, 32, 16, 1, 0, 0, 16, 8)); gDPSetPrimColor(POLY_XLU_DISP++, 128, 128, 255, 255, 160, this->triforceSpot.triforceSpotOpacity); gDPSetEnvColor(POLY_XLU_DISP++, 170, 140, 0, 255); - gSPDisplayList(POLY_XLU_DISP++, gTriforceDL); + gSPDisplayList(POLY_XLU_DISP++, object_triforce_spot_000600_DL); } else { func_8002EBCC(&this->actor, play, 0); Gfx_SetupDL_25Opa(play->state.gfxCtx); @@ -1971,7 +1971,7 @@ void DemoEffect_DrawTriforceSpot(Actor* thisx, PlayState* play) { Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, 0, 0, 32, 16, 1, 0, 0, 16, 8)); gDPSetPrimColor(POLY_OPA_DISP++, 128, 128, 255, 255, 160, 255); gDPSetEnvColor(POLY_OPA_DISP++, 170, 140, 0, 255); - gSPDisplayList(POLY_OPA_DISP++, gTriforceDL); + gSPDisplayList(POLY_OPA_DISP++, object_triforce_spot_000600_DL); } } } @@ -1994,7 +1994,7 @@ void DemoEffect_DrawGetItem(Actor* thisx, PlayState* play) { } } -s32 DemoEffect_OverrideLimbDrawTimeWarp(PlayState* play, SkelCurve* skelCurve, s32 limbIndex, void* thisx) { +s32 DemoEffect_DrawTimewarpLimbs(PlayState* play, SkelAnimeCurve* skelCuve, s32 limbIndex, void* thisx) { STACK_PAD(s32); DemoEffect* this = (DemoEffect*)thisx; u32 frames = play->gameplayFrames; @@ -2010,13 +2010,13 @@ s32 DemoEffect_OverrideLimbDrawTimeWarp(PlayState* play, SkelCurve* skelCurve, s CLOSE_DISPS(play->state.gfxCtx, "../z_demo_effect.c", 3172); if (limbIndex == 0) { - s16* transform = skelCurve->jointTable[0]; + LimbTransform* transform = &skelCuve->transforms[0]; - transform[2] = transform[0] = 1024; - transform[1] = 1024; + transform->scale.y = 1024; + transform->scale.z = transform->scale.x = 1024; } - return true; + return 1; } void DemoEffect_DrawTimeWarp(Actor* thisx, PlayState* play) { @@ -2027,12 +2027,9 @@ void DemoEffect_DrawTimeWarp(Actor* thisx, PlayState* play) { if (effectType == DEMO_EFFECT_TIMEWARP_TIMEBLOCK_LARGE || effectType == DEMO_EFFECT_TIMEWARP_TIMEBLOCK_SMALL || CutsceneFlags_Get(play, 1) || IS_CUTSCENE_LAYER || gSaveContext.save.entranceIndex == ENTR_TEMPLE_OF_TIME_4) { OPEN_DISPS(gfxCtx, "../z_demo_effect.c", 3201); - POLY_XLU_DISP = Gfx_SetupDL(POLY_XLU_DISP, SETUPDL_25); Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); - SkelCurve_Draw(&this->actor, play, &this->skelCurve, DemoEffect_OverrideLimbDrawTimeWarp, NULL, 1, - &this->actor); - + SkelCurve_Draw(thisx, play, &this->skelCurve, DemoEffect_DrawTimewarpLimbs, NULL, 1, this); CLOSE_DISPS(gfxCtx, "../z_demo_effect.c", 3216); } } 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 05747ff8dd5..b66e9953a12 100644 --- a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.h +++ b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.h @@ -3,11 +3,11 @@ #include "ultra64.h" #include "actor.h" -#include "curve.h" +#include "animation_curve.h" struct DemoEffect; -typedef void (*DemoEffectFunc)(struct DemoEffect*, struct PlayState*); +typedef void (*DemoEffectFunc)(struct DemoEffect* this, struct PlayState* play); typedef struct DemoEffectFireBall { /* 0x00 */ u8 timer; @@ -79,7 +79,7 @@ typedef struct DemoEffectDust { typedef struct DemoEffect { /* 0x0000 */ Actor actor; - /* 0x014C */ SkelCurve skelCurve; + /* 0x014C */ SkelAnimeCurve skelCurve; /* 0x016C */ u8 requiredObjectSlot; /* 0x0170 */ Gfx* jewelDisplayList; /* 0x0174 */ Gfx* jewelHolderDisplayList; diff --git a/src/overlays/actors/ovl_Demo_Ext/z_demo_ext.c b/src/overlays/actors/ovl_Demo_Ext/z_demo_ext.c index 1837fc7671b..9f07ad91960 100644 --- a/src/overlays/actors/ovl_Demo_Ext/z_demo_ext.c +++ b/src/overlays/actors/ovl_Demo_Ext/z_demo_ext.c @@ -1,258 +1,246 @@ -/* - * File: z_demo_ext.c - * Overlay: Demo_Ext - * Description: Magic Vortex in Silver Gauntlets Cutscene - */ - #include "z_demo_ext.h" +#include "array_count.h" #include "gfx.h" #include "gfx_setupdl.h" #include "printf.h" #include "regs.h" #include "sfx.h" #include "sys_matrix.h" -#include "terminal.h" -#include "translation.h" #include "play_state.h" #include "skin.h" +#include "stack_pad.h" #include "assets/objects/object_fhg/object_fhg.h" #define FLAGS ACTOR_FLAG_UPDATE_CULLING_DISABLED -typedef enum DemoExtAction { - /* 0x00 */ EXT_WAIT, - /* 0x01 */ EXT_MAINTAIN, - /* 0x02 */ EXT_DISPELL -} DemoExtAction; - -typedef enum DemoExtDrawMode { - /* 0x00 */ EXT_DRAW_NOTHING, - /* 0x01 */ EXT_DRAW_VORTEX -} DemoExtDrawMode; - void DemoExt_Init(Actor* thisx, PlayState* play); void DemoExt_Destroy(Actor* thisx, PlayState* play); void DemoExt_Update(Actor* thisx, PlayState* play); void DemoExt_Draw(Actor* thisx, PlayState* play); +void func_80977854(DemoExt*, PlayState*); +void func_80977874(DemoExt* this, PlayState* play); +void func_809778AC(DemoExt* this, PlayState* arg1); +void func_80977944(DemoExt* arg0, PlayState* arg1); +void func_80977950(DemoExt* this, PlayState* play); + +typedef void (*DemoExtUpdateFunc)(DemoExt*, PlayState*); +static DemoExtUpdateFunc sUpdateFuncs[] = { + func_80977854, + func_80977874, + func_809778AC, +}; +typedef void (*DemoExtDrawFunc)(DemoExt*, PlayState*); +static DemoExtDrawFunc sDrawFuncs[] = { + func_80977944, + func_80977950, +}; +ActorProfile Demo_Ext_Profile = { + /**/ ACTOR_DEMO_EXT, + /**/ ACTORCAT_NPC, + /**/ FLAGS, + /**/ OBJECT_FHG, + /**/ sizeof(DemoExt), + /**/ DemoExt_Init, + /**/ DemoExt_Destroy, + /**/ DemoExt_Update, + /**/ DemoExt_Draw, +}; + void DemoExt_Destroy(Actor* thisx, PlayState* play) { } void DemoExt_Init(Actor* thisx, PlayState* play) { DemoExt* this = (DemoExt*)thisx; - this->scrollIncr[0] = 25; - this->scrollIncr[1] = 40; - this->scrollIncr[2] = 5; - this->scrollIncr[3] = 30; - this->primAlpha = kREG(28) + 255; - this->envAlpha = kREG(32) + 255; - this->scale.x = kREG(19) + 400.0f; - this->scale.y = kREG(20) + 100.0f; - this->scale.z = kREG(21) + 400.0f; + this->texScrollStep[0] = 25; + this->texScrollStep[1] = 40; + this->texScrollStep[2] = 5; + this->texScrollStep[3] = 30; + this->unk170 = kREG(28) + 0xFF; + this->unk174 = kREG(32) + 0xFF; + this->unk178.x = kREG(19) + 400.0f; + this->unk178.y = kREG(20) + 100.0f; + this->unk178.z = kREG(21) + 400.0f; } -void DemoExt_PlayVortexSFX(DemoExt* this) { - if (this->alphaTimer <= (kREG(35) + 40.0f) - 15.0f) { +void func_80977450(DemoExt* this) { + if (this->unk16C <= (kREG(35) + 40.0f - 15.0f)) { SFX_PLAY_AT_POS(&this->actor.projectedPos, NA_SE_EV_FANTOM_WARP_L - SFX_FLAG); } } -CsCmdActorCue* DemoExt_GetCue(PlayState* play, s32 cueChannel) { +CsCmdActorCue* func_809774D8(PlayState* play, s32 arg1) { if (play->csCtx.state != CS_STATE_IDLE) { - CsCmdActorCue* cue = play->csCtx.actorCues[cueChannel]; + CsCmdActorCue* cue = play->csCtx.actorCues[arg1]; return cue; } - return NULL; } -void DemoExt_SetupWait(DemoExt* this) { - this->action = EXT_WAIT; - this->drawMode = EXT_DRAW_NOTHING; +void func_809774FC(DemoExt* this) { + this->unk14C = 0; + this->unk150 = 0; } -void DemoExt_SetupMaintainVortex(DemoExt* this, PlayState* play) { - CsCmdActorCue* cue = DemoExt_GetCue(play, 5); +void func_80977508(DemoExt* this, PlayState* play) { + CsCmdActorCue* temp_v0; + s16 temp_v1; - if (cue != NULL) { - this->actor.world.pos.x = cue->startPos.x; - this->actor.world.pos.y = cue->startPos.y; - this->actor.world.pos.z = cue->startPos.z; - this->actor.world.rot.y = this->actor.shape.rot.y = cue->rot.y; + temp_v0 = func_809774D8(play, 5); + if (temp_v0 != NULL) { + this->actor.world.pos.x = temp_v0->startPos.x; + this->actor.world.pos.y = temp_v0->startPos.y; + this->actor.world.pos.z = temp_v0->startPos.z; + temp_v1 = temp_v0->rot.y; + this->actor.shape.rot.y = temp_v1; + this->actor.world.rot.y = temp_v1; } - this->action = EXT_MAINTAIN; - this->drawMode = EXT_DRAW_VORTEX; + this->unk14C = 1; + this->unk150 = 1; } -void DemoExt_SetupDispellVortex(DemoExt* this) { - this->action = EXT_DISPELL; - this->drawMode = EXT_DRAW_VORTEX; +void func_80977590(DemoExt* this) { + this->unk14C = 2; + this->unk150 = 1; } -void DemoExt_FinishClosing(DemoExt* this) { - this->alphaTimer += 1.0f; - if ((kREG(35) + 40.0f) <= this->alphaTimer) { +void func_809775A4(DemoExt* this) { + this->unk16C += 1.0f; + if ((kREG(35) + 40.0f) <= this->unk16C) { Actor_Kill(&this->actor); } } -void DemoExt_HandleCues(DemoExt* this, PlayState* play) { - CsCmdActorCue* cue = DemoExt_GetCue(play, 5); - s32 nextCueId; - s32 currentCueId; - - if (cue != NULL) { - nextCueId = cue->id; - currentCueId = this->cueId; +void func_80977610(DemoExt* this, PlayState* play) { + CsCmdActorCue* temp_v0; + s32 temp_a2; + s32 v; - if (nextCueId != currentCueId) { - switch (nextCueId) { + temp_v0 = func_809774D8(play, 5); + if (temp_v0 != NULL) { + temp_a2 = temp_v0->id; + v = this->cueId; + if (temp_a2 != v) { + switch (temp_a2) { case 1: - DemoExt_SetupWait(this); + func_809774FC(this); break; + case 2: - DemoExt_SetupMaintainVortex(this, play); + func_80977508(this, play); break; + case 3: - DemoExt_SetupDispellVortex(this); + func_80977590(this); break; + default: - PRINTF(T("Demo_Ext_Check_DemoMode:そんな動作は無い!!!!!!!!\n", - "Demo_Ext_Check_DemoMode: There is no such action!!!!!!!!\n")); + PRINTF("Demo_Ext_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); break; } - this->cueId = nextCueId; + this->cueId = temp_a2; } } } -void DemoExt_SetScrollAndRotation(DemoExt* this) { - s16* scrollIncr = this->scrollIncr; - s16* curScroll = this->curScroll; - s32 i; +void func_809776D0(DemoExt* this) { + s16* texScrollPos = this->texScrollPos; + s16* texScrollStep = this->texScrollStep; + s32 var_v0; - for (i = 3; i != 0; i--) { - curScroll[i] += scrollIncr[i]; + for (var_v0 = 3; var_v0 != 0; var_v0--) { + texScrollPos[var_v0] += texScrollStep[var_v0]; } - this->rotationPitch += (s16)(kREG(34) + 1000); + this->unk168 += (s16)(kREG(34) + 0x3E8); } -void DemoExt_SetColorsAndScales(DemoExt* this) { - Vec3f* scale = &this->scale; - f32 shrinkFactor; +void func_8097771C(DemoExt* this) { + Vec3f* temp_v0; + f32 var_fv0; - shrinkFactor = ((kREG(35) + 40.0f) - this->alphaTimer) / (kREG(35) + 40.0f); - if (shrinkFactor < 0.0f) { - shrinkFactor = 0.0f; + temp_v0 = &this->unk178; + var_fv0 = ((kREG(35) + 40.0f) - this->unk16C) / (kREG(35) + 40.0f); + if (var_fv0 < 0.0f) { + var_fv0 = 0.0f; } - - this->primAlpha = (u32)(kREG(28) + 255) * shrinkFactor; - this->envAlpha = (u32)(kREG(32) + 255) * shrinkFactor; - scale->x = (kREG(19) + 400.0f) * shrinkFactor; - scale->y = (kREG(20) + 100.0f) * shrinkFactor; - scale->z = (kREG(21) + 400.0f) * shrinkFactor; + this->unk170 = (s32)((u32)(kREG(28) + 0xFF) * var_fv0); + this->unk174 = (s32)((u32)(kREG(32) + 0xFF) * var_fv0); + temp_v0->x = (kREG(19) + 400.0f) * var_fv0; + temp_v0->y = (kREG(20) + 100.0f) * var_fv0; + temp_v0->z = (kREG(21) + 400.0f) * var_fv0; } -void DemoExt_Wait(DemoExt* this, PlayState* play) { - DemoExt_HandleCues(this, play); +void func_80977854(DemoExt* this, PlayState* play) { + func_80977610(this, play); } -void DemoExt_MaintainVortex(DemoExt* this, PlayState* play) { - DemoExt_PlayVortexSFX(this); - DemoExt_SetScrollAndRotation(this); - DemoExt_HandleCues(this, play); +void func_80977874(DemoExt* this, PlayState* play) { + func_80977450(this); + func_809776D0(this); + func_80977610(this, play); } -void DemoExt_DispellVortex(DemoExt* this, PlayState* play) { - DemoExt_PlayVortexSFX(this); - DemoExt_SetScrollAndRotation(this); - DemoExt_SetColorsAndScales(this); - DemoExt_FinishClosing(this); +void func_809778AC(DemoExt* this, PlayState* play) { + func_80977450(this); + func_809776D0(this); + func_8097771C(this); + func_809775A4(this); } -static DemoExtActionFunc sActionFuncs[] = { - DemoExt_Wait, - DemoExt_MaintainVortex, - DemoExt_DispellVortex, -}; - void DemoExt_Update(Actor* thisx, PlayState* play) { DemoExt* this = (DemoExt*)thisx; - if ((this->action < EXT_WAIT) || (this->action > EXT_DISPELL) || sActionFuncs[this->action] == NULL) { - PRINTF(VT_FGCOL(RED) T("メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n", - "The main mode is wrong!!!!!!!!!!!!!!!!!!!!!!!!!\n") VT_RST); - } else { - sActionFuncs[this->action](this, play); + if ((this->unk14C < 0) || (this->unk14C >= ARRAY_COUNT(sUpdateFuncs)) || (sUpdateFuncs[this->unk14C] == NULL)) { + PRINTF(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); + return; } + sUpdateFuncs[this->unk14C](this, play); } -void DemoExt_DrawNothing(Actor* thisx, PlayState* play) { +void func_80977944(DemoExt* this, PlayState* play) { } -void DemoExt_DrawVortex(Actor* thisx, PlayState* play) { - DemoExt* this = (DemoExt*)thisx; - Mtx* mtx; +void func_80977950(DemoExt* this, PlayState* play) { GraphicsContext* gfxCtx; - s16* curScroll; - Vec3f* scale; + Mtx* mtx; + Vec3f* temp_v0; + s16* texScrollPos; + STACK_PAD(s32); - curScroll = this->curScroll; - scale = &this->scale; gfxCtx = play->state.gfxCtx; - mtx = GRAPH_ALLOC(gfxCtx, sizeof(Mtx)); - + texScrollPos = this->texScrollPos; + temp_v0 = &this->unk178; + mtx = GRAPH_ALLOC(gfxCtx, 0x40U); OPEN_DISPS(gfxCtx, "../z_demo_ext.c", 460); Matrix_Push(); - Matrix_Scale(scale->x, scale->y, scale->z, MTXMODE_APPLY); - Matrix_RotateZYX((s16)(kREG(16) + 0x4000), this->rotationPitch, kREG(18), MTXMODE_APPLY); + Matrix_Scale(temp_v0->x, temp_v0->y, temp_v0->z, MTXMODE_APPLY); + Matrix_RotateZYX(kREG(16) + 0x4000, this->unk168, kREG(18), MTXMODE_APPLY); Matrix_Translate(kREG(22), kREG(23), kREG(24), MTXMODE_APPLY); MATRIX_TO_MTX(mtx, "../z_demo_ext.c", 476); Matrix_Pop(); Gfx_SetupDL_25Xlu(gfxCtx); - - gDPSetPrimColor(POLY_XLU_DISP++, 0, kREG(33) + 128, kREG(25) + 140, kREG(26) + 80, kREG(27) + 140, this->primAlpha); - gDPSetEnvColor(POLY_XLU_DISP++, kREG(29) + 90, kREG(30) + 50, kREG(31) + 95, this->envAlpha); - gSPSegment( - POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(gfxCtx, 0, curScroll[0], curScroll[1], 0x40, 0x40, 1, curScroll[2], curScroll[3], 0x40, 0x40)); - + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, kREG(33) + 0x80, kREG(25) + 0x8C, kREG(26) + 0x50, kREG(27) + 0x8C, + this->unk170); + gDPSetEnvColor(POLY_XLU_DISP++, kREG(29) + 0x5A, kREG(30) + 0x32, kREG(31) + 0x5F, this->unk174); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(gfxCtx, 0, texScrollPos[0], texScrollPos[1], 64, 64, 1, texScrollPos[2], + texScrollPos[3], 64, 64)); gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gPhantomWarpDL); gSPPopMatrix(POLY_XLU_DISP++, G_MTX_MODELVIEW); - CLOSE_DISPS(gfxCtx, "../z_demo_ext.c", 512); } -static DemoExtDrawFunc sDrawFuncs[] = { - DemoExt_DrawNothing, - DemoExt_DrawVortex, -}; - void DemoExt_Draw(Actor* thisx, PlayState* play) { DemoExt* this = (DemoExt*)thisx; - if ((this->drawMode < EXT_DRAW_NOTHING) || (this->drawMode > EXT_DRAW_VORTEX) || - sDrawFuncs[this->drawMode] == NULL) { - PRINTF(VT_FGCOL(RED) T("描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n", - "The drawing mode is wrong!!!!!!!!!!!!!!!!!!!!!!!!!\n") VT_RST); - } else { - sDrawFuncs[this->drawMode](thisx, play); + if ((this->unk150 < 0) || (this->unk150 >= ARRAY_COUNT(sDrawFuncs)) || (sDrawFuncs[this->unk150] == NULL)) { + PRINTF(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); + return; } + sDrawFuncs[this->unk150](this, play); } - -ActorProfile Demo_Ext_Profile = { - /**/ ACTOR_DEMO_EXT, - /**/ ACTORCAT_NPC, - /**/ FLAGS, - /**/ OBJECT_FHG, - /**/ sizeof(DemoExt), - /**/ DemoExt_Init, - /**/ DemoExt_Destroy, - /**/ DemoExt_Update, - /**/ DemoExt_Draw, -}; diff --git a/src/overlays/actors/ovl_Demo_Ext/z_demo_ext.h b/src/overlays/actors/ovl_Demo_Ext/z_demo_ext.h index e34a059d50a..1b2d8bd2757 100644 --- a/src/overlays/actors/ovl_Demo_Ext/z_demo_ext.h +++ b/src/overlays/actors/ovl_Demo_Ext/z_demo_ext.h @@ -6,21 +6,19 @@ struct DemoExt; -typedef void (*DemoExtActionFunc)(struct DemoExt*, struct PlayState*); -typedef void (*DemoExtDrawFunc)(Actor*, struct PlayState*); - typedef struct DemoExt { - /* 0x0000 */ Actor actor; - /* 0x014C */ s32 action; - /* 0x014C */ s32 drawMode; - /* 0x0154 */ s32 cueId; - /* 0x015E */ s16 scrollIncr[4]; - /* 0x0160 */ s16 curScroll[4]; - /* 0x0168 */ s16 rotationPitch; - /* 0x016C */ f32 alphaTimer; - /* 0x0170 */ s32 primAlpha; - /* 0x0174 */ s32 envAlpha; - /* 0x0178 */ Vec3f scale; -} DemoExt; // size = 0x0184 + /* 0x000 */ Actor actor; + /* 0x14C */ s32 unk14C; + /* 0x150 */ s32 unk150; + /* 0x154 */ s32 cueId; + /* 0x158 */ s16 texScrollStep[4]; + /* 0x160 */ s16 texScrollPos[4]; + /* 0x168 */ s16 unk168; + /* 0x16A */ char pad16A[2]; + /* 0x16C */ f32 unk16C; + /* 0x170 */ s32 unk170; + /* 0x174 */ s32 unk174; + /* 0x178 */ Vec3f unk178; +} DemoExt; // size = 0x184 #endif diff --git a/src/overlays/actors/ovl_Demo_Go/z_demo_go.c b/src/overlays/actors/ovl_Demo_Go/z_demo_go.c index a154b34fabb..1bf8f1a2395 100644 --- a/src/overlays/actors/ovl_Demo_Go/z_demo_go.c +++ b/src/overlays/actors/ovl_Demo_Go/z_demo_go.c @@ -62,7 +62,7 @@ ActorProfile Demo_Go_Profile = { /**/ DemoGo_Draw, }; -s32 DemoGo_GetCueChannel(DemoGo* this) { +UNK_TYPE DemoGo_GetCueChannel(DemoGo* this) { s32 ret; switch (this->actor.params) { @@ -107,7 +107,7 @@ void func_8097C930(DemoGo* this) { STACK_PADS(s32, 3); if (DECR(*something) == 0) { - *something = Rand_S16Offset(60, 60); + *something = Rand_S16Offset(0x3C, 0x3C); } *other = *something; if (*other >= 3) { @@ -374,7 +374,7 @@ void func_8097D29C(DemoGo* this, PlayState* play) { void DemoGo_Draw(Actor* thisx, PlayState* play) { DemoGo* this = (DemoGo*)thisx; - if (this->drawConfig < 0 || this->drawConfig >= 2 || D_8097D468[this->drawConfig] == NULL) { + if (this->drawConfig < 0 || this->drawConfig >= 2 || D_8097D468[this->drawConfig] == 0) { PRINTF(VT_FGCOL(RED) T("描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n", "The drawing mode is wrong!!!!!!!!!!!!!!!!!!!!!!!!!\n") VT_RST); return; diff --git a/src/overlays/actors/ovl_Demo_Ik/z_demo_ik.c b/src/overlays/actors/ovl_Demo_Ik/z_demo_ik.c index 376908b1a5d..43ab87684f5 100644 --- a/src/overlays/actors/ovl_Demo_Ik/z_demo_ik.c +++ b/src/overlays/actors/ovl_Demo_Ik/z_demo_ik.c @@ -277,7 +277,7 @@ void DemoIk_Type1PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s switch (this->actor.params) { case 0: MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, gfxCtx, "../z_demo_ik_inArmer.c", 390); - gSPDisplayList(POLY_XLU_DISP++, gIronKnuckleArmorRivetAndSymbolDL); + gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016BE0); break; case 2: MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, gfxCtx, "../z_demo_ik_inArmer.c", 396); @@ -439,7 +439,7 @@ void DemoIk_Type2PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s break; case 5: MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, gfxCtx, "../z_demo_ik_inFace.c", 286); - gSPDisplayList(POLY_XLU_DISP++, gIronKnuckleArmorRivetAndSymbolDL); + gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016BE0); break; default: MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, gfxCtx, "../z_demo_ik_inFace.c", 292); diff --git a/src/overlays/actors/ovl_Demo_Im/z_demo_im.c b/src/overlays/actors/ovl_Demo_Im/z_demo_im.c index e257735b147..5c2f0d0d797 100644 --- a/src/overlays/actors/ovl_Demo_Im/z_demo_im.c +++ b/src/overlays/actors/ovl_Demo_Im/z_demo_im.c @@ -1175,7 +1175,7 @@ void DemoIm_Destroy(Actor* thisx, PlayState* play) { DemoIm_DestroyCollider(thisx, play); } -s32 DemoIm_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { +s32 func_80987514(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { DemoIm* this = (DemoIm*)thisx; s32* unk_2D0 = &this->unk_2D0; @@ -1195,14 +1195,15 @@ s32 DemoIm_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* } } - if ((*unk_2D0 != 0) && (limbIndex == IMPA_LIMB_RIGHT_HAND)) { - *dList = gImpaHandPointingDL; + if (*unk_2D0 != 0) { + if (limbIndex == IMPA_LIMB_RIGHT_HAND) { + *dList = gImpaHandPointingDL; + } } - - return false; + return 0; } -void DemoIm_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { +void func_809875C0(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { DemoIm* this = (DemoIm*)thisx; if (limbIndex == IMPA_LIMB_HEAD) { @@ -1237,8 +1238,8 @@ void DemoIm_DrawSolid(DemoIm* this, PlayState* play) { gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); gSPSegment(POLY_OPA_DISP++, 0x0C, ACTOR_SETUP_OPA_DL); - SkelAnime_DrawFlexOpa(play, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, - DemoIm_OverrideLimbDraw, DemoIm_PostLimbDraw, this); + SkelAnime_DrawFlexOpa(play, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, func_80987514, + func_809875C0, this); CLOSE_DISPS(play->state.gfxCtx, "../z_demo_im.c", 925); } 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 7a1dc7f6e1d..516ab22008d 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 @@ -1,13 +1,13 @@ #include "z_demo_tre_lgt.h" #include "src/overlays/actors/ovl_En_Box/z_en_box.h" +#include "animation_curve.h" #include "gfx.h" #include "gfx_setupdl.h" #include "printf.h" #include "sfx.h" #include "stack_pad.h" #include "translation.h" -#include "curve.h" #include "play_state.h" #include "save.h" @@ -49,7 +49,7 @@ ActorProfile Demo_Tre_Lgt_Profile = { /**/ DemoTreLgt_Draw, }; -static CurveAnimationHeader* sAnimations[] = { &gTreasureChestCurveAnim_4B60, &gTreasureChestCurveAnim_4F70 }; +static TransformUpdateIndex* sTransformUpdIdx[] = { &gTreasureChestCurveAnim_4B60, &gTreasureChestCurveAnim_4F70 }; static DemoTreLgtActionFunc sActionFuncs[] = { func_8099375C, @@ -59,7 +59,7 @@ static DemoTreLgtActionFunc sActionFuncs[] = { void DemoTreLgt_Init(Actor* thisx, PlayState* play) { DemoTreLgt* this = (DemoTreLgt*)thisx; - if (!SkelCurve_Init(play, &this->skelCurve, &gTreasureChestCurveSkel, sAnimations[0])) { + if (!SkelCurve_Init(play, &this->skelCurve, &gTreasureChestCurveSkel, sTransformUpdIdx[0])) { PRINTF(T("Demo_Tre_Lgt_Actor_ct();コンストラクト失敗\n", "Demo_Tre_Lgt_Actor_ct(); Construct failed\n")); } @@ -84,18 +84,18 @@ void func_80993754(DemoTreLgt* this) { void func_8099375C(DemoTreLgt* this, PlayState* play) { EnBox* treasureChest = (EnBox*)this->actor.parent; - if ((treasureChest != NULL) && Animation_OnFrame(&treasureChest->skelanime, 10.0f)) { + if (treasureChest != NULL && Animation_OnFrame(&treasureChest->skelanime, 10.0f)) { func_809937B4(this, play, treasureChest->skelanime.curFrame); } } void func_809937B4(DemoTreLgt* this, PlayState* play, f32 currentFrame) { - SkelCurve* skelCurve = &this->skelCurve; + SkelAnimeCurve* skelCurve = &this->skelCurve; STACK_PADS(s32, 2); this->action = DEMO_TRE_LGT_ACTION_ANIMATE; - SkelCurve_SetAnim(skelCurve, sAnimations[gSaveContext.save.linkAge], 1.0f, + SkelCurve_SetAnim(skelCurve, sTransformUpdIdx[gSaveContext.save.linkAge], 1.0f, sDemoTreLgtInfo[gSaveContext.save.linkAge].endFrame + sDemoTreLgtInfo[gSaveContext.save.linkAge].unk_08, currentFrame, 1.0f); @@ -103,7 +103,7 @@ void func_809937B4(DemoTreLgt* this, PlayState* play, f32 currentFrame) { } void func_80993848(DemoTreLgt* this, PlayState* play) { - f32 currentFrame = this->skelCurve.curFrame; + f32 currentFrame = this->skelCurve.animCurFrame; if (currentFrame < sDemoTreLgtInfo[((void)0, gSaveContext.save.linkAge)].endFrame) { this->unk_170 = 255; @@ -142,7 +142,7 @@ void DemoTreLgt_Update(Actor* thisx, PlayState* play) { sActionFuncs[this->action](this, play); } -s32 DemoTreLgt_OverrideLimbDraw(PlayState* play, SkelCurve* skelCurve, s32 limbIndex, void* thisx) { +s32 DemoTreLgt_OverrideLimbDraw(PlayState* play, SkelAnimeCurve* skelCurve, s32 limbIndex, void* thisx) { STACK_PAD(s32); DemoTreLgt* this = (DemoTreLgt*)thisx; @@ -160,14 +160,9 @@ s32 DemoTreLgt_OverrideLimbDraw(PlayState* play, SkelCurve* skelCurve, s32 limbI CLOSE_DISPS(play->state.gfxCtx, "../z_demo_tre_lgt.c", 448); //! @bug missing return - //! If the returned value (i.e. the contents of v0) ends up being false (0), the limb won't draw. Therefore what - //! matters is what was last written to v0 before the end of the function. - //! - In debug versions, the last instruction that does this is in `Graph_CloseDisps`. - //! - In retail versions, `gDPSetPrimColor` writes to it last. - //! In both cases, that instruction sets v0 to a non-NULL pointer, which is "true", so the limb happens to be drawn. -#ifdef AVOID_UB - return true; -#endif + // If the return value ends up being false (0), the limb won't draw (meaning no limb at all will draw). + // In MQ Debug, `Graph_CloseDisps` has the last instruction writing to v0 before this function ends. + // That instruction sets v0 to a non-NULL pointer, which is "true", so the limbs get drawn. } void DemoTreLgt_Draw(Actor* thisx, PlayState* play) { @@ -182,7 +177,7 @@ void DemoTreLgt_Draw(Actor* thisx, PlayState* play) { Gfx_SetupDL_25Xlu(gfxCtx); gDPSetEnvColor(POLY_XLU_DISP++, 200, 255, 0, 0); - SkelCurve_Draw(&this->actor, play, &this->skelCurve, DemoTreLgt_OverrideLimbDraw, NULL, 1, &this->actor); + SkelCurve_Draw(&this->actor, play, &this->skelCurve, DemoTreLgt_OverrideLimbDraw, NULL, 1, thisx); CLOSE_DISPS(gfxCtx, "../z_demo_tre_lgt.c", 476); } 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 5b4947575b4..55ff2359c7b 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 @@ -3,7 +3,7 @@ #include "ultra64.h" #include "actor.h" -#include "curve.h" +#include "animation_curve.h" struct DemoTreLgt; @@ -11,7 +11,7 @@ typedef void (*DemoTreLgtActionFunc)(struct DemoTreLgt*, struct PlayState*); typedef struct DemoTreLgt { /* 0x0000 */ Actor actor; - /* 0x014C */ SkelCurve skelCurve; + /* 0x014C */ SkelAnimeCurve skelCurve; /* 0x016C */ s32 action; /* 0x0170 */ u32 unk_170; // some sort of alpha /* 0x0174 */ u32 unk_174; // another sort of alpha diff --git a/src/overlays/actors/ovl_Door_Toki/z_door_toki.c b/src/overlays/actors/ovl_Door_Toki/z_door_toki.c index d014ace60ce..5457c0dd133 100644 --- a/src/overlays/actors/ovl_Door_Toki/z_door_toki.c +++ b/src/overlays/actors/ovl_Door_Toki/z_door_toki.c @@ -36,8 +36,8 @@ static InitChainEntry sInitChain[] = { }; void DoorToki_Init(Actor* thisx, PlayState* play) { - STACK_PAD(s32); DoorToki* this = (DoorToki*)thisx; + STACK_PAD(s32); CollisionHeader* colHeader = NULL; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); diff --git a/src/overlays/actors/ovl_Door_Toki/z_door_toki.h b/src/overlays/actors/ovl_Door_Toki/z_door_toki.h index fd0d8105b1a..23b4949fac5 100644 --- a/src/overlays/actors/ovl_Door_Toki/z_door_toki.h +++ b/src/overlays/actors/ovl_Door_Toki/z_door_toki.h @@ -8,7 +8,7 @@ struct DoorToki; typedef struct DoorToki { /* 0x0000 */ DynaPolyActor dyna; - /* 0x0164 */ char unk_164[0x4]; + /* 0x0164 */ char unk_164[4]; } DoorToki; // size = 0x0168 #endif 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 5e24cb8b9b9..d9bef2eaf70 100644 --- a/src/overlays/actors/ovl_En_Ani/z_en_ani.c +++ b/src/overlays/actors/ovl_En_Ani/z_en_ani.c @@ -71,18 +71,20 @@ static ColliderCylinderInit sCylinderInit = { { 30, 40, 0, { 0, 0, 0 } }, }; -void EnAni_SetupAction(EnAni* this, EnAniActionFunc actionFunc) { - this->actionFunc = actionFunc; -} - static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_CONTINUE), ICHAIN_F32(cullingVolumeDistance, 850, ICHAIN_STOP), }; +static Vec3f sMultVec = { 800.0f, 500.0f, 0.0f }; + +void EnAni_SetupAction(EnAni* this, EnAniActionFunc actionFunc) { + this->actionFunc = actionFunc; +} + void EnAni_Init(Actor* thisx, PlayState* play) { - STACK_PAD(s32); EnAni* this = (EnAni*)thisx; + STACK_PAD(s32); Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, -2800.0f, ActorShadow_DrawCircle, 36.0f); @@ -192,14 +194,14 @@ void func_809B07F8(EnAni* this, PlayState* play) { } else { EnAni_SetupAction(this, func_809B0524); } - } else if (yawDiff > -0x36B0 && yawDiff < 0 && this->actor.xzDistToPlayer < 150.0f && + } else if (yawDiff >= -0x36AF && yawDiff < 0 && this->actor.xzDistToPlayer < 150.0f && -80.0f < this->actor.yDistToPlayer) { if (GET_ITEMGETINF(ITEMGETINF_15)) { EnAni_SetText(this, play, 0x5056); } else { EnAni_SetText(this, play, 0x5055); } - } else if (yawDiff > -0x3E8 && yawDiff < 0x36B0 && this->actor.xzDistToPlayer < 350.0f) { + } else if (yawDiff >= -0x3E7 && yawDiff < 0x36B0 && this->actor.xzDistToPlayer < 350.0f) { if (!GET_EVENTCHKINF(EVENTCHKINF_2F)) { textId = 0x5052; } else { @@ -288,12 +290,12 @@ void EnAni_Update(Actor* thisx, PlayState* play) { Math_SmoothStepToS(&this->unk_2A2.y, 0, 6, 6200, 100); } - if (DECR(this->blinkTimer) == 0) { - this->blinkTimer = Rand_S16Offset(60, 60); + if (DECR(this->unk_2AE) == 0) { + this->unk_2AE = Rand_S16Offset(60, 60); } - this->eyeIndex = this->blinkTimer; - if (this->eyeIndex >= 3) { - this->eyeIndex = 0; + this->unk_2AC = this->unk_2AE; + if (this->unk_2AC >= 3) { + this->unk_2AC = 0; } } @@ -308,7 +310,6 @@ s32 EnAni_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* p } void EnAni_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - static Vec3f sMultVec = { 800.0f, 500.0f, 0.0f }; EnAni* this = (EnAni*)thisx; if (limbIndex == 15) { @@ -329,7 +330,7 @@ void EnAni_Draw(Actor* thisx, PlayState* play) { Gfx_SetupDL_37Opa(play->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[this->eyeIndex])); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[this->unk_2AC])); SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnAni_OverrideLimbDraw, EnAni_PostLimbDraw, this); 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 024f4310d1a..97a3ad01456 100644 --- a/src/overlays/actors/ovl_En_Ani/z_en_ani.h +++ b/src/overlays/actors/ovl_En_Ani/z_en_ani.h @@ -18,8 +18,8 @@ typedef struct EnAni { /* 0x02A2 */ Vec3s unk_2A2; /* 0x02A8 */ u16 unk_2A8; /* 0x02AA */ u16 unk_2AA; - /* 0x02AC */ s16 eyeIndex; - /* 0x02AE */ s16 blinkTimer; + /* 0x02AC */ s16 unk_2AC; + /* 0x02AE */ s16 unk_2AE; /* 0x02B0 */ EnAniActionFunc actionFunc; } EnAni; // size = 0x02B4 diff --git a/src/overlays/actors/ovl_En_Anubice/z_en_anubice.c b/src/overlays/actors/ovl_En_Anubice/z_en_anubice.c index 242e0c66896..f03c8205126 100644 --- a/src/overlays/actors/ovl_En_Anubice/z_en_anubice.c +++ b/src/overlays/actors/ovl_En_Anubice/z_en_anubice.c @@ -38,8 +38,8 @@ void EnAnubice_FindFlameCircles(EnAnubice* this, PlayState* play); void EnAnubice_SetupIdle(EnAnubice* this, PlayState* play); void EnAnubice_Idle(EnAnubice* this, PlayState* play); void EnAnubice_GoToHome(EnAnubice* this, PlayState* play); -void EnAnubice_SetupShootFireball(EnAnubice* this, PlayState* play); -void EnAnubice_ShootFireball(EnAnubice* this, PlayState* play); +void EnAnubis_SetupShootFireball(EnAnubice* this, PlayState* play); +void EnAnubis_ShootFireball(EnAnubice* this, PlayState* play); void EnAnubice_Die(EnAnubice* this, PlayState* play); ActorProfile En_Anubice_Profile = { @@ -74,45 +74,39 @@ static ColliderCylinderInit sCylinderInit = { { 29, 103, 0, { 0, 0, 0 } }, }; -typedef enum AnubiceDamageReaction { - /* 0x0 */ ANUBICE_DMG_REACT_NONE, - /* 0x2 */ ANUBICE_DMG_REACT_FIRE = 2, - /* 0xF */ ANUBICE_DMG_REACT_0xF = 0xF // Treated the same as ANUBICE_DMG_REACT_NONE in code -} AnubiceDamageReaction; - static DamageTable sDamageTable[] = { - /* Deku nut */ DMG_ENTRY(0, ANUBICE_DMG_REACT_NONE), - /* Deku stick */ DMG_ENTRY(0, ANUBICE_DMG_REACT_0xF), - /* Slingshot */ DMG_ENTRY(0, ANUBICE_DMG_REACT_0xF), - /* Explosive */ DMG_ENTRY(0, ANUBICE_DMG_REACT_0xF), - /* Boomerang */ DMG_ENTRY(0, ANUBICE_DMG_REACT_0xF), - /* Normal arrow */ DMG_ENTRY(0, ANUBICE_DMG_REACT_0xF), - /* Hammer swing */ DMG_ENTRY(1, ANUBICE_DMG_REACT_0xF), - /* Hookshot */ DMG_ENTRY(2, ANUBICE_DMG_REACT_0xF), - /* Kokiri sword */ DMG_ENTRY(0, ANUBICE_DMG_REACT_0xF), - /* Master sword */ DMG_ENTRY(2, ANUBICE_DMG_REACT_0xF), - /* Giant's Knife */ DMG_ENTRY(6, ANUBICE_DMG_REACT_0xF), - /* Fire arrow */ DMG_ENTRY(2, ANUBICE_DMG_REACT_FIRE), - /* Ice arrow */ DMG_ENTRY(0, ANUBICE_DMG_REACT_0xF), - /* Light arrow */ DMG_ENTRY(0, ANUBICE_DMG_REACT_0xF), - /* Unk arrow 1 */ DMG_ENTRY(0, ANUBICE_DMG_REACT_0xF), - /* Unk arrow 2 */ DMG_ENTRY(0, ANUBICE_DMG_REACT_0xF), - /* Unk arrow 3 */ DMG_ENTRY(0, ANUBICE_DMG_REACT_0xF), - /* Fire magic */ DMG_ENTRY(3, ANUBICE_DMG_REACT_FIRE), - /* Ice magic */ DMG_ENTRY(0, ANUBICE_DMG_REACT_NONE), - /* Light magic */ DMG_ENTRY(0, ANUBICE_DMG_REACT_NONE), - /* Shield */ DMG_ENTRY(0, ANUBICE_DMG_REACT_NONE), - /* Mirror Ray */ DMG_ENTRY(0, ANUBICE_DMG_REACT_NONE), - /* Kokiri spin */ DMG_ENTRY(0, ANUBICE_DMG_REACT_0xF), - /* Giant spin */ DMG_ENTRY(6, ANUBICE_DMG_REACT_0xF), - /* Master spin */ DMG_ENTRY(2, ANUBICE_DMG_REACT_0xF), - /* Kokiri jump */ DMG_ENTRY(0, ANUBICE_DMG_REACT_0xF), - /* Giant jump */ DMG_ENTRY(12, ANUBICE_DMG_REACT_0xF), - /* Master jump */ DMG_ENTRY(4, ANUBICE_DMG_REACT_0xF), - /* Unknown 1 */ DMG_ENTRY(0, ANUBICE_DMG_REACT_NONE), - /* Unblockable */ DMG_ENTRY(0, ANUBICE_DMG_REACT_NONE), - /* Hammer jump */ DMG_ENTRY(0, ANUBICE_DMG_REACT_NONE), - /* Unknown 2 */ DMG_ENTRY(0, ANUBICE_DMG_REACT_NONE), + /* Deku nut */ DMG_ENTRY(0, 0x0), + /* Deku stick */ DMG_ENTRY(0, 0xF), + /* Slingshot */ DMG_ENTRY(0, 0xF), + /* Explosive */ DMG_ENTRY(0, 0xF), + /* Boomerang */ DMG_ENTRY(0, 0xF), + /* Normal arrow */ DMG_ENTRY(0, 0xF), + /* Hammer swing */ DMG_ENTRY(1, 0xF), + /* Hookshot */ DMG_ENTRY(2, 0xF), + /* Kokiri sword */ DMG_ENTRY(0, 0xF), + /* Master sword */ DMG_ENTRY(2, 0xF), + /* Giant's Knife */ DMG_ENTRY(6, 0xF), + /* Fire arrow */ DMG_ENTRY(2, 0x2), + /* Ice arrow */ DMG_ENTRY(0, 0xF), + /* Light arrow */ DMG_ENTRY(0, 0xF), + /* Unk arrow 1 */ DMG_ENTRY(0, 0xF), + /* Unk arrow 2 */ DMG_ENTRY(0, 0xF), + /* Unk arrow 3 */ DMG_ENTRY(0, 0xF), + /* Fire magic */ DMG_ENTRY(3, 0x2), + /* Ice magic */ DMG_ENTRY(0, 0x0), + /* Light magic */ DMG_ENTRY(0, 0x0), + /* Shield */ DMG_ENTRY(0, 0x0), + /* Mirror Ray */ DMG_ENTRY(0, 0x0), + /* Kokiri spin */ DMG_ENTRY(0, 0xF), + /* Giant spin */ DMG_ENTRY(6, 0xF), + /* Master spin */ DMG_ENTRY(2, 0xF), + /* Kokiri jump */ DMG_ENTRY(0, 0xF), + /* Giant jump */ DMG_ENTRY(12, 0xF), + /* Master jump */ DMG_ENTRY(4, 0xF), + /* Unknown 1 */ DMG_ENTRY(0, 0x0), + /* Unblockable */ DMG_ENTRY(0, 0x0), + /* Hammer jump */ DMG_ENTRY(0, 0x0), + /* Unknown 2 */ DMG_ENTRY(0, 0x0), }; void EnAnubice_Hover(EnAnubice* this, PlayState* play) { @@ -125,19 +119,19 @@ void EnAnubice_Hover(EnAnubice* this, PlayState* play) { this->actor.velocity.y = Math_SinS(this->hoverVelocityTimer); } -void EnAnubice_AimFireball(EnAnubice* this, PlayState* play) { - f32 xzDist; +void EnAnubice_SetFireballRot(EnAnubice* this, PlayState* play) { + f32 xzdist; f32 x; f32 y; f32 z; Player* player = GET_PLAYER(play); - x = player->actor.world.pos.x - this->headPos.x; - y = player->actor.world.pos.y + 10.0f - this->headPos.y; - z = player->actor.world.pos.z - this->headPos.z; - xzDist = sqrtf(SQ(x) + SQ(z)); + x = player->actor.world.pos.x - this->fireballPos.x; + y = player->actor.world.pos.y + 10.0f - this->fireballPos.y; + z = player->actor.world.pos.z - this->fireballPos.z; + xzdist = sqrtf(SQ(x) + SQ(z)); - this->fireballRot.x = -RAD_TO_BINANG(Math_FAtan2F(y, xzDist)); + this->fireballRot.x = -RAD_TO_BINANG(Math_FAtan2F(y, xzdist)); this->fireballRot.y = RAD_TO_BINANG(Math_FAtan2F(x, z)); } @@ -145,16 +139,15 @@ void EnAnubice_Init(Actor* thisx, PlayState* play) { EnAnubice* this = (EnAnubice*)thisx; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); - SkelAnime_Init(play, &this->skelAnime, &gAnubiceSkel, &gAnubiceIdleAnim, this->jointTable, this->morphTable, - ANUBICE_LIMB_MAX); + SkelAnime_Init(play, &this->skelAnime, &gAnubiceSkel, &gAnubiceIdleAnim, this->jointTable, this->morphTable, 16); PRINTF("\n\n"); PRINTF(VT_FGCOL(YELLOW) T("☆☆☆☆☆ アヌビス発生 ☆☆☆☆☆ \n", "☆☆☆☆☆ Anubis spawn ☆☆☆☆☆ \n") VT_RST); this->actor.naviEnemyId = NAVI_ENEMY_ANUBIS; - Collider_InitCylinder(play, &this->collider); - Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, &this->col); + Collider_SetCylinder(play, &this->col, &this->actor, &sCylinderInit); Actor_SetScale(&this->actor, 0.015f); @@ -170,16 +163,16 @@ void EnAnubice_Init(Actor* thisx, PlayState* play) { void EnAnubice_Destroy(Actor* thisx, PlayState* play) { EnAnubice* this = (EnAnubice*)thisx; - EnAnubiceTag* tag; + EnAnubiceTag* temp_v1; - Collider_DestroyCylinder(play, &this->collider); + Collider_DestroyCylinder(play, &this->col); if (this->actor.params != 0) { if (this->actor.parent) {} - tag = (EnAnubiceTag*)this->actor.parent; - if (tag != NULL && tag->actor.update != NULL) { - tag->anubis = NULL; + temp_v1 = (EnAnubiceTag*)this->actor.parent; + if (temp_v1 != NULL && temp_v1->actor.update != NULL) { + temp_v1->anubis = NULL; } } } @@ -188,7 +181,7 @@ void EnAnubice_FindFlameCircles(EnAnubice* this, PlayState* play) { Actor* currentProp; s32 flameCirclesFound; - if (this->isMirroringPlayer) { + if (this->isMirroringLink) { if (!this->hasSearchedForFlameCircles) { flameCirclesFound = 0; currentProp = play->actorCtx.actorLists[ACTORCAT_PROP].head; @@ -201,7 +194,7 @@ void EnAnubice_FindFlameCircles(EnAnubice* this, PlayState* play) { flameCirclesFound); PRINTF(VT_FGCOL(YELLOW) T("☆☆☆☆☆ 火は幾つ? ☆☆☆☆☆ %x\n", "☆☆☆☆☆ How many fires? ☆☆☆☆☆ %x\n") VT_RST, this->flameCircles[flameCirclesFound]); - if (flameCirclesFound < ARRAY_COUNT(this->flameCircles) - 1) { + if (flameCirclesFound < 4) { flameCirclesFound++; } currentProp = currentProp->next; @@ -238,8 +231,8 @@ void EnAnubice_Idle(EnAnubice* this, PlayState* play) { this->actor.shape.yOffset = 0.0f; if (player->meleeWeaponState != 0) { - this->actionFunc = EnAnubice_SetupShootFireball; - } else if (this->isPlayerOutOfRange) { + this->actionFunc = EnAnubis_SetupShootFireball; + } else if (this->isLinkOutOfRange) { this->actor.velocity.y = 0.0f; this->actor.gravity = -1.0f; this->actionFunc = EnAnubice_GoToHome; @@ -248,9 +241,9 @@ void EnAnubice_Idle(EnAnubice* this, PlayState* play) { } void EnAnubice_GoToHome(EnAnubice* this, PlayState* play) { - f32 xzDist; - f32 normalizedX; - f32 normalizedY; + f32 xzdist; + f32 xRatio; + f32 zRatio; f32 x; f32 z; @@ -262,33 +255,32 @@ void EnAnubice_GoToHome(EnAnubice* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 3000, 0); } - if ((fabsf(this->home.x - this->actor.world.pos.x) > 3.0f) && - (fabsf(this->home.z - this->actor.world.pos.z) > 3.0f)) { + if (fabsf(this->home.x - this->actor.world.pos.x) > 3.0f && fabsf(this->home.z - this->actor.world.pos.z) > 3.0f) { x = this->home.x - this->actor.world.pos.x; z = this->home.z - this->actor.world.pos.z; - xzDist = sqrtf(SQ(x) + SQ(z)); - normalizedX = x / xzDist; - normalizedY = z / xzDist; - this->actor.world.pos.x += normalizedX * 8; - this->actor.world.pos.z += normalizedY * 8.0f; + xzdist = sqrtf(SQ(x) + SQ(z)); + xRatio = ((x) / xzdist); + zRatio = ((z) / xzdist); + this->actor.world.pos.x += (xRatio * 8); + this->actor.world.pos.z += (zRatio * 8.0f); } else if (this->actor.shape.yOffset < -4220.0f) { this->actor.shape.yOffset = -4230.0f; - this->isMirroringPlayer = this->isPlayerOutOfRange = false; + this->isMirroringLink = this->isLinkOutOfRange = false; this->actionFunc = EnAnubice_FindFlameCircles; this->actor.gravity = 0.0f; } } -void EnAnubice_SetupShootFireball(EnAnubice* this, PlayState* play) { +void EnAnubis_SetupShootFireball(EnAnubice* this, PlayState* play) { f32 lastFrame = Animation_GetLastFrame(&gAnubiceAttackingAnim); this->animLastFrame = lastFrame; Animation_Change(&this->skelAnime, &gAnubiceAttackingAnim, 1.0f, 0.0f, lastFrame, ANIMMODE_ONCE, -10.0f); - this->actionFunc = EnAnubice_ShootFireball; + this->actionFunc = EnAnubis_ShootFireball; this->actor.velocity.x = this->actor.velocity.z = 0.0f; } -void EnAnubice_ShootFireball(EnAnubice* this, PlayState* play) { +void EnAnubis_ShootFireball(EnAnubice* this, PlayState* play) { f32 curFrame = this->skelAnime.curFrame; SkelAnime_Update(&this->skelAnime); @@ -297,11 +289,11 @@ void EnAnubice_ShootFireball(EnAnubice* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 3000, 0); } - EnAnubice_AimFireball(this, play); + EnAnubice_SetFireballRot(this, play); if (curFrame == 12.0f) { - Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ANUBICE_FIRE, this->headPos.x, this->headPos.y + 15.0f, - this->headPos.z, this->fireballRot.x, this->fireballRot.y, 0, 0); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ANUBICE_FIRE, this->fireballPos.x, this->fireballPos.y + 15.0f, + this->fireballPos.z, this->fireballRot.x, this->fireballRot.y, 0, 0); } if (this->animLastFrame <= curFrame) { @@ -315,15 +307,15 @@ void EnAnubice_SetupDie(EnAnubice* this, PlayState* play) { this->animLastFrame = lastFrame; Animation_Change(&this->skelAnime, &gAnubiceFallDownAnim, 1.0f, 0.0f, lastFrame, ANIMMODE_ONCE, -20.0f); - this->isNearWall = false; - this->fallTargetYaw = 0; + this->unk_256 = false; + this->unk_258 = 0; this->deathTimer = 20; this->actor.velocity.x = this->actor.velocity.z = 0.0f; this->actor.gravity = -1.0f; - if (BgCheck_SphVsFirstPoly(&play->colCtx, &this->headPos, 70.0f)) { - this->isNearWall = true; - this->fallTargetYaw = this->actor.shape.rot.x - 0x7F00; + if (BgCheck_SphVsFirstPoly(&play->colCtx, &this->fireballPos, 70.0f)) { + this->unk_256 = true; + this->unk_258 = this->actor.shape.rot.x - 0x7F00; } this->actionFunc = EnAnubice_Die; @@ -331,39 +323,36 @@ void EnAnubice_SetupDie(EnAnubice* this, PlayState* play) { void EnAnubice_Die(EnAnubice* this, PlayState* play) { f32 curFrame; - f32 rotX; - Vec3f baseFireEffectPos = { 0.0f, 0.0f, 0.0f }; - Vec3f rotatedFireEffectPos = { 0.0f, 0.0f, 0.0f }; + f32 phi_f2; + Vec3f sp4C = { 0.0f, 0.0f, 0.0f }; + Vec3f fireEffectPos = { 0.0f, 0.0f, 0.0f }; STACK_PAD(s32); SkelAnime_Update(&this->skelAnime); Math_ApproachZeroF(&this->actor.shape.shadowScale, 0.4f, 0.25f); - // If near a wall, turn away from it while dying to avoid going through it. - // The implementation of this is bugged in the sense that the target angle is hardcoded in practice. If the poly - // already has an angle of -0x7F00, the expected behavior won't occur. - if (this->isNearWall) { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->fallTargetYaw, 1, 10000, 0); - if (fabsf(this->actor.shape.rot.y - this->fallTargetYaw) < 100.0f) { - this->isNearWall = false; + if (this->unk_256) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->unk_258, 1, 10000, 0); + if (fabsf(this->actor.shape.rot.y - this->unk_258) < 100.0f) { + this->unk_256 = false; } } curFrame = this->skelAnime.curFrame; - rotX = curFrame * -3000.0f; - rotX = CLAMP_MIN(rotX, -11000.0f); + phi_f2 = curFrame * -3000.0f; + phi_f2 = CLAMP_MIN(phi_f2, -11000.0f); Matrix_RotateY(BINANG_TO_RAD_ALT(this->actor.shape.rot.y), MTXMODE_NEW); - Matrix_RotateX(BINANG_TO_RAD_ALT(rotX), MTXMODE_APPLY); - baseFireEffectPos.y = Rand_CenteredFloat(10.0f) + 30.0f; - Matrix_MultVec3f(&baseFireEffectPos, &rotatedFireEffectPos); - rotatedFireEffectPos.x += this->actor.world.pos.x + Rand_CenteredFloat(40.0f); - rotatedFireEffectPos.y += this->actor.world.pos.y + Rand_CenteredFloat(40.0f); - rotatedFireEffectPos.z += this->actor.world.pos.z + Rand_CenteredFloat(30.0f); - Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 128, COLORFILTER_BUFFLAG_OPA, 8); - EffectSsEnFire_SpawnVec3f(play, &this->actor, &rotatedFireEffectPos, 100, 0, 0, -1); - - if ((this->animLastFrame <= curFrame) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { + Matrix_RotateX(BINANG_TO_RAD_ALT(phi_f2), MTXMODE_APPLY); + sp4C.y = Rand_CenteredFloat(10.0f) + 30.0f; + Matrix_MultVec3f(&sp4C, &fireEffectPos); + fireEffectPos.x += this->actor.world.pos.x + Rand_CenteredFloat(40.0f); + fireEffectPos.y += this->actor.world.pos.y + Rand_CenteredFloat(40.0f); + fireEffectPos.z += this->actor.world.pos.z + Rand_CenteredFloat(30.0f); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 0x80, COLORFILTER_BUFFLAG_OPA, 8); + EffectSsEnFire_SpawnVec3f(play, &this->actor, &fireEffectPos, 100, 0, 0, -1); + + if (this->animLastFrame <= curFrame && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { Math_ApproachF(&this->actor.shape.yOffset, -4230.0f, 0.5f, 300.0f); if (this->actor.shape.yOffset < -2000.0f) { Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, @@ -377,19 +366,19 @@ void EnAnubice_Update(Actor* thisx, PlayState* play) { f32 zero; BgHidanCurtain* flameCircle; s32 i; - Vec3f baseKnockbackVelocity; - Vec3f rotatedKnockbackVelocity; + Vec3f sp48; + Vec3f sp3C; EnAnubice* this = (EnAnubice*)thisx; - if ((this->actionFunc != EnAnubice_SetupDie) && (this->actionFunc != EnAnubice_Die) && - (this->actor.shape.yOffset == 0.0f)) { + if (this->actionFunc != EnAnubice_SetupDie && this->actionFunc != EnAnubice_Die && + this->actor.shape.yOffset == 0.0f) { EnAnubice_Hover(this, play); - for (i = 0; i < ARRAY_COUNT(this->flameCircles); i++) { + for (i = 0; i < 5; i++) { flameCircle = this->flameCircles[i]; - if ((flameCircle != NULL) && (fabsf(flameCircle->actor.world.pos.x - this->actor.world.pos.x) < 60.0f) && - (fabsf(this->flameCircles[i]->actor.world.pos.z - this->actor.world.pos.z) < 60.0f) && - (flameCircle->timer != 0)) { + if (flameCircle != NULL && fabsf(flameCircle->actor.world.pos.x - this->actor.world.pos.x) < 60.0f && + fabsf(this->flameCircles[i]->actor.world.pos.z - this->actor.world.pos.z) < 60.0f && + flameCircle->timer != 0) { Actor_ChangeCategory(play, &play->actorCtx, &this->actor, ACTORCAT_PROP); this->actor.flags &= ~ACTOR_FLAG_ATTENTION_ENABLED; Enemy_StartFinishingBlow(play, &this->actor); @@ -399,9 +388,9 @@ void EnAnubice_Update(Actor* thisx, PlayState* play) { } } - if (this->collider.base.acFlags & AC_HIT) { - this->collider.base.acFlags &= ~AC_HIT; - if (this->actor.colChkInfo.damageReaction == ANUBICE_DMG_REACT_FIRE) { + if (this->col.base.acFlags & AC_HIT) { + this->col.base.acFlags &= ~AC_HIT; + if (this->actor.colChkInfo.damageReaction == 2) { Actor_ChangeCategory(play, &play->actorCtx, &this->actor, ACTORCAT_PROP); this->actor.flags &= ~ACTOR_FLAG_ATTENTION_ENABLED; Enemy_StartFinishingBlow(play, &this->actor); @@ -414,20 +403,20 @@ void EnAnubice_Update(Actor* thisx, PlayState* play) { this->knockbackTimer = 10; this->isKnockedback = true; - baseKnockbackVelocity.x = 0.0f; - baseKnockbackVelocity.y = 0.0f; - baseKnockbackVelocity.z = -10.0f; - rotatedKnockbackVelocity.x = 0.0f; - rotatedKnockbackVelocity.y = 0.0f; - rotatedKnockbackVelocity.z = 0.0f; + sp48.x = 0.0f; + sp48.y = 0.0f; + sp48.z = -10.0f; + sp3C.x = 0.0f; + sp3C.y = 0.0f; + sp3C.z = 0.0f; Matrix_RotateY(BINANG_TO_RAD_ALT(this->actor.shape.rot.y), MTXMODE_NEW); - Matrix_MultVec3f(&baseKnockbackVelocity, &rotatedKnockbackVelocity); + Matrix_MultVec3f(&sp48, &sp3C); - this->actor.velocity.x = rotatedKnockbackVelocity.x; - this->actor.velocity.z = rotatedKnockbackVelocity.z; - this->knockbackRecoveryVelocity.x = -rotatedKnockbackVelocity.x; - this->knockbackRecoveryVelocity.z = -rotatedKnockbackVelocity.z; + this->actor.velocity.x = sp3C.x; + this->actor.velocity.z = sp3C.z; + this->knockbackRecoveryVelocity.x = -sp3C.x; + this->knockbackRecoveryVelocity.z = -sp3C.z; Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_CUTBODY); } @@ -464,7 +453,7 @@ void EnAnubice_Update(Actor* thisx, PlayState* play) { this->actor.velocity.y += this->actor.gravity; Actor_UpdatePos(&this->actor); - if (!this->isPlayerOutOfRange) { + if (!this->isLinkOutOfRange) { Actor_UpdateBgCheckInfo(play, &this->actor, 5.0f, 5.0f, 10.0f, UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_3 | UPDBGCHECKINFO_FLAG_4); @@ -473,37 +462,37 @@ void EnAnubice_Update(Actor* thisx, PlayState* play) { UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_3 | UPDBGCHECKINFO_FLAG_4); } - if ((this->actionFunc != EnAnubice_SetupDie) && (this->actionFunc != EnAnubice_Die)) { + if (this->actionFunc != EnAnubice_SetupDie && this->actionFunc != EnAnubice_Die) { Actor_SetFocus(&this->actor, this->focusHeightOffset); - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + Collider_UpdateCylinder(&this->actor, &this->col); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->col.base); - if (!this->isKnockedback && (this->actor.shape.yOffset == 0.0f)) { - CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + if (!this->isKnockedback && this->actor.shape.yOffset == 0.0f) { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->col.base); } } } -s32 EnAnubice_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { +s32 EnAnubis_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { EnAnubice* this = (EnAnubice*)thisx; - if (limbIndex == ANUBICE_LIMB_HEAD) { - rot->z += this->headPitch; + if (limbIndex == 13) { + rot->z += this->unk_278; } return false; } -void EnAnubice_PostLimbDraw(struct PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { +void EnAnubis_PostLimbDraw(struct PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { EnAnubice* this = (EnAnubice*)thisx; Vec3f pos = { 0.0f, 0.0f, 0.0f }; - if (limbIndex == ANUBICE_LIMB_HEAD) { + if (limbIndex == 13) { OPEN_DISPS(play->state.gfxCtx, "../z_en_anubice.c", 853); MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx, "../z_en_anubice.c", 856); gSPDisplayList(POLY_XLU_DISP++, gAnubiceEyesDL); - Matrix_MultVec3f(&pos, &this->headPos); + Matrix_MultVec3f(&pos, &this->fireballPos); CLOSE_DISPS(play->state.gfxCtx, "../z_en_anubice.c", 868); } @@ -513,6 +502,6 @@ void EnAnubice_Draw(Actor* thisx, PlayState* play) { EnAnubice* this = (EnAnubice*)thisx; Gfx_SetupDL_25Xlu(play->state.gfxCtx); - SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnAnubice_OverrideLimbDraw, - EnAnubice_PostLimbDraw, this); + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnAnubis_OverrideLimbDraw, + EnAnubis_PostLimbDraw, this); } diff --git a/src/overlays/actors/ovl_En_Anubice/z_en_anubice.h b/src/overlays/actors/ovl_En_Anubice/z_en_anubice.h index fd54405a294..9abce19bcdc 100644 --- a/src/overlays/actors/ovl_En_Anubice/z_en_anubice.h +++ b/src/overlays/actors/ovl_En_Anubice/z_en_anubice.h @@ -13,31 +13,31 @@ typedef void (*EnAnubiceActionFunc)(struct EnAnubice*, struct PlayState*); typedef struct EnAnubice { /* 0x0000 */ Actor actor; /* 0x014C */ SkelAnime skelAnime; - /* 0x0190 */ Vec3s jointTable[ANUBICE_LIMB_MAX]; - /* 0x01F0 */ Vec3s morphTable[ANUBICE_LIMB_MAX]; + /* 0x0190 */ Vec3s jointTable[16]; + /* 0x01F0 */ Vec3s morphTable[16]; /* 0x0250 */ EnAnubiceActionFunc actionFunc; /* 0x0254 */ s16 timeAlive; - /* 0x0256 */ s16 isNearWall; // Technically any bg poly, but in practice usually a wall - /* 0x0258 */ s16 fallTargetYaw; + /* 0x0256 */ s16 unk_256; + /* 0x0258 */ s16 unk_258; /* 0x025A */ s16 deathTimer; /* 0x025C */ s16 knockbackTimer; - /* 0x025E */ s16 isMirroringPlayer; - /* 0x0260 */ s16 isPlayerOutOfRange; - /* 0x0262 */ s16 isKnockedback; // Hit by an attack without ANUBICE_DMG_REACT_FIRE + /* 0x025E */ s16 isMirroringLink; + /* 0x0260 */ s16 isLinkOutOfRange; + /* 0x0262 */ s16 isKnockedback; /* 0x0264 */ s16 hasSearchedForFlameCircles; /* 0x0268 */ f32 hoverVelocityTimer; /* 0x026C */ f32 animLastFrame; /* 0x0270 */ f32 targetHeight; /* 0x0274 */ f32 playerHeightOffset; // How high above the player to hover at - /* 0x0278 */ f32 headPitch; // Never changed from initial value 0 + /* 0x0278 */ f32 unk_278; /* 0x027C */ f32 focusHeightOffset; - /* 0x0280 */ Vec3f headPos; + /* 0x0280 */ Vec3f fireballPos; /* 0x028C */ Vec3f fireballRot; /* 0x0298 */ Vec3f home; /* 0x02A4 */ Vec3f knockbackRecoveryVelocity; /* 0x02B0 */ struct BgHidanCurtain* flameCircles[5]; - /* 0x02C4 */ char unk_2C4[0x4]; // Possibly another element of flameCircles - /* 0x02C8 */ ColliderCylinder collider; + /* 0x02C4 */ char unk_2C0[4]; + /* 0x02C8 */ ColliderCylinder col; } EnAnubice; // size = 0x0314 #endif diff --git a/src/overlays/actors/ovl_En_Anubice_Tag/z_en_anubice_tag.c b/src/overlays/actors/ovl_En_Anubice_Tag/z_en_anubice_tag.c index c03f399110c..ddd29808b2f 100644 --- a/src/overlays/actors/ovl_En_Anubice_Tag/z_en_anubice_tag.c +++ b/src/overlays/actors/ovl_En_Anubice_Tag/z_en_anubice_tag.c @@ -49,7 +49,7 @@ void EnAnubiceTag_Init(Actor* thisx, PlayState* play) { this->actor.params = 0; } if (this->actor.params != 0) { - this->extraTriggerRange = this->actor.params * 40.0f; + this->triggerRange = this->actor.params * 40.0f; } this->actionFunc = EnAnubiceTag_SpawnAnubis; } @@ -86,16 +86,21 @@ void EnAnubiceTag_ManageAnubis(EnAnubiceTag* this, PlayState* play) { return; } - if (this->actor.xzDistToPlayer < (200.0f + this->extraTriggerRange)) { - if (!anubis->isPlayerOutOfRange && !anubis->isKnockedback) { - anubis->isMirroringPlayer = true; - offset.x = -Math_SinS(this->actor.yawTowardsPlayer) * this->actor.xzDistToPlayer; - offset.z = -Math_CosS(this->actor.yawTowardsPlayer) * this->actor.xzDistToPlayer; - Math_ApproachF(&anubis->actor.world.pos.x, this->actor.world.pos.x + offset.x, 0.3f, 10.0f); - Math_ApproachF(&anubis->actor.world.pos.z, this->actor.world.pos.z + offset.z, 0.3f, 10.0f); + if (this->actor.xzDistToPlayer < (200.0f + this->triggerRange)) { + if (!anubis->isLinkOutOfRange) { + if (!anubis->isKnockedback) { + anubis->isMirroringLink = true; + offset.x = -Math_SinS(this->actor.yawTowardsPlayer) * this->actor.xzDistToPlayer; + offset.z = -Math_CosS(this->actor.yawTowardsPlayer) * this->actor.xzDistToPlayer; + Math_ApproachF(&anubis->actor.world.pos.x, (this->actor.world.pos.x + offset.x), 0.3f, 10.0f); + Math_ApproachF(&anubis->actor.world.pos.z, (this->actor.world.pos.z + offset.z), 0.3f, 10.0f); + return; + } + } + } else { + if (anubis->isMirroringLink) { + anubis->isLinkOutOfRange = true; } - } else if (anubis->isMirroringPlayer) { - anubis->isPlayerOutOfRange = true; } } @@ -111,6 +116,6 @@ void EnAnubiceTag_Draw(Actor* thisx, PlayState* play) { if (DEBUG_FEATURES && BREG(0) != 0) { DebugDisplay_AddObject(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, 1.0f, 1.0f, - 1.0f, 255, 0, 0, 255, 4, play->state.gfxCtx); + 1.0f, 0xFF, 0, 0, 0xFF, 4, play->state.gfxCtx); } } diff --git a/src/overlays/actors/ovl_En_Anubice_Tag/z_en_anubice_tag.h b/src/overlays/actors/ovl_En_Anubice_Tag/z_en_anubice_tag.h index afbc61970bd..72fe06ddd99 100644 --- a/src/overlays/actors/ovl_En_Anubice_Tag/z_en_anubice_tag.h +++ b/src/overlays/actors/ovl_En_Anubice_Tag/z_en_anubice_tag.h @@ -12,7 +12,7 @@ typedef struct EnAnubiceTag { /* 0x0000 */ Actor actor; /* 0x014C */ EnAnubiceTagActionFunc actionFunc; /* 0x0150 */ struct EnAnubice* anubis; - /* 0x0154 */ f32 extraTriggerRange; + /* 0x0154 */ f32 triggerRange; } EnAnubiceTag; // size = 0x0158 #endif 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 02c00ea38b2..d1d203c4a35 100644 --- a/src/overlays/actors/ovl_En_Bb/z_en_bb.c +++ b/src/overlays/actors/ovl_En_Bb/z_en_bb.c @@ -569,7 +569,7 @@ void EnBb_Blue(EnBb* this, PlayState* play) { Math_SmoothStepToF(&this->flameScaleY, 80.0f, 1.0f, 10.0f, 0.0f); Math_SmoothStepToF(&this->flameScaleX, 100.0f, 1.0f, 10.0f, 0.0f); - if (this->actor.floorHeight > BGCHECK_Y_MIN) { + if (this->actor.floorHeight > -32000.0f) { Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.floorHeight + 50.0f + this->flyHeightMod, 1.0f, 0.5f, 0.0f); } 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 15a48fb01d2..da8bfdb613a 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 @@ -108,8 +108,8 @@ void EnBomBowlMan_Destroy(Actor* thisx, PlayState* play) { } void EnBomBowlMan_SetupAsleepWaitTalk(EnBomBowlMan* this, PlayState* play) { - this->curAnimFrameCount = Animation_GetLastFrame(&gBowlingGirlSleepingAnim); - Animation_Change(&this->skelAnime, &gBowlingGirlSleepingAnim, 1.0f, 0.0f, this->curAnimFrameCount, ANIMMODE_LOOP, + this->curAnimLastFrame = Animation_GetLastFrame(&gBowlingGirlSleepingAnim); + Animation_Change(&this->skelAnime, &gBowlingGirlSleepingAnim, 1.0f, 0.0f, this->curAnimLastFrame, ANIMMODE_LOOP, -10.0f); this->actor.textId = 0xC0; this->waitMessageState = TEXT_STATE_EVENT; @@ -141,8 +141,8 @@ void EnBomBowlMan_AsleepTalking(EnBomBowlMan* this, PlayState* play) { } void EnBomBowlMan_SetupWakingUpTalking(EnBomBowlMan* this, PlayState* play) { - this->curAnimFrameCount = Animation_GetLastFrame(&gBowlingGirlWakingUpAnim); - Animation_Change(&this->skelAnime, &gBowlingGirlWakingUpAnim, 1.0f, 0.0f, this->curAnimFrameCount, ANIMMODE_ONCE, + this->curAnimLastFrame = Animation_GetLastFrame(&gBowlingGirlWakingUpAnim); + Animation_Change(&this->skelAnime, &gBowlingGirlWakingUpAnim, 1.0f, 0.0f, this->curAnimLastFrame, ANIMMODE_ONCE, -10.0f); this->eyesState = 1; this->actionFunc = EnBomBowlMan_WakingUpTalking; @@ -174,8 +174,8 @@ void EnBomBowlMan_FinishWakingUpTalking(EnBomBowlMan* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if ((this->waitMessageState == Message_GetState(&play->msgCtx)) && Message_ShouldAdvance(play)) { Message_CloseTextbox(play); - this->curAnimFrameCount = Animation_GetLastFrame(&gBowlingGirlHandsOnCounterAnim); - Animation_Change(&this->skelAnime, &gBowlingGirlHandsOnCounterAnim, 1.0f, 0.0f, this->curAnimFrameCount, + this->curAnimLastFrame = Animation_GetLastFrame(&gBowlingGirlHandsOnCounterAnim); + Animation_Change(&this->skelAnime, &gBowlingGirlHandsOnCounterAnim, 1.0f, 0.0f, this->curAnimLastFrame, ANIMMODE_LOOP, -10.0f); this->eyesState = 3; this->eyesTimer = (s16)Rand_ZeroFloat(60.0f) + 20; 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 e162188ee1e..f6dfa5634e6 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 @@ -46,7 +46,7 @@ typedef struct EnBomBowlMan { /* 0x244 */ s16 gameEndStatus; /* 0x246 */ char pad_246[2]; /* 0x248 */ Vec3f homePos; - /* 0x254 */ f32 curAnimFrameCount; + /* 0x254 */ f32 curAnimLastFrame; /* 0x258 */ u8 gameStartStatus; /* 0x259 */ char pad_259[3]; /* 0x25C */ struct EnBomBowlPit* finalTargetManager; 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 97e3b594499..e3b24de83a4 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 @@ -415,7 +415,7 @@ void EnBomChu_Update(Actor* thisx, PlayState* play2) { if (this->actor.floorBgId != BGCHECK_SCENE) { yaw = this->actor.shape.rot.y; - DynaPolyActor_TransformCarriedActor(&play->colCtx, this->actor.floorBgId, &this->actor); + DynaPolyActor_TransformActorOnTop(&play->colCtx, this->actor.floorBgId, &this->actor); if (yaw != this->actor.shape.rot.y) { yaw = this->actor.shape.rot.y - yaw; 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 c031fc64b94..a07a44bcc26 100644 --- a/src/overlays/actors/ovl_En_Boom/z_en_boom.c +++ b/src/overlays/actors/ovl_En_Boom/z_en_boom.c @@ -147,7 +147,7 @@ void EnBoom_Fly(EnBoom* this, PlayState* play) { distXYZScale = 0.12f; } - if ((target != &player->actor) && ((target->update == NULL) || (ABS(yawDiff) > 0x4000))) { + if ((target != (Actor*)player) && ((target->update == NULL) || (ABS(yawDiff) > 0x4000))) { //! @bug This condition is why the boomerang will randomly fly off in a the down left direction sometimes. // If the actor targeted is not Link and the difference between the 2 y angles is greater than 0x4000, // the moveTo pointer is nulled and it flies off in a seemingly random direction. 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 83b960bc660..49f38619a5b 100644 --- a/src/overlays/actors/ovl_En_Boom/z_en_boom.h +++ b/src/overlays/actors/ovl_En_Boom/z_en_boom.h @@ -12,11 +12,11 @@ typedef void (*EnBoomActionFunc)(struct EnBoom*, struct PlayState*); typedef struct EnBoom { /* 0x0000 */ Actor actor; /* 0x014C */ ColliderQuad collider; - /* 0x01CC */ Actor* moveTo; // actor boomerang moves toward - /* 0x01D0 */ Actor* grabbed; // actor grabbed by the boomerang - /* 0x01D4 */ u8 returnTimer; // returns to Link when 0 - /* 0x01D5 */ u8 activeTimer; // increments once every update - /* 0x01D8 */ s32 effectIndex; + /* 0x01CC */ Actor* moveTo; // actor boomerang moves toward + /* 0x01D0 */ Actor* grabbed; // actor grabbed by the boomerang + /* 0x01D4 */ u8 returnTimer; // returns to Link when 0 + /* 0x01D5 */ u8 activeTimer; // increments once every update + /* 0x01D8 */ s32 effectIndex; // set by Effect_Add /* 0x01DC */ WeaponInfo weaponInfo; /* 0x01F8 */ EnBoomActionFunc actionFunc; } EnBoom; // size = 0x01FC 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 c0042e520e4..5925f51688f 100644 --- a/src/overlays/actors/ovl_En_Box/z_en_box.c +++ b/src/overlays/actors/ovl_En_Box/z_en_box.c @@ -15,7 +15,6 @@ #include "sys_matrix.h" #include "z_lib.h" #include "audio.h" -#include "curve.h" #include "effect.h" #include "ocarina.h" #include "play_state.h" diff --git a/src/overlays/actors/ovl_En_Bw/z_en_bw.c b/src/overlays/actors/ovl_En_Bw/z_en_bw.c index 7ee624c3781..5d204ffcc70 100644 --- a/src/overlays/actors/ovl_En_Bw/z_en_bw.c +++ b/src/overlays/actors/ovl_En_Bw/z_en_bw.c @@ -242,7 +242,7 @@ void func_809CEA24(EnBw* this, PlayState* play) { sp60 = ABS(sp58) * 85.0f; this->color1.g = sp60; } - if ((((play->gameplayFrames % 4) == (u32)this->actor.params) && (this->actor.speed != 0.0f) && + if ((((play->gameplayFrames % 4) == this->actor.params) && (this->actor.speed != 0.0f) && (sp64 = BgCheck_AnyLineTest2(&play->colCtx, &this->actor.world.pos, &this->unk_264, &sp68, &sp74, true, false, false, true))) || (this->unk_222 == 0)) { @@ -892,7 +892,7 @@ void EnBw_Draw(Actor* thisx, PlayState* play2) { EnBw_OverrideLimbDraw, NULL, this, POLY_XLU_DISP); } - if (((play->gameplayFrames + 1) % 4) == (u32)thisx->params) { + if (((play->gameplayFrames + 1) % 4) == thisx->params) { spAC.z = thisx->scale.z * 375000.0f; Matrix_MultVec3f(&spAC, &this->unk_264); spAC.z = thisx->scale.z * 150000.0f; diff --git a/src/overlays/actors/ovl_En_Changer/z_en_changer.c b/src/overlays/actors/ovl_En_Changer/z_en_changer.c index 00009629e4b..91178644430 100644 --- a/src/overlays/actors/ovl_En_Changer/z_en_changer.c +++ b/src/overlays/actors/ovl_En_Changer/z_en_changer.c @@ -1,9 +1,3 @@ -/* - * File: z_en_changer.c - * Overlay: ovl_En_Changer - * Description: Treasure Box Shop Minigame - */ - #include "z_en_changer.h" #include "src/overlays/actors/ovl_En_Box/z_en_box.h" #include "src/overlays/actors/ovl_En_Ex_Item/z_en_ex_item.h" @@ -20,18 +14,13 @@ #define FLAGS 0 -typedef enum ChangerChestSide { - /* 0 */ CHEST_LEFT, - /* 1 */ CHEST_RIGHT -} ChangerChestSide; - void EnChanger_Init(Actor* thisx, PlayState* play2); void EnChanger_Destroy(Actor* thisx, PlayState* play); void EnChanger_Update(Actor* thisx, PlayState* play); -void EnChanger_Wait(EnChanger* this, PlayState* play); -void EnChanger_OpenChests(EnChanger* this, PlayState* play); -void EnChanger_SetHeartPieceFlag(EnChanger* this, PlayState* play); +void func_809D2CCC(EnChanger* this, PlayState* play); +void func_809D2D70(EnChanger* this, PlayState* play); +void func_809D2F74(EnChanger* this, PlayState* play); ActorProfile En_Changer_Profile = { /**/ ACTOR_EN_CHANGER, @@ -44,31 +33,17 @@ ActorProfile En_Changer_Profile = { /**/ EnChanger_Update, /**/ NULL, }; - -static Vec3f sLeftChestPos[] = { +static Vec3f sLeftChestPositions[6] = { { 0.0f, 0.0f, 0.0f }, { -100.0f, 20.0f, -245.0f }, { -100.0f, 20.0f, -685.0f }, { -100.0f, 20.0f, -1125.0f }, { -100.0f, 20.0f, -1565.0f }, { -100.0f, 20.0f, -2005.0f }, }; - -static Vec3f sRightChestPos[] = { +static Vec3f sRightChestPositions[6] = { { 0.0f, 0.0f, 0.0f }, { 140.0f, 20.0f, -245.0f }, { 140.0f, 20.0f, -685.0f }, { 140.0f, 20.0f, -1125.0f }, { 140.0f, 20.0f, -1565.0f }, { 140.0f, 20.0f, -2005.0f }, }; - -static s32 sLoserGetItemIds[] = { - GI_NONE, GI_RUPEE_GREEN_LOSE, GI_RUPEE_GREEN_LOSE, GI_RUPEE_BLUE_LOSE, GI_RUPEE_BLUE_LOSE, GI_RUPEE_RED_LOSE, -}; - -static s32 sItemEtcTypes[] = { - 0, - ITEM_ETC_RUPEE_GREEN_CHEST_GAME, - ITEM_ETC_RUPEE_GREEN_CHEST_GAME, - ITEM_ETC_RUPEE_BLUE_CHEST_GAME, - ITEM_ETC_RUPEE_BLUE_CHEST_GAME, - ITEM_ETC_RUPEE_RED_CHEST_GAME, -}; - -static s32 sTreasureFlags[] = { 0x0000, 0x0002, 0x0004, 0x0006, 0x0008, 0x000A }; +static s32 D_809D3130[6] = { 0, 0x72, 0x72, 0x73, 0x73, 0x74 }; +static s32 D_809D3148[6] = { 0, 8, 8, 9, 9, 0xA }; +static s32 sTreasureFlags[6] = { 0, 2, 4, 6, 8, 0xA }; void EnChanger_Destroy(Actor* thisx, PlayState* play) { } @@ -76,216 +51,166 @@ void EnChanger_Destroy(Actor* thisx, PlayState* play) { void EnChanger_Init(Actor* thisx, PlayState* play2) { EnChanger* this = (EnChanger*)thisx; PlayState* play = play2; - s16 leftChestParams; - s16 rightChestParams; - s16 rewardChestParams; - s16 minigameRoomNum; - s16 rightChestItem; - s16 leftChestItem; - s32 rewardParams; - - minigameRoomNum = play->roomCtx.curRoom.num - 1; - if (minigameRoomNum < 0) { - minigameRoomNum = 0; + s16 sp6E_leftChestParams; + s16 sp6C_rightChestParams; + s16 sp6A_finalChestParams; + s16 temp_v1_curRoomIndex; + s16 sp66_rightChestThing; + s16 sp64_leftChestThing; + s32 new_var_someParams; + + temp_v1_curRoomIndex = play->roomCtx.curRoom.num - 1; + if (temp_v1_curRoomIndex < 0) { + temp_v1_curRoomIndex = 0; } - if (Flags_GetTreasure(play, sTreasureFlags[minigameRoomNum])) { - this->roomChestsOpened = true; + if (Flags_GetTreasure(play, sTreasureFlags[temp_v1_curRoomIndex])) { + this->unk168 = 1; } - PRINTF("\n\n"); - PRINTF(VT_FGCOL(GREEN) T("☆☆☆☆☆ 宝発生(部屋はどれ?) %d\n", "☆☆☆☆☆ Treasure found (which room?) %d\n") VT_RST, - play->roomCtx.curRoom.num); - PRINTF(VT_FGCOL(GREEN) T("☆☆☆☆☆ ビットは? \t %x\n", "☆☆☆☆☆ What about bits? \t %x\n") VT_RST, - play->actorCtx.flags.chest); - PRINTF(VT_FGCOL(GREEN) T("☆☆☆☆☆ セーブBITは? %x\n", "☆☆☆☆☆ What is the save BIT? %x\n") VT_RST, - sTreasureFlags[minigameRoomNum]); - PRINTF(VT_FGCOL(GREEN) T("☆☆☆☆☆ もう、ゾンビ?\t %d\n", "☆☆☆☆☆ Already a zombie?\t %d\n") VT_RST, - this->roomChestsOpened); + PRINTF(VT_FGCOL(GREEN) "☆☆☆☆☆ 宝発生(部屋はどれ?) %d\n" VT_RST, play->roomCtx.curRoom.num); + PRINTF(VT_FGCOL(GREEN) "☆☆☆☆☆ ビットは? \t %x\n" VT_RST, play->actorCtx.flags.chest); + PRINTF(VT_FGCOL(GREEN) "☆☆☆☆☆ セーブBITは? %x\n" VT_RST, sTreasureFlags[temp_v1_curRoomIndex]); + PRINTF(VT_FGCOL(GREEN) "☆☆☆☆☆ もう、ゾンビ?\t %d\n" VT_RST, this->unk168); PRINTF("\n\n"); - - minigameRoomNum *= 2; - // Spawn Heart Piece in chest (or Purple Rupee if won Heart Piece) + temp_v1_curRoomIndex = temp_v1_curRoomIndex * 2; if (play->roomCtx.curRoom.num >= 6) { - rewardChestParams = GET_ITEMGETINF(ITEMGETINF_1B) ? 0x4EA0 : 0x4EC0; - rewardChestParams = sTreasureFlags[5] | rewardChestParams; - this->finalChest = (EnBox*)Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_BOX, 20.0f, 20.0f, - -2500.0f, 0, 0x7FFF, 0, rewardChestParams); - if (this->finalChest != NULL) { - if (this->roomChestsOpened) { - Flags_SetTreasure(play, rewardChestParams & 0x1F); + sp6A_finalChestParams = GET_ITEMGETINF(ITEMGETINF_1B) ? 0x4EA0 : 0x4EC0; + sp6A_finalChestParams = sTreasureFlags[5] | sp6A_finalChestParams; + this->unk158 = (EnBox*)Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_BOX, 20.0f, 20.0f, + -2500.0f, 0, 0x7FFF, 0, sp6A_finalChestParams); + if (this->unk158 != NULL) { + if (this->unk168 != 0) { + Flags_SetTreasure(play, sp6A_finalChestParams & 0x1F); Actor_Kill(&this->actor); return; - } else { - rewardParams = (GET_ITEMGETINF(ITEMGETINF_1B) ? ITEM_ETC_RUPEE_PURPLE_CHEST_GAME - : ITEM_ETC_HEART_PIECE_CHEST_GAME) & - 0xFF; - Actor_Spawn(&play->actorCtx, play, ACTOR_ITEM_ETCETERA, 20.0f, 20.0f, -2500.0f, 0, 0, 0, - ((sTreasureFlags[5] & 0x1F) << 8) + rewardParams); - PRINTF(VT_FGCOL(YELLOW) T("☆☆☆☆☆ 中央宝発生(GREAT) ☆☆☆☆☆ %x\n", - "☆☆☆☆☆ Central treasure spawn (GREAT) ☆☆☆☆☆ %x\n") VT_RST, - rewardChestParams); - this->actionFunc = EnChanger_SetHeartPieceFlag; - return; } + new_var_someParams = ((gSaveContext.save.info.itemGetInf[1] & 0x800) ? 0xB : 0xC) & 0xFF; + Actor_Spawn(&play->actorCtx, play, ACTOR_ITEM_ETCETERA, 20.0f, 20.0f, -2500.0f, 0, 0, 0, + ((sTreasureFlags[5] & 0x1F) << 8) + new_var_someParams); + PRINTF(VT_FGCOL(YELLOW) "☆☆☆☆☆ 中央宝発生(GREAT) ☆☆☆☆☆ %x\n" VT_RST, sp6A_finalChestParams); + this->unk14C = func_809D2F74; + return; } } - - // Set up items in chests, swap them round with probability 1/2 - leftChestParams = (sLoserGetItemIds[play->roomCtx.curRoom.num] << 5) | 0x4000; - this->leftChestNum = minigameRoomNum; - this->leftChestGetItemId = sLoserGetItemIds[play->roomCtx.curRoom.num]; - leftChestItem = sItemEtcTypes[play->roomCtx.curRoom.num]; - leftChestParams |= minigameRoomNum; - rightChestParams = minigameRoomNum | 0x4E21; - this->rightChestNum = minigameRoomNum | 1; - this->rightChestGetItemId = GI_DOOR_KEY; - rightChestItem = ITEM_ETC_KEY_SMALL_CHEST_GAME; - + sp6E_leftChestParams = (D_809D3130[play->roomCtx.curRoom.num] << 5) | 0x4000; + this->unk15C_l = temp_v1_curRoomIndex; + sp6E_leftChestParams |= temp_v1_curRoomIndex; + this->unk160 = D_809D3130[play->roomCtx.curRoom.num]; + sp64_leftChestThing = D_809D3148[play->roomCtx.curRoom.num]; + sp6C_rightChestParams = temp_v1_curRoomIndex | 0x4E21; + this->unk15E_r = temp_v1_curRoomIndex | 1; + this->unk162 = 0x71; + sp66_rightChestThing = 0xD; if (Rand_ZeroFloat(1.99f) < 1.0f) { - rightChestParams = (sLoserGetItemIds[play->roomCtx.curRoom.num] << 5) | 0x4000; - this->rightChestNum = minigameRoomNum; - this->rightChestGetItemId = sLoserGetItemIds[play->roomCtx.curRoom.num]; - rightChestItem = sItemEtcTypes[play->roomCtx.curRoom.num]; - leftChestParams = minigameRoomNum | 0x4E21; - rightChestParams |= minigameRoomNum; - this->leftChestNum = minigameRoomNum | 1; - this->leftChestGetItemId = GI_DOOR_KEY; - leftChestItem = ITEM_ETC_KEY_SMALL_CHEST_GAME; + sp6C_rightChestParams = (D_809D3130[play->roomCtx.curRoom.num] << 5) | 0x4000; + this->unk15E_r = temp_v1_curRoomIndex; + this->unk162 = D_809D3130[play->roomCtx.curRoom.num]; + sp66_rightChestThing = D_809D3148[play->roomCtx.curRoom.num]; + sp6E_leftChestParams = temp_v1_curRoomIndex | 0x4E21; + sp6C_rightChestParams |= temp_v1_curRoomIndex; + this->unk15C_l = temp_v1_curRoomIndex | 1; + this->unk160 = 0x71; + sp64_leftChestThing = 0xD; } - - this->leftChest = (EnBox*)Actor_SpawnAsChild( - &play->actorCtx, &this->actor, play, ACTOR_EN_BOX, sLeftChestPos[play->roomCtx.curRoom.num].x, - sLeftChestPos[play->roomCtx.curRoom.num].y, sLeftChestPos[play->roomCtx.curRoom.num].z, 0, -0x3FFF, 0, - leftChestParams); - - if (this->leftChest != NULL) { - PRINTF(VT_FGCOL(MAGENTA) T("☆☆☆☆☆ 左宝発生(ナニがはいってるの?) ☆☆☆☆☆ %x\n", - "☆☆☆☆☆ Left treasure spawn (what does it contain?) ☆☆☆☆☆ %x\n") VT_RST, - leftChestParams); - PRINTF(VT_FGCOL(MAGENTA) T("☆☆☆☆☆ 部屋番号は? %x\n", "☆☆☆☆☆ What is the room number? %x\n") VT_RST, - play->roomCtx.curRoom.num); - PRINTF(VT_FGCOL(MAGENTA) T("☆☆☆☆☆ ビットはなぁに? %x\n", "☆☆☆☆☆ What is the bit? %x\n") VT_RST, - this->rightChestNum); - // "Sukesuke-kun" (something to do with being invisible) - PRINTF(VT_FGCOL(MAGENTA) T("☆☆☆☆☆ すけすけ君? %x\n", "☆☆☆☆☆ See-through guy? %x\n") VT_RST, rightChestItem); + this->unk150 = (EnBox*)Actor_SpawnAsChild( + &play->actorCtx, &this->actor, play, ACTOR_EN_BOX, sLeftChestPositions[play->roomCtx.curRoom.num].x, + sLeftChestPositions[play->roomCtx.curRoom.num].y, sLeftChestPositions[play->roomCtx.curRoom.num].z, 0, -0x3FFF, + 0, sp6E_leftChestParams); + if (this->unk150 != NULL) { + PRINTF(VT_FGCOL(MAGENTA) "☆☆☆☆☆ 左宝発生(ナニがはいってるの?) ☆☆☆☆☆ %x\n" VT_RST, sp6E_leftChestParams); + PRINTF(VT_FGCOL(MAGENTA) "☆☆☆☆☆ 部屋番号は? %x\n" VT_RST, play->roomCtx.curRoom.num); + PRINTF(VT_FGCOL(MAGENTA) "☆☆☆☆☆ ビットはなぁに? %x\n" VT_RST, this->unk15E_r); + PRINTF(VT_FGCOL(MAGENTA) "☆☆☆☆☆ すけすけ君? %x\n" VT_RST, sp66_rightChestThing); PRINTF("\n\n"); - if (this->roomChestsOpened) { - Flags_SetTreasure(play, this->leftChestNum & 0x1F); + if (this->unk168 != 0) { + Flags_SetTreasure(play, this->unk15C_l & 0x1F); } else { - Actor_Spawn(&play->actorCtx, play, ACTOR_ITEM_ETCETERA, sLeftChestPos[play->roomCtx.curRoom.num].x, - sLeftChestPos[play->roomCtx.curRoom.num].y, sLeftChestPos[play->roomCtx.curRoom.num].z, 0, 0, 0, - ((this->leftChestNum & 0x1F) << 8) + (leftChestItem & 0xFF)); + Actor_Spawn(&play->actorCtx, play, ACTOR_ITEM_ETCETERA, sLeftChestPositions[play->roomCtx.curRoom.num].x, + sLeftChestPositions[play->roomCtx.curRoom.num].y, + sLeftChestPositions[play->roomCtx.curRoom.num].z, 0, 0, 0, + ((this->unk15C_l & 0x1F) << 8) + (sp64_leftChestThing & 0xFF)); } } - - this->rightChest = (EnBox*)Actor_SpawnAsChild( - &play->actorCtx, &this->actor, play, ACTOR_EN_BOX, sRightChestPos[play->roomCtx.curRoom.num].x, - sRightChestPos[play->roomCtx.curRoom.num].y, sRightChestPos[play->roomCtx.curRoom.num].z, 0, 0x3FFF, 0, - rightChestParams); - - if (this->rightChest != NULL) { - PRINTF(VT_FGCOL(CYAN) T("☆☆☆☆☆ 右宝発生(ナニがはいってるの?) ☆☆☆☆☆ %x\n", - "☆☆☆☆☆ Right treasure spawn (what does it contain?) ☆☆☆☆☆ %x\n") VT_RST, - rightChestParams); - PRINTF(VT_FGCOL(CYAN) T("☆☆☆☆☆ 部屋番号は? %d\n", "☆☆☆☆☆ What is the room number? %d\n") VT_RST, - play->roomCtx.curRoom.num); - PRINTF(VT_FGCOL(CYAN) T("☆☆☆☆☆ ビットはなぁに? %x\n", "☆☆☆☆☆ What is the bit? %x\n") VT_RST, - this->leftChestNum); - // "Sukesuke-kun" (something to do with being invisible) - PRINTF(VT_FGCOL(CYAN) T("☆☆☆☆☆ すけすけ君? %x\n", "☆☆☆☆☆ See-through guy? %x\n") VT_RST, leftChestItem); + this->unk154 = (EnBox*)Actor_SpawnAsChild( + &play->actorCtx, &this->actor, play, ACTOR_EN_BOX, sRightChestPositions[play->roomCtx.curRoom.num].x, + sRightChestPositions[play->roomCtx.curRoom.num].y, sRightChestPositions[play->roomCtx.curRoom.num].z, 0, 0x3FFF, + 0, sp6C_rightChestParams); + if (this->unk154 != NULL) { + PRINTF(VT_FGCOL(CYAN) "☆☆☆☆☆ 右宝発生(ナニがはいってるの?) ☆☆☆☆☆ %x\n" VT_RST, sp6C_rightChestParams); + PRINTF(VT_FGCOL(CYAN) "☆☆☆☆☆ 部屋番号は? %d\n" VT_RST, play->roomCtx.curRoom.num); + PRINTF(VT_FGCOL(CYAN) "☆☆☆☆☆ ビットはなぁに? %x\n" VT_RST, this->unk15C_l); + PRINTF(VT_FGCOL(CYAN) "☆☆☆☆☆ すけすけ君? %x\n" VT_RST, sp64_leftChestThing); PRINTF("\n\n"); - - if (this->roomChestsOpened) { - Flags_SetTreasure(play, this->rightChestNum & 0x1F); + if (this->unk168 != 0) { + Flags_SetTreasure(play, this->unk15E_r & 0x1F); Actor_Kill(&this->actor); return; } - - Actor_Spawn(&play->actorCtx, play, ACTOR_ITEM_ETCETERA, sRightChestPos[play->roomCtx.curRoom.num].x, - sRightChestPos[play->roomCtx.curRoom.num].y, sRightChestPos[play->roomCtx.curRoom.num].z, 0, 0, 0, - ((this->rightChestNum & 0x1F) << 8) + (rightChestItem & 0xFF)); + Actor_Spawn(&play->actorCtx, play, ACTOR_ITEM_ETCETERA, sRightChestPositions[play->roomCtx.curRoom.num].x, + sRightChestPositions[play->roomCtx.curRoom.num].y, + sRightChestPositions[play->roomCtx.curRoom.num].z, 0, 0, 0, + ((this->unk15E_r & 0x1F) << 8) + (sp66_rightChestThing & 0xFF)); } - this->actor.flags &= ~ACTOR_FLAG_ATTENTION_ENABLED; - this->actionFunc = EnChanger_Wait; + this->unk14C = func_809D2CCC; } -void EnChanger_Wait(EnChanger* this, PlayState* play) { - if (this->leftChest->unk_1F4 != 0) { - this->timer = 80; - Flags_SetTreasure(play, this->rightChestNum & 0x1F); - this->actionFunc = EnChanger_OpenChests; - } else if (this->rightChest->unk_1F4 != 0) { - this->selectedChest = CHEST_RIGHT; - this->timer = 80; - Flags_SetTreasure(play, this->leftChestNum & 0x1F); - this->actionFunc = EnChanger_OpenChests; +void func_809D2CCC(EnChanger* this, PlayState* play) { + if (this->unk150->unk_1F4 != 0) { + this->unk166 = 0x50; + Flags_SetTreasure(play, this->unk15E_r & 0x1F); + this->unk14C = func_809D2D70; + } else if (this->unk154->unk_1F4 != 0) { + this->unk164 = 1; + this->unk166 = 0x50; + Flags_SetTreasure(play, this->unk15C_l & 0x1F); + this->unk14C = func_809D2D70; } } -// Spawns the EnExItem showing what was in the other chest -void EnChanger_OpenChests(EnChanger* this, PlayState* play) { - f32 zPos; - f32 yPos; - f32 xPos; - s16 selectedChest; - s16 unopenedChestItemType; - EnBox* left; - EnBox* right; - - left = this->leftChest; - right = this->rightChest; - - if (this->timer == 0) { - // `unopenedChestItemType` being set here is required for matching, but doesn't do anything useful - unopenedChestItemType = selectedChest = this->selectedChest; - - switch (selectedChest) { - case CHEST_LEFT: - xPos = right->dyna.actor.world.pos.x; - yPos = right->dyna.actor.world.pos.y; - zPos = right->dyna.actor.world.pos.z; - - if (this->rightChestGetItemId == GI_DOOR_KEY) { - Actor_Spawn(&play->actorCtx, play, ACTOR_EN_EX_ITEM, xPos, yPos, zPos, 0, 0, 0, - EXITEM_SMALL_KEY_CHEST); +void func_809D2D70(EnChanger* this, PlayState* play) { + Vec3f pos; + EnBox* temp_v0; + EnBox* temp_v1; + s16 temp_s0; + + temp_v0 = this->unk150; + temp_v1 = this->unk154; + if (this->unk166 == 0) { + switch (this->unk164) { + case 0: + pos.x = temp_v1->dyna.actor.world.pos.x; + pos.y = temp_v1->dyna.actor.world.pos.y; + pos.z = temp_v1->dyna.actor.world.pos.z; + if (this->unk162 == 0x71) { + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_EX_ITEM, pos.x, pos.y, pos.z, 0, 0, 0, 0xF); Flags_SetSwitch(play, 0x32); } else { - unopenedChestItemType = - (s16)(this->rightChestGetItemId - GI_RUPEE_GREEN_LOSE) + EXITEM_GREEN_RUPEE_CHEST; - PRINTF(VT_FGCOL(GREEN) T("☆☆☆☆☆ 右宝開く ☆☆☆☆☆ %d\n", "☆☆☆☆☆ Right treasure open ☆☆☆☆☆ %d\n") - VT_RST, - unopenedChestItemType); - Actor_Spawn(&play->actorCtx, play, ACTOR_EN_EX_ITEM, xPos, yPos, zPos, 0, 0, 0, - unopenedChestItemType); + temp_s0 = (s16)(this->unk162 - GI_RUPEE_GREEN_LOSE) + EXITEM_GREEN_RUPEE_CHEST; + PRINTF(VT_FGCOL(GREEN) "☆☆☆☆☆ 右宝開く ☆☆☆☆☆ %d\n" VT_RST, temp_s0); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_EX_ITEM, pos.x, pos.y, pos.z, 0, 0, 0, temp_s0); } break; - case CHEST_RIGHT: - xPos = left->dyna.actor.world.pos.x; - yPos = left->dyna.actor.world.pos.y; - zPos = left->dyna.actor.world.pos.z; - - if (this->leftChestGetItemId == GI_DOOR_KEY) { - Actor_Spawn(&play->actorCtx, play, ACTOR_EN_EX_ITEM, xPos, yPos, zPos, 0, 0, 0, - EXITEM_SMALL_KEY_CHEST); + case 1: + pos.x = temp_v0->dyna.actor.world.pos.x; + pos.y = temp_v0->dyna.actor.world.pos.y; + pos.z = temp_v0->dyna.actor.world.pos.z; + if (this->unk160 == 0x71) { + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_EX_ITEM, pos.x, pos.y, pos.z, 0, 0, 0, 0xF); Flags_SetSwitch(play, 0x32); } else { - unopenedChestItemType = - (s16)(this->leftChestGetItemId - GI_RUPEE_GREEN_LOSE) + EXITEM_GREEN_RUPEE_CHEST; - PRINTF(VT_FGCOL(GREEN) T("☆☆☆☆☆ 左宝開く ☆☆☆☆☆ %d\n", "☆☆☆☆☆ Left treasure open ☆☆☆☆☆ %d\n") VT_RST, - unopenedChestItemType); - Actor_Spawn(&play->actorCtx, play, ACTOR_EN_EX_ITEM, xPos, yPos, zPos, 0, 0, 0, - unopenedChestItemType); + temp_s0 = (s16)(this->unk160 - GI_RUPEE_GREEN_LOSE) + EXITEM_GREEN_RUPEE_CHEST; + PRINTF(VT_FGCOL(GREEN) "☆☆☆☆☆ 左宝開く ☆☆☆☆☆ %d\n" VT_RST, temp_s0); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_EX_ITEM, pos.x, pos.y, pos.z, 0, 0, 0, temp_s0); } break; } - Actor_Kill(&this->actor); } } -void EnChanger_SetHeartPieceFlag(EnChanger* this, PlayState* play) { - if (this->finalChest->unk_1F4 != 0) { +void func_809D2F74(EnChanger* this, PlayState* play) { + if (this->unk158->unk_1F4 != 0) { if (!GET_ITEMGETINF(ITEMGETINF_1B)) { SET_ITEMGETINF(ITEMGETINF_1B); } @@ -296,12 +221,10 @@ void EnChanger_SetHeartPieceFlag(EnChanger* this, PlayState* play) { void EnChanger_Update(Actor* thisx, PlayState* play) { EnChanger* this = (EnChanger*)thisx; - this->actionFunc(this, play); - - if (this->timer != 0) { - this->timer--; + this->unk14C(this, play); + if (this->unk166 != 0) { + this->unk166--; } - if (DEBUG_FEATURES && BREG(0) != 0) { DebugDisplay_AddObject(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, 1.0f, 1.0f, diff --git a/src/overlays/actors/ovl_En_Changer/z_en_changer.h b/src/overlays/actors/ovl_En_Changer/z_en_changer.h index 45f8799a5f8..af4ff04f817 100644 --- a/src/overlays/actors/ovl_En_Changer/z_en_changer.h +++ b/src/overlays/actors/ovl_En_Changer/z_en_changer.h @@ -9,18 +9,19 @@ struct EnChanger; typedef void (*EnChangerActionFunc)(struct EnChanger*, struct PlayState*); typedef struct EnChanger { - /* 0x0000 */ Actor actor; - /* 0x014C */ EnChangerActionFunc actionFunc; - /* 0x0150 */ struct EnBox* leftChest; - /* 0x0154 */ struct EnBox* rightChest; - /* 0x0158 */ struct EnBox* finalChest; - /* 0x015C */ s16 leftChestNum; - /* 0x015E */ s16 rightChestNum; - /* 0x0160 */ s16 leftChestGetItemId; - /* 0x0162 */ s16 rightChestGetItemId; - /* 0x0164 */ s16 selectedChest; - /* 0x0166 */ s16 timer; - /* 0x0168 */ s16 roomChestsOpened; + /* 0x000 */ Actor actor; + /* 0x14C */ EnChangerActionFunc unk14C; + /* 0x150 */ struct EnBox* unk150; + /* 0x154 */ struct EnBox* unk154; + /* 0x158 */ struct EnBox* unk158; + /* 0x15C */ s16 unk15C_l; + /* 0x15E */ s16 unk15E_r; + /* 0x160 */ s16 unk160; + /* 0x162 */ s16 unk162; + /* 0x164 */ s16 unk164; + /* 0x166 */ s16 unk166; + /* 0x168 */ s16 unk168; + /* 0x16A */ char pad16A[2]; } EnChanger; // size = 0x016C #endif 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 79c65884cb9..cb8d07ef1a3 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 @@ -478,7 +478,7 @@ void EnClearTag_Update(Actor* thisx, PlayState* play2) { Math_ApproachS(&this->actor.world.rot.z, 0, 15, this->targetDirection.z); Math_ApproachF(&this->targetDirection.z, 0x500, 1.0f, 0x100); - // Check if the Arwing should fire its laser. + // Check if the Arwing should fire it's laser. if ((this->frameCounter % 4) == 0 && (Rand_ZeroOne() < 0.75f) && (this->state == CLEAR_TAG_STATE_TARGET_LOCKED)) { this->shouldShootLaser = true; @@ -826,7 +826,7 @@ void EnClearTag_UpdateEffects(PlayState* play) { effect->velocity.y *= -0.5f; effect->timer = ((s16)Rand_ZeroFloat(20)) + 25; } else { - // The Debris effect is done bouncing. Set its velocity and acceleration to 0. + // The Debris effect is done bounding. Set it's velocity and acceleration to 0. effect->velocity.x = effect->velocity.z = effect->acceleration.y = effect->velocity.y = 0.0f; } 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 a607315b5d5..3e82de77ab9 100644 --- a/src/overlays/actors/ovl_En_Crow/z_en_crow.c +++ b/src/overlays/actors/ovl_En_Crow/z_en_crow.c @@ -23,13 +23,13 @@ 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, PlayState* play); -void EnCrow_Respawn(EnCrow* this, PlayState* play); -void EnCrow_DiveAttack(EnCrow* this, PlayState* play); +void EnCrow_SetupWait(EnCrow* this); +void EnCrow_Wait(EnCrow* this, PlayState* play); +void func_809E10A8(EnCrow* this, PlayState* play); +void func_809E0C8C(EnCrow* this, PlayState* play); void EnCrow_Die(EnCrow* this, PlayState* play); -void EnCrow_TurnAway(EnCrow* this, PlayState* play); -void EnCrow_Damaged(EnCrow* this, PlayState* play); +void func_809E1004(EnCrow* this, PlayState* play); +void func_809E0E2C(EnCrow* this, PlayState* play); static Vec3f sZeroVecAccel = { 0.0f, 0.0f, 0.0f }; @@ -131,7 +131,7 @@ void EnCrow_Init(Actor* thisx, PlayState* play) { CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); ActorShape_Init(&this->actor.shape, 2000.0f, ActorShadow_DrawCircle, 20.0f); sDeathCount = 0; - EnCrow_SetupFlyIdle(this); + EnCrow_SetupWait(this); } void EnCrow_Destroy(Actor* thisx, PlayState* play) { @@ -140,23 +140,21 @@ void EnCrow_Destroy(Actor* thisx, PlayState* play) { Collider_DestroyJntSph(play, &this->collider); } -// Setup Action functions - -void EnCrow_SetupFlyIdle(EnCrow* this) { +void EnCrow_SetupWait(EnCrow* this) { this->timer = 100; this->collider.base.acFlags |= AC_ON; - this->actionFunc = EnCrow_FlyIdle; + this->actionFunc = EnCrow_Wait; this->skelAnime.playSpeed = 1.0f; } -void EnCrow_SetupDiveAttack(EnCrow* this) { +void func_809E0384(EnCrow* this) { this->timer = 300; this->actor.speed = 4.0f; this->skelAnime.playSpeed = 2.0f; - this->actionFunc = EnCrow_DiveAttack; + this->actionFunc = func_809E0C8C; } -void EnCrow_SetupDamaged(EnCrow* this, PlayState* play) { +void func_809E03B4(EnCrow* this, PlayState* play) { s32 i; f32 scale; Vec3f iceParticlePos; @@ -171,7 +169,7 @@ void EnCrow_SetupDamaged(EnCrow* this, PlayState* play) { this->actor.lockOnArrowOffset = 0.0f; Actor_PlaySfx(&this->actor, NA_SE_EN_KAICHO_DEAD); - if (this->actor.colChkInfo.damageReaction == 3) { // Ice arrows + if (this->actor.colChkInfo.damageReaction == 3) { Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 255, COLORFILTER_BUFFLAG_OPA, 40); for (i = 0; i < 8; i++) { iceParticlePos.x = ((i & 1 ? 7.0f : -7.0f) * scale) + this->actor.world.pos.x; @@ -180,7 +178,7 @@ void EnCrow_SetupDamaged(EnCrow* this, PlayState* play) { EffectSsEnIce_SpawnFlyingVec3f(play, &this->actor, &iceParticlePos, 150, 150, 150, 250, 235, 245, 255, ((Rand_ZeroOne() * 0.15f) + 0.85f) * scale); } - } else if (this->actor.colChkInfo.damageReaction == 2) { // Fire arrows and Din's Fire + } else if (this->actor.colChkInfo.damageReaction == 2) { Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 40); for (i = 0; i < 4; i++) { @@ -197,7 +195,7 @@ void EnCrow_SetupDamaged(EnCrow* this, PlayState* play) { this->collider.base.acFlags &= ~AC_ON; this->actor.flags |= ACTOR_FLAG_UPDATE_CULLING_DISABLED; - this->actionFunc = EnCrow_Damaged; + this->actionFunc = func_809E0E2C; } void EnCrow_SetupDie(EnCrow* this) { @@ -205,7 +203,7 @@ void EnCrow_SetupDie(EnCrow* this) { this->actionFunc = EnCrow_Die; } -void EnCrow_SetupTurnAway(EnCrow* this) { +void func_809E06E8(EnCrow* this) { this->timer = 100; this->actor.speed = 3.5f; this->aimRotX = -0x1000; @@ -213,10 +211,10 @@ void EnCrow_SetupTurnAway(EnCrow* this) { this->skelAnime.playSpeed = 2.0f; Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 255, COLORFILTER_BUFFLAG_OPA, 5); Actor_PlaySfx(&this->actor, NA_SE_EN_GOMA_JR_FREEZE); - this->actionFunc = EnCrow_TurnAway; + this->actionFunc = func_809E1004; } -void EnCrow_SetupRespawn(EnCrow* this) { +void func_809E0770(EnCrow* this) { if (sDeathCount == 10) { this->actor.params = 1; sDeathCount = 0; @@ -235,12 +233,10 @@ void EnCrow_SetupRespawn(EnCrow* this) { this->actor.shape.yOffset = 2000; this->actor.lockOnArrowOffset = 2000.0f; this->actor.draw = NULL; - this->actionFunc = EnCrow_Respawn; + this->actionFunc = func_809E10A8; } -// Action functions - -void EnCrow_FlyIdle(EnCrow* this, PlayState* play) { +void EnCrow_Wait(EnCrow* this, PlayState* play) { Player* player = GET_PLAYER(play); s32 skelanimeUpdated; s16 var; @@ -293,11 +289,11 @@ void EnCrow_FlyIdle(EnCrow* this, PlayState* play) { } if ((this->timer == 0) && (this->actor.xzDistToPlayer < 300.0f) && !(player->stateFlags1 & PLAYER_STATE1_23) && (this->actor.depthInWater < -40.0f) && (Player_GetMask(play) != PLAYER_MASK_SKULL)) { - EnCrow_SetupDiveAttack(this); + func_809E0384(this); } } -void EnCrow_DiveAttack(EnCrow* this, PlayState* play) { +void func_809E0C8C(EnCrow* this, PlayState* play) { Player* player = GET_PLAYER(play); s32 facingPlayer; @@ -336,11 +332,11 @@ void EnCrow_DiveAttack(EnCrow* this, PlayState* play) { Actor_PlaySfx(&this->actor, NA_SE_EN_KAICHO_ATTACK); } - EnCrow_SetupFlyIdle(this); + EnCrow_SetupWait(this); } } -void EnCrow_Damaged(EnCrow* this, PlayState* play) { +void func_809E0E2C(EnCrow* this, PlayState* play) { Math_StepToF(&this->actor.speed, 0.0f, 0.5f); this->actor.colorFilterTimer = 40; @@ -374,13 +370,13 @@ void EnCrow_Die(EnCrow* this, PlayState* play) { } else { Item_DropCollectible(play, &this->actor.world.pos, ITEM00_RUPEE_RED); } - EnCrow_SetupRespawn(this); + func_809E0770(this); } this->actor.scale.z = this->actor.scale.y = this->actor.scale.x; } -void EnCrow_TurnAway(EnCrow* this, PlayState* play) { +void func_809E1004(EnCrow* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { @@ -396,11 +392,11 @@ void EnCrow_TurnAway(EnCrow* this, PlayState* play) { this->timer--; } if (this->timer == 0) { - EnCrow_SetupFlyIdle(this); + EnCrow_SetupWait(this); } } -void EnCrow_Respawn(EnCrow* this, PlayState* play) { +void func_809E10A8(EnCrow* this, PlayState* play) { f32 target; if (this->timer != 0) { @@ -419,24 +415,24 @@ void EnCrow_Respawn(EnCrow* this, PlayState* play) { this->actor.flags |= ACTOR_FLAG_ATTENTION_ENABLED; this->actor.flags &= ~ACTOR_FLAG_UPDATE_CULLING_DISABLED; this->actor.colChkInfo.health = 1; - EnCrow_SetupFlyIdle(this); + EnCrow_SetupWait(this); } this->actor.scale.z = this->actor.scale.y = this->actor.scale.x; } } -void EnCrow_UpdateDamage(EnCrow* this, PlayState* play) { +void func_809E1174(EnCrow* this, PlayState* play) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; Actor_SetDropFlag(&this->actor, &this->collider.elements[0].base, true); if ((this->actor.colChkInfo.damageReaction != 0) || (this->actor.colChkInfo.damage != 0)) { - if (this->actor.colChkInfo.damageReaction == 1) { // Deku Nuts - EnCrow_SetupTurnAway(this); + if (this->actor.colChkInfo.damageReaction == 1) { + func_809E06E8(this); } else { Actor_ApplyDamage(&this->actor); this->actor.flags &= ~ACTOR_FLAG_ATTENTION_ENABLED; Enemy_StartFinishingBlow(play, &this->actor); - EnCrow_SetupDamaged(this, play); + func_809E03B4(this, play); } } } @@ -448,13 +444,13 @@ void EnCrow_Update(Actor* thisx, PlayState* play) { f32 height; f32 scale; - EnCrow_UpdateDamage(this, play); + func_809E1174(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; - if (this->actionFunc != EnCrow_Respawn) { + if (this->actionFunc != func_809E10A8) { if (this->actor.colChkInfo.health != 0) { height = 20.0f * scale; Actor_MoveXYZ(&this->actor); @@ -472,7 +468,7 @@ void EnCrow_Update(Actor* thisx, PlayState* play) { this->collider.elements[0].dim.worldSphere.center.y = this->actor.world.pos.y + height; this->collider.elements[0].dim.worldSphere.center.z = this->actor.world.pos.z; - if (this->actionFunc == EnCrow_DiveAttack) { + if (this->actionFunc == func_809E0C8C) { CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } @@ -480,7 +476,7 @@ void EnCrow_Update(Actor* thisx, PlayState* play) { CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } - if (this->actionFunc != EnCrow_Respawn) { + if (this->actionFunc != func_809E10A8) { CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } diff --git a/src/overlays/actors/ovl_En_Cs/z_en_cs.c b/src/overlays/actors/ovl_En_Cs/z_en_cs.c index 0132cb0b78b..a714401dfab 100644 --- a/src/overlays/actors/ovl_En_Cs/z_en_cs.c +++ b/src/overlays/actors/ovl_En_Cs/z_en_cs.c @@ -267,7 +267,7 @@ void EnCs_HandleTalking(EnCs* this, PlayState* play) { Actor_GetScreenPos(play, &this->actor, &sp2A, &sp28); if ((sp2A >= 0) && (sp2A <= 320) && (sp28 >= 0) && (sp28 <= 240) && - Actor_OfferTalk(&this->actor, play, 100.0f)) { + (Actor_OfferTalk(&this->actor, play, 100.0f))) { this->actor.textId = EnCs_GetTextId(this, play); } } diff --git a/src/overlays/actors/ovl_En_Dh/z_en_dh.c b/src/overlays/actors/ovl_En_Dh/z_en_dh.c index 3c5be0ad059..6b7f371b479 100644 --- a/src/overlays/actors/ovl_En_Dh/z_en_dh.c +++ b/src/overlays/actors/ovl_En_Dh/z_en_dh.c @@ -33,13 +33,13 @@ ACTOR_FLAG_HOOKSHOT_PULLS_PLAYER) typedef enum EnDhAction { - /* 0 */ DH_WAIT, - /* 1 */ DH_RETREAT, - /* 2 */ DH_BURROW, - /* 3 */ DH_WALK, - /* 4 */ DH_ATTACK, - /* 5 */ DH_DEATH, - /* 6 */ DH_DAMAGE + DH_WAIT, + DH_RETREAT, + DH_BURROW, + DH_WALK, + DH_ATTACK, + DH_DEATH, + DH_DAMAGE } EnDhAction; void EnDh_Init(Actor* thisx, PlayState* play); @@ -119,7 +119,7 @@ static ColliderJntSphInit sJntSphInit = { sJntSphElementsInit, }; -static DamageTable D_809EC620 = { +static DamageTable sDamageTable = { /* Deku nut */ DMG_ENTRY(0, 0x0), /* Deku stick */ DMG_ENTRY(2, 0xF), /* Slingshot */ DMG_ENTRY(0, 0x0), @@ -169,7 +169,7 @@ void EnDh_Init(Actor* thisx, PlayState* play) { EnDh* this = (EnDh*)thisx; Actor_ProcessInitChain(&this->actor, sInitChain); - this->actor.colChkInfo.damageTable = &D_809EC620; + this->actor.colChkInfo.damageTable = &sDamageTable; SkelAnime_InitFlex(play, &this->skelAnime, &object_dh_Skel_007E88, &object_dh_Anim_005880, this->jointTable, this->morphTable, 16); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 64.0f); diff --git a/src/overlays/actors/ovl_En_Dha/z_en_dha.c b/src/overlays/actors/ovl_En_Dha/z_en_dha.c index 89d07dfae8a..f1f9aefa633 100644 --- a/src/overlays/actors/ovl_En_Dha/z_en_dha.c +++ b/src/overlays/actors/ovl_En_Dha/z_en_dha.c @@ -427,7 +427,6 @@ void EnDha_UpdateHealth(EnDha* this, PlayState* play) { } } } - if ((this->actor.parent != NULL) && (this->actor.parent->params == ENDH_DEATH)) { EnDha_SetupDeath(this); } diff --git a/src/overlays/actors/ovl_En_Dodojr/z_en_dodojr.c b/src/overlays/actors/ovl_En_Dodojr/z_en_dodojr.c index cee0dac43b6..5245d8f3e62 100644 --- a/src/overlays/actors/ovl_En_Dodojr/z_en_dodojr.c +++ b/src/overlays/actors/ovl_En_Dodojr/z_en_dodojr.c @@ -650,7 +650,7 @@ s32 EnDodojr_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f Matrix_MultVec3f(&D_809F7F64, &this->headPos); } - return false; + return 0; } void EnDodojr_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { diff --git a/src/overlays/actors/ovl_En_Elf/z_en_elf.c b/src/overlays/actors/ovl_En_Elf/z_en_elf.c index 940e7f1a98f..9e37a4f0288 100644 --- a/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ b/src/overlays/actors/ovl_En_Elf/z_en_elf.c @@ -685,7 +685,6 @@ void func_80A0329C(EnElf* this, PlayState* play) { } if (!(this->fairyFlags & FAIRY_FLAG_BIG)) { - // GI_MAX in this case allows the player to catch the actor in a bottle Actor_OfferGetItem(&this->actor, play, GI_MAX, 80.0f, 60.0f); } } diff --git a/src/overlays/actors/ovl_En_Fd/z_en_fd.c b/src/overlays/actors/ovl_En_Fd/z_en_fd.c index 6947fa9b033..ed66adddcc4 100644 --- a/src/overlays/actors/ovl_En_Fd/z_en_fd.c +++ b/src/overlays/actors/ovl_En_Fd/z_en_fd.c @@ -1,9 +1,3 @@ -/* - * File: z_en_fd.c - * Overlay: ovl_En_Fd - * Description: Flare Dancer (enflamed form) - */ - #include "z_en_fd.h" #include "attributes.h" @@ -655,7 +649,7 @@ void EnFd_Run(EnFd* this, PlayState* play) { #define FLG_COREDONE (0x8000) /** - * En_Fw will set `this` params when it is done with its action. + * En_Fw will set `this` params when it is done with it's action. * It will set FLG_COREDONE when the core has returned to `this`'s initial * position, and FLG_COREDEAD when there is no health left */ diff --git a/src/overlays/actors/ovl_En_Fhg_Fire/z_en_fhg_fire.c b/src/overlays/actors/ovl_En_Fhg_Fire/z_en_fhg_fire.c index aa4422b6ea7..e8c40cb32ab 100644 --- a/src/overlays/actors/ovl_En_Fhg_Fire/z_en_fhg_fire.c +++ b/src/overlays/actors/ovl_En_Fhg_Fire/z_en_fhg_fire.c @@ -488,7 +488,7 @@ void EnFhgFire_EnergyBall(EnFhgFire* this, PlayState* play) { switch (this->work[FHGFIRE_FIRE_MODE]) { case FHGFIRE_LIGHT_GREEN: canBottleReflect1 = - ((player->stateFlags1 & PLAYER_STATE1_SWINGING_BOTTLE) && + ((player->stateFlags1 & PLAYER_STATE1_1) && (ABS((s16)(player->actor.shape.rot.y - (s16)(bossGnd->actor.yawTowardsPlayer + 0x8000))) < 0x2000) && (sqrtf(SQ(dxL) + SQ(dyL) + SQ(dzL)) <= 25.0f)) 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 f97ec6af4f0..7967f774743 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -88,8 +88,8 @@ typedef enum EnFuFace { } EnFuFace; void EnFu_Init(Actor* thisx, PlayState* play) { - STACK_PAD(s32); EnFu* this = (EnFu*)thisx; + STACK_PAD(s32); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); SkelAnime_InitFlex(play, &this->skelanime, &gWindmillManSkel, &gWindmillManPlayStillAnim, this->jointTable, @@ -147,8 +147,9 @@ void func_80A1DA04(EnFu* this, PlayState* play) { } void EnFu_WaitChild(EnFu* this, PlayState* play) { - u16 textId = MaskReaction_GetTextId(play, MASK_REACTION_SET_WINDMILL_MAN); + u16 textId; + textId = MaskReaction_GetTextId(play, MASK_REACTION_SET_WINDMILL_MAN); if (textId == 0) { textId = GET_EVENTCHKINF(EVENTCHKINF_DRAINED_WELL) ? 0x5033 : 0x5032; } @@ -203,7 +204,6 @@ void func_80A1DBD4(EnFu* this, PlayState* play) { void EnFu_WaitForPlayback(EnFu* this, PlayState* play) { Player* player = GET_PLAYER(play); - player->stateFlags2 |= PLAYER_STATE2_23; // if dialog state is 7, player has played back the song if (Message_GetState(&play->msgCtx) == TEXT_STATE_SONG_DEMO_DONE) { @@ -214,7 +214,6 @@ void EnFu_WaitForPlayback(EnFu* this, PlayState* play) { void EnFu_TeachSong(EnFu* this, PlayState* play) { Player* player = GET_PLAYER(play); - player->stateFlags2 |= PLAYER_STATE2_23; // if dialog state is 2, start song demonstration if (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) { @@ -250,8 +249,8 @@ void EnFu_WaitAdult(EnFu* this, PlayState* play) { } void EnFu_Update(Actor* thisx, PlayState* play) { - STACK_PAD(s32); EnFu* this = (EnFu*)thisx; + STACK_PAD(s32); Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); diff --git a/src/overlays/actors/ovl_En_Fw/z_en_fw.c b/src/overlays/actors/ovl_En_Fw/z_en_fw.c index 94bb0d1ad7d..486a3c6b20f 100644 --- a/src/overlays/actors/ovl_En_Fw/z_en_fw.c +++ b/src/overlays/actors/ovl_En_Fw/z_en_fw.c @@ -1,9 +1,3 @@ -/* - * File: z_en_fw.c - * Overlay: ovl_En_Fw - * Description: Flare Dancer Core - */ - #include "z_en_fw.h" #include "src/overlays/actors/ovl_En_Bom/z_en_bom.h" @@ -79,7 +73,7 @@ static ColliderJntSphInit sJntSphInit = { sJntSphElementsInit, }; -static CollisionCheckInfoInit2 D_80A1FB94 = { 8, 2, 25, 25, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 8, 2, 25, 25, MASS_IMMOVABLE }; typedef enum EnFwAnimation { /* 0 */ ENFW_ANIM_0, @@ -208,7 +202,7 @@ void EnFw_Init(Actor* thisx, PlayState* play) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); Collider_InitJntSph(play, &this->collider); Collider_SetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); - CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x10), &D_80A1FB94); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x10), &sColChkInfoInit); Actor_SetScale(&this->actor, 0.01f); this->runDirection = -this->actor.params; this->actionFunc = EnFw_Bounce; 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 891ae41d941..5bf7e07b99f 100644 --- a/src/overlays/actors/ovl_En_Fz/z_en_fz.h +++ b/src/overlays/actors/ovl_En_Fz/z_en_fz.h @@ -16,7 +16,7 @@ typedef struct EnFzEffect { /* 0x0010 */ Vec3f velocity; /* 0x001C */ Vec3f accel; /* 0x0028 */ char unk_28[0x4]; - /* 0x002C */ s16 primAlpha; // transparency in RGBA color system + /* 0x002C */ s16 primAlpha; // transparency in RGBA colour system /* 0x002E */ s16 primAlphaState; // 0: increasing (more opaque) 1: decreasing (more transparent) 2: collision /* 0x0030 */ f32 xyScale; /* 0x0034 */ f32 xyScaleTarget; @@ -42,7 +42,7 @@ typedef struct EnFz { /* 0x024C */ f32 iceSmokeFreezingSpawnHeight; // Height for Ice Smoke Spawn, only when freezing /* 0x0250 */ f32 unusedFloat; // Set to 135.0f /* 0x0254 */ f32 speedXZ; // Set to 4.0f when moving - /* 0x0258 */ u32 envAlpha; // transparency in RGBA color system + /* 0x0258 */ u32 envAlpha; // transparency in RGBA colour system /* 0x025C */ u16 unusedNum1; // Only set to 0 /* 0x025E */ u16 unusedNum2; // Set to either 0 when hidden or 4000 when growing /* 0x0260 */ u8 state; // 0 (hidden) 1 (growning/shrinking) 2 (full size) 3 (melting from fire) diff --git a/src/overlays/actors/ovl_En_Ganon_Organ/z_en_ganon_organ.c b/src/overlays/actors/ovl_En_Ganon_Organ/z_en_ganon_organ.c index ba86c228068..dde4aa43dcc 100644 --- a/src/overlays/actors/ovl_En_Ganon_Organ/z_en_ganon_organ.c +++ b/src/overlays/actors/ovl_En_Ganon_Organ/z_en_ganon_organ.c @@ -37,95 +37,7 @@ ActorProfile En_Ganon_Organ_Profile = { UNUSED static u64 sForceAlignment = 0; -#define sRoomCarpetTex_WIDTH 64 -#define sRoomCarpetTex_HEIGHT 16 -static u64 sRoomCarpetTex[TEX_LEN(u64, sRoomCarpetTex_WIDTH, sRoomCarpetTex_HEIGHT, 16)] = { -#include "assets/overlays/ovl_En_Ganon_Organ/sRoomCarpetTex.rgba16.inc.c" -}; - -#define sRoomOrganPipeTex_WIDTH 16 -#define sRoomOrganPipeTex_HEIGHT 64 -static u64 sRoomOrganPipeTex[TEX_LEN(u64, sRoomOrganPipeTex_WIDTH, sRoomOrganPipeTex_HEIGHT, 4)] = { -#include "assets/overlays/ovl_En_Ganon_Organ/sRoomOrganPipeTex.i4.inc.c" -}; - -#define sRoomOrganCorbelsTex_WIDTH 16 -#define sRoomOrganCorbelsTex_HEIGHT 16 -static u64 sRoomOrganCorbelsTex[TEX_LEN(u64, sRoomOrganCorbelsTex_WIDTH, sRoomOrganCorbelsTex_HEIGHT, 4)] = { -#include "assets/overlays/ovl_En_Ganon_Organ/sRoomOrganCorbelsTex.i4.inc.c" -}; - -#define sRoomOrganGrillTex_WIDTH 16 -#define sRoomOrganGrillTex_HEIGHT 16 -static u64 sRoomOrganGrillTex[TEX_LEN(u64, sRoomOrganGrillTex_WIDTH, sRoomOrganGrillTex_HEIGHT, 16)] = { -#include "assets/overlays/ovl_En_Ganon_Organ/sRoomOrganGrillTex.rgba16.inc.c" -}; - -#define sRoomCrestFriezeTex_WIDTH 32 -#define sRoomCrestFriezeTex_HEIGHT 32 -static u64 sRoomCrestFriezeTex[TEX_LEN(u64, sRoomCrestFriezeTex_WIDTH, sRoomCrestFriezeTex_HEIGHT, 4)] = { -#include "assets/overlays/ovl_En_Ganon_Organ/sRoomCrestFriezeTex.i4.inc.c" -}; - -#define sRoomColumnFriezeAndCanopyTex_WIDTH 16 -#define sRoomColumnFriezeAndCanopyTex_HEIGHT 16 -static u64 sRoomColumnFriezeAndCanopyTex[TEX_LEN(u64, sRoomColumnFriezeAndCanopyTex_WIDTH, - sRoomColumnFriezeAndCanopyTex_HEIGHT, 4)] = { -#include "assets/overlays/ovl_En_Ganon_Organ/sRoomColumnFriezeAndCanopyTex.i4.inc.c" -}; - -#define sRoomColumnMetalEdgingTex_WIDTH 16 -#define sRoomColumnMetalEdgingTex_HEIGHT 16 -static u64 - sRoomColumnMetalEdgingTex[TEX_LEN(u64, sRoomColumnMetalEdgingTex_WIDTH, sRoomColumnMetalEdgingTex_HEIGHT, 16)] = { -#include "assets/overlays/ovl_En_Ganon_Organ/sRoomColumnMetalEdgingTex.rgba16.inc.c" - }; - -#define sRoomStatueWingTex_WIDTH 16 -#define sRoomStatueWingTex_HEIGHT 16 -static u64 sRoomStatueWingTex[TEX_LEN(u64, sRoomStatueWingTex_WIDTH, sRoomStatueWingTex_HEIGHT, 16)] = { -#include "assets/overlays/ovl_En_Ganon_Organ/sRoomStatueWingTex.rgba16.inc.c" -}; - -#define sRoomPillarTex_WIDTH 8 -#define sRoomPillarTex_HEIGHT 32 -static u64 sRoomPillarTex[TEX_LEN(u64, sRoomPillarTex_WIDTH, sRoomPillarTex_HEIGHT, 8)] = { -#include "assets/overlays/ovl_En_Ganon_Organ/sRoomPillarTex.i8.inc.c" -}; - -#define sRoomOrganKeyboardTex_WIDTH 32 -#define sRoomOrganKeyboardTex_HEIGHT 8 -static u64 sRoomOrganKeyboardTex[TEX_LEN(u64, sRoomOrganKeyboardTex_WIDTH, sRoomOrganKeyboardTex_HEIGHT, 16)] = { -#include "assets/overlays/ovl_En_Ganon_Organ/sRoomOrganKeyboardTex.rgba16.inc.c" -}; - -#define sRoomOrganKeyEndTex_WIDTH 4 -#define sRoomOrganKeyEndTex_HEIGHT 8 -static u64 sRoomOrganKeyEndTex[TEX_LEN(u64, sRoomOrganKeyEndTex_WIDTH, sRoomOrganKeyEndTex_HEIGHT, 16)] = { -#include "assets/overlays/ovl_En_Ganon_Organ/sRoomOrganKeyEndTex.rgba16.inc.c" -}; - -#define sRoomStepTex_WIDTH 16 -#define sRoomStepTex_HEIGHT 16 -static u64 sRoomStepTex[TEX_LEN(u64, sRoomStepTex_WIDTH, sRoomStepTex_HEIGHT, 4)] = { -#include "assets/overlays/ovl_En_Ganon_Organ/sRoomStepTex.i4.inc.c" -}; - -static Vtx sRoomOrganAndFloorVtx[] = { -#include "assets/overlays/ovl_En_Ganon_Organ/sRoomOrganAndFloorVtx.inc.c" -}; - -static Gfx sRoomOrganAndFloorDL[429] = { -#include "assets/overlays/ovl_En_Ganon_Organ/sRoomOrganAndFloorDL.inc.c" -}; - -static Vtx sRoomStatuesVtx[] = { -#include "assets/overlays/ovl_En_Ganon_Organ/sRoomStatuesVtx.inc.c" -}; - -static Gfx sRoomStatuesDL[152] = { -#include "assets/overlays/ovl_En_Ganon_Organ/sRoomStatuesDL.inc.c" -}; +#include "assets/overlays/ovl_En_Ganon_Organ/ovl_En_Ganon_Organ.c" void EnGanonOrgan_Init(Actor* thisx, PlayState* play) { thisx->flags &= ~ACTOR_FLAG_ATTENTION_ENABLED; @@ -198,9 +110,8 @@ void EnGanonOrgan_Draw(Actor* thisx, PlayState* play) { Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_NEW); MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx, "../z_en_ganon_organ.c", 221); - gSPDisplayList(POLY_OPA_DISP++, sRoomOrganAndFloorDL); - gSPDisplayList(POLY_OPA_DISP++, sRoomStatuesDL); - + gSPDisplayList(POLY_OPA_DISP++, sGanonOrgan1DL); + gSPDisplayList(POLY_OPA_DISP++, sGanonOrgan2DL); PRINTF("ORGAN DRAW 2\n"); CLOSE_DISPS(play->state.gfxCtx, "../z_en_ganon_organ.c", 230); 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 5164bbf4852..b06768b2ecd 100644 --- a/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c +++ b/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c @@ -1,9 +1,3 @@ -/* - * File: z_en_ge1.c - * Overlay: ovl_En_Ge1 - * Description: White-clothed Gerudo - */ - #include "z_en_ge1.h" #include "libu64/debug.h" @@ -14,47 +8,40 @@ #include "sfx.h" #include "stack_pad.h" #include "sys_matrix.h" -#include "terminal.h" -#include "translation.h" #include "z_lib.h" #include "face_reaction.h" #include "horse.h" #include "play_state.h" #include "player.h" #include "save.h" +#include "translation.h" #include "assets/objects/object_ge1/object_ge1.h" #define FLAGS (ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_FRIENDLY) -#define GE1_STATE_TALKING (1 << 0) -#define GE1_STATE_GIVE_QUIVER (1 << 1) -#define GE1_STATE_IDLE_ANIM (1 << 2) -#define GE1_STATE_STOP_FIDGET (1 << 3) - -typedef enum EnGe1Hairstyle { - /* 0 */ GE1_HAIR_BOB, - /* 1 */ GE1_HAIR_STRAIGHT, - /* 2 */ GE1_HAIR_SPIKY -} EnGe1Hairstyle; - 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); -s32 EnGe1_CheckAllCarpentersRescued(void); -void EnGe1_WatchForPlayerFrontOnly(EnGe1* this, PlayState* play); -void EnGe1_SetNormalText(EnGe1* this, PlayState* play); -void EnGe1_WatchForAndSensePlayer(EnGe1* this, PlayState* play); -void EnGe1_GetReaction_ValleyFloor(EnGe1* this, PlayState* play); -void EnGe1_CheckForCard_GTGGuard(EnGe1* this, PlayState* play); -void EnGe1_CheckGate_GateOp(EnGe1* this, PlayState* play); -void EnGe1_GetReaction_GateGuard(EnGe1* this, PlayState* play); -void EnGe1_TalkAfterGame_Archery(EnGe1* this, PlayState* play); -void EnGe1_Wait_Archery(EnGe1* this, PlayState* play); -void EnGe1_CueUpAnimation(EnGe1* this); -void EnGe1_StopFidget(EnGe1* this); +s32 EnGe1_AreAllCarpentersRescued(void); +void EnGe1_SentinelShortSighted(EnGe1* this, PlayState* play); +void EnGe1_OfferTalkGreet(EnGe1* this, PlayState* play); +void EnGe1_Sentinel(EnGe1* this, PlayState* play); +void EnGe1_OfferTalkGeneric(EnGe1* this, PlayState* play); +void EnGe1_GTGGatekeeper_OfferTalk(EnGe1* this, PlayState* play); +void EnGe1_WastelandGatekeeper_OfferTalk(EnGe1* this, PlayState* play); +void EnGe1_ChildEraWastelandGatekeeper_OfferTalk(EnGe1* this, PlayState* play); +void EnGe1_Archery_ChooseReward(EnGe1* this, PlayState* play); +void EnGe1_Archery_OfferTalk(EnGe1* this, PlayState* play); +void EnGe1_PlayAnimLoop(EnGe1* this); +void EnGe1_PlayAnimOnce(EnGe1* this); + +#define EN_GE1_STATE_FLAG_LOOK_AT_PLAYER (1 << 0) +#define EN_GE1_STATE_FLAG_ARCHERY_REWARD_IS_QUIVER (1 << 1) +#define EN_GE1_STATE_FLAG_ANIM_ENDED (1 << 2) +#define EN_GE1_STATE_FLAG_NO_FIDGET (1 << 3) ActorProfile En_Ge1_Profile = { /**/ ACTOR_EN_GE1, @@ -88,106 +75,109 @@ static ColliderCylinderInit sCylinderInit = { { 20, 40, 0, { 0, 0, 0 } }, }; -static Gfx* sHairstyleDLists[] = { - gGerudoWhiteHairstyleBobDL, - gGerudoWhiteHairstyleStraightFringeDL, - gGerudoWhiteHairstyleSpikyDL, +typedef enum EnGe1HairType { + EN_GE1_HAIR_TYPE_STRANDS, + EN_GE1_HAIR_TYPE_FRINGE, + EN_GE1_HAIR_TYPE_SPIKY +} EnGe1HairType; + +static Gfx* sHairDLists[3] = { + gObjectGe1HairStrandsDL, + gObjectGe1HairFringeDL, + gObjectGe1HairSpikyDL, }; -static Vec3f D_80A327A8 = { 600.0f, 700.0f, 0.0f }; +static Vec3f sFocusOffset = { 600.0f, 700.0f, 0.0f }; -static void* sEyeTextures[] = { - gGerudoWhiteEyeOpenTex, - gGerudoWhiteEyeHalfTex, - gGerudoWhiteEyeClosedTex, +static void* sEyeTextures[3] = { + gObjectGe1EyeOpenTex, + gObjectGe1EyeHalfTex, + gObjectGe1EyeClosedTex, }; void EnGe1_Init(Actor* thisx, PlayState* play) { - STACK_PAD(s32); EnGe1* this = (EnGe1*)thisx; + STACK_PAD(s32); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - SkelAnime_InitFlex(play, &this->skelAnime, &gGerudoWhiteSkel, &gGerudoWhiteIdleAnim, this->jointTable, - this->morphTable, GERUDO_WHITE_LIMB_MAX); - Animation_PlayOnce(&this->skelAnime, &gGerudoWhiteIdleAnim); + SkelAnime_InitFlex(play, &this->skelAnime, &gObjectGe1Skel, &gObjectGe1ArmsCrossedAnim, this->jointTable, + this->morphTable, OBJECT_GE1_LIMB_MAX); + Animation_PlayOnce(&this->skelAnime, &gObjectGe1ArmsCrossedAnim); Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->animation = &gGerudoWhiteIdleAnim; - this->animFunc = EnGe1_CueUpAnimation; + this->curAnim = &gObjectGe1ArmsCrossedAnim; + this->playAnimFunc = EnGe1_PlayAnimLoop; this->actor.attentionRangeType = ATTENTION_RANGE_6; Actor_SetScale(&this->actor, 0.01f); - - this->actor.cullingVolumeDistance = ((play->sceneId == SCENE_GERUDO_VALLEY) ? 1000.0f : 1200.0f); + if (play->sceneId == SCENE_GERUDO_VALLEY) { + this->actor.cullingVolumeDistance = 1000.0f; + } else { + this->actor.cullingVolumeDistance = 1200.0f; + } switch (PARAMS_GET_U(this->actor.params, 0, 8)) { - - case GE1_TYPE_GATE_GUARD: - this->hairstyle = GE1_HAIR_SPIKY; - this->actionFunc = EnGe1_GetReaction_GateGuard; + case EN_GE1_TYPE_CHILD_ERA_WASTELAND_GATEKEEPER: + this->hairType = EN_GE1_HAIR_TYPE_SPIKY; + this->actionFunc = EnGe1_ChildEraWastelandGatekeeper_OfferTalk; break; - case GE1_TYPE_GATE_OPERATOR: - this->hairstyle = GE1_HAIR_STRAIGHT; - - if (EnGe1_CheckAllCarpentersRescued()) { - this->actionFunc = EnGe1_CheckGate_GateOp; + case EN_GE1_TYPE_WASTELAND_GATEKEEPER: + this->hairType = EN_GE1_HAIR_TYPE_FRINGE; + if (EnGe1_AreAllCarpentersRescued()) { + this->actionFunc = EnGe1_WastelandGatekeeper_OfferTalk; } else { - this->actionFunc = EnGe1_WatchForPlayerFrontOnly; + this->actionFunc = EnGe1_SentinelShortSighted; } break; - case GE1_TYPE_NORMAL: - this->hairstyle = GE1_HAIR_STRAIGHT; - - if (EnGe1_CheckAllCarpentersRescued()) { - this->actionFunc = EnGe1_SetNormalText; + case EN_GE1_TYPE_SENTINEL: + this->hairType = EN_GE1_HAIR_TYPE_FRINGE; + if (EnGe1_AreAllCarpentersRescued()) { + this->actionFunc = EnGe1_OfferTalkGreet; } else { - this->actionFunc = EnGe1_WatchForAndSensePlayer; + this->actionFunc = EnGe1_Sentinel; } break; - case GE1_TYPE_VALLEY_FLOOR: + case EN_GE1_TYPE_5: if (LINK_IS_ADULT) { - PRINTF(VT_FGCOL(CYAN) T("谷底 ゲルド 撤退 \n", "Valley floor Gerudo withdrawal \n") VT_RST); + PRINTF(VT_FGCOL(CYAN) T("谷底 ゲルド 撤退 \n", "Retreat from the Gerudo canyon floor \n") VT_RST); Actor_Kill(&this->actor); return; } - this->hairstyle = GE1_HAIR_BOB; - this->actionFunc = EnGe1_GetReaction_ValleyFloor; + this->hairType = EN_GE1_HAIR_TYPE_STRANDS; + this->actionFunc = EnGe1_OfferTalkGeneric; break; - case GE1_TYPE_HORSEBACK_ARCHERY: - if (INV_CONTENT(SLOT_BOW) == ITEM_NONE) { + case EN_GE1_TYPE_HORSEBACK_ARCHERY: + if (INV_CONTENT(ITEM_BOW) == ITEM_NONE) { Actor_Kill(&this->actor); return; } this->actor.attentionRangeType = ATTENTION_RANGE_3; - this->hairstyle = GE1_HAIR_BOB; + this->hairType = EN_GE1_HAIR_TYPE_STRANDS; PRINTF(VT_FGCOL(CYAN) - T("やぶさめ ゲルド EVENT_INF(0) = %x\n", "Horseback archery Gerudo EVENT_INF(0) = %x\n") VT_RST, + T("やぶさめ ゲルド EVENT_INF(0) = %x\n", "Gerudo horseback archery EVENT_INF(0) = %x\n") VT_RST, gSaveContext.eventInf[0]); - if (GET_EVENTINF(EVENTINF_HORSES_08)) { - this->actionFunc = EnGe1_TalkAfterGame_Archery; - } else if (EnGe1_CheckAllCarpentersRescued()) { - this->actionFunc = EnGe1_Wait_Archery; + this->actionFunc = EnGe1_Archery_ChooseReward; + } else if (EnGe1_AreAllCarpentersRescued()) { + this->actionFunc = EnGe1_Archery_OfferTalk; } else { - this->actionFunc = EnGe1_WatchForPlayerFrontOnly; + this->actionFunc = EnGe1_SentinelShortSighted; } break; - case GE1_TYPE_TRAINING_GROUNDS_GUARD: - this->hairstyle = GE1_HAIR_STRAIGHT; - - if (EnGe1_CheckAllCarpentersRescued()) { - this->actionFunc = EnGe1_CheckForCard_GTGGuard; + case EN_GE1_TYPE_GTG_GATEKEEPER: + this->hairType = EN_GE1_HAIR_TYPE_FRINGE; + if (EnGe1_AreAllCarpentersRescued()) { + this->actionFunc = EnGe1_GTGGatekeeper_OfferTalk; } else { - this->actionFunc = EnGe1_WatchForPlayerFrontOnly; + this->actionFunc = EnGe1_SentinelShortSighted; } break; } - this->stateFlags = 0; } @@ -197,400 +187,371 @@ void EnGe1_Destroy(Actor* thisx, PlayState* play) { Collider_DestroyCylinder(play, &this->collider); } -s32 EnGe1_SetTalkAction(EnGe1* this, PlayState* play, u16 textId, f32 arg3, EnGe1ActionFunc actionFunc) { +s32 EnGe1_OfferTalk(EnGe1* this, PlayState* play, u16 textId, f32 range, EnGe1ActionFunc actionFunc) { if (Actor_TalkOfferAccepted(&this->actor, play)) { this->actionFunc = actionFunc; - this->animFunc = EnGe1_StopFidget; - this->stateFlags &= ~GE1_STATE_IDLE_ANIM; - this->animation = &gGerudoWhiteIdleAnim; - Animation_Change(&this->skelAnime, &gGerudoWhiteIdleAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gGerudoWhiteIdleAnim), ANIMMODE_ONCE, -8.0f); + this->playAnimFunc = EnGe1_PlayAnimOnce; + this->stateFlags &= ~EN_GE1_STATE_FLAG_ANIM_ENDED; + this->curAnim = &gObjectGe1ArmsCrossedAnim; + Animation_Change(&this->skelAnime, &gObjectGe1ArmsCrossedAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gObjectGe1ArmsCrossedAnim), ANIMMODE_ONCE, -8.0f); return true; + } else { + this->actor.textId = textId; + if (this->actor.xzDistToPlayer < range) { + Actor_OfferTalk(&this->actor, play, range); + } + return false; } - - this->actor.textId = textId; - - if (this->actor.xzDistToPlayer < arg3) { - Actor_OfferTalk(&this->actor, play, arg3); - } - - return false; } -void EnGe1_SetAnimationIdle(EnGe1* this) { - Animation_Change(&this->skelAnime, &gGerudoWhiteIdleAnim, -1.0f, Animation_GetLastFrame(&gGerudoWhiteIdleAnim), - 0.0f, ANIMMODE_ONCE, 8.0f); - this->animation = &gGerudoWhiteIdleAnim; - this->animFunc = EnGe1_CueUpAnimation; +void EnGe1_ChangeAnimArmsCrossed(EnGe1* this) { + Animation_Change(&this->skelAnime, &gObjectGe1ArmsCrossedAnim, -1.0f, + Animation_GetLastFrame(&gObjectGe1ArmsCrossedAnim), 0.0f, ANIMMODE_ONCE, 8.0f); + this->curAnim = &gObjectGe1ArmsCrossedAnim; + this->playAnimFunc = EnGe1_PlayAnimLoop; } -s32 EnGe1_CheckAllCarpentersRescued(void) { +s32 EnGe1_AreAllCarpentersRescued(void) { if (!(GET_EVENTCHKINF(EVENTCHKINF_CARPENTER_0_RESCUED) && GET_EVENTCHKINF(EVENTCHKINF_CARPENTER_1_RESCUED) && GET_EVENTCHKINF(EVENTCHKINF_CARPENTER_2_RESCUED) && GET_EVENTCHKINF(EVENTCHKINF_CARPENTER_3_RESCUED))) { return false; + } else { + return true; } - return true; } -/** - * Sends player to different places depending on if has hookshot, and if this is the first time captured - */ -void EnGe1_KickPlayer(EnGe1* this, PlayState* play) { - this->stateFlags |= GE1_STATE_TALKING; - - if (this->cutsceneTimer > 0) { - this->cutsceneTimer--; +void EnGe1_PlayerCaught(EnGe1* this, PlayState* play) { + this->stateFlags |= EN_GE1_STATE_FLAG_LOOK_AT_PLAYER; + if (this->timer > 0) { + this->timer--; } else { Horse_ResetHorseData(play); - if ((INV_CONTENT(ITEM_HOOKSHOT) == ITEM_NONE) || (INV_CONTENT(ITEM_LONGSHOT) == ITEM_NONE)) { play->nextEntranceIndex = ENTR_GERUDO_VALLEY_1; - } else if (GET_EVENTCHKINF(EVENTCHKINF_GERUDO_CAUGHT_TOWER_FALL)) { // Caught previously + } else if (GET_EVENTCHKINF(EVENTCHKINF_GERUDO_CAUGHT_TOWER_FALL)) { play->nextEntranceIndex = ENTR_GERUDOS_FORTRESS_18; } else { play->nextEntranceIndex = ENTR_GERUDOS_FORTRESS_17; } - play->transitionType = TRANS_TYPE_CIRCLE(TCA_STARBURST, TCC_BLACK, TCS_FAST); play->transitionTrigger = TRANS_TRIGGER_START; } } -void EnGe1_SpotPlayer(EnGe1* this, PlayState* play) { - this->cutsceneTimer = 30; - this->actionFunc = EnGe1_KickPlayer; +void EnGe1_SetupPlayerCaught(EnGe1* this, PlayState* play) { + this->timer = 30; + this->actionFunc = EnGe1_PlayerCaught; Player_SetCsActionWithHaltedActors(play, &this->actor, PLAYER_CSACTION_95); Sfx_PlaySfxCentered(NA_SE_SY_FOUND); Message_StartTextbox(play, 0x6000, &this->actor); } -void EnGe1_WatchForPlayerFrontOnly(EnGe1* this, PlayState* play) { - s16 angleDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; +void EnGe1_SentinelShortSighted(EnGe1* this, PlayState* play) { + s16 relYawTowardsPlayer = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if ((ABS(angleDiff) <= 0x4300) && (this->actor.xzDistToPlayer < 100.0f)) { - EnGe1_SpotPlayer(this, play); + if ((ABS(relYawTowardsPlayer) <= 0x4300) && (this->actor.xzDistToPlayer < 100.0f)) { + EnGe1_SetupPlayerCaught(this, play); } - if (this->collider.base.acFlags & AC_HIT) { - EnGe1_SpotPlayer(this, play); + EnGe1_SetupPlayerCaught(this, play); } - CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } -void EnGe1_ChooseActionFromTextId(EnGe1* this, PlayState* play) { - this->stateFlags |= GE1_STATE_TALKING; +void EnGe1_WaitTalkEnd(EnGe1* this, PlayState* play) { + this->stateFlags |= EN_GE1_STATE_FLAG_LOOK_AT_PLAYER; if (Actor_TextboxIsClosing(&this->actor, play)) { switch (this->actor.textId) { case 0x6001: - this->actionFunc = EnGe1_SetNormalText; + this->actionFunc = EnGe1_OfferTalkGreet; break; - case 0x601A: case 0x6019: - this->actionFunc = EnGe1_GetReaction_ValleyFloor; + case 0x601A: + this->actionFunc = EnGe1_OfferTalkGeneric; break; case 0x6018: - this->actionFunc = EnGe1_CheckGate_GateOp; + this->actionFunc = EnGe1_WastelandGatekeeper_OfferTalk; break; default: - this->actionFunc = EnGe1_GetReaction_ValleyFloor; + this->actionFunc = EnGe1_OfferTalkGeneric; break; } } } -void EnGe1_SetNormalText(EnGe1* this, PlayState* play) { - EnGe1_SetTalkAction(this, play, 0x6001, 100.0f, EnGe1_ChooseActionFromTextId); +void EnGe1_OfferTalkGreet(EnGe1* this, PlayState* play) { + EnGe1_OfferTalk(this, play, 0x6001, 100.0f, EnGe1_WaitTalkEnd); } -void EnGe1_WatchForAndSensePlayer(EnGe1* this, PlayState* play) { - s16 angleDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; +void EnGe1_Sentinel(EnGe1* this, PlayState* play) { + s16 relYawTowardsPlayer = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if ((this->actor.xzDistToPlayer < 50.0f) || ((ABS(angleDiff) <= 0x4300) && (this->actor.xzDistToPlayer < 400.0f))) { - EnGe1_SpotPlayer(this, play); + if ((this->actor.xzDistToPlayer < 50.0f) || + ((ABS(relYawTowardsPlayer) <= 0x4300) && (this->actor.xzDistToPlayer < 400.0f))) { + EnGe1_SetupPlayerCaught(this, play); } - if (this->collider.base.acFlags & AC_HIT) { - EnGe1_SpotPlayer(this, play); + EnGe1_SetupPlayerCaught(this, play); } CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } -void EnGe1_GetReaction_ValleyFloor(EnGe1* this, PlayState* play) { +void EnGe1_OfferTalkGeneric(EnGe1* this, PlayState* play) { u16 textId = MaskReaction_GetTextId(play, MASK_REACTION_SET_GERUDO_WHITE); if (textId == 0) { textId = 0x6019; } - - EnGe1_SetTalkAction(this, play, textId, 100.0f, EnGe1_ChooseActionFromTextId); + EnGe1_OfferTalk(this, play, textId, 100.0f, EnGe1_WaitTalkEnd); } -// Gerudo Training Ground Guard functions - -void EnGe1_WaitTillOpened_GTGGuard(EnGe1* this, PlayState* play) { - if (this->cutsceneTimer > 0) { - this->cutsceneTimer--; +void EnGe1_GTGDoorkeeper_WaitGateOpen(EnGe1* this, PlayState* play) { + if (this->timer > 0) { + this->timer--; } else { - EnGe1_SetAnimationIdle(this); - this->actionFunc = EnGe1_SetNormalText; + EnGe1_ChangeAnimArmsCrossed(this); + this->actionFunc = EnGe1_OfferTalkGreet; } - - this->stateFlags |= GE1_STATE_STOP_FIDGET; + this->stateFlags |= EN_GE1_STATE_FLAG_NO_FIDGET; } -void EnGe1_Open_GTGGuard(EnGe1* this, PlayState* play) { - if (this->stateFlags & GE1_STATE_IDLE_ANIM) { - this->actionFunc = EnGe1_WaitTillOpened_GTGGuard; +void EnGe1_GTGGatekeeper_OpenGate(EnGe1* this, PlayState* play) { + if (this->stateFlags & EN_GE1_STATE_FLAG_ANIM_ENDED) { + this->actionFunc = EnGe1_GTGDoorkeeper_WaitGateOpen; Flags_SetSwitch(play, PARAMS_GET_U(this->actor.params, 8, 6)); - this->cutsceneTimer = 50; + this->timer = 50; Message_CloseTextbox(play); } else if ((this->skelAnime.curFrame == 15.0f) || (this->skelAnime.curFrame == 19.0f)) { Actor_PlaySfx(&this->actor, NA_SE_IT_HAND_CLAP); } } -void EnGe1_SetupOpen_GTGGuard(EnGe1* this, PlayState* play) { +void EnGe1_GTGGatekeeper_WaitTalkEndOpenGate(EnGe1* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(play)) { - this->actionFunc = EnGe1_Open_GTGGuard; - Animation_Change(&this->skelAnime, &gGerudoWhiteClapAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gGerudoWhiteClapAnim), ANIMMODE_ONCE, -3.0f); - this->animation = &gGerudoWhiteClapAnim; - this->animFunc = EnGe1_StopFidget; - this->stateFlags &= ~GE1_STATE_IDLE_ANIM; + this->actionFunc = EnGe1_GTGGatekeeper_OpenGate; + Animation_Change(&this->skelAnime, &gObjectGe1ClapHandsAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gObjectGe1ClapHandsAnim), ANIMMODE_ONCE, -3.0f); + this->curAnim = &gObjectGe1ClapHandsAnim; + this->playAnimFunc = EnGe1_PlayAnimOnce; + this->stateFlags &= ~EN_GE1_STATE_FLAG_ANIM_ENDED; } } -void EnGe1_RefuseEntryTooPoor_GTGGuard(EnGe1* this, PlayState* play) { +void EnGe1_GTGGatekeeper_WaitTalkEnd(EnGe1* this, PlayState* play) { if (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) { - this->actionFunc = EnGe1_CheckForCard_GTGGuard; - EnGe1_SetAnimationIdle(this); + this->actionFunc = EnGe1_GTGGatekeeper_OfferTalk; + EnGe1_ChangeAnimArmsCrossed(this); } } -void EnGe1_OfferOpen_GTGGuard(EnGe1* this, PlayState* play) { - this->stateFlags |= GE1_STATE_TALKING; +void EnGe1_GTGGatekeeper_WaitAnswer(EnGe1* this, PlayState* play) { + this->stateFlags |= EN_GE1_STATE_FLAG_LOOK_AT_PLAYER; if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { Message_CloseTextbox(play); - switch (play->msgCtx.choiceIndex) { case 0: if (gSaveContext.save.info.playerData.rupees < 10) { Message_ContinueTextbox(play, 0x6016); - this->actionFunc = EnGe1_RefuseEntryTooPoor_GTGGuard; + this->actionFunc = EnGe1_GTGGatekeeper_WaitTalkEnd; } else { Rupees_ChangeBy(-10); Message_ContinueTextbox(play, 0x6015); - this->actionFunc = EnGe1_SetupOpen_GTGGuard; + this->actionFunc = EnGe1_GTGGatekeeper_WaitTalkEndOpenGate; } break; + case 1: - this->actionFunc = EnGe1_CheckForCard_GTGGuard; - EnGe1_SetAnimationIdle(this); + this->actionFunc = EnGe1_GTGGatekeeper_OfferTalk; + EnGe1_ChangeAnimArmsCrossed(this); break; } } } -void EnGe1_RefuseOpenNoCard_GTGGuard(EnGe1* this, PlayState* play) { - this->stateFlags |= GE1_STATE_TALKING; +void EnGe1_GTGGatekeeper_TalkNoCard(EnGe1* this, PlayState* play) { + this->stateFlags |= EN_GE1_STATE_FLAG_LOOK_AT_PLAYER; + if (Actor_TextboxIsClosing(&this->actor, play)) { - this->actionFunc = EnGe1_CheckForCard_GTGGuard; - EnGe1_SetAnimationIdle(this); + this->actionFunc = EnGe1_GTGGatekeeper_OfferTalk; + EnGe1_ChangeAnimArmsCrossed(this); } } -void EnGe1_CheckForCard_GTGGuard(EnGe1* this, PlayState* play) { +void EnGe1_GTGGatekeeper_OfferTalk(EnGe1* this, PlayState* play) { if (CHECK_QUEST_ITEM(QUEST_GERUDOS_CARD)) { - EnGe1_SetTalkAction(this, play, 0x6014, 100.0f, EnGe1_OfferOpen_GTGGuard); + EnGe1_OfferTalk(this, play, 0x6014, 100.0f, EnGe1_GTGGatekeeper_WaitAnswer); } else { - //! @bug This outcome is inaccessible in normal gameplay since this function it is unreachable without - //! obtaining the card in the first place. - EnGe1_SetTalkAction(this, play, 0x6013, 100.0f, EnGe1_RefuseOpenNoCard_GTGGuard); + EnGe1_OfferTalk(this, play, 0x6013, 100.0f, EnGe1_GTGGatekeeper_TalkNoCard); } } -// Gate Operator functions - -void EnGe1_WaitGateOpen_GateOp(EnGe1* this, PlayState* play) { - this->stateFlags |= GE1_STATE_TALKING; - +void EnGe1_WastelandGatekeeper_WaitTalkEnd(EnGe1* this, PlayState* play) { + this->stateFlags |= EN_GE1_STATE_FLAG_LOOK_AT_PLAYER; if ((Message_GetState(&play->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(play)) { Message_CloseTextbox(play); - this->actionFunc = EnGe1_CheckGate_GateOp; - EnGe1_SetAnimationIdle(this); + this->actionFunc = EnGe1_WastelandGatekeeper_OfferTalk; + EnGe1_ChangeAnimArmsCrossed(this); } } -void EnGe1_WaitUntilGateOpened_GateOp(EnGe1* this, PlayState* play) { - if (this->cutsceneTimer > 0) { - this->cutsceneTimer--; +void EnGe1_WastelandGatekeeper_WaitGateOpen(EnGe1* this, PlayState* play) { + if (this->timer > 0) { + this->timer--; } else { - EnGe1_SetAnimationIdle(this); - this->actionFunc = EnGe1_CheckGate_GateOp; + EnGe1_ChangeAnimArmsCrossed(this); + this->actionFunc = EnGe1_WastelandGatekeeper_OfferTalk; } - this->stateFlags |= GE1_STATE_STOP_FIDGET; + this->stateFlags |= EN_GE1_STATE_FLAG_NO_FIDGET; } -void EnGe1_OpenGate_GateOp(EnGe1* this, PlayState* play) { - if (this->stateFlags & GE1_STATE_IDLE_ANIM) { - this->actionFunc = EnGe1_WaitUntilGateOpened_GateOp; +void EnGe1_WastelandGatekeeper_OpenGate(EnGe1* this, PlayState* play) { + if (this->stateFlags & EN_GE1_STATE_FLAG_ANIM_ENDED) { + this->actionFunc = EnGe1_WastelandGatekeeper_WaitGateOpen; Flags_SetSwitch(play, PARAMS_GET_U(this->actor.params, 8, 6)); - this->cutsceneTimer = 50; + this->timer = 50; Message_CloseTextbox(play); } else if ((this->skelAnime.curFrame == 15.0f) || (this->skelAnime.curFrame == 19.0f)) { Actor_PlaySfx(&this->actor, NA_SE_IT_HAND_CLAP); } } -void EnGe1_SetupOpenGate_GateOp(EnGe1* this, PlayState* play) { - this->stateFlags |= GE1_STATE_TALKING; - +void EnGe1_WastelandGatekeeper_WaitTalkEndOpenGate(EnGe1* this, PlayState* play) { + this->stateFlags |= EN_GE1_STATE_FLAG_LOOK_AT_PLAYER; if ((Message_GetState(&play->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(play)) { - this->actionFunc = EnGe1_OpenGate_GateOp; - Animation_Change(&this->skelAnime, &gGerudoWhiteClapAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gGerudoWhiteClapAnim), ANIMMODE_ONCE, -3.0f); - this->animation = &gGerudoWhiteClapAnim; - this->animFunc = EnGe1_StopFidget; - this->stateFlags &= ~GE1_STATE_IDLE_ANIM; + this->actionFunc = EnGe1_WastelandGatekeeper_OpenGate; + Animation_Change(&this->skelAnime, &gObjectGe1ClapHandsAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gObjectGe1ClapHandsAnim), ANIMMODE_ONCE, -3.0f); + this->curAnim = &gObjectGe1ClapHandsAnim; + this->playAnimFunc = EnGe1_PlayAnimOnce; + this->stateFlags &= ~EN_GE1_STATE_FLAG_ANIM_ENDED; } } -void EnGe1_CheckGate_GateOp(EnGe1* this, PlayState* play) { +void EnGe1_WastelandGatekeeper_OfferTalk(EnGe1* this, PlayState* play) { if (Flags_GetSwitch(play, PARAMS_GET_U(this->actor.params, 8, 6))) { - EnGe1_SetTalkAction(this, play, 0x6018, 100.0f, EnGe1_WaitGateOpen_GateOp); + EnGe1_OfferTalk(this, play, 0x6018, 100.0f, EnGe1_WastelandGatekeeper_WaitTalkEnd); } else { - EnGe1_SetTalkAction(this, play, 0x6017, 100.0f, EnGe1_SetupOpenGate_GateOp); + EnGe1_OfferTalk(this, play, 0x6017, 100.0f, EnGe1_WastelandGatekeeper_WaitTalkEndOpenGate); } } -// Gate guard functions - -void EnGe1_Talk_GateGuard(EnGe1* this, PlayState* play) { - this->stateFlags |= GE1_STATE_TALKING; +void EnGe1_ChildEraWastelandGatekeeper_WaitTalkEnd(EnGe1* this, PlayState* play) { + this->stateFlags |= EN_GE1_STATE_FLAG_LOOK_AT_PLAYER; if (Actor_TextboxIsClosing(&this->actor, play)) { - this->actionFunc = EnGe1_GetReaction_GateGuard; - EnGe1_SetAnimationIdle(this); + this->actionFunc = EnGe1_ChildEraWastelandGatekeeper_OfferTalk; + EnGe1_ChangeAnimArmsCrossed(this); } } -void EnGe1_GetReaction_GateGuard(EnGe1* this, PlayState* play) { +void EnGe1_ChildEraWastelandGatekeeper_OfferTalk(EnGe1* this, PlayState* play) { u16 textId = MaskReaction_GetTextId(play, MASK_REACTION_SET_GERUDO_WHITE); if (textId == 0) { textId = 0x6069; } - - if (EnGe1_SetTalkAction(this, play, textId, 100.0f, EnGe1_Talk_GateGuard)) { - this->animFunc = EnGe1_CueUpAnimation; - this->animation = &gGerudoWhiteDismissiveAnim; - Animation_Change(&this->skelAnime, &gGerudoWhiteDismissiveAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gGerudoWhiteDismissiveAnim), ANIMMODE_ONCE, -8.0f); + if (EnGe1_OfferTalk(this, play, textId, 100.0f, EnGe1_ChildEraWastelandGatekeeper_WaitTalkEnd)) { + this->playAnimFunc = EnGe1_PlayAnimLoop; + this->curAnim = &gObjectGe1ShooAwayAnim; + Animation_Change(&this->skelAnime, &gObjectGe1ShooAwayAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gObjectGe1ShooAwayAnim), ANIMMODE_ONCE, -8.0f); } } -// Archery functions - -void EnGe1_SetupWait_Archery(EnGe1* this, PlayState* play) { +void EnGe1_Archery_RewardWaitTalkEnd(EnGe1* this, PlayState* play) { if (Actor_TextboxIsClosing(&this->actor, play)) { - this->actionFunc = EnGe1_Wait_Archery; - EnGe1_SetAnimationIdle(this); + this->actionFunc = EnGe1_Archery_OfferTalk; + EnGe1_ChangeAnimArmsCrossed(this); } } -void EnGe1_WaitTillItemGiven_Archery(EnGe1* this, PlayState* play) { - s32 getItemId; +void EnGe1_Archery_GiveReward(EnGe1* this, PlayState* play) { + s32 giReward; if (Actor_HasParent(&this->actor, play)) { - this->actionFunc = EnGe1_SetupWait_Archery; - if (this->stateFlags & GE1_STATE_GIVE_QUIVER) { - SET_ITEMGETINF(ITEMGETINF_0F); + this->actionFunc = EnGe1_Archery_RewardWaitTalkEnd; + if (this->stateFlags & EN_GE1_STATE_FLAG_ARCHERY_REWARD_IS_QUIVER) { + SET_ITEMGETINF(ITEMGETINF_HORSEBACK_ARCHERY_QUIVER); } else { - SET_INFTABLE(INFTABLE_190); + SET_INFTABLE(INFTABLE_HORSEBACK_ARCHERY_GOT_HEART_PIECE); } - } else { - if (this->stateFlags & GE1_STATE_GIVE_QUIVER) { - switch (CUR_UPG_VALUE(UPG_QUIVER)) { - //! @bug Asschest. See next function for details - case 1: - getItemId = GI_QUIVER_40; - break; - case 2: - getItemId = GI_QUIVER_50; - break; - } - } else { - getItemId = GI_HEART_PIECE; + return; + } + if (this->stateFlags & EN_GE1_STATE_FLAG_ARCHERY_REWARD_IS_QUIVER) { + switch (CUR_UPG_VALUE(UPG_QUIVER)) { + case 1: + giReward = GI_QUIVER_40; + break; + case 2: + giReward = GI_QUIVER_50; + break; } - Actor_OfferGetItem(&this->actor, play, getItemId, 10000.0f, 50.0f); + } else { + giReward = GI_HEART_PIECE; } + //! @bug giReward may be used uninitialized + Actor_OfferGetItem(&this->actor, play, giReward, 10000.0f, 50.0f); } -void EnGe1_BeginGiveItem_Archery(EnGe1* this, PlayState* play) { - s32 getItemId; +void EnGe1_Archery_WaitTalkEndGiveReward(EnGe1* this, PlayState* play) { + s32 giReward; if (Actor_TextboxIsClosing(&this->actor, play)) { this->actor.flags &= ~ACTOR_FLAG_TALK_OFFER_AUTO_ACCEPTED; - this->actionFunc = EnGe1_WaitTillItemGiven_Archery; + this->actionFunc = EnGe1_Archery_GiveReward; } - - if (this->stateFlags & GE1_STATE_GIVE_QUIVER) { + if (this->stateFlags & EN_GE1_STATE_FLAG_ARCHERY_REWARD_IS_QUIVER) { switch (CUR_UPG_VALUE(UPG_QUIVER)) { - //! @bug Asschest: the compiler inserts a default assigning *(sp+0x24) to getItemId, which is junk data left - //! over from the previous function run in EnGe1_Update, namely EnGe1_CueUpAnimation. The top stack variable - //! in that function is &this->skelAnime = thisx + 198, and depending on where this loads in memory, the - //! getItemId changes. case 1: - getItemId = GI_QUIVER_40; + giReward = GI_QUIVER_40; break; case 2: - getItemId = GI_QUIVER_50; + giReward = GI_QUIVER_50; break; } } else { - getItemId = GI_HEART_PIECE; + giReward = GI_HEART_PIECE; } - - Actor_OfferGetItem(&this->actor, play, getItemId, 10000.0f, 50.0f); + //! @bug giReward may be used uninitialized + Actor_OfferGetItem(&this->actor, play, giReward, 10000.0f, 50.0f); } -void EnGe1_TalkWinPrize_Archery(EnGe1* this, PlayState* play) { +void EnGe1_Archery_TalkGiveReward(EnGe1* this, PlayState* play) { if (Actor_TalkOfferAccepted(&this->actor, play)) { - this->actionFunc = EnGe1_BeginGiveItem_Archery; + this->actionFunc = EnGe1_Archery_WaitTalkEndGiveReward; this->actor.flags &= ~ACTOR_FLAG_TALK_OFFER_AUTO_ACCEPTED; } else { Actor_OfferTalk(&this->actor, play, 200.0f); } } -void EnGe1_TalkTooPoor_Archery(EnGe1* this, PlayState* play) { +void EnGe1_Archery_NotEnoughRupeesWaitTalkEnd(EnGe1* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(play)) { Message_CloseTextbox(play); - this->actionFunc = EnGe1_Wait_Archery; - EnGe1_SetAnimationIdle(this); + this->actionFunc = EnGe1_Archery_OfferTalk; + EnGe1_ChangeAnimArmsCrossed(this); } } -void EnGe1_WaitDoNothing(EnGe1* this, PlayState* play) { +void EnGe1_DoNothing(EnGe1* this, PlayState* play) { } -void EnGe1_BeginGame_Archery(EnGe1* this, PlayState* play) { +void EnGe1_Archery_WaitAnswer(EnGe1* this, PlayState* play) { Player* player = GET_PLAYER(play); - Actor* horse; + Actor* epona; if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { this->actor.flags &= ~ACTOR_FLAG_TALK_OFFER_AUTO_ACCEPTED; - switch (play->msgCtx.choiceIndex) { case 0: if (gSaveContext.save.info.playerData.rupees < 20) { Message_ContinueTextbox(play, 0x85); - this->actionFunc = EnGe1_TalkTooPoor_Archery; + this->actionFunc = EnGe1_Archery_NotEnoughRupeesWaitTalkEnd; } else { Rupees_ChangeBy(-20); play->nextEntranceIndex = ENTR_GERUDOS_FORTRESS_0; @@ -598,95 +559,93 @@ void EnGe1_BeginGame_Archery(EnGe1* this, PlayState* play) { play->transitionType = TRANS_TYPE_CIRCLE(TCA_STARBURST, TCC_BLACK, TCS_FAST); play->transitionTrigger = TRANS_TRIGGER_START; SET_EVENTINF(EVENTINF_HORSES_08); - SET_EVENTCHKINF(EVENTCHKINF_68); - + SET_EVENTCHKINF(EVENTCHKINF_HORSEBACK_ARCHERY_EXPLAINED); if (!(player->stateFlags1 & PLAYER_STATE1_23)) { Player_SetCsActionWithHaltedActors(play, &this->actor, PLAYER_CSACTION_1); } else { - horse = Actor_FindNearby(play, &player->actor, ACTOR_EN_HORSE, ACTORCAT_BG, 1200.0f); + epona = Actor_FindNearby(play, &player->actor, ACTOR_EN_HORSE, ACTORCAT_BG, 1200.0f); player->actor.freezeTimer = 1200; - - if (horse != NULL) { - horse->freezeTimer = 1200; + if (epona != NULL) { + epona->freezeTimer = 1200; } } - - this->actionFunc = EnGe1_WaitDoNothing; + this->actionFunc = EnGe1_DoNothing; } break; case 1: - this->actionFunc = EnGe1_Wait_Archery; + this->actionFunc = EnGe1_Archery_OfferTalk; Message_CloseTextbox(play); break; } } } -void EnGe1_TalkOfferPlay_Archery(EnGe1* this, PlayState* play) { +void EnGe1_Archery_AskToPlay(EnGe1* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(play)) { Message_ContinueTextbox(play, 0x6041); - this->actionFunc = EnGe1_BeginGame_Archery; + this->actionFunc = EnGe1_Archery_WaitAnswer; } } -void EnGe1_TalkNoPrize_Archery(EnGe1* this, PlayState* play) { +void EnGe1_Archery_NoReward(EnGe1* this, PlayState* play) { if (Actor_TalkOfferAccepted(&this->actor, play)) { - this->actionFunc = EnGe1_TalkOfferPlay_Archery; + this->actionFunc = EnGe1_Archery_AskToPlay; } else { Actor_OfferTalk(&this->actor, play, 300.0f); } } -void EnGe1_TalkAfterGame_Archery(EnGe1* this, PlayState* play) { +void EnGe1_Archery_ChooseReward(EnGe1* this, PlayState* play) { CLEAR_EVENTINF(EVENTINF_HORSES_08); + LOG_NUM("z_common_data.yabusame_total", gSaveContext.minigameScore, "../z_en_ge1.c", 1110); // With the current `SaveContext` struct definition, the expression in the debug string is an out-of-bounds read, // see the other occurrence of this for more details. LOG_NUM("z_common_data.memory.information.room_inf[127][ 0 ]", HIGH_SCORE(HS_HBA), "../z_en_ge1.c", 1111); - this->actor.flags |= ACTOR_FLAG_TALK_OFFER_AUTO_ACCEPTED; + this->actor.flags |= ACTOR_FLAG_TALK_OFFER_AUTO_ACCEPTED; if (HIGH_SCORE(HS_HBA) < gSaveContext.minigameScore) { HIGH_SCORE(HS_HBA) = gSaveContext.minigameScore; } - if (gSaveContext.minigameScore < 1000) { this->actor.textId = 0x6045; - this->actionFunc = EnGe1_TalkNoPrize_Archery; - } else if (!GET_INFTABLE(INFTABLE_190)) { + this->actionFunc = EnGe1_Archery_NoReward; + } else if (!GET_INFTABLE(INFTABLE_HORSEBACK_ARCHERY_GOT_HEART_PIECE)) { this->actor.textId = 0x6046; - this->actionFunc = EnGe1_TalkWinPrize_Archery; - this->stateFlags &= ~GE1_STATE_GIVE_QUIVER; + this->actionFunc = EnGe1_Archery_TalkGiveReward; + this->stateFlags &= ~EN_GE1_STATE_FLAG_ARCHERY_REWARD_IS_QUIVER; } else if (gSaveContext.minigameScore < 1500) { this->actor.textId = 0x6047; - this->actionFunc = EnGe1_TalkNoPrize_Archery; - } else if (GET_ITEMGETINF(ITEMGETINF_0F)) { + this->actionFunc = EnGe1_Archery_NoReward; + } else if (GET_ITEMGETINF(ITEMGETINF_HORSEBACK_ARCHERY_QUIVER)) { this->actor.textId = 0x6047; - this->actionFunc = EnGe1_TalkNoPrize_Archery; + this->actionFunc = EnGe1_Archery_NoReward; } else { this->actor.textId = 0x6044; - this->actionFunc = EnGe1_TalkWinPrize_Archery; - this->stateFlags |= GE1_STATE_GIVE_QUIVER; + this->actionFunc = EnGe1_Archery_TalkGiveReward; + this->stateFlags |= EN_GE1_STATE_FLAG_ARCHERY_REWARD_IS_QUIVER; } } -void EnGe1_TalkNoHorse_Archery(EnGe1* this, PlayState* play) { - this->stateFlags |= GE1_STATE_TALKING; +void EnGe1_Archery_NoHorseWaitTalkEnd(EnGe1* this, PlayState* play) { + this->stateFlags |= EN_GE1_STATE_FLAG_LOOK_AT_PLAYER; + if (Actor_TextboxIsClosing(&this->actor, play)) { - this->actionFunc = EnGe1_Wait_Archery; - EnGe1_SetAnimationIdle(this); + this->actionFunc = EnGe1_Archery_OfferTalk; + EnGe1_ChangeAnimArmsCrossed(this); } } -void EnGe1_Wait_Archery(EnGe1* this, PlayState* play) { +void EnGe1_Archery_OfferTalk(EnGe1* this, PlayState* play) { Player* player = GET_PLAYER(play); u16 textId; if (!(player->stateFlags1 & PLAYER_STATE1_23)) { - EnGe1_SetTalkAction(this, play, 0x603F, 100.0f, EnGe1_TalkNoHorse_Archery); + EnGe1_OfferTalk(this, play, 0x603F, 100.0f, EnGe1_Archery_NoHorseWaitTalkEnd); } else { - if (GET_EVENTCHKINF(EVENTCHKINF_68)) { - if (GET_INFTABLE(INFTABLE_190)) { + if (GET_EVENTCHKINF(EVENTCHKINF_HORSEBACK_ARCHERY_EXPLAINED)) { + if (GET_INFTABLE(INFTABLE_HORSEBACK_ARCHERY_GOT_HEART_PIECE)) { textId = 0x6042; } else { textId = 0x6043; @@ -694,40 +653,37 @@ void EnGe1_Wait_Archery(EnGe1* this, PlayState* play) { } else { textId = 0x6040; } - EnGe1_SetTalkAction(this, play, textId, 200.0f, EnGe1_TalkOfferPlay_Archery); + EnGe1_OfferTalk(this, play, textId, 200.0f, EnGe1_Archery_AskToPlay); } } -// General functions - -void EnGe1_TurnToFacePlayer(EnGe1* this, PlayState* play) { +void EnGe1_TrackPlayer(EnGe1* this, PlayState* play) { STACK_PAD(s32); - s16 angleDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + s16 relYawTowardsPlayer = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if (ABS(angleDiff) <= 0x4000) { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 6, 4000, 100); + if (ABS(relYawTowardsPlayer) <= 0x4000) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 6, 0xFA0, 0x64); this->actor.world.rot.y = this->actor.shape.rot.y; - Actor_TrackPlayer(play, &this->actor, &this->headRot, &this->unk_2A2, this->actor.focus.pos); + Actor_TrackPlayer(play, &this->actor, &this->headRot, &this->torsoRot, this->actor.focus.pos); } else { - if (angleDiff < 0) { - Math_SmoothStepToS(&this->headRot.y, -0x2000, 6, 6200, 0x100); + if (relYawTowardsPlayer < 0) { + Math_SmoothStepToS(&this->headRot.y, -0x2000, 6, 0x1838, 0x100); } else { - Math_SmoothStepToS(&this->headRot.y, 0x2000, 6, 6200, 0x100); + Math_SmoothStepToS(&this->headRot.y, 0x2000, 6, 0x1838, 0x100); } - - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 12, 1000, 100); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 12, 0x3E8, 0x64); this->actor.world.rot.y = this->actor.shape.rot.y; } } -void EnGe1_LookAtPlayer(EnGe1* this, PlayState* play) { - s16 angleDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; +void EnGe1_TrackPlayerIfNear(EnGe1* this, PlayState* play) { + s16 relYawTowardsPlayer = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if ((ABS(angleDiff) <= 0x4300) && (this->actor.xzDistToPlayer < 100.0f)) { - Actor_TrackPlayer(play, &this->actor, &this->headRot, &this->unk_2A2, this->actor.focus.pos); + if ((ABS(relYawTowardsPlayer) <= 0x4300) && (this->actor.xzDistToPlayer < 100.0f)) { + Actor_TrackPlayer(play, &this->actor, &this->headRot, &this->torsoRot, this->actor.focus.pos); } else { - Math_SmoothStepToS(&this->headRot.x, 0, 6, 6200, 100); - Math_SmoothStepToS(&this->headRot.y, 0, 6, 6200, 100); + Math_SmoothStepToS(&this->headRot.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->headRot.y, 0, 6, 0x1838, 0x64); } } @@ -739,91 +695,78 @@ void EnGe1_Update(Actor* thisx, PlayState* play) { CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); Actor_MoveXZGravity(&this->actor); Actor_UpdateBgCheckInfo(play, &this->actor, 40.0f, 25.0f, 40.0f, UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_2); - this->animFunc(this); + this->playAnimFunc(this); this->actionFunc(this, play); - - if (this->stateFlags & GE1_STATE_TALKING) { - EnGe1_TurnToFacePlayer(this, play); - this->stateFlags &= ~GE1_STATE_TALKING; + if (this->stateFlags & EN_GE1_STATE_FLAG_LOOK_AT_PLAYER) { + EnGe1_TrackPlayer(this, play); + this->stateFlags &= ~EN_GE1_STATE_FLAG_LOOK_AT_PLAYER; } else { - EnGe1_LookAtPlayer(this, play); + EnGe1_TrackPlayerIfNear(this, play); } - this->unk_2A2.x = this->unk_2A2.y = this->unk_2A2.z = 0; - - if (DECR(this->blinkTimer) == 0) { - this->blinkTimer = Rand_S16Offset(60, 60); + this->torsoRot.x = this->torsoRot.y = this->torsoRot.z = 0; + if (DECR(this->eyeTimer) == 0) { + this->eyeTimer = Rand_S16Offset(60, 60); } - this->eyeIndex = this->blinkTimer; - - if (this->eyeIndex >= 3) { - this->eyeIndex = 0; + this->eyeTexIndex = this->eyeTimer; + if (this->eyeTexIndex >= 3) { + this->eyeTexIndex = 0; } } -// Animation functions - -void EnGe1_CueUpAnimation(EnGe1* this) { +void EnGe1_PlayAnimLoop(EnGe1* this) { if (SkelAnime_Update(&this->skelAnime)) { - Animation_PlayOnce(&this->skelAnime, this->animation); + Animation_PlayOnce(&this->skelAnime, this->curAnim); } } -void EnGe1_StopFidget(EnGe1* this) { - if (!(this->stateFlags & GE1_STATE_IDLE_ANIM)) { +void EnGe1_PlayAnimOnce(EnGe1* this) { + if (!(this->stateFlags & EN_GE1_STATE_FLAG_ANIM_ENDED)) { if (SkelAnime_Update(&this->skelAnime)) { - this->stateFlags |= GE1_STATE_IDLE_ANIM; + this->stateFlags |= EN_GE1_STATE_FLAG_ANIM_ENDED; } - this->stateFlags |= GE1_STATE_STOP_FIDGET; + this->stateFlags |= EN_GE1_STATE_FLAG_NO_FIDGET; } } s32 EnGe1_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - STACK_PAD(s32); EnGe1* this = (EnGe1*)thisx; + STACK_PAD(s32); - if (limbIndex == GERUDO_WHITE_LIMB_HEAD) { + if (limbIndex == OBJECT_GE1_LIMB_HEAD) { rot->x += this->headRot.y; rot->z += this->headRot.x; } - - if (this->stateFlags & GE1_STATE_STOP_FIDGET) { - this->stateFlags &= ~GE1_STATE_STOP_FIDGET; - return 0; + if (this->stateFlags & EN_GE1_STATE_FLAG_NO_FIDGET) { + this->stateFlags &= ~EN_GE1_STATE_FLAG_NO_FIDGET; + return false; } - - // The purpose of the state flag GE1_STATE_STOP_FIDGET is to skip this code, which this actor has in lieu of an idle - // animation. - if ((limbIndex == GERUDO_WHITE_LIMB_TORSO) || (limbIndex == GERUDO_WHITE_LIMB_L_FOREARM) || - (limbIndex == GERUDO_WHITE_LIMB_R_FOREARM)) { - rot->y += Math_SinS(play->state.frames * (limbIndex * FIDGET_FREQ_LIMB + FIDGET_FREQ_Y)) * FIDGET_AMPLITUDE; - rot->z += Math_CosS(play->state.frames * (limbIndex * FIDGET_FREQ_LIMB + FIDGET_FREQ_Z)) * FIDGET_AMPLITUDE; + if ((limbIndex == OBJECT_GE1_LIMB_TORSO) || (limbIndex == OBJECT_GE1_LIMB_LEFT_FOREARM) || + (limbIndex == OBJECT_GE1_LIMB_RIGHT_FOREARM)) { + rot->y += Math_SinS(play->state.frames * ((limbIndex * FIDGET_FREQ_LIMB) + FIDGET_FREQ_Y)) * FIDGET_AMPLITUDE; + rot->z += Math_CosS(play->state.frames * ((limbIndex * FIDGET_FREQ_LIMB) + FIDGET_FREQ_Z)) * FIDGET_AMPLITUDE; } - return 0; + return false; } void EnGe1_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { EnGe1* this = (EnGe1*)thisx; OPEN_DISPS(play->state.gfxCtx, "../z_en_ge1.c", 1419); - - if (limbIndex == GERUDO_WHITE_LIMB_HEAD) { - gSPDisplayList(POLY_OPA_DISP++, sHairstyleDLists[this->hairstyle]); - Matrix_MultVec3f(&D_80A327A8, &this->actor.focus.pos); + if (limbIndex == OBJECT_GE1_LIMB_HEAD) { + gSPDisplayList(POLY_OPA_DISP++, sHairDLists[this->hairType]); + Matrix_MultVec3f(&sFocusOffset, &this->actor.focus.pos); } - CLOSE_DISPS(play->state.gfxCtx, "../z_en_ge1.c", 1427); } void EnGe1_Draw(Actor* thisx, PlayState* play) { - STACK_PAD(s32); EnGe1* this = (EnGe1*)thisx; + STACK_PAD(s32); OPEN_DISPS(play->state.gfxCtx, "../z_en_ge1.c", 1442); - Gfx_SetupDL_37Opa(play->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeIndex])); + gSPSegment(POLY_OPA_DISP++, 8, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeTexIndex])); SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnGe1_OverrideLimbDraw, EnGe1_PostLimbDraw, this); - CLOSE_DISPS(play->state.gfxCtx, "../z_en_ge1.c", 1459); } 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 4566dacbbd5..fcd13f9c8c4 100644 --- a/src/overlays/actors/ovl_En_Ge1/z_en_ge1.h +++ b/src/overlays/actors/ovl_En_Ge1/z_en_ge1.h @@ -6,36 +6,35 @@ #include "assets/objects/object_ge1/object_ge1.h" +typedef enum EnGe1Type { + /* 0 */ EN_GE1_TYPE_CHILD_ERA_WASTELAND_GATEKEEPER, + /* 1 */ EN_GE1_TYPE_WASTELAND_GATEKEEPER, + /* 4 */ EN_GE1_TYPE_SENTINEL = 4, + /* 5 */ EN_GE1_TYPE_5, + /* 69 */ EN_GE1_TYPE_HORSEBACK_ARCHERY = 69, + /* 70 */ EN_GE1_TYPE_GTG_GATEKEEPER +} EnGe1Type; + struct EnGe1; -typedef void (*EnGe1AnimFunc)(struct EnGe1*); typedef void (*EnGe1ActionFunc)(struct EnGe1*, struct PlayState*); -typedef enum EnGe1Type { - /* 0x00 */ GE1_TYPE_GATE_GUARD, - /* 0x01 */ GE1_TYPE_GATE_OPERATOR, - /* 0x04 */ GE1_TYPE_NORMAL = 4, - /* 0x05 */ GE1_TYPE_VALLEY_FLOOR, - /* 0x45 */ GE1_TYPE_HORSEBACK_ARCHERY = 0x45, - /* 0x46 */ GE1_TYPE_TRAINING_GROUNDS_GUARD -} EnGe1Type; - typedef struct EnGe1 { - /* 0x0000 */ Actor actor; - /* 0x014C */ ColliderCylinder collider; - /* 0x0198 */ SkelAnime skelAnime; - /* 0x01DC */ Vec3s jointTable[GERUDO_WHITE_LIMB_MAX]; - /* 0x023C */ Vec3s morphTable[GERUDO_WHITE_LIMB_MAX]; - /* 0x029C */ Vec3s headRot; - /* 0x02A2 */ Vec3s unk_2A2; - /* 0x02A8 */ s16 eyeIndex; - /* 0x02AA */ s16 blinkTimer; - /* 0x02AC */ u16 stateFlags; - /* 0x02AE */ u8 hairstyle; - /* 0x02AF */ u8 cutsceneTimer; - /* 0x02B0 */ AnimationHeader* animation; - /* 0x02B4 */ EnGe1ActionFunc actionFunc; - /* 0x02B8 */ EnGe1AnimFunc animFunc; -} EnGe1; // size = 0x02BC + /* 0x000 */ Actor actor; + /* 0x14C */ ColliderCylinder collider; + /* 0x198 */ SkelAnime skelAnime; + /* 0x1DC */ Vec3s jointTable[OBJECT_GE1_LIMB_MAX]; + /* 0x23C */ Vec3s morphTable[OBJECT_GE1_LIMB_MAX]; + /* 0x29C */ Vec3s headRot; + /* 0x2A2 */ Vec3s torsoRot; + /* 0x2A8 */ s16 eyeTexIndex; + /* 0x2AA */ s16 eyeTimer; + /* 0x2AC */ u16 stateFlags; + /* 0x2AE */ u8 hairType; + /* 0x2AF */ u8 timer; + /* 0x2B0 */ AnimationHeader* curAnim; + /* 0x2B4 */ EnGe1ActionFunc actionFunc; + /* 0x2B8 */ void (*playAnimFunc)(struct EnGe1*); +} EnGe1; // size = 0x2BC #endif 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 de5c0b655e9..d4fe6c2a72c 100644 --- a/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c +++ b/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c @@ -22,14 +22,17 @@ #define FLAGS (ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_FRIENDLY | ACTOR_FLAG_UPDATE_CULLING_DISABLED) -void EnGe3_Init(Actor* thisx, PlayState* play2); +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* play2); +void EnGe3_UpdateTalking(Actor* thisx, PlayState* play); +void EnGe3_Draw(Actor* thisx, PlayState* play); -void EnGe3_WaitLookAtPlayer(EnGe3* this, PlayState* play); -void EnGe3_ForceTalk(EnGe3* this, PlayState* play); -void EnGe3_UpdateWhenNotTalking(Actor* thisx, PlayState* play); +void EnGe3_Idle(EnGe3* this, PlayState* play); +void EnGe3_StartTalk(EnGe3* this, PlayState* play); +void EnGe3_UpdateIdle(Actor* thisx, PlayState* play); + +#define EN_GE3_STATE_FLAG_NO_SKELANIME_UPDATE (1 << 1) +#define EN_GE3_STATE_FLAG_PLAYER_CS_ACTION_STARTED (1 << 2) ActorProfile En_Ge3_Profile = { /**/ ACTOR_EN_GE3, @@ -39,7 +42,7 @@ ActorProfile En_Ge3_Profile = { /**/ sizeof(EnGe3), /**/ EnGe3_Init, /**/ EnGe3_Destroy, - /**/ EnGe3_Update, + /**/ EnGe3_UpdateTalking, /**/ EnGe3_Draw, }; @@ -63,22 +66,20 @@ static ColliderCylinderInit sCylinderInit = { { 20, 50, 0, { 0, 0, 0 } }, }; -static EnGe3ActionFunc sActionFuncs[] = { EnGe3_WaitLookAtPlayer }; -static AnimationHeader* sAnimations[] = { &gGerudoRedStandAnim }; // Idle with right hand on hip and left over mouth -static u8 sAnimationModes[] = { ANIMMODE_LOOP }; - -void EnGe3_ChangeAction(EnGe3* this, s32 i) { - this->actionFunc = sActionFuncs[i]; - - Animation_Change(&this->skelAnime, sAnimations[i], 1.0f, 0.0f, (f32)Animation_GetLastFrame(sAnimations[i]), - sAnimationModes[i], -8.0f); +static EnGe3ActionFunc sActionFuncs[1] = { EnGe3_Idle }; +static AnimationHeader* sAnims[1] = { &gGerudoRedStandAnim }; +static u8 sAnimModes[1] = { ANIMMODE_LOOP }; - this->unk_30C &= ~2; +void EnGe3_SetupAction(EnGe3* this, s32 action) { + this->actionFunc = sActionFuncs[action]; + Animation_Change(&this->skelAnime, sAnims[action], 1.0f, 0.0f, Animation_GetLastFrame(sAnims[action]), + sAnimModes[action], -8.0f); + this->stateFlags &= ~EN_GE3_STATE_FLAG_NO_SKELANIME_UPDATE; } -void EnGe3_Init(Actor* thisx, PlayState* play2) { +void EnGe3_Init(Actor* thisx, PlayState* play) { EnGe3* this = (EnGe3*)thisx; - PlayState* play = play2; + STACK_PAD(s32); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); SkelAnime_InitFlex(play, &this->skelAnime, &gGerudoRedSkel, NULL, this->jointTable, this->morphTable, @@ -90,9 +91,9 @@ void EnGe3_Init(Actor* thisx, PlayState* play2) { Actor_SetScale(&this->actor, 0.01f); this->actor.world.rot.z = 0; this->actor.shape.rot.z = 0; - EnGe3_ChangeAction(this, 0); - this->actionFunc = EnGe3_ForceTalk; - this->unk_30C = 0; + EnGe3_SetupAction(this, 0); + this->actionFunc = EnGe3_StartTalk; + this->stateFlags = 0; this->actor.attentionRangeType = ATTENTION_RANGE_6; this->actor.minVelocityY = -4.0f; this->actor.gravity = -1.0f; @@ -104,149 +105,141 @@ void EnGe3_Destroy(Actor* thisx, PlayState* play) { Collider_DestroyCylinder(play, &this->collider); } -void EnGe3_TurnToFacePlayer(EnGe3* this, PlayState* play) { +void EnGe3_TrackPlayer(EnGe3* this, PlayState* play) { + s16 relYawTowardsPlayer = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; STACK_PAD(s32); - s16 angleDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if (ABS(angleDiff) <= 0x4000) { - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 6, 4000, 100); + if (ABS(relYawTowardsPlayer) <= 0x4000) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 6, 0xFA0, 0x64); this->actor.world.rot.y = this->actor.shape.rot.y; - Actor_TrackPlayer(play, &this->actor, &this->headRot, &this->unk_306, this->actor.focus.pos); + Actor_TrackPlayer(play, &this->actor, &this->headRot, &this->torsoRot, this->actor.focus.pos); } else { - if (angleDiff < 0) { - Math_SmoothStepToS(&this->headRot.y, -0x2000, 6, 6200, 0x100); + if (relYawTowardsPlayer < 0) { + Math_SmoothStepToS(&this->headRot.y, -0x2000, 6, 0x1838, 0x100); } else { - Math_SmoothStepToS(&this->headRot.y, 0x2000, 6, 6200, 0x100); + Math_SmoothStepToS(&this->headRot.y, 0x2000, 6, 0x1838, 0x100); } - - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 12, 1000, 100); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 12, 0x3E8, 0x64); this->actor.world.rot.y = this->actor.shape.rot.y; } } -void EnGe3_LookAtPlayer(EnGe3* this, PlayState* play) { - if ((ABS((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) <= 0x2300) && - (this->actor.xzDistToPlayer < 100.0f)) { - Actor_TrackPlayer(play, &this->actor, &this->headRot, &this->unk_306, this->actor.focus.pos); +void EnGe3_TrackPlayerIfNear(EnGe3* this, PlayState* play) { + s16 relYawTowardsPlayer = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + + if ((ABS(relYawTowardsPlayer) <= 0x2300) && (this->actor.xzDistToPlayer < 100.0f)) { + Actor_TrackPlayer(play, &this->actor, &this->headRot, &this->torsoRot, this->actor.focus.pos); } else { - Math_SmoothStepToS(&this->headRot.x, 0, 6, 6200, 100); - Math_SmoothStepToS(&this->headRot.y, 0, 6, 6200, 100); - Math_SmoothStepToS(&this->unk_306.x, 0, 6, 6200, 100); - Math_SmoothStepToS(&this->unk_306.y, 0, 6, 6200, 100); + Math_SmoothStepToS(&this->headRot.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->headRot.y, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->torsoRot.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->torsoRot.y, 0, 6, 0x1838, 0x64); } } -void EnGe3_Wait(EnGe3* this, PlayState* play) { +void EnGe3_WaitTalkEnd(EnGe3* this, PlayState* play) { if (Actor_TextboxIsClosing(&this->actor, play)) { - this->actionFunc = EnGe3_WaitLookAtPlayer; - this->actor.update = EnGe3_UpdateWhenNotTalking; + this->actionFunc = EnGe3_Idle; + this->actor.update = EnGe3_UpdateIdle; this->actor.flags &= ~ACTOR_FLAG_TALK_OFFER_AUTO_ACCEPTED; } - EnGe3_TurnToFacePlayer(this, play); + EnGe3_TrackPlayer(this, play); } -void EnGe3_WaitLookAtPlayer(EnGe3* this, PlayState* play) { - EnGe3_LookAtPlayer(this, play); +void EnGe3_Idle(EnGe3* this, PlayState* play) { + EnGe3_TrackPlayerIfNear(this, play); } -void EnGe3_WaitTillCardGiven(EnGe3* this, PlayState* play) { +void EnGe3_GiveGerudosCard(EnGe3* this, PlayState* play) { if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; - this->actionFunc = EnGe3_Wait; + this->actionFunc = EnGe3_WaitTalkEnd; } else { Actor_OfferGetItem(&this->actor, play, GI_GERUDOS_CARD, 10000.0f, 50.0f); } } -void EnGe3_GiveCard(EnGe3* this, PlayState* play) { +void EnGe3_Talking(EnGe3* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(play)) { Message_CloseTextbox(play); this->actor.flags &= ~ACTOR_FLAG_TALK_OFFER_AUTO_ACCEPTED; - this->actionFunc = EnGe3_WaitTillCardGiven; + this->actionFunc = EnGe3_GiveGerudosCard; Actor_OfferGetItem(&this->actor, play, GI_GERUDOS_CARD, 10000.0f, 50.0f); } } -void EnGe3_ForceTalk(EnGe3* this, PlayState* play) { +void EnGe3_StartTalk(EnGe3* this, PlayState* play) { if (Actor_TalkOfferAccepted(&this->actor, play)) { - this->actionFunc = EnGe3_GiveCard; + this->actionFunc = EnGe3_Talking; } else { - if (!(this->unk_30C & 4)) { + if (!(this->stateFlags & EN_GE3_STATE_FLAG_PLAYER_CS_ACTION_STARTED)) { Player_SetCsActionWithHaltedActors(play, &this->actor, PLAYER_CSACTION_7); - this->unk_30C |= 4; + this->stateFlags |= EN_GE3_STATE_FLAG_PLAYER_CS_ACTION_STARTED; } this->actor.textId = 0x6004; this->actor.flags |= ACTOR_FLAG_TALK_OFFER_AUTO_ACCEPTED; Actor_OfferTalkExchange(&this->actor, play, 300.0f, 300.0f, EXCH_ITEM_NONE); } - EnGe3_LookAtPlayer(this, play); + EnGe3_TrackPlayerIfNear(this, play); } -void EnGe3_UpdateCollision(EnGe3* this, PlayState* play) { +void EnGe3_UpdateImplPre(EnGe3* this, PlayState* play) { STACK_PADS(s32, 2); Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); Actor_UpdateBgCheckInfo(play, &this->actor, 40.0f, 25.0f, 40.0f, UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_2); - - if (!(this->unk_30C & 2) && SkelAnime_Update(&this->skelAnime)) { - this->unk_30C |= 2; + if (!(this->stateFlags & EN_GE3_STATE_FLAG_NO_SKELANIME_UPDATE) && SkelAnime_Update(&this->skelAnime)) { + this->stateFlags |= EN_GE3_STATE_FLAG_NO_SKELANIME_UPDATE; } } -void EnGe3_MoveAndBlink(EnGe3* this, PlayState* play) { - +void EnGe3_UpdateImplPost(EnGe3* this, PlayState* play) { Actor_MoveXZGravity(&this->actor); - - if (DECR(this->blinkTimer) == 0) { - this->blinkTimer = Rand_S16Offset(60, 60); + if (DECR(this->eyeTimer) == 0) { + this->eyeTimer = Rand_S16Offset(60, 60); } - - this->eyeIndex = this->blinkTimer; - - if (this->eyeIndex >= 3) { - this->eyeIndex = 0; + this->eyeTexIndex = this->eyeTimer; + if (this->eyeTexIndex >= 3) { + this->eyeTexIndex = 0; } } -void EnGe3_UpdateWhenNotTalking(Actor* thisx, PlayState* play) { +void EnGe3_UpdateIdle(Actor* thisx, PlayState* play) { EnGe3* this = (EnGe3*)thisx; - EnGe3_UpdateCollision(this, play); + EnGe3_UpdateImplPre(this, play); this->actionFunc(this, play); - if (Actor_TalkOfferAccepted(&this->actor, play)) { - this->actionFunc = EnGe3_Wait; - this->actor.update = EnGe3_Update; + this->actionFunc = EnGe3_WaitTalkEnd; + this->actor.update = EnGe3_UpdateTalking; } else { this->actor.textId = 0x6005; if (this->actor.xzDistToPlayer < 100.0f) { Actor_OfferTalk(&this->actor, play, 100.0f); } } - - EnGe3_MoveAndBlink(this, play); + EnGe3_UpdateImplPost(this, play); } -void EnGe3_Update(Actor* thisx, PlayState* play) { +void EnGe3_UpdateTalking(Actor* thisx, PlayState* play) { EnGe3* this = (EnGe3*)thisx; - EnGe3_UpdateCollision(this, play); + EnGe3_UpdateImplPre(this, play); this->actionFunc(this, play); - EnGe3_MoveAndBlink(this, play); + EnGe3_UpdateImplPost(this, play); } s32 EnGe3_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { EnGe3* this = (EnGe3*)thisx; switch (limbIndex) { - // Hide swords and veil from object_geldb case GERUDO_RED_LIMB_VEIL: - case GERUDO_RED_LIMB_R_SWORD: - case GERUDO_RED_LIMB_L_SWORD: + case GERUDO_RED_LIMB_RIGHT_SWORD: + case GERUDO_RED_LIMB_LEFT_SWORD: *dList = NULL; return false; - // Turn head + case GERUDO_RED_LIMB_HEAD: rot->x += this->headRot.y; #if OOT_VERSION >= PAL_1_1 @@ -256,18 +249,21 @@ s32 EnGe3_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* p // depending on what was drawn earlier in the frame. OPEN_DISPS(play->state.gfxCtx, "../z_en_ge3.c", 547); switch (limbIndex) { - case GERUDO_RED_LIMB_NECK: + case GERUDO_RED_LIMB_HEAD_ROOT: break; + case GERUDO_RED_LIMB_HEAD: gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 80, 60, 10, 255); break; - case GERUDO_RED_LIMB_R_SWORD: - case GERUDO_RED_LIMB_L_SWORD: + + case GERUDO_RED_LIMB_RIGHT_SWORD: + case GERUDO_RED_LIMB_LEFT_SWORD: gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 140, 170, 230, 255); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + gDPSetPrimColor(POLY_OPA_DISP++, 0x00, 0x00, 255, 255, 255, 255); break; + default: gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 140, 0, 0, 255); @@ -282,29 +278,27 @@ s32 EnGe3_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* p void EnGe3_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { EnGe3* this = (EnGe3*)thisx; - Vec3f D_80A351C8 = { 600.0f, 700.0f, 0.0f }; + Vec3f focusOffset = { 600.0f, 700.0f, 0.0f }; if (limbIndex == GERUDO_RED_LIMB_HEAD) { - Matrix_MultVec3f(&D_80A351C8, &this->actor.focus.pos); + Matrix_MultVec3f(&focusOffset, &this->actor.focus.pos); } } -void EnGe3_Draw(Actor* thisx, PlayState* play2) { - static void* eyeTextures[] = { +void EnGe3_Draw(Actor* thisx, PlayState* play) { + static void* sEyeTextures[] = { gGerudoRedEyeOpenTex, gGerudoRedEyeHalfTex, gGerudoRedEyeShutTex, }; + STACK_PAD(s32); EnGe3* this = (EnGe3*)thisx; - PlayState* play = play2; OPEN_DISPS(play->state.gfxCtx, "../z_en_ge3.c", 614); - Gfx_SetupDL_37Opa(play->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[this->eyeIndex])); + gSPSegment(POLY_OPA_DISP++, 8, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeTexIndex])); func_8002EBCC(&this->actor, play, 0); SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnGe3_OverrideLimbDraw, EnGe3_PostLimbDraw, this); - CLOSE_DISPS(play->state.gfxCtx, "../z_en_ge3.c", 631); } 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 297129e439d..d8f11836d3a 100644 --- a/src/overlays/actors/ovl_En_Ge3/z_en_ge3.h +++ b/src/overlays/actors/ovl_En_Ge3/z_en_ge3.h @@ -11,17 +11,17 @@ struct EnGe3; typedef void (*EnGe3ActionFunc)(struct EnGe3*, struct PlayState*); typedef struct EnGe3 { - /* 0x0000 */ Actor actor; - /* 0x014C */ ColliderCylinder collider; - /* 0x0198 */ SkelAnime skelAnime; - /* 0x01DC */ Vec3s jointTable[GERUDO_RED_LIMB_MAX]; - /* 0x026C */ Vec3s morphTable[GERUDO_RED_LIMB_MAX]; - /* 0x02FC */ s16 eyeIndex; - /* 0x02FE */ s16 blinkTimer; - /* 0x0300 */ Vec3s headRot; - /* 0x0306 */ Vec3s unk_306; - /* 0x030C */ u16 unk_30C; - /* 0x0310 */ EnGe3ActionFunc actionFunc; -} EnGe3; // size = 0x0314 + /* 0x000 */ Actor actor; + /* 0x14C */ ColliderCylinder collider; + /* 0x198 */ SkelAnime skelAnime; + /* 0x1DC */ Vec3s jointTable[GERUDO_RED_LIMB_MAX]; + /* 0x26C */ Vec3s morphTable[GERUDO_RED_LIMB_MAX]; + /* 0x2FC */ s16 eyeTexIndex; + /* 0x2FE */ s16 eyeTimer; + /* 0x300 */ Vec3s headRot; + /* 0x306 */ Vec3s torsoRot; + /* 0x30C */ u16 stateFlags; + /* 0x310 */ EnGe3ActionFunc actionFunc; +} EnGe3; // size = 0x314 #endif diff --git a/src/overlays/actors/ovl_En_GeldB/z_en_geldb.c b/src/overlays/actors/ovl_En_GeldB/z_en_geldb.c index c3b6cc7ba69..5f7bdebe953 100644 --- a/src/overlays/actors/ovl_En_GeldB/z_en_geldb.c +++ b/src/overlays/actors/ovl_En_GeldB/z_en_geldb.c @@ -1,9 +1,3 @@ -/* - * File: z_en_geldb.c - * Overlay: ovl_En_GeldB - * Description: Gerudo fighter - */ - #include "z_en_geldb.h" #include "attributes.h" @@ -397,8 +391,8 @@ void EnGeldB_Wait(EnGeldB* this, PlayState* play) { this->actor.focus.pos = this->actor.world.pos; this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND_TOUCH; this->actor.velocity.y = 0.0f; - Actor_SpawnFloorDustRing(play, &this->actor, &this->leftFootPos, 3.0f, 2, 2.0f, 0, 0, false); Actor_SpawnFloorDustRing(play, &this->actor, &this->rightFootPos, 3.0f, 2, 2.0f, 0, 0, false); + Actor_SpawnFloorDustRing(play, &this->actor, &this->leftFootPos, 3.0f, 2, 2.0f, 0, 0, false); } if (SkelAnime_Update(&this->skelAnime)) { EnGeldB_SetupReady(this); @@ -422,8 +416,8 @@ void EnGeldB_Flee(EnGeldB* this, PlayState* play) { } if (this->skelAnime.curFrame == 2.0f) { this->actor.gravity = 0.0f; - Actor_SpawnFloorDustRing(play, &this->actor, &this->leftFootPos, 3.0f, 2, 2.0f, 0, 0, false); Actor_SpawnFloorDustRing(play, &this->actor, &this->rightFootPos, 3.0f, 2, 2.0f, 0, 0, false); + Actor_SpawnFloorDustRing(play, &this->actor, &this->leftFootPos, 3.0f, 2, 2.0f, 0, 0, false); } if (SkelAnime_Update(&this->skelAnime)) { Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.floorHeight + 300.0f, 1.0f, 20.5f, 0.0f); @@ -509,9 +503,11 @@ void EnGeldB_SetupAdvance(EnGeldB* this, PlayState* play) { void EnGeldB_Advance(EnGeldB* this, PlayState* play) { s32 prevFrame; s32 beforeCurFrame; - s32 absPlaySpeed; + STACK_PAD(s32); s16 facingAngletoLink; Player* player = GET_PLAYER(play); + STACK_PADS(s32, 2); + f32 absPlaySpeed; if (!EnGeldB_DodgeRanged(play, this)) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0x2EE, 0); @@ -536,9 +532,9 @@ void EnGeldB_Advance(EnGeldB* this, PlayState* play) { prevFrame = (s32)this->skelAnime.curFrame; SkelAnime_Update(&this->skelAnime); - beforeCurFrame = (s32)(this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed)); - absPlaySpeed = (s32)(f32)ABS(this->skelAnime.playSpeed); - + absPlaySpeed = ABS(this->skelAnime.playSpeed); + beforeCurFrame = (s32)(this->skelAnime.curFrame - absPlaySpeed); + absPlaySpeed = ABS(this->skelAnime.playSpeed); // yes it does this twice. if (!Actor_IsFacingPlayer(&this->actor, 0x11C7)) { if (Rand_ZeroOne() > 0.5f) { EnGeldB_SetupCircle(this); @@ -572,12 +568,10 @@ void EnGeldB_Advance(EnGeldB* this, PlayState* play) { if ((play->gameplayFrames & 0x5F) == 0) { Actor_PlaySfx(&this->actor, NA_SE_EN_GERUDOFT_BREATH); } - if (prevFrame != (s32)this->skelAnime.curFrame) { - s32 afterPrevFrame = absPlaySpeed + prevFrame; - - if (((beforeCurFrame < 0) && (afterPrevFrame > 0)) || ((beforeCurFrame < 4) && (afterPrevFrame > 4))) { - Actor_PlaySfx(&this->actor, NA_SE_EN_MUSI_LAND); - } + if ((prevFrame != (s32)this->skelAnime.curFrame) && + ((beforeCurFrame < 0 && (s32)absPlaySpeed + prevFrame > 0) || + (beforeCurFrame < 4 && (s32)absPlaySpeed + prevFrame > 4))) { + Actor_PlaySfx(&this->actor, NA_SE_EN_MUSI_LAND); } } } @@ -958,8 +952,8 @@ void EnGeldB_SpinAttack(EnGeldB* this, PlayState* play) { if ((s32)this->skelAnime.curFrame < 9) { this->actor.shape.rot.y = this->actor.world.rot.y = this->actor.yawTowardsPlayer; } else if ((s32)this->skelAnime.curFrame == 13) { - Actor_SpawnFloorDustRing(play, &this->actor, &this->leftFootPos, 3.0f, 2, 2.0f, 0, 0, false); Actor_SpawnFloorDustRing(play, &this->actor, &this->rightFootPos, 3.0f, 2, 2.0f, 0, 0, false); + Actor_SpawnFloorDustRing(play, &this->actor, &this->leftFootPos, 3.0f, 2, 2.0f, 0, 0, false); this->swordState = 1; this->actor.speed = 10.0f; Actor_PlaySfx(&this->actor, NA_SE_EN_GERUDOFT_ATTACK); @@ -1125,8 +1119,8 @@ void EnGeldB_SetupJump(EnGeldB* this) { void EnGeldB_Jump(EnGeldB* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0xFA0, 1); if (this->actor.velocity.y >= 5.0f) { - func_800355B8(play, &this->leftFootPos); func_800355B8(play, &this->rightFootPos); + func_800355B8(play, &this->leftFootPos); } if (SkelAnime_Update(&this->skelAnime) && (this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH))) { @@ -1465,14 +1459,14 @@ s32 EnGeldB_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* EnGeldB* this = (EnGeldB*)thisx; OPEN_DISPS(play->state.gfxCtx, "../z_en_geldB.c", 2507); - if (limbIndex == GERUDO_RED_LIMB_NECK) { + if (limbIndex == GERUDO_RED_LIMB_HEAD_ROOT) { rot->z += this->headRot.x; rot->x += this->headRot.y; rot->y += this->headRot.z; } else if (limbIndex == GERUDO_RED_LIMB_HEAD) { gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 80, 60, 10, 255); - } else if ((limbIndex == GERUDO_RED_LIMB_R_SWORD) || (limbIndex == GERUDO_RED_LIMB_L_SWORD)) { + } else if ((limbIndex == GERUDO_RED_LIMB_RIGHT_SWORD) || (limbIndex == GERUDO_RED_LIMB_LEFT_SWORD)) { gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 140, 170, 230, 255); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); @@ -1498,7 +1492,7 @@ void EnGeldB_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* ro EnGeldB* this = (EnGeldB*)thisx; s32 bodyPart = -1; - if (limbIndex == GERUDO_RED_LIMB_R_SWORD) { + if (limbIndex == GERUDO_RED_LIMB_RIGHT_SWORD) { Matrix_MultVec3f(&swordQuadOffset1, &this->swordCollider.dim.quad[1]); Matrix_MultVec3f(&swordQuadOffset0, &this->swordCollider.dim.quad[0]); Matrix_MultVec3f(&swordQuadOffset3, &this->swordCollider.dim.quad[3]); @@ -1516,49 +1510,46 @@ void EnGeldB_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* ro EffectBlure_AddVertex(Effect_GetByIndex(this->blureIndex), &swordTip, &swordHilt); } } else { - Actor_SetFeetPos(&this->actor, limbIndex, GERUDO_RED_LIMB_L_FOOT, &footOffset, GERUDO_RED_LIMB_R_FOOT, + Actor_SetFeetPos(&this->actor, limbIndex, GERUDO_RED_LIMB_LEFT_FOOT, &footOffset, GERUDO_RED_LIMB_RIGHT_FOOT, &footOffset); } - - if (limbIndex == GERUDO_RED_LIMB_L_FOOT) { - Matrix_MultVec3f(&footOffset, &this->leftFootPos); - } else if (limbIndex == GERUDO_RED_LIMB_R_FOOT) { + if (limbIndex == GERUDO_RED_LIMB_LEFT_FOOT) { Matrix_MultVec3f(&footOffset, &this->rightFootPos); + } else if (limbIndex == GERUDO_RED_LIMB_RIGHT_FOOT) { + Matrix_MultVec3f(&footOffset, &this->leftFootPos); } - if (this->iceTimer != 0) { switch (limbIndex) { - case GERUDO_RED_LIMB_NECK: + case GERUDO_RED_LIMB_HEAD_ROOT: bodyPart = 0; break; - case GERUDO_RED_LIMB_L_SWORD: + case GERUDO_RED_LIMB_LEFT_SWORD: bodyPart = 1; break; - case GERUDO_RED_LIMB_R_SWORD: + case GERUDO_RED_LIMB_RIGHT_SWORD: bodyPart = 2; break; - case GERUDO_RED_LIMB_L_UPPER_ARM: + case GERUDO_RED_LIMB_LEFT_ARM: bodyPart = 3; break; - case GERUDO_RED_LIMB_R_UPPER_ARM: + case GERUDO_RED_LIMB_RIGHT_ARM: bodyPart = 4; break; case GERUDO_RED_LIMB_TORSO: bodyPart = 5; break; - case GERUDO_RED_LIMB_WAIST: + case GERUDO_RED_LIMB_PELVIS: bodyPart = 6; break; - case GERUDO_RED_LIMB_L_FOOT: + case GERUDO_RED_LIMB_LEFT_FOOT: bodyPart = 7; break; - case GERUDO_RED_LIMB_R_FOOT: + case GERUDO_RED_LIMB_RIGHT_FOOT: bodyPart = 8; break; default: break; } - if (bodyPart >= 0) { Vec3f limbPos; diff --git a/src/overlays/actors/ovl_En_GeldB/z_en_geldb.h b/src/overlays/actors/ovl_En_GeldB/z_en_geldb.h index 003a6dc5a5c..82a077b4587 100644 --- a/src/overlays/actors/ovl_En_GeldB/z_en_geldb.h +++ b/src/overlays/actors/ovl_En_GeldB/z_en_geldb.h @@ -38,8 +38,8 @@ typedef struct EnGeldB { /* 0x036C */ ColliderQuad swordCollider; /* 0x03EC */ ColliderTris blockCollider; /* 0x040C */ ColliderTrisElement blockElements[2]; - /* 0x04C4 */ Vec3f rightFootPos; - /* 0x04D0 */ Vec3f leftFootPos; + /* 0x04C4 */ Vec3f leftFootPos; + /* 0x04D0 */ Vec3f rightFootPos; /* 0x04DC */ Vec3s headRot; } EnGeldB; // size = 0x04E4 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 44a960e7926..e3695974242 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -215,12 +215,13 @@ s16 EnGo_UpdateTalkState(PlayState* play, Actor* thisx) { s16 talkState = NPC_TALK_STATE_TALKING; f32 xzRange; f32 yRange = fabsf(thisx->yDistToPlayer) + 1.0f; + EnGo* this = (EnGo*)thisx; - xzRange = thisx->xzDistToPlayer + 1.0f; + xzRange = this->actor.xzDistToPlayer + 1.0f; switch (Message_GetState(&play->msgCtx)) { if (play) {} case TEXT_STATE_CLOSING: - switch (thisx->textId) { + switch (this->actor.textId) { case 0x3008: SET_INFTABLE(INFTABLE_E0); talkState = NPC_TALK_STATE_IDLE; @@ -242,7 +243,7 @@ s16 EnGo_UpdateTalkState(PlayState* play, Actor* thisx) { talkState = NPC_TALK_STATE_IDLE; break; case 0x3036: - Actor_OfferGetItem(thisx, play, GI_TUNIC_GORON, xzRange, yRange); + Actor_OfferGetItem(&this->actor, play, GI_TUNIC_GORON, xzRange, yRange); SET_INFTABLE(INFTABLE_10D); // EnGo exclusive flag talkState = NPC_TALK_STATE_ACTION; break; @@ -273,33 +274,33 @@ s16 EnGo_UpdateTalkState(PlayState* play, Actor* thisx) { break; case TEXT_STATE_CHOICE: if (Message_ShouldAdvance(play)) { - switch (thisx->textId) { + switch (this->actor.textId) { case 0x300A: if (play->msgCtx.choiceIndex == 0) { if (CUR_UPG_VALUE(UPG_STRENGTH) != 0 || GET_INFTABLE(INFTABLE_EB)) { - thisx->textId = 0x300B; + this->actor.textId = 0x300B; } else { - thisx->textId = 0x300C; + this->actor.textId = 0x300C; } } else { - thisx->textId = 0x300D; + this->actor.textId = 0x300D; } - Message_ContinueTextbox(play, thisx->textId); + Message_ContinueTextbox(play, this->actor.textId); talkState = NPC_TALK_STATE_TALKING; break; case 0x3034: if (play->msgCtx.choiceIndex == 0) { if (GET_INFTABLE(INFTABLE_10B)) { - thisx->textId = 0x3033; + this->actor.textId = 0x3033; } else { - thisx->textId = 0x3035; + this->actor.textId = 0x3035; } } else if (GET_INFTABLE(INFTABLE_10B)) { - thisx->textId = 0x3036; + this->actor.textId = 0x3036; } else { - thisx->textId = 0x3033; + this->actor.textId = 0x3033; } - Message_ContinueTextbox(play, thisx->textId); + Message_ContinueTextbox(play, this->actor.textId); talkState = NPC_TALK_STATE_TALKING; break; case 0x3054: @@ -307,8 +308,8 @@ s16 EnGo_UpdateTalkState(PlayState* play, Actor* thisx) { if (play->msgCtx.choiceIndex == 0) { talkState = NPC_TALK_STATE_ACTION; } else { - thisx->textId = 0x3056; - Message_ContinueTextbox(play, thisx->textId); + this->actor.textId = 0x3056; + Message_ContinueTextbox(play, this->actor.textId); talkState = NPC_TALK_STATE_TALKING; } SET_INFTABLE(INFTABLE_B4); @@ -318,14 +319,14 @@ s16 EnGo_UpdateTalkState(PlayState* play, Actor* thisx) { break; case TEXT_STATE_EVENT: if (Message_ShouldAdvance(play)) { - switch (thisx->textId) { + switch (this->actor.textId) { case 0x3035: SET_INFTABLE(INFTABLE_10B); FALLTHROUGH; case 0x3032: case 0x3033: - thisx->textId = 0x3034; - Message_ContinueTextbox(play, thisx->textId); + this->actor.textId = 0x3034; + Message_ContinueTextbox(play, this->actor.textId); talkState = NPC_TALK_STATE_TALKING; break; default: @@ -966,7 +967,7 @@ void func_80A40B1C(EnGo* this, PlayState* play) { void EnGo_GetItem(EnGo* this, PlayState* play) { f32 xzDist; f32 yDist; - s32 getItemId; + s32 getItem; if (Actor_HasParent(&this->actor, play)) { this->interactInfo.talkState = NPC_TALK_STATE_ACTION; @@ -976,24 +977,24 @@ void EnGo_GetItem(EnGo* this, PlayState* play) { this->unk_20C = 0; if (PARAMS_GET_NOSHIFT(this->actor.params, 4, 4) == 0x90) { if (INV_CONTENT(ITEM_TRADE_ADULT) == ITEM_CLAIM_CHECK) { - getItemId = GI_SWORD_BIGGORON; + getItem = GI_SWORD_BIGGORON; this->unk_20C = 1; } if (INV_CONTENT(ITEM_TRADE_ADULT) == ITEM_EYE_DROPS) { - getItemId = GI_CLAIM_CHECK; + getItem = GI_CLAIM_CHECK; } if (INV_CONTENT(ITEM_TRADE_ADULT) == ITEM_BROKEN_GORONS_SWORD) { - getItemId = GI_PRESCRIPTION; + getItem = GI_PRESCRIPTION; } } if (PARAMS_GET_NOSHIFT(this->actor.params, 4, 4) == 0) { - getItemId = GI_TUNIC_GORON; + getItem = GI_TUNIC_GORON; } yDist = fabsf(this->actor.yDistToPlayer) + 1.0f; xzDist = this->actor.xzDistToPlayer + 1.0f; - Actor_OfferGetItem(&this->actor, play, getItemId, xzDist, yDist); + Actor_OfferGetItem(&this->actor, play, getItem, xzDist, yDist); } } diff --git a/src/overlays/actors/ovl_En_Go2/z_en_go2.c b/src/overlays/actors/ovl_En_Go2/z_en_go2.c index fce3ad3a79f..7c4f3c99d03 100644 --- a/src/overlays/actors/ovl_En_Go2/z_en_go2.c +++ b/src/overlays/actors/ovl_En_Go2/z_en_go2.c @@ -794,6 +794,7 @@ u16 EnGo2_GetTextId(PlayState* play, Actor* thisx) { s16 EnGo2_UpdateTalkState(PlayState* play, Actor* thisx) { EnGo2* this = (EnGo2*)thisx; + switch (PARAMS_GET_S(this->actor.params, 0, 5)) { case GORON_CITY_ROLLING_BIG: return EnGo2_UpdateTalkStateGoronCityRollingBig(play, this); 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 a3db731d91b..651e5560a36 100644 --- a/src/overlays/actors/ovl_En_Hata/z_en_hata.c +++ b/src/overlays/actors/ovl_En_Hata/z_en_hata.c @@ -37,41 +37,26 @@ ActorProfile En_Hata_Profile = { /**/ EnHata_Draw, }; -// Unused Collider and CollisionCheck data - -UNUSED static ColliderCylinderInit sCylinderInit = { - { - COL_MATERIAL_NONE, - AT_NONE, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEM_MATERIAL_UNK0, - { 0x00000000, HIT_SPECIAL_EFFECT_NONE, 0x00 }, - { 0x00000080, HIT_BACKLASH_NONE, 0x00 }, - ATELEM_NONE, - ACELEM_ON | ACELEM_HOOKABLE, - OCELEM_ON, - }, - { 16, 246, 0, { 0, 0, 0 } }, +static UNK_TYPE sUnusedData[] = { + 0x0A000939, 0x20010000, 0x00000000, 0x00000000, 0x00000000, 0x00000080, 0x00000000, + 0x00050100, 0x001000F6, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, }; -UNUSED static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static Vec3f sVec = { 0, 0, 0 }; void EnHata_Init(Actor* thisx, PlayState* play) { EnHata* this = (EnHata*)thisx; STACK_PAD(s32); - CollisionHeader* colHeader = NULL; - f32 frameCount = Animation_GetLastFrame(&gFlagpoleFlapAnim); + CollisionHeader* colHeader; + f32 frameCount; + colHeader = NULL; + frameCount = Animation_GetLastFrame(&gObjectHataAnim); Actor_SetScale(&this->dyna.actor, 1.0f / 75.0f); - SkelAnime_Init(play, &this->skelAnime, &gFlagpoleSkel, &gFlagpoleFlapAnim, NULL, NULL, 0); - Animation_Change(&this->skelAnime, &gFlagpoleFlapAnim, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP, 0.0f); + SkelAnime_Init(play, &this->skelAnime, &gObjectHataSkel, &gObjectHataAnim, NULL, NULL, 0); + Animation_Change(&this->skelAnime, &gObjectHataAnim, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP, 0.0f); DynaPolyActor_Init(&this->dyna, 0); - CollisionHeader_GetVirtual(&gFlagpoleCol, &colHeader); + CollisionHeader_GetVirtual(&gObjectHataCol, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); this->dyna.actor.cullingVolumeScale = 500.0f; this->dyna.actor.cullingVolumeDownward = 550.0f; @@ -79,12 +64,11 @@ void EnHata_Init(Actor* thisx, PlayState* play) { this->invScale = 6; this->maxStep = 1000; this->minStep = 1; - this->unk_278 = Rand_ZeroOne() * 0xFFFF; + this->unk_278 = Rand_ZeroOne() * 65535.0f; } void EnHata_Destroy(Actor* thisx, PlayState* play) { EnHata* this = (EnHata*)thisx; - SkelAnime_Free(&this->skelAnime, play); DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } @@ -93,40 +77,33 @@ void EnHata_Update(Actor* thisx, PlayState* play2) { PlayState* play = play2; EnHata* this = (EnHata*)thisx; s32 pitch; - Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - Vec3f windVec; + Vec3f sp48 = sVec; + Vec3f sp3C; f32 sin; SkelAnime_Update(&this->skelAnime); - // Rotate to hang down by default - this->limbs[FLAGPOLE_LIMB_FLAG_1_BASE].y = this->limbs[FLAGPOLE_LIMB_FLAG_2_BASE].y = -0x4000; - windVec.x = play->envCtx.windDirection.x; - windVec.y = play->envCtx.windDirection.y; - windVec.z = play->envCtx.windDirection.z; - + this->limbs[3].y = this->limbs[12].y = -0x4000; + sp3C.x = play->envCtx.windDirection.x; + sp3C.y = play->envCtx.windDirection.y; + sp3C.z = play->envCtx.windDirection.z; if (play->envCtx.windSpeed > 255.0f) { play->envCtx.windSpeed = 255.0f; } - if (play->envCtx.windSpeed < 0.0f) { play->envCtx.windSpeed = 0.0f; } - if (Rand_ZeroOne() > 0.5f) { this->unk_278 += 6000; } else { this->unk_278 += 3000; } - - // Mimic varying wind gusts sin = Math_SinS(this->unk_278) * 80.0f; - pitch = -Math_Vec3f_Pitch(&zeroVec, &windVec); - pitch = ((s32)((15000 - pitch) * (1.0f - (play->envCtx.windSpeed / (255.0f - sin))))) + pitch; - Math_SmoothStepToS(&this->limbs[FLAGPOLE_LIMB_FLAG_1_HOIST_END_BASE].y, pitch, this->invScale, this->maxStep, - this->minStep); - this->limbs[FLAGPOLE_LIMB_FLAG_2_HOIST_END_BASE].y = this->limbs[FLAGPOLE_LIMB_FLAG_1_HOIST_END_BASE].y; - this->limbs[FLAGPOLE_LIMB_FLAG_1_HOIST_END_BASE].z = -Math_Vec3f_Yaw(&zeroVec, &windVec); - this->limbs[FLAGPOLE_LIMB_FLAG_2_HOIST_END_BASE].z = this->limbs[FLAGPOLE_LIMB_FLAG_1_HOIST_END_BASE].z; + pitch = -Math_Vec3f_Pitch(&sp48, &sp3C); + pitch = ((s32)((0x3A98 - pitch) * (1.0f - (play->envCtx.windSpeed / (255.0f - sin))))) + pitch; + Math_SmoothStepToS(&this->limbs[4].y, pitch, this->invScale, this->maxStep, this->minStep); + this->limbs[13].y = this->limbs[4].y; + this->limbs[4].z = -Math_Vec3f_Yaw(&sp48, &sp3C); + this->limbs[13].z = this->limbs[4].z; this->skelAnime.playSpeed = (Rand_ZeroFloat(1.25f) + 2.75f) * (play->envCtx.windSpeed / 255.0f); } @@ -134,8 +111,7 @@ s32 EnHata_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* EnHata* this = (EnHata*)thisx; Vec3s* limbs; - if (limbIndex == FLAGPOLE_LIMB_FLAG_2_BASE || limbIndex == FLAGPOLE_LIMB_FLAG_1_BASE || - limbIndex == FLAGPOLE_LIMB_FLAG_2_HOIST_END_BASE || limbIndex == FLAGPOLE_LIMB_FLAG_1_HOIST_END_BASE) { + if (limbIndex == 12 || limbIndex == 3 || limbIndex == 13 || limbIndex == 4) { limbs = this->limbs; rot->x += limbs[limbIndex].x; rot->y += limbs[limbIndex].y; @@ -149,7 +125,6 @@ void EnHata_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot void EnHata_Draw(Actor* thisx, PlayState* play) { EnHata* this = (EnHata*)thisx; - Gfx_SetupDL_37Opa(play->state.gfxCtx); Matrix_Scale(1.0f, 1.1f, 1.0f, MTXMODE_APPLY); SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnHata_OverrideLimbDraw, 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 38c85e6349c..65823ef2974 100644 --- a/src/overlays/actors/ovl_En_Hata/z_en_hata.h +++ b/src/overlays/actors/ovl_En_Hata/z_en_hata.h @@ -4,13 +4,11 @@ #include "ultra64.h" #include "actor.h" -#include "assets/objects/object_hata/object_hata.h" - typedef struct EnHata { /* 0x0000 */ DynaPolyActor dyna; /* 0x0164 */ SkelAnime skelAnime; - /* 0x01A8 */ ColliderCylinder collider; // Unused, but indicated by the form of the unused data - /* 0x01F4 */ Vec3s limbs[FLAGPOLE_LIMB_MAX]; + /* 0x01A8 */ char unk_1A8[0x4C]; + /* 0x01F4 */ Vec3s limbs[0x15]; /* 0x0272 */ s16 invScale; /* 0x0274 */ s16 maxStep; /* 0x0276 */ s16 minStep; diff --git a/src/overlays/actors/ovl_En_Heishi2/z_en_heishi2.c b/src/overlays/actors/ovl_En_Heishi2/z_en_heishi2.c index 2f4ef1b0b03..7a41200466b 100644 --- a/src/overlays/actors/ovl_En_Heishi2/z_en_heishi2.c +++ b/src/overlays/actors/ovl_En_Heishi2/z_en_heishi2.c @@ -292,29 +292,31 @@ void func_80A535BC(EnHeishi2* this, PlayState* play) { } void func_80A53638(EnHeishi2* this, PlayState* play) { - STACK_PAD(s32); - f32 frameCount = this->skelAnime.curFrame; - - BgSpot15Saku* actor = (BgSpot15Saku*)play->actorCtx.actorLists[ACTORCAT_ITEMACTION].head; + Actor* thisx; + f32 frameCount; + Actor* actor; + frameCount = this->skelAnime.curFrame; + thisx = &this->actor; + actor = play->actorCtx.actorLists[ACTORCAT_ITEMACTION].head; SkelAnime_Update(&this->skelAnime); if ((frameCount >= 12.0f) && (!this->audioFlag)) { - Actor_PlaySfx(&this->actor, NA_SE_EV_SPEAR_HIT); + Actor_PlaySfx(thisx, NA_SE_EV_SPEAR_HIT); this->audioFlag = 1; } if (this->unk_2EC <= frameCount) { while (actor != NULL) { - if (actor->dyna.actor.id != ACTOR_BG_SPOT15_SAKU) { - actor = (BgSpot15Saku*)(actor->dyna.actor.next); + if (ACTOR_BG_SPOT15_SAKU != actor->id) { + actor = actor->next; } else { - this->gate = &actor->dyna.actor; - actor->unk_168 = 1; + this->gate = actor; + ((BgSpot15Saku*)actor)->unk_168 = 1; break; } } PRINTF(VT_FGCOL(MAGENTA) T("☆☆☆ きたきたきたぁ! ☆☆☆ %x\n", "☆☆☆ It's here, it's here, it's here! ☆☆☆ %x\n") VT_RST, - actor->dyna.actor.next); + actor->next); this->actionFunc = func_80A5372C; } } @@ -459,10 +461,10 @@ void func_80A53C90(EnHeishi2* this, PlayState* play) { void func_80A53D0C(EnHeishi2* this, PlayState* play) { STACK_PAD(s32); f32 frameCount; - BgGateShutter* gate; + Actor* gate; frameCount = this->skelAnime.curFrame; - gate = (BgGateShutter*)play->actorCtx.actorLists[ACTORCAT_ITEMACTION].head; + gate = play->actorCtx.actorLists[ACTORCAT_ITEMACTION].head; SkelAnime_Update(&this->skelAnime); if (12.0f <= frameCount) { if (this->audioFlag == 0) { @@ -472,17 +474,17 @@ void func_80A53D0C(EnHeishi2* this, PlayState* play) { } if (this->unk_2EC <= frameCount) { while (gate != NULL) { - if (gate->dyna.actor.id != ACTOR_BG_GATE_SHUTTER) { - gate = (BgGateShutter*)gate->dyna.actor.next; + if (gate->id != ACTOR_BG_GATE_SHUTTER) { + gate = gate->next; } else { - this->gate = &gate->dyna.actor; - gate->openingState = 1; + this->gate = gate; + ((BgGateShutter*)gate)->openingState = 1; break; } } PRINTF(VT_FGCOL(MAGENTA) T("☆☆☆ きたきたきたぁ! ☆☆☆ %x\n", "☆☆☆ It's here, it's here, it's here! ☆☆☆ %x\n") VT_RST, - gate->dyna.actor.next); + gate->next); this->actionFunc = func_80A53DF8; } } @@ -619,27 +621,29 @@ void func_80A54320(EnHeishi2* this, PlayState* play) { } void func_80A543A0(EnHeishi2* this, PlayState* play) { - STACK_PAD(s32); - f32 frameCount = this->skelAnime.curFrame; - BgGateShutter* gate = (BgGateShutter*)(play->actorCtx.actorLists[ACTORCAT_ITEMACTION].head); - SkelAnime_Update(&this->skelAnime); + Actor* thisx; + f32 frameCount; + Actor* gate; + frameCount = this->skelAnime.curFrame; + thisx = &this->actor; + gate = play->actorCtx.actorLists[ACTORCAT_ITEMACTION].head; + SkelAnime_Update(&this->skelAnime); if ((frameCount >= 12.0f) && (!this->audioFlag)) { - Actor_PlaySfx(&this->actor, NA_SE_EV_SPEAR_HIT); + Actor_PlaySfx(thisx, NA_SE_EV_SPEAR_HIT); this->audioFlag = 1; } - if (this->unk_2EC <= frameCount) { while (gate != NULL) { - if (ACTOR_BG_GATE_SHUTTER != gate->dyna.actor.id) { - gate = (BgGateShutter*)(gate->dyna.actor.next); + if (ACTOR_BG_GATE_SHUTTER != gate->id) { + gate = gate->next; } else { - this->gate = &gate->dyna.actor; + this->gate = gate; if (this->unk_30A != 2) { - gate->openingState = -1; + ((BgGateShutter*)gate)->openingState = -1; break; } else { - gate->openingState = 2; + ((BgGateShutter*)gate)->openingState = 2; break; } } @@ -650,7 +654,6 @@ void func_80A543A0(EnHeishi2* this, PlayState* play) { this->actionFunc = func_80A53DF8; } } - void func_80A544AC(EnHeishi2* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.z, -6100, 5, this->unk_2E4, 0); Math_ApproachF(&this->unk_2E4, 3000.0f, 1.0f, 500.0f); @@ -664,7 +667,7 @@ void func_80A544AC(EnHeishi2* this, PlayState* play) { } void func_80A5455C(EnHeishi2* this, PlayState* play) { - STACK_PAD(s32); + Actor* thisx = &this->actor; Vec3f pos; f32 rotY; EnBom* bomb; @@ -676,7 +679,7 @@ void func_80A5455C(EnHeishi2* this, PlayState* play) { pos.x = Rand_CenteredFloat(20.0f) + this->unk_274.x; pos.y = Rand_CenteredFloat(20.0f) + (this->unk_274.y - 40.0f); pos.z = Rand_CenteredFloat(20.0f) + (this->unk_274.z - 20.0f); - rotY = Rand_CenteredFloat(7000.0f) + this->actor.yawTowardsPlayer; + rotY = Rand_CenteredFloat(7000.0f) + thisx->yawTowardsPlayer; bomb = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, pos.x, pos.y, pos.z, 0, rotY, 0, 0); if (bomb != NULL) { bomb->actor.speed = Rand_CenteredFloat(5.0f) + 10.0f; @@ -838,7 +841,6 @@ s32 EnHeishi2_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3 void EnHeishi2_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { EnHeishi2* this = (EnHeishi2*)thisx; - if (limbIndex == 16) { Matrix_Get(&this->mtxf_330); } diff --git a/src/overlays/actors/ovl_En_Heishi4/z_en_heishi4.c b/src/overlays/actors/ovl_En_Heishi4/z_en_heishi4.c index 20c16a3a008..58dc5daee29 100644 --- a/src/overlays/actors/ovl_En_Heishi4/z_en_heishi4.c +++ b/src/overlays/actors/ovl_En_Heishi4/z_en_heishi4.c @@ -283,11 +283,13 @@ void func_80A56900(EnHeishi4* this, PlayState* play) { void func_80A56994(EnHeishi4* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); Actor_TrackPlayer(play, &this->actor, &this->headRot, &this->torsoRot, this->actor.focus.pos); - if ((this->unk_282 == Message_GetState(&play->msgCtx)) && Message_ShouldAdvance(play)) { - Message_CloseTextbox(play); - SET_INFTABLE(INFTABLE_6C); - Player_SetCsActionWithHaltedActors(play, NULL, PLAYER_CSACTION_8); - this->actionFunc = func_80A56A50; + if (this->unk_282 == Message_GetState(&play->msgCtx)) { + if (Message_ShouldAdvance(play)) { + Message_CloseTextbox(play); + SET_INFTABLE(INFTABLE_6C); + Player_SetCsActionWithHaltedActors(play, NULL, PLAYER_CSACTION_8); + this->actionFunc = func_80A56A50; + } } } 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 264a7d6eb11..827016ee5bc 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -174,7 +174,7 @@ static ColliderJntSphInit sJntSphInit = { sJntSphElementsInit, }; -static CollisionCheckInfoInit D_80A65F38 = { 10, 35, 100, MASS_HEAVY }; +static CollisionCheckInfoInit sColChkInfoInit = { 10, 35, 100, MASS_HEAVY }; typedef struct EnHorseSpawnpoint { /* 0x0 */ s16 sceneId; @@ -355,7 +355,7 @@ static EnHorseSpawnpoint sHorseSpawns[] = { { SCENE_LON_LON_RANCH, 882, 0, -2256, 0 }, { SCENE_LON_LON_RANCH, -1003, 0, -755, 0 }, // Hardcoded to always load in lon lon { SCENE_LON_LON_RANCH, -2254, 0, -629, 0 }, - { SCENE_LON_LON_RANCH, 907, 0, -2336, 0 }, + { SCENE_LON_LON_RANCH, 907, 0, -2336, 0 } }; typedef struct BridgeJumpPoint { @@ -850,7 +850,7 @@ void EnHorse_Init(Actor* thisx, PlayState* play2) { Collider_SetCylinder(play, &this->colliderCylinder2, &this->actor, &sCylinderInit2); Collider_InitJntSph(play, &this->colliderJntSph); Collider_SetJntSph(play, &this->colliderJntSph, &this->actor, &sJntSphInit, this->colliderJntSphElements); - CollisionCheck_SetInfo(&this->actor.colChkInfo, DamageTable_Get(0xB), &D_80A65F38); + CollisionCheck_SetInfo(&this->actor.colChkInfo, DamageTable_Get(0xB), &sColChkInfoInit); this->actor.focus.pos = this->actor.world.pos; this->actor.focus.pos.y += 70.0f; this->playerControlled = false; @@ -2554,7 +2554,7 @@ void EnHorse_UpdateHorsebackArchery(EnHorse* this, PlayState* play) { if (play->interfaceCtx.hbaAmmo != 0) { if (!(this->hbaFlags & 2)) { - if (GET_INFTABLE(INFTABLE_190)) { + if (GET_INFTABLE(INFTABLE_HORSEBACK_ARCHERY_GOT_HEART_PIECE)) { if ((s32)gSaveContext.minigameScore >= 1500) { this->hbaFlags |= 4; } @@ -3241,7 +3241,7 @@ void EnHorse_UpdateBgCheckInfo(EnHorse* this, PlayState* play) { obstaclePos.z += intersectDist * Math_CosS(this->actor.world.rot.y); obstacleTop = obstaclePos; obstacleTop.y = BgCheck_EntityRaycastDown3(&play->colCtx, &obstacleFloor, &bgId, &obstaclePos); - if (obstacleTop.y == BGCHECK_Y_MIN) { + if (obstacleTop.y == -32000.0f) { return; } obstacleHeight = obstacleTop.y - this->actor.world.pos.y; @@ -3290,7 +3290,7 @@ void EnHorse_UpdateBgCheckInfo(EnHorse* this, PlayState* play) { obstacleTop = obstaclePos; obstacleTop.y = BgCheck_EntityRaycastDown3(&play->colCtx, &obstacleFloor, &bgId, &obstaclePos); - if (obstacleTop.y == BGCHECK_Y_MIN) { + if (obstacleTop.y == -32000.0f) { return; } diff --git a/src/overlays/actors/ovl_En_Ice_Hono/z_en_ice_hono.c b/src/overlays/actors/ovl_En_Ice_Hono/z_en_ice_hono.c index 4d2336c4fc2..f83364489f5 100644 --- a/src/overlays/actors/ovl_En_Ice_Hono/z_en_ice_hono.c +++ b/src/overlays/actors/ovl_En_Ice_Hono/z_en_ice_hono.c @@ -1,9 +1,3 @@ -/* - * File: z_en_ice_hono.c - * Overlay: ovl_En_Ice_Hono - * Description: The various types of Blue Fire - */ - #include "z_en_ice_hono.h" #include "attributes.h" @@ -113,8 +107,11 @@ static InitChainEntry sInitChainSmallFlame[] = { ICHAIN_F32(cullingVolumeDownward, 1000, ICHAIN_STOP), }; -f32 EnIceHono_XZDistanceSquared(Vec3f* v1, Vec3f* v2) { - return SQ(v1->x - v2->x) + SQ(v1->z - v2->z); +f32 EnIceHono_SquareDist(Vec3f* pos1, Vec3f* pos2) { + f32 dx = pos1->x - pos2->x; + f32 dz = pos1->z - pos2->z; + + return SQ(dx) + SQ(dz); } void EnIceHono_InitCapturableFlame(Actor* thisx, PlayState* play) { @@ -202,7 +199,7 @@ void EnIceHono_Destroy(Actor* thisx, PlayState* play) { } } -u32 EnIceHono_InBottleRange(EnIceHono* this, PlayState* play) { +u32 EnIceHono_LinkCloseAndFacing(EnIceHono* this, PlayState* play) { Player* player = GET_PLAYER(play); if (this->actor.xzDistToPlayer < 60.0f) { @@ -210,15 +207,11 @@ u32 EnIceHono_InBottleRange(EnIceHono* this, PlayState* play) { tempPos.x = Math_SinS(this->actor.yawTowardsPlayer + 0x8000) * 40.0f + player->actor.world.pos.x; tempPos.y = player->actor.world.pos.y; tempPos.z = Math_CosS(this->actor.yawTowardsPlayer + 0x8000) * 40.0f + player->actor.world.pos.z; - - //! @bug this check is superfluous: it is automatically satisfied if the coarse check is satisfied. It may have - //! been intended to check the actor is in front of Player, but yawTowardsPlayer does not depend on Player's - //! world rotation. - if (EnIceHono_XZDistanceSquared(&tempPos, &this->actor.world.pos) <= SQ(40.0f)) { - return true; + if (EnIceHono_SquareDist(&tempPos, &this->actor.world.pos) <= SQ(40.0f)) { + return 1; } } - return false; + return 0; } void EnIceHono_SetupActionCapturableFlame(EnIceHono* this) { @@ -230,8 +223,7 @@ void EnIceHono_SetupActionCapturableFlame(EnIceHono* this) { void EnIceHono_CapturableFlame(EnIceHono* this, PlayState* play) { if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; - } else if (EnIceHono_InBottleRange(this, play)) { - // GI_MAX in this case allows the player to catch the actor in a bottle + } else if (EnIceHono_LinkCloseAndFacing(this, play)) { Actor_OfferGetItem(&this->actor, play, GI_MAX, 60.0f, 100.0f); } 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 3d5ed0c4be0..cbb1587deff 100644 --- a/src/overlays/actors/ovl_En_Ik/z_en_ik.c +++ b/src/overlays/actors/ovl_En_Ik/z_en_ik.c @@ -18,7 +18,6 @@ #include "sequence.h" #include "stack_pad.h" #include "sys_matrix.h" -#include "terminal.h" #include "translation.h" #include "versions.h" #include "z_en_item00.h" @@ -37,57 +36,44 @@ typedef void (*EnIkDrawFunc)(struct EnIk*, PlayState*); -#define ARMOR_BROKEN (1 << 0) - -typedef enum EnIkCsAction { - /* 0x00 */ IK_CS_ACTION_0, - /* 0x01 */ IK_CS_ACTION_1, - /* 0x02 */ IK_CS_ACTION_2, - /* 0x03 */ IK_CS_ACTION_3, - /* 0x04 */ IK_CS_ACTION_4, - /* 0x05 */ IK_CS_ACTION_5 -} EnIkCsAction; - -typedef enum EnIkCsDrawMode { - /* 0x00 */ IK_CS_DRAW_NOTHING, - /* 0x01 */ IK_CS_DRAW_INTRO, - /* 0x02 */ IK_CS_DRAW_DEFEAT -} EnIkCsDrawMode; - -typedef enum EnIkDamageReaction { - /* 0x0 */ EN_IK_DMG_REACT_NONE, - /* 0x6 */ EN_IK_DMG_REACT_ELEMENTAL_MAGIC = 0x6, - /* 0xD */ EN_IK_DMG_REACT_SPARKS_NO_DMG = 0xD, - /* 0xE */ EN_IK_DMG_REACT_PROJECTILE, - /* 0xF */ EN_IK_DMG_REACT_DAMAGE -} EnIkDamageReaction; - -void EnIk_UpdateEnemy(Actor* thisx, PlayState* play); -void EnIk_DrawEnemy(Actor* thisx, PlayState* play); - -void EnIk_SetupStandUp(EnIk* this); -void EnIk_StandUp(EnIk* this, PlayState* play); -void EnIk_Idle(EnIk* this, PlayState* play); -void EnIk_SetupWalkOrRun(EnIk* this); -void EnIk_WalkOrRun(EnIk* this, PlayState* play); -void EnIk_SetupVerticalAttack(EnIk* this); -void EnIk_VerticalAttack(EnIk* this, PlayState* play); -void EnIk_SetupPullOutAxe(EnIk* this); -void EnIk_PullOutAxe(EnIk* this, PlayState* play); -void EnIk_SetupDoubleHorizontalAttack(EnIk* this); -void EnIk_DoubleHorizontalAttack(EnIk* this, PlayState* play); -void EnIk_SetupRecoverFromHorizontalAttack(EnIk* this); -void EnIk_RecoverFromHorizontalAttack(EnIk* this, PlayState* play); -void EnIk_SetupSingleHorizontalAttack(EnIk* this); -void EnIk_SingleHorizontalAttack(EnIk* this, PlayState* play); -void EnIk_SetupStopAndBlock(EnIk* this); -void EnIk_StopAndBlock(EnIk* this, PlayState* play); -void EnIk_ReactToAttack(EnIk* this, PlayState* play); -void EnIk_Die(EnIk* this, PlayState* play); - -void EnIk_HandleCsCues(EnIk* this, PlayState* play); -void EnIk_ChangeToEnemy(EnIk* this, PlayState* play); -void EnIk_StartDefeatCutscene(Actor* thisx, PlayState* play); +void EnIk_Init(Actor* thisx, PlayState* play); +void EnIk_Destroy(Actor* thisx, PlayState* play); +void EnIk_Update(Actor* thisx, PlayState* play); +void EnIk_Draw(Actor* thisx, PlayState* play); + +void func_80A74714(EnIk* this); +void func_80A747C0(EnIk* this, PlayState* play); +void func_80A7492C(EnIk* this, PlayState* play); +void func_80A74AAC(EnIk* this); +void func_80A74BA4(EnIk* this, PlayState* play); +void func_80A74E2C(EnIk* this); +void func_80A74EBC(EnIk* this, PlayState* play); +void func_80A7506C(EnIk* this); +void func_80A7510C(EnIk* this, PlayState* play); +void func_80A751C8(EnIk* this); +void func_80A75260(EnIk* this, PlayState* play); +void func_80A753D0(EnIk* this); +void func_80A7545C(EnIk* this, PlayState* play); +void func_80A754A0(EnIk* this); +void func_80A75530(EnIk* this, PlayState* play); +void func_80A755F0(EnIk* this); +void func_80A7567C(EnIk* this, PlayState* play); +void func_80A758B0(EnIk* this, PlayState* play); +void func_80A75A38(EnIk* this, PlayState* play); +void func_80A75FA0(Actor* thisx, PlayState* play); +void func_80A76798(Actor* thisx, PlayState* play); +void func_80A7748C(EnIk* this, PlayState* play); +void func_80A774BC(EnIk* this, PlayState* play); +void func_80A774F8(EnIk* this, PlayState* play); +void func_80A77844(EnIk* this, PlayState* play); +void func_80A779DC(EnIk* this, PlayState* play); +void func_80A77AEC(EnIk* this, PlayState* play); +void func_80A77B0C(EnIk* this, PlayState* play); +void func_80A77B3C(EnIk* this, PlayState* play); +void func_80A77ED0(EnIk* this, PlayState* play); +void func_80A77EDC(EnIk* this, PlayState* play); +void func_80A78160(EnIk* this, PlayState* play); +void func_80A781CC(Actor* thisx, PlayState* play); static ColliderCylinderInit sCylinderInit = { { @@ -168,38 +154,38 @@ static ColliderQuadInit sQuadInit = { }; static DamageTable sDamageTable = { - /* Deku nut */ DMG_ENTRY(0, EN_IK_DMG_REACT_SPARKS_NO_DMG), - /* Deku stick */ DMG_ENTRY(2, EN_IK_DMG_REACT_DAMAGE), - /* Slingshot */ DMG_ENTRY(1, EN_IK_DMG_REACT_PROJECTILE), - /* Explosive */ DMG_ENTRY(2, EN_IK_DMG_REACT_DAMAGE), - /* Boomerang */ DMG_ENTRY(0, EN_IK_DMG_REACT_SPARKS_NO_DMG), - /* Normal arrow */ DMG_ENTRY(2, EN_IK_DMG_REACT_PROJECTILE), - /* Hammer swing */ DMG_ENTRY(2, EN_IK_DMG_REACT_DAMAGE), - /* Hookshot */ DMG_ENTRY(0, EN_IK_DMG_REACT_SPARKS_NO_DMG), - /* Kokiri sword */ DMG_ENTRY(1, EN_IK_DMG_REACT_DAMAGE), - /* Master sword */ DMG_ENTRY(2, EN_IK_DMG_REACT_DAMAGE), - /* Giant's Knife */ DMG_ENTRY(4, EN_IK_DMG_REACT_DAMAGE), - /* Fire arrow */ DMG_ENTRY(2, EN_IK_DMG_REACT_PROJECTILE), - /* Ice arrow */ DMG_ENTRY(2, EN_IK_DMG_REACT_PROJECTILE), - /* Light arrow */ DMG_ENTRY(2, EN_IK_DMG_REACT_PROJECTILE), - /* Unk arrow 1 */ DMG_ENTRY(2, EN_IK_DMG_REACT_PROJECTILE), - /* Unk arrow 2 */ DMG_ENTRY(2, EN_IK_DMG_REACT_PROJECTILE), - /* Unk arrow 3 */ DMG_ENTRY(15, EN_IK_DMG_REACT_PROJECTILE), - /* Fire magic */ DMG_ENTRY(0, EN_IK_DMG_REACT_ELEMENTAL_MAGIC), - /* Ice magic */ DMG_ENTRY(0, EN_IK_DMG_REACT_ELEMENTAL_MAGIC), - /* Light magic */ DMG_ENTRY(0, EN_IK_DMG_REACT_ELEMENTAL_MAGIC), - /* Shield */ DMG_ENTRY(0, EN_IK_DMG_REACT_NONE), - /* Mirror Ray */ DMG_ENTRY(0, EN_IK_DMG_REACT_NONE), - /* Kokiri spin */ DMG_ENTRY(1, EN_IK_DMG_REACT_DAMAGE), - /* Giant spin */ DMG_ENTRY(4, EN_IK_DMG_REACT_DAMAGE), - /* Master spin */ DMG_ENTRY(2, EN_IK_DMG_REACT_DAMAGE), - /* Kokiri jump */ DMG_ENTRY(2, EN_IK_DMG_REACT_DAMAGE), - /* Giant jump */ DMG_ENTRY(8, EN_IK_DMG_REACT_DAMAGE), - /* Master jump */ DMG_ENTRY(4, EN_IK_DMG_REACT_DAMAGE), - /* Unknown 1 */ DMG_ENTRY(10, EN_IK_DMG_REACT_DAMAGE), - /* Unblockable */ DMG_ENTRY(0, EN_IK_DMG_REACT_NONE), - /* Hammer jump */ DMG_ENTRY(4, EN_IK_DMG_REACT_DAMAGE), - /* Unknown 2 */ DMG_ENTRY(0, EN_IK_DMG_REACT_NONE), + /* Deku nut */ DMG_ENTRY(0, 0xD), + /* Deku stick */ DMG_ENTRY(2, 0xF), + /* Slingshot */ DMG_ENTRY(1, 0xE), + /* Explosive */ DMG_ENTRY(2, 0xF), + /* Boomerang */ DMG_ENTRY(0, 0xD), + /* Normal arrow */ DMG_ENTRY(2, 0xE), + /* Hammer swing */ DMG_ENTRY(2, 0xF), + /* Hookshot */ DMG_ENTRY(0, 0xD), + /* Kokiri sword */ DMG_ENTRY(1, 0xF), + /* Master sword */ DMG_ENTRY(2, 0xF), + /* Giant's Knife */ DMG_ENTRY(4, 0xF), + /* Fire arrow */ DMG_ENTRY(2, 0xE), + /* Ice arrow */ DMG_ENTRY(2, 0xE), + /* Light arrow */ DMG_ENTRY(2, 0xE), + /* Unk arrow 1 */ DMG_ENTRY(2, 0xE), + /* Unk arrow 2 */ DMG_ENTRY(2, 0xE), + /* Unk arrow 3 */ DMG_ENTRY(15, 0xE), + /* Fire magic */ DMG_ENTRY(0, 0x6), + /* Ice magic */ DMG_ENTRY(0, 0x6), + /* Light magic */ DMG_ENTRY(0, 0x6), + /* Shield */ DMG_ENTRY(0, 0x0), + /* Mirror Ray */ DMG_ENTRY(0, 0x0), + /* Kokiri spin */ DMG_ENTRY(1, 0xF), + /* Giant spin */ DMG_ENTRY(4, 0xF), + /* Master spin */ DMG_ENTRY(2, 0xF), + /* Kokiri jump */ DMG_ENTRY(2, 0xF), + /* Giant jump */ DMG_ENTRY(8, 0xF), + /* Master jump */ DMG_ENTRY(4, 0xF), + /* Unknown 1 */ DMG_ENTRY(10, 0xF), + /* Unblockable */ DMG_ENTRY(0, 0x0), + /* Hammer jump */ DMG_ENTRY(4, 0xF), + /* Unknown 2 */ DMG_ENTRY(0, 0x0), }; void EnIk_Destroy(Actor* thisx, PlayState* play) { @@ -218,13 +204,13 @@ void EnIk_SetupAction(EnIk* this, EnIkActionFunc actionFunc) { this->actionFunc = actionFunc; } -void EnIk_InitImpl(Actor* thisx, PlayState* play) { +void func_80A74398(Actor* thisx, PlayState* play) { EnIk* this = (EnIk*)thisx; STACK_PAD(s32); EffectBlureInit1 blureInit; - thisx->update = EnIk_UpdateEnemy; - thisx->draw = EnIk_DrawEnemy; + thisx->update = func_80A75FA0; + thisx->draw = func_80A76798; thisx->flags |= ACTOR_FLAG_HOOKSHOT_PULLS_PLAYER; Collider_InitCylinder(play, &this->bodyCollider); @@ -236,13 +222,13 @@ void EnIk_InitImpl(Actor* thisx, PlayState* play) { thisx->colChkInfo.damageTable = &sDamageTable; thisx->colChkInfo.mass = MASS_HEAVY; - this->isBreakingProp = false; + this->unk_2FC = 0; thisx->colChkInfo.health = 30; thisx->gravity = -1.0f; - this->switchFlag = IK_GET_SWITCH_FLAG(thisx); - thisx->params = IK_GET_ARMOR_TYPE(thisx); + this->switchFlags = PARAMS_GET_U(thisx->params, 8, 8); + thisx->params &= 0xFF; - if (thisx->params == IK_TYPE_NABOORU) { + if (thisx->params == 0) { thisx->colChkInfo.health += 20; thisx->naviEnemyId = NAVI_ENEMY_IRON_KNUCKLE_NABOORU; } else { @@ -265,10 +251,10 @@ void EnIk_InitImpl(Actor* thisx, PlayState* play) { blureInit.calcMode = 2; Effect_Add(play, &this->blureIdx, EFFECT_BLURE1, 0, 0, &blureInit); - EnIk_SetupStandUp(this); + func_80A74714(this); - if (this->switchFlag != 0xFF) { - if (Flags_GetSwitch(play, this->switchFlag)) { + if (this->switchFlags != 0xFF) { + if (Flags_GetSwitch(play, this->switchFlags)) { Actor_Kill(thisx); } } else if (thisx->params != 0 && Flags_GetClear(play, play->roomCtx.curRoom.num)) { @@ -276,18 +262,18 @@ void EnIk_InitImpl(Actor* thisx, PlayState* play) { } } -s32 EnIk_HandleBlocking(EnIk* this, PlayState* play) { - if (((this->armorStatusFlag != 0) || (this->actor.params == IK_TYPE_NABOORU)) && +s32 func_80A745E4(EnIk* this, PlayState* play) { + if (((this->unk_2FB != 0) || (this->actor.params == 0)) && (func_800354B4(play, &this->actor, 100.0f, 0x2710, 0x4000, this->actor.shape.rot.y) != 0) && (play->gameplayFrames & 1)) { - EnIk_SetupStopAndBlock(this); + func_80A755F0(this); return true; } else { return false; } } -Actor* EnIk_FindBreakableProp(PlayState* play, Actor* actor) { +Actor* func_80A74674(PlayState* play, Actor* actor) { Actor* prop = play->actorCtx.actorLists[ACTORCAT_PROP].head; while (prop != NULL) { @@ -304,190 +290,175 @@ Actor* EnIk_FindBreakableProp(PlayState* play, Actor* actor) { return NULL; } -void EnIk_SetupStandUp(EnIk* this) { - f32 endFrame = Animation_GetLastFrame(&gIronKnuckleStandUpAnim); - f32 startFrame; +void func_80A74714(EnIk* this) { + f32 frames = Animation_GetLastFrame(&object_ik_Anim_00CD70); + f32 frame; - if (this->actor.params >= IK_TYPE_BLACK) { - startFrame = endFrame - 1.0f; + if (this->actor.params >= 2) { + frame = frames - 1.0f; } else { - startFrame = 0.0f; + frame = 0.0f; } - Animation_Change(&this->skelAnime, &gIronKnuckleStandUpAnim, 0.0f, startFrame, endFrame, ANIMMODE_ONCE, 0.0f); + Animation_Change(&this->skelAnime, &object_ik_Anim_00CD70, 0.0f, frame, frames, ANIMMODE_ONCE, 0.0f); this->unk_2F8 = 3; this->actor.speed = 0.0f; - EnIk_SetupAction(this, EnIk_StandUp); + EnIk_SetupAction(this, func_80A747C0); } -void EnIk_StandUp(EnIk* this, PlayState* play) { - Vec3f sparksPos; +void func_80A747C0(EnIk* this, PlayState* play) { + Vec3f sp24; if (this->bodyCollider.base.acFlags & AC_HIT) { - sparksPos = this->actor.world.pos; + sp24 = this->actor.world.pos; Actor_PlaySfx(&this->actor, NA_SE_EN_IRONNACK_ARMOR_HIT); - sparksPos.y += 30.0f; - func_8003424C(play, &sparksPos); + sp24.y += 30.0f; + func_8003424C(play, &sp24); this->skelAnime.playSpeed = 1.0f; func_800F5ACC(NA_BGM_MINI_BOSS); } - if (this->skelAnime.curFrame == 5.0f) { Actor_PlaySfx(&this->actor, NA_SE_EN_IRONNACK_WAKEUP); } - if (SkelAnime_Update(&this->skelAnime)) { this->actor.flags |= ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_HOSTILE; - EnIk_SetupWalkOrRun(this); + func_80A74AAC(this); } } -void EnIk_SetupIdle(EnIk* this) { - f32 endFrame = Animation_GetLastFrame(&object_ik_Anim_00DD50); +void func_80A7489C(EnIk* this) { + f32 frames = Animation_GetLastFrame(&object_ik_Anim_00DD50); this->actor.flags |= ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_HOSTILE; this->unk_2F8 = 4; this->actor.speed = 0.0f; - Animation_Change(&this->skelAnime, &object_ik_Anim_00DD50, 0.0f, 0.0f, endFrame, ANIMMODE_LOOP, 4.0f); - EnIk_SetupAction(this, EnIk_Idle); + Animation_Change(&this->skelAnime, &object_ik_Anim_00DD50, 0.0f, 0.0f, frames, ANIMMODE_LOOP, 4.0f); + EnIk_SetupAction(this, func_80A7492C); } -void EnIk_Idle(EnIk* this, PlayState* play) { - s32 detectionThreshold = (this->armorStatusFlag == 0) ? 0xAAA : 0x3FFC; +void func_80A7492C(EnIk* this, PlayState* play) { + s32 phi_a0 = (this->unk_2FB == 0) ? 0xAAA : 0x3FFC; s16 yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if ((ABS(yawDiff) <= detectionThreshold) && (this->actor.xzDistToPlayer < 100.0f) && + if ((ABS(yawDiff) <= phi_a0) && (this->actor.xzDistToPlayer < 100.0f) && (ABS(this->actor.yDistToPlayer) < 150.0f)) { if ((play->gameplayFrames & 1)) { - EnIk_SetupVerticalAttack(this); + func_80A74E2C(this); } else { - EnIk_SetupDoubleHorizontalAttack(this); + func_80A751C8(this); } } else if ((ABS(yawDiff) <= 0x4000) && (ABS(this->actor.yDistToPlayer) < 150.0f)) { - EnIk_SetupWalkOrRun(this); + func_80A74AAC(this); } else { - EnIk_SetupWalkOrRun(this); + func_80A74AAC(this); } - - EnIk_HandleBlocking(this, play); + func_80A745E4(this, play); SkelAnime_Update(&this->skelAnime); } -void EnIk_SetupWalkOrRun(EnIk* this) { +void func_80A74AAC(EnIk* this) { this->unk_2F8 = 5; - - if (this->armorStatusFlag == 0) { - Animation_Change(&this->skelAnime, &gIronKnuckleWalkAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gIronKnuckleWalkAnim), ANIMMODE_LOOP, -4.0f); + if (this->unk_2FB == 0) { + Animation_Change(&this->skelAnime, &object_ik_Anim_00ED24, 1.0f, 0.0f, + Animation_GetLastFrame(&object_ik_Anim_00ED24), ANIMMODE_LOOP, -4.0f); this->actor.speed = 0.9f; } else { - Animation_Change(&this->skelAnime, &gIronKnuckleRunAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gIronKnuckleRunAnim), ANIMMODE_LOOP, -4.0f); + Animation_Change(&this->skelAnime, &object_ik_Anim_006734, 1.0f, 0.0f, + Animation_GetLastFrame(&object_ik_Anim_006734), ANIMMODE_LOOP, -4.0f); Actor_PlaySfx(&this->actor, NA_SE_EN_IRONNACK_DASH); this->actor.speed = 2.5f; } - this->actor.world.rot.y = this->actor.shape.rot.y; - EnIk_SetupAction(this, EnIk_WalkOrRun); + EnIk_SetupAction(this, func_80A74BA4); } -void EnIk_WalkOrRun(EnIk* this, PlayState* play) { +void func_80A74BA4(EnIk* this, PlayState* play) { s16 temp_t0; - s16 targetYaw; + s16 temp_a1; s16 yawDiff; - s16 footstepFrame1; - s16 footstepFrame2; - s16 stepVal; + s16 sp30; + s16 sp2E; + s16 phi_a3; - if (this->armorStatusFlag == 0) { + if (this->unk_2FB == 0) { temp_t0 = 0xAAA; - stepVal = 0x320; - footstepFrame1 = 0; - footstepFrame2 = 16; + phi_a3 = 0x320; + sp30 = 0; + sp2E = 0x10; } else { temp_t0 = 0x3FFC; - stepVal = 0x4B0; - footstepFrame1 = 2; - footstepFrame2 = 9; + phi_a3 = 0x4B0; + sp30 = 2; + sp2E = 9; } - - targetYaw = this->actor.wallYaw - this->actor.shape.rot.y; - - if ((this->actor.bgCheckFlags & BGCHECKFLAG_WALL) && (ABS(targetYaw) >= 0x4000)) { - targetYaw = (this->actor.yawTowardsPlayer > 0) ? this->actor.wallYaw - 0x4000 : this->actor.wallYaw + 0x4000; - Math_SmoothStepToS(&this->actor.world.rot.y, targetYaw, 1, stepVal, 0); + temp_a1 = this->actor.wallYaw - this->actor.shape.rot.y; + if ((this->actor.bgCheckFlags & BGCHECKFLAG_WALL) && (ABS(temp_a1) >= 0x4000)) { + temp_a1 = (this->actor.yawTowardsPlayer > 0) ? this->actor.wallYaw - 0x4000 : this->actor.wallYaw + 0x4000; + Math_SmoothStepToS(&this->actor.world.rot.y, temp_a1, 1, phi_a3, 0); } else { - Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, stepVal, 0); + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, phi_a3, 0); } - this->actor.shape.rot.y = this->actor.world.rot.y; yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if ((ABS(yawDiff) <= temp_t0) && (this->actor.xzDistToPlayer < 100.0f)) { if (ABS(this->actor.yDistToPlayer) < 150.0f) { - if (play->gameplayFrames & 1) { - EnIk_SetupVerticalAttack(this); + if ((play->gameplayFrames & 1)) { + func_80A74E2C(this); } else { - EnIk_SetupDoubleHorizontalAttack(this); + func_80A751C8(this); } } } - - if (EnIk_FindBreakableProp(play, &this->actor) != NULL) { - EnIk_SetupDoubleHorizontalAttack(this); - this->isBreakingProp = true; + if (func_80A74674(play, &this->actor) != NULL) { + func_80A751C8(this); + this->unk_2FC = 1; } else { temp_t0 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if (ABS(temp_t0) > 0x4000) { this->unk_300--; - if (this->unk_300 == 0) { - EnIk_SetupSingleHorizontalAttack(this); + func_80A754A0(this); } } else { - this->unk_300 = 40; + this->unk_300 = 0x28; } } - - EnIk_HandleBlocking(this, play); + func_80A745E4(this, play); SkelAnime_Update(&this->skelAnime); - - if (((s16)this->skelAnime.curFrame == footstepFrame1) || ((s16)this->skelAnime.curFrame == footstepFrame2)) { + if ((sp30 == (s16)this->skelAnime.curFrame) || (sp2E == (s16)this->skelAnime.curFrame)) { Actor_PlaySfx(&this->actor, NA_SE_EN_IRONNACK_WALK); } } -void EnIk_SetupVerticalAttack(EnIk* this) { - f32 endFrame = Animation_GetLastFrame(&gIronKnuckleVerticalAttackAnim); +void func_80A74E2C(EnIk* this) { + f32 frames = Animation_GetLastFrame(&object_ik_Anim_001C28); this->unk_2FF = 1; this->unk_2F8 = 6; this->actor.speed = 0.0f; - Animation_Change(&this->skelAnime, &gIronKnuckleVerticalAttackAnim, 1.5f, 0.0f, endFrame, ANIMMODE_ONCE, -4.0f); - EnIk_SetupAction(this, EnIk_VerticalAttack); + Animation_Change(&this->skelAnime, &object_ik_Anim_001C28, 1.5f, 0.0f, frames, ANIMMODE_ONCE, -4.0f); + EnIk_SetupAction(this, func_80A74EBC); } -void EnIk_VerticalAttack(EnIk* this, PlayState* play) { - Vec3f sparksPos; +void func_80A74EBC(EnIk* this, PlayState* play) { + Vec3f sp2C; if (this->skelAnime.curFrame == 15.0f) { Actor_PlaySfx(&this->actor, NA_SE_EN_IRONNACK_SWING_AXE); } else if (this->skelAnime.curFrame == 21.0f) { - sparksPos.x = this->actor.world.pos.x + Math_SinS(this->actor.shape.rot.y + 0x6A4) * 70.0f; - sparksPos.z = this->actor.world.pos.z + Math_CosS(this->actor.shape.rot.y + 0x6A4) * 70.0f; - sparksPos.y = this->actor.world.pos.y; - + sp2C.x = this->actor.world.pos.x + Math_SinS(this->actor.shape.rot.y + 0x6A4) * 70.0f; + sp2C.z = this->actor.world.pos.z + Math_CosS(this->actor.shape.rot.y + 0x6A4) * 70.0f; + sp2C.y = this->actor.world.pos.y; Actor_PlaySfx(&this->actor, NA_SE_EN_IRONNACK_HIT_GND); Camera_RequestQuake(&play->mainCamera, 2, 25, 5); Rumble_Request(this->actor.xzDistToPlayer, 255, 20, 150); - CollisionCheck_SpawnShieldParticles(play, &sparksPos); + CollisionCheck_SpawnShieldParticles(play, &sp2C); } if ((this->skelAnime.curFrame > 17.0f) && (this->skelAnime.curFrame < 23.0f)) { this->unk_2FE = 1; } else { - if ((this->armorStatusFlag != 0) && (this->skelAnime.curFrame < 10.0f)) { + if ((this->unk_2FB != 0) && (this->skelAnime.curFrame < 10.0f)) { Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 0x5DC, 0); this->actor.shape.rot.y = this->actor.world.rot.y; } @@ -495,116 +466,105 @@ void EnIk_VerticalAttack(EnIk* this, PlayState* play) { } if (SkelAnime_Update(&this->skelAnime)) { - EnIk_SetupPullOutAxe(this); + func_80A7506C(this); } } -void EnIk_SetupPullOutAxe(EnIk* this) { - f32 endFrame = Animation_GetLastFrame(&gIronKnuckleAxeStuckAnim); +void func_80A7506C(EnIk* this) { + f32 frames = Animation_GetLastFrame(&object_ik_Anim_0029FC); this->unk_2FE = 0; - this->animationTimer = (s8)endFrame; + this->unk_2F9 = (s8)frames; this->unk_2F8 = 7; this->unk_2FF = this->unk_2FE; - Animation_Change(&this->skelAnime, &gIronKnuckleAxeStuckAnim, 1.0f, 0.0f, endFrame, ANIMMODE_LOOP, -4.0f); + Animation_Change(&this->skelAnime, &object_ik_Anim_0029FC, 1.0f, 0.0f, frames, ANIMMODE_LOOP, -4.0f); Actor_PlaySfx(&this->actor, NA_SE_EN_IRONNACK_PULLOUT); - EnIk_SetupAction(this, EnIk_PullOutAxe); + EnIk_SetupAction(this, func_80A7510C); } -void EnIk_PullOutAxe(EnIk* this, PlayState* play) { - f32 endFrame; +void func_80A7510C(EnIk* this, PlayState* play) { + f32 frames; - if (SkelAnime_Update(&this->skelAnime) || (--this->animationTimer == 0)) { + if (SkelAnime_Update(&this->skelAnime) || (--this->unk_2F9 == 0)) { if (this->unk_2F8 == 8) { - EnIk_SetupIdle(this); + func_80A7489C(this); } else { - endFrame = Animation_GetLastFrame(&gIronKnuckleRecoverFromVerticalAttackAnim); + frames = Animation_GetLastFrame(&object_ik_Anim_002538); this->unk_2F8 = 8; - Animation_Change(&this->skelAnime, &gIronKnuckleRecoverFromVerticalAttackAnim, 1.5f, 0.0f, endFrame, - ANIMMODE_ONCE_INTERP, -4.0f); + Animation_Change(&this->skelAnime, &object_ik_Anim_002538, 1.5f, 0.0f, frames, ANIMMODE_ONCE_INTERP, -4.0f); } } } -// Happens when Player is in front of Iron Knuckle or when Iron Knuckle encounters ACTOR_BG_JYA_IRONOBJ -void EnIk_SetupDoubleHorizontalAttack(EnIk* this) { - f32 endFrame = Animation_GetLastFrame(&gIronKnuckleHorizontalAttackAnim); +void func_80A751C8(EnIk* this) { + f32 frames = Animation_GetLastFrame(&object_ik_Anim_0033C4); this->unk_2FF = 2; this->unk_300 = 0; this->unk_2F8 = 6; this->actor.speed = 0.0f; - Animation_Change(&this->skelAnime, &gIronKnuckleHorizontalAttackAnim, 0.0f, 0.0f, endFrame, ANIMMODE_ONCE_INTERP, - -6.0f); - this->isBreakingProp = false; - EnIk_SetupAction(this, EnIk_DoubleHorizontalAttack); + Animation_Change(&this->skelAnime, &object_ik_Anim_0033C4, 0.0f, 0.0f, frames, ANIMMODE_ONCE_INTERP, -6.0f); + this->unk_2FC = 0; + EnIk_SetupAction(this, func_80A75260); } -void EnIk_DoubleHorizontalAttack(EnIk* this, PlayState* play) { - f32 playSpeed; +void func_80A75260(EnIk* this, PlayState* play) { + f32 temp_f0; this->unk_300 += 0x1C2; - playSpeed = Math_SinS(this->unk_300); - this->skelAnime.playSpeed = ABS(playSpeed); + temp_f0 = Math_SinS(this->unk_300); + this->skelAnime.playSpeed = ABS(temp_f0); if (this->skelAnime.curFrame > 11.0f) { this->unk_2FF = 3; } - if (((this->skelAnime.curFrame > 1.0f) && (this->skelAnime.curFrame < 9.0f)) || ((this->skelAnime.curFrame > 13.0f) && (this->skelAnime.curFrame < 18.0f))) { - if (!this->isBreakingProp && (this->armorStatusFlag != 0) && (this->skelAnime.curFrame < 10.0f)) { + if ((this->unk_2FC == 0) && (this->unk_2FB != 0) && (this->skelAnime.curFrame < 10.0f)) { Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 0x5DC, 0); this->actor.shape.rot.y = this->actor.world.rot.y; } - if (this->unk_2FE < 0) { Actor_PlaySfx(&this->actor, NA_SE_EN_IRONNACK_SWING_AXE); } - this->unk_2FE = 1; } else { this->unk_2FE = 0; } - if (SkelAnime_Update(&this->skelAnime)) { - EnIk_SetupRecoverFromHorizontalAttack(this); + func_80A753D0(this); } } -void EnIk_SetupRecoverFromHorizontalAttack(EnIk* this) { - f32 endFrame = Animation_GetLastFrame(&gIronKnuckleRecoverFromHorizontalAttackAnim); +void func_80A753D0(EnIk* this) { + f32 frames = Animation_GetLastFrame(&object_ik_Anim_003DBC); this->unk_2FF = this->unk_2FE = 0; this->unk_2F8 = 8; - Animation_Change(&this->skelAnime, &gIronKnuckleRecoverFromHorizontalAttackAnim, 1.5f, 0.0f, endFrame, - ANIMMODE_ONCE_INTERP, -4.0f); - EnIk_SetupAction(this, EnIk_RecoverFromHorizontalAttack); + Animation_Change(&this->skelAnime, &object_ik_Anim_003DBC, 1.5f, 0.0f, frames, ANIMMODE_ONCE_INTERP, -4.0f); + EnIk_SetupAction(this, func_80A7545C); } -void EnIk_RecoverFromHorizontalAttack(EnIk* this, PlayState* play) { +void func_80A7545C(EnIk* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { - EnIk_SetupIdle(this); - EnIk_HandleBlocking(this, play); + func_80A7489C(this); + func_80A745E4(this, play); } } -// Attack pattern when player is behind Iron Knuckle or attacks Iron Knuckle from behind -void EnIk_SetupSingleHorizontalAttack(EnIk* this) { - f32 endFrame = Animation_GetLastFrame(&gIronKnuckleHorizontalAttackAnim); +void func_80A754A0(EnIk* this) { + f32 frames = Animation_GetLastFrame(&object_ik_Anim_0033C4); this->unk_2F8 = 1; this->unk_2FF = 3; this->actor.speed = 0.0f; - Animation_Change(&this->skelAnime, &gIronKnuckleHorizontalAttackAnim, 0.5f, 13.0f, endFrame, ANIMMODE_ONCE_INTERP, - -4.0f); - EnIk_SetupAction(this, EnIk_SingleHorizontalAttack); + Animation_Change(&this->skelAnime, &object_ik_Anim_0033C4, 0.5f, 13.0f, frames, ANIMMODE_ONCE_INTERP, -4.0f); + EnIk_SetupAction(this, func_80A75530); } -void EnIk_SingleHorizontalAttack(EnIk* this, PlayState* play) { +void func_80A75530(EnIk* this, PlayState* play) { Math_StepUntilS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0x7D0); this->actor.shape.rot.y = this->actor.world.rot.y; - if ((this->skelAnime.curFrame > 13.0f) && (this->skelAnime.curFrame < 18.0f)) { if (this->unk_2FE < 0) { Actor_PlaySfx(&this->actor, NA_SE_EN_IRONNACK_SWING_AXE); @@ -613,117 +573,107 @@ void EnIk_SingleHorizontalAttack(EnIk* this, PlayState* play) { } else { this->unk_2FE = 0; } - if (SkelAnime_Update(&this->skelAnime)) { - EnIk_SetupRecoverFromHorizontalAttack(this); - EnIk_HandleBlocking(this, play); + func_80A753D0(this); + func_80A745E4(this, play); } } -void EnIk_SetupStopAndBlock(EnIk* this) { - f32 endFrame = Animation_GetLastFrame(&gIronKnuckleBlockAnim); +void func_80A755F0(EnIk* this) { + f32 frames = Animation_GetLastFrame(&object_ik_Anim_00485C); this->unk_2FE = 0; this->unk_2F8 = 9; this->actor.speed = 0.0f; - Animation_Change(&this->skelAnime, &gIronKnuckleBlockAnim, 1.0f, 0.0f, endFrame, ANIMMODE_ONCE_INTERP, -4.0f); - EnIk_SetupAction(this, EnIk_StopAndBlock); + Animation_Change(&this->skelAnime, &object_ik_Anim_00485C, 1.0f, 0.0f, frames, ANIMMODE_ONCE_INTERP, -4.0f); + EnIk_SetupAction(this, func_80A7567C); } -void EnIk_StopAndBlock(EnIk* this, PlayState* play) { +void func_80A7567C(EnIk* this, PlayState* play) { CollisionCheck_SetAC(play, &play->colChkCtx, &this->shieldCollider.base); - if (SkelAnime_Update(&this->skelAnime)) { if ((ABS((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) <= 0x4000) && (this->actor.xzDistToPlayer < 100.0f) && (ABS(this->actor.yDistToPlayer) < 150.0f)) { if ((play->gameplayFrames & 1)) { - EnIk_SetupVerticalAttack(this); + func_80A74E2C(this); } else { - EnIk_SetupDoubleHorizontalAttack(this); + func_80A751C8(this); } } else { - EnIk_SetupIdle(this); + func_80A7489C(this); } } } -void EnIk_SetupReactToAttack(EnIk* this) { +void func_80A75790(EnIk* this) { s16 yaw; s16 yawDiff; yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->bodyCollider.base.ac->world.pos); this->unk_2F8 = 0; yawDiff = yaw - this->actor.shape.rot.y; - if (ABS(yawDiff) <= 0x4000) { - Animation_Change(&this->skelAnime, &gIronKnuckleFrontHitAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gIronKnuckleFrontHitAnim), ANIMMODE_ONCE, -4.0f); + Animation_Change(&this->skelAnime, &object_ik_Anim_006194, 1.0f, 0.0f, + Animation_GetLastFrame(&object_ik_Anim_006194), ANIMMODE_ONCE, -4.0f); this->actor.speed = -6.0f; } else { - Animation_Change(&this->skelAnime, &gIronKnuckleBackHitAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gIronKnuckleBackHitAnim), ANIMMODE_ONCE, -4.0f); + Animation_Change(&this->skelAnime, &object_ik_Anim_0045BC, 1.0f, 0.0f, + Animation_GetLastFrame(&object_ik_Anim_0045BC), ANIMMODE_ONCE, -4.0f); this->actor.speed = 6.0f; } - this->unk_2FE = 0; - EnIk_SetupAction(this, EnIk_ReactToAttack); + EnIk_SetupAction(this, func_80A758B0); } -void EnIk_ReactToAttack(EnIk* this, PlayState* play) { +void func_80A758B0(EnIk* this, PlayState* play) { Math_SmoothStepToF(&this->actor.speed, 0.0f, 1.0f, 1.0f, 0.0f); - if (BodyBreak_SpawnParts(&this->actor, &this->bodyBreak, play, this->actor.params + 4)) { this->bodyBreak.val = BODYBREAK_STATUS_FINISHED; } - if (SkelAnime_Update(&this->skelAnime)) { if (ABS((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) <= 0x4000) { - EnIk_SetupIdle(this); - EnIk_HandleBlocking(this, play); + func_80A7489C(this); + func_80A745E4(this, play); } else { - EnIk_SetupSingleHorizontalAttack(this); + func_80A754A0(this); } } } -void EnIk_SetupDie(EnIk* this) { - f32 endFrame = Animation_GetLastFrame(&gIronKnuckleDeathAnim); +void func_80A7598C(EnIk* this) { + f32 frames = Animation_GetLastFrame(&object_ik_Anim_005944); this->unk_2FE = 0; this->unk_2F8 = 2; this->actor.speed = 0.0f; - Animation_Change(&this->skelAnime, &gIronKnuckleDeathAnim, 1.0f, 0.0f, endFrame, ANIMMODE_ONCE, -4.0f); - this->animationTimer = 24; + Animation_Change(&this->skelAnime, &object_ik_Anim_005944, 1.0f, 0.0f, frames, ANIMMODE_ONCE, -4.0f); + this->unk_2F9 = 0x18; Actor_PlaySfx(&this->actor, NA_SE_EN_IRONNACK_DEAD); Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_CUTBODY); - EnIk_SetupAction(this, EnIk_Die); + EnIk_SetupAction(this, func_80A75A38); } -void EnIk_Die(EnIk* this, PlayState* play) { +void func_80A75A38(EnIk* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { - if ((this->actor.colChkInfo.health == 0) && (this->animationTimer != 0)) { + if ((this->actor.colChkInfo.health == 0) && (this->unk_2F9 != 0)) { s32 i; Vec3f pos; Vec3f sp7C = { 0.0f, 0.5f, 0.0f }; - this->animationTimer--; + this->unk_2F9--; - for (i = 0xC - (this->animationTimer >> 1); i >= 0; i--) { + for (i = 0xC - (this->unk_2F9 >> 1); i >= 0; i--) { pos.x = this->actor.world.pos.x + Rand_CenteredFloat(120.0f); pos.z = this->actor.world.pos.z + Rand_CenteredFloat(120.0f); pos.y = this->actor.world.pos.y + 20.0f + Rand_CenteredFloat(50.0f); - EffectSsDeadDb_Spawn(play, &pos, &sp7C, &sp7C, 100, 0, 255, 255, 255, 255, 0, 0, 255, 1, 9, true); } - - if (this->animationTimer == 0) { + if (this->unk_2F9 == 0) { Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, COLLECTIBLE_DROP_RANDOM_PARAMS(COLLECTIBLE_DROP_TABLE_11, false)); - - if (this->switchFlag != 0xFF) { - Flags_SetSwitch(play, this->switchFlag); + if (this->switchFlags != 0xFF) { + Flags_SetSwitch(play, this->switchFlags); } - Actor_Kill(&this->actor); } } @@ -732,58 +682,52 @@ void EnIk_Die(EnIk* this, PlayState* play) { } } -void EnIk_UpdateDamage(EnIk* this, PlayState* play) { +void func_80A75C38(EnIk* this, PlayState* play) { + if ((this->unk_2F8 == 3) || (this->unk_2F8 == 2)) { return; } - if (this->shieldCollider.base.acFlags & AC_BOUNCED) { - f32 frames = Animation_GetLastFrame(&gIronKnuckleBlockAnim) - 2.0f; + f32 temp_f0; - if (this->skelAnime.curFrame < frames) { - this->skelAnime.curFrame = frames; + temp_f0 = Animation_GetLastFrame(&object_ik_Anim_00485C) - 2.0f; + if (this->skelAnime.curFrame < temp_f0) { + this->skelAnime.curFrame = temp_f0; } - this->shieldCollider.base.acFlags &= ~AC_BOUNCED; this->bodyCollider.base.acFlags &= ~AC_HIT; } else if (this->bodyCollider.base.acFlags & AC_HIT) { STACK_PAD(s16); u8 prevHealth; STACK_PAD(s32); - Vec3f sparksPos = this->actor.world.pos; - - sparksPos.y += 50.0f; + Vec3f sp38; + sp38 = this->actor.world.pos; + sp38.y += 50.0f; Actor_SetDropFlag(&this->actor, &this->bodyCollider.elem, true); - - this->damageReaction = this->actor.colChkInfo.damageReaction; + this->unk_2FD = this->actor.colChkInfo.damageReaction; this->bodyCollider.base.acFlags &= ~AC_HIT; - if ((this->damageReaction == EN_IK_DMG_REACT_NONE) || (this->damageReaction == EN_IK_DMG_REACT_SPARKS_NO_DMG) || - ((this->armorStatusFlag == 0) && (this->damageReaction == EN_IK_DMG_REACT_PROJECTILE))) { - if (this->damageReaction != EN_IK_DMG_REACT_NONE) { - // spawn sparks and don't damage - CollisionCheck_SpawnShieldParticlesMetal(play, &sparksPos); + if ((this->unk_2FD == 0) || (this->unk_2FD == 0xD) || ((this->unk_2FB == 0) && (this->unk_2FD == 0xE))) { + if (this->unk_2FD != 0) { + CollisionCheck_SpawnShieldParticlesMetal(play, &sp38); } return; } - Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 12); - prevHealth = this->actor.colChkInfo.health; Actor_ApplyDamage(&this->actor); - - if (this->actor.params != IK_TYPE_NABOORU) { + if (this->actor.params != 0) { if ((prevHealth > 10) && (this->actor.colChkInfo.health <= 10)) { - this->armorStatusFlag = ARMOR_BROKEN; + this->unk_2FB = 1; BodyBreak_Alloc(&this->bodyBreak, 3, play); } } else if (this->actor.colChkInfo.health <= 10) { Actor_ChangeCategory(play, &play->actorCtx, &this->actor, ACTORCAT_BOSS); SfxSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_EN_LAST_DAMAGE); #if !OOT_PAL_N64 - if (this->switchFlag != 0xFF) { - Flags_SetSwitch(play, this->switchFlag); + if (this->switchFlags != 0xFF) { + Flags_SetSwitch(play, this->switchFlags); } #endif return; @@ -792,97 +736,82 @@ void EnIk_UpdateDamage(EnIk* this, PlayState* play) { } if (this->actor.colChkInfo.health == 0) { - EnIk_SetupDie(this); + func_80A7598C(this); Enemy_StartFinishingBlow(play, &this->actor); return; } - Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 0x7D0, 0); - - if ((this->actor.params == IK_TYPE_NABOORU) && (Rand_ZeroOne() < 0.5f)) { + if ((this->actor.params == 0) && (Rand_ZeroOne() < 0.5f)) { if (ABS((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) > 0x4000) { - EnIk_SetupSingleHorizontalAttack(this); + func_80A754A0(this); } } - - if ((this->actor.params != IK_TYPE_NABOORU) && (this->armorStatusFlag != 0)) { + if ((this->actor.params != 0) && (this->unk_2FB != 0)) { if ((prevHealth > 10) && (this->actor.colChkInfo.health <= 10)) { Actor_PlaySfx(&this->actor, NA_SE_EN_IRONNACK_ARMOR_OFF_DEMO); } else { Actor_PlaySfx(&this->actor, NA_SE_EN_IRONNACK_DAMAGE); Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_CUTBODY); } - - EnIk_SetupReactToAttack(this); - } else { - Actor_PlaySfx(&this->actor, NA_SE_EN_IRONNACK_ARMOR_HIT); - Actor_PlaySfx(&this->actor, NA_SE_EN_IRONNACK_DAMAGE); - CollisionCheck_SpawnShieldParticles(play, &sparksPos); + func_80A75790(this); + return; } + Actor_PlaySfx(&this->actor, NA_SE_EN_IRONNACK_ARMOR_HIT); + Actor_PlaySfx(&this->actor, NA_SE_EN_IRONNACK_DAMAGE); + CollisionCheck_SpawnShieldParticles(play, &sp38); } } -void EnIk_UpdateEnemy(Actor* thisx, PlayState* play) { +void func_80A75FA0(Actor* thisx, PlayState* play) { EnIk* this = (EnIk*)thisx; STACK_PAD(s32); Player* player = GET_PLAYER(play); u8 prevInvincibilityTimer; - this->drawArmorFlag = this->armorStatusFlag; - EnIk_UpdateDamage(this, play); - - if ((this->actor.params == IK_TYPE_NABOORU) && (this->actor.colChkInfo.health <= 10)) { - EnIk_StartDefeatCutscene(&this->actor, play); - } else { - this->actionFunc(this, play); - - if (this->axeCollider.base.atFlags & AT_HIT) { - this->axeCollider.base.atFlags &= ~AT_HIT; - - if (this->axeCollider.base.at == &player->actor) { - prevInvincibilityTimer = player->invincibilityTimer; - - if (player->invincibilityTimer <= 0) { - if (player->invincibilityTimer <= -40) { - player->invincibilityTimer = 0; - } else { - player->invincibilityTimer = 0; - play->damagePlayer(play, -64); - this->unk_2FE = 0; - } + this->unk_2FA = this->unk_2FB; + func_80A75C38(this, play); + if ((this->actor.params == 0) && (this->actor.colChkInfo.health <= 10)) { + func_80A781CC(&this->actor, play); + return; + } + this->actionFunc(this, play); + if (this->axeCollider.base.atFlags & AT_HIT) { + this->axeCollider.base.atFlags &= ~AT_HIT; + if (&player->actor == this->axeCollider.base.at) { + prevInvincibilityTimer = player->invincibilityTimer; + if (player->invincibilityTimer <= 0) { + if (player->invincibilityTimer < -39) { + player->invincibilityTimer = 0; + } else { + player->invincibilityTimer = 0; + play->damagePlayer(play, -64); + this->unk_2FE = 0; } - - Actor_SetPlayerKnockbackLargeNoDamage(play, &this->actor, 8.0f, this->actor.yawTowardsPlayer, 8.0f); - player->invincibilityTimer = prevInvincibilityTimer; } + Actor_SetPlayerKnockbackLargeNoDamage(play, &this->actor, 8.0f, this->actor.yawTowardsPlayer, 8.0f); + player->invincibilityTimer = prevInvincibilityTimer; } - - Actor_MoveXZGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 75.0f, 30.0f, 30.0f, - UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_3 | - UPDBGCHECKINFO_FLAG_4); - - this->actor.focus.pos = this->actor.world.pos; - this->actor.focus.pos.y += 45.0f; - - Collider_UpdateCylinder(&this->actor, &this->bodyCollider); - CollisionCheck_SetOC(play, &play->colChkCtx, &this->bodyCollider.base); - - if ((this->actor.colChkInfo.health > 0) && (this->actor.colorFilterTimer == 0) && (this->unk_2F8 >= 2)) { - CollisionCheck_SetAC(play, &play->colChkCtx, &this->bodyCollider.base); - } - - if (this->unk_2FE > 0) { - CollisionCheck_SetAT(play, &play->colChkCtx, &this->axeCollider.base); - } - - if (this->unk_2F8 == 9) { - CollisionCheck_SetAC(play, &play->colChkCtx, &this->shieldCollider.base); - } + } + Actor_MoveXZGravity(&this->actor); + Actor_UpdateBgCheckInfo(play, &this->actor, 75.0f, 30.0f, 30.0f, + UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_3 | + UPDBGCHECKINFO_FLAG_4); + this->actor.focus.pos = this->actor.world.pos; + this->actor.focus.pos.y += 45.0f; + Collider_UpdateCylinder(&this->actor, &this->bodyCollider); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->bodyCollider.base); + if ((this->actor.colChkInfo.health > 0) && (this->actor.colorFilterTimer == 0) && (this->unk_2F8 >= 2)) { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->bodyCollider.base); + } + if (this->unk_2FE > 0) { + CollisionCheck_SetAT(play, &play->colChkCtx, &this->axeCollider.base); + } + if (this->unk_2F8 == 9) { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->shieldCollider.base); } } -Gfx* EnIk_SetPrimEnvColors(GraphicsContext* gfxCtx, u8 primR, u8 primG, u8 primB, u8 envR, u8 envG, u8 envB) { +Gfx* func_80A761B0(GraphicsContext* gfxCtx, u8 primR, u8 primG, u8 primB, u8 envR, u8 envG, u8 envB) { Gfx* displayList; Gfx* displayListHead; @@ -897,28 +826,26 @@ Gfx* EnIk_SetPrimEnvColors(GraphicsContext* gfxCtx, u8 primR, u8 primG, u8 primB return displayList; } -s32 EnIk_OverrideLimbDrawEnemy(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { +s32 EnIk_OverrideLimbDraw3(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { EnIk* this = (EnIk*)thisx; - if (limbIndex == IRON_KNUCKLE_LIMB_HELMET_ARMOR) { - if (this->actor.params != IK_TYPE_NABOORU) { - *dList = gIronKnuckleHelmetDL; + if (limbIndex == 12) { + if (this->actor.params != 0) { + *dList = object_ik_DL_018E78; } - } else if (limbIndex == IRON_KNUCKLE_LIMB_HEAD) { - if (this->actor.params != IK_TYPE_NABOORU) { - *dList = gIronKnuckleGerudoHeadDL; + } else if (limbIndex == 13) { + if (this->actor.params != 0) { + *dList = object_ik_DL_019100; } - } else if ((limbIndex == IRON_KNUCKLE_LIMB_CHEST_ARMOR_FRONT) || - (limbIndex == IRON_KNUCKLE_LIMB_CHEST_ARMOR_BACK)) { - if (this->drawArmorFlag & ARMOR_BROKEN) { + } else if ((limbIndex == 26) || (limbIndex == 27)) { + if ((this->unk_2FA & 1)) { *dList = NULL; } - } else if ((limbIndex == IRON_KNUCKLE_LIMB_TORSO) || (limbIndex == IRON_KNUCKLE_LIMB_WAIST)) { - if (!(this->drawArmorFlag & ARMOR_BROKEN)) { + } else if ((limbIndex == 28) || (limbIndex == 29)) { + if (!(this->unk_2FA & 1)) { *dList = NULL; } } - return false; } @@ -943,26 +870,24 @@ static Vec3f D_80A784D0[] = { { -3000.0, -700.0, -5000.0 }, }; -void EnIk_PostLimbDrawEnemy(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { +void EnIk_PostLimbDraw3(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { Vec3f spF4; Vec3f spE8; EnIk* this = (EnIk*)thisx; OPEN_DISPS(play->state.gfxCtx, "../z_en_ik_inFight.c", 1201); - if (this->armorStatusFlag & ARMOR_BROKEN) { - BodyBreak_SetInfo(&this->bodyBreak, limbIndex, IRON_KNUCKLE_LIMB_CHEST_ARMOR_FRONT, - IRON_KNUCKLE_LIMB_CHEST_ARMOR_BACK, IRON_KNUCKLE_LIMB_TORSO, dList, - BODYBREAK_OBJECT_SLOT_DEFAULT); + if (this->unk_2FB & 1) { + BodyBreak_SetInfo(&this->bodyBreak, limbIndex, 26, 27, 28, dList, BODYBREAK_OBJECT_SLOT_DEFAULT); } - if (limbIndex == IRON_KNUCKLE_LIMB_HELMET_ARMOR) { + if (limbIndex == 12) { MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx, "../z_en_ik_inFight.c", 1217); - if (this->actor.params != IK_TYPE_NABOORU) { - gSPDisplayList(POLY_XLU_DISP++, gIronKnuckleHelmetMarkingDL); + if (this->actor.params != 0) { + gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_019E08); } else { gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016D88); } - } else if (limbIndex == IRON_KNUCKLE_LIMB_AXE) { + } else if (limbIndex == 17) { s32 i; Vec3f sp9C[3]; Vec3f sp78[3]; @@ -993,25 +918,22 @@ void EnIk_PostLimbDrawEnemy(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* } switch (limbIndex) { - case IRON_KNUCKLE_LIMB_UPPER_LEFT_PAULDRON: + case 22: MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx, "../z_en_ik_inFight.c", 1270); gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016F88); break; - - case IRON_KNUCKLE_LIMB_UPPER_RIGHT_PAULDRON: + case 24: MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx, "../z_en_ik_inFight.c", 1275); gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016EE8); break; - - case IRON_KNUCKLE_LIMB_CHEST_ARMOR_FRONT: - if (!(this->drawArmorFlag & ARMOR_BROKEN)) { + case 26: + if (!(this->unk_2FA & 1)) { MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx, "../z_en_ik_inFight.c", 1281); - gSPDisplayList(POLY_XLU_DISP++, gIronKnuckleArmorRivetAndSymbolDL); + gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016BE0); } break; - - case IRON_KNUCKLE_LIMB_CHEST_ARMOR_BACK: - if (!(this->drawArmorFlag & ARMOR_BROKEN)) { + case 27: + if (!(this->unk_2FA & 1)) { MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx, "../z_en_ik_inFight.c", 1288); gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016CD8); } @@ -1021,7 +943,7 @@ void EnIk_PostLimbDrawEnemy(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* CLOSE_DISPS(play->state.gfxCtx, "../z_en_ik_inFight.c", 1294); } -void EnIk_DrawEnemy(Actor* thisx, PlayState* play) { +void func_80A76798(Actor* thisx, PlayState* play) { EnIk* this = (EnIk*)thisx; OPEN_DISPS(play->state.gfxCtx, "../z_en_ik_inFight.c", 1309); @@ -1029,36 +951,34 @@ void EnIk_DrawEnemy(Actor* thisx, PlayState* play) { Gfx_SetupDL_25Opa(play->state.gfxCtx); Gfx_SetupDL_25Xlu(play->state.gfxCtx); - if (this->actor.params == IK_TYPE_NABOORU) { - gSPSegment(POLY_OPA_DISP++, 0x08, EnIk_SetPrimEnvColors(play->state.gfxCtx, 245, 225, 155, 30, 30, 0)); - gSPSegment(POLY_OPA_DISP++, 0x09, EnIk_SetPrimEnvColors(play->state.gfxCtx, 255, 40, 0, 40, 0, 0)); - gSPSegment(POLY_OPA_DISP++, 0x0A, EnIk_SetPrimEnvColors(play->state.gfxCtx, 255, 255, 255, 20, 40, 30)); - } else if (this->actor.params == IK_TYPE_SILVER) { - gSPSegment(POLY_OPA_DISP++, 0x08, EnIk_SetPrimEnvColors(play->state.gfxCtx, 245, 255, 205, 30, 35, 0)); - gSPSegment(POLY_OPA_DISP++, 0x09, EnIk_SetPrimEnvColors(play->state.gfxCtx, 185, 135, 25, 20, 20, 0)); - gSPSegment(POLY_OPA_DISP++, 0x0A, EnIk_SetPrimEnvColors(play->state.gfxCtx, 255, 255, 255, 30, 40, 20)); - } else if (this->actor.params == IK_TYPE_BLACK) { - gSPSegment(POLY_OPA_DISP++, 0x08, EnIk_SetPrimEnvColors(play->state.gfxCtx, 55, 65, 55, 0, 0, 0)); - gSPSegment(POLY_OPA_DISP++, 0x09, EnIk_SetPrimEnvColors(play->state.gfxCtx, 205, 165, 75, 25, 20, 0)); - gSPSegment(POLY_OPA_DISP++, 0x0A, EnIk_SetPrimEnvColors(play->state.gfxCtx, 205, 165, 75, 25, 20, 0)); + if (this->actor.params == 0) { + gSPSegment(POLY_OPA_DISP++, 0x08, func_80A761B0(play->state.gfxCtx, 245, 225, 155, 30, 30, 0)); + gSPSegment(POLY_OPA_DISP++, 0x09, func_80A761B0(play->state.gfxCtx, 255, 40, 0, 40, 0, 0)); + gSPSegment(POLY_OPA_DISP++, 0x0A, func_80A761B0(play->state.gfxCtx, 255, 255, 255, 20, 40, 30)); + } else if (this->actor.params == 1) { + gSPSegment(POLY_OPA_DISP++, 0x08, func_80A761B0(play->state.gfxCtx, 245, 255, 205, 30, 35, 0)); + gSPSegment(POLY_OPA_DISP++, 0x09, func_80A761B0(play->state.gfxCtx, 185, 135, 25, 20, 20, 0)); + gSPSegment(POLY_OPA_DISP++, 0x0A, func_80A761B0(play->state.gfxCtx, 255, 255, 255, 30, 40, 20)); + } else if (this->actor.params == 2) { + gSPSegment(POLY_OPA_DISP++, 0x08, func_80A761B0(play->state.gfxCtx, 55, 65, 55, 0, 0, 0)); + gSPSegment(POLY_OPA_DISP++, 0x09, func_80A761B0(play->state.gfxCtx, 205, 165, 75, 25, 20, 0)); + gSPSegment(POLY_OPA_DISP++, 0x0A, func_80A761B0(play->state.gfxCtx, 205, 165, 75, 25, 20, 0)); } else { - gSPSegment(POLY_OPA_DISP++, 0x08, EnIk_SetPrimEnvColors(play->state.gfxCtx, 255, 255, 255, 180, 180, 180)); - gSPSegment(POLY_OPA_DISP++, 0x09, EnIk_SetPrimEnvColors(play->state.gfxCtx, 225, 205, 115, 25, 20, 0)); - gSPSegment(POLY_OPA_DISP++, 0x0A, EnIk_SetPrimEnvColors(play->state.gfxCtx, 225, 205, 115, 25, 20, 0)); + gSPSegment(POLY_OPA_DISP++, 0x08, func_80A761B0(play->state.gfxCtx, 255, 255, 255, 180, 180, 180)); + gSPSegment(POLY_OPA_DISP++, 0x09, func_80A761B0(play->state.gfxCtx, 225, 205, 115, 25, 20, 0)); + gSPSegment(POLY_OPA_DISP++, 0x0A, func_80A761B0(play->state.gfxCtx, 225, 205, 115, 25, 20, 0)); } - SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnIk_OverrideLimbDrawEnemy, EnIk_PostLimbDrawEnemy, this); + EnIk_OverrideLimbDraw3, EnIk_PostLimbDraw3, this); CLOSE_DISPS(play->state.gfxCtx, "../z_en_ik_inFight.c", 1351); } -void EnIk_StartMinibossBgm(void) { +void EnIk_StartMusic(void) { func_800F5ACC(NA_BGM_MINI_BOSS); } -// Cutscene: Nabooru Knuckle Wakes up -void EnIk_UpdateAction2Sfx(EnIk* this) { +void func_80A76C14(EnIk* this) { if (Animation_OnFrame(&this->skelAnime, 1.0f)) { SFX_PLAY_AT_POS(&this->actor.projectedPos, NA_SE_EN_IRONNACK_WAKEUP); } else if (Animation_OnFrame(&this->skelAnime, 33.0f)) { @@ -1074,13 +994,12 @@ void EnIk_UpdateAction2Sfx(EnIk* this) { } } -// Cutscene: Summons Axe for Nabooru Knuckle -void EnIk_PlayAxeSpawnSfx(EnIk* this, PlayState* play, Vec3f* pos) { +void func_80A76DDC(EnIk* this, PlayState* play, Vec3f* pos) { SFX_PLAY_AT_POS(&this->actor.projectedPos, NA_SE_EN_TWINROBA_TRANSFORM); } -void EnIk_SpawnAxeSmoke(EnIk* this, PlayState* play, Vec3f* pos) { - static Vec3f sAxeSmokeEffectData[] = { +void func_80A76E2C(EnIk* this, PlayState* play, Vec3f* pos) { + static Vec3f D_80A78514[] = { { 1000.0, -1000.0, 1000.0 }, { 0.0, -1000.0, 0.0 }, { -1000.0, -5000.0, -4000.0 }, { 1000.0, -5000.0, -3000.0 }, { -1000.0, 1000.0, -6000.0 }, { -1000.0, 3000.0, -5000.0 }, { -800.0, 1000.0, -3000.0 }, { 0.0, -4000.0, -2000.0 }, { -1000.0, -2000.0, -6000.0 }, @@ -1090,43 +1009,40 @@ void EnIk_SpawnAxeSmoke(EnIk* this, PlayState* play, Vec3f* pos) { { 900.0, -800.0, 2700.0 }, { 720.0f, 900.0f, 2500.0f }, }; - if (!this->isAxeSummoned) { + if (this->unk_4D4 == 0) { STACK_PAD(s32); Vec3f effectVelocity = { 0.0f, 0.0f, 0.0f }; Vec3f effectAccel = { 0.0f, 0.3f, 0.0f }; s32 i; - for (i = ARRAY_COUNT(sAxeSmokeEffectData) - 1; i >= 0; i--) { + for (i = ARRAY_COUNT(D_80A78514) - 1; i >= 0; i--) { Color_RGBA8 primColor = { 200, 200, 200, 255 }; Color_RGBA8 envColor = { 150, 150, 150, 0 }; - s32 randColorOffset; + s32 temp_v0; Vec3f effectPos; - Matrix_MultVec3f(&sAxeSmokeEffectData[i], &effectPos); - randColorOffset = (Rand_ZeroOne() * 20.0f) - 10.0f; - - primColor.r += randColorOffset; - primColor.g += randColorOffset; - primColor.b += randColorOffset; - - envColor.r += randColorOffset; - envColor.g += randColorOffset; - envColor.b += randColorOffset; - + Matrix_MultVec3f(&D_80A78514[i], &effectPos); + temp_v0 = (Rand_ZeroOne() * 20.0f) - 10.0f; + primColor.r += temp_v0; + primColor.g += temp_v0; + primColor.b += temp_v0; + envColor.r += temp_v0; + envColor.g += temp_v0; + envColor.b += temp_v0; func_8002829C(play, &effectPos, &effectVelocity, &effectAccel, &primColor, &envColor, (Rand_ZeroOne() * 60.0f) + 300.0f, 0); } - this->isAxeSummoned = true; - EnIk_PlayAxeSpawnSfx(this, play, pos); + this->unk_4D4 = 1; + func_80A76DDC(this, play, pos); } } -void EnIk_UpdateBgCheckInfo(EnIk* this, PlayState* play) { +void func_80A77034(EnIk* this, PlayState* play) { Actor_UpdateBgCheckInfo(play, &this->actor, 75.0f, 30.0f, 30.0f, UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_2); } -s32 EnIk_UpdateSkelAnime(EnIk* this) { +s32 func_80A7707C(EnIk* this) { return SkelAnime_Update(&this->skelAnime); } @@ -1152,50 +1068,47 @@ void EnIk_SetStartPosRotFromCue(EnIk* this, PlayState* play, s32 cueChannel) { } } -f32 EnIk_GetAnimCurFrame(Actor* thisx) { +f32 EnIk_curFrame(Actor* thisx) { EnIk* this = (EnIk*)thisx; return this->skelAnime.curFrame; } -// unused -void EnIk_SetupCsAction0(EnIk* this) { - this->csAction = IK_CS_ACTION_0; - this->csDrawMode = IK_CS_DRAW_NOTHING; +void func_80A77148(EnIk* this) { + this->action = 0; + this->drawMode = 0; this->actor.shape.shadowAlpha = 0; } -// Cutscene: Nabooru sitting and Kotake and Koume looking at her -void EnIk_SetupCsAction1(EnIk* this, PlayState* play) { - Animation_Change(&this->skelAnime, &gIronKnuckleNabooruSummonAxeAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gIronKnuckleNabooruSummonAxeAnim), ANIMMODE_ONCE, 0.0f); +void func_80A77158(EnIk* this, PlayState* play) { + Animation_Change(&this->skelAnime, &object_ik_Anim_00C114, 1.0f, 0.0f, + Animation_GetLastFrame(&object_ik_Anim_00C114), ANIMMODE_ONCE, 0.0f); EnIk_SetStartPosRotFromCue(this, play, 4); - this->csAction = IK_CS_ACTION_1; - this->csDrawMode = IK_CS_DRAW_INTRO; - this->actor.shape.shadowAlpha = 255; + this->action = 1; + this->drawMode = 1; + this->actor.shape.shadowAlpha = 0xFF; } -// Cutscene: Nabooru Knuckle starts to stand up -void EnIk_SetupCsAction2(EnIk* this) { - Animation_Change(&this->skelAnime, &gIronKnuckleNabooruSummonAxeAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gIronKnuckleNabooruSummonAxeAnim), ANIMMODE_ONCE, 0.0f); - this->csAction = IK_CS_ACTION_2; - this->csDrawMode = IK_CS_DRAW_INTRO; - this->isAxeSummoned = false; - this->actor.shape.shadowAlpha = 255; +void func_80A771E4(EnIk* this) { + Animation_Change(&this->skelAnime, &object_ik_Anim_00C114, 1.0f, 0.0f, + Animation_GetLastFrame(&object_ik_Anim_00C114), ANIMMODE_ONCE, 0.0f); + this->action = 2; + this->drawMode = 1; + this->unk_4D4 = 0; + this->actor.shape.shadowAlpha = 0xFF; } -void EnIk_HandleEnemyChange(EnIk* this, PlayState* play, s32 animFinished) { - if (animFinished && (EnIk_GetCue(play, 4) != NULL)) { - EnIk_ChangeToEnemy(this, play); +void func_80A77264(EnIk* this, PlayState* play, s32 arg2) { + if ((arg2 != 0) && (EnIk_GetCue(play, 4) != NULL)) { + func_80A78160(this, play); } } -void EnIk_PlayArmorFallSfx(EnIk* this) { +void func_80A772A4(EnIk* this) { SFX_PLAY_AT_POS(&this->actor.projectedPos, NA_SE_EN_IRONNACK_STAGGER_DEMO); } -void EnIk_PlayDeathSfx(EnIk* this, PlayState* play) { +void func_80A772EC(EnIk* this, PlayState* play) { static Vec3f D_80A78FA0; STACK_PADS(s32, 2); f32 wDest; @@ -1204,116 +1117,107 @@ void EnIk_PlayDeathSfx(EnIk* this, PlayState* play) { SFX_PLAY_AT_POS(&D_80A78FA0, NA_SE_EN_IRONNACK_DEAD); } -// Cutscene: starts after final hit to Nabooru -void EnIk_SetupCsAction3(EnIk* this, PlayState* play) { +void func_80A7735C(EnIk* this, PlayState* play) { STACK_PADS(s32, 3); - f32 endFrame = Animation_GetLastFrame(&gIronKnuckleNabooruDeathAnim); + f32 frames = Animation_GetLastFrame(&object_ik_Anim_0203D8); - SkelAnime_InitFlex(play, &this->skelAnime, &gIronKnuckleDefeatSkel, NULL, this->jointTable, this->morphTable, - IRON_KNUCKLE_LIMB_MAX); - Animation_Change(&this->skelAnime, &gIronKnuckleNabooruDeathAnim, 1.0f, 0.0f, endFrame, ANIMMODE_ONCE, 0.0f); - this->csAction = IK_CS_ACTION_3; - this->csDrawMode = IK_CS_DRAW_DEFEAT; + SkelAnime_InitFlex(play, &this->skelAnime, &object_ik_Skel_0205C0, NULL, this->jointTable, this->morphTable, 30); + Animation_Change(&this->skelAnime, &object_ik_Anim_0203D8, 1.0f, 0.0f, frames, ANIMMODE_ONCE, 0.0f); + this->action = 3; + this->drawMode = 2; EnIk_SetStartPosRotFromCue(this, play, 4); - EnIk_PlayDeathSfx(this, play); - this->actor.shape.shadowAlpha = 255; + func_80A772EC(this, play); + this->actor.shape.shadowAlpha = 0xFF; } -// Cutscene: Armor falling off revealing Nabooru underneath -void EnIk_SetupCsAction4(EnIk* this, PlayState* play) { - this->csAction = IK_CS_ACTION_4; - this->csDrawMode = IK_CS_DRAW_DEFEAT; - EnIk_PlayArmorFallSfx(this); - this->actor.shape.shadowAlpha = 255; +void func_80A77434(EnIk* this, PlayState* play) { + this->action = 4; + this->drawMode = 2; + func_80A772A4(this); + this->actor.shape.shadowAlpha = 0xFF; } -// Cutscene: all the armor has fallen off -void EnIk_SetupCsAction5(EnIk* this, PlayState* play) { - this->csAction = IK_CS_ACTION_5; - this->csDrawMode = IK_CS_DRAW_NOTHING; +void func_80A77474(EnIk* this, PlayState* play) { + this->action = 5; + this->drawMode = 0; this->actor.shape.shadowAlpha = 0; } -void EnIk_CsAction3(EnIk* this, PlayState* play) { - EnIk_UpdateBgCheckInfo(this, play); - EnIk_HandleCsCues(this, play); +void func_80A7748C(EnIk* this, PlayState* play) { + func_80A77034(this, play); + func_80A779DC(this, play); } -void EnIk_CsAction4(EnIk* this, PlayState* play) { - EnIk_UpdateSkelAnime(this); - EnIk_UpdateBgCheckInfo(this, play); - EnIk_HandleCsCues(this, play); +void func_80A774BC(EnIk* this, PlayState* play) { + func_80A7707C(this); + func_80A77034(this, play); + func_80A779DC(this, play); } -void EnIk_CsAction5(EnIk* this, PlayState* play) { +void func_80A774F8(EnIk* this, PlayState* play) { if (EnIk_GetCue(play, 4) == NULL) { #if OOT_PAL_N64 - Flags_SetSwitch(play, this->switchFlag); + Flags_SetSwitch(play, this->switchFlags); #endif Actor_Kill(&this->actor); } } -s32 EnIk_OverrideLimbDrawDefeat(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - if ((limbIndex == IRON_KNUCKLE_DEFEAT_LIMB_HELMET_ARMOR) || - (limbIndex == IRON_KNUCKLE_DEFEAT_LIMB_CHEST_ARMOR_FRONT) || - (limbIndex == IRON_KNUCKLE_DEFEAT_LIMB_CHEST_ARMOR_BACK)) { - if (EnIk_GetAnimCurFrame(thisx) >= 30.0f) { +s32 EnIk_OverrideLimbDraw2(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + EnIk* this = (EnIk*)thisx; + + if ((limbIndex == 13) || (limbIndex == 26) || (limbIndex == 27)) { + if (EnIk_curFrame(&this->actor) >= 30.0f) { *dList = NULL; } } - return false; + return 0; } -void EnIk_PostLimbDrawDefeat(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { +void EnIk_PostLimbDraw2(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { GraphicsContext* gfxCtx = play->state.gfxCtx; OPEN_DISPS(gfxCtx, "../z_en_ik_inAwake.c", 207); switch (limbIndex) { - case IRON_KNUCKLE_DEFEAT_LIMB_HELMET_ARMOR: { + case 13: { EnIk* this = (EnIk*)thisx; - if (EnIk_GetAnimCurFrame(&this->actor) < 30.0f) { + if (EnIk_curFrame(&this->actor) < 30.0f) { MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, gfxCtx, "../z_en_ik_inAwake.c", 267); gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016D88); } } break; - - case IRON_KNUCKLE_DEFEAT_LIMB_UPPER_LEFT_PAULDRON: + case 22: MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, gfxCtx, "../z_en_ik_inAwake.c", 274); gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016F88); break; - - case IRON_KNUCKLE_DEFEAT_LIMB_UPPER_RIGHT_PAULDRON: + case 24: MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, gfxCtx, "../z_en_ik_inAwake.c", 280); gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016EE8); break; - - case IRON_KNUCKLE_DEFEAT_LIMB_CHEST_ARMOR_FRONT: { + case 26: { EnIk* this = (EnIk*)thisx; - if (EnIk_GetAnimCurFrame(&this->actor) < 30.0f) { + if (EnIk_curFrame(&this->actor) < 30.0f) { MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, gfxCtx, "../z_en_ik_inAwake.c", 288); - gSPDisplayList(POLY_XLU_DISP++, gIronKnuckleArmorRivetAndSymbolDL); + gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016BE0); } } break; - - case IRON_KNUCKLE_DEFEAT_LIMB_CHEST_ARMOR_BACK: { + case 27: { EnIk* this = (EnIk*)thisx; - if (EnIk_GetAnimCurFrame(&this->actor) < 30.0f) { + if (EnIk_curFrame(&this->actor) < 30.0f) { MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, gfxCtx, "../z_en_ik_inAwake.c", 297); gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016CD8); } } break; } - CLOSE_DISPS(gfxCtx, "../z_en_ik_inAwake.c", 304); } -void EnIk_CsDrawDefeat(EnIk* this, PlayState* play) { +void func_80A77844(EnIk* this, PlayState* play) { GraphicsContext* gfxCtx = play->state.gfxCtx; SkelAnime* skelAnime = &this->skelAnime; STACK_PADS(s32, 2); @@ -1323,16 +1227,16 @@ void EnIk_CsDrawDefeat(EnIk* this, PlayState* play) { func_8002EBCC(&this->actor, play, 0); Gfx_SetupDL_25Opa(gfxCtx); Gfx_SetupDL_25Xlu(gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, EnIk_SetPrimEnvColors(gfxCtx, 245, 225, 155, 30, 30, 0)); - gSPSegment(POLY_OPA_DISP++, 0x09, EnIk_SetPrimEnvColors(gfxCtx, 255, 40, 0, 40, 0, 0)); - gSPSegment(POLY_OPA_DISP++, 0x0A, EnIk_SetPrimEnvColors(gfxCtx, 255, 255, 255, 20, 40, 30)); + gSPSegment(POLY_OPA_DISP++, 0x08, func_80A761B0(gfxCtx, 245, 225, 155, 30, 30, 0)); + gSPSegment(POLY_OPA_DISP++, 0x09, func_80A761B0(gfxCtx, 255, 40, 0, 40, 0, 0)); + gSPSegment(POLY_OPA_DISP++, 0x0A, func_80A761B0(gfxCtx, 255, 255, 255, 20, 40, 30)); SkelAnime_DrawFlexOpa(play, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, - EnIk_OverrideLimbDrawDefeat, EnIk_PostLimbDrawDefeat, this); + EnIk_OverrideLimbDraw2, EnIk_PostLimbDraw2, this); CLOSE_DISPS(gfxCtx, "../z_en_ik_inAwake.c", 345); } -void EnIk_HandleCsCues(EnIk* this, PlayState* play) { +void func_80A779DC(EnIk* this, PlayState* play) { CsCmdActorCue* cue = EnIk_GetCue(play, 4); u32 nextCueId; u32 currentCueId; @@ -1340,37 +1244,29 @@ void EnIk_HandleCsCues(EnIk* this, PlayState* play) { if (cue != NULL) { nextCueId = cue->id; currentCueId = this->cueId; - if (nextCueId != currentCueId) { switch (nextCueId) { case 1: - EnIk_SetupCsAction0(this); + func_80A77148(this); break; - case 2: - EnIk_SetupCsAction1(this, play); + func_80A77158(this, play); break; - case 3: - EnIk_SetupCsAction2(this); + func_80A771E4(this); break; - case 4: - EnIk_ChangeToEnemy(this, play); + func_80A78160(this, play); break; - case 5: - EnIk_SetupCsAction3(this, play); + func_80A7735C(this, play); break; - case 6: - EnIk_SetupCsAction4(this, play); + func_80A77434(this, play); break; - case 7: - EnIk_SetupCsAction5(this, play); + func_80A77474(this, play); break; - default: PRINTF(T("En_Ik_inConfrontion_Check_DemoMode:そんな動作は無い!!!!!!!!\n", "En_Ik_inConfrontion_Check_DemoMode: There is no such action!!!!!!!!\n")); @@ -1381,91 +1277,86 @@ void EnIk_HandleCsCues(EnIk* this, PlayState* play) { } } -void EnIk_CsAction0(EnIk* this, PlayState* play) { - EnIk_HandleCsCues(this, play); +void func_80A77AEC(EnIk* this, PlayState* play) { + func_80A779DC(this, play); } -void EnIk_CsAction1(EnIk* this, PlayState* play) { - EnIk_UpdateBgCheckInfo(this, play); - EnIk_HandleCsCues(this, play); +void func_80A77B0C(EnIk* this, PlayState* play) { + func_80A77034(this, play); + func_80A779DC(this, play); } -void EnIk_CsAction2(EnIk* this, PlayState* play) { - s32 animFinished; +void func_80A77B3C(EnIk* this, PlayState* play) { + s32 sp24; - animFinished = EnIk_UpdateSkelAnime(this); - EnIk_UpdateAction2Sfx(this); - EnIk_UpdateBgCheckInfo(this, play); - EnIk_HandleCsCues(this, play); - EnIk_HandleEnemyChange(this, play, animFinished); + sp24 = func_80A7707C(this); + func_80A76C14(this); + func_80A77034(this, play); + func_80A779DC(this, play); + func_80A77264(this, play, sp24); } -static EnIkActionFunc sCsActionFuncs[] = { - EnIk_CsAction0, EnIk_CsAction1, EnIk_CsAction2, EnIk_CsAction3, EnIk_CsAction4, EnIk_CsAction5, +static EnIkActionFunc sActionFuncs[] = { + func_80A77AEC, func_80A77B0C, func_80A77B3C, func_80A7748C, func_80A774BC, func_80A774F8, }; -void EnIk_UpdateCutscene(Actor* thisx, PlayState* play) { +void EnIk_Update(Actor* thisx, PlayState* play) { EnIk* this = (EnIk*)thisx; - if (this->csAction < 0 || this->csAction >= ARRAY_COUNT(sCsActionFuncs) || sCsActionFuncs[this->csAction] == NULL) { + if (this->action < 0 || this->action >= ARRAY_COUNT(sActionFuncs) || sActionFuncs[this->action] == NULL) { PRINTF(VT_FGCOL(RED) T("メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n", "The main mode is wrong!!!!!!!!!!!!!!!!!!!!!!!!!\n") VT_RST); return; } - sCsActionFuncs[this->csAction](this, play); + sActionFuncs[this->action](this, play); } -s32 EnIk_OverrideLimbDrawIntro(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { +s32 EnIk_OverrideLimbDraw1(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { EnIk* this = (EnIk*)thisx; f32 curFrame; switch (limbIndex) { - case IRON_KNUCKLE_LIMB_AXE: + case 17: curFrame = this->skelAnime.curFrame; if (curFrame < 120.0f) { *dList = NULL; } else { - EnIk_SpawnAxeSmoke(this, play, pos); + func_80A76E2C(this, play, pos); } break; - - case IRON_KNUCKLE_LIMB_WAIST: - case IRON_KNUCKLE_LIMB_MAX: + case 29: + case 30: *dList = NULL; break; } - return false; + return 0; } -void EnIk_PostLimbDrawIntro(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { +void EnIk_PostLimbDraw1(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { GraphicsContext* gfxCtx = play->state.gfxCtx; OPEN_DISPS(gfxCtx, "../z_en_ik_inConfrontion.c", 571); switch (limbIndex) { - case IRON_KNUCKLE_LIMB_HELMET_ARMOR: + case 12: MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, gfxCtx, "../z_en_ik_inConfrontion.c", 575); gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016D88); break; - - case IRON_KNUCKLE_LIMB_UPPER_LEFT_PAULDRON: + case 22: MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, gfxCtx, "../z_en_ik_inConfrontion.c", 581); gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016F88); break; - - case IRON_KNUCKLE_LIMB_UPPER_RIGHT_PAULDRON: + case 24: MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, gfxCtx, "../z_en_ik_inConfrontion.c", 587); gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016EE8); break; - - case IRON_KNUCKLE_LIMB_CHEST_ARMOR_FRONT: + case 26: MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, gfxCtx, "../z_en_ik_inConfrontion.c", 593); - gSPDisplayList(POLY_XLU_DISP++, gIronKnuckleArmorRivetAndSymbolDL); + gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016BE0); break; - - case IRON_KNUCKLE_LIMB_CHEST_ARMOR_BACK: + case 27: MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, gfxCtx, "../z_en_ik_inConfrontion.c", 599); gSPDisplayList(POLY_XLU_DISP++, object_ik_DL_016CD8); break; @@ -1474,10 +1365,10 @@ void EnIk_PostLimbDrawIntro(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* CLOSE_DISPS(gfxCtx, "../z_en_ik_inConfrontion.c", 604); } -void EnIk_CsDrawNothing(EnIk* this, PlayState* play) { +void func_80A77ED0(EnIk* this, PlayState* play) { } -void EnIk_CsDrawIntro(EnIk* this, PlayState* play) { +void func_80A77EDC(EnIk* this, PlayState* play) { GraphicsContext* gfxCtx = play->state.gfxCtx; SkelAnime* skelAnime = &this->skelAnime; STACK_PADS(s32, 2); @@ -1487,82 +1378,79 @@ void EnIk_CsDrawIntro(EnIk* this, PlayState* play) { func_8002EBCC(&this->actor, play, 0); Gfx_SetupDL_25Opa(gfxCtx); Gfx_SetupDL_25Xlu(gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, EnIk_SetPrimEnvColors(gfxCtx, 245, 225, 155, 30, 30, 0)); - gSPSegment(POLY_OPA_DISP++, 0x09, EnIk_SetPrimEnvColors(gfxCtx, 255, 40, 0, 40, 0, 0)); - gSPSegment(POLY_OPA_DISP++, 0x0A, EnIk_SetPrimEnvColors(gfxCtx, 255, 255, 255, 20, 40, 30)); + gSPSegment(POLY_OPA_DISP++, 0x08, func_80A761B0(gfxCtx, 245, 225, 155, 30, 30, 0)); + gSPSegment(POLY_OPA_DISP++, 0x09, func_80A761B0(gfxCtx, 255, 40, 0, 40, 0, 0)); + gSPSegment(POLY_OPA_DISP++, 0x0A, func_80A761B0(gfxCtx, 255, 255, 255, 20, 40, 30)); SkelAnime_DrawFlexOpa(play, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, - EnIk_OverrideLimbDrawIntro, EnIk_PostLimbDrawIntro, this); + EnIk_OverrideLimbDraw1, EnIk_PostLimbDraw1, this); CLOSE_DISPS(gfxCtx, "../z_en_ik_inConfrontion.c", 653); } -static EnIkDrawFunc sCsDrawFuncs[] = { EnIk_CsDrawNothing, EnIk_CsDrawIntro, EnIk_CsDrawDefeat }; +static EnIkDrawFunc sDrawFuncs[] = { func_80A77ED0, func_80A77EDC, func_80A77844 }; -void EnIk_DrawCutscene(Actor* thisx, PlayState* play) { +void EnIk_Draw(Actor* thisx, PlayState* play) { EnIk* this = (EnIk*)thisx; - if (this->csDrawMode < 0 || this->csDrawMode >= ARRAY_COUNT(sCsDrawFuncs) || - sCsDrawFuncs[this->csDrawMode] == NULL) { + if (this->drawMode < 0 || this->drawMode >= ARRAY_COUNT(sDrawFuncs) || sDrawFuncs[this->drawMode] == NULL) { PRINTF(VT_FGCOL(RED) T("描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n", "The drawing mode is wrong!!!!!!!!!!!!!!!!!!!!!!!!!\n") VT_RST); return; } - sCsDrawFuncs[this->csDrawMode](this, play); + sDrawFuncs[this->drawMode](this, play); } -void EnIk_CsInit(EnIk* this, PlayState* play) { - if (this->actor.params == IK_TYPE_NABOORU) { +void func_80A780D0(EnIk* this, PlayState* play) { + if (this->actor.params == 0) { if (!GET_EVENTCHKINF(EVENTCHKINF_3B)) { - this->actor.update = EnIk_UpdateCutscene; - this->actor.draw = EnIk_DrawCutscene; + this->actor.update = EnIk_Update; + this->actor.draw = EnIk_Draw; Actor_SetScale(&this->actor, 0.01f); } else { - EnIk_ChangeToEnemy(this, play); - EnIk_StartMinibossBgm(); + func_80A78160(this, play); + EnIk_StartMusic(); } } - PRINTF("En_Ik_inConfrontion_Init : %d !!!!!!!!!!!!!!!!\n", this->actor.params); } -void EnIk_ChangeToEnemy(EnIk* this, PlayState* play) { - this->actor.update = EnIk_UpdateEnemy; - this->actor.draw = EnIk_DrawEnemy; +void func_80A78160(EnIk* this, PlayState* play) { + this->actor.update = func_80A75FA0; + this->actor.draw = func_80A76798; this->actor.flags |= ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_HOSTILE; SET_EVENTCHKINF(EVENTCHKINF_3B); Actor_SetScale(&this->actor, 0.012f); - EnIk_SetupIdle(this); + func_80A7489C(this); } -void EnIk_StartDefeatCutscene(Actor* thisx, PlayState* play) { +void func_80A781CC(Actor* thisx, PlayState* play) { EnIk* this = (EnIk*)thisx; if (!Play_InCsMode(play)) { - this->actor.update = EnIk_UpdateCutscene; - this->actor.draw = EnIk_DrawCutscene; + this->actor.update = EnIk_Update; + this->actor.draw = EnIk_Draw; Cutscene_SetScript(play, gSpiritBossNabooruKnuckleDefeatCs); gSaveContext.cutsceneTrigger = 1; Actor_SetScale(&this->actor, 0.01f); SET_EVENTCHKINF(EVENTCHKINF_DEFEATED_NABOORU_KNUCKLE); - EnIk_SetupCsAction3(this, play); + func_80A7735C(this, play); } } void EnIk_Init(Actor* thisx, PlayState* play) { EnIk* this = (EnIk*)thisx; - s32 upperParams = IK_GET_UPPER_PARAMS(&this->actor); + s32 flag = this->actor.params & 0xFF00; - if (((IK_GET_ARMOR_TYPE(&this->actor) == IK_TYPE_NABOORU) && - GET_EVENTCHKINF(EVENTCHKINF_DEFEATED_NABOORU_KNUCKLE)) || - (upperParams != 0 && Flags_GetSwitch(play, upperParams >> 8))) { + if (((this->actor.params & 0xFF) == 0 && GET_EVENTCHKINF(EVENTCHKINF_DEFEATED_NABOORU_KNUCKLE)) || + (flag != 0 && Flags_GetSwitch(play, flag >> 8))) { Actor_Kill(&this->actor); } else { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - SkelAnime_InitFlex(play, &this->skelAnime, &gIronKnuckleSkel, &gIronKnuckleNabooruSummonAxeAnim, - this->jointTable, this->morphTable, IRON_KNUCKLE_LIMB_MAX); - EnIk_InitImpl(&this->actor, play); - EnIk_CsInit(this, play); + SkelAnime_InitFlex(play, &this->skelAnime, &object_ik_Skel_01E178, &object_ik_Anim_00C114, this->jointTable, + this->morphTable, 30); + func_80A74398(&this->actor, play); + func_80A780D0(this, play); } } @@ -1574,6 +1462,6 @@ ActorProfile En_Ik_Profile = { /**/ sizeof(EnIk), /**/ EnIk_Init, /**/ EnIk_Destroy, - /**/ EnIk_UpdateCutscene, - /**/ EnIk_DrawCutscene, + /**/ EnIk_Update, + /**/ EnIk_Draw, }; 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 9ae2a9cee4a..fb0bb5d8e25 100644 --- a/src/overlays/actors/ovl_En_Ik/z_en_ik.h +++ b/src/overlays/actors/ovl_En_Ik/z_en_ik.h @@ -8,102 +8,21 @@ struct EnIk; typedef void (*EnIkActionFunc)(struct EnIk*, struct PlayState*); -#define IK_GET_UPPER_PARAMS(thisx) PARAMS_GET_NOSHIFT(this->actor.params, 8, 8) -#define IK_GET_ARMOR_TYPE(thisx) PARAMS_GET_U((thisx)->params, 0, 8) -#define IK_GET_SWITCH_FLAG(thisx) PARAMS_GET_U((thisx)->params, 8, 8) - -typedef enum EnIkType { - /* 0 */ IK_TYPE_NABOORU, - /* 1 */ IK_TYPE_SILVER, - /* 2 */ IK_TYPE_BLACK, - /* 3 */ IK_TYPE_WHITE -} EnIkType; - -typedef enum IronKnuckleLimb { - /* 0x00 */ IRON_KNUCKLE_LIMB_NONE, - /* 0x01 */ IRON_KNUCKLE_LIMB_ROOT, - /* 0x02 */ IRON_KNUCKLE_LIMB_LOWER_BODY, - /* 0x03 */ IRON_KNUCKLE_LIMB_RIGHT_THIGH, - /* 0x04 */ IRON_KNUCKLE_LIMB_RIGHT_SHIN, - /* 0x05 */ IRON_KNUCKLE_LIMB_RIGHT_FOOT, - /* 0x06 */ IRON_KNUCKLE_LIMB_LEFT_THIGH, - /* 0x07 */ IRON_KNUCKLE_LIMB_LEFT_SHIN, - /* 0x08 */ IRON_KNUCKLE_LIMB_LEFT_FOOT, - /* 0x09 */ IRON_KNUCKLE_LIMB_UPPER_BODY_ROOT, - /* 0x0A */ IRON_KNUCKLE_LIMB_UPPER_BODY, - /* 0x0B */ IRON_KNUCKLE_LIMB_HEAD_ROOT, - /* 0x0C */ IRON_KNUCKLE_LIMB_HELMET_ARMOR, - /* 0x0D */ IRON_KNUCKLE_LIMB_HEAD, - /* 0x0E */ IRON_KNUCKLE_LIMB_RIGHT_UPPER_ARM, - /* 0x0F */ IRON_KNUCKLE_LIMB_RIGHT_FOREARM, - /* 0x10 */ IRON_KNUCKLE_LIMB_RIGHT_HAND_ROOT, - /* 0x11 */ IRON_KNUCKLE_LIMB_AXE, - /* 0x12 */ IRON_KNUCKLE_LIMB_RIGHT_HAND, - /* 0x13 */ IRON_KNUCKLE_LIMB_LEFT_UPPER_ARM, - /* 0x14 */ IRON_KNUCKLE_LIMB_LEFT_FOREARM, - /* 0x15 */ IRON_KNUCKLE_LIMB_LEFT_HAND, - /* 0x16 */ IRON_KNUCKLE_LIMB_UPPER_LEFT_PAULDRON, - /* 0x17 */ IRON_KNUCKLE_LIMB_LOWER_LEFT_PAULDRON, - /* 0x18 */ IRON_KNUCKLE_LIMB_UPPER_RIGHT_PAULDRON, - /* 0x19 */ IRON_KNUCKLE_LIMB_LOWER_RIGHT_PAULDRON, - /* 0x1A */ IRON_KNUCKLE_LIMB_CHEST_ARMOR_FRONT, - /* 0x1B */ IRON_KNUCKLE_LIMB_CHEST_ARMOR_BACK, - /* 0x1C */ IRON_KNUCKLE_LIMB_TORSO, - /* 0x1D */ IRON_KNUCKLE_LIMB_WAIST, - /* 0x1E */ IRON_KNUCKLE_LIMB_MAX -} IronKnuckleLimb; - -// This skeleton is only used in the defeat cutscene that reveals Nabooru under the armor. -// The only difference between this skeleton and the main one is that the head and helmet armor limbs are swapped. -typedef enum IronKnuckleDefeatLimb { - /* 0x00 */ IRON_KNUCKLE_DEFEAT_LIMB_NONE, - /* 0x01 */ IRON_KNUCKLE_DEFEAT_LIMB_ROOT, - /* 0x02 */ IRON_KNUCKLE_DEFEAT_LIMB_LOWER_BODY, - /* 0x03 */ IRON_KNUCKLE_DEFEAT_LIMB_RIGHT_THIGH, - /* 0x04 */ IRON_KNUCKLE_DEFEAT_LIMB_RIGHT_SHIN, - /* 0x05 */ IRON_KNUCKLE_DEFEAT_LIMB_RIGHT_FOOT, - /* 0x06 */ IRON_KNUCKLE_DEFEAT_LIMB_LEFT_THIGH, - /* 0x07 */ IRON_KNUCKLE_DEFEAT_LIMB_LEFT_SHIN, - /* 0x08 */ IRON_KNUCKLE_DEFEAT_LIMB_LEFT_FOOT, - /* 0x09 */ IRON_KNUCKLE_DEFEAT_LIMB_UPPER_BODY_ROOT, - /* 0x0A */ IRON_KNUCKLE_DEFEAT_LIMB_UPPER_BODY, - /* 0x0B */ IRON_KNUCKLE_DEFEAT_LIMB_HEAD_ROOT, - /* 0x0C */ IRON_KNUCKLE_DEFEAT_LIMB_HEAD, - /* 0x0D */ IRON_KNUCKLE_DEFEAT_LIMB_HELMET_ARMOR, - /* 0x0E */ IRON_KNUCKLE_DEFEAT_LIMB_RIGHT_UPPER_ARM, - /* 0x0F */ IRON_KNUCKLE_DEFEAT_LIMB_RIGHT_FOREARM, - /* 0x10 */ IRON_KNUCKLE_DEFEAT_LIMB_RIGHT_HAND_ROOT, - /* 0x11 */ IRON_KNUCKLE_DEFEAT_LIMB_AXE, - /* 0x12 */ IRON_KNUCKLE_DEFEAT_LIMB_RIGHT_HAND, - /* 0x13 */ IRON_KNUCKLE_DEFEAT_LIMB_LEFT_UPPER_ARM, - /* 0x14 */ IRON_KNUCKLE_DEFEAT_LIMB_LEFT_FOREARM, - /* 0x15 */ IRON_KNUCKLE_DEFEAT_LIMB_LEFT_HAND, - /* 0x16 */ IRON_KNUCKLE_DEFEAT_LIMB_UPPER_LEFT_PAULDRON, - /* 0x17 */ IRON_KNUCKLE_DEFEAT_LIMB_LOWER_LEFT_PAULDRON, - /* 0x18 */ IRON_KNUCKLE_DEFEAT_LIMB_UPPER_RIGHT_PAULDRON, - /* 0x19 */ IRON_KNUCKLE_DEFEAT_LIMB_LOWER_RIGHT_PAULDRON, - /* 0x1A */ IRON_KNUCKLE_DEFEAT_LIMB_CHEST_ARMOR_FRONT, - /* 0x1B */ IRON_KNUCKLE_DEFEAT_LIMB_CHEST_ARMOR_BACK, - /* 0x1C */ IRON_KNUCKLE_DEFEAT_LIMB_TORSO, - /* 0x1D */ IRON_KNUCKLE_DEFEAT_LIMB_WAIST, - /* 0x1E */ IRON_KNUCKLE_DEFEAT_LIMB_MAX -} IronKnuckleDefeatLimb; - typedef struct EnIk { /* 0x0000 */ Actor actor; /* 0x014C */ SkelAnime skelAnime; - /* 0x0190 */ Vec3s jointTable[IRON_KNUCKLE_LIMB_MAX]; - /* 0x0244 */ Vec3s morphTable[IRON_KNUCKLE_LIMB_MAX]; + /* 0x0190 */ Vec3s jointTable[30]; + /* 0x0244 */ Vec3s morphTable[30]; /* 0x02F8 */ u8 unk_2F8; - /* 0x02F9 */ u8 animationTimer; - /* 0x02FA */ u8 drawArmorFlag; - /* 0x02FB */ u8 armorStatusFlag; - /* 0x02FC */ u8 isBreakingProp; - /* 0x02FD */ u8 damageReaction; + /* 0x02F9 */ u8 unk_2F9; + /* 0x02FA */ u8 unk_2FA; + /* 0x02FB */ u8 unk_2FB; + /* 0x02FC */ u8 unk_2FC; + /* 0x02FD */ u8 unk_2FD; /* 0x02FE */ s8 unk_2FE; /* 0x02FF */ s8 unk_2FF; /* 0x0300 */ s16 unk_300; - /* 0x0302 */ s16 switchFlag; + /* 0x0302 */ s16 switchFlags; /* 0x0304 */ EnIkActionFunc actionFunc; /* 0x0308 */ BodyBreak bodyBreak; /* 0x0320 */ ColliderCylinder bodyCollider; @@ -111,10 +30,10 @@ typedef struct EnIk { /* 0x03EC */ ColliderTris shieldCollider; /* 0x040C */ ColliderTrisElement shieldColliderElements[2]; /* 0x04C4 */ s32 blureIdx; - /* 0x04C8 */ s32 csAction; - /* 0x04CC */ s32 csDrawMode; + /* 0x04C8 */ s32 action; + /* 0x04CC */ s32 drawMode; /* 0x04D0 */ u32 cueId; - /* 0x04D4 */ s32 isAxeSummoned; + /* 0x04D4 */ s32 unk_4D4; /* 0x04D8 */ char unk_4D8[0x04]; } EnIk; // size = 0x04DC 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 f893b35cb72..9250c64b3eb 100644 --- a/src/overlays/actors/ovl_En_Insect/z_en_insect.c +++ b/src/overlays/actors/ovl_En_Insect/z_en_insect.c @@ -1,9 +1,3 @@ -/* - * File: z_en_insect.c - * Overlay: ovl_En_Insect - * Description: Bugs - */ - #include "z_en_insect.h" #include "src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.h" @@ -126,7 +120,7 @@ f32 EnInsect_XZDistanceSquared(Vec3f* v1, Vec3f* v2) { return SQ(v1->x - v2->x) + SQ(v1->z - v2->z); } -s32 EnInsect_InBottleRange(EnInsect* this, PlayState* play) { +s32 func_80A7BE6C(EnInsect* this, PlayState* play) { STACK_PAD(s32); Player* player = GET_PLAYER(play); Vec3f pos; @@ -136,15 +130,12 @@ s32 EnInsect_InBottleRange(EnInsect* this, PlayState* play) { pos.y = player->actor.world.pos.y; pos.z = Math_CosS(this->actor.yawTowardsPlayer + 0x8000) * 16.0f + player->actor.world.pos.z; - //! @bug this check is superfluous: it is automatically satisfied if the coarse check is satisfied. It may have - //! been intended to check the actor is in front of Player, but yawTowardsPlayer does not depend on Player's - //! world rotation. - if (EnInsect_XZDistanceSquared(&pos, &this->actor.world.pos) <= SQ(20.0f)) { - return true; + if (EnInsect_XZDistanceSquared(&pos, &this->actor.world.pos) <= 400.0f) { + return 1; } } - return false; + return 0; } void EnInsect_SetCrawlAnim(EnInsect* this) { @@ -185,7 +176,7 @@ s32 EnInsect_TryFindNearbySoil(EnInsect* this, PlayState* play) { */ void EnInsect_UpdateCrawlSfx(EnInsect* this) { if (this->crawlSoundDelay > 0) { - this->crawlSoundDelay--; + this->crawlSoundDelay -= 1; return; } @@ -568,9 +559,9 @@ void EnInsect_SetupDropped(EnInsect* this) { EnInsect_SetCrawlAnim(this); this->actionTimer = 100; this->unk_324 = 1.5f; - this->unk_328 = Rand_ZeroOne() * (0xFFFF + 0.5f); + this->unk_328 = Rand_ZeroOne() * 65535.5f; this->unk_316 = (Rand_ZeroOne() - 0.5f) * 1500.0f; - this->actor.world.rot.y = Rand_ZeroOne() * (0xFFFF + 0.5f); + this->actor.world.rot.y = Rand_ZeroOne() * 65535.5f; Actor_SetScale(&this->actor, 0.003f); this->actionFunc = EnInsect_Dropped; this->insectFlags |= INSECT_FLAG_CRAWLING; @@ -722,7 +713,7 @@ void EnInsect_Dropped(EnInsect* this, PlayState* play) { EnInsect_SetupSlowDown(this); } else if ((type == INSECT_TYPE_FIRST_DROPPED || type == INSECT_TYPE_EXTRA_DROPPED) && (this->insectFlags & INSECT_FLAG_0) && this->lifeTimer <= 0 && this->actionTimer <= 0 && - this->actor.floorHeight < BGCHECK_Y_MIN + 10.0f) { + this->actor.floorHeight < -31990.0f) { PRINTF_COLOR_WARNING(); PRINTF(T("BG 抜け? Actor_delete します(%s %d)\n", "BG missing? To do Actor_delete (%s %d)\n"), "../z_en_mushi.c", 1197); @@ -794,10 +785,8 @@ void EnInsect_Update(Actor* thisx, PlayState* play) { CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } - if (!(this->insectFlags & INSECT_FLAG_UNCATCHABLE) && sCaughtCount < 4 && - EnInsect_InBottleRange(this, play) && - // GI_MAX in this case allows the player to catch the actor in a bottle - Actor_OfferGetItem(&this->actor, play, GI_MAX, 60.0f, 30.0f)) { + if (!(this->insectFlags & INSECT_FLAG_UNCATCHABLE) && sCaughtCount < 4 && func_80A7BE6C(this, play) != 0 && + Actor_OfferGetItem(&this->actor, play, GI_MAX, 60.0f, 30.0f) != 0) { sCaughtCount++; } } 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 d968a36ff02..200f9033d14 100644 --- a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c +++ b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c @@ -107,16 +107,9 @@ static ColliderCylinderInit sCylinderInits[] = { OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { - ELEM_MATERIAL_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x4FC1FFF6, 0x00, 0x00 }, - ATELEM_NONE, - ACELEM_ON, - OCELEM_ON, - }, + { 0x00, { 0x00000000, 0x00, 0x00 }, { 0x4FC1FFF6, 0x00, 0x00 }, 0x00, 0x01, 0x01 }, { 55, 70, 0, { 0, 0, 0 } }, - }, + } }; static CollisionCheckInfoInit sColChkInfoInit = { 0, 12, 60, MASS_IMMOVABLE }; @@ -387,7 +380,6 @@ void EnIshi_Wait(EnIshi* this, PlayState* play) { if (this->actor.xzDistToPlayer < 400.0f) { CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); if (this->actor.xzDistToPlayer < 90.0f) { - // GI_NONE in these cases allows the player to lift the actor if (type == ROCK_LARGE) { Actor_OfferGetItem(&this->actor, play, GI_NONE, 80.0f, 20.0f); } else { diff --git a/src/overlays/actors/ovl_En_Jj/z_en_jj.c b/src/overlays/actors/ovl_En_Jj/z_en_jj.c index 2d8bea4a423..49f02c8ae83 100644 --- a/src/overlays/actors/ovl_En_Jj/z_en_jj.c +++ b/src/overlays/actors/ovl_En_Jj/z_en_jj.c @@ -19,6 +19,7 @@ #include "play_state.h" #include "player.h" #include "save.h" +#include "stack_pad.h" #include "assets/objects/object_jj/object_jj.h" @@ -98,7 +99,7 @@ void EnJj_SetupAction(EnJj* this, EnJjActionFunc actionFunc) { } void EnJj_Init(Actor* thisx, PlayState* play) { - s32 pad; + STACK_PAD(s32); EnJj* this = (EnJj*)thisx; CollisionHeader* colHeader = NULL; @@ -303,7 +304,7 @@ void EnJj_Update(Actor* thisx, PlayState* play) { void EnJj_Draw(Actor* thisx, PlayState* play) { EnJj* this = (EnJj*)thisx; - s32 pad; + STACK_PAD(s32); OPEN_DISPS(play->state.gfxCtx, "../z_en_jj.c", 879); Gfx_SetupDL_37Opa(play->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Jj/z_en_jj_cutscene_data.inc.c b/src/overlays/actors/ovl_En_Jj/z_en_jj_cutscene_data.inc.c index 35a67d6972e..e97636a5baa 100644 --- a/src/overlays/actors/ovl_En_Jj/z_en_jj_cutscene_data.inc.c +++ b/src/overlays/actors/ovl_En_Jj/z_en_jj_cutscene_data.inc.c @@ -1,5 +1,5 @@ -#include "z_en_jj.h" #include "cutscene_commands.h" +#include "player.h" // clang-format off static CutsceneData gJabuInhalingCs[] = { 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 4986986fef8..3eba9a07330 100644 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c @@ -1,9 +1,3 @@ -/* - * File: z_en_kusa.c - * Overlay: ovl_en_kusa - * Description: Bush - */ - #include "z_en_kusa.h" #include "src/overlays/actors/ovl_En_Insect/z_en_insect.h" #include "src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.h" @@ -14,13 +8,12 @@ #include "printf.h" #include "rand.h" #include "sfx.h" -#include "stack_pad.h" -#include "terminal.h" -#include "translation.h" #include "z_en_item00.h" #include "z_lib.h" #include "effect.h" #include "play_state.h" +#include "stack_pad.h" +#include "translation.h" #include "assets/objects/gameplay_keep/cuttable_shrub.h" #include "assets/objects/gameplay_field_keep/gameplay_field_keep.h" @@ -31,30 +24,28 @@ void EnKusa_Init(Actor* thisx, PlayState* play); void EnKusa_Destroy(Actor* thisx, PlayState* play2); void EnKusa_Update(Actor* thisx, PlayState* play); -void EnKusa_Draw(Actor* thisx, PlayState* play); -void EnKusa_SetupLiftedUp(EnKusa* this); void EnKusa_SetupWaitForObject(EnKusa* this); +void EnKusa_WaitForObject(EnKusa* this, PlayState* play); void EnKusa_SetupMain(EnKusa* this); +void EnKusa_Main(EnKusa* this, PlayState* play); +void EnKusa_SetupCarried(EnKusa* this); +void EnKusa_Carried(EnKusa* this, PlayState* play); void EnKusa_SetupFall(EnKusa* this); -void EnKusa_SetupCut(EnKusa* this); -void EnKusa_SetupUprootedWaitRegrow(EnKusa* this); -void EnKusa_SetupRegrow(EnKusa* this); - void EnKusa_Fall(EnKusa* this, PlayState* play); -void EnKusa_WaitForObject(EnKusa* this, PlayState* play); -void EnKusa_Main(EnKusa* this, PlayState* play); -void EnKusa_LiftedUp(EnKusa* this, PlayState* play); +void EnKusa_SetupCut(EnKusa* this); void EnKusa_CutWaitRegrow(EnKusa* this, PlayState* play); void EnKusa_DoNothing(EnKusa* this, PlayState* play); +void EnKusa_SetupUprootedWaitRegrow(EnKusa* this); void EnKusa_UprootedWaitRegrow(EnKusa* this, PlayState* play); +void EnKusa_SetupRegrow(EnKusa* this); void EnKusa_Regrow(EnKusa* this, PlayState* play); +void EnKusa_Draw(Actor* thisx, PlayState* play); static s16 rotSpeedXtarget = 0; static s16 rotSpeedX = 0; static s16 rotSpeedYtarget = 0; static s16 rotSpeedY = 0; - ActorProfile En_Kusa_Profile = { /**/ ACTOR_EN_KUSA, /**/ ACTORCAT_PROP, @@ -67,7 +58,11 @@ ActorProfile En_Kusa_Profile = { /**/ NULL, }; -static s16 sObjectIds[] = { OBJECT_GAMEPLAY_FIELD_KEEP, OBJECT_KUSA, OBJECT_KUSA }; +static s16 sRequiredObjectIds[] = { + OBJECT_GAMEPLAY_FIELD_KEEP, + OBJECT_KUSA, + OBJECT_KUSA, +}; static ColliderCylinderInit sCylinderInit = { { @@ -91,14 +86,16 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit sColChkInfoInit = { 0, 12, 30, MASS_IMMOVABLE }; -static Vec3f sUnitDirections[] = { +static Vec3f sUnitDirections[4] = { { 0.0f, 0.7071f, 0.7071f }, { 0.7071f, 0.7071f, 0.0f }, { 0.0f, 0.7071f, -0.7071f }, { -0.7071f, 0.7071f, 0.0f }, }; -static s16 sFragmentScales[] = { 108, 102, 96, 84, 66, 55, 42, 38 }; +static s16 sFragmentScales[8] = { + 108, 102, 96, 84, 66, 55, 42, 38, +}; static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 400, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -3200, ICHAIN_CONTINUE), @@ -106,26 +103,30 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(cullingVolumeScale, 100, ICHAIN_CONTINUE), ICHAIN_F32(cullingVolumeDownward, 120, ICHAIN_STOP), }; +static Gfx* sDLists[3] = { + gFieldBushDL, + object_kusa_DL_000140, + object_kusa_DL_000140, +}; + void EnKusa_SetupAction(EnKusa* this, EnKusaActionFunc actionFunc) { this->timer = 0; this->actionFunc = actionFunc; } -s32 EnKusa_SnapToFloor(EnKusa* this, PlayState* play, f32 yOffset) { +s32 EnKusa_SnapToGround(EnKusa* this, PlayState* play, f32 offsetY) { STACK_PAD(s32); CollisionPoly* groundPoly; Vec3f pos; s32 bgId; - f32 floorY; + f32 groundY; pos.x = this->actor.world.pos.x; pos.y = this->actor.world.pos.y + 30.0f; pos.z = this->actor.world.pos.z; - - floorY = BgCheck_EntityRaycastDown4(&play->colCtx, &groundPoly, &bgId, &this->actor, &pos); - - if (floorY > BGCHECK_Y_MIN) { - this->actor.world.pos.y = floorY + yOffset; + groundY = BgCheck_EntityRaycastDown4(&play->colCtx, &groundPoly, &bgId, &this->actor, &pos); + if (groundY > BGCHECK_Y_MIN) { + this->actor.world.pos.y = groundY + offsetY; Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.world.pos); return true; } else { @@ -137,18 +138,18 @@ s32 EnKusa_SnapToFloor(EnKusa* this, PlayState* play, f32 yOffset) { } void EnKusa_DropCollectible(EnKusa* this, PlayState* play) { - s16 dropParams; + s16 dropTable; + STACK_PAD(s32); switch (PARAMS_GET_U(this->actor.params, 0, 2)) { case ENKUSA_TYPE_0: case ENKUSA_TYPE_2: - dropParams = PARAMS_GET_U(this->actor.params, 8, 4); - - if (dropParams >= COLLECTIBLE_DROP_TABLE_13) { - dropParams = COLLECTIBLE_DROP_TABLE_0; + dropTable = PARAMS_GET_U(this->actor.params, 8, 4); + if (dropTable >= COLLECTIBLE_DROP_TABLE_13) { + dropTable = COLLECTIBLE_DROP_TABLE_0; } Item_DropCollectibleRandom(play, NULL, &this->actor.world.pos, - COLLECTIBLE_DROP_RANDOM_PARAMS(dropParams, false)); + COLLECTIBLE_DROP_RANDOM_PARAMS(dropTable, false)); break; case ENKUSA_TYPE_1: if (Rand_ZeroOne() < 0.5f) { @@ -162,7 +163,6 @@ void EnKusa_DropCollectible(EnKusa* this, PlayState* play) { void EnKusa_UpdateVelY(EnKusa* this) { this->actor.velocity.y += this->actor.gravity; - if (this->actor.velocity.y < this->actor.minVelocityY) { this->actor.velocity.y = this->actor.minVelocityY; } @@ -181,42 +181,35 @@ void EnKusa_SetScaleSmall(EnKusa* this) { this->actor.scale.z = 0.120000005f; } -void EnKusa_SpawnFragments(EnKusa* this, PlayState* play) { - Vec3f velocity; - Vec3f pos; - s32 i; - s32 scaleIndex; +void EnKusa_SpawnFragmentsEffects(EnKusa* this, PlayState* play) { + Vec3f effVel; + Vec3f effPos; Vec3f* dir; + s32 scaleIndex; + s32 i; STACK_PAD(s32); for (i = 0; i < ARRAY_COUNT(sUnitDirections); i++) { dir = &sUnitDirections[i]; - - pos.x = this->actor.world.pos.x + (dir->x * this->actor.scale.x * 20.0f); - pos.y = this->actor.world.pos.y + (dir->y * this->actor.scale.y * 20.0f) + 10.0f; - pos.z = this->actor.world.pos.z + (dir->z * this->actor.scale.z * 20.0f); - - velocity.x = (Rand_ZeroOne() - 0.5f) * 8.0f; - velocity.y = Rand_ZeroOne() * 10.0f; - velocity.z = (Rand_ZeroOne() - 0.5f) * 8.0f; - + effPos.x = this->actor.world.pos.x + (dir->x * this->actor.scale.x * 20.0f); + effPos.y = this->actor.world.pos.y + (dir->y * this->actor.scale.y * 20.0f) + 10.0f; + effPos.z = this->actor.world.pos.z + (dir->z * this->actor.scale.z * 20.0f); + effVel.x = (Rand_ZeroOne() - 0.5f) * 8.0f; + effVel.y = Rand_ZeroOne() * 10.0f; + effVel.z = (Rand_ZeroOne() - 0.5f) * 8.0f; scaleIndex = (s32)(Rand_ZeroOne() * 111.1f) & 7; - - EffectSsKakera_Spawn(play, &pos, &velocity, &pos, -100, 64, 40, 3, 0, sFragmentScales[scaleIndex], 0, 0, 80, - KAKERA_COLOR_NONE, OBJECT_GAMEPLAY_KEEP, gCuttableShrubStalkDL); - - pos.x = this->actor.world.pos.x + (dir->x * this->actor.scale.x * 40.0f); - pos.y = this->actor.world.pos.y + (dir->y * this->actor.scale.y * 40.0f) + 10.0f; - pos.z = this->actor.world.pos.z + (dir->z * this->actor.scale.z * 40.0f); - - velocity.x = (Rand_ZeroOne() - 0.5f) * 6.0f; - velocity.y = Rand_ZeroOne() * 10.0f; - velocity.z = (Rand_ZeroOne() - 0.5f) * 6.0f; - + EffectSsKakera_Spawn(play, &effPos, &effVel, &effPos, -100, 0x40, 0x28, 3, 0, sFragmentScales[scaleIndex], 0, 0, + 80, -1, 1, gCuttableShrubStalkDL); + + effPos.x = this->actor.world.pos.x + (dir->x * this->actor.scale.x * 40.0f); + effPos.y = this->actor.world.pos.y + (dir->y * this->actor.scale.y * 40.0f) + 10.0f; + effPos.z = this->actor.world.pos.z + (dir->z * this->actor.scale.z * 40.0f); + effVel.x = (Rand_ZeroOne() - 0.5f) * 6.0f; + effVel.y = Rand_ZeroOne() * 10.0f; + effVel.z = (Rand_ZeroOne() - 0.5f) * 6.0f; scaleIndex = (s32)(Rand_ZeroOne() * 111.1f) % 7; - - EffectSsKakera_Spawn(play, &pos, &velocity, &pos, -100, 64, 40, 3, 0, sFragmentScales[scaleIndex], 0, 0, 80, - KAKERA_COLOR_NONE, OBJECT_GAMEPLAY_KEEP, gCuttableShrubTipDL); + EffectSsKakera_Spawn(play, &effPos, &effVel, &effPos, -100, 0x40, 0x28, 3, 0, sFragmentScales[scaleIndex], 0, 0, + 80, -1, 1, gCuttableShrubTipDL); } } @@ -224,11 +217,9 @@ void EnKusa_SpawnBugs(EnKusa* this, PlayState* play) { s32 i; for (i = 0; i < 3; i++) { - Actor* bug = - Actor_Spawn(&play->actorCtx, play, ACTOR_EN_INSECT, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, Rand_ZeroOne() * 0xFFFF, 0, INSECT_TYPE_SPAWNED); - - if (bug == NULL) { + if (Actor_Spawn(&play->actorCtx, play, ACTOR_EN_INSECT, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, TRUNCF_BINANG(Rand_ZeroOne() * 0xFFFF), 0, + INSECT_TYPE_SPAWNED) == NULL) { break; } } @@ -246,36 +237,26 @@ void EnKusa_Init(Actor* thisx, PlayState* play) { EnKusa* this = (EnKusa*)thisx; Actor_ProcessInitChain(&this->actor, sInitChain); - if (play->csCtx.state != CS_STATE_IDLE) { this->actor.cullingVolumeDistance += 1000.0f; } - - EnKusa_InitCollider(thisx, play); + EnKusa_InitCollider(&this->actor, play); CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); - if (this->actor.shape.rot.y == 0) { - s16 rand = Rand_ZeroFloat(0x10000); - - this->actor.world.rot.y = rand; - this->actor.home.rot.y = rand; - this->actor.shape.rot.y = rand; + this->actor.shape.rot.y = this->actor.home.rot.y = this->actor.world.rot.y = (s16)(s32)Rand_ZeroFloat(65536.0f); } - - if (!EnKusa_SnapToFloor(this, play, 0.0f)) { + if (!EnKusa_SnapToGround(this, play, 0.0f)) { Actor_Kill(&this->actor); return; } - - this->requiredObjectSlot = Object_GetSlot(&play->objectCtx, sObjectIds[PARAMS_GET_U(thisx->params, 0, 2)]); - + this->requiredObjectSlot = + Object_GetSlot(&play->objectCtx, sRequiredObjectIds[PARAMS_GET_U(this->actor.params, 0, 2)]); if (this->requiredObjectSlot < 0) { PRINTF(T("Error : バンク危険! (arg_data 0x%04x)(%s %d)\n", "Error : Bank danger! (arg_data 0x%04x)(%s %d)\n"), - thisx->params, "../z_en_kusa.c", 561); + this->actor.params, "../z_en_kusa.c", 561); Actor_Kill(&this->actor); return; } - EnKusa_SetupWaitForObject(this); } @@ -297,7 +278,6 @@ void EnKusa_WaitForObject(EnKusa* this, PlayState* play) { } else { EnKusa_SetupMain(this); } - this->actor.draw = EnKusa_Draw; this->actor.objectSlot = this->requiredObjectSlot; this->actor.flags &= ~ACTOR_FLAG_UPDATE_CULLING_DISABLED; @@ -313,34 +293,29 @@ void EnKusa_Main(EnKusa* this, PlayState* play) { STACK_PAD(s32); if (Actor_HasParent(&this->actor, play)) { - EnKusa_SetupLiftedUp(this); + EnKusa_SetupCarried(this); SfxSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_PL_PULL_UP_PLANT); } else if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; - EnKusa_SpawnFragments(this, play); + EnKusa_SpawnFragmentsEffects(this, play); EnKusa_DropCollectible(this, play); SfxSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_EV_PLANT_BROKEN); - if (PARAMS_GET_U(this->actor.params, 4, 1)) { EnKusa_SpawnBugs(this, play); } - if (PARAMS_GET_U(this->actor.params, 0, 2) == ENKUSA_TYPE_0) { Actor_Kill(&this->actor); return; } - EnKusa_SetupCut(this); this->actor.flags |= ACTOR_FLAG_GRASS_DESTROYED; } else { if (!(this->collider.base.ocFlags1 & OC1_TYPE_PLAYER) && (this->actor.xzDistToPlayer > 12.0f)) { this->collider.base.ocFlags1 |= OC1_TYPE_PLAYER; } - if (this->actor.xzDistToPlayer < 600.0f) { Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); - if (this->actor.xzDistToPlayer < 400.0f) { CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); if (this->actor.xzDistToPlayer < 100.0f) { @@ -351,18 +326,18 @@ void EnKusa_Main(EnKusa* this, PlayState* play) { } } -void EnKusa_SetupLiftedUp(EnKusa* this) { - EnKusa_SetupAction(this, EnKusa_LiftedUp); +void EnKusa_SetupCarried(EnKusa* this) { + EnKusa_SetupAction(this, EnKusa_Carried); this->actor.room = -1; this->actor.flags |= ACTOR_FLAG_UPDATE_CULLING_DISABLED; } -void EnKusa_LiftedUp(EnKusa* this, PlayState* play) { +void EnKusa_Carried(EnKusa* this, PlayState* play) { if (Actor_HasNoParent(&this->actor, play)) { this->actor.room = play->roomCtx.curRoom.num; EnKusa_SetupFall(this); - this->actor.velocity.x = this->actor.speed * Math_SinS(this->actor.world.rot.y); - this->actor.velocity.z = this->actor.speed * Math_CosS(this->actor.world.rot.y); + this->actor.velocity.x = Math_SinS(this->actor.world.rot.y) * this->actor.speed; + this->actor.velocity.z = Math_CosS(this->actor.world.rot.y) * this->actor.speed; this->actor.colChkInfo.mass = 240; this->actor.gravity = -0.1f; EnKusa_UpdateVelY(this); @@ -385,44 +360,41 @@ void EnKusa_SetupFall(EnKusa* this) { void EnKusa_Fall(EnKusa* this, PlayState* play) { STACK_PAD(s32); - Vec3f contactPos; + Vec3f waterSurfacePos; if (this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH | BGCHECKFLAG_WALL)) { if (!(this->actor.bgCheckFlags & BGCHECKFLAG_WATER)) { SfxSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_EV_PLANT_BROKEN); } - EnKusa_SpawnFragments(this, play); + EnKusa_SpawnFragmentsEffects(this, play); EnKusa_DropCollectible(this, play); switch (PARAMS_GET_U(this->actor.params, 0, 2)) { case ENKUSA_TYPE_0: case ENKUSA_TYPE_2: Actor_Kill(&this->actor); break; - case ENKUSA_TYPE_1: EnKusa_SetupUprootedWaitRegrow(this); break; } return; } - if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH) { - contactPos.x = this->actor.world.pos.x; - contactPos.y = this->actor.world.pos.y + this->actor.depthInWater; - contactPos.z = this->actor.world.pos.z; - EffectSsGSplash_Spawn(play, &contactPos, NULL, NULL, 0, 400); - EffectSsGRipple_Spawn(play, &contactPos, 150, 650, 0); - EffectSsGRipple_Spawn(play, &contactPos, 400, 800, 4); - EffectSsGRipple_Spawn(play, &contactPos, 500, 1100, 8); + waterSurfacePos.x = this->actor.world.pos.x; + waterSurfacePos.y = this->actor.world.pos.y + this->actor.depthInWater; + waterSurfacePos.z = this->actor.world.pos.z; + EffectSsGSplash_Spawn(play, &waterSurfacePos, NULL, NULL, 0, 400); + EffectSsGRipple_Spawn(play, &waterSurfacePos, 150, 650, 0); + EffectSsGRipple_Spawn(play, &waterSurfacePos, 400, 800, 4); + EffectSsGRipple_Spawn(play, &waterSurfacePos, 500, 1100, 8); this->actor.minVelocityY = -3.0f; - rotSpeedX >>= 1; - rotSpeedXtarget >>= 1; - rotSpeedY >>= 1; - rotSpeedYtarget >>= 1; + rotSpeedX = rotSpeedX >> 1; + rotSpeedXtarget = rotSpeedXtarget >> 1; + rotSpeedY = rotSpeedY >> 1; + rotSpeedYtarget = rotSpeedYtarget >> 1; this->actor.bgCheckFlags &= ~BGCHECKFLAG_WATER_TOUCH; SfxSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); } - EnKusa_UpdateVelY(this); Math_StepToS(&rotSpeedX, rotSpeedXtarget, 0x1F4); Math_StepToS(&rotSpeedY, rotSpeedYtarget, 0xAA); @@ -467,12 +439,9 @@ void EnKusa_SetupUprootedWaitRegrow(EnKusa* this) { } void EnKusa_UprootedWaitRegrow(EnKusa* this, PlayState* play) { - if (this->timer > 120) { - if (Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y, 0.6f)) { - if (this->timer >= 170) { - EnKusa_SetupRegrow(this); - } - } + if ((this->timer > 120) && Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y, 0.6f) && + (this->timer >= 170)) { + EnKusa_SetupRegrow(this); } } @@ -489,7 +458,6 @@ void EnKusa_Regrow(EnKusa* this, PlayState* play) { isFullyGrown &= Math_StepToF(&this->actor.scale.y, 0.4f, 0.014f); isFullyGrown &= Math_StepToF(&this->actor.scale.x, 0.4f, 0.011f); this->actor.scale.z = this->actor.scale.x; - if (isFullyGrown) { Actor_SetScale(&this->actor, 0.4f); EnKusa_SetupMain(this); @@ -501,9 +469,7 @@ void EnKusa_Update(Actor* thisx, PlayState* play) { EnKusa* this = (EnKusa*)thisx; this->timer++; - this->actionFunc(this, play); - if (this->actor.flags & ACTOR_FLAG_GRASS_DESTROYED) { this->actor.shape.yOffset = -6.25f; } else { @@ -512,12 +478,9 @@ void EnKusa_Update(Actor* thisx, PlayState* play) { } void EnKusa_Draw(Actor* thisx, PlayState* play) { - static Gfx* dLists[] = { gFieldBushDL, object_kusa_DL_000140, object_kusa_DL_000140 }; - EnKusa* this = (EnKusa*)thisx; - - if (this->actor.flags & ACTOR_FLAG_GRASS_DESTROYED) { + if (thisx->flags & ACTOR_FLAG_GRASS_DESTROYED) { Gfx_DrawDListOpa(play, object_kusa_DL_0002E0); } else { - Gfx_DrawDListOpa(play, dLists[PARAMS_GET_U(thisx->params, 0, 2)]); + Gfx_DrawDListOpa(play, sDLists[PARAMS_GET_U(thisx->params, 0, 2)]); } } 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 85ed0d54075..c3e4057a613 100644 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.h +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.h @@ -15,11 +15,11 @@ typedef enum EnKusaType { } EnKusaType; typedef struct EnKusa { - /* 0x0000 */ Actor actor; - /* 0x014C */ EnKusaActionFunc actionFunc; - /* 0x0150 */ ColliderCylinder collider; - /* 0x019C */ s16 timer; - /* 0x019E */ s8 requiredObjectSlot; -} EnKusa; // size = 0x01A0 + /* 0x000 */ Actor actor; + /* 0x14C */ EnKusaActionFunc actionFunc; + /* 0x150 */ ColliderCylinder collider; + /* 0x19C */ s16 timer; + /* 0x19E */ s8 requiredObjectSlot; +} EnKusa; // size = 0x1A0 #endif diff --git a/src/overlays/actors/ovl_En_Kz/z_en_kz.c b/src/overlays/actors/ovl_En_Kz/z_en_kz.c index 81cdd79b286..bb9c95e2a52 100644 --- a/src/overlays/actors/ovl_En_Kz/z_en_kz.c +++ b/src/overlays/actors/ovl_En_Kz/z_en_kz.c @@ -303,7 +303,7 @@ void func_80A9CB18(EnKz* this, PlayState* play) { #endif if (EnKz_UpdateTalking(play, &this->actor, &this->interactInfo.talkState, 340.0f, EnKz_GetTextId, - EnKz_UpdateTalkState)) { + EnKz_UpdateTalkState) != 0) { if ((this->actor.textId == 0x401A) && !GET_EVENTCHKINF(EVENTCHKINF_GAVE_LETTER_TO_KING_ZORA)) { if (Actor_GetPlayerExchangeItemId(play) == EXCH_ITEM_BOTTLE_RUTOS_LETTER) { this->actor.textId = 0x401B; 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 ea2433aced4..87015578dc7 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 @@ -11,6 +11,7 @@ #include "play_state.h" #include "player.h" #include "save.h" +#include "stack_pad.h" #include "assets/objects/gameplay_keep/spin_attack.h" @@ -27,7 +28,7 @@ typedef enum EnMThunderAttackStrength { /* 1 */ M_THUNDER_ATTACK_WEAK } EnMThunderAttackStrength; -void EnMThunder_Init(Actor* thisx, PlayState* play2); +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); @@ -68,24 +69,25 @@ static ColliderCylinderInit sCylinderInit = { { 200, 200, 0, { 0, 0, 0 } }, }; -static u32 sSpinAttackDmgFlags[] = { DMG_SPIN_MASTER, DMG_SPIN_KOKIRI, DMG_SPIN_GIANT }; -static u32 sJumpAttackDmgFlags[] = { DMG_JUMP_MASTER, DMG_JUMP_KOKIRI, DMG_JUMP_GIANT }; +static u32 sSpinAttackDmgFlags[3] = { DMG_SPIN_MASTER, DMG_SPIN_KOKIRI, DMG_SPIN_GIANT }; +static u32 sJumpAttackDmgFlags[3] = { DMG_JUMP_MASTER, DMG_JUMP_KOKIRI, DMG_JUMP_GIANT }; void EnMThunder_SetupAction(EnMThunder* this, EnMThunderActionFunc actionFunc) { this->actionFunc = actionFunc; } -void EnMThunder_Init(Actor* thisx, PlayState* play2) { - PlayState* play = play2; +void EnMThunder_Init(Actor* thisx, PlayState* play) { + STACK_PAD(s32); EnMThunder* this = (EnMThunder*)thisx; - Player* player = GET_PLAYER(play); + Player* player; + player = GET_PLAYER(play); Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); - this->swordType = PARAMS_GET_S(this->actor.params, 0, 8) - 1; - 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); + this->swordType = PARAMS_GET_U(this->actor.params, 0, 8) - 1; + Lights_PointNoGlowSetInfo(&this->unk19C, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + 255, 255, 255, 0); + this->unk198 = LightContext_InsertLight(play, &play->lightCtx, &this->unk19C); this->collider.dim.radius = 0; this->collider.dim.height = 40; this->collider.dim.yShift = -20; @@ -98,22 +100,24 @@ void EnMThunder_Init(Actor* thisx, PlayState* play2) { this->actor.room = -1; Actor_SetScale(&this->actor, 0.1f); this->isUsingMagic = false; - if (player->stateFlags2 & PLAYER_STATE2_17) { if (!gSaveContext.save.info.playerData.isMagicAcquired || (gSaveContext.magicState != MAGIC_STATE_IDLE) || - (PARAMS_GET_S(this->actor.params, 8, 8) && - !(Magic_RequestChange(play, PARAMS_GET_S(this->actor.params, 8, 8), MAGIC_CONSUME_NOW)))) { + ((PARAMS_GET_S(this->actor.params, 8, 8) != 0) && + (Magic_RequestChange(play, PARAMS_GET_S(this->actor.params, 8, 8), MAGIC_CONSUME_NOW) == 0))) { SFX_PLAY_AT_POS(&player->actor.projectedPos, NA_SE_IT_ROLLING_CUT); SFX_PLAY_AT_POS(&player->actor.projectedPos, NA_SE_IT_SWORD_SWING_HARD); Actor_Kill(&this->actor); return; } - player->stateFlags2 &= ~PLAYER_STATE2_17; this->isUsingMagic = true; this->collider.elem.atDmgInfo.dmgFlags = sSpinAttackDmgFlags[this->swordType]; this->attackStrength = M_THUNDER_ATTACK_WEAK; - this->targetScale = ((this->swordType == M_THUNDER_SWORD_KOKIRI) ? 2 : 4); + if (this->swordType == M_THUNDER_SWORD_KOKIRI) { + this->targetScale = 2; + } else { + this->targetScale = 4; + } EnMThunder_SetupAction(this, EnMThunder_SpinAttacking); this->followPlayerTimer = 8; SFX_PLAY_AT_POS(&player->actor.projectedPos, NA_SE_IT_ROLLING_CUT_LV1); @@ -130,10 +134,9 @@ void EnMThunder_Destroy(Actor* thisx, PlayState* play) { if (this->isUsingMagic) { Magic_Reset(play); } - Collider_DestroyCylinder(play, &this->collider); EnMThunder_AdjustEnvLights(play, 0.0f); - LightContext_RemoveLight(play, &play->lightCtx, this->lightNode); + LightContext_RemoveLight(play, &play->lightCtx, this->unk198); } void EnMThunder_AdjustEnvLights(PlayState* play, f32 intensity) { @@ -141,98 +144,97 @@ void EnMThunder_AdjustEnvLights(PlayState* play, f32 intensity) { } void EnMThunder_EmptySpinAttack(EnMThunder* this, PlayState* play) { - Player* player = GET_PLAYER(play); + Player* player; + player = GET_PLAYER(play); if (player->stateFlags2 & PLAYER_STATE2_17) { if (player->meleeWeaponAnimation >= PLAYER_MWA_SPIN_ATTACK_1H) { SFX_PLAY_AT_POS(&player->actor.projectedPos, NA_SE_IT_ROLLING_CUT); SFX_PLAY_AT_POS(&player->actor.projectedPos, NA_SE_IT_SWORD_SWING_HARD); } - Actor_Kill(&this->actor); return; } - if (!(player->stateFlags1 & PLAYER_STATE1_CHARGING_SPIN_ATTACK)) { Actor_Kill(&this->actor); } } void EnMThunder_ChargingSpinAttack(EnMThunder* this, PlayState* play) { - Player* player = GET_PLAYER(play); - Actor* child = this->actor.child; + Player* player; + Actor* child; + player = GET_PLAYER(play); + child = this->actor.child; this->spinChargePercent = player->unk_858; this->actor.world.pos = player->bodyPartsPos[PLAYER_BODYPART_WAIST]; this->actor.shape.rot.y = player->actor.shape.rot.y + 0x8000; - - if (!this->isUsingMagic) { - if (player->unk_858 >= 0.1f) { - if ((gSaveContext.magicState != MAGIC_STATE_IDLE) || - (PARAMS_GET_S(this->actor.params, 8, 8) && - !(Magic_RequestChange(play, PARAMS_GET_S(this->actor.params, 8, 8), MAGIC_CONSUME_WAIT_PREVIEW)))) { - EnMThunder_EmptySpinAttack(this, play); - EnMThunder_SetupAction(this, EnMThunder_EmptySpinAttack); - this->chargeAlpha = 0; - this->dimmingIntensity = 0.0; - this->spinAttackTimer = 0.0f; - return; - } - - this->isUsingMagic = true; + if (!this->isUsingMagic && (player->unk_858 >= 0.10f)) { + if ((gSaveContext.magicState != MAGIC_STATE_IDLE) || + ((PARAMS_GET_S(this->actor.params, 8, 8) != 0) && + (Magic_RequestChange(play, PARAMS_GET_S(this->actor.params, 8, 8), MAGIC_CONSUME_WAIT_PREVIEW) == 0))) { + EnMThunder_EmptySpinAttack(this, play); + EnMThunder_SetupAction(this, EnMThunder_EmptySpinAttack); + this->chargeAlpha = 0; + this->dimmingIntensity = 0; + this->spinAttackTimer = 0.0f; + return; } + this->isUsingMagic = true; } - - if (player->unk_858 >= 0.1f) { - Rumble_Request(0.0f, (s32)(player->unk_858 * 150.0f), 2, (s32)(player->unk_858 * 150.0f)); + if (player->unk_858 >= 0.10f) { + Rumble_Request(0.0f, (u8)(s32)(player->unk_858 * 150.0f), 2, (u8)(s32)(player->unk_858 * 150.0f)); } - if (player->stateFlags2 & PLAYER_STATE2_17) { if ((child != NULL) && (child->update != NULL)) { child->parent = NULL; } - if (player->unk_858 <= 0.15f) { - if ((player->unk_858 >= 0.1f) && (player->meleeWeaponAnimation >= PLAYER_MWA_SPIN_ATTACK_1H)) { + if ((player->unk_858 >= 0.10f) && (player->meleeWeaponAnimation >= PLAYER_MWA_SPIN_ATTACK_1H)) { SFX_PLAY_AT_POS(&player->actor.projectedPos, NA_SE_IT_ROLLING_CUT); SFX_PLAY_AT_POS(&player->actor.projectedPos, NA_SE_IT_SWORD_SWING_HARD); } Actor_Kill(&this->actor); return; - } else { - player->stateFlags2 &= ~PLAYER_STATE2_17; - if (PARAMS_GET_S(this->actor.params, 8, 8)) { - gSaveContext.magicState = MAGIC_STATE_CONSUME_SETUP; + } + player->stateFlags2 &= ~PLAYER_STATE2_17; + if (PARAMS_GET_S(this->actor.params, 8, 8) != 0) { + gSaveContext.magicState = MAGIC_STATE_CONSUME_SETUP; + } + if (player->unk_858 < 0.85f) { + this->collider.elem.atDmgInfo.dmgFlags = sSpinAttackDmgFlags[this->swordType]; + this->attackStrength = M_THUNDER_ATTACK_WEAK; + if (this->swordType == M_THUNDER_SWORD_KOKIRI) { + this->targetScale = 2; + } else { + this->targetScale = 4; } - if (player->unk_858 < 0.85f) { - this->collider.elem.atDmgInfo.dmgFlags = sSpinAttackDmgFlags[this->swordType]; - this->attackStrength = M_THUNDER_ATTACK_WEAK; - this->targetScale = ((this->swordType == M_THUNDER_SWORD_KOKIRI) ? 2 : 4); + } else { + this->collider.elem.atDmgInfo.dmgFlags = sJumpAttackDmgFlags[this->swordType]; + this->attackStrength = M_THUNDER_ATTACK_STRONG; + if (this->swordType == M_THUNDER_SWORD_KOKIRI) { + this->targetScale = 4; } else { - this->collider.elem.atDmgInfo.dmgFlags = sJumpAttackDmgFlags[this->swordType]; - this->attackStrength = M_THUNDER_ATTACK_STRONG; - this->targetScale = ((this->swordType == M_THUNDER_SWORD_KOKIRI) ? 4 : 8); + this->targetScale = 8; } + } + EnMThunder_SetupAction(this, EnMThunder_SpinAttacking); + this->followPlayerTimer = 8; - EnMThunder_SetupAction(this, EnMThunder_SpinAttacking); - this->followPlayerTimer = 8; - - { - static u16 sSfxIds[] = { - NA_SE_IT_ROLLING_CUT_LV2, - NA_SE_IT_ROLLING_CUT_LV1, - NA_SE_IT_ROLLING_CUT_LV2, - NA_SE_IT_ROLLING_CUT_LV1, - }; - - SFX_PLAY_AT_POS(&player->actor.projectedPos, sSfxIds[this->attackStrength]); - } + { + static u16 D_80AA0464[4] = { + NA_SE_IT_ROLLING_CUT_LV2, + NA_SE_IT_ROLLING_CUT_LV1, + NA_SE_IT_ROLLING_CUT_LV2, + NA_SE_IT_ROLLING_CUT_LV1, + }; - this->spinAttackTimer = 1.0f; - return; + SFX_PLAY_AT_POS(&player->actor.projectedPos, D_80AA0464[this->attackStrength]); } - } + this->spinAttackTimer = 1.0f; + return; + } if (!(player->stateFlags1 & PLAYER_STATE1_CHARGING_SPIN_ATTACK)) { if (this->actor.child != NULL) { this->actor.child->parent = NULL; @@ -240,31 +242,28 @@ void EnMThunder_ChargingSpinAttack(EnMThunder* this, PlayState* play) { Actor_Kill(&this->actor); return; } - if (player->unk_858 > 0.15f) { - this->chargeAlpha = 255; + this->chargeAlpha = 0xFF; 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, this->swordType + 2); } - this->dimmingIntensity += ((((player->unk_858 - 0.15f) * 1.5f) - this->dimmingIntensity) * 0.5f); - - } else if (player->unk_858 > .1f) { - this->chargeAlpha = (s32)((player->unk_858 - .1f) * 255.0f * 20.0f); - this->spinAttackTimer = (player->unk_858 - .1f) * 10.0f; + this->dimmingIntensity = + this->dimmingIntensity + ((((player->unk_858 - 0.15f) * 1.5f) - this->dimmingIntensity) * 0.5f); + } else if (player->unk_858 > 0.1f) { + this->chargeAlpha = (u8)(s32)((player->unk_858 - 0.1f) * 255.0f * 20.0f); + this->spinAttackTimer = (player->unk_858 - 0.1f) * 10.0f; } else { this->chargeAlpha = 0; } - if (player->unk_858 > 0.85f) { Audio_PlaySwordChargeSfx(&player->actor.projectedPos, 2); } else if (player->unk_858 > 0.15f) { Audio_PlaySwordChargeSfx(&player->actor.projectedPos, 1); - } else if (player->unk_858 > 0.1f) { + } else if (player->unk_858 > 0.10f) { Audio_PlaySwordChargeSfx(&player->actor.projectedPos, 0); } - if (Play_InCsMode(play)) { Actor_Kill(&this->actor); } @@ -272,106 +271,98 @@ void EnMThunder_ChargingSpinAttack(EnMThunder* this, PlayState* play) { void EnMThunder_UpdateSpinAttack(EnMThunder* this, PlayState* play) { if (this->followPlayerTimer < 2) { - if (this->chargeAlpha < 40) { + if (this->chargeAlpha < 0x28) { this->chargeAlpha = 0; } else { - this->chargeAlpha -= 40; + this->chargeAlpha = this->chargeAlpha - 0x28; } } - this->spinTrailTexScroll += 2.0f * this->spinAttackAlpha; - if (this->dimmingIntensity < this->spinAttackTimer) { - this->dimmingIntensity += ((this->spinAttackTimer - this->dimmingIntensity) * 0.1f); + this->dimmingIntensity = this->dimmingIntensity + ((this->spinAttackTimer - this->dimmingIntensity) * 0.1f); } else { this->dimmingIntensity = this->spinAttackTimer; } } void EnMThunder_SpinAttacking(EnMThunder* this, PlayState* play) { - Player* player = GET_PLAYER(play); + Player* player; + player = GET_PLAYER(play); if (Math_StepToF(&this->spinAttackTimer, 0.0f, 1 / 16.0f)) { Actor_Kill(&this->actor); } else { Math_SmoothStepToF(&this->actor.scale.x, (s32)this->targetScale, 0.6f, 0.8f, 0.0f); Actor_SetScale(&this->actor, this->actor.scale.x); - this->collider.dim.radius = (this->actor.scale.x * 25.0f); + this->collider.dim.radius = this->actor.scale.x * 25.0f; Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } - if (this->followPlayerTimer > 0) { this->actor.world.pos.x = player->bodyPartsPos[PLAYER_BODYPART_WAIST].x; this->actor.world.pos.z = player->bodyPartsPos[PLAYER_BODYPART_WAIST].z; - this->followPlayerTimer--; + this->followPlayerTimer = this->followPlayerTimer - 1; } - if (this->spinAttackTimer > 0.6f) { this->spinAttackAlpha = 1.0f; } else { this->spinAttackAlpha = this->spinAttackTimer * (5.0f / 3.0f); } - EnMThunder_UpdateSpinAttack(this, play); - if (Play_InCsMode(play)) { Actor_Kill(&this->actor); } } void EnMThunder_Update(Actor* thisx, PlayState* play) { + f32 temp_fv0; + s32 temp_v0; EnMThunder* this = (EnMThunder*)thisx; - f32 blueRadius; - s32 redGreen; this->actionFunc(this, play); EnMThunder_AdjustEnvLights(play, this->dimmingIntensity); - blueRadius = this->spinAttackTimer; - redGreen = (u32)(blueRadius * 255.0f) & 0xFF; - Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, redGreen, redGreen, (u32)(blueRadius * 100.0f), - (s32)(blueRadius * 800.0f)); + temp_fv0 = this->spinAttackTimer; + temp_v0 = (u32)(temp_fv0 * 255.0f) & 0xFF; + Lights_PointNoGlowSetInfo(&this->unk19C, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + temp_v0, temp_v0, temp_fv0 * 100.0f, temp_fv0 * 800.0f); } +static f32 sSpinChargeScale[9] = { 0.1f, 0.15f, 0.2f, 0.25f, 0.3f, 0.25f, 0.2f, 0.15f, 0.0f }; + void EnMThunder_Draw(Actor* thisx, PlayState* play2) { - static f32 sSpinChargeScale[] = { 0.1f, 0.15f, 0.2f, 0.25f, 0.3f, 0.25f, 0.2f, 0.15f }; + f32 spinChargeScale; PlayState* play = play2; + Player* player; EnMThunder* this = (EnMThunder*)thisx; - Player* player = GET_PLAYER(play); - f32 spinChargeScale; s32 chargeTexScroll; - OPEN_DISPS(play->state.gfxCtx, "../z_en_m_thunder.c", 844); + player = GET_PLAYER(play); + OPEN_DISPS(play->state.gfxCtx, "../z_en_m_thunder.c", 0x34C); Gfx_SetupDL_25Xlu(play->state.gfxCtx); Matrix_Scale(0.02f, 0.02f, 0.02f, MTXMODE_APPLY); MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx, "../z_en_m_thunder.c", 853); - switch (this->attackStrength) { case M_THUNDER_ATTACK_STRONG: case M_THUNDER_ATTACK_WEAK: - gSPSegment(POLY_XLU_DISP++, 0x08, + gSPSegment(POLY_XLU_DISP++, 8, Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, - 0xFF - ((u8)(s32)(this->spinTrailTexScroll * 30) & 0xFF), 0, 64, 32, 1, - 0xFF - ((u8)(s32)(this->spinTrailTexScroll * 20) & 0xFF), 0, 8, 8)); + 0xFF - ((u8)(s32)(this->spinTrailTexScroll * 30.0f) & 0xFF), 0, 64, 32, 1, + 0xFF - ((u8)(s32)(this->spinTrailTexScroll * 20.0f) & 0xFF), 0, 8, 8)); break; } - switch (this->attackStrength) { case M_THUNDER_ATTACK_STRONG: - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 170, (u8)(this->spinAttackAlpha * 255)); + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 255, 255, 0xAA, (u8)(this->spinAttackAlpha * 255.0f)); gSPDisplayList(POLY_XLU_DISP++, gSpinAttack3DL); gSPDisplayList(POLY_XLU_DISP++, gSpinAttack4DL); break; case M_THUNDER_ATTACK_WEAK: - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 170, 255, 255, (u8)(this->spinAttackAlpha * 255)); + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 0xAA, 255, 255, (u8)(this->spinAttackAlpha * 255.0f)); gSPDisplayList(POLY_XLU_DISP++, gSpinAttack1DL); gSPDisplayList(POLY_XLU_DISP++, gSpinAttack2DL); break; } - Matrix_Mult(&player->mf_9E0, MTXMODE_NEW); - switch (this->swordType) { case M_THUNDER_SWORD_KOKIRI: Matrix_Translate(0.0f, 220.0f, 0.0f, MTXMODE_APPLY); @@ -389,27 +380,23 @@ void EnMThunder_Draw(Actor* thisx, PlayState* play2) { Matrix_RotateX(16384.0f, MTXMODE_APPLY); break; } - if (this->spinChargePercent >= 0.85f) { - spinChargeScale = (sSpinChargeScale[(play->gameplayFrames & 7)] * 6.0f) + 1.0f; - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 170, this->chargeAlpha); + spinChargeScale = (sSpinChargeScale[play->gameplayFrames & 7] * 6.0f) + 1.0f; + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 255, 255, 0xAA, this->chargeAlpha); gDPSetEnvColor(POLY_XLU_DISP++, 255, 100, 0, 128); - chargeTexScroll = 40; + chargeTexScroll = 0x28; } else { - spinChargeScale = (sSpinChargeScale[play->gameplayFrames & 7] * 2.0f) + 1.0f; - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 170, 255, 255, this->chargeAlpha); + spinChargeScale = (2.0f * sSpinChargeScale[play->gameplayFrames & 7]) + 1.0f; + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 0xAA, 255, 255, this->chargeAlpha); gDPSetEnvColor(POLY_XLU_DISP++, 0, 100, 255, 128); - chargeTexScroll = 20; + chargeTexScroll = 0x14; } Matrix_Scale(1.0f, spinChargeScale, spinChargeScale, MTXMODE_APPLY); MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx, "../z_en_m_thunder.c", 960); - - gSPSegment(POLY_XLU_DISP++, 0x09, - Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, (play->gameplayFrames * 5) & 0xFF, 0, 32, 32, 1, - (play->gameplayFrames * 20) & 0xFF, (play->gameplayFrames * chargeTexScroll) & 0xFF, 8, - 8)); - + gSPSegment(POLY_XLU_DISP++, 9, + Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, (play->gameplayFrames * 5) & 0xFF, 0U, 32, 32, 1, + (play->gameplayFrames * 0x14) & 0xFF, (play->gameplayFrames * chargeTexScroll) & 0xFF, + 8, 8)); gSPDisplayList(POLY_XLU_DISP++, gSpinAttackChargingDL); - - CLOSE_DISPS(play->state.gfxCtx, "../z_en_m_thunder.c", 1031); + CLOSE_DISPS(play->state.gfxCtx, "../z_en_m_thunder.c", 0x407); } 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 7c9068f7d64..da6fe149ac0 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 @@ -10,22 +10,24 @@ struct EnMThunder; typedef void (*EnMThunderActionFunc)(struct EnMThunder*, struct PlayState*); typedef struct EnMThunder { - /* 0x0000 */ Actor actor; - /* 0x014C */ ColliderCylinder collider; - /* 0x0198 */ LightNode* lightNode; - /* 0x019C */ LightInfo lightInfo; - /* 0x01AC */ f32 spinAttackTimer; - /* 0x01B0 */ f32 spinAttackAlpha; - /* 0x01B4 */ f32 spinTrailTexScroll; - /* 0x01B8 */ f32 spinChargePercent; - /* 0x01BC */ f32 dimmingIntensity; - /* 0x01C0 */ EnMThunderActionFunc actionFunc; - /* 0x01C4 */ u16 followPlayerTimer; - /* 0x01C6 */ u8 attackStrength; // see `EnMThunderAttackStrength` - /* 0x01C7 */ u8 swordType; // see `EnMThunderSwordType` - /* 0x01C8 */ u8 chargeAlpha; - /* 0x01C9 */ u8 targetScale; - /* 0x01CA */ u8 isUsingMagic; -} EnMThunder; // size = 0x01CC + /* 0x000 */ Actor actor; + /* 0x14C */ ColliderCylinder collider; + /* 0x198 */ LightNode* unk198; + /* 0x19C */ LightInfo unk19C; + /* 0x1AA */ char pad1AA[2]; + /* 0x1AC */ f32 spinAttackTimer; + /* 0x1B0 */ f32 spinAttackAlpha; + /* 0x1B4 */ f32 spinTrailTexScroll; + /* 0x1B8 */ f32 spinChargePercent; + /* 0x1BC */ f32 dimmingIntensity; + /* 0x1C0 */ EnMThunderActionFunc actionFunc; + /* 0x1C4 */ u16 followPlayerTimer; + /* 0x1C6 */ u8 attackStrength; // see `EnMThunderAttackStrength` + /* 0x1C7 */ u8 swordType; // see `EnMThunderSwordType` + /* 0x1C8 */ u8 chargeAlpha; + /* 0x1C9 */ u8 targetScale; + /* 0x1CA */ u8 isUsingMagic; + /* 0x1CB */ char pad1CB[1]; +} EnMThunder; // size = 0x1CC #endif 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 3cb7af7bfc4..692e0159e09 100644 --- a/src/overlays/actors/ovl_En_Mag/z_en_mag.c +++ b/src/overlays/actors/ovl_En_Mag/z_en_mag.c @@ -396,9 +396,9 @@ void EnMag_Update(Actor* thisx, PlayState* play) { } } -BAD_RETURN(s32) EnMag_DrawTextureI8(Gfx** gfxP, void* texture, s16 texWidth, s16 texHeight, s16 rectLeft, s16 rectTop, +BAD_RETURN(s32) EnMag_DrawTextureI8(Gfx** gfxp, void* texture, s16 texWidth, s16 texHeight, s16 rectLeft, s16 rectTop, s16 rectWidth, s16 rectHeight, u16 dsdx, u16 dtdy) { - Gfx* gfx = *gfxP; + Gfx* gfx = *gfxp; gDPLoadTextureBlock(gfx++, texture, G_IM_FMT_I, G_IM_SIZ_8b, texWidth, texHeight, 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); @@ -406,14 +406,14 @@ BAD_RETURN(s32) EnMag_DrawTextureI8(Gfx** gfxP, void* texture, s16 texWidth, s16 gSPTextureRectangle(gfx++, rectLeft << 2, rectTop << 2, (rectLeft + rectWidth) << 2, (rectTop + rectHeight) << 2, G_TX_RENDERTILE, 0, 0, dsdx, dtdy); - *gfxP = gfx; + *gfxp = gfx; } -BAD_RETURN(s32) EnMag_DrawEffectTextures(Gfx** gfxP, void* maskTex, void* effectTex, s16 maskWidth, s16 maskHeight, +BAD_RETURN(s32) EnMag_DrawEffectTextures(Gfx** gfxp, void* maskTex, void* effectTex, s16 maskWidth, s16 maskHeight, s16 effectWidth, s16 effectHeight, s16 rectLeft, s16 rectTop, s16 rectWidth, s16 rectHeight, u16 dsdx, u16 dtdy, u16 shifts, u16 shiftt, u16 flag, EnMag* this) { - Gfx* gfx = *gfxP; + Gfx* gfx = *gfxp; gDPLoadMultiBlock_4b(gfx++, maskTex, 0x0000, G_TX_RENDERTILE, G_IM_FMT_I, maskWidth, maskHeight, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, @@ -429,11 +429,11 @@ BAD_RETURN(s32) EnMag_DrawEffectTextures(Gfx** gfxP, void* maskTex, void* effect gSPTextureRectangle(gfx++, rectLeft << 2, rectTop << 2, (rectLeft + rectWidth) << 2, (rectTop + rectHeight) << 2, G_TX_RENDERTILE, 0, 0, dsdx, dtdy); - *gfxP = gfx; + *gfxp = gfx; } -void EnMag_DrawImageRGBA32(Gfx** gfxP, s16 centerX, s16 centerY, u8* source, u32 width, u32 height) { - Gfx* gfx = *gfxP; +void EnMag_DrawImageRGBA32(Gfx** gfxp, s16 centerX, s16 centerY, u8* source, u32 width, u32 height) { + Gfx* gfx = *gfxp; u8* curTexture; s32 textureCount; u32 rectLeft; @@ -489,7 +489,7 @@ void EnMag_DrawImageRGBA32(Gfx** gfxP, s16 centerX, s16 centerY, u8* source, u32 } } - *gfxP = gfx; + *gfxp = gfx; } #if PLATFORM_N64 @@ -518,8 +518,8 @@ void func_80AEEA48_unknown(Gfx** gfxP, s16 arg1, s16 arg2, u32 arg3) { } #endif -void EnMag_DrawCharTexture(Gfx** gfxP, u8* texture, s32 rectLeft, s32 rectTop) { - Gfx* gfx = *gfxP; +void EnMag_DrawCharTexture(Gfx** gfxp, u8* texture, s32 rectLeft, s32 rectTop) { + Gfx* gfx = *gfxp; YREG(0) = 1024.0f / (YREG(1) / 100.0f); YREG(2) = 16.0f * (YREG(1) / 100.0f); @@ -530,7 +530,7 @@ void EnMag_DrawCharTexture(Gfx** gfxP, u8* texture, s32 rectLeft, s32 rectTop) { gSPTextureRectangle(gfx++, rectLeft << 2, rectTop << 2, (rectLeft + YREG(2)) << 2, (rectTop + YREG(2)) << 2, G_TX_RENDERTILE, 0, 0, YREG(0), YREG(0)); - *gfxP = gfx; + *gfxp = gfx; } #if PLATFORM_IQUE @@ -546,7 +546,7 @@ void EnMag_DrawCharTexture(Gfx** gfxP, u8* texture, s32 rectLeft, s32 rectTop) { #define TITLE_X_SHIFT (-32) #endif -void EnMag_DrawInner(Actor* thisx, PlayState* play, Gfx** gfxP) { +void EnMag_DrawInner(Actor* thisx, PlayState* play, Gfx** gfxp) { static s16 textAlpha = 0; static s16 textFadeDirection = 0; static s16 textFadeTimer = 0; @@ -578,7 +578,7 @@ void EnMag_DrawInner(Actor* thisx, PlayState* play, Gfx** gfxP) { EnMag* this = (EnMag*)thisx; Font* font = &this->font; STACK_PAD(s32); - Gfx* gfx = *gfxP; + Gfx* gfx = *gfxp; u16 i, j, k; u16 rectLeft; u16 rectTop; @@ -880,7 +880,7 @@ void EnMag_DrawInner(Actor* thisx, PlayState* play, Gfx** gfxP) { } } - *gfxP = gfx; + *gfxp = gfx; } void EnMag_Draw(Actor* thisx, PlayState* play) { diff --git a/src/overlays/actors/ovl_En_Mb/z_en_mb.c b/src/overlays/actors/ovl_En_Mb/z_en_mb.c index 212375363fb..e5b73d935ef 100644 --- a/src/overlays/actors/ovl_En_Mb/z_en_mb.c +++ b/src/overlays/actors/ovl_En_Mb/z_en_mb.c @@ -1,9 +1,3 @@ -/* - * File: z_en_mb.c - * Overlay: ovl_En_Mb - * Description: Moblins - */ - #include "z_en_mb.h" #include "attributes.h" @@ -685,7 +679,7 @@ void EnMb_SpearPatrolTurnTowardsWaypoint(EnMb* this, PlayState* play) { if (ABS(this->actor.yDistToPlayer) <= 20.0f && EnMb_IsPlayerInCorridor(this, play)) { relYawFromPlayer = this->actor.shape.rot.y - this->actor.yawTowardsPlayer; - if (ABS(relYawFromPlayer) <= 0x4000 || (func_8002DDE4(play) && this->actor.xzDistToPlayer < 160.0f)) { + if (ABS(relYawFromPlayer) <= 0x4000 || ((func_8002DDE4(play) != 0) && this->actor.xzDistToPlayer < 160.0f)) { EnMb_FindWaypointTowardsPlayer(this, play); Actor_PlaySfx(&this->actor, NA_SE_EN_MORIBLIN_VOICE); EnMb_SetupSpearPrepareAndCharge(this); @@ -1249,7 +1243,7 @@ void EnMb_SpearPatrolWalkTowardsWaypoint(EnMb* this, PlayState* play) { yDistToPlayerAbs = (this->actor.yDistToPlayer >= 0.0f) ? this->actor.yDistToPlayer : -this->actor.yDistToPlayer; if (yDistToPlayerAbs <= 20.0f && EnMb_IsPlayerInCorridor(this, play)) { relYawTowardsPlayer = (this->actor.shape.rot.y - this->actor.yawTowardsPlayer); - if (ABS(relYawTowardsPlayer) <= 0x4000 || (func_8002DDE4(play) && this->actor.xzDistToPlayer < 160.0f)) { + if (ABS(relYawTowardsPlayer) <= 0x4000 || (func_8002DDE4(play) != 0 && this->actor.xzDistToPlayer < 160.0f)) { EnMb_FindWaypointTowardsPlayer(this, play); Actor_PlaySfx(&this->actor, NA_SE_EN_MORIBLIN_VOICE); EnMb_SetupSpearPrepareAndCharge(this); diff --git a/src/overlays/actors/ovl_En_Md/z_en_md.c b/src/overlays/actors/ovl_En_Md/z_en_md.c index 77de88b009e..d0500a58def 100644 --- a/src/overlays/actors/ovl_En_Md/z_en_md.c +++ b/src/overlays/actors/ovl_En_Md/z_en_md.c @@ -1,10 +1,5 @@ -/* - * File: z_en_md.c - * Overlay: ovl_En_Md - * Description: Mido - */ - #include "z_en_md.h" +#include "actor.h" #include "src/overlays/actors/ovl_En_Elf/z_en_elf.h" #include "libc64/math64.h" @@ -122,11 +117,11 @@ static AnimationInfo sAnimationInfo[] = { }; void EnMd_ReverseAnimation(EnMd* this) { - f32 startFrame; + f32 startFrame = this->skelAnime.startFrame; + f32 endFrame = this->skelAnime.endFrame; - startFrame = this->skelAnime.startFrame; - this->skelAnime.startFrame = this->skelAnime.endFrame; - this->skelAnime.curFrame = this->skelAnime.endFrame; + this->skelAnime.startFrame = endFrame; + this->skelAnime.curFrame = endFrame; this->skelAnime.endFrame = startFrame; this->skelAnime.playSpeed = -1.0f; } @@ -348,6 +343,7 @@ void EnMd_UpdateAnimSequence(EnMd* this) { break; case ENMD_ANIM_SEQ_STOP_WALKING: EnMd_UpdateAnimSequence_StopWalking(this); + break; } } @@ -364,7 +360,7 @@ void EnMd_UpdateAnimSequence_WithTalking(EnMd* this) { if ((this->messageEntry == 5) && (this->animSequence != ENMD_ANIM_SEQ_CURIOUS_TO_ANNOYED)) { EnMd_SetAnimSequence(this, ENMD_ANIM_SEQ_CURIOUS_TO_ANNOYED); } - if ((this->messageEntry == 11) && (this->animSequence != ENMD_ANIM_SEQ_ANNOYED_TO_HALT)) { + if ((this->messageEntry == 0xB) && (this->animSequence != ENMD_ANIM_SEQ_ANNOYED_TO_HALT)) { EnMd_SetAnimSequence(this, ENMD_ANIM_SEQ_ANNOYED_TO_HALT); } break; @@ -399,20 +395,18 @@ void EnMd_UpdateAnimSequence_WithTalking(EnMd* this) { Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_INDEX_IDLE); EnMd_SetAnimSequence(this, ENMD_ANIM_SEQ_NONE); } - EnMd_UpdateAnimSequence(this); } -s16 EnMd_TrackMessageState(EnMd* this, PlayState* play) { +s16 EnMd_TrackMessageState(Actor* thisx, PlayState* play) { + EnMd* this = (EnMd*)thisx; s16 messageState = Message_GetState(&play->msgCtx); - if ((this->messageState == TEXT_STATE_AWAITING_NEXT) || (this->messageState == TEXT_STATE_EVENT) || - (this->messageState == TEXT_STATE_CLOSING) || (this->messageState == TEXT_STATE_DONE_HAS_NEXT)) { - if (this->messageState != messageState) { - this->messageEntry++; - } + if (((this->messageState == TEXT_STATE_AWAITING_NEXT) || (this->messageState == TEXT_STATE_EVENT) || + (this->messageState == TEXT_STATE_CLOSING) || (this->messageState == TEXT_STATE_DONE_HAS_NEXT)) && + (this->messageState != messageState)) { + this->messageEntry++; } - this->messageState = messageState; return messageState; } @@ -423,61 +417,49 @@ u16 EnMd_GetTextIdKokiriForest(PlayState* play, EnMd* this) { if (textId != 0) { return textId; } - this->messageEntry = 0; this->messageState = TEXT_STATE_NONE; - if (CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD)) { return 0x1045; } - if (GET_EVENTCHKINF(EVENTCHKINF_04)) { return 0x1034; } - if ((CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD) == EQUIP_VALUE_SHIELD_DEKU) && (CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) == EQUIP_VALUE_SWORD_KOKIRI)) { return 0x1033; } - if (GET_INFTABLE(INFTABLE_0C)) { return 0x1030; } - return 0x102F; } u16 EnMd_GetTextIdMidosHouse(PlayState* play, EnMd* this) { this->messageEntry = 0; this->messageState = TEXT_STATE_NONE; - if (GET_EVENTCHKINF(EVENTCHKINF_OBTAINED_ZELDAS_LETTER)) { return 0x1028; } - return 0x1046; } u16 EnMd_GetTextIdLostWoods(PlayState* play, EnMd* this) { this->messageEntry = 0; this->messageState = TEXT_STATE_NONE; - if (GET_EVENTCHKINF(EVENTCHKINF_48)) { if (GET_INFTABLE(INFTABLE_19)) { return 0x1071; + } else { + return 0x1070; } - return 0x1070; - } - - if (GET_EVENTCHKINF(EVENTCHKINF_0A)) { + } else if (GET_EVENTCHKINF(EVENTCHKINF_0A)) { return 0x1068; - } - - if (GET_INFTABLE(INFTABLE_15)) { + } else if (GET_INFTABLE(INFTABLE_15)) { return 0x1061; + } else { + return 0x1060; } - - return 0x1060; } u16 EnMd_GetTextId(PlayState* play, Actor* thisx) { @@ -496,8 +478,7 @@ u16 EnMd_GetTextId(PlayState* play, Actor* thisx) { } s16 EnMd_UpdateTalkState(PlayState* play, Actor* thisx) { - EnMd* this = (EnMd*)thisx; - switch (EnMd_TrackMessageState(this, play)) { + switch (EnMd_TrackMessageState(thisx, play)) { case TEXT_STATE_NONE: case TEXT_STATE_DONE_HAS_NEXT: case TEXT_STATE_DONE_FADING: @@ -507,8 +488,9 @@ s16 EnMd_UpdateTalkState(PlayState* play, Actor* thisx) { case TEXT_STATE_8: case TEXT_STATE_9: return NPC_TALK_STATE_TALKING; + case TEXT_STATE_CLOSING: - switch (this->actor.textId) { + switch (thisx->textId) { case 0x1028: SET_EVENTCHKINF(EVENTCHKINF_0F); break; @@ -527,43 +509,36 @@ s16 EnMd_UpdateTalkState(PlayState* play, Actor* thisx) { return NPC_TALK_STATE_ACTION; } return NPC_TALK_STATE_IDLE; + case TEXT_STATE_EVENT: if (Message_ShouldAdvance(play)) { return NPC_TALK_STATE_ACTION; } - FALLTHROUGH; - default: - return NPC_TALK_STATE_TALKING; + break; } + return NPC_TALK_STATE_TALKING; } -u8 EnMd_ShouldSpawn(EnMd* this, PlayState* play) { - if (play->sceneId == SCENE_KOKIRI_FOREST) { - if (!GET_EVENTCHKINF(EVENTCHKINF_1C) && !GET_EVENTCHKINF(EVENTCHKINF_OBTAINED_ZELDAS_LETTER)) { - return 1; - } - } - - if (play->sceneId == SCENE_MIDOS_HOUSE) { - if (GET_EVENTCHKINF(EVENTCHKINF_1C) || GET_EVENTCHKINF(EVENTCHKINF_OBTAINED_ZELDAS_LETTER)) { - if (!LINK_IS_ADULT) { - return 1; - } - } - } - - if (play->sceneId == SCENE_LOST_WOODS) { - return 1; +s32 EnMd_CheckCanSpawn(EnMd* this, PlayState* play) { + if ((play->sceneId == SCENE_KOKIRI_FOREST) && !GET_EVENTCHKINF(EVENTCHKINF_1C) && + !GET_EVENTCHKINF(EVENTCHKINF_OBTAINED_ZELDAS_LETTER)) { + return true; + } else if ((play->sceneId == SCENE_MIDOS_HOUSE) && + (GET_EVENTCHKINF(EVENTCHKINF_1C) || GET_EVENTCHKINF(EVENTCHKINF_OBTAINED_ZELDAS_LETTER)) && + !LINK_IS_ADULT) { + return true; + } else if (play->sceneId == SCENE_LOST_WOODS) { + return true; + } else { + return false; } - - return 0; } void EnMd_UpdateEyes(EnMd* this) { - if (DECR(this->blinkTimer) == 0) { + if (DECR(this->eyeTimer) == 0) { this->eyeTexIndex++; - if (this->eyeTexIndex > 2) { - this->blinkTimer = Rand_S16Offset(30, 30); + if (this->eyeTexIndex >= 3) { + this->eyeTimer = Rand_S16Offset(30, 30); this->eyeTexIndex = 0; } } @@ -571,27 +546,28 @@ void EnMd_UpdateEyes(EnMd* this) { void EnMd_UpdateTalking(EnMd* this, PlayState* play) { Player* player = GET_PLAYER(play); - s16 absYawDiff; - s16 trackingMode; + s16 absRelYawTowardsPlayer; + s16 relYawTowardsPlayer; s16 canUpdateTalking; - s16 yawDiff; + s16 trackingMode; if (this->actor.xzDistToPlayer < 170.0f) { - yawDiff = (f32)this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - absYawDiff = ABS(yawDiff); - - trackingMode = - absYawDiff <= Npc_GetTrackingPresetMaxPlayerYaw(2) ? NPC_TRACKING_HEAD_AND_TORSO : NPC_TRACKING_NONE; - canUpdateTalking = true; + relYawTowardsPlayer = (f32)this->actor.yawTowardsPlayer - (f32)this->actor.shape.rot.y; + absRelYawTowardsPlayer = ABS(relYawTowardsPlayer); + if (absRelYawTowardsPlayer <= Npc_GetTrackingPresetMaxPlayerYaw(2)) { + trackingMode = NPC_TRACKING_HEAD_AND_TORSO; + canUpdateTalking = true; + } else { + trackingMode = NPC_TRACKING_NONE; + canUpdateTalking = true; + } } else { trackingMode = NPC_TRACKING_NONE; canUpdateTalking = false; } - if (this->interactInfo.talkState != NPC_TALK_STATE_IDLE) { trackingMode = NPC_TRACKING_FULL_BODY; } - if (this->actionFunc == EnMd_Walk) { trackingMode = NPC_TRACKING_NONE; canUpdateTalking = false; @@ -600,81 +576,79 @@ void EnMd_UpdateTalking(EnMd* this, PlayState* play) { trackingMode = NPC_TRACKING_FULL_BODY; canUpdateTalking = true; } - - if ((play->csCtx.state != CS_STATE_IDLE) || gDebugCamEnabled) { + if ((play->csCtx.state != CS_STATE_IDLE) || (gDebugCamEnabled != 0)) { this->interactInfo.trackPos = play->view.eye; this->interactInfo.yOffset = 40.0f; trackingMode = NPC_TRACKING_HEAD_AND_TORSO; } else { this->interactInfo.trackPos = player->actor.world.pos; - this->interactInfo.yOffset = (gSaveContext.save.linkAge > 0) ? 0.0f : -18.0f; + if (gSaveContext.save.linkAge > 0) { + this->interactInfo.yOffset = 0.0f; + } else { + this->interactInfo.yOffset = -18.0f; + } } - Npc_TrackPoint(&this->actor, &this->interactInfo, 2, trackingMode); - if (this->actionFunc != EnMd_ListenToOcarina) { - if (canUpdateTalking) { - Npc_UpdateTalking(play, &this->actor, &this->interactInfo.talkState, this->collider.dim.radius + 30.0f, - EnMd_GetTextId, EnMd_UpdateTalkState); - } + if ((this->actionFunc != EnMd_ListenToOcarina) && canUpdateTalking) { + Npc_UpdateTalking(play, &this->actor, &this->interactInfo.talkState, this->collider.dim.radius + 30.0f, + EnMd_GetTextId, EnMd_UpdateTalkState); } } -u8 EnMd_FollowPath(EnMd* this, PlayState* play) { +s32 EnMd_UpdateRotFollowPath(EnMd* this, PlayState* play) { Path* path; + STACK_PAD(s32); + f32 dx; + f32 dz; Vec3s* pointPos; - f32 pathDiffX; - f32 pathDiffZ; + s32 pathIndexNoShift = ENMD_GET_PATH_INDEX_NOSHIFT(this); - if (ENMD_GET_PATH_INDEX_NOSHIFT(this) == (ENMD_PATH_NONE << 8)) { + if (pathIndexNoShift == (ENMD_PATH_NONE << 8)) { return 0; } - - path = &play->pathList[ENMD_GET_PATH_INDEX(this)]; + path = &play->pathList[pathIndexNoShift >> 8]; pointPos = SEGMENTED_TO_VIRTUAL(path->points); pointPos += this->waypoint; - - pathDiffX = pointPos->x - this->actor.world.pos.x; - pathDiffZ = pointPos->z - this->actor.world.pos.z; - Math_SmoothStepToS(&this->actor.world.rot.y, Math_FAtan2F(pathDiffX, pathDiffZ) * (65536.0f / (2 * M_PI)), 4, 4000, - 1); - - if ((SQ(pathDiffX) + SQ(pathDiffZ)) < 100.0f) { + dx = (f32)pointPos->x - this->actor.world.pos.x; + dz = (f32)pointPos->z - this->actor.world.pos.z; + Math_SmoothStepToS(&this->actor.world.rot.y, RAD_TO_BINANG(Math_FAtan2F(dx, dz)), 4, 0xFA0, 1); + if ((SQ(dx) + SQ(dz)) < 100.0f) { this->waypoint++; if (this->waypoint >= path->count) { this->waypoint = 0; } - return 1; + return true; } - return 0; + return false; } -u8 EnMd_SetMovedPos(EnMd* this, PlayState* play) { +s32 EnMd_SetPosToPathEnd(EnMd* this, PlayState* play) { Path* path; - Vec3s* lastPointPos; + s32 pathIndexNoShift = ENMD_GET_PATH_INDEX_NOSHIFT(this); + Vec3s* pointPos; - if (ENMD_GET_PATH_INDEX_NOSHIFT(this) == (ENMD_PATH_NONE << 8)) { - return 0; + if (pathIndexNoShift == (ENMD_PATH_NONE << 8)) { + return false; } - - path = &play->pathList[ENMD_GET_PATH_INDEX(this)]; - lastPointPos = SEGMENTED_TO_VIRTUAL(path->points); - lastPointPos += path->count - 1; - - this->actor.world.pos.x = lastPointPos->x; - this->actor.world.pos.y = lastPointPos->y; - this->actor.world.pos.z = lastPointPos->z; - - return 1; + path = &play->pathList[pathIndexNoShift >> 8]; + pointPos = SEGMENTED_TO_VIRTUAL(path->points); + pointPos += path->count - 1; + this->actor.world.pos.x = pointPos->x; + this->actor.world.pos.y = pointPos->y; + this->actor.world.pos.z = pointPos->z; + return true; } void EnMd_UpdateAlphaByDistance(EnMd* this, PlayState* play) { f32 radius; if (play->sceneId != SCENE_MIDOS_HOUSE) { - radius = (CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD) && !GET_EVENTCHKINF(EVENTCHKINF_1C) && - (play->sceneId == SCENE_KOKIRI_FOREST)) - ? 100.0f - : 400.0f; + if (CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD) && !GET_EVENTCHKINF(EVENTCHKINF_1C) && + (play->sceneId == SCENE_KOKIRI_FOREST)) { + radius = 100.0f; + } else { + radius = 400.0f; + } this->alpha = Actor_UpdateAlphaByDistance(&this->actor, play, this->alpha, radius); this->actor.shape.shadowAlpha = this->alpha; } else { @@ -689,40 +663,36 @@ void EnMd_Init(Actor* thisx, PlayState* play) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); SkelAnime_InitFlex(play, &this->skelAnime, &gMidoSkel, NULL, this->jointTable, this->morphTable, MIDO_LIMB_MAX); - Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, NULL, &sColChkInfoInit); - if (!EnMd_ShouldSpawn(this, play)) { + if (!EnMd_CheckCanSpawn(this, play)) { Actor_Kill(&this->actor); return; } - Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_INDEX_IDLE_DEFAULT); Actor_SetScale(&this->actor, 0.01f); this->actor.attentionRangeType = ATTENTION_RANGE_6; this->alpha = 255; Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_ELF, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, FAIRY_KOKIRI); - if (((play->sceneId == SCENE_KOKIRI_FOREST) && !GET_EVENTCHKINF(EVENTCHKINF_04)) || ((play->sceneId == SCENE_KOKIRI_FOREST) && GET_EVENTCHKINF(EVENTCHKINF_04) && CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD)) || ((play->sceneId == SCENE_LOST_WOODS) && !GET_EVENTCHKINF(EVENTCHKINF_0A))) { this->actor.home.pos = this->actor.world.pos; this->actionFunc = EnMd_BlockPath; - return; - } - - if (play->sceneId != SCENE_MIDOS_HOUSE) { - EnMd_SetMovedPos(this, play); + } else { + if (play->sceneId != SCENE_MIDOS_HOUSE) { + EnMd_SetPosToPathEnd(this, play); + } + this->actionFunc = EnMd_Idle; } - - this->actionFunc = EnMd_Idle; } void EnMd_Destroy(Actor* thisx, PlayState* play) { EnMd* this = (EnMd*)thisx; + Collider_DestroyCylinder(play, &this->collider); } @@ -733,7 +703,6 @@ void EnMd_Idle(EnMd* this, PlayState* play) { (this->animSequence != ENMD_ANIM_SEQ_SURPRISE_TO_IDLE)) { EnMd_SetAnimSequence(this, ENMD_ANIM_SEQ_SURPRISE_TO_IDLE); } - EnMd_UpdateAnimSequence_WithTalking(this); } @@ -746,65 +715,52 @@ void EnMd_Watch(EnMd* this, PlayState* play) { void EnMd_BlockPath(EnMd* this, PlayState* play) { Player* player = GET_PLAYER(play); - f32 temp; - Actor* actorToBlock = &GET_PLAYER(play)->actor; - s16 yaw; + f32 playSpeed; + Player* player2 = GET_PLAYER(play); + s16 yawTowardsPlayerFromHome; + STACK_PAD(s32); EnMd_UpdateAnimSequence_WithTalking(this); - if (this->interactInfo.talkState == NPC_TALK_STATE_IDLE) { - this->actor.world.rot.y = this->actor.yawTowardsPlayer; - this->actor.shape.rot.y = this->actor.yawTowardsPlayer; - - yaw = Math_Vec3f_Yaw(&this->actor.home.pos, &actorToBlock->world.pos); - + this->actor.shape.rot.y = this->actor.world.rot.y = this->actor.yawTowardsPlayer; + yawTowardsPlayerFromHome = Math_Vec3f_Yaw(&this->actor.home.pos, &player2->actor.world.pos); this->actor.world.pos.x = this->actor.home.pos.x; - this->actor.world.pos.x += 60.0f * Math_SinS(yaw); - + this->actor.world.pos.x += 60.0f * Math_SinS(yawTowardsPlayerFromHome); this->actor.world.pos.z = this->actor.home.pos.z; - this->actor.world.pos.z += 60.0f * Math_CosS(yaw); - - temp = fabsf((f32)this->actor.yawTowardsPlayer - yaw) * 0.001f * 3.0f; - this->skelAnime.playSpeed = CLAMP(temp, 1.0f, 3.0f); + this->actor.world.pos.z += 60.0f * Math_CosS(yawTowardsPlayerFromHome); + playSpeed = fabsf((f32)this->actor.yawTowardsPlayer - (f32)yawTowardsPlayerFromHome) * 0.001f * 3.0f; + this->skelAnime.playSpeed = CLAMP(playSpeed, 1.0f, 3.0f); } - if (this->interactInfo.talkState == NPC_TALK_STATE_ACTION) { if (CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD) && !GET_EVENTCHKINF(EVENTCHKINF_1C) && (play->sceneId == SCENE_KOKIRI_FOREST)) { play->msgCtx.msgMode = MSGMODE_PAUSED; } - if (play->sceneId == SCENE_KOKIRI_FOREST) { SET_EVENTCHKINF(EVENTCHKINF_04); } if (play->sceneId == SCENE_LOST_WOODS) { SET_EVENTCHKINF(EVENTCHKINF_0A); } - EnMd_SetAnimSequence(this, ENMD_ANIM_SEQ_WALK_AWAY); EnMd_UpdateAnimSequence(this); this->waypoint = 1; this->interactInfo.talkState = NPC_TALK_STATE_IDLE; this->actionFunc = EnMd_Walk; this->actor.speed = 1.5f; - return; - } - - if (this->skelAnime.animation == &gMidoIdleAnim) { - Actor_UpdateFidgetTables(play, this->fidgetTableY, this->fidgetTableZ, MIDO_LIMB_MAX); - } - - if ((this->interactInfo.talkState == NPC_TALK_STATE_IDLE) && (play->sceneId == SCENE_LOST_WOODS)) { - if (player->stateFlags2 & PLAYER_STATE2_24) { - player->stateFlags2 |= PLAYER_STATE2_25; - player->unk_6A8 = &this->actor; - Message_StartOcarina(play, OCARINA_ACTION_CHECK_SARIA); - this->actionFunc = EnMd_ListenToOcarina; - return; + } else { + if (this->skelAnime.animation == &gMidoIdleAnim) { + Actor_UpdateFidgetTables(play, this->fidgetTableY, this->fidgetTableZ, MIDO_LIMB_MAX); } - - if (this->actor.xzDistToPlayer < (30.0f + this->collider.dim.radius)) { - player->stateFlags2 |= PLAYER_STATE2_23; + if ((this->interactInfo.talkState == NPC_TALK_STATE_IDLE) && (play->sceneId == SCENE_LOST_WOODS)) { + if (player->stateFlags2 & PLAYER_STATE2_24) { + player->stateFlags2 |= PLAYER_STATE2_25; + player->unk_6A8 = &this->actor; + Message_StartOcarina(play, OCARINA_ACTION_CHECK_SARIA); + this->actionFunc = EnMd_ListenToOcarina; + } else if (this->actor.xzDistToPlayer < (30.0f + this->collider.dim.radius)) { + player->stateFlags2 |= PLAYER_STATE2_23; + } } } } @@ -818,8 +774,7 @@ void EnMd_ListenToOcarina(EnMd* this, PlayState* play) { } else if (play->msgCtx.ocarinaMode == OCARINA_MODE_03) { SFX_PLAY_CENTERED(NA_SE_SY_CORRECT_CHIME); this->actor.textId = 0x1067; - Actor_OfferTalk(&this->actor, play, this->collider.dim.radius + 30.0f); - + Actor_OfferTalk(&this->actor, play, (f32)this->collider.dim.radius + 30.0f); this->actionFunc = EnMd_BlockPath; play->msgCtx.ocarinaMode = OCARINA_MODE_04; } else { @@ -830,26 +785,20 @@ void EnMd_ListenToOcarina(EnMd* this, PlayState* play) { void EnMd_Walk(EnMd* this, PlayState* play) { Actor_UpdateFidgetTables(play, this->fidgetTableY, this->fidgetTableZ, MIDO_LIMB_MAX); EnMd_UpdateAnimSequence(this); - - if (!(EnMd_FollowPath(this, play)) || (this->waypoint != 0)) { + if (!EnMd_UpdateRotFollowPath(this, play) || (this->waypoint != 0)) { this->actor.shape.rot = this->actor.world.rot; - return; - } - - if (CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD) && !GET_EVENTCHKINF(EVENTCHKINF_1C) && - (play->sceneId == SCENE_KOKIRI_FOREST)) { + } else if (CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD) && !GET_EVENTCHKINF(EVENTCHKINF_1C) && + (play->sceneId == SCENE_KOKIRI_FOREST)) { Message_CloseTextbox(play); SET_EVENTCHKINF(EVENTCHKINF_1C); Actor_Kill(&this->actor); - return; + } else { + EnMd_SetAnimSequence(this, ENMD_ANIM_SEQ_STOP_WALKING); + this->skelAnime.playSpeed = 0.0f; + this->actor.speed = 0.0f; + this->actor.home.pos = this->actor.world.pos; + this->actionFunc = EnMd_Watch; } - - EnMd_SetAnimSequence(this, ENMD_ANIM_SEQ_STOP_WALKING); - - this->skelAnime.playSpeed = 0.0f; - this->actor.speed = 0.0f; - this->actor.home.pos = this->actor.world.pos; - this->actionFunc = EnMd_Watch; } void EnMd_Update(Actor* thisx, PlayState* play) { @@ -883,27 +832,25 @@ s32 EnMd_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po Matrix_RotateX(BINANG_TO_RAD_ALT(limbRot.x), MTXMODE_APPLY); Matrix_RotateY(BINANG_TO_RAD_ALT(limbRot.y), MTXMODE_APPLY); } - - if (((limbIndex == MIDO_LIMB_TORSO) || (limbIndex == MIDO_LIMB_LEFT_UPPER_ARM)) || + if ((limbIndex == MIDO_LIMB_TORSO) || (limbIndex == MIDO_LIMB_LEFT_UPPER_ARM) || (limbIndex == MIDO_LIMB_RIGHT_UPPER_ARM)) { rot->y += Math_SinS(this->fidgetTableY[limbIndex]) * FIDGET_AMPLITUDE; rot->z += Math_CosS(this->fidgetTableZ[limbIndex]) * FIDGET_AMPLITUDE; } - - return false; + return 0; } void EnMd_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfx) { EnMd* this = (EnMd*)thisx; - Vec3f vec = { 400.0f, 0.0f, 0.0f }; + Vec3f focusPosOffset = { 400.0f, 0.0f, 0.0f }; if (limbIndex == MIDO_LIMB_HEAD) { - Matrix_MultVec3f(&vec, &this->actor.focus.pos); + Matrix_MultVec3f(&focusPosOffset, &this->actor.focus.pos); } } void EnMd_Draw(Actor* thisx, PlayState* play) { - static void* sEyeTextures[] = { + static void* sEyeTextures[3] = { gMidoEyeOpenTex, gMidoEyeHalfTex, gMidoEyeClosedTex, @@ -911,14 +858,12 @@ void EnMd_Draw(Actor* thisx, PlayState* play) { EnMd* this = (EnMd*)thisx; OPEN_DISPS(play->state.gfxCtx, "../z_en_md.c", 1280); - if (this->alpha == 255) { - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeTexIndex])); + gSPSegment(POLY_OPA_DISP++, 8, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeTexIndex])); func_80034BA0(play, &this->skelAnime, EnMd_OverrideLimbDraw, EnMd_PostLimbDraw, &this->actor, this->alpha); } else if (this->alpha != 0) { - gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeTexIndex])); + gSPSegment(POLY_XLU_DISP++, 8, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeTexIndex])); func_80034CC4(play, &this->skelAnime, EnMd_OverrideLimbDraw, EnMd_PostLimbDraw, &this->actor, this->alpha); } - CLOSE_DISPS(play->state.gfxCtx, "../z_en_md.c", 1317); } diff --git a/src/overlays/actors/ovl_En_Md/z_en_md.h b/src/overlays/actors/ovl_En_Md/z_en_md.h index 802e6822a86..1ef07fb572f 100644 --- a/src/overlays/actors/ovl_En_Md/z_en_md.h +++ b/src/overlays/actors/ovl_En_Md/z_en_md.h @@ -15,23 +15,23 @@ typedef void (*EnMdActionFunc)(struct EnMd*, struct PlayState*); #define ENMD_PATH_NONE 0xFF typedef struct EnMd { - /* 0x0000 */ Actor actor; - /* 0x014C */ SkelAnime skelAnime; - /* 0x0190 */ EnMdActionFunc actionFunc; - /* 0x0194 */ ColliderCylinder collider; - /* 0x01E0 */ NpcInteractInfo interactInfo; - /* 0x0208 */ u8 messageEntry; // tracks message state changes, like with `BOX_BREAK` or `TEXTID` - /* 0x0209 */ u8 messageState; // last known result of `Message_GetState` - /* 0x020A */ u8 animSequenceEntry; // each one changes animation info and waits - /* 0x020B */ u8 animSequence; - /* 0x020C */ s16 blinkTimer; - /* 0x020E */ s16 eyeTexIndex; - /* 0x0210 */ s16 alpha; - /* 0x0212 */ s16 waypoint; - /* 0x0214 */ s16 fidgetTableY[MIDO_LIMB_MAX]; - /* 0x0236 */ s16 fidgetTableZ[MIDO_LIMB_MAX]; - /* 0x0258 */ Vec3s jointTable[MIDO_LIMB_MAX]; - /* 0x02BE */ Vec3s morphTable[MIDO_LIMB_MAX]; + /* 0x000 */ Actor actor; + /* 0x14C */ SkelAnime skelAnime; + /* 0x190 */ EnMdActionFunc actionFunc; + /* 0x194 */ ColliderCylinder collider; + /* 0x1E0 */ NpcInteractInfo interactInfo; + /* 0x208 */ u8 messageEntry; // tracks message state changes, like with `BOX_BREAK` or `TEXTID` + /* 0x209 */ u8 messageState; // last known result of `Message_GetState` + /* 0x20A */ u8 animSequenceEntry; // each one changes animation info and waits + /* 0x20B */ u8 animSequence; + /* 0x20C */ s16 eyeTimer; + /* 0x20E */ s16 eyeTexIndex; + /* 0x210 */ s16 alpha; + /* 0x212 */ s16 waypoint; + /* 0x214 */ s16 fidgetTableY[MIDO_LIMB_MAX]; + /* 0x236 */ s16 fidgetTableZ[MIDO_LIMB_MAX]; + /* 0x258 */ Vec3s jointTable[MIDO_LIMB_MAX]; + /* 0x2BE */ Vec3s morphTable[MIDO_LIMB_MAX]; } EnMd; // size = 0x0324 #endif 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 cbe3ff0edb1..0c7ac7cab41 100644 --- a/src/overlays/actors/ovl_En_Mk/z_en_mk.c +++ b/src/overlays/actors/ovl_En_Mk/z_en_mk.c @@ -362,12 +362,12 @@ s32 EnMk_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po rot->z += this->headRotation.x; } - return false; + return 0; } void EnMk_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { static Vec3f D_80AAD64C = { 1000.0f, -100.0f, 0.0f }; - EnMk* this = (EnMk*)thisx; + EnMk* this = thisx; if (limbIndex == 11) { Matrix_MultVec3f(&D_80AAD64C, &this->actor.focus.pos); 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 6d6a6411489..9a3854641f9 100644 --- a/src/overlays/actors/ovl_En_Mm/z_en_mm.c +++ b/src/overlays/actors/ovl_En_Mm/z_en_mm.c @@ -537,10 +537,9 @@ void EnMm_Draw(Actor* thisx, PlayState* play) { if (GET_ITEMGETINF(ITEMGETINF_3B)) { s32 linkChildObjectSlot = Object_GetSlot(&play->objectCtx, OBJECT_LINK_CHILD); - // Draw Bunny Hood if (linkChildObjectSlot >= 0) { Mtx* mtx; - Vec3s earRot; + Vec3s sp50; Mtx* mtx2; mtx = GRAPH_ALLOC(play->state.gfxCtx, sizeof(Mtx) * 2); @@ -552,20 +551,18 @@ void EnMm_Draw(Actor* thisx, PlayState* play) { gSPSegment(POLY_OPA_DISP++, 0x0B, mtx); gSPSegment(POLY_OPA_DISP++, 0x0D, mtx2 - 7); - // Draw the ears in the neutral position (unlike Player, no flopping physics) + sp50.x = 994; + sp50.y = 3518; + sp50.z = -13450; - // Right ear - earRot.x = 0x3E2; - earRot.y = 0xDBE; - earRot.z = -0x348A; - Matrix_SetTranslateRotateYXZ(97.0f, -1203.0f, -240.0f, &earRot); + Matrix_SetTranslateRotateYXZ(97.0f, -1203.0f, -240.0f, &sp50); MATRIX_TO_MTX(mtx++, "../z_en_mm.c", 1124); - // Left ear - earRot.x = -0x3E2; - earRot.y = -0xDBE; - earRot.z = -0x348A; - Matrix_SetTranslateRotateYXZ(97.0f, -1203.0f, 240.0f, &earRot); + sp50.x = -994; + sp50.y = -3518; + sp50.z = -13450; + + Matrix_SetTranslateRotateYXZ(97.0f, -1203.0f, 240.0f, &sp50); MATRIX_TO_MTX(mtx, "../z_en_mm.c", 1131); gSPDisplayList(POLY_OPA_DISP++, gLinkChildBunnyHoodDL); 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 d652d0bfb01..51a319d4a1c 100644 --- a/src/overlays/actors/ovl_En_Ms/z_en_ms.c +++ b/src/overlays/actors/ovl_En_Ms/z_en_ms.c @@ -122,10 +122,12 @@ void EnMs_Wait(EnMs* this, PlayState* play) { yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; EnMs_SetOfferText(this, play); - if (Actor_TalkOfferAccepted(&this->actor, play)) { this->actionFunc = EnMs_Talk; - } else if ((this->actor.xzDistToPlayer < 90.0f) && (ABS(yawDiff) < 0x2000)) { // talk range + return; + } + + if ((this->actor.xzDistToPlayer < 90.0f) && (ABS(yawDiff) < 0x2000)) { // talk range Actor_OfferTalk(&this->actor, play, 90.0f); } } @@ -138,20 +140,22 @@ void EnMs_Talk(EnMs* this, PlayState* play) { if ((dialogState == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { // advanced final textbox this->actionFunc = EnMs_Wait; } - } else if (Message_ShouldAdvance(play)) { - switch (play->msgCtx.choiceIndex) { - case 0: // yes - if (gSaveContext.save.info.playerData.rupees < sPrices[BEANS_BOUGHT]) { - Message_ContinueTextbox(play, 0x4069); // not enough rupees text + } else { + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.choiceIndex) { + case 0: // yes + if (gSaveContext.save.info.playerData.rupees < sPrices[BEANS_BOUGHT]) { + Message_ContinueTextbox(play, 0x4069); // not enough rupees text + return; + } + Actor_OfferGetItem(&this->actor, play, GI_MAGIC_BEAN, 90.0f, 10.0f); + this->actionFunc = EnMs_Sell; + return; + case 1: // no + Message_ContinueTextbox(play, 0x4068); + default: return; - } - Actor_OfferGetItem(&this->actor, play, GI_MAGIC_BEAN, 90.0f, 10.0f); - this->actionFunc = EnMs_Sell; - return; - case 1: // no - Message_ContinueTextbox(play, 0x4068); - default: - return; + } } } } @@ -161,9 +165,9 @@ void EnMs_Sell(EnMs* this, PlayState* play) { Rupees_ChangeBy(-sPrices[BEANS_BOUGHT]); this->actor.parent = NULL; this->actionFunc = EnMs_TalkAfterPurchase; - } else { - Actor_OfferGetItem(&this->actor, play, GI_MAGIC_BEAN, 90.0f, 10.0f); + return; } + Actor_OfferGetItem(&this->actor, play, GI_MAGIC_BEAN, 90.0f, 10.0f); } void EnMs_TalkAfterPurchase(EnMs* this, PlayState* play) { diff --git a/src/overlays/actors/ovl_En_Mu/z_en_mu.c b/src/overlays/actors/ovl_En_Mu/z_en_mu.c index 500f5ffdc99..4b14df44571 100644 --- a/src/overlays/actors/ovl_En_Mu/z_en_mu.c +++ b/src/overlays/actors/ovl_En_Mu/z_en_mu.c @@ -27,7 +27,7 @@ void EnMu_Draw(Actor* thisx, PlayState* play); void EnMu_Pose(EnMu* this, PlayState* play); s16 EnMu_UpdateTalkState(PlayState* play, Actor* thisx); -static ColliderCylinderInit D_80AB0BD0 = { +static ColliderCylinderInit sCylinderInit = { { COL_MATERIAL_NONE, AT_NONE, @@ -47,7 +47,7 @@ static ColliderCylinderInit D_80AB0BD0 = { { 100, 70, 0, { 0, 0, 0 } }, }; -static CollisionCheckInfoInit2 D_80AB0BFC = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; ActorProfile En_Mu_Profile = { /**/ ACTOR_EN_MU, @@ -147,8 +147,8 @@ void EnMu_Init(Actor* thisx, PlayState* play) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 160.0f); SkelAnime_InitFlex(play, &this->skelAnime, &object_mu_Skel_004F70, &object_mu_Anim_0003F4, NULL, NULL, 0); Collider_InitCylinder(play, &this->collider); - Collider_SetCylinder(play, &this->collider, &this->actor, &D_80AB0BD0); - CollisionCheck_SetInfo2(&this->actor.colChkInfo, NULL, &D_80AB0BFC); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, NULL, &sColChkInfoInit); this->actor.attentionRangeType = ATTENTION_RANGE_6; Actor_SetScale(&this->actor, 0.01f); EnMu_Interact(this, play); 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 82650d86c6f..88ffbcb7e12 100644 --- a/src/overlays/actors/ovl_En_Niw/z_en_niw.c +++ b/src/overlays/actors/ovl_En_Niw/z_en_niw.c @@ -374,24 +374,27 @@ void EnNiw_SpawnAttackCucco(EnNiw* this, PlayState* play) { f32 viewY; f32 viewZ; Vec3f attackCuccoPos; - Actor* attackCucco; - - if ((this->timer5 == 0) && (this->unk_296 < 7)) { - viewX = play->view.at.x - play->view.eye.x; - viewY = play->view.at.y - play->view.eye.y; - viewZ = play->view.at.z - play->view.eye.z; - attackCuccoPos.x = ((Rand_ZeroOne() - 0.5f) * viewX) + play->view.eye.x; - attackCuccoPos.y = Rand_CenteredFloat(0.3f) + ((play->view.eye.y + 50.0f) + (viewY * 0.5f)); - attackCuccoPos.z = ((Rand_ZeroOne() - 0.5f) * viewZ) + play->view.eye.z; - attackCucco = Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_ATTACK_NIW, attackCuccoPos.x, - attackCuccoPos.y, attackCuccoPos.z, 0, 0, 0, 0); - - if (attackCucco != NULL) { - this->unk_296++; - this->timer5 = 10; - } else { - PRINTF("\n\n"); - PRINTF(VT_FGCOL(GREEN) T(" ☆☆☆☆☆ 発生できず ☆☆☆☆☆ \n", " ☆☆☆☆☆ Cannot spawn ☆☆☆☆☆ \n") VT_RST); + EnAttackNiw* attackCucco; + + if (this->timer5 == 0) { + if (this->unk_296 < 7) { + viewX = play->view.at.x - play->view.eye.x; + viewY = play->view.at.y - play->view.eye.y; + viewZ = play->view.at.z - play->view.eye.z; + attackCuccoPos.x = ((Rand_ZeroOne() - 0.5f) * viewX) + play->view.eye.x; + attackCuccoPos.y = Rand_CenteredFloat(0.3f) + ((play->view.eye.y + 50.0f) + (viewY * 0.5f)); + attackCuccoPos.z = ((Rand_ZeroOne() - 0.5f) * viewZ) + play->view.eye.z; + attackCucco = + (EnAttackNiw*)Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_ATTACK_NIW, + attackCuccoPos.x, attackCuccoPos.y, attackCuccoPos.z, 0, 0, 0, 0); + + if (attackCucco != NULL) { + this->unk_296++; + this->timer5 = 10; + } else { + PRINTF("\n\n"); + PRINTF(VT_FGCOL(GREEN) T(" ☆☆☆☆☆ 発生できず ☆☆☆☆☆ \n", " ☆☆☆☆☆ Cannot occur ☆☆☆☆☆ \n") VT_RST); + } } } } @@ -459,7 +462,7 @@ void func_80AB6324(EnNiw* this, PlayState* play) { } void func_80AB63A8(EnNiw* this, PlayState* play) { - if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && this->actor.velocity.y < 0.0f) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND && this->actor.velocity.y < 0.0f) { this->unk_2AC.x = this->unk_2B8.x = this->actor.world.pos.x; this->unk_2AC.y = this->unk_2B8.y = this->actor.world.pos.y; this->unk_2AC.z = this->unk_2B8.z = this->actor.world.pos.z; @@ -491,7 +494,6 @@ void func_80AB6450(EnNiw* this, PlayState* play) { this->actor.speed = 0.0f; this->actionFunc = func_80AB6BF8; } else { - // GI_NONE in this case allows the player to lift the actor Actor_OfferGetItem(&this->actor, play, GI_NONE, 25.0f, 10.0f); func_80AB5BF8(this, play, 1); } diff --git a/src/overlays/actors/ovl_En_Niw_Girl/z_en_niw_girl.c b/src/overlays/actors/ovl_En_Niw_Girl/z_en_niw_girl.c index f258235c63d..ea3ffe8df8b 100644 --- a/src/overlays/actors/ovl_En_Niw_Girl/z_en_niw_girl.c +++ b/src/overlays/actors/ovl_En_Niw_Girl/z_en_niw_girl.c @@ -276,7 +276,7 @@ void EnNiwGirl_Draw(Actor* thisx, PlayState* play) { Gfx_SetupDL_25Opa(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[this->eyeIndex])); SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnNiwGirlOverrideLimbDraw, NULL, this); + EnNiwGirlOverrideLimbDraw, 0, this); func_80033C30(&this->actor.world.pos, &sp4C, 255, play); CLOSE_DISPS(play->state.gfxCtx, "../z_en_niw_girl.c", 592); diff --git a/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.c b/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.c index 268e59d8f34..79a55e933c3 100644 --- a/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.c +++ b/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.c @@ -350,13 +350,13 @@ void func_80ABA654(EnNiwLady* this, PlayState* play) { this->unk_26E = 0xB; if (!GET_ITEMGETINF(ITEMGETINF_0C)) { this->actor.parent = NULL; - this->getItemId = GI_BOTTLE_EMPTY; + this->unk_284 = GI_BOTTLE_EMPTY; Actor_OfferGetItem(&this->actor, play, GI_BOTTLE_EMPTY, 100.0f, 50.0f); this->actionFunc = func_80ABAC00; return; } if (this->unk_26C == 1) { - this->getItemId = GI_RUPEE_PURPLE; + this->unk_284 = GI_RUPEE_PURPLE; Actor_OfferGetItem(&this->actor, play, GI_RUPEE_PURPLE, 100.0f, 50.0f); this->actionFunc = func_80ABAC00; } @@ -482,7 +482,7 @@ void func_80ABAC00(EnNiwLady* this, PlayState* play) { if (Actor_HasParent(&this->actor, play)) { this->actionFunc = func_80ABAC84; } else { - getItemId = this->getItemId; + getItemId = this->unk_284; if (LINK_IS_ADULT) { getItemId = !GET_ITEMGETINF(ITEMGETINF_2C) ? GI_POCKET_EGG : GI_COJIRO; } diff --git a/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.h b/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.h index 124efa5947b..27951753568 100644 --- a/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.h +++ b/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.h @@ -37,7 +37,7 @@ typedef struct EnNiwLady { /* 0x027E */ s16 unk_27E; /* 0x0280 */ s8 aneObjectSlot; /* 0x0281 */ s8 osAnimeObjectSlot; - /* 0x0284 */ s32 getItemId; + /* 0x0284 */ s32 unk_284; /* 0x0288 */ NpcInteractInfo interactInfo; /* 0x02B0 */ ColliderCylinder collider; } EnNiwLady; // size = 0x02FC 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 69f2d7c0ee6..2df3cc4c94a 100644 --- a/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c +++ b/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c @@ -35,8 +35,8 @@ void EnNwc_Idle(EnNwc* this, PlayState* play); #define CHICK_BG_WALL (1 << 1) typedef enum ChickTypes { - /* 0 */ CHICK_NONE, - /* 1 */ CHICK_NORMAL + CHICK_NONE, + CHICK_NORMAL } ChickTypes; ActorProfile En_Nwc_Profile = { diff --git a/src/overlays/actors/ovl_En_Po_Field/z_en_po_field.c b/src/overlays/actors/ovl_En_Po_Field/z_en_po_field.c index bcfd8568513..23963221fee 100644 --- a/src/overlays/actors/ovl_En_Po_Field/z_en_po_field.c +++ b/src/overlays/actors/ovl_En_Po_Field/z_en_po_field.c @@ -103,7 +103,7 @@ static ColliderCylinderInit D_80AD70AC = { { 10, 30, 0, { 0, 0, 0 } }, }; -static CollisionCheckInfoInit D_80AD70D8 = { 4, 25, 50, 40 }; +static CollisionCheckInfoInit sColChkInfoInit = { 4, 25, 50, 40 }; static DamageTable sDamageTable = { /* Deku nut */ DMG_ENTRY(0, 0x0), @@ -188,7 +188,7 @@ void EnPoField_Init(Actor* thisx, PlayState* play) { Collider_SetCylinder(play, &this->collider, &this->actor, &D_80AD7080); Collider_InitCylinder(play, &this->flameCollider); Collider_SetCylinder(play, &this->flameCollider, &this->actor, &D_80AD70AC); - CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &D_80AD70D8); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); 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); @@ -216,7 +216,7 @@ void EnPoField_SetupWaitForSpawn(EnPoField* this, PlayState* play) { this->actor.flags &= ~(ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_TALK_OFFER_AUTO_ACCEPTED); this->collider.base.acFlags &= ~AC_ON; this->collider.base.ocFlags1 = OC1_ON | OC1_TYPE_ALL; - this->actor.colChkInfo.health = D_80AD70D8.health; + this->actor.colChkInfo.health = sColChkInfoInit.health; this->actor.gravity = 0.0f; this->actor.velocity.y = 0.0f; this->actionFunc = EnPoField_WaitForSpawn; diff --git a/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c b/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c index fe609a132bb..d79fa0de8ad 100644 --- a/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c +++ b/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c @@ -1,7 +1,7 @@ /* * File: z_en_ru1.c * Overlay: En_Ru1 - * Description: Ruto (child) + * Description: */ #include "z_en_ru1.h" @@ -15,7 +15,6 @@ #include "printf.h" #include "regs.h" #include "segmented_address.h" -#include "seqcmd.h" #include "sequence.h" #include "sfx.h" #include "stack_pad.h" @@ -424,15 +423,17 @@ s32 EnRu1_IsTextboxClosing(PlayState* play) { #if DEBUG_FEATURES void func_80AEB1D8(EnRu1* this) { + Actor* thisx = &this->actor; + this->action = ENRU1_ACTION_THROWN_ONTO_SAPPHIRE_PLATFORM; this->drawConfig = ENRU1_DRAW_NOTHING; - this->actor.velocity.x = 0.0f; - this->actor.velocity.y = 0.0f; - this->actor.velocity.z = 0.0f; - this->actor.speed = 0.0f; - this->actor.gravity = 0.0f; - this->actor.minVelocityY = 0.0f; - EnRu1_SetPlatformCamSetting(this, CAM_SET_NONE); + thisx->velocity.x = 0.0f; + thisx->velocity.y = 0.0f; + thisx->velocity.z = 0.0f; + thisx->speed = 0.0f; + thisx->gravity = 0.0f; + thisx->minVelocityY = 0.0f; + EnRu1_SetPlatformCamSetting(this, 0); } void func_80AEB220(EnRu1* this, PlayState* play) { @@ -508,10 +509,11 @@ s32 EnRu1_CheckFountainCueNotMatchingId(PlayState* play, u16 cueId) { void EnRu1_SpawnRipple(EnRu1* this, PlayState* play, s16 radiusMax, s16 life) { Vec3f pos; + Actor* thisx = &this->actor; - pos.x = this->actor.world.pos.x; - pos.y = this->actor.world.pos.y + this->actor.depthInWater; - pos.z = this->actor.world.pos.z; + pos.x = thisx->world.pos.x; + pos.y = thisx->world.pos.y + thisx->depthInWater; + pos.z = thisx->world.pos.z; EffectSsGRipple_Spawn(play, &pos, 100, radiusMax, life); } @@ -531,10 +533,11 @@ void EnRu1_SpawnThreeRipples(EnRu1* this, PlayState* play) { void EnRu1_SpawnSplash(EnRu1* this, PlayState* play) { Vec3f pos; + Actor* thisx = &this->actor; - pos.x = this->actor.world.pos.x; - pos.y = this->actor.world.pos.y + this->actor.depthInWater; - pos.z = this->actor.world.pos.z; + pos.x = thisx->world.pos.x; + pos.y = thisx->world.pos.y + thisx->depthInWater; + pos.z = thisx->world.pos.z; EffectSsGSplash_Spawn(play, &pos, NULL, NULL, 1, 0); } @@ -582,14 +585,14 @@ f32 EnRu1_Lerp(f32 scale, s32 startPos, s32 endPos) { } void EnRu1_InitPositionFromFountainCue(EnRu1* this, PlayState* play) { + Actor* thisx = &this->actor; CsCmdActorCue* cue = EnRu1_GetFountainCue(play); if (cue != NULL) { - this->actor.world.rot.y = this->actor.shape.rot.y = cue->rot.y; - - this->actor.world.pos.x = cue->startPos.x; - this->actor.world.pos.y = cue->startPos.y; - this->actor.world.pos.z = cue->startPos.z; + thisx->world.rot.y = thisx->shape.rot.y = cue->rot.y; + thisx->world.pos.x = cue->startPos.x; + thisx->world.pos.y = cue->startPos.y; + thisx->world.pos.z = cue->startPos.z; } } @@ -609,11 +612,11 @@ void EnRu1_SwimTowardLink(EnRu1* this, PlayState* play) { Vec3f* thisPos; f32 swimProximity; CsCmdActorCue* cue = EnRu1_GetFountainCue(play); - STACK_PAD(s32); + Actor* thisx = &this->actor; if (cue != NULL) { swimProximity = EnRu1_GetSwimLerpFactor(cue, play); - thisPos = &this->actor.world.pos; + thisPos = &thisx->world.pos; thisPos->x = EnRu1_Lerp(swimProximity, cue->startPos.x, cue->endPos.x); thisPos->y = EnRu1_Lerp(swimProximity, cue->startPos.y, cue->endPos.y); thisPos->z = EnRu1_Lerp(swimProximity, cue->startPos.z, cue->endPos.z); @@ -630,11 +633,11 @@ void EnRu1_SwimAwayFromLink(EnRu1* this, PlayState* play) { Vec3f* thisPos; f32 proximity; CsCmdActorCue* cue = EnRu1_GetFountainCue(play); - STACK_PAD(s32); + Actor* thisx = &this->actor; if (cue != NULL) { proximity = EnRu1_GetSwimLerpFactor(cue, play); - thisPos = &this->actor.world.pos; + thisPos = &thisx->world.pos; thisPos->x = EnRu1_Lerp(proximity, treadStartPos->x, cue->endPos.x); thisPos->y = EnRu1_Lerp(proximity, treadStartPos->y, cue->endPos.y); thisPos->z = EnRu1_Lerp(proximity, treadStartPos->z, cue->endPos.z); @@ -848,6 +851,8 @@ void EnRu1_Fountain_FinishingSwimBack(EnRu1* this, PlayState* play) { } void EnRu1_InitInJabuJabuHolesRoom(EnRu1* this, PlayState* play) { + Actor* thisx = &this->actor; + if (!GET_INFTABLE(INFTABLE_RUTO_MET_FIRST_TIME)) { EnRu1_AnimationChange(this, &gRutoChildWait2Anim, ANIMMODE_LOOP, 0, false); this->action = ENRU1_ACTION_MEETING_RANGE_CHECK; @@ -858,18 +863,18 @@ void EnRu1_InitInJabuJabuHolesRoom(EnRu1* this, PlayState* play) { s8 actorRoom; EnRu1_AnimationChange(this, &gRutoChildWait2Anim, ANIMMODE_LOOP, 0, false); - actorRoom = this->actor.room; + actorRoom = thisx->room; this->action = ENRU1_ACTION_SPEAK_JABU_PRE_SPAWN; - this->actor.room = -1; + thisx->room = -1; this->drawConfig = ENRU1_DRAW_NOTHING; this->roomNum1 = actorRoom; this->roomNum3 = actorRoom; this->roomNum2 = actorRoom; } else { - Actor_Kill(&this->actor); + Actor_Kill(thisx); } } else { - Actor_Kill(&this->actor); + Actor_Kill(thisx); } } @@ -877,49 +882,53 @@ void EnRu1_InitInJabuJabuHolesRoom(EnRu1* this, PlayState* play) { * Accelerates Ruto forward as she starts to walk away. This lasts for eight frames. */ void EnRu1_AccelerateAway(EnRu1* this) { + Actor* thisx = &this->actor; f32 walkingFrame = this->walkingFrame; if (walkingFrame < 8.0f) { - this->actor.speed = (((kREG(3) * 0.01f) + 2.7f) / 8.0f) * walkingFrame; + thisx->speed = (((kREG(3) * 0.01f) + 2.7f) / 8.0f) * walkingFrame; } else { - this->actor.speed = (kREG(3) * 0.01f) + 2.7f; + thisx->speed = (kREG(3) * 0.01f) + 2.7f; } - this->actor.velocity.y = -1.0f; - Actor_MoveXZGravity(&this->actor); + thisx->velocity.y = -1.0f; + Actor_MoveXZGravity(thisx); } /** * Moves Ruto forward at a constant speed walking away from Link. */ void EnRu1_MoveForwardConstant(EnRu1* this) { - this->actor.velocity.y = -1.0f; - Actor_MoveXZGravity(&this->actor); + Actor* thisx = &this->actor; + thisx->velocity.y = -1.0f; + Actor_MoveXZGravity(thisx); } /** * Accelerate's Ruto's actor downward as she falls down the hole. */ void EnRu1_AccelerateDownHole(EnRu1* this) { - f32* speedXZ = &this->actor.speed; + Actor* thisx = &this->actor; + f32* speedXZ = &thisx->speed; f32* walkingFrame = &this->walkingFrame; if (this->walkingFrame < 8.0f) { *walkingFrame += 1.0f; *speedXZ *= (8.0f - *walkingFrame) / 8.0f; - this->actor.velocity.y = -*walkingFrame * (((kREG(4) * 0.01f) + 13.0f) / 8.0f); + thisx->velocity.y = -*walkingFrame * (((kREG(4) * 0.01f) + 13.0f) / 8.0f); } else { *speedXZ = 0.0f; - this->actor.velocity.y = -((kREG(4) * 0.01f) + 13.0f); + thisx->velocity.y = -((kREG(4) * 0.01f) + 13.0f); } - Actor_MoveXZGravity(&this->actor); + Actor_MoveXZGravity(thisx); } s32 EnRu1_IsPlayerInRangeForFirstEncounter(EnRu1* this, PlayState* play) { Player* player = GET_PLAYER(play); - f32 thisPosZ = this->actor.world.pos.z; + Actor* thisx = &this->actor; + f32 thisPosZ = thisx->world.pos.z; f32 playerPosZ = player->actor.world.pos.z; - if ((playerPosZ - thisPosZ <= 265.0f) && (player->actor.world.pos.y >= this->actor.world.pos.y)) { + if ((playerPosZ - thisPosZ <= 265.0f) && (player->actor.world.pos.y >= thisx->world.pos.y)) { return true; } return false; @@ -968,17 +977,18 @@ void EnRu1_CheckStartFirstEncounter(EnRu1* this, PlayState* play) { } void EnRu1_SetupPositionForFirstEncounter(EnRu1* this, PlayState* play) { + Actor* thisx = &this->actor; CsCmdActorCue* cue; s16 newRotY; if (EnRu1_CheckCueNotMatchingId(play, 1, 3)) { cue = play->csCtx.actorCues[3]; - this->actor.world.pos.x = cue->startPos.x; - this->actor.world.pos.y = cue->startPos.y; - this->actor.world.pos.z = cue->startPos.z; + thisx->world.pos.x = cue->startPos.x; + thisx->world.pos.y = cue->startPos.y; + thisx->world.pos.z = cue->startPos.z; newRotY = cue->rot.y; - this->actor.shape.rot.y = newRotY; - this->actor.world.rot.y = newRotY; + thisx->shape.rot.y = newRotY; + thisx->world.rot.y = newRotY; this->action = ENRU1_ACTION_MEETING_FACING_LINK; this->drawConfig = ENRU1_DRAW_OPA; } @@ -1012,12 +1022,13 @@ void EnRu1_AdvanceWalkingAway(EnRu1* this) { } void EnRu1_CheckStartFalling(EnRu1* this) { - if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { + Actor* thisx = &this->actor; + if (!(thisx->bgCheckFlags & BGCHECKFLAG_GROUND)) { STACK_PAD(s32); this->action = ENRU1_ACTION_MEETING_FALLING_DOWN_HOLE; this->walkingFrame = 0.0f; - this->actor.velocity.y = 0.0f; + thisx->velocity.y = 0.0f; } } @@ -1087,7 +1098,7 @@ void EnRu1_Meeting_End(EnRu1* this, PlayState* play) { } void EnRu1_SpawnBlueWarp(EnRu1* this, PlayState* play) { - STACK_PAD(s32); + Actor* thisx = &this->actor; Vec3f* pos; s16 yawTowardsPlayer; f32 spawnX; @@ -1095,8 +1106,8 @@ void EnRu1_SpawnBlueWarp(EnRu1* this, PlayState* play) { f32 spawnZ; STACK_PADS(s32, 2); - yawTowardsPlayer = this->actor.yawTowardsPlayer; - pos = &this->actor.world.pos; + yawTowardsPlayer = thisx->yawTowardsPlayer; + pos = &thisx->world.pos; spawnX = ((kREG(1) + 12.0f) * Math_SinS(yawTowardsPlayer)) + pos->x; spawnY = pos->y; spawnZ = ((kREG(1) + 12.0f) * Math_CosS(yawTowardsPlayer)) + pos->z; @@ -1123,13 +1134,13 @@ void EnRu1_Rise(EnRu1* this, PlayState* play) { * Ruto rises up in sync with Link as they warp out together. */ void EnRu1_RiseWithLink(EnRu1* this, PlayState* play) { - STACK_PAD(s32); + Actor* thisx = &this->actor; Player* player = GET_PLAYER(play); Vec3f* playerPos = &player->actor.world.pos; s16 shapeRotY = player->actor.shape.rot.y; STACK_PAD(s32); f32 xzDistToPlayer = this->xzDistToPlayerInBlueWarp; - Vec3f* pos = &this->actor.world.pos; + Vec3f* pos = &thisx->world.pos; pos->x = (Math_SinS(shapeRotY) * xzDistToPlayer) + playerPos->x; pos->y = playerPos->y; @@ -1137,11 +1148,11 @@ void EnRu1_RiseWithLink(EnRu1* this, PlayState* play) { } void EnRu1_SetPlayerMarkInBlueWarp(EnRu1* this, PlayState* play) { - STACK_PAD(s32); + Actor* thisx = &this->actor; Player* player = GET_PLAYER(play); Vec3f* player_unk_450 = &player->unk_450; - Vec3f* pos = &this->actor.world.pos; - s16 shapeRotY = this->actor.shape.rot.y; + Vec3f* pos = &thisx->world.pos; + s16 shapeRotY = thisx->shape.rot.y; player_unk_450->x = ((kREG(2) + 30.0f) * Math_SinS(shapeRotY)) + pos->x; player_unk_450->z = ((kREG(2) + 30.0f) * Math_CosS(shapeRotY)) + pos->z; @@ -1206,9 +1217,10 @@ void EnRu1_SetupRiseThroughBlueWarp(EnRu1* this, PlayState* play) { } void EnRu1_EndRise(EnRu1* this) { - if (this->actor.shape.yOffset >= 0.0f) { + Actor* thisx = &this->actor; + if (thisx->shape.yOffset >= 0.0f) { this->action = ENRU1_ACTION_WAIT_INSIDE_BLUE_WARP; - this->actor.shape.yOffset = 0.0f; + thisx->shape.yOffset = 0.0f; EnRu1_SetBlueWarpState(this, WARP_BLUE_RUTO_STATE_READY); } } @@ -1281,23 +1293,25 @@ void EnRu1_BossRoom_WarpingOut(EnRu1* this, PlayState* play) { } void EnRu1_InitInJabuJabuBasement(EnRu1* this, PlayState* play) { + Actor* thisx = &this->actor; + if (GET_INFTABLE(INFTABLE_RUTO_MET_FIRST_TIME) && !GET_INFTABLE(INFTABLE_RUTO_HAS_SAPPHIRE) && !GET_INFTABLE(INFTABLE_RUTO_PLACED_ON_SWITCH) && !GET_INFTABLE(INFTABLE_RUTO_BROUGHT_BACK_TO_HOLES_ROOM)) { if (!EnRu1_IsAssistingLink(this, play)) { s8 actorRoom; EnRu1_AnimationChange(this, &gRutoChildWait2Anim, ANIMMODE_LOOP, 0, false); - actorRoom = this->actor.room; + actorRoom = thisx->room; this->action = ENRU1_ACTION_SPEAK_JABU_PRE_SPAWN; - this->actor.room = -1; + thisx->room = -1; this->roomNum1 = actorRoom; this->roomNum3 = actorRoom; this->roomNum2 = actorRoom; } else { - Actor_Kill(&this->actor); + Actor_Kill(thisx); } } else { - Actor_Kill(&this->actor); + Actor_Kill(thisx); } } @@ -1331,14 +1345,15 @@ void func_80AED600(EnRu1* this) { } s32 func_80AED624(EnRu1* this, PlayState* play) { + Actor* thisx = &this->actor; s8 curRoomNum = play->roomCtx.curRoom.num; if (this->roomNum2 != curRoomNum) { - Actor_Kill(&this->actor); + Actor_Kill(thisx); return false; } else if (((this->roomNum1 != curRoomNum) || (this->roomNum2 != curRoomNum)) && // roomNum2 is always curRoomNum here - (this->actor.depthInWater > kREG(16) + 50.0f) && (this->action != ENRU1_ACTION_SITTING_DISAPPEARING)) { + (thisx->depthInWater > kREG(16) + 50.0f) && (this->action != ENRU1_ACTION_SITTING_DISAPPEARING)) { this->action = ENRU1_ACTION_SITTING_DISAPPEARING; this->drawConfig = ENRU1_DRAW_XLU; this->alpha = 255; @@ -1427,10 +1442,11 @@ void EnRu1_UpdateHeadRotation(EnRu1* this) { } void EnRu1_ResetBgCheckFlags(EnRu1* this, PlayState* play) { - DynaPolyActor* dynaPolyActor = DynaPoly_GetActor(&play->colCtx, this->actor.floorBgId); + Actor* thisx = &this->actor; + DynaPolyActor* dyna = DynaPoly_GetActor(&play->colCtx, thisx->floorBgId); - if (dynaPolyActor == NULL || dynaPolyActor->actor.id == ACTOR_EN_BOX) { - this->actor.bgCheckFlags &= ~(BGCHECKFLAG_GROUND | BGCHECKFLAG_WALL | BGCHECKFLAG_CEILING); + if (dyna == NULL || dyna->actor.id == ACTOR_EN_BOX) { + thisx->bgCheckFlags &= ~(BGCHECKFLAG_GROUND | BGCHECKFLAG_WALL | BGCHECKFLAG_CEILING); } } @@ -1440,14 +1456,14 @@ void EnRu1_UpdateBouncing(EnRu1* this, PlayState* play) { f32* gravity; if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { - DynaPolyActor* dynaPolyActor; + DynaPolyActor* temp_dyna; velocityY = &this->actor.velocity.y; - dynaPolyActor = DynaPoly_GetActor(&play->colCtx, this->actor.floorBgId); + temp_dyna = DynaPoly_GetActor(&play->colCtx, this->actor.floorBgId); if (*velocityY <= 0.0f) { speedXZ = &this->actor.speed; - if (dynaPolyActor != NULL) { - if (dynaPolyActor->actor.id != ACTOR_EN_BOX) { + if (temp_dyna != NULL) { + if (temp_dyna->actor.id != ACTOR_EN_BOX) { *speedXZ = 0.0f; } } else { @@ -1458,8 +1474,8 @@ void EnRu1_UpdateBouncing(EnRu1* this, PlayState* play) { } } gravity = &this->actor.gravity; - if (dynaPolyActor != NULL) { - if (dynaPolyActor->actor.id != ACTOR_EN_BOX) { + if (temp_dyna != NULL) { + if (temp_dyna->actor.id != ACTOR_EN_BOX) { *velocityY = 0.0f; this->actor.minVelocityY = 0.0f; *gravity = 0.0f; @@ -1526,9 +1542,9 @@ void EnRu1_UpdateBouncing(EnRu1* this, PlayState* play) { void EnRu1_UpdateSpeedXZ(EnRu1* this, PlayState* play) { f32* speedXZ = &this->actor.speed; - DynaPolyActor* dynaPolyActor = DynaPoly_GetActor(&play->colCtx, this->actor.floorBgId); + DynaPolyActor* dyna = DynaPoly_GetActor(&play->colCtx, this->actor.floorBgId); - if (dynaPolyActor != NULL && dynaPolyActor->actor.id == ACTOR_EN_BOX) { + if (dyna != NULL && dyna->actor.id == ACTOR_EN_BOX) { if (*speedXZ != 0.0f) { *speedXZ *= 1.1f; } else { @@ -1549,12 +1565,14 @@ void EnRu1_UpdatePosition(EnRu1* this, PlayState* play) { } void EnRu1_StopMoving(EnRu1* this) { - this->actor.velocity.x = 0.0f; - this->actor.velocity.y = 0.0f; - this->actor.velocity.z = 0.0f; - this->actor.speed = 0.0f; - this->actor.gravity = 0.0f; - this->actor.minVelocityY = 0.0f; + Actor* thisx = &this->actor; + + thisx->velocity.x = 0.0f; + thisx->velocity.y = 0.0f; + thisx->velocity.z = 0.0f; + thisx->speed = 0.0f; + thisx->gravity = 0.0f; + thisx->minVelocityY = 0.0f; } void EnRu1_UpdateWaterState(EnRu1* this) { @@ -1614,17 +1632,19 @@ void EnRu1_UpdateWaterState(EnRu1* this) { } s32 EnRu1_TalkOfferAccepted(EnRu1* this, PlayState* play) { - if (!Actor_TalkOfferAccepted(&this->actor, play)) { - this->actor.flags |= ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_FRIENDLY; + Actor* thisx = &this->actor; + + if (!Actor_TalkOfferAccepted(thisx, play)) { + thisx->flags |= ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_FRIENDLY; if (GET_INFTABLE(INFTABLE_RUTO_LET_LINK_CARRY)) { - this->actor.textId = 0x404E; - Actor_OfferTalkNearColChkInfoCylinder(&this->actor, play); + thisx->textId = 0x404E; + Actor_OfferTalkNearColChkInfoCylinder(thisx, play); } else if (GET_INFTABLE(INFTABLE_RUTO_EXPLAINED_WHY_IN_JABU)) { - this->actor.textId = 0x404D; - Actor_OfferTalkNearColChkInfoCylinder(&this->actor, play); + thisx->textId = 0x404D; + Actor_OfferTalkNearColChkInfoCylinder(thisx, play); } else { - this->actor.textId = 0x404C; - Actor_OfferTalkNearColChkInfoCylinder(&this->actor, play); + thisx->textId = 0x404C; + Actor_OfferTalkNearColChkInfoCylinder(thisx, play); } return false; } @@ -1632,14 +1652,14 @@ s32 EnRu1_TalkOfferAccepted(EnRu1* this, PlayState* play) { } void EnRu1_CheckForDoorSwitch(EnRu1* this, PlayState* play) { - DynaPolyActor* dynaPolyActor; + DynaPolyActor* dyna; s32 floorBgId; if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (this->actor.floorBgId != BGCHECK_SCENE)) { floorBgId = this->actor.floorBgId; - dynaPolyActor = DynaPoly_GetActor(&play->colCtx, floorBgId); - if ((dynaPolyActor != NULL) && (dynaPolyActor->actor.id == ACTOR_BG_BDAN_SWITCH)) { - if (PARAMS_GET_U(dynaPolyActor->actor.params, 8, 6) == 0x38) { + dyna = DynaPoly_GetActor(&play->colCtx, floorBgId); + if ((dyna != NULL) && (dyna->actor.id == ACTOR_BG_BDAN_SWITCH)) { + if (PARAMS_GET_U(dyna->actor.params, 8, 6) == 0x38) { SET_INFTABLE(INFTABLE_RUTO_PLACED_ON_SWITCH); return; } @@ -1651,21 +1671,21 @@ void EnRu1_CheckForDoorSwitch(EnRu1* this, PlayState* play) { s32 EnRu1_IsOnSapphirePlatform(EnRu1* this, PlayState* play) { STACK_PADS(s32, 2); CollisionContext* colCtx; - DynaPolyActor* dynaPolyActor; + DynaPolyActor* dynaActor; s32 floorBgId; if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && this->actor.floorBgId != BGCHECK_SCENE) { colCtx = &play->colCtx; floorBgId = this->actor.floorBgId; // necessary match, can't move this out of this block unfortunately - dynaPolyActor = DynaPoly_GetActor(colCtx, floorBgId); - if (dynaPolyActor != NULL && dynaPolyActor->actor.id == ACTOR_BG_BDAN_OBJECTS && - dynaPolyActor->actor.params == 0 && !Player_InCsMode(play) && play->msgCtx.msgLength == 0) { + dynaActor = DynaPoly_GetActor(colCtx, floorBgId); + if (dynaActor != NULL && dynaActor->actor.id == ACTOR_BG_BDAN_OBJECTS && dynaActor->actor.params == 0 && + !Player_InCsMode(play) && play->msgCtx.msgLength == 0) { EnRu1_StopMoving(this); play->csCtx.script = gRutoObtainingSapphireCs; gSaveContext.cutsceneTrigger = 1; this->action = ENRU1_ACTION_THROWN_ONTO_SAPPHIRE_PLATFORM; this->drawConfig = ENRU1_DRAW_NOTHING; - this->bigOctoPlatform = (BgBdanObjects*)dynaPolyActor; + this->bigOctoPlatform = (BgBdanObjects*)dynaActor; this->actor.shape.shadowAlpha = 0; return true; } @@ -1674,28 +1694,30 @@ s32 EnRu1_IsOnSapphirePlatform(EnRu1* this, PlayState* play) { } void EnRu1_UpdateSittingAction(EnRu1* this, PlayState* play) { + Actor* thisx = &this->actor; s8 curRoomNum; // Test if Link is picking Ruto up - if (Actor_HasParent(&this->actor, play)) { + if (Actor_HasParent(thisx, play)) { // Ruto has been picked up curRoomNum = play->roomCtx.curRoom.num; this->roomNum3 = curRoomNum; this->action = ENRU1_ACTION_SITTING_CARRIED; EnRu1_PlayLiftingSfx(this, play); - } else if (!EnRu1_IsOnSapphirePlatform(this, play) && !(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { + } else if ((!EnRu1_IsOnSapphirePlatform(this, play)) && (!(thisx->bgCheckFlags & BGCHECKFLAG_GROUND))) { STACK_PAD(s32); - this->actor.minVelocityY = -((kREG(24) * 0.01f) + 6.8f); - this->actor.gravity = -((kREG(23) * 0.01f) + 1.3f); + thisx->minVelocityY = -((kREG(24) * 0.01f) + 6.8f); + thisx->gravity = -((kREG(23) * 0.01f) + 1.3f); this->action = ENRU1_ACTION_SITTING_RELEASED; } } void EnRu1_CheckLanding(EnRu1* this, PlayState* play) { + Actor* thisx = &this->actor; + if (!EnRu1_IsOnSapphirePlatform(this, play)) { - if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (this->actor.speed == 0.0f) && - (this->actor.minVelocityY == 0.0f)) { + if ((thisx->bgCheckFlags & BGCHECKFLAG_GROUND) && (thisx->speed == 0.0f) && (thisx->minVelocityY == 0.0f)) { STACK_PAD(s32); EnRu1_StopMoving(this); @@ -1705,7 +1727,7 @@ void EnRu1_CheckLanding(EnRu1* this, PlayState* play) { return; } - if (this->actor.depthInWater > 0.0f) { + if (thisx->depthInWater > 0.0f) { this->action = ENRU1_ACTION_SITTING_ENTERING_WATER; this->waterState = ENRU1_WATER_OUTSIDE; } @@ -1816,11 +1838,13 @@ s32 EnRu1_CheckHitBottomUnderwater(EnRu1* this, PlayState* play) { } void EnRu1_CheckSinkingState(EnRu1* this, PlayState* play) { - if ((!EnRu1_CheckHitBottomUnderwater(this, play)) && (this->waterState == ENRU1_WATER_SINKING)) { + Actor* thisx = &this->actor; + + if ((EnRu1_CheckHitBottomUnderwater(this, play) == 0) && (this->waterState == ENRU1_WATER_SINKING)) { this->action = ENRU1_ACTION_SITTING_SINKING; EnRu1_StopMoving(this); - this->actor.gravity = -0.1f; - this->actor.minVelocityY = -((kREG(18) * 0.1f) + 0.7f); + thisx->gravity = -0.1f; + thisx->minVelocityY = -((kREG(18) * 0.1f) + 0.7f); } } @@ -2077,6 +2101,7 @@ void EnRu1_LookUpAtSapphire(EnRu1* this) { } void EnRu1_SetupRetrievingSapphireAnimation(EnRu1* this, PlayState* play) { + Actor* thisx = &this->actor; f32 frameCount; CsCmdActorCue* cue; CsCmdActorCue* cue2; @@ -2087,24 +2112,24 @@ void EnRu1_SetupRetrievingSapphireAnimation(EnRu1* this, PlayState* play) { // this weird part with the redundant variable is necessary to match for some reason cue2 = play->csCtx.actorCues[3]; cue = cue2; - this->actor.world.pos.x = cue->startPos.x; - this->actor.world.pos.y = cue->startPos.y; - this->actor.world.pos.z = cue->startPos.z; + thisx->world.pos.x = cue->startPos.x; + thisx->world.pos.y = cue->startPos.y; + thisx->world.pos.z = cue->startPos.z; newRotTmp = cue->rot.x; - this->actor.shape.rot.x = newRotTmp; - this->actor.world.rot.x = newRotTmp; + thisx->shape.rot.x = newRotTmp; + thisx->world.rot.x = newRotTmp; newRotTmp = cue->rot.y; - this->actor.shape.rot.y = newRotTmp; - this->actor.world.rot.y = newRotTmp; + thisx->shape.rot.y = newRotTmp; + thisx->world.rot.y = newRotTmp; newRotTmp = cue->rot.z; - this->actor.shape.rot.z = newRotTmp; - this->actor.world.rot.z = newRotTmp; + thisx->shape.rot.z = newRotTmp; + thisx->world.rot.z = newRotTmp; Animation_Change(&this->skelAnime, &gRutoChildWalkToAndHoldUpSapphireAnim, 1.0f, 0.0f, frameCount, ANIMMODE_ONCE, 0.0f); EnRu1_StartWalkingTowardSapphire(this, play); this->action = ENRU1_ACTION_RETRIEVING_SAPPHIRE; this->drawConfig = ENRU1_DRAW_OPA; - this->actor.shape.shadowAlpha = 255; + thisx->shape.shadowAlpha = 255; } } @@ -2148,13 +2173,15 @@ void EnRu1_EndRetrievalCutscene(EnRu1* this, PlayState* play) { } void EnRu1_RespondToAbduction(EnRu1* this, PlayState* play) { + Actor* thisx = &this->actor; + if (EnRu1_GetPlatformCamSetting(this) == CAM_SET_DUNGEON0) { - this->actor.flags |= ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_FRIENDLY; - this->actor.textId = 0x4048; + thisx->flags |= ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_FRIENDLY; + thisx->textId = 0x4048; #if !OOT_PAL_N64 - Message_ContinueTextbox(play, this->actor.textId); + Message_ContinueTextbox(play, thisx->textId); #else - Message_StartTextbox(play, this->actor.textId, NULL); + Message_StartTextbox(play, thisx->textId, NULL); #endif EnRu1_PlayAbductedSfx(this, play); this->action = ENRU1_ACTION_BEING_ABDUCTED; @@ -2164,7 +2191,7 @@ void EnRu1_RespondToAbduction(EnRu1* this, PlayState* play) { void EnRu1_RemoveInAbduction(EnRu1* this, PlayState* play) { if (EnRu1_IsTextboxClosing(play)) { - EnRu1_SetPlatformCamSetting(this, CAM_SET_DUNGEON1); + EnRu1_SetPlatformCamSetting(this, 4); Actor_Kill(&this->actor); } } @@ -2244,6 +2271,8 @@ void EnRu1_SapphireRoom_BeingAbducted(EnRu1* this, PlayState* play) { } void EnRu1_InitInSapphireRoom(EnRu1* this, PlayState* play) { + Actor* thisx = &this->actor; + if (GET_INFTABLE(INFTABLE_RUTO_HAS_SAPPHIRE) && !GET_INFTABLE(INFTABLE_RUTO_ABDUCTED)) { STACK_PAD(s32); @@ -2251,9 +2280,9 @@ void EnRu1_InitInSapphireRoom(EnRu1* this, PlayState* play) { this->action = ENRU1_ACTION_WAITING_IN_SAPPHIRE_ROOM; this->bigOctoPlatform = EnRu1_FindBigOctoPlatform(play); EnRu1_SetPlatformCamSetting(this, CAM_SET_NORMAL0); - this->actor.flags &= ~(ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_FRIENDLY); + thisx->flags &= ~(ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_FRIENDLY); } else { - Actor_Kill(&this->actor); + Actor_Kill(thisx); } } @@ -2267,24 +2296,28 @@ void EnRu1_SapphireRoom_Waiting(EnRu1* this, PlayState* play) { } void EnRu1_InitBesideKingZora(EnRu1* this, PlayState* play) { + Actor* thisx = &this->actor; + if (GET_EVENTCHKINF(EVENTCHKINF_37) && LINK_IS_CHILD) { EnRu1_AnimationChange(this, &gRutoChildWait2Anim, ANIMMODE_LOOP, 0, false); - this->actor.flags &= ~ACTOR_FLAG_UPDATE_CULLING_DISABLED; + thisx->flags &= ~ACTOR_FLAG_UPDATE_CULLING_DISABLED; this->action = ENRU1_ACTION_THRONE_IDLE; this->drawConfig = ENRU1_DRAW_OPA; } else { - Actor_Kill(&this->actor); + Actor_Kill(thisx); } } s32 EnRu1_ThroneRoomTalkOfferAccepted(EnRu1* this, PlayState* play) { - if (!Actor_TalkOfferAccepted(&this->actor, play)) { - this->actor.flags |= ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_FRIENDLY; - this->actor.textId = MaskReaction_GetTextId(play, MASK_REACTION_SET_RUTO); - if (this->actor.textId == 0) { - this->actor.textId = 0x402C; + Actor* thisx = &this->actor; + + if (!Actor_TalkOfferAccepted(thisx, play)) { + thisx->flags |= ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_FRIENDLY; + thisx->textId = MaskReaction_GetTextId(play, MASK_REACTION_SET_RUTO); + if (thisx->textId == 0) { + thisx->textId = 0x402C; } - Actor_OfferTalkNearColChkInfoCylinder(&this->actor, play); + Actor_OfferTalkNearColChkInfoCylinder(thisx, play); return false; } return true; @@ -2331,22 +2364,23 @@ void EnRu1_ThroneRoom_Talk(EnRu1* this, PlayState* play) { * Places Ruto beside the door switch outside the room with the map. */ void EnRu1_InitBesideDoorSwitch(EnRu1* this, PlayState* play) { + Actor* thisx = &this->actor; s8 actorRoom; if (GET_INFTABLE(INFTABLE_RUTO_MET_FIRST_TIME) && GET_INFTABLE(INFTABLE_RUTO_PLACED_ON_SWITCH) && !GET_INFTABLE(INFTABLE_RUTO_HAS_SAPPHIRE) && !EnRu1_IsAssistingLink(this, play)) { EnRu1_AnimationChange(this, &gRutoChildWait2Anim, ANIMMODE_LOOP, 0, false); - actorRoom = this->actor.room; + actorRoom = thisx->room; this->action = ENRU1_ACTION_SPEAK_JABU_PRE_SPAWN; - this->actor.room = -1; + thisx->room = -1; this->drawConfig = ENRU1_DRAW_NOTHING; this->roomNum1 = actorRoom; this->roomNum3 = actorRoom; this->roomNum2 = actorRoom; - PRINTF(T("スイッチルトセット!!!!!!!!!!!!!!!!!!!!!!\n", "Ruto switch set!!!!!!!!!!!!!!!!!!!!!!\n")); + PRINTF("スイッチルトセット!!!!!!!!!!!!!!!!!!!!!!\n"); } else { - PRINTF(T("スイッチルトセットしない!!!!!!!!!!!!!!!!!!!!!!\n", "Ruto switch not set!!!!!!!!!!!!!!!!!!!!!!\n")); - Actor_Kill(&this->actor); + PRINTF("スイッチルトセットしない!!!!!!!!!!!!!!!!!!!!!!\n"); + Actor_Kill(thisx); } } @@ -2363,7 +2397,7 @@ void func_80AF0050(EnRu1* this, PlayState* play) { void EnRu1_Update(Actor* thisx, PlayState* play) { EnRu1* this = (EnRu1*)thisx; - if (this->action < 0 || this->action >= ARRAY_COUNT(sActionFuncs) || sActionFuncs[this->action] == NULL) { + if (this->action < 0 || this->action >= 46 || sActionFuncs[this->action] == NULL) { PRINTF(VT_FGCOL(RED) T("メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n", "The main mode is wrong!!!!!!!!!!!!!!!!!!!!!!!!!\n") VT_RST); return; @@ -2373,10 +2407,10 @@ void EnRu1_Update(Actor* thisx, PlayState* play) { } void EnRu1_Init(Actor* thisx, PlayState* play) { - STACK_PAD(s32); EnRu1* this = (EnRu1*)thisx; + STACK_PAD(s32); - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 30.0f); SkelAnime_InitFlex(play, &this->skelAnime, &gRutoChildSkel, NULL, this->jointTable, this->morphTable, 17); EnRu1_InitColliders(&this->actor, play); switch (EnRu1_GetType(this)) { @@ -2407,8 +2441,8 @@ void EnRu1_Init(Actor* thisx, PlayState* play) { break; #endif default: - Actor_Kill(&this->actor); - PRINTF(T("該当 arge_data = %d 無し\n", "Relevant arge_data = %d unacceptable\n"), EnRu1_GetType(this)); + Actor_Kill(thisx); + PRINTF("該当 arge_data = %d 無し\n", EnRu1_GetType(this)); break; } } @@ -2435,8 +2469,7 @@ s32 EnRu1_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* p if ((this->preLimbDrawIndex < 0) || (this->preLimbDrawIndex > 0) || (*sPreLimbDrawFuncs[this->preLimbDrawIndex] == NULL)) { - PRINTF(VT_FGCOL(RED) T("首回しモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n", - "Neck rotation mode is improper!!!!!!!!!!!!!!!!!!!!!!!!!\n") VT_RST); + PRINTF(VT_FGCOL(RED) "首回しモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); } else { sPreLimbDrawFuncs[this->preLimbDrawIndex](this, play, limbIndex, rot); } @@ -2517,7 +2550,7 @@ void EnRu1_DrawXlu(EnRu1* this, PlayState* play) { void EnRu1_Draw(Actor* thisx, PlayState* play) { EnRu1* this = (EnRu1*)thisx; - if (this->drawConfig < 0 || this->drawConfig >= ARRAY_COUNT(sDrawFuncs) || sDrawFuncs[this->drawConfig] == NULL) { + if (this->drawConfig < 0 || this->drawConfig >= 3 || sDrawFuncs[this->drawConfig] == NULL) { PRINTF(VT_FGCOL(RED) T("描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n", "The drawing mode is wrong!!!!!!!!!!!!!!!!!!!!!!!!!\n") VT_RST); return; diff --git a/src/overlays/actors/ovl_En_Ru2/z_en_ru2.c b/src/overlays/actors/ovl_En_Ru2/z_en_ru2.c index 55aea57acbe..6dd706542ca 100644 --- a/src/overlays/actors/ovl_En_Ru2/z_en_ru2.c +++ b/src/overlays/actors/ovl_En_Ru2/z_en_ru2.c @@ -260,19 +260,19 @@ CsCmdActorCue* EnRu2_GetCue(PlayState* play, s32 cueChannel) { s32 EnRu2_CheckCueMatchingId(EnRu2* this, PlayState* play, u16 cueId, s32 cueChannel) { CsCmdActorCue* cue = EnRu2_GetCue(play, cueChannel); - if ((cue != NULL) && (cue->id == cueId)) { - return true; + if (cue != NULL && cue->id == cueId) { + return 1; } - return false; + return 0; } s32 EnRu2_CheckCueNotMatchingId(EnRu2* this, PlayState* play, u16 cueId, s32 cueChannel) { CsCmdActorCue* cue = EnRu2_GetCue(play, cueChannel); - if ((cue != NULL) && (cue->id != cueId)) { - return true; + if (cue != NULL && cue->id != cueId) { + return 1; } - return false; + return 0; } /** @@ -367,7 +367,7 @@ void EnRu2_CheckWaterMedallionCutscene(EnRu2* this, PlayState* play) { Player* player; s16 yaw; - if ((gSaveContext.chamberCutsceneNum == CHAMBER_CS_WATER) && !IS_CUTSCENE_LAYER) { + if (gSaveContext.chamberCutsceneNum == CHAMBER_CS_WATER && !IS_CUTSCENE_LAYER) { player = GET_PLAYER(play); this->action = ENRU2_AWAIT_BLUE_WARP; play->csCtx.script = gWaterMedallionCs; @@ -385,8 +385,7 @@ void EnRu2_CheckIfBlueWarpShouldSpawn(EnRu2* this, PlayState* play) { if (csCtx->state != CS_STATE_IDLE) { cue = csCtx->actorCues[3]; - - if ((cue != NULL) && (cue->id == 2)) { + if (cue != NULL && cue->id == 2) { this->action = ENRU2_RISE_THROUGH_BLUE_WARP; this->drawConfig = ENRU2_DRAW_OPA; EnRu2_SpawnBlueWarp(this, play); @@ -413,8 +412,7 @@ void EnRu2_CheckStartRaisingArms(EnRu2* this, PlayState* play) { if (play->csCtx.state != CS_STATE_IDLE) { cue = play->csCtx.actorCues[3]; - - if ((cue != NULL) && (cue->id == 3)) { + if (cue != NULL && cue->id == 3) { Animation_Change(&this->skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), ANIMMODE_ONCE, 0.0f); this->action = ENRU2_RAISE_ARMS; @@ -440,8 +438,7 @@ void EnRu2_CheckIfWaterMedallionShouldSpawn(EnRu2* this, PlayState* play) { if (play->csCtx.state != CS_STATE_IDLE) { cue = play->csCtx.actorCues[6]; - - if ((cue != NULL) && (cue->id == 2)) { + if (cue != NULL && cue->id == 2) { this->action = ENRU2_FINISH_WATER_MEDALLION_CS; EnRu2_SpawnWaterMedallion(this, play); } @@ -711,8 +708,7 @@ void EnRu2_NextCreditsAction(EnRu2* this, PlayState* play) { EnRu2_SetupTurnHeadDownLeftAnimation(this); break; default: - PRINTF(T("En_Ru2_inEnding_Check_DemoMode:そんな動作は無い!!!!!!!!\n", - "En_Ru2_inEnding_Check_DemoMode: There is no such action!!!!!!!!\n")); + PRINTF("En_Ru2_inEnding_Check_DemoMode:そんな動作は無い!!!!!!!!\n"); break; } this->cueId = nextCueId; @@ -779,7 +775,7 @@ void EnRu2_PlayFanfare(void) { void EnRu2_SwimUpProgress(EnRu2* this) { f32 funcFloat; - this->swimmingUpFrame++; + this->swimmingUpFrame += 1; funcFloat = Environment_LerpWeightAccelDecel((kREG(2) + 0x96) & 0xFFFF, 0, this->swimmingUpFrame, 8, 0); this->actor.world.pos.y = this->actor.home.pos.y + (300.0f * funcFloat); } @@ -843,11 +839,11 @@ void EnRu2_DialogCameraHandler(EnRu2* this, PlayState* play) { if (dialogState == TEXT_STATE_DONE_FADING) { if (this->lastDialogState != TEXT_STATE_DONE_FADING) { - PRINTF(T("おれが小松だ! \n", "I'm Komatsu! \n")); // (cinema scene dev) + PRINTF("おれが小松だ! \n"); this->textboxCount++; if (this->textboxCount % 6 == 3) { player = GET_PLAYER(play); - PRINTF(T("うおりゃー! \n", "uorya-! \n")); // (screaming sound) + PRINTF("うおりゃー! \n"); Camera_SetFinishedFlag(GET_ACTIVE_CAM(play)); player->actor.world.pos.x = 820.0f; player->actor.world.pos.y = 0.0f; @@ -873,7 +869,7 @@ void EnRu2_StartSwimmingUp(EnRu2* this, PlayState* play) { } void EnRu2_EndSwimmingUp(EnRu2* this, PlayState* play) { - if (this->swimmingUpFrame > ((((u16)(kREG(3) + 0x28)) + ((u16)(kREG(2) + 0x96))) & 0xFFFF)) { + if (this->swimmingUpFrame > (((u16)(kREG(3) + 0x28) + (u16)(kREG(2) + 0x96)) & 0xFFFF)) { Actor_Kill(&this->actor); } } @@ -929,7 +925,7 @@ void EnRu2_WaterTempleSwimmingUp(EnRu2* this, PlayState* play) { void EnRu2_Update(Actor* thisx, PlayState* play) { EnRu2* this = (EnRu2*)thisx; - if ((this->action < 0) || (this->action >= ARRAY_COUNT(sActionFuncs)) || (sActionFuncs[this->action] == NULL)) { + if (this->action < 0 || this->action >= 20 || sActionFuncs[this->action] == 0) { PRINTF(VT_FGCOL(RED) T("メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n", "The main mode is wrong!!!!!!!!!!!!!!!!!!!!!!!!!\n") VT_RST); return; @@ -989,8 +985,7 @@ void EnRu2_DrawOpa(EnRu2* this, PlayState* play) { void EnRu2_Draw(Actor* thisx, PlayState* play) { EnRu2* this = (EnRu2*)thisx; - if ((this->drawConfig < 0) || (this->drawConfig >= ARRAY_COUNT(sDrawFuncs)) || - (sDrawFuncs[this->drawConfig] == NULL)) { + if (this->drawConfig < 0 || this->drawConfig >= 3 || sDrawFuncs[this->drawConfig] == NULL) { PRINTF(VT_FGCOL(RED) T("描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n", "The drawing mode is wrong!!!!!!!!!!!!!!!!!!!!!!!!!\n") VT_RST); return; 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 e4e2f2e2e95..89ff9c9c61b 100644 --- a/src/overlays/actors/ovl_En_Sb/z_en_sb.c +++ b/src/overlays/actors/ovl_En_Sb/z_en_sb.c @@ -69,7 +69,7 @@ static ColliderCylinderInitType1 sCylinderInit = { { 30, 40, 0, { 0, 0, 0 } }, }; -static DamageTable sDamageTable[] = { +static DamageTable sDamageTable = { /* Deku nut */ DMG_ENTRY(0, 0x0), /* Deku stick */ DMG_ENTRY(0, 0x0), /* Slingshot */ DMG_ENTRY(0, 0x0), @@ -129,7 +129,7 @@ void EnSb_Init(Actor* thisx, PlayState* play) { EnSb* this = (EnSb*)thisx; Actor_ProcessInitChain(&this->actor, sInitChain); - this->actor.colChkInfo.damageTable = sDamageTable; + this->actor.colChkInfo.damageTable = &sDamageTable; this->actor.colChkInfo.health = 2; SkelAnime_InitFlex(play, &this->skelAnime, &object_sb_Skel_002BF0, &object_sb_Anim_000194, NULL, NULL, 0); Collider_InitCylinder(play, &this->collider); 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 5ee82311b25..8668b21efba 100644 --- a/src/overlays/actors/ovl_En_Si/z_en_si.c +++ b/src/overlays/actors/ovl_En_Si/z_en_si.c @@ -46,7 +46,7 @@ static ColliderCylinderInit sCylinderInit = { { 20, 18, 2, { 0, 0, 0 } }, }; -static CollisionCheckInfoInit2 D_80AFBADC = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; ActorProfile En_Si_Profile = { /**/ ACTOR_EN_SI, @@ -65,7 +65,7 @@ void EnSi_Init(Actor* thisx, PlayState* play) { Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); - CollisionCheck_SetInfo2(&this->actor.colChkInfo, NULL, &D_80AFBADC); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, NULL, &sColChkInfoInit); Actor_SetScale(&this->actor, 0.025f); this->unk_19C = 0; this->actionFunc = func_80AFB768; 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 a0b393eff1a..da3ef053519 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.c +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.c @@ -67,7 +67,7 @@ static ColliderJntSphElementInit sJntSphElementsInit[] = { ACELEM_NONE, OCELEM_NONE, }, - { 15, { { 0, 0, 0 }, 10 }, 100 }, + { STALCHILD_LIMB_RIGHT_HAND, { { 0, 0, 0 }, 10 }, 100 }, }, { { @@ -78,7 +78,7 @@ static ColliderJntSphElementInit sJntSphElementsInit[] = { ACELEM_ON | ACELEM_HOOKABLE, OCELEM_ON, }, - { 1, { { 0, 0, 0 }, 20 }, 100 }, + { STALCHILD_LIMB_ROOT, { { 0, 0, 0 }, 20 }, 100 }, }, }; @@ -146,23 +146,22 @@ void EnSkb_SetupAction(EnSkb* this, EnSkbActionFunc actionFunc) { this->actionFunc = actionFunc; } -void EnSkb_SpawnDebris(PlayState* play, EnSkb* this, Vec3f* spawnPos) { - Vec3f pos; - Vec3f vel = { 0.0f, 8.0f, 0.0f }; - Vec3f accel = { 0.0f, -1.5f, 0.0f }; - f32 spreadAngle; - f32 scale; - - spreadAngle = (Rand_ZeroOne() - 0.5f) * 6.28f; - pos.y = this->actor.floorHeight; - pos.x = (Math_SinF(spreadAngle) * 15.0f) + spawnPos->x; - pos.z = (Math_CosF(spreadAngle) * 15.0f) + spawnPos->z; - accel.x = Rand_CenteredFloat(1.0f); - accel.z = Rand_CenteredFloat(1.0f); - vel.y += (Rand_ZeroOne() - 0.5f) * 4.0f; - scale = (Rand_ZeroOne() * 5.0f) + 12.0f; - EffectSsHahen_Spawn(play, &pos, &vel, &accel, 2, scale * 0.8f, -1, 10, NULL); - func_80033480(play, &pos, 10.0f, 1, 150, 0, 1); +void EnSkb_SpawnDigEffects(PlayState* play, EnSkb* this, Vec3f* pos) { + Vec3f effPos; + Vec3f effVel = { 0.0f, 8.0f, 0.0f }; + Vec3f effAccel = { 0.0f, -1.5f, 0.0f }; + f32 angle; + STACK_PAD(s32); + + angle = (Rand_ZeroOne() - 0.5f) * 6.28f; + effPos.y = this->actor.floorHeight; + effPos.x = (Math_SinF(angle) * 15.0f) + pos->x; + effPos.z = (Math_CosF(angle) * 15.0f) + pos->z; + effAccel.x = Rand_CenteredFloat(1.0f); + effAccel.z = Rand_CenteredFloat(1.0f); + effVel.y += (Rand_ZeroOne() - 0.5f) * 4.0f; + EffectSsHahen_Spawn(play, &effPos, &effVel, &effAccel, 2, ((Rand_ZeroOne() * 5.0f) + 12.0f) * 0.8f, -1, 10, NULL); + func_80033480(play, &effPos, 10.0f, 1, 150, 0, 1); } static InitChainEntry sInitChain[] = { @@ -180,33 +179,30 @@ void EnSkb_Init(Actor* thisx, PlayState* play) { this->actor.colChkInfo.mass = MASS_HEAVY; this->actor.colChkInfo.health = 2; this->actor.shape.yOffset = -8000.0f; - SkelAnime_Init(play, &this->skelAnime, &gStalchildSkel, &gStalchildUncurlingAnim, this->jointTable, - this->morphTable, 20); + SkelAnime_Init(play, &this->skelAnime, &gStalchildSkel, &gStalchildUncurlAnim, this->jointTable, this->morphTable, + STALCHILD_LIMB_MAX); this->actor.naviEnemyId = NAVI_ENEMY_STALCHILD; - Collider_InitJntSph(play, &this->collider); Collider_SetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); Actor_SetScale(&this->actor, ((this->actor.params * 0.1f) + 1.0f) * 0.01f); - this->collider.elements[0].dim.modelSphere.radius = this->collider.elements[0].dim.worldSphere.radius = - 10 + this->actor.params; + this->actor.params + 10; this->collider.elements[1].dim.modelSphere.radius = this->collider.elements[1].dim.worldSphere.radius = - 20 + (this->actor.params * 2); - + (this->actor.params + 10) * 2; this->actor.home.pos = this->actor.world.pos; this->actor.floorHeight = this->actor.world.pos.y; EnSkb_SetupRiseFromGround(this); } void EnSkb_Destroy(Actor* thisx, PlayState* play) { + EnEncount1* temp_v1; EnSkb* this = (EnSkb*)thisx; - if (this->actor.parent != NULL) { - EnEncount1* spawner = (EnEncount1*)this->actor.parent; - - if (spawner->actor.update != NULL) { - if (spawner->curNumSpawn > 0) { - spawner->curNumSpawn--; + if ((this->actor.parent != NULL)) { + temp_v1 = (EnEncount1*)this->actor.parent; + if ((temp_v1->actor.update != NULL)) { + if (temp_v1->curNumSpawn > 0) { + temp_v1->curNumSpawn -= 1; } } } @@ -225,7 +221,7 @@ void EnSkb_DecideNextAction(EnSkb* this) { } void EnSkb_SetupRiseFromGround(EnSkb* this) { - Animation_PlayOnceSetSpeed(&this->skelAnime, &gStalchildUncurlingAnim, 1.0f); + Animation_PlayOnceSetSpeed(&this->skelAnime, &gStalchildUncurlAnim, 1.0f); this->actionState = SKB_BEHAVIOR_BURIED; this->actor.flags &= ~ACTOR_FLAG_ATTENTION_ENABLED; Actor_PlaySfx(&this->actor, NA_SE_EN_RIVA_APPEAR); @@ -234,24 +230,23 @@ void EnSkb_SetupRiseFromGround(EnSkb* this) { void EnSkb_RiseFromGround(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; + this->actor.shape.rot.y = this->actor.world.rot.y = this->actor.yawTowardsPlayer; } else { this->actor.flags |= ACTOR_FLAG_ATTENTION_ENABLED; } Math_SmoothStepToF(&this->actor.shape.yOffset, 0.0f, 1.0f, 800.0f, 0.0f); Math_SmoothStepToF(&this->actor.shape.shadowScale, 25.0f, 1.0f, 2.5f, 0.0f); - if ((play->gameplayFrames & 1) != 0) { - EnSkb_SpawnDebris(play, this, &this->actor.world.pos); + if (play->gameplayFrames & 1) { + EnSkb_SpawnDigEffects(play, this, &this->actor.world.pos); } - if (SkelAnime_Update(&this->skelAnime) && (0.0f == this->actor.shape.yOffset)) { + if (SkelAnime_Update(&this->skelAnime) && (this->actor.shape.yOffset == 0.0f)) { EnSkb_DecideNextAction(this); } } void EnSkb_SetupDespawn(EnSkb* this) { - Animation_Change(&this->skelAnime, &gStalchildUncurlingAnim, -1.0f, - Animation_GetLastFrame(&gStalchildUncurlingAnim), 0.0f, ANIMMODE_ONCE, -4.0f); + Animation_Change(&this->skelAnime, &gStalchildUncurlAnim, -1.0f, Animation_GetLastFrame(&gStalchildUncurlAnim), + 0.0f, ANIMMODE_ONCE, -4.0f); this->actionState = SKB_BEHAVIOR_BURIED; this->setColliderAT = false; this->actor.flags &= ~ACTOR_FLAG_ATTENTION_ENABLED; @@ -263,7 +258,7 @@ void EnSkb_SetupDespawn(EnSkb* this) { void EnSkb_Despawn(EnSkb* this, PlayState* play) { if ((Math_SmoothStepToF(&this->actor.shape.yOffset, -8000.0f, 1.0f, 500.0f, 0.0f) != 0.0f) && (play->gameplayFrames & 1)) { - EnSkb_SpawnDebris(play, this, &this->actor.world.pos); + EnSkb_SpawnDigEffects(play, this, &this->actor.world.pos); } Math_SmoothStepToF(&this->actor.shape.shadowScale, 0.0f, 1.0f, 2.5f, 0.0f); if (SkelAnime_Update(&this->skelAnime)) { @@ -272,8 +267,8 @@ void EnSkb_Despawn(EnSkb* this, PlayState* play) { } void EnSkb_SetupWalkForward(EnSkb* this) { - Animation_Change(&this->skelAnime, &gStalchildWalkingAnim, 0.96000004f, 0.0f, - Animation_GetLastFrame(&gStalchildWalkingAnim), ANIMMODE_LOOP, -4.0f); + Animation_Change(&this->skelAnime, &gStalchildWalkAnim, 0.96000004f, 0.0f, + Animation_GetLastFrame(&gStalchildWalkAnim), ANIMMODE_LOOP, -4.0f); this->actionState = SKB_BEHAVIOR_WALKING; this->headlessYawOffset = 0; this->actor.speed = this->actor.scale.y * 160.0f; @@ -281,37 +276,27 @@ void EnSkb_SetupWalkForward(EnSkb* this) { } void EnSkb_WalkForward(EnSkb* this, PlayState* play) { - s32 thisKeyFrame; - s32 prevKeyFrame; - f32 playSpeed; + s32 temp_ft2_sp34; + f32 var_fv1_2; + s32 temp_ft4; Player* player = GET_PLAYER(play); - if ((this->breakFlags != 0) && ((play->gameplayFrames & 0xF) == 0)) { - this->headlessYawOffset = Rand_CenteredFloat(50000.0f); + if ((this->breakFlags != 0) && !(play->gameplayFrames & 0xF)) { + this->headlessYawOffset = (s16)(s32)Rand_CenteredFloat(50000.0f); } - Math_SmoothStepToS(&this->actor.shape.rot.y, (this->actor.yawTowardsPlayer + this->headlessYawOffset), 1, 0x2EE, 0); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer + this->headlessYawOffset, 1, 0x2EE, 0); this->actor.world.rot.y = this->actor.shape.rot.y; - thisKeyFrame = this->skelAnime.curFrame; + temp_ft2_sp34 = (s32)this->skelAnime.curFrame; SkelAnime_Update(&this->skelAnime); - if (this->skelAnime.playSpeed >= 0.0f) { - playSpeed = this->skelAnime.playSpeed; - } else { - playSpeed = -this->skelAnime.playSpeed; + var_fv1_2 = ABS(this->skelAnime.playSpeed); + temp_ft4 = (s32)(this->skelAnime.curFrame - var_fv1_2); + var_fv1_2 = ABS(this->skelAnime.playSpeed); + if ((temp_ft2_sp34 != (s32)this->skelAnime.curFrame) && + (((temp_ft4 < 9) && (((s32)var_fv1_2 + temp_ft2_sp34) >= 8)) || + ((temp_ft4 < 0x10) && (((s32)var_fv1_2 + temp_ft2_sp34) >= 0xF)))) { + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_WALK); } - prevKeyFrame = (this->skelAnime.curFrame - playSpeed); - if (this->skelAnime.playSpeed >= 0.0f) { - playSpeed = this->skelAnime.playSpeed; - } else { - playSpeed = -this->skelAnime.playSpeed; - } - if (thisKeyFrame != (s32)this->skelAnime.curFrame) { - if (((prevKeyFrame < 9) && (((s32)playSpeed + thisKeyFrame) >= 8)) || - !((prevKeyFrame >= 16) || (((s32)playSpeed + thisKeyFrame) < 15))) { - - Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_WALK); - } - } - if (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) > 800.0f || IS_DAY) { + if ((Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) > 800.0f) || IS_DAY) { EnSkb_SetupDespawn(this); } else if (Actor_IsFacingPlayer(&this->actor, 0x11C7) && (this->actor.xzDistToPlayer < (60.0f + (this->actor.params * 6.0f)))) { @@ -320,8 +305,8 @@ void EnSkb_WalkForward(EnSkb* this, PlayState* play) { } void EnSkb_SetupAttack(EnSkb* this) { - Animation_Change(&this->skelAnime, &gStalchildAttackingAnim, 0.6f, 0.0f, - Animation_GetLastFrame(&gStalchildAttackingAnim), ANIMMODE_ONCE_INTERP, 4.0f); + Animation_Change(&this->skelAnime, &gStalchildAttackAnim, 0.6f, 0.0f, Animation_GetLastFrame(&gStalchildAttackAnim), + ANIMMODE_ONCE_INTERP, 4.0f); this->collider.base.atFlags &= ~AT_BOUNCED; this->actionState = SKB_BEHAVIOR_ATTACKING; this->actor.speed = 0.0f; @@ -329,13 +314,14 @@ void EnSkb_SetupAttack(EnSkb* this) { } void EnSkb_Attack(EnSkb* this, PlayState* play) { - s32 frameData; + s32 temp_ft1; + STACK_PAD(s32); - frameData = this->skelAnime.curFrame; - if (frameData == 3) { + temp_ft1 = (s32)this->skelAnime.curFrame; + if (temp_ft1 == 3) { Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_ATTACK); this->setColliderAT = true; - } else if (frameData == 6) { + } else if (temp_ft1 == 6) { this->setColliderAT = false; } if (this->collider.base.atFlags & AT_BOUNCED) { @@ -347,7 +333,7 @@ void EnSkb_Attack(EnSkb* this, PlayState* play) { } void EnSkb_SetupRecoil(EnSkb* this) { - Animation_Change(&this->skelAnime, &gStalchildAttackingAnim, -0.4f, this->skelAnime.curFrame - 1.0f, 0.0f, + Animation_Change(&this->skelAnime, &gStalchildAttackAnim, -0.4f, this->skelAnime.curFrame - 1.0f, 0.0f, ANIMMODE_ONCE_INTERP, 0.0f); this->collider.base.atFlags &= ~AT_BOUNCED; this->actionState = SKB_BEHAVIOR_RECOILING; @@ -361,7 +347,7 @@ void EnSkb_Recoil(EnSkb* this, PlayState* play) { } } -void EnSkb_SetupStunned(EnSkb* this) { +void func_80AFD540(EnSkb* this) { if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { this->actor.speed = 0.0f; } @@ -372,6 +358,8 @@ void EnSkb_SetupStunned(EnSkb* this) { } void EnSkb_Stunned(EnSkb* this, PlayState* play) { + STACK_PAD(s32); + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { this->actor.speed = 0.0f; } @@ -401,23 +389,21 @@ void EnSkb_SetupTakeDamage(EnSkb* this) { } void EnSkb_TakeDamage(EnSkb* this, PlayState* play) { - // this cast is likely not real, but allows for a match u8* new_var; new_var = &this->breakFlags; if ((this->breakFlags != 1) || BodyBreak_SpawnParts(&this->actor, &this->bodyBreak, play, 1)) { - if ((*new_var) != 0) { - this->breakFlags = (*new_var) | 2; + if (*new_var != 0) { + this->breakFlags = *new_var | 2; } if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { - this->actor.speed = 0; + this->actor.speed = 0.0f; } if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { if (this->actor.speed < 0.0f) { this->actor.speed += 0.05f; } } - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0x1194, 0); if (SkelAnime_Update(&this->skelAnime) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { EnSkb_DecideNextAction(this); @@ -426,9 +412,8 @@ void EnSkb_TakeDamage(EnSkb* this, PlayState* play) { } void EnSkb_SetupDeath(EnSkb* this, PlayState* play) { - Animation_MorphToPlayOnce(&this->skelAnime, &gStalchildDyingAnim, -4.0f); - this->actor.shape.rot.y = this->actor.yawTowardsPlayer; - this->actor.world.rot.y = this->actor.yawTowardsPlayer; + Animation_MorphToPlayOnce(&this->skelAnime, &gStalchildDieAnim, -4.0f); + this->actor.world.rot.y = this->actor.shape.rot.y = this->actor.yawTowardsPlayer; if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { this->actor.speed = -6.0f; } @@ -436,11 +421,12 @@ void EnSkb_SetupDeath(EnSkb* this, PlayState* play) { this->actor.flags &= ~ACTOR_FLAG_ATTENTION_ENABLED; BodyBreak_Alloc(&this->bodyBreak, 18, play); this->breakFlags |= 4; - EffectSsDeadSound_SpawnStationary(play, &this->actor.projectedPos, NA_SE_EN_STALKID_DEAD, 1, 1, 0x28); + EffectSsDeadSound_SpawnStationary(play, &this->actor.projectedPos, NA_SE_EN_STALKID_DEAD, 1, 1, 40); EnSkb_SetupAction(this, EnSkb_Death); } void EnSkb_Death(EnSkb* this, PlayState* play) { + if (BodyBreak_SpawnParts(&this->actor, &this->bodyBreak, play, 1)) { if (this->actor.scale.x == 0.01f) { Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, @@ -452,19 +438,17 @@ void EnSkb_Death(EnSkb* this, PlayState* play) { Item_DropCollectible(play, &this->actor.world.pos, ITEM00_RUPEE_RED); Item_DropCollectible(play, &this->actor.world.pos, ITEM00_RUPEE_RED); } - this->breakFlags |= 8; Actor_Kill(&this->actor); } } void EnSkb_CheckDamage(EnSkb* this, PlayState* play) { - STACK_PAD(s16); - s32 i; - Vec3f flamePos; - s16 scale; - s16 colorFilterDuration; Player* player; + s32 colorFilterDuration; + Vec3f sp54; + s16 sp52; + s32 var_s0; if ((this->actionState != SKB_BEHAVIOR_DYING) && (this->actor.bgCheckFlags & (BGCHECKFLAG_WATER | BGCHECKFLAG_WATER_TOUCH)) && @@ -472,50 +456,46 @@ void EnSkb_CheckDamage(EnSkb* this, PlayState* play) { this->actor.colChkInfo.health = 0; this->setColliderAT = false; EnSkb_SetupDeath(this, play); - } else if (this->actionState >= SKB_BEHAVIOR_ATTACKING) { - if (this->collider.base.acFlags & AC_HIT) { - this->collider.base.acFlags &= ~AC_HIT; - if (this->actor.colChkInfo.damageReaction != 6) { - this->lastDamageReaction = this->actor.colChkInfo.damageReaction; - Actor_SetDropFlag(&this->actor, &this->collider.elements[1].base, true); - this->setColliderAT = false; - if (this->actor.colChkInfo.damageReaction == 1) { - if (this->actionState != SKB_BEHAVIOR_STUNNED) { - Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 120, COLORFILTER_BUFFLAG_OPA, - 80); - Actor_ApplyDamage(&this->actor); - EnSkb_SetupStunned(this); + } else if ((this->actionState >= SKB_BEHAVIOR_ATTACKING) && (this->collider.base.acFlags & AC_HIT)) { + this->collider.base.acFlags &= ~AC_HIT; + if (((this->actor.colChkInfo.damageReaction != 6))) { + this->lastDamageReaction = this->actor.colChkInfo.damageReaction; + Actor_SetDropFlag(&this->actor, &this->collider.elements[1].base, true); + this->setColliderAT = false; + if (this->actor.colChkInfo.damageReaction == 1) { + if (this->actionState != SKB_BEHAVIOR_STUNNED) { + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 120, COLORFILTER_BUFFLAG_OPA, 80); + Actor_ApplyDamage(&this->actor); + func_80AFD540(this); + } + } else { + colorFilterDuration = 8; + if (this->actor.colChkInfo.damageReaction == 7) { + sp52 = this->actor.scale.y * 7500.0f; + for (var_s0 = 4; var_s0 >= 0; var_s0--) { + sp54 = this->actor.world.pos; + sp54.x += Rand_CenteredFloat(20.0f); + sp54.z += Rand_CenteredFloat(20.0f); + sp54.y += Rand_ZeroOne() * 25.0f; + EffectSsEnFire_SpawnVec3f(play, &this->actor, &sp54, sp52, 0, 0, -1); } + colorFilterDuration = 25; + } + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, + colorFilterDuration); + if (Actor_ApplyDamage(&this->actor) == 0) { + EnSkb_SetupDeath(this, play); } else { - colorFilterDuration = 8; - if (this->actor.colChkInfo.damageReaction == 7) { - scale = this->actor.scale.y * 7500.0f; - for (i = 4; i >= 0; i--) { - flamePos = this->actor.world.pos; - flamePos.x += Rand_CenteredFloat(20.0f); - flamePos.z += Rand_CenteredFloat(20.0f); - flamePos.y += (Rand_ZeroOne() * 25.0f); - EffectSsEnFire_SpawnVec3f(play, &this->actor, &flamePos, scale, 0, 0, -1); - } - colorFilterDuration = 25; - } - Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, - colorFilterDuration); - if (!Actor_ApplyDamage(&this->actor)) { - EnSkb_SetupDeath(this, play); - return; - } player = GET_PLAYER(play); - if (this->breakFlags == 0) { - if ((this->actor.colChkInfo.damageReaction == 0xD) || - ((this->actor.colChkInfo.damageReaction == 0xE) && - ((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)))) { - BodyBreak_Alloc(&this->bodyBreak, 2, play); - this->breakFlags = 1; // setup for head bodybreak - } + if ((this->breakFlags == 0) && + (((this->actor.colChkInfo.damageReaction == 0xD)) || + ((this->actor.colChkInfo.damageReaction == 0xE) && + (((((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))))) { + BodyBreak_Alloc(&this->bodyBreak, 2, play); + this->breakFlags = 1; // setup for head bodybreak } EnSkb_SetupTakeDamage(this); } @@ -535,48 +515,45 @@ void EnSkb_Update(Actor* thisx, PlayState* play) { UPDBGCHECKINFO_FLAG_4); this->actionFunc(this, play); this->actor.focus.pos = this->actor.world.pos; - this->actor.focus.pos.y += (3000.0f * this->actor.scale.y); + this->actor.focus.pos.y += 3000.0f * this->actor.scale.y; if (this->setColliderAT) { CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } - - if (this->actionState >= SKB_BEHAVIOR_ATTACKING) { - if ((this->actor.colorFilterTimer == 0) || ((this->actor.colorFilterParams & 0x4000) == 0)) { - - CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); - } + if ((this->actionState >= SKB_BEHAVIOR_ATTACKING) && + ((this->actor.colorFilterTimer == 0) || !(this->actor.colorFilterParams & 0x4000))) { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -s32 EnSkb_OverrideLimbDraw(PlayState* play2, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - EnSkb* this = (EnSkb*)thisx; - PlayState* play = (PlayState*)play2; - s16 color; +s32 EnSkb_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + EnSkb* this = thisx; + PlayState* play2 = play; + s32 temp_v0; - if (limbIndex == 11) { - if ((this->breakFlags & 2) == 0) { // head limb, head is still attached - OPEN_DISPS(play->state.gfxCtx, "../z_en_skb.c", 972); - color = ABS((s16)(Math_SinS(play->gameplayFrames * 0x1770) * 95.0f)) + 160; + if (limbIndex == STALCHILD_LIMB_HEAD) { + if (!(this->breakFlags & 2)) { // head limb, head is still attached + OPEN_DISPS(play2->state.gfxCtx, "../z_en_skb.c", 972); + temp_v0 = (s16)(ABS((s16)(Math_SinS(play2->gameplayFrames * 0x1770) * 95.0f)) + 0xA0); gDPPipeSync(POLY_OPA_DISP++); - gDPSetEnvColor(POLY_OPA_DISP++, color, color, color, 255); - CLOSE_DISPS(play->state.gfxCtx, "../z_en_skb.c", 978); + gDPSetEnvColor(POLY_OPA_DISP++, temp_v0, temp_v0, temp_v0, 255); + CLOSE_DISPS(play2->state.gfxCtx, "../z_en_skb.c", 978); } else { *dList = NULL; } - } else if ((limbIndex == 12) && ((this->breakFlags & 2) != 0)) { // jaw limb, don't draw if headless + } else if ((limbIndex == STALCHILD_LIMB_JAW) && (this->breakFlags & 2)) { // jaw limb, don't draw if headless *dList = NULL; } return 0; } -void EnSkb_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { - EnSkb* this = (EnSkb*)thisx; +void EnSkb_PostLimbDraw(PlayState* arg0, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { + EnSkb* this = thisx; Collider_UpdateSpheres(limbIndex, &this->collider); - if ((this->breakFlags ^ 1) == 0) { - BodyBreak_SetInfo(&this->bodyBreak, limbIndex, 11, 12, 18, dList, BODYBREAK_OBJECT_SLOT_DEFAULT); + BodyBreak_SetInfo(&this->bodyBreak, limbIndex, STALCHILD_LIMB_HEAD, STALCHILD_LIMB_JAW, 18, dList, + BODYBREAK_OBJECT_SLOT_DEFAULT); } else if ((this->breakFlags ^ (this->breakFlags | 4)) == 0) { BodyBreak_SetInfo(&this->bodyBreak, limbIndex, 0, 18, 18, dList, BODYBREAK_OBJECT_SLOT_DEFAULT); } @@ -584,7 +561,8 @@ void EnSkb_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void EnSkb_Draw(Actor* thisx, PlayState* play) { EnSkb* this = (EnSkb*)thisx; + Gfx_SetupDL_25Opa(play->state.gfxCtx); SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSkb_OverrideLimbDraw, - EnSkb_PostLimbDraw, &this->actor); + EnSkb_PostLimbDraw, this); } 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 e40c049cfa7..bd46a416a0c 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.h +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.h @@ -4,24 +4,26 @@ #include "ultra64.h" #include "actor.h" +#include "assets/objects/object_skb/object_skb.h" + struct EnSkb; typedef void (*EnSkbActionFunc)(struct EnSkb*, struct PlayState*); typedef struct EnSkb { - /* 0x0000 */ Actor actor; - /* 0x014C */ SkelAnime skelAnime; - /* 0x0190 */ Vec3s jointTable[20]; - /* 0x0208 */ Vec3s morphTable[20]; - /* 0x0280 */ u8 actionState; - /* 0x0281 */ u8 setColliderAT; - /* 0x0282 */ u8 lastDamageReaction; - /* 0x0283 */ u8 breakFlags; - /* 0x0284 */ EnSkbActionFunc actionFunc; - /* 0x0288 */ s16 headlessYawOffset; - /* 0x028C */ BodyBreak bodyBreak; - /* 0x02A4 */ ColliderJntSph collider; - /* 0x02C4 */ ColliderJntSphElement colliderElements[2]; -} EnSkb; // size = 0x0344 + /* 0x000 */ Actor actor; + /* 0x14C */ SkelAnime skelAnime; + /* 0x190 */ Vec3s jointTable[STALCHILD_LIMB_MAX]; + /* 0x208 */ Vec3s morphTable[STALCHILD_LIMB_MAX]; + /* 0x280 */ u8 actionState; + /* 0x281 */ u8 setColliderAT; + /* 0x282 */ u8 lastDamageReaction; + /* 0x283 */ u8 breakFlags; + /* 0x284 */ EnSkbActionFunc actionFunc; + /* 0x288 */ s16 headlessYawOffset; + /* 0x28C */ BodyBreak bodyBreak; + /* 0x2A4 */ ColliderJntSph collider; + /* 0x2C4 */ ColliderJntSphElement colliderElements[2]; +} EnSkb; // size = 0x344 #endif 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 3f021fe6c93..018ab3b166e 100644 --- a/src/overlays/actors/ovl_En_St/z_en_st.c +++ b/src/overlays/actors/ovl_En_St/z_en_st.c @@ -1,9 +1,3 @@ -/* - * File: z_en_st.c - * Overlay: ovl_En_St - * Description: Skulltula (normal, big, invisible) - */ - #include "z_en_st.h" #include "libc64/qrand.h" @@ -153,7 +147,7 @@ void EnSt_SetupAction(EnSt* this, EnStActionFunc actionFunc) { } /** - * Spawns `dustCnt` dust particles in a random pattern around the Skulltula + * Spawns `dustCnt` dust particles in a random pattern around the skulltulla */ void EnSt_SpawnDust(EnSt* this, PlayState* play, s32 dustCnt) { Color_RGBA8 primColor = { 170, 130, 90, 255 }; @@ -221,8 +215,8 @@ s32 EnSt_CreateBlureEffect(PlayState* play) { } /** - * Checks for the position of the ceiling above the Skulltula. - * If no ceiling is found it is set to 1000 units above the Skulltula + * Checks for the position of the ceiling above the skulltulla. + * If no ceiling is found it is set to 1000 units above the skulltulla */ s32 EnSt_CheckCeilingPos(EnSt* this, PlayState* play) { CollisionPoly* poly; @@ -292,7 +286,7 @@ void EnSt_SetDropAnimAndVel(EnSt* this) { } /** - * Initializes the Skulltula's 6 cylinders, and sphere collider. + * Initializes the skulltulla's 6 cylinders, and sphere collider. */ void EnSt_InitColliders(EnSt* this, PlayState* play) { ColliderCylinderInit* cylinders[6] = { @@ -506,11 +500,11 @@ s32 EnSt_CheckHitBackside(EnSt* this, PlayState* play) { } /** - * Checks if the Skulltula's colliders have been hit, returns true if the hit has dealt damage to the Skulltula + * Checks if the skulltulla's colliders have been hit, returns true if the hit has dealt damage to the skulltulla */ s32 EnSt_CheckColliders(EnSt* this, PlayState* play) { if (EnSt_CheckHitFrontside(this)) { - // player has hit the front shield area of the Skulltula + // player has hit the front shield area of the skulltulla return false; } @@ -519,12 +513,12 @@ s32 EnSt_CheckColliders(EnSt* this, PlayState* play) { } if (EnSt_CheckHitBackside(this, play)) { - // player has hit the backside of the Skulltula + // player has hit the backside of the skulltulla return true; } if (this->stunTimer == 0 && this->takeDamageSpinTimer == 0) { - // check if the Skulltula has hit the player. + // check if the skulltulla has hit the player. EnSt_CheckHitPlayer(this, play); } return false; @@ -591,7 +585,7 @@ s32 EnSt_DecrStunTimer(EnSt* this) { } /** - * Updates the yaw of the Skulltula, used for the shaking animation right before + * Updates the yaw of the skulltulla, used for the shaking animation right before * turning, and the actual turning to face away from the player, and then back to * face the player */ @@ -617,7 +611,7 @@ void EnSt_UpdateYaw(EnSt* this, PlayState* play) { if (this->swayTimer == 0 && this->deathTimer == 0 && this->finishDeathTimer == 0) { // not swaying or dying if (this->takeDamageSpinTimer != 0 || this->gaveDamageSpinTimer != 0) { - // Skulltula is doing a spinning animation + // skulltulla is doing a spinning animation this->actor.shape.rot.y += 0x2000; return; } @@ -675,17 +669,17 @@ void EnSt_UpdateYaw(EnSt* this, PlayState* play) { } /** - * Checks to see if the Skulltula is done bouncing on the ground, - * spawns dust particles as the Skulltula hits the ground + * Checks to see if the skulltulla is done bouncing on the ground, + * spawns dust particles as the skulltulla hits the ground */ s32 EnSt_IsDoneBouncing(EnSt* this, PlayState* play) { if (this->actor.velocity.y > 0.0f || this->groundBounces == 0) { - // the Skulltula is moving upwards or the groundBounces is 0 + // the skulltulla is moving upwards or the groundBounces is 0 return false; } if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { - // the Skulltula is not on the ground. + // the skulltulla is not on the ground. return false; } @@ -697,7 +691,7 @@ s32 EnSt_IsDoneBouncing(EnSt* this, PlayState* play) { if (this->groundBounces != 0) { return false; } else { - // make sure the Skulltula stays on the ground. + // make sure the skulltulla stays on the ground. this->actor.velocity.y = 0.0f; } return true; @@ -720,19 +714,19 @@ s32 EnSt_IsCloseToPlayer(EnSt* this, PlayState* play) { // skull is spinning from damage. return false; } else if (this->actor.xzDistToPlayer > 160.0f) { - // player is more than 160 xz units from the Skulltula + // player is more than 160 xz units from the skulltulla return false; } yDist = this->actor.world.pos.y - player->actor.world.pos.y; if (yDist < 0.0f || yDist > 400.0f) { - // player is above the Skulltula or more than 400 units below - // the Skulltula + // player is above the skulltulla or more than 400 units below + // the skulltulla return false; } if (player->actor.world.pos.y < this->actor.floorHeight) { - // player is below the Skulltula's ground position + // player is below the Skulltulla's ground position return false; } return true; @@ -759,7 +753,7 @@ s32 EnSt_IsCloseToGround(EnSt* this) { } /** - * Does the animation of the Skulltula swaying back and forth after the Skulltula + * Does the animation of the skulltulla swaying back and forth after the skulltulla * has been hit in the front by a sword */ void EnSt_Sway(EnSt* this) { @@ -851,7 +845,7 @@ void EnSt_WaitOnCeiling(EnSt* this, PlayState* play) { } /** - * Skulltula is waiting on the ground for the player to move away, or for + * Skulltulla is waiting on the ground for the player to move away, or for * a collider to have contact */ void EnSt_WaitOnGround(EnSt* this, PlayState* play) { @@ -903,12 +897,12 @@ void EnSt_LandOnGround(EnSt* this, PlayState* play) { this->sfxTimer++; if (this->sfxTimer == 14) { - // play the sound effect of the Skulltula hitting the ground. + // play the sound effect of the skulltulla hitting the ground. Actor_PlaySfx(&this->actor, NA_SE_EN_STALTU_DOWN_SET); } if ((this->actor.floorHeight + this->floorHeightOffset) < this->actor.world.pos.y) { - // the Skulltula has hit the ground. + // the skulltulla has hit the ground. this->sfxTimer = 0; EnSt_SetupAction(this, EnSt_WaitOnGround); } else { @@ -929,7 +923,7 @@ void EnSt_MoveToGround(EnSt* this, PlayState* play) { EnSt_SetReturnToCeilingAnimation(this); EnSt_SetupAction(this, EnSt_ReturnToCeiling); } else if (EnSt_IsCloseToGround(this)) { - // The Skulltula has become close to the ground. + // The skulltulla has become close to the ground. EnSt_SpawnBlastEffect(this, play); EnSt_SetLandAnimation(this); EnSt_SetupAction(this, EnSt_LandOnGround); @@ -951,7 +945,7 @@ void EnSt_ReturnToCeiling(EnSt* this, PlayState* play) { EnSt_SetDropAnimAndVel(this); EnSt_SetupAction(this, EnSt_MoveToGround); } else if (EnSt_IsCloseToInitialPos(this)) { - // the Skulltula is close to the initial postion. + // the skulltulla is close to the initial postion. EnSt_SetWaitingAnimation(this); EnSt_SetupAction(this, EnSt_WaitOnCeiling); } else { @@ -961,7 +955,7 @@ void EnSt_ReturnToCeiling(EnSt* this, PlayState* play) { } /** - * The Skulltula has been killed, bounce around + * The skulltulla has been killed, bounce around */ void EnSt_BounceAround(EnSt* this, PlayState* play) { this->actor.colorFilterTimer = this->deathTimer; @@ -1054,14 +1048,14 @@ void EnSt_Update(Actor* thisx, PlayState* play) { Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_2); if ((this->stunTimer == 0) && (this->swayTimer == 0)) { - // run the current action if the Skulltula isn't stunned + // run the current action if the skulltulla isn't stunned // or swaying. this->actionFunc(this, play); } else if (this->stunTimer != 0) { // decrement the stun timer. EnSt_DecrStunTimer(this); } else { - // sway the Skulltula. + // sway the skulltulla. EnSt_Sway(this); } 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 7a5ccc666c0..31d609324af 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -77,7 +77,7 @@ static ColliderJntSphInit sJntSphInit = { sJntSphElementsInit, }; -static CollisionCheckInfoInit2 D_80B0F074 = { 1, 2, 25, 25, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 1, 2, 25, 25, MASS_IMMOVABLE }; typedef enum EnSwAnimation { /* 0 */ ENSW_ANIM_0, @@ -273,7 +273,7 @@ void EnSw_Init(Actor* thisx, PlayState* play) { ActorShape_Init(&thisx->shape, 0.0f, NULL, 0.0f); Collider_InitJntSph(play, &this->collider); Collider_SetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); - CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0xE), &D_80B0F074); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0xE), &sColChkInfoInit); this->actor.scale.x = 0.02f; if (PARAMS_GET_S(thisx->params, 13, 3) == 0) { 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 2af05049882..41c72dddc78 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 @@ -498,7 +498,7 @@ void EnSyatekiMan_Update(Actor* thisx, PlayState* play) { Actor_TrackPlayer(play, &this->actor, &this->headRot, &this->bodyRot, this->actor.focus.pos); } -s32 EnSyatekiMan_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { +s32 func_80B1148C(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { EnSyatekiMan* this = (EnSyatekiMan*)thisx; s32 turnDirection; @@ -523,7 +523,7 @@ void EnSyatekiMan_Draw(Actor* thisx, PlayState* play) { Gfx_SetupDL_25Opa(play->state.gfxCtx); SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnSyatekiMan_OverrideLimbDraw, NULL, this); + func_80B1148C, NULL, this); } #if DEBUG_FEATURES 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 414db70d385..66e0667e628 100644 --- a/src/overlays/actors/ovl_En_Test/z_en_test.c +++ b/src/overlays/actors/ovl_En_Test/z_en_test.c @@ -78,67 +78,10 @@ void func_80862FA8(EnTest* this, PlayState* play); s32 EnTest_ReactToProjectile(PlayState* play, EnTest* this); static u8 sUpperBodyLimbCopyMap[] = { - false, // STALFOS_LIMB_NONE - false, // STALFOS_LIMB_ROOT - false, // STALFOS_LIMB_UPPERBODY_ROOT - false, // STALFOS_LIMB_CORE_LOWER_ROOT - true, // STALFOS_LIMB_CORE_UPPER_ROOT - true, // STALFOS_LIMB_NECK_ROOT - true, // STALFOS_LIMB_HEAD_ROOT - true, // STALFOS_LIMB_7 - true, // STALFOS_LIMB_8 - true, // STALFOS_LIMB_JAW_ROOT - true, // STALFOS_LIMB_JAW - true, // STALFOS_LIMB_HEAD - true, // STALFOS_LIMB_NECK_UPPER - true, // STALFOS_LIMB_NECK_LOWER - true, // STALFOS_LIMB_CORE_UPPER - true, // STALFOS_LIMB_CHEST - true, // STALFOS_LIMB_SHOULDER_R_ROOT - true, // STALFOS_LIMB_SHOULDER_ARMOR_R_ROOT - true, // STALFOS_LIMB_SHOULDER_ARMOR_R - true, // STALFOS_LIMB_SHOULDER_L_ROOT - true, // STALFOS_LIMB_SHOULDER_ARMOR_L_ROOT - true, // STALFOS_LIMB_SHOULDER_ARMOR_L - true, // STALFOS_LIMB_ARM_L_ROOT - true, // STALFOS_LIMB_UPPERARM_L_ROOT - true, // STALFOS_LIMB_FOREARM_L_ROOT - true, // STALFOS_LIMB_HAND_L_ROOT - true, // STALFOS_LIMB_HAND_L - true, // STALFOS_LIMB_SHIELD - true, // STALFOS_LIMB_FOREARM_L - true, // STALFOS_LIMB_UPPERARM_L - true, // STALFOS_LIMB_ARM_R_ROOT - true, // STALFOS_LIMB_UPPERARM_R_ROOT - true, // STALFOS_LIMB_FOREARM_R_ROOT - true, // STALFOS_LIMB_HAND_R_ROOT - true, // STALFOS_LIMB_SWORD - true, // STALFOS_LIMB_HAND_R - true, // STALFOS_LIMB_FOREARM_R - true, // STALFOS_LIMB_UPPERARM_R - true, // STALFOS_LIMB_CORE_LOWER - false, // STALFOS_LIMB_LOWERBODY_ROOT - false, // STALFOS_LIMB_WAIST_ROOT - false, // STALFOS_LIMB_LEGS_ROOT - false, // STALFOS_LIMB_LEG_L_ROOT - false, // STALFOS_LIMB_THIGH_L_ROOT - false, // STALFOS_LIMB_LOWERLEG_L_ROOT - false, // STALFOS_LIMB_ANKLE_L_ROOT - false, // STALFOS_LIMB_ANKLE_L - false, // STALFOS_LIMB_FOOT_L_ROOT - false, // STALFOS_LIMB_FOOT_L - false, // STALFOS_LIMB_LOWERLEG_L - false, // STALFOS_LIMB_THIGH_L - false, // STALFOS_LIMB_LEG_R_ROOT - false, // STALFOS_LIMB_THIGH_R_ROOT - false, // STALFOS_LIMB_LOWERLEG_R_ROOT - false, // STALFOS_LIMB_ANKLE_R_ROOT - false, // STALFOS_LIMB_ANKLE_R - false, // STALFOS_LIMB_FOOT_R_ROOT - false, // STALFOS_LIMB_FOOT_R - false, // STALFOS_LIMB_LOWERLEG_R - false, // STALFOS_LIMB_THIGH_R - false, // STALFOS_LIMB_WAIST + false, false, false, false, true, true, true, true, true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, false, false, false, false, false, }; ActorProfile En_Test_Profile = { @@ -275,10 +218,10 @@ void EnTest_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(&this->actor, sInitChain); - SkelAnime_Init(play, &this->skelAnime, &gStalfosSkel, &gStalfosMiddleGuardAnim, this->jointTable, this->morphTable, - STALFOS_LIMB_MAX); - SkelAnime_Init(play, &this->upperSkelanime, &gStalfosSkel, &gStalfosMiddleGuardAnim, this->upperJointTable, - this->upperMorphTable, STALFOS_LIMB_MAX); + SkelAnime_Init(play, &this->skelAnime, &gStalfosSkel, &gStalfosFightingWaitAnim, this->jointTable, this->morphTable, + 61); + SkelAnime_Init(play, &this->upperSkelanime, &gStalfosSkel, &gStalfosFightingWaitAnim, this->upperJointTable, + this->upperMorphTable, 61); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawFeet, 90.0f); @@ -440,7 +383,7 @@ void EnTest_ChooseAction(EnTest* this, PlayState* play) { } void EnTest_SetupWaitGround(EnTest* this) { - Animation_PlayLoop(&this->skelAnime, &gStalfosMiddleGuardAnim); + Animation_PlayLoop(&this->skelAnime, &gStalfosFightingWaitAnim); this->unk_7C8 = 0; this->timer = 15; this->actor.scale.y = 0.0f; @@ -471,7 +414,7 @@ void EnTest_WaitGround(EnTest* this, PlayState* play) { } void EnTest_SetupWaitAbove(EnTest* this) { - Animation_PlayLoop(&this->skelAnime, &gStalfosMiddleGuardAnim); + Animation_PlayLoop(&this->skelAnime, &gStalfosFightingWaitAnim); this->unk_7C8 = 0; this->actor.world.pos.y = this->actor.home.pos.y + 150.0f; Actor_SetScale(&this->actor, 0.0f); @@ -492,7 +435,7 @@ void EnTest_WaitAbove(EnTest* this, PlayState* play) { } void EnTest_SetupIdle(EnTest* this) { - Animation_PlayLoop(&this->skelAnime, &gStalfosMiddleGuardAnim); + Animation_PlayLoop(&this->skelAnime, &gStalfosFightingWaitAnim); this->unk_7C8 = 0xA; this->timer = (Rand_ZeroOne() * 10.0f) + 5.0f; this->actor.speed = 0.0f; @@ -552,7 +495,7 @@ void EnTest_Idle(EnTest* this, PlayState* play) { } void EnTest_Fall(EnTest* this, PlayState* play) { - Animation_PlayOnceSetSpeed(&this->skelAnime, &gStalfosLandFromLeapAnim, 0.0f); + Animation_PlayOnceSetSpeed(&this->skelAnime, &gStalfosLandingAnim, 0.0f); SkelAnime_Update(&this->skelAnime); if (this->actor.world.pos.y <= this->actor.floorHeight) { @@ -572,9 +515,9 @@ void EnTest_Land(EnTest* this, PlayState* play) { } void EnTest_SetupWalkAndBlock(EnTest* this) { - Animation_Change(&this->upperSkelanime, &gStalfosBlockWithShieldAnim, 2.0f, 0.0f, - Animation_GetLastFrame(&gStalfosBlockWithShieldAnim), 2, 2.0f); - Animation_PlayLoop(&this->skelAnime, &gStalfosSlowAdvanceAnim); + Animation_Change(&this->upperSkelanime, &gStalfosDefendAnim, 2.0f, 0.0f, + Animation_GetLastFrame(&gStalfosDefendAnim), 2, 2.0f); + Animation_PlayLoop(&this->skelAnime, &gStalfosFightingWalkAnim); this->timer = (s16)(Rand_ZeroOne() * 5.0f); this->unk_7C8 = 0xD; this->actor.world.rot.y = this->actor.shape.rot.y; @@ -618,12 +561,12 @@ void EnTest_WalkAndBlock(EnTest* this, PlayState* play) { if (ABS(this->actor.speed) < 3.0f) { STACK_PAD(s32); - Animation_Change(&this->skelAnime, &gStalfosSlowAdvanceAnim, 0.0f, this->skelAnime.curFrame, - Animation_GetLastFrame(&gStalfosSlowAdvanceAnim), 0, -6.0f); + Animation_Change(&this->skelAnime, &gStalfosFightingWalkAnim, 0.0f, this->skelAnime.curFrame, + Animation_GetLastFrame(&gStalfosFightingWalkAnim), 0, -6.0f); playSpeed = this->actor.speed * 10.0f; } else { - Animation_Change(&this->skelAnime, &gStalfosFastAdvanceAnim, 0.0f, this->skelAnime.curFrame, - Animation_GetLastFrame(&gStalfosFastAdvanceAnim), 0, -4.0f); + Animation_Change(&this->skelAnime, &gStalfosFightingRunAnim, 0.0f, this->skelAnime.curFrame, + Animation_GetLastFrame(&gStalfosFightingRunAnim), 0, -4.0f); playSpeed = this->actor.speed * 10.0f * 0.02f; } @@ -657,11 +600,12 @@ void EnTest_WalkAndBlock(EnTest* this, PlayState* play) { prevFrame = (s32)this->skelAnime.curFrame; SkelAnime_Update(&this->skelAnime); - beforeCurFrame = (s32)(this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed)); + + beforeCurFrame = this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed); absPlaySpeed = (s32)(f32)ABS(this->skelAnime.playSpeed); if ((s32)this->skelAnime.curFrame != prevFrame) { - s32 afterPrevFrame = absPlaySpeed + prevFrame; + s32 afterPrevFrame = (s32)absPlaySpeed + prevFrame; if (((afterPrevFrame > 1) && (beforeCurFrame < 1)) || ((beforeCurFrame < 7) && (afterPrevFrame > 7))) { Actor_PlaySfx(&this->actor, NA_SE_EN_STAL_WALK); @@ -726,7 +670,7 @@ void EnTest_WalkAndBlock(EnTest* this, PlayState* play) { // a variation of sidestep void func_80860BDC(EnTest* this) { - Animation_PlayLoop(&this->skelAnime, &gStalfosSidestepAnim); + Animation_PlayLoop(&this->skelAnime, &gStalfosSideWalkAnim); this->unk_7C8 = 0xE; EnTest_SetupAction(this, func_80860C24); } @@ -739,7 +683,7 @@ void func_80860C24(EnTest* this, PlayState* play) { s32 prevFrame; s32 beforeCurFrame; s32 afterPrevFrame; - s32 absPlaySpeed; + f32 absPlaySpeed; if (!EnTest_ReactToProjectile(play, this)) { yawDiff = this->actor.yawTowardsPlayer; @@ -765,13 +709,17 @@ void func_80860C24(EnTest* this, PlayState* play) { this->skelAnime.playSpeed = playSpeed; } - prevFrame = (s32)this->skelAnime.curFrame; + prevFrame = this->skelAnime.curFrame; + SkelAnime_Update(&this->skelAnime); - beforeCurFrame = (s32)(this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed)); - absPlaySpeed = (s32)(f32)ABS(this->skelAnime.playSpeed); + + beforeCurFrame = this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed); + absPlaySpeed = ABS(this->skelAnime.playSpeed); + + if (1) {} if ((s32)this->skelAnime.curFrame != prevFrame) { - afterPrevFrame = absPlaySpeed + prevFrame; + afterPrevFrame = (s32)absPlaySpeed + prevFrame; if (((afterPrevFrame > 2) && (beforeCurFrame <= 0)) || ((beforeCurFrame < 7) && (afterPrevFrame >= 9))) { Actor_PlaySfx(&this->actor, NA_SE_EN_STAL_WALK); @@ -794,7 +742,7 @@ void func_80860C24(EnTest* this, PlayState* play) { // a variation of sidestep void func_80860EC0(EnTest* this) { - Animation_PlayLoop(&this->skelAnime, &gStalfosSidestepAnim); + Animation_PlayLoop(&this->skelAnime, &gStalfosSideWalkAnim); this->unk_7C8 = 0xF; this->actor.speed = (Rand_ZeroOne() > 0.5f) ? -0.5f : 0.5f; this->timer = (s16)((Rand_ZeroOne() * 15.0f) + 25.0f); @@ -813,7 +761,8 @@ void func_80860F84(EnTest* this, PlayState* play) { Player* player = GET_PLAYER(play); f32 checkDist = 0.0f; s16 newYaw; - s32 absPlaySpeed; + f32 absPlaySpeed; + s32 afterPrevFrame; if (!EnTest_ReactToProjectile(play, this)) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0xFA0, 1); @@ -879,14 +828,14 @@ void func_80860F84(EnTest* this, PlayState* play) { } this->skelAnime.playSpeed = this->actor.speed * 0.5f; - - prevFrame = (s32)this->skelAnime.curFrame; + prevFrame = this->skelAnime.curFrame; SkelAnime_Update(&this->skelAnime); - beforeCurFrame = (s32)(this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed)); - absPlaySpeed = (s32)(f32)ABS(this->skelAnime.playSpeed); + + beforeCurFrame = this->skelAnime.curFrame - ABS(this->skelAnime.playSpeed); + absPlaySpeed = ABS(this->skelAnime.playSpeed); if ((s32)this->skelAnime.curFrame != prevFrame) { - s32 afterPrevFrame = absPlaySpeed + prevFrame; + afterPrevFrame = (s32)absPlaySpeed + prevFrame; if (((afterPrevFrame > 1) && (beforeCurFrame < 1)) || ((beforeCurFrame < 7) && (afterPrevFrame > 7))) { Actor_PlaySfx(&this->actor, NA_SE_EN_STAL_WALK); @@ -909,7 +858,7 @@ void func_80860F84(EnTest* this, PlayState* play) { } void EnTest_SetupSlashDown(EnTest* this) { - Animation_PlayOnce(&this->skelAnime, &gStalfosDownSlashAnim); + Animation_PlayOnce(&this->skelAnime, &gStalfosKiruAnim); Audio_StopSfxByPosAndId(&this->actor.projectedPos, NA_SE_EN_STAL_WARAU); this->swordCollider.base.atFlags &= ~AT_BOUNCED; this->unk_7C8 = 0x10; @@ -949,7 +898,7 @@ void EnTest_SlashDown(EnTest* this, PlayState* play) { } void EnTest_SetupSlashDownEnd(EnTest* this) { - Animation_PlayOnce(&this->skelAnime, &gStalfosRecoverFromDownSlashAnim); + Animation_PlayOnce(&this->skelAnime, &gStalfosKiruEndAnim); this->unk_7C8 = 0x12; this->actor.speed = 0.0f; EnTest_SetupAction(this, EnTest_SlashDownEnd); @@ -1009,7 +958,7 @@ void EnTest_SlashDownEnd(EnTest* this, PlayState* play) { } void EnTest_SetupSlashUp(EnTest* this) { - Animation_PlayOnce(&this->skelAnime, &gStalfosUpSlashAnim); + Animation_PlayOnce(&this->skelAnime, &gStalfosKiruFinshAnim); this->swordCollider.base.atFlags &= ~AT_BOUNCED; this->unk_7C8 = 0x11; this->swordCollider.elem.atDmgInfo.damage = 16; @@ -1040,7 +989,7 @@ void EnTest_SlashUp(EnTest* this, PlayState* play) { } void EnTest_SetupJumpBack(EnTest* this) { - Animation_PlayOnce(&this->skelAnime, &gStalfosJumpBackwardsAnim); + Animation_PlayOnce(&this->skelAnime, &gStalfosBackJumpAnim); Actor_PlaySfx(&this->actor, NA_SE_EN_STAL_JUMP); this->unk_7C8 = 0x14; this->timer = 5; @@ -1091,7 +1040,7 @@ void EnTest_JumpBack(EnTest* this, PlayState* play) { } void EnTest_SetupJumpslash(EnTest* this) { - Animation_PlayOnce(&this->skelAnime, &gStalfosJumpAnim); + Animation_PlayOnce(&this->skelAnime, &gStalfosJumpKiruAnim); Audio_StopSfxByPosAndId(&this->actor.projectedPos, NA_SE_EN_STAL_WARAU); this->timer = 0; this->unk_7C8 = 0x17; @@ -1111,7 +1060,7 @@ void EnTest_SetupJumpslash(EnTest* this) { void EnTest_Jumpslash(EnTest* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { if (this->timer == 0) { - Animation_PlayOnce(&this->skelAnime, &gStalfosJumpslashAnim); + Animation_PlayOnce(&this->skelAnime, &gStalfosJumpKiruEndAnim); this->timer = 1; this->swordState = 1; Actor_PlaySfx(&this->actor, NA_SE_EN_STAL_SAKEBI); @@ -1138,7 +1087,7 @@ void EnTest_Jumpslash(EnTest* this, PlayState* play) { } void EnTest_SetupJumpUp(EnTest* this) { - Animation_PlayOnce(&this->skelAnime, &gStalfosJumpAnim); + Animation_PlayOnce(&this->skelAnime, &gStalfosJumpKiruAnim); this->timer = 0; this->unk_7C8 = 4; this->actor.velocity.y = 14.0f; @@ -1166,14 +1115,14 @@ void EnTest_JumpUp(EnTest* this, PlayState* play) { this->actor.speed = 0.0f; this->unk_7C8 = 0xC; this->timer = 4; - Animation_Change(&this->skelAnime, &gStalfosLandFromLeapAnim, 0.0f, 0.0f, 0.0f, 2, 0.0f); + Animation_Change(&this->skelAnime, &gStalfosLandingAnim, 0.0f, 0.0f, 0.0f, 2, 0.0f); EnTest_SetupAction(this, EnTest_Land); } } void EnTest_SetupStopAndBlock(EnTest* this) { - Animation_Change(&this->skelAnime, &gStalfosBlockWithShieldAnim, 2.0f, 0.0f, - Animation_GetLastFrame(&gStalfosBlockWithShieldAnim), 2, 2.0f); + Animation_Change(&this->skelAnime, &gStalfosDefendAnim, 2.0f, 0.0f, Animation_GetLastFrame(&gStalfosDefendAnim), 2, + 2.0f); this->unk_7C8 = 0x15; this->actor.speed = 0.0f; this->timer = (Rand_ZeroOne() * 10.0f) + 11.0f; @@ -1200,7 +1149,7 @@ void EnTest_StopAndBlock(EnTest* this, PlayState* play) { } void EnTest_SetupIdleFromBlock(EnTest* this) { - Animation_MorphToLoop(&this->skelAnime, &gStalfosMiddleGuardAnim, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &gStalfosFightingWaitAnim, -4.0f); this->unk_7C8 = 0x16; EnTest_SetupAction(this, EnTest_IdleFromBlock); } @@ -1224,7 +1173,7 @@ void EnTest_IdleFromBlock(EnTest* this, PlayState* play) { } void func_80862154(EnTest* this) { - Animation_PlayOnce(&this->skelAnime, &gStalfosFlinchFromHitFrontAnim); + Animation_PlayOnce(&this->skelAnime, &gStalfosFrontDamageAnim); Actor_PlaySfx(&this->actor, NA_SE_EN_STAL_DAMAGE); this->unk_7C8 = 8; this->actor.speed = -2.0f; @@ -1268,7 +1217,7 @@ void func_808621D4(EnTest* this, PlayState* play) { } void func_80862398(EnTest* this) { - Animation_PlayOnce(&this->skelAnime, &gStalfosFlinchFromHitBehindAnim); + Animation_PlayOnce(&this->skelAnime, &gStalfosBackDamageAnim); Actor_PlaySfx(&this->actor, NA_SE_EN_STAL_DAMAGE); this->unk_7C8 = 9; this->actor.speed = -2.0f; @@ -1322,7 +1271,7 @@ void EnTest_SetupStunned(EnTest* this) { if (this->lastDamageReaction == STALFOS_DMG_REACT_FREEZE) { this->iceTimer = 36; } else { - Animation_PlayOnceSetSpeed(&this->skelAnime, &gStalfosFlinchFromHitFrontAnim, 0.0f); + Animation_PlayOnceSetSpeed(&this->skelAnime, &gStalfosFrontDamageAnim, 0.0f); } } @@ -1366,7 +1315,7 @@ void func_808627C4(EnTest* this, PlayState* play) { return; } - Animation_MorphToLoop(&this->skelAnime, &gStalfosSidestepAnim, -2.0f); + Animation_MorphToLoop(&this->skelAnime, &gStalfosSideWalkAnim, -2.0f); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0xFA0, 1); this->actor.speed = ((play->gameplayFrames % 2) != 0) ? -4.0f : 4.0f; this->actor.world.rot.y = this->actor.shape.rot.y + 0x3FFF; @@ -1387,6 +1336,7 @@ void func_808628C8(EnTest* this, PlayState* play) { f32 checkDist = 0.0f; s16 newYaw; f32 absPlaySpeed; + s32 afterPrevFrame; Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0xFA0, 1); @@ -1465,7 +1415,7 @@ void func_808628C8(EnTest* this, PlayState* play) { Actor_PlaySfx(&this->actor, NA_SE_EN_STAL_WARAU); } if ((s32)this->skelAnime.curFrame != prevFrame) { - s32 afterPrevFrame = (s32)absPlaySpeed + prevFrame; + afterPrevFrame = (s32)absPlaySpeed + prevFrame; if (((afterPrevFrame > 1) && (beforeCurFrame < 1)) || ((beforeCurFrame < 7) && (afterPrevFrame > 7))) { Actor_PlaySfx(&this->actor, NA_SE_EN_STAL_WALK); @@ -1551,7 +1501,7 @@ void func_80862E6C(EnTest* this, PlayState* play) { } void func_80862FA8(EnTest* this, PlayState* play) { - Animation_PlayOnce(&this->skelAnime, &gStalfosFallOverBackwardsAnim); + Animation_PlayOnce(&this->skelAnime, &gStalfosBackDownAnim); Actor_PlaySfx(&this->actor, NA_SE_EN_STAL_DEAD); this->unk_7DE = 0; this->actor.flags &= ~ACTOR_FLAG_ATTENTION_ENABLED; @@ -1580,7 +1530,7 @@ void func_80863044(EnTest* this, PlayState* play) { } void func_808630F0(EnTest* this, PlayState* play) { - Animation_PlayOnce(&this->skelAnime, &gStalfosFallOverForwardsAnim); + Animation_PlayOnce(&this->skelAnime, &gStalfosFrontDownAnim); Actor_PlaySfx(&this->actor, NA_SE_EN_STAL_DEAD); this->unk_7C8 = 6; this->actor.colorFilterTimer = 0; @@ -1758,8 +1708,8 @@ void EnTest_Update(Actor* thisx, PlayState* play) { break; case 1: - Animation_Change(&this->upperSkelanime, &gStalfosBlockWithShieldAnim, 2.0f, 0.0f, - Animation_GetLastFrame(&gStalfosBlockWithShieldAnim), 2, 2.0f); + Animation_Change(&this->upperSkelanime, &gStalfosDefendAnim, 2.0f, 0.0f, + Animation_GetLastFrame(&gStalfosDefendAnim), 2, 2.0f); AnimTaskQueue_AddCopyUsingMap(play, this->skelAnime.limbCount, this->skelAnime.jointTable, this->upperSkelanime.jointTable, sUpperBodyLimbCopyMap); this->unk_7DE++; @@ -1842,11 +1792,11 @@ s32 EnTest_OverrideLimbDraw(PlayState* play2, s32 limbIndex, Gfx** dList, Vec3f* EnTest* this = (EnTest*)thisx; PlayState* play = (PlayState*)play2; - if (limbIndex == STALFOS_LIMB_HEAD_ROOT) { + if (limbIndex == 6) { rot->x += this->headRot.y; rot->y -= this->headRot.x; rot->z += this->headRot.z; - } else if (limbIndex == STALFOS_LIMB_HEAD) { + } else if (limbIndex == 11) { OPEN_DISPS(play->state.gfxCtx, "../z_en_test.c", 3582); gDPPipeSync(POLY_OPA_DISP++); @@ -1887,7 +1837,7 @@ void EnTest_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot BodyBreak_SetInfo(&this->bodyBreak, limbIndex, 0, 60, 60, dList, BODYBREAK_OBJECT_SLOT_DEFAULT); - if (limbIndex == STALFOS_LIMB_SWORD) { + if (limbIndex == 34) { Matrix_MultVec3f(&D_8086467C, &this->swordCollider.dim.quad[1]); Matrix_MultVec3f(&D_80864688, &this->swordCollider.dim.quad[0]); Matrix_MultVec3f(&D_80864694, &this->swordCollider.dim.quad[3]); @@ -1907,16 +1857,16 @@ void EnTest_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot this->swordState = -1; } - } else if ((limbIndex == STALFOS_LIMB_SHIELD) && (this->unk_7DE != 0)) { + } else if ((limbIndex == 27) && (this->unk_7DE != 0)) { Matrix_MultVec3f(&D_80864670, &sp64); this->shieldCollider.dim.pos.x = sp64.x; this->shieldCollider.dim.pos.y = sp64.y; this->shieldCollider.dim.pos.z = sp64.z; } else { - Actor_SetFeetPos(&this->actor, limbIndex, STALFOS_LIMB_FOOT_L, &D_80864658, STALFOS_LIMB_ANKLE_R, &D_80864658); + Actor_SetFeetPos(&this->actor, limbIndex, 48, &D_80864658, 55, &D_80864658); - if ((limbIndex == STALFOS_LIMB_FOOT_L) || (limbIndex == STALFOS_LIMB_ANKLE_R)) { + if ((limbIndex == 48) || (limbIndex == 55)) { if ((this->unk_7C8 == 0x15) || (this->unk_7C8 == 0x16)) { if (this->actor.speed != 0.0f) { Matrix_MultVec3f(&D_80864658, &sp64); @@ -1928,31 +1878,31 @@ void EnTest_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot if (this->iceTimer != 0) { switch (limbIndex) { - case STALFOS_LIMB_HEAD: + case 11: bodyPart = 0; break; - case STALFOS_LIMB_CHEST: + case 15: bodyPart = 1; break; - case STALFOS_LIMB_SWORD: + case 34: bodyPart = 2; break; - case STALFOS_LIMB_SHIELD: + case 27: bodyPart = 3; break; - case STALFOS_LIMB_UPPERARM_R: + case 37: bodyPart = 4; break; - case STALFOS_LIMB_UPPERARM_L: + case 29: bodyPart = 5; break; - case STALFOS_LIMB_WAIST: + case 60: bodyPart = 6; break; - case STALFOS_LIMB_FOOT_L: + case 48: bodyPart = 7; break; - case STALFOS_LIMB_FOOT_R: + case 57: bodyPart = 8; break; } @@ -1993,7 +1943,7 @@ void EnTest_Draw(Actor* thisx, PlayState* play) { // a variation of sidestep void func_80864158(EnTest* this, f32 xzSpeed) { - Animation_MorphToLoop(&this->skelAnime, &gStalfosSidestepAnim, -2.0f); + Animation_MorphToLoop(&this->skelAnime, &gStalfosSideWalkAnim, -2.0f); this->actor.speed = xzSpeed; this->actor.world.rot.y = this->actor.shape.rot.y + 0x3FFF; this->timer = (Rand_ZeroOne() * 20.0f) + 15.0f; 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 8cd0191654c..ca6655f8d1a 100644 --- a/src/overlays/actors/ovl_En_Test/z_en_test.h +++ b/src/overlays/actors/ovl_En_Test/z_en_test.h @@ -13,11 +13,11 @@ typedef struct EnTest { /* 0x000 */ Actor actor; /* 0x14C */ Vec3s bodyPartsPos[10]; /* 0x188 */ SkelAnime skelAnime; - /* 0x1CC */ Vec3s jointTable[STALFOS_LIMB_MAX]; - /* 0x33A */ Vec3s morphTable[STALFOS_LIMB_MAX]; + /* 0x1CC */ Vec3s jointTable[61]; + /* 0x33A */ Vec3s morphTable[61]; /* 0x4A8 */ SkelAnime upperSkelanime; - /* 0x4EC */ Vec3s upperJointTable[STALFOS_LIMB_MAX]; - /* 0x65A */ Vec3s upperMorphTable[STALFOS_LIMB_MAX]; + /* 0x4EC */ Vec3s upperJointTable[61]; + /* 0x65A */ Vec3s upperMorphTable[61]; /* 0x7C8 */ u8 unk_7C8; /* 0x7CC */ EnTestActionFunc actionFunc; /* 0x7D0 */ Vec3s headRot; 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 e9aff52e3c4..9359dac5f4e 100644 --- a/src/overlays/actors/ovl_En_Tite/z_en_tite.c +++ b/src/overlays/actors/ovl_En_Tite/z_en_tite.c @@ -889,7 +889,7 @@ void EnTite_CheckDamage(Actor* thisx, PlayState* play) { if (thisx->colChkInfo.health == 0) { EnTite_SetupDeathCry(this); } else { - // Flip tektite back up if it's on its back + // Flip tektite back up if it's on it's back Actor_PlaySfx(thisx, NA_SE_EN_TEKU_DAMAGE); if (this->flipState != TEKTITE_FLIPPED) { EnTite_SetupRecoil(this); diff --git a/src/overlays/actors/ovl_En_Tp/z_en_tp.c b/src/overlays/actors/ovl_En_Tp/z_en_tp.c index 3f069618692..2824151e6b3 100644 --- a/src/overlays/actors/ovl_En_Tp/z_en_tp.c +++ b/src/overlays/actors/ovl_En_Tp/z_en_tp.c @@ -140,7 +140,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(lockOnArrowOffset, 10, ICHAIN_STOP), }; -void EnTp_SetupAction(EnTp* this, void (*actionFunc)(EnTp*, PlayState*)) { +void EnTp_SetupAction(EnTp* this, EnTpActionFunc actionFunc) { this->actionFunc = actionFunc; } @@ -249,9 +249,8 @@ void EnTp_Head_SetupAttack(EnTp* this) { } void EnTp_Head_Attack(EnTp* this, PlayState* play) { - Player* player; + Player* player = GET_PLAYER(play); - player = GET_PLAYER(play); Math_SmoothStepToF(&this->actor.world.pos.y, player->actor.world.pos.y + 30.0f, 1.0f, 0.5f, 0.0f); SFX_PLAY_AT_POS(&this->actor.projectedPos, NA_SE_EN_TAIL_FLY - SFX_FLAG); if (this->collider.base.atFlags & AT_HIT) { @@ -371,9 +370,8 @@ void EnTp_Head_SetupHover(EnTp* this) { void EnTp_Head_Hover(EnTp* this, PlayState* play) { STACK_PAD(s32); - Player* player; + Player* player = GET_PLAYER(play); - player = GET_PLAYER(play); Math_SmoothStepToF(&this->actor.speed, 2.5f, 0.1f, 0.2f, 0.0f); // bodyElemDist_ is always 0 here Math_SmoothStepToF(&this->actor.world.pos.y, player->actor.world.pos.y + 85.0f + this->bodyElemDist, 1.0f, @@ -417,10 +415,9 @@ void EnTp_Head_SetupWaitPlayerAndRise(EnTp* this) { } void EnTp_Head_WaitPlayerAndRise(EnTp* this, PlayState* play) { - Player* player; + Player* player = GET_PLAYER(play); s16 sp32; - player = GET_PLAYER(play); this->timer2--; if (this->actor.xzDistToPlayer < 200.0f) { if (this->collider.base.atFlags & AT_HIT) { @@ -475,11 +472,10 @@ void EnTp_Head_SinkIntoGroundAndReappear(EnTp* this, PlayState* play) { static Color_RGBA8 sBubbleEnvColor = { 150, 150, 150, 0 }; Vec3f bubbleVel; Vec3f bubblePos; - s32 isInsideGround; + s32 isInsideGround = false; EnTp* child; s16 new_var; //! FAKE - isInsideGround = false; this->timer2--; // timer is initialized to 0, // so this runs due to the pos.y check once the actor is deep enough under ground (see other "plunge" branch below) @@ -626,18 +622,16 @@ void EnTp_CheckCollide(EnTp* this, PlayState* play) { } void EnTp_Update(Actor* thisx, PlayState* play) { - Player* player; + EnTp* this = (EnTp*)thisx; STACK_PAD(s32); Vec3f sparkVel = { 0.0f, 0.0f, 0.0f }; Vec3f sparkAccel = { 0.0f, -0.6f, 0.0f }; Vec3f sparkPos; Color_RGBA8 sparkPrimColor = { 0, 0, 255, 255 }; Color_RGBA8 sparkEnvColor = { 0, 0, 0, 0 }; - EnTp* this = (EnTp*)thisx; + Player* player = GET_PLAYER(play); s16 v; - player = GET_PLAYER(play); - if (player->stateFlags1 & PLAYER_STATE1_26) { this->unk_158 = ENTP_DMG_REACT_NO_EFFECT; } diff --git a/src/overlays/actors/ovl_En_Tp/z_en_tp.h b/src/overlays/actors/ovl_En_Tp/z_en_tp.h index 642a2c0864e..0a89ee45c0d 100644 --- a/src/overlays/actors/ovl_En_Tp/z_en_tp.h +++ b/src/overlays/actors/ovl_En_Tp/z_en_tp.h @@ -14,11 +14,13 @@ typedef enum EnTpType { struct EnTp; +typedef void (*EnTpActionFunc)(struct EnTp*, struct PlayState*); + typedef struct EnTp { /* 0x000 */ Actor actor; /* 0x14C */ s32 action; /* 0x150 */ s32 modeVar; - /* 0x154 */ void (*actionFunc)(struct EnTp*, struct PlayState*); + /* 0x154 */ EnTpActionFunc actionFunc; /* 0x158 */ u8 unk_158; /* 0x159 */ char pad_159[1]; /* 0x15A */ s16 timer; diff --git a/src/overlays/actors/ovl_En_Tr/z_en_tr.c b/src/overlays/actors/ovl_En_Tr/z_en_tr.c index 9c39556bd62..12bddfb7e2f 100644 --- a/src/overlays/actors/ovl_En_Tr/z_en_tr.c +++ b/src/overlays/actors/ovl_En_Tr/z_en_tr.c @@ -28,13 +28,12 @@ void EnTr_Destroy(Actor* thisx, PlayState* play); void EnTr_Update(Actor* thisx, PlayState* play); void EnTr_Draw(Actor* thisx, PlayState* play); -void EnTr_DoNothing(EnTr* this, PlayState* play); -void EnTr_ShrinkVanish(EnTr* this, PlayState* play); -void EnTr_WaitToReappear(EnTr* this, PlayState* play); -void EnTr_ChooseAction1(EnTr* this, PlayState* play); - -void EnTr_SetRotFromCue(EnTr* this, PlayState* play, s32 cueChannel); +void func_80B22F1C(EnTr* this, PlayState* play); +void func_80B234D4(EnTr* this, PlayState* play); +void func_80B23820(EnTr* this, PlayState* play); +void func_80B23A88(EnTr* this, PlayState* play); void func_80B24038(EnTr* this, PlayState* play, s32 cueChannel); +void EnTr_SetRotFromCue(EnTr* this, PlayState* play, s32 cueChannel); void EnTr_SetStartPosRotFromCue(EnTr* this, PlayState* play, s32 cueChannel); ActorProfile En_Tr_Profile = { @@ -48,51 +47,41 @@ ActorProfile En_Tr_Profile = { /**/ EnTr_Update, /**/ EnTr_Draw, }; - -// The first elements of these animation arrays are for Koume, the second for Kotake - -UNUSED static AnimationHeader* unused[] = { +UNUSED static AnimationHeader* D_80B24360[2] = { &gKotakeKoumeStandingBroomOverRightShoulderAnim, &gKotakeKoumeStandingBroomOverLeftShoulderAnim, }; - -static AnimationHeader* D_80B24368[] = { +static AnimationHeader* D_80B24368[2] = { &gKotakeKoumeLookOverLeftShoulderAnim, &gKotakeKoumeLookOverRightShoulderAnim, }; - -static AnimationHeader* D_80B24370[] = { +static AnimationHeader* D_80B24370[2] = { &gKotakeKoumeLookingOverLeftShoulderAnim, &gKotakeKoumeLookingOverRightShoulderAnim, }; - -static AnimationHeader* D_80B24378[] = { +static AnimationHeader* D_80B24378[2] = { &gKotakeKoumeFlyAnim, &gKotakeKoumeFlyAnim, }; - -static AnimationHeader* D_80B24380[] = { +static AnimationHeader* D_80B24380[2] = { &gKotakeKoumeCastMagicAnim, &gKotakeKoumeCastMagicAnim, }; - -static f32 D_80B24388[] = { 0.0f, 20.0f, -30.0f, 20.0f, -20.0f, -20.0f, 30.0f }; - -static f32 D_80B243A4[] = { 0.0f, 30.0f, 0.0f, -30.0f, 30.0f, -30.0f, 0.0f }; - -// Has to be 1-dimensional to match +static f32 D_80B24388[7] = { 0.0f, 20.0f, -30.0f, 20.0f, -20.0f, -20.0f, 30.0f }; +static f32 D_80B243A4[7] = { 0.0f, 30.0f, 0.0f, -30.0f, 30.0f, -30.0f, 0.0f }; static Color_RGBA8 D_80B243C0[4] = { - { 255, 200, 0, 255 }, - { 255, 0, 0, 255 }, - { 255, 255, 255, 255 }, - { 0, 0, 255, 255 }, + { 0xFF, 0xC8, 0, 0xFF }, + { 0xFF, 0, 0, 0xFF }, + { 0xFF, 0xFF, 0xFF, 0xFF }, + { 0, 0, 0xFF, 0xFF }, }; - -static void* sEyeTextures[] = { +static void* D_80B243D0[3] = { gKotakeKoumeEyeOpenTex, gKotakeKoumeEyeHalfTex, gKotakeKoumeEyeClosedTex, }; +static Vec3f D_80B243DC = { 2300.0f, 0.0f, -600.0f }; +static Vec3f D_80B243E8 = { 0.0f, 0.0f, 0.0f }; void EnTr_SetupAction(EnTr* this, EnTrActionFunc actionFunc) { this->actionFunc = actionFunc; @@ -102,32 +91,31 @@ void EnTr_Init(Actor* thisx, PlayState* play) { EnTr* this = (EnTr*)thisx; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - EnTr_SetupAction(this, EnTr_DoNothing); - this->unk_2D4 = 0; // Set and not used + EnTr_SetupAction(this, func_80B22F1C); + this->unk2D4 = 0; this->actor.child = NULL; Actor_SetScale(&this->actor, 0.01f); - switch (this->actor.params) { - case TR_KOUME: + case 0: SkelAnime_InitFlex(play, &this->skelAnime, &gKoumeSkel, &gKotakeKoumeStandingBroomOverRightShoulderAnim, - this->jointTable, this->morphTable, KOTAKE_KOUME_LIMB_MAX); + this->unk190, this->unk232, KOTAKE_KOUME_LIMB_MAX); Animation_PlayOnce(&this->skelAnime, &gKotakeKoumeStandingBroomOverRightShoulderAnim); - this->animation = NULL; - EnTr_SetupAction(this, EnTr_ChooseAction1); + this->unk2E4 = NULL; + EnTr_SetupAction(this, func_80B23A88); this->cueChannel = 3; break; - case TR_KOTAKE: + case 1: SkelAnime_InitFlex(play, &this->skelAnime, &gKotakeSkel, &gKotakeKoumeStandingBroomOverLeftShoulderAnim, - this->jointTable, this->morphTable, KOTAKE_KOUME_LIMB_MAX); + this->unk190, this->unk232, KOTAKE_KOUME_LIMB_MAX); Animation_PlayOnce(&this->skelAnime, &gKotakeKoumeStandingBroomOverLeftShoulderAnim); - this->animation = NULL; - EnTr_SetupAction(this, EnTr_ChooseAction1); + this->unk2E4 = NULL; + EnTr_SetupAction(this, func_80B23A88); this->cueChannel = 2; break; default: - ASSERT(0, "0", "../z_en_tr.c", 277); + ASSERT(0, "0", "../z_en_tr.c", 0x115); break; } } @@ -135,43 +123,43 @@ void EnTr_Init(Actor* thisx, PlayState* play) { void EnTr_Destroy(Actor* thisx, PlayState* play) { } -void EnTr_CrySpellcast(EnTr* this, PlayState* play) { - if (this->timer == 11) { - // Both cry in the title screen cutscene, but only Kotake in the in-game cutscene - if ((this->actor.params != TR_KOUME) || (gSaveContext.sceneLayer == 6)) { - SFX_PLAY_CENTERED(NA_SE_EN_TWINROBA_SHOOT_VOICE); - } +void func_80B22E6C(EnTr* this, PlayState* play) { + if ((this->unk2D6 == 0xB) && ((this->actor.params != 0) || (gSaveContext.sceneLayer == 6))) { + SFX_PLAY_CENTERED(NA_SE_EN_TWINROBA_SHOOT_VOICE); } - - if (this->timer > 0) { - this->timer--; - } else if (this->actor.child != NULL) { - this->actor.child = NULL; + if (this->unk2D6 > 0) { + this->unk2D6--; + } else { + if (this->actor.child != NULL) { + this->actor.child = NULL; + } } Actor_PlaySfx_Flagged(&this->actor, NA_SE_EN_TWINROBA_FLY_DEMO - SFX_FLAG); } -void EnTr_DoNothing(EnTr* this, PlayState* play) { +void func_80B22F1C(EnTr* this, PlayState* play) { } -void EnTr_ChooseAction2(EnTr* this, PlayState* play) { - if (play->csCtx.state != CS_STATE_IDLE) { - if (play->csCtx.actorCues[this->cueChannel] != NULL) { - switch (play->csCtx.actorCues[this->cueChannel]->id) { +void func_80B22F28(EnTr* this, PlayState* play) { + CsCmdActorCue* temp_v0; + if (play->csCtx.state != CS_STATE_IDLE) { + temp_v0 = play->csCtx.actorCues[this->cueChannel]; + if (temp_v0 != NULL) { + switch (temp_v0->id) { case 4: Actor_SetScale(&this->actor, 0.01f); - EnTr_SetupAction(this, EnTr_ShrinkVanish); - this->timer = 24; + EnTr_SetupAction(this, func_80B234D4); + this->unk2D6 = 0x18; Actor_PlaySfx(&this->actor, NA_SE_EN_PO_DEAD2); break; case 6: Animation_Change(&this->skelAnime, D_80B24380[this->actor.params], 1.0f, 0.0f, Animation_GetLastFrame(D_80B24380[this->actor.params]), ANIMMODE_ONCE, -5.0f); - EnTr_SetupAction(this, EnTr_CrySpellcast); - this->animation = D_80B24378[this->actor.params]; - this->timer = 39; + EnTr_SetupAction(this, func_80B22E6C); + this->unk2E4 = D_80B24378[this->actor.params]; + this->unk2D6 = 0x27; Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_DEMO_6K, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, this->actor.params + 9); @@ -188,30 +176,30 @@ void EnTr_ChooseAction2(EnTr* this, PlayState* play) { } } -void EnTr_FlyKidnapCutscene(EnTr* this, PlayState* play) { - Vec3f originalPos = this->actor.world.pos; +void func_80B230D8(EnTr* this, PlayState* play) { + Vec3f sp34; + CsCmdActorCue* temp_v0; + sp34 = this->actor.world.pos; if (play->csCtx.state != CS_STATE_IDLE) { - if (play->csCtx.actorCues[this->cueChannel] != NULL) { - if (play->csCtx.actorCues[this->cueChannel]->id == 8) { + temp_v0 = play->csCtx.actorCues[this->cueChannel]; + if (temp_v0 != NULL) { + if (temp_v0->id == 8) { func_80B24038(this, play, this->cueChannel); this->actor.world.rot.y = Math_Atan2S(this->actor.velocity.z, this->actor.velocity.x); - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 10, 0x400, 0x100); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 0xA, 0x400, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; } else { EnTr_SetStartPosRotFromCue(this, play, this->cueChannel); - this->actor.world.pos.x += Math_SinS(this->timer) * 150.0f; + this->actor.world.pos.x += Math_SinS(this->unk2D6) * 150.0f; this->actor.world.pos.y += -100.0f; - this->actor.world.pos.z += Math_CosS(this->timer) * 150.0f; - - this->actor.shape.rot.y = (s16)(this->timer) + 0x4000; - this->timer += 0x400; - - this->actor.velocity.x = this->actor.world.pos.x - originalPos.x; - this->actor.velocity.y = this->actor.world.pos.y - originalPos.y; - this->actor.velocity.z = this->actor.world.pos.z - originalPos.z; + this->actor.world.pos.z += Math_CosS(this->unk2D6) * 150.0f; + this->actor.shape.rot.y = (s16)this->unk2D6 + 0x4000; + this->unk2D6 += 0x400; + this->actor.velocity.x = this->actor.world.pos.x - sp34.x; + this->actor.velocity.y = this->actor.world.pos.y - sp34.y; + this->actor.velocity.z = this->actor.world.pos.z - sp34.z; } - if (play->csCtx.curFrame < 670) { Actor_PlaySfx_Flagged(&this->actor, NA_SE_EN_TWINROBA_FLY_DEMO - SFX_FLAG); } @@ -219,164 +207,169 @@ void EnTr_FlyKidnapCutscene(EnTr* this, PlayState* play) { } } -void func_80B23254(EnTr* this, PlayState* play, s32 arg2, f32 arg3, f32 scale) { - Vec3f pos; - Vec3f velocity; - Vec3f accel; +void func_80B23254(EnTr* this, PlayState* play, s32 arg2, f32 arg3, f32 arg4) { + Vec3f sp7C; + Vec3f sp70; + Vec3f sp64; Vec3f sp58; - Color_RGBA8* primColor; - Color_RGBA8* envColor; - Vec3f cameraEye = GET_ACTIVE_CAM(play)->eye; - s16 yaw = Math_Vec3f_Yaw(&cameraEye, &this->actor.world.pos); - s16 reversePitch = -Math_Vec3f_Pitch(&cameraEye, &this->actor.world.pos); - f32 sp3C; - - accel.x = accel.z = 0.0f; - sp3C = Math_SinS(yaw); - velocity.x = Math_CosS(reversePitch) * (arg3 * sp3C); - velocity.y = Math_SinS(reversePitch) * arg3; - sp3C = Math_CosS(yaw); - velocity.z = Math_CosS(reversePitch) * (arg3 * sp3C); - accel.y = 0.5f; - - primColor = &D_80B243C0[2 * this->actor.params]; - envColor = &D_80B243C0[2 * this->actor.params + 1]; - + Color_RGBA8* sp54; + Color_RGBA8* sp50; + Vec3f sp44; + s16 temp_s0; + s16 sp40; + + sp44 = GET_ACTIVE_CAM(play)->eye; + temp_s0 = Math_Vec3f_Yaw(&sp44, &this->actor.world.pos); + sp40 = -Math_Vec3f_Pitch(&sp44, &this->actor.world.pos); + sp64.z = 0.0f; + sp64.x = 0.0f; + sp70.x = arg3 * Math_SinS(temp_s0) * Math_CosS(sp40); + sp70.y = arg3 * Math_SinS(sp40); + sp70.z = arg3 * Math_CosS(temp_s0) * Math_CosS(sp40); + sp64.y = 0.5f; + sp54 = &D_80B243C0[(this->actor.params * 2) + 0]; + sp50 = &D_80B243C0[(this->actor.params * 2) + 1]; sp58 = this->actor.world.pos; - sp58.x -= velocity.x * 10.0f; - sp58.y -= velocity.y * 10.0f; - sp58.z -= velocity.z * 10.0f; - - pos.x = sp58.x + ((D_80B24388[arg2] * scale) * Math_CosS(yaw)); - pos.y = sp58.y + (D_80B243A4[arg2] * scale); - pos.z = sp58.z - ((D_80B24388[arg2] * scale) * Math_SinS(yaw)); - func_8002829C(play, &pos, &velocity, &accel, primColor, envColor, (s32)(800.0f * scale), (s32)(80.0f * scale)); + sp58.x -= sp70.x * 10.0f; + sp58.y -= sp70.y * 10.0f; + sp58.z -= sp70.z * 10.0f; + sp7C.x = sp58.x + (D_80B24388[arg2] * arg4 * Math_CosS(temp_s0)); + sp7C.y = sp58.y + (D_80B243A4[arg2] * arg4); + sp7C.z = sp58.z - (D_80B24388[arg2] * arg4 * Math_SinS(temp_s0)); + func_8002829C(play, &sp7C, &sp70, &sp64, sp54, sp50, 800.0f * arg4, 80.0f * arg4); } -void EnTr_ShrinkVanish(EnTr* this, PlayState* play) { +void func_80B234D4(EnTr* this, PlayState* play) { s32 temp_hi; - if (this->timer >= 17) { - this->actor.shape.rot.y = (this->actor.shape.rot.y - (this->timer * 0x28F)) + 0x3D68; + if (this->unk2D6 >= 0x11) { + this->actor.shape.rot.y = (this->actor.shape.rot.y - (this->unk2D6 * 0x28F)) + 0x3D68; + } else if (this->unk2D6 >= 5) { + Actor_SetScale(&this->actor, this->actor.scale.x * 0.9f); + this->actor.shape.rot.y = (this->actor.shape.rot.y - (this->unk2D6 * 0x28F)) + 0x3D68; + } else if (this->unk2D6 > 0) { + temp_hi = (this->unk2D6 * 2) % 7; + func_80B23254(this, play, temp_hi, 5.0f, 0.2f); + func_80B23254(this, play, (temp_hi + 1) % 7, 5.0f, 0.2f); + Actor_SetScale(&this->actor, this->actor.scale.x * 0.9f); + this->actor.shape.rot.y = (this->actor.shape.rot.y - (this->unk2D6 * 0x28F)) + 0x3D68; } else { - if (this->timer >= 5) { - Actor_SetScale(&this->actor, this->actor.scale.x * 0.9f); - this->actor.shape.rot.y = (this->actor.shape.rot.y - (this->timer * 0x28F)) + 0x3D68; - } else if (this->timer > 0) { - temp_hi = (this->timer * 2) % 7; - - func_80B23254(this, play, temp_hi, 5.0f, 0.2f); - func_80B23254(this, play, (temp_hi + 1) % 7, 5.0f, 0.2f); - Actor_SetScale(&this->actor, this->actor.scale.x * 0.9f); - this->actor.shape.rot.y = (this->actor.shape.rot.y - (this->timer * 0x28F)) + 0x3D68; - } else { - EnTr_SetupAction(this, EnTr_WaitToReappear); - this->actor.draw = NULL; - } + EnTr_SetupAction(this, func_80B23820); + this->actor.draw = NULL; } - - if (this->timer == 4) { + if (this->unk2D6 == 4) { Actor_PlaySfx(&this->actor, NA_SE_EN_BUBLE_DOWN); } - - if (this->timer > 0) { - this->timer--; + if (this->unk2D6 > 0) { + this->unk2D6--; } } -void EnTr_Reappear(EnTr* this, PlayState* play) { - if (this->timer >= 31) { - s32 temp_hi = (this->timer * 2) % 7; +void func_80B23690(EnTr* this, PlayState* play) { + s32 temp_hi; + if (this->unk2D6 >= 0x1F) { + temp_hi = (this->unk2D6 * 2) % 7; func_80B23254(this, play, temp_hi, 5.0f, 1.0f); func_80B23254(this, play, (temp_hi + 1) % 7, 5.0f, 1.0f); - } else if (this->timer == 30) { + } else if (this->unk2D6 == 0x1E) { this->actor.draw = EnTr_Draw; - this->actor.shape.rot.y += this->timer * 0x1A6; - } else if (this->timer > 0) { - this->actor.shape.rot.y += this->timer * 0x1A6; + this->actor.shape.rot.y += this->unk2D6 * 0x1A6; + } else if (this->unk2D6 > 0) { + this->actor.shape.rot.y += this->unk2D6 * 0x1A6; Actor_SetScale(&this->actor, (this->actor.scale.x * 0.8f) + 0.002f); } else { - EnTr_SetupAction(this, EnTr_ChooseAction2); + EnTr_SetupAction(this, func_80B22F28); Actor_SetScale(&this->actor, 0.01f); } - - if (this->timer > 0) { - this->timer--; + if (this->unk2D6 > 0) { + this->unk2D6--; } Actor_PlaySfx_Flagged(&this->actor, NA_SE_EN_TWINROBA_FLY_DEMO - SFX_FLAG); } -void EnTr_WaitToReappear(EnTr* this, PlayState* play) { +void func_80B23820(EnTr* this, PlayState* play) { + CsCmdActorCue* temp_v0; + if (play->csCtx.state != CS_STATE_IDLE) { - if ((play->csCtx.actorCues[this->cueChannel] != NULL) && ((play->csCtx.actorCues[this->cueChannel]->id == 3) || - (play->csCtx.actorCues[this->cueChannel]->id == 5))) { - Actor_PlaySfx(&this->actor, NA_SE_EN_TWINROBA_TRANSFORM); - this->timer = 34; + temp_v0 = play->csCtx.actorCues[this->cueChannel]; + if ((temp_v0 != NULL) && (((temp_v0->id == 3)) || (temp_v0->id == 5))) { + Actor_PlaySfx(&this->actor, 0x390DU); + this->unk2D6 = 0x22; EnTr_SetStartPosRotFromCue(this, play, this->cueChannel); - EnTr_SetupAction(this, EnTr_Reappear); + EnTr_SetupAction(this, func_80B23690); Animation_PlayLoop(&this->skelAnime, &gKotakeKoumeFlyAnim); - this->animation = NULL; + this->unk2E4 = NULL; Actor_SetScale(&this->actor, 0.003f); } } } -void EnTr_TakeOff(EnTr* this, PlayState* play) { - f32 lastFrame = Animation_GetLastFrame(D_80B24378[this->actor.params]); +void func_80B238E0(EnTr* this, PlayState* play) { + CsCmdActorCue* temp_v0; + f32 temp_fv0; + temp_fv0 = Animation_GetLastFrame(D_80B24378[this->actor.params]); if (play->csCtx.state != CS_STATE_IDLE) { - if ((play->csCtx.actorCues[this->cueChannel] != NULL) && (play->csCtx.actorCues[this->cueChannel]->id == 3)) { - Animation_Change(&this->skelAnime, D_80B24378[this->actor.params], 1.0f, 0.0f, lastFrame, ANIMMODE_LOOP, - -10.0f); - this->animation = NULL; - EnTr_SetupAction(this, EnTr_ChooseAction2); + temp_v0 = play->csCtx.actorCues[this->cueChannel]; + if ((temp_v0 != NULL) && (temp_v0->id == 3)) { + Animation_Change(&this->skelAnime, D_80B24378[this->actor.params], 1.0f, 0.0f, temp_fv0, 0U, -10.0f); + this->unk2E4 = NULL; + EnTr_SetupAction(this, func_80B22F28); } } } -void EnTr_TurnLookOverShoulder(EnTr* this, PlayState* play) { - f32 lastFrame = Animation_GetLastFrame(D_80B24368[this->actor.params]); +void func_80B239A8(EnTr* this, PlayState* play) { + CsCmdActorCue* temp_v0; + f32 temp_fv0; + temp_fv0 = Animation_GetLastFrame(D_80B24368[this->actor.params]); if (play->csCtx.state != CS_STATE_IDLE) { - if ((play->csCtx.actorCues[this->cueChannel] != NULL) && (play->csCtx.actorCues[this->cueChannel]->id == 2)) { - Animation_Change(&this->skelAnime, D_80B24368[this->actor.params], 1.0f, 0.0f, lastFrame, ANIMMODE_ONCE, - -4.0f); - this->animation = D_80B24370[this->actor.params]; - EnTr_SetupAction(this, EnTr_TakeOff); + temp_v0 = play->csCtx.actorCues[this->cueChannel]; + if ((temp_v0 != NULL) && (temp_v0->id == 2)) { + Animation_Change(&this->skelAnime, D_80B24368[this->actor.params], 1.0f, 0.0f, temp_fv0, 2U, -4.0f); + this->unk2E4 = D_80B24370[this->actor.params]; + EnTr_SetupAction(this, func_80B238E0); } } } -void EnTr_ChooseAction1(EnTr* this, PlayState* play) { - u32 frames = play->gameplayFrames; +void func_80B23A88(EnTr* this, PlayState* play) { + u32 temp_a3; + CsCmdActorCue* temp_v1; + temp_a3 = play->gameplayFrames; if (play->csCtx.state != CS_STATE_IDLE) { - if (play->csCtx.actorCues[this->cueChannel] != NULL) { - switch (play->csCtx.actorCues[this->cueChannel]->id) { + temp_v1 = play->csCtx.actorCues[this->cueChannel]; + if (temp_v1 != NULL) { + switch (temp_v1->id) { case 1: EnTr_SetStartPosRotFromCue(this, play, this->cueChannel); - EnTr_SetupAction(this, EnTr_TurnLookOverShoulder); + EnTr_SetupAction(this, func_80B239A8); break; case 3: EnTr_SetStartPosRotFromCue(this, play, this->cueChannel); - EnTr_SetupAction(this, EnTr_ChooseAction2); + EnTr_SetupAction(this, func_80B22F28); Animation_PlayLoop(&this->skelAnime, &gKotakeKoumeFlyAnim); - this->animation = NULL; + this->unk2E4 = NULL; break; case 4: - EnTr_SetupAction(this, EnTr_WaitToReappear); + EnTr_SetupAction(this, func_80B23820); this->actor.draw = NULL; break; case 7: - EnTr_SetupAction(this, EnTr_FlyKidnapCutscene); + EnTr_SetupAction(this, func_80B230D8); Animation_PlayLoop(&this->skelAnime, &gKotakeKoumeFlyAnim); - this->animation = NULL; - this->timer = - ((this->actor.params != TR_KOUME) ? ((u8)frames * 0x400) + 0x8000 : (u8)frames * 0x400); + this->unk2E4 = NULL; + if (this->actor.params != 0) { + this->unk2D6 = ((u8)temp_a3 * 0x400) + 0x8000; + } else { + this->unk2D6 = (u8)temp_a3 * 0x400; + } break; } } @@ -384,74 +377,73 @@ void EnTr_ChooseAction1(EnTr* this, PlayState* play) { } void EnTr_Update(Actor* thisx, PlayState* play) { - STACK_PAD(s32); EnTr* this = (EnTr*)thisx; + STACK_PAD(s32); Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_2); this->actionFunc(this, play); - if (SkelAnime_Update(&this->skelAnime)) { - if (this->animation != NULL) { - if ((this->animation == &gKotakeKoumeLookingOverLeftShoulderAnim) || - (this->animation == &gKotakeKoumeLookingOverRightShoulderAnim)) { - if (this->actor.params != TR_KOUME) { + if (this->unk2E4 != NULL) { + if ((this->unk2E4 == &gKotakeKoumeLookingOverLeftShoulderAnim) || + (this->unk2E4 == &gKotakeKoumeLookingOverRightShoulderAnim)) { + if (this->actor.params != 0) { Actor_PlaySfx(&this->actor, NA_SE_EN_TWINROBA_LAUGH2); } else { Actor_PlaySfx(&this->actor, NA_SE_EN_TWINROBA_LAUGH); } - Animation_PlayLoop(&this->skelAnime, this->animation); - } else if (this->animation == &gKotakeKoumeFlyAnim) { - EnTr_SetupAction(this, EnTr_ChooseAction2); + Animation_PlayLoop(&this->skelAnime, this->unk2E4); + } else if (this->unk2E4 == &gKotakeKoumeFlyAnim) { + EnTr_SetupAction(this, func_80B22F28); Animation_Change(&this->skelAnime, &gKotakeKoumeFlyAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gKotakeKoumeFlyAnim), ANIMMODE_LOOP, -5.0f); } else { - Animation_PlayLoop(&this->skelAnime, this->animation); + Animation_PlayLoop(&this->skelAnime, this->unk2E4); } - this->animation = NULL; + this->unk2E4 = NULL; } else { this->skelAnime.curFrame = 0.0f; } } Actor_SetFocus(&this->actor, 0.0f); - - if (DECR(this->blinkTimer) == 0) { - this->blinkTimer = Rand_S16Offset(60, 60); + if (DECR(this->unk2E2) == 0) { + this->unk2E2 = Rand_S16Offset(0x3C, 0x3C); } - this->eyeIndex = this->blinkTimer; - if (this->eyeIndex >= 3) { - this->eyeIndex = 0; + this->unk2E0 = this->unk2E2; + if (this->unk2E0 >= 3) { + this->unk2E0 = 0; } } -s32 EnTr_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - Vec3f src = { 2300.0f, 0.0f, -600.0f }; - Vec3f dest = { 0.0f, 0.0f, 0.0f }; +s32 EnTr_OverrideLimbDraw(PlayState* play, s32 arg1, Gfx** arg2, Vec3f* arg3, Vec3s* arg4, void* thisx) { + Vec3f sp34; + Vec3f sp28; EnTr* this = (EnTr*)thisx; - Actor* child = this->actor.child; - - if ((child != NULL) && (limbIndex == KOTAKE_KOUME_LIMB_RIGHT_HAND)) { - Matrix_MultVec3f(&src, &dest); - dest.x -= (10.0f * Math_SinS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)))); - dest.z -= (10.0f * Math_CosS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)))); - child->world.pos = dest; + Actor* sp20; + + sp34 = D_80B243DC; + sp28 = D_80B243E8; + sp20 = this->actor.child; + if ((sp20 != NULL) && (arg1 == KOTAKE_KOUME_LIMB_RIGHT_HAND)) { + Matrix_MultVec3f(&sp34, &sp28); + sp28.x -= 10.0f * Math_SinS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play))); + sp28.z -= 10.0f * Math_CosS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play))); + sp20->world.pos = sp28; } return 0; } void EnTr_Draw(Actor* thisx, PlayState* play) { - STACK_PAD(s32); EnTr* this = (EnTr*)thisx; - - if (1) {} + STACK_PAD(s32); if ((play->csCtx.state == CS_STATE_IDLE) || (play->csCtx.actorCues[this->cueChannel] == NULL)) { this->actor.shape.shadowDraw = NULL; } else { + if (1) {} this->actor.shape.shadowDraw = ActorShadow_DrawCircle; - OPEN_DISPS(play->state.gfxCtx, "../z_en_tr.c", 840); Gfx_SetupDL_37Opa(play->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeIndex])); + gSPSegment(POLY_OPA_DISP++, 8, SEGMENTED_TO_VIRTUAL(D_80B243D0[this->unk2E0])); func_8002EBCC(&this->actor, play, 0); SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnTr_OverrideLimbDraw, NULL, this); @@ -459,83 +451,85 @@ void EnTr_Draw(Actor* thisx, PlayState* play) { } } -f32 func_80B23FDC(PlayState* play, s32 cueChannel) { - f32 phi_f2 = Environment_LerpWeight(play->csCtx.actorCues[cueChannel]->endFrame, - play->csCtx.actorCues[cueChannel]->startFrame, play->csCtx.curFrame); - phi_f2 = CLAMP_MAX(phi_f2, 1.0f); - return phi_f2; +f32 func_80B23FDC(PlayState* arg0, s32 cueChannel) { + CsCmdActorCue* temp_v0; + f32 temp_fv0; + f32 var_fv1; + + temp_v0 = arg0->csCtx.actorCues[cueChannel]; + temp_fv0 = Environment_LerpWeight(temp_v0->endFrame, temp_v0->startFrame, arg0->csCtx.curFrame); + var_fv1 = temp_fv0; + if (temp_fv0 > 1.0f) { + var_fv1 = 1.0f; + } + return var_fv1; } void func_80B24038(EnTr* this, PlayState* play, s32 cueChannel) { - Vec3f startPos; - Vec3f endPos; - f32 temp_f0; - f32 temp_f0_2; - f32 phi_f12; - - startPos.x = play->csCtx.actorCues[cueChannel]->startPos.x; - startPos.y = play->csCtx.actorCues[cueChannel]->startPos.y; - startPos.z = play->csCtx.actorCues[cueChannel]->startPos.z; - - endPos.x = play->csCtx.actorCues[cueChannel]->endPos.x; - endPos.y = play->csCtx.actorCues[cueChannel]->endPos.y; - endPos.z = play->csCtx.actorCues[cueChannel]->endPos.z; - - temp_f0 = func_80B23FDC(play, cueChannel); - - startPos.x = ((endPos.x - startPos.x) * temp_f0) + startPos.x; - startPos.y = ((endPos.y - startPos.y) * temp_f0) + startPos.y; - startPos.z = ((endPos.z - startPos.z) * temp_f0) + startPos.z; - - endPos.x = (startPos.x - this->actor.world.pos.x) * 0.1f; - endPos.y = (startPos.y - this->actor.world.pos.y) * 0.1f; - endPos.z = (startPos.z - this->actor.world.pos.z) * 0.1f; - - temp_f0_2 = sqrtf(SQ(endPos.x) + SQ(endPos.y) + SQ(endPos.z)); - phi_f12 = CLAMP(temp_f0_2, 0.0f, 20.0f); - - if ((temp_f0_2 != phi_f12) && (temp_f0_2 != 0.0f)) { - endPos.x *= phi_f12 / temp_f0_2; - endPos.y *= phi_f12 / temp_f0_2; - endPos.z *= phi_f12 / temp_f0_2; + Vec3f sp34; + Vec3f sp28; + f32 temp_fv0; + f32 var_fa0; + CsCmdActorCue* v; + + v = play->csCtx.actorCues[cueChannel]; + sp34.x = v->startPos.x; + sp34.y = v->startPos.y; + sp34.z = v->startPos.z; + sp28.x = v->endPos.x; + sp28.y = v->endPos.y; + sp28.z = v->endPos.z; + temp_fv0 = func_80B23FDC(play, (s32)cueChannel); + sp34.x = ((sp28.x - sp34.x) * temp_fv0) + sp34.x; + sp34.y = ((sp28.y - sp34.y) * temp_fv0) + sp34.y; + sp34.z = ((sp28.z - sp34.z) * temp_fv0) + sp34.z; + sp28.x = (sp34.x - this->actor.world.pos.x) * 0.1f; + sp28.y = (sp34.y - this->actor.world.pos.y) * 0.1f; + sp28.z = (sp34.z - this->actor.world.pos.z) * 0.1f; + temp_fv0 = sqrtf(SQXYZ(sp28)); + var_fa0 = CLAMP(temp_fv0, 0.0f, 20.0f); + if ((temp_fv0 != var_fa0) && (temp_fv0 != 0.0f)) { + sp28.x *= var_fa0 / temp_fv0; + sp28.y *= var_fa0 / temp_fv0; + sp28.z *= var_fa0 / temp_fv0; } - - Math_StepToF(&this->actor.velocity.x, endPos.x, 1.0f); - Math_StepToF(&this->actor.velocity.y, endPos.y, 1.0f); - Math_StepToF(&this->actor.velocity.z, endPos.z, 1.0f); + Math_StepToF(&this->actor.velocity.x, sp28.x, 1.0f); + Math_StepToF(&this->actor.velocity.y, sp28.y, 1.0f); + Math_StepToF(&this->actor.velocity.z, sp28.z, 1.0f); Actor_UpdatePos(&this->actor); } void EnTr_SetRotFromCue(EnTr* this, PlayState* play, s32 cueChannel) { - s16 rotY = play->csCtx.actorCues[cueChannel]->rot.y; - s32 rotDiff = this->actor.world.rot.y - rotY; - s32 rotSign; - - if (rotDiff < 0) { - rotDiff = -rotDiff; - rotSign = 1; + s32 var_v0; + s16 new_var; + s32 var_v1; + + new_var = play->csCtx.actorCues[cueChannel]->rot.y; + var_v1 = this->actor.world.rot.y - new_var; + if (var_v1 < 0) { + var_v1 = -var_v1; + var_v0 = 1; } else { - rotSign = -1; + var_v0 = -1; } - - if (rotDiff >= 0x8000) { - rotSign = -rotSign; - rotDiff = 0x10000 - rotDiff; + if (var_v1 >= 0x8000) { + var_v0 = -var_v0; + var_v1 = 0x10000 - var_v1; } - - rotDiff *= 0.1f; - - this->actor.world.rot.y += rotDiff * rotSign; + var_v1 *= 0.1f; + this->actor.world.rot.y += var_v1 * var_v0; this->actor.shape.rot.y = this->actor.world.rot.y; } void EnTr_SetStartPosRotFromCue(EnTr* this, PlayState* play, s32 cueChannel) { - Vec3f startPos; - - startPos.x = play->csCtx.actorCues[cueChannel]->startPos.x; - startPos.y = play->csCtx.actorCues[cueChannel]->startPos.y; - startPos.z = play->csCtx.actorCues[cueChannel]->startPos.z; - - this->actor.world.pos = startPos; - this->actor.world.rot.y = this->actor.shape.rot.y = play->csCtx.actorCues[cueChannel]->rot.y; + Vec3f spC; + s16 temp_v1; + + spC.x = play->csCtx.actorCues[cueChannel]->startPos.x; + spC.y = play->csCtx.actorCues[cueChannel]->startPos.y; + spC.z = play->csCtx.actorCues[cueChannel]->startPos.z; + this->actor.world.pos = spC; + temp_v1 = play->csCtx.actorCues[cueChannel]->rot.y; + this->actor.shape.rot.y = temp_v1; + this->actor.world.rot.y = temp_v1; } diff --git a/src/overlays/actors/ovl_En_Tr/z_en_tr.h b/src/overlays/actors/ovl_En_Tr/z_en_tr.h index d6490902299..069915ae7df 100644 --- a/src/overlays/actors/ovl_En_Tr/z_en_tr.h +++ b/src/overlays/actors/ovl_En_Tr/z_en_tr.h @@ -40,22 +40,18 @@ typedef enum KotakeKoumeLimb { } KotakeKoumeLimb; typedef struct EnTr { - /* 0x0000 */ Actor actor; - /* 0x014C */ SkelAnime skelAnime; - /* 0x0190 */ Vec3s jointTable[KOTAKE_KOUME_LIMB_MAX]; - /* 0x0232 */ Vec3s morphTable[KOTAKE_KOUME_LIMB_MAX]; - /* 0x02D4 */ s16 unk_2D4; - /* 0x02D6 */ u16 timer; // Also used as an angle - /* 0x02D8 */ s16 cueChannel; - /* 0x02DC */ EnTrActionFunc actionFunc; - /* 0x02E0 */ s16 eyeIndex; - /* 0x02E2 */ s16 blinkTimer; - /* 0x02E4 */ AnimationHeader* animation; -} EnTr; // size = 0x02E8 - -typedef enum TwinrovaType { - /* 0 */ TR_KOUME, - /* 1 */ TR_KOTAKE -} TwinrovaType; + /* 0x000 */ Actor actor; + /* 0x14C */ SkelAnime skelAnime; + /* 0x190 */ Vec3s unk190[KOTAKE_KOUME_LIMB_MAX]; + /* 0x232 */ Vec3s unk232[KOTAKE_KOUME_LIMB_MAX]; + /* 0x2D4 */ s16 unk2D4; + /* 0x2D6 */ u16 unk2D6; + /* 0x2D8 */ s16 cueChannel; + /* 0x2DA */ char pad2DA[2]; + /* 0x2DC */ EnTrActionFunc actionFunc; + /* 0x2E0 */ s16 unk2E0; + /* 0x2E2 */ s16 unk2E2; + /* 0x2E4 */ AnimationHeader* unk2E4; +} EnTr; // size = 0x2E8 #endif 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 51f0b56916c..e7db1030f3a 100644 --- a/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c +++ b/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c @@ -581,7 +581,7 @@ void EnViewer_DrawGanondorf(EnViewer* this, PlayState* play) { if (type == ENVIEWER_TYPE_9_GANONDORF) { SkelAnime_DrawFlexOpa(play, this->skin.skelAnime.skeleton, this->skin.skelAnime.jointTable, - this->skin.skelAnime.dListCount, NULL, EnViewer_Ganondorf9PostLimbDraw, this); + this->skin.skelAnime.dListCount, 0, EnViewer_Ganondorf9PostLimbDraw, this); } else if (type == ENVIEWER_TYPE_3_GANONDORF) { SkelAnime_DrawFlexOpa(play, this->skin.skelAnime.skeleton, this->skin.skelAnime.jointTable, this->skin.skelAnime.dListCount, EnViewer_Ganondorf3OverrideLimbDraw, @@ -591,12 +591,12 @@ void EnViewer_DrawGanondorf(EnViewer* this, PlayState* play) { type == ENVIEWER_TYPE_7_GANONDORF || type == ENVIEWER_TYPE_8_GANONDORF) { if ((play->csCtx.state != CS_STATE_IDLE) && (play->csCtx.actorCues[1] != NULL)) { SkelAnime_DrawFlexOpa(play, this->skin.skelAnime.skeleton, this->skin.skelAnime.jointTable, - this->skin.skelAnime.dListCount, NULL, EnViewer_GanondorfPostLimbDrawUpdateCapeVec, + this->skin.skelAnime.dListCount, 0, EnViewer_GanondorfPostLimbDrawUpdateCapeVec, this); EnViewer_UpdateGanondorfCape(play, this); } } else { - SkelAnime_DrawOpa(play, this->skin.skelAnime.skeleton, this->skin.skelAnime.jointTable, NULL, NULL, this); + SkelAnime_DrawOpa(play, this->skin.skelAnime.skeleton, this->skin.skelAnime.jointTable, NULL, 0, this); } CLOSE_DISPS(play->state.gfxCtx, "../z_en_viewer.c", 1511); } @@ -703,7 +703,7 @@ void EnViewer_DrawImpa(EnViewer* this, PlayState* play) { gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); gSPSegment(POLY_OPA_DISP++, 0x0C, ACTOR_SETUP_OPA_DL); SkelAnime_DrawFlexOpa(play, this->skin.skelAnime.skeleton, this->skin.skelAnime.jointTable, - this->skin.skelAnime.dListCount, EnViewer_ImpaOverrideLimbDraw, NULL, this); + this->skin.skelAnime.dListCount, EnViewer_ImpaOverrideLimbDraw, 0, this); CLOSE_DISPS(play->state.gfxCtx, "../z_en_viewer.c", 1740); } 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 864659fb86e..58619aaa1ba 100644 --- a/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c +++ b/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c @@ -1,7 +1,7 @@ /* * File: z_en_wood02.c * Overlay: ovl_En_Wood02 - * Description: Trees, bushes, leaves + * Description: Trees & Bushes */ #include "z_en_wood02.h" @@ -25,29 +25,19 @@ #define FLAGS 0 -void EnWood02_Init(Actor* thisx, PlayState* play2); +void EnWood02_Init(Actor* thisx, PlayState* play); void EnWood02_Destroy(Actor* thisx, PlayState* play); -void EnWood02_Update(Actor* thisx, PlayState* play2); +void EnWood02_Update(Actor* thisx, PlayState* play); void EnWood02_Draw(Actor* thisx, PlayState* play); -/** - * WOOD_SPAWN_SPAWNER is also used by some individual trees: EnWood02_Update also checks for parent before running any - * despawning code. - * */ -typedef enum WoodSpawnType { - /* 0 */ WOOD_SPAWN_NORMAL, - /* 1 */ WOOD_SPAWN_SPAWNED, - /* 2 */ WOOD_SPAWN_SPAWNER -} WoodSpawnType; +s32 EnWood02_IsInUncullZone(EnWood02* this, PlayState* play, Vec3f* pos); +void EnWood02_SpawnUnculledChildren(EnWood02* this, PlayState* play); -typedef enum WoodDrawType { - /* 0 */ WOOD_DRAW_TREE_CONICAL, - /* 1 */ WOOD_DRAW_TREE_OVAL, - /* 2 */ WOOD_DRAW_TREE_KAKARIKO_ADULT, - /* 3 */ WOOD_DRAW_BUSH_GREEN, - /* 4 */ WOOD_DRAW_4, // Used for black bushes and green leaves - /* 5 */ WOOD_DRAW_LEAF_YELLOW -} WoodDrawType; +extern Gfx D_6000090[]; +extern Gfx D_6000340[]; +extern Gfx D_6000440[]; +extern Gfx D_6000700[]; +extern Gfx D_6007E20[]; ActorProfile En_Wood02_Profile = { /**/ ACTOR_EN_WOOD02, @@ -60,7 +50,6 @@ ActorProfile En_Wood02_Profile = { /**/ EnWood02_Update, /**/ EnWood02_Draw, }; - static ColliderCylinderInit sCylinderInit = { { COL_MATERIAL_TREE, @@ -80,21 +69,16 @@ static ColliderCylinderInit sCylinderInit = { }, { 18, 60, 0, { 0, 0, 0 } }, }; - -static f32 sSpawnDistance[] = { 707.0f, 525.0f, 510.0f, 500.0f, 566.0f, 141.0f }; - -static s16 sSpawnAngle[] = { 0x1FFF, 0x4C9E, 0x77F5, 0xA5C9, 0xD6C3, 0xA000 }; - +static f32 sSpawnDistances[] = { 707.0f, 525.0f, 510.0f, 500.0f, 566.0f, 141.0f }; +static s16 sSpawnAngles[] = { 0x1FFF, 0x4C9E, 0x77F5, 0xA5C9, -0x293D, 0xA000 }; static InitChainEntry sInitChain[] = { ICHAIN_F32(lockOnArrowOffset, 5600, ICHAIN_STOP), }; - -static Gfx* D_80B3BF54[] = { +static Gfx* D_80B3BF54[7] = { object_wood02_DL_0078D0, object_wood02_DL_007CA0, object_wood02_DL_0080D0, object_wood02_DL_000090, object_wood02_DL_000340, object_wood02_DL_000340, object_wood02_DL_000700, }; - -static Gfx* D_80B3BF70[] = { +static Gfx* D_80B3BF70[0xC] = { object_wood02_DL_007968, object_wood02_DL_007D38, object_wood02_DL_0081A8, @@ -108,196 +92,189 @@ static Gfx* D_80B3BF70[] = { object_wood02_DL_000440, object_wood02_DL_000700, }; +static f32 sCos; +static f32 sSin; -static f32 sSpawnCos; - -static f32 sSpawnSin; - -s32 EnWood02_SpawnZoneCheck(EnWood02* this, PlayState* play, Vec3f* pos) { - f32 phi_f12; +s32 EnWood02_IsInUncullZone(EnWood02* this, PlayState* play, Vec3f* pos) { + f32 invW; SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, pos, &this->actor.projectedPos, &this->actor.projectedW); - - phi_f12 = ((this->actor.projectedW == 0.0f) ? 1000.0f : fabsf(1.0f / this->actor.projectedW)); - + if (this->actor.projectedW == 0.0f) { + invW = 1000.0f; + } else { + invW = fabsf(1.0f / this->actor.projectedW); + } if ((-this->actor.cullingVolumeScale < this->actor.projectedPos.z) && (this->actor.projectedPos.z < (this->actor.cullingVolumeDistance + this->actor.cullingVolumeScale)) && - (((fabsf(this->actor.projectedPos.x) - this->actor.cullingVolumeScale) * phi_f12) < 1.0f) && - (((this->actor.projectedPos.y + this->actor.cullingVolumeDownward) * phi_f12) > -1.0f) && - (((this->actor.projectedPos.y - this->actor.cullingVolumeScale) * phi_f12) < 1.0f)) { - return true; + (((fabsf(this->actor.projectedPos.x) - this->actor.cullingVolumeScale) * invW) < 1.0f)) { + if ((((this->actor.projectedPos.y + this->actor.cullingVolumeDownward) * invW) > -1.0f) && + (((this->actor.projectedPos.y - this->actor.cullingVolumeScale) * invW) < 1.0f)) { + return true; + } } return false; } -/** 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, PlayState* play) { - EnWood02* childWood; - s16* childSpawnAngle; - Vec3f childPos; - s16 extraRot; - s16 childParams; +void EnWood02_SpawnUnculledChildren(EnWood02* this, PlayState* play) { + STACK_PADS(s32, 2); + Vec3f newEnWood02Pos; + EnWood02* newEnWood02; + s16 spawnAngleModifier; + s16 newEnWood02Params; s32 i; for (i = 4; i >= 0; i--) { - if ((this->unk_14E[i] & 0x7F) == 0) { - extraRot = 0; - if (this->actor.params == WOOD_BUSH_GREEN_LARGE_SPAWNER) { - extraRot = 0x4000; + if ((this->unk14E[i] & 0x7F) == 0) { + spawnAngleModifier = 0; + if (this->actor.params == EN_WOOD_02_TYPE_15) { + spawnAngleModifier = 0x4000; } - childSpawnAngle = &sSpawnAngle[i]; - sSpawnCos = Math_CosS(*childSpawnAngle + this->actor.world.rot.y + extraRot); - sSpawnSin = Math_SinS(*childSpawnAngle + this->actor.world.rot.y + extraRot); - childPos.x = (sSpawnDistance[i] * sSpawnSin) + this->actor.home.pos.x; - childPos.y = this->actor.home.pos.y; - childPos.z = (sSpawnDistance[i] * sSpawnCos) + this->actor.home.pos.z; - if (EnWood02_SpawnZoneCheck(this, play, &childPos)) { - if ((this->unk_14E[i] & 0x80) != 0) { - childParams = (0xFF00 | (this->actor.params + 1)); + sCos = Math_CosS(sSpawnAngles[i] + this->actor.world.rot.y + spawnAngleModifier); + sSin = Math_SinS(sSpawnAngles[i] + this->actor.world.rot.y + spawnAngleModifier); + newEnWood02Pos.x = (sSpawnDistances[i] * sSin) + this->actor.home.pos.x; + newEnWood02Pos.y = this->actor.home.pos.y; + newEnWood02Pos.z = (sSpawnDistances[i] * sCos) + this->actor.home.pos.z; + if (EnWood02_IsInUncullZone(this, play, &newEnWood02Pos)) { + if (this->unk14E[i] & 0x80) { + newEnWood02Params = ((this->actor.params + 1) | 0xFF00); } else { - childParams = (((this->drawType & 0xF0) << 4) | (this->actor.params + 1)); + newEnWood02Params = (((this->unk154 & 0xF0) * 0x10) | (this->actor.params + 1)); } - childWood = (EnWood02*)Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_WOOD02, - childPos.x, childPos.y, childPos.z, this->actor.world.rot.x, - *childSpawnAngle, 0, childParams); - if (childWood != NULL) { - childWood->unk_14E[0] = i; - this->unk_14E[i] |= 1; - childWood->actor.projectedPos = this->actor.projectedPos; + newEnWood02 = (EnWood02*)Actor_SpawnAsChild( + &play->actorCtx, &this->actor, play, ACTOR_EN_WOOD02, newEnWood02Pos.x, newEnWood02Pos.y, + newEnWood02Pos.z, this->actor.world.rot.x, sSpawnAngles[i], 0, newEnWood02Params); + if (newEnWood02 != NULL) { + newEnWood02->unk14E[0] = i; + this->unk14E[i] |= 1; + newEnWood02->actor.projectedPos = this->actor.projectedPos; } else { - this->unk_14E[i] &= 0x80; + this->unk14E[i] &= 0x80; } } } } } -void EnWood02_Init(Actor* thisx, PlayState* play2) { - s16 spawnType; - f32 actorScale; - PlayState* play = play2; +void EnWood02_Init(Actor* thisx, PlayState* play) { + s16 var_t0_sp4E; + f32 scale; EnWood02* this = (EnWood02*)thisx; - CollisionPoly* poly; - s32 bgId; f32 floorY; - s16 extraRot; - - spawnType = WOOD_SPAWN_NORMAL; - actorScale = 1.0f; - this->unk_14C = PARAMS_GET_U(this->actor.params, 8, 8); - + CollisionPoly* floorPoly; + s32 floorBgId; + STACK_PAD(s32); + s16 spawnAngleModifier; + + scale = 1.0f; + var_t0_sp4E = 0; + this->unk14C = PARAMS_GET_U(this->actor.params, 8, 8); if (this->actor.home.rot.z != 0) { - this->actor.home.rot.z = (this->actor.home.rot.z << 8) | this->unk_14C; - this->unk_14C = -1; - this->actor.world.rot.z = this->actor.shape.rot.z = 0; - } else if (this->unk_14C & 0x80) { - this->unk_14C = -1; + this->actor.shape.rot.z = 0; + this->actor.home.rot.z = (this->actor.home.rot.z << 8) | this->unk14C; + this->unk14C = -1; + this->actor.world.rot.z = this->actor.shape.rot.z; + } else if (this->unk14C & 0x80) { + this->unk14C = -1; } - - this->actor.params &= 0xFF; + this->actor.params = PARAMS_GET_U(this->actor.params, 0, 8); Actor_ProcessInitChain(&this->actor, sInitChain); - - if (this->actor.params <= WOOD_TREE_KAKARIKO_ADULT) { + if (this->actor.params < EN_WOOD_02_TYPE_11) { Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + var_t0_sp4E = 0; } - switch (this->actor.params) { - case WOOD_BUSH_GREEN_LARGE_SPAWNER: - case WOOD_BUSH_BLACK_LARGE_SPAWNER: - spawnType = 1; + case EN_WOOD_02_TYPE_15: + case EN_WOOD_02_TYPE_21: + var_t0_sp4E = 1; FALLTHROUGH; - case WOOD_BUSH_GREEN_LARGE_SPAWNED: - case WOOD_BUSH_BLACK_LARGE_SPAWNED: - spawnType++; + case EN_WOOD_02_TYPE_16: + case EN_WOOD_02_TYPE_22: + var_t0_sp4E += 1; FALLTHROUGH; - case WOOD_TREE_CONICAL_LARGE: - case WOOD_BUSH_GREEN_LARGE: - case WOOD_BUSH_BLACK_LARGE: - actorScale = 1.5f; + case EN_WOOD_02_TYPE_0: + case EN_WOOD_02_TYPE_12: + case EN_WOOD_02_TYPE_18: + scale = 1.5f; this->actor.cullingVolumeDistance = 4000.0f; this->actor.cullingVolumeScale = 2000.0f; this->actor.cullingVolumeDownward = 2400.0f; break; - case WOOD_TREE_CONICAL_SPAWNER: - case WOOD_TREE_OVAL_YELLOW_SPAWNER: - case WOOD_TREE_OVAL_GREEN_SPAWNER: - case WOOD_BUSH_GREEN_SMALL_SPAWNER: - case WOOD_BUSH_BLACK_SMALL_SPAWNER: - spawnType = 1; + + case EN_WOOD_02_TYPE_3: + case EN_WOOD_02_TYPE_6: + case EN_WOOD_02_TYPE_8: + case EN_WOOD_02_TYPE_13: + case EN_WOOD_02_TYPE_19: + var_t0_sp4E = 1; FALLTHROUGH; - case WOOD_TREE_CONICAL_SPAWNED: - case WOOD_TREE_OVAL_YELLOW_SPAWNED: - case WOOD_TREE_OVAL_GREEN_SPAWNED: - case WOOD_BUSH_GREEN_SMALL_SPAWNED: - case WOOD_BUSH_BLACK_SMALL_SPAWNED: - spawnType++; + case EN_WOOD_02_TYPE_4: + case EN_WOOD_02_TYPE_7: + case EN_WOOD_02_TYPE_9: + case EN_WOOD_02_TYPE_14: + case EN_WOOD_02_TYPE_20: + var_t0_sp4E += 1; FALLTHROUGH; - case WOOD_TREE_CONICAL_MEDIUM: - case WOOD_TREE_OVAL_GREEN: - case WOOD_TREE_KAKARIKO_ADULT: - case WOOD_BUSH_GREEN_SMALL: - case WOOD_BUSH_BLACK_SMALL: + case EN_WOOD_02_TYPE_1: + case EN_WOOD_02_TYPE_5: + case EN_WOOD_02_TYPE_10: + case EN_WOOD_02_TYPE_11: + case EN_WOOD_02_TYPE_17: this->actor.cullingVolumeDistance = 4000.0f; this->actor.cullingVolumeScale = 800.0f; this->actor.cullingVolumeDownward = 1800.0f; break; - case WOOD_TREE_CONICAL_SMALL: - actorScale = 0.6f; + + case EN_WOOD_02_TYPE_2: + scale = 0.6f; this->actor.cullingVolumeDistance = 4000.0f; this->actor.cullingVolumeScale = 400.0f; this->actor.cullingVolumeDownward = 1000.0f; break; - case WOOD_LEAF_GREEN: - case WOOD_LEAF_YELLOW: - this->unk_14E[0] = 0x4B; - actorScale = 0.02f; + + case EN_WOOD_02_TYPE_23: + case EN_WOOD_02_TYPE_24: + this->unk14E[0] = 0x4B; + scale = 0.02f; this->actor.velocity.x = Rand_CenteredFloat(6.0f); this->actor.velocity.z = Rand_CenteredFloat(6.0f); + var_t0_sp4E = 0; this->actor.velocity.y = (Rand_ZeroOne() * 1.25f) + -3.1f; break; } - - if (this->actor.params <= WOOD_TREE_CONICAL_SPAWNED) { - this->drawType = WOOD_DRAW_TREE_CONICAL; - } else if (this->actor.params <= WOOD_TREE_OVAL_GREEN_SPAWNED) { - this->drawType = WOOD_DRAW_TREE_OVAL; - } else if (this->actor.params <= WOOD_TREE_KAKARIKO_ADULT) { - this->drawType = WOOD_DRAW_TREE_KAKARIKO_ADULT; - } else if (this->actor.params <= WOOD_BUSH_GREEN_LARGE_SPAWNED) { - this->drawType = WOOD_DRAW_BUSH_GREEN; - } else if (this->actor.params <= WOOD_LEAF_GREEN) { // Black bushes and green leaves - this->drawType = WOOD_DRAW_4; + if (this->actor.params <= EN_WOOD_02_TYPE_4) { + this->unk154 = 0; + } else if (this->actor.params <= EN_WOOD_02_TYPE_9) { + this->unk154 = 1; + } else if (this->actor.params <= EN_WOOD_02_TYPE_10) { + this->unk154 = 2; + } else if (this->actor.params <= EN_WOOD_02_TYPE_16) { + this->unk154 = 3; + } else if (this->actor.params <= EN_WOOD_02_TYPE_23) { + this->unk154 = 4; } else { - this->drawType = WOOD_DRAW_LEAF_YELLOW; + this->unk154 = 5; } - - Actor_SetScale(&this->actor, actorScale); - this->spawnType = spawnType; - - if (spawnType != WOOD_SPAWN_NORMAL) { - extraRot = 0; - - if (this->actor.params == WOOD_BUSH_GREEN_LARGE_SPAWNER) { - extraRot = 0x4000; + Actor_SetScale(&this->actor, scale); + this->unk153 = var_t0_sp4E; + if (var_t0_sp4E != 0) { + spawnAngleModifier = 0; + if (this->actor.params == EN_WOOD_02_TYPE_15) { + spawnAngleModifier = 0x4000; } - - if (spawnType == WOOD_SPAWN_SPAWNER) { - this->drawType |= this->unk_14C << 4; - 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]); - this->actor.world.pos.z += (sSpawnCos * sSpawnDistance[5]); + if (var_t0_sp4E == 2) { + this->unk154 |= this->unk14C * 0x10; + EnWood02_SpawnUnculledChildren(this, play); + sCos = Math_CosS(sSpawnAngles[5] + this->actor.world.rot.y + spawnAngleModifier); + sSin = Math_SinS(sSpawnAngles[5] + this->actor.world.rot.y + spawnAngleModifier); + this->actor.world.pos.x += sSin * sSpawnDistances[5]; + this->actor.world.pos.z += sCos * sSpawnDistances[5]; } else { this->actor.flags |= ACTOR_FLAG_UPDATE_CULLING_DISABLED; } - - // Snap to floor, or remove if over void this->actor.world.pos.y += 200.0f; - floorY = BgCheck_EntityRaycastDown4(&play->colCtx, &poly, &bgId, &this->actor, &this->actor.world.pos); - + floorY = + BgCheck_EntityRaycastDown4(&play->colCtx, &floorPoly, &floorBgId, &this->actor, &this->actor.world.pos); if (floorY > BGCHECK_Y_MIN) { this->actor.world.pos.y = floorY; } else { @@ -313,163 +290,148 @@ void EnWood02_Init(Actor* thisx, PlayState* play2) { void EnWood02_Destroy(Actor* thisx, PlayState* play) { EnWood02* this = (EnWood02*)thisx; - if (this->actor.params <= WOOD_TREE_KAKARIKO_ADULT) { + if (this->actor.params < EN_WOOD_02_TYPE_11) { Collider_DestroyCylinder(play, &this->collider); } } -void EnWood02_Update(Actor* thisx, PlayState* play2) { - PlayState* play = play2; +void EnWood02_Update(Actor* thisx, PlayState* play) { + STACK_PAD(s32); EnWood02* this = (EnWood02*)thisx; - f32 wobbleAmplitude; + f32 sp6C; + u8 v; + u8 var_v0; + STACK_PAD(s32); - // Despawn extra trees in a group if out of range - if ((this->spawnType == WOOD_SPAWN_SPAWNED) && (this->actor.parent != NULL)) { + if ((this->unk153 == 1) && (this->actor.parent != NULL)) { if (!(this->actor.flags & ACTOR_FLAG_INSIDE_CULLING_VOLUME)) { - u8 new_var = this->unk_14E[0]; - u8 phi_v0 = 0; - STACK_PAD(s32); - - if (this->unk_14C < 0) { - phi_v0 = 0x80; + v = this->unk14E[0]; + var_v0 = 0; + if (this->unk14C < 0) { + var_v0 = 0x80; } - - ((EnWood02*)this->actor.parent)->unk_14E[new_var] = phi_v0; + ((EnWood02*)this->actor.parent)->unk14E[v] = var_v0; Actor_Kill(&this->actor); return; } - } else if (this->spawnType == WOOD_SPAWN_SPAWNER) { - EnWood02_SpawnOffspring(this, play); + } else if (this->unk153 == 2) { + EnWood02_SpawnUnculledChildren(this, play); } - - if (this->actor.params <= WOOD_TREE_KAKARIKO_ADULT) { + if (thisx->params < EN_WOOD_02_TYPE_11) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; Actor_PlaySfx(&this->actor, NA_SE_IT_REFLECTION_WOOD); } - if (this->actor.home.rot.y != 0) { - Vec3f dropsSpawnPt = this->actor.world.pos; - - dropsSpawnPt.y += 200.0f; - - if ((this->unk_14C >= 0) && (this->unk_14C < 0x64)) { - Item_DropCollectibleRandom(play, &this->actor, &dropsSpawnPt, - COLLECTIBLE_DROP_RANDOM_PARAMS(this->unk_14C, false)); - } else { - if (this->actor.home.rot.z != 0) { - this->actor.home.rot.z &= 0x1FFF; - this->actor.home.rot.z |= 0xE000; - Actor_Spawn(&play->actorCtx, play, ACTOR_EN_SW, dropsSpawnPt.x, dropsSpawnPt.y, dropsSpawnPt.z, 0, - this->actor.world.rot.y, 0, this->actor.home.rot.z); - this->actor.home.rot.z = 0; - } + Vec3f sp58; + s32 var_s0; + s32 var_v1_sp44_or_sp50; + + sp58 = this->actor.world.pos; + sp58.y += 200.0f; + if ((this->unk14C >= 0) && (this->unk14C < 0x64)) { + Item_DropCollectibleRandom(play, &this->actor, &sp58, + COLLECTIBLE_DROP_RANDOM_PARAMS(this->unk14C, false)); + } else if (this->actor.home.rot.z != 0) { + this->actor.home.rot.z &= 0x1FFF; + this->actor.home.rot.z |= 0xE000; + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_SW, sp58.x, sp58.y, sp58.z, 0, this->actor.world.rot.y, 0, + this->actor.home.rot.z); + this->actor.home.rot.z = 0; } - - // Spawn falling leaves - if (this->unk_14C >= -1) { - s32 i; - s32 leavesParams = WOOD_LEAF_GREEN; - - if ((this->actor.params == WOOD_TREE_OVAL_YELLOW_SPAWNER) || - (this->actor.params == WOOD_TREE_OVAL_YELLOW_SPAWNED)) { - leavesParams = WOOD_LEAF_YELLOW; + var_v1_sp44_or_sp50 = EN_WOOD_02_TYPE_23; + if (this->unk14C >= -1) { + if ((this->actor.params == EN_WOOD_02_TYPE_6) || (this->actor.params == EN_WOOD_02_TYPE_7)) { + var_v1_sp44_or_sp50 = EN_WOOD_02_TYPE_24; } Actor_PlaySfx(&this->actor, NA_SE_EV_TREE_SWING); - - for (i = 3; i >= 0; i--) { - Actor_Spawn(&play->actorCtx, play, ACTOR_EN_WOOD02, dropsSpawnPt.x, dropsSpawnPt.y, dropsSpawnPt.z, - 0, Rand_CenteredFloat(65535.0f), 0, leavesParams); + for (var_s0 = 3; var_s0 >= 0; var_s0--) { + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_WOOD02, sp58.x, sp58.y, sp58.z, 0, + (s16)(s32)Rand_CenteredFloat(65535.0f), 0, var_v1_sp44_or_sp50); } } - this->unk_14C = -0x15; + this->unk14C = -21; this->actor.home.rot.y = 0; } - if (this->actor.xzDistToPlayer < 600.0f) { Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } - } else if (this->actor.params < 0x17) { // Bush - Player* player = GET_PLAYER(play); - - if (this->unk_14C >= -1) { - if (((player->rideActor == NULL) && (sqrt(this->actor.xyzDistToPlayerSq) < 20.0) && - (player->speedXZ != 0.0f)) || - ((player->rideActor != NULL) && (sqrt(this->actor.xyzDistToPlayerSq) < 60.0) && - (player->rideActor->speed != 0.0f))) { - if ((this->unk_14C >= 0) && (this->unk_14C < 0x64)) { - Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, - COLLECTIBLE_DROP_RANDOM_PARAMS(this->unk_14C, true)); - } - this->unk_14C = -0x15; - Actor_PlaySfx(&this->actor, NA_SE_EV_TREE_SWING); + } else if (this->actor.params < EN_WOOD_02_TYPE_23) { + Player* player; + + player = GET_PLAYER(play); + if ((this->unk14C >= (-1)) && + (((((player->rideActor == NULL)) && (sqrt(this->actor.xyzDistToPlayerSq) < 20.0)) && + (player->speedXZ != 0.0f)) || + (((player->rideActor != NULL) && (sqrt(this->actor.xyzDistToPlayerSq) < 60.0)) && + (player->rideActor->speed != 0.0f)))) { + if ((this->unk14C >= 0) && (this->unk14C < 0x64)) { + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, + COLLECTIBLE_DROP_RANDOM_PARAMS(this->unk14C, true)); } + this->unk14C = -21; + Actor_PlaySfx(&this->actor, NA_SE_EV_TREE_SWING); } - } else { // Leaves - this->unk_14C++; - Math_ApproachF(&this->actor.velocity.x, 0.0f, 1.0f, 5 * 0.01f); - Math_ApproachF(&this->actor.velocity.z, 0.0f, 1.0f, 5 * 0.01f); + } else { + this->unk14C += 1; + Math_ApproachF(&this->actor.velocity.x, 0.0f, 1.0f, 0.049999997f); + Math_ApproachF(&this->actor.velocity.z, 0.0f, 1.0f, 0.049999997f); Actor_UpdatePos(&this->actor); - this->actor.shape.rot.z = Math_SinS(3000 * this->unk_14C) * 0x4000; - this->unk_14E[0]--; - - if (this->unk_14E[0] == 0) { + this->actor.shape.rot.z = (s16)(s32)(Math_SinS((s16)(this->unk14C * 0xBB8)) * 16384.0f); + this->unk14E[0] -= 1; + if (this->unk14E[0] == 0) { Actor_Kill(&this->actor); } } - - // Wobble from impact - if (this->unk_14C < -1) { - this->unk_14C++; - wobbleAmplitude = Math_SinS((this->unk_14C ^ 0xFFFF) * 0x3332) * 250.0f; - this->actor.shape.rot.x = (Math_CosS(this->actor.yawTowardsPlayer - this->actor.shape.rot.y) * wobbleAmplitude); - this->actor.shape.rot.z = (Math_SinS(this->actor.yawTowardsPlayer - this->actor.shape.rot.y) * wobbleAmplitude); + if (this->unk14C < -1) { + this->unk14C += 1; + sp6C = Math_SinS((this->unk14C ^ 0xFFFF) * 0x3332) * 250.0f; + this->actor.shape.rot.x = Math_CosS(this->actor.yawTowardsPlayer - this->actor.shape.rot.y) * sp6C; + this->actor.shape.rot.z = Math_SinS(this->actor.yawTowardsPlayer - this->actor.shape.rot.y) * sp6C; } } void EnWood02_Draw(Actor* thisx, PlayState* play) { - EnWood02* this = (EnWood02*)thisx; + GraphicsContext* gfxCtx; s16 type; - GraphicsContext* gfxCtx = play->state.gfxCtx; - u8 red; - u8 green; - u8 blue; + EnWood02* this = (EnWood02*)thisx; + u8 r; + u8 g; + u8 b; + gfxCtx = play->state.gfxCtx; OPEN_DISPS(gfxCtx, "../z_en_wood02.c", 775); type = this->actor.params; - - if ((type == WOOD_TREE_OVAL_GREEN_SPAWNER) || (type == WOOD_TREE_OVAL_GREEN_SPAWNED) || - (type == WOOD_TREE_OVAL_GREEN) || (type == WOOD_LEAF_GREEN)) { - red = 50; - green = 170; - blue = 70; - } else if ((type == WOOD_TREE_OVAL_YELLOW_SPAWNER) || (type == WOOD_TREE_OVAL_YELLOW_SPAWNED) || - (type == WOOD_LEAF_YELLOW)) { - red = 180; - green = 155; - blue = 0; + if ((type == EN_WOOD_02_TYPE_8) || (type == EN_WOOD_02_TYPE_9) || (type == EN_WOOD_02_TYPE_5) || + (type == EN_WOOD_02_TYPE_23)) { + r = 50; + g = 170; + b = 70; + } else if ((type == EN_WOOD_02_TYPE_6) || (type == EN_WOOD_02_TYPE_7) || ((type == EN_WOOD_02_TYPE_24))) { + r = 180; + g = 155; + b = 0; } else { - red = green = blue = 255; + r = g = b = 255; } - Gfx_SetupDL_25Xlu(gfxCtx); - - if ((this->actor.params == WOOD_LEAF_GREEN) || (this->actor.params == WOOD_LEAF_YELLOW)) { + if ((this->actor.params == EN_WOOD_02_TYPE_23) || (this->actor.params == EN_WOOD_02_TYPE_24)) { Gfx_SetupDL_25Opa(gfxCtx); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, red, green, blue, 127); + gDPSetPrimColor(POLY_OPA_DISP++, 0x00, 0x00, r, g, b, 127); Gfx_DrawDListOpa(play, object_wood02_DL_000700); - } else if (D_80B3BF70[this->drawType & 0xF] != NULL) { - Gfx_DrawDListOpa(play, D_80B3BF54[this->drawType & 0xF]); - gDPSetEnvColor(POLY_XLU_DISP++, red, green, blue, 0); - MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, gfxCtx, "../z_en_wood02.c", 808); - gSPDisplayList(POLY_XLU_DISP++, D_80B3BF70[this->drawType & 0xF]); } else { - Gfx_SetupDL_25Xlu(gfxCtx); - MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, gfxCtx, "../z_en_wood02.c", 814); - gSPDisplayList(POLY_XLU_DISP++, D_80B3BF54[this->drawType & 0xF]); + if (D_80B3BF70[this->unk154 & 0xF] != NULL) { + Gfx_DrawDListOpa(play, D_80B3BF54[this->unk154 & 0xF]); + gDPSetEnvColor(POLY_XLU_DISP++, r, g, b, 0); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, gfxCtx, "../z_en_wood02.c", 808); + gSPDisplayList(POLY_XLU_DISP++, D_80B3BF70[this->unk154 & 0xF]); + } else { + Gfx_SetupDL_25Xlu(gfxCtx); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, gfxCtx, "../z_en_wood02.c", 814); + gSPDisplayList(POLY_XLU_DISP++, D_80B3BF54[this->unk154 & 0xF]); + } } - CLOSE_DISPS(gfxCtx, "../z_en_wood02.c", 840); } 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 d9ebab697a6..e3ca27e3be3 100644 --- a/src/overlays/actors/ovl_En_Wood02/z_en_wood02.h +++ b/src/overlays/actors/ovl_En_Wood02/z_en_wood02.h @@ -4,45 +4,45 @@ #include "ultra64.h" #include "actor.h" +typedef enum EnWood02Type { + /* 0 */ EN_WOOD_02_TYPE_0, + /* 1 */ EN_WOOD_02_TYPE_1, + /* 2 */ EN_WOOD_02_TYPE_2, + /* 3 */ EN_WOOD_02_TYPE_3, + /* 4 */ EN_WOOD_02_TYPE_4, + /* 5 */ EN_WOOD_02_TYPE_5, + /* 6 */ EN_WOOD_02_TYPE_6, + /* 7 */ EN_WOOD_02_TYPE_7, + /* 8 */ EN_WOOD_02_TYPE_8, + /* 9 */ EN_WOOD_02_TYPE_9, + /* 10 */ EN_WOOD_02_TYPE_10, + /* 11 */ EN_WOOD_02_TYPE_11, + /* 12 */ EN_WOOD_02_TYPE_12, + /* 13 */ EN_WOOD_02_TYPE_13, + /* 14 */ EN_WOOD_02_TYPE_14, + /* 15 */ EN_WOOD_02_TYPE_15, + /* 16 */ EN_WOOD_02_TYPE_16, + /* 17 */ EN_WOOD_02_TYPE_17, + /* 18 */ EN_WOOD_02_TYPE_18, + /* 19 */ EN_WOOD_02_TYPE_19, + /* 20 */ EN_WOOD_02_TYPE_20, + /* 21 */ EN_WOOD_02_TYPE_21, + /* 22 */ EN_WOOD_02_TYPE_22, + /* 23 */ EN_WOOD_02_TYPE_23, + /* 24 */ EN_WOOD_02_TYPE_24, + /* 25 */ EN_WOOD_02_TYPE_MAX +} EnWood02Type; + struct EnWood02; typedef struct EnWood02 { - /* 0x0000 */ Actor actor; - /* 0x014C */ s16 unk_14C; - /* 0x014E */ u8 unk_14E[5]; - /* 0x0153 */ u8 spawnType; - /* 0x0154 */ u8 drawType; - /* 0x0158 */ ColliderCylinder collider; -} EnWood02; // size = 0x01A4 - -// Types with SPAWNED in the name are those that can be managed by a spawner, however the actor allows you to spawn them -// on their own without a spawner as well. -typedef enum WoodType { - /* 0x00 */ WOOD_TREE_CONICAL_LARGE, - /* 0x01 */ WOOD_TREE_CONICAL_MEDIUM, - /* 0x02 */ WOOD_TREE_CONICAL_SMALL, - /* 0x03 */ WOOD_TREE_CONICAL_SPAWNER, - /* 0x04 */ WOOD_TREE_CONICAL_SPAWNED, - /* 0x05 */ WOOD_TREE_OVAL_GREEN, - /* 0x06 */ WOOD_TREE_OVAL_YELLOW_SPAWNER, - /* 0x07 */ WOOD_TREE_OVAL_YELLOW_SPAWNED, - /* 0x08 */ WOOD_TREE_OVAL_GREEN_SPAWNER, - /* 0x09 */ WOOD_TREE_OVAL_GREEN_SPAWNED, - /* 0x0A */ WOOD_TREE_KAKARIKO_ADULT, - /* 0x0B */ WOOD_BUSH_GREEN_SMALL, - /* 0x0C */ WOOD_BUSH_GREEN_LARGE, - /* 0x0D */ WOOD_BUSH_GREEN_SMALL_SPAWNER, - /* 0x0E */ WOOD_BUSH_GREEN_SMALL_SPAWNED, - /* 0x0F */ WOOD_BUSH_GREEN_LARGE_SPAWNER, - /* 0x10 */ WOOD_BUSH_GREEN_LARGE_SPAWNED, - /* 0x11 */ WOOD_BUSH_BLACK_SMALL, - /* 0x12 */ WOOD_BUSH_BLACK_LARGE, - /* 0x13 */ WOOD_BUSH_BLACK_SMALL_SPAWNER, - /* 0x14 */ WOOD_BUSH_BLACK_SMALL_SPAWNED, - /* 0x15 */ WOOD_BUSH_BLACK_LARGE_SPAWNER, - /* 0x16 */ WOOD_BUSH_BLACK_LARGE_SPAWNED, - /* 0x17 */ WOOD_LEAF_GREEN, - /* 0x18 */ WOOD_LEAF_YELLOW -} WoodType; + /* 0x000 */ Actor actor; + /* 0x14C */ s16 unk14C; + /* 0x14E */ u8 unk14E[5]; + /* 0x153 */ u8 unk153; + /* 0x154 */ u8 unk154; + /* 0x155 */ char pad155[3]; + /* 0x158 */ ColliderCylinder collider; +} EnWood02; // size = 0x1A4 #endif diff --git a/src/overlays/actors/ovl_En_Xc/z_en_xc.c b/src/overlays/actors/ovl_En_Xc/z_en_xc.c index a1fa5b65b32..2ad3d29d776 100644 --- a/src/overlays/actors/ovl_En_Xc/z_en_xc.c +++ b/src/overlays/actors/ovl_En_Xc/z_en_xc.c @@ -35,8 +35,8 @@ #include "assets/scenes/indoors/tokinoma/tokinoma_scene.h" #include "assets/scenes/dungeons/ice_doukutu/ice_doukutu_scene.h" -#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ique-cn:128 ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128" +#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ique-cn:0" \ + "ntsc-1.0:0 ntsc-1.1:0 ntsc-1.2:0 pal-1.0:0 pal-1.1:0" #define FLAGS ACTOR_FLAG_UPDATE_CULLING_DISABLED 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 e3dfb56430f..a57a15fc4d0 100644 --- a/src/overlays/actors/ovl_En_Zl1/z_en_zl1.c +++ b/src/overlays/actors/ovl_En_Zl1/z_en_zl1.c @@ -107,11 +107,11 @@ void EnZl1_Init(Actor* thisx, PlayState* play) { Animation_Change(&this->skelAnime, &gChildZelda1Anim_00438, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP, 0.0f); this->unk_1E6 = 0; this->actionFunc = func_80B4BC78; - } else if (Flags_GetEventChkInf(EVENTCHKINF_09) && Flags_GetEventChkInf(EVENTCHKINF_25) && - Flags_GetEventChkInf(EVENTCHKINF_37)) { + } else if ((Flags_GetEventChkInf(EVENTCHKINF_09)) && (Flags_GetEventChkInf(EVENTCHKINF_25)) && + (Flags_GetEventChkInf(EVENTCHKINF_37))) { Actor_Kill(&this->actor); - } else if ((Flags_GetEventChkInf(EVENTCHKINF_09) && Flags_GetEventChkInf(EVENTCHKINF_25)) || - (Flags_GetEventChkInf(EVENTCHKINF_09) && Flags_GetEventChkInf(EVENTCHKINF_37))) { + } else if (((Flags_GetEventChkInf(EVENTCHKINF_09)) && (Flags_GetEventChkInf(EVENTCHKINF_25))) || + ((Flags_GetEventChkInf(EVENTCHKINF_09)) && (Flags_GetEventChkInf(EVENTCHKINF_37)))) { frameCount = Animation_GetLastFrame(&gChildZelda1Anim_00438); Animation_Change(&this->skelAnime, &gChildZelda1Anim_00438, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP, 0.0f); this->actor.textId = 0x703D; @@ -612,7 +612,7 @@ void EnZl1_Update(Actor* thisx, PlayState* play) { func_80B4AE18(this); } -s32 EnZl1_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { +s32 func_80B4C340(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { EnZl1* this = (EnZl1*)thisx; if ((limbIndex == 4) || (limbIndex == 3) || (limbIndex == 6) || (limbIndex == 5)) { @@ -633,7 +633,7 @@ s32 EnZl1_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* p return 0; } -void EnZl1_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { +void func_80B4C400(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { Vec3f vec = { 0.0f, 0.0f, 0.0f }; EnZl1* this = (EnZl1*)thisx; @@ -653,7 +653,7 @@ void EnZl1_Draw(Actor* thisx, PlayState* play) { Gfx_SetupDL_25Opa(play->state.gfxCtx); SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnZl1_OverrideLimbDraw, EnZl1_PostLimbDraw, this); + func_80B4C340, func_80B4C400, this); CLOSE_DISPS(play->state.gfxCtx, "../z_en_girlB.c", 2046); } diff --git a/src/overlays/actors/ovl_Fishing/z_fishing.c b/src/overlays/actors/ovl_Fishing/z_fishing.c index d67f7426613..07c9ef3fbf5 100644 --- a/src/overlays/actors/ovl_Fishing/z_fishing.c +++ b/src/overlays/actors/ovl_Fishing/z_fishing.c @@ -39,7 +39,7 @@ #include "cic6105.h" #endif -#pragma increment_block_number "gc-eu:224 gc-eu-mq:224 gc-jp:224 gc-jp-ce:224 gc-jp-mq:224 gc-us:224 gc-us-mq:224" \ +#pragma increment_block_number "gc-eu:160 gc-eu-mq:160 gc-jp:160 gc-jp-ce:160 gc-jp-mq:160 gc-us:160 gc-us-mq:160" \ "ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128" #define FLAGS ACTOR_FLAG_UPDATE_CULLING_DISABLED 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 511f8a5921e..0e9e085c51f 100644 --- a/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c +++ b/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c @@ -122,25 +122,25 @@ void ItemEtcetera_Init(Actor* thisx, PlayState* play) { Actor_SetScale(&this->actor, 0.25f); ItemEtcetera_SetupAction(this, ItemEtcetera_WaitForObject); switch (type) { - case ITEM_ETC_LETTER: + case ITEM_ETCETERA_LETTER: Actor_SetScale(&this->actor, 0.5f); this->futureActionFunc = func_80B858B4; if (GET_EVENTCHKINF(EVENTCHKINF_31)) { Actor_Kill(&this->actor); } break; - case ITEM_ETC_ARROW_FIRE: + case ITEM_ETCETERA_ARROW_FIRE: this->futureActionFunc = ItemEtcetera_UpdateFireArrow; 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: + case ITEM_ETCETERA_RUPEE_GREEN_CHEST_GAME: + case ITEM_ETCETERA_RUPEE_BLUE_CHEST_GAME: + case ITEM_ETCETERA_RUPEE_RED_CHEST_GAME: + case ITEM_ETCETERA_RUPEE_PURPLE_CHEST_GAME: + case ITEM_ETCETERA_HEART_PIECE_CHEST_GAME: + case ITEM_ETCETERA_KEY_SMALL_CHEST_GAME: Actor_SetScale(&this->actor, 0.5f); this->futureActionFunc = func_80B85B28; this->drawFunc = ItemEtcetera_DrawThroughLens; 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 dcae852df4c..39810139c5a 100644 --- a/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.h +++ b/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.h @@ -19,20 +19,20 @@ typedef struct ItemEtcetera { } ItemEtcetera; // size = 0x0160 typedef enum ItemEtceteraType { - /* 0x00 */ ITEM_ETC_BOTTLE, - /* 0x01 */ ITEM_ETC_LETTER, - /* 0x02 */ ITEM_ETC_SHIELD_HYLIAN, - /* 0x03 */ ITEM_ETC_QUIVER, - /* 0x04 */ ITEM_ETC_SCALE_SILVER, - /* 0x05 */ ITEM_ETC_SCALE_GOLD, - /* 0x06 */ ITEM_ETC_KEY_SMALL, - /* 0x07 */ ITEM_ETC_ARROW_FIRE, - /* 0x08 */ ITEM_ETC_RUPEE_GREEN_CHEST_GAME, - /* 0x09 */ ITEM_ETC_RUPEE_BLUE_CHEST_GAME, - /* 0x0A */ ITEM_ETC_RUPEE_RED_CHEST_GAME, - /* 0x0B */ ITEM_ETC_RUPEE_PURPLE_CHEST_GAME, - /* 0x0C */ ITEM_ETC_HEART_PIECE_CHEST_GAME, - /* 0x0D */ ITEM_ETC_KEY_SMALL_CHEST_GAME + /* 0x00 */ ITEM_ETCETERA_BOTTLE, + /* 0x01 */ ITEM_ETCETERA_LETTER, + /* 0x02 */ ITEM_ETCETERA_SHIELD_HYLIAN, + /* 0x03 */ ITEM_ETCETERA_QUIVER, + /* 0x04 */ ITEM_ETCETERA_SCALE_SILVER, + /* 0x05 */ ITEM_ETCETERA_SCALE_GOLD, + /* 0x06 */ ITEM_ETCETERA_KEY_SMALL, + /* 0x07 */ ITEM_ETCETERA_ARROW_FIRE, + /* 0x08 */ ITEM_ETCETERA_RUPEE_GREEN_CHEST_GAME, + /* 0x09 */ ITEM_ETCETERA_RUPEE_BLUE_CHEST_GAME, + /* 0x0A */ ITEM_ETCETERA_RUPEE_RED_CHEST_GAME, + /* 0x0B */ ITEM_ETCETERA_RUPEE_PURPLE_CHEST_GAME, + /* 0x0C */ ITEM_ETCETERA_HEART_PIECE_CHEST_GAME, + /* 0x0D */ ITEM_ETCETERA_KEY_SMALL_CHEST_GAME } ItemEtceteraType; #endif diff --git a/src/overlays/actors/ovl_Magic_Fire/z_magic_fire.c b/src/overlays/actors/ovl_Magic_Fire/z_magic_fire.c index 6c3a8e53244..fc2ba7c9cbd 100644 --- a/src/overlays/actors/ovl_Magic_Fire/z_magic_fire.c +++ b/src/overlays/actors/ovl_Magic_Fire/z_magic_fire.c @@ -137,7 +137,7 @@ void MagicFire_UpdateBeforeCast(Actor* thisx, PlayState* play) { if (this->actionTimer > 0) { this->actionTimer--; } else { - this->actor.update = MagicFire_Update; + this->actor.update = &MagicFire_Update; Player_PlaySfx(player, NA_SE_PL_MAGIC_FIRE); } this->actor.world.pos = player->actor.world.pos; diff --git a/src/overlays/actors/ovl_Magic_Wind/z_magic_wind.c b/src/overlays/actors/ovl_Magic_Wind/z_magic_wind.c index 9a7d3c6f136..b2134ce280a 100644 --- a/src/overlays/actors/ovl_Magic_Wind/z_magic_wind.c +++ b/src/overlays/actors/ovl_Magic_Wind/z_magic_wind.c @@ -6,6 +6,7 @@ #include "z_magic_wind.h" +#include "animation_curve.h" #include "array_count.h" #include "gfx.h" #include "gfx_setupdl.h" @@ -13,7 +14,6 @@ #include "sfx.h" #include "stack_pad.h" #include "translation.h" -#include "curve.h" #include "play_state.h" #include "player.h" @@ -56,7 +56,7 @@ void MagicWind_Init(Actor* thisx, PlayState* play) { MagicWind* this = (MagicWind*)thisx; Player* player = GET_PLAYER(play); - if (!SkelCurve_Init(play, &this->skelCurve, &sSkel, &sAnim)) { + if (SkelCurve_Init(play, &this->skelCurve, &sSkel, &sAnim) == 0) { PRINTF(T("Magic_Wind_Actor_ct():コンストラクト失敗\n", "Magic_Wind_Actor_ct(): Construct failed\n")); } this->actor.room = -1; @@ -150,7 +150,7 @@ void MagicWind_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); } -s32 MagicWind_OverrideLimbDraw(PlayState* play, SkelCurve* skelCurve, s32 limbIndex, void* thisx) { +s32 MagicWind_OverrideLimbDraw(PlayState* play, SkelAnimeCurve* skelCurve, s32 limbIndex, void* thisx) { STACK_PAD(s32); OPEN_DISPS(play->state.gfxCtx, "../z_magic_wind.c", 615); @@ -183,7 +183,7 @@ void MagicWind_Draw(Actor* thisx, PlayState* play) { if (this->actionFunc != MagicWind_WaitForTimer) { POLY_XLU_DISP = Gfx_SetupDL(POLY_XLU_DISP, SETUPDL_25); - SkelCurve_Draw(&this->actor, play, &this->skelCurve, MagicWind_OverrideLimbDraw, NULL, 1, NULL); + SkelCurve_Draw(thisx, play, &this->skelCurve, MagicWind_OverrideLimbDraw, NULL, 1, NULL); } CLOSE_DISPS(gfxCtx, "../z_magic_wind.c", 673); diff --git a/src/overlays/actors/ovl_Magic_Wind/z_magic_wind.h b/src/overlays/actors/ovl_Magic_Wind/z_magic_wind.h index 6a186dcb560..53731dd3972 100644 --- a/src/overlays/actors/ovl_Magic_Wind/z_magic_wind.h +++ b/src/overlays/actors/ovl_Magic_Wind/z_magic_wind.h @@ -3,7 +3,7 @@ #include "ultra64.h" #include "actor.h" -#include "curve.h" +#include "animation_curve.h" struct MagicWind; @@ -11,7 +11,7 @@ typedef void (*MagicWindFunc)(struct MagicWind* this, struct PlayState* play); typedef struct MagicWind { /* 0x0000 */ Actor actor; - /* 0x014C */ SkelCurve skelCurve; + /* 0x014C */ SkelAnimeCurve skelCurve; /* 0x016C */ s16 timer; /* 0x0170 */ MagicWindFunc actionFunc; } MagicWind; // size = 0x0174 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 7c5db5a5e15..2f0d541a43b 100644 --- a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c +++ b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c @@ -1,7 +1,7 @@ /* * File: z_mir_ray.c * Overlay: ovl_Mir_Ray - * Description: Reflectable Light Beam and reflections + * Description: Reflectable Light Beam */ #include "z_mir_ray.h" @@ -31,21 +31,14 @@ 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); - -// Locations of light beams in sMirRayData -typedef enum MirRayBeamLocations { - /* 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 -} MirRayBeamLocations; +typedef struct struct_80B8D8A0 { + /* 0x00 */ Vec3f reflectionPos; + /* 0x0C */ MtxF reflectionTransform; + /* 0x4C */ CollisionPoly* unk4C; + /* 0x50 */ u8 unk50; +} struct_80B8D8A0; // size = 0x54 + +s32 MirRay_IsInConeFrustum(Vec3f* centerTop, Vec3f* centerBase, f32 x, f32 y, f32 z, s16 radiusTop, s16 radiusBase); ActorProfile Mir_Ray_Profile = { /**/ ACTOR_MIR_RAY, @@ -59,9 +52,8 @@ ActorProfile Mir_Ray_Profile = { /**/ MirRay_Draw, }; -static u8 D_80B8E670 = 0; - -static ColliderQuadInit sQuadInit = { +static u8 D_80B8E670 = false; +static ColliderQuadInit sColliderQuadInit = { { COL_MATERIAL_NONE, AT_ON | AT_TYPE_PLAYER, @@ -80,47 +72,151 @@ static ColliderQuadInit sQuadInit = { }, { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, }; - -static ColliderJntSphElementInit sJntSphElementsInit[] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { - ELEM_MATERIAL_UNK0, - { 0x00200000, HIT_SPECIAL_EFFECT_NONE, 0x00 }, - { 0x00000000, HIT_BACKLASH_NONE, 0x00 }, - ATELEM_ON | ATELEM_SFX_NORMAL, - ACELEM_NONE, - OCELEM_NONE, - }, - { 0, { { 0, 0, 0 }, 50 }, 100 }, + { 0, { 0x200000, 0, 0 }, { 0, 0, 0 }, 1, 0, 0 }, + { 0, { { 0, 0, 0 }, 0x32 }, 0x64 }, }, }; - -static ColliderJntSphInit sJntSphInit = { +static ColliderJntSphInit sJntSphInit = { { 0xA, 9, 0, 0, 0, 0 }, 1, sJntSphElementsInit }; +typedef struct struct_80B8E6F8 { + /* 0x00 */ Vec3s coneFrustumCenterTop; + /* 0x06 */ Vec3s coneFrustumCenterBase; + /* 0x0C */ s16 coneFrustumRadiusTop; + /* 0x0E */ s16 coneFrustumRadiusBase; + /* 0x10 */ f32 unk10_sphereColliderPosRatioTowardsBase; + /* 0x14 */ s16 unk14_sphereColliderRadiusModel; + /* 0x16 */ s16 unk16_pointLightRadius; + /* 0x18 */ f32 unk18_pointLightPosRatio; + /* 0x1C */ Color_RGB8 unk1C_lightColor; +#define UNK1F_0 (1 << 0) +#define UNK1F_1 (1 << 1) +#define UNK1F_2 (1 << 2) +#define UNK1F_POINTLIGHTPOS_TO_PLAYER (1 << 3) + /* 0x1F */ u8 unk1F; +} struct_80B8E6F8; +static struct_80B8E6F8 D_80B8E6F8[0xA] = { { - COL_MATERIAL_NONE, - AT_ON | AT_TYPE_PLAYER, - AC_NONE, - OC1_NONE, - OC2_NONE, - COLSHAPE_JNTSPH, + { -1160, 686, -880 }, + { -920, 480, -889 }, + 30, + 50, + 1.0f, + 50, + 150, + 0.8f, + { 255, 255, 255 }, + UNK1F_1, + }, + { + { -1856, 1092, -190 }, + { -1703, 841, -186 }, + 30, + 70, + 0.88f, + 54, + 150, + 0.8f, + { 255, 255, 255 }, + UNK1F_1, + }, + { + { 1367, 738, -860 }, + { 1091, 476, -860 }, + 30, + 85, + 0.0f, + 0, + 150, + 0.8f, + { 255, 255, 255 }, + 0, + }, + { + { 2200, 1103, -220 }, + { 2040, 843, -220 }, + 30, + 60, + 0.0f, + 0, + 150, + 0.8f, + { 255, 255, 255 }, + UNK1F_0, + }, + { + { -560, 2169, -310 }, + { -560, 1743, -310 }, + 30, + 70, + 0.0f, + 0, + 150, + 0.8f, + { 255, 255, 255 }, + 0, + }, + { + { 60, 1802, -1090 }, + { 60, 973, -1090 }, + 30, + 70, + 0.0f, + 0, + 150, + 0.9f, + { 255, 255, 255 }, + UNK1F_0 | UNK1F_2 | UNK1F_POINTLIGHTPOS_TO_PLAYER, + }, + { + { 1140, 480, -860 }, + { 1140, 480, -860 }, + 30, + 30, + 1.0f, + 10, + 100, + 0.9f, + { 255, 255, 255 }, + UNK1F_1 | UNK1F_2 | UNK1F_POINTLIGHTPOS_TO_PLAYER, + }, + { + { -560, 1743, -310 }, + { -560, 1743, -310 }, + 30, + 30, + 0.0f, + 0, + 100, + 0.94f, + { 255, 255, 255 }, + UNK1F_2 | UNK1F_POINTLIGHTPOS_TO_PLAYER, + }, + { + { 60, 1743, -310 }, + { 60, 1743, -310 }, + 30, + 30, + 0.0f, + 0, + 100, + 0.94f, + { 255, 255, 255 }, + UNK1F_2 | UNK1F_POINTLIGHTPOS_TO_PLAYER, + }, + { + { -1174, 448, 1194 }, + { -1174, 148, 1194 }, + 50, + 100, + 1.0f, + 50, + 150, + 0.8f, + { 255, 255, 255 }, + UNK1F_0 | UNK1F_1, }, - ARRAY_COUNT(sJntSphElementsInit), - sJntSphElementsInit, -}; - -static MirRayDataEntry sMirRayData[] = { - { { -1160, 686, -880 }, { -920, 480, -889 }, 30, 50, 1.0f, 50, 150, 0.8f, 255, 255, 255, 0x02 }, - { { -1856, 1092, -190 }, { -1703, 841, -186 }, 30, 70, 0.88f, 54, 150, 0.8f, 255, 255, 255, 0x02 }, - { { 1367, 738, -860 }, { 1091, 476, -860 }, 30, 85, 0.0f, 0, 150, 0.8f, 255, 255, 255, 0x00 }, - { { 2200, 1103, -220 }, { 2040, 843, -220 }, 30, 60, 0.0f, 0, 150, 0.8f, 255, 255, 255, 0x01 }, - { { -560, 2169, -310 }, { -560, 1743, -310 }, 30, 70, 0.0f, 0, 150, 0.8f, 255, 255, 255, 0x00 }, - { { 60, 1802, -1090 }, { 60, 973, -1090 }, 30, 70, 0.0f, 0, 150, 0.9f, 255, 255, 255, 0x0D }, - { { 1140, 480, -860 }, { 1140, 480, -860 }, 30, 30, 1.0f, 10, 100, 0.9f, 255, 255, 255, 0x0E }, - { { -560, 1743, -310 }, { -560, 1743, -310 }, 30, 30, 0.0f, 0, 100, 0.94f, 255, 255, 255, 0x0C }, - { { 60, 1743, -310 }, { 60, 1743, -310 }, 30, 30, 0.0f, 0, 100, 0.94f, 255, 255, 255, 0x0C }, - { { -1174, 448, 1194 }, { -1174, 148, 1194 }, 50, 100, 1.0f, 50, 150, 0.8f, 255, 255, 255, 0x03 } }; - static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 0, ICHAIN_CONTINUE), ICHAIN_F32(cullingVolumeDistance, 4000, ICHAIN_CONTINUE), @@ -128,114 +224,104 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(cullingVolumeDownward, 1000, ICHAIN_STOP), }; -void MirRay_SetupCollider(MirRay* this) { - Vec3f colliderOffset; - MirRayDataEntry* dataEntry = &sMirRayData[this->actor.params]; - - colliderOffset.x = (this->poolPt.x - this->sourcePt.x) * dataEntry->unk_10; - colliderOffset.y = (this->poolPt.y - this->sourcePt.y) * dataEntry->unk_10; - colliderOffset.z = (this->poolPt.z - this->sourcePt.z) * dataEntry->unk_10; - this->colliderJntSph.elements[0].dim.worldSphere.center.x = colliderOffset.x + this->sourcePt.x; - this->colliderJntSph.elements[0].dim.worldSphere.center.y = colliderOffset.y + this->sourcePt.y; - this->colliderJntSph.elements[0].dim.worldSphere.center.z = colliderOffset.z + this->sourcePt.z; - this->colliderJntSph.elements[0].dim.worldSphere.radius = - dataEntry->unk_14 * this->colliderJntSph.elements->dim.scale; +void MirRay_UpdateColliderSphereShape(MirRay* this) { + Vec3f vec; + struct_80B8E6F8* temp_v0; + ColliderJntSphElement* new_var; + + temp_v0 = &D_80B8E6F8[this->actor.params]; + vec.x = (this->coneFrustumCenterBase.x - this->coneFrustumCenterTop.x) * + temp_v0->unk10_sphereColliderPosRatioTowardsBase; + vec.y = (this->coneFrustumCenterBase.y - this->coneFrustumCenterTop.y) * + temp_v0->unk10_sphereColliderPosRatioTowardsBase; + vec.z = (this->coneFrustumCenterBase.z - this->coneFrustumCenterTop.z) * + temp_v0->unk10_sphereColliderPosRatioTowardsBase; + this->unk14C.elements[0].dim.worldSphere.center.x = this->coneFrustumCenterTop.x + vec.x; + this->unk14C.elements[0].dim.worldSphere.center.y = this->coneFrustumCenterTop.y + vec.y; + this->unk14C.elements[0].dim.worldSphere.center.z = this->coneFrustumCenterTop.z + vec.z; + new_var = &this->unk14C.elements[0]; + new_var->dim.worldSphere.radius = temp_v0->unk14_sphereColliderRadiusModel * new_var->dim.scale; } -// Set up a light point between source point and reflection point. Reflection point is the pool point (for windows) or -// at the player position (for mirrors) -void MirRay_MakeShieldLight(MirRay* this, PlayState* play) { - Player* player = GET_PLAYER(play); - MirRayDataEntry* dataEntry = &sMirRayData[this->actor.params]; - Vec3f reflectionPt; - Vec3s lightPt; - - if (MirRay_CheckInFrustum(&this->sourcePt, &this->poolPt, player->actor.world.pos.x, - player->actor.world.pos.y + 30.0f, player->actor.world.pos.z, this->sourceEndRad, - this->poolEndRad)) { - - if (PARAMS_GET_NOSHIFT(dataEntry->params, 3, 1)) { // Light beams from mirrors - Math_Vec3f_Diff(&player->actor.world.pos, &this->sourcePt, &reflectionPt); - } else { // Light beams from windows - Math_Vec3f_Diff(&this->poolPt, &this->sourcePt, &reflectionPt); +void MirRay_UpdateLight(MirRay* this, PlayState* play) { + Player* player; + struct_80B8E6F8* temp_s1; + Vec3f sp44; + Vec3s pointLightPos; + + player = GET_PLAYER(play); + temp_s1 = &D_80B8E6F8[this->actor.params]; + if (MirRay_IsInConeFrustum(&this->coneFrustumCenterTop, &this->coneFrustumCenterBase, player->actor.world.pos.x, + player->actor.world.pos.y + 30.0f, player->actor.world.pos.z, this->coneFrustumRadiusTop, + this->coneFrustumRadiusBase)) { + if (temp_s1->unk1F & UNK1F_POINTLIGHTPOS_TO_PLAYER) { + Math_Vec3f_Diff(&player->actor.world.pos, &this->coneFrustumCenterTop, &sp44); + } else { + Math_Vec3f_Diff(&this->coneFrustumCenterBase, &this->coneFrustumCenterTop, &sp44); } - - lightPt.x = (dataEntry->unk_18 * reflectionPt.x) + this->sourcePt.x; - lightPt.y = (dataEntry->unk_18 * reflectionPt.y) + this->sourcePt.y; - lightPt.z = (dataEntry->unk_18 * reflectionPt.z) + this->sourcePt.z; - - // Fade up - Math_StepToS(&this->lightPointRad, dataEntry->lgtPtMaxRad, 6); - Lights_PointNoGlowSetInfo(&this->lightInfo, lightPt.x, lightPt.y, lightPt.z, dataEntry->color.r, - dataEntry->color.g, dataEntry->color.b, this->lightPointRad); + pointLightPos.x = (temp_s1->unk18_pointLightPosRatio * sp44.x) + this->coneFrustumCenterTop.x; + pointLightPos.y = (temp_s1->unk18_pointLightPosRatio * sp44.y) + this->coneFrustumCenterTop.y; + pointLightPos.z = (temp_s1->unk18_pointLightPosRatio * sp44.z) + this->coneFrustumCenterTop.z; + Math_StepToS(&this->pointLightRadius, temp_s1->unk16_pointLightRadius, 6); + Lights_PointNoGlowSetInfo(&this->lightInfo, pointLightPos.x, pointLightPos.y, pointLightPos.z, + temp_s1->unk1C_lightColor.r, temp_s1->unk1C_lightColor.g, temp_s1->unk1C_lightColor.b, + this->pointLightRadius); } else { - // Fade down - Math_StepToS(&this->lightPointRad, 0, 6); - Lights_PointSetColorAndRadius(&this->lightInfo, dataEntry->color.r, dataEntry->color.g, dataEntry->color.b, - this->lightPointRad); + Math_StepToS(&this->pointLightRadius, 0, 6); + Lights_PointSetColorAndRadius(&this->lightInfo, temp_s1->unk1C_lightColor.r, temp_s1->unk1C_lightColor.g, + temp_s1->unk1C_lightColor.b, this->pointLightRadius); } } void MirRay_Init(Actor* thisx, PlayState* play) { STACK_PAD(s32); + struct_80B8E6F8* temp_s1; MirRay* this = (MirRay*)thisx; - MirRayDataEntry* dataEntry = &sMirRayData[this->actor.params]; + temp_s1 = &D_80B8E6F8[this->actor.params]; Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); - PRINTF(T("反射用 光の発生!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n", - "Spawn of reflectable light!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n")); - LOG_NUM("this->actor.arg_data", this->actor.params, "../z_mir_ray.c", 518); - - if (this->actor.params >= 0xA) { - LOG_STRING_T("反射光 発生失敗", "Reflected light failed to spawn", "../z_mir_ray.c", 521); + PRINTF("反射用 光の発生!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); +#if DEBUG_FEATURES + LogUtils_LogThreadId("../z_mir_ray.c", 518); + PRINTF("this->actor.arg_data = %d\n", this->actor.params); +#endif + if (this->actor.params >= ARRAY_COUNT(D_80B8E6F8)) { + LOG_STRING("反射光 発生失敗", "../z_mir_ray.c", 521); Actor_Kill(&this->actor); } - - this->sourcePt.x = dataEntry->sourcePoint.x; - this->sourcePt.y = dataEntry->sourcePoint.y; - this->sourcePt.z = dataEntry->sourcePoint.z; - this->sourceEndRad = dataEntry->sourceEndRadius; - - this->poolPt.x = dataEntry->poolPoint.x; - this->poolPt.y = dataEntry->poolPoint.y; - this->poolPt.z = dataEntry->poolPoint.z; - this->poolEndRad = dataEntry->poolEndRadius; - - Lights_PointNoGlowSetInfo(&this->lightInfo, this->sourcePt.x, this->sourcePt.y, this->sourcePt.z, 255, 255, 255, - 100); + this->coneFrustumCenterTop.x = temp_s1->coneFrustumCenterTop.x; + this->coneFrustumCenterTop.y = temp_s1->coneFrustumCenterTop.y; + this->coneFrustumCenterTop.z = temp_s1->coneFrustumCenterTop.z; + this->coneFrustumRadiusTop = temp_s1->coneFrustumRadiusTop; + this->coneFrustumCenterBase.x = temp_s1->coneFrustumCenterBase.x; + this->coneFrustumCenterBase.y = temp_s1->coneFrustumCenterBase.y; + this->coneFrustumCenterBase.z = temp_s1->coneFrustumCenterBase.z; + this->coneFrustumRadiusBase = temp_s1->coneFrustumRadiusBase; + Lights_PointNoGlowSetInfo(&this->lightInfo, this->coneFrustumCenterTop.x, this->coneFrustumCenterTop.y, + this->coneFrustumCenterTop.z, 255, 255, 255, 100); this->lightNode = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfo); - - this->shieldCorners[0].x = -536.0f; - this->shieldCorners[0].y = -939.0f; - - this->shieldCorners[1].x = -1690.0f; - this->shieldCorners[1].y = 0.0f; - - this->shieldCorners[2].x = -536.0f; - this->shieldCorners[2].y = 938.0f; - - this->shieldCorners[3].x = 921.0f; - this->shieldCorners[3].y = 0.0f; - - this->shieldCorners[4].x = 758.0f; - this->shieldCorners[4].y = 800.0f; - - this->shieldCorners[5].x = 758.0f; - this->shieldCorners[5].y = -800.0f; - - if (PARAMS_GET_NOSHIFT(dataEntry->params, 1, 1)) { - Collider_InitJntSph(play, &this->colliderJntSph); - Collider_SetJntSph(play, &this->colliderJntSph, &this->actor, &sJntSphInit, this->colliderJntSphElements); - if (!PARAMS_GET_NOSHIFT(dataEntry->params, 2, 1)) { // Beams not from mirrors - MirRay_SetupCollider(this); + this->reflectionOriginModelPositions[0].x = -536.0f; + this->reflectionOriginModelPositions[0].y = -939.0f; + this->reflectionOriginModelPositions[1].x = -1690.0f; + this->reflectionOriginModelPositions[1].y = 0.0f; + this->reflectionOriginModelPositions[2].x = -536.0f; + this->reflectionOriginModelPositions[2].y = 938.0f; + this->reflectionOriginModelPositions[3].x = 921.0f; + this->reflectionOriginModelPositions[3].y = 0.0f; + this->reflectionOriginModelPositions[4].x = 758.0f; + this->reflectionOriginModelPositions[4].y = 800.0f; + this->reflectionOriginModelPositions[5].x = 758.0f; + this->reflectionOriginModelPositions[5].y = -800.0f; + if (temp_s1->unk1F & UNK1F_1) { + Collider_InitJntSph(play, &this->unk14C); + Collider_SetJntSph(play, &this->unk14C, &this->actor, &sJntSphInit, &this->unk16C); + if (!(temp_s1->unk1F & UNK1F_2)) { + MirRay_UpdateColliderSphereShape(this); } } - - Collider_InitQuad(play, &this->shieldRay); - Collider_SetQuad(play, &this->shieldRay, &this->actor, &sQuadInit); - - // Spirit Temple top room mirrors + Collider_InitQuad(play, &this->unk1AC); + Collider_SetQuad(play, &this->unk1AC, &this->actor, &sColliderQuadInit); if ((this->actor.params == 5) || (this->actor.params == 7) || (this->actor.params == 8)) { this->actor.room = -1; } @@ -245,239 +331,247 @@ void MirRay_Destroy(Actor* thisx, PlayState* play) { MirRay* this = (MirRay*)thisx; LightContext_RemoveLight(play, &play->lightCtx, this->lightNode); - - if (sMirRayData[this->actor.params].params & 2) { - Collider_DestroyJntSph(play, &this->colliderJntSph); + if (D_80B8E6F8[this->actor.params].unk1F & UNK1F_1) { + Collider_DestroyJntSph(play, &this->unk14C); } - - Collider_DestroyQuad(play, &this->shieldRay); + Collider_DestroyQuad(play, &this->unk1AC); } void MirRay_Update(Actor* thisx, PlayState* play) { - STACK_PAD(s32); + STACK_PADS(s32, 2); + Player* player; MirRay* this = (MirRay*)thisx; - Player* player = GET_PLAYER(play); - - D_80B8E670 = 0; - if (!this->unLit) { - if (sMirRayData[this->actor.params].params & 2) { - if (sMirRayData[this->actor.params].params & 4) { // Beams from mirrors - MirRay_SetupCollider(this); + player = GET_PLAYER(play); + D_80B8E670 = false; + if (this->unk2AE == 0) { + if (D_80B8E6F8[this->actor.params].unk1F & UNK1F_1) { + if (D_80B8E6F8[this->actor.params].unk1F & UNK1F_2) { + MirRay_UpdateColliderSphereShape(this); } - CollisionCheck_SetAT(play, &play->colChkCtx, &this->colliderJntSph.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->unk14C.base); } - if (this->reflectIntensity > 0.0f) { - CollisionCheck_SetAT(play, &play->colChkCtx, &this->shieldRay.base); + if (this->lightReflectionFactor > 0.0f) { + CollisionCheck_SetAT(play, &play->colChkCtx, &this->unk1AC.base); } - MirRay_MakeShieldLight(this, play); - - if (this->reflectIntensity > 0.0f) { + MirRay_UpdateLight(this, play); + if (this->lightReflectionFactor > 0.0f) { Actor_PlaySfx_Flagged2(&player->actor, NA_SE_IT_SHIELD_BEAM - SFX_FLAG); } } } -void MirRay_SetIntensity(MirRay* this, PlayState* play) { - f32 sp4C[3]; - f32 temp_f0; - f32 temp_f0_2; - f32 temp_f2_2; - STACK_PAD(s32); - Player* player = GET_PLAYER(play); - MtxF* shieldMtx = &player->shieldMf; - - this->reflectIntensity = 0.0f; - - if (MirRay_CheckInFrustum(&this->sourcePt, &this->poolPt, shieldMtx->xw, shieldMtx->yw, shieldMtx->zw, - this->sourceEndRad, this->poolEndRad)) { - - temp_f0 = sqrtf(SQ(shieldMtx->zz) + (SQ(shieldMtx->xz) + SQ(shieldMtx->yz))); - - if (temp_f0 == 0.0f) { - this->reflectRange = 1.0f; +void func_80B8D6F0(MirRay* this, PlayState* play) { + Vec3f sp4C_lightShineDirection; + f32 temp_fv0; + f32 temp_fv0_2; + f32 temp_fv1_2; + MtxF* shieldMf; + Player* player; + + player = GET_PLAYER(play); + this->lightReflectionFactor = 0.0f; + shieldMf = &player->shieldMf; + if (MirRay_IsInConeFrustum(&this->coneFrustumCenterTop, &this->coneFrustumCenterBase, shieldMf->xw, shieldMf->yw, + shieldMf->zw, this->coneFrustumRadiusTop, this->coneFrustumRadiusBase)) { + temp_fv0 = sqrtf(SQ(shieldMf->zz) + (SQ(shieldMf->xz) + SQ(shieldMf->yz))); + if (temp_fv0 == 0.0f) { + this->shieldForwardNormalizeFactor = 1.0f; } else { - this->reflectRange = 1.0f / temp_f0; + this->shieldForwardNormalizeFactor = 1.0f / temp_fv0; } - - // If light beam is adirectional, always reflect, else only reflect if shield is pointing in correct direction - if (sMirRayData[this->actor.params].params & 1) { - this->reflectIntensity = 1.0f; + if (D_80B8E6F8[this->actor.params].unk1F & UNK1F_0) { + this->lightReflectionFactor = 1.0f; } else { - sp4C[0] = this->poolPt.x - this->sourcePt.x; - sp4C[1] = this->poolPt.y - this->sourcePt.y; - sp4C[2] = this->poolPt.z - this->sourcePt.z; - - temp_f2_2 = -shieldMtx->xz * sp4C[0] - shieldMtx->yz * sp4C[1] - shieldMtx->zz * sp4C[2]; - - if (temp_f2_2 < 0.0f) { - temp_f0_2 = sqrtf(SQ(sp4C[0]) + SQ(sp4C[1]) + SQ(sp4C[2])); - if ((temp_f0 != 0.0f) && (temp_f0_2 != 0.0f)) { - this->reflectIntensity = -temp_f2_2 / (temp_f0 * temp_f0_2); + sp4C_lightShineDirection.x = this->coneFrustumCenterBase.x - this->coneFrustumCenterTop.x; + sp4C_lightShineDirection.y = this->coneFrustumCenterBase.y - this->coneFrustumCenterTop.y; + sp4C_lightShineDirection.z = this->coneFrustumCenterBase.z - this->coneFrustumCenterTop.z; + sp4C_lightShineDirection = sp4C_lightShineDirection; //! FAKE + // The shield's forward direction is -z in model space + temp_fv1_2 = (-shieldMf->xz * sp4C_lightShineDirection.x) - (shieldMf->yz * sp4C_lightShineDirection.y) - + (sp4C_lightShineDirection.z * shieldMf->zz); + if (temp_fv1_2 < 0.0f) { + temp_fv0_2 = sqrtf(SQ(sp4C_lightShineDirection.z) + + (SQ(sp4C_lightShineDirection.x) + SQ(sp4C_lightShineDirection.y))); + if ((temp_fv0 != 0.0f) && (temp_fv0_2 != 0.0f)) { + this->lightReflectionFactor = -temp_fv1_2 / (temp_fv0 * temp_fv0_2); } } } } } -// Draws six images, one for each corner of the shield, by finding the intersection of a line segment from the corner -// perpendicular to the shield with the nearest collision (if any). -void MirRay_SetupReflectionPolys(MirRay* this, PlayState* play, MirRayShieldReflection* reflection) { - Player* player = GET_PLAYER(play); - MtxF* shieldMtx; +void func_80B8D8A0(MirRay* this, PlayState* play, struct_80B8D8A0* arg2) { + Player* player; // v0 + MtxF* shieldMf; // s0 s32 i; - Vec3f posA; - Vec3f posB; - Vec3f posResult; - CollisionPoly* outPoly; - f32 sp60[3]; - - shieldMtx = &player->shieldMf; - - sp60[0] = -((*shieldMtx).xz * this->reflectRange) * this->reflectIntensity * 400.0f; - sp60[1] = -((*shieldMtx).yz * this->reflectRange) * this->reflectIntensity * 400.0f; - sp60[2] = -((*shieldMtx).zz * this->reflectRange) * this->reflectIntensity * 400.0f; - + Vec3f reflectionOriginPos; // sp88 + Vec3f reflectionMaxPos; // sp7C + Vec3f sp70; // sp70 + CollisionPoly* sp6C; // sp6C + Vec3f forwards; // sp60 + + player = GET_PLAYER(play); + shieldMf = &player->shieldMf; + forwards.x = -(shieldMf->xz * this->shieldForwardNormalizeFactor) * this->lightReflectionFactor * 400.0f; + forwards.y = -(shieldMf->yz * this->shieldForwardNormalizeFactor) * this->lightReflectionFactor * 400.0f; + forwards.z = -(shieldMf->zz * this->shieldForwardNormalizeFactor) * this->lightReflectionFactor * 400.0f; for (i = 0; i < 6; i++) { - posA.x = ((*shieldMtx).xw + (this->shieldCorners[i].x * (*shieldMtx).xx)) + - (this->shieldCorners[i].y * (*shieldMtx).xy); - posA.y = ((*shieldMtx).yw + (this->shieldCorners[i].x * (*shieldMtx).yx)) + - (this->shieldCorners[i].y * (*shieldMtx).yy); - posA.z = ((*shieldMtx).zw + (this->shieldCorners[i].x * (*shieldMtx).zx)) + - (this->shieldCorners[i].y * (*shieldMtx).zy); - posB.x = sp60[0] + posA.x; - posB.y = sp60[1] + posA.y; - posB.z = sp60[2] + posA.z; - if (BgCheck_AnyLineTest1(&play->colCtx, &posA, &posB, &posResult, &outPoly, true)) { - reflection[i].reflectionPoly = outPoly; + if (!(&forwards) != 0) {} //! FAKE + //! FAKE (*shieldMf) + reflectionOriginPos.x = shieldMf->xw + (this->reflectionOriginModelPositions[i].x * shieldMf->xx) + + (this->reflectionOriginModelPositions[i].y * (*shieldMf).xy); + reflectionOriginPos.y = shieldMf->yw + (this->reflectionOriginModelPositions[i].x * shieldMf->yx) + + (this->reflectionOriginModelPositions[i].y * (*shieldMf).yy); + reflectionOriginPos.z = shieldMf->zw + (this->reflectionOriginModelPositions[i].x * shieldMf->zx) + + (this->reflectionOriginModelPositions[i].y * (*shieldMf).zy); + reflectionMaxPos.x = forwards.x + reflectionOriginPos.x; + reflectionMaxPos.y = forwards.y + reflectionOriginPos.y; + reflectionMaxPos.z = forwards.z + reflectionOriginPos.z; + if (BgCheck_AnyLineTest1(&play->colCtx, &reflectionOriginPos, &reflectionMaxPos, &sp70, &sp6C, 1) != 0) { + arg2[i].unk4C = sp6C; } else { - reflection[i].reflectionPoly = NULL; + arg2[i].unk4C = NULL; } } } -// Remove reflections that are in the same position and are sufficiently near to the same plane -void MirRay_RemoveSimilarReflections(MirRayShieldReflection* reflection) { +void func_80B8DA78(struct_80B8D8A0* arg0) { s32 i; s32 j; for (i = 0; i < 6; i++) { for (j = i + 1; j < 6; j++) { - if (reflection[i].reflectionPoly != NULL) { - if ((reflection[j].reflectionPoly != NULL) && - (ABS(reflection[i].reflectionPoly->normal.x - reflection[j].reflectionPoly->normal.x) < 100) && - (ABS(reflection[i].reflectionPoly->normal.y - reflection[j].reflectionPoly->normal.y) < 100) && - (ABS(reflection[i].reflectionPoly->normal.z - reflection[j].reflectionPoly->normal.z) < 100) && - (reflection[i].reflectionPoly->dist == reflection[j].reflectionPoly->dist)) { - reflection[j].reflectionPoly = NULL; - } + if ((arg0[i].unk4C != NULL) && (arg0[j].unk4C != NULL) && + (ABS(arg0[i].unk4C->normal.x - arg0[j].unk4C->normal.x) < 100) && + (ABS(arg0[i].unk4C->normal.y - arg0[j].unk4C->normal.y) < 100) && + (ABS(arg0[i].unk4C->normal.z - arg0[j].unk4C->normal.z) < 100) && + (arg0[i].unk4C->dist == arg0[j].unk4C->dist)) { + arg0[j].unk4C = NULL; } } } } -// Creates the reflected beam's collider (to interact with objects) and places and orients the shield images -void MirRay_ReflectedBeam(MirRay* this, PlayState* play, MirRayShieldReflection* reflection) { - Player* player = GET_PLAYER(play); - s32 i; - f32 temp_f0; - Vec3f vecB; - Vec3f vecD; - Vec3f sp118; - Vec3f sp10C; - Vec3f sp100; - Vec3f intersection; - f32 spE8[3]; - f32 polyNormal[3]; - MtxF* shieldMtx; - - shieldMtx = &player->shieldMf; - - spE8[0] = -(shieldMtx->xz * this->reflectRange) * this->reflectIntensity * 400.0f; - spE8[1] = -(shieldMtx->yz * this->reflectRange) * this->reflectIntensity * 400.0f; - spE8[2] = -(shieldMtx->zz * this->reflectRange) * this->reflectIntensity * 400.0f; - - vecB.x = shieldMtx->xw; - vecB.y = shieldMtx->yw; - vecB.z = shieldMtx->zw; - - vecD.x = spE8[0] + vecB.x; - vecD.y = spE8[1] + vecB.y; - vecD.z = spE8[2] + vecB.z; +void func_80B8DB7C(MirRay* this, PlayState* play, struct_80B8D8A0* arg2) { + MirRay* new_var4 = this; + float new_var2; + MtxF* shieldMf; // s1 + Vec3f originPos; // sp130 + Vec3f inFrontPos; // sp124 + Vec3f intersect; // sp118 + Vec3f originPosWithOffset; // sp10C + Vec3f inFrontPosWithOffset; // sp100 + Vec3f intersectWithOffset; // spF4 + Vec3f forwards; // spE8 + Vec3f spDC; // spDC + Player* player; // s3 + + player = GET_PLAYER(play); + shieldMf = &player->shieldMf; + forwards.x = -(shieldMf->xz * this->shieldForwardNormalizeFactor) * this->lightReflectionFactor * 400.0f; + new_var2 = 100.0f; + forwards.y = -(shieldMf->yz * this->shieldForwardNormalizeFactor) * new_var4->lightReflectionFactor * 400.0f; + forwards.z = -(shieldMf->zz * new_var4->shieldForwardNormalizeFactor) * new_var4->lightReflectionFactor * 400.0f; + // Where the mirror shield is located + originPos.x = shieldMf->xw; + originPos.y = shieldMf->yw; + originPos.z = shieldMf->zw; + // In front of the mirror shield + inFrontPos.x = forwards.x + originPos.x; + inFrontPos.y = forwards.y + originPos.y; + inFrontPos.z = forwards.z + originPos.z; { - Vec3f vecA; - Vec3f vecC; - - vecA.x = vecB.x + (shieldMtx->xx * 300.0f); - vecA.y = vecB.y + (shieldMtx->yx * 300.0f); - vecA.z = vecB.z + (shieldMtx->zx * 300.0f); - - vecC.x = vecD.x + (shieldMtx->xx * 300.0f); - vecC.y = vecD.y + (shieldMtx->yx * 300.0f); - vecC.z = vecD.z + (shieldMtx->zx * 300.0f); - - Collider_SetQuadVertices(&this->shieldRay, &vecA, &vecB, &vecC, &vecD); - + Vec3f upPos; // spCC + Vec3f upAndInFrontPos; // spC0 + s32 i; // s2 + struct_80B8D8A0* var_s0; // s0 + float new_var3; + f32* new_var; + f32 sp80; // sp80 + STACK_PAD(s32); + f32 temp_fv0; + + // Above the mirror shield origin + upPos.x = (shieldMf->xx * 300.0f) + originPos.x; + upPos.y = (shieldMf->yx * 300.0f) + originPos.y; + upPos.z = (shieldMf->zx * 300.0f) + originPos.z; + // Above and in front of the origin + upAndInFrontPos.x = (shieldMf->xx * 300.0f) + inFrontPos.x; + upAndInFrontPos.y = (shieldMf->yx * 300.0f) + inFrontPos.y; + upAndInFrontPos.z = (shieldMf->zx * 300.0f) + inFrontPos.z; + Collider_SetQuadVertices(&this->unk1AC, &upPos, &originPos, &upAndInFrontPos, &inFrontPos); for (i = 0; i < 6; i++) { - if (reflection[i].reflectionPoly != NULL) { - polyNormal[0] = COLPOLY_GET_NORMAL(reflection[i].reflectionPoly->normal.x); - polyNormal[1] = COLPOLY_GET_NORMAL(reflection[i].reflectionPoly->normal.y); - polyNormal[2] = COLPOLY_GET_NORMAL(reflection[i].reflectionPoly->normal.z); - - if (Math3D_LineSegVsPlane(polyNormal[0], polyNormal[1], polyNormal[2], - reflection[i].reflectionPoly->dist, &vecB, &vecD, &sp118, 1)) { - - reflection[i].pos.x = sp118.x; - reflection[i].pos.y = sp118.y; - reflection[i].pos.z = sp118.z; - - temp_f0 = sqrtf(SQ(sp118.x - vecB.x) + SQ(sp118.y - vecB.y) + SQ(sp118.z - vecB.z)); - - if (temp_f0 < (this->reflectIntensity * 600.0f)) { - reflection[i].opacity = 200; + new_var = &spDC.x; //! FAKE + var_s0 = &arg2[i]; + if (var_s0->unk4C != NULL) { + if (&forwards) {} //! FAKE + spDC.x = COLPOLY_GET_NORMAL(var_s0->unk4C->normal.x); + spDC.y = COLPOLY_GET_NORMAL(var_s0->unk4C->normal.y); + spDC.z = COLPOLY_GET_NORMAL(var_s0->unk4C->normal.z); + if (Math3D_LineSegVsPlane(*new_var, spDC.y, spDC.z, var_s0->unk4C->dist, &originPos, &inFrontPos, + &intersect, true)) { + var_s0->reflectionPos.x = intersect.x; + var_s0->reflectionPos.y = intersect.y; + var_s0->reflectionPos.z = intersect.z; + temp_fv0 = sqrtf(SQ(intersect.x - originPos.x) + SQ(intersect.y - originPos.y) + + SQ(intersect.z - originPos.z)); + //! @bug temp_fv0 is at most + //! norm(sp124_inFront - sp130_origin) = norm(spE8_forwards) = this->lightReflectionFactor * 400 + //! so this condition always passes. This logic was probably meant to fade the reflections with + //! distance. (TODO test in-game) + if (temp_fv0 < (this->lightReflectionFactor * 600.0f)) { + var_s0->unk50 = 200; } else { - reflection[i].opacity = (s32)(800.0f - temp_f0); + var_s0->unk50 = (u8)(s32)(800.0f - temp_fv0); } - 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.zw = 0.0f; - - 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; - - if (Math3D_LineSegVsPlane(polyNormal[0], polyNormal[1], polyNormal[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; + // The rest of the function computes a transformation that transforms the XY plane (corresponding to + // the reflection in model space) into the surface plane. It does so by computing the same + // intersection as above but with an offset in the x direction, which gives the transformation for + // the x axis, then the same in the y direction. + + originPosWithOffset.x = (shieldMf->xx * new_var2) + originPos.x; + originPosWithOffset.y = (shieldMf->yx * new_var2) + originPos.y; + originPosWithOffset.z = (shieldMf->zx * 100.0f) + originPos.z; + inFrontPosWithOffset.x = (forwards.x * 4.0f) + originPosWithOffset.x; + inFrontPosWithOffset.y = (forwards.y * 4.0f) + originPosWithOffset.y; + inFrontPosWithOffset.z = (forwards.z * 4.0f) + originPosWithOffset.z; + var_s0->reflectionTransform.xx = var_s0->reflectionTransform.yy = var_s0->reflectionTransform.zz = + var_s0->reflectionTransform.ww = 1.0f; + + //! FAKE + sp80 = var_s0->reflectionTransform.zw = 0.0f; + new_var3 = var_s0->reflectionTransform.xz = var_s0->reflectionTransform.yz = + var_s0->reflectionTransform.wz = var_s0->reflectionTransform.xw = + var_s0->reflectionTransform.yw = sp80; + var_s0->reflectionTransform.yx = var_s0->reflectionTransform.zx = var_s0->reflectionTransform.wx = + var_s0->reflectionTransform.xy = var_s0->reflectionTransform.zy = + var_s0->reflectionTransform.wy = new_var3; + if (Math3D_LineSegVsPlane(spDC.x, spDC.y, spDC.z, var_s0->unk4C->dist, &originPosWithOffset, + &inFrontPosWithOffset, &intersectWithOffset, true)) { + do { + } while (0); //! FAKE + var_s0->reflectionTransform.xx = intersectWithOffset.x - intersect.x; + var_s0->reflectionTransform.yx = intersectWithOffset.y - intersect.y; + var_s0->reflectionTransform.zx = intersectWithOffset.z - intersect.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(polyNormal[0], polyNormal[1], polyNormal[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; + originPosWithOffset.x = (shieldMf->xy * 100.0f) + originPos.x; + originPosWithOffset.y = (shieldMf->yy * 100.0f) + originPos.y; + originPosWithOffset.z = (shieldMf->zy * 100.0f) + originPos.z; + inFrontPosWithOffset.x = (forwards.x * 4.0f) + originPosWithOffset.x; + inFrontPosWithOffset.y = (forwards.y * 4.0f) + originPosWithOffset.y; + inFrontPosWithOffset.z = (forwards.z * 4.0f) + originPosWithOffset.z; + if (Math3D_LineSegVsPlane(spDC.x, spDC.y, spDC.z, var_s0->unk4C->dist, &originPosWithOffset, + &inFrontPosWithOffset, &intersectWithOffset, true)) { + if (!intersect.z) {} //! FAKE + var_s0->reflectionTransform.xy = intersectWithOffset.x - intersect.x; + var_s0->reflectionTransform.yy = intersectWithOffset.y - intersect.y; + var_s0->reflectionTransform.zy = intersectWithOffset.z - intersect.z; } } else { - reflection[i].reflectionPoly = NULL; + var_s0->unk4C = NULL; } } } @@ -486,113 +580,106 @@ void MirRay_ReflectedBeam(MirRay* this, PlayState* play, MirRayShieldReflection* void MirRay_Draw(Actor* thisx, PlayState* play) { MirRay* this = (MirRay*)thisx; - Player* player = GET_PLAYER(play); s32 i; - MirRayShieldReflection reflection[6]; STACK_PAD(s32); + struct_80B8D8A0 sp7C[6]; + Player* player; - this->reflectIntensity = 0.0f; - if ((D_80B8E670 == 0) && !this->unLit && Player_HasMirrorShieldSetToDraw(play)) { + player = GET_PLAYER(play); + this->lightReflectionFactor = 0.0f; + if (!D_80B8E670 && (this->unk2AE == 0) && Player_HasMirrorShieldSetToDraw(play)) { Matrix_Mult(&player->shieldMf, MTXMODE_NEW); - MirRay_SetIntensity(this, play); - if (!(this->reflectIntensity <= 0.0f)) { + func_80B8D6F0(this, play); + if (!(this->lightReflectionFactor <= 0.0f)) { OPEN_DISPS(play->state.gfxCtx, "../z_mir_ray.c", 966); - Gfx_SetupDL_25Xlu(play->state.gfxCtx); - Matrix_Scale(1.0f, 1.0f, this->reflectIntensity * 5.0f, MTXMODE_APPLY); + Matrix_Scale(1.0f, 1.0f, this->lightReflectionFactor * 5.0f, MTXMODE_APPLY); MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx, "../z_mir_ray.c", 972); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 150, (s32)(this->reflectIntensity * 100.0f) & 0xFF); - gSPDisplayList(POLY_XLU_DISP++, gShieldBeamGlowDL); - MirRay_SetupReflectionPolys(this, play, reflection); - MirRay_RemoveSimilarReflections(reflection); - MirRay_ReflectedBeam(this, play, reflection); - - if (reflection[0].reflectionPoly == NULL) { - reflection[0].opacity = 0; + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x00, 255, 255, 150, + (u8)(s32)(this->lightReflectionFactor * 100.0f)); + gSPDisplayList(POLY_XLU_DISP++, object_mir_ray_000C50_DL); + func_80B8D8A0(this, play, sp7C); + func_80B8DA78(sp7C); + func_80B8DB7C(this, play, sp7C); + if (sp7C[0].unk4C == NULL) { + sp7C[0].unk50 = 0; } - for (i = 1; i < 6; i++) { - if (reflection[i].reflectionPoly != NULL) { - if (reflection[0].opacity < reflection[i].opacity) { - reflection[0].opacity = reflection[i].opacity; + for (i = 1; i < ARRAY_COUNT(sp7C); i++) { + if (sp7C[i].unk4C != NULL) { + if (sp7C[0].unk50 < sp7C[i].unk50) { + sp7C[0].unk50 = sp7C[i].unk50; } } } - for (i = 0; i < 6; i++) { - if (reflection[i].reflectionPoly != NULL) { - Matrix_Translate(reflection[i].pos.x, reflection[i].pos.y, reflection[i].pos.z, MTXMODE_NEW); + for (i = 0; i < ARRAY_COUNT(sp7C); i++) { + if (sp7C[i].unk4C != NULL) { + Matrix_Translate(sp7C[i].reflectionPos.x, sp7C[i].reflectionPos.y, sp7C[i].reflectionPos.z, + MTXMODE_NEW); Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); - Matrix_Mult(&reflection[i].mtx, MTXMODE_APPLY); + Matrix_Mult(&sp7C[i].reflectionTransform, MTXMODE_APPLY); MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx, "../z_mir_ray.c", 1006); gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_DECAL2); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 150, reflection[0].opacity); - gSPDisplayList(POLY_XLU_DISP++, gShieldBeamImageDL); + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x00, 255, 255, 150, sp7C[0].unk50); + gSPDisplayList(POLY_XLU_DISP++, object_mir_ray_0000B0_DL); } } - - D_80B8E670 = 1; - + D_80B8E670 = true; CLOSE_DISPS(play->state.gfxCtx, "../z_mir_ray.c", 1027); } } } -// Computes if the Point (pointx, pointy, pointz) lies within the right conical frustum with one end centred at vecA -// with radius radiusA, the other at vecB with radius radiusB -s32 MirRay_CheckInFrustum(Vec3f* vecA, Vec3f* vecB, f32 pointx, f32 pointy, f32 pointz, s16 radiusA, s16 radiusB) { - f32 coneRadius; - f32 closestPtx; - f32 closestPty; - f32 closestPtz; - Vec3f vecdiff; - f32 dist; - Vec3f sp5C; - Vec3f sp50; - Vec3f sp44; - - vecdiff.x = vecB->x - vecA->x; - vecdiff.y = vecB->y - vecA->y; - vecdiff.z = vecB->z - vecA->z; - - dist = SQ(vecdiff.x) + SQ(vecdiff.y) + SQ(vecdiff.z); - - if (dist == 0.0f) { - return 0; +/** + * Checks if coordinates (x,y,z) lie inside the cone frustum defined by the given top face (a disk centered on + * `centerTop` with radius `radiusTop`) and base face (a disk centered on `centerBase` with radius `radiusBase`). + */ +s32 MirRay_IsInConeFrustum(Vec3f* centerTop, Vec3f* centerBase, f32 x, f32 y, f32 z, s16 radiusTop, s16 radiusBase) { + f32 f; + f32 xProj; + f32 yProj; + f32 zProj; + Vec3f hVec; + f32 radiusLocal; + Vec3f hVec2; + Vec3f topToPos; + Vec3f baseToPos; + + hVec.x = centerBase->x - centerTop->x; + hVec.y = centerBase->y - centerTop->y; + hVec.z = centerBase->z - centerTop->z; + f = SQ(hVec.x) + SQ(hVec.y) + SQ(hVec.z); + if (f == 0.0f) { + return false; } - - dist = - (((pointx - vecA->x) * vecdiff.x) + ((pointy - vecA->y) * vecdiff.y) + ((pointz - vecA->z) * vecdiff.z)) / dist; - - // Closest point on line A-B to Point - closestPtx = (vecdiff.x * dist) + vecA->x; - closestPty = (vecdiff.y * dist) + vecA->y; - closestPtz = (vecdiff.z * dist) + vecA->z; - - // Diameter of the double cone on the perpendicular plane through the closest point - coneRadius = ((radiusB - radiusA) * dist) + radiusA; - - // If the Point is within the bounding double cone, check if it is in the frustum by checking whether it is between - // the bounding planes - if ((SQ(closestPtx - pointx) + SQ(closestPty - pointy) + SQ(closestPtz - pointz)) <= SQ(coneRadius)) { - - // Stores the vector difference again - Math_Vec3f_Diff(vecB, vecA, &sp5C); - - sp50.x = pointx - vecA->x; - sp50.y = pointy - vecA->y; - sp50.z = pointz - vecA->z; - - if (Math3D_Cos(&sp5C, &sp50) < 0.0f) { - return 0; + f = (((x - centerTop->x) * hVec.x) + ((y - centerTop->y) * hVec.y) + ((z - centerTop->z) * hVec.z)) / f; + // Project (x,y,z) onto the top-base line + xProj = (hVec.x * f) + centerTop->x; + yProj = (hVec.y * f) + centerTop->y; + zProj = (hVec.z * f) + centerTop->z; + // Lerp radius to get local radius + radiusLocal = ((radiusBase - radiusTop) * f) + radiusTop; + // If the point lies in the infinitely extended double cone containing the frustum of interest + if ((SQ(xProj - x) + SQ(yProj - y) + SQ(zProj - z)) <= SQ(radiusLocal)) { + Math_Vec3f_Diff(centerBase, centerTop, &hVec2); + + topToPos.x = x - centerTop->x; + topToPos.y = y - centerTop->y; + topToPos.z = z - centerTop->z; + // If the point lies above the top face + if (Math3D_Cos(&hVec2, &topToPos) < 0.0f) { + return false; } - sp44.x = pointx - vecB->x; - sp44.y = pointy - vecB->y; - sp44.z = pointz - vecB->z; - - if (Math3D_Cos(&sp5C, &sp44) > 0.0f) { - return 0; + baseToPos.x = x - centerBase->x; + baseToPos.y = y - centerBase->y; + baseToPos.z = z - centerBase->z; + // If the point lies below the base face + if (Math3D_Cos(&hVec2, &baseToPos) > 0.0f) { + return false; } - return 1; + + return true; + } else { + return false; } - return 0; } 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 ddc4a4708dc..7e000c9ef3c 100644 --- a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.h +++ b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.h @@ -7,42 +7,24 @@ struct MirRay; -typedef struct MirRayDataEntry { - /* 0x00 */ Vec3s sourcePoint; - /* 0x06 */ Vec3s poolPoint; // point at center of light pool on floor for windows and BigMirror, same as source point for Cobra Mirror - /* 0x0C */ s16 sourceEndRadius; // Radius of beam frustum at the source end - /* 0x0E */ s16 poolEndRadius; // Radius of beam frustum at the pool end - /* 0x10 */ f32 unk_10; // placement of collider center along beam - /* 0x14 */ s16 unk_14; // collider radius before scaled - /* 0x16 */ s16 lgtPtMaxRad; // light point max radius - /* 0x18 */ f32 unk_18; // placement of light point between source and reflection point (pool point for windows, player for mirrors) - /* 0x1C */ Color_RGB8 color; - /* 0x1F */ u8 params; -} MirRayDataEntry; // size = 0x20 - -typedef struct MirRayShieldReflection { - /* 0x00 */ Vec3f pos; - /* 0x0C */ MtxF mtx; - /* 0x4C */ struct CollisionPoly* reflectionPoly; - /* 0x50 */ u8 opacity; -} MirRayShieldReflection; // size = 0x54 - typedef struct MirRay { - /* 0x0000 */ Actor actor; - /* 0x014C */ ColliderJntSph colliderJntSph; - /* 0x016C */ ColliderJntSphElement colliderJntSphElements[1]; - /* 0x01AC */ ColliderQuad shieldRay; - /* 0x022C */ f32 reflectIntensity; // Reflection occurs if it is positive, brightness depends on it - /* 0x0230 */ Vec3f shieldCorners[6]; - /* 0x0278 */ f32 reflectRange; - /* 0x027C */ Vec3f sourcePt; - /* 0x0288 */ Vec3f poolPt; - /* 0x0294 */ s16 sourceEndRad; - /* 0x0296 */ s16 poolEndRad; - /* 0x0298 */ s16 lightPointRad; - /* 0x029C */ LightNode* lightNode; - /* 0x02A0 */ LightInfo lightInfo; - /* 0x02AE */ u8 unLit; // Conditioned on. set in Cobra? + /* 0x000 */ Actor actor; + /* 0x14C */ ColliderJntSph unk14C; + /* 0x16C */ ColliderJntSphElement unk16C; + /* 0x1AC */ ColliderQuad unk1AC; + /* 0x22C */ f32 lightReflectionFactor; + /* 0x230 */ Vec3f reflectionOriginModelPositions[6]; + /* 0x278 */ f32 shieldForwardNormalizeFactor; + /* 0x27C */ Vec3f coneFrustumCenterTop; + /* 0x288 */ Vec3f coneFrustumCenterBase; + /* 0x294 */ s16 coneFrustumRadiusTop; + /* 0x296 */ s16 coneFrustumRadiusBase; + /* 0x298 */ s16 pointLightRadius; + /* 0x29A */ char pad29A[2]; + /* 0x29C */ LightNode* lightNode; + /* 0x2A0 */ LightInfo lightInfo; + /* 0x2AE */ u8 unk2AE; + /* 0x2AF */ char pad2AF[1]; } MirRay; // size = 0x02B0 #endif 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 1741cdbc35b..319ba0621fd 100644 --- a/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c +++ b/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c @@ -45,18 +45,18 @@ void ObjBlockstop_Destroy(Actor* thisx, PlayState* play) { void ObjBlockstop_Update(Actor* thisx, PlayState* play) { ObjBlockstop* this = (ObjBlockstop*)thisx; - DynaPolyActor* dynaPolyActor; + DynaPolyActor* dynaActor; Vec3f sp4C; s32 bgId; STACK_PAD(s32); if (BgCheck_EntityLineTest2(&play->colCtx, &this->actor.home.pos, &this->actor.world.pos, &sp4C, &this->actor.floorPoly, false, false, true, true, &bgId, &this->actor)) { - dynaPolyActor = DynaPoly_GetActor(&play->colCtx, bgId); + dynaActor = DynaPoly_GetActor(&play->colCtx, bgId); - if (dynaPolyActor != NULL && dynaPolyActor->actor.id == ACTOR_OBJ_OSHIHIKI) { - if (PARAMS_GET_U(dynaPolyActor->actor.params, 0, 4) == PUSHBLOCK_HUGE_START_ON || - PARAMS_GET_U(dynaPolyActor->actor.params, 0, 4) == PUSHBLOCK_HUGE_START_OFF) { + if (dynaActor != NULL && dynaActor->actor.id == ACTOR_OBJ_OSHIHIKI) { + if (PARAMS_GET_U(dynaActor->actor.params, 0, 4) == PUSHBLOCK_HUGE_START_ON || + PARAMS_GET_U(dynaActor->actor.params, 0, 4) == PUSHBLOCK_HUGE_START_OFF) { Sfx_PlaySfxCentered(NA_SE_SY_CORRECT_CHIME); } else { Sfx_PlaySfxCentered(NA_SE_SY_TRE_BOX_APPEAR); diff --git a/src/overlays/actors/ovl_Obj_Dekujr/z_obj_dekujr.c b/src/overlays/actors/ovl_Obj_Dekujr/z_obj_dekujr.c index e7dbae22abf..321286f43db 100644 --- a/src/overlays/actors/ovl_Obj_Dekujr/z_obj_dekujr.c +++ b/src/overlays/actors/ovl_Obj_Dekujr/z_obj_dekujr.c @@ -62,7 +62,7 @@ void ObjDekujr_Init(Actor* thisx, PlayState* play) { if (gSaveContext.save.cutsceneIndex < CS_INDEX_0) { if (!LINK_IS_ADULT) { - Actor_Kill(thisx); + Actor_Kill(&this->actor); return; } this->unk_19C = 2; @@ -72,15 +72,15 @@ void ObjDekujr_Init(Actor* thisx, PlayState* play) { this->unk_19B = 1; } if (!CHECK_QUEST_ITEM(QUEST_MEDALLION_FOREST)) { - Actor_Kill(thisx); + Actor_Kill(&this->actor); } else { - ActorShape_Init(&thisx->shape, 0.0f, NULL, 0.0f); + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); Collider_InitCylinder(play, &this->collider); - sCylinderInit.base.actor = thisx; + sCylinderInit.base.actor = thisx; // thisx required to match here Collider_SetCylinderToActor(play, &this->collider, &sCylinderInit); - thisx->colChkInfo.mass = MASS_IMMOVABLE; - thisx->textId = func_80037C30(play, 0xF); - Actor_SetScale(thisx, 0.4f); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.textId = func_80037C30(play, 0xF); + Actor_SetScale(&this->actor, 0.4f); } } 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 a12596be909..6bfcf91d1e5 100644 --- a/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c +++ b/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c @@ -147,7 +147,7 @@ void ObjLift_Destroy(Actor* thisx, PlayState* play) { void ObjLift_SetupWait(ObjLift* this) { this->timer = sFallTimerDurations[PARAMS_GET_U(this->dyna.actor.params, 8, 3)]; - ObjLift_SetupAction(this, ObjLift_Wait); + ObjLift_SetupAction(this, &ObjLift_Wait); } void ObjLift_Wait(ObjLift* this, PlayState* play) { 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 f4b5eeb73b4..3382b8635a5 100644 --- a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c +++ b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c @@ -160,13 +160,13 @@ void ObjOshihiki_ResetFloors(ObjOshihiki* this) { } ObjOshihiki* ObjOshihiki_GetBlockUnder(ObjOshihiki* this, PlayState* play) { - DynaPolyActor* dynaPolyActor; + DynaPolyActor* dyna; if ((this->floorBgIds[this->highestFloor] != BGCHECK_SCENE) && (fabsf(this->dyna.actor.floorHeight - this->dyna.actor.world.pos.y) < 0.001f)) { - dynaPolyActor = DynaPoly_GetActor(&play->colCtx, this->floorBgIds[this->highestFloor]); - if ((dynaPolyActor != NULL) && (dynaPolyActor->actor.id == ACTOR_OBJ_OSHIHIKI)) { - return (ObjOshihiki*)dynaPolyActor; + dyna = DynaPoly_GetActor(&play->colCtx, this->floorBgIds[this->highestFloor]); + if ((dyna != NULL) && (dyna->actor.id == ACTOR_OBJ_OSHIHIKI)) { + return (ObjOshihiki*)dyna; } } return NULL; @@ -388,7 +388,7 @@ s32 ObjOshihiki_CheckFloor(ObjOshihiki* this, PlayState* play) { } s32 ObjOshihiki_CheckGround(ObjOshihiki* this, PlayState* play) { - if (this->dyna.actor.world.pos.y <= BGCHECK_Y_MIN + 10.0f) { + if (this->dyna.actor.world.pos.y <= -31990.0f) { PRINTF(T("Warning : 押し引きブロック落ちすぎた(%s %d)(arg_data 0x%04x)\n", "Warning : Push/pull block fell too much (%s %d)(arg_data 0x%04x)\n"), "../z_obj_oshihiki.c", 809, this->dyna.actor.params); @@ -495,7 +495,7 @@ void ObjOshihiki_SetupOnActor(ObjOshihiki* this, PlayState* play) { void ObjOshihiki_OnActor(ObjOshihiki* this, PlayState* play) { s32 bgId; Player* player = GET_PLAYER(play); - DynaPolyActor* dynaPolyActor; + DynaPolyActor* dynaActor; this->stateFlags |= PUSHBLOCK_ON_ACTOR; Actor_MoveXZGravity(&this->dyna.actor); @@ -505,13 +505,13 @@ void ObjOshihiki_OnActor(ObjOshihiki* this, PlayState* play) { if (bgId == BGCHECK_SCENE) { ObjOshihiki_SetupOnScene(this, play); } else { - dynaPolyActor = DynaPoly_GetActor(&play->colCtx, bgId); - if (dynaPolyActor != NULL) { - DynaPolyActor_SetActorOnTop(dynaPolyActor); - DynaPolyActor_SetSwitchPressed(dynaPolyActor); + dynaActor = DynaPoly_GetActor(&play->colCtx, bgId); + if (dynaActor != NULL) { + DynaPolyActor_SetActorOnTop(dynaActor); + DynaPolyActor_SetSwitchPressed(dynaActor); if ((this->timer <= 0) && (fabsf(this->dyna.unk_150) > 0.001f)) { - if (ObjOshihiki_StrongEnough(this) && ObjOshihiki_NoSwitchPress(this, dynaPolyActor, play) && + if (ObjOshihiki_StrongEnough(this) && ObjOshihiki_NoSwitchPress(this, dynaActor, play) && !ObjOshihiki_CheckWall(play, this->dyna.unk_158, this->dyna.unk_150, this)) { this->direction = this->dyna.unk_150; @@ -533,11 +533,11 @@ void ObjOshihiki_OnActor(ObjOshihiki* this, PlayState* play) { if (bgId == BGCHECK_SCENE) { ObjOshihiki_SetupFall(this, play); } else { - dynaPolyActor = DynaPoly_GetActor(&play->colCtx, bgId); + dynaActor = DynaPoly_GetActor(&play->colCtx, bgId); - if ((dynaPolyActor != NULL) && (dynaPolyActor->transformFlags & DYNA_TRANSFORM_POS)) { - DynaPolyActor_SetActorOnTop(dynaPolyActor); - DynaPolyActor_SetSwitchPressed(dynaPolyActor); + if ((dynaActor != NULL) && (dynaActor->transformFlags & DYNA_TRANSFORM_POS)) { + DynaPolyActor_SetActorOnTop(dynaActor); + DynaPolyActor_SetSwitchPressed(dynaActor); this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight; } else { ObjOshihiki_SetupFall(this, play); diff --git a/src/overlays/actors/ovl_Obj_Timeblock/z_obj_timeblock.c b/src/overlays/actors/ovl_Obj_Timeblock/z_obj_timeblock.c index fb9ca98e5b2..b27c960da24 100644 --- a/src/overlays/actors/ovl_Obj_Timeblock/z_obj_timeblock.c +++ b/src/overlays/actors/ovl_Obj_Timeblock/z_obj_timeblock.c @@ -32,16 +32,15 @@ void ObjTimeblock_Destroy(Actor* thisx, PlayState* play); void ObjTimeblock_Update(Actor* thisx, PlayState* play); void ObjTimeblock_Draw(Actor* thisx, PlayState* play); -void ObjTimeblock_SetupNormal(ObjTimeblock* this); -void ObjTimeblock_SetupAltBehaviorVisible(ObjTimeblock* this); -void ObjTimeblock_SetupAltBehaviourNotVisible(ObjTimeblock* this); - -s32 ObjTimeblock_WaitForOcarina(ObjTimeblock* this, PlayState* play); -s32 ObjTimeblock_WaitForSong(ObjTimeblock* this, PlayState* play); -void ObjTimeblock_DoNothing(ObjTimeblock* this, PlayState* play); -void ObjTimeblock_Normal(ObjTimeblock* this, PlayState* play); -void ObjTimeblock_AltBehaviorVisible(ObjTimeblock* this, PlayState* play); -void ObjTimeblock_AltBehaviourNotVisible(ObjTimeblock* this, PlayState* play); +s32 func_80BA040C(ObjTimeblock*, PlayState*); +s32 func_80BA0480(ObjTimeblock*, PlayState*); +void func_80BA0508(ObjTimeblock* arg0, PlayState* arg1); +void func_80BA0514(ObjTimeblock* this); +void func_80BA0524(ObjTimeblock* this, PlayState* play); +void func_80BA0758(ObjTimeblock* this); +void func_80BA0768(ObjTimeblock* this, PlayState* play); +void func_80BA083C(ObjTimeblock* this); +void func_80BA084C(ObjTimeblock* this, PlayState* play); ActorProfile Obj_Timeblock_Profile = { /**/ ACTOR_OBJ_TIMEBLOCK, @@ -54,314 +53,319 @@ ActorProfile Obj_Timeblock_Profile = { /**/ ObjTimeblock_Update, /**/ ObjTimeblock_Draw, }; - -typedef struct ObjTimeblockSizeOptions { - /* 0x00 */ f32 scale; - /* 0x04 */ f32 height; - /* 0x08 */ s16 demoEffectParams; -} ObjTimeblockSizeOptions; // size = 0x0C - -static ObjTimeblockSizeOptions sSizeOptions[] = { - { 1.0, 60.0, 0x0018 }, - { 0.60, 40.0, 0x0019 }, -}; - -static f32 sRanges[] = { 60.0, 100.0, 140.0, 180.0, 220.0, 260.0, 300.0, 300.0 }; - -static InitChainEntry sInitChain[] = { +typedef struct struct_80BA0AF0 { + f32 unk0; + f32 unk4; + s16 unk8; +} struct_80BA0AF0; +struct_80BA0AF0 D_80BA0AF0[2] = { { 1.0f, 60.0f, 0x18 }, { 0.6f, 40.0f, 0x19 } }; +static f32 D_80BA0B08[8] = { 60.0f, 100.0f, 140.0f, 180.0f, 220.0f, 260.0f, 300.0f, 300.0f }; +static InitChainEntry sInitChain[4] = { ICHAIN_U8(attentionRangeType, ATTENTION_RANGE_2, ICHAIN_CONTINUE), ICHAIN_F32(cullingVolumeDistance, 1800, ICHAIN_CONTINUE), ICHAIN_F32(cullingVolumeScale, 300, ICHAIN_CONTINUE), ICHAIN_F32(cullingVolumeDownward, 1500, ICHAIN_STOP), }; - -static Color_RGB8 sPrimColors[] = { - { 100, 120, 140 }, { 80, 140, 200 }, { 100, 150, 200 }, { 100, 200, 240 }, - { 80, 110, 140 }, { 70, 160, 225 }, { 80, 100, 130 }, { 100, 110, 190 }, +static Color_RGB8 D_80BA0B38[8] = { + { 0x64, 0x78, 0x8C }, { 0x50, 0x8C, 0xC8 }, { 0x64, 0x96, 0xC8 }, { 0x64, 0xC8, 0xF0 }, + { 0x50, 0x6E, 0x8C }, { 0x46, 0xA0, 0xE1 }, { 0x50, 0x64, 0x82 }, { 0x64, 0x6E, 0xBE }, }; -u32 ObjTimeblock_CalculateIsVisible(ObjTimeblock* this) { +s32 func_80B9FFA0(ObjTimeblock* this) { + s32 var_a1; + STACK_PAD(s32); + if (!PARAMS_GET_U(this->dyna.actor.params, 10, 1)) { - if (this->unk_177 == 0) { - return this->unk_175; + if (this->unk177 == 0) { + return this->unk175; + } + if (PARAMS_GET_U(this->dyna.actor.params, 15, 1)) { + var_a1 = 1; + } else { + var_a1 = 0; + } + if (this->unk177 == 1) { + return this->unk174 ^ var_a1; } else { - u8 temp = PARAMS_GET_U(this->dyna.actor.params, 15, 1) ? true : false; + s32 var_v1_2; - if (this->unk_177 == 1) { - return this->unk_174 ^ temp; + if (LINK_AGE_IN_YEARS == 5) { + var_v1_2 = 1; } else { - u8 linkIsChild = (LINK_AGE_IN_YEARS == YEARS_CHILD) ? true : false; - - return this->unk_174 ^ temp ^ linkIsChild; + var_v1_2 = 0; } + return this->unk174 ^ var_a1 ^ var_v1_2; } - } else { - return (PARAMS_GET_U(this->dyna.actor.params, 15, 1) ? true : false) ^ this->unk_174; } + return (PARAMS_GET_U(this->dyna.actor.params, 15, 1) ? 1 : 0) ^ this->unk174; } -void ObjTimeblock_SpawnDemoEffect(ObjTimeblock* this, PlayState* play) { +void func_80BA0058(ObjTimeblock* this, PlayState* play) { 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, - sSizeOptions[PARAMS_GET_U(this->dyna.actor.params, 8, 1)].demoEffectParams); + this->dyna.actor.world.pos.z, 0, 0, 0, (D_80BA0AF0[PARAMS_GET_U(this->dyna.actor.params, 8, 1)].unk8)); } -void ObjTimeblock_ToggleSwitchFlag(PlayState* play, s32 flag) { - if (Flags_GetSwitch(play, flag)) { - Flags_UnsetSwitch(play, flag); - } else { - Flags_SetSwitch(play, flag); +void func_80BA00CC(PlayState* play, s32 arg1) { + if (Flags_GetSwitch(play, arg1) != 0) { + Flags_UnsetSwitch(play, arg1); + return; } + Flags_SetSwitch(play, arg1); } void ObjTimeblock_Init(Actor* thisx, PlayState* play) { ObjTimeblock* this = (ObjTimeblock*)thisx; STACK_PAD(s32); - CollisionHeader* colHeader = NULL; + CollisionHeader* sp2C; + sp2C = NULL; DynaPolyActor_Init(&this->dyna, 0); this->dyna.actor.world.rot.z = this->dyna.actor.shape.rot.z = 0; - - CollisionHeader_GetVirtual(&gSongOfTimeBlockCol, &colHeader); - - this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); - + CollisionHeader_GetVirtual(&gSongOfTimeBlockCol, &sp2C); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, sp2C); Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - Actor_SetScale(&this->dyna.actor, sSizeOptions[PARAMS_GET_U(this->dyna.actor.params, 8, 1)].scale); - + Actor_SetScale(&this->dyna.actor, D_80BA0AF0[PARAMS_GET_U(this->dyna.actor.params, 8, 1)].unk0); if (PARAMS_GET_U(this->dyna.actor.params, 6, 1)) { - this->unk_177 = 0; + this->unk177 = 0; + } else if (PARAMS_GET_U(this->dyna.actor.params, 0, 6) < 0x38) { + this->unk177 = 2; } else { - this->unk_177 = (PARAMS_GET_U(this->dyna.actor.params, 0, 6) < 0x38) ? 2 : 1; + this->unk177 = 1; } - - this->songObserverFunc = ObjTimeblock_WaitForOcarina; - - Actor_SetFocus(&this->dyna.actor, sSizeOptions[PARAMS_GET_U(this->dyna.actor.params, 8, 1)].height); - - this->unk_174 = (Flags_GetSwitch(play, PARAMS_GET_U(this->dyna.actor.params, 0, 6))) ? true : false; - this->unk_175 = PARAMS_GET_U(this->dyna.actor.params, 15, 1) ? true : false; - this->isVisible = ObjTimeblock_CalculateIsVisible(this); - - if (!PARAMS_GET_U(this->dyna.actor.params, 10, 1)) { - ObjTimeblock_SetupNormal(this); - } else if (this->isVisible) { - ObjTimeblock_SetupAltBehaviorVisible(this); + this->unk168 = func_80BA040C; + Actor_SetFocus(&this->dyna.actor, D_80BA0AF0[PARAMS_GET_U(this->dyna.actor.params, 8, 1)].unk4); + if (Flags_GetSwitch(play, PARAMS_GET_U(this->dyna.actor.params, 0, 6))) { + this->unk174 = 1; } else { - ObjTimeblock_SetupAltBehaviourNotVisible(this); + this->unk174 = 0; } - - PRINTF(T("時のブロック ( %04xH save:%d color:%d range:%d move:%d)\n", - "Time Block ( %04xH save:%d color:%d range:%d move:%d)\n"), - (u16)this->dyna.actor.params, this->unk_177, this->dyna.actor.home.rot.z & 7, - PARAMS_GET_U(this->dyna.actor.params, 11, 3), PARAMS_GET_U(this->dyna.actor.params, 10, 1)); + if (PARAMS_GET_U(this->dyna.actor.params, 15, 1)) { + this->unk175 = 1; + } else { + this->unk175 = 0; + } + this->unk178 = func_80B9FFA0(this); + if (PARAMS_GET_U(this->dyna.actor.params, 10, 1) == 0) { + func_80BA0514(this); + } else if (this->unk178 != 0) { + func_80BA0758(this); + } else { + func_80BA083C(this); + } + PRINTF("時のブロック ( %04xH save:%d color:%d range:%d move:%d)\n", this->dyna.actor.params & 0xFFFF, + this->unk177, this->dyna.actor.home.rot.z & 7, PARAMS_GET_U(this->dyna.actor.params, 11, 3), + PARAMS_GET_U(this->dyna.actor.params, 10, 1)); } void ObjTimeblock_Destroy(Actor* thisx, PlayState* play) { - STACK_PAD(s32); ObjTimeblock* this = (ObjTimeblock*)thisx; DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } -u8 ObjTimeblock_PlayerIsInRange(ObjTimeblock* this, PlayState* play) { - if (this->isVisible && DynaPolyActor_IsPlayerAbove(&this->dyna)) { - return false; - } +s32 func_80BA032C(ObjTimeblock* this, PlayState* play) { + Vec3f sp1C; + f32 temp_fv1; - if (this->dyna.actor.xzDistToPlayer <= sRanges[PARAMS_GET_U(this->dyna.actor.params, 11, 3)]) { - Vec3f playerRelativePos; - f32 blockSize; - - Actor_WorldToActorCoords(&this->dyna.actor, &playerRelativePos, &GET_PLAYER(play)->actor.world.pos); - blockSize = this->dyna.actor.scale.x * 50.0f + 6.0f; - // Return true if player's xz position is not inside the block - if (blockSize < fabsf(playerRelativePos.x) || blockSize < fabsf(playerRelativePos.z)) { - return true; + if ((this->unk178 != 0) && (DynaPolyActor_IsPlayerAbove(&this->dyna) != 0)) { + return 0; + } + if ((this->dyna.actor.xzDistToPlayer <= D_80BA0B08[PARAMS_GET_U(this->dyna.actor.params, 11, 3)])) { + Actor_WorldToActorCoords(&this->dyna.actor, &sp1C, &GET_PLAYER(play)->actor.world.pos); + temp_fv1 = (this->dyna.actor.scale.x * 50.0f) + 6.0f; + if ((temp_fv1 < fabsf(sp1C.x)) || (temp_fv1 < fabsf(sp1C.z))) { + return 1; } } - - return false; + return 0; } -s32 ObjTimeblock_WaitForOcarina(ObjTimeblock* this, PlayState* play) { - Player* player = GET_PLAYER(play); +s32 func_80BA040C(ObjTimeblock* this, PlayState* play) { + Player* temp_v1; - if (ObjTimeblock_PlayerIsInRange(this, play)) { - if (player->stateFlags2 & PLAYER_STATE2_24) { + temp_v1 = GET_PLAYER(play); + if (func_80BA032C(this, play) != 0) { + if (temp_v1->stateFlags2 & PLAYER_STATE2_24) { Message_StartOcarina(play, OCARINA_ACTION_FREE_PLAY); - this->songObserverFunc = ObjTimeblock_WaitForSong; + this->unk168 = func_80BA0480; } else { - player->stateFlags2 |= PLAYER_STATE2_23; + temp_v1->stateFlags2 |= PLAYER_STATE2_23; } } - return false; + return 0; } -s32 ObjTimeblock_WaitForSong(ObjTimeblock* this, PlayState* play) { +s32 func_80BA0480(ObjTimeblock* this, PlayState* play) { if (play->msgCtx.ocarinaMode == OCARINA_MODE_04) { - this->songObserverFunc = ObjTimeblock_WaitForOcarina; + this->unk168 = func_80BA040C; } if (play->msgCtx.lastPlayedSong == OCARINA_SONG_TIME) { - if (this->unk_172 == 254) { - this->songEndTimer = 110; + if (this->unk172 == 0xFE) { + this->unk16E = 0x6E; } else { - this->songEndTimer--; - if (this->songEndTimer == 0) { - return true; + this->unk16E -= 1; + if (this->unk16E == 0) { + return 1; } } } - return false; + return 0; } -void ObjTimeblock_SetupDoNothing(ObjTimeblock* this) { - this->actionFunc = ObjTimeblock_DoNothing; +void func_80BA04F8(ObjTimeblock* this) { + this->unk164 = func_80BA0508; } -void ObjTimeblock_DoNothing(ObjTimeblock* this, PlayState* play) { +void func_80BA0508(ObjTimeblock* this, PlayState* play) { } -void ObjTimeblock_SetupNormal(ObjTimeblock* this) { - this->actionFunc = ObjTimeblock_Normal; +void func_80BA0514(ObjTimeblock* this) { + this->unk164 = func_80BA0524; } -void ObjTimeblock_Normal(ObjTimeblock* this, PlayState* play) { - u32 newIsVisible; - - if (this->songObserverFunc(this, play) && this->demoEffectTimer <= 0) { - ObjTimeblock_SpawnDemoEffect(this, play); - this->demoEffectTimer = 160; +void func_80BA0524(ObjTimeblock* this, PlayState* play) { + s32 var_v1; - // Possibly points the camera to this actor + if ((this->unk168(this, play) != 0) && (this->unk16C <= 0)) { + func_80BA0058(this, play); + this->unk16C = 0xA0; OnePointCutscene_Attention(play, &this->dyna.actor); - PRINTF(T("◯◯◯◯ Time Block 注目カメラ (frame counter %d)\n", - "◯◯◯◯ Time Block Attention Camera (frame counter %d)\n"), - play->state.frames); - - this->demoEffectFirstPartTimer = 12; - - if (this->unk_177 == 0) { + PRINTF("◯◯◯◯ Time Block 注目カメラ (frame counter %d)\n", play->state.frames); + this->unk170 = 0xC; + if (this->unk177 == 0) { this->dyna.actor.params ^= 0x8000; } else { - ObjTimeblock_ToggleSwitchFlag(play, PARAMS_GET_U(this->dyna.actor.params, 0, 6)); + func_80BA00CC(play, PARAMS_GET_U(this->dyna.actor.params, 0, 6)); } } - - this->unk_172 = play->msgCtx.lastPlayedSong; - if (this->demoEffectFirstPartTimer > 0) { - this->demoEffectFirstPartTimer--; - if (this->demoEffectFirstPartTimer == 0) { - if (this->unk_177 == 0) { - this->unk_175 = PARAMS_GET_U(this->dyna.actor.params, 15, 1) ? true : false; + this->unk172 = play->msgCtx.lastPlayedSong; + if (this->unk170 > 0) { + this->unk170 -= 1; + if (this->unk170 == 0) { + if (this->unk177 == 0) { + if (PARAMS_GET_U(this->dyna.actor.params, 15, 1)) { + this->unk175 = 1; + } else { + this->unk175 = 0; + } + } else if (Flags_GetSwitch(play, PARAMS_GET_U(this->dyna.actor.params, 0, 6)) != 0) { + this->unk174 = 1; } else { - this->unk_174 = (Flags_GetSwitch(play, PARAMS_GET_U(this->dyna.actor.params, 0, 6))) ? true : false; + this->unk174 = 0; } } } - - newIsVisible = ObjTimeblock_CalculateIsVisible(this); - if (this->unk_177 == 1 && newIsVisible != this->isVisible) { - ObjTimeblock_SetupDoNothing(this); + var_v1 = func_80B9FFA0(this); + if ((this->unk177 == 1) && (var_v1 != this->unk178)) { + func_80BA04F8(this); } - this->isVisible = newIsVisible; - - if (this->demoEffectTimer == 50) { - Sfx_PlaySfxCentered(NA_SE_SY_TRE_BOX_APPEAR); + this->unk178 = var_v1; + if (this->unk16C == 0x32) { + Sfx_PlaySfxCentered(0x4807U); } } void func_80BA06AC(ObjTimeblock* this, PlayState* play) { - s32 switchFlag = PARAMS_GET_U(this->dyna.actor.params, 0, 6); - - this->unk_172 = play->msgCtx.lastPlayedSong; - - if (this->demoEffectFirstPartTimer > 0 && --this->demoEffectFirstPartTimer == 0) { - this->unk_174 = (Flags_GetSwitch(play, switchFlag)) ? true : false; + s32 sp24; + s16 temp_v0; + + sp24 = PARAMS_GET_U(this->dyna.actor.params, 0, 6); + temp_v0 = this->unk170; + this->unk172 = play->msgCtx.lastPlayedSong; + if (temp_v0 > 0) { + this->unk170 = temp_v0 - 1; + if (this->unk170 == 0) { + if (Flags_GetSwitch(play, sp24) != 0) { + this->unk174 = 1; + } else { + this->unk174 = 0; + } + } } - - this->isVisible = ObjTimeblock_CalculateIsVisible(this); - this->unk_176 = (Flags_GetSwitch(play, switchFlag)) ? true : false; + this->unk178 = func_80B9FFA0(this); + if (Flags_GetSwitch(play, sp24) != 0) { + this->unk176 = 1; + return; + } + this->unk176 = 0; } -void ObjTimeblock_SetupAltBehaviorVisible(ObjTimeblock* this) { - this->actionFunc = ObjTimeblock_AltBehaviorVisible; +void func_80BA0758(ObjTimeblock* this) { + this->unk164 = func_80BA0768; } -void ObjTimeblock_AltBehaviorVisible(ObjTimeblock* this, PlayState* play) { - if (this->songObserverFunc(this, play) && this->demoEffectTimer <= 0) { - this->demoEffectFirstPartTimer = 12; - ObjTimeblock_SpawnDemoEffect(this, play); - this->demoEffectTimer = 160; +void func_80BA0768(ObjTimeblock* this, PlayState* play) { + if ((this->unk168(this, play) != 0) && (this->unk16C <= 0)) { + this->unk170 = 0xC; + func_80BA0058(this, play); + this->unk16C = 0xA0; OnePointCutscene_Attention(play, &this->dyna.actor); - PRINTF(T("◯◯◯◯ Time Block 注目カメラ (frame counter %d)\n", - "◯◯◯◯ Time Block Attention Camera (frame counter %d)\n"), - play->state.frames); - ObjTimeblock_ToggleSwitchFlag(play, PARAMS_GET_U(this->dyna.actor.params, 0, 6)); + PRINTF("◯◯◯◯ Time Block 注目カメラ (frame counter %d)\n", play->state.frames); + func_80BA00CC(play, PARAMS_GET_U(this->dyna.actor.params, 0, 6)); } - func_80BA06AC(this, play); - - if (this->demoEffectTimer == 50) { + if (this->unk16C == 0x32) { Sfx_PlaySfxCentered(NA_SE_SY_TRE_BOX_APPEAR); } - - if (!this->isVisible && this->demoEffectTimer <= 0) { - ObjTimeblock_SetupAltBehaviourNotVisible(this); + if ((this->unk178 == 0) && (this->unk16C <= 0)) { + func_80BA083C(this); } } -void ObjTimeblock_SetupAltBehaviourNotVisible(ObjTimeblock* this) { - this->actionFunc = ObjTimeblock_AltBehaviourNotVisible; +void func_80BA083C(ObjTimeblock* this) { + this->unk164 = func_80BA084C; } -void ObjTimeblock_AltBehaviourNotVisible(ObjTimeblock* this, PlayState* play) { - s32 switchFlag = PARAMS_GET_U(this->dyna.actor.params, 0, 6); - s8 switchFlagIsSet = (Flags_GetSwitch(play, switchFlag)) ? true : false; +void func_80BA084C(ObjTimeblock* this, PlayState* play) { + s32 var_v1; + s32 flag = PARAMS_GET_U(this->dyna.actor.params, 0, 6); - if (this->unk_176 ^ switchFlagIsSet && - switchFlagIsSet ^ (PARAMS_GET_U(this->dyna.actor.params, 15, 1) ? true : false)) { - if (this->demoEffectTimer <= 0) { - ObjTimeblock_SpawnDemoEffect(this, play); - this->demoEffectTimer = 160; + if (Flags_GetSwitch(play, flag) != 0) { + var_v1 = 1; + } else { + var_v1 = 0; + } + if (this->unk176 ^ var_v1) { + if ((PARAMS_GET_U(this->dyna.actor.params, 15, 1) ? 1 : 0) ^ var_v1) { + if (this->unk16C <= 0) { + func_80BA0058(this, play); + this->unk16C = 0xA0; + } + this->unk170 = 0xC; } - this->demoEffectFirstPartTimer = 12; } - func_80BA06AC(this, play); - - if (this->isVisible && this->demoEffectTimer <= 0) { - ObjTimeblock_SetupAltBehaviorVisible(this); + if ((this->unk178 != 0) && (this->unk16C <= 0)) { + func_80BA0758(this); } } void ObjTimeblock_Update(Actor* thisx, PlayState* play) { + s16 temp_v0; ObjTimeblock* this = (ObjTimeblock*)thisx; - this->actionFunc(this, play); - - if (this->demoEffectTimer > 0) { - this->demoEffectTimer--; + this->unk164(this, play); + temp_v0 = this->unk16C; + if (temp_v0 > 0) { + this->unk16C = temp_v0 - 1; } - - if (this->isVisible) { + if (this->unk178 != 0) { DynaPoly_EnableCollision(play, &play->colCtx.dyna, this->dyna.bgId); - } else { - DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); + return; } + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); } void ObjTimeblock_Draw(Actor* thisx, PlayState* play) { - if (((ObjTimeblock*)thisx)->isVisible) { - Color_RGB8* primColor = &sPrimColors[thisx->home.rot.z & 7]; + Color_RGB8* sp44; + if (((ObjTimeblock*)thisx)->unk178 != 0) { + sp44 = &D_80BA0B38[thisx->home.rot.z & 7]; OPEN_DISPS(play->state.gfxCtx, "../z_obj_timeblock.c", 762); - Gfx_SetupDL_25Opa(play->state.gfxCtx); MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx, "../z_obj_timeblock.c", 766); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, primColor->r, primColor->g, primColor->b, 255); + gDPSetPrimColor(POLY_OPA_DISP++, 0x00, 0x00, sp44->r, sp44->g, sp44->b, 255); gSPDisplayList(POLY_OPA_DISP++, gSongOfTimeBlockDL); - CLOSE_DISPS(play->state.gfxCtx, "../z_obj_timeblock.c", 772); } } diff --git a/src/overlays/actors/ovl_Obj_Timeblock/z_obj_timeblock.h b/src/overlays/actors/ovl_Obj_Timeblock/z_obj_timeblock.h index 1cd2a07644d..4d45d76b80d 100644 --- a/src/overlays/actors/ovl_Obj_Timeblock/z_obj_timeblock.h +++ b/src/overlays/actors/ovl_Obj_Timeblock/z_obj_timeblock.h @@ -6,22 +6,23 @@ struct ObjTimeblock; -typedef s32 (*ObjTimeblockSongObserverFunc)(struct ObjTimeblock*, struct PlayState*); typedef void (*ObjTimeblockActionFunc)(struct ObjTimeblock*, struct PlayState*); +typedef s32 (*ObjTimeblockUnk168Func)(struct ObjTimeblock*, struct PlayState*); typedef struct ObjTimeblock { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x0164 */ ObjTimeblockActionFunc actionFunc; - /* 0x0168 */ ObjTimeblockSongObserverFunc songObserverFunc; - /* 0x016C */ s16 demoEffectTimer; - /* 0x016E */ s16 songEndTimer; - /* 0x0170 */ s16 demoEffectFirstPartTimer; - /* 0x0172 */ u16 unk_172; - /* 0x0174 */ u8 unk_174; - /* 0x0175 */ u8 unk_175; - /* 0x0176 */ u8 unk_176; - /* 0x0177 */ u8 unk_177; - /* 0x0178 */ u8 isVisible; -} ObjTimeblock; // size = 0x017C + /* 0x000 */ DynaPolyActor dyna; + /* 0x164 */ ObjTimeblockActionFunc unk164; + /* 0x168 */ ObjTimeblockUnk168Func unk168; + /* 0x16C */ s16 unk16C; + /* 0x16E */ s16 unk16E; + /* 0x170 */ s16 unk170; + /* 0x172 */ u16 unk172; + /* 0x174 */ u8 unk174; + /* 0x175 */ u8 unk175; + /* 0x176 */ u8 unk176; + /* 0x177 */ u8 unk177; + /* 0x178 */ u8 unk178; + /* 0x179 */ char pad179[3]; /* maybe part of unk178[4]? */ +} ObjTimeblock; // size = 0x017C #endif 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 56583b5f69a..c9c00b5e785 100644 --- a/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c +++ b/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c @@ -5,7 +5,6 @@ */ #include "z_obj_tsubo.h" -#include "src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.h" #include "libc64/qrand.h" #include "ichain.h" @@ -28,22 +27,16 @@ 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* play); - -void ObjTsubo_SpawnCollectible(ObjTsubo* this, PlayState* play); -void ObjTsubo_ApplyGravity(ObjTsubo* this); -s32 ObjTsubo_SnapToFloor(ObjTsubo* this, PlayState* play); -void ObjTsubo_InitCollider(Actor* thisx, PlayState* play); -void ObjTsubo_AirBreak(ObjTsubo* this, PlayState* play); -void ObjTsubo_WaterBreak(ObjTsubo* this, PlayState* play); -void ObjTsubo_SetupWaitForObject(ObjTsubo* this); -void ObjTsubo_WaitForObject(ObjTsubo* this, PlayState* play); -void ObjTsubo_SetupIdle(ObjTsubo* this); -void ObjTsubo_Idle(ObjTsubo* this, PlayState* play); -void ObjTsubo_SetupLiftedUp(ObjTsubo* this); -void ObjTsubo_LiftedUp(ObjTsubo* this, PlayState* play); -void ObjTsubo_SetupThrown(ObjTsubo* this); -void ObjTsubo_Thrown(ObjTsubo* this, PlayState* play); + +void func_80BA152C(ObjTsubo* this); +void func_80BA153C(ObjTsubo* this, PlayState* play); +void func_80BA15AC(ObjTsubo* this); +void func_80BA15BC(ObjTsubo* this, PlayState* play); +void func_80BA17C4(ObjTsubo* this); +void func_80BA180C(ObjTsubo* this, PlayState* play); +void func_80BA188C(ObjTsubo* this); +void func_80BA1958(ObjTsubo* this, PlayState* play); +void func_80BA1B0C(Actor* thisx, PlayState* play); static s16 D_80BA1B50 = 0; static s16 D_80BA1B54 = 0; @@ -62,11 +55,9 @@ ActorProfile Obj_Tsubo_Profile = { /**/ NULL, }; -static s16 sObjectIds[] = { OBJECT_GAMEPLAY_DANGEON_KEEP, OBJECT_TSUBO }; - -static Gfx* D_80BA1B84[] = { gPotDL, object_tsubo_DL_0017C0 }; - -static Gfx* D_80BA1B8C[] = { gPotFragmentDL, object_tsubo_DL_001960 }; +static s16 D_80BA1B80[2] = { OBJECT_GAMEPLAY_DANGEON_KEEP, OBJECT_TSUBO }; +static Gfx* D_80BA1B84[2] = { gPotDL, object_tsubo_DL_0017C0 }; +static Gfx* D_80BA1B8C[2] = { gPotFragmentDL, object_tsubo_DL_001960 }; static ColliderCylinderInit sCylinderInit = { { @@ -88,51 +79,52 @@ static ColliderCylinderInit sCylinderInit = { { 9, 26, 0, { 0, 0, 0 } }, }; -static CollisionCheckInfoInit sColChkInfoInit[] = { 0, 12, 60, MASS_IMMOVABLE }; - +static CollisionCheckInfoInit sColChkInfoInit = { 0, 0xC, 0x3C, MASS_IMMOVABLE }; static InitChainEntry sInitChain[] = { ICHAIN_F32_DIV1000(gravity, -1200, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(minVelocityY, -20000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 150, ICHAIN_CONTINUE), ICHAIN_F32(cullingVolumeDistance, 900, ICHAIN_CONTINUE), ICHAIN_F32(cullingVolumeScale, 100, ICHAIN_CONTINUE), ICHAIN_F32(cullingVolumeDownward, 800, ICHAIN_STOP), }; -void ObjTsubo_SpawnCollectible(ObjTsubo* this, PlayState* play) { - s16 dropParams = PARAMS_GET_U(this->actor.params, 0, 5); +void func_80BA0D60(ObjTsubo* this, PlayState* play) { + s16 temp_v0; - if ((dropParams >= 0) && (dropParams < ITEM00_MAX)) { - Item_DropCollectible(play, &this->actor.world.pos, dropParams | (PARAMS_GET_U(this->actor.params, 9, 6) << 8)); + temp_v0 = PARAMS_GET_U(this->actor.params, 0, 5); + if ((temp_v0 >= 0) && (temp_v0 < ITEM00_MAX)) { + Item_DropCollectible(play, &this->actor.world.pos, + (s16)(temp_v0 | (PARAMS_GET_U(this->actor.params, 9, 6) << 8))); } } -void ObjTsubo_ApplyGravity(ObjTsubo* this) { +void func_80BA0DC0(ObjTsubo* this) { this->actor.velocity.y += this->actor.gravity; if (this->actor.velocity.y < this->actor.minVelocityY) { this->actor.velocity.y = this->actor.minVelocityY; } } -s32 ObjTsubo_SnapToFloor(ObjTsubo* this, PlayState* play) { - CollisionPoly* groundPoly; - Vec3f pos; - s32 bgId; - f32 groundY; - - pos.x = this->actor.world.pos.x; - pos.y = this->actor.world.pos.y + 20.0f; - pos.z = this->actor.world.pos.z; - groundY = BgCheck_EntityRaycastDown4(&play->colCtx, &groundPoly, &bgId, &this->actor, &pos); - if (groundY > BGCHECK_Y_MIN) { - this->actor.world.pos.y = groundY; +s32 func_80BA0DF4(ObjTsubo* this, PlayState* play) { + CollisionPoly* sp34; + Vec3f sp28; + s32 sp24; + f32 temp_fv0; + + sp28.x = this->actor.world.pos.x; + sp28.y = this->actor.world.pos.y + 20.0f; + sp28.z = this->actor.world.pos.z; + temp_fv0 = BgCheck_EntityRaycastDown4(&play->colCtx, &sp34, &sp24, &this->actor, (Vec3f*)&sp28); + if (temp_fv0 > BGCHECK_Y_MIN) { + this->actor.world.pos.y = temp_fv0; Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.world.pos); - return true; + return 1; } else { - PRINTF(T("地面に付着失敗\n", "Failed to attach to ground\n")); - return false; + PRINTF("地面に付着失敗\n"); + return 0; } } -void ObjTsubo_InitCollider(Actor* thisx, PlayState* play) { - ObjTsubo* this = (ObjTsubo*)thisx; +void func_80BA0E98(ObjTsubo* this2, PlayState* play) { + ObjTsubo* this = this2; Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); @@ -143,20 +135,19 @@ void ObjTsubo_Init(Actor* thisx, PlayState* play) { ObjTsubo* this = (ObjTsubo*)thisx; Actor_ProcessInitChain(&this->actor, sInitChain); - ObjTsubo_InitCollider(&this->actor, play); - CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, sColChkInfoInit); - if (!ObjTsubo_SnapToFloor(this, play)) { - Actor_Kill(&this->actor); - return; - } - this->requiredObjectSlot = Object_GetSlot(&play->objectCtx, sObjectIds[PARAMS_GET_U(this->actor.params, 8, 1)]); - if (this->requiredObjectSlot < 0) { - PRINTF(T("Error : バンク危険! (arg_data 0x%04x)(%s %d)\n", "Error : Bank danger! (arg_data 0x%04x)(%s %d)\n"), - this->actor.params, "../z_obj_tsubo.c", 410); + func_80BA0E98(this, play); + CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); + if (func_80BA0DF4(this, play) == 0) { Actor_Kill(&this->actor); } else { - ObjTsubo_SetupWaitForObject(this); - PRINTF(T("(dungeon keep 壷)(arg_data 0x%04x)\n", "(dungeon keep pot)(arg_data 0x%04x)\n"), this->actor.params); + this->requiredObjectSlot = Object_GetSlot(&play->objectCtx, D_80BA1B80[PARAMS_GET_U(this->actor.params, 8, 1)]); + if (this->requiredObjectSlot < 0) { + PRINTF("Error : バンク危険! (arg_data 0x%04x)(%s %d)\n", this->actor.params, "../z_obj_tsubo.c", 410); + Actor_Kill(&this->actor); + } else { + func_80BA152C(this); + PRINTF("(dungeon keep 壷)(arg_data 0x%04x)\n", this->actor.params); + } } } @@ -167,106 +158,112 @@ void ObjTsubo_Destroy(Actor* thisx, PlayState* play2) { Collider_DestroyCylinder(play, &this->collider); } -void ObjTsubo_AirBreak(ObjTsubo* this, PlayState* play) { +void func_80BA100C(ObjTsubo* this, PlayState* play) { STACK_PAD(s32); - f32 rand; - s16 angle; - Vec3f pos; - Vec3f velocity; - f32 sins; - f32 coss; - s32 arg5; - s32 i; - - for (i = 0, angle = 0; i < 15; i++, angle += 0x4E20) { - sins = Math_SinS(angle); - coss = Math_CosS(angle); - pos.x = sins * 8.0f; - pos.y = (Rand_ZeroOne() * 5.0f) + 2.0f; - pos.z = coss * 8.0f; - velocity.x = pos.x * 0.23f; - velocity.y = (Rand_ZeroOne() * 5.0f) + 2.0f; - velocity.z = pos.z * 0.23f; - Math_Vec3f_Sum(&pos, &this->actor.world.pos, &pos); - rand = Rand_ZeroOne(); - if (rand < 0.2f) { - arg5 = 96; - } else if (rand < 0.6f) { - arg5 = 64; + f32 sin; + f32 cos; + Vec3f spC8; + Vec3f spBC; + f32 temp_fv0; + s32 var_s0; + s32 var_s2; + s16 var_s1; + + for (var_s2 = 0, var_s1 = 0; var_s2 < 15; var_s2++, var_s1 += 0x4E20) { + sin = Math_SinS(var_s1); + cos = Math_CosS(var_s1); + spC8.x = sin * 8.0f; + spC8.y = (Rand_ZeroOne() * 5.0f) + 2.0f; + spC8.z = cos * 8.0f; + spBC.x = spC8.x * 0.23f; + spBC.y = (Rand_ZeroOne() * 5.0f) + 2.0f; + spBC.z = spC8.z * 0.23f; + Math_Vec3f_Sum(&spC8, &this->actor.world.pos, &spC8); + temp_fv0 = Rand_ZeroOne(); + if (temp_fv0 < 0.2f) { + var_s0 = 0x60; + } else if (temp_fv0 < 0.6f) { + var_s0 = 0x40; } else { - arg5 = 32; + var_s0 = 0x20; } - EffectSsKakera_Spawn(play, &pos, &velocity, &this->actor.world.pos, -240, arg5, 10, 10, 0, - (Rand_ZeroOne() * 95.0f) + 15.0f, 0, 32, 60, KAKERA_COLOR_NONE, - sObjectIds[PARAMS_GET_U(this->actor.params, 8, 1)], + EffectSsKakera_Spawn(play, &spC8, &spBC, &this->actor.world.pos, -240, var_s0, 0xA, 0xA, 0, + (Rand_ZeroOne() * 95.0f) + 15.0f, 0, 0x20, 60, -1, + D_80BA1B80[PARAMS_GET_U(this->actor.params, 8, 1)], D_80BA1B8C[PARAMS_GET_U(this->actor.params, 8, 1)]); } - func_80033480(play, &this->actor.world.pos, 30.0f, 4, 20, 50, 1); + func_80033480(play, &this->actor.world.pos, 30.0f, 4, 0x14, 0x32, 1U); } -void ObjTsubo_WaterBreak(ObjTsubo* this, PlayState* play) { +void func_80BA1294(ObjTsubo* this, PlayState* play) { + f32 temp_fs0; + f32 temp_fs1; + s16 var_s1; + Vec3f spC8; + Vec3f spBC; + s32 var_s0; + s32 var_s2; STACK_PADS(s32, 2); - s16 angle; - Vec3f pos = this->actor.world.pos; - Vec3f velocity; - s32 phi_s0; - s32 i; - - pos.y += this->actor.depthInWater; - EffectSsGSplash_Spawn(play, &pos, NULL, NULL, 0, 400); - for (i = 0, angle = 0; i < 15; i++, angle += 0x4E20) { - f32 sins = Math_SinS(angle); - f32 coss = Math_CosS(angle); - - pos.x = sins * 8.0f; - pos.y = (Rand_ZeroOne() * 5.0f) + 2.0f; - pos.z = coss * 8.0f; - velocity.x = pos.x * 0.2f; - velocity.y = (Rand_ZeroOne() * 4.0f) + 2.0f; - velocity.z = pos.z * 0.2f; - Math_Vec3f_Sum(&pos, &this->actor.world.pos, &pos); - phi_s0 = (Rand_ZeroOne() < .2f) ? 64 : 32; - EffectSsKakera_Spawn(play, &pos, &velocity, &this->actor.world.pos, -180, phi_s0, 30, 30, 0, - (Rand_ZeroOne() * 95.0f) + 15.0f, 0, 32, 70, KAKERA_COLOR_NONE, - sObjectIds[PARAMS_GET_U(this->actor.params, 8, 1)], + + spC8 = this->actor.world.pos; + spC8.y += this->actor.depthInWater; + EffectSsGSplash_Spawn(play, &spC8, NULL, NULL, 0, 0x190); + + for (var_s2 = 0, var_s1 = 0; var_s2 < 15; var_s2++, var_s1 += 0x4E20) { + temp_fs0 = Math_SinS(var_s1); + temp_fs1 = Math_CosS(var_s1); + spC8.x = temp_fs0 * 8.0f; + spC8.y = (Rand_ZeroOne() * 5.0f) + 2.0f; + spC8.z = temp_fs1 * 8.0f; + spBC.x = spC8.x * 0.20f; + spBC.y = (Rand_ZeroOne() * 4.0f) + 2.0f; + spBC.z = spC8.z * 0.20f; + Math_Vec3f_Sum(&spC8, &this->actor.world.pos, &spC8); + if (Rand_ZeroOne() < 0.2f) { + var_s0 = 0x40; + } else { + var_s0 = 0x20; + } + EffectSsKakera_Spawn(play, &spC8, &spBC, &this->actor.world.pos, -180, var_s0, 0x1E, 0x1E, 0, + (Rand_ZeroOne() * 95.0f) + 15.0f, 0, 0x20, 70, -1, + D_80BA1B80[PARAMS_GET_U(this->actor.params, 8, 1)], D_80BA1B8C[PARAMS_GET_U(this->actor.params, 8, 1)]); } } -void ObjTsubo_SetupWaitForObject(ObjTsubo* this) { - this->actionFunc = ObjTsubo_WaitForObject; +void func_80BA152C(ObjTsubo* this) { + this->actionFunc = func_80BA153C; } -void ObjTsubo_WaitForObject(ObjTsubo* this, PlayState* play) { +void func_80BA153C(ObjTsubo* this, PlayState* play) { if (Object_IsLoaded(&play->objectCtx, this->requiredObjectSlot)) { - this->actor.draw = ObjTsubo_Draw; + this->actor.draw = func_80BA1B0C; this->actor.objectSlot = this->requiredObjectSlot; - ObjTsubo_SetupIdle(this); + func_80BA15AC(this); this->actor.flags &= ~ACTOR_FLAG_UPDATE_CULLING_DISABLED; } } -void ObjTsubo_SetupIdle(ObjTsubo* this) { - this->actionFunc = ObjTsubo_Idle; +void func_80BA15AC(ObjTsubo* this) { + this->actionFunc = func_80BA15BC; } -void ObjTsubo_Idle(ObjTsubo* this, PlayState* play) { - STACK_PAD(s32); +void func_80BA15BC(ObjTsubo* this, PlayState* play) { s16 temp_v0; - s32 phi_v1; + STACK_PAD(s32); if (Actor_HasParent(&this->actor, play)) { - ObjTsubo_SetupLiftedUp(this); + func_80BA17C4(this); } else if ((this->actor.bgCheckFlags & BGCHECKFLAG_WATER) && (this->actor.depthInWater > 15.0f)) { - ObjTsubo_WaterBreak(this, play); + func_80BA1294(this, play); SfxSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_EV_POT_BROKEN); - ObjTsubo_SpawnCollectible(this, play); + func_80BA0D60(this, play); Actor_Kill(&this->actor); } else if ((this->collider.base.acFlags & AC_HIT) && (this->collider.elem.acHitElem->atDmgInfo.dmgFlags & (DMG_SWORD | DMG_RANGED | DMG_HAMMER | DMG_BOOMERANG | DMG_EXPLOSIVE))) { - ObjTsubo_AirBreak(this, play); - ObjTsubo_SpawnCollectible(this, play); + func_80BA100C(this, play); + func_80BA0D60(this, play); SfxSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_EV_POT_BROKEN); Actor_Kill(&this->actor); } else { @@ -280,61 +277,59 @@ void ObjTsubo_Idle(ObjTsubo* this, PlayState* play) { } if (this->actor.xzDistToPlayer < 100.0f) { temp_v0 = this->actor.yawTowardsPlayer - GET_PLAYER(play)->actor.world.rot.y; - phi_v1 = ABS(temp_v0); - if (phi_v1 >= 0x5556) { - // GI_NONE in this case allows the player to lift the actor + if (ABS(temp_v0) > 0x5555) { Actor_OfferGetItem(&this->actor, play, GI_NONE, 30.0f, 30.0f); } } } } -void ObjTsubo_SetupLiftedUp(ObjTsubo* this) { - this->actionFunc = ObjTsubo_LiftedUp; +void func_80BA17C4(ObjTsubo* this) { + this->actionFunc = func_80BA180C; this->actor.room = -1; //! @bug This is an unsafe cast, although the sound effect will still play Player_PlaySfx((Player*)&this->actor, NA_SE_PL_PULL_UP_POT); this->actor.flags |= ACTOR_FLAG_UPDATE_CULLING_DISABLED; } -void ObjTsubo_LiftedUp(ObjTsubo* this, PlayState* play) { +void func_80BA180C(ObjTsubo* this, PlayState* play) { if (Actor_HasNoParent(&this->actor, play)) { this->actor.room = play->roomCtx.curRoom.num; - ObjTsubo_SetupThrown(this); - ObjTsubo_ApplyGravity(this); + func_80BA188C(this); + func_80BA0DC0(this); Actor_UpdatePos(&this->actor); Actor_UpdateBgCheckInfo(play, &this->actor, 5.0f, 15.0f, 0.0f, UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_7); } } -void ObjTsubo_SetupThrown(ObjTsubo* this) { +void func_80BA188C(ObjTsubo* this) { this->actor.velocity.x = Math_SinS(this->actor.world.rot.y) * this->actor.speed; this->actor.velocity.z = Math_CosS(this->actor.world.rot.y) * this->actor.speed; - this->actor.colChkInfo.mass = 240; + this->actor.colChkInfo.mass = 0xF0; D_80BA1B50 = (Rand_ZeroOne() - 0.7f) * 2800.0f; D_80BA1B58 = (Rand_ZeroOne() - 0.5f) * 2000.0f; D_80BA1B54 = 0; D_80BA1B5C = 0; - this->actionFunc = ObjTsubo_Thrown; + this->actionFunc = func_80BA1958; } -void ObjTsubo_Thrown(ObjTsubo* this, PlayState* play) { +void func_80BA1958(ObjTsubo* this, PlayState* play) { STACK_PADS(s32, 2); if ((this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH | BGCHECKFLAG_WALL)) || (this->collider.base.atFlags & AT_HIT)) { - ObjTsubo_AirBreak(this, play); - ObjTsubo_SpawnCollectible(this, play); + func_80BA100C(this, play); + func_80BA0D60(this, play); SfxSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_EV_POT_BROKEN); Actor_Kill(&this->actor); } else if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH) { - ObjTsubo_WaterBreak(this, play); - ObjTsubo_SpawnCollectible(this, play); + func_80BA1294(this, play); + func_80BA0D60(this, play); SfxSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_EV_POT_BROKEN); Actor_Kill(&this->actor); } else { - ObjTsubo_ApplyGravity(this); + func_80BA0DC0(this); Actor_UpdatePos(&this->actor); Math_StepToS(&D_80BA1B54, D_80BA1B50, 0x64); Math_StepToS(&D_80BA1B5C, D_80BA1B58, 0x64); @@ -354,6 +349,6 @@ void ObjTsubo_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); } -void ObjTsubo_Draw(Actor* thisx, PlayState* play) { +void func_80BA1B0C(Actor* thisx, PlayState* play) { Gfx_DrawDListOpa(play, D_80BA1B84[PARAMS_GET_U(thisx->params, 8, 1)]); } 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 b42de51f48b..e8bc99bd25e 100644 --- a/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.h +++ b/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.h @@ -9,11 +9,11 @@ struct ObjTsubo; typedef void (*ObjTsuboActionFunc)(struct ObjTsubo*, struct PlayState*); typedef struct ObjTsubo { - /* 0x0000 */ Actor actor; - /* 0x014C */ ObjTsuboActionFunc actionFunc; - /* 0x0150 */ ColliderCylinder collider; - /* 0x019C */ s8 requiredObjectSlot; -} ObjTsubo; // size = 0x01A0 + /* 0x000 */ Actor actor; + /* 0x14C */ ObjTsuboActionFunc actionFunc; + /* 0x150 */ ColliderCylinder collider; + /* 0x19C */ s8 requiredObjectSlot; + /* 0x19D */ char pad19D[3]; +} ObjTsubo; // size = 0x1A0 #endif - 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 ecb37b39adb..355ef1b33ac 100644 --- a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c +++ b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c @@ -49,11 +49,11 @@ void ObjectKankyo_SunGraveSpark(ObjectKankyo* this, PlayState* play); void ObjectKankyo_WaitForBeamObject(ObjectKankyo* this, PlayState* play); void ObjectKankyo_Beams(ObjectKankyo* this, PlayState* play); -void ObjectKankyo_DrawFairies(Actor* thisx, PlayState* play2); -void ObjectKankyo_DrawSnow(Actor* thisx, PlayState* play2); -void ObjectKankyo_DrawLightning(Actor* thisx, PlayState* play); -void ObjectKankyo_DrawSunGraveSpark(Actor* thisx, PlayState* play2); -void ObjectKankyo_DrawBeams(Actor* thisx, PlayState* play2); +void ObjectKankyo_DrawFairies(ObjectKankyo* this2, PlayState* play2); +void ObjectKankyo_DrawSnow(ObjectKankyo* this2, PlayState* play2); +void ObjectKankyo_DrawLightning(ObjectKankyo* this, PlayState* play); +void ObjectKankyo_DrawSunGraveSpark(ObjectKankyo* this2, PlayState* play2); +void ObjectKankyo_DrawBeams(ObjectKankyo* this2, PlayState* play2); static void* sEffLightningTextures[] = { gEffLightning1Tex, gEffLightning2Tex, gEffLightning3Tex, gEffLightning4Tex, @@ -177,9 +177,6 @@ void ObjectKankyo_Init(Actor* thisx, PlayState* play) { this->requiredObjectLoaded = false; ObjectKankyo_SetupAction(this, ObjectKankyo_InitBeams); break; - - default: - break; } } @@ -242,9 +239,6 @@ void ObjectKankyo_Fairies(ObjectKankyo* this, PlayState* play) { case 771: Sfx_PlaySfxCentered(NA_SE_VO_RT_THROW); break; - - default: - break; } } @@ -376,9 +370,6 @@ void ObjectKankyo_Fairies(ObjectKankyo* this, PlayState* play) { this->effects[i].dirPhase.y += 0.08f * Rand_ZeroOne(); this->effects[i].dirPhase.z += 0.05f * Rand_ZeroOne(); break; - - default: - break; } } else if (this->effects[i].state == 2) { // scatter when the player moves or after a long enough time @@ -475,9 +466,6 @@ void ObjectKankyo_Fairies(ObjectKankyo* this, PlayState* play) { case 3: // reset, never reached this->effects[i].state = 0; break; - - default: - break; } } } @@ -489,35 +477,34 @@ void ObjectKankyo_Update(Actor* thisx, PlayState* play) { } void ObjectKankyo_Draw(Actor* thisx, PlayState* play) { - switch (thisx->params) { + ObjectKankyo* this = (ObjectKankyo*)thisx; + + switch (this->actor.params) { case 0: - ObjectKankyo_DrawFairies(thisx, play); + ObjectKankyo_DrawFairies(this, play); break; case 2: - ObjectKankyo_DrawLightning(thisx, play); + ObjectKankyo_DrawLightning(this, play); break; case 3: - ObjectKankyo_DrawSnow(thisx, play); + ObjectKankyo_DrawSnow(this, play); break; case 4: - ObjectKankyo_DrawSunGraveSpark(thisx, play); + ObjectKankyo_DrawSunGraveSpark(this, play); break; case 5: - ObjectKankyo_DrawBeams(thisx, play); - break; - - default: + ObjectKankyo_DrawBeams(this, play); break; } } -void ObjectKankyo_DrawFairies(Actor* thisx, PlayState* play2) { +void ObjectKankyo_DrawFairies(ObjectKankyo* this2, PlayState* play2) { + ObjectKankyo* this = this2; PlayState* play = play2; - ObjectKankyo* this = (ObjectKankyo*)thisx; f32 alphaScale; UNUSED Vec3f vec1 = { 0.0f, 0.0f, 0.0f }; UNUSED Vec3f vec2 = { 0.0f, 0.0f, 0.0f }; @@ -600,9 +587,9 @@ void ObjectKankyo_DrawFairies(Actor* thisx, PlayState* play2) { } } -void ObjectKankyo_DrawSnow(Actor* thisx, PlayState* play2) { +void ObjectKankyo_DrawSnow(ObjectKankyo* this2, PlayState* play2) { + ObjectKankyo* this = this2; PlayState* play = play2; - ObjectKankyo* this = (ObjectKankyo*)thisx; f32 dist; f32 dx; f32 dy; @@ -708,9 +695,6 @@ void ObjectKankyo_DrawSnow(Actor* thisx, PlayState* play2) { case 2: this->effects[i].state = 0; break; - - default: - break; } if (1) {} @@ -762,16 +746,12 @@ void ObjectKankyo_Lightning(ObjectKankyo* this, PlayState* play) { this->effects[0].state = 0; } break; - - default: - break; } } } -void ObjectKankyo_DrawLightning(Actor* thisx, PlayState* play) { - STACK_PAD(s32); - ObjectKankyo* this = (ObjectKankyo*)thisx; +void ObjectKankyo_DrawLightning(ObjectKankyo* this, PlayState* play) { + STACK_PADS(s32, 2); OPEN_DISPS(play->state.gfxCtx, "../z_object_kankyo.c", 1182); @@ -830,9 +810,9 @@ void ObjectKankyo_SunGraveSpark(ObjectKankyo* this, PlayState* play) { } } -void ObjectKankyo_DrawSunGraveSpark(Actor* thisx, PlayState* play2) { +void ObjectKankyo_DrawSunGraveSpark(ObjectKankyo* this2, PlayState* play2) { + ObjectKankyo* this = this2; PlayState* play = play2; - ObjectKankyo* this = (ObjectKankyo*)thisx; Vec3f start; Vec3f end; f32 weight; @@ -928,7 +908,7 @@ void ObjectKankyo_Beams(ObjectKankyo* this, PlayState* play) { } } -void ObjectKankyo_DrawBeams(Actor* thisx, PlayState* play2) { +void ObjectKankyo_DrawBeams(ObjectKankyo* this2, PlayState* play2) { static Color_RGB8 sBeamPrimColors[] = { { 255, 255, 170 }, { 170, 255, 255 }, { 255, 170, 255 }, { 255, 255, 170 }, { 255, 255, 170 }, { 255, 255, 170 }, @@ -936,8 +916,8 @@ void ObjectKankyo_DrawBeams(Actor* thisx, PlayState* play2) { static Color_RGB8 sBeamEnvColors[] = { { 0, 200, 0 }, { 0, 50, 255 }, { 100, 0, 200 }, { 200, 0, 0 }, { 200, 255, 0 }, { 255, 120, 0 }, }; + ObjectKankyo* this = this2; PlayState* play = play2; - ObjectKankyo* this = (ObjectKankyo*)thisx; s16 i; f32 beamX[] = { 430.0f, 860.0f, 430.0f, -426.0f, -862.0f, -440.0f }; f32 beamY[] = { 551.0f, 551.0f, 551.0f, 554.0f, 551.0f, 547.0f }; diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index b7de419c5b9..d18c637b512 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -76,9 +76,6 @@ typedef struct GetItemEntry { #define CHEST_ANIM_SHORT 0 #define CHEST_ANIM_LONG 1 -#define GET_ITEM_NONE \ - { ITEM_NONE, 0, 0, 0, OBJECT_INVALID } - typedef struct ExplosiveInfo { /* 0x00 */ u8 itemId; /* 0x02 */ s16 actorId; @@ -158,6 +155,14 @@ typedef struct struct_80854B18 { }; } struct_80854B18; // size = 0x08 +typedef struct struct_80858AC8 { + /* 0x00 */ s16 unk_00; + /* 0x02 */ s16 unk_02; + /* 0x04 */ s16 unk_04; + /* 0x06 */ s16 unk_06; + /* 0x08 */ s16 unk_08; +} struct_80858AC8; // size = 0x0A + void Player_InitItemAction(PlayState* play, Player* this, s8 itemAction); void Player_InitDefaultIA(PlayState* play, Player* this); @@ -190,7 +195,7 @@ void func_80839F90(Player* this, PlayState* play); s32 func_8083C61C(PlayState* play, Player* this); void Player_UpdateCommon(Player* this, PlayState* play, Input* input); void func_8084FF7C(Player* this); -void Player_UpdateBunnyEars(Player* this); +void func_8085002C(Player* this); void func_80851008(PlayState* play, Player* this, void* anim); void func_80851030(PlayState* play, Player* this, void* anim); void func_80851050(PlayState* play, Player* this, void* anim); @@ -366,22 +371,22 @@ void Player_Action_CsAction(Player* this, PlayState* play); // .bss part 1 -#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:64 gc-jp-ce:64 gc-jp-mq:64 gc-us:64 gc-us-mq:64" \ - "ique-cn:128 ntsc-1.0:64 ntsc-1.1:64 ntsc-1.2:64 pal-1.0:64 pal-1.1:64" +#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ique-cn:0" \ + "ntsc-1.0:0 ntsc-1.1:0 ntsc-1.2:0 pal-1.0:0 pal-1.1:0" static s32 D_80858AA0; // TODO: There's probably a way to match BSS ordering with less padding by spreading the variables out and moving // data around. It would be easier if we had more options for controlling BSS ordering in debug. -#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:192 gc-jp-ce:192 gc-jp-mq:192 gc-us:192 gc-us-mq:192" \ - "ique-cn:128 ntsc-1.0:192 ntsc-1.1:192 ntsc-1.2:192 pal-1.0:192 pal-1.1:192" +#pragma increment_block_number "gc-eu:192 gc-eu-mq:192 gc-jp:192 gc-jp-ce:192 gc-jp-mq:192 gc-us:192 gc-us-mq:192" \ + "ique-cn:192 ntsc-1.0:192 ntsc-1.1:192 ntsc-1.2:192 pal-1.0:192 pal-1.1:192" static s32 sSavedCurrentMask; static Vec3f sInteractWallCheckResult; static Input* sControlInput; #pragma increment_block_number "gc-eu:192 gc-eu-mq:192 gc-jp:192 gc-jp-ce:192 gc-jp-mq:192 gc-us:192 gc-us-mq:192" \ - "ique-cn:192 ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128" + "ique-cn:160 ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128" // .data @@ -792,9 +797,9 @@ static GetItemEntry sGetItemTable[] = { // GI_BULLET_BAG_50 GET_ITEM(ITEM_BULLET_BAG_50, OBJECT_GI_DEKUPOUCH, GID_BULLET_BAG_50, 0x6C, 0x80, CHEST_ANIM_LONG), // GI_ICE_TRAP - GET_ITEM_NONE, + { ITEM_NONE, 0, 0, 0, 0 }, // GI_TEXT_0 - GET_ITEM_NONE, + { ITEM_NONE, 0, 0, 0, 0 }, }; #define GET_PLAYER_ANIM(group, type) D_80853914[group * PLAYER_ANIMTYPE_MAX + type] @@ -3702,7 +3707,7 @@ s32 Player_UpdateUpperBody(Player* this, PlayState* play) { func_80832224(this); this->yaw = this->actor.shape.rot.y; this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; - this->hoverBootsTimer = 0; + this->unk_893 = 0; this->unk_6AE_rotFlags |= UNK6AE_ROT_FOCUS_X | UNK6AE_ROT_FOCUS_Y | UNK6AE_ROT_UPPER_X; Player_PlayVoiceSfx(this, NA_SE_VO_LI_LASH); return true; @@ -4715,7 +4720,7 @@ void func_80837C0C(PlayState* play, Player* this, s32 hitResponseType, f32 speed } } - this->hoverBootsTimer = 0; + this->unk_893 = 0; this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; } else { if ((this->speedXZ > 4.0f) && !Player_CheckHostileLockOn(this)) { @@ -4987,7 +4992,7 @@ void func_80838940(Player* this, LinkAnimationHeader* anim, f32 arg2, PlayState* } this->actor.velocity.y = arg2 * sWaterSpeedFactor; - this->hoverBootsTimer = 0; + this->unk_893 = 0; this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; Player_PlayJumpingSfx(this); @@ -5851,7 +5856,7 @@ void func_8083AA10(Player* this, PlayState* play) { return; } - if (this->hoverBootsTimer != 0) { + if (this->unk_893 != 0) { this->actor.velocity.y = 1.0f; sPrevFloorProperty = FLOOR_PROPERTY_9; return; @@ -6321,7 +6326,7 @@ void func_8083BA90(PlayState* play, Player* this, s32 arg2, f32 xzSpeed, f32 yVe this->actor.velocity.y = yVelocity; this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; - this->hoverBootsTimer = 0; + this->unk_893 = 0; Player_PlayJumpingSfx(this); Player_PlayVoiceSfx(this, NA_SE_VO_LI_SWORD_L); @@ -7732,7 +7737,7 @@ s32 func_8083F524(PlayState* play, Player* this) { /** * Two exit walls are placed at each end of the crawlspace, separate to the two entrance walls used to enter the - * crawlspace. These front and back exit walls are further into the crawlspace than the front and + * crawlspace. These front and back exit walls are further into the crawlspace relative to the front and * back entrance walls. When player interacts with either of these two interior exit walls, start the leaving-crawlspace * cutscene and return true. Else, return false */ @@ -8040,7 +8045,7 @@ void func_8084029C(Player* this, f32 arg1) { if (1) {} if ((this->currentBoots == PLAYER_BOOTS_HOVER) && !(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && - (this->hoverBootsTimer != 0)) { + (this->unk_893 != 0)) { Actor_PlaySfx_Flagged2(&this->actor, NA_SE_PL_HOBBERBOOTS_LV - SFX_FLAG); } else if (func_8084021C(this->unk_868, arg1, 29.0f, 10.0f) || func_8084021C(this->unk_868, arg1, 29.0f, 24.0f)) { Player_PlaySteppingSfx(this, this->speedXZ); @@ -11032,23 +11037,23 @@ void Player_UpdateInterface(PlayState* play, Player* this) { s32 Player_UpdateHoverBoots(Player* this) { s32 canHoverOnGround; - if ((this->currentBoots == PLAYER_BOOTS_HOVER) && (this->hoverBootsTimer != 0)) { - this->hoverBootsTimer--; + if ((this->currentBoots == PLAYER_BOOTS_HOVER) && (this->unk_893 != 0)) { + this->unk_893--; } else { - this->hoverBootsTimer = 0; + this->unk_893 = 0; } canHoverOnGround = (this->currentBoots == PLAYER_BOOTS_HOVER) && ((this->actor.depthInWater >= 0.0f) || (func_80838144(sFloorType) >= 0) || func_8083816C(sFloorType)); - if (canHoverOnGround && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (this->hoverBootsTimer != 0)) { + if (canHoverOnGround && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (this->unk_893 != 0)) { this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; } if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { if (!canHoverOnGround) { - this->hoverBootsTimer = 19; + this->unk_893 = 0x13; } return false; @@ -11797,7 +11802,7 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { this->actor.shape.face = this->faceChange.face + ((play->gameplayFrames & 32) ? 0 : 3); if (this->currentMask == PLAYER_MASK_BUNNY) { - Player_UpdateBunnyEars(this); + func_8085002C(this); } if (func_8002DD6C(this) != 0) { @@ -11963,8 +11968,8 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { this->stateFlags2 &= ~(PLAYER_STATE2_CAN_ACCEPT_TALK_OFFER | PLAYER_STATE2_21); } - this->stateFlags1 &= ~(PLAYER_STATE1_SWINGING_BOTTLE | PLAYER_STATE1_9 | PLAYER_STATE1_CHARGING_SPIN_ATTACK | - PLAYER_STATE1_SHIELDING); + this->stateFlags1 &= + ~(PLAYER_STATE1_1 | PLAYER_STATE1_9 | PLAYER_STATE1_CHARGING_SPIN_ATTACK | PLAYER_STATE1_SHIELDING); this->stateFlags2 &= ~(PLAYER_STATE2_0 | PLAYER_STATE2_2 | PLAYER_STATE2_3 | PLAYER_STATE2_5 | PLAYER_STATE2_6 | PLAYER_STATE2_8 | PLAYER_STATE2_FORCE_SAND_FLOOR_SOUND | PLAYER_STATE2_12 | PLAYER_STATE2_14 | PLAYER_STATE2_DO_ACTION_ENTER | PLAYER_STATE2_22 | PLAYER_STATE2_26); @@ -12164,12 +12169,7 @@ skip_update:; } } -typedef struct BunnyEarKinematics { - /* 0x0 */ Vec3s rot; - /* 0x6 */ Vec3s angVel; -} BunnyEarKinematics; // size = 0xC - -static BunnyEarKinematics sBunnyEarKinematics; +static struct_80858AC8 D_80858AC8; static Gfx* sMaskDlists[PLAYER_MASK_MAX - 1] = { gLinkChildKeatonMaskDL, gLinkChildSkullMaskDL, gLinkChildSpookyMaskDL, gLinkChildBunnyHoodDL, @@ -12189,40 +12189,38 @@ void Player_DrawGameplay(PlayState* play, Player* this, s32 lod, Gfx* cullDList, Player_PostLimbDrawGameplay, this); if ((overrideLimbDraw == Player_OverrideLimbDrawGameplayDefault) && (this->currentMask != PLAYER_MASK_NONE)) { - Mtx* bunnyEarMtx = GRAPH_ALLOC(play->state.gfxCtx, 2 * sizeof(Mtx)); + Mtx* sp70 = GRAPH_ALLOC(play->state.gfxCtx, 2 * sizeof(Mtx)); if (this->currentMask == PLAYER_MASK_BUNNY) { - Vec3s earRot; + Vec3s sp68; - gSPSegment(POLY_OPA_DISP++, 0x0B, bunnyEarMtx); + gSPSegment(POLY_OPA_DISP++, 0x0B, sp70); - // Right ear - earRot.x = sBunnyEarKinematics.rot.y + 0x3E2; - earRot.y = sBunnyEarKinematics.rot.z + 0xDBE; - earRot.z = sBunnyEarKinematics.rot.x - 0x348A; - Matrix_SetTranslateRotateYXZ(97.0f, -1203.0f, -240.0f, &earRot); - MATRIX_TO_MTX(bunnyEarMtx++, "../z_player.c", 19273); + sp68.x = D_80858AC8.unk_02 + 0x3E2; + sp68.y = D_80858AC8.unk_04 + 0xDBE; + sp68.z = D_80858AC8.unk_00 - 0x348A; + Matrix_SetTranslateRotateYXZ(97.0f, -1203.0f, -240.0f, &sp68); + MATRIX_TO_MTX(sp70++, "../z_player.c", 19273); - // Left ear - earRot.x = sBunnyEarKinematics.rot.y - 0x3E2; - earRot.y = -sBunnyEarKinematics.rot.z - 0xDBE; - earRot.z = sBunnyEarKinematics.rot.x - 0x348A; - Matrix_SetTranslateRotateYXZ(97.0f, -1203.0f, 240.0f, &earRot); - MATRIX_TO_MTX(bunnyEarMtx, "../z_player.c", 19279); + sp68.x = D_80858AC8.unk_02 - 0x3E2; + sp68.y = -0xDBE - D_80858AC8.unk_04; + sp68.z = D_80858AC8.unk_00 - 0x348A; + Matrix_SetTranslateRotateYXZ(97.0f, -1203.0f, 240.0f, &sp68); + MATRIX_TO_MTX(sp70, "../z_player.c", 19279); } gSPDisplayList(POLY_OPA_DISP++, sMaskDlists[this->currentMask - 1]); } if ((this->currentBoots == PLAYER_BOOTS_HOVER) && !(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && - !(this->stateFlags1 & PLAYER_STATE1_23) && ((u32)this->hoverBootsTimer != 0)) { + !(this->stateFlags1 & PLAYER_STATE1_23) && ((u32)this->unk_893 != 0)) { static s32 D_8085486C = 255; - if (this->hoverBootsTimer < 19) { - if (this->hoverBootsTimer >= 15) { - D_8085486C = (19 - this->hoverBootsTimer) * 51.0f; - } else if (this->hoverBootsTimer < 19) { - s32 sp5C = this->hoverBootsTimer; + if (this->unk_893 < 19) { + if (this->unk_893 >= 15) { + D_8085486C = (19 - this->unk_893) * 51.0f; + } else if (this->unk_893 < 19) { + s32 sp5C = this->unk_893; if (sp5C > 9) { sp5C = 9; @@ -12633,10 +12631,10 @@ void Player_Action_8084B78C(Player* this, PlayState* play) { void func_8084B840(PlayState* play, Player* this, f32 arg2) { if (this->actor.wallBgId != BGCHECK_SCENE) { - DynaPolyActor* dynaPolyActor = DynaPoly_GetActor(&play->colCtx, this->actor.wallBgId); + DynaPolyActor* dynaActor = DynaPoly_GetActor(&play->colCtx, this->actor.wallBgId); - if (dynaPolyActor != NULL) { - func_8002DFA4(dynaPolyActor, arg2, this->actor.world.rot.y); + if (dynaActor != NULL) { + func_8002DFA4(dynaActor, arg2, this->actor.world.rot.y); } } } @@ -14042,7 +14040,7 @@ void Player_Action_8084EAC0(Player* this, PlayState* play) { } typedef enum BottleCatchType { - BOTTLE_CATCH_NONE, // This type does not have an associated entry in `sBottleCatchInfo` + BOTTLE_CATCH_NONE, // This type does not have an associated entry in `D_80854A04` BOTTLE_CATCH_FAIRY, BOTTLE_CATCH_FISH, BOTTLE_CATCH_BLUE_FIRE, @@ -14056,11 +14054,11 @@ typedef struct BottleCatchInfo { /* 0x04 */ u8 textId; } BottleCatchInfo; // size = 0x06 -static BottleCatchInfo sBottleCatchInfo[] = { - { ACTOR_EN_ELF, ITEM_BOTTLE_FAIRY, PLAYER_IA_BOTTLE_FAIRY, 0x46 }, // BOTTLE_CATCH_FAIRY - { ACTOR_EN_FISH, ITEM_BOTTLE_FISH, PLAYER_IA_BOTTLE_FISH, 0x47 }, // BOTTLE_CATCH_FISH - { ACTOR_EN_ICE_HONO, ITEM_BOTTLE_BLUE_FIRE, PLAYER_IA_BOTTLE_FIRE, 0x5D }, // BOTTLE_CATCH_BLUE_FIRE - { ACTOR_EN_INSECT, ITEM_BOTTLE_BUG, PLAYER_IA_BOTTLE_BUG, 0x7A }, // BOTTLE_CATCH_BUGS +static BottleCatchInfo D_80854A04[] = { + { ACTOR_EN_ELF, ITEM_BOTTLE_FAIRY, 0x2A, 0x46 }, // BOTTLE_CATCH_FAIRY + { ACTOR_EN_FISH, ITEM_BOTTLE_FISH, 0x1F, 0x47 }, // BOTTLE_CATCH_FISH + { ACTOR_EN_ICE_HONO, ITEM_BOTTLE_BLUE_FIRE, 0x20, 0x5D }, // BOTTLE_CATCH_BLUE_FIRE + { ACTOR_EN_INSECT, ITEM_BOTTLE_BUG, 0x21, 0x7A }, // BOTTLE_CATCH_BUGS }; void Player_Action_SwingBottle(Player* this, PlayState* play) { @@ -14074,8 +14072,8 @@ void Player_Action_SwingBottle(Player* this, PlayState* play) { if (LinkAnimation_Update(play, &this->skelAnime)) { if (this->av1.bottleCatchType != BOTTLE_CATCH_NONE) { if (!this->av2.startedTextbox) { - // 1 is subtracted because `sBottleCatchInfo` does not have an entry for `BOTTLE_CATCH_NONE` - Message_StartTextbox(play, sBottleCatchInfo[this->av1.bottleCatchType - 1].textId, &this->actor); + // 1 is subtracted because `D_80854A04` does not have an entry for `BOTTLE_CATCH_NONE` + Message_StartTextbox(play, D_80854A04[this->av1.bottleCatchType - 1].textId, &this->actor); Audio_PlayFanfare(NA_BGM_ITEM_GET | 0x900); this->av2.startedTextbox = true; } else if (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) { @@ -14096,18 +14094,18 @@ void Player_Action_SwingBottle(Player* this, PlayState* play) { // `interactRangeActor` will be set by the Get Item system. See `Actor_OfferGetItem`. if (this->interactRangeActor != NULL) { - BottleCatchInfo* catchInfo = &sBottleCatchInfo[0]; + BottleCatchInfo* catchInfo = &D_80854A04[0]; s32 i; - // Try to find an `interactRangeActor` with the same ID as an entry in `sBottleCatchInfo` - for (i = 0; i < ARRAY_COUNT(sBottleCatchInfo); i++, catchInfo++) { + // Try to find an `interactRangeActor` with the same ID as an entry in `D_80854A04` + for (i = 0; i < ARRAY_COUNT(D_80854A04); i++, catchInfo++) { if (this->interactRangeActor->id == catchInfo->actorId) { break; } } - if (i < ARRAY_COUNT(sBottleCatchInfo)) { - // 1 is added because `sBottleCatchInfo` does not have an entry for `BOTTLE_CATCH_NONE` + if (i < ARRAY_COUNT(D_80854A04)) { + // 1 is added because `D_80854A04` does not have an entry for `BOTTLE_CATCH_NONE` this->av1.bottleCatchType = i + 1; this->av2.startedTextbox = false; @@ -14122,11 +14120,8 @@ void Player_Action_SwingBottle(Player* this, PlayState* play) { } } - //! @bug If the animation is changed at any point above (such as by func_8083C0E8() or - //! Player_AnimPlayOnceAdjusted()), it will change the curFrame to 0. This causes this flag to be set for one frame, - //! at a time when it does not look like Player is swinging the bottle. if (this->skelAnime.curFrame <= 7.0f) { - this->stateFlags1 |= PLAYER_STATE1_SWINGING_BOTTLE; + this->stateFlags1 |= PLAYER_STATE1_1; } } @@ -14585,50 +14580,44 @@ void func_8084FF7C(Player* this) { } } -/** - * Updates the Bunny Hood's floppy ears' rotation and velocity. - */ -void Player_UpdateBunnyEars(Player* this) { - Vec3s force; - s16 angle; +void func_8085002C(Player* this) { + STACK_PAD(s32); + s16 sp2A; + s16 sp28; + s16 sp26; - // Damping: decay by 1/8 the previous value each frame - sBunnyEarKinematics.angVel.x -= sBunnyEarKinematics.angVel.x >> 3; - sBunnyEarKinematics.angVel.y -= sBunnyEarKinematics.angVel.y >> 3; + D_80858AC8.unk_06 -= D_80858AC8.unk_06 >> 3; + D_80858AC8.unk_08 -= D_80858AC8.unk_08 >> 3; + D_80858AC8.unk_06 += -D_80858AC8.unk_00 >> 2; + D_80858AC8.unk_08 += -D_80858AC8.unk_02 >> 2; - // Elastic restorative force - sBunnyEarKinematics.angVel.x += -sBunnyEarKinematics.rot.x >> 2; - sBunnyEarKinematics.angVel.y += -sBunnyEarKinematics.rot.y >> 2; + sp26 = this->actor.world.rot.y - this->actor.shape.rot.y; - // Forcing from motion relative to shape frame - angle = this->actor.world.rot.y - this->actor.shape.rot.y; - force.x = (s32)(this->actor.speed * -200.0f * Math_CosS(angle) * (Rand_CenteredFloat(2.0f) + 10.0f)) & 0xFFFF; - force.y = (s32)(this->actor.speed * 100.0f * Math_SinS(angle) * (Rand_CenteredFloat(2.0f) + 10.0f)) & 0xFFFF; + sp28 = (s32)(this->actor.speed * -200.0f * Math_CosS(sp26) * (Rand_CenteredFloat(2.0f) + 10.0f)) & 0xFFFF; + sp2A = (s32)(this->actor.speed * 100.0f * Math_SinS(sp26) * (Rand_CenteredFloat(2.0f) + 10.0f)) & 0xFFFF; - sBunnyEarKinematics.angVel.x += force.x >> 2; - sBunnyEarKinematics.angVel.y += force.y >> 2; + D_80858AC8.unk_06 += sp28 >> 2; + D_80858AC8.unk_08 += sp2A >> 2; - // Clamp both angular velocities to [-6000, 6000] - if (sBunnyEarKinematics.angVel.x > 6000) { - sBunnyEarKinematics.angVel.x = 6000; - } else if (sBunnyEarKinematics.angVel.x < -6000) { - sBunnyEarKinematics.angVel.x = -6000; + if (D_80858AC8.unk_06 > 6000) { + D_80858AC8.unk_06 = 6000; + } else if (D_80858AC8.unk_06 < -6000) { + D_80858AC8.unk_06 = -6000; } - if (sBunnyEarKinematics.angVel.y > 6000) { - sBunnyEarKinematics.angVel.y = 6000; - } else if (sBunnyEarKinematics.angVel.y < -6000) { - sBunnyEarKinematics.angVel.y = -6000; + + if (D_80858AC8.unk_08 > 6000) { + D_80858AC8.unk_08 = 6000; + } else if (D_80858AC8.unk_08 < -6000) { + D_80858AC8.unk_08 = -6000; } - // Add angular velocity to rotations - sBunnyEarKinematics.rot.x += sBunnyEarKinematics.angVel.x; - sBunnyEarKinematics.rot.y += sBunnyEarKinematics.angVel.y; + D_80858AC8.unk_00 += D_80858AC8.unk_06; + D_80858AC8.unk_02 += D_80858AC8.unk_08; - // swivel ears outwards if bending backwards - if (sBunnyEarKinematics.rot.x < 0) { - sBunnyEarKinematics.rot.z = sBunnyEarKinematics.rot.x >> 1; + if (D_80858AC8.unk_00 < 0) { + D_80858AC8.unk_04 = D_80858AC8.unk_00 >> 1; } else { - sBunnyEarKinematics.rot.z = 0; + D_80858AC8.unk_04 = 0; } } diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_choose.c b/src/overlays/gamestates/ovl_file_choose/z_file_choose.c index cb98b7de76a..eebb1349f59 100644 --- a/src/overlays/gamestates/ovl_file_choose/z_file_choose.c +++ b/src/overlays/gamestates/ovl_file_choose/z_file_choose.c @@ -546,7 +546,7 @@ void FileSelect_UpdateMainMenu(GameState* thisx) { this->newFileNameCharCount = 0; this->nameEntryBoxPosX = 120; this->nameEntryBoxAlpha = 0; - MemCopy(&this->fileNames[this->buttonIndex][0], &emptyName, sizeof(emptyName)); + MemCopy(&this->fileNames[this->buttonIndex][0], &emptyName, 8); } else if (this->n64ddFlags[this->buttonIndex] == this->n64ddFlag) { SFX_PLAY_CENTERED(NA_SE_SY_FSEL_DECIDE_L); this->actionTimer = 8; diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.c index 7432fb0a3bc..b6be3308bb8 100644 --- a/src/overlays/gamestates/ovl_title/z_title.c +++ b/src/overlays/gamestates/ovl_title/z_title.c @@ -33,15 +33,15 @@ #include "assets/textures/nintendo_rogo_static/nintendo_rogo_static.h" #if DEBUG_FEATURES -void ConsoleLogo_PrintBuildInfo(Gfx** gfxP) { - Gfx* gfx; +void ConsoleLogo_PrintBuildInfo(Gfx** gfxp) { + Gfx* g; GfxPrint* printer; - gfx = *gfxP; - gfx = Gfx_SetupDL_28(gfx); + g = *gfxp; + g = Gfx_SetupDL_28(g); printer = alloca(sizeof(GfxPrint)); GfxPrint_Init(printer); - GfxPrint_Open(printer, gfx); + GfxPrint_Open(printer, g); GfxPrint_SetColor(printer, 255, 155, 255, 255); GfxPrint_SetPos(printer, 9, 21); GfxPrint_Printf(printer, "NOT MARIO CLUB VERSION"); @@ -50,9 +50,9 @@ void ConsoleLogo_PrintBuildInfo(Gfx** gfxP) { GfxPrint_Printf(printer, "[Creator:%s]", gBuildCreator); GfxPrint_SetPos(printer, 7, 24); GfxPrint_Printf(printer, "[Date:%s]", gBuildDate); - gfx = GfxPrint_Close(printer); + g = GfxPrint_Close(printer); GfxPrint_Destroy(printer); - *gfxP = gfx; + *gfxp = g; } #endif diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_debug.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_debug.c index 269bc58159c..19b85169e53 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_debug.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_debug.c @@ -175,12 +175,12 @@ static s16 sSlotItems[] = { ITEM_BOOMERANG, ITEM_LENS_OF_TRUTH, ITEM_MAGIC_BEAN, ITEM_HAMMER, ITEM_ARROW_LIGHT, ITEM_NAYRUS_LOVE, }; -void KaleidoScope_DrawInventoryEditorText(Gfx** gfxP) { +void KaleidoScope_DrawInventoryEditorText(Gfx** gfxp) { GfxPrint printer; STACK_PADS(s32, 2); GfxPrint_Init(&printer); - GfxPrint_Open(&printer, *gfxP); + GfxPrint_Open(&printer, *gfxp); GfxPrint_SetPos(&printer, 4, 2); GfxPrint_SetColor(&printer, 255, 60, 0, 255); @@ -216,7 +216,7 @@ void KaleidoScope_DrawInventoryEditorText(Gfx** gfxP) { GfxPrint_SetPos(&printer, 28, 24); GfxPrint_Printf(&printer, "%s", "/4"); - *gfxP = GfxPrint_Close(&printer); + *gfxp = GfxPrint_Close(&printer); GfxPrint_Destroy(&printer); } diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.c index f41a29510c3..12ea07dd5f7 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.c @@ -42,8 +42,8 @@ #endif #include "assets/textures/icon_item_gameover_static/icon_item_gameover_static.h" -#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ntsc-1.0:0 ntsc-1.1:0 ntsc-1.2:0 pal-1.0:0 pal-1.1:0" +#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ntsc-1.0:0" \ + "ntsc-1.1:0 ntsc-1.2:0 pal-1.0:0 pal-1.1:0" #if !PLATFORM_GC #define KALEIDO_PROMPT_CURSOR_R 100 diff --git a/tools/assets/extract/extase_oot64/skelcurve_resources.py b/tools/assets/extract/extase_oot64/skelcurve_resources.py index 1eed98884b3..501a51d8232 100644 --- a/tools/assets/extract/extase_oot64/skelcurve_resources.py +++ b/tools/assets/extract/extase_oot64/skelcurve_resources.py @@ -50,7 +50,7 @@ def get_h_includes(self): return ("ultra64.h",) -class CurveInterpKnotArrayResource(CDataResource, can_size_be_unknown=True): +class TransformDataArrayResource(CDataResource, can_size_be_unknown=True): elem_cdata_ext = CDataExt_Struct( ( ("flags", CDataExt_Value.u16), @@ -74,7 +74,7 @@ def try_parse_data(self, memory_context: "MemoryContext"): raise ResourceParseWaiting(waiting_for=["self.length"]) def get_c_declaration_base(self): - return f"CurveInterpKnot {self.symbol_name}[]" + return f"TransformData {self.symbol_name}[]" def get_c_reference(self, resource_offset: int): if resource_offset == 0: @@ -83,7 +83,7 @@ def get_c_reference(self, resource_offset: int): raise ValueError() def get_h_includes(self): - return ("curve.h",) + return ("animation_curve.h",) class ConstantDataArrayResource(CDataResource, can_size_be_unknown=True): @@ -114,7 +114,7 @@ def get_h_includes(self): return ("ultra64.h",) -class CurveAnimationHeaderResource(CDataResource): +class TransformUpdateIndexResource(CDataResource): def report_knotCounts(resource, memory_context: "MemoryContext", v): assert isinstance(v, int) address = v @@ -142,8 +142,8 @@ def report_interpolationData(resource, memory_context: "MemoryContext", v): memory_context.report_resource_at_segmented( resource, address, - CurveInterpKnotArrayResource, - lambda file, offset: CurveInterpKnotArrayResource( + TransformDataArrayResource, + lambda file, offset: TransformDataArrayResource( file, offset, f"{resource.name}_{address:08X}_InterpolationData" ), ) @@ -191,7 +191,7 @@ def write_constantData( CDataExt_Value("I") .set_report(report_interpolationData) .set_write(write_interpolationData), - ), # CurveInterpKnot* + ), # TransformData* ( "constantData", CDataExt_Value("I") @@ -213,7 +213,7 @@ def try_parse_data(self, memory_context): ) resource_interpolationData = memory_context.resolve_segmented( interpolationData - ).get_resource(CurveInterpKnotArrayResource) + ).get_resource(TransformDataArrayResource) resource_constantData = memory_context.resolve_segmented( constantData ).get_resource(ConstantDataArrayResource) @@ -248,13 +248,13 @@ def try_parse_data(self, memory_context): raise NotImplementedError def get_c_declaration_base(self): - return f"CurveAnimationHeader {self.symbol_name}" + return f"TransformUpdateIndex {self.symbol_name}" def get_c_reference(self, resource_offset: int): raise ValueError() def get_h_includes(self): - return ("curve.h",) + return ("animation_curve.h",) class SkelCurveLimbResource(CDataResource): @@ -283,7 +283,7 @@ def get_c_reference(self, resource_offset: int): raise ValueError() def get_h_includes(self): - return ("curve.h",) + return ("animation_curve.h",) class SkelCurveLimbArrayResource(CDataResource): @@ -328,10 +328,10 @@ def get_c_reference(self, resource_offset: int): raise ValueError() def get_h_includes(self): - return ("curve.h",) + return ("animation_curve.h",) -class CurveSkeletonHeaderResource(CDataResource): +class SkelCurveLimbListResource(CDataResource): def report_limbs(resource, memory_context: "MemoryContext", v): assert isinstance(v, int) address = v @@ -369,10 +369,10 @@ def write_limbs( ) def get_c_declaration_base(self): - return f"CurveSkeletonHeader {self.symbol_name}" + return f"SkelCurveLimbList {self.symbol_name}" def get_c_reference(self, resource_offset: int): raise ValueError() def get_h_includes(self): - return ("curve.h",) + return ("animation_curve.h",) diff --git a/tools/assets/extract/write_source.txt b/tools/assets/extract/write_source.txt index 236acb241d1..36cafcbe295 100644 --- a/tools/assets/extract/write_source.txt +++ b/tools/assets/extract/write_source.txt @@ -345,6 +345,7 @@ assets/objects/object_torch2/object_torch2.c assets/objects/object_toryo/object_toryo.c assets/objects/object_tp/object_tp.c assets/objects/object_trap/object_trap.c +assets/objects/object_triforce_spot/object_triforce_spot.c assets/objects/object_tr/object_tr.c assets/objects/object_ts/object_ts.c assets/objects/object_tsubo/object_tsubo.c @@ -370,6 +371,7 @@ assets/overlays/ovl_Boss_Sst/ovl_Boss_Sst.c assets/overlays/ovl_Demo_Shd/ovl_Demo_Shd.c assets/overlays/ovl_En_Bili/ovl_En_Bili.c assets/overlays/ovl_En_Clear_Tag/ovl_En_Clear_Tag.c +assets/overlays/ovl_En_Ganon_Organ/ovl_En_Ganon_Organ.c assets/overlays/ovl_En_Mag/ovl_En_Mag.c assets/overlays/ovl_En_Sda/ovl_En_Sda.c assets/overlays/ovl_En_Ssh/ovl_En_Ssh.c diff --git a/tools/assets/extract/z64_resource_handlers.py b/tools/assets/extract/z64_resource_handlers.py index 0298c901021..ac51493f5ea 100644 --- a/tools/assets/extract/z64_resource_handlers.py +++ b/tools/assets/extract/z64_resource_handlers.py @@ -107,7 +107,7 @@ def skeleton_resource_handler( ) elif resource_desc.limb_type == z64resources.LimbType.CURVE: assert resource_desc.type == z64resources.SkeletonType.CURVE - res = skelcurve_resources.CurveSkeletonHeaderResource( + res = skelcurve_resources.SkelCurveLimbListResource( file, offset, resource_desc.symbol_name ) else: @@ -116,7 +116,7 @@ def skeleton_resource_handler( resource_desc.limb_type, ) # TODO check is this works for SkeletonSkinResource - # TODO implement for CurveSkeletonHeaderResource + # TODO implement for SkelCurveLimbListResource if resource_desc.limb_enum_name is not None: res.set_enum_name(resource_desc.limb_enum_name) if resource_desc.limb_enum_none_member_name is not None: @@ -364,7 +364,7 @@ def CurveAnimation_handler( resource_desc: z64resources.CurveAnimationResourceDesc, ): # TODO use resource_desc.skeleton - return skelcurve_resources.CurveAnimationHeaderResource( + return skelcurve_resources.TransformUpdateIndexResource( file, resource_desc.offset, resource_desc.symbol_name ) diff --git a/tools/fix_bss.py b/tools/fix_bss.py index d6200a3576b..60f28b00886 100755 --- a/tools/fix_bss.py +++ b/tools/fix_bss.py @@ -230,7 +230,6 @@ def resolver(x: Path) -> Path|None: if not ( mapfile_segment.name.startswith("..boot") or mapfile_segment.name.startswith("..code") - or mapfile_segment.name.startswith("..n64dd") or mapfile_segment.name.startswith("..ovl_") ): continue diff --git a/tools/m2ctx.py b/tools/m2ctx.py index 3b2c537a302..bcee5a1e6d8 100755 --- a/tools/m2ctx.py +++ b/tools/m2ctx.py @@ -3,7 +3,6 @@ import os import sys import subprocess -import argparse from pathlib import Path script_dir = os.path.dirname(os.path.realpath(__file__)) @@ -24,10 +23,9 @@ def get_c_file(directory): if file.endswith(".c") and "data" not in file: return file - def import_c_file(in_file, version): in_file = os.path.relpath(in_file, root_dir) - cpp_command = ["gcc", "-nostdinc", "-E", "-P", "-Iinclude", "-Iinclude/libc", "-Isrc", f"-Ibuild/{version}", "-I.", f"-Iextracted/{version}", "-undef", "-DM2CTX", "-D__sgi", "-D_LANGUAGE_C", + cpp_command = ["cpp", "-nostdinc", "-P", "-Iinclude", "-Iinclude/libc", "-Isrc", f"-Ibuild/{version}", "-I.", f"-Iextracted/{version}", "-undef", "-DM2CTX", "-D__sgi", "-D_LANGUAGE_C", "-DNON_MATCHING", "-D_Static_assert(x, y)=", "-D__attribute__(x)=", in_file] try: return subprocess.check_output(cpp_command, cwd=root_dir, encoding="utf-8") @@ -36,33 +34,28 @@ def import_c_file(in_file, version): "Failed to preprocess input file, when running command:\n" + " ".join(cpp_command), file=sys.stderr, - ) + ) sys.exit(1) - def main(): - parser = argparse.ArgumentParser(usage="./m2ctx.py path/to/file.c or ./m2ctx.py (from an actor or gamestate's asm dir)", - description="Creates a ctx.c file for mips2c. " - "Output will be saved as oot/ctx.c") - parser.add_argument('filepath', help="path of c file to be processed") - parser.add_argument("-v", "--version", dest="oot_version", required=True) - args = parser.parse_args() - - version = args.oot_version - - if args.filepath: - c_file_path = args.filepath - print("Using file: {}".format(c_file_path)) + version = "gc-eu-mq-dbg" + if len(sys.argv) > 1: + arg = sys.argv[1] + if arg == "-h" or arg == "--help": + sys.exit("Usage: ./m2ctx.py path/to/file.c [version]\n" \ + "or ./m2ctx.py (from an actor or gamestate's asm dir)\n" \ + "Output will be saved in oot/ctx.c") + c_file_path = Path.cwd() / sys.argv[1] + if len(sys.argv) > 2: + version = sys.argv[2] else: this_dir = Path.cwd() c_dir_path = get_c_dir(this_dir.name) if c_dir_path is None: - sys.exit( - "Cannot find appropriate c file dir. In argumentless mode, run this script from the c file's corresponding asm dir.") + sys.exit("Cannot find appropriate c file dir. In argumentless mode, run this script from the c file's corresponding asm dir.") c_file = get_c_file(c_dir_path) c_file_path = os.path.join(c_dir_path, c_file) - print("Using file: {}".format(c_file_path)) - + output = import_c_file(c_file_path, version) with open(os.path.join(root_dir, "ctx.c"), "w", encoding="UTF-8") as f: diff --git a/tools/mkdmadata.c b/tools/mkdmadata.c index 7e55b71a17c..ab27d7ad9aa 100644 --- a/tools/mkdmadata.c +++ b/tools/mkdmadata.c @@ -9,7 +9,7 @@ #include "spec.h" #include "util.h" -struct Segment* g_segments; +Segment* g_segments; int g_segmentsCount; static void write_dmadata_table(FILE *fout) @@ -103,7 +103,6 @@ int main(int argc, char **argv) write_compress_ranges(compress_ranges_out); fclose(compress_ranges_out); - free_rom_spec(g_segments, g_segmentsCount); free(spec); return 0; diff --git a/tools/mkldscript.c b/tools/mkldscript.c index 3351298838a..654965ac16f 100644 --- a/tools/mkldscript.c +++ b/tools/mkldscript.c @@ -9,10 +9,10 @@ #include "spec.h" #include "util.h" -struct Segment *g_segments; +Segment *g_segments; int g_segmentsCount; -static void write_includes(const struct Segment *seg, FILE *fout, const char *segments_dir, const char *section) +static void write_includes(const Segment *seg, FILE *fout, const char *segments_dir, const char *section) { // Note sections contain a suffix wildcard as compilers other than IDO such as GCC may emit sections titled // e.g. .rodata.cstN, .rodata.strN.M, .text.FUNCNAME depending on their settings. @@ -94,7 +94,7 @@ static void write_ld_script(FILE *fout, uint32_t entrypoint_addr, const char *ma uint32_t last_romalign = 0; for (i = 0; i < g_segmentsCount; i++) { - const struct Segment *seg = &g_segments[i]; + const Segment *seg = &g_segments[i]; fprintf(fout, " /* %s */\n\n", seg->name); @@ -310,7 +310,6 @@ int main(int argc, char **argv) write_ld_script(ldout, entrypoint_addr, argv[3], argv[4]); fclose(ldout); - free_rom_spec(g_segments, g_segmentsCount); free(spec); return EXIT_SUCCESS; } diff --git a/tools/mkspecrules.c b/tools/mkspecrules.c index 16c84111cdb..b05f3d8cf5f 100644 --- a/tools/mkspecrules.c +++ b/tools/mkspecrules.c @@ -6,10 +6,10 @@ #include "spec.h" #include "util.h" -struct Segment* g_segments; +Segment* g_segments; int g_segmentsCount; -static void write_progbits_section(FILE *fout, struct Segment *seg, const char *section_name, bool with_padding) +static void write_progbits_section(FILE *fout, Segment *seg, const char *section_name, bool with_padding) { fprintf(fout, " .%s :\n {\n", section_name); @@ -22,7 +22,7 @@ static void write_progbits_section(FILE *fout, struct Segment *seg, const char * fprintf(fout, " }\n"); } -static void write_noload_section(FILE *fout, struct Segment *seg, const char *section_name) +static void write_noload_section(FILE *fout, Segment *seg, const char *section_name) { fprintf(fout, " .%s (NOLOAD) :\n {\n", section_name); @@ -39,7 +39,7 @@ static void write_noload_section(FILE *fout, struct Segment *seg, const char *se * however in the iQue version we have bss files that are created partway through linking that need * special handling in the linker script. */ -static void write_linker_script(FILE *fout, struct Segment *seg) +static void write_linker_script(FILE *fout, Segment *seg) { fprintf(fout, "OUTPUT_ARCH (mips)\n" diff --git a/tools/n64chksum.h b/tools/n64chksum.h index f5b73be49c6..0ca13a819b2 100644 --- a/tools/n64chksum.h +++ b/tools/n64chksum.h @@ -1,7 +1,5 @@ -#ifndef N64CHKSUM_H -#define N64CHKSUM_H - -#include +#ifndef _N64CHKSUM_H_ +#define _N64CHKSUM_H_ bool n64chksum_calculate(const uint8_t *romData, int cicType, uint32_t *chksum); diff --git a/tools/namefixer.py b/tools/namefixer.py index 0877e2893ec..cae85f3b4b5 100755 --- a/tools/namefixer.py +++ b/tools/namefixer.py @@ -498,7 +498,7 @@ def replace_all(repo): file = subdir + os.sep + filename replace_single(file) -parser = argparse.ArgumentParser(description='Apply function renames to a file') +parser = argparse.ArgumentParser(description='Update to the new animation names') parser.add_argument('file', help="source file to be processed. use . to process the whole repo") if __name__ == "__main__": diff --git a/tools/permuter_settings.toml b/tools/permuter_settings.toml index 607781e3730..e9d1d979002 100644 --- a/tools/permuter_settings.toml +++ b/tools/permuter_settings.toml @@ -33,6 +33,10 @@ PRINTF = "void" SCHED_DEBUG_PRINTF = "void" ACTOR_DEBUG_PRINTF = "void" +PLAYER_LIMB_BUF_COUNT = "int" +"BGCHECKFLAG_.*" = "int" +GET_PLAYER = "void*" + [decompme.compilers] "tools/ido_recomp/*/7.1/cc" = "ido7.1" "tools/ido_recomp/*/5.3/cc" = "ido5.3" diff --git a/tools/spec.c b/tools/spec.c index 187549ead75..88da86ae5c7 100644 --- a/tools/spec.c +++ b/tools/spec.c @@ -11,9 +11,9 @@ #define ARRAY_COUNT(arr) (sizeof(arr) / sizeof(arr[0])) -static struct Segment *add_segment(struct Segment **segments, int *segments_count) +static Segment *add_segment(Segment **segments, int *segments_count) { - struct Segment *seg; + Segment *seg; (*segments_count)++; *segments = realloc(*segments, *segments_count * sizeof(**segments)); @@ -146,121 +146,25 @@ static const char *const stmtNames[] = [STMT_pad_text] = "pad_text", }; -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, const struct Segment *segments, int segment_count) { - // ensure no duplicates (except for 'include' or 'pad_text') - if (stmt != STMT_include && stmt != STMT_pad_text && - (currSeg->fields & (1 << stmt))) - util_fatal_error("line %i: duplicate '%s' statement", lineNum, stmtNames[stmt]); - - currSeg->fields |= 1 << stmt; - - // statements valid within a segment definition - switch (stmt) +static unsigned int parse_statement_name(const char *stmtName, int lineNum) +{ + unsigned int stmt; + for (stmt = 0; stmt < ARRAY_COUNT(stmtNames); 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: { - char *inc; - - if (!parse_quoted_string(args, &inc)) - util_fatal_error("line %i: invalid filename", lineNum); - - bool inc_is_dup = false; - for (int i = 0; i < segment_count; i++) { - for (int j = 0; j < segments[i].includesCount; j++) { - if (strcmp(segments[i].includes[j].fpath, inc) == 0) { - inc_is_dup = true; - } - } - } - - if (!inc_is_dup) { - currSeg->includesCount++; - currSeg->includes = realloc(currSeg->includes, currSeg->includesCount * sizeof(*currSeg->includes)); - currSeg->includes[currSeg->includesCount - 1].fpath = inc; - currSeg->includes[currSeg->includesCount - 1].linkerPadding = 0; + if (strcmp(stmtName, stmtNames[stmt]) == 0) + { + return stmt; } - } 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; + util_fatal_error("line %i: unknown statement '%s'", lineNum, stmtName); } -/** - * `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) +void parse_rom_spec(char *spec, Segment **segments, int *segment_count) { int lineNum = 1; char *line = spec; - struct Segment *currSeg = NULL; + Segment *currSeg = NULL; // iterate over lines while (line[0] != 0) @@ -276,13 +180,98 @@ void parse_rom_spec(char *spec, struct Segment **segments, int *segment_count) if (line[0] != 0 && stmtName[0] != 0) { char *args = token_split(stmtName); - STMTId stmt = get_stmt_id_by_stmt_name(stmtName, lineNum); + unsigned int stmt = parse_statement_name(stmtName, lineNum); if (currSeg != NULL) { - bool segmentEnded = parse_segment_statement(currSeg, stmt, args, lineNum, *segments, *segment_count); - if (segmentEnded) { + // ensure no duplicates (except for 'include' or 'pad_text') + if (stmt != STMT_include && stmt != STMT_pad_text && + (currSeg->fields & (1 << stmt))) + util_fatal_error("line %i: duplicate '%s' statement", lineNum, stmtName); + + currSeg->fields |= 1 << stmt; + + // 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: { + char *inc; + + if (!parse_quoted_string(args, &inc)) + util_fatal_error("line %i: invalid filename", lineNum); + + bool inc_is_dup = false; + for (int i = 0; i < *segment_count; i++) { + for (int j = 0; j < (*segments)[i].includesCount; j++) { + if (strcmp((*segments)[i].includes[j].fpath, inc) == 0) { + inc_is_dup = true; + } + } + } + + if (!inc_is_dup) { + currSeg->includesCount++; + currSeg->includes = realloc(currSeg->includes, currSeg->includesCount * sizeof(*currSeg->includes)); + currSeg->includes[currSeg->includesCount - 1].fpath = inc; + currSeg->includes[currSeg->includesCount - 1].linkerPadding = 0; + } + } 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 @@ -309,7 +298,7 @@ void parse_rom_spec(char *spec, struct Segment **segments, int *segment_count) } } -void free_rom_spec(struct Segment *segments, int segment_count) +void free_rom_spec(Segment *segments, int segment_count) { int i; diff --git a/tools/spec.h b/tools/spec.h index 96ca6c16f67..d2b6323eff1 100644 --- a/tools/spec.h +++ b/tools/spec.h @@ -1,10 +1,11 @@ #ifndef SPEC_H #define SPEC_H -#include #include +#include -typedef enum { +enum +{ STMT_address, STMT_after, STMT_align, @@ -20,9 +21,10 @@ typedef enum { STMT_stack, STMT_increment, STMT_pad_text, -} STMTId; +}; -enum { +enum +{ FLAG_BOOT = (1 << 0), FLAG_OBJECT = (1 << 1), FLAG_RAW = (1 << 2), @@ -31,15 +33,17 @@ enum { FLAG_OVL = (1 << 5) }; -struct Include { - char* fpath; +struct Include +{ + char *fpath; int linkerPadding; }; -typedef struct Segment { +typedef struct Segment +{ uint32_t fields; - char* name; - char* after; + char *name; + char *after; uint32_t flags; uint32_t address; uint32_t stack; @@ -48,13 +52,13 @@ typedef struct Segment { uint32_t increment; uint32_t entry; uint32_t number; - struct Include* includes; + struct Include *includes; int includesCount; bool compress; } Segment; -void parse_rom_spec(char* spec, struct Segment** segments, int* segment_count); +void parse_rom_spec(char *spec, Segment **segments, int *segment_count); -void free_rom_spec(struct Segment* segments, int segment_count); +void free_rom_spec(Segment *segments, int segment_count); #endif diff --git a/tools/util.c b/tools/util.c index 824e089e071..5886a201db9 100644 --- a/tools/util.c +++ b/tools/util.c @@ -12,18 +12,18 @@ void util_fatal_error(const char *msgfmt, ...) { va_list args; - fputs(ERRMSG_START, stderr); + fputs("\x1b[31m" "error: ", stderr); va_start(args, msgfmt); vfprintf(stderr, msgfmt, args); va_end(args); - fputs(ERRMSG_END "\n", stderr); + fputs("\x1b[m" "\n", stderr); exit(1); } -// reads a whole file into memory, and returns a malloc'd pointer to the data. +// 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"); diff --git a/tools/util.h b/tools/util.h index ed692bf53d2..82c7508a7d9 100644 --- a/tools/util.h +++ b/tools/util.h @@ -3,10 +3,6 @@ #include #include -#include - -#define ERRMSG_START "\x1b[91merror\x1b[97m: " -#define ERRMSG_END "\x1b[0m" #ifdef __GNUC__ __attribute__((format(printf, 1, 2), noreturn)) diff --git a/tools/vt_fmt.py b/tools/vt_fmt.py index 139ddb7d7ad..d7191d7028b 100755 --- a/tools/vt_fmt.py +++ b/tools/vt_fmt.py @@ -9,7 +9,7 @@ 'GREEN', 'YELLOW', 'BLUE', - 'PURPLE', + 'MAGENTA', 'CYAN', 'WHITE', ]