Refresh 1

master
n64 2019-09-01 15:50:50 -04:00
parent c6102eb802
commit 1ef98ec785
475 changed files with 100280 additions and 97252 deletions

View File

@ -1,4 +1,5 @@
IndentWidth: 4
Language: Cpp
AlignAfterOpenBracket: Align
SortIncludes: false
ColumnLimit: 104
@ -8,8 +9,10 @@ AllowShortIfStatementsOnASingleLine: false
BinPackArguments: true
BinPackParameters: true
SpaceAfterCStyleCast: true
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: true
BreakBeforeBinaryOperators: NonAssignment
Cpp11BracedListStyle: false
IndentCaseLabels: true
AlignTrailingComments: true
UseTab: Never

6
.clang-tidy Normal file
View File

@ -0,0 +1,6 @@
---
Checks: '-*,readability-braces-around-statements'
WarningsAsErrors: ''
HeaderFilterRegex: '(src|include|enhancements)\/.*\.h$'
FormatStyle: 'file'
CheckOptions:

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto
# List text files in case git doesn't characterize correctly
*.c text
*.h text
*.s text
*.in text
*.js text
*.md text
*.py text
*.sh text
*.ld text
*.inc text
*.txt text
*.json text
*.yaml text
# Same for binary
*.bin binary
*.m64 binary
*.png binary
*.aiff binary

25
CHANGES Normal file
View File

@ -0,0 +1,25 @@
Refresh #1
Changes from initial release:
1.) More README cleanups and documentation
2.) Fix .gitignore in tools/
3.) More README cleanups and corrections
4.) oUnk190 -> oInteractionSubtype
5.) Normalize line endings
6.) Replace bank_sets.s by sequences.json + build magic
7.) Fix tabledesign in .gitignore
8.) Cleaned and documented arrays in audio/
9.) Change minimum Python 3 requirement in README.md to 3.6
10.) Remove whitespace in ingame_menu.c, save_file.c, and star_select.c
11.) Documentation comment style fixed
12.) sm64.map -> sm64.version.map (ex: sm64.us.map)
13.) Decompile EU versions of HUD and obj behaviors
14.) Label ukiki.inc.c and ukiki_cage.inc.c
15.) Add missing OS header includes
16.) Fix alignment issue in model_ids.h
17.) A bunch of behavior changes:
a.) Made styles consistent with function names (ex: BehBehaviorLoop -> beh_behavior_loop)
b.) Split obj_behaviors_2.c into multiple .inc.c files in behaviors/
c.) bhvHauntedRoomCheck -> bhvCoffinManager
18.) Update README.md notes on WSL and add links
19.) Added tidy.sh and also bracing around single-line ifs and loops

View File

@ -173,7 +173,8 @@ SOUND_SAMPLE_TABLES := $(foreach file,$(SOUND_SAMPLE_AIFFS),$(BUILD_DIR)/$(file:
SOUND_SAMPLE_AIFCS := $(foreach file,$(SOUND_SAMPLE_AIFFS),$(BUILD_DIR)/$(file:.aiff=.aifc))
SOUND_OBJ_FILES := $(SOUND_BIN_DIR)/sound_data.ctl.o \
$(SOUND_BIN_DIR)/sound_data.tbl.o \
$(SOUND_BIN_DIR)/sequences.bin.o
$(SOUND_BIN_DIR)/sequences.bin.o \
$(SOUND_BIN_DIR)/bank_sets.o
# Object files
@ -222,7 +223,7 @@ ASFLAGS := -march=vr4300 -mabi=32 -I include -I $(BUILD_DIR) $(VERSION_ASFLAGS)
CFLAGS = -Wab,-r4300_mul -non_shared -G 0 -Xcpluscomm -Xfullwarn $(OPT_FLAGS) -signed -I include -I $(BUILD_DIR)/include -I src -D_LANGUAGE_C $(VERSION_CFLAGS) $(MIPSISET) $(GRUCODE_CFLAGS)
OBJCOPYFLAGS := --pad-to=0x800000 --gap-fill=0xFF
SYMBOL_LINKING_FLAGS := $(addprefix -R ,$(SEG_FILES))
LDFLAGS := -T undefined_syms.txt -T $(BUILD_DIR)/$(LD_SCRIPT) -Map $(BUILD_DIR)/sm64.map --no-check-sections $(SYMBOL_LINKING_FLAGS)
LDFLAGS := -T undefined_syms.txt -T $(BUILD_DIR)/$(LD_SCRIPT) -Map $(BUILD_DIR)/sm64.$(VERSION).map --no-check-sections $(SYMBOL_LINKING_FLAGS)
ifeq ($(shell getconf LONG_BIT), 32)
# Work around memory allocation bug in QEMU
@ -375,14 +376,17 @@ $(BUILD_DIR)/%.table: %.aiff
$(BUILD_DIR)/%.aifc: $(BUILD_DIR)/%.table %.aiff
$(VADPCM_ENC) -c $^ $@
$(SOUND_BIN_DIR)/sound_data.ctl: $(SOUND_BANK_FILES) $(SOUND_SAMPLE_AIFCS)
$(SOUND_BIN_DIR)/sound_data.ctl: sound/sound_banks/ $(SOUND_BANK_FILES) $(SOUND_SAMPLE_AIFCS)
$(PYTHON) tools/assemble_sound.py $(BUILD_DIR)/sound/samples/ sound/sound_banks/ $(SOUND_BIN_DIR)/sound_data.ctl $(SOUND_BIN_DIR)/sound_data.tbl $(VERSION_CFLAGS)
$(SOUND_BIN_DIR)/sound_data.tbl: $(SOUND_BIN_DIR)/sound_data.ctl
touch $@
$(SOUND_BIN_DIR)/sequences.bin: $(SOUND_SEQUENCE_FILES)
$(PYTHON) tools/assemble_sound.py --sequences $@ $^
$(SOUND_BIN_DIR)/sequences.bin: $(SOUND_BANK_FILES) sound/sequences.json sound/sequences/ sound/sequences/$(VERSION)/ $(SOUND_SEQUENCE_FILES)
$(PYTHON) tools/assemble_sound.py --sequences $@ $(SOUND_BIN_DIR)/bank_sets sound/sound_banks/ sound/sequences.json $(SOUND_SEQUENCE_FILES) $(VERSION_CFLAGS)
$(SOUND_BIN_DIR)/bank_sets: $(SOUND_BIN_DIR)/sequences.bin
touch $@
$(SOUND_BIN_DIR)/%.m64: $(SOUND_BIN_DIR)/%.o
$(OBJCOPY) -j .rodata $< -O binary $@

View File

@ -17,53 +17,56 @@ A prior copy of the game is required to extract the required assets.
### Linux
1. For each version (jp/us/eu) that you want to build a ROM for, put an existing ROM at
#### 1. Copy baserom(s) for asset extraction
For each version (jp/us/eu) that you want to build a ROM for, put an existing ROM at
`./baserom.<version>.z64` for asset extraction.
2. Install the following packages:
#### 2. Install build dependencies
The build system has the following package requirements:
* binutils-mips >= 2.27
* python3 >= 3.6
* libaudiofile
* qemu-irix
__Debian / Ubuntu__
* git
* binutils-mips-linux-gnu / mips64-elf (>= 2.27)
* python3 (>= 3.7)
* build-essential
* pkg-config
* zlib1g-dev
* libaudiofile-dev
```
sudo apt install build-essential pkg-config git binutils-mips-linux-gnu python3 zlib1g-dev libaudiofile-dev
```
__Arch Linux__
* base-devel
* python
* audiofile
```
sudo pacman -Sy base-devel python audiofile
```
Install the following AUR packages:
* [mips64-elf-binutils](https://aur.archlinux.org/packages/mips64-elf-binutils) (AUR)
* [qemu-irix-git](https://aur.archlinux.org/packages/qemu-irix-git) (AUR)
#### 3. Install qemu-irix
3. Install qemu-irix
3.a Options:
1. Clone https://github.com/n64decomp/qemu-irix to somewhere and follow its
install instructions in the README.
2. Optionally, grab the prebuilt qemu-irix from the Releases section.
1. Options:
1. Clone https://github.com/n64decomp/qemu-irix to somewhere and follow its install instructions in the README.
2. Optionally, grab the prebuilt qemu-irix from the [Releases](https://github.com/n64decomp/sm64/releases) section.
3. (Arch) Use AUR package [qemu-irix-git](https://aur.archlinux.org/packages/qemu-irix-git)
3.b (For options 1 or 2), copy executable `qemu-irix` from irix-linux-user to
somewhere convenient with a relatively short path.
2. (For the first two options), copy executable `qemu-irix` from irix-linux-user to
somewhere convenient with a relatively short path. e.g.:
```
mkdir -p /opt/qemu-irix/bin
cp irix-linux-user/qemu-irix /opt/qemu-irix/bin
```
3.c Define `QEMU_IRIX` environment variable in your `~/.bashrc` to point to
this qemu-irix executable.
3. Define `QEMU_IRIX` environment variable in your `~/.bashrc` to point to this qemu-irix executable.
```
export QEMU_IRIX=/opt/qemu-irix/bin/qemu-irix
```
6. Run `make` to build the ROM (defaults to us version). Make sure your path to
the repo is not too long or else this process will error, as the emulated
IDO compiler cannot handle paths longer than 255 characters.
Build examples:
#### 4. Build ROM
Run `make` to build the ROM (defaults to `VERSION=us`). Make sure your path to the repo
is not too long or else this process will error, as the emulated IDO compiler cannot
handle paths longer than 255 characters.
Examples:
```
make VERSION=jp -j4 # build (J) version instead with 4 jobs
make VERSION=eu COMPARE=0 # non-matching EU version still WIP
@ -71,7 +74,16 @@ make VERSION=eu COMPARE=0 # non-matching EU version still WIP
## Windows
For Windows, install WSL and a distro of your choice and follow the Linux guide.
For Windows, install WSL and a distro of your choice following
[Windows Subsystem for Linux Installation Guide for Windows 10](https://docs.microsoft.com/en-us/windows/wsl/install-win10)
We recommend either Debian or Ubuntu 18.04 Linux distributions under WSL.
Then follow the directions in the [Linux](#linux) installation section above.
## macOS
macOS is currently unsupported as qemu-irix is unable to be built for macOS host.
The recommended path is installing a Linux distribution under a VM.
## Contributing

View File

@ -1008,107 +1008,107 @@
"levels/wmotr/2.rgba16.png": [32,32,2048,{"jp":[4989632,3072],"us":[4997920,3072],"eu":[4876848,3072]}],
"levels/wmotr/3.rgba16.png": [32,8,512,{"jp":[4989632,5120],"us":[4997920,5120],"eu":[4876848,5120]}],
"levels/wmotr/4.rgba16.png": [8,32,512,{"jp":[4989632,5632],"us":[4997920,5632],"eu":[4876848,5632]}],
"sound/sequences/eu/seq_01.m64": [626,{"eu":[7954384]}],
"sound/sequences/eu/seq_02.m64": [8282,{"eu":[7955024]}],
"sound/sequences/eu/seq_03.m64": [5131,{"eu":[7963312]}],
"sound/sequences/eu/seq_04.m64": [2505,{"eu":[7968448]}],
"sound/sequences/eu/seq_05.m64": [4788,{"eu":[7970960]}],
"sound/sequences/eu/seq_06.m64": [2455,{"eu":[7975760]}],
"sound/sequences/eu/seq_07.m64": [3424,{"eu":[7978224]}],
"sound/sequences/eu/seq_08.m64": [8150,{"eu":[7981648]}],
"sound/sequences/eu/seq_09.m64": [7445,{"eu":[7989808]}],
"sound/sequences/eu/seq_0A.m64": [5681,{"eu":[7997264]}],
"sound/sequences/eu/seq_0B.m64": [1400,{"eu":[8002960]}],
"sound/sequences/eu/seq_0C.m64": [4899,{"eu":[8004368]}],
"sound/sequences/eu/seq_0D.m64": [138,{"eu":[8009280]}],
"sound/sequences/eu/seq_0E.m64": [3137,{"eu":[8009424]}],
"sound/sequences/eu/seq_0F.m64": [2779,{"eu":[8012576]}],
"sound/sequences/eu/seq_10.m64": [558,{"eu":[8015360]}],
"sound/sequences/eu/seq_11.m64": [4753,{"eu":[8015920]}],
"sound/sequences/eu/seq_12.m64": [275,{"eu":[8020688]}],
"sound/sequences/eu/seq_13.m64": [1660,{"eu":[8020976]}],
"sound/sequences/eu/seq_14.m64": [200,{"eu":[8022640]}],
"sound/sequences/eu/seq_15.m64": [649,{"eu":[8022848]}],
"sound/sequences/eu/seq_16.m64": [3444,{"eu":[8023504]}],
"sound/sequences/eu/seq_17.m64": [677,{"eu":[8026960]}],
"sound/sequences/eu/seq_18.m64": [1783,{"eu":[8027648]}],
"sound/sequences/eu/seq_19.m64": [3521,{"eu":[8029440]}],
"sound/sequences/eu/seq_1A.m64": [14328,{"eu":[8032976]}],
"sound/sequences/eu/seq_1B.m64": [219,{"eu":[8047312]}],
"sound/sequences/eu/seq_1C.m64": [211,{"eu":[8047536]}],
"sound/sequences/eu/seq_1D.m64": [436,{"eu":[8047760]}],
"sound/sequences/eu/seq_1E.m64": [1770,{"eu":[8048208]}],
"sound/sequences/eu/seq_1F.m64": [2066,{"eu":[8049984]}],
"sound/sequences/eu/seq_20.m64": [1887,{"eu":[8052064]}],
"sound/sequences/eu/seq_21.m64": [786,{"eu":[8053952]}],
"sound/sequences/eu/seq_22.m64": [317,{"eu":[8054752]}],
"sound/sequences/jp/seq_01.m64": [633,{"jp":[7639712]}],
"sound/sequences/jp/seq_02.m64": [8276,{"jp":[7640352]}],
"sound/sequences/jp/seq_03.m64": [5134,{"jp":[7648640]}],
"sound/sequences/jp/seq_04.m64": [2504,{"jp":[7653776]}],
"sound/sequences/jp/seq_05.m64": [4816,{"jp":[7656288]}],
"sound/sequences/jp/seq_06.m64": [2459,{"jp":[7661104]}],
"sound/sequences/jp/seq_07.m64": [3430,{"jp":[7663568]}],
"sound/sequences/jp/seq_08.m64": [8157,{"jp":[7667008]}],
"sound/sequences/jp/seq_09.m64": [7452,{"jp":[7675168]}],
"sound/sequences/jp/seq_0A.m64": [5686,{"jp":[7682624]}],
"sound/sequences/jp/seq_0B.m64": [1405,{"jp":[7688320]}],
"sound/sequences/jp/seq_0C.m64": [4905,{"jp":[7689728]}],
"sound/sequences/jp/seq_0D.m64": [138,{"jp":[7694640]}],
"sound/sequences/jp/seq_0E.m64": [3143,{"jp":[7694784]}],
"sound/sequences/jp/seq_0F.m64": [2786,{"jp":[7697936]}],
"sound/sequences/jp/seq_10.m64": [564,{"jp":[7700736]}],
"sound/sequences/jp/seq_11.m64": [4763,{"jp":[7701312]}],
"sound/sequences/jp/seq_12.m64": [279,{"jp":[7706080]}],
"sound/sequences/jp/seq_13.m64": [1663,{"jp":[7706368]}],
"sound/sequences/jp/seq_14.m64": [203,{"jp":[7708032]}],
"sound/sequences/jp/seq_15.m64": [654,{"jp":[7708240]}],
"sound/sequences/jp/seq_16.m64": [3451,{"jp":[7708896]}],
"sound/sequences/jp/seq_17.m64": [683,{"jp":[7712352]}],
"sound/sequences/jp/seq_18.m64": [1789,{"jp":[7713040]}],
"sound/sequences/jp/seq_19.m64": [3527,{"jp":[7714832]}],
"sound/sequences/jp/seq_1A.m64": [14341,{"jp":[7718368]}],
"sound/sequences/jp/seq_1B.m64": [222,{"jp":[7732720]}],
"sound/sequences/jp/seq_1C.m64": [214,{"jp":[7732944]}],
"sound/sequences/jp/seq_1D.m64": [440,{"jp":[7733168]}],
"sound/sequences/jp/seq_1E.m64": [1774,{"jp":[7733616]}],
"sound/sequences/jp/seq_1F.m64": [2074,{"jp":[7735392]}],
"sound/sequences/jp/seq_20.m64": [1892,{"jp":[7737472]}],
"sound/sequences/jp/seq_21.m64": [789,{"jp":[7739376]}],
"sound/sequences/us/seq_01.m64": [619,{"us":[8076816]}],
"sound/sequences/us/seq_02.m64": [8254,{"us":[8077440]}],
"sound/sequences/us/seq_03.m64": [5122,{"us":[8085696]}],
"sound/sequences/us/seq_04.m64": [2494,{"us":[8090832]}],
"sound/sequences/us/seq_05.m64": [4780,{"us":[8093328]}],
"sound/sequences/us/seq_06.m64": [2451,{"us":[8098112]}],
"sound/sequences/us/seq_07.m64": [3418,{"us":[8100576]}],
"sound/sequences/us/seq_08.m64": [8143,{"us":[8104000]}],
"sound/sequences/us/seq_09.m64": [7432,{"us":[8112144]}],
"sound/sequences/us/seq_0A.m64": [5674,{"us":[8119584]}],
"sound/sequences/us/seq_0B.m64": [1395,{"us":[8125264]}],
"sound/sequences/us/seq_0C.m64": [4887,{"us":[8126672]}],
"sound/sequences/us/seq_0D.m64": [134,{"us":[8131568]}],
"sound/sequences/us/seq_0E.m64": [3129,{"us":[8131712]}],
"sound/sequences/us/seq_0F.m64": [2770,{"us":[8134848]}],
"sound/sequences/us/seq_10.m64": [552,{"us":[8137632]}],
"sound/sequences/us/seq_11.m64": [4741,{"us":[8138192]}],
"sound/sequences/us/seq_12.m64": [271,{"us":[8142944]}],
"sound/sequences/us/seq_13.m64": [1657,{"us":[8143216]}],
"sound/sequences/us/seq_14.m64": [197,{"us":[8144880]}],
"sound/sequences/us/seq_15.m64": [644,{"us":[8145088]}],
"sound/sequences/us/seq_16.m64": [3435,{"us":[8145744]}],
"sound/sequences/us/seq_17.m64": [671,{"us":[8149184]}],
"sound/sequences/us/seq_18.m64": [1777,{"us":[8149856]}],
"sound/sequences/us/seq_19.m64": [3515,{"us":[8151648]}],
"sound/sequences/us/seq_1A.m64": [14313,{"us":[8155168]}],
"sound/sequences/us/seq_1B.m64": [216,{"us":[8169488]}],
"sound/sequences/us/seq_1C.m64": [208,{"us":[8169712]}],
"sound/sequences/us/seq_1D.m64": [432,{"us":[8169920]}],
"sound/sequences/us/seq_1E.m64": [1764,{"us":[8170352]}],
"sound/sequences/us/seq_1F.m64": [2058,{"us":[8172128]}],
"sound/sequences/us/seq_20.m64": [1882,{"us":[8174192]}],
"sound/sequences/us/seq_21.m64": [781,{"us":[8176080]}],
"sound/sequences/us/seq_22.m64": [313,{"us":[8176864]}],
"sound/sequences/eu/01_cutscene_collect_star.m64": [626,{"eu":[7954384]}],
"sound/sequences/eu/02_menu_title_screen.m64": [8282,{"eu":[7955024]}],
"sound/sequences/eu/03_level_grass.m64": [5131,{"eu":[7963312]}],
"sound/sequences/eu/04_level_inside_castle.m64": [2505,{"eu":[7968448]}],
"sound/sequences/eu/05_level_water.m64": [4788,{"eu":[7970960]}],
"sound/sequences/eu/06_level_hot.m64": [2455,{"eu":[7975760]}],
"sound/sequences/eu/07_level_boss_koopa.m64": [3424,{"eu":[7978224]}],
"sound/sequences/eu/08_level_snow.m64": [8150,{"eu":[7981648]}],
"sound/sequences/eu/09_level_slide.m64": [7445,{"eu":[7989808]}],
"sound/sequences/eu/0A_level_spooky.m64": [5681,{"eu":[7997264]}],
"sound/sequences/eu/0B_event_piranha_plant.m64": [1400,{"eu":[8002960]}],
"sound/sequences/eu/0C_level_underground.m64": [4899,{"eu":[8004368]}],
"sound/sequences/eu/0D_menu_star_select.m64": [138,{"eu":[8009280]}],
"sound/sequences/eu/0E_event_powerup.m64": [3137,{"eu":[8009424]}],
"sound/sequences/eu/0F_event_metal_cap.m64": [2779,{"eu":[8012576]}],
"sound/sequences/eu/10_event_koopa_message.m64": [558,{"eu":[8015360]}],
"sound/sequences/eu/11_level_koopa_road.m64": [4753,{"eu":[8015920]}],
"sound/sequences/eu/12_event_high_score.m64": [275,{"eu":[8020688]}],
"sound/sequences/eu/13_event_merry_go_round.m64": [1660,{"eu":[8020976]}],
"sound/sequences/eu/14_event_race.m64": [200,{"eu":[8022640]}],
"sound/sequences/eu/15_cutscene_star_spawn.m64": [649,{"eu":[8022848]}],
"sound/sequences/eu/16_event_boss.m64": [3444,{"eu":[8023504]}],
"sound/sequences/eu/17_cutscene_collect_key.m64": [677,{"eu":[8026960]}],
"sound/sequences/eu/18_event_endless_stairs.m64": [1783,{"eu":[8027648]}],
"sound/sequences/eu/19_level_boss_koopa_final.m64": [3521,{"eu":[8029440]}],
"sound/sequences/eu/1A_cutscene_credits.m64": [14328,{"eu":[8032976]}],
"sound/sequences/eu/1B_event_solve_puzzle.m64": [219,{"eu":[8047312]}],
"sound/sequences/eu/1C_event_toad_message.m64": [211,{"eu":[8047536]}],
"sound/sequences/eu/1D_event_peach_message.m64": [436,{"eu":[8047760]}],
"sound/sequences/eu/1E_cutscene_intro.m64": [1770,{"eu":[8048208]}],
"sound/sequences/eu/1F_cutscene_victory.m64": [2066,{"eu":[8049984]}],
"sound/sequences/eu/20_cutscene_ending.m64": [1887,{"eu":[8052064]}],
"sound/sequences/eu/21_menu_file_select.m64": [786,{"eu":[8053952]}],
"sound/sequences/eu/22_cutscene_lakitu.m64": [317,{"eu":[8054752]}],
"sound/sequences/jp/01_cutscene_collect_star.m64": [633,{"jp":[7639712]}],
"sound/sequences/jp/02_menu_title_screen.m64": [8276,{"jp":[7640352]}],
"sound/sequences/jp/03_level_grass.m64": [5134,{"jp":[7648640]}],
"sound/sequences/jp/04_level_inside_castle.m64": [2504,{"jp":[7653776]}],
"sound/sequences/jp/05_level_water.m64": [4816,{"jp":[7656288]}],
"sound/sequences/jp/06_level_hot.m64": [2459,{"jp":[7661104]}],
"sound/sequences/jp/07_level_boss_koopa.m64": [3430,{"jp":[7663568]}],
"sound/sequences/jp/08_level_snow.m64": [8157,{"jp":[7667008]}],
"sound/sequences/jp/09_level_slide.m64": [7452,{"jp":[7675168]}],
"sound/sequences/jp/0A_level_spooky.m64": [5686,{"jp":[7682624]}],
"sound/sequences/jp/0B_event_piranha_plant.m64": [1405,{"jp":[7688320]}],
"sound/sequences/jp/0C_level_underground.m64": [4905,{"jp":[7689728]}],
"sound/sequences/jp/0D_menu_star_select.m64": [138,{"jp":[7694640]}],
"sound/sequences/jp/0E_event_powerup.m64": [3143,{"jp":[7694784]}],
"sound/sequences/jp/0F_event_metal_cap.m64": [2786,{"jp":[7697936]}],
"sound/sequences/jp/10_event_koopa_message.m64": [564,{"jp":[7700736]}],
"sound/sequences/jp/11_level_koopa_road.m64": [4763,{"jp":[7701312]}],
"sound/sequences/jp/12_event_high_score.m64": [279,{"jp":[7706080]}],
"sound/sequences/jp/13_event_merry_go_round.m64": [1663,{"jp":[7706368]}],
"sound/sequences/jp/14_event_race.m64": [203,{"jp":[7708032]}],
"sound/sequences/jp/15_cutscene_star_spawn.m64": [654,{"jp":[7708240]}],
"sound/sequences/jp/16_event_boss.m64": [3451,{"jp":[7708896]}],
"sound/sequences/jp/17_cutscene_collect_key.m64": [683,{"jp":[7712352]}],
"sound/sequences/jp/18_event_endless_stairs.m64": [1789,{"jp":[7713040]}],
"sound/sequences/jp/19_level_boss_koopa_final.m64": [3527,{"jp":[7714832]}],
"sound/sequences/jp/1A_cutscene_credits.m64": [14341,{"jp":[7718368]}],
"sound/sequences/jp/1B_event_solve_puzzle.m64": [222,{"jp":[7732720]}],
"sound/sequences/jp/1C_event_toad_message.m64": [214,{"jp":[7732944]}],
"sound/sequences/jp/1D_event_peach_message.m64": [440,{"jp":[7733168]}],
"sound/sequences/jp/1E_cutscene_intro.m64": [1774,{"jp":[7733616]}],
"sound/sequences/jp/1F_cutscene_victory.m64": [2074,{"jp":[7735392]}],
"sound/sequences/jp/20_cutscene_ending.m64": [1892,{"jp":[7737472]}],
"sound/sequences/jp/21_menu_file_select.m64": [789,{"jp":[7739376]}],
"sound/sequences/us/01_cutscene_collect_star.m64": [619,{"us":[8076816]}],
"sound/sequences/us/02_menu_title_screen.m64": [8254,{"us":[8077440]}],
"sound/sequences/us/03_level_grass.m64": [5122,{"us":[8085696]}],
"sound/sequences/us/04_level_inside_castle.m64": [2494,{"us":[8090832]}],
"sound/sequences/us/05_level_water.m64": [4780,{"us":[8093328]}],
"sound/sequences/us/06_level_hot.m64": [2451,{"us":[8098112]}],
"sound/sequences/us/07_level_boss_koopa.m64": [3418,{"us":[8100576]}],
"sound/sequences/us/08_level_snow.m64": [8143,{"us":[8104000]}],
"sound/sequences/us/09_level_slide.m64": [7432,{"us":[8112144]}],
"sound/sequences/us/0A_level_spooky.m64": [5674,{"us":[8119584]}],
"sound/sequences/us/0B_event_piranha_plant.m64": [1395,{"us":[8125264]}],
"sound/sequences/us/0C_level_underground.m64": [4887,{"us":[8126672]}],
"sound/sequences/us/0D_menu_star_select.m64": [134,{"us":[8131568]}],
"sound/sequences/us/0E_event_powerup.m64": [3129,{"us":[8131712]}],
"sound/sequences/us/0F_event_metal_cap.m64": [2770,{"us":[8134848]}],
"sound/sequences/us/10_event_koopa_message.m64": [552,{"us":[8137632]}],
"sound/sequences/us/11_level_koopa_road.m64": [4741,{"us":[8138192]}],
"sound/sequences/us/12_event_high_score.m64": [271,{"us":[8142944]}],
"sound/sequences/us/13_event_merry_go_round.m64": [1657,{"us":[8143216]}],
"sound/sequences/us/14_event_race.m64": [197,{"us":[8144880]}],
"sound/sequences/us/15_cutscene_star_spawn.m64": [644,{"us":[8145088]}],
"sound/sequences/us/16_event_boss.m64": [3435,{"us":[8145744]}],
"sound/sequences/us/17_cutscene_collect_key.m64": [671,{"us":[8149184]}],
"sound/sequences/us/18_event_endless_stairs.m64": [1777,{"us":[8149856]}],
"sound/sequences/us/19_level_boss_koopa_final.m64": [3515,{"us":[8151648]}],
"sound/sequences/us/1A_cutscene_credits.m64": [14313,{"us":[8155168]}],
"sound/sequences/us/1B_event_solve_puzzle.m64": [216,{"us":[8169488]}],
"sound/sequences/us/1C_event_toad_message.m64": [208,{"us":[8169712]}],
"sound/sequences/us/1D_event_peach_message.m64": [432,{"us":[8169920]}],
"sound/sequences/us/1E_cutscene_intro.m64": [1764,{"us":[8170352]}],
"sound/sequences/us/1F_cutscene_victory.m64": [2058,{"us":[8172128]}],
"sound/sequences/us/20_cutscene_ending.m64": [1882,{"us":[8174192]}],
"sound/sequences/us/21_menu_file_select.m64": [781,{"us":[8176080]}],
"sound/sequences/us/22_cutscene_lakitu.m64": [313,{"us":[8176864]}],
"textures/bbh_skybox/skybox.00000.rgba16.png": [32,32,2048,{"jp":[3118928,0],"us":[3125680,0],"eu":[2999280,0]}],
"textures/bbh_skybox/skybox.00800.rgba16.png": [32,32,2048,{"jp":[3118928,2048],"us":[3125680,2048],"eu":[2999280,2048]}],
"textures/bbh_skybox/skybox.01000.rgba16.png": [32,32,2048,{"jp":[3118928,4096],"us":[3125680,4096],"eu":[2999280,4096]}],

View File

@ -105,7 +105,7 @@
.set objHealth, 0x3F
.set objBehParams, 0x40
.set objPrevAction, 0x41
.set objUnk190, 0x42
.set objInteractSubtype, 0x42
.set objCollisionDistance, 0x43
.set objNumLootCoins, 0x44
.set objDrawingDistance, 0x45
@ -363,7 +363,7 @@ glabel bhvStarDoor # 0000
begin OBJ_LIST_SURFACE
obj_set_int objInteractType, 4
collision_data inside_castle_seg7_collision_star_door
obj_set_int objUnk190, 32
obj_set_int objInteractSubtype, 32
obj_or_int objFlags, (OBJ_FLAG_ACTIVE_FROM_AFAR | OBJ_FLAG_COMPUTE_DIST_TO_MARIO | OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE)
set_hitbox 80, 100
obj_set_pos
@ -796,7 +796,7 @@ glabel bhvExitPodiumWarp # 0720
glabel bhvFadingWarp # 075C
begin OBJ_LIST_LEVEL
obj_set_int objUnk190, 0x0001
obj_set_int objInteractSubtype, 0x0001
obj_or_int objFlags, (OBJ_FLAG_SET_FACE_YAW_TO_MOVE_YAW | OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE)
obj_set_int objInteractType, 0x2000
obj_set_int objIntangibleTimer, 0
@ -1280,8 +1280,9 @@ glabel bhvUnusedParticleSpawn # 0ED0
glabel bhvUkiki # 0F08
begin OBJ_LIST_GENACTOR
goto .L13001CB4
glabel bhvUnused0F14 # 0F14
goto ukikiData
glabel bhvUkikiCageChild # 0F14
begin OBJ_LIST_GENACTOR
obj_or_int objFlags, OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE
obj_set_float objPosX, 0x0A00
@ -1289,25 +1290,25 @@ glabel bhvUnused0F14 # 0F14
obj_set_float objPosZ, 0x076A
break
glabel bhvLittleCage2 # 0F2C
glabel bhvUkikiCageStar # 0F2C
begin OBJ_LIST_DEFAULT
obj_or_int objFlags, OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE
obj_set_pos
begin_loop
callnative bhv_little_cage_2_loop
callnative bhv_ukiki_cage_star_loop
end_loop
glabel bhvLittleCage # 0F48
glabel bhvUkikiCage # 0F48
begin OBJ_LIST_SURFACE
obj_or_int objFlags, (OBJ_FLAG_SET_FACE_YAW_TO_MOVE_YAW | OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE)
obj_set_pos
collision_data ttm_seg7_collision_little_cage
obj_child MODEL_STAR, bhvLittleCage2
obj_child MODEL_NONE, bhvUnused0F14
collision_data ttm_seg7_collision_ukiki_cage
obj_child MODEL_STAR, bhvUkikiCageStar
obj_child MODEL_NONE, bhvUkikiCageChild
obj_set_float objCollisionDistance, 0x4E20
gravity 0x001E, 0xFE70, 0xFFCE, 0x03E8, 0x03E8, 0x00C8, 0x0000, 0x0000
begin_loop
callnative bhv_little_cage_loop
callnative bhv_ukiki_cage_loop
end_loop
glabel bhvBitfsSinkingPlatforms # 0F9C
@ -1506,7 +1507,7 @@ glabel bhvSpindrift # 12B4
animate 0x00
gravity 0x001E, 0xFE70, 0x0000, 0x0000, 0x0000, 0x00C8, 0x0000, 0x0000
obj_set_pos
obj_set_int objUnk190, 0x0080
obj_set_int objInteractSubtype, 0x0080
begin_loop
callnative bhv_spindrift_loop
end_loop
@ -1670,7 +1671,7 @@ glabel bhvHeaveHo # 1548
gravity 0x00C8, 0xFE70, 0xFFCE, 0x03E8, 0x03E8, 0x0258, 0x0000, 0x0000
obj_spawn MODEL_NONE, bhvHeaveHoThrowMario
obj_set_int objInteractType, 0x02
obj_set_int objUnk190, 0x0204
obj_set_int objInteractSubtype, 0x0204
set_hitbox 0x0078, 0x0064
obj_set_pos
obj_set_int objIntangibleTimer, 0
@ -1768,7 +1769,7 @@ glabel bhvGrandStar # 1714
begin OBJ_LIST_LEVEL
obj_or_int objFlags, OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE
interact_type INTERACT_STAR_OR_KEY
obj_set_int objUnk190, 0x0800
obj_set_int objInteractSubtype, 0x0800
set_hitbox 0x00A0, 0x0064
obj_set_pos
begin_loop
@ -1857,7 +1858,7 @@ glabel bhvBowserBodyAnchor # 18CC
obj_or_int objFlags, OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE
set_hitbox 0x0064, 0x012C
interact_type INTERACT_DAMAGE
obj_set_int objUnk190, 0x0008
obj_set_int objInteractSubtype, 0x0008
graph_clear
obj_set_int objDamageOrCoinValue, 2
obj_set_int objIntangibleTimer, 0
@ -2075,12 +2076,12 @@ glabel bhvClockHourHand # 1C8C
callnative bhv_rotating_clock_arm_loop
end_loop
glabel bhvUkikiOpenCage # 1CB0
glabel bhvMacroUkiki # 1CB0
begin OBJ_LIST_GENACTOR
.L13001CB4: # 1CB4
ukikiData: # 1CB4
obj_or_int objFlags, (OBJ_FLAG_COMPUTE_ANGLE_TO_MARIO | OBJ_FLAG_HOLDABLE | OBJ_FLAG_COMPUTE_DIST_TO_MARIO | OBJ_FLAG_SET_FACE_YAW_TO_MOVE_YAW | OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE)
obj_set_int objInteractType, 0x02
obj_set_int objUnk190, 0x0010
obj_set_int objInteractSubtype, 0x0010
set_hitbox 0x0028, 0x0028
obj_set_int objIntangibleTimer, 0
drop_floor
@ -2088,9 +2089,9 @@ glabel bhvUkikiOpenCage # 1CB0
animate 0x00
gravity 0x001E, 0xFE70, 0xFFCE, 0x0000, 0x0000, 0x00C8, 0x0000, 0x0000
obj_set_pos
callnative bhv_ukiki_open_cage_init
callnative bhv_ukiki_init
begin_loop
callnative bhv_ukiki_open_cage_loop
callnative bhv_ukiki_loop
end_loop
glabel bhvStub1D0C # 1D0C
@ -2338,7 +2339,7 @@ glabel bhvSmallPenguin # 20E8
animate 0x00
gravity 0x001E, 0xFE70, 0xFFCE, 0x0000, 0x0000, 0x00C8, 0x0000, 0x0000
obj_set_int objInteractType, 0x02
obj_set_int objUnk190, 0x0010
obj_set_int objInteractSubtype, 0x0010
obj_set_int objIntangibleTimer, 0
set_hitbox 0x0028, 0x0028
obj_set_pos
@ -3487,7 +3488,7 @@ glabel bhvMessagePanel # 32C0
obj_or_int objFlags, OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE
collision_data wooden_signpost_seg3_collision_0302DD80
interact_type INTERACT_TEXT
obj_set_int objUnk190, 0x1000
obj_set_int objInteractSubtype, 0x1000
drop_floor
set_hitbox 0x0096, 0x0050
obj_set_int objVarF4, 0
@ -3501,7 +3502,7 @@ glabel bhvSignOnWall # 3304
begin OBJ_LIST_SURFACE
obj_or_int objFlags, OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE
interact_type INTERACT_TEXT
obj_set_int objUnk190, 0x1000
obj_set_int objInteractSubtype, 0x1000
set_hitbox 0x0096, 0x0050
obj_set_int objVarF4, 0
begin_loop
@ -4050,13 +4051,13 @@ glabel bhvPyramidPillarTouchDetector # 3BEC
glabel bhvWaterfallSoundLoop # 3C10
begin OBJ_LIST_DEFAULT
begin_loop
callnative BehWaterfallSoundLoop
callnative bhv_waterfall_sound_loop
end_loop
glabel bhvVolcanoSoundLoop # 3C24
begin OBJ_LIST_DEFAULT
begin_loop
callnative BehVolcanoSoundLoop
callnative bhv_volcano_sound_loop
end_loop
glabel bhvCastleFlagWaving # 3C38
@ -4064,14 +4065,14 @@ glabel bhvCastleFlagWaving # 3C38
obj_or_int objFlags, OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE
obj_set_int32 objAnimations, castle_grounds_seg7_anim_flags
animate 0x00
callnative BehCastleFlagWavingInit
callnative bhv_castle_flag_init
begin_loop
end_loop
glabel bhvBirdsSoundLoop # 3C5C
begin OBJ_LIST_DEFAULT
begin_loop
callnative BehBirdsSoundLoop
callnative bhv_birds_sound_loop
end_loop
glabel bhvAmbientSounds # 3C70
@ -4083,7 +4084,7 @@ glabel bhvAmbientSounds # 3C70
glabel bhvSandSoundLoop # 3C84
begin OBJ_LIST_DEFAULT
begin_loop
callnative BehSandSoundLoop
callnative bhv_sand_sound_loop
end_loop
glabel bhvHiddenAt120Stars # 3C98
@ -4091,7 +4092,7 @@ glabel bhvHiddenAt120Stars # 3C98
obj_or_int objFlags, OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE
collision_data castle_grounds_seg7_collision_cannon_grill
obj_set_float objCollisionDistance, 0x0FA0
callnative BehHiddenAt120StarsInit
callnative bhv_castle_cannon_grate_init
begin_loop
callnative load_object_collision_model
end_loop
@ -4692,7 +4693,7 @@ glabel bhvFlyGuy # 46BC
obj_set_pos
gravity 0x0032, 0x0000, 0x0000, 0x0000, 0x03E8, 0x0258, 0x0000, 0x0000
callnative bhv_init_room
obj_set_int objUnk190, 0x0080
obj_set_int objInteractSubtype, 0x0080
obj_set_float objGraphYOffset, 30
scale 150
begin_loop
@ -5087,18 +5088,18 @@ glabel bhvSlidingPlatform2 # 4E2C
begin OBJ_LIST_SURFACE
obj_or_int objFlags, (OBJ_FLAG_COMPUTE_DIST_TO_MARIO | OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE)
obj_set_pos
callnative BehSlidingPlatform2Init
callnative bhv_sliding_plat_2_init
begin_loop
callnative BehSlidingPlatform2Loop
callnative bhv_sliding_plat_2_loop
callnative load_object_collision_model
end_loop
glabel bhvOctagonalPlatformRotating # 4E58
begin OBJ_LIST_SURFACE
obj_or_int objFlags, OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE
callnative BehOctagonalPlatformRotatingInit
callnative bhv_rotating_octagonal_plat_init
begin_loop
callnative BehOctagonalPlatformRotatingLoop
callnative bhv_rotating_octagonal_plat_loop
callnative load_object_collision_model
end_loop
@ -5106,9 +5107,9 @@ glabel bhvAnimatesOnFloorSwitchPress # 4E80
begin OBJ_LIST_SURFACE
obj_or_int objFlags, (OBJ_FLAG_COMPUTE_DIST_TO_MARIO | OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE)
obj_set_float objCollisionDistance, 0x1F40
callnative BehAnimatesOnFloorSwitchPressInit
callnative bhv_animates_on_floor_switch_press_init
begin_loop
callnative BehAnimatesOnFloorSwitchPressLoop
callnative bhv_animates_on_floor_switch_press_loop
callnative load_object_collision_model
end_loop
@ -5133,14 +5134,14 @@ glabel bhvWaterBombCannon # 4EF0
begin OBJ_LIST_DEFAULT
obj_or_int objFlags, (OBJ_FLAG_COMPUTE_DIST_TO_MARIO | OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE)
begin_loop
callnative BehWaterBombCannonLoop
callnative bhv_water_bomb_cannon_loop
end_loop
glabel bhvCannonBarrelBubbles # 4F08
begin OBJ_LIST_DEFAULT
obj_or_int objFlags, (OBJ_FLAG_SET_FACE_YAW_TO_MOVE_YAW | OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE)
begin_loop
callnative BehCannonBarrelBubblesLoop
callnative bhv_bubble_cannon_barrel_loop
end_loop
glabel bhvUnagi # 4F20
@ -5151,16 +5152,16 @@ glabel bhvUnagi # 4F20
obj_set_pos
scale 300
obj_set_float objDrawingDistance, 0x1770
callnative BehUnagiInit
callnative bhv_unagi_init
begin_loop
callnative BehUnagiLoop
callnative bhv_unagi_loop
end_loop
glabel bhvUnagiSubobject # 4F58
begin OBJ_LIST_GENACTOR
obj_or_int objFlags, (OBJ_FLAG_COMPUTE_DIST_TO_MARIO | OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE)
begin_loop
callnative BehUnagiSubobjectLoop
callnative bhv_unagi_subobject_loop
end_loop
glabel bhvDorrie # 4F70
@ -5186,9 +5187,9 @@ glabel bhvHauntedChair # 4FB4
gravity 0x0028, 0x0000, 0xFFCE, 0x03E8, 0x03E8, 0x00C8, 0x0000, 0x0000
obj_set_pos
callnative bhv_init_room
callnative BehHauntedChairInit
callnative bhv_haunted_chair_init
begin_loop
callnative BehHauntedChairLoop
callnative bhv_haunted_chair_loop
end_loop
glabel bhvMadPiano # 5004
@ -5214,7 +5215,7 @@ glabel bhvFlyingBookend # 504C
scale 70
callnative bhv_init_room
begin_loop
callnative BehFlyingBookendLoop
callnative bhv_flying_bookend_loop
end_loop
glabel bhvBookendSpawn # 5094
@ -5222,7 +5223,7 @@ glabel bhvBookendSpawn # 5094
obj_or_int objFlags, (OBJ_FLAG_COMPUTE_ANGLE_TO_MARIO | OBJ_FLAG_COMPUTE_DIST_TO_MARIO | OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE)
callnative bhv_init_room
begin_loop
callnative BehBookendSpawnLoop
callnative bhv_bookend_spawn_loop
end_loop
glabel bhvHauntedBookshelfManager # 50B4
@ -5263,7 +5264,7 @@ glabel bhvSmallPiranhaFlame # 5138
billboard
gravity 0x001E, 0x0000, 0xFFCE, 0x03E8, 0x03E8, 0x00C8, 0x0000, 0x0000
begin_loop
callnative BehSmallPiranhaFlameLoop
callnative bhv_small_piranha_flame_loop
obj_add_int objAnimState, 1
end_loop
@ -5282,7 +5283,7 @@ glabel bhvFlyguyFlame # 518C
billboard
gravity 0x0000, 0x00C8, 0x0000, 0x03E8, 0x03E8, 0x00C8, 0x0000, 0x0000
begin_loop
callnative BehFlyGuyFlameLoop
callnative bhv_fly_guy_flame_loop
obj_add_int objAnimState, 1
end_loop
@ -5294,7 +5295,7 @@ glabel bhvSnufit # 51C0
callnative bhv_init_room
begin_loop
obj_set_int objVarF4, 0
callnative BehSnufitLoop
callnative bhv_snufit_loop
end_loop
glabel bhvSnufitBalls # 51FC
@ -5306,7 +5307,7 @@ glabel bhvSnufitBalls # 51FC
obj_set_float objGraphYOffset, 0x000A
scale 10
begin_loop
callnative BehSnufitBallsLoop
callnative bhv_snufit_balls_loop
end_loop
glabel bhvHorizontalGrindel # 523C
@ -5393,22 +5394,22 @@ glabel bhvPenguinRaceShortcutCheck # 53BC
callnative bhv_penguin_race_shortcut_check_update
end_loop
glabel bhvHauntedRoomCheck # 53D4
glabel bhvCoffinManager # 53D4
begin OBJ_LIST_SURFACE
obj_or_int objFlags, (OBJ_FLAG_COMPUTE_DIST_TO_MARIO | OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE)
callnative bhv_init_room
begin_loop
callnative BehHauntedRoomCheckLoop
callnative bhv_coffin_manager_loop
end_loop
glabel bhvHauntedRoomCheckSubobject # 53F4
glabel bhvCoffin # 53F4
begin OBJ_LIST_SURFACE
collision_data bbh_seg7_collision_coffin
obj_or_int objFlags, (OBJ_FLAG_COMPUTE_DIST_TO_MARIO | OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE)
obj_set_pos
callnative bhv_init_room
begin_loop
callnative BehHauntedRoomCheckSubobjectLoop
callnative bhv_coffin_loop
end_loop
glabel bhvClamShell # 5420
@ -5418,7 +5419,7 @@ glabel bhvClamShell # 5420
obj_set_int32 objAnimations, clam_shell_seg5_anims_05001744
obj_set_float objGraphYOffset, 0x000A
begin_loop
callnative BehClamShellLoop
callnative bhv_clam_loop
end_loop
glabel bhvSkeeter # 5448
@ -5511,7 +5512,7 @@ glabel bhvBubba # 55BC
gravity 0x00C8, 0xFE70, 0xFFCE, 0x03E8, 0x03E8, 0x0000, 0x0000, 0x0000
scale 50
begin_loop
callnative BehBubbaLoop
callnative bhv_bubba_loop
end_loop
glabel bhvBeginningLakitu # 55F0
@ -5521,7 +5522,7 @@ glabel bhvBeginningLakitu # 55F0
animate 0x00
obj_set_float objOpacity, 0x0000
begin_loop
callnative BehBeginningLakituLoop
callnative bhv_intro_lakitu_loop
end_loop
glabel bhvBeginningPeach # 5618
@ -5530,7 +5531,7 @@ glabel bhvBeginningPeach # 5618
obj_set_int32 objAnimations, peach_seg5_anims_0501C41C
animate 0x00
begin_loop
callnative BehBeginningPeachLoop
callnative bhv_intro_peach_loop
end_loop
glabel bhvEndBirds1 # 563C
@ -5539,7 +5540,7 @@ glabel bhvEndBirds1 # 563C
obj_set_int32 objAnimations, birds_seg5_anims_050009E8
animate 0x00
begin_loop
callnative BehEndBirds1Loop
callnative bhv_end_birds_1_loop
end_loop
glabel bhvEndBirds2 # 5660
@ -5548,14 +5549,14 @@ glabel bhvEndBirds2 # 5660
obj_set_int32 objAnimations, birds_seg5_anims_050009E8
animate 0x00
begin_loop
callnative BehEndBirds2Loop
callnative bhv_end_birds_2_loop
end_loop
glabel bhvIntroScene # 5684
begin OBJ_LIST_DEFAULT
obj_or_int objFlags, OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE
begin_loop
callnative BehIntroSceneLoop
callnative bhv_intro_scene_loop
end_loop
.align 4

View File

@ -26,7 +26,7 @@ done
set -- "${POSITIONAL[@]}"
BASEROM=baserom.$LANG
MAPFILE="build/$LANG/sm64.map"
MAPFILE="build/$LANG/sm64.$LANG.map"
MYDUMP=sm64.$LANG.dump
MYIMG=build/$LANG/sm64.$LANG.z64
BASEDUMP=$BASEROM.dump

View File

@ -94,16 +94,18 @@ void point_light(s16 x, s16 y, s16 z, s16 size, f32 shade, s16 size1, f32 shade1
if (gMarioState->pos[0] >= (x - size1) && gMarioState->pos[0] <= x + size1
&& gMarioState->pos[1] >= (y - size1) && gMarioState->pos[1] <= y + size1
&& gMarioState->pos[2] >= (z - size1) && gMarioState->pos[2] <= z + size1)
&& gMarioState->pos[2] >= (z - size1) && gMarioState->pos[2] <= z + size1) {
set_mario_shade_light(shade1);
}
/* Inner region */
if (gMarioState->pos[0] >= (x - size) && gMarioState->pos[0] <= x + size
&& gMarioState->pos[1] >= (y - size) && gMarioState->pos[1] <= y + size
&& gMarioState->pos[2] >= (z - size) && gMarioState->pos[2] <= z + size)
&& gMarioState->pos[2] >= (z - size) && gMarioState->pos[2] <= z + size) {
set_mario_shade_light(shade);
}
}
/*
* Sets up the automatic shading for levels and sets up point lights.
@ -138,13 +140,15 @@ void set_level_shading(void) {
break;
case LEVEL_CASTLE:
set_mario_shade_light(SHADE_75);
if (gCurrAreaIndex == 3)
if (gCurrAreaIndex == 3) {
set_mario_shade_light(SHADE_50);
}
break;
case LEVEL_SSL:
set_mario_shade_light(SHADE_100);
if (gCurrAreaIndex == 2 || gCurrAreaIndex == 3) /* Both pyramid areas */
if (gCurrAreaIndex == 2 || gCurrAreaIndex == 3) { /* Both pyramid areas */
set_mario_shade_light(SHADE_25);
}
break;
case LEVEL_JRB:
case LEVEL_DDD:
@ -155,8 +159,9 @@ void set_level_shading(void) {
case LEVEL_SL:
case LEVEL_PSS:
set_mario_shade_light(SHADE_75);
if (gCurrAreaIndex == 2)
if (gCurrAreaIndex == 2) {
set_mario_shade_light(SHADE_50);
}
break;
default:
set_mario_shade_light(SHADE_100);

View File

@ -31,7 +31,7 @@ baseimg = 'baserom.' + lang + '.z64'
basemap = 'sm64.' + lang + '.map'
myimg = 'build/' + lang + '/sm64.' + lang + '.z64'
mymap = 'build/' + lang + '/sm64.map'
mymap = 'build/' + lang + '/sm64.' + lang + '.map'
if os.path.isfile('expected/' + mymap):
basemap = 'expected/' + mymap

View File

@ -1,6 +1,8 @@
#ifndef _ULTRA64_GBI_H_
#define _ULTRA64_GBI_H_
#include <PR/ultratypes.h>
/* Types */
/* Vertex (set up for use with colors) */

View File

@ -1,6 +1,9 @@
#ifndef _ULTRA64_GU_H_
#define _ULTRA64_GU_H_
#include <PR/mbi.h>
#include <PR/ultratypes.h>
#define GU_PI 3.1415926
/* Functions */

View File

@ -1,5 +1,7 @@
#ifndef _ULTRA64_TIME_H_
#define _ULTRA64_TIME_H_
#include <PR/ultratypes.h>
#include <PR/os_message.h>
/* Types */

View File

@ -1,6 +1,9 @@
#ifndef _ULTRA64_VI_H_
#define _ULTRA64_VI_H_
#include <PR/ultratypes.h>
#include <PR/os_message.h>
/* Ultra64 Video Interface */

View File

@ -96,9 +96,9 @@ extern u32 bhvEndToad[];
extern u32 bhvEndPeach[];
extern u32 bhvUnusedParticleSpawn[];
extern u32 bhvUkiki[];
extern u32 bhvUnused0F14[];
extern u32 bhvLittleCage2[];
extern u32 bhvLittleCage[];
extern u32 bhvUkikiCageChild[];
extern u32 bhvUkikiCageStar[];
extern u32 bhvUkikiCage[];
extern u32 bhvBitfsSinkingPlatforms[];
extern u32 bhvBitfsSinkingCagePlatform[];
extern u32 bhvDddMovingPole[];
@ -179,7 +179,7 @@ extern u32 bhvDddWarp[];
extern u32 bhvMoatGrills[];
extern u32 bhvClockMinuteHand[];
extern u32 bhvClockHourHand[];
extern u32 bhvUkikiOpenCage[];
extern u32 bhvMacroUkiki[];
extern u32 bhvStub1D0C[];
extern u32 bhvLllRotatingHexagonalPlatform[];
extern u32 bhvLllSinkingRockBlock[];
@ -521,8 +521,8 @@ extern u32 bhvBird[];
extern u32 bhvRacingPenguin[];
extern u32 bhvPenguinRaceFinishLine[];
extern u32 bhvPenguinRaceShortcutCheck[];
extern u32 bhvHauntedRoomCheck[];
extern u32 bhvHauntedRoomCheckSubobject[];
extern u32 bhvCoffinManager[];
extern u32 bhvCoffin[];
extern u32 bhvClamShell[];
extern u32 bhvSkeeter[];
extern u32 bhvSkeeterWave[];

View File

@ -264,8 +264,8 @@ struct MacroPreset MacroObjectPresets[] = {
{bhvYellowCoin, MODEL_YELLOW_COIN, 0},
{bhvYellowCoin, MODEL_YELLOW_COIN, 0},
{bhvYellowCoin, MODEL_YELLOW_COIN, 0},
{bhvUkikiOpenCage, MODEL_UKIKI, 0}, // unused
{bhvUkikiOpenCage, MODEL_UKIKI, 1}, // unused
{bhvMacroUkiki, MODEL_UKIKI, 0}, // unused
{bhvMacroUkiki, MODEL_UKIKI, 1}, // unused
{bhvPiranhaPlant, MODEL_PIRANHA_PLANT, 0}, // unused
{bhvYellowCoin, MODEL_YELLOW_COIN, 0},
{bhvSmallWhomp, MODEL_WHOMP, 0},

View File

@ -99,6 +99,11 @@
OBJ_MOVE_UNDERWATER_ON_GROUND)
#define OBJ_MOVE_MASK_HIT_WALL_OR_IN_WATER \
(OBJ_MOVE_HIT_WALL | OBJ_MOVE_MASK_IN_WATER)
#define OBJ_MOVE_MASK_NOT_AIR (\
OBJ_MOVE_LANDED |\
OBJ_MOVE_ON_GROUND |\
OBJ_MOVE_AT_WATER_SURFACE |\
OBJ_MOVE_UNDERWATER_ON_GROUND)
/* oActiveParticleFlags */
#define ACTIVE_PARTICLE_0 0x00000001
@ -569,6 +574,82 @@
#define MONTY_MOLE_ROCK_ACT_HELD 0
#define MONTY_MOLE_ROCK_ACT_MOVE 1
/* Ukiki */
/* oAction */
#define UKIKI_ACT_IDLE 0
#define UKIKI_ACT_RUN 1
#define UKIKI_ACT_TURN_TO_MARIO 2
#define UKIKI_ACT_JUMP 3
#define UKIKI_ACT_GO_TO_CAGE 4
#define UKIKI_ACT_WAIT_TO_RESPAWN 5
#define UKIKI_ACT_UNUSED_TURN 6
#define UKIKI_ACT_RETURN_HOME 7
/* oSubAction */
#define UKIKI_SUB_ACT_TAUNT_NONE 0
#define UKIKI_SUB_ACT_TAUNT_ITCH 1
#define UKIKI_SUB_ACT_TAUNT_SCREECH 2
#define UKIKI_SUB_ACT_TAUNT_JUMP_CLAP 3
#define UKIKI_SUB_ACT_TAUNT_HANDSTAND 4
#define UKIKI_SUB_ACT_CAGE_RUN_TO_CAGE 0
#define UKIKI_SUB_ACT_CAGE_WAIT_FOR_MARIO 1
#define UKIKI_SUB_ACT_CAGE_TALK_TO_MARIO 2
#define UKIKI_SUB_ACT_CAGE_TURN_TO_CAGE 3
#define UKIKI_SUB_ACT_CAGE_JUMP_TO_CAGE 4
#define UKIKI_SUB_ACT_CAGE_LAND_ON_CAGE 5
#define UKIKI_SUB_ACT_CAGE_SPIN_ON_CAGE 6
#define UKIKI_SUB_ACT_CAGE_DESPAWN 7
/* oUkikiTextState */
#define UKIKI_TEXT_DEFAULT 0
#define UKIKI_TEXT_CAGE_TEXTBOX 1
#define UKIKI_TEXT_GO_TO_CAGE 2
#define UKIKI_TEXT_STOLE_HAT 3
#define UKIKI_TEXT_HAS_HAT 4
#define UKIKI_TEXT_GAVE_HAT_BACK 5
#define UKIKI_TEXT_DO_NOT_LET_GO 6
#define UKIKI_TEXT_STEAL_HAT 7
/* oBehParams2ndByte */
#define UKIKI_CAGE 0
#define UKIKI_HAT 1
/* Animations */
#define UKIKI_ANIM_RUN 0
#define UKIKI_ANIM_UNUSED_WALK 1
#define UKIKI_ANIM_UNUSED_APOSE 2
#define UKIKI_ANIM_UNUSED_DEATH 3
#define UKIKI_ANIM_SCREECH 4
#define UKIKI_ANIM_JUMP_CLAP 5
#define UKIKI_ANIM_UNUSED_HOP 6
#define UKIKI_ANIM_LAND 7
#define UKIKI_ANIM_JUMP 8
#define UKIKI_ANIM_ITCH 9
#define UKIKI_ANIM_HANDSTAND 10
#define UKIKI_ANIM_TURN 11
#define UKIKI_ANIM_HELD 12
/* oAnimState */
#define UKIKI_ANIM_STATE_DEFAULT 0
#define UKIKI_ANIM_STATE_EYE_CLOSED 1
#define UKIKI_ANIM_STATE_HAT_ON 2
/* oUkikiHasHat */
#define UKIKI_HAT_ON 1
/* Ukiki Cage Star */
/* oAction */
#define UKIKI_CAGE_STAR_ACT_IN_CAGE 0
#define UKIKI_CAGE_STAR_ACT_SPAWN_STAR 1
/* Ukiki Cage */
/* oAction */
#define UKIKI_CAGE_ACT_WAIT_FOR_UKIKI 0
#define UKIKI_CAGE_ACT_SPIN 1
#define UKIKI_CAGE_ACT_FALL 2
#define UKIKI_CAGE_ACT_HIDE 3
/* Piranha Plant */
/* oAction */
#define PIRANHA_PLANT_ACT_IDLE 0

View File

@ -93,7 +93,7 @@
#define /*0x184*/ oHealth OBJECT_FIELD_S32(0x3F)
#define /*0x188*/ oBehParams OBJECT_FIELD_S32(0x40)
#define /*0x18C*/ oPrevAction OBJECT_FIELD_S32(0x41)
#define /*0x190*/ oUnk190 OBJECT_FIELD_U32(0x42)
#define /*0x190*/ oInteractionSubtype OBJECT_FIELD_U32(0x42)
#define /*0x194*/ oCollisionDistance OBJECT_FIELD_F32(0x43)
#define /*0x198*/ oNumLootCoins OBJECT_FIELD_S32(0x44)
#define /*0x19C*/ oDrawingDistance OBJECT_FIELD_F32(0x45)
@ -103,13 +103,9 @@
#define /*0x1AC*/ oUnk1AC_VPTR OBJECT_FIELD_VPTR(0x49)
#define /*0x1AC*/ oUnk1AC_S32 OBJECT_FIELD_S32(0x49)
#define /*0x1AC*/ oUnk1AC_F32 OBJECT_FIELD_F32(0x49)
#define /*0x1AC*/ oMipsForwardVelocity OBJECT_FIELD_F32(0x49)
#define /*0x1AC*/ oUnk1AC_S16 OBJECT_FIELD_S16(0x49, 0)
#define /*0x1AE*/ oUnk1AE OBJECT_FIELD_S16(0x49, 1)
#define /*0x1B0*/ oUnk1B0 OBJECT_FIELD_S32(0x4A)
#define /*0x1B0*/ oEyesShut OBJECT_FIELD_S16(0x4A, 0)
#define /*0x1B0*/ oUnk1B0_S16 OBJECT_FIELD_S16(0x4A, 0)
#define /*0x1B2*/ oUnk1B2 OBJECT_FIELD_S16(0x4A, 1)
// more generic fields
#define /*0x1B4*/ oWallAngle OBJECT_FIELD_U32(0x4B)
#define /*0x1B8*/ oFloorType OBJECT_FIELD_S16(0x4C, 0)
@ -359,6 +355,9 @@
#define /*0x10E*/ oBowserUnk10E OBJECT_FIELD_S16(0x21, 1)
#define /*0x110*/ oBowserUnk110 OBJECT_FIELD_S16(0x22, 0)
#define /*0x112*/ oBowserAngleToCentre OBJECT_FIELD_S16(0x22, 1)
#define /*0x1AE*/ oBowserUnk1AE OBJECT_FIELD_S16(0x49, 1)
#define /*0x1B0*/ oBowserEyesShut OBJECT_FIELD_S16(0x4A, 0)
#define /*0x1B2*/ oBowserUnk1B2 OBJECT_FIELD_S16(0x4A, 1)
/* Flame */
#define /*0x0F4*/ oFlameUnkF4 OBJECT_FIELD_F32(0x1B)
@ -387,12 +386,19 @@
/* bhvBowserKeyCourseExit */
#define /*0x0F4*/ oBowserKeyCourseExitScale OBJECT_FIELD_F32(0x1B)
/* UkikiOpenCage */
#define /*0x0F4*/ oUkikiOpenCageUnkF4 OBJECT_FIELD_S16(0x1B, 0)
#define /*0x0F6*/ oUkikiOpenCageUnkF6 OBJECT_FIELD_S16(0x1B, 1)
#define /*0x0FC*/ oUkikiOpenCageUnkFC OBJECT_FIELD_VPTR(0x1D)
#define /*0x10C*/ oUkikiOpenCageUnk10C OBJECT_FIELD_S32(0x21)
#define /*0x110*/ oUkikiOpenCageUnk110 OBJECT_FIELD_F32(0x22)
/* Ukiki */
#define /*0x0F4*/ oUkikiTauntCounter OBJECT_FIELD_S16(0x1B, 0)
#define /*0x0F6*/ oUkikiTauntsToBeDone OBJECT_FIELD_S16(0x1B, 1)
//TODO change to the actual waypoint form.
#define /*0x0FC*/ oUkikiPath OBJECT_FIELD_VPTR(0x1D)
#define /*0x110*/ oUkikiChaseFleeRange OBJECT_FIELD_F32(0x22)
#define /*0x1AC*/ oUkikiTextState OBJECT_FIELD_S16(0x49, 0)
#define /*0x1AE*/ oUkikiTextboxTimer OBJECT_FIELD_S16(0x49, 1)
#define /*0x1B0*/ oUkikiCageSpinTimer OBJECT_FIELD_S16(0x4A, 0)
#define /*0x1B2*/ oUkikiHasHat OBJECT_FIELD_S16(0x4A, 1)
/* Ukiki Cage*/
#define /*0x088*/ oUkikiCageNextAction OBJECT_FIELD_S32(0x00)
/* HorizontalMovement */
#define /*0x0F4*/ oHorizontalMovementUnkF4 OBJECT_FIELD_S32(0x1B)
@ -1030,6 +1036,7 @@
/* Mips */
#define /*0x0F4*/ oMipsStarStatus OBJECT_FIELD_S32(0x1B)
#define /*0x0F8*/ oMipsStartWaypointIndex OBJECT_FIELD_S32(0x1C)
#define /*0x1AC*/ oMipsForwardVelocity OBJECT_FIELD_F32(0x49)
/* Yoshi */
#define /*0x0F4*/ oYoshiUnkF4 OBJECT_FIELD_S32(0x1B)

View File

@ -1,44 +1,45 @@
#ifndef _SEQ_IDS_H
#define _SEQ_IDS_H
#ifndef SEQ_IDS_H
#define SEQ_IDS_H
#define SEQ_VARIATION 0x80
#define SEQ_SOUND_PLAYER 0x0000
#define SEQ_EVENT_CUTSCENE_COLLECT_STAR 0x0001
#define SEQ_MENU_TITLE_SCREEN 0x0002
#define SEQ_LEVEL_GRASS 0x0003
#define SEQ_LEVEL_INSIDE_CASTLE 0x0004
#define SEQ_LEVEL_WATER 0x0005
#define SEQ_LEVEL_HOT 0x0006
#define SEQ_LEVEL_BOSS_KOOPA 0x0007
#define SEQ_LEVEL_SNOW 0x0008
#define SEQ_LEVEL_SLIDE 0x0009
#define SEQ_LEVEL_SPOOKY 0x000A
#define SEQ_EVENT_PIRANHA_PLANT 0x000B
#define SEQ_LEVEL_UNDERGROUND 0x000C
#define SEQ_MENU_STAR_SELECT 0x000D
#define SEQ_EVENT_POWERUP 0x000E
#define SEQ_EVENT_METAL_CAP 0x000F
#define SEQ_EVENT_KOOPA_MESSAGE 0x0010
#define SEQ_LEVEL_KOOPA_ROAD 0x0011
#define SEQ_EVENT_HIGH_SCORE 0x0012
#define SEQ_EVENT_MERRY_GO_ROUND 0x0013
#define SEQ_EVENT_RACE 0x0014
#define SEQ_EVENT_CUTSCENE_STAR_SPAWN 0x0015
#define SEQ_EVENT_BOSS 0x0016
#define SEQ_EVENT_CUTSCENE_COLLECT_KEY 0x0017
#define SEQ_EVENT_ENDLESS_STAIRS 0x0018
#define SEQ_LEVEL_BOSS_KOOPA_FINAL 0x0019
#define SEQ_EVENT_CUTSCENE_CREDITS 0x001A
#define SEQ_EVENT_SOLVE_PUZZLE 0x001B
#define SEQ_EVENT_TOAD_MESSAGE 0x001C
#define SEQ_EVENT_PEACH_MESSAGE 0x001D
#define SEQ_EVENT_CUTSCENE_INTRO 0x001E
#define SEQ_EVENT_CUTSCENE_VICTORY 0x001F
#define SEQ_EVENT_CUTSCENE_ENDING 0x0020
#define SEQ_MENU_FILE_SELECT 0x0021
#ifndef VERSION_JP
#define SEQ_EVENT_CUTSCENE_LAKITU 0x0022
#endif
enum SeqId {
SEQ_SOUND_PLAYER, // 0x00
SEQ_EVENT_CUTSCENE_COLLECT_STAR, // 0x01
SEQ_MENU_TITLE_SCREEN, // 0x02
SEQ_LEVEL_GRASS, // 0x03
SEQ_LEVEL_INSIDE_CASTLE, // 0x04
SEQ_LEVEL_WATER, // 0x05
SEQ_LEVEL_HOT, // 0x06
SEQ_LEVEL_BOSS_KOOPA, // 0x07
SEQ_LEVEL_SNOW, // 0x08
SEQ_LEVEL_SLIDE, // 0x09
SEQ_LEVEL_SPOOKY, // 0x0A
SEQ_EVENT_PIRANHA_PLANT, // 0x0B
SEQ_LEVEL_UNDERGROUND, // 0x0C
SEQ_MENU_STAR_SELECT, // 0x0D
SEQ_EVENT_POWERUP, // 0x0E
SEQ_EVENT_METAL_CAP, // 0x0F
SEQ_EVENT_KOOPA_MESSAGE, // 0x10
SEQ_LEVEL_KOOPA_ROAD, // 0x11
SEQ_EVENT_HIGH_SCORE, // 0x12
SEQ_EVENT_MERRY_GO_ROUND, // 0x13
SEQ_EVENT_RACE, // 0x14
SEQ_EVENT_CUTSCENE_STAR_SPAWN, // 0x15
SEQ_EVENT_BOSS, // 0x16
SEQ_EVENT_CUTSCENE_COLLECT_KEY, // 0x17
SEQ_EVENT_ENDLESS_STAIRS, // 0x18
SEQ_LEVEL_BOSS_KOOPA_FINAL, // 0x19
SEQ_EVENT_CUTSCENE_CREDITS, // 0x1A
SEQ_EVENT_SOLVE_PUZZLE, // 0x1B
SEQ_EVENT_TOAD_MESSAGE, // 0x1C
SEQ_EVENT_PEACH_MESSAGE, // 0x1D
SEQ_EVENT_CUTSCENE_INTRO, // 0x1E
SEQ_EVENT_CUTSCENE_VICTORY, // 0x1F
SEQ_EVENT_CUTSCENE_ENDING, // 0x20
SEQ_MENU_FILE_SELECT, // 0x21
SEQ_EVENT_CUTSCENE_LAKITU, // 0x22 (not in JP)
SEQ_COUNT
};
#endif

View File

@ -15,7 +15,7 @@ script_func_local_2:
object /*model*/ MODEL_BBH_MOVING_BOOKSHELF, /*pos*/ -1994, 819, 213, /*angle*/ 0, 0, 0, /*behParam*/ 0x00000000, /*beh*/ bhvHauntedBookshelf
object /*model*/ MODEL_BBH_MESH_ELEVATOR, /*pos*/ -2985, -205, 5400, /*angle*/ 0, -45, 0, /*behParam*/ 0x00000000, /*beh*/ bhvMeshElevator
object /*model*/ MODEL_BBH_MERRY_GO_ROUND, /*pos*/ -205, -2560, 205, /*angle*/ 0, 0, 0, /*behParam*/ 0x00000000, /*beh*/ bhvMerryGoRound
object /*model*/ MODEL_NONE, /*pos*/ 2200, 819, -800, /*angle*/ 0, 0, 0, /*behParam*/ 0x00000000, /*beh*/ bhvHauntedRoomCheck
object /*model*/ MODEL_NONE, /*pos*/ 2200, 819, -800, /*angle*/ 0, 0, 0, /*behParam*/ 0x00000000, /*beh*/ bhvCoffinManager
return
script_func_local_3:

View File

@ -24,7 +24,7 @@ script_func_local_2:
script_func_local_3:
object /*model*/ MODEL_STAR, /*pos*/ 1200, 2600, 150, /*angle*/ 0, 0, 0, /*behParam*/ 0x00000000, /*beh*/ bhvStar, /*acts*/ ACT_1
object /*model*/ MODEL_TTM_STAR_CAGE, /*pos*/ 2496, 1670, 1492, /*angle*/ 0, 0, 0, /*behParam*/ 0x01000000, /*beh*/ bhvLittleCage, /*acts*/ ACT_2
object /*model*/ MODEL_TTM_STAR_CAGE, /*pos*/ 2496, 1670, 1492, /*angle*/ 0, 0, 0, /*behParam*/ 0x01000000, /*beh*/ bhvUkikiCage, /*acts*/ ACT_2
object /*model*/ MODEL_NONE, /*pos*/ -3250, -2500, -3700, /*angle*/ 0, 0, 0, /*behParam*/ 0x02000000, /*beh*/ bhvHiddenRedCoinStar, /*acts*/ ALL_ACTS
object /*model*/ MODEL_STAR, /*pos*/ -2900, -2700, 3650, /*angle*/ 0, 0, 0, /*behParam*/ 0x03000000, /*beh*/ bhvStar, /*acts*/ ALL_ACTS
object /*model*/ MODEL_STAR, /*pos*/ 1800, 1200, 1050, /*angle*/ 0, 0, 0, /*behParam*/ 0x04000000, /*beh*/ bhvStar, /*acts*/ ALL_ACTS

View File

@ -1,4 +1,4 @@
glabel ttm_seg7_collision_little_cage # 0x07013790 - 0x07013814
glabel ttm_seg7_collision_ukiki_cage # 0x07013790 - 0x07013814
colInit
colVertexInit 0x8
colVertex -76, 102, -76

View File

@ -83,8 +83,9 @@ void _Ldtob(printf_struct *args, u8 type) {
nsig = 0;
exp = 0;
} else {
if (val < 0)
if (val < 0) {
val = -val;
}
exp = exp * 30103 / 0x000186A0 - 4;
if (exp < 0) {
n = (3 - exp) & ~3;
@ -109,8 +110,9 @@ void _Ldtob(printf_struct *args, u8 type) {
}
}
gen = ((type == 'f') ? exp + 10 : 6) + args->precision;
if (gen > 0x13)
if (gen > 0x13) {
gen = 0x13;
}
*ptr++ = '0';
while (gen > 0 && 0 < val) {
lo = val;
@ -136,13 +138,15 @@ void _Ldtob(printf_struct *args, u8 type) {
}
nsig = ((type == 'f') ? exp + 1 : ((type == 'e' || type == 'E') ? 1 : 0)) + args->precision;
if (gen < nsig)
if (gen < nsig) {
nsig = gen;
}
if (nsig > 0) {
if (nsig < gen && ptr[nsig] > '4')
if (nsig < gen && ptr[nsig] > '4') {
drop = '9';
else
} else {
drop = '0';
}
for (n2 = nsig; ptr[--n2] == drop;) {
nsig--;
@ -170,9 +174,9 @@ static s16 _Ldunscale(s16 *pex, printf_struct *px) {
*pex = xchar - (_DBIAS - 1);
return (FINITE);
}
if (0 > xchar)
if (0 > xchar) {
return NAN;
else {
} else {
*pex = 0;
return (0);
}
@ -180,80 +184,94 @@ static s16 _Ldunscale(s16 *pex, printf_struct *px) {
static void _Genld(printf_struct *px, u8 code, u8 *p, s16 nsig, s16 xexp) {
u8 point = '.';
if (nsig <= 0)
if (nsig <= 0) {
nsig = 1,
p = (u8 *) "0";
}
if (code == 'f'
|| ((code == 'g' || code == 'G') && (-4 <= xexp) && (xexp < px->precision))) { /* 'f' format */
++xexp; /* change to leading digit count */
if (code != 'f') { /* fixup for 'g' */
if (!(px->flags & FLAGS_HASH) && nsig < px->precision)
if (!(px->flags & FLAGS_HASH) && nsig < px->precision) {
px->precision = nsig;
if ((px->precision -= xexp) < 0)
}
if ((px->precision -= xexp) < 0) {
px->precision = 0;
}
}
if (xexp <= 0) { /* digits only to right of point */
px->buff[px->part2_len++] = '0';
if (0 < px->precision || px->flags & FLAGS_HASH)
if (0 < px->precision || px->flags & FLAGS_HASH) {
px->buff[px->part2_len++] = point;
if (px->precision < -xexp)
}
if (px->precision < -xexp) {
xexp = -px->precision;
}
px->num_mid_zeros = -xexp;
px->precision += xexp;
if (px->precision < nsig)
if (px->precision < nsig) {
nsig = px->precision;
}
memcpy(&px->buff[px->part2_len], p, px->part3_len = nsig);
px->num_trailing_zeros = px->precision - nsig;
} else if (nsig < xexp) { /* zeros before point */
memcpy(&px->buff[px->part2_len], p, nsig);
px->part2_len += nsig;
px->num_mid_zeros = xexp - nsig;
if (0 < px->precision || px->flags & FLAGS_HASH)
if (0 < px->precision || px->flags & FLAGS_HASH) {
px->buff[px->part2_len] = point, ++px->part3_len;
}
px->num_trailing_zeros = px->precision;
} else { /* enough digits before point */
memcpy(&px->buff[px->part2_len], p, xexp);
px->part2_len += xexp;
nsig -= xexp;
if (0 < px->precision || px->flags & FLAGS_HASH)
if (0 < px->precision || px->flags & FLAGS_HASH) {
px->buff[px->part2_len++] = point;
if (px->precision < nsig)
}
if (px->precision < nsig) {
nsig = px->precision;
}
memcpy(&px->buff[px->part2_len], p + xexp, nsig);
px->part2_len += nsig;
px->num_mid_zeros = px->precision - nsig;
}
} else { /* 'e' format */
if (code == 'g' || code == 'G') { /* fixup for 'g' */
if (nsig < px->precision)
if (nsig < px->precision) {
px->precision = nsig;
if (--px->precision < 0)
}
if (--px->precision < 0) {
px->precision = 0;
}
code = code == 'g' ? 'e' : 'E';
}
px->buff[px->part2_len++] = *p++;
if (0 < px->precision || px->flags & FLAGS_HASH)
if (0 < px->precision || px->flags & FLAGS_HASH) {
px->buff[px->part2_len++] = point;
}
if (0 < px->precision) { /* put fraction digits */
if (px->precision < --nsig)
if (px->precision < --nsig) {
nsig = px->precision;
}
memcpy(&px->buff[px->part2_len], p, nsig);
px->part2_len += nsig;
px->num_mid_zeros = px->precision - nsig;
}
p = (u8 *) &px->buff[px->part2_len]; /* put exponent */
*p++ = code;
if (0 <= xexp)
if (0 <= xexp) {
*p++ = '+';
else { /* negative exponent */
} else { /* negative exponent */
*p++ = '-';
xexp = -xexp;
}
if (100 <= xexp) { /* put oversize exponent */
if (1000 <= xexp)
if (1000 <= xexp) {
*p++ = xexp / 1000 + '0', xexp %= 1000;
}
*p++ = xexp / 100 + '0', xexp %= 100;
}
*p++ = xexp / 10 + '0', xexp %= 10;
@ -264,7 +282,8 @@ static void _Genld(printf_struct *px, u8 code, u8 *p, s16 nsig, s16 xexp) {
int n =
px->part1_len + px->part2_len + px->num_mid_zeros + px->part3_len + px->num_trailing_zeros;
if (n < px->width)
if (n < px->width) {
px->num_leading_zeros = px->width - n;
}
}
}

View File

@ -16,20 +16,23 @@ void _Litob(printf_struct *args, u8 type) {
u64 num;
lldiv_t quotrem;
if (type == 'X')
if (type == 'X') {
num_map = D_80334974;
else
} else {
num_map = D_80334960;
}
base = (type == 'o') ? 8 : ((type != 'x' && type != 'X') ? 10 : 16);
buff_ind = BUFF_LEN;
num = args->value.s64;
if ((type == 'd' || type == 'i') && args->value.s64 < 0)
if ((type == 'd' || type == 'i') && args->value.s64 < 0) {
num = -num;
}
if (num != 0 || args->precision != 0)
if (num != 0 || args->precision != 0) {
buff[--buff_ind] = num_map[num % base];
}
args->value.s64 = num / base;
@ -43,12 +46,14 @@ void _Litob(printf_struct *args, u8 type) {
memcpy(args->buff, buff + buff_ind, args->part2_len);
if (args->part2_len < args->precision)
if (args->part2_len < args->precision) {
args->num_leading_zeros = args->precision - args->part2_len;
}
if (args->precision < 0 && (args->flags & (FLAGS_ZERO | FLAGS_MINUS)) == FLAGS_ZERO) {
buff_ind = args->width - args->part1_len - args->num_leading_zeros - args->part2_len;
if (buff_ind > 0)
if (buff_ind > 0) {
args->num_leading_zeros += buff_ind;
}
}
}

View File

@ -50,8 +50,9 @@ s32 _Printf(char *(*prout)(char *, const char *, size_t), char *dst, const char
}
}
_PROUT(dst, fmt, fmt_ptr - (u8 *) fmt);
if (c == 0)
if (c == 0) {
return sp78.size;
}
fmt = (char *) ++fmt_ptr;
sp78.flags = 0;
for (; (flag_index = strchr(flags_str, *fmt_ptr)) != NULL; fmt_ptr++) {
@ -78,10 +79,11 @@ s32 _Printf(char *(*prout)(char *, const char *, size_t), char *dst, const char
ATOI(sp78.precision, fmt_ptr);
}
}
if (strchr(length_str, *fmt_ptr) != NULL)
if (strchr(length_str, *fmt_ptr) != NULL) {
sp78.length = *fmt_ptr++;
else
} else {
sp78.length = 0;
}
if (sp78.length == 'l' && *fmt_ptr == 'l') {
sp78.length = 'L';
@ -114,22 +116,25 @@ static void _Putfld(printf_struct *a0, va_list *args, u8 type, u8 *buff) {
case 'd':
case 'i':
if (a0->length == 'l')
if (a0->length == 'l') {
a0->value.s64 = va_arg(*args, s32);
else if (a0->length == 'L')
} else if (a0->length == 'L') {
a0->value.s64 = va_arg(*args, s64);
else
} else {
a0->value.s64 = va_arg(*args, s32);
}
if (a0->length == 'h')
if (a0->length == 'h') {
a0->value.s64 = (s16) a0->value.s64;
}
if (a0->value.s64 < 0)
if (a0->value.s64 < 0) {
buff[a0->part1_len++] = '-';
else if (a0->flags & FLAGS_PLUS)
} else if (a0->flags & FLAGS_PLUS) {
buff[a0->part1_len++] = '+';
else if (a0->flags & FLAGS_SPACE)
} else if (a0->flags & FLAGS_SPACE) {
buff[a0->part1_len++] = ' ';
}
a0->buff = (char *) &buff[a0->part1_len];
@ -140,24 +145,27 @@ static void _Putfld(printf_struct *a0, va_list *args, u8 type, u8 *buff) {
case 'X':
case 'u':
case 'o':
if (a0->length == 'l')
if (a0->length == 'l') {
a0->value.s64 = va_arg(*args, s32);
else if (a0->length == 'L')
} else if (a0->length == 'L') {
a0->value.s64 = va_arg(*args, s64);
else
} else {
a0->value.s64 = va_arg(*args, s32);
}
if (a0->length == 'h')
if (a0->length == 'h') {
a0->value.s64 = (u16) a0->value.s64;
else if (a0->length == 0)
} else if (a0->length == 0) {
a0->value.s64 = (u32) a0->value.s64;
}
if (a0->flags & FLAGS_HASH) {
buff[a0->part1_len++] = '0';
if (type == 'x' || type == 'X')
if (type == 'x' || type == 'X') {
buff[a0->part1_len++] = type;
}
}
a0->buff = (char *) &buff[a0->part1_len];
_Litob(a0, type);
break;
@ -173,25 +181,27 @@ static void _Putfld(printf_struct *a0, va_list *args, u8 type, u8 *buff) {
if (a0->value.u16 & 0x8000) {
buff[a0->part1_len++] = '-';
} else {
if (a0->flags & FLAGS_PLUS)
if (a0->flags & FLAGS_PLUS) {
buff[a0->part1_len++] = '+';
else if (a0->flags & FLAGS_SPACE)
} else if (a0->flags & FLAGS_SPACE) {
buff[a0->part1_len++] = ' ';
}
}
a0->buff = (char *) &buff[a0->part1_len];
_Ldtob(a0, type);
break;
case 'n':
if (a0->length == 'h')
if (a0->length == 'h') {
*(va_arg(*args, u16 *)) = a0->size;
else if (a0->length == 'l')
} else if (a0->length == 'l') {
*va_arg(*args, u32 *) = a0->size;
else if (a0->length == 'L')
} else if (a0->length == 'L') {
*va_arg(*args, u64 *) = a0->size;
else
} else {
*va_arg(*args, u32 *) = a0->size;
}
break;
case 'p':
@ -203,8 +213,9 @@ static void _Putfld(printf_struct *a0, va_list *args, u8 type, u8 *buff) {
case 's':
a0->buff = va_arg(*args, char *);
a0->part2_len = strlen((u8 *) a0->buff);
if (a0->precision >= 0 && a0->part2_len > a0->precision)
if (a0->precision >= 0 && a0->part2_len > a0->precision) {
a0->part2_len = a0->precision;
}
break;
case '%':

View File

@ -3,8 +3,9 @@
s32 __osAiDeviceBusy(void) {
register s32 status = HW_REG(AI_STATUS_REG, u32);
if ((status & AI_STATUS_AI_FULL) != 0)
if ((status & AI_STATUS_AI_FULL) != 0) {
return 1;
else
} else {
return 0;
}
}

View File

@ -14,8 +14,9 @@ void __osPiCreateAccessQueue() {
void __osPiGetAccess() {
OSMesg sp1c;
if (!gOsPiAccessQueueCreated)
if (!gOsPiAccessQueueCreated) {
__osPiCreateAccessQueue();
}
osRecvMesg(&gOsPiMessageQueue, &sp1c, OS_MESG_BLOCK);
}

View File

@ -12,8 +12,9 @@ void __osSiCreateAccessQueue() {
void __osSiGetAccess(void) {
OSMesg sp1c;
if (!gOsSiAccessQueueCreated)
if (!gOsSiAccessQueueCreated) {
__osSiCreateAccessQueue();
}
osRecvMesg(&gOsSiMessageQueue, &sp1c, OS_MESG_BLOCK);
}

View File

@ -1,8 +1,9 @@
#include "libultra_internal.h"
#include "hardware.h"
s32 __osSiRawReadIo(void *a0, u32 *a1) {
if (__osSiDeviceBusy())
if (__osSiDeviceBusy()) {
return -1;
}
*a1 = HW_REG((u32) a0, u32);
return 0;
}

View File

@ -1,8 +1,9 @@
#include "libultra_internal.h"
#include "hardware.h"
s32 __osSiRawWriteIo(void *a0, u32 a1) {
if (__osSiDeviceBusy())
if (__osSiDeviceBusy()) {
return -1;
}
HW_REG((u32) a0, u32) = a1;
return 0;
}

View File

@ -3,7 +3,8 @@
s32 __osSpDeviceBusy() {
register u32 status = HW_REG(SP_STATUS_REG, u32);
if (status & (SPSTATUS_IO_FULL | SPSTATUS_DMA_FULL | SPSTATUS_DMA_BUSY))
if (status & (SPSTATUS_IO_FULL | SPSTATUS_DMA_FULL | SPSTATUS_DMA_BUSY)) {
return 1;
}
return 0;
}

View File

@ -2,13 +2,15 @@
#include "hardware.h"
s32 __osSpRawStartDma(u32 dir, void *sp_ptr, void *dram_ptr, size_t size) {
if (__osSpDeviceBusy())
if (__osSpDeviceBusy()) {
return -1;
}
HW_REG(SP_MEM_ADDR_REG, void *) = sp_ptr;
HW_REG(SP_DRAM_ADDR_REG, void *) = (void *) osVirtualToPhysical(dram_ptr);
if (dir == 0)
if (dir == 0) {
HW_REG(SP_WR_LEN_REG, u32) = size - 1;
else
} else {
HW_REG(SP_RD_LEN_REG, u32) = size - 1;
}
return 0;
}

View File

@ -20,14 +20,16 @@ void __osSyncPutChars(s32 a0, s32 a1, u8 *a2) {
sp24.unk2[sp20] = a2[sp20];
}
while (!__osAtomicDec(&D_80334A44))
while (!__osAtomicDec(&D_80334A44)) {
;
}
sp1c = __osDisableInt();
*(u32 *) 0xC0000000 = *(u32 *) &sp24;
while (!(__osGetCause() & 0x2000))
while (!(__osGetCause() & 0x2000)) {
;
}
*(u32 *) 0xC000000C = 0;
D_80334A44++;

View File

@ -42,8 +42,9 @@ void __osViInit(void) {
D_80334914->unk00 = 32;
D_80334914->features = D_80334914->unk08->comRegs.ctrl;
#ifndef VERSION_JP
while (HW_REG(VI_CURRENT_REG, u32) > 0xa)
while (HW_REG(VI_CURRENT_REG, u32) > 0xa) {
;
}
HW_REG(VI_STATUS_REG, u32) = 0;
#endif
__osViSwapContext();

View File

@ -29,8 +29,9 @@ void __osViSwapContext() {
s1->unk2c = s0->fldRegs[field].yScale;
}
hStart = s0->comRegs.hStart;
if (s1->unk00 & 0x20)
if (s1->unk00 & 0x20) {
hStart = 0;
}
if (s1->unk00 & 0x40) {
s1->unk2c = 0;
origin = osVirtualToPhysical(s1->buffer);

View File

@ -16,16 +16,18 @@ static void _bnkfPatchBank(ALInstrument *inst, ALBankFile *f, u8 *table) {
ALWaveTable *wavetable;
u8 *table2;
if (inst->flags)
if (inst->flags) {
return;
}
inst->flags = 1;
for (i = 0; i < inst->soundCount; i++) {
PATCH(inst->soundArray[i], f, ALSound *);
sound = inst->soundArray[i];
if (sound->flags)
if (sound->flags) {
continue;
}
table2 = table;
@ -34,21 +36,24 @@ static void _bnkfPatchBank(ALInstrument *inst, ALBankFile *f, u8 *table) {
PATCH(sound->keyMap, f, ALKeyMap *);
PATCH(sound->wavetable, f, ALWaveTable *);
wavetable = sound->wavetable;
if (wavetable->flags)
if (wavetable->flags) {
continue;
}
wavetable->flags = 1;
PATCH(wavetable->base, table2, u8 *);
if (wavetable->type == 0) {
PATCH(wavetable->waveInfo.adpcmWave.book, f, ALADPCMBook *);
if (wavetable->waveInfo.adpcmWave.loop != NULL)
if (wavetable->waveInfo.adpcmWave.loop != NULL) {
PATCH(wavetable->waveInfo.adpcmWave.loop, f, ALADPCMloop *);
}
} else if (wavetable->type == 1) {
if (wavetable->waveInfo.rawWave.loop != NULL)
if (wavetable->waveInfo.rawWave.loop != NULL) {
PATCH(wavetable->waveInfo.rawWave.loop, f, ALRawLoop *);
}
}
}
}
// Force adding another jr $ra. Has to be called or it doesn't get put in the
// right place.
@ -60,13 +65,15 @@ void alBnkfNew(ALBankFile *f, u8 *table) {
int i;
int j;
unused();
if (f->revision != AL_BANK_VERSION)
if (f->revision != AL_BANK_VERSION) {
return;
}
for (i = 0; i < f->bankCount; i++) {
PATCH(f->bankArray[i], f, ALBank *);
if (f->bankArray[i] == NULL)
if (f->bankArray[i] == NULL) {
continue;
}
bank = f->bankArray[i];
if (bank->flags == 0) {

View File

@ -40,13 +40,14 @@ void guMtxIdentF(float mf[4][4]) {
int r, c;
for (r = 0; r < 4; r++) {
for (c = 0; c < 4; c++) {
if (r == c)
if (r == c) {
mf[r][c] = 1.0f;
else
} else {
mf[r][c] = 0.0f;
}
}
}
}
void guMtxIdent(Mtx *m) {
float mf[4][4];
guMtxIdentF(mf);

View File

@ -13,10 +13,11 @@ void guOrthoF(float m[4][4], float left, float right, float bottom, float top, f
m[3][2] = -(far + near) / (far - near);
m[3][3] = 1;
for (row = 0; row < 4; row++) {
for (col = 0; col < 4; col++)
for (col = 0; col < 4; col++) {
m[row][col] *= scale;
}
}
}
void guOrtho(Mtx *m, float left, float right, float bottom, float top, float near, float far,
float scale) {

View File

@ -24,11 +24,12 @@ void guPerspectiveF(float mf[4][4], u16 *perspNorm, float fovy, float aspect, fl
*perspNorm = 65535;
} else {
*perspNorm = (double) (1 << 17) / (near + far);
if (*perspNorm <= 0)
if (*perspNorm <= 0) {
*perspNorm = 1;
}
}
}
}
void guPerspective(Mtx *m, u16 *perspNorm, float fovy, float aspect, float near, float far,
float scale) {
float mat[4][4];

View File

@ -41,8 +41,9 @@ void send_packet(u8 *a0, s32 a1) {
sp1c.unk2[i] = a0[i];
}
*(volatile u32 *) 0xc0000000 = *(u32 *) &sp1c;
while (!(__osGetCause() & 0x2000))
while (!(__osGetCause() & 0x2000)) {
;
}
*(volatile u32 *) 0xc000000c = 0;
}
@ -51,8 +52,9 @@ void send(u8 *buff, s32 len) {
s32 end;
s32 rem;
if (!D_80334A44) {
while (!(__osGetCause() & 0x2000))
while (!(__osGetCause() & 0x2000)) {
;
}
*(volatile u32 *) 0xc000000c = 0;
D_80334A44 = 1;
}

View File

@ -12,12 +12,14 @@ s32 osAiSetFrequency(u32 freq) {
a1 = ftmp;
if (a1 < 0x84)
if (a1 < 0x84) {
return -1;
}
a2 = (a1 / 66) & 0xff;
if (a2 > 16)
if (a2 > 16) {
a2 = 16;
}
HW_REG(AI_DACRATE_REG, u32) = a1 - 1;
HW_REG(AI_BITRATE_REG, u32) = a2 - 1;

View File

@ -30,8 +30,9 @@ s32 osAiSetNextBuffer(void *buff, u32 len) {
D_80334820 = 0;
}
if (__osAiDeviceBusy())
if (__osAiDeviceBusy()) {
return -1;
}
HW_REG(AI_DRAM_ADDR_REG, void *) = (void *) osVirtualToPhysical(sp1c);
HW_REG(AI_LEN_REG, u32) = len;

View File

@ -40,8 +40,9 @@ s32 osEepromRead(OSMesgQueue *mq, u8 address, u8 *buffer) {
sp34 = 0;
sp30 = 0;
sp2c = (u8 *) &D_80365E00;
if (address > 0x40)
if (address > 0x40) {
return -1;
}
__osSiGetAccess();
sp34 = __osEepStatus(mq, &sp28);
if (sp34 != 0 || sp28.unk00 != 0x8000) {

View File

@ -29,10 +29,12 @@ void osInitialize(void) {
D_80365CD0 = TRUE;
__osSetSR(__osGetSR() | 0x20000000);
__osSetFpcCsr(0x01000800);
while (__osSiRawReadIo(PIF_ADDR_START, &sp34))
while (__osSiRawReadIo(PIF_ADDR_START, &sp34)) {
;
while (__osSiRawWriteIo(PIF_ADDR_START, sp34 | 8))
}
while (__osSiRawWriteIo(PIF_ADDR_START, sp34 | 8)) {
;
}
*(exceptionPreamble *) EXCEPTION_TLB_MISS = __osExceptionPreamble;
*(exceptionPreamble *) EXCEPTION_XTLB_MISS = __osExceptionPreamble;
*(exceptionPreamble *) EXCEPTION_CACHE_ERROR = __osExceptionPreamble;

View File

@ -3,7 +3,8 @@
extern OSMgrArgs piMgrArgs;
OSMesgQueue *osPiGetCmdQueue(void) {
if (!piMgrArgs.initialized)
if (!piMgrArgs.initialized) {
return NULL;
}
return piMgrArgs.unk08;
}

View File

@ -6,8 +6,9 @@ s32 osPiStartDma(OSIoMesg *mb, s32 priority, s32 direction, u32 devAddr, void *v
OSMesgQueue *mq) {
register s32 result;
register OSMesgQueue *cmdQueue;
if (!piMgrArgs.initialized)
if (!piMgrArgs.initialized) {
return -1;
}
// TODO: name magic constants
if (direction == OS_READ) {

View File

@ -32,22 +32,27 @@ void osSpTaskLoad(OSTask *task) {
osWritebackDCache(physicalTask, sizeof(OSTask));
__osSpSetStatus(SPSTATUS_CLEAR_SIGNAL0 | SPSTATUS_CLEAR_SIGNAL1 | SPSTATUS_CLEAR_SIGNAL2
| SPSTATUS_SET_INTR_ON_BREAK);
while (__osSpSetPc((void *) SP_IMEM_START) == -1)
;
while (__osSpRawStartDma(1, (void *) (SP_IMEM_START - sizeof(*physicalTask)), physicalTask,
sizeof(OSTask))
== -1)
;
while (__osSpDeviceBusy())
;
while (__osSpRawStartDma(1, (void *) SP_IMEM_START, physicalTask->t.ucode_boot,
physicalTask->t.ucode_boot_size)
== -1)
while (__osSpSetPc((void *) SP_IMEM_START) == -1) {
;
}
void osSpTaskStartGo(UNUSED OSTask *task) {
while (__osSpDeviceBusy())
while (__osSpRawStartDma(1, (void *) (SP_IMEM_START - sizeof(*physicalTask)), physicalTask,
sizeof(OSTask))
== -1) {
;
}
while (__osSpDeviceBusy()) {
;
}
while (__osSpRawStartDma(1, (void *) SP_IMEM_START, physicalTask->t.ucode_boot,
physicalTask->t.ucode_boot_size)
== -1) {
;
}
}
void osSpTaskStartGo(UNUSED OSTask *task) {
while (__osSpDeviceBusy()) {
;
}
__osSpSetStatus(SPSTATUS_SET_INTR_ON_BREAK | SPSTATUS_CLEAR_SSTEP | SPSTATUS_CLEAR_BROKE
| SPSTATUS_CLEAR_HALT);
}

View File

@ -23,8 +23,9 @@ void __osTimerInterrupt() {
OSTimer *sp24;
u32 sp20;
u32 sp1c;
if (D_80334830->next == D_80334830)
if (D_80334830->next == D_80334830) {
return;
}
while (1) {
sp24 = D_80334830->next;
if (sp24 == D_80334830) {

View File

@ -11,16 +11,18 @@ void *memcpy(void *dst, const void *src, size_t size) {
}
size_t strlen(const u8 *str) {
const u8 *ptr = str;
while (*ptr)
while (*ptr) {
ptr++;
}
return ptr - str;
}
const u8 *strchr(const u8 *str, s32 ch) {
u8 c = ch;
while (*str != c) {
if (*str == 0)
if (*str == 0) {
return NULL;
}
str++;
}
return str;

View File

@ -769,6 +769,7 @@ SECTIONS
gMusicData = .;
BUILD_DIR/sound/sequences.bin.o(.data);
. = ALIGN(0x10);
gBankSetsData = .;
BUILD_DIR/sound/bank_sets.o(.data);
. = ALIGN(0x10);
}

View File

@ -29,7 +29,7 @@ which is similar to MIDI, but Turing complete. An .m64 file has a sequence
script that can spawn channels, which have channel scripts that can spawn
layers, which have layer scripts that can play notes. Each note is performed
using an instrument from a sound bank. A sequence file can use multiple banks;
`bank_sets.s` describes the mapping from sequences to sound banks. Channels
`sequences.json` describes the mapping from sequences to sound banks. Channels
can switch between banks using a command. However, in practice most sequences
limit themselves to a single sound bank. The main exception is sequence 0,
which is responsible for sound effects.

View File

@ -1,122 +0,0 @@
# This file maps each sequence to a set of sound banks it needs.
.include "macros.inc"
.section .data
.macro banks name
.hword (\name - gBankSetsData)
.endm
glabel gBankSetsData
banks bank_set_00
banks bank_set_01
banks bank_set_02
banks bank_set_03
banks bank_set_04
banks bank_set_05
banks bank_set_06
banks bank_set_07
banks bank_set_08
banks bank_set_09
banks bank_set_0A
banks bank_set_0B
banks bank_set_0C
banks bank_set_0D
banks bank_set_0E
banks bank_set_0F
banks bank_set_10
banks bank_set_11
banks bank_set_12
banks bank_set_13
banks bank_set_14
banks bank_set_15
banks bank_set_16
banks bank_set_17
banks bank_set_18
banks bank_set_19
banks bank_set_1A
banks bank_set_1B
banks bank_set_1C
banks bank_set_1D
banks bank_set_1E
banks bank_set_1F
banks bank_set_20
banks bank_set_21
.ifndef VERSION_JP
banks bank_set_22
.endif
bank_set_00: # SEQ_SOUND_PLAYER
.byte 11, 0x0A, 0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00
bank_set_01: # SEQ_EVENT_CUTSCENE_COLLECT_STAR
.byte 1, 0x22
bank_set_02: # SEQ_MENU_TITLE_SCREEN
.byte 1, 0x11
bank_set_03: # SEQ_LEVEL_GRASS
.byte 1, 0x22
bank_set_04: # SEQ_LEVEL_INSIDE_CASTLE
.byte 1, 0x0E
bank_set_05: # SEQ_LEVEL_WATER
.byte 1, 0x13
bank_set_06: # SEQ_LEVEL_HOT
.byte 1, 0x0F
bank_set_07: # SEQ_LEVEL_BOSS_KOOPA
.byte 1, 0x12
bank_set_08: # SEQ_LEVEL_SNOW
.byte 1, 0x0B
bank_set_09: # SEQ_LEVEL_SLIDE
.byte 1, 0x0D
bank_set_0A: # SEQ_LEVEL_SPOOKY
.byte 2, 0x21, 0x10
bank_set_0B: # SEQ_EVENT_PIRANHA_PLANT
.byte 1, 0x14
bank_set_0C: # SEQ_LEVEL_UNDERGROUND
.byte 1, 0x15
bank_set_0D: # SEQ_MENU_STAR_SELECT
.byte 1, 0x16
bank_set_0E: # SEQ_EVENT_POWERUP
.byte 1, 0x17
bank_set_0F: # SEQ_EVENT_METAL_CAP
.byte 1, 0x18
bank_set_10: # SEQ_EVENT_KOOPA_MESSAGE
.byte 1, 0x12
bank_set_11: # SEQ_LEVEL_KOOPA_ROAD
.byte 1, 0x19
bank_set_12: # SEQ_EVENT_HIGH_SCORE
.byte 1, 0x1F
bank_set_13: # SEQ_EVENT_MERRY_GO_ROUND
.byte 1, 0x21
bank_set_14: # SEQ_EVENT_RACE
.byte 1, 0x1A
bank_set_15: # SEQ_EVENT_CUTSCENE_STAR_SPAWN
.byte 1, 0x0E
bank_set_16: # SEQ_EVENT_BOSS
.byte 1, 0x1B
bank_set_17: # SEQ_EVENT_CUTSCENE_COLLECT_KEY
.byte 1, 0x1A
bank_set_18: # SEQ_EVENT_ENDLESS_STAIRS
.byte 1, 0x1C
bank_set_19: # SEQ_LEVEL_BOSS_KOOPA_FINAL
.byte 1, 0x1D
bank_set_1A: # SEQ_EVENT_CUTSCENE_CREDITS
.byte 1, 0x25
bank_set_1B: # SEQ_EVENT_SOLVE_PUZZLE
.byte 1, 0x14
bank_set_1C: # SEQ_EVENT_TOAD_MESSAGE
.byte 1, 0x20
bank_set_1D: # SEQ_EVENT_PEACH_MESSAGE
.byte 1, 0x1E
bank_set_1E: # SEQ_EVENT_CUTSCENE_INTRO
.byte 1, 0x1B
bank_set_1F: # SEQ_EVENT_CUTSCENE_VICTORY
.byte 1, 0x1A
bank_set_20: # SEQ_EVENT_CUTSCENE_ENDING
.byte 1, 0x23
bank_set_21: # SEQ_MENU_FILE_SELECT
.byte 1, 0x24
.ifndef VERSION_JP
bank_set_22: # SEQ_EVENT_CUTSCENE_LAKITU
.byte 1, 0x1B
.endif
bank_sets_end:

38
sound/sequences.json Normal file
View File

@ -0,0 +1,38 @@
{
"comment": "This file lists all sequences together with the sound banks they use. If a sequence uses multiple banks, the first bank will be used by default, and it can switch between them using the chan_setbank command; e.g. chan_setbank 0 will switch to the first bank in the given list.",
"00_sound_player": ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "0A"],
"01_cutscene_collect_star": ["22"],
"02_menu_title_screen": ["11"],
"03_level_grass": ["22"],
"04_level_inside_castle": ["0E"],
"05_level_water": ["13"],
"06_level_hot": ["0F"],
"07_level_boss_koopa": ["12"],
"08_level_snow": ["0B"],
"09_level_slide": ["0D"],
"0A_level_spooky": ["10", "21"],
"0B_event_piranha_plant": ["14"],
"0C_level_underground": ["15"],
"0D_menu_star_select": ["16"],
"0E_event_powerup": ["17"],
"0F_event_metal_cap": ["18"],
"10_event_koopa_message": ["12"],
"11_level_koopa_road": ["19"],
"12_event_high_score": ["1F"],
"13_event_merry_go_round": ["21"],
"14_event_race": ["1A"],
"15_cutscene_star_spawn": ["0E"],
"16_event_boss": ["1B"],
"17_cutscene_collect_key": ["1A"],
"18_event_endless_stairs": ["1C"],
"19_level_boss_koopa_final": ["1D"],
"1A_cutscene_credits": ["25"],
"1B_event_solve_puzzle": ["14"],
"1C_event_toad_message": ["20"],
"1D_event_peach_message": ["1E"],
"1E_cutscene_intro": ["1B"],
"1F_cutscene_victory": ["1A"],
"20_cutscene_ending": ["23"],
"21_menu_file_select": ["24"],
"22_cutscene_lakitu": {"ifdef": ["VERSION_US", "VERSION_EU"], "banks": ["1B"]}
}

View File

@ -47,19 +47,19 @@ struct Struct80332190 D_80332190[18] = {
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};
// Approximately 0x7FFF*(127*127-i*i)/(127*127), though towards the end it's 20% off from that. Unused.
u16 D_80332388[128] = { 0x7FFF, 32764, 32757, 32744, 32727, 32704, 32677, 32644, 32607, 32564, 32517,
32464, 32407, 32344, 32277, 32205, 32127, 32045, 31958, 31866, 31770, 31668,
31561, 31450, 31334, 31213, 31087, 30957, 30822, 30682, 30537, 30388, 30234,
30075, 29912, 29744, 29572, 29395, 29214, 29028, 28838, 28643, 28444, 28241,
28033, 27821, 27605, 27385, 27160, 26931, 26698, 26461, 26220, 25975, 25726,
25473, 25216, 24956, 24691, 24423, 24151, 23875, 23596, 23313, 23026, 22736,
22442, 22145, 21845, 21541, 21234, 20924, 20610, 20294, 19974, 19651, 19325,
18997, 18665, 18331, 17993, 17653, 17310, 16965, 16617, 16266, 15913, 15558,
15200, 14840, 14477, 14113, 13746, 13377, 13006, 12633, 12258, 11881, 11503,
11122, 10740, 10357, 9971, 9584, 9196, 8806, 8415, 8023, 7630, 7235,
6839, 6442, 6044, 5646, 5246, 4845, 4444, 4042, 3640, 3237, 2833,
2429, 2025, 1620, 1216, 810, 405, 0 };
// gAudioCosineTable[k] = round((2**15 - 1) * cos(pi/2 * k / 127)). Unused.
u16 gAudioCosineTable[128] = {
0x7FFF, 32764, 32757, 32744, 32727, 32704, 32677, 32644, 32607, 32564, 32517, 32464, 32407,
32344, 32277, 32205, 32127, 32045, 31958, 31866, 31770, 31668, 31561, 31450, 31334, 31213,
31087, 30957, 30822, 30682, 30537, 30388, 30234, 30075, 29912, 29744, 29572, 29395, 29214,
29028, 28838, 28643, 28444, 28241, 28033, 27821, 27605, 27385, 27160, 26931, 26698, 26461,
26220, 25975, 25726, 25473, 25216, 24956, 24691, 24423, 24151, 23875, 23596, 23313, 23026,
22736, 22442, 22145, 21845, 21541, 21234, 20924, 20610, 20294, 19974, 19651, 19325, 18997,
18665, 18331, 17993, 17653, 17310, 16965, 16617, 16266, 15913, 15558, 15200, 14840, 14477,
14113, 13746, 13377, 13006, 12633, 12258, 11881, 11503, 11122, 10740, 10357, 9971, 9584,
9196, 8806, 8415, 8023, 7630, 7235, 6839, 6442, 6044, 5646, 5246, 4845, 4444,
4042, 3640, 3237, 2833, 2429, 2025, 1620, 1216, 810, 405, 0,
};
// Transforms a pitch scale factor in -127..127 into a frequency scale factor
// between -1 and +1 octave.
@ -99,33 +99,35 @@ f32 gPitchBendFrequencyScale[255] = {
// Frequencies for notes using the standard twelve-tone equal temperament scale.
// For indices 0..116, gNoteFrequencies[k] = 2^((k-39)/12).
// For indices 117..128, gNoteFrequencies[k] = 0.5 * 2^((k-39)/12).
// The 39 in the formula might refer to piano key 40 (middle C, at 256 Hz) being
// the reference frequency, which is assigned value 1?
// The 39 in the formula refers to piano key 40 (middle C, at 256 Hz) being
// the reference frequency, which is assigned value 1.
// clang-format off
f32 gNoteFrequencies[128] = {
0.105112f, 0.111362f, 0.117984f, 0.125f, 0.132433f, 0.140308f, 0.148651f, 0.15749f,
0.166855f, 0.176777f, 0.187288f, 0.198425f, 0.210224f, 0.222725f, 0.235969f, 0.25f,
0.264866f, 0.280616f, 0.297302f, 0.31498f, 0.33371f, 0.353553f, 0.374577f, 0.39685f,
0.420448f, 0.445449f, 0.471937f, 0.5f, 0.529732f, 0.561231f, 0.594604f, 0.629961f,
0.66742f, 0.707107f, 0.749154f, 0.793701f, 0.840897f, 0.890899f, 0.943875f, 1.0f,
1.059463f, 1.122462f, 1.189207f, 1.259921f, 1.33484f, 1.414214f, 1.498307f, 1.587401f,
1.681793f, 1.781798f, 1.887749f, 2.0f, 2.118926f, 2.244924f, 2.378414f, 2.519842f,
2.66968f, 2.828428f, 2.996615f, 3.174803f, 3.363586f, 3.563596f, 3.775498f, 4.0f,
4.237853f, 4.489849f, 4.756829f, 5.039685f, 5.33936f, 5.656855f, 5.993229f, 6.349606f,
6.727173f, 7.127192f, 7.550996f, 8.0f, 8.475705f, 8.979697f, 9.513658f, 10.07937f,
10.67872f, 11.31371f, 11.986459f, 12.699211f, 13.454346f, 14.254383f, 15.101993f, 16.0f,
16.95141f, 17.959394f, 19.027315f, 20.15874f, 21.35744f, 22.62742f, 23.972918f, 25.398422f,
26.908691f, 28.508766f, 30.203985f, 32.0f, 33.90282f, 35.91879f, 38.05463f, 40.31748f,
42.71488f, 45.25484f, 47.945835f, 50.796844f, 53.817383f, 57.017532f, 60.40797f, 64.0f,
67.80564f, 71.83758f, 76.10926f, 80.63496f, 85.42976f, 45.25484f, 47.945835f, 50.796844f,
0.105112f, 0.111362f, 0.117984f, 0.125f, 0.132433f, 0.140308f, 0.148651f, 0.15749f, 0.166855f, 0.176777f, 0.187288f, 0.198425f,
0.210224f, 0.222725f, 0.235969f, 0.25f, 0.264866f, 0.280616f, 0.297302f, 0.31498f, 0.33371f, 0.353553f, 0.374577f, 0.39685f,
0.420448f, 0.445449f, 0.471937f, 0.5f, 0.529732f, 0.561231f, 0.594604f, 0.629961f, 0.66742f, 0.707107f, 0.749154f, 0.793701f,
0.840897f, 0.890899f, 0.943875f, 1.0f, 1.059463f, 1.122462f, 1.189207f, 1.259921f, 1.33484f, 1.414214f, 1.498307f, 1.587401f,
1.681793f, 1.781798f, 1.887749f, 2.0f, 2.118926f, 2.244924f, 2.378414f, 2.519842f, 2.66968f, 2.828428f, 2.996615f, 3.174803f,
3.363586f, 3.563596f, 3.775498f, 4.0f, 4.237853f, 4.489849f, 4.756829f, 5.039685f, 5.33936f, 5.656855f, 5.993229f, 6.349606f,
6.727173f, 7.127192f, 7.550996f, 8.0f, 8.475705f, 8.979697f, 9.513658f, 10.07937f, 10.67872f, 11.31371f, 11.986459f, 12.699211f,
13.454346f, 14.254383f, 15.101993f, 16.0f, 16.95141f, 17.959394f, 19.027315f, 20.15874f, 21.35744f, 22.62742f, 23.972918f, 25.398422f,
26.908691f, 28.508766f, 30.203985f, 32.0f, 33.90282f, 35.91879f, 38.05463f, 40.31748f, 42.71488f, 45.25484f, 47.945835f, 50.796844f,
53.817383f, 57.017532f, 60.40797f, 64.0f, 67.80564f, 71.83758f, 76.10926f, 80.63496f, 85.42976f, 45.25484f, 47.945835f, 50.796844f,
53.817383f, 57.017532f, 60.40797f, 64.0f, 67.80564f, 71.83758f, 76.10926f, 80.63496f
};
// clang-format on
u8 gDefaultShortNoteVelocityTable[16] = { 12, 25, 38, 51, 57, 64, 71, 76,
83, 89, 96, 102, 109, 115, 121, 127 };
u8 gDefaultShortNoteDurationTable[16] = { 229, 203, 177, 151, 139, 126, 113, 100,
87, 74, 61, 48, 36, 23, 10, 0 };
// goes up by ~12 at each step for the first 4 values (starting from 0), then by ~6
u8 gDefaultShortNoteVelocityTable[16] = {
12, 25, 38, 51, 57, 64, 71, 76, 83, 89, 96, 102, 109, 115, 121, 127,
};
// i*8
// goes down by 26 at each step for the first 4 values (starting from 255), then by ~12
u8 gDefaultShortNoteDurationTable[16] = {
229, 203, 177, 151, 139, 126, 113, 100, 87, 74, 61, 48, 36, 23, 10, 0,
};
// gVibratoCurve[k] = k*8
s8 gVibratoCurve[16] = { 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120 };
struct AdsrEnvelope gDefaultEnvelope[] = {
@ -134,42 +136,47 @@ struct AdsrEnvelope gDefaultEnvelope[] = {
{ ADSR_HANG, 0 } // then continue staying there
};
s16 sSineWave[0x40] = { 0, 3211, 6392, 9511, 12539, 15446, 18204, 20787, 23169, 25329,
27244, 28897, 30272, 31356, 32137, 32609, 0x7FFF, 32609, 32137, 31356,
30272, 28897, 27244, 25329, 23169, 20787, 18204, 15446, 12539, 9511,
6392, 3211, 0, -3211, -6392, -9511, -12539, -15446, -18204, -20787,
-23169, -25329, -27244, -28897, -30272, -31356, -32137, -32609, -0x7FFF, -32609,
-32137, -31356, -30272, -28897, -27244, -25329, -23169, -20787, -18204, -15446,
-12539, -9511, -6392, -3211 };
s16 sSquareWave[0x40] = { 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF,
0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
-0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF,
-0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF };
s16 sTriangleWave[0x40] = { 0, 0x7FF, 0xFFF, 0x17FF, 0x1FFF, 0x27FF, 0x2FFF, 0x37FF,
0x3FFF, 0x47FF, 0x4FFF, 0x57FF, 0x5FFF, 0x67FF, 0x6FFF, 0x77FF,
0x7FFF, 0x77FF, 0x6FFF, 0x67FF, 0x5FFF, 0x57FF, 0x4FFF, 0x47FF,
0x3FFF, 0x37FF, 0x2FFF, 0x27FF, 0x1FFF, 0x17FF, 0xFFF, 0x7FF,
0, -0x7FF, -0xFFF, -0x17FF, -0x1FFF, -10239, -0x2FFF, -0x37FF,
-0x3FFF, -0x47FF, -0x4FFF, -22527, -24575, -26623, -28671, -30719,
-0x7FFF, -30719, -28671, -26623, -24575, -22527, -0x4FFF, -0x47FF,
-0x3FFF, -0x37FF, -0x2FFF, -0x27FF, -0x1FFF, -0x17FF, -0xFFF, -0x7FF };
s16 sSawtoothWave[0x40] = { 0, 1023, 2047, 3071, 4095, 5119, 6143, 7167,
8191, 9215, 10239, 11263, 0x2FFF, 13311, 0x37FF, 15359,
0x3FFF, 17407, 0x47FF, 19455, 0x4FFF, 21503, 22527, 23551,
24575, 25599, 26623, 27647, 28671, 29695, 30719, 31743,
-0x7FFF, -31743, -30719, -29695, -28671, -27647, -26623, -25599,
-24575, -23551, -22527, -21503, -0x4FFF, -19455, -0x47FF, -17407,
-0x3FFF, -15359, -0x37FF, -13311, -0x2FFF, -11263, -10239, -9215,
-8191, -7167, -6143, -5119, -4095, -3071, -2047, -1023 };
s16 sSineWave[0x40] = {
0, 3211, 6392, 9511, 12539, 15446, 18204, 20787, 23169, 25329, 27244,
28897, 30272, 31356, 32137, 32609, 0x7FFF, 32609, 32137, 31356, 30272, 28897,
27244, 25329, 23169, 20787, 18204, 15446, 12539, 9511, 6392, 3211, 0,
-3211, -6392, -9511, -12539, -15446, -18204, -20787, -23169, -25329, -27244, -28897,
-30272, -31356, -32137, -32609, -0x7FFF, -32609, -32137, -31356, -30272, -28897, -27244,
-25329, -23169, -20787, -18204, -15446, -12539, -9511, -6392, -3211,
};
s16 sSquareWave[0x40] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF,
0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF,
-0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF,
};
s16 sTriangleWave[0x40] = {
0, 0x7FF, 0xFFF, 0x17FF, 0x1FFF, 0x27FF, 0x2FFF, 0x37FF, 0x3FFF, 0x47FF, 0x4FFF,
0x57FF, 0x5FFF, 0x67FF, 0x6FFF, 0x77FF, 0x7FFF, 0x77FF, 0x6FFF, 0x67FF, 0x5FFF, 0x57FF,
0x4FFF, 0x47FF, 0x3FFF, 0x37FF, 0x2FFF, 0x27FF, 0x1FFF, 0x17FF, 0xFFF, 0x7FF, 0,
-0x7FF, -0xFFF, -0x17FF, -0x1FFF, -10239, -0x2FFF, -0x37FF, -0x3FFF, -0x47FF, -0x4FFF, -22527,
-24575, -26623, -28671, -30719, -0x7FFF, -30719, -28671, -26623, -24575, -22527, -0x4FFF,
-0x47FF, -0x3FFF, -0x37FF, -0x2FFF, -0x27FF, -0x1FFF, -0x17FF, -0xFFF, -0x7FF,
};
s16 sSawtoothWave[0x40] = {
0, 1023, 2047, 3071, 4095, 5119, 6143, 7167, 8191, 9215, 10239,
11263, 0x2FFF, 13311, 0x37FF, 15359, 0x3FFF, 17407, 0x47FF, 19455, 0x4FFF, 21503,
22527, 23551, 24575, 25599, 26623, 27647, 28671, 29695, 30719, 31743, -0x7FFF,
-31743, -30719, -29695, -28671, -27647, -26623, -25599, -24575, -23551, -22527, -21503,
-0x4FFF, -19455, -0x47FF, -17407, -0x3FFF, -15359, -0x37FF, -13311, -0x2FFF, -11263, -10239,
-9215, -8191, -7167, -6143, -5119, -4095, -3071, -2047, -1023,
};
s16 *gWaveSamples[4] = { sSawtoothWave, sTriangleWave, sSineWave, sSquareWave };
u16 gHeadsetPanQuantization[10] = { 0x40, 0x30, 0x20, 0x10, 0, 0, 0, 0, 0, 0 };
// Linearly interpolated between
// f(0/2 * 127) = 1
// f(1/2 * 127) = 1/sqrt(2)
// f(2/2 * 127) = 0
f32 gHeadsetPanVolume[128] = {
1.0f, 0.995386f, 0.990772f, 0.986157f, 0.981543f, 0.976929f, 0.972315f, 0.967701f, 0.963087f,
0.958472f, 0.953858f, 0.949244f, 0.94463f, 0.940016f, 0.935402f, 0.930787f, 0.926173f, 0.921559f,
@ -188,6 +195,12 @@ f32 gHeadsetPanVolume[128] = {
0.50326f, 0.5f
};
// Linearly interpolated between
// f(0/4 * 127) = 1/sqrt(2)
// f(1/4 * 127) = 1
// f(2/4 * 127) = 1/sqrt(2)
// f(3/4 * 127) = 0
// f(4/4 * 127) = 1/sqrt(8)
f32 gStereoPanVolume[128] = {
0.707f, 0.716228f, 0.725457f, 0.734685f, 0.743913f, 0.753142f, 0.76237f, 0.771598f, 0.780827f,
0.790055f, 0.799283f, 0.808512f, 0.81774f, 0.826968f, 0.836197f, 0.845425f, 0.854654f, 0.863882f,
@ -206,6 +219,7 @@ f32 gStereoPanVolume[128] = {
0.342366f, 0.3535f
};
// gDefaultVolume[k] = cos(pi/2 * k / 127)
f32 gDefaultPanVolume[128] = {
1.0f, 0.999924f, 0.999694f, 0.999312f, 0.998776f, 0.998088f, 0.997248f, 0.996254f, 0.995109f,
0.993811f, 0.992361f, 0.990759f, 0.989006f, 0.987101f, 0.985045f, 0.982839f, 0.980482f, 0.977976f,

View File

@ -21,10 +21,12 @@ void sequence_player_process_sound(struct SequencePlayer *seqPlayer) {
if (seqPlayer->fadeTimer != 0) {
seqPlayer->fadeVolume += seqPlayer->fadeVelocity;
if (seqPlayer->fadeVolume > US_FLOAT2(1))
if (seqPlayer->fadeVolume > US_FLOAT2(1)) {
seqPlayer->fadeVolume = US_FLOAT2(1);
if (seqPlayer->fadeVolume < 0)
}
if (seqPlayer->fadeVolume < 0) {
seqPlayer->fadeVolume = 0;
}
if (--seqPlayer->fadeTimer == 0) {
switch (seqPlayer->state) {
@ -55,8 +57,9 @@ void sequence_player_process_sound(struct SequencePlayer *seqPlayer) {
channelVolume =
seqChannel->seqPlayer->fadeVolume * (seqChannel->volume * seqChannel->volumeScale);
if (seqChannel->seqPlayer->muted && (seqChannel->muteBehavior & MUTE_BEHAVIOR_20) != 0)
if (seqChannel->seqPlayer->muted && (seqChannel->muteBehavior & MUTE_BEHAVIOR_20) != 0) {
channelVolume *= seqChannel->seqPlayer->muteVolumeScale;
}
panFromChannel = seqChannel->panChannelWeight * seqChannel->pan;
panLayerWeight = US_FLOAT(1.0) - seqChannel->panChannelWeight;
@ -76,14 +79,16 @@ void sequence_player_process_sound(struct SequencePlayer *seqPlayer) {
f32 get_portamento_freq_scale(struct Portamento *p) {
u32 v0;
f32 result;
if (p->mode == 0)
if (p->mode == 0) {
return 1.0f;
}
p->cur += p->speed;
v0 = (u32) p->cur;
if (v0 >= 127)
if (v0 >= 127) {
v0 = 127;
}
result = US_FLOAT(1.0) + p->extent * (gPitchBendFrequencyScale[v0 + 127] - US_FLOAT(1.0));
return result;
@ -136,10 +141,11 @@ f32 get_vibrato_freq_scale(struct VibratoState *vib) {
} else {
if (vib->extent != vib->seqChannel->vibratoExtentTarget) {
vib->extentChangeTimer = vib->seqChannel->vibratoExtentChangeDelay;
if (vib->extentChangeTimer == 0)
if (vib->extentChangeTimer == 0) {
vib->extent = vib->seqChannel->vibratoExtentTarget;
}
}
}
if (vib->rateChangeTimer) {
if (vib->rateChangeTimer == 1) {
@ -152,10 +158,11 @@ f32 get_vibrato_freq_scale(struct VibratoState *vib) {
} else {
if (vib->rate != vib->seqChannel->vibratoRateTarget) {
vib->rateChangeTimer = vib->seqChannel->vibratoRateChangeDelay;
if (vib->rateChangeTimer == 0)
if (vib->rateChangeTimer == 0) {
vib->rate = vib->seqChannel->vibratoRateTarget;
}
}
}
if (vib->extent == 0) {
return 1.0f;

View File

@ -155,46 +155,94 @@ u8 sSoundRequestCount = 0;
#define DYN3(cond1, val1, cond2, val2, cond3, val3, res) \
1 << (15 - cond1) | 1 << (15 - cond2) | 1 << (15 - cond3) | res, val1, val2, val3
s16 sDynBbh[] = { // BBH
SEQ_LEVEL_SPOOKY, DYN1(MARIO_IS_IN_ROOM, BBH_OUTSIDE_ROOM, 6),
DYN1(MARIO_IS_IN_ROOM, BBH_NEAR_MERRY_GO_ROUND_ROOM, 6), 5
s16 sDynBbh[] = {
SEQ_LEVEL_SPOOKY,
DYN1(MARIO_IS_IN_ROOM, BBH_OUTSIDE_ROOM, 6),
DYN1(MARIO_IS_IN_ROOM, BBH_NEAR_MERRY_GO_ROUND_ROOM, 6),
5,
};
s16 sDynDdd[] = { // DDD
SEQ_LEVEL_WATER, DYN2(MARIO_X_LT, -800, MARIO_IS_IN_AREA, AREA_DDD_WHIRLPOOL & 0xf, 0),
s16 sDynDdd[] = {
SEQ_LEVEL_WATER,
DYN2(MARIO_X_LT, -800, MARIO_IS_IN_AREA, AREA_DDD_WHIRLPOOL & 0xf, 0),
DYN3(MARIO_Y_GE, -2000, MARIO_X_LT, 470, MARIO_IS_IN_AREA, AREA_DDD_WHIRLPOOL & 0xf, 0),
DYN2(MARIO_Y_GE, 100, MARIO_IS_IN_AREA, AREA_DDD_SUB & 0xf, 2), 1
DYN2(MARIO_Y_GE, 100, MARIO_IS_IN_AREA, AREA_DDD_SUB & 0xf, 2),
1,
};
s16 sDynJrb[] = {
// JRB
SEQ_LEVEL_WATER,
DYN2(MARIO_Y_GE, 945, MARIO_X_LT, -5260, 0),
DYN1(MARIO_IS_IN_AREA, AREA_JRB_SHIP & 0xf, 0),
DYN1(MARIO_Y_GE, 1000, 0),
DYN2(MARIO_Y_GE, -3100, MARIO_Z_LT, -900, 2),
1,
5 // bogus entry, ignored
5, // bogus entry, ignored (was JRB originally intended to have spooky music?)
};
s16 sDynWdw[] = { // WDW
SEQ_LEVEL_UNDERGROUND, DYN2(MARIO_Y_LT, -670, MARIO_IS_IN_AREA, AREA_WDW_MAIN & 0xf, 4),
DYN1(MARIO_IS_IN_AREA, AREA_WDW_TOWN & 0xf, 4), 3
s16 sDynWdw[] = {
SEQ_LEVEL_UNDERGROUND,
DYN2(MARIO_Y_LT, -670, MARIO_IS_IN_AREA, AREA_WDW_MAIN & 0xf, 4),
DYN1(MARIO_IS_IN_AREA, AREA_WDW_TOWN & 0xf, 4),
3,
};
s16 sDynHmc[] = { // HMC
SEQ_LEVEL_UNDERGROUND, DYN2(MARIO_X_GE, 0, MARIO_Y_LT, -203, 4),
DYN2(MARIO_X_LT, 0, MARIO_Y_LT, -2400, 4), 3
s16 sDynHmc[] = {
SEQ_LEVEL_UNDERGROUND,
DYN2(MARIO_X_GE, 0, MARIO_Y_LT, -203, 4),
DYN2(MARIO_X_LT, 0, MARIO_Y_LT, -2400, 4),
3,
};
s16 sDynUnk38[] = { // LEVEL_UNKNOWN_38
SEQ_LEVEL_UNDERGROUND, DYN1(MARIO_IS_IN_AREA, 1, 3), DYN1(MARIO_IS_IN_AREA, 2, 4),
DYN1(MARIO_IS_IN_AREA, 3, 7), 0
s16 sDynUnk38[] = {
SEQ_LEVEL_UNDERGROUND,
DYN1(MARIO_IS_IN_AREA, 1, 3),
DYN1(MARIO_IS_IN_AREA, 2, 4),
DYN1(MARIO_IS_IN_AREA, 3, 7),
0,
};
s16 D_80331EA8[] = { 0, 0 };
s16 sDynNone[] = { SEQ_SOUND_PLAYER, 0 };
u8 sCurrentMusicDynamic = 0xff;
u8 sBackgroundMusicForDynamics = SEQUENCE_NONE;
#define _ D_80331EA8
s16 *sLevelDynamics[] = { _, _, _, _, sDynBbh, _, _, sDynHmc, _, _, _, sDynWdw, sDynJrb,
_, _, _, _, _, _, _, _, _, _, sDynDdd, _, _,
_, _, _, _, _, _, _, _, _, _, _, _, sDynUnk38 };
#define _ sDynNone
s16 *sLevelDynamics[] = {
_, // LEVEL_NONE
_, // LEVEL_UNKNOWN_1
_, // LEVEL_UNKNOWN_2
_, // LEVEL_UNKNOWN_3
sDynBbh, // LEVEL_BBH
_, // LEVEL_CCM
_, // LEVEL_CASTLE
sDynHmc, // LEVEL_HMC
_, // LEVEL_SSL
_, // LEVEL_BOB
_, // LEVEL_SL
sDynWdw, // LEVEL_WDW
sDynJrb, // LEVEL_JRB
_, // LEVEL_THI
_, // LEVEL_TTC
_, // LEVEL_RR
_, // LEVEL_CASTLE_GROUNDS
_, // LEVEL_BITDW
_, // LEVEL_VCUTM
_, // LEVEL_BITFS
_, // LEVEL_SA
_, // LEVEL_BITS
_, // LEVEL_LLL
sDynDdd, // LEVEL_DDD
_, // LEVEL_WF
_, // LEVEL_ENDING
_, // LEVEL_CASTLE_COURTYARD
_, // LEVEL_PSS
_, // LEVEL_COTMC
_, // LEVEL_TOTWC
_, // LEVEL_BOWSER_1
_, // LEVEL_WMOTR
_, // LEVEL_UNKNOWN_32
_, // LEVEL_BOWSER_2
_, // LEVEL_BOWSER_3
_, // LEVEL_UNKNOWN_35
_, // LEVEL_TTM
_, // LEVEL_UNKNOWN_37
sDynUnk38, // LEVEL_UNKNOWN_38
};
STATIC_ASSERT(ARRAY_COUNT(sLevelDynamics) == LEVEL_COUNT, "change this array if you are adding levels");
#undef _
@ -210,10 +258,14 @@ struct MusicDynamic {
}; // size = 0xC
struct MusicDynamic sMusicDynamics[8] = {
{ 0x0000, 0, 127, 100, 0x0e43, 0, 0, 100 }, { 0x0003, 0, 127, 100, 0x0e40, 0, 0, 100 },
{ 0x0e43, 0, 127, 200, 0x0000, 0, 0, 200 }, { 0x02ff, 0, 127, 100, 0x0100, 0, 0, 100 },
{ 0x03f7, 0, 127, 100, 0x0008, 0, 0, 100 }, { 0x0070, 0, 127, 10, 0x0000, 0, 0, 100 },
{ 0x0000, 0, 127, 100, 0x0070, 0, 0, 10 }, { 0xffff, 0, 127, 100, 0x0000, 0, 0, 100 }
{ 0x0000, 0, 127, 100, 0x0e43, 0, 0, 100 }, // SEQ_LEVEL_WATER
{ 0x0003, 0, 127, 100, 0x0e40, 0, 0, 100 }, // SEQ_LEVEL_WATER
{ 0x0e43, 0, 127, 200, 0x0000, 0, 0, 200 }, // SEQ_LEVEL_WATER
{ 0x02ff, 0, 127, 100, 0x0100, 0, 0, 100 }, // SEQ_LEVEL_UNDERGROUND
{ 0x03f7, 0, 127, 100, 0x0008, 0, 0, 100 }, // SEQ_LEVEL_UNDERGROUND
{ 0x0070, 0, 127, 10, 0x0000, 0, 0, 100 }, // SEQ_LEVEL_SPOOKY
{ 0x0000, 0, 127, 100, 0x0070, 0, 0, 10 }, // SEQ_LEVEL_SPOOKY
{ 0xffff, 0, 127, 100, 0x0000, 0, 0, 100 }, // any (unused)
};
u8 gAreaEchoLevel[][3] = {
@ -313,7 +365,8 @@ STATIC_ASSERT(ARRAY_COUNT(D_80332028) == LEVEL_COUNT, "change this array if you
#define AUDIO_MAX_DISTANCE US_FLOAT(22000.0)
u8 sBackgroundMusicDefaultVolume[35] = {
// Default volume for background music sequences (playing on player 0).
u8 sBackgroundMusicDefaultVolume[] = {
127, // SEQ_SOUND_PLAYER
80, // SEQ_EVENT_CUTSCENE_COLLECT_STAR
80, // SEQ_MENU_TITLE_SCREEN
@ -348,23 +401,30 @@ u8 sBackgroundMusicDefaultVolume[35] = {
80, // SEQ_EVENT_CUTSCENE_VICTORY
70, // SEQ_EVENT_CUTSCENE_ENDING
65, // SEQ_MENU_FILE_SELECT
0 // SEQ_EVENT_CUTSCENE_LAKITU
0, // SEQ_EVENT_CUTSCENE_LAKITU (not in JP)
};
STATIC_ASSERT(ARRAY_COUNT(sBackgroundMusicDefaultVolume) == SEQ_COUNT,
"change this array if you are adding sequences");
u8 gPlayer0CurSeqId = SEQUENCE_NONE;
u8 sMusicDynamicDelay = 0;
u8 D_803320A4[SOUND_BANK_COUNT] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // pointers to head of list
u8 D_803320B0[SOUND_BANK_COUNT] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; // pointers to head of list
u8 D_803320BC[SOUND_BANK_COUNT] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
u8 D_803320C8[SOUND_BANK_COUNT] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; // sizes of D_80360C38
// Banks 2 and 7 both grew from 0x30 sounds to 0x40 in size in US.
#ifdef VERSION_JP
#define NUM_DIFF 0x30
#define BANK27_SIZE 0x30
#else
#define NUM_DIFF 0x40
#define BANK27_SIZE 0x40
#endif
u8 sNumSoundsPerBank[SOUND_BANK_COUNT] = { 0x70, 0x30, NUM_DIFF, 0x80, 0x20,
0x80, 0x20, NUM_DIFF, 0x80, 0x80 };
#undef NUM_DIFF
u8 sNumSoundsPerBank[SOUND_BANK_COUNT] = {
0x70, 0x30, BANK27_SIZE, 0x80, 0x20, 0x80, 0x20, BANK27_SIZE, 0x80, 0x80,
};
#undef BANK27_SIZE
f32 gDefaultSoundArgs[3] = { 0.0f, 0.0f, 0.0f };
f32 gUnusedSoundArgs[3] = { 1.0f, 1.0f, 1.0f };
u8 gSoundBankDisabled[16] = { 0 };
@ -387,8 +447,8 @@ struct Sound sSoundRequests[0x100];
struct ChannelVolumeScaleFade D_80360928[SEQUENCE_PLAYERS][CHANNELS_MAX];
u8 D_80360C28[SOUND_BANK_COUNT];
u8 D_80360C38[SOUND_BANK_COUNT][1];
struct SoundCharacteristics gSoundBanks[SOUND_BANK_COUNT]
[40]; // list item memory for D_803320A4 and D_803320B0
// list item memory for D_803320A4 and D_803320B0
struct SoundCharacteristics gSoundBanks[SOUND_BANK_COUNT][40];
u8 D_80363808[SOUND_BANK_COUNT];
u8 D_80363812;
static u8 sCapVolumeTo40;
@ -916,12 +976,14 @@ static f32 get_sound_pan(f32 x, f32 z) {
f32 pan;
absX = (x < 0 ? -x : x);
if (absX > AUDIO_MAX_DISTANCE)
if (absX > AUDIO_MAX_DISTANCE) {
absX = AUDIO_MAX_DISTANCE;
}
absZ = (z < 0 ? -z : z);
if (absZ > AUDIO_MAX_DISTANCE)
if (absZ > AUDIO_MAX_DISTANCE) {
absZ = AUDIO_MAX_DISTANCE;
}
// There are 4 panning equations (12-hr clock used for angles)
// 1. (0,0) fully-centered pan
@ -1024,8 +1086,9 @@ static u8 get_sound_reverb(UNUSED u8 bankIndex, UNUSED u8 item, u8 channelIndex)
#endif
level = (gCurrLevelNum > LEVEL_MAX ? LEVEL_MAX : gCurrLevelNum);
area = gCurrAreaIndex - 1;
if (area > 2)
if (area > 2) {
area = 2;
}
#ifndef VERSION_JP
}
#endif
@ -1774,8 +1837,9 @@ void play_music(u8 player, u16 seqArgs, s16 fadeTimer) {
}
// Abort if the queue is already full.
if (sBackgroundMusicQueueSize == MAX_BG_MUSIC_QUEUE_SIZE)
if (sBackgroundMusicQueueSize == MAX_BG_MUSIC_QUEUE_SIZE) {
return;
}
// If already in the queue, abort, after first restarting the sequence if
// it is first, and handling disabled music somehow.
@ -1822,8 +1886,9 @@ void stop_background_music(u16 seqId) {
u8 foundIndex;
u8 i;
if (sBackgroundMusicQueueSize == 0)
if (sBackgroundMusicQueueSize == 0) {
return;
}
// If sequence is not found, remove an empty queue item (the next empty
// queue slot).

View File

@ -485,8 +485,9 @@ void *sequence_dma_immediate(s32 seqId, s32 arg1) {
seqLength = ALIGN16(seqLength);
seqData = gSeqFileHeader->seqArray[seqId].offset;
ptr = alloc_bank_or_seq(&gSeqLoadedPool, 1, seqLength, arg1, seqId);
if (ptr == NULL)
if (ptr == NULL) {
return NULL;
}
audio_dma_copy_immediate((u32) seqData, ptr, seqLength);
gSeqLoadStatus[seqId] = SOUND_LOAD_STATUS_COMPLETE;
@ -640,6 +641,9 @@ void load_sequence_internal(u32 player, u32 seqId, s32 loadAsync) {
if (bank_load_async(bankId, 2, seqPlayer) == NULL) {
return;
}
// @bug This should set the last bank (i.e. the first in the JSON)
// as default, not the missing one. This code path never gets
// taken, though -- all sequence loading is synchronous.
seqPlayer->anyBank[0] = bankId;
} else if (load_banks_immediate(seqId, &seqPlayer->anyBank[0]) == NULL) {
return;
@ -651,17 +655,20 @@ void load_sequence_internal(u32 player, u32 seqId, s32 loadAsync) {
seqPlayer->seqId = seqId;
sequenceData = get_bank_or_seq(&gSeqLoadedPool, 2, seqId);
if (sequenceData == NULL) {
if (seqPlayer->seqDmaInProgress)
if (seqPlayer->seqDmaInProgress) {
return;
}
if (loadAsync)
if (loadAsync) {
sequenceData = sequence_dma_async(seqId, 2, seqPlayer);
else
} else {
sequenceData = sequence_dma_immediate(seqId, 2);
}
if (sequenceData == NULL)
if (sequenceData == NULL) {
return;
}
}
init_sequence_player(player);
seqPlayer->scriptState.depth = 0;

View File

@ -83,10 +83,11 @@ void discard_sequence(s32 seqId) {
s32 i;
for (i = 0; i < SEQUENCE_PLAYERS; i++) {
if (gSequencePlayers[i].enabled && gSequencePlayers[i].seqId == seqId)
if (gSequencePlayers[i].enabled && gSequencePlayers[i].seqId == seqId) {
sequence_player_disable(gSequencePlayers + i);
}
}
}
void *soundAlloc(struct SoundAllocPool *pool, u32 size) {
s32 last;
@ -97,8 +98,9 @@ void *soundAlloc(struct SoundAllocPool *pool, u32 size) {
start = pool->cur;
pool->cur += ALIGN16(size);
last = pool->cur - start - 1;
for (i = 0; i <= last; i++)
for (i = 0; i <= last; i++) {
start[i] = 0;
}
} else {
return NULL;
}

View File

@ -310,8 +310,9 @@ void note_pool_clear(struct NotePool *pool) {
j = 0;
do {
cur = source->next;
if (cur == source)
if (cur == source) {
break;
}
audio_list_remove(cur);
audio_list_push_back(dest, cur);
j++;
@ -329,8 +330,9 @@ void note_pool_fill(struct NotePool *pool, s32 count) {
note_pool_clear(pool);
for (i = 0, j = 0; j < count; i++) {
if (i == 4)
if (i == 4) {
return;
}
switch (i) {
case 0:
@ -356,8 +358,9 @@ void note_pool_fill(struct NotePool *pool, s32 count) {
while (j < count) {
note = audio_list_pop_back(source);
if (note == NULL)
if (note == NULL) {
break;
}
audio_list_push_back(dest, &note->listItem);
j++;
}

View File

@ -795,8 +795,9 @@ u8 get_instrument(struct SequenceChannel *seqChannel, u8 instId, struct Instrume
while (instId != 0xff) {
inst = gCtlEntries[seqChannelCpy.bankId].instruments[instId];
if (inst != NULL)
if (inst != NULL) {
break;
}
instId--;
}
}
@ -1069,8 +1070,9 @@ void sequence_channel_process_script(struct SequenceChannel *seqChannel) {
case 0xc6: // switch bank within set
temp = m64_read_u8(state);
// Switch to the temp's (0-indexed) bank in this
// sequence's bank set, counting backwards.
// Switch to the temp's (0-indexed) bank in this sequence's
// bank set. Note that in the binary format (not in the JSON!)
// the banks are listed backwards, so we counts from the back.
// (gAlBankSets[offset] is number of banks)
offset = ((u16 *) gAlBankSets)[seqPlayer->seqId];
temp = gAlBankSets[offset + gAlBankSets[offset] - temp];
@ -1339,12 +1341,15 @@ void sequence_player_process_sequence(struct SequencePlayer *seqPlayer) {
case 0xf9: // jump if < 0
case 0xf5: // jump if >= 0
u16v = m64_read_s16(state);
if (cmd == 0xfa && value != 0)
if (cmd == 0xfa && value != 0) {
break;
if (cmd == 0xf9 && value >= 0)
}
if (cmd == 0xf9 && value >= 0) {
break;
if (cmd == 0xf5 && value < 0)
}
if (cmd == 0xf5 && value < 0) {
break;
}
state->pc = seqPlayer->seqData + u16v;
break;

View File

@ -123,9 +123,10 @@ u64 *func_80313CD4(u64 *cmdBuf, s32 *writtenCmds, u16 *aiBuf, s32 bufLen) {
// chunkLen = v0 rounded to nearest multiple of 8
chunkLen = v0 - (v0 & 7);
if ((v0 & 7) >= 4)
if ((v0 & 7) >= 4) {
chunkLen += 8;
}
}
process_sequences(i - 1);
if (D_802211B0.unk1 != 0) {
func_80313920(chunkLen, gAudioUpdatesPerFrame - i);
@ -134,8 +135,9 @@ u64 *func_80313CD4(u64 *cmdBuf, s32 *writtenCmds, u16 *aiBuf, s32 bufLen) {
remaining -= chunkLen;
aiBufPtr += chunkLen;
}
if (D_802211B0.unk2 != 0)
if (D_802211B0.unk2 != 0) {
D_802211B0.unk2--;
}
D_802211B0.unk3 ^= 1;
*writtenCmds = cmd - cmdBuf;
return cmd;

View File

@ -24,8 +24,9 @@ static void func_80383B70(u32 segptr) {
u16 RandomU16(void) {
u16 temp1, temp2;
if (gRandomSeed16 == 22026)
if (gRandomSeed16 == 22026) {
gRandomSeed16 = 0;
}
temp1 = (gRandomSeed16 & 0x00FF) << 8;
temp1 = temp1 ^ gRandomSeed16;
@ -36,10 +37,11 @@ u16 RandomU16(void) {
temp2 = (temp1 >> 1) ^ 0xFF80;
if ((temp1 & 1) == 0) {
if (temp2 == 43605)
if (temp2 == 43605) {
gRandomSeed16 = 0;
else
} else {
gRandomSeed16 = temp2 ^ 0x1FF4;
}
} else {
gRandomSeed16 = temp2 ^ 0x8180;
}
@ -53,11 +55,12 @@ f32 RandomFloat(void) {
}
s32 RandomSign(void) {
if (RandomU16() >= 0x7FFF)
if (RandomU16() >= 0x7FFF) {
return 1;
else
} else {
return -1;
}
}
void func_80383D68(struct Object *object) {
object->header.gfx.pos[0] = object->oPosX;
@ -83,9 +86,10 @@ static u32 cur_object_stack_pop(void) {
static void Unknown80383E44(void) // ?
{
for (;;)
for (;;) {
;
}
}
static s32 beh_cmd_unhide(void) {
obj_hide();
@ -558,12 +562,15 @@ static s32 Behavior24(void) {
}
static s32 beh_cmd_begin(void) {
if (obj_has_behavior(bhvHauntedChair))
if (obj_has_behavior(bhvHauntedChair)) {
bhv_init_room();
if (obj_has_behavior(bhvMadPiano))
}
if (obj_has_behavior(bhvMadPiano)) {
bhv_init_room();
if (obj_has_behavior(bhvMessagePanel))
}
if (obj_has_behavior(bhvMessagePanel)) {
gCurrentObject->oCollisionDistance = 150.0f;
}
gBehCommand++;
return BEH_CONTINUE;
}
@ -605,7 +612,7 @@ static s32 beh_cmd_interact_type(void) {
// unused
static s32 Behavior31(void) {
gCurrentObject->oUnk190 = gBehCommand[1];
gCurrentObject->oInteractionSubtype = gBehCommand[1];
gBehCommand += 2;
return BEH_CONTINUE;
@ -662,8 +669,9 @@ static s32 beh_cmd_text_anim_rate(void) {
u8 objectOffset = (gBehCommand[0] >> 16) & 0xFF;
s16 arg1 = (gBehCommand[0] & 0xFFFF);
if ((gGlobalTimer % arg1) == 0)
if ((gGlobalTimer % arg1) == 0) {
cur_object_add_int(objectOffset, 1);
}
gBehCommand++;
return BEH_CONTINUE;
@ -748,8 +756,9 @@ void cur_object_exec_behavior(void) {
distanceFromMario = 0.0f;
}
if (flagsLo & OBJ_FLAG_COMPUTE_ANGLE_TO_MARIO)
if (flagsLo & OBJ_FLAG_COMPUTE_ANGLE_TO_MARIO) {
gCurrentObject->oAngleToMario = angle_to_object(gCurrentObject, gMarioObject);
}
if (gCurrentObject->oAction != gCurrentObject->oPrevAction) {
(void) (gCurrentObject->oTimer = 0, gCurrentObject->oSubAction = 0,
@ -765,8 +774,9 @@ void cur_object_exec_behavior(void) {
gCurrentObject->behScript = gBehCommand;
if (gCurrentObject->oTimer < 0x3FFFFFFF)
if (gCurrentObject->oTimer < 0x3FFFFFFF) {
gCurrentObject->oTimer++;
}
if (gCurrentObject->oAction != gCurrentObject->oPrevAction) {
(void) (gCurrentObject->oTimer = 0, gCurrentObject->oSubAction = 0,
@ -775,26 +785,33 @@ void cur_object_exec_behavior(void) {
flagsLo = (s16) gCurrentObject->oFlags;
if (flagsLo & OBJ_FLAG_0010)
if (flagsLo & OBJ_FLAG_0010) {
obj_set_facing_to_move_angles(gCurrentObject);
}
if (flagsLo & OBJ_FLAG_SET_FACE_YAW_TO_MOVE_YAW)
if (flagsLo & OBJ_FLAG_SET_FACE_YAW_TO_MOVE_YAW) {
gCurrentObject->oFaceAngleYaw = gCurrentObject->oMoveAngleYaw;
}
if (flagsLo & OBJ_FLAG_MOVE_XZ_USING_FVEL)
if (flagsLo & OBJ_FLAG_MOVE_XZ_USING_FVEL) {
obj_move_xz_using_fvel_and_yaw();
}
if (flagsLo & OBJ_FLAG_MOVE_Y_WITH_TERMINAL_VEL)
if (flagsLo & OBJ_FLAG_MOVE_Y_WITH_TERMINAL_VEL) {
obj_move_y_with_terminal_vel();
}
if (flagsLo & OBJ_FLAG_TRANSFORM_RELATIVE_TO_PARENT)
if (flagsLo & OBJ_FLAG_TRANSFORM_RELATIVE_TO_PARENT) {
build_object_transform_relative_to_parent(gCurrentObject);
}
if (flagsLo & OBJ_FLAG_0800)
if (flagsLo & OBJ_FLAG_0800) {
func_802A2270(gCurrentObject);
}
if (flagsLo & OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE)
if (flagsLo & OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE) {
func_80383D68(gCurrentObject);
}
if (gCurrentObject->oRoom != -1) {
obj_enable_rendering_if_mario_in_room();

View File

@ -18,7 +18,8 @@ Vec3s gVec3sZero = { 0, 0, 0 };
Vec3f gVec3fOne = { 1.0f, 1.0f, 1.0f };
UNUSED Vec3s gVec3sOne = { 1, 1, 1 };
/** Initialize a geo node with a given type. Sets all links such that there
/**
* Initialize a geo node with a given type. Sets all links such that there
* are no siblings, parent or children for this node.
*/
void init_scene_graph_node_links(struct GraphNode *graphNode, s32 type) {
@ -30,7 +31,8 @@ void init_scene_graph_node_links(struct GraphNode *graphNode, s32 type) {
graphNode->children = NULL;
}
/** Allocated and returns a newly created root node
/**
* Allocated and returns a newly created root node
*/
struct GraphNodeRoot *init_graph_node_root(struct AllocOnlyPool *pool, struct GraphNodeRoot *graphNode,
s16 areaIndex, s16 x, s16 y, s16 width, s16 height) {
@ -54,7 +56,8 @@ struct GraphNodeRoot *init_graph_node_root(struct AllocOnlyPool *pool, struct Gr
return graphNode;
}
/** Allocates and returns a newly created otrhographic projection node
/**
* Allocates and returns a newly created otrhographic projection node
*/
struct GraphNodeOrthoProjection *
init_graph_node_ortho_projection(struct AllocOnlyPool *pool, struct GraphNodeOrthoProjection *graphNode,
@ -71,7 +74,8 @@ init_graph_node_ortho_projection(struct AllocOnlyPool *pool, struct GraphNodeOrt
return graphNode;
}
/** Allocates and returns a newly created perspective node
/**
* Allocates and returns a newly created perspective node
*/
struct GraphNodePerspective *init_graph_node_perspective(struct AllocOnlyPool *pool,
struct GraphNodePerspective *graphNode,
@ -98,7 +102,8 @@ struct GraphNodePerspective *init_graph_node_perspective(struct AllocOnlyPool *p
return graphNode;
}
/** Allocates and returns a newly created start node
/**
* Allocates and returns a newly created start node
*/
struct GraphNodeStart *init_graph_node_start(struct AllocOnlyPool *pool,
struct GraphNodeStart *graphNode) {
@ -113,7 +118,8 @@ struct GraphNodeStart *init_graph_node_start(struct AllocOnlyPool *pool,
return graphNode;
}
/** Allocates and returns a newly created master list node
/**
* Allocates and returns a newly created master list node
*/
struct GraphNodeMasterList *init_graph_node_master_list(struct AllocOnlyPool *pool,
struct GraphNodeMasterList *graphNode, s16 on) {
@ -132,7 +138,8 @@ struct GraphNodeMasterList *init_graph_node_master_list(struct AllocOnlyPool *po
return graphNode;
}
/** Allocates and returns a newly created render range node
/**
* Allocates and returns a newly created render range node
*/
struct GraphNodeLevelOfDetail *init_graph_node_render_range(struct AllocOnlyPool *pool,
struct GraphNodeLevelOfDetail *graphNode,
@ -150,7 +157,8 @@ struct GraphNodeLevelOfDetail *init_graph_node_render_range(struct AllocOnlyPool
return graphNode;
}
/** Allocates and returns a newly created switch case node
/**
* Allocates and returns a newly created switch case node
*/
struct GraphNodeSwitchCase *init_graph_node_switch_case(struct AllocOnlyPool *pool,
struct GraphNodeSwitchCase *graphNode,
@ -175,7 +183,8 @@ struct GraphNodeSwitchCase *init_graph_node_switch_case(struct AllocOnlyPool *po
return graphNode;
}
/** Allocates and returns a newly created camera node
/**
* Allocates and returns a newly created camera node
*/
struct GraphNodeCamera *init_graph_node_camera(struct AllocOnlyPool *pool,
struct GraphNodeCamera *graphNode, f32 *fromPos,
@ -201,7 +210,8 @@ struct GraphNodeCamera *init_graph_node_camera(struct AllocOnlyPool *pool,
return graphNode;
}
/** Allocates and returns a newly created translation rotation node
/**
* Allocates and returns a newly created translation rotation node
*/
struct GraphNodeTranslationRotation *
init_graph_node_translation_rotation(struct AllocOnlyPool *pool,
@ -223,7 +233,8 @@ init_graph_node_translation_rotation(struct AllocOnlyPool *pool,
return graphNode;
}
/** Allocates and returns a newly created translation node
/**
* Allocates and returns a newly created translation node
*/
struct GraphNodeTranslation *init_graph_node_translation(struct AllocOnlyPool *pool,
struct GraphNodeTranslation *graphNode,
@ -244,7 +255,8 @@ struct GraphNodeTranslation *init_graph_node_translation(struct AllocOnlyPool *p
return graphNode;
}
/** Allocates and returns a newly created rotation node
/**
* Allocates and returns a newly created rotation node
*/
struct GraphNodeRotation *init_graph_node_rotation(struct AllocOnlyPool *pool,
struct GraphNodeRotation *graphNode,
@ -264,7 +276,8 @@ struct GraphNodeRotation *init_graph_node_rotation(struct AllocOnlyPool *pool,
return graphNode;
}
/** Allocates and returns a newly created scaling node
/**
* Allocates and returns a newly created scaling node
*/
struct GraphNodeScale *init_graph_node_scale(struct AllocOnlyPool *pool,
struct GraphNodeScale *graphNode, s32 drawingLayer,
@ -283,7 +296,8 @@ struct GraphNodeScale *init_graph_node_scale(struct AllocOnlyPool *pool,
return graphNode;
}
/** Allocates and returns a newly created object node
/**
* Allocates and returns a newly created object node
*/
struct GraphNodeObject *init_graph_node_object(struct AllocOnlyPool *pool,
struct GraphNodeObject *graphNode,
@ -312,7 +326,8 @@ struct GraphNodeObject *init_graph_node_object(struct AllocOnlyPool *pool,
return graphNode;
}
/** Allocates and returns a newly created frustum culling radius node
/**
* Allocates and returns a newly created frustum culling radius node
*/
struct GraphNodeCullingRadius *init_graph_node_culling_radius(struct AllocOnlyPool *pool,
struct GraphNodeCullingRadius *graphNode,
@ -329,7 +344,8 @@ struct GraphNodeCullingRadius *init_graph_node_culling_radius(struct AllocOnlyPo
return graphNode;
}
/** Allocates and returns a newly created animated part node
/**
* Allocates and returns a newly created animated part node
*/
struct GraphNodeAnimatedPart *init_graph_node_animated_part(struct AllocOnlyPool *pool,
struct GraphNodeAnimatedPart *graphNode,
@ -349,7 +365,8 @@ struct GraphNodeAnimatedPart *init_graph_node_animated_part(struct AllocOnlyPool
return graphNode;
}
/** Allocates and returns a newly created billboard node
/**
* Allocates and returns a newly created billboard node
*/
struct GraphNodeBillboard *init_graph_node_billboard(struct AllocOnlyPool *pool,
struct GraphNodeBillboard *graphNode,
@ -369,7 +386,8 @@ struct GraphNodeBillboard *init_graph_node_billboard(struct AllocOnlyPool *pool,
return graphNode;
}
/** Allocates and returns a newly created displaylist node
/**
* Allocates and returns a newly created displaylist node
*/
struct GraphNodeDisplayList *init_graph_node_display_list(struct AllocOnlyPool *pool,
struct GraphNodeDisplayList *graphNode,
@ -387,7 +405,8 @@ struct GraphNodeDisplayList *init_graph_node_display_list(struct AllocOnlyPool *
return graphNode;
}
/** Allocates and returns a newly created shadow node
/**
* Allocates and returns a newly created shadow node
*/
struct GraphNodeShadow *init_graph_node_shadow(struct AllocOnlyPool *pool,
struct GraphNodeShadow *graphNode, s16 shadowScale,
@ -406,7 +425,8 @@ struct GraphNodeShadow *init_graph_node_shadow(struct AllocOnlyPool *pool,
return graphNode;
}
/** Allocates and returns a newly created object parent node
/**
* Allocates and returns a newly created object parent node
*/
struct GraphNodeObjectParent *init_graph_node_object_parent(struct AllocOnlyPool *pool,
struct GraphNodeObjectParent *graphNode,
@ -423,7 +443,8 @@ struct GraphNodeObjectParent *init_graph_node_object_parent(struct AllocOnlyPool
return graphNode;
}
/** Allocates and returns a newly created generated node
/**
* Allocates and returns a newly created generated node
*/
struct GraphNodeGenerated *init_graph_node_generated(struct AllocOnlyPool *pool,
struct GraphNodeGenerated *graphNode,
@ -445,7 +466,8 @@ struct GraphNodeGenerated *init_graph_node_generated(struct AllocOnlyPool *pool,
return graphNode;
}
/** Allocates and returns a newly created background node
/**
* Allocates and returns a newly created background node
*/
struct GraphNodeBackground *init_graph_node_background(struct AllocOnlyPool *pool,
struct GraphNodeBackground *graphNode,
@ -470,7 +492,8 @@ struct GraphNodeBackground *init_graph_node_background(struct AllocOnlyPool *poo
return graphNode;
}
/** Allocates and returns a newly created held object node
/**
* Allocates and returns a newly created held object node
*/
struct GraphNodeHeldObject *init_graph_node_held_object(struct AllocOnlyPool *pool,
struct GraphNodeHeldObject *graphNode,
@ -495,7 +518,8 @@ struct GraphNodeHeldObject *init_graph_node_held_object(struct AllocOnlyPool *po
return graphNode;
}
/** Adds 'childNode' to the end of the list children from 'parent'
/**
* Adds 'childNode' to the end of the list children from 'parent'
*/
struct GraphNode *geo_add_child(struct GraphNode *parent, struct GraphNode *childNode) {
struct GraphNode *parentFirstChild;
@ -521,7 +545,8 @@ struct GraphNode *geo_add_child(struct GraphNode *parent, struct GraphNode *chil
return childNode;
}
/** Remove a node from the scene graph. It changes the links with its
/**
* Remove a node from the scene graph. It changes the links with its
* siblings and with its parent, it doesn't deallocate the memory
* since geo nodes are allocated in a pointer-bumping pool that
* gets thrown out when changing areas.
@ -550,7 +575,8 @@ struct GraphNode *geo_remove_child(struct GraphNode *graphNode) {
return parent;
}
/** Reorders the given node so it's the first child of its parent.
/**
* Reorders the given node so it's the first child of its parent.
* This is called on the Mario object when he is spawned. That's why Mario's
* object is always drawn before any other objects. (Note that the geo order
* is independent from processing group order, where Mario is not first.)
@ -579,7 +605,8 @@ struct GraphNode *geo_make_first_child(struct GraphNode *newFirstChild) {
return parent;
}
/** Helper function for geo_call_global_function_nodes that recursively
/**
* Helper function for geo_call_global_function_nodes that recursively
* traverses the scene graph and calls the functions of global nodes.
*/
void geo_call_global_function_nodes_helper(struct GraphNode *graphNode, s32 callContext) {
@ -630,7 +657,8 @@ void geo_call_global_function_nodes_helper(struct GraphNode *graphNode, s32 call
} while ((curNode = curNode->next) != graphNode);
}
/** Call the update functions of geo nodes that are stored in global variables.
/**
* Call the update functions of geo nodes that are stored in global variables.
* These variables include gCurGraphNodeMasterList, gCurGraphNodeCamFrustum,
* gCurGraphNodeCamera and gCurGraphNodeObject.
* callContext is one of the GEO_CONTEXT_ defines.
@ -648,7 +676,8 @@ void geo_call_global_function_nodes(struct GraphNode *graphNode, s32 callContext
}
}
/** When objects are cleared, this is called on all object nodes (loaded or unloaded).
/**
* When objects are cleared, this is called on all object nodes (loaded or unloaded).
*/
void geo_reset_object_node(struct GraphNodeObject *graphNode) {
init_graph_node_object(NULL, graphNode, 0, gVec3fZero, gVec3sZero, gVec3fOne);
@ -657,7 +686,8 @@ void geo_reset_object_node(struct GraphNodeObject *graphNode) {
graphNode->node.flags &= ~GRAPH_RENDER_ACTIVE;
}
/** Initialize an object node using the given parameters
/**
* Initialize an object node using the given parameters
*/
void geo_obj_init(struct GraphNodeObject *graphNode, void *sharedChild, Vec3f pos, Vec3s angle) {
vec3f_set(graphNode->scale, 1.0f, 1.0f, 1.0f);
@ -675,7 +705,8 @@ void geo_obj_init(struct GraphNodeObject *graphNode, void *sharedChild, Vec3f po
graphNode->node.flags &= ~GRAPH_RENDER_BILLBOARD;
}
/** Initialize and object node using the given SpawnInfo struct
/**
* Initialize and object node using the given SpawnInfo struct
*/
void geo_obj_init_spawninfo(struct GraphNodeObject *graphNode, struct SpawnInfo *spawn) {
vec3f_set(graphNode->scale, 1.0f, 1.0f, 1.0f);
@ -698,7 +729,8 @@ void geo_obj_init_spawninfo(struct GraphNodeObject *graphNode, struct SpawnInfo
graphNode->node.flags &= ~GRAPH_RENDER_BILLBOARD;
}
/** Initialize the animation of an object node
/**
* Initialize the animation of an object node
*/
void geo_obj_init_animation(struct GraphNodeObject *graphNode, void *sp34) {
void **animSegmented = segmented_to_virtual(sp34);
@ -712,7 +744,8 @@ void geo_obj_init_animation(struct GraphNodeObject *graphNode, void *sp34) {
}
}
/** Initialize the animation of an object node
/**
* Initialize the animation of an object node
*/
void geo_obj_init_animation_accel(struct GraphNodeObject *graphNode, void *sp34, u32 animAccel) {
void **animSegmented = segmented_to_virtual(sp34);
@ -729,7 +762,8 @@ void geo_obj_init_animation_accel(struct GraphNodeObject *graphNode, void *sp34,
graphNode->unk38.animAccel = animAccel;
}
/** Retrieves an index into animation data based on the attribute pointer
/**
* Retrieves an index into animation data based on the attribute pointer
* An attribute is an x-, y- or z-component of the translation / rotation for a part
* Each attribute is a pair of s16's, where the first s16 represents the maximum frame
* and the second s16 the actual index. This index can be used to index in the array
@ -749,7 +783,8 @@ s32 retrieve_animation_index(s32 frame, u16 **attributes) {
return result;
}
/** Update the animation frame of an object. The animation flags determine
/**
* Update the animation frame of an object. The animation flags determine
* whether it plays forwards or backwards, and whether it stops or loops at
* the end etc.
*/
@ -804,7 +839,8 @@ s16 geo_update_animation_frame(struct GraphNodeObject_sub *obj, s32 *accelAssist
return GET_HIGH_S16_OF_32(result);
}
/** Unused function to retrieve an object's current animation translation
/**
* Unused function to retrieve an object's current animation translation
* Assumes that it has x, y and z data in animations, which isn't always the
* case since some animation types only have vertical or lateral translation.
* This might have been used for positioning the shadow under an object, which
@ -838,7 +874,8 @@ void geo_retreive_animation_translation(struct GraphNodeObject *obj, Vec3f posit
}
}
/** Unused function to find the root of the geo node tree, which should be a
/**
* Unused function to find the root of the geo node tree, which should be a
* GraphNodeRoot. If it is not for some reason, null is returned.
*/
struct GraphNodeRoot *geo_find_root(struct GraphNode *graphNode) {

View File

@ -9,7 +9,8 @@
#include "game/area.h"
#include "geo_layout.h"
/** Takes a pointer to three shorts (supplied by a geo layout script) and
/**
* Takes a pointer to three shorts (supplied by a geo layout script) and
* copies it to the destination float vector.
*/
s16 *read_vec3s_to_vec3f(Vec3f dst, s16 *src) {
@ -19,7 +20,8 @@ s16 *read_vec3s_to_vec3f(Vec3f dst, s16 *src) {
return src;
}
/** Takes a pointer to three shorts (supplied by a geo layout script) and
/**
* Takes a pointer to three shorts (supplied by a geo layout script) and
* copies it to the destination vector. It's essentially a memcpy but consistent
* with the other two 'geo-script vector to internal vector' functions.
*/
@ -30,7 +32,8 @@ s16 *read_vec3s(Vec3s dst, s16 *src) {
return src;
}
/** Takes a pointer to three angles in degrees (supplied by a geo layout script)
/**
* Takes a pointer to three angles in degrees (supplied by a geo layout script)
* and converts it to a vector of three in-game angle units in [-32768, 32767]
* range.
*/
@ -41,7 +44,8 @@ s16 *read_vec3s_angle(Vec3s dst, s16 *src) {
return src;
}
/** Add the given graph node as a child to the current top of the gfx stack:
/**
* Add the given graph node as a child to the current top of the gfx stack:
* 'gCurGraphNodeList'. This is called from geo_layout commands to add nodes
* to the scene graph.
*/

View File

@ -353,11 +353,12 @@ static void level_cmd_begin_area(void) {
screenArea->areaIndex = areaIndex;
gAreas[areaIndex].unk04 = (struct GraphNode *) screenArea;
if (node != NULL)
if (node != NULL) {
gAreas[areaIndex].camera = (struct LevelCamera *) node->config.levelCamera;
else
} else {
gAreas[areaIndex].camera = NULL;
}
}
sCurrentCmd = CMD_NEXT;
}
@ -372,9 +373,10 @@ static void level_cmd_21(void) {
s16 val2 = CMD_GET(u16, 2) >> 12;
void *val3 = CMD_GET(void *, 4);
if (val1 < 256)
if (val1 < 256) {
gLoadedGraphNodes[val1] =
(struct GraphNode *) init_graph_node_display_list(sLevelPool, 0, val2, val3);
}
sCurrentCmd = CMD_NEXT;
}
@ -383,8 +385,9 @@ static void level_cmd_22(void) {
s16 arg0 = CMD_GET(s16, 2);
void *arg1 = CMD_GET(void *, 4);
if (arg0 < 256)
if (arg0 < 256) {
gLoadedGraphNodes[arg0] = process_geo_layout(sLevelPool, arg1);
}
sCurrentCmd = CMD_NEXT;
}
@ -401,11 +404,12 @@ static void level_cmd_23(void) {
arg2.i = CMD_GET(s32, 8); // store the raw word as a union s32. this allows is to reinterpret the
// contents as a f32 without the value being converted implicitly.
if (model < 256)
if (model < 256) {
// GraphNodeScale has a GraphNode at the top. This
// is being stored to the array, so cast the pointer.
gLoadedGraphNodes[model] =
(struct GraphNode *) init_graph_node_scale(sLevelPool, 0, arg0H, arg1, arg2.f);
}
sCurrentCmd = CMD_NEXT;
}
@ -483,9 +487,10 @@ static void level_cmd_create_instant_warp(void) {
gAreas[sCurrAreaIndex].instantWarps =
alloc_only_pool_alloc(sLevelPool, 4 * sizeof(struct InstantWarp));
for (i = INSTANT_WARP_INDEX_START; i < INSTANT_WARP_INDEX_STOP; i++)
for (i = INSTANT_WARP_INDEX_START; i < INSTANT_WARP_INDEX_STOP; i++) {
gAreas[sCurrAreaIndex].instantWarps[i].id = 0;
}
}
warp = gAreas[sCurrAreaIndex].instantWarps + CMD_GET(u8, 2);
@ -501,8 +506,9 @@ static void level_cmd_create_instant_warp(void) {
}
static void level_cmd_set_terrain_type(void) {
if (sCurrAreaIndex != -1)
if (sCurrAreaIndex != -1) {
gAreas[sCurrAreaIndex].terrainType |= CMD_GET(s16, 2);
}
sCurrentCmd = CMD_NEXT;
}
@ -516,9 +522,10 @@ static void level_cmd_create_painting_warp_node(void) {
gAreas[sCurrAreaIndex].paintingWarpNodes =
alloc_only_pool_alloc(sLevelPool, 45 * sizeof(struct WarpNode));
for (i = 0; i < 45; i++)
for (i = 0; i < 45; i++) {
gAreas[sCurrAreaIndex].paintingWarpNodes[i].id = 0;
}
}
node = &gAreas[sCurrAreaIndex].paintingWarpNodes[CMD_GET(u8, 2)];
@ -535,9 +542,10 @@ static void level_cmd_3A(void) {
struct UnusedArea28 *val4;
if (sCurrAreaIndex != -1) {
if ((val4 = gAreas[sCurrAreaIndex].unused28) == NULL)
if ((val4 = gAreas[sCurrAreaIndex].unused28) == NULL) {
val4 = gAreas[sCurrAreaIndex].unused28 =
alloc_only_pool_alloc(sLevelPool, sizeof(struct UnusedArea28));
}
val4->unk00 = CMD_GET(s16, 2);
val4->unk02 = CMD_GET(s16, 4);
@ -582,20 +590,23 @@ static void level_cmd_set_gamma(void) {
}
static void level_cmd_set_terrain_data(void) {
if (sCurrAreaIndex != -1)
if (sCurrAreaIndex != -1) {
gAreas[sCurrAreaIndex].terrainData = segmented_to_virtual(CMD_GET(void *, 4));
}
sCurrentCmd = CMD_NEXT;
}
static void level_cmd_set_rooms(void) {
if (sCurrAreaIndex != -1)
if (sCurrAreaIndex != -1) {
gAreas[sCurrAreaIndex].surfaceRooms = segmented_to_virtual(CMD_GET(void *, 4));
}
sCurrentCmd = CMD_NEXT;
}
static void level_cmd_39(void) {
if (sCurrAreaIndex != -1)
if (sCurrAreaIndex != -1) {
gAreas[sCurrAreaIndex].macroObjects = segmented_to_virtual(CMD_GET(void *, 4));
}
sCurrentCmd = CMD_NEXT;
}
@ -634,8 +645,9 @@ static void level_cmd_2D(void) {
}
static void level_cmd_set_transition(void) {
if (gCurrentArea != NULL)
if (gCurrentArea != NULL) {
play_transition(CMD_GET(u8, 2), CMD_GET(u8, 3), CMD_GET(u8, 4), CMD_GET(u8, 5), CMD_GET(u8, 6));
}
sCurrentCmd = CMD_NEXT;
}
@ -645,9 +657,10 @@ static void level_cmd_nop(void) {
static void level_cmd_30(void) {
if (sCurrAreaIndex != -1) {
if (CMD_GET(u8, 2) < 2)
if (CMD_GET(u8, 2) < 2) {
gAreas[sCurrAreaIndex].dialog[CMD_GET(u8, 2)] = CMD_GET(u8, 3);
}
}
sCurrentCmd = CMD_NEXT;
}
@ -779,8 +792,9 @@ struct LevelCommand *level_script_execute(struct LevelCommand *cmd) {
sScriptStatus = SCRIPT_RUNNING;
sCurrentCmd = cmd;
while (sScriptStatus == SCRIPT_RUNNING)
while (sScriptStatus == SCRIPT_RUNNING) {
LevelScriptJumpTable[sCurrentCmd->type]();
}
profiler_log_thread5_time(LEVEL_SCRIPT_EXECUTE);
init_render_image();

View File

@ -97,7 +97,8 @@ void *vec3s_to_vec3f(Vec3f dest, Vec3s a) {
return &dest; //! warning: function returns address of local variable
}
/** Convert float vector a to a short vector 'dest' by rounding the components
/**
* Convert float vector a to a short vector 'dest' by rounding the components
* to the nearest integer.
*/
void *vec3f_to_vec3s(Vec3s dest, Vec3f a) {
@ -108,7 +109,8 @@ void *vec3f_to_vec3s(Vec3s dest, Vec3f a) {
return &dest; //! warning: function returns address of local variable
}
/** Set 'dest' the normal vector of a triangle with vertices a, b and c.
/**
* Set 'dest' the normal vector of a triangle with vertices a, b and c.
* It is similar to vec3f_cross, but it calculates the vectors (c-b) and (b-a)
* at the same time.
*/
@ -146,11 +148,13 @@ void mtxf_copy(Mat4 dest, Mat4 src) {
register u32 *d = (u32 *) dest;
register u32 *s = (u32 *) src;
for (i = 0; i < 16; i++)
for (i = 0; i < 16; i++) {
*d++ = *s++;
}
}
/** Set mtx to the identity matrix
/**
* Set mtx to the identity matrix
*/
void mtxf_identity(Mat4 mtx) {
register s32 i;
@ -158,15 +162,18 @@ void mtxf_identity(Mat4 mtx) {
// initialize everything except the first and last cells to 0
// (this need to be on one line to match on PAL)
for (dest = (f32 *) mtx + 1, i = 0; i < 14; dest++, i++)
for (dest = (f32 *) mtx + 1, i = 0; i < 14; dest++, i++) {
*dest = 0;
// initialize the diagonal cells to 1
for (dest = (f32 *) mtx, i = 0; i < 4; dest += 5, i++)
*dest = 1;
}
/** Set dest to a translation matrix of vector b
// initialize the diagonal cells to 1
for (dest = (f32 *) mtx, i = 0; i < 4; dest += 5, i++) {
*dest = 1;
}
}
/**
* Set dest to a translation matrix of vector b
*/
void mtxf_translate(Mat4 dest, Vec3f b) {
mtxf_identity(dest);
@ -175,7 +182,8 @@ void mtxf_translate(Mat4 dest, Vec3f b) {
dest[3][2] = b[2];
}
/** Set mtx to a look-at matrix for the camera. The resulting transformation
/**
* Set mtx to a look-at matrix for the camera. The resulting transformation
* transforms the world as if there exists a camera at position 'from' pointed
* at the position 'to'. The up-vector is assumed to be (0, 1, 0), but the 'roll'
* angle allows a bank rotation of the camera.
@ -322,7 +330,8 @@ void mtxf_rotate_xyz_and_translate(Mat4 dest, Vec3f b, Vec3s c) {
dest[3][3] = 1;
}
/** Set 'dest' to a transformation matrix that turns an object to face the camera.
/**
* Set 'dest' to a transformation matrix that turns an object to face the camera.
* 'mtx' is the look-at matrix from the camera
* 'position' is the position of the object in the world
* 'angle' rotates the object while still facing the camera.
@ -352,7 +361,8 @@ void mtxf_billboard(Mat4 dest, Mat4 mtx, Vec3f position, s16 angle) {
dest[3][3] = 1;
}
/** Set 'dest' to a transformation matrix that aligns an object with the terrain
/**
* Set 'dest' to a transformation matrix that aligns an object with the terrain
* based on the normal. Used for enemies.
* 'upDir' is the terrain normal
* 'yaw' is the angle which it should face
@ -393,7 +403,8 @@ void mtxf_align_terrain_normal(Mat4 dest, Vec3f upDir, Vec3f pos, s16 yaw) {
dest[3][3] = 1.0f;
}
/** Set 'mtx' to a transformation matrix that aligns an object with the terrain
/**
* Set 'mtx' to a transformation matrix that aligns an object with the terrain
* based on 3 height samples in an equilateral triangle around the object.
* Used for Mario when crawling or sliding.
* 'yaw' is the angle which it should face
@ -423,14 +434,17 @@ void mtxf_align_terrain_triangle(Mat4 mtx, Vec3f pos, s16 yaw, f32 radius) {
point1[1] = find_floor(point1[0], pos[1] + 150, point1[2], &sp74);
point2[1] = find_floor(point2[0], pos[1] + 150, point2[2], &sp74);
if (point0[1] - pos[1] < minY)
if (point0[1] - pos[1] < minY) {
point0[1] = pos[1];
}
if (point1[1] - pos[1] < minY)
if (point1[1] - pos[1] < minY) {
point1[1] = pos[1];
}
if (point2[1] - pos[1] < minY)
if (point2[1] - pos[1] < minY) {
point2[1] = pos[1];
}
avgY = (point0[1] + point1[1] + point2[1]) / 3;
@ -463,7 +477,8 @@ void mtxf_align_terrain_triangle(Mat4 mtx, Vec3f pos, s16 yaw, f32 radius) {
mtx[3][3] = 1;
}
/** Sets matrix 'dest' to the matrix product b * a assuming they are both
/**
* Sets matrix 'dest' to the matrix product b * a assuming they are both
* transformation matrices with a w-component of 1. Since the bottom row
* is assumed to equal [0, 0, 0, 1], it saves some multiplications and
* addition.
@ -514,7 +529,8 @@ void mtxf_mul(Mat4 dest, Mat4 a, Mat4 b) {
mtxf_copy(dest, temp);
}
/** Set matrix 'dest' to 'mtx' scaled by vector s
/**
* Set matrix 'dest' to 'mtx' scaled by vector s
*/
void mtxf_scale_vec3f(Mat4 dest, Mat4 mtx, Vec3f s) {
register s32 i;
@ -527,7 +543,8 @@ void mtxf_scale_vec3f(Mat4 dest, Mat4 mtx, Vec3f s) {
}
}
/** Multiply a vector with a transformation matrix, which applies the transformation
/**
* Multiply a vector with a transformation matrix, which applies the transformation
* to the point. Note that the bottom row is assumed to be [0, 0, 0, 1], which is
* true for transformation matrices if the translation has a w component of 1.
*/
@ -541,7 +558,8 @@ void mtxf_mul_vec3s(Mat4 mtx, Vec3s b) {
b[2] = x * mtx[0][2] + y * mtx[1][2] + z * mtx[2][2] + mtx[3][2];
}
/** Convert float matrix 'src' to fixed point matrix 'dest'.
/**
* Convert float matrix 'src' to fixed point matrix 'dest'.
* The float matrix may not contain entries larger than 65536 or the console
* crashes. The fixed point matrix has entries with a 16-bit integer part, so
* the floating point numbers are multipled by 2^16 before being cast to a s32
@ -563,7 +581,8 @@ void mtxf_to_mtx(Mtx *dest, Mat4 src) {
}
}
/** Set 'mtx' to a transformation matrix that rotates around the z axis.
/**
* Set 'mtx' to a transformation matrix that rotates around the z axis.
*/
void mtxf_rotate_xy(Mtx *mtx, s16 angle) {
Mat4 temp;
@ -576,7 +595,8 @@ void mtxf_rotate_xy(Mtx *mtx, s16 angle) {
mtxf_to_mtx(mtx, temp);
}
/** Extract a position given an object's transformation matrix and a camera matrix.
/**
* Extract a position given an object's transformation matrix and a camera matrix.
* This is used for determining the world position of the held object: since objMtx
* inherits the transformation from both the camera and Mario, it calculates this
* by taking the camera matrix and inverting its transformation by first rotating
@ -596,7 +616,8 @@ void get_pos_from_transform_mtx(Vec3f dest, Mat4 objMtx, Mat4 camMtx) {
objMtx[3][0] * camMtx[2][0] + objMtx[3][1] * camMtx[2][1] + objMtx[3][2] * camMtx[2][2] - camZ;
}
/** Take the vector starting at 'from' pointed at 'to' an retrieve the length
/**
* Take the vector starting at 'from' pointed at 'to' an retrieve the length
* of that vector, as well as the yaw and pitch angles.
*/
void vec3f_get_dist_and_angle(Vec3f from, Vec3f to, f32 *dist, s16 *pitch, s16 *yaw) {
@ -609,7 +630,8 @@ void vec3f_get_dist_and_angle(Vec3f from, Vec3f to, f32 *dist, s16 *pitch, s16 *
*yaw = atan2s(z, x);
}
/** Construct the 'to' point which is distance 'dist' away from the 'from' position,
/**
* Construct the 'to' point which is distance 'dist' away from the 'from' position,
* and has the angles pitch and yaw.
*/
void vec3f_set_dist_and_angle(Vec3f from, Vec3f to, f32 dist, s16 pitch, s16 yaw) {
@ -618,7 +640,8 @@ void vec3f_set_dist_and_angle(Vec3f from, Vec3f to, f32 dist, s16 pitch, s16 yaw
to[2] = from[2] + dist * coss(pitch) * coss(yaw);
}
/** Return the value 'current' after it tries to approach target, going up at
/**
* Return the value 'current' after it tries to approach target, going up at
* most 'inc' and going down at most 'dec'.
*/
s32 approach_s32(s32 current, s32 target, s32 inc, s32 dec) {
@ -627,46 +650,54 @@ s32 approach_s32(s32 current, s32 target, s32 inc, s32 dec) {
if (current < target) {
current += inc;
if (current > target)
if (current > target) {
current = target;
}
} else {
current -= dec;
if (current < target)
if (current < target) {
current = target;
}
}
return current;
}
/** Return the value 'current' after it tries to approach target, going up at
/**
* Return the value 'current' after it tries to approach target, going up at
* most 'inc' and going down at most 'dec'.
*/
f32 approach_f32(f32 current, f32 target, f32 inc, f32 dec) {
if (current < target) {
current += inc;
if (current > target)
if (current > target) {
current = target;
}
} else {
current -= dec;
if (current < target)
if (current < target) {
current = target;
}
}
return current;
}
/** Helper function for atan2s. Does a look up of the arctangent of y/x assuming
/**
* Helper function for atan2s. Does a look up of the arctangent of y/x assuming
* the resulting angle is in range [0, 0x2000] (1/8 of a circle).
*/
static u16 atan2_lookup(f32 y, f32 x) {
u16 ret;
if (x == 0)
if (x == 0) {
ret = gArctanTable[0];
else
} else {
ret = gArctanTable[(s32)(y / x * 1024 + 0.5f)];
}
return ret;
}
/** Compute the angle from (0, 0) to (x, y) as a s16. Given that terrain is in
/**
* Compute the angle from (0, 0) to (x, y) as a s16. Given that terrain is in
* the xz-plane, this is commonly called with (z, x) to get a yaw angle.
*/
s16 atan2s(f32 y, f32 x) {
@ -674,36 +705,41 @@ s16 atan2s(f32 y, f32 x) {
if (x >= 0) {
if (y >= 0) {
if (y >= x)
if (y >= x) {
ret = atan2_lookup(x, y);
else
} else {
ret = 0x4000 - atan2_lookup(y, x);
}
} else {
y = -y;
if (y < x)
if (y < x) {
ret = 0x4000 + atan2_lookup(y, x);
else
} else {
ret = 0x8000 - atan2_lookup(x, y);
}
}
} else {
x = -x;
if (y < 0) {
y = -y;
if (y >= x)
if (y >= x) {
ret = 0x8000 + atan2_lookup(x, y);
else
ret = 0xC000 - atan2_lookup(y, x);
} else {
if (y < x)
ret = 0xC000 - atan2_lookup(y, x);
}
} else {
if (y < x) {
ret = 0xC000 + atan2_lookup(y, x);
else
} else {
ret = -atan2_lookup(x, y);
}
}
}
return ret;
}
/** Compute the atan2 in radians by calling atan2s and converting the result.
/**
* Compute the atan2 in radians by calling atan2s and converting the result.
*/
f32 atan2f(f32 y, f32 x) {
return (f32) atan2s(y, x) * M_PI / 0x8000;
@ -715,7 +751,8 @@ f32 atan2f(f32 y, f32 x) {
#define CURVE_END_1 4
#define CURVE_END_2 5
/** Set 'result' to a 4-vector with weights corresponding to interpolation
/**
* Set 'result' to a 4-vector with weights corresponding to interpolation
* value t in [0, 1] and gSplineState. Given the current control point P, these
* weights are for P[0], P[1], P[2] and P[3] to obtain an interpolated point.
* The weights naturally sum to 1, and they are also always in range [0, 1] so
@ -779,7 +816,8 @@ void spline_get_weights(Vec4f result, f32 t, UNUSED s32 c) {
}
}
/** Initialize a spline animation.
/**
* Initialize a spline animation.
* 'keyframes' should be an array of (s, x, y, z) vectors
* s: the speed of the keyframe in 1000/frames, e.g. s=100 means the keyframe lasts 10 frames
* (x, y, z): point in 3D space on the curve
@ -792,7 +830,8 @@ void anim_spline_init(Vec4s *keyFrames) {
gSplineState = 1;
}
/** Poll the next point from a spline animation.
/**
* Poll the next point from a spline animation.
* anim_spline_init should be called before polling for vectors.
* Returns TRUE when the last point is reached, FALSE otherwise.
*/
@ -817,8 +856,9 @@ s32 anim_spline_poll(Vec3f result) {
hasEnded = TRUE;
break;
case CURVE_MIDDLE:
if (gSplineKeyframe[2][0] == 0)
if (gSplineKeyframe[2][0] == 0) {
gSplineState = CURVE_END_1;
}
break;
default:
gSplineState++;

View File

@ -33,8 +33,9 @@ static s32 find_wall_collisions_from_list(struct SurfaceNode *surfaceNode,
s32 numCols = 0;
// Max collision radius = 200
if (radius > 200.0f)
if (radius > 200.0f) {
radius = 200.0f;
}
// Stay in this loop until out of walls.
while (surfaceNode != NULL) {
@ -67,20 +68,26 @@ static s32 find_wall_collisions_from_list(struct SurfaceNode *surfaceNode,
y3 = surf->vertex3[1];
if (surf->normal.x > 0.0f) {
if ((y1 - y) * (w2 - w1) - (w1 - -pz) * (y2 - y1) > 0.0f)
if ((y1 - y) * (w2 - w1) - (w1 - -pz) * (y2 - y1) > 0.0f) {
continue;
if ((y2 - y) * (w3 - w2) - (w2 - -pz) * (y3 - y2) > 0.0f)
}
if ((y2 - y) * (w3 - w2) - (w2 - -pz) * (y3 - y2) > 0.0f) {
continue;
if ((y3 - y) * (w1 - w3) - (w3 - -pz) * (y1 - y3) > 0.0f)
}
if ((y3 - y) * (w1 - w3) - (w3 - -pz) * (y1 - y3) > 0.0f) {
continue;
}
} else {
if ((y1 - y) * (w2 - w1) - (w1 - -pz) * (y2 - y1) < 0.0f)
if ((y1 - y) * (w2 - w1) - (w1 - -pz) * (y2 - y1) < 0.0f) {
continue;
if ((y2 - y) * (w3 - w2) - (w2 - -pz) * (y3 - y2) < 0.0f)
}
if ((y2 - y) * (w3 - w2) - (w2 - -pz) * (y3 - y2) < 0.0f) {
continue;
if ((y3 - y) * (w1 - w3) - (w3 - -pz) * (y1 - y3) < 0.0f)
}
if ((y3 - y) * (w1 - w3) - (w3 - -pz) * (y1 - y3) < 0.0f) {
continue;
}
}
} else {
w1 = surf->vertex1[0];
w2 = surf->vertex2[0];
@ -90,30 +97,38 @@ static s32 find_wall_collisions_from_list(struct SurfaceNode *surfaceNode,
y3 = surf->vertex3[1];
if (surf->normal.z > 0.0f) {
if ((y1 - y) * (w2 - w1) - (w1 - px) * (y2 - y1) > 0.0f)
if ((y1 - y) * (w2 - w1) - (w1 - px) * (y2 - y1) > 0.0f) {
continue;
if ((y2 - y) * (w3 - w2) - (w2 - px) * (y3 - y2) > 0.0f)
}
if ((y2 - y) * (w3 - w2) - (w2 - px) * (y3 - y2) > 0.0f) {
continue;
if ((y3 - y) * (w1 - w3) - (w3 - px) * (y1 - y3) > 0.0f)
}
if ((y3 - y) * (w1 - w3) - (w3 - px) * (y1 - y3) > 0.0f) {
continue;
}
} else {
if ((y1 - y) * (w2 - w1) - (w1 - px) * (y2 - y1) < 0.0f)
if ((y1 - y) * (w2 - w1) - (w1 - px) * (y2 - y1) < 0.0f) {
continue;
if ((y2 - y) * (w3 - w2) - (w2 - px) * (y3 - y2) < 0.0f)
}
if ((y2 - y) * (w3 - w2) - (w2 - px) * (y3 - y2) < 0.0f) {
continue;
if ((y3 - y) * (w1 - w3) - (w3 - px) * (y1 - y3) < 0.0f)
}
if ((y3 - y) * (w1 - w3) - (w3 - px) * (y1 - y3) < 0.0f) {
continue;
}
}
}
// Determine if checking for the camera or not.
if (gCheckingSurfaceCollisionsForCamera) {
if (surf->flags & SURFACE_FLAG_NO_CAM_COLLISION)
if (surf->flags & SURFACE_FLAG_NO_CAM_COLLISION) {
continue;
}
} else {
// Ignore camera only surfaces.
if (surf->type == SURFACE_CAMERA_BOUNDARY)
if (surf->type == SURFACE_CAMERA_BOUNDARY) {
continue;
}
// If an object can pass through a vanish cap wall, pass through.
if (surf->type == SURFACE_VANISH_CAP_WALLS) {
@ -186,10 +201,12 @@ s32 find_wall_collisions(struct WallCollisionData *colData) {
colData->numWalls = 0;
if (x <= -LEVEL_BOUNDARY_MAX || x >= LEVEL_BOUNDARY_MAX)
if (x <= -LEVEL_BOUNDARY_MAX || x >= LEVEL_BOUNDARY_MAX) {
return numCollisions;
if (z <= -LEVEL_BOUNDARY_MAX || z >= LEVEL_BOUNDARY_MAX)
}
if (z <= -LEVEL_BOUNDARY_MAX || z >= LEVEL_BOUNDARY_MAX) {
return numCollisions;
}
// World (level) consists of a 16x16 grid. Find where the collision is on
// the grid (round toward -inf)
@ -236,22 +253,26 @@ static struct Surface *find_ceil_from_list(struct SurfaceNode *surfaceNode, s32
x2 = surf->vertex2[0];
// Checking if point is in bounds of the triangle laterally.
if ((z1 - z) * (x2 - x1) - (x1 - x) * (z2 - z1) > 0)
if ((z1 - z) * (x2 - x1) - (x1 - x) * (z2 - z1) > 0) {
continue;
}
// Slight optimization by checking these later.
x3 = surf->vertex3[0];
z3 = surf->vertex3[2];
if ((z2 - z) * (x3 - x2) - (x2 - x) * (z3 - z2) > 0)
if ((z2 - z) * (x3 - x2) - (x2 - x) * (z3 - z2) > 0) {
continue;
if ((z3 - z) * (x1 - x3) - (x3 - x) * (z1 - z3) > 0)
}
if ((z3 - z) * (x1 - x3) - (x3 - x) * (z1 - z3) > 0) {
continue;
}
// Determine if checking for the camera or not.
if (gCheckingSurfaceCollisionsForCamera != 0) {
if (surf->flags & SURFACE_FLAG_NO_CAM_COLLISION)
if (surf->flags & SURFACE_FLAG_NO_CAM_COLLISION) {
continue;
}
}
// Ignore camera only surfaces.
else if (surf->type == SURFACE_CAMERA_BOUNDARY) {
continue;
@ -265,8 +286,9 @@ static struct Surface *find_ceil_from_list(struct SurfaceNode *surfaceNode, s32
f32 height;
// If a wall, ignore it. Likely a remnant, should never occur.
if (ny == 0.0f)
if (ny == 0.0f) {
continue;
}
// Find the ceil height at the specific point.
height = -(x * nx + nz * z + oo) / ny;
@ -275,8 +297,9 @@ static struct Surface *find_ceil_from_list(struct SurfaceNode *surfaceNode, s32
//! (Exposed Ceilings) Because any point above a ceiling counts
// as interacting with a ceiling, ceilings far below can cause
// "invisible walls" that are really just exposed ceilings.
if (y - (height - -78.0f) > 0.0f)
if (y - (height - -78.0f) > 0.0f) {
continue;
}
*pheight = height;
ceil = surf;
@ -405,23 +428,27 @@ static struct Surface *find_floor_from_list(struct SurfaceNode *surfaceNode, s32
z2 = surf->vertex2[2];
// Check that the point is within the triangle bounds.
if ((z1 - z) * (x2 - x1) - (x1 - x) * (z2 - z1) < 0)
if ((z1 - z) * (x2 - x1) - (x1 - x) * (z2 - z1) < 0) {
continue;
}
// To slightly save on computation time, set this later.
x3 = surf->vertex3[0];
z3 = surf->vertex3[2];
if ((z2 - z) * (x3 - x2) - (x2 - x) * (z3 - z2) < 0)
if ((z2 - z) * (x3 - x2) - (x2 - x) * (z3 - z2) < 0) {
continue;
if ((z3 - z) * (x1 - x3) - (x3 - x) * (z1 - z3) < 0)
}
if ((z3 - z) * (x1 - x3) - (x3 - x) * (z1 - z3) < 0) {
continue;
}
// Determine if we are checking for the camera or not.
if (gCheckingSurfaceCollisionsForCamera != 0) {
if (surf->flags & SURFACE_FLAG_NO_CAM_COLLISION)
if (surf->flags & SURFACE_FLAG_NO_CAM_COLLISION) {
continue;
}
}
// If we are not checking for the camera, ignore camera only floors.
else if (surf->type == SURFACE_CAMERA_BOUNDARY) {
continue;
@ -440,8 +467,9 @@ static struct Surface *find_floor_from_list(struct SurfaceNode *surfaceNode, s32
// Find the height of the floor at a given location.
height = -(x * nx + nz * z + oo) / ny;
// Checks for floor interaction with a 78 unit buffer.
if (y - (height + -78.0f) < 0.0f)
if (y - (height + -78.0f) < 0.0f) {
continue;
}
*pheight = height;
floor = surf;

View File

@ -325,16 +325,20 @@ static struct Surface *read_surface_data(s16 *vertexData, s16 **vertexIndices) {
// Could have used min_3 and max_3 for this...
minY = y1;
if (y2 < minY)
if (y2 < minY) {
minY = y2;
if (y3 < minY)
}
if (y3 < minY) {
minY = y3;
}
maxY = y1;
if (y2 > maxY)
if (y2 > maxY) {
maxY = y2;
if (y3 > maxY)
}
if (y3 > maxY) {
maxY = y3;
}
// Checking to make sure no DIV/0
if (mag < 0.0001) {

View File

@ -120,9 +120,10 @@ u32 get_mario_spawn_type(struct Object *o) {
void *behavior = virtual_to_segmented(0x13, o->behavior);
for (i = 0; i < 20; i++) {
if (D_8032CE9C[i] == behavior)
if (D_8032CE9C[i] == behavior) {
return D_8032CEEC[i];
}
}
return 0;
}
@ -130,9 +131,10 @@ struct ObjectWarpNode *area_get_warp_node(u8 id) {
struct ObjectWarpNode *node = NULL;
for (node = gCurrentArea->warpNodes; node != NULL; node = node->next) {
if (node->node.id == id)
if (node->node.id == id) {
break;
}
}
return node;
}
@ -151,9 +153,10 @@ void func_8027A4C4(void) {
if (sp1C->activeFlags && get_mario_spawn_type(sp1C) != 0) {
sp24 = func_8027A478(sp1C);
if (sp24 != NULL)
if (sp24 != NULL) {
sp24->object = sp1C;
}
}
} while ((sp20 = (struct Object *) sp20->header.gfx.node.next)
!= (struct Object *) gObjParentGraphNode.children);
}
@ -216,8 +219,9 @@ void load_area(s32 index) {
gCurrentArea->macroObjects);
}
if (gCurrentArea->objectSpawnInfos != NULL)
if (gCurrentArea->objectSpawnInfos != NULL) {
spawn_objects_from_info(0, gCurrentArea->objectSpawnInfos);
}
func_8027A4C4();
geo_call_global_function_nodes(gCurrentArea->unk04, GEO_CONTEXT_AREA_LOAD);
@ -250,10 +254,11 @@ void func_8027AA88(void) {
unload_objects_from_area(0, gMarioSpawnInfo->activeAreaIndex);
gCurrentArea->flags &= ~0x01;
if (gCurrentArea->flags == 0)
if (gCurrentArea->flags == 0) {
func_8027A998();
}
}
}
void change_area(s32 index) {
s32 areaFlags = gCurrentArea->flags;
@ -316,16 +321,18 @@ void play_transition(s16 transType, s16 time, u8 red, u8 green, u8 blue) {
if (transType & 1) // Is the image fading in?
{
gWarpTransition.data.startCircleRadius = 320;
if (transType >= 0x0F)
if (transType >= 0x0F) {
gWarpTransition.data.endCircleRadius = 16;
else
} else {
gWarpTransition.data.endCircleRadius = 0;
}
} else // The image is fading out. (Reverses start & end circles)
{
if (transType >= 0x0E)
if (transType >= 0x0E) {
gWarpTransition.data.startCircleRadius = 16;
else
} else {
gWarpTransition.data.startCircleRadius = 0;
}
gWarpTransition.data.endCircleRadius = 320;
}
}
@ -359,12 +366,13 @@ void render_game(void) {
240 - BORDER_HEIGHT);
D_8033A75E = func_802DCD98();
if (D_8033A75E != 0)
if (D_8033A75E != 0) {
D_8033A760 = D_8033A75E;
}
if (D_8032CE78 != NULL)
if (D_8032CE78 != NULL) {
make_viewport_clip_rect(D_8032CE78);
else
} else
gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, 0, BORDER_HEIGHT, 320,
240 - BORDER_HEIGHT);
@ -373,22 +381,24 @@ void render_game(void) {
gWarpTransition.isActive = !func_802CC108(0, gWarpTransition.type, gWarpTransition.time,
&gWarpTransition.data);
if (!gWarpTransition.isActive) {
if (gWarpTransition.type & 1)
if (gWarpTransition.type & 1) {
gWarpTransition.pauseRendering = TRUE;
else
} else {
set_warp_transition_rgb(0, 0, 0);
}
}
} else {
gWarpTransDelay--;
}
}
} else {
render_text_labels();
if (D_8032CE78 != 0)
if (D_8032CE78 != 0) {
clear_viewport(D_8032CE78, gWarpTransFBSetColor);
else
} else {
clear_frame_buffer(gWarpTransFBSetColor);
}
}
D_8032CE74 = NULL;
D_8032CE78 = 0;

View File

@ -144,12 +144,13 @@ void func_802AA618(s32 sp18, s32 sp1C, f32 sp20) {
D_8032F270.sizeBase = sp20;
D_8032F270.sizeRange = sp20 / 20.0;
D_8032F270.offsetY = sp1C;
if (sp18 == 0)
if (sp18 == 0) {
D_8032F270.count = 20;
else if (sp18 > 20)
} else if (sp18 > 20) {
D_8032F270.count = sp18;
else
} else {
D_8032F270.count = 4;
}
obj_spawn_particles(&D_8032F270);
}
@ -166,7 +167,7 @@ void func_802AA618(s32 sp18, s32 sp1C, f32 sp20) {
#include "behaviors/ground_particles.inc.c"
#include "behaviors/wind.inc.c"
#include "behaviors/unused_particle_spawn.inc.c"
#include "behaviors/little_cage.inc.c"
#include "behaviors/ukiki_cage.inc.c"
#include "behaviors/falling_rising_platform.inc.c"
#include "behaviors/fishing_boo.inc.c"
#include "behaviors/flamethrower.inc.c"
@ -214,9 +215,10 @@ void func_802B2328(
{
s32 i;
s16 separation = 0x10000 / n; // Evenly spread around a circle
for (i = 0; i < n; i++)
for (i = 0; i < n; i++) {
spawn_object_relative(0, sins(D_8035FF10 + i * separation) * a1, (i + 1) * a2,
coss(D_8035FF10 + i * separation) * a1, o, MODEL_NONE, bhvSparkleSpawn);
}
D_8035FF10 += r * 0x100;
}
@ -234,7 +236,7 @@ void func_802B2328(
#include "behaviors/bowser_key_cutscene.inc.c"
#include "behaviors/moat_grill.inc.c"
#include "behaviors/clock_arm.inc.c"
#include "behaviors/ukiki_cage.inc.c"
#include "behaviors/ukiki.inc.c"
#include "behaviors/lll_octagonal_rotating_mesh.inc.c"
#include "behaviors/lll_sinking_rock_block.inc.c"
#include "behaviors/lll_rotating_hex_flame.inc.c"
@ -271,16 +273,7 @@ void func_802B2328(
#include "behaviors/music_touch.inc.c"
#endif
#include "behaviors/castle_floor_trap.inc.c"
// not in behavior file
void BehClimbDetectLoop(void) {
if (o->oPosY - 10.0f < gMarioObject->oPosY
&& gMarioObject->oPosY < o->oPosY + o->hitboxHeight + 30.0f)
if (o->oTimer > 10)
if (!(gMarioStates->action & MARIO_PUNCHING))
obj_push_mario_away(70.0f);
}
#include "behaviors/pole_base.inc.c"
#include "behaviors/sparkle_spawn.inc.c"
#include "behaviors/scuttlebug.inc.c" // :scuttleeyes:
#include "behaviors/whomp.inc.c"

View File

@ -0,0 +1,77 @@
// animated_floor_switch.inc.c
struct Struct80331A54 {
void *unk00;
s16 unk04;
};
struct Struct80331A54 D_80331A54[][5] = {
{
{ bits_seg7_collision_0701B734, MODEL_BITS_STAIRCASE_FRAME4 },
{ bits_seg7_collision_0701B59C, MODEL_BITS_STAIRCASE_FRAME3 },
{ bits_seg7_collision_0701B404, MODEL_BITS_STAIRCASE_FRAME2 },
{ bits_seg7_collision_0701B26C, MODEL_BITS_STAIRCASE_FRAME1 },
{ bits_seg7_collision_0701B0D4, MODEL_BITS_STAIRCASE },
},
{
{ bitdw_seg7_collision_0700FD9C, MODEL_BITDW_STAIRCASE },
{ bitdw_seg7_collision_0700FC7C, MODEL_BITDW_STAIRCASE_FRAME1 },
{ bitdw_seg7_collision_0700FB5C, MODEL_BITDW_STAIRCASE_FRAME2 },
{ bitdw_seg7_collision_0700FA3C, MODEL_BITDW_STAIRCASE_FRAME3 },
{ bitdw_seg7_collision_0700F91C, MODEL_BITDW_STAIRCASE_FRAME4 },
},
{
{ rr_seg7_collision_0702A6B4, MODEL_RR_TRICKY_TRIANGLES_FRAME4 },
{ rr_seg7_collision_0702A32C, MODEL_RR_TRICKY_TRIANGLES_FRAME3 },
{ rr_seg7_collision_07029FA4, MODEL_RR_TRICKY_TRIANGLES_FRAME2 },
{ rr_seg7_collision_07029C1C, MODEL_RR_TRICKY_TRIANGLES_FRAME1 },
{ rr_seg7_collision_07029924, MODEL_RR_TRICKY_TRIANGLES },
},
};
s16 D_80331ACC[] = { 250, 200, 200 };
void bhv_animates_on_floor_switch_press_init(void) {
o->parentObj = obj_nearest_object_with_behavior(bhvFloorSwitchAnimatesObject);
}
void bhv_animates_on_floor_switch_press_loop(void) {
if (o->oFloorSwitchPressAnimationUnk100 != 0) {
if (o->parentObj->oAction != 2) {
o->oFloorSwitchPressAnimationUnk100 = 0;
}
if (o->oFloorSwitchPressAnimationUnkFC != 0) {
o->oFloorSwitchPressAnimationUnkF4 = D_80331ACC[o->oBehParams2ndByte];
} else {
o->oFloorSwitchPressAnimationUnkF4 = 0;
}
} else if (o->parentObj->oAction == 2) {
o->oFloorSwitchPressAnimationUnkFC ^= 1;
o->oFloorSwitchPressAnimationUnk100 = 1;
}
if (o->oFloorSwitchPressAnimationUnkF4 != 0) {
if (o->oFloorSwitchPressAnimationUnkF4 < 60) {
PlaySound(SOUND_CH8_SWITCH6);
} else {
PlaySound(SOUND_CH8_SWITCH5);
}
if (--o->oFloorSwitchPressAnimationUnkF4 == 0) {
o->oFloorSwitchPressAnimationUnkFC = 0;
}
if (o->oFloorSwitchPressAnimationUnkF8 < 9) {
o->oFloorSwitchPressAnimationUnkF8 += 1;
}
} else if ((o->oFloorSwitchPressAnimationUnkF8 -= 2) < 0) {
o->oFloorSwitchPressAnimationUnkF8 = 0;
o->oFloorSwitchPressAnimationUnkFC = 1;
}
o->collisionData = segmented_to_virtual(
D_80331A54[o->oBehParams2ndByte][o->oFloorSwitchPressAnimationUnkF8 / 2].unk00);
obj_set_model(D_80331A54[o->oBehParams2ndByte][o->oFloorSwitchPressAnimationUnkF8 / 2].unk04);
}

View File

@ -17,16 +17,15 @@ static s32 arrow_lift_move_away(void) {
o->oMoveAngleYaw = o->oFaceAngleYaw - 0x4000;
o->oVelY = 0;
o->oForwardVel = 12.0f;
o->oForwardVel = 12;
// Cumulative displacement is used to keep track of how far the platform
// has travelled, so that it can stop.
o->oArrowLiftDisplacement += o->oForwardVel;
// Stop the platform after moving 384 units.
if (o->oArrowLiftDisplacement > 384.0f) {
o->oForwardVel = 0.0f;
o->oArrowLiftDisplacement = 384.0f;
if (o->oArrowLiftDisplacement > 384) {
o->oForwardVel = 0;
o->oArrowLiftDisplacement = 384;
status = ARROW_LIFT_DONE_MOVING;
}
@ -42,14 +41,13 @@ static s8 arrow_lift_move_back(void) {
o->oMoveAngleYaw = o->oFaceAngleYaw + 0x4000;
o->oVelY = 0;
o->oForwardVel = 12.0f;
o->oForwardVel = 12;
o->oArrowLiftDisplacement -= o->oForwardVel;
// Stop the platform after returning back to its original position.
if (o->oArrowLiftDisplacement < 0.0f) {
o->oForwardVel = 0.0f;
o->oArrowLiftDisplacement = 0.0f;
if (o->oArrowLiftDisplacement < 0) {
o->oForwardVel = 0;
o->oArrowLiftDisplacement = 0;
status = ARROW_LIFT_DONE_MOVING;
}

View File

@ -16,7 +16,7 @@ void bhv_bobomb_init(void) {
o->oGravity = 2.5;
o->oFriction = 0.8;
o->oBuoyancy = 1.3;
o->oUnk190 = 0x100;
o->oInteractionSubtype = INT_SUBTYPE_KICKABLE;
}
void func_802E5B7C(void) {
@ -281,7 +281,7 @@ void bhv_bobomb_buddy_init(void) {
o->oGravity = 2.5;
o->oFriction = 0.8;
o->oBuoyancy = 1.3;
o->oUnk190 = 0x4000;
o->oInteractionSubtype = INT_SUBTYPE_NPC;
}
void BobombBuddyIdleLoop(void) {

View File

@ -499,17 +499,17 @@ void ActionBooGivingStar2(void) {
}
void func_802C41AC(void) {
CreateStar(980.0f, 1100.0f, 250.0f);
create_star(980.0f, 1100.0f, 250.0f);
}
void func_802C41E4(void) {
CreateStar(700.0f, 3200.0f, 1900.0f);
create_star(700.0f, 3200.0f, 1900.0f);
}
void func_802C4220(void) {
struct Object *merryGoRound;
CreateStar(-1600.0f, -2100.0f, 205.0f);
create_star(-1600.0f, -2100.0f, 205.0f);
merryGoRound = obj_nearest_object_with_behavior(bhvMerryGoRound);

View File

@ -303,7 +303,7 @@ void ActionBowser18() // unused?
void ActionBowser0() // only lasts one frame
{
o->oEyesShut = 0;
o->oBowserEyesShut = 0;
set_obj_animation_and_sound_state(12);
// stop him still
o->oAngleVelYaw = 0;
@ -416,7 +416,7 @@ void ActionBowser12(void) {
o->oForwardVel = -400.0f;
o->oVelY = 100.0f;
o->oMoveAngleYaw = o->oBowserAngleToCentre + 0x8000;
o->oEyesShut = 1;
o->oBowserEyesShut = 1;
}
if (o->oSubAction == 0) {
set_obj_animation_and_sound_state(25);
@ -438,7 +438,7 @@ void ActionBowser12(void) {
o->oAction = 3;
else
o->oAction = 0;
o->oEyesShut = 0;
o->oBowserEyesShut = 0;
}
} else {
}
@ -788,7 +788,7 @@ void func_802B5D18(void) {
}
void func_802B5DD8(void) {
o->oEyesShut = 1;
o->oBowserEyesShut = 1;
func_802B392C(&o->oBowserUnkF8);
if (o->oMoveFlags & 1)
PlaySound2(SOUND_OBJECT_BOWSERWALK);
@ -1159,12 +1159,12 @@ void bhv_bowser_init(void) {
else
level = 0;
o->oBehParams2ndByte = level;
o->oUnk1B2 = D_8032F690[level];
o->oBowserUnk1B2 = D_8032F690[level];
o->oHealth = D_8032F694[level];
func_802A11B4(o, 4);
o->oAction = 5;
o->oUnk1AE = 0;
o->oEyesShut = 0;
o->oBowserUnk1AE = 0;
o->oBowserEyesShut = 0;
}
#undef BITDW
@ -1199,23 +1199,23 @@ void func_802B70C8(struct Object *a0, struct GraphNodeSwitchCase *switchCase) {
if (a0->oAngleVelYaw < 0)
switchCase->selectedCase = 3;
}
if (a0->oUnk1AE > 50)
if (a0->oBowserUnk1AE > 50)
switchCase->selectedCase = 1;
break;
case 1:
if (a0->oUnk1AE > 2)
if (a0->oBowserUnk1AE > 2)
switchCase->selectedCase = 2;
break;
case 2:
if (a0->oUnk1AE > 2)
if (a0->oBowserUnk1AE > 2)
switchCase->selectedCase = 9;
break;
case 9:
if (a0->oUnk1AE > 2)
if (a0->oBowserUnk1AE > 2)
switchCase->selectedCase = 0;
break;
case 5:
if (a0->oUnk1AE > 2) {
if (a0->oBowserUnk1AE > 2) {
switchCase->selectedCase = 6;
if (a0->oAngleVelYaw <= 0)
switchCase->selectedCase = 0;
@ -1226,7 +1226,7 @@ void func_802B70C8(struct Object *a0, struct GraphNodeSwitchCase *switchCase) {
switchCase->selectedCase = 5;
break;
case 3:
if (a0->oUnk1AE > 2) {
if (a0->oBowserUnk1AE > 2) {
switchCase->selectedCase = 4;
if (a0->oAngleVelYaw >= 0)
switchCase->selectedCase = 0;
@ -1240,11 +1240,11 @@ void func_802B70C8(struct Object *a0, struct GraphNodeSwitchCase *switchCase) {
switchCase->selectedCase = 0;
}
if (switchCase->selectedCase != sp1C)
a0->oUnk1AE = -1;
a0->oBowserUnk1AE = -1;
}
/** Geo switch for controlling the state of bowser's eye direction and open/closed
* state. Checks whether oEyesShut is TRUE and closes eyes if so and processes
* state. Checks whether oBowserEyesShut is TRUE and closes eyes if so and processes
* direction otherwise.
*/
s32 geo_switch_bowser_eyes(s32 run, struct GraphNode *node, UNUSED Mat4 *mtx) {
@ -1255,7 +1255,7 @@ s32 geo_switch_bowser_eyes(s32 run, struct GraphNode *node, UNUSED Mat4 *mtx) {
if (run == TRUE) {
if (gCurGraphNodeHeldObject != NULL)
obj = (struct Object *) gCurGraphNodeHeldObject->objNode;
switch (sp36 = obj->oEyesShut) {
switch (sp36 = obj->oBowserEyesShut) {
case 0: // eyes open, handle eye looking direction
func_802B70C8(obj, switchCase);
break;
@ -1263,7 +1263,7 @@ s32 geo_switch_bowser_eyes(s32 run, struct GraphNode *node, UNUSED Mat4 *mtx) {
switchCase->selectedCase = 2;
break;
}
obj->oUnk1AE++;
obj->oBowserUnk1AE++;
}
return 0;
}
@ -1285,7 +1285,7 @@ Gfx *Geo18_802B7D44(s32 a0, struct GraphNode *node, UNUSED s32 a2) {
sp20->fnNode.node.flags = (sp20->fnNode.node.flags & 0xFF) | (0x100 | 0x400);
sp28 = sp2C = alloc_display_list(16);
if (sp24->oUnk1B2 != 0) {
if (sp24->oBowserUnk1B2 != 0) {
gSPClearGeometryMode(sp28++, G_LIGHTING);
}
gSPEndDisplayList(sp28);

View File

@ -0,0 +1,172 @@
// bubba.inc.c
static struct ObjectHitbox sBubbaHitbox = {
/* interactType: */ INTERACT_CLAM_OR_BUBBA,
/* downOffset: */ 0,
/* damageOrCoinValue: */ 1,
/* health: */ 99,
/* numLootCoins: */ 0,
/* radius: */ 300,
/* height: */ 200,
/* hurtboxRadius: */ 300,
/* hurtboxHeight: */ 200,
};
void bubba_act_0(void) {
f32 sp24;
sp24 = obj_lateral_dist_to_home();
treat_far_home_as_mario(2000.0f);
o->oAnimState = 0;
o->oBubbaUnk1AC = obj_get_pitch_to_home(sp24);
approach_f32_ptr(&o->oBubbaUnkF4, 5.0f, 0.5f);
if (o->oBubbaUnkFC != 0) {
if (abs_angle_diff(o->oMoveAngleYaw, o->oBubbaUnk1AE) < 800) {
o->oBubbaUnkFC = 0;
}
} else {
if (o->oDistanceToMario >= 25000.0f) {
o->oBubbaUnk1AE = o->oAngleToMario;
o->oBubbaUnkF8 = random_linear_offset(20, 30);
}
if ((o->oBubbaUnkFC = o->oMoveFlags & 0x00000200) != 0) {
o->oBubbaUnk1AE = obj_reflect_move_angle_off_wall();
} else if (o->oTimer > 30 && o->oDistanceToMario < 2000.0f) {
o->oAction = 1;
} else if (o->oBubbaUnkF8 != 0) {
o->oBubbaUnkF8 -= 1;
} else {
o->oBubbaUnk1AE = obj_random_fixed_turn(0x2000);
o->oBubbaUnkF8 = random_linear_offset(100, 100);
}
}
}
void bubba_act_1(void) {
s16 val06;
s16 val04;
treat_far_home_as_mario(2500.0f);
if (o->oDistanceToMario > 2500.0f) {
o->oAction = 0;
} else if (o->oBubbaUnk100 != 0) {
if (--o->oBubbaUnk100 == 0) {
PlaySound2(SOUND_OBJECT_CHOMPINGSOUND);
o->oAction = 0;
} else if (o->oBubbaUnk100 < 15) {
o->oAnimState = 1;
} else if (o->oBubbaUnk100 == 20) {
val06 = 10000 - (s16)(20.0f * (find_water_level(o->oPosX, o->oPosZ) - o->oPosY));
o->oBubbaUnk1AC -= val06;
o->oMoveAnglePitch = o->oBubbaUnk1AC;
o->oBubbaUnkF4 = 40.0f;
obj_compute_vel_from_move_pitch(o->oBubbaUnkF4);
o->oAnimState = 0;
;
} else {
o->oBubbaUnk1AE = o->oAngleToMario;
o->oBubbaUnk1AC = o->oBubbaUnk104;
obj_rotate_yaw_toward(o->oBubbaUnk1AE, 400);
obj_move_pitch_approach(o->oBubbaUnk1AC, 400);
}
} else {
if (abs_angle_diff(gMarioObject->oFaceAngleYaw, o->oAngleToMario) < 0x3000) {
val04 = 0x4000 - atan2s(800.0f, o->oDistanceToMario - 800.0f);
if ((s16)(o->oMoveAngleYaw - o->oAngleToMario) < 0) {
val04 = -val04;
}
o->oBubbaUnk1AE = o->oAngleToMario + val04;
;
} else {
o->oBubbaUnk1AE = o->oAngleToMario;
}
o->oBubbaUnk1AC = o->oBubbaUnk104;
if (obj_is_near_to_and_facing_mario(500.0f, 3000)
&& abs_angle_diff(o->oBubbaUnk1AC, o->oMoveAnglePitch) < 3000) {
o->oBubbaUnk100 = 30;
o->oBubbaUnkF4 = 0;
o->oAnimState = 1;
} else {
approach_f32_ptr(&o->oBubbaUnkF4, 20.0f, 0.5f);
}
}
}
void bhv_bubba_loop(void) {
UNUSED s32 unused;
struct Object *sp38;
s16 sp36;
o->oInteractionSubtype &= ~INT_SUBTYPE_EATS_MARIO;
o->oBubbaUnk104 = obj_turn_pitch_toward_mario(120.0f, 0);
if (abs_angle_diff(o->oAngleToMario, o->oMoveAngleYaw) < 0x1000
&& abs_angle_diff(o->oBubbaUnk104 + 0x800, o->oMoveAnglePitch) < 0x2000) {
if (o->oAnimState != 0 && o->oDistanceToMario < 250.0f) {
o->oInteractionSubtype |= INT_SUBTYPE_EATS_MARIO;
}
o->hurtboxRadius = 100.0f;
} else {
o->hurtboxRadius = 150.0f;
}
obj_update_floor_and_walls();
switch (o->oAction) {
case 0:
bubba_act_0();
break;
case 1:
bubba_act_1();
break;
}
if (o->oMoveFlags & 0x00000078) {
if (o->oMoveFlags & 0x00000008) {
sp38 = spawn_object(o, MODEL_WATER_SPLASH, bhvWaterSplash);
if (sp38 != NULL) {
scale_object(sp38, 3.0f);
}
o->oBubbaUnk108 = o->oVelY;
o->oBubbaUnk10C = 0.0f;
;
} else {
approach_f32_ptr(&o->oBubbaUnk108, 0.0f, 4.0f);
if ((o->oBubbaUnk10C -= o->oBubbaUnk108) > 1.0f) {
sp36 = RandomU16();
o->oBubbaUnk10C -= 1.0f;
spawn_object_relative(0, 150.0f * coss(sp36), 0x64, 150.0f * sins(sp36), o,
MODEL_WHITE_PARTICLE_SMALL, bhvSmallParticleSnow);
}
}
obj_smooth_turn(&o->oBubbaUnk1B0, &o->oMoveAnglePitch, o->oBubbaUnk1AC, 0.05f, 10, 50, 2000);
obj_smooth_turn(&o->oBubbaUnk1B2, &o->oMoveAngleYaw, o->oBubbaUnk1AE, 0.05f, 10, 50, 2000);
obj_compute_vel_from_move_pitch(o->oBubbaUnkF4);
} else {
o->oBubbaUnkF4 = sqrtf(o->oForwardVel * o->oForwardVel + o->oVelY * o->oVelY);
o->oMoveAnglePitch = obj_get_pitch_from_vel();
obj_face_pitch_approach(o->oMoveAnglePitch, 400);
o->oBubbaUnk1B0 = 0;
}
obj_face_pitch_approach(o->oMoveAnglePitch, 400);
obj_check_attacks(&sBubbaHitbox, o->oAction);
obj_move_standard(78);
o->oFloorHeight += 150.0f;
if (o->oPosY < o->oFloorHeight) {
o->oPosY = o->oFloorHeight;
}
}

View File

@ -199,9 +199,9 @@ void BullyLavaDeath(void) {
func_802A3004();
if (o->oBullySubtype == BULLY_STYPE_CHILL)
CreateStar(130.0f, 1600.0f, -4335.0f);
create_star(130.0f, 1600.0f, -4335.0f);
else {
CreateStar(0, 950.0f, -6800.0f);
create_star(0, 950.0f, -6800.0f);
spawn_object_abs_with_rot(o, 0, MODEL_NONE, bhvLllTumblingBridge, 0, 154, -5631, 0, 0,
0);
}
@ -286,12 +286,16 @@ void bhv_big_bully_with_minions_init(void) {
void BigBullyWithMinionsLavaDeath(void) {
if (ObjLavaDeath() == 1) {
func_802A3004();
CreateStar(3700.0f, 600.0f, -5500.0f);
create_star(3700.0f, 600.0f, -5500.0f);
}
}
void bhv_big_bully_with_minions_loop(void) {
#ifdef VERSION_EU
s32 collisionFlags;
#else
s16 collisionFlags;
#endif
o->oBullyPrevX = o->oPosX;
o->oBullyPrevY = o->oPosY;

View File

@ -0,0 +1,6 @@
// castle_cannon_grate.inc.c
void bhv_castle_cannon_grate_init(void) {
if (save_file_get_total_star_count(gCurrSaveFileNum - 1, 0, 24) >= 120)
o->activeFlags = 0;
}

View File

@ -0,0 +1,5 @@
// castle_flag.inc.c
void bhv_castle_flag_init(void) {
o->header.gfx.unk38.animFrame = RandomFloat() * 28.0f;
}

View File

@ -192,7 +192,7 @@ void bhv_chuckya_loop(void) {
f32 sp2C = 20.0f;
f32 sp28 = 50.0f;
obj_scale(2.0f);
o->oUnk190 |= 4;
o->oInteractionSubtype |= INT_SUBTYPE_GRABS_MARIO;
switch (o->oHeldState) {
case HELD_FREE:
func_802A97B8();

View File

@ -0,0 +1,64 @@
// clam.inc.c
struct ObjectHitbox sClamShellHitbox = {
/* interactType: */ INTERACT_CLAM_OR_BUBBA,
/* downOffset: */ 0,
/* damageOrCoinValue: */ 2,
/* health: */ 99,
/* numLootCoins: */ 0,
/* radius: */ 150,
/* height: */ 80,
/* hurtboxRadius: */ 150,
/* hurtboxHeight: */ 80,
};
void clam_act_0(void) {
if (func_802F92EC(0, 25)) {
PlaySound2(SOUND_GENERAL_CLAMSHELL4);
func_802ADA94();
obj_become_tangible();
o->oClamUnkF4 = 10;
o->oTimer = 0;
} else if (o->oTimer > 150 && o->oDistanceToMario < 500.0f) {
PlaySound2(SOUND_GENERAL_CLAMSHELL3);
o->oAction = 1;
} else if (o->oClamUnkF4 != 0) {
o->oClamUnkF4 -= 1;
obj_shake_y(3.0f);
}
}
void clam_act_1(void) {
s16 val06;
s16 val04;
s16 val02;
if (o->oTimer > 150) {
o->oAction = 0;
} else if (obj_is_rendering_enabled() && func_802F92EC(1, 8)) {
for (val06 = -0x2000; val06 < 0x2000; val06 += 0x555) {
val04 = (s16)(100.0f * sins(val06));
val02 = (s16)(100.0f * coss(val06));
spawn_object_relative(0, val04, 30, val02, o, MODEL_BUBBLE, bhvBubbleMaybe);
}
} else if (obj_check_anim_frame(30)) {
obj_become_intangible();
}
}
void bhv_clam_loop(void) {
o->header.gfx.scale[1] = 1.5f;
switch (o->oAction) {
case 0:
clam_act_0();
break;
case 1:
clam_act_1();
break;
}
obj_check_attacks(&sClamShellHitbox, o->oAction);
}

View File

@ -0,0 +1,123 @@
// coffin.inc.c
struct Struct80331C00 {
s16 unk00;
s16 unk02;
};
struct Struct80331C00 D_80331C00[] = {
{ 0x019C, 0xFF6A }, { 0x02FA, 0xFF6A }, { 0x0458, 0xFF6A },
{ 0x019C, 0x0096 }, { 0x02FA, 0x0096 }, { 0x0458, 0x0096 },
};
void bhv_coffin_manager_loop(void) {
struct Object *val0C;
s32 val08;
s16 val06;
if (o->oAction == 0) {
if (!(o->activeFlags & 0x0008)) {
for (val08 = 0; val08 < 6; val08++) {
val06 = D_80331C00[val08].unk02;
val0C = spawn_object_relative(val08 & 0x00000001, D_80331C00[val08].unk00, 0, val06, o,
MODEL_BBH_WOODEN_TOMB, bhvCoffin);
if (val0C != NULL) {
if (val06 > 0) {
val0C->oFaceAngleYaw = 0x8000;
}
}
}
o->oAction += 1;
}
} else if (o->activeFlags & 0x0008) {
o->oAction = 0;
}
}
void coffin_act_0(void) {
f32 val14;
f32 val10;
f32 val0C;
f32 val08;
f32 val04;
f32 val00;
if (o->oBehParams2ndByte != 0) {
if (o->oFaceAnglePitch != 0) {
o->oAngleVelPitch = approach_s16_symmetric(o->oAngleVelPitch, -2000, 200);
if (obj_face_pitch_approach(0, -o->oAngleVelPitch)) {
PlaySound2(SOUND_GENERAL_ELEVATORMOVE_2);
obj_perform_position_op(0);
o->oMoveAngleYaw = o->oFaceAngleYaw - 0x4000;
obj_set_dist_from_home(200.0f);
func_802ADA94();
obj_perform_position_op(2);
}
o->oTimer = 0;
} else {
val14 = coss(o->oFaceAngleYaw);
val10 = sins(o->oFaceAngleYaw);
val0C = gMarioObject->oPosX - o->oPosX;
val08 = gMarioObject->oPosZ - o->oPosZ;
val04 = val0C * val14 + val08 * val10;
val00 = val08 * val14 - val0C * val10;
if (o->oTimer > 60
&& (o->oDistanceToMario > 100.0f || gMarioState->action == ACT_SQUISHED)) {
if (gMarioObject->oPosY - o->oPosY < 200.0f && absf(val04) < 140.0f) {
if (val00 < 150.0f && val00 > -450.0f) {
PlaySound2(SOUND_GENERAL_BUTTONPRESS_2_LOWPRIO);
o->oAction = 1;
}
}
}
o->oAngleVelPitch = 0;
}
}
}
void coffin_act_1(void) {
if (o->oFaceAnglePitch != 0x4000) {
o->oAngleVelPitch = approach_s16_symmetric(o->oAngleVelPitch, 1000, 200);
obj_face_pitch_approach(0x4000, o->oAngleVelPitch);
} else {
if (o->oTimer > 60) {
o->oAction = 0;
o->oFaceAngleRoll = 0;
} else if (o->oTimer > 30) {
if (gGlobalTimer % 4 == 0) {
PlaySound2(SOUND_GENERAL_ELEVATORMOVE_2);
}
o->oFaceAngleRoll = 400 * (gGlobalTimer % 2) - 200;
}
o->oAngleVelPitch = 0;
}
}
void bhv_coffin_loop(void) {
if (o->parentObj->oAction == 0) {
mark_object_for_deletion(o);
} else {
o->header.gfx.scale[1] = 1.1f;
switch (o->oAction) {
case 0:
coffin_act_0();
break;
case 1:
coffin_act_1();
break;
}
load_object_collision_model();
}
}

View File

@ -0,0 +1,29 @@
// end_birds_1.inc.c
void bhv_end_birds_1_loop(void) {
Vec3f sp34;
UNUSED f32 sp30 = RandomFloat();
switch (gCurrentObject->oAction) {
case 0:
obj_scale(0.7f);
gCurrentObject->oIntroLakituUnk110 = -554.f;
gCurrentObject->oIntroLakituUnk10C = 3044.f;
gCurrentObject->oIntroLakituUnk108 = -1314.f;
gCurrentObject->oAction += 1;
break;
case 1:
vec3f_set(sp34, gCurrentObject->oIntroLakituUnk110, gCurrentObject->oIntroLakituUnk10C,
gCurrentObject->oIntroLakituUnk108);
if (gCurrentObject->oTimer < 100)
func_8029A7DC(gCurrentObject, sp34, 0, 0, 0x20, 0x20);
if ((gCurrentObject->oEndBirdUnk104 == 0.f) && (gCurrentObject->oTimer == 0))
PlaySound2(SOUND_GENERAL_BIRDSFLYAWAY);
if (gCutsceneTimer == 0)
mark_object_for_deletion(gCurrentObject);
break;
}
func_802A2A38();
}

View File

@ -0,0 +1,31 @@
// end_birds_2.inc.c
void bhv_end_birds_2_loop(void) {
Vec3f sp3C;
UNUSED f32 sp38;
f32 sp34;
s16 sp32, sp30;
sp38 = RandomFloat();
gCurrentObject->oForwardVel = (RandomFloat() * 10.f) + 25.f;
switch (gCurrentObject->oAction) {
case 0:
obj_scale(0.7f);
gCurrentObject->oAction += 1;
break;
case 1:
vec3f_get_dist_and_angle(gCurrLevelCamera->pos, gCurrLevelCamera->focus, &sp34, &sp32,
&sp30);
sp30 += 0x1000;
sp32 += 0; // nice work, Nintendo
vec3f_set_dist_and_angle(gCurrLevelCamera->pos, sp3C, 14000.f, sp32, sp30);
func_8029A7DC(gCurrentObject, sp3C, 0, 0, 8, 8);
if ((gCurrentObject->oEndBirdUnk104 == 0.f) && (gCurrentObject->oTimer == 0))
PlaySound2(SOUND_GENERAL_BIRDSFLYAWAY);
break;
}
func_802A2A38();
}

View File

@ -118,7 +118,7 @@ static void eyerok_boss_act_fight(void) {
static void eyerok_boss_act_die(void) {
if (o->oTimer == 60) {
if (obj_update_dialog_unk2(2, 0, 0xA2, 0x76)) {
CreateStar(0.0f, -900.0f, -3700.0f);
create_star(0.0f, -900.0f, -3700.0f);
} else {
o->oTimer -= 1;
}

View File

@ -68,7 +68,7 @@ static void fire_piranha_plant_act_hide(void) {
if ((u16)(o->oBehParams >> 16) != 0 && o->oHealth == 0) {
if (++sNumKilledFirePiranhaPlants == 5) {
CreateStar(-6300.0f, -1850.0f, -6300.0f);
create_star(-6300.0f, -1850.0f, -6300.0f);
}
obj_die_if_health_non_positive();

View File

@ -0,0 +1,53 @@
// flame.inc.c
void bhv_small_piranha_flame_loop(void) {
f32 sp2C;
if ((u16)(o->oBehParams >> 16) == 0) {
if (o->oTimer > 0) {
mark_object_for_deletion(o);
} else {
sp2C = RandomFloat() - 0.5f;
o->header.gfx.scale[1] = o->header.gfx.scale[2] * (1.0f + 0.7f * sp2C);
o->header.gfx.scale[0] = o->header.gfx.scale[2] * (0.9f - 0.5f * sp2C);
o->oAnimState = RandomU16();
}
} else {
obj_update_floor_and_walls();
if (approach_f32_ptr(&o->oSmallPiranhaFlameUnkF4, o->oSmallPiranhaFlameUnkF8, 0.6f)) {
obj_rotate_yaw_toward(o->oAngleToMario, 0x200);
}
obj_compute_vel_from_move_pitch(o->oSmallPiranhaFlameUnkF4);
obj_move_standard(-78);
spawn_object_with_scale(o, o->oSmallPiranhaFlameUnkFC, bhvSmallPiranhaFlame,
0.4f * o->header.gfx.scale[0]);
if (o->oTimer > o->oSmallPiranhaFlameUnk100) {
spawn_object_relative_with_scale(1, 0, o->oGraphYOffset, 0, o->header.gfx.scale[0], o,
o->oSmallPiranhaFlameUnkFC, bhvFlyguyFlame);
o->oSmallPiranhaFlameUnk100 = random_linear_offset(8, 15);
o->oTimer = 0;
}
obj_check_attacks(&sPiranhaPlantFireHitbox, o->oAction);
o->oSmallPiranhaFlameUnk104 += o->oSmallPiranhaFlameUnkF4;
if (o->oSmallPiranhaFlameUnk104 > 1500.0f || (o->oMoveFlags & 0x00000278)) {
obj_die_if_health_non_positive();
}
}
o->oGraphYOffset = 15.0f * o->header.gfx.scale[1];
}
void bhv_fly_guy_flame_loop(void) {
obj_move_using_fvel_and_gravity();
if (approach_f32_ptr(&o->header.gfx.scale[0], 0.0f, 0.6f)) {
mark_object_for_deletion(o);
}
obj_scale(o->header.gfx.scale[0]);
}

View File

@ -0,0 +1,303 @@
// flying_bookend_switch.inc.c
struct Struct80331B30 {
s16 unk00;
s16 unk02;
};
struct ObjectHitbox sFlyingBookendHitbox = {
/* interactType: */ INTERACT_HIT_FROM_BELOW,
/* downOffset: */ 0,
/* damageOrCoinValue: */ 2,
/* health: */ 0,
/* numLootCoins: */ -1,
/* radius: */ 60,
/* height: */ 30,
/* hurtboxRadius: */ 40,
/* hurtboxHeight: */ 30,
};
struct Struct80331B30 D_80331B30[] = {
{ 52, 150 },
{ 135, 3 },
{ -75, 78 },
};
struct ObjectHitbox sBookSwitchHitbox = {
/* interactType: */ INTERACT_BREAKABLE,
/* downOffset: */ 0,
/* damageOrCoinValue: */ 0,
/* health: */ 99,
/* numLootCoins: */ 0,
/* radius: */ 20,
/* height: */ 30,
/* hurtboxRadius: */ 20,
/* hurtboxHeight: */ 30,
};
void flying_bookend_act_0(void) {
if (obj_is_near_to_and_facing_mario(400.0f, 0x3000)) {
PlaySound2(SOUND_OBJECT_DEFAULTDEATH);
o->oAction = 1;
o->oBookendUnkF4 = o->oFaceAnglePitch + 0x7FFF;
o->oBookendUnkF8 = o->oFaceAngleRoll - 0x7FFF;
obj_set_model(MODEL_BOOKEND_PART);
}
}
void flying_bookend_act_1(void) {
if (obj_forward_vel_approach(3.0f, 1.0f)) {
if (func_802F92B0(2)) {
o->oAction = 2;
o->oForwardVel = 0.0f;
} else {
o->oForwardVel = 3.0f;
if (o->oTimer > 5) {
obj_face_pitch_approach(o->oBookendUnkF4, 2000);
if (o->oTimer >= 10) {
obj_face_roll_approach(o->oBookendUnkF8, 2000);
if (o->oTimer >= 20) {
approach_f32_ptr(&o->header.gfx.scale[0], 3.0f, 0.2f);
}
}
}
}
}
obj_move_using_fvel_and_gravity();
}
void flying_bookend_act_2(void) {
set_obj_animation_and_sound_state(1);
obj_update_floor_and_walls();
if (o->oForwardVel == 0.0f) {
obj_turn_pitch_toward_mario(120.0f, 1000);
o->oFaceAnglePitch = o->oMoveAnglePitch + 0x7FFF;
obj_rotate_yaw_toward(o->oAngleToMario, 1000);
if (o->oTimer > 30) {
obj_compute_vel_from_move_pitch(50.0f);
}
}
obj_move_standard(78);
}
void flying_bookend_act_3(void) {
o->oDamageOrCoinValue = 1;
o->oNumLootCoins = 0;
if (o->oTimer >= 4) {
o->oAction = 2;
o->oForwardVel = 50.0f;
}
obj_forward_vel_approach(50.0f, 2.0f);
obj_move_using_fvel_and_gravity();
}
void bhv_flying_bookend_loop(void) {
if (!(o->activeFlags & 0x0008)) {
o->oDeathSound = SOUND_OBJECT_POUNDING1;
obj_scale(o->header.gfx.scale[0]);
switch (o->oAction) {
case 0:
flying_bookend_act_0();
break;
case 1:
flying_bookend_act_1();
break;
case 2:
flying_bookend_act_2();
break;
case 3:
flying_bookend_act_3();
break;
}
obj_check_attacks(&sFlyingBookendHitbox, -1);
if (o->oAction == -1 || (o->oMoveFlags & 0x00000203)) {
o->oNumLootCoins = 0;
obj_die_if_health_non_positive();
}
o->oGraphYOffset = 30.0f * o->header.gfx.scale[0];
}
}
void bhv_bookend_spawn_loop(void) {
struct Object *sp1C;
if (!(o->activeFlags & 0x0008)) {
if (o->oTimer > 40 && obj_is_near_to_and_facing_mario(600.0f, 0x2000)) {
sp1C = spawn_object(o, MODEL_BOOKEND, bhvFlyingBookend);
if (sp1C != NULL) {
sp1C->oAction = 3;
PlaySound2(SOUND_OBJECT_DEFAULTDEATH);
}
o->oTimer = 0;
}
}
}
void bookshelf_manager_act_0(void) {
s32 val04;
if (!(o->activeFlags & 0x0008)) {
for (val04 = 0; val04 < 3; val04++) {
spawn_object_relative(val04, D_80331B30[val04].unk00, D_80331B30[val04].unk02, 0, o,
MODEL_BOOKEND, bhvBookSwitch);
}
o->oAction = 1;
}
}
void bookshelf_manager_act_1(void) {
if (o->oBookSwitchManagerUnkF8 == 0) {
if (obj_is_near_to_and_facing_mario(500.0f, 0x3000)) {
o->oBookSwitchManagerUnkF8 = 1;
}
} else if (o->oTimer > 60) {
o->oAction = 2;
o->oBookSwitchManagerUnkF8 = 0;
}
}
void bookshelf_manager_act_2(void) {
if (!(o->activeFlags & 0x0008)) {
if (o->oBookSwitchManagerUnkF4 < 0) {
if (o->oTimer > 30) {
o->oBookSwitchManagerUnkF4 = o->oBookSwitchManagerUnkF8 = 0;
} else if (o->oTimer > 10) {
o->oBookSwitchManagerUnkF8 = 1;
}
} else {
if (o->oBookSwitchManagerUnkF4 >= 3) {
if (o->oTimer > 100) {
o->parentObj = obj_nearest_object_with_behavior(bhvHauntedBookshelf);
o->parentObj->oAction = 1;
o->oPosX = o->parentObj->oPosX;
o->oAction = 3;
} else if (o->oTimer == 30) {
play_puzzle_jingle();
}
} else {
o->oTimer = 0;
}
}
} else {
o->oAction = 4;
}
}
void bookshelf_manager_act_3(void) {
if (o->oTimer > 85) {
o->oAction = 4;
} else {
o->oForwardVel = o->parentObj->oPosX - o->oPosX;
o->oPosX = o->parentObj->oPosX;
}
}
void bookshelf_manager_act_4(void) {
if (o->oBookSwitchManagerUnkF4 >= 3) {
mark_object_for_deletion(o);
} else {
o->oAction = 0;
}
}
void bhv_haunted_bookshelf_manager_loop(void) {
switch (o->oAction) {
case 0:
bookshelf_manager_act_0();
break;
case 2:
bookshelf_manager_act_2();
break;
case 1:
bookshelf_manager_act_1();
break;
case 3:
bookshelf_manager_act_3();
break;
case 4:
bookshelf_manager_act_4();
break;
}
}
void bhv_book_switch_loop(void) {
s32 sp3C;
struct Object *sp38;
s16 sp36;
s16 sp34;
o->header.gfx.scale[0] = 2.0f;
o->header.gfx.scale[1] = 0.9f;
if (o->parentObj->oAction == 4) {
mark_object_for_deletion(o);
} else {
sp3C = obj_check_attacks(&sBookSwitchHitbox, o->oAction);
if (o->parentObj->oBookSwitchManagerUnkF8 != 0 || o->oAction == 1) {
if (o->oDistanceToMario < 100.0f) {
obj_become_tangible();
} else {
obj_become_intangible();
}
o->oAction = 1;
if (o->oBookSwitchUnkF4 == 0.0f) {
PlaySound2(SOUND_OBJECT_DEFAULTDEATH);
}
if (approach_f32_ptr(&o->oBookSwitchUnkF4, 50.0f, 20.0f)) {
if (o->parentObj->oBookSwitchManagerUnkF4 >= 0 && o->oTimer > 60) {
if (sp3C == 1 || sp3C == 2 || sp3C == 6) {
o->oAction = 2;
}
}
} else {
o->oTimer = 0;
}
} else {
obj_become_intangible();
if (approach_f32_ptr(&o->oBookSwitchUnkF4, 0.0f, 20.0f)) {
if (o->oAction != 0) {
if (o->parentObj->oBookSwitchManagerUnkF4 == o->oBehParams2ndByte) {
play_sound(SOUND_CH8_RIGHTANSWER, gDefaultSoundArgs);
o->parentObj->oBookSwitchManagerUnkF4 += 1;
} else {
sp36 = RandomU16() & 0x1;
sp34 = gMarioObject->oPosZ + 1.5f * gMarioStates[0].vel[2];
play_sound(SOUND_MENU_CAMERABUZZ, gDefaultSoundArgs);
if (sp34 > 0) {
sp34 = 0;
}
sp38 = spawn_object_abs_with_rot(o, 0, MODEL_BOOKEND, bhvFlyingBookend,
0x1FC * sp36 - 0x8CA, 890, sp34, 0,
0x8000 * sp36 + 0x4000, 0);
if (sp38 != NULL) {
sp38->oAction = 3;
}
o->parentObj->oBookSwitchManagerUnkF4 = -1;
}
o->oAction = 0;
}
}
}
o->oPosX += o->parentObj->oForwardVel;
o->oPosZ = o->oHomeZ - o->oBookSwitchUnkF4;
obj_push_mario_away_from_cylinder(70.0f, 70.0f);
}
}

View File

@ -0,0 +1,142 @@
// haunted_chair.inc.c
struct ObjectHitbox sHauntedChairHitbox = {
/* interactType: */ INTERACT_MR_BLIZZARD,
/* downOffset: */ 0,
/* damageOrCoinValue: */ 2,
/* health: */ 0,
/* numLootCoins: */ 0,
/* radius: */ 50,
/* height: */ 50,
/* hurtboxRadius: */ 50,
/* hurtboxHeight: */ 50,
};
void bhv_haunted_chair_init(void) {
struct Object *val04;
f32 val00;
val04 = obj_find_nearest_object_with_behavior(bhvMadPiano, &val00);
if (val04 != NULL && val00 < 300.0f) {
o->parentObj = val04;
} else {
o->oHauntedChairUnkF4 = 1;
}
}
void haunted_chair_act_0(void) {
s16 val0E;
f32 val08;
if (o->parentObj != o) {
if (o->oHauntedChairUnk104 == 0) {
if (lateral_dist_between_objects(o, o->parentObj) < 250.0f) {
val0E = angle_to_object(o, o->parentObj) - o->oFaceAngleYaw + 0x2000;
if (val0E & 0x4000) {
o->oHauntedChairUnk100 = &o->oFaceAngleRoll;
if (val0E > 0) {
o->oHauntedChairUnk104 = 0x4000;
} else {
o->oHauntedChairUnk104 = -0x4000;
}
} else {
o->oHauntedChairUnk100 = &o->oFaceAnglePitch;
if (val0E < 0) {
o->oHauntedChairUnk104 = 0x5000;
} else {
o->oHauntedChairUnk104 = -0x4000;
}
}
if (o->oHauntedChairUnk104 < 0) {
o->oHauntedChairUnkF8 = -1500.0f;
} else {
o->oHauntedChairUnkF8 = 1500.0f;
}
}
} else {
oscillate_toward(o->oHauntedChairUnk100, &o->oHauntedChairUnkF8, o->oHauntedChairUnk104,
4000.0f, 20.0f, 2.0f);
}
} else if (o->oHauntedChairUnkF4 != 0) {
if (o->oDistanceToMario < 500.0f) {
o->oHauntedChairUnkF4 -= 1;
}
o->oTimer = 0.0f;
} else {
if ((o->oTimer & 0x8) != 0) {
if (o->oFaceAnglePitch < 0) {
PlaySound2(SOUND_GENERAL_MOVINGBOOMAYBE);
val08 = 4.0f;
} else {
val08 = -4.0f;
}
o->oHomeX -= val08;
o->oHomeZ -= val08;
o->oFaceAnglePitch = o->oFaceAngleRoll = (s32)(50.0f * val08);
;
} else {
o->oFaceAnglePitch = o->oFaceAngleRoll = 0;
}
if (o->oTimer > 30) {
o->oAction = 1;
o->oHauntedChairUnkF8 = 0.0f;
o->oHauntedChairUnkFC = 200.0f;
o->oHauntedChairUnkF4 = 40;
}
}
obj_push_mario_away_from_cylinder(80.0f, 120.0f);
}
void haunted_chair_act_1(void) {
obj_update_floor_and_walls();
if (o->oTimer < 70) {
if (o->oTimer < 50) {
o->oVelY = 6.0f;
} else {
o->oVelY = 0.0f;
}
o->oGravity = 0.0f;
oscillate_toward(&o->oFaceAnglePitch, &o->oHauntedChairUnkF8, -4000, 200.0f, 20.0f, 2.0f);
oscillate_toward(&o->oFaceAngleRoll, &o->oHauntedChairUnkFC, 0, 0.0f, 20.0f, 1.0f);
} else {
if (o->oHauntedChairUnkF4 != 0) {
if (--o->oHauntedChairUnkF4 == 0) {
PlaySound2(SOUND_GENERAL_HAUNTEDCHAIR);
o->oMoveAnglePitch = obj_turn_pitch_toward_mario(120.0f, 0);
o->oMoveAngleYaw = o->oAngleToMario;
obj_compute_vel_from_move_pitch(50.0f);
} else if (o->oHauntedChairUnkF4 > 20) {
if (gGlobalTimer % 4 == 0) {
PlaySound2(SOUND_GENERAL_SWISHAIR_2);
}
o->oFaceAngleYaw += 0x2710;
}
} else if (o->oMoveFlags & 0x00000203) {
obj_die_if_health_non_positive();
}
}
obj_check_attacks(&sHauntedChairHitbox, o->oAction);
obj_move_standard(78);
}
void bhv_haunted_chair_loop(void) {
if (!(o->activeFlags & 0x0008)) {
switch (o->oAction) {
case 0:
haunted_chair_act_0();
break;
case 1:
haunted_chair_act_1();
break;
}
func_802F8D78(30.0f, 30.0f);
}
}

View File

@ -0,0 +1,203 @@
// intro_lakitu.inc.c
void func_8029AB70(struct Object *o, Vec3f b) {
f32 sp2C;
Vec3s sp24;
s16 sp22, sp20;
vec3f_add(b, gCurrLevelCamera->pos);
vec3f_get_dist_and_angle(gCurrLevelCamera->pos, gCurrLevelCamera->focus, &sp2C, &sp24[0], &sp24[1]);
vec3f_get_dist_and_angle(gCurrLevelCamera->pos, b, &sp2C, &sp22, &sp20);
vec3f_set_dist_and_angle(gCurrLevelCamera->pos, b, sp2C, sp24[0] + sp22, sp24[1] + sp20);
vec3f_to_object_pos(o, b);
}
void func_8029AC3C(struct Object *o, Vec3f b) {
UNUSED Vec3f sp3C;
Vec3f sp30;
f32 sp2C;
s16 sp2A, sp28;
UNUSED u32 sp24;
vec3f_set(sp30, 0.f, 0.f, 0.f);
vec3f_get_dist_and_angle(sp30, b, &sp2C, &sp2A, &sp28);
o->oFaceAnglePitch = sp2A;
o->oFaceAngleYaw = sp28;
}
s32 func_8029ACAC(struct Object *o, struct CinematicCameraTable b[], struct CinematicCameraTable c[]) {
Vec3f sp2C, sp20;
s32 sp1C = 0;
s16 sp1A = o->oIntroLakituUnkFC;
if ((func_80287CFC(sp20, b, &sp1A, &(o->oIntroLakituUnkF8)) == 1)
|| (func_80287CFC(sp2C, c, &sp1A, &(o->oIntroLakituUnkF8)) == 1))
sp1C += 1;
o->oIntroLakituUnkFC = sp1A;
func_8029AB70(o, sp2C);
func_8029AC3C(o, sp20);
return sp1C;
}
void bhv_intro_lakitu_loop(void) {
Vec3f sp64, sp58, sp4C;
UNUSED u32 pad[4];
switch (gCurrentObject->oAction) {
case 0:
obj_disable_rendering();
gCurrentObject->oIntroLakituUnkFC = 0.f;
gCurrentObject->oIntroLakituUnkF8 = 0.f;
gCurrentObject->oUnk1AC_VPTR =
spawn_object_relative_with_scale(1, 0, 0, 0, 2.f, gCurrentObject, MODEL_MIST, bhvCloud);
if (gCurrLevelCamera->cutscene == CUTSCENE_END_WAVING)
gCurrentObject->oAction = 100;
else
gCurrentObject->oAction += 1;
break;
case 1:
obj_enable_rendering();
if ((gCutsceneTimer > 350) && (gCutsceneTimer < 458)) {
gCurrentObject->oPosX = gCurrLevelCamera->pos[0];
gCurrentObject->oPosY = gCurrLevelCamera->pos[1] + 500.f;
gCurrentObject->oPosZ = gCurrLevelCamera->pos[2];
}
if (gCutsceneTimer > 52)
PlaySound(SOUND_CH6_LAKITUFLY_HIGHPRIO);
if (func_8029ACAC(gCurrentObject, D_8032E3CC, D_8032E2B4) == 1)
gCurrentObject->oAction += 1;
switch (gCurrentObject->oTimer) {
#ifdef VERSION_US
case 534:
PlaySound2(SOUND_ACTION_UNKNOWN456);
break;
case 581:
PlaySound2(SOUND_ACTION_UNKNOWN45E);
break;
#endif
case 73:
gCurrentObject->oAnimState += 1;
break;
case 74:
gCurrentObject->oAnimState -= 1;
break;
case 82:
gCurrentObject->oAnimState += 1;
break;
case 84:
gCurrentObject->oAnimState -= 1;
break;
}
#ifdef VERSION_EU
if (gCurrentObject->oTimer == 446)
PlaySound2(SOUND_ACTION_UNKNOWN456);
if (gCurrentObject->oTimer == 485)
PlaySound2(SOUND_ACTION_UNKNOWN45E);
#endif
break;
case 2:
if (gCutsceneTimer > 720) {
gCurrentObject->oAction += 1;
gCurrentObject->oIntroLakituUnk100 = 1400.f;
gCurrentObject->oIntroLakituUnk104 = -4096.f;
gCurrentObject->oIntroLakituUnk108 = 2048.f;
gCurrentObject->oIntroLakituUnk10C = -200.f;
gCurrentObject->oMoveAngleYaw = 0x8000;
gCurrentObject->oFaceAngleYaw = gCurrentObject->oMoveAngleYaw + 0x4000;
gCurrentObject->oMoveAnglePitch = 0x800;
}
PlaySound(SOUND_CH6_LAKITUFLY_HIGHPRIO);
break;
case 3:
PlaySound(SOUND_CH6_LAKITUFLY_HIGHPRIO);
vec3f_set(sp58, -1128.f, 560.f, 4664.f);
gCurrentObject->oMoveAngleYaw += 0x200;
gCurrentObject->oIntroLakituUnk100 =
approach_f32_exponential(gCurrentObject->oIntroLakituUnk100, 100.f, 0.03f);
gCurrentObject->oFaceAnglePitch = atan2s(200.f, gCurrentObject->oPosY - 400.f);
gCurrentObject->oFaceAngleYaw = approach_s16_exponential(
gCurrentObject->oFaceAngleYaw, gCurrentObject->oMoveAngleYaw + 0x8000, 4);
vec3f_set_dist_and_angle(sp58, sp4C, gCurrentObject->oIntroLakituUnk100, 0,
gCurrentObject->oMoveAngleYaw);
sp4C[1] += 150.f * coss((s16) gCurrentObject->oIntroLakituUnk104);
gCurrentObject->oIntroLakituUnk104 += gCurrentObject->oIntroLakituUnk108;
gCurrentObject->oIntroLakituUnk108 =
approach_f32_exponential(gCurrentObject->oIntroLakituUnk108, 512.f, 0.05f);
sp4C[0] += gCurrentObject->oIntroLakituUnk10C;
gCurrentObject->oIntroLakituUnk10C =
approach_f32_exponential(gCurrentObject->oIntroLakituUnk10C, 0.f, 0.05f);
vec3f_to_object_pos(gCurrentObject, sp4C);
if (gCurrentObject->oTimer == 31) {
gCurrentObject->oPosY -= 158.f;
func_802ADA94();
gCurrentObject->oPosY += 158.f;
}
#ifdef VERSION_EU
#define TIMER 74
#else
#define TIMER 98
#endif
if (gCurrentObject->oTimer == TIMER) {
mark_object_for_deletion(gCurrentObject);
mark_object_for_deletion(gCurrentObject->oUnk1AC_VPTR);
}
#ifndef VERSION_JP
if (gCurrentObject->oTimer == 14)
PlaySound2(SOUND_ACTION_UNKNOWN45F);
#endif
break;
case 100:
obj_enable_rendering();
vec3f_set(sp64, -100.f, 100.f, 300.f);
set_pos_from_face_angle_and_vec3f(sp4C, gCurrLevelCamera->pos, sp64,
sMarioStatusForCamera->faceAngle);
vec3f_to_object_pos(gCurrentObject, sp4C);
gCurrentObject->oMoveAnglePitch = 0x1000;
gCurrentObject->oMoveAngleYaw = 0x9000;
gCurrentObject->oFaceAnglePitch = gCurrentObject->oMoveAnglePitch / 2;
gCurrentObject->oFaceAngleYaw = gCurrentObject->oMoveAngleYaw;
gCurrentObject->oAction += 1;
break;
case 101:
object_pos_to_vec3f(sp4C, gCurrentObject);
if (gCurrentObject->oTimer > 60) {
gCurrentObject->oForwardVel =
approach_f32_exponential(gCurrentObject->oForwardVel, -10.f, 0.05f);
gCurrentObject->oMoveAngleYaw += 0x78;
gCurrentObject->oMoveAnglePitch += 0x40;
gCurrentObject->oFaceAngleYaw = camera_approach_s16_symmetric(
gCurrentObject->oFaceAngleYaw, (s16) calculate_yaw(sp4C, gCurrLevelCamera->pos),
0x200);
}
if (gCurrentObject->oTimer > 105) {
gCurrentObject->oAction += 1;
gCurrentObject->oMoveAnglePitch = 0xE00;
}
gCurrentObject->oFaceAnglePitch = 0;
func_802A2A38();
break;
case 102:
object_pos_to_vec3f(sp4C, gCurrentObject);
gCurrentObject->oForwardVel =
approach_f32_exponential(gCurrentObject->oForwardVel, 60.f, 0.05f);
gCurrentObject->oFaceAngleYaw = camera_approach_s16_symmetric(
gCurrentObject->oFaceAngleYaw, (s16) calculate_yaw(sp4C, gCurrLevelCamera->pos), 0x200);
if (gCurrentObject->oTimer < 62)
gCurrentObject->oMoveAngleYaw =
approach_s16_exponential(gCurrentObject->oMoveAngleYaw, 0x1800, 0x1E);
gCurrentObject->oMoveAnglePitch =
camera_approach_s16_symmetric(gCurrentObject->oMoveAnglePitch, -0x2000, 0x5A);
gCurrentObject->oFaceAnglePitch = 0;
func_802A2A38();
break;
}
}
#undef TIMER

View File

@ -0,0 +1,49 @@
// intro_peach.inc.c
void func_8029A87C(struct Object *o, f32 b, f32 c) {
Vec3f sp2C;
s16 sp2A, sp28;
f32 sp24, sp20;
vec3f_get_dist_and_angle(gCameraStatus.pos, gCameraStatus.focus, &sp24, &sp2A, &sp28);
vec3f_set_dist_and_angle(gCameraStatus.pos, sp2C, o->oIntroPeachUnk110, o->oIntroPeachUnk10C + sp2A,
o->oIntroPeachUnk108 + sp28);
vec3f_to_object_pos(o, sp2C);
sp20 = o->oOpacity;
camera_approach_f32_symmetric_bool(&sp20, b, c);
o->oOpacity = sp20;
}
void bhv_intro_peach_loop(void) {
switch (gCurrentObject->oAction) {
case 0:
gCurrentObject->oAction += 1;
gCurrentObject->oFaceAnglePitch = 0x400;
gCurrentObject->oFaceAngleYaw = 0x7500;
gCurrentObject->oFaceAngleRoll = -0x3700;
gCurrentObject->oIntroPeachUnk110 = 186.f;
gCurrentObject->oIntroPeachUnk10C = -9984.f;
gCurrentObject->oIntroPeachUnk108 = -768.f;
gCurrentObject->oOpacity = 255;
gCurrentObject->header.gfx.unk38.animFrame = 100;
break;
case 1:
func_8029A87C(gCurrentObject, 0.f, 0.f);
if (gCurrentObject->oTimer > 20)
gCurrentObject->oAction += 1;
break;
case 2:
func_8029A87C(gCurrentObject, 255.f, 3.f);
if ((gCurrentObject->oTimer > 100) && (get_dialog_id() == -1))
gCurrentObject->oAction += 1;
break;
case 3:
func_8029A87C(gCurrentObject, 0.f, 8.f);
if (gCurrentObject->oTimer > 60)
mark_object_for_deletion(gCurrentObject);
break;
}
}

View File

@ -0,0 +1,75 @@
// intro_scene.inc.c
void func_8029B964(struct Object *parent, s16 xOffset, s16 yOffset, s16 zOffset, s16 pitchOffset,
s16 yawOffset, s16 rollOffset, s16 forwardVel, s32 model, void *behavior) {
struct Object *sp1C = spawn_object(parent, model, behavior);
sp1C->header.gfx.unk38.animFrame = RandomFloat() * 6.f;
sp1C->oEndBirdUnk104 = D_8033B6F0[9].unk4[0];
D_8033B6F0[9].unk4[0] += 1.f;
sp1C->oPosX += xOffset;
sp1C->oPosY += yOffset;
if (gCutsceneTimer > 700)
sp1C->oPosY += -150.f;
sp1C->oPosZ += zOffset;
sp1C->oMoveAnglePitch += pitchOffset;
sp1C->oMoveAngleYaw += yawOffset;
sp1C->oMoveAngleRoll += rollOffset;
sp1C->oForwardVel = forwardVel;
}
void bhv_intro_scene_loop(void) {
UNUSED struct Object *sp34;
if (sCutscenePhase != 0) {
gCurrentObject->oPosX = gCurrLevelCamera->pos[0];
gCurrentObject->oPosY = gCurrLevelCamera->pos[1];
gCurrentObject->oPosZ = gCurrLevelCamera->pos[2];
gCurrentObject->oMoveAnglePitch = 0;
gCurrentObject->oMoveAngleYaw = 0;
switch (sCutscenePhase) {
case 6:
sp34 = spawn_object(gCurrentObject, MODEL_LAKITU, bhvBeginningLakitu);
break;
case 5:
sp34 = spawn_object(gCurrentObject, MODEL_PEACH, bhvBeginningPeach);
break;
case 7:
func_8029B964(gCurrentObject, 0, 205, 500, 0x1000, 0x6000, -0x1E00, 25, MODEL_BIRDS,
bhvEndBirds1);
func_8029B964(gCurrentObject, 0, 205, 800, 0x1800, 0x6000, -0x1400, 35, MODEL_BIRDS,
bhvEndBirds1);
func_8029B964(gCurrentObject, -100, 300, 500, 0x800, 0x6000, 0, 25, MODEL_BIRDS,
bhvEndBirds1);
func_8029B964(gCurrentObject, 100, -200, 800, 0, 0x4000, 0x1400, 45, MODEL_BIRDS,
bhvEndBirds1);
func_8029B964(gCurrentObject, -80, 300, 350, 0x1800, 0x5000, 0xA00, 35, MODEL_BIRDS,
bhvEndBirds1);
func_8029B964(gCurrentObject, -300, 300, 500, 0x800, 0x6000, 0x2800, 25, MODEL_BIRDS,
bhvEndBirds1);
func_8029B964(gCurrentObject, -400, -200, 800, 0, 0x4000, -0x1400, 45, MODEL_BIRDS,
bhvEndBirds1);
break;
case 9:
func_8029B964(gCurrentObject, 50, 205, 500, 0x1000, 0x6000, 0, 35, MODEL_BIRDS,
bhvEndBirds1);
func_8029B964(gCurrentObject, 0, 285, 800, 0x1800, 0x6000, 0, 35, MODEL_BIRDS,
bhvEndBirds1);
break;
case 8:
func_8029B964(gCurrentObject, -100, -100, -700, 0, 0, -0xF00, 25, MODEL_BIRDS,
bhvEndBirds2);
func_8029B964(gCurrentObject, -250, 255, -200, 0, 0, -0x1400, 25, MODEL_BIRDS,
bhvEndBirds2);
func_8029B964(gCurrentObject, -100, 155, -600, 0, 0, -0x500, 35, MODEL_BIRDS,
bhvEndBirds2);
func_8029B964(gCurrentObject, 250, 200, -1200, 0, 0, -0x700, 25, MODEL_BIRDS,
bhvEndBirds2);
func_8029B964(gCurrentObject, -250, 255, -700, 0, 0, 0, 25, MODEL_BIRDS, bhvEndBirds2);
break;
}
sCutscenePhase = 0;
}
}

View File

@ -166,7 +166,7 @@ void ActionKingBobomb7(void) {
obj_spawn_star_at_y_offset(2000.0f, 4500.0f, -4500.0f, 200.0f);
#else
o->oPosY += 100.0f;
CreateStar(2000.0f, 4500.0f, -4500.0f);
create_star(2000.0f, 4500.0f, -4500.0f);
#endif
o->oAction = 8;
}
@ -291,7 +291,7 @@ void bhv_king_bobomb_loop(void) {
f32 sp34 = 20.0f;
f32 sp30 = 50.0f;
UNUSED u8 pad[8];
o->oUnk190 |= 4;
o->oInteractionSubtype |= INT_SUBTYPE_GRABS_MARIO;
switch (o->oHeldState) {
case HELD_FREE:
func_802A7748();

View File

@ -361,7 +361,7 @@ void bhv_klepto_update(void) {
save_file_clear_flags(SAVE_FLAG_CAP_ON_KLEPTO);
spawn_object(o, MODEL_MARIOS_CAP, bhvNormalCap);
} else if (o->oAnimState == KLEPTO_ANIM_STATE_HOLDING_STAR) {
CreateStar(-5550.0f, 300.0f, -930.0f);
create_star(-5550.0f, 300.0f, -930.0f);
}
o->oAnimState = KLEPTO_ANIM_STATE_HOLDING_NOTHING;

View File

@ -737,7 +737,7 @@ static void koopa_the_quick_act_after_race(void) {
o->oTimer = 0;
}
} else if (o->parentObj->oKoopaRaceEndpointRaceStatus != 0) {
CreateStar(sKoopaTheQuickProperties[o->oKoopaTheQuickRaceIndex].starPos[0],
create_star(sKoopaTheQuickProperties[o->oKoopaTheQuickRaceIndex].starPos[0],
sKoopaTheQuickProperties[o->oKoopaTheQuickRaceIndex].starPos[1],
sKoopaTheQuickProperties[o->oKoopaTheQuickRaceIndex].starPos[2]);

View File

@ -1,54 +0,0 @@
// little_cage.c.inc
void bhv_little_cage_2_loop(void) {
switch (o->oAction) {
case 0:
if (o->oTimer == 0)
if (func_802A377C(1)
& save_file_get_star_flags(gCurrSaveFileNum - 1, gCurrCourseNum - 1))
obj_set_model(MODEL_TRANSPARENT_STAR);
copy_object_pos(o, o->parentObj);
copy_object_behavior_params(o, o->parentObj);
if (o->parentObj->oAction == 3)
o->oAction++;
break;
case 1:
mark_object_for_deletion(o);
func_802A3004();
spawn_triangle_break_particles(20, 138, 0.7, 3);
CreateStar(2500.0f, -1200.0f, 1300.0f);
break;
}
o->oFaceAngleYaw += 0x400;
}
void ActionLittleCage0(void) {
if (o->oUnknownUnk88 != 0)
o->oAction = 1;
load_object_collision_model();
}
void ActionLittleCage1(void) {
if (o->oUnknownUnk88 != 1)
o->oAction = 2;
o->oMoveAngleYaw += 0x800;
load_object_collision_model();
}
void ActionLittleCage2(void) {
obj_update_floor_and_walls();
obj_move_standard(78);
if (o->oMoveFlags & (8 | 1))
o->oAction = 3;
}
void ActionLittleCage3(void) {
obj_hide();
}
void (*sLittleCageActions[])(void) = { ActionLittleCage0, ActionLittleCage1, ActionLittleCage2,
ActionLittleCage3 };
void bhv_little_cage_loop(void) {
obj_call_action_function(sLittleCageActions);
}

View File

@ -1,5 +1,12 @@
// lll_octagonal_rotating_mesh.c.inc
s16 D_8032F860[] = { 2, 30, 0x4000, 0, 1, 220, 900, 30, 1, 30, 0, -30, 2,
30, -0x4000, 0, 1, 220, 900, 30, 1, 30, 0, -30, 3, 0 };
s16 D_8032F894[] = { 4, 0, 0, 0, 1, 475, 900, 30, 1, 30, 0, -30, 2,
30, 0x8000, 0, 1, 475, 900, 30, 1, 30, 0, -30, 3, 0 };
s16 *D_8032F8C8[] = { D_8032F860, D_8032F894 };
s32 func_802BB414(s16 *a0, s32 a1) {
switch (a0[a1]) {
case 4:

View File

@ -82,7 +82,7 @@ void bhv_manta_ray_loop(void) {
func_802F5FD8();
if (o->oUnk1AC_S32 == 5) {
func_802A3004();
CreateStar(-3180.0f, -3600.0f, 120.0f);
create_star(-3180.0f, -3600.0f, 120.0f);
o->oAction = 1;
}
break;

Some files were not shown because too many files have changed in this diff Show More