diff --git a/Makefile b/Makefile index 0891f78410..a65a8713d2 100644 --- a/Makefile +++ b/Makefile @@ -156,10 +156,17 @@ build/src/libultra/rmon/%.o: OPTFLAGS := -O2 build/src/libultra/flash/%.o: OPTFLAGS := -g build/src/libultra/flash/%.o: MIPS_VERSION := -mips1 +build/src/code/audio/%.o: OPTFLAGS := -O2 + # file flags build/src/boot_O2_g3/fault.o: CFLAGS += -trapuv build/src/boot_O2_g3/fault_drawer.o: CFLAGS += -trapuv +build/src/code/jpegutils.o: OPTFLAGS := -O2 +build/src/code/jpegdecoder.o: OPTFLAGS := -O2 +build/src/code/jpegutils.o: CC := $(CC_OLD) +build/src/code/jpegdecoder.o: CC := $(CC_OLD) + build/src/libultra/libc/ll.o: OPTFLAGS := -O1 build/src/libultra/libc/ll.o: MIPS_VERSION := -mips3 -32 build/src/libultra/libc/llcvt.o: OPTFLAGS := -O1 @@ -172,6 +179,7 @@ build/src/boot_O2_g3/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $( build/src/libultra/%.o: CC := python3 tools/asm-processor/build.py $(CC_OLD) -- $(AS) $(ASFLAGS) -- build/src/code/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- +build/src/code/audio/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- build/src/overlays/actors/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- build/src/overlays/effects/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- diff --git a/assets/xml/misc/locerrmsg.xml b/assets/xml/misc/locerrmsg.xml new file mode 100644 index 0000000000..d6f8bfdaaa --- /dev/null +++ b/assets/xml/misc/locerrmsg.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/assets/xml/misc/memerrmsg.xml b/assets/xml/misc/memerrmsg.xml new file mode 100644 index 0000000000..92c15f4746 --- /dev/null +++ b/assets/xml/misc/memerrmsg.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/include/PR/abi.h b/include/PR/abi.h index 63d6b0f99a..49d5397628 100644 --- a/include/PR/abi.h +++ b/include/PR/abi.h @@ -1,7 +1,8 @@ -#ifndef _ABI_H_ -#define _ABI_H_ +#ifndef ULTRA64_ABI_H +#define ULTRA64_ABI_H /* Audio commands: */ +/* #define A_SPNOOP 0 #define A_ADPCM 1 #define A_CLEARBUFF 2 @@ -18,12 +19,37 @@ #define A_INTERLEAVE 13 #define A_POLEF 14 #define A_SETLOOP 15 +*/ +#define A_SPNOOP 0 +#define A_ADPCM 1 +#define A_CLEARBUFF 2 +#define A_UNK3 3 +#define A_ADDMIXER 4 +#define A_RESAMPLE 5 +#define A_RESAMPLE_ZOH 6 +#define A_FILTER 7 +#define A_SETBUFF 8 +#define A_DUPLICATE 9 +#define A_DMEMMOVE 10 +#define A_LOADADPCM 11 +#define A_MIXER 12 +#define A_INTERLEAVE 13 +#define A_HILOGAIN 14 +#define A_SETLOOP 15 +#define A_INTERL 17 +#define A_ENVSETUP1 18 +#define A_ENVMIXER 19 +#define A_LOADBUFF 20 +#define A_SAVEBUFF 21 +#define A_ENVSETUP2 22 +#define A_S8DEC 23 +#define A_UNK19 25 #define ACMD_SIZE 32 + /* * Audio flags */ - #define A_INIT 0x01 #define A_CONTINUE 0x00 #define A_LOOP 0x02 @@ -254,138 +280,252 @@ typedef short ENVMIX_STATE[40]; * Macros to assemble the audio command list */ -#define aADPCMdec(pkt, f, s) \ - { \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_ADPCM, 24, 8) | _SHIFTL(f, 16, 8); \ - _a->words.w1 = (unsigned int)(s); \ - } +#define aADPCMdec(pkt, f, s) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_ADPCM, 24, 8) | _SHIFTL(f, 16, 8); \ + _a->words.w1 = (unsigned int)(s); \ +} -#define aPoleFilter(pkt, f, g, s) \ - { \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_POLEF, 24, 8) | _SHIFTL(f, 16, 8) | \ - _SHIFTL(g, 0, 16)); \ - _a->words.w1 = (unsigned int)(s); \ - } +#define aPoleFilter(pkt, f, g, s) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_POLEF, 24, 8) | _SHIFTL(f, 16, 8) | \ + _SHIFTL(g, 0, 16)); \ + _a->words.w1 = (unsigned int)(s); \ +} + +#define aHiLoGain(pkt, gain, count, dmem, a4) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_HILOGAIN, 24, 8) | \ + _SHIFTL(gain, 16, 8) | _SHIFTL(count, 0, 16)); \ + _a->words.w1 = _SHIFTL(dmem, 16, 16) | _SHIFTL(a4, 0, 16); \ +} + +#define aUnkCmd3(pkt, a1, a2, a3) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_UNK3, 24, 8) | _SHIFTL(a3, 0, 16); \ + _a->words.w1 = _SHIFTL(a1, 16, 16) | _SHIFTL(a2, 0, 16); \ +} + +#define aUnkCmd19(pkt, a1, a2, a3, a4) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_UNK19, 24, 8) | _SHIFTL(a1, 16, 8) | \ + _SHIFTL(a2, 0, 16)); \ + _a->words.w1 = _SHIFTL(a3, 16, 16) | _SHIFTL(a4, 0, 16); \ +} + +#define aS8Dec(pkt, a1, a2) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_S8DEC, 24, 8) | _SHIFTL(a1, 16, 8); \ + _a->words.w1 = (unsigned int)(a2); \ +} #define aClearBuffer(pkt, d, c) \ - { \ +{ \ Acmd *_a = (Acmd *)pkt; \ \ _a->words.w0 = _SHIFTL(A_CLEARBUFF, 24, 8) | _SHIFTL(d, 0, 24); \ _a->words.w1 = (unsigned int)(c); \ - } +} -#define aEnvMixer(pkt, f, s) \ - { \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_ENVMIXER, 24, 8) | _SHIFTL(f, 16, 8); \ - _a->words.w1 = (unsigned int)(s); \ - } +#define aEnvMixer(pkt, dmemi, count, swapLR, x0, x1, x2, x3, m, bits) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (bits | _SHIFTL(dmemi >> 4, 16, 8) | \ + _SHIFTL(count, 8, 8) | _SHIFTL(swapLR, 4, 1) | \ + _SHIFTL(x0, 3, 1) | _SHIFTL(x1, 2, 1) | \ + _SHIFTL(x2, 1, 1) | _SHIFTL(x3, 0, 1)); \ + _a->words.w1 = (unsigned int)(m); \ +} -#define aInterleave(pkt, l, r) \ - { \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_INTERLEAVE, 24, 8); \ - _a->words.w1 = _SHIFTL(l, 16, 16) | _SHIFTL(r, 0, 16); \ - } +#define aInterleave(pkt, o, l, r, c) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_INTERLEAVE, 24, 8) | \ + _SHIFTL(c >> 4, 16, 8) | _SHIFTL(o, 0, 16)); \ + _a->words.w1 = _SHIFTL(l, 16, 16) | _SHIFTL(r, 0, 16); \ +} -#define aLoadBuffer(pkt, s) \ - { \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_LOADBUFF, 24, 8); \ - _a->words.w1 = (unsigned int)(s); \ - } +#define aInterl(pkt, dmemi, dmemo, count) \ +{ \ + Acmd *_a = (Acmd*)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_INTERL, 24, 8) | \ + _SHIFTL(count, 0, 16)); \ + _a->words.w1 = _SHIFTL(dmemi, 16, 16) | _SHIFTL(dmemo, 0, 16); \ +} -#define aMix(pkt, f, g, i, o) \ - { \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_MIXER, 24, 8) | _SHIFTL(f, 16, 8) | \ - _SHIFTL(g, 0, 16)); \ - _a->words.w1 = _SHIFTL(i, 16, 16) | _SHIFTL(o, 0, 16); \ - } +#define aLoadBuffer(pkt, s, d, c) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_LOADBUFF, 24, 8) | \ + _SHIFTL((c) >> 4, 16, 8) | _SHIFTL(d, 0, 16); \ + _a->words.w1 = (unsigned int)(s); \ +} -#define aPan(pkt, f, d, s) \ - { \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_PAN, 24, 8) | _SHIFTL(f, 16, 8) | \ - _SHIFTL(d, 0, 16)); \ - _a->words.w1 = (unsigned int)(s); \ - } +#define aMix(pkt, f, g, i, o) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_MIXER, 24, 8) | _SHIFTL(f, 16, 8) | \ + _SHIFTL(g, 0, 16)); \ + _a->words.w1 = _SHIFTL(i, 16, 16) | _SHIFTL(o, 0, 16); \ +} -#define aResample(pkt, f, p, s) \ - { \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_RESAMPLE, 24, 8) | _SHIFTL(f, 16, 8) | \ - _SHIFTL(p, 0, 16)); \ - _a->words.w1 = (unsigned int)(s); \ - } +#define aPan(pkt, f, d, s) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_PAN, 24, 8) | _SHIFTL(f, 16, 8) | \ + _SHIFTL(d, 0, 16)); \ + _a->words.w1 = (unsigned int)(s); \ +} -#define aSaveBuffer(pkt, s) \ - { \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_SAVEBUFF, 24, 8); \ - _a->words.w1 = (unsigned int)(s); \ - } +#define aResample(pkt, f, p, s) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_RESAMPLE, 24, 8) | \ + _SHIFTL(f, 16, 8) | _SHIFTL(p, 0, 16)); \ + _a->words.w1 = (unsigned int)(s); \ +} -#define aSegment(pkt, s, b) \ - { \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_SEGMENT, 24, 8); \ - _a->words.w1 = _SHIFTL(s, 24, 8) | _SHIFTL(b, 0, 24); \ - } +#define aSaveBuffer(pkt, s, d, c) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_SAVEBUFF, 24, 8) | \ + _SHIFTL((c) >> 4, 16, 8) | _SHIFTL(s, 0, 16); \ + _a->words.w1 = (unsigned int)(d); \ +} + +#define aSegment(pkt, s, b) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_SEGMENT, 24, 8); \ + _a->words.w1 = _SHIFTL(s, 24, 8) | _SHIFTL(b, 0, 24); \ +} #define aSetBuffer(pkt, f, i, o, c) \ - { \ +{ \ Acmd *_a = (Acmd *)pkt; \ \ _a->words.w0 = (_SHIFTL(A_SETBUFF, 24, 8) | _SHIFTL(f, 16, 8) | \ _SHIFTL(i, 0, 16)); \ - _a->words.w1 = _SHIFTL(c, 0, 16) | _SHIFTL(o, 16, 16); \ - } + _a->words.w1 = _SHIFTL(o, 16, 16) | _SHIFTL(c, 0, 16); \ +} -#define aSetVolume(pkt, f, v, t, r) \ - { \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_SETVOL, 24, 8) | _SHIFTL(f, 16, 16) | \ - _SHIFTL(v, 0, 16)); \ - /* had to change this otherwise it doesn't want to match */ \ - _a->words.w1 = (unsigned int)(r); /*_SHIFTL(r, 0, 16)|_SHIFTL(t, 16, 16) ;*/ \ - } +#define aSetVolume(pkt, f, v, t, r) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_SETVOL, 24, 8) | _SHIFTL(f, 16, 16) | \ + _SHIFTL(v, 0, 16)); \ + _a->words.w1 = _SHIFTL(r, 0, 16) | _SHIFTL(t, 16, 16); \ +} -#define aSetLoop(pkt, a) \ - { \ - Acmd *_a = (Acmd *)pkt; \ - _a->words.w0 = _SHIFTL(A_SETLOOP, 24, 8); \ - _a->words.w1 = (unsigned int)(a); \ - } +#define aSetVolume32(pkt, f, v, tr) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_SETVOL, 24, 8) | _SHIFTL(f, 16, 16) | \ + _SHIFTL(v, 0, 16)); \ + _a->words.w1 = (unsigned int)(tr); \ +} -#define aDMEMMove(pkt, i, o, c) \ - { \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_DMEMMOVE, 24, 8) | _SHIFTL(i, 0, 24); \ - _a->words.w1 = _SHIFTL(o, 16, 16) | _SHIFTL(c, 0, 16); \ - } +#define aSetLoop(pkt, a) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_SETLOOP, 24, 8); \ + _a->words.w1 = (unsigned int)(a); \ +} + +#define aDMEMMove(pkt, i, o, c) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_DMEMMOVE, 24, 8) | _SHIFTL(i, 0, 24); \ + _a->words.w1 = _SHIFTL(o, 16, 16) | _SHIFTL(c, 0, 16); \ +} #define aLoadADPCM(pkt, c, d) \ - { \ +{ \ Acmd *_a = (Acmd *)pkt; \ \ _a->words.w0 = _SHIFTL(A_LOADADPCM, 24, 8) | _SHIFTL(c, 0, 24); \ _a->words.w1 = (unsigned int)d; \ - } +} -#endif /* !_ABI_H_ */ + + +#define aEnvSetup1(pkt, a, b, c, d) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_ENVSETUP1, 24, 8) | \ + _SHIFTL(a, 16, 8) | _SHIFTL(b, 0, 16)); \ + _a->words.w1 = _SHIFTL(c, 16, 16) | _SHIFTL(d, 0, 16); \ +} + +#define aEnvSetup2(pkt, volLeft, volRight) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_ENVSETUP2, 24, 8); \ + _a->words.w1 = _SHIFTL(volLeft, 16, 16) | \ + _SHIFTL(volRight, 0, 16); \ +} + +#define aFilter(pkt, f, countOrBuf, addr) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_FILTER, 24, 8) | _SHIFTL(f, 16, 8) | \ + _SHIFTL(countOrBuf, 0, 16); \ + _a->words.w1 = (unsigned int)(addr); \ +} + +#define aDuplicate(pkt, count, dmemi, dmemo, a4) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_DUPLICATE, 24, 8) | \ + _SHIFTL(count, 16, 8) | _SHIFTL(dmemi, 0, 16)); \ + _a->words.w1 = _SHIFTL(dmemo, 16, 16) | _SHIFTL(a4, 0, 16); \ +} + +#define aAddMixer(pkt, count, dmemi, dmemo, a4) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_ADDMIXER, 24, 8) | \ + _SHIFTL(count >> 4, 16, 8) | _SHIFTL(a4, 0, 16)); \ + _a->words.w1 = _SHIFTL(dmemi, 16, 16) | _SHIFTL(dmemo, 0, 16); \ +} + +#define aResampleZoh(pkt, pitch, pitchAccu) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_RESAMPLE_ZOH, 24, 8) | \ + _SHIFTL(pitch, 0, 16)); \ + _a->words.w1 = _SHIFTL(pitchAccu, 0, 16); \ +} + +#endif /* ULTRA64_ABI_H */ diff --git a/include/PR/pfs.h b/include/PR/pfs.h index 135a6b56c7..596fafbfee 100644 --- a/include/PR/pfs.h +++ b/include/PR/pfs.h @@ -134,6 +134,7 @@ typedef struct { /* 0x101 */ u8 map[PFS_INODE_DIST_MAP]; } __OSInodeCache; // size = 0x202 +s32 __osCheckPackId(OSPfs* pfs, __OSPackId* check); s32 __osGetId(OSPfs* pfs); s32 osPfsChecker(OSPfs* pfs); diff --git a/include/PR/sched.h b/include/PR/sched.h new file mode 100644 index 0000000000..d0aac1d0e7 --- /dev/null +++ b/include/PR/sched.h @@ -0,0 +1,38 @@ +#ifndef SCHED_H +#define SCHED_H + +#include "PR/ultratypes.h" +#include "ultra64/vi.h" +#include "ultra64/sptask.h" + +#define OS_SC_NEEDS_RDP 0x0001 +#define OS_SC_NEEDS_RSP 0x0002 +#define OS_SC_DRAM_DLIST 0x0004 +#define OS_SC_PARALLEL_TASK 0x0010 +#define OS_SC_LAST_TASK 0x0020 +#define OS_SC_SWAPBUFFER 0x0040 + +#define OS_SC_RCP_MASK 0x0003 +#define OS_SC_TYPE_MASK 0x0007 + +#define OS_SC_DP 0x0001 +#define OS_SC_SP 0x0002 +#define OS_SC_YIELD 0x0010 +#define OS_SC_YIELDED 0x0020 + +typedef struct OSScTask { + /* 0x00 */ struct OSScTask* next; + /* 0x04 */ u32 state; + /* 0x08 */ u32 flags; + /* 0x0C */ void* framebuffer; + /* 0x10 */ OSTask list; + /* 0x50 */ OSMesgQueue* msgQ; + /* 0x54 */ OSMesg msg; +} OSScTask; // size = 0x58 + +typedef struct { + /* 0x0 */ s16 type; + /* 0x2 */ u8 misc[30]; +} OSScMsg; + +#endif diff --git a/include/bgm.h b/include/bgm.h index 4cd19c957a..c3ac3b1d10 100644 --- a/include/bgm.h +++ b/include/bgm.h @@ -3,4 +3,134 @@ #define NA_BGM_STOP 0x100000FF +#define NA_BGM_GENERAL_SFX 0x00 // General Sound Effects +#define NA_BGM_NATURE_AMBIENCE 0x01 // Ambient background noises +#define NA_BGM_TERMINA_FIELD 0x02 // Termina Field +#define NA_BGM_CHASE 0x03 // Forest Chase +#define NA_BGM_MAJORAS_THEME 0x04 // Majora's Theme "STALKID" +#define NA_BGM_CLOCK_TOWER 0x05 // The Clock Tower +#define NA_BGM_STONE_TOWER_TEMPLE 0x06 // Stone Tower Temple +#define NA_BGM_INV_STONE_TOWER_TEMPLE 0x07 // Stone Tower Temple Inverted +#define NA_BGM_FAILURE_0 0x08 // Missed Event 1 +#define NA_BGM_FAILURE_1 0x09 // Title +#define NA_BGM_HAPPY_MASK_SALESMAN 0x0A // Mask Salesman "OMENYA" +#define NA_BGM_SONG_OF_HEALING 0x0B // Song of Healing "DEMO_CURE" +#define NA_BGM_SWAMP_REGION 0x0C // Southern Swamp and Woodfall "DAMP_AREA" +#define NA_BGM_ALIEN_INVASION 0x0D // Ghost Attack "UFO" +#define NA_BGM_SWAMP_CRUISE 0x0E // Mini Game "JUNGLE_CREWS" +#define NA_BGM_SHARPS_CURSE 0x0F // Sharp's Curse +#define NA_BGM_GREAT_BAY_REGION 0x10 // Great Bay Coast "SEA_AREA" +#define NA_BGM_IKANA_REGION 0x11 // Ikana Valley +#define NA_BGM_DEKU_KING 0x12 // Court of the Deku King +#define NA_BGM_MOUNTAIN_REGION 0x13 // Mountain Village "SNOW_AREA" +#define NA_BGM_PIRATES_FORTRESS 0x14 // Pirates' Fortress "PIRATE_AREA" +#define NA_BGM_CLOCK_TOWN_DAY_1 0x15 // Clock Town Day 1 This song's filename is dummied out in MM3D "DUMMY_21" +#define NA_BGM_CLOCK_TOWN_DAY_2 0x16 // Clock Town Day 2 his song's filename is dummied out in MM3D "DUMMY_22" +#define NA_BGM_CLOCK_TOWN_DAY_3 0x17 // Clock Town Day 3 This song's filename is dummied out in MM3D "DUMMY_23" +#define NA_BGM_FILE_SELECT 0x18 // This song has no track name, as it's a duplicate of the Fairy's Fountain +#define NA_BGM_CLEAR_EVENT 0x19 // Event Clear +#define NA_BGM_ENEMY 0x1A // Battle +#define NA_BGM_BOSS 0x1B // Boss Battle +#define NA_BGM_WOODFALL_TEMPLE 0x1C // Woodfall Temple "JUNGLE_DUNGEON" +#define NA_BGM_MARKET 0x1D // Clock Town Day 1 Duplicate of #15. Interesting filename in MM3D. ✘ +#define NA_BGM_OPENING 0x1E // Forest Ambush +#define NA_BGM_INSIDE_A_HOUSE 0x1F // House "LINK_HOUSE" +#define NA_BGM_GAME_OVER 0x20 // Game Over +#define NA_BGM_CLEAR_BOSS 0x21 // Boss Clear +#define NA_BGM_GET_ITEM 0x22 // Item Catch +#define NA_BGM_GATE_OPEN 0x23 // Clock Town Day 2 Duplicate of #16. In MM3D, it shares its filename with the Door of Time song from OoT +#define NA_BGM_GET_HEART 0x24 // Complete a Heart Piece +#define NA_BGM_MINI_GAME_2 0x25 // Playing Minigame +#define NA_BGM_GORON_RACE 0x26 // Goron Race +#define NA_BGM_MUSIC_BOX_HOUSE 0x27 // Music Box House "ORGEL_HOUSE" +#define NA_BGM_FAIRY_FOUNTAIN 0x28 // Fairy's Fountain In MM3D, it shares its filename with the Door of Time song from OoT "GODESS" +#define NA_BGM_ZELDAS_LULLABY 0x29 // Zelda's Lullaby "HIME" +#define NA_BGM_ROSA_SISTERS 0x2A // Rosa Sisters' Dance "SISTER_DANCER" +#define NA_BGM_OPEN_CHEST 0x2B // Open Chest "OPEN_TRE_BOX" +#define NA_BGM_MARINE_RESEARCH_LAB 0x2C // Marine Research Laboratory "DRUGSTORE" +#define NA_BGM_GIANTS_THEME 0x2D // The Four Giants "KYOJIN_ROOM" +#define NA_BGM_SONG_OF_STORMS 0x2E // Guru-Guru's Song "FUSHA" +#define NA_BGM_ROMANI_RANCH 0x2F // Romani Ranch "RONRON" +#define NA_BGM_GORON_VILLAGE 0x30 // Goron Village +#define NA_BGM_MAYORS_OFFICE 0x31 // Mayor Dotour "MEETING" +#define NA_BGM_OCA_EPONA 0x32 // Ocarina Epona's Song +#define NA_BGM_OCA_SUNS 0x33 // Ocarina Sun's Song +#define NA_BGM_OCA_TIME 0x34 // Ocarina Song of Time "TIME_NORMAL" +#define NA_BGM_OCA_STORM 0x35 // Ocarina Song of Storms +#define NA_BGM_ZORA_HALL 0x36 // Zora Hall +#define NA_BGM_GET_NEW_MASK 0x37 // A New Mask +#define NA_BGM_MINI_BOSS 0x38 // Mini Boss "MIDDLE_BOSS" +#define NA_BGM_GET_SMALL_ITEM 0x39 // Small Item Catch "S_ITEM_GET" +#define NA_BGM_ASTRAL_OBSERVATORY 0x3A // Astral Observatory "TENMONDAI" +#define NA_BGM_CAVERN 0x3B // Clock Town Cavern "NORMAL_DUNGEON" +#define NA_BGM_MILK_BAR 0x3C // Milk Bar Latte +#define NA_BGM_ZELDA_APPEAR 0x3D // Meet Zelda (OoT) +#define NA_BGM_SARIAS_SONG 0x3E // Saria's Theme Song from OoT "MAYOIMORI" +#define NA_BGM_GORON_GOAL 0x3F // Goron Race Goal +#define NA_BGM_HORSE 0x40 // Gorman Race +#define NA_BGM_HORSE_GOAL 0x41 // Race Finish +#define NA_BGM_INGO 0x42 // Gorman Bros. "INGO" +#define NA_BGM_KOTAKE_POTION_SHOP 0x43 // Kotake's Potion Shop "KOTAKE_KOUME" +#define NA_BGM_SHOP 0x44 // Store +#define NA_BGM_OWL 0x45 // Gaebora's Theme +#define NA_BGM_MINI_GAME 0x46 // Target Practice +#define NA_BGM_OCA_SOARING 0x47 // Ocarina Song of Soaring "OCA_BIGWING" +#define NA_BGM_OCA_HEALING 0x48 // Ocarina Song of Healing "OCA_CURE" +#define NA_BGM_INVERTED_SONG_OF_TIME 0x49 // Inverted Song of Time "_SPEED" +#define NA_BGM_SONG_OF_DOUBLE_TIME 0x4A // Song of Double Time "TIME_JUMP" +#define NA_BGM_SONATA_OF_AWAKENING 0x4B // Sonata of Awakening "DEMO_AWAKING" +#define NA_BGM_GORON_LULLABY 0x4C // Goron Lullaby "DEMO_LULLABY" +#define NA_BGM_NEW_WAVE_BOSSA_NOVA 0x4D // New Wave Bossa Nova "DEMO_TIDE" +#define NA_BGM_ELEGY_OF_EMPTINESS 0x4E // Elegy of Emptiness "DEMO_SHELL" +#define NA_BGM_OATH_TO_ORDER 0x4F // Oath to Order "DEMO_PLEDGE" +#define NA_BGM_SWORD_TRAINING_HALL 0x50 // Sword Training "EXERCISE_HALL" +#define NA_BGM_GORON_LULLABY_INTRO 0x51 // Ocarina Goron Lullaby Intro "DEMO_LULLABY_HALF" +#define NA_BGM_OCA_FAIRY 0x52 // New Song "OCA_YOUSEI" +#define NA_BGM_BREMEN_MARCH 0x53 // Bremen March "FACEMASK" +#define NA_BGM_BALLAD_OF_THE_WIND_FISH 0x54 // Quartet performed in on the milk bar stage "QUARTET" +#define NA_BGM_SONG_OF_SOARING 0x55 // Song of Soaring "WING_WARP" +#define NA_BGM_MILK_BAR_DUPLICATE 0x56 // Milk Bar Latte Duplicate. "MILK_BAR_DUMMY" +#define NA_BGM_FINAL_HOURS 0x57 // Final Hours "TIME_LIMIT" +#define NA_BGM_MIKAU_RIFF 0x58 // Mikau's Tale "MIKAU_LIFF" +#define NA_BGM_MIKAU_FINALE 0x59 // A single guitar chord. "MIKAU_FIN" +#define NA_BGM_FROG_SONG 0x5A // Don Gero's Song +#define NA_BGM_OCA_SONATA 0x5B // Ocarina Sonata of Awakening "OCA_AWAKING" +#define NA_BGM_OCA_LULLABY 0x5C // Ocarina Goron Lullaby "OCA_LULLABY" +#define NA_BGM_OCA_NEW_WAVE 0x5D // Ocarina New Wave Bossa Nova "OCA_TIDE" +#define NA_BGM_OCA_ELEGY 0x5E // Ocarina Elegy of Emptiness "OCA_SHELL" +#define NA_BGM_OCA_OATH 0x5F // Ocarina Oath to Order "OCA_PLEDGE" +#define NA_BGM_MAJORAS_LAIR 0x60 // "LAST_DUNGEON" +#define NA_BGM_OCA_LULLABY_INTRO 0x61 // "OCA_LULLABY_HALF" +#define NA_BGM_OCA_GUITAR_BASS_SESSION 0x62 // Bass and Guitar Session "OCA_SESSION" +#define NA_BGM_PIANO_SESSION 0x63 // Piano Solo "DEMO_SESSION" +#define NA_BGM_INDIGO_GO_SESSION 0x64 // The Indigo-Go's Rehearsal "ALLPART_SESSION" +#define NA_BGM_SNOWHEAD_TEMPLE 0x65 // Snowhead Temple "SILVER_DUNGEON" +#define NA_BGM_GREAT_BAY_TEMPLE 0x66 // Great Bay Temple "DEEPBLUE_DUNGEON" +#define NA_BGM_NEW_WAVE_SAXOPHONE 0x67 // "DEMO_TIDE_SAX" +#define NA_BGM_NEW_WAVE_VOCAL 0x68 // "DEMO_TIDE_VOCAL" +#define NA_BGM_MAJORAS_WRATH 0x69 // Majora's Wrath "MUJURA_1" +#define NA_BGM_MAJORAS_INCARNATION 0x6A // Majora's Incarnation "MUJURA_2" +#define NA_BGM_MAJORAS_MASK 0x6B // Majora's Mask Battle "MUJURA_3" +#define NA_BGM_BASS_PLAY 0x6C // Bass Practice "BASS_PLAY" +#define NA_BGM_DRUMS_PLAY 0x6D // Drums Practice "DRUMS_PLAY" +#define NA_BGM_PIANO_PLAY 0x6E // Piano Practice "PIANO_PLAY" +#define NA_BGM_IKANA_CASTLE 0x6F // Ikana Castle +#define NA_BGM_GATHERING_GIANTS 0x70 // Calling the Four Giants +#define NA_BGM_KAMARO_DANCE 0x71 // Kamaro's Dance "CAMARO_DANCE" +#define NA_BGM_CREMIA_CARRIAGE 0x72 // Cremia's Carriage "DONKEY_CART" +#define NA_BGM_KEATON_QUIZ 0x73 // Keaton "QUIZ" +#define NA_BGM_END_CREDITS_1 0x74 // The End/Credits I "END_DEMO" +#define NA_BGM_OPENING_LOOP 0x75 // Forest Ambush (?) Duplicate. +#define NA_BGM_TITLE_THEME 0x76 // Title Screen +#define NA_BGM_DUNGEON_APPEAR 0x77 // Surfacing of Woodfall +#define NA_BGM_WOODFALL_CLEAR 0x78 // Woodfall Clear "PURIFICATION_0" +#define NA_BGM_SNOWHEAD_CLEAR 0x79 // Snowhead Clear "PURIFICATION_1" +#define NA_BGM_INTO_THE_MOON 0x7B // To the Moon +#define NA_BGM_GOODBYE_GIANT 0x7C // +#define NA_BGM_TATL_AND_TAEL 0x7D // Tatl and Tael "CHAT" +#define NA_BGM_MOONS_DESTRUCTION 0x7E // Moon's Destruction "MOON_VANISH" +#define NA_BGM_NO_MUSIC 0x7F // +#define NA_BGM_END_CREDITS_2 0x82 // The End/Credits II "STAFFROLL2" +#define NA_BGM_DISABLED 0xFFFF + #endif diff --git a/include/color.h b/include/color.h index 06cf639720..438d857ad9 100644 --- a/include/color.h +++ b/include/color.h @@ -3,6 +3,9 @@ #include "PR/ultratypes.h" +// For checking the alpha bit in an RGBA16 pixel +#define RGBA16_PIXEL_OPAQUE 1 + typedef struct { /* 0x0 */ u8 r; /* 0x1 */ u8 g; diff --git a/include/functions.h b/include/functions.h index 3c5e14ea11..521a87f405 100644 --- a/include/functions.h +++ b/include/functions.h @@ -15,9 +15,9 @@ s32 DmaMgr_FindDmaIndex(u32 vromAddr); const char* func_800809F4(u32 param_1); void DmaMgr_ProcessMsg(DmaRequest* req); void DmaMgr_ThreadEntry(void* arg); -s32 DmaMgr_SendRequestImpl(DmaRequest* request, void* vramStart, u32 vromStart, size_t size, UNK_TYPE4 unused, +s32 DmaMgr_SendRequestImpl(DmaRequest* request, void* vramStart, uintptr_t vromStart, size_t size, UNK_TYPE4 unused, OSMesgQueue* callback, void* callbackMesg); -s32 DmaMgr_SendRequest0(void* vramStart, u32 vromStart, size_t size); +s32 DmaMgr_SendRequest0(void* vramStart, uintptr_t vromStart, size_t size); void DmaMgr_Start(void); void DmaMgr_Stop(void); void* Yaz0_FirstDMA(void); @@ -71,7 +71,7 @@ void Fault_Wait5Seconds(void); void Fault_WaitForButtonCombo(void); void Fault_DrawMemDumpPage(const char* title, u32* addr, u32 param_3); void Fault_DrawMemDump(u32 pc, u32 sp, u32 unk0, u32 unk1); -void Fault_FindNextStackCall(u32** sp, u32** pc, u32** ra); +void Fault_FindNextStackCall(uintptr_t* spPtr, uintptr_t* pcPtr, uintptr_t* raPtr); void Fault_DrawStackTrace(OSThread* t, u32 flags); void osSyncPrintfStackTrace(OSThread* t, u32 flags); void Fault_ResumeThread(OSThread* t); @@ -96,12 +96,12 @@ void FaultDrawer_SetFontColor(u16 color); void FaultDrawer_SetCharPad(s8 padW, s8 padH); void FaultDrawer_SetCursor(s32 x, s32 y); void FaultDrawer_FillScreen(void); -FaultDrawer* FaultDrawer_FormatStringFunc(FaultDrawer* arg, const char* str, s32 count); +void* FaultDrawer_FormatStringFunc(void* arg, const char* str, size_t count); void FaultDrawer_VPrintf(const char* str, char* args); void FaultDrawer_Printf(const char* fmt, ...); void FaultDrawer_DrawText(s32 x, s32 y, const char* fmt, ...); void FaultDrawer_SetDrawerFB(void* fb, u16 w, u16 h); -void FaultDrawer_SetInputCallback(void* func); +void FaultDrawer_SetInputCallback(FaultDrawerCallback callback); void FaultDrawer_Init(void); void func_80084940(void); void func_80084968(void); @@ -356,8 +356,8 @@ const char* strchr(const char* __s, s32 __c); size_t strlen(const char* __s); void* memcpy(void* __dest, const void* __src, size_t __n); void osCreateMesgQueue(OSMesgQueue* mq, OSMesg* msq, s32 count); -void osInvalICache(void* vaddr, s32 nbytes); -void osInvalDCache(void* vaddr, s32 nbytes); +void osInvalICache(void* vaddr, size_t nbytes); +void osInvalDCache(void* vaddr, size_t nbytes); void __osTimerServicesInit(void); void __osTimerInterrupt(void); void __osSetTimerIntr(OSTime tim); @@ -533,7 +533,7 @@ void func_800AE5E4(GlobalContext* globalCtx, Color_RGBA8* arg1, s16 arg2, s16 ar void func_800AE778(GlobalContext* globalCtx, Color_RGBA8* color, s16 param_3, s16 param_4); void func_800AE8EC(GlobalContext* globalCtx); void func_800AE930(CollisionContext* colCtx, s32 param_2, Vec3f* param_3, f32 param_4, s16 param_5, CollisionPoly* param_6, s32 param_7); -void func_800AEF44(s32 arg0); +void func_800AEF44(s32 arg0); void EffectTireMark_InitParticle(EffTireMarkParticle* particle); void EffectTireMark_Init(EffTireMarkParams* params, EffTireMarkInit* init); void EffectTireMark_Destroy(EffTireMarkParams* params); @@ -912,219 +912,179 @@ void ActorOverlayTable_FaultPrint(void* arg0, void* arg1); // ActorOverlayTable_ void* ActorOverlayTable_FaultAddrConv(void* arg0, void* arg1); // ActorOverlayTable_FaultAddrConv void ActorOverlayTable_Init(void); // ActorOverlayTable_Init void ActorOverlayTable_Cleanup(void); // ActorOverlayTable_Cleanup -void BgCheck_PolygonLinkedListNodeInit(SSNode* node, s16* polyIndex, u16 next); -void BgCheck_PolygonLinkedListResetHead(u16* head); -void BgCheck_ScenePolygonListsNodeInsert(SSNodeList* list, u16* head, s16* polyIndex); -void BgCheck_PolygonLinkedListNodeInsert(DynaSSNodeList* list, u16* head, s16* polyIndex); -void BgCheck_PolygonLinkedListInit(GlobalContext* globalCtx, DynaSSNodeList* list); -void BgCheck_PolygonLinkedListAlloc(GlobalContext* globalCtx, DynaSSNodeList* list, u32 numNodes); -void BgCheck_PolygonLinkedListReset(DynaSSNodeList* list); -u16 BgCheck_AllocPolygonLinkedListNode(DynaSSNodeList* list); -void BgCheck_CreateVec3fFromVertex(Vec3s* vertex, Vec3f* vector); -void BgCheck_CreateVertexFromVec3f(Vec3s* vertex, Vec3f* vector); -float func_800BFD84(CollisionPoly* polygon, f32 param_2, f32 param_3); -s32 func_800BFDEC(CollisionPoly* param_1, CollisionPoly* param_2, u32* param_3, u32* param_4); -s32 BgCheck_PolygonGetMinY(CollisionPoly* polygons, Vec3s* vertices); -void BgCheck_PolygonGetNormal(CollisionPoly* polygon, f32* normalX, f32* normalY, f32* normalZ); -void func_800C0094(struct CollisionPoly* param_1, f32 xOffset, f32 yOffset, f32 zOffset, MtxF* matrix); -f32 func_800C01B8(CollisionPoly* param_1, Vec3f* param_2); -void BgCheck_CreateColTriParamsFromPolygon(CollisionPoly* polygon, Vec3s* vertices, TriNorm* tri); -void func_800C02C0(CollisionPoly* poly, s32 index, CollisionContext* colCtx, TriNorm* tri); -// void func_800C0340(CollisionPoly* param_1, Vec3s* param_2, UNK_TYPE4 param_3, UNK_TYPE4 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -// UNK_TYPE4 func_800C0474(CollisionPoly* param_1, Vec3s* param_2, UNK_TYPE4 param_3, UNK_TYPE4 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -// void func_800C0668(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_800C06A8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_800C074C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_800C07F0(void); -void BgCheck_PolygonCollidesWithSphere(CollisionPoly* polygon, Vec3s* verticies, Vec3f* pos, f32 readius); -void BgCheck_ScenePolygonListsInsertSorted(CollisionContext* colCtx, u16* head, CollisionPoly* polygons, Vec3s* vertices, s16 index); -void BgCheck_ScenePolygonListsInsert(StaticLookup* subdivision, CollisionContext* colCtx, CollisionPoly* polygons, Vec3s* vertices, s16 index); -// void func_800C0E74(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10); -// void func_800C10FC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9); -// void func_800C1238(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE1 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11); -// void func_800C12A4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9); -// void func_800C1B68(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8); -// void func_800C1D7C(void); -// void func_800C2008(void); -// void func_800C20F4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -// void func_800C2310(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE2 param_7, UNK_TYPE4 param_8); -// void func_800C2460(void); -// void func_800C2514(void); -// void func_800C25E0(void); -void BgCheck_GetPolyMinSubdivisions(CollisionContext* colCtx, Vec3f* min, s32* xSubdivision, s32* ySubdivision, s32* zSubdivision); -void BgCheck_GetPolyMaxSubdivisions(CollisionContext* colCtx, Vec3f* max, s32* xSubdivision, s32* ySubdivision, s32* zSubdivision); -void BgCheck_GetPolyMinMaxSubdivisions(CollisionContext* colCtx, Vec3s* vertices, CollisionPoly* polygons, s32* minX, s32* minY, s32* minZ, s32* maxX, s32* maxY, s32* maxZ, s16 index); -// UNK_TYPE4 func_800C2BE0(Vec3f* param_1, Vec3f* param_2, CollisionPoly* polygons, Vec3s* vertices, s16 index); -u32 BgCheck_SplitScenePolygonsIntoSubdivisions(CollisionContext* colCtx, GlobalContext* globalCtx, StaticLookup* subdivisions); -s32 BgCheck_GetIsDefaultSpecialScene(GlobalContext* globalCtx); -s32 BgCheck_GetSpecialSceneMaxMemory(s32 sceneId, u32* maxMemory); -void BgCheck_CalcSubdivisionSize(f32 min, s32 subdivisions, f32* max, f32* subdivisionSize, f32* inverseSubdivisionSize); -s32 BgCheck_GetSpecialSceneMaxObjects(GlobalContext* globalCtx, u32* maxNodes, u32* maxPolygons, u32* maxVertices); -void BgCheck_Init(CollisionContext* colCtx, GlobalContext* globalCtx, CollisionHeader* mesh); -void func_800C3C00(CollisionContext* colCtx, u32 param_2); -void func_800C3C14(CollisionContext* colCtx, u32 param_2); -CollisionHeader* BgCheck_GetActorMeshHeader(CollisionContext* colCtx, s32 index); -// void func_800C3C94(void); -f32 func_800C3D50(s32 arg0, CollisionContext* colCtx, s32 arg2, CollisionPoly** arg3, s32* arg4, Vec3f* pos, Actor* actor, s32 arg7, f32 arg8, s32 arg9); -// void func_800C3F40(void); -f32 func_800C3FA0(CollisionContext* colCtx, CollisionPoly** arg1, Vec3f* arg2); -f32 func_800C4000(GlobalContext* globalCtx, CollisionContext* colCtx, s32* arg2, Vec3f* arg3); -// void func_800C4058(void); -f32 func_800C40B4(CollisionContext* colCtx, CollisionPoly** arg1, s32* arg2, Vec3f* pos); -f32 func_800C411C(CollisionContext* colCtx, CollisionPoly** arg1, s32* arg2, Actor* actor, Vec3f* pos); -f32 func_800C4188(GlobalContext* globalCtx, CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos); -// void func_800C41E4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -// void func_800C4240(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -// void func_800C42A8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_800C4314(void); -// void func_800C43CC(void); -// void func_800C4488(void); -// void func_800C44F0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_800C455C(void); -s32 func_800C45C4(CollisionContext* colCtx, u32 arg1, Vec3f* arg2, Vec3f* arg3, Vec3f* arg4, f32 arg5, s32* arg6, s32* arg7, DynaPolyActor* arg8, f32 arg9, u8 arg10); -// void func_800C4C74(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -// void func_800C4CD8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8); -// void func_800C4D3C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9); -// void func_800C4DA4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9); -// void func_800C4E10(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8); -// void func_800C4F38(void); -// void func_800C4F84(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -// void func_800C4FD4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11); -// void func_800C5464(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_800C54AC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10); -// void func_800C5538(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10); -s32 func_800C55C4(CollisionContext* colCtx, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, CollisionPoly** arg4, u32 arg5, u32 arg6, u32 arg7, u32 arg8, u32* arg9); -// void func_800C5650(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11); -// void func_800C56E0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11, UNK_TYPE4 param_12); -s32 func_800C576C(CollisionContext* colCtx, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, CollisionPoly** arg4, u32 arg5, u32 arg6, u32 arg7, u32 arg8, u32* arg9); -// void func_800C57F8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -// void func_800C583C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9); -// void func_800C58C8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10); -// void func_800C5954(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE2 param_8); -s32 func_800C5A20(CollisionContext* colCtx, Vec3f* arg1, f32 arg2); -s32 func_800C5A64(CollisionContext* colCtx, Vec3f* arg1, f32 arg2, Actor* actor); -void BgCheck_ScenePolygonListsInit(SSNodeList* arg0); -void BgCheck_ScenePolygonListsAlloc(GlobalContext* globalCtx, SSNodeList* lists, s32 numNodes, u32 numPolygons); -s32 func_800C5B80(u16* arg0); -u16 BgCheck_ScenePolygonListsReserveNode(SSNodeList* lists); -void BgCheck_ActorMeshParamsInit(ScaleRotPos* params); -void BgCheck_SetActorMeshParams(ScaleRotPos* params, Vec3f* scale, Vec3s* rotation, Vec3f* position); -s32 BgCheck_AreActorMeshParamsEqual(ScaleRotPos* arg0, ScaleRotPos* arg1); -void BgCheck_ActorMeshPolyListsHeadsInit(DynaLookup* lists); -void BgCheck_ActorMeshPolyListsInit(DynaLookup* lists); -void BgCheck_ActorMeshVerticesIndexInit(s16* index); -void BgCheck_ActorMeshWaterboxesIndexInit(s16* index); -void BgCheck_ActorMeshInit(GlobalContext* globalCtx, BgActor* mesh); -void BgCheck_ActorMeshInitFromActor(BgActor* actorMesh, DynaPolyActor* actor, CollisionHeader* header); -s32 BgCheck_HasActorMeshChanged(BgActor* mesh); -void BgCheck_PolygonsInit(CollisionPoly** polygons); -void BgCheck_PolygonsAlloc(GlobalContext* globalCtx, CollisionPoly* polygons, u32 numPolygons); -void BgCheck_VerticesInit(Vec3s** vertices); -void BgCheck_VerticesListAlloc(GlobalContext* globalCtx, Vec3s** vertices, u32 numVertices); -void BgCheck_WaterboxListInit(DynaSSWaterboxList* waterboxList); -void BgCheck_WaterboxListAlloc(GlobalContext* globalCtx, DynaSSWaterboxList* waterboxList, u32 numWaterboxes); -void BgCheck_ActorMeshUpdateParams(GlobalContext* globalCtx, BgActor* mesh); -s32 BgCheck_IsActorMeshIndexValid(s32 index); -void BgCheck_DynaInit(GlobalContext* globalCtx, DynaCollisionContext* param_2); -void BgCheck_DynaAlloc(GlobalContext* globalCtx, DynaCollisionContext* dyna); -s32 BgCheck_AddActorMesh(GlobalContext* globalCtx, DynaCollisionContext* dyna, DynaPolyActor* actor, CollisionHeader* header); -DynaPolyActor* BgCheck_GetActorOfMesh(CollisionContext* colCtx, s32 index); -void func_800C62BC(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 index); -void func_800C6314(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 index); -void func_800C636C(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 index); -void func_800C63C4(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 index); -void func_800C641C(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 index); -void func_800C6474(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 index); -void BgCheck_RemoveActorMesh(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 index); -// void func_800C6554(void); +void SSNode_SetValue(SSNode* node, s16* polyIndex, u16 next); +void SSList_SetNull(SSList* head); +void SSNodeList_SetSSListHead(SSNodeList* list, SSList* ssList, s16* polyIndex); +void DynaSSNodeList_SetSSListHead(DynaSSNodeList* list, SSList* ssList, s16* polyIndex); +void DynaSSNodeList_Init(GlobalContext* globalCtx, DynaSSNodeList* list); +void DynaSSNodeList_Alloc(GlobalContext* globalCtx, DynaSSNodeList* list, u32 numNodes); +void DynaSSNodeList_ResetCount(DynaSSNodeList* list); +u16 DynaSSNodeList_GetNextNodeIdx(DynaSSNodeList* list); +void BgCheck_Vec3sToVec3f(Vec3s* vertex, Vec3f* vector); +void BgCheck_Vec3fToVec3s(Vec3s* vertex, Vec3f* vector); +f32 func_800BFD84(CollisionPoly *poly, f32 arg1, f32 arg2); +s32 func_800BFDEC(CollisionPoly* polyA, CollisionPoly* polyB, u32* outVtxId0, u32* outVtxId1); +s16 CollisionPoly_GetMinY(CollisionPoly* poly, Vec3s* vertices); +void CollisionPoly_GetNormalF(CollisionPoly* poly, f32* nx, f32* ny, f32* nz); +void func_800C0094(CollisionPoly* poly, f32 tx, f32 ty, f32 tz, MtxF* dest); +f32 CollisionPoly_GetPointDistanceFromPlane(CollisionPoly* poly, Vec3f* point); +void CollisionPoly_GetVerticesByBgId(CollisionPoly* poly, s32 bgId, CollisionContext* colCtx, Vec3f* dest); +s32 CollisionPoly_SphVsPoly(CollisionPoly* poly, Vec3s* vtxList, Vec3f* center, f32 radius); +void StaticLookup_AddPolyToSSList(CollisionContext* colCtx, SSList* ssList, CollisionPoly* polyList, Vec3s* vtxList, s16 polyId); +void StaticLookup_AddPoly(StaticLookup* lookup, CollisionContext* colCtx, CollisionPoly* polyList, Vec3s* vtxList, s16 index); +void BgCheck_GetSubdivisionMinBounds(CollisionContext* colCtx, Vec3f* pos, s32* sx, s32* sy, s32* sz); +void BgCheck_GetSubdivisionMaxBounds(CollisionContext* colCtx, Vec3f* pos, s32* sx, s32* sy, s32* sz); +void BgCheck_GetPolySubdivisionBounds(CollisionContext* colCtx, Vec3s* vtxList, CollisionPoly* polyList, s32* subdivMinX, s32* subdivMinY, s32* subdivMinZ, s32* subdivMaxX, s32* subdivMaxY, s32* subdivMaxZ, s16 polyId); +s32 BgCheck_PolyIntersectsSubdivision(Vec3f* min, Vec3f* max, CollisionPoly* polyList, Vec3s* vtxList, s16 polyId); +u32 BgCheck_InitStaticLookup(CollisionContext* colCtx, GlobalContext* globalCtx, StaticLookup* lookupTbl); +s32 BgCheck_IsSmallMemScene(GlobalContext* globalCtx); +s32 BgCheck_TryGetCustomMemsize(s32 sceneId, u32* memSize); +void BgCheck_SetSubdivisionDimension(f32 min, s32 subdivAmount, f32* max, f32* subdivLength, f32* subdivLengthInv); +s32 BgCheck_GetSpecialSceneMaxObjects(GlobalContext* globalCtx, s32* maxNodes, s32* maxPolygons, s32* maxVertices); +void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, CollisionHeader* colHeader); +void BgCheck_SetContextFlags(CollisionContext* colCtx, u32 flags); +void BgCheck_UnsetContextFlags(CollisionContext* colCtx, u32 flags); +CollisionHeader* BgCheck_GetCollisionHeader(CollisionContext* colCtx, s32 bgId); +f32 BgCheck_RaycastFloorImpl(GlobalContext* globalCtx, CollisionContext* colCtx, u16 xpFlags, CollisionPoly** outPoly, s32* outBgId, Vec3f* pos, Actor* actor, u32 arg7, f32 chkDist, s32 arg9); +f32 BgCheck_CameraRaycastFloor1(CollisionContext* colCtx, CollisionPoly** outPoly, Vec3f* pos); +f32 BgCheck_EntityRaycastFloor1(CollisionContext* colCtx, CollisionPoly** outPoly, Vec3f* pos); +f32 BgCheck_EntityRaycastFloor2(GlobalContext* globalCtx, CollisionContext* colCtx, CollisionPoly** outPoly, Vec3f* pos); +f32 BgCheck_EntityRaycastFloor2_1(GlobalContext* globalCtx, CollisionContext* colCtx, CollisionPoly** outPoly, Vec3f* pos); +f32 BgCheck_EntityRaycastFloor3(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Vec3f* pos); +f32 BgCheck_EntityRaycastFloor5(CollisionContext* colCtx, CollisionPoly** outPoly, s32* outBgId, Actor* actor, Vec3f* pos); +f32 BgCheck_EntityRaycastFloor5_2(GlobalContext* globalCtx, CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos); +f32 BgCheck_EntityRaycastFloor5_3(GlobalContext* globalCtx, CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos); +f32 BgCheck_EntityRaycastFloor6(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos, f32 chkDist); +f32 BgCheck_EntityRaycastFloor7(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos); +f32 BgCheck_AnyRaycastFloor1(CollisionContext* colCtx, CollisionPoly* outPoly, Vec3f* pos); +f32 BgCheck_AnyRaycastFloor2(CollisionContext* colCtx, CollisionPoly* outPoly, s32* bgId, Vec3f* pos); +f32 BgCheck_CameraRaycastFloor2(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Vec3f* pos); +f32 BgCheck_EntityRaycastFloor8(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos); +f32 BgCheck_EntityRaycastFloor9(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Vec3f* pos); +s32 BgCheck_CheckWallImpl(CollisionContext* colCtx, u16 xpFlags, Vec3f* posResult, Vec3f* posNext, Vec3f* posPrev, f32 radius, CollisionPoly** outPoly, s32* outBgId, Actor* actor, f32 checkHeight, u8 argA); +s32 BgCheck_EntitySphVsWall1(CollisionContext* colCtx, Vec3f* posResult, Vec3f* posNext, Vec3f* posPrev, f32 radius, CollisionPoly** outPoly, f32 checkHeight); +s32 BgCheck_EntitySphVsWall2(CollisionContext* colCtx, Vec3f* posResult, Vec3f* posNext, Vec3f* posPrev, f32 radius, CollisionPoly** outPoly, s32* outBgId, f32 checkHeight); +s32 BgCheck_EntitySphVsWall3(CollisionContext* colCtx, Vec3f* posResult, Vec3f* posNext, Vec3f* posPrev, f32 radius, CollisionPoly** outPoly, s32* outBgId, Actor* actor, f32 checkHeight); +s32 BgCheck_EntitySphVsWall4(CollisionContext* colCtx, Vec3f* posResult, Vec3f* posNext, Vec3f* posPrev, f32 radius, CollisionPoly** outPoly, s32* outBgId, Actor* actor, f32 checkHeight); +s32 BgCheck_CheckCeilingImpl(CollisionContext* colCtx, u16 xpFlags, f32* outY, Vec3f* pos, f32 checkHeight, CollisionPoly** outPoly, s32* outBgId, Actor* actor); +s32 BgCheck_AnyCheckCeiling(CollisionContext* colCtx, f32* outY, Vec3f* pos, f32 checkHeight); +s32 BgCheck_EntityCheckCeiling(CollisionContext* colCtx, f32* outY, Vec3f* pos, f32 checkHeight, CollisionPoly** outPoly, s32* outBgId, Actor* actor); +s32 BgCheck_CameraLineTest1(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId); +s32 BgCheck_CameraLineTest2(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId); +s32 BgCheck_EntityLineTest1(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId); +s32 BgCheck_EntityLineTest2(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId, Actor* actor); +s32 BgCheck_EntityLineTest3(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId, Actor* actor, f32 chkDist); +s32 BgCheck_ProjectileLineTest(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId); +s32 BgCheck_AnyLineTest1(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 chkOneFace); +s32 BgCheck_AnyLineTest2(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace); +s32 BgCheck_AnyLineTest3(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId); +s32 BgCheck_SphVsFirstPolyImpl(CollisionContext* colCtx, u16 xpFlags, CollisionPoly** outPoly, s32* outBgId, Vec3f* center, f32 radius, Actor* actor, u16 bciFlags); +s32 BgCheck_SphVsFirstPoly(CollisionContext* colCtx, Vec3f* center, f32 radius); +s32 BgCheck_SphVsFirstWall(CollisionContext* colCtx, Vec3f* center, f32 radius); +void SSNodeList_Init(SSNodeList* this); +void SSNodeList_Alloc(GlobalContext* globalCtx, SSNodeList* this, s32 tblMax, s32 numPolys); +SSNode* SSNodeList_GetNextNode(SSNodeList* this); +u16 SSNodeList_GetNextNodeIdx(SSNodeList* this); +void ScaleRotPos_Init(ScaleRotPos* srp); +void ScaleRotPos_SetValue(ScaleRotPos* srp, Vec3f* scale, Vec3s* rot, Vec3f* pos); +s32 ScaleRotPos_IsEqual(ScaleRotPos* a, ScaleRotPos* b); +void DynaLookup_ResetLists(DynaLookup* dynaLookup); +void DynaLookup_Reset(DynaLookup* dynaLookup); +void DynaLookup_ResetVtxStartIndex(u16* vtxStartIndex); +void DynaLookup_ResetWaterBoxStartIndex(u16* waterBoxStartIndex); +void BgActor_Init(GlobalContext* globalCtx, BgActor* bgActor); +void BgActor_SetActor(BgActor* bgActor, Actor* actor, CollisionHeader* colHeader); +s32 BgActor_IsTransformUnchanged(BgActor* bgActor); +void DynaPoly_NullPolyList(CollisionPoly** polyList); +void DynaPoly_AllocPolyList(GlobalContext* globalCtx, CollisionPoly** polyList, s32 numPolys); +void DynaPoly_NullVtxList(Vec3s** vtxList); +void DynaPoly_AllocVtxList(GlobalContext* globalCtx, Vec3s** vtxList, s32 numVtx); +void DynaPoly_InitWaterBoxList(DynaWaterBoxList* waterBoxList); +void DynaPoly_AllocWaterBoxList(GlobalContext* globalCtx, DynaWaterBoxList* waterBoxList, s32 numWaterBoxes); +void DynaPoly_SetBgActorPrevTransform(GlobalContext* globalCtx, BgActor* bgActor); +s32 DynaPoly_IsBgIdBgActor(s32 bgId); +void DynaPoly_Init(GlobalContext* globalCtx, DynaCollisionContext* dyna); +void DynaPoly_Alloc(GlobalContext* globalCtx, DynaCollisionContext* dyna); +s32 DynaPoly_SetBgActor(GlobalContext* globalCtx, DynaCollisionContext* dyna, Actor* actor, CollisionHeader* colHeader); +DynaPolyActor* DynaPoly_GetActor(CollisionContext* colCtx, s32 bgId); +void func_800C62BC(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId); +void func_800C6314(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId); +void func_800C636C(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId); +void func_800C63C4(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId); +void func_800C641C(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId); +void func_800C6474(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId); +void DynaPoly_DeleteBgActor(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId); void BgCheck_CalcWaterboxDimensions(Vec3f* minPos, Vec3f* maxXPos, Vec3f* maxZPos, Vec3s* minPosOut, s16* xLength, s16* zLength); -void BgCheck_AddActorMeshToLists(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 index, s32* currVertices, s32* currPolygons, s32* currWaterboxes); +void DynaPoly_ExpandSRT(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId, s32* vtxStartIndex, s32* polyStartIndex, s32* waterBoxStartIndex); void BgCheck_ResetFlagsIfLoadedActor(GlobalContext* globalCtx, DynaCollisionContext* dyna, Actor* actor); -void BgCheck_Update(GlobalContext* globalCtx, DynaCollisionContext* dyna); -void func_800C756C(s32 param_1, s32* param_2, s32* param_3, s32* param_4); -void BgCheck_UpdateAllActorMeshes(GlobalContext* globalCtx, DynaCollisionContext* dyna); -// void func_800C76EC(void); -// void func_800C7974(void); -// void func_800C7E40(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11, UNK_TYPE4 param_12); -// void func_800C8580(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9); -// void func_800C87D0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9); -// void func_800C8A60(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8); -// void func_800C8BD0(void); -// void func_800C8DC0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11); -// void func_800C8EEC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11); -// void func_800C90AC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -// void func_800C921C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE2 param_7, UNK_TYPE4 param_8); -// void func_800C9380(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE2 param_8); -void BgCheck_RelocateMeshHeaderPointers(CollisionHeader* header); -void BgCheck_RelocateMeshHeader(CollisionHeader* meshSegPtr, CollisionHeader** param_2); -void BgCheck_RelocateAllMeshHeaders(CollisionContext* colCtx, GlobalContext* globalCtx); -// void func_800C9640(void); -u32 BgCheck_GetPolygonAttributes(CollisionContext* colCtx, CollisionPoly* polygon, s32 index, s32 attributeIndex); -u32 func_800C9704(CollisionContext* colCtx, CollisionPoly* polygon, s32 index); -// void func_800C9728(void); -// UNK_TYPE4 func_800C9770(CollisionContext* colCtx, CollisionPoly* polygon, s32 index); -// void func_800C97F8(void); -// UNK_TYPE4 func_800C9844(CollisionContext* colCtx, CollisionPoly* polygon, s32 index); -// void func_800C98CC(void); -// UNK_TYPE4 func_800C9924(CollisionContext* colCtx, CollisionPoly* polygon, s32 index); -u32 func_800C99AC(CollisionContext* colCtx, CollisionPoly* polygon, s32 index); -u32 func_800C99D4(CollisionContext* colCtx, CollisionPoly* polygon, s32 index); -u32 func_800C99FC(CollisionContext* colCtx, CollisionPoly* polygon, s32 index); -u32 func_800C9A24(CollisionContext* colCtx, CollisionPoly* polygon, s32 index); -u32 func_800C9A4C(CollisionContext* colCtx, CollisionPoly* polygon, s32 index); -u32 func_800C9A7C(CollisionContext* colCtx, CollisionPoly* polygon, s32 index); -u32 func_800C9AB0(CollisionContext* colCtx, CollisionPoly* polygon, s32 index); -u32 func_800C9AE4(CollisionContext* colCtx, CollisionPoly* polygon, s32 index); -u32 func_800C9B18(CollisionContext* colCtx, CollisionPoly* polygon, s32 index); -u32 func_800C9B40(CollisionContext* colCtx, CollisionPoly* polygon, s32 index); -u32 func_800C9B68(CollisionContext* colCtx, CollisionPoly* polygon, s32 index); -u32 func_800C9B90(CollisionContext* colCtx, CollisionPoly* polygon, s32 index); -u32 func_800C9BB8(CollisionContext* colCtx, CollisionPoly* polygon, s32 index); -u32 func_800C9BDC(CollisionContext* colCtx, CollisionPoly* polygon, s32 index); -// u32 func_800C9C24(CollisionContext* colCtx, CollisionPoly* polygon, s32 index, UNK_TYPE4 param_4); -u32 func_800C9C74(CollisionContext* colCtx, CollisionPoly* polygon, s32 index); -u32 func_800C9C9C(CollisionContext* colCtx, CollisionPoly* polygon, s32 index); -u32 func_800C9CC4(CollisionContext* colCtx, CollisionPoly* polygon, s32 index); -u32 func_800C9CEC(CollisionContext* colCtx, CollisionPoly* polygon, s32 index); -// void func_800C9D14(void); -// void func_800C9D50(void); -u32 func_800C9D8C(CollisionContext* param_1, CollisionPoly* param_2, s32 param_3); -// void func_800C9DDC(void); -u32 func_800C9E18(CollisionContext* colCtx, CollisionPoly* polygon, s32 index); -u32 func_800C9E40(CollisionContext* colCtx, CollisionPoly* polygon, s32 index); -u32 func_800C9E88(CollisionContext* colCtx, CollisionPoly* polygon, s32 index); -s32 func_800C9EBC(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox, s32* bgId); -s32 func_800CA1AC(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox); -s32 func_800CA1E8(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox); -// void func_800CA22C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -// void func_800CA568(void); -// void func_800CA634(void); -// void func_800CA648(void); -// void func_800CA6B8(void); -// void func_800CA6D8(void); -// void func_800CA6F0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -// void func_800CA9D0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -// void func_800CAA14(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); +void DynaPoly_Setup(GlobalContext* globalCtx, DynaCollisionContext* dyna); +void func_800C756C(DynaCollisionContext* dyna, s32* numPolygons, s32* numVertices, s32* numWaterBoxes); +void DynaPoly_UpdateBgActorTransforms(GlobalContext* globalCtx, DynaCollisionContext* dyna); +void CollisionHeader_SegmentedToVirtual(CollisionHeader* header); +void CollisionHeader_GetVirtual(CollisionHeader* meshSegPtr, CollisionHeader** param_2); +void BgCheck_InitCollisionHeaders(CollisionContext* colCtx, GlobalContext* globalCtx); +u32 SurfaceType_GetData(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId, s32 dataIdx); +u32 SurfaceType_GetCamDataIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u16 SurfaceType_GetCameraSType(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u16 SurfaceType_GetNumCameras(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +Vec3s* SurfaceType_GetCamPosData(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u32 SurfaceType_GetSceneExitIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u32 func_800C99D4(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u32 func_800C99FC(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u32 func_800C9A24(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +s32 func_800C9A4C(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +s32 func_800C9A7C(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +s32 func_800C9AB0(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +s32 func_800C9AE4(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u32 func_800C9B18(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u32 func_800C9B40(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u32 func_800C9B68(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u32 SurfaceType_IsHorseBlocked(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u32 func_800C9BB8(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u16 SurfaceType_GetSfx(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +s32 func_800C9C24(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId, s32 arg3); +u32 SurfaceType_GetSlope(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u32 SurfaceType_GetLightSettingIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u32 SurfaceType_GetEcho(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u32 SurfaceType_IsHookshotSurface(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +s32 SurfaceType_IsIgnoredByEntities(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +s32 SurfaceType_IsIgnoredByProjectiles(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +s32 SurfaceType_IsConveyor(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +s32 func_800C9DDC(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u32 SurfaceType_GetConveyorSpeed(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u32 SurfaceType_GetConveyorDirection(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u32 SurfaceType_IsWallDamage(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +s32 WaterBox_GetSurfaceImpl(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox, s32* bgId); +s32 WaterBox_GetSurface1(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox); +s32 WaterBox_GetSurface1_2(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox); +s32 WaterBox_GetSurface2(GlobalContext* globalCtx, CollisionContext* colCtx, Vec3f* pos, f32 surfaceChkDist, WaterBox** outWaterBox, s32* bgId); +f32 func_800CA568(CollisionContext* colCtx, s32 waterBoxId, s32 bgId); +u16 WaterBox_GetCameraSType(CollisionContext* colCtx, WaterBox* waterBox, s32 bgId); +void func_800CA6B8(CollisionContext* colCtx, WaterBox* waterBox); +u32 WaterBox_GetLightSettingIndex(CollisionContext* colCtx, WaterBox* waterBox); +s32 func_800CA6F0(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox, s32* bgId); +s32 func_800CA9D0(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox); +s32 func_800CAA14(CollisionPoly* polyA, CollisionPoly* polyB, Vec3f* pointA, Vec3f* pointB, Vec3f* closestPoint); void BgCheck2_UpdateActorPosition(CollisionContext* colCtx, s32 index, Actor* actor); void BgCheck2_UpdateActorYRotation(CollisionContext* colCtx, s32 index, Actor* actor); void BgCheck2_AttachToMesh(CollisionContext* colCtx, Actor* actor, s32 index); u32 BgCheck2_UpdateActorAttachedToMesh(CollisionContext* colCtx, s32 index, Actor* actor); -void BcCheck3_BgActorInit(DynaPolyActor* actor, UNK_TYPE4 param_2); -void BgCheck3_LoadMesh(GlobalContext* globalCtx, DynaPolyActor* actor, CollisionHeader* meshHeader); -void BgCheck3_ResetFlags(DynaPolyActor* actor); -void func_800CAE88(DynaPolyActor* actor); -void func_800CAE9C(DynaPolyActor* actor); -void func_800CAEB0(CollisionContext* colCtx, s32 index); -void func_800CAEE0(DynaPolyActor* actor); -void func_800CAEF4(CollisionContext* colCtx, s32 index); -void func_800CAF24(DynaPolyActor* actor); -void func_800CAF38(DynaPolyActor* actor); -s32 func_800CAF4C(DynaPolyActor* actor); -s32 func_800CAF70(DynaPolyActor* actor); -s32 func_800CAF94(DynaPolyActor* actor); -s32 func_800CAFB8(DynaPolyActor* actor); -s32 func_800CAFDC(DynaPolyActor* actor); -// void func_800CB000(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); +void DynaPolyActor_Init(DynaPolyActor* dynaActor, s32 flags); +void DynaPolyActor_LoadMesh(GlobalContext* globalCtx, DynaPolyActor* dynaActor, CollisionHeader* meshHeader); +void DynaPolyActor_ResetState(DynaPolyActor* dynaActor); +void DynaPolyActor_SetRidingFallingState(DynaPolyActor* dynaActor); +void DynaPolyActor_SetRidingMovingState(DynaPolyActor* dynaActor); +void DynaPolyActor_SetRidingMovingStateByIndex(CollisionContext* colCtx, s32 index); +void DynaPolyActor_SetRidingRotatingState(DynaPolyActor* dynaActor); +void DynaPolyActor_SetRidingRotatingStateByIndex(CollisionContext* colCtx, s32 index); +void DynaPolyActor_SetSwitchPressedState(DynaPolyActor* dynaActor); +void DynaPolyActor_SetHeavySwitchPressedState(DynaPolyActor* dynaActor); +s32 DynaPolyActor_IsInRidingFallingState(DynaPolyActor* dynaActor); +s32 DynaPolyActor_IsInRidingMovingState(DynaPolyActor* dynaActor); +s32 DynaPolyActor_IsInRidingRotatingState(DynaPolyActor* dynaActor); +s32 DynaPolyActor_IsInSwitchPressedState(DynaPolyActor* dynaActor); +s32 DynaPolyActor_IsInHeavySwitchPressedState(DynaPolyActor* dynaActor); +s32 DynaPolyActor_ValidateMove(GlobalContext* globalCtx, DynaPolyActor* dynaActor, s16 arg2, s16 arg3, s16 arg4); f32 Camera_fabsf(f32 f); f32 Camera_LengthVec3f(Vec3f* v); // void func_800CB270(void); @@ -1308,7 +1268,7 @@ s16 Camera_ClearFlags(Camera* camera, s16 flags); // UNK_TYPE4 func_800E0228(void); // void func_800E0238(void); void func_800E02AC(Camera* camera, Actor* actor); -// void func_800E0308(void); +void func_800E0308(Camera* camera, Actor* actor); // void func_800E031C(void); void func_800E0348(Camera* camera); DamageTable* DamageTable_Get(s32 index); @@ -1623,7 +1583,7 @@ void func_800F03C0(GlobalContext* globalCtx); void func_800F048C(GlobalContext* globalCtx, Vec3f* param_2, u8 param_3, u16 param_4, u8 param_5); void Audio_PlaySoundAtPosition(GlobalContext* globalCtx, Vec3f* position, s32 param_3, u16 sfxId); void func_800F0590(GlobalContext* globalCtx, Vec3f* arg1, s32 arg2, s32 arg3); -// void func_800F05C0(void); +u16 ElfMessage_GetFirstCycleHint(GlobalContext* globalCtx); // void func_800F07C0(void); // void func_800F0888(void); // void func_800F0944(void); @@ -1696,11 +1656,7 @@ void FireObj_Update(GlobalContext* globalCtx, FireObj* fire, Actor* actor); void func_800F40A0(GlobalContext* globalCtx, s32 param_2); // void func_800F415C(void); UNK_TYPE func_800F41E4(GlobalContext* globalCtx, ActorContext* actorCtx); -// void func_800F42A0(void); -// void func_800F43BC(void); -// void func_800F44F4(void); -// void func_800F4540(void); -// s32 func_800F470C(UNK_TYPE4 param_1, UNK_TYPE4 param_2, s32 param_3, u32 param_4); + void func_800F4A10(GlobalContext* globalCtx); void func_800F4C0C(GlobalContext* globalCtx); void func_800F4E20(GlobalContext* globalCtx); @@ -1761,7 +1717,7 @@ void func_800FD654(GlobalContext* globalCtx, Color_RGB8* pzParm2, f32 fParm3); // u32 get_days_elapsed(void); // void reset_days_elapsed(void); // u32 get_current_day(void); -void func_800FD750(UNK_TYPE arg0); +void func_800FD750(u16 seqId); // void func_800FD768(void); void func_800FD78C(GlobalContext* globalCtx); void func_800FD858(GlobalContext* globalCtx); @@ -1778,7 +1734,7 @@ u32 func_800FE4B8(GlobalContext* globalCtx); // void func_800FE590(void); // void func_800FE5D0(void); // UNK_TYPE4 func_800FE610(void); -s32 func_800FE620(GlobalContext* globalCtx); +u32 func_800FE620(GlobalContext* globalCtx); void func_800FE658(f32 arg0); // UNK_TYPE4 func_800FE6F8(UNK_TYPE4 param_1, s16 param_2, s16 param_3); // void func_800FE778(void); @@ -2067,7 +2023,7 @@ s32 func_8010BF58(Actor* actor, GlobalContext* globalCtx, s32* param_3, UNK_PTR void Nmi_Init(void); void Nmi_SetPrenmiStart(void); // s32 Nmi_GetPrenmiHasStarted(void); -// void func_8010C1B0(void); +void MsgEvent_SendNullTask(void); f32 OLib_Vec3fDist(Vec3f* a, Vec3f* b); f32 OLib_Vec3fDistOutDiff(Vec3f* a, Vec3f* b, Vec3f* dest); f32 OLib_Vec3fDistXZ(Vec3f* a, Vec3f* b); @@ -2536,10 +2492,10 @@ void SkelAnime_DrawFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** s void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor); void func_80134148(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, - OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, UnkActorDraw unkDraw, Actor* actor, + OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, UnkActorDrawOpa unkDraw, Actor* actor, Mtx** mtx); void func_801343C0(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, - OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, UnkActorDraw unkDraw, Actor* actor); + OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, UnkActorDrawOpa unkDraw, Actor* actor); void SkelAnime_GetFrameData(AnimationHeader* animationSeg, s32 currentFrame, s32 limbCount, Vec3s* dst); s16 Animation_GetLength(void* animation); s16 Animation_GetLastFrame(void* animation); @@ -2675,60 +2631,60 @@ void func_8013A46C(s32 flag); u32 func_8013A4C4(s32 flag); s16 func_8013A504(s16 val); s32 func_8013A530(GlobalContext* globalCtx, Actor* actor, s32 flag, Vec3f* pos, Vec3s* rot, f32 distanceMin, f32 distanceMax, s16 angleError); -// void func_8013A7C0(void); -// void func_8013A860(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10); -Gfx* func_8013AB00(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, void* func1, void* func2, void* func3, Actor* actor, Gfx* gfx); +Actor* func_8013A7C0(GlobalContext* globalCtx, s32 arg1); +Gfx* func_8013A860(GlobalContext* globalCtx, s32 idx, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, UnkActorDraw unkActorDraw, Actor* actor, Mtx** mtx, Gfx* gfx); +Gfx* func_8013AB00(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, UnkActorDraw unkActorDraw, Actor* actor, Gfx* gfx); s32 func_8013AD6C(GlobalContext* globalCtx); -// void func_8013AD9C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -void func_8013AED4(u16* param_1, u16 param_2, u16 param_3); -void func_8013AF00(UNK_PTR arg0, UNK_TYPE arg1, UNK_TYPE arg2); -// void func_8013B010(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -// void func_8013B0C8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_8013B350(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -s32 func_8013B6B0(Path* path, UNK_PTR arg1, s32* arg2, s32 arg3, s32 arg4, s32* arg5, UNK_PTR arg6, Vec3f* arg7, s16 arg8); +s32 func_8013AD9C(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 arg5); +void func_8013AED4(u16* arg0, u16 arg1, u16 arg2); +void func_8013AF00(f32* arg0, s32 arg1, s32 arg2); +s32 func_8013B010(f32* arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, f32* arg6); +void func_8013B0C8(s32 arg0, f32 arg1, s32 arg2, f32* arg3, f32* arg4); +void func_8013B350(Vec3f* arg0, f32* arg1, f32 arg2, s32 arg3, s32 arg4, Vec3s* arg5, f32* arg6); +s32 func_8013B6B0(Path* path, f32* arg1, s32* arg2, s32 arg3, s32 arg4, s32* arg5, f32* arg6, Vec3f* arg7, s32 arg8); void func_8013B878(GlobalContext* globalCtx, Path* path, s32 arg2, Vec3f* arg3); Path* func_8013BB34(GlobalContext* globalCtx, u8 arg1, s32 arg2); -Actor* func_8013BB7C(Actor* actor, GlobalContext* globalCtx, s32 actorCategory, s32 actorId); +Actor* func_8013BB7C(Actor* actor, GlobalContext* globalCtx, u8 actorCategory, s16 actorId); s32 func_8013BC6C(SkelAnime* skelAnime, ActorAnimationEntryS* arg1, s32 arg2); -// void func_8013BD40(void); -s32 func_8013BEDC(GlobalContext* globalCtx, s32 arg1, s32 arg2, s32* arg3); -// void func_8013C068(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_8013C624(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -// void func_8013C8B8(void); -void func_8013C964(Actor* actor, GlobalContext* globalCtx, f32 param_3, f32 param_4, s32 param_5, s16 param_6); -// void func_8013CC2C(void); -// void func_8013CD64(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -// void func_8013CF04(void); -// void func_8013D0E0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -void func_8013D2E0(Vec3f* arg0, PosRot* arg1, ActorShape* arg2, s16* arg3, s16* arg4, s16* arg5, s16* arg6); -UNK_TYPE func_8013D5E8(s16 arg0, UNK_TYPE arg1, s16 arg2); -Path* func_8013D648(GlobalContext* globalCtx, s16 arg1, s32 arg2); -UNK_TYPE func_8013D68C(Path* path, s16 arg1, UNK_PTR arg2); -// void func_8013D720(void); -UNK_TYPE func_8013D768(Actor* actor, UNK_PTR arg1, s16 arg2); -// void func_8013D83C(void); -s32 func_8013D8DC(s8 arg0, GlobalContext* globalCtx); -s8 func_8013D924(s32 arg0, GlobalContext* globalCtx); -Actor* func_ActorCategoryIterateById(GlobalContext* globalCtx, Actor* actorListStart, s32 actorCategory, s32 actorId); -void func_8013D9C8(GlobalContext* globalCtx, s16* arg1, s16* arg2, UNK_TYPE arg3); -u8 func_8013DB90(GlobalContext* globalCtx, UNK_PTR arg1, f32 arg2); -// void func_8013DC40(void); -void func_8013DCE0(GlobalContext* globalCtx, Vec3f* param_2, Actor* actor, EnDno_ActorUnkStruct* param_4, Path* param_5, s32 param_6, s32 param_7, s32 param_8, s32 param_9, s32 param_10); -void func_8013DE04(GlobalContext* globalCtx, EnDno_ActorUnkStruct* arg1, EnDno_ActorUnkFunc arg2, EnDno_ActorUnkFunc arg3, EnDno_ActorUnkFunc arg4, EnDno_ActorUnkFunc arg5); -s32 func_8013DF3C(GlobalContext* globalCtx, EnDno_ActorUnkStruct* arg1); -// void func_8013E054(void); -// void func_8013E07C(void); -s32 func_8013E0A4(GlobalContext* globalCtx, EnDno_ActorUnkStruct* arg1); +s32 func_8013BD40(Actor* actor, Path* path, s32 arg2); +Path* func_8013BEDC(GlobalContext* globalCtx, u8 arg1, u8 arg2, s32* arg3); +s32 func_8013C068(Path* path, s32 arg1, Vec3f* arg2, f32 arg3, s32 arg4); +s32 func_8013C624(Actor* actor, Path* path, s32* arg2, f32* arg3, s32 arg4, s32 arg5); +s32 func_8013C8B8(Path* path, s32 arg1, Vec3f* arg2); +s32 func_8013C964(Actor* actor, GlobalContext* globalCtx, f32 arg2, f32 arg3, s32 arg4, s32 arg5); +void func_8013CC2C(s32 arg0, s32 arg1, u8* arg2, s32 arg3); +void func_8013CD64(Vec3f* arg0, Vec3f* arg1, u8* arg2, f32 arg3, u8 arg4, u8* arg5, s8* arg6); +void func_8013CF04(Actor* actor, GraphicsContext** gfxCtxPtr, u8* arg2); +s16 func_8013D0E0(s16* arg0, s16 arg1, s16 arg2, f32 arg3, f32 arg4, f32 arg5); +s32 func_8013D2E0(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, Vec3s* arg3, Vec3s* arg4, Vec3s* arg5, u16* arg6); +s32 func_8013D5E8(s16 arg0, s16 arg1, s16 arg2); +Path* func_8013D648(GlobalContext* globalCtx, s16 arg1, s16 arg2); +s32 func_8013D68C(Path* path, s32 arg1, Vec3f* arg2); +s16 func_8013D720(Vec3f* arg0, Vec3f* arg1, f32* arg2); +s32 func_8013D768(Actor* actor, Vec3f* arg1, s16 arg2); +s16 func_8013D83C(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq); +s8 func_8013D8DC(s8 arg0, GlobalContext* globalCtx); +s8 func_8013D924(s16 arg0, GlobalContext* globalCtx); +Actor* func_ActorCategoryIterateById(GlobalContext* globalCtx, Actor* actorListStart, u8 actorCategory, s16 actorId); +s32 func_8013D9C8(GlobalContext* globalCtx, s16* arg1, s16* arg2, s32 arg3); +u8 func_8013DB90(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2); +s32 func_8013DC40(Path* arg0, s32 arg1, s32 arg2, Vec3f* arg3); +void func_8013DCE0(GlobalContext* globalCtx, Vec3f* arg1, Actor* arg2, struct_8013DF3C_arg1* arg3, Path* arg4, s32 arg5, s32 arg6, s32 arg7, s32 arg8, u8 arg9); +s32 func_8013DE04(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1, struct_8013DF3C_arg1_unk_func1 arg2, struct_8013DF3C_arg1_unk_func2 arg3, struct_8013DF3C_arg1_unk_func2 arg4, struct_8013DF3C_arg1_unk_func2 arg5); +void func_8013DF3C(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1); +s32 func_8013E054(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1); +s32 func_8013E07C(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1); +s32 func_8013E0A4(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1); void func_8013E1C8(SkelAnime* skelAnime, struct_80B8E1A8 animations[], s32 animationIndex, s32* actorAnimationIndex); -s32 func_8013E2D4(Actor* actor, s16 arg1, s32 arg2, s32 arg3); -s32 func_8013E3B8(Actor* actor, s16 cutscenes[], s32 cutsceneArrayLen); -// void func_8013E4B0(void); -s32 func_8013E5CC(Vec3f* param_1, Vec3s* param_2, Vec3f* param_3, Vec3f* param_4, Vec3f* param_5, Vec3f* param_6); -// void func_8013E640(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -// void func_8013E748(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -// void func_8013E7C0(void); -// void func_8013E8F8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7); -s32 func_8013E950(Vec3f* param_1, Vec3f* param_2, s16 param_3, Vec3f* param_4, Vec3f* param_5, s16* param_6, s16* param_7, s16* param_8, s16* param_9, u16 param_10, u16 param_11, u16 param_12, u16 param_13); +s32 func_8013E2D4(Actor* actor, s16 arg1, s16 arg2, s32 arg3); +s32 func_8013E3B8(Actor* actor, s16 cutscenes[], s16 len); +void func_8013E4B0(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, Plane* plane); +s32 func_8013E5CC(Vec3f* arg0, Vec3s* arg1, Vec3f* arg2, Vec3f* arg3, Vec3f* arg4, Vec3f* arg5); +Actor* func_8013E640(GlobalContext* globalCtx, Actor* arg1, Actor* actorListStart, u8 actorCategory, s16 actorId, void* arg5, func_8013E640_arg6 arg6); +s32 func_8013E748(Actor* actor, GlobalContext* globalCtx, f32 arg2, f32 arg3, s32 arg4, Vec3s* arg5, func_8013E748_arg6 arg6); +s32 func_8013E7C0(GlobalContext* globalCtx, Actor* actor, Vec3s* arg2); +void func_8013E8F8(Actor* actor, GlobalContext* globalCtx, f32 arg2, f32 arg3, s32 arg4, s16 arg5, s16 arg6); +s32 func_8013E950(Vec3f* arg0, Vec3f* arg1, s16 arg2, Vec3f* arg3, Vec3f* arg4, s16* arg5, s16* arg6, s16* arg7, s16* arg8, u16 arg9, u16 arg10, u16 arg11, u16 arg12); // void func_8013EC10(void); void func_8013EC44(f32 arg0, u8 arg1, u8 arg2, u8 arg3); void func_8013ECE0(f32 xyzDistToPlayerSq, u8 arg1, u8 arg2, u8 arg3); @@ -2798,11 +2754,11 @@ void func_801420C0(void* arg0); void func_801420F4(void* arg0); void func_80142100(void* arg0, Gfx** gfx, u32 arg2); s32 func_80142440(SkyboxContext* skyboxCtx, Vtx* vtx, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, - s32 arg8); -void func_80143148(SkyboxContext* skyboxCtx, s32 arg1); -void func_801431E8(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyType); + s32 arg8); +void func_80143148(SkyboxContext* skyboxCtx, s32 arg1); +void func_801431E8(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyType); void func_80143324(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skyType); -void func_801434E4(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyType); +void func_801434E4(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyType); // void func_801435A0(void); // void func_80143624(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5, UNK_TYPE1 param_6, UNK_TYPE1 param_7); // void func_80143668(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); @@ -3033,7 +2989,7 @@ void func_80169600(GlobalContext* globalCtx, s16 param_2); Camera* Play_GetCamera(GlobalContext* globalCtx, s16 index); s32 Play_CameraSetAtEye(GlobalContext* globalCtx, s16 camId, Vec3f* at, Vec3f* eye); void func_8016981C(GlobalContext* globalCtx, s16 arg1, Vec3f* arg2, Vec3f* arg3, Vec3f* arg4); -// void func_80169940(void); +void func_80169940(GlobalContext* globalCtx, s16 camId, f32 arg2); // void func_80169988(void); void func_801699D4(GlobalContext* globalCtx, s16 arg1, s16 arg2); // void func_80169A50(void); @@ -3236,7 +3192,7 @@ void Sched_Init(SchedContext* sched, void* stack, OSPri pri, UNK_TYPE arg3, UNK_ void func_801773A0(void* arg0); void func_801773C4(void* arg0); void SpeedMeter_DrawTimeEntries(void* displayList, GraphicsContext* gfxCtx); -// void func_80177A84(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9); +// void func_80177A84(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9); //void func_80177AC8(void); void SpeedMeter_DrawAllocEntries(void* displayList, GraphicsContext* gfxCtx, GameState* gameState); void func_801780F0(Mtx* param_1, f32 param_2, f32 param_3, f32 param_4, f32 param_5, f32 param_6, f32 param_7); @@ -3257,10 +3213,10 @@ s32 func_80178A94(s32 param_1, s32 param_2); // void func_80178DAC(void); // void func_80178E3C(void); // void func_80178E7C(void); -void Check_WriteRGBA16Pixel(u16* buffer, u32 x, u32 y, u16 value); -void Check_WriteI4Pixel(u16* buffer, u32 x, u32 y, u32 value); -void Check_DrawI4Texture(u16* buffer, u32 x, u32 y, u32 width, u32 height, u8* texture); -void Check_ClearRGBA16(s16* buffer); +// void Check_WriteRGBA16Pixel(u16* buffer, u32 x, u32 y, u32 value); +// void Check_WriteI4Pixel(u16* buffer, u32 x, u32 y, u32 value); +// void Check_DrawI4Texture(u16* buffer, u32 x, u32 y, u32 width, u32 height, u8* texture); +// void Check_ClearRGBA16(u16* buffer); // void Check_DrawExpansionPakErrorMessage(void); // void Check_DrawRegionLockErrorMessage(void); void Check_ExpansionPak(void); @@ -3273,7 +3229,7 @@ f32 cos_rad(f32 rad); f32 Rand_ZeroFloat(f32 scale); f32 randPlusMinusPoint5Scaled(f32 scale); f32 Math3D_Normalize(Vec3f* vec); -// UNK_TYPE4 func_80179678(f32 fParm1, f32 fParm2, f32 fParm5, f32 param_4, f32 param_5, f32 param_6, f32 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11); +s32 Math3D_PlaneVsLineSegClosestPoint(f32 planeAA, f32 planeAB, f32 planeAC, f32 planeADist, f32 planeBA, f32 planeBB, f32 planeBC, f32 planeBDist, Vec3f* linePointA, Vec3f* linePointB, Vec3f* closestPoint); // UNK_TYPE4 func_80179798(Vec3f* param_1, Vec3f* param_2, Vec3f* param_3, Vec3f* param_4, Vec3f* param_5, Vec3f* param_6); // void func_80179A44(void); void func_80179B34(float fParm1, f32 fParm2, f32 fParm5, f32 fParm6, f32 param_5, f32 param_6, f32 param_7, float* param_8, float* param_9); @@ -3287,7 +3243,7 @@ void func_80179F64(Vec3f* param_1, Vec3f* param_2, Vec3f* param_3); s32 Math3D_XZBoundCheck(f32 xMin, f32 xMax, f32 zMin, f32 zMax, f32 x, f32 z); // void func_8017A09C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); // void func_8017A1D0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -// void func_8017A304(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); +s32 func_8017A304(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 z, f32 x, f32 chkDist); // UNK_TYPE4 func_8017A438(Vec3f* pfParm1, Vec3f* pfParm2, Vec3f* pfParm3, Vec3f* pfParm4, f32 param_5); f32 Math3D_XZLengthSquared(f32 x, f32 z); f32 Math3D_XZLength(f32 x, f32 z); @@ -3295,46 +3251,46 @@ f32 Math3D_XZDistanceSquared(f32 x1, f32 x2, f32 z1, f32 z2); f32 Math3D_XZDistance(f32 x1, f32 x2, f32 z1, f32 z2); f32 Math3D_LengthSquared(Vec3f* vec); f32 Math3D_Vec3fMagnitude(Vec3f* vec); -f32 Math3D_DistanceSquared(Vec3f* a, Vec3f* b); +f32 Math3D_Vec3fDistSq(Vec3f* a, Vec3f* b); f32 Math3D_Distance(Vec3f* a, Vec3f* b); f32 Math3D_DistanceS(Vec3s* s, Vec3f* f); f32 func_8017A7B8(f32* param_1, f32* param_2, f32 param_3, f32 param_4); f32 func_8017A7F8(f32* param_1, f32* param_2, f32 param_3, f32 param_4); f32 func_8017A838(f32* param_1, f32* param_2, f32 param_3, f32 param_4); void Math3D_CrossProduct(Vec3f* a, Vec3f* b, Vec3f* res); -void Math3D_NormalVector(Vec3f* a, Vec3f* b, Vec3f* c, Vec3f* res); -u32 func_8017A954(Vec3f* param_1, Vec3f* param_2, Vec3f* param_3); -u32 func_8017AA0C(Vec3f* param_1, Vec3f* param_2, Vec3f* param_3); -u32 func_8017ABBC(Vec3f* param_1, Vec3f* param_2, Vec3f* param_3); -// void func_8017AD38(void); +void Math3D_SurfaceNorm(Vec3f* a, Vec3f* b, Vec3f* c, Vec3f* res); +u32 Math3D_PointRelativeToCubeFaces(Vec3f* param_1, Vec3f* param_2, Vec3f* param_3); +u32 Math3D_PointRelativeToCubeEdges(Vec3f* param_1, Vec3f* param_2, Vec3f* param_3); +u32 Math3D_PointRelativeToCubeVertices(Vec3f* param_1, Vec3f* param_2, Vec3f* param_3); +s32 Math3D_LineVsCube(Vec3f* min, Vec3f* max, Vec3f* a, Vec3f* b); // void func_8017B68C(void); void func_8017B7F8(Vec3f* arg0, s16 arg1, f32* arg2, f32* arg3, f32* arg4); void Math3D_UnitNormalVector(Vec3f* a, Vec3f* b, Vec3f* c, f32* normX, f32* normY, f32* normZ, f32* param_7); f32 Math3D_SignedDistanceFromPlane(f32 normX, f32 normY, f32 normZ, f32 d, Vec3f* position); // void func_8017B9D8(void); -f32 Math3D_NormalizedDistanceFromPlane(f32 normX, f32 normY, f32 normZ, f32 d, Vec3f* position); -f32 Math3D_NormalizedSignedDistanceFromPlane(f32 normX, f32 normY, f32 normZ, f32 d, Vec3f* position); -// void func_8017BAD0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8); +f32 Math3D_UDistPlaneToPos(f32 normX, f32 normY, f32 normZ, f32 d, Vec3f* position); +f32 Math3D_DistPlaneToPos(f32 normX, f32 normY, f32 normZ, f32 d, Vec3f* position); +s32 Math3D_TriChkPointParaYDist(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 y, f32 z, f32 unk, f32 chkDist, f32 ny); // void func_8017BD98(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); // void func_8017BDE0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_8017BE30(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11); -// void func_8017BEE0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11); +s32 Math3D_TriChkPointParaYIntersectDist(Vec3f* a, Vec3f* b, Vec3f* c, f32 nx, f32 ny, f32 nz, f32 dist, f32 z, f32 x, f32* yIntersect, f32 chkDist); +s32 Math3D_TriChkPointParaYIntersectInsideTri(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 z, f32 x, f32* yIntersect, f32 chkDist); // void func_8017BF8C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -// void func_8017C008(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11, UNK_TYPE4 param_12); +s32 Math3D_TriChkLineSegParaYIntersect(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 z, f32 x, f32* yIntersect, f32 y0, f32 y1); // void func_8017C17C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); // void func_8017C1F0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8); -// void func_8017C494(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11); -// void func_8017C540(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8); +s32 Math3D_TriChkPointParaYIntersectInsideTri2(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 z, f32 x, f32* yIntersect, f32 chkDist); +s32 Math3D_TriChkPointParaXDist(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 y, f32 z, f32 unk, f32 chkDist, f32 nx); // void func_8017C808(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -// void func_8017C850(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10); +s32 Math3D_TriChkPointParaXIntersect(Vec3f* a, Vec3f* b, Vec3f* c, f32 nx, f32 ny, f32 nz, f32 dist, f32 y, f32 z, f32* xIntersect); // void func_8017C904(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -// void func_8017C980(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11, UNK_TYPE4 param_12); +s32 Math3D_TriChkLineSegParaXIntersect(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 y, f32 z, f32* xIntersect, f32 x0, f32 x1); // void func_8017CB08(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -// void func_8017CB7C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8); +s32 Math3D_TriChkLineSegParaZDist(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 y, f32 z, f32 unk, f32 chkDist, f32 nz); // void func_8017CEA8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -// void func_8017CEF0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10); +s32 Math3D_TriChkPointParaZIntersect(Vec3f* a, Vec3f* b, Vec3f* c, f32 nx, f32 ny, f32 nz, f32 dist, f32 x, f32 y, f32* zIntersect); // void func_8017CFA4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -// void func_8017D020(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11, UNK_TYPE4 param_12); +s32 Math3D_TriChkLineSegParaZIntersect(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 x, f32 y, f32* zIntersect, f32 z0, f32 z1); // void func_8017D1AC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); // void func_8017D220(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_8017D2FC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8); @@ -3346,14 +3302,14 @@ u32 Math3D_IsPointInSphere(Sphere16* sphere, Vec3f* point); // void func_8017D814(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_8017D91C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_8017DA24(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -s32 Math3D_ColSphereLineSeg(Sphere16* sphere, LineSegment* line); +s32 Math3D_LineVsSph(Sphere16* sphere, LineSegment* line); void func_8017DD34(Sphere16* sphere, TriNorm* tri, Vec3f* pfParm3); s32 Math3D_ColSphereTri(Sphere16* sphere, TriNorm* tri, Vec3f* uParm3); // void func_8017E294(void); UNK_TYPE func_8017E350(UNK_PTR, Vec3f*, Vec3f*, Vec3f*, Vec3f*); s32 Math3D_ColCylinderTri(Cylinder16* cylinder, TriNorm* tri, Vec3f* pzParm3); // void func_8017F1A0(void); -s32 Math3D_ColSphereSphere(Sphere16* sphere1, Sphere16* sphere2); +s32 Math3D_SphVsSph(Sphere16* sphere1, Sphere16* sphere2); s32 Math3D_ColSphereSphereIntersect(Sphere16* sphere1, Sphere16* sphere2, f32* intersectAmount); s32 Math3D_ColSphereSphereIntersectAndDistance(Sphere16* sphere1, Sphere16* sphere2, f32* intersectAmount, f32* dist); s32 Math3D_ColSphereCylinderDistance(Sphere16* sphere, Cylinder16* cylinder, f32* dist); @@ -3361,9 +3317,9 @@ s32 Math3D_ColSphereCylinderDistanceAndAmount(Sphere16* sphere, Cylinder16* cyli s32 Math3D_ColCylinderCylinderAmount(Cylinder16* cylinder1, Cylinder16* cylinder2, f32* intersectAmount); s32 Math3D_ColCylinderCylinderAmountAndDistance(Cylinder16* cylinder1, Cylinder16* cylinder2, f32* intersectAmount, f32* dist); s32 Math3d_ColTriTri(TriNorm* tri1, TriNorm* tri2, Vec3f* uParm3); -// void func_8017F9C0(void); -// void func_8017FA34(void); -// void func_8017FAA8(void); +s32 Math3D_XZInSphere(Sphere16* sphere, f32 x, f32 z); +s32 Math3D_XYInSphere(Sphere16* sphere, f32 x, f32 y); +s32 Math3D_YZInSphere(Sphere16* sphere, f32 y, f32 z); // void func_8017FB1C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11); // void func_8017FD44(void); u16 Math_GetAtan2Tbl(f32 opposite, f32 adjacent); @@ -3413,10 +3369,12 @@ void func_8018219C(MtxF* pfParm1, Vec3s* psParm2, s32 iParm3); // void func_801822C4(void); void Matrix_InsertRotationAroundUnitVector_f(f32 rotation, Vec3f* vector, s32 appendToState); void Matrix_InsertRotationAroundUnitVector_s(s16 rotation, Vec3f* vector, s32 appendToState); + u64* SysUcode_GetUCodeBoot(void); u32 SysUcode_GetUCodeBootSize(void); u64* SysUcode_GetUCode(void); u64* SysUcode_GetUCodeData(void); + // void func_80182CE0(void); // void func_80183020(void); // void func_80183058(void); @@ -3838,12 +3796,12 @@ void func_8019E014(void); // void func_8019EB2C(void); // void func_8019F024(void); // void func_8019F05C(void); +void func_8019F170(Vec3f* pos, u16 sfxId); +void func_8019F1C0(Vec3f* pos, u16 sfxId); void play_sound(u16 sfxId); void func_8019F128(u16 sfxId); -// void func_8019F170(void); -void func_8019F1C0(Vec3f* pos, u16 sfxId); -void func_8019F208(void); -void func_8019F230(void); // Plays "No" sound +void func_8019F208(void); // decide +void func_8019F230(void); // cancel // void func_8019F258(void); // void func_8019F300(void); void func_8019F420(Vec3f* pos, u16 sfxId); @@ -3865,7 +3823,7 @@ void func_8019FAD8(Vec3f* param_1, u16 param_2, f32 param_3); // void func_8019FD90(void); void func_8019FDC8(UNK_PTR arg0, u16 sfxId, UNK_TYPE arg2); // void func_8019FE1C(void); -// void func_8019FE74(void); +void func_8019FE74(f32* arg0, f32 arg1, s32 arg2); // void func_8019FEDC(void); // void func_8019FF38(void); // void func_8019FF9C(void); @@ -3874,14 +3832,14 @@ void func_8019FDC8(UNK_PTR arg0, u16 sfxId, UNK_TYPE arg2); void func_801A0124(Vec3f* pos, u8 arg1); // void func_801A0184(void); // void func_801A01C4(void); -void func_801A0204(UNK_TYPE); +void func_801A0204(s8 seqId); // void func_801A0238(void); // void func_801A026C(void); // void func_801A0318(void); // void func_801A046C(void); // void func_801A0554(void); // void func_801A05F0(void); -// void func_801A0654(void); +void func_801A0654(Vec3f* arg0, u16 sfxId, s32 arg2); // void func_801A0810(void); // void func_801A0868(void); // void func_801A09D4(void); @@ -3895,10 +3853,10 @@ void func_801A0204(UNK_TYPE); // void func_801A1904(void); // void func_801A1A10(void); // void func_801A1A8C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -void func_801A1D44(Vec3f* vec, UNK_TYPE arg1, f32 arg2); -void func_801A1DB8(Vec3f* vec, UNK_TYPE arg1, f32 arg2); +void func_801A1D44(Vec3f* vec, u8 seqId, f32 arg2); +void func_801A1DB8(Vec3f* vec, u8 seqId, f32 arg2); // void func_801A1E0C(void); -void func_801A1F00(s32 arg0, s32 arg1); +void func_801A1F00(u8 arg0, u16 seqId); void func_801A1F88(void); // void func_801A1FB4(void); // void func_801A2090(void); @@ -3911,20 +3869,20 @@ void func_801A246C(u8 param_1, u8 param_2); // void func_801A27E8(void); // void func_801A281C(void); void func_801A29D4(UNK_TYPE arg0, f32 arg1, UNK_TYPE arg2); -void func_801A2BB8(s32 arg0); +void func_801A2BB8(s32 seqId); void func_801A2C20(void); // void func_801A2C44(void); // void func_801A2C88(void); // void func_801A2D54(void); -s32 func_801A2DE0(UNK_TYPE4 arg1); +s32 Audio_IsSequencePlaying(u8 seqId); void func_801A2E54(s32 param_1); void func_801A2ED8(void); // void func_801A2F88(void); // void func_801A3000(void); // void func_801A3038(void); -void func_801A3098(u16 arg0); +void func_801A3098(u16 seqId); // void func_801A312C(void); -void func_801A31EC(UNK_TYPE1 arg1, UNK_TYPE4 arg2, u8 arg3); +void func_801A31EC(u16 seqId, s8 arg1, u8 arg2); // void func_801A3238(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5); // void func_801A32CC(void); // void func_801A3590(void); @@ -3959,10 +3917,10 @@ void Audio_PreNMI(void); // void func_801A44D4(void); s32 func_801A46F8(void); // void func_801A4748(void); -// void func_801A479C(void); +void func_801A479C(Vec3f* arg0, u16 sfxId, s32 arg2); // void func_801A47DC(void); // void func_801A48E0(void); -// void func_801A4A28(void); +void func_801A4A28(s32 arg0); // void func_801A4B80(void); void func_801A4C30(void); // void func_801A4C54(void); @@ -3974,8 +3932,8 @@ void func_801A4D00(void); // void func_801A4EB0(void); // void func_801A4EB8(void); // void func_801A4FD8(void); -// void func_801A5080(void); -// void func_801A5100(void); +void func_801A5080(u16 arg0); +u16 func_801A5100(void); // void func_801A5118(void); UNK_TYPE func_801A51F0(UNK_TYPE arg0); // void func_801A5228(void); @@ -4025,18 +3983,7 @@ s32 func_801A8A50(s32 param1); // void func_801A982C(void); // void func_801A99B8(void); // void func_801A9A74(void); -// void func_801A9B10(void); -// void func_801A9B78(void); -// void func_801A9BFC(void); -// void func_801A9C68(void); -// void func_801A9D10(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5); -// void func_801A9DCC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5); -// void func_801A9EA4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE1 param_6); -// void func_801A9F4C(void); -// void func_801AA020(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_801AA248(void); -// void func_801AA3E4(void); -// void func_801AA520(void); + void GameOver_Init(GlobalContext* globalCtx); void GameOver_FadeLights(GlobalContext* globalCtx); void GameOver_Update(GlobalContext* globalCtx); diff --git a/include/irqmgr.h b/include/irqmgr.h new file mode 100644 index 0000000000..40ed322d13 --- /dev/null +++ b/include/irqmgr.h @@ -0,0 +1,27 @@ +#ifndef IRQMGR_H +#define IRQMGR_H + +#include "PR/ultratypes.h" +#include "PR/sched.h" +#include "ultra64/message.h" + +typedef struct IrqMgrClient { + /* 0x0 */ struct IrqMgrClient* next; + /* 0x4 */ OSMesgQueue* queue; +} IrqMgrClient; // size = 0x8 + +typedef struct { + /* 0x000 */ OSScMsg verticalRetraceMesg; + /* 0x020 */ OSScMsg prenmiMsg; + /* 0x040 */ OSScMsg nmiMsg; + /* 0x060 */ OSMesgQueue irqQueue; + /* 0x078 */ OSMesg irqBuffer[8]; + /* 0x098 */ OSThread thread; + /* 0x248 */ IrqMgrClient* callbacks; + /* 0x24C */ u8 prenmiStage; + /* 0x250 */ OSTime lastPrenmiTime; + /* 0x258 */ OSTimer prenmiTimer; + /* 0x278 */ OSTime lastFrameTime; +} IrqMgr; // size = 0x280 + +#endif diff --git a/include/macros.h b/include/macros.h index 6d1e6f4bff..6dc1e5e4e4 100644 --- a/include/macros.h +++ b/include/macros.h @@ -5,6 +5,12 @@ #include "convert.h" #include "z64.h" +#define SCREEN_WIDTH 320 +#define SCREEN_HEIGHT 240 + +#define SCREEN_WIDTH_HIGH_RES 576 +#define SCREEN_HEIGHT_HIGH_RES 454 + #define ARRAY_COUNT(arr) (s32)(sizeof(arr) / sizeof(arr[0])) #define ARRAY_COUNTU(arr) (u32)(sizeof(arr) / sizeof(arr[0])) @@ -124,7 +130,7 @@ extern GraphicsContext* __gfxCtx; #define SQ(x) ((x) * (x)) #define ABS(x) ((x) >= 0 ? (x) : -(x)) #define ABS_ALT(x) ((x) < 0 ? -(x) : (x)) -#define DECR(x) ((x) == 0 ? 0 : ((x) -= 1)) +#define DECR(x) ((x) == 0 ? 0 : --(x)) #define CLAMP(x, min, max) ((x) < (min) ? (min) : (x) > (max) ? (max) : (x)) #define CLAMP_MAX(x, max) ((x) > (max) ? (max) : (x)) diff --git a/include/os.h b/include/os.h index 568cc17942..838d8234ac 100644 --- a/include/os.h +++ b/include/os.h @@ -1,6 +1,7 @@ #ifndef _OS_H_ #define _OS_H_ +#include "libc/stdint.h" #include "libc/stdlib.h" #include "ultra64/thread.h" #include "ultra64/message.h" @@ -53,8 +54,8 @@ typedef struct { } __OSTranxInfo; // size = 0x60 -typedef struct OSPiHandle_s { - /* 0x00 */ struct OSPiHandle_s* next; +typedef struct OSPiHandle { + /* 0x00 */ struct OSPiHandle* next; /* 0x04 */ u8 type; /* 0x05 */ u8 latency; /* 0x06 */ u8 pageSize; @@ -84,7 +85,7 @@ typedef struct { typedef struct { /* 0x00 */ OSIoMesgHdr hdr; /* 0x08 */ void* dramAddr; - /* 0x0C */ u32 devAddr; + /* 0x0C */ uintptr_t devAddr; /* 0x10 */ size_t size; /* 0x14 */ OSPiHandle* piHandle; } OSIoMesg; // size = 0x88 diff --git a/include/scheduler.h b/include/scheduler.h new file mode 100644 index 0000000000..3cf588b1f1 --- /dev/null +++ b/include/scheduler.h @@ -0,0 +1,47 @@ +#ifndef SCHEDULER_H +#define SCHEDULER_H + +#include "PR/ultratypes.h" +#include "PR/sched.h" +#include "ultra64/vi.h" +#include "ultra64/sptask.h" +#include "irqmgr.h" + +#define TASK_FRAMEBUFFER(task) ((CfbInfo*)(task)->framebuffer) + +typedef struct { + /* 0x00 */ u16* fb1; + /* 0x04 */ u16* swapBuffer; + /* 0x08 */ OSViMode* viMode; + /* 0x0C */ u32 features; + /* 0x10 */ u8 unk_10; + /* 0x11 */ s8 updateRate; + /* 0x12 */ s8 updateRate2; + /* 0x13 */ u8 unk_13; + /* 0x14 */ f32 xScale; + /* 0x18 */ f32 yScale; +} CfbInfo; // size = 0x1C + +typedef struct { + /* 0x000 */ OSMesgQueue interruptQ; + /* 0x018 */ OSMesg intBuf[64]; + /* 0x118 */ OSMesgQueue cmdQ; + /* 0x130 */ OSMesg cmdMsgBuf[8]; + /* 0x150 */ OSThread thread; + /* 0x300 */ OSScTask* audioListHead; + /* 0x304 */ OSScTask* gfxListHead; + /* 0x308 */ OSScTask* audioListTail; + /* 0x30C */ OSScTask* gfxListTail; + /* 0x310 */ OSScTask* curRSPTask; + /* 0x314 */ OSScTask* curRDPTask; + /* 0x318 */ s32 retraceCount; + /* 0x318 */ s32 doAudio; + /* 0x320 */ CfbInfo* curBuf; + /* 0x324 */ CfbInfo* pendingSwapBuf1; + /* 0x328 */ CfbInfo* pendingSwapBuf2; + /* 0x32C */ char unk_32C[0x3]; + /* 0x32F */ u8 shouldUpdateVi; + /* 0x330 */ IrqMgrClient irqClient; +} SchedContext; // size = 0x338 + +#endif diff --git a/include/segment_symbols.h b/include/segment_symbols.h index a2dc30ff39..0044936729 100644 --- a/include/segment_symbols.h +++ b/include/segment_symbols.h @@ -1161,7 +1161,9 @@ DECLARE_ROM_SEGMENT(scene_texture_07) DECLARE_ROM_SEGMENT(scene_texture_08) DECLARE_ROM_SEGMENT(nintendo_rogo_static) DECLARE_ROM_SEGMENT(title_static) +DECLARE_SEGMENT(memerrmsg) DECLARE_ROM_SEGMENT(memerrmsg) +DECLARE_SEGMENT(locerrmsg) DECLARE_ROM_SEGMENT(locerrmsg) DECLARE_ROM_SEGMENT(parameter_static) DECLARE_ROM_SEGMENT(week_static) diff --git a/include/ultra64.h b/include/ultra64.h index d309026b97..49323cc2bd 100644 --- a/include/ultra64.h +++ b/include/ultra64.h @@ -11,6 +11,7 @@ #include "ultra64/sptask.h" #include "ultra64/thread.h" #include "ultra64/rcp.h" +#include "ultra64/rdp.h" #include "ultra64/rsp.h" #include "ultra64/vi.h" diff --git a/include/ultra64/hardware.h b/include/ultra64/hardware.h index c3eb8dd4cb..ae6470d51d 100644 --- a/include/ultra64/hardware.h +++ b/include/ultra64/hardware.h @@ -96,6 +96,7 @@ #define SI_STATUS_INTERRUPT (1 << 12) #define PIF_RAM_START 0x1FC007C0 +#define PIF_RAM_SIZE 0x40 #define MI_INIT_MODE_REG 0x04300000 #define MI_MODE_REG MI_INIT_MODE_REG diff --git a/include/ultra64/rdp.h b/include/ultra64/rdp.h new file mode 100644 index 0000000000..b4b3bb532f --- /dev/null +++ b/include/ultra64/rdp.h @@ -0,0 +1,45 @@ +#ifndef ULTRA64_RDP_H +#define ULTRA64_RDP_H + +/* DP Command Registers */ +#define DPC_START_REG 0x04100000 +#define DPC_END_REG 0x04100004 +#define DPC_CURRENT_REG 0x04100008 +#define DPC_STATUS_REG 0x0410000C +#define DPC_CLOCK_REG 0x04100010 +#define DPC_BUFBUSY_REG 0x04100014 +#define DPC_PIPEBUSY_REG 0x04100018 +#define DPC_TMEM_REG 0x0410001C + +/* DP Span Registers */ +#define DPS_TBIST_REG 0x04200000 +#define DPS_TEST_MODE_REG 0x04200004 +#define DPS_BUFTEST_ADDR_REG 0x04200008 +#define DPS_BUFTEST_DATA_REG 0x0420000C + +/* DP Status Read Flags */ +#define DPC_STATUS_XBUS_DMEM_DMA (1 << 0) +#define DPC_STATUS_FREEZE (1 << 1) +#define DPC_STATUS_FLUSH (1 << 2) +#define DPC_STATUS_START_GCLK (1 << 3) +#define DPC_STATUS_TMEM_BUSY (1 << 4) +#define DPC_STATUS_PIPE_BUSY (1 << 5) +#define DPC_STATUS_CMD_BUSY (1 << 6) +#define DPC_STATUS_CBUF_READY (1 << 7) +#define DPC_STATUS_DMA_BUSY (1 << 8) +#define DPC_STATUS_END_VALID (1 << 9) +#define DPC_STATUS_START_VALID (1 << 10) + +/* DP Status Write Flags */ +#define DPC_CLR_XBUS_DMEM_DMA (1 << 0) +#define DPC_SET_XBUS_DMEM_DMA (1 << 1) +#define DPC_CLR_FREEZE (1 << 2) +#define DPC_SET_FREEZE (1 << 3) +#define DPC_CLR_FLUSH (1 << 4) +#define DPC_SET_FLUSH (1 << 5) +#define DPC_CLR_TMEM_CTR (1 << 6) +#define DPC_CLR_PIPE_CTR (1 << 7) +#define DPC_CLR_CMD_CTR (1 << 8) +#define DPC_CLR_CLOCK_CTR (1 << 9) + +#endif diff --git a/include/ultra64/vi.h b/include/ultra64/vi.h index 67d7f681db..ca9b8e45eb 100644 --- a/include/ultra64/vi.h +++ b/include/ultra64/vi.h @@ -1,17 +1,18 @@ #ifndef _ULTRA64_VI_H_ #define _ULTRA64_VI_H_ +#include "PR/ultratypes.h" #include "ultra64/message.h" /* Special Features */ -#define OS_VI_GAMMA_ON 0x0001 -#define OS_VI_GAMMA_OFF 0x0002 -#define OS_VI_GAMMA_DITHER_ON 0x0004 -#define OS_VI_GAMMA_DITHER_OFF 0x0008 -#define OS_VI_DIVOT_ON 0x0010 -#define OS_VI_DIVOT_OFF 0x0020 -#define OS_VI_DITHER_FILTER_ON 0x0040 -#define OS_VI_DITHER_FILTER_OFF 0x0080 +#define OS_VI_GAMMA_ON (1 << 0) +#define OS_VI_GAMMA_OFF (1 << 1) +#define OS_VI_GAMMA_DITHER_ON (1 << 2) +#define OS_VI_GAMMA_DITHER_OFF (1 << 3) +#define OS_VI_DIVOT_ON (1 << 4) +#define OS_VI_DIVOT_OFF (1 << 5) +#define OS_VI_DITHER_FILTER_ON (1 << 6) +#define OS_VI_DITHER_FILTER_OFF (1 << 7) #define OS_VI_GAMMA 0x08 #define OS_VI_GAMMA_DITHER 0x04 diff --git a/include/variables.h b/include/variables.h index 281996873f..baf145e0f8 100644 --- a/include/variables.h +++ b/include/variables.h @@ -3,15 +3,16 @@ #include "z64.h" #include "segment_symbols.h" +#include "macros.h" // pre-boot variables extern u32 osTvType; extern u32 osRomType; -extern u32 osRomBase; +extern uintptr_t osRomBase; extern u32 osResetType; extern u32 osCicId; extern u32 osVersion; -extern u32 osMemSize; +extern size_t osMemSize; extern s32 osAppNmiBuffer[0x10]; extern u16 gFramebuffer1[SCREEN_HEIGHT][SCREEN_WIDTH]; // at 0x80000500 extern u8 D_80025D00[]; @@ -84,7 +85,7 @@ extern OSViMode osViModeMpalLan1; // extern __OSViContext D_80098060[2]; extern __OSViContext* __osViCurr; extern __OSViContext* __osViNext; -// extern UNK_TYPE4 D_800980D0; +// extern UNK_TYPE4 sCartRomNeedsInit; extern OSViMode osViModeFpalLan1; // extern u8 ldigs[]; // extern u8 udigs[]; @@ -359,7 +360,7 @@ extern u16 viRetrace; extern DmaEntry dmadata[1568]; // extern UNK_TYPE1 D_80186028; // extern UNK_TYPE1 D_801AAAB0; -// extern UNK_TYPE1 D_801AD370; +extern u64 gJpegUCode[]; extern ActorInit En_A_Obj_InitVars; extern ColliderCylinderInit enAObjCylinderInit; extern InitChainEntry enAObjInitVar; @@ -441,14 +442,8 @@ extern Gfx D_801AEFA0[]; // extern UNK_TYPE1 D_801AEFC0; extern ActorOverlay gActorOverlayTable[ACTOR_ID_MAX]; extern s32 gMaxActorId; -extern u32 D_801B4620[32]; -extern u16 D_801B46A0[16]; -extern u8 D_801B46C0[16]; -extern s16 bgSpecialSceneParamsDefault[1]; -// extern UNK_TYPE1 D_801B46D2; -extern BgSpecialSceneMaxMemory bgSpecialSceneMaxMemory[1]; -extern BgSpecialSceneMeshSubdivision bgSpecialSceneMeshSubdivisions[3]; -extern BgSpecialSceneMaxObjects bgSpecialSceneMaxObjects[1]; +extern BgCheckSceneSubdivisionEntry sSceneSubdivisionList[]; +extern BgSpecialSceneMaxObjects sCustomDynapolyMem[]; // extern UNK_TYPE1 D_801B4708; // extern UNK_TYPE1 D_801B4710; // extern UNK_TYPE1 D_801B4738; @@ -917,7 +912,7 @@ extern s32 graphNumGameStates; // extern UNK_TYPE2 D_801BDA7C; extern s32 D_801BDA9C; extern UNK_TYPE4 D_801BDAA0; -// extern UNK_TYPE4 D_801BDAA4; +extern UNK_TYPE4 D_801BDAA4; // extern UNK_TYPE2 D_801BDAA8; // extern UNK_TYPE2 D_801BDAAA; // extern UNK_TYPE2 D_801BDAAC; @@ -1709,7 +1704,7 @@ extern UNK_PTR D_801D618C; // extern UNK_TYPE1 D_801D6648; // extern UNK_TYPE1 D_801D664C; // extern UNK_TYPE1 D_801D6650; -// extern UNK_TYPE4 D_801D6654; +extern f32 D_801D6654; // extern UNK_TYPE1 D_801D6658; // extern UNK_TYPE1 D_801D665C; // extern UNK_TYPE1 D_801D6660; @@ -1827,14 +1822,14 @@ extern UNK_PTR D_801D8B24; // extern UNK_TYPE1 D_801D8E48; // extern UNK_TYPE1 D_801D8E50; // extern UNK_TYPE1 D_801D8F70; -// extern UNK_TYPE1 D_801D9090; -// extern UNK_TYPE1 D_801D9C10; -// extern UNK_TYPE1 D_801DA350; -// extern UNK_TYPE1 D_801DA510; -// extern UNK_TYPE1 D_801DAC50; -// extern UNK_TYPE1 D_801DADD0; -// extern UNK_TYPE1 D_801DAE10; -extern UNK_PTR D_801DB450; +// extern SfxParams sEnemyBankParams[]; +// extern SfxParams sPlayerBankParams[]; +// extern SfxParams sItemBankParams[]; +// extern SfxParams sEnvBankParams[]; +// extern SfxParams sSystemBankParams[]; +// extern SfxParams sOcarinaBankParams[]; +// extern SfxParams sVoiceBankParams[]; +extern SfxParams* gSfxParams[7]; // extern UNK_TYPE1 D_801DB470; // extern UNK_TYPE1 D_801DB474; extern UNK_PTR D_801DB478[7]; @@ -1866,7 +1861,7 @@ extern s8 D_801DB4B8; // extern UNK_TYPE1 D_801DB8B8; // extern UNK_TYPE1 D_801DB900; extern UNK_PTR D_801DB930; -extern s8018CFAC D_801DB958[21]; +extern AudioSpec D_801DB958[21]; // rodata extern f32 D_801DBDF0; @@ -3106,7 +3101,7 @@ extern UNK_PTR D_801E10B0; // extern UNK_TYPE1 D_801E1E80; // extern UNK_TYPE1 D_801E2160; // extern UNK_TYPE1 D_801E3790; -// extern UNK_TYPE1 D_801E3F40; +extern u64 gJpegUCodeData[]; // extern UNK_TYPE1 D_801E3FA0; // bss @@ -3138,28 +3133,15 @@ extern FaultClient D_801ED930; extern FaultAddrConvClient D_801ED940; extern char D_801ED950[80]; extern char D_801ED9A0[80]; -extern Vec3f D_801ED9F0; -extern Vec3f D_801ED9FC; -extern Vec3f D_801EDA08; -extern Vec3f D_801EDA18; -extern Vec3f D_801EDA24; -extern Vec3f D_801EDA30; +extern Vec3f D_801ED9F0[3]; +extern Vec3f D_801EDA18[3]; extern MtxF D_801EDA40; -extern Vec3f D_801EDA80; -extern Vec3f D_801EDA8C; -extern Vec3f D_801EDA98; +extern Vec3f D_801EDA80[3]; extern char D_801EDAA8[80]; extern char D_801EDAF8[80]; -extern Vec3f D_801EDB48; -extern Vec3f D_01EDB54; -extern Vec3f D_01EDB60; -extern Vec3f D_01EDB70; -extern Vec3f D_801EDB7C; -extern Vec3f D_801EDB88; -extern f32 D_801EDB98; -extern f32 D_801EDB9C; -extern f32 D_801EDBA0; -// extern UNK_TYPE1 D_801EDBA4; +extern Vec3f D_801EDB48[3]; +extern Vec3f D_801EDB70[3]; +extern Plane D_801EDB98; extern Sphere16 D_801EDBA8; extern TriNorm D_801EDBB0; // extern UNK_TYPE1 D_801EDBD4; @@ -3272,7 +3254,7 @@ extern u8 D_801F4E30; // extern UNK_TYPE1 D_801F4E68; extern f32 D_801F4E70; // extern UNK_TYPE1 D_801F4E74; -// extern UNK_TYPE1 D_801F4E78; +extern u16 D_801F4E78; extern s16 D_801F4E7A; // extern UNK_TYPE1 D_801F4E80; // extern UNK_TYPE1 D_801F4EE0; @@ -3634,7 +3616,7 @@ extern OSMesg D_801FD034; // extern UNK_TYPE1 D_801FE4C0; // extern UNK_TYPE1 D_801FE640; // extern UNK_TYPE1 D_801FE6D0; -extern s801FE7C0 D_801FE7C0[1]; +extern SoundRequest D_801FE7C0[1]; // extern UNK_TYPE1 D_801FFBC0; // extern UNK_TYPE1 D_801FFBC8; // extern UNK_TYPE1 D_801FFBD0; @@ -3788,11 +3770,6 @@ extern OSMesg D_80203290[1]; // extern UNK_TYPE4 D_80208E6C; // extern UNK_TYPE4 D_80208E70; // extern UNK_TYPE4 D_80208E74; -// extern UNK_TYPE1 D_80208E90; -// extern UNK_TYPE1 D_80208E94; -// extern UNK_TYPE1 D_80208E98; -// extern UNK_TYPE1 D_80208E99; -// extern UNK_TYPE1 D_80208E9C; // post-code buffers extern u8 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE]; diff --git a/include/z64.h b/include/z64.h index 4acffe880b..23f8c7df84 100644 --- a/include/z64.h +++ b/include/z64.h @@ -13,15 +13,18 @@ #include "io/controller.h" #include "osint.h" #include "os.h" +#include "irqmgr.h" +#include "scheduler.h" #include "xstdio.h" #include "bgm.h" -#include "sfx.h" #include "color.h" #include "ichain.h" +#include "sfx.h" #include "z64actor.h" #include "z64animation.h" +#include "z64audio.h" #include "z64bgcheck.h" #include "z64collision_check.h" #include "z64cutscene.h" @@ -37,12 +40,6 @@ #include "z64transition.h" #include "regs.h" -#define SCREEN_WIDTH 320 -#define SCREEN_HEIGHT 240 - -#define SCREEN_WIDTH_HIGH_RES 576 -#define SCREEN_HEIGHT_HIGH_RES 454 - #define Z_THREAD_ID_IDLE 1 #define Z_THREAD_ID_SLOWLY 2 #define Z_THREAD_ID_MAIN 3 @@ -79,13 +76,6 @@ typedef struct { /* 0xF */ u8 letterboxSize; } ActorCutscene; // size = 0x10 -typedef struct { - /* 0x0 */ s16 polyStartIndex; - /* 0x2 */ s16 ceilingNodeHead; - /* 0x4 */ s16 wallNodeHead; - /* 0x6 */ s16 floorNodeHead; -} ActorMeshPolyLists; // size = 0x8 - typedef struct { /* 0x0 */ s8 segment; /* 0x2 */ s16 type; @@ -106,49 +96,6 @@ typedef struct { /* 0x08 */ void* end; } PolygonType2; // size = 0xC -typedef struct { - /* 0x0 */ u16 floorHead; - /* 0x2 */ u16 wallHead; - /* 0x4 */ u16 ceilingHead; -} BgMeshSubdivision; // size = 0x6 - -typedef struct { - /* 0x0 */ u32 attributes[2]; -} BgPolygonAttributes; // size = 0x8 - -typedef struct { - /* 0x0 */ s16 polyIndex; - /* 0x2 */ u16 next; -} BgPolygonLinkedListNode; // size = 0x4 - -typedef struct { - /* 0x0 */ u16 maxNodes; - /* 0x2 */ u16 reservedNodes; - /* 0x4 */ BgPolygonLinkedListNode* nodes; - /* 0x8 */ u8* unk8; -} BgScenePolygonLists; // size = 0xC - -typedef struct { - /* 0x0 */ s16 sceneNumber; - /* 0x2 */ UNK_TYPE1 pad2[0x2]; - /* 0x4 */ u32 maxMemory; -} BgSpecialSceneMaxMemory; // size = 0x8 - -typedef struct { - /* 0x0 */ s16 sceneId; - /* 0x2 */ s16 maxNodes; - /* 0x4 */ s16 maxPolygons; - /* 0x6 */ s16 maxVertices; -} BgSpecialSceneMaxObjects; // size = 0x8 - -typedef struct { - /* 0x0 */ s16 sceneNumber; - /* 0x2 */ s16 xSubdivisions; - /* 0x4 */ s16 ySubdivisions; - /* 0x6 */ s16 zSubdivisions; - /* 0x8 */ s32 unk8; -} BgSpecialSceneMeshSubdivision; // size = 0xC - typedef struct { /* 0x0 */ s16 func; /* 0x2 */ UNK_TYPE1 pad2[0x6]; @@ -249,30 +196,6 @@ typedef struct { /* 0x14 */ s16 data[REG_GROUPS * REG_PER_GROUP]; // 0xAE0 entries } GameInfo; // size = 0x15D4 -typedef struct IrqMgrClient { - /* 0x0 */ struct IrqMgrClient* next; - /* 0x4 */ OSMesgQueue* queue; -} IrqMgrClient; // size = 0x8 - -typedef struct { - /* 0x0 */ s16 type; - /* 0x2 */ u8 misc[30]; -} OSScMsg; - -typedef struct { - /* 0x000 */ OSScMsg verticalRetraceMesg; - /* 0x020 */ OSScMsg prenmiMsg; - /* 0x040 */ OSScMsg nmiMsg; - /* 0x060 */ OSMesgQueue irqQueue; - /* 0x078 */ OSMesg irqBuffer[8]; - /* 0x098 */ OSThread thread; - /* 0x248 */ IrqMgrClient* callbacks; - /* 0x24C */ u8 prenmiStage; - /* 0x250 */ OSTime lastPrenmiTime; - /* 0x258 */ OSTimer prenmiTimer; - /* 0x278 */ OSTime lastFrameTime; -} IrqMgr; // size = 0x280 - typedef struct { /* 0x0000 */ u32 size; /* 0x0004 */ void* bufp; @@ -316,44 +239,6 @@ typedef struct { /* 0x20308 */ u16 tailMagic; // 5678 } GfxPool; // size = 0x20310 -typedef struct { - /* 0x00 */ u16* fb1; - /* 0x04 */ u16* swapBuffer; - /* 0x08 */ OSViMode* viMode; - /* 0x0C */ u32 features; - /* 0x10 */ u8 unk_10; - /* 0x11 */ s8 updateRate; - /* 0x12 */ s8 updateRate2; - /* 0x13 */ u8 unk_13; - /* 0x14 */ f32 xScale; - /* 0x18 */ f32 yScale; -} CfbInfo; // size = 0x1C - -#define OS_SC_NEEDS_RDP 0x0001 -#define OS_SC_NEEDS_RSP 0x0002 -#define OS_SC_DRAM_DLIST 0x0004 -#define OS_SC_PARALLEL_TASK 0x0010 -#define OS_SC_LAST_TASK 0x0020 -#define OS_SC_SWAPBUFFER 0x0040 - -#define OS_SC_RCP_MASK 0x0003 -#define OS_SC_TYPE_MASK 0x0007 - -#define OS_SC_DP 0x0001 -#define OS_SC_SP 0x0002 -#define OS_SC_YIELD 0x0010 -#define OS_SC_YIELDED 0x0020 - -typedef struct OSScTask { - /* 0x00 */ struct OSScTask* next; - /* 0x04 */ u32 state; - /* 0x08 */ u32 flags; - /* 0x0C */ CfbInfo* framebuffer; - /* 0x10 */ OSTask list; - /* 0x50 */ OSMesgQueue* msgQ; - /* 0x54 */ OSMesg msg; -} OSScTask; // size = 0x58 - typedef struct GraphicsContext { /* 0x000 */ Gfx* polyOpaBuffer; // Pointer to "Zelda 0" /* 0x004 */ Gfx* polyXluBuffer; // Pointer to "Zelda 1" @@ -392,28 +277,6 @@ typedef struct GraphicsContext { /* 0x2FC */ GfxMasterList* masterList; } GraphicsContext; // size = 0x300 -typedef struct { - /* 0x000 */ OSMesgQueue interruptQ; - /* 0x018 */ OSMesg intBuf[64]; - /* 0x118 */ OSMesgQueue cmdQ; - /* 0x130 */ OSMesg cmdMsgBuf[8]; - /* 0x150 */ OSThread thread; - /* 0x300 */ OSScTask* audioListHead; - /* 0x304 */ OSScTask* gfxListHead; - /* 0x308 */ OSScTask* audioListTail; - /* 0x30C */ OSScTask* gfxListTail; - /* 0x310 */ OSScTask* curRSPTask; - /* 0x314 */ OSScTask* curRDPTask; - /* 0x318 */ s32 retraceCount; - /* 0x318 */ s32 doAudio; - /* 0x320 */ CfbInfo* curBuf; - /* 0x324 */ CfbInfo* pendingSwapBuf1; - /* 0x328 */ CfbInfo* pendingSwapBuf2; - /* 0x32C */ char unk_32C[0x3]; - /* 0x32F */ u8 shouldUpdateVi; - /* 0x330 */ IrqMgrClient irqClient; -} SchedContext; // size = 0x338 - typedef enum IRQ_MSG_TYPE { IRQ_VERTICAL_RETRACE_MSG = 0x1, IRQ_PRENMI_2_MSG = 0x3, @@ -528,29 +391,6 @@ typedef struct { /* 0x14 */ OSMesgQueue unk14; } s80185D40; // size = 0x2C -typedef struct { - /* 0x00 */ u32 unk0; - /* 0x04 */ u8 unk4; - /* 0x05 */ u8 unk5; - /* 0x06 */ u8 unk6; - /* 0x07 */ UNK_TYPE1 pad7[0x2]; - /* 0x09 */ u8 unk9; - /* 0x0A */ UNK_TYPE1 padA[0x2]; - /* 0x0C */ u32 unkC; - /* 0x10 */ u16 unk10; - /* 0x12 */ u16 unk12; - /* 0x14 */ u16 unk14; - /* 0x16 */ UNK_TYPE1 pad16[0x2]; - /* 0x18 */ u32 unk18; - /* 0x1C */ u32 unk1C; - /* 0x20 */ u32 unk20; - /* 0x24 */ u32 unk24; - /* 0x28 */ u32 unk28; - /* 0x2C */ u32 unk2C; - /* 0x30 */ u32 unk30; - /* 0x34 */ u32 unk34; -} s8018CFAC; // size = 0x38 - typedef struct { /* 0x0 */ u8 unk0; /* 0x1 */ u8 unk1; @@ -562,10 +402,6 @@ typedef struct { /* 0x7 */ u8 unk7; } s801AEC84; // size = 0x8 -typedef struct { - /* 0x00 */ UNK_TYPE1 pad0[0x14]; -} s801FE7C0; // size = 0x14 - typedef struct { /* 0x00 */ Vec3f unk0; /* 0x0C */ Vec3f unkC; @@ -573,18 +409,6 @@ typedef struct { /* 0x1A */ s16 unk1A; } s80874650; // size = 0x1C -typedef struct { - /* 0x00 */ Vec3f scale; - /* 0x0C */ Vec3s rotation; - /* 0x14 */ Vec3f pos; -} ActorMeshParams; // size = 0x20 - -typedef struct { - /* 0x0 */ BgPolygonLinkedListNode* nodes; - /* 0x4 */ u32 nextFreeNode; - /* 0x8 */ s32 maxNodes; -} BgPolygonLinkedList; // size = 0xC - typedef struct { /* 0x00 */ f32 x[4]; /* 0x10 */ f32 y[4]; @@ -592,15 +416,20 @@ typedef struct { /* 0x30 */ f32 w[4]; } z_Matrix; // size = 0x40 -typedef struct { - /* 0x0 */ Vec3s pos; -} BgVertex; // size = 0x6 - typedef union { F3DVertexColor color; F3DVertexNormal normal; } F3DVertex; // size = 0x10 +// End of RDRAM without the Expansion Pak installed +#define NORMAL_RDRAM_END 0x80400000 +// End of RDRAM with the Expansion Pak installed +#define EXPANDED_RDRAM_END 0x80800000 +// Address at the end of normal RDRAM after which is room for a screen buffer +#define FAULT_FB_ADDRESS (NORMAL_RDRAM_END - sizeof(u16[SCREEN_HEIGHT][SCREEN_WIDTH])) + +typedef void (*FaultDrawerCallback)(void); + typedef struct { /* 0x00 */ u16* fb; /* 0x04 */ u16 w; @@ -613,7 +442,7 @@ typedef struct { /* 0x12 */ u16 backColor; /* 0x14 */ u16 cursorX; /* 0x16 */ u16 cursorY; - /* 0x18 */ u32* font; + /* 0x18 */ const u32* font; /* 0x1C */ u8 charW; /* 0x1D */ u8 charH; /* 0x1E */ s8 charWPad; @@ -621,7 +450,7 @@ typedef struct { /* 0x20 */ u16 printColors[10]; /* 0x34 */ u8 escCode; /* 0x35 */ u8 osSyncPrintfEnabled; - /* 0x38 */ void* inputCallback; + /* 0x38 */ FaultDrawerCallback inputCallback; } FaultDrawer; // size = 0x3C typedef struct GfxPrint { @@ -689,12 +518,6 @@ typedef struct { typedef void(*fault_update_input_func)(Input* input); -typedef struct { - /* 0x00 */ u8 noteIdx; - /* 0x01 */ u8 state; - /* 0x02 */ u8 pos; -} OcarinaStaff; // size = 0x3; - typedef struct { /* 0x000 */ View view; /* 0x168 */ u8* iconItemSegment; @@ -1029,7 +852,7 @@ typedef struct { /* 0x11F23 */ UNK_TYPE1 pad11F23[0xFD]; /* 0x12020 */ u8 unk12020; /* 0x12021 */ u8 choiceIndex; - /* 0x12022 */ UNK_TYPE1 unk12022; + /* 0x12022 */ u8 unk12022; /* 0x12023 */ u8 unk12023; /* 0x12024 */ UNK_TYPE1 unk12024[0x6]; /* 0x1202A */ u16 unk1202A; @@ -1037,7 +860,9 @@ typedef struct { /* 0x1202E */ u16 unk1202E; /* 0x12030 */ UNK_TYPE1 pad12030[0x14]; /* 0x12044 */ s16 unk12044; - /* 0x12046 */ UNK_TYPE1 pad12046[0x24]; + /* 0x12046 */ UNK_TYPE1 pad12046[0x2]; + /* 0x12048 */ u8 unk12048; // EnKakasi + /* 0x12049 */ UNK_TYPE1 pad12049[0x21]; /* 0x1206A */ s16 unk1206A; /* 0x1206C */ s32 unk1206C; /* 0x12070 */ UNK_TYPE1 pad12070[0x8]; @@ -1376,12 +1201,6 @@ typedef struct ActorListEntry { #define OS_SC_NMI_MSG 3 // name is made up, 3 is OS_SC_RDP_DONE_MSG in the original sched.c #define OS_SC_PRE_NMI_MSG 4 -typedef struct { - /* 0x0000 */ OSTask task; - /* 0x0040 */ OSMesgQueue* taskQueue; - /* 0x0044 */ char unk_44[0xC]; -} AudioTask; // size = 0x50 - typedef struct { /* 0x000 */ IrqMgr* irqMgr; /* 0x004 */ SchedContext* sched; @@ -1456,7 +1275,7 @@ struct TargetContext { /* 0x50 */ TargetContextEntry unk50[3]; /* 0x8C */ Actor* unk8C; /* 0x90 */ Actor* unk90; - /* 0x94 */ UNK_TYPE1 pad94[0x4]; + /* 0x94 */ Actor* unk_94; }; // size = 0x98 struct s800B948C { @@ -1646,6 +1465,38 @@ typedef struct { /* 0x8 */ s32 unk8; } struct_80133038_arg2; // size = 0xC +typedef s32 (*func_8013E748_arg6)(struct GlobalContext*, Actor*, Vec3s*); + +typedef s32 (*func_8013E640_arg6)(struct GlobalContext*, Actor*, Actor*, void*); + +struct struct_8013DF3C_arg1; +typedef void (*struct_8013DF3C_arg1_unk_func1)(struct GlobalContext*, struct struct_8013DF3C_arg1*); +typedef s32 (*struct_8013DF3C_arg1_unk_func2)(struct GlobalContext*, struct struct_8013DF3C_arg1*); + +typedef struct struct_8013DF3C_arg1 { + /* 0x00 */ Path* setupPathList; + /* 0x04 */ s32 pathIndex; + /* 0x08 */ Vec3s* points; + /* 0x0C */ s32 count; + /* 0x10 */ s32 unk_10; + /* 0x14 */ s32 unk_14; + /* 0x18 */ s32 unk_18; + /* 0x1C */ u8 unk_1C; + /* 0x1D */ u8 unk_1D; + /* 0x20 */ Vec3f unk_20; + /* 0x2C */ Vec3f unk_2C; + /* 0x38 */ Vec3f unk_38; + /* 0x44 */ Vec3f* unk_44; + /* 0x48 */ Actor* actor; + /* 0x4C */ f32 unk_4C; + /* 0x50 */ f32 unk_50; + /* 0x54 */ Vec3s unk_54; + /* 0x5C */ struct_8013DF3C_arg1_unk_func1 unk_5C; + /* 0x60 */ struct_8013DF3C_arg1_unk_func2 unk_60; + /* 0x64 */ struct_8013DF3C_arg1_unk_func2 unk_64; + /* 0x68 */ struct_8013DF3C_arg1_unk_func2 unk_68; +} struct_8013DF3C_arg1; // size = 0x6C + typedef struct { /* 0x00 */ u32 type; /* 0x04 */ u32 setScissor; diff --git a/include/z64actor.h b/include/z64actor.h index 9e75f0f9e3..2b35bec243 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -76,32 +76,6 @@ typedef struct { /* 0x3A */ s16 unk3A; } ActorEnTest20C; // size = 0x3C -struct EnDno_ActorUnkStruct; -typedef s32 (*EnDno_ActorUnkFunc)(struct GlobalContext*, struct EnDno_ActorUnkStruct*); - -typedef struct EnDno_ActorUnkStruct { - /* 0x00 */ Vec3f unk_00; - /* 0x0C */ UNK_TYPE1 unk_0C[0x4]; - /* 0x10 */ s16 unk_10; - /* 0x12 */ UNK_TYPE1 unk_12[0xA]; - /* 0x1C */ u8 unk_1C; - /* 0x1D */ u8 unk_1D; - /* 0x20 */ Vec3f unk_20; - /* 0x2C */ Vec3f unk_2C; - /* 0x38 */ Vec3f unk_38; - /* 0x44 */ UNK_TYPE1 unk_44[0x4]; - /* 0x48 */ struct Actor* unk_48; - /* 0x4C */ f32 unk_4C; - /* 0x50 */ f32 unk_50; - /* 0x54 */ s16 unk_54; - /* 0x56 */ s16 unk_56; - /* 0x58 */ s32 unk_58; - /* 0x5C */ EnDno_ActorUnkFunc unk_5C; - /* 0x60 */ EnDno_ActorUnkFunc unk_60; - /* 0x64 */ EnDno_ActorUnkFunc unk_64; - /* 0x68 */ EnDno_ActorUnkFunc unk_68; -} EnDno_ActorUnkStruct; // size >= 0x6C - typedef struct { /* 0x00 */ s16 id; /* 0x02 */ u8 type; @@ -228,12 +202,12 @@ typedef enum { typedef struct { /* 0x000 */ Actor actor; /* 0x144 */ s32 bgId; - /* 0x148 */ f32 unk148; + /* 0x148 */ f32 pushForce; /* 0x14C */ f32 unk14C; - /* 0x150 */ s16 unk150; + /* 0x150 */ s16 yRotation; /* 0x152 */ u16 unk152; - /* 0x154 */ u32 unk154; - /* 0x158 */ u8 unk_158; + /* 0x154 */ u32 flags; + /* 0x158 */ u8 stateFlags; /* 0x15A */ s16 pad15A; } DynaPolyActor; // size = 0x15C diff --git a/include/z64animation.h b/include/z64animation.h index 2eed33ffda..abd95423bd 100644 --- a/include/z64animation.h +++ b/include/z64animation.h @@ -213,7 +213,9 @@ typedef s32 (*OverrideLimbDrawFlex)(struct GlobalContext* globalCtx, s32 limbInd typedef void (*PostLimbDrawFlex)(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList1, Gfx** dList2, Vec3s* rot, struct Actor* actor); -typedef void (*UnkActorDraw)(struct GlobalContext* globalCtx, s32 limbIndex, struct Actor* actor); +typedef void (*UnkActorDrawOpa)(struct GlobalContext* globalCtx, s32 limbIndex, struct Actor* actor); + +typedef void (*UnkActorDraw)(struct GlobalContext* globalCtx, s32 limbIndex, struct Actor* actor, Gfx** gfx); typedef void (*AnimationEntryCallback)(struct GlobalContext*, AnimationEntryData*); diff --git a/include/z64audio.h b/include/z64audio.h new file mode 100644 index 0000000000..bc6d81a712 --- /dev/null +++ b/include/z64audio.h @@ -0,0 +1,1186 @@ +#ifndef Z64_AUDIO_H +#define Z64_AUDIO_H + +#define MK_AUDIO_CMD(b0,b1,b2,b3) ((((b0) & 0xFF) << 0x18) | (((b1) & 0xFF) << 0x10) | (((b2) & 0xFF) << 0x8) | (((b3) & 0xFF) << 0)) + +#define NO_LAYER ((SequenceLayer*)(-1)) + +#define TATUMS_PER_BEAT 48 + +#define IS_SEQUENCE_CHANNEL_VALID(ptr) ((uintptr_t)(ptr) != (uintptr_t)&gAudioContext.sequenceChannelNone) + +#define MAX_CHANNELS_PER_BANK 3 + +#define ADSR_DISABLE 0 +#define ADSR_HANG -1 +#define ADSR_GOTO -2 +#define ADSR_RESTART -3 + +#define AIBUF_LEN 0x580 + +typedef enum { + /* 0 */ ADSR_STATE_DISABLED, + /* 1 */ ADSR_STATE_INITIAL, + /* 2 */ ADSR_STATE_START_LOOP, + /* 3 */ ADSR_STATE_LOOP, + /* 4 */ ADSR_STATE_FADE, + /* 5 */ ADSR_STATE_HANG, + /* 6 */ ADSR_STATE_DECAY, + /* 7 */ ADSR_STATE_RELEASE, + /* 8 */ ADSR_STATE_SUSTAIN +} AdsrStatus; + +typedef enum { + /* 0 */ MEDIUM_RAM, + /* 1 */ MEDIUM_UNK1, + /* 2 */ MEDIUM_CART, + /* 3 */ MEDIUM_DISK_DRIVE, + /* 4 */ MEDIUM_UNK4, + /* 5 */ MEDIUM_UNK5 +} SampleMedium; + +typedef enum { + /* 0 */ CODEC_ADPCM, + /* 1 */ CODEC_S8, + /* 2 */ CODEC_S16_INMEMORY, + /* 3 */ CODEC_SMALL_ADPCM, + /* 4 */ CODEC_REVERB, + /* 5 */ CODEC_S16 +} SampleCodec; + +typedef enum { + /* 0 */ SEQUENCE_TABLE, + /* 1 */ FONT_TABLE, + /* 2 */ SAMPLE_TABLE +} SampleBankTableType; + +typedef enum { + /* 0 */ CACHE_TEMPORARY, + /* 1 */ CACHE_PERSISTENT, + /* 2 */ CACHE_EITHER, + /* 3 */ CACHE_PERMANENT +} AudioCacheType; + +typedef enum { + /* 0 */ OCARINA_SONG_SONATA, + /* 1 */ OCARINA_SONG_GORON_LULLABY, + /* 2 */ OCARINA_SONG_NEW_WAVE, + /* 3 */ OCARINA_SONG_ELEGY, + /* 4 */ OCARINA_SONG_OATH, + /* 5 */ OCARINA_SONG_SARIAS, + /* 6 */ OCARINA_SONG_TIME, + /* 7 */ OCARINA_SONG_HEALING, + /* 8 */ OCARINA_SONG_EPONAS, + /* 9 */ OCARINA_SONG_SOARING, + /* 10 */ OCARINA_SONG_STORMS, + /* 11 */ OCARINA_SONG_SUNS, + /* 12 */ OCARINA_SONG_INVERTED_TIME, + /* 13 */ OCARINA_SONG_DOUBLE_TIME, + /* 14 */ OCARINA_SONG_GORON_LULLABY_INTRO, + /* 15 */ OCARINA_SONG_WIND_FISH_HUMAN, // "Ballad of the Wind Fish" + /* 16 */ OCARINA_SONG_WIND_FISH_GORON, + /* 17 */ OCARINA_SONG_WIND_FISH_ZORA, + /* 18 */ OCARINA_SONG_WIND_FISH_DEKU, + /* 19 */ OCARINA_SONG_EVAN_PART1, + /* 20 */ OCARINA_SONG_EVAN_PART2, + /* 21 */ OCARINA_SONG_ZELDAS_LULLABY, + /* 22 */ OCARINA_SONG_SCARECROW, + /* 23 */ OCARINA_SONG_TERMINA_WALL, + /* 24 */ OCARINA_SONG_MAX, +} OcarinaSongId; + +typedef enum { + /* 0 */ OCARINA_BTN_A, + /* 1 */ OCARINA_BTN_C_DOWN, + /* 2 */ OCARINA_BTN_C_RIGHT, + /* 3 */ OCARINA_BTN_C_LEFT, + /* 4 */ OCARINA_BTN_C_UP, + /* -1 */ OCARINA_BTN_INVALID = 0xFF +} OcarinaButtonIdx; + +typedef enum { + /* 0x0 */ NOTE_C4, + /* 0x1 */ NOTE_DFLAT4, + /* 0x2 */ NOTE_D4, + /* 0x3 */ NOTE_EFLAT4, + /* 0x4 */ NOTE_E4, + /* 0x5 */ NOTE_F4, + /* 0x6 */ NOTE_GFLAT4, + /* 0x7 */ NOTE_G4, + /* 0x8 */ NOTE_AFLAT4, + /* 0x9 */ NOTE_A4, + /* 0xA */ NOTE_BFLAT4, + /* 0xB */ NOTE_B4, + /* 0xC */ NOTE_C5, + /* 0xD */ NOTE_DFLAT5, + /* 0xE */ NOTE_D5, + /* 0xF */ NOTE_EFLAT5, + /* -1 */ NOTE_NONE = 0xFF +} OcarinaNoteIdx; + +typedef s32 (*DmaHandler)(OSPiHandle* handle, OSIoMesg* mb, s32 direction); + +struct Note; +struct NotePool; +struct SequenceChannel; +struct SequenceLayer; + +// A node in a circularly linked list. Each node is either a head or an item: +// - Items can be either detached (prev = NULL), or attached to a list. +// 'value' points to something of interest. +// - List heads are always attached; if a list is empty, its head points +// to itself. 'count' contains the size of the list. +// If the list holds notes, 'pool' points back to the pool where it lives. +// Otherwise, that member is NULL. +typedef struct AudioListItem { + /* 0x00 */ struct AudioListItem* prev; + /* 0x04 */ struct AudioListItem* next; + union { + /* 0x08 */ void* value; // either Note* or SequenceLayer* + /* 0x08 */ s32 count; + } u; + /* 0x0C */ struct NotePool* pool; +} AudioListItem; // size = 0x10 + +typedef struct NotePool { + /* 0x00 */ AudioListItem disabled; + /* 0x10 */ AudioListItem decaying; + /* 0x20 */ AudioListItem releasing; + /* 0x30 */ AudioListItem active; +} NotePool; // size = 0x40 + +// Pitch sliding by up to one octave in the positive direction. Negative +// direction is "supported" by setting extent to be negative. The code +// extrapolates exponentially in the wrong direction in that case, but that +// doesn't prevent seqplayer from doing it, AFAICT. +typedef struct { + /* 0x00 */ u8 mode; // bit 0x80 denotes something; the rest are an index 0-5 + /* 0x02 */ u16 cur; + /* 0x04 */ u16 speed; + /* 0x08 */ f32 extent; +} Portamento; // size = 0xC + +typedef struct { + /* 0x0 */ s16 delay; + /* 0x2 */ s16 arg; +} AdsrEnvelope; // size = 0x4 + +typedef struct { + /* 0x00 */ u32 start; + /* 0x04 */ u32 end; + /* 0x08 */ u32 count; + /* 0x0C */ u32 unk_0C; + /* 0x10 */ s16 state[16]; // only exists if count != 0. 8-byte aligned +} AdpcmLoop; // size = 0x30 (or 0x10) + +typedef struct { + /* 0x00 */ s32 order; + /* 0x04 */ s32 npredictors; + /* 0x08 */ s16 book[1]; // size 8 * order * npredictors. 8-byte aligned +} AdpcmBook; // size >= 0x8 + +typedef struct { + /* 0x00 */ u32 unk_0 : 1; + /* 0x00 */ u32 codec : 3; + /* 0x00 */ u32 medium : 2; + /* 0x00 */ u32 unk_bit26 : 1; + /* 0x00 */ u32 unk_bit25 : 1; + /* 0x01 */ u32 size : 24; + /* 0x04 */ u8* sampleAddr; + /* 0x08 */ AdpcmLoop* loop; + /* 0x0C */ AdpcmBook* book; +} SoundFontSample; // size = 0x10 + +typedef struct { + /* 0x00 */ SoundFontSample* sample; + /* 0x04 */ f32 tuning; // frequency scale factor +} SoundFontSound; // size = 0x8 + +typedef struct { + /* 0x00 */ s16 numSamplesAfterDownsampling; // never read + /* 0x02 */ s16 chunkLen; // never read + /* 0x04 */ s16* toDownsampleLeft; + /* 0x08 */ s16* toDownsampleRight; // data pointed to by left and right are adjacent in memory + /* 0x0C */ s32 startPos; // start pos in ring buffer + /* 0x10 */ s16 lengthA; // first length in ring buffer (from startPos, at most until end) + /* 0x12 */ s16 lengthB; // second length in ring buffer (from pos 0) + /* 0x14 */ u16 unk_14; + /* 0x16 */ u16 unk_16; + /* 0x18 */ u16 unk_18; +} ReverbRingBufferItem; // size = 0x1C + +typedef struct { + /* 0x000 */ u8 resampleFlags; + /* 0x001 */ u8 useReverb; + /* 0x002 */ u8 framesToIgnore; + /* 0x003 */ u8 curFrame; + /* 0x004 */ u8 downsampleRate; + /* 0x005 */ s8 unk_05; + /* 0x006 */ u16 windowSize; + /* 0x008 */ s16 unk_08; + /* 0x00A */ s16 unk_0A; + /* 0x00C */ u16 unk_0C; + /* 0x00E */ u16 unk_0E; + /* 0x010 */ s16 leakRtl; + /* 0x012 */ s16 leakLtr; + /* 0x014 */ u16 unk_14; + /* 0x016 */ s16 unk_16; + /* 0x018 */ u8 unk_18; + /* 0x019 */ s8 unk_19; + /* 0x01A */ u16 unk_1A; + /* 0x01C */ u16 unk_1C; + /* 0x01E */ u8 unk_1E; + /* 0x020 */ s32 nextRingBufPos; + /* 0x024 */ s32 unk_24; // May be bufSizePerChan + /* 0x028 */ s16* leftRingBuf; + /* 0x02C */ s16* rightRingBuf; + /* 0x030 */ void* unk_30; + /* 0x034 */ void* unk_34; + /* 0x038 */ void* unk_38; + /* 0x03C */ void* unk_3C; + /* 0x040 */ ReverbRingBufferItem items[2][5]; + /* 0x158 */ ReverbRingBufferItem items2[2][5]; + /* 0x270 */ s16* filterLeft; + /* 0x274 */ s16* filterRight; + /* 0x278 */ s16* unk_278; + /* 0x27C */ s16* unk_27C; + /* 0x280 */ s16* filterLeftState; + /* 0x284 */ s16* filterRightState; + /* 0x288 */ SoundFontSound sound; + /* 0x290 */ SoundFontSample sample; + /* 0x2A0 */ AdpcmLoop loop; +} SynthesisReverb; // size = 0x2D0 + +typedef struct { + /* 0x00 */ u8 loaded; + /* 0x01 */ u8 normalRangeLo; + /* 0x02 */ u8 normalRangeHi; + /* 0x03 */ u8 releaseRate; + /* 0x04 */ AdsrEnvelope* envelope; + /* 0x08 */ SoundFontSound lowNotesSound; + /* 0x10 */ SoundFontSound normalNotesSound; + /* 0x18 */ SoundFontSound highNotesSound; +} Instrument; // size = 0x20 + +typedef struct { + /* 0x00 */ u8 releaseRate; + /* 0x01 */ u8 pan; + /* 0x02 */ u8 loaded; + /* 0x04 */ SoundFontSound sound; + /* 0x14 */ AdsrEnvelope* envelope; +} Drum; // size = 0x18 + +typedef struct { + /* 0x00 */ u8 numInstruments; + /* 0x01 */ u8 numDrums; + /* 0x02 */ u8 sampleBankId1; + /* 0x03 */ u8 sampleBankId2; + /* 0x04 */ u16 numSfx; + /* 0x08 */ Instrument** instruments; + /* 0x0C */ Drum** drums; + /* 0x10 */ SoundFontSound* soundEffects; +} SoundFont; // size = 0x14 + +typedef struct { + /* 0x00 */ u8* pc; + /* 0x04 */ u8* stack[4]; + /* 0x14 */ u8 remLoopIters[4]; + /* 0x18 */ u8 depth; + /* 0x19 */ s8 value; +} SeqScriptState; // size = 0x1C + +// Also known as a Group, according to debug strings. +typedef struct { + /* 0x000 */ u8 enabled : 1; + /* 0x000 */ u8 finished : 1; + /* 0x000 */ u8 muted : 1; + /* 0x000 */ u8 seqDmaInProgress : 1; + /* 0x000 */ u8 fontDmaInProgress : 1; + /* 0x000 */ u8 recalculateVolume : 1; + /* 0x000 */ u8 stopScript : 1; + /* 0x000 */ u8 unk_0b1 : 1; + /* 0x001 */ u8 state; + /* 0x002 */ u8 noteAllocPolicy; + /* 0x003 */ u8 muteBehavior; + /* 0x004 */ u8 seqId; + /* 0x005 */ u8 defaultFont; + /* 0x006 */ u8 unk_06[1]; + /* 0x007 */ s8 playerIdx; + /* 0x008 */ u16 tempo; // tatums per minute + /* 0x00A */ u16 tempoAcc; + /* 0x00C */ s16 unk_0C; + /* 0x00E */ s16 transposition; + /* 0x010 */ u16 delay; + /* 0x012 */ u16 fadeTimer; + /* 0x014 */ u16 fadeTimerUnkEu; + /* 0x016 */ u16 unk_16; // New to MM + union { + /* 0x018 */ u8* seqData; + /* 0x018 */ u16* seqData16; + }; + /* 0x01C */ f32 fadeVolume; + /* 0x020 */ f32 fadeVelocity; + /* 0x024 */ f32 volume; + /* 0x028 */ f32 muteVolumeScale; + /* 0x02C */ f32 fadeVolumeScale; + /* 0x030 */ f32 appliedFadeVolume; + /* 0x034 */ f32 unk_34; + /* 0x038 */ struct SequenceChannel* channels[16]; + /* 0x078 */ SeqScriptState scriptState; + /* 0x094 */ u8* shortNoteVelocityTable; + /* 0x098 */ u8* shortNoteGateTimeTable; + /* 0x09C */ NotePool notePool; + /* 0x0DC */ s32 skipTicks; + /* 0x0E0 */ u32 scriptCounter; + /* 0x0E4 */ char unk_E4[0x74]; // unused struct members for sequence/sound font dma management, according to sm64 decomp + /* 0x158 */ s8 soundScriptIO[8]; +} SequencePlayer; // size = 0x160 + +typedef struct { + /* 0x0 */ u8 releaseRate; + /* 0x1 */ u8 sustain; + /* 0x4 */ AdsrEnvelope* envelope; +} AdsrSettings; // size = 0x8 + +typedef struct { + union { + struct { + /* 0x00 */ u8 unk_0b80 : 1; + /* 0x00 */ u8 hang : 1; + /* 0x00 */ u8 decay : 1; + /* 0x00 */ u8 release : 1; + /* 0x00 */ u8 state : 4; + } s; + /* 0x00 */ u8 asByte; + } action; + /* 0x01 */ u8 envIndex; + /* 0x02 */ s16 delay; + /* 0x04 */ f32 sustain; + /* 0x08 */ f32 velocity; + /* 0x0C */ f32 fadeOutVel; + /* 0x10 */ f32 current; + /* 0x14 */ f32 target; + /* 0x18 */ char unk_18[4]; + /* 0x1C */ AdsrEnvelope* envelope; +} AdsrState; // size = 0x20 + +typedef struct { + /* 0x0 */ u8 unused : 2; + /* 0x0 */ u8 bit2 : 2; + /* 0x0 */ u8 strongRight : 1; + /* 0x0 */ u8 strongLeft : 1; + /* 0x0 */ u8 stereoHeadsetEffects : 1; + /* 0x0 */ u8 usesHeadsetPanEffects : 1; +} StereoData; // size = 0x1 + +typedef union { + /* 0x0 */ StereoData s; + /* 0x0 */ u8 asByte; +} Stereo; // size = 0x1 + +typedef struct { + /* 0x00 */ u8 reverb; + /* 0x01 */ u8 unk_1; + /* 0x02 */ u8 pan; + /* 0x03 */ u8 unk_3; // Possibly part of stereo? + /* 0x04 */ Stereo stereo; + /* 0x05 */ u8 unk_4; + /* 0x06 */ u16 unk_6; + /* 0x08 */ f32 freqScale; + /* 0x0C */ f32 velocity; + /* 0x10 */ s16* filter; + /* 0x14 */ s16* filterBuf; +} NoteAttributes; // size = 0x18 + +typedef struct VibratoSubStruct { + /* 0x0 */ u16 vibratoRateStart; + /* 0x2 */ u16 vibratoExtentStart; + /* 0x4 */ u16 vibratoRateTarget; + /* 0x6 */ u16 vibratoExtentTarget; + /* 0x8 */ u16 vibratoRateChangeDelay; + /* 0xA */ u16 vibratoExtentChangeDelay; + /* 0xC */ u16 vibratoDelay; +} VibratoSubStruct; // size = 0xE + +typedef struct SequenceChannelSubStruct { + /* 0x0 */ u8 enabled : 1; + /* 0x0 */ u8 finished : 1; + /* 0x0 */ u8 stopScript : 1; + /* 0x0 */ u8 stopSomething2 : 1; // sets SequenceLayer.stopSomething + /* 0x0 */ u8 hasInstrument : 1; + /* 0x0 */ u8 stereoHeadsetEffects : 1; + /* 0x0 */ u8 largeNotes : 1; // notes specify duration and velocity + /* 0x0 */ u8 unused : 1; +} SequenceChannelSubStruct; // size = 0x1 + +// Also known as a SubTrack, according to sm64 debug strings. +typedef struct SequenceChannel { + /* 0x00 */ u8 enabled : 1; + /* 0x00 */ u8 finished : 1; + /* 0x00 */ u8 stopScript : 1; + /* 0x00 */ u8 stopSomething2 : 1; // sets SequenceLayer.stopSomething + /* 0x00 */ u8 hasInstrument : 1; + /* 0x00 */ u8 stereoHeadsetEffects : 1; + /* 0x00 */ u8 largeNotes : 1; // notes specify duration and velocity + /* 0x00 */ u8 unused : 1; + union { + struct { + /* 0x01 */ u8 freqScale : 1; + /* 0x01 */ u8 volume : 1; + /* 0x01 */ u8 pan : 1; + } s; + /* 0x01 */ u8 asByte; + } changes; + /* 0x02 */ u8 noteAllocPolicy; + /* 0x03 */ u8 muteBehavior; + /* 0x04 */ u8 reverb; // or dry/wet mix + /* 0x05 */ u8 notePriority; // 0-3 + /* 0x06 */ u8 someOtherPriority; + /* 0x07 */ u8 fontId; + /* 0x08 */ u8 reverbIndex; + /* 0x09 */ u8 bookOffset; + /* 0x0A */ u8 newPan; + /* 0x0B */ u8 panChannelWeight; // proportion of pan that comes from the channel (0..128) + /* 0x0C */ u8 unk_0C; + /* 0x0D */ u8 velocityRandomVariance; + /* 0x0E */ u8 gateTimeRandomVariance; + /* 0x0F */ u8 unk_0F; + /* 0x10 */ u8 unk_10; // New to MM + /* 0x11 */ u8 unk_11; // New to MM + /* 0x12 */ VibratoSubStruct vibrato; + /* 0x20 */ u16 delay; + /* 0x22 */ u16 unk_20; + /* 0x24 */ u16 unk_22; + /* 0x26 */ s16 instOrWave; // either 0 (none), instrument index + 1, or + // 0x80..0x83 for sawtooth/triangle/sine/square waves. + /* 0x28 */ s16 transposition; + /* 0x2C */ f32 volumeScale; + /* 0x30 */ f32 volume; + /* 0x34 */ s32 pan; + /* 0x38 */ f32 appliedVolume; + /* 0x3C */ f32 freqScale; + /* 0x40 */ u8 (*dynTable)[][2]; + /* 0x44 */ struct Note* noteUnused; + /* 0x48 */ struct SequenceLayer* layerUnused; + /* 0x4C */ Instrument* instrument; + /* 0x50 */ SequencePlayer* seqPlayer; + /* 0x54 */ struct SequenceLayer* layers[4]; + /* 0x64 */ SeqScriptState scriptState; + /* 0x80 */ AdsrSettings adsr; + /* 0x88 */ NotePool notePool; + /* 0xC8 */ s8 soundScriptIO[8]; // bridge between sound script and audio lib, "io ports" + /* 0xD0 */ u8* unk_D0; // New to MM + /* 0xD4 */ s16* filter; + /* 0xD8 */ Stereo stereo; + /* 0xDC */ s32 unk_DC; // New to MM + /* 0xE0 */ s32 unk_E0; // New to MM +} SequenceChannel; // size = 0xE4 + +// Might also be known as a Track, according to sm64 debug strings (?). +typedef struct SequenceLayer { + /* 0x00 */ u8 enabled : 1; + /* 0x00 */ u8 finished : 1; + /* 0x00 */ u8 stopSomething : 1; + /* 0x00 */ u8 continuousNotes : 1; // keep the same note for consecutive notes with the same sound + /* 0x00 */ u8 bit3 : 1; // "loaded"? + /* 0x00 */ u8 ignoreDrumPan : 1; + /* 0x00 */ u8 bit1 : 1; // "has initialized continuous notes"? + /* 0x00 */ u8 notePropertiesNeedInit : 1; + /* 0x01 */ Stereo stereo; + /* 0x02 */ u8 instOrWave; + /* 0x03 */ u8 gateTime; + /* 0x04 */ u8 semitone; + /* 0x05 */ u8 portamentoTargetNote; + /* 0x06 */ u8 pan; // 0..128 + /* 0x07 */ u8 notePan; + /* 0x08 */ u8 unk_08; + /* 0x09 */ u8 unk_09; + union { + struct { + /* 0x0A */ u16 bit_0 : 1; + /* 0x0A */ u16 bit_1 : 1; + /* 0x0A */ u16 bit_2 : 1; + /* 0x0A */ u16 bit_3 : 1; + /* 0x0A */ u16 bit_4 : 1; + /* 0x0A */ u16 bit_5 : 1; + /* 0x0A */ u16 bit_6 : 1; + /* 0x0A */ u16 bit_7 : 1; + /* 0x0A */ u16 bit_8 : 1; + /* 0x0A */ u16 bit_9 : 1; + /* 0x0A */ u16 bit_A : 1; + /* 0x0A */ u16 bit_B : 1; + /* 0x0A */ u16 bit_C : 1; + /* 0x0A */ u16 bit_D : 1; + /* 0x0A */ u16 bit_E : 1; + /* 0x0A */ u16 bit_F : 1; + } s; + /* 0x0A */ u16 asByte; + } unk_0A; + /* 0x0C */ VibratoSubStruct vibrato; + /* 0x1A */ s16 delay; + /* 0x1C */ s16 gateDelay; + /* 0x1E */ s16 delay2; + /* 0x20 */ u16 portamentoTime; + /* 0x22 */ s16 transposition; // #semitones added to play commands + // (seq instruction encoding only allows referring to the limited range + // 0..0x3F; this makes 0x40..0x7F accessible as well) + /* 0x24 */ s16 shortNoteDefaultDelay; + /* 0x26 */ s16 lastDelay; + /* 0x28 */ AdsrSettings adsr; + /* 0x30 */ Portamento portamento; + /* 0x3C */ struct Note* note; + /* 0x40 */ f32 freqScale; + /* 0x44 */ f32 unk_34; + /* 0x48 */ f32 velocitySquare2; + /* 0x4C */ f32 velocitySquare; // not sure which one of those corresponds to the sm64 original + /* 0x50 */ f32 noteVelocity; + /* 0x54 */ f32 noteFreqScale; + /* 0x58 */ Instrument* instrument; + /* 0x5C */ SoundFontSound* sound; + /* 0x60 */ SequenceChannel* channel; // Not SequenceChannel? + /* 0x64 */ SeqScriptState scriptState; + /* 0x80 */ AudioListItem listItem; +} SequenceLayer; // size = 0x90 + +typedef struct { + /* 0x00 */ s16 adpcmdecState[0x10]; + /* 0x20 */ s16 finalResampleState[0x10]; + /* 0x40 */ s16 mixEnvelopeState[0x28]; + /* 0x90 */ s16 panResampleState[0x10]; + /* 0xB0 */ s16 panSamplesBuffer[0x20]; + /* 0xF0 */ s16 dummyResampleState[0x10]; +} NoteSynthesisBuffers; // size = 0x110 + +typedef struct { + /* 0x00 */ u8 restart_bit0 : 1; + /* 0x00 */ u8 restart_bit1 : 1; + /* 0x00 */ u8 restart_bit2 : 1; + /* 0x00 */ u8 restart_bit3 : 1; + /* 0x00 */ u8 restart_bit4 : 1; + /* 0x00 */ u8 restart_bit5 : 1; + /* 0x00 */ u8 restart_bit6 : 1; + /* 0x00 */ u8 restart_bit7 : 1; + /* 0x01 */ u8 sampleDmaIndex; + /* 0x02 */ u8 prevHeadsetPanRight; + /* 0x03 */ u8 prevHeadsetPanLeft; + /* 0x04 */ u8 reverbVol; + /* 0x05 */ u8 numParts; + /* 0x06 */ u16 samplePosFrac; + /* 0x08 */ u16 unk_08; // New to MM + /* 0x0C */ s32 samplePosInt; + /* 0x10 */ NoteSynthesisBuffers* synthesisBuffers; + /* 0x14 */ s16 curVolLeft; + /* 0x16 */ s16 curVolRight; + /* 0x18 */ u16 unk_14; + /* 0x1A */ u16 unk_16; + /* 0x1C */ u16 unk_18; + /* 0x1E */ u8 unk_1A; + /* 0x1F */ u8 unk_1F; + /* 0x20 */ u16 unk_1C; + /* 0x22 */ u16 unk_1E; +} NoteSynthesisState; // size = 0x24 + +typedef struct { + /* 0x00 */ struct VibratoSubStruct* vibSubStruct; // MM Something else? + /* 0x04 */ u32 time; + /* 0x08 */ s16* curve; + /* 0x0C */ f32 extent; + /* 0x10 */ f32 rate; + /* 0x14 */ u8 active; + /* 0x16 */ u16 rateChangeTimer; + /* 0x18 */ u16 extentChangeTimer; + /* 0x1A */ u16 delay; +} VibratoState; // size = 0x1C + +typedef struct { + /* 0x00 */ u8 priority; + /* 0x01 */ u8 waveId; + /* 0x02 */ u8 sampleCountIndex; + /* 0x03 */ u8 fontId; + /* 0x04 */ u8 unk_04; + /* 0x05 */ u8 stereoHeadsetEffects; + /* 0x06 */ s16 adsrVolScaleUnused; + /* 0x08 */ f32 portamentoFreqScale; + /* 0x0C */ f32 vibratoFreqScale; + /* 0x18 */ SequenceLayer* wantedParentLayer; + /* 0x14 */ SequenceLayer* parentLayer; + /* 0x10 */ SequenceLayer* prevParentLayer; + /* 0x1C */ NoteAttributes attributes; + /* 0x34 */ AdsrState adsr; + /* 0x54 */ Portamento portamento; + /* 0x60 */ VibratoState vibratoState; + /* 0x7C */ char unk_7C[0x8]; + /* 0x84 */ u32 unk_84; +} NotePlaybackState; // size = 0x88 + +typedef struct { + struct { + /* 0x00 */ volatile u8 enabled : 1; + /* 0x00 */ u8 needsInit : 1; + /* 0x00 */ u8 finished : 1; // ? + /* 0x00 */ u8 unused : 1; + /* 0x00 */ u8 stereoStrongRight : 1; + /* 0x00 */ u8 stereoStrongLeft : 1; + /* 0x00 */ u8 stereoHeadsetEffects : 1; + /* 0x00 */ u8 usesHeadsetPanEffects : 1; // ? + } bitField0; + struct { + /* 0x01 */ u8 reverbIndex : 3; + /* 0x01 */ u8 bookOffset : 2; + /* 0x01 */ u8 isSyntheticWave : 1; + /* 0x01 */ u8 hasTwoParts : 1; + /* 0x01 */ u8 usesHeadsetPanEffects2 : 1; + } bitField1; + /* 0x02 */ u8 unk_2; + /* 0x03 */ u8 headsetPanRight; + /* 0x04 */ u8 headsetPanLeft; + /* 0x05 */ u8 reverbVol; + /* 0x06 */ u8 unk_06; + /* 0x07 */ u8 unk_07; + /* 0x08 */ u16 targetVolLeft; + /* 0x0A */ u16 targetVolRight; + /* 0x0C */ u16 resamplingRateFixedPoint; + /* 0x0E */ u16 unk_0E; + union { + /* 0x10 */ SoundFontSound* soundFontSound; + /* 0x10 */ s16* samples; // used for synthetic waves + } sound; + /* 0x14 */ s16* filter; + /* 0x18 */ u8 unk_18; // New to MM + /* 0x19 */ u8 unk_19; // New to MM + /* 0x1A */ UNK_TYPE1 pad_1A[0x6]; +} NoteSubEu; // size = 0x20 + +typedef struct Note { + /* 0x00 */ AudioListItem listItem; + /* 0x10 */ NoteSynthesisState synthesisState; + /* 0x34 */ NotePlaybackState playbackState; + /* 0xBC */ char unk_BC[0x1C]; + /* 0xD8 */ NoteSubEu noteSubEu; +} Note; // size = 0xF8 + +typedef struct { + /* 0x00 */ u8 downsampleRate; + /* 0x02 */ u16 windowSize; + /* 0x04 */ u16 unk_4; + /* 0x06 */ u16 unk_6; + /* 0x08 */ u16 unk_8; + /* 0x0A */ u16 unk_A; + /* 0x0C */ u16 leakRtl; + /* 0x0E */ u16 leakLtr; + /* 0x10 */ s8 unk_10; + /* 0x12 */ u16 unk_12; + /* 0x14 */ s16 lowPassFilterCutoffLeft; + /* 0x16 */ s16 lowPassFilterCutoffRight; +} ReverbSettings; // size = 0x18 + +typedef struct { + /* 0x00 */ u32 frequency; + /* 0x04 */ u8 unk_04; + /* 0x05 */ u8 numNotes; + /* 0x06 */ u8 numSequencePlayers; + /* 0x07 */ u8 unk_07[0x2]; // unused, set to zero + /* 0x09 */ u8 numReverbs; + /* 0x0A */ u8 unk_0A[0x2]; + /* 0x0C */ ReverbSettings* reverbSettings; + /* 0x10 */ u16 sampleDmaBufSize1; + /* 0x12 */ u16 sampleDmaBufSize2; + /* 0x14 */ u16 unk_14; + /* 0x18 */ u32 persistentSeqMem; + /* 0x1C */ u32 persistentFontMem; + /* 0x20 */ u32 persistentSampleMem; + /* 0x24 */ u32 temporarySeqMem; + /* 0x28 */ u32 temporaryFontMem; + /* 0x2C */ u32 temporarySampleMem; + /* 0x30 */ s32 persistentSampleCacheMem; + /* 0x34 */ s32 temporarySampleCacheMem; +} AudioSpec; // size = 0x38 + +typedef struct { + /* 0x00 */ s16 specUnk4; + /* 0x02 */ u16 frequency; + /* 0x04 */ u16 aiFrequency; + /* 0x06 */ s16 samplesPerFrameTarget; + /* 0x08 */ s16 maxAiBufferLength; + /* 0x0A */ s16 minAiBufferLength; + /* 0x0C */ s16 updatesPerFrame; + /* 0x0E */ s16 samplesPerUpdate; + /* 0x10 */ s16 samplesPerUpdateMax; + /* 0x12 */ s16 samplesPerUpdateMin; + /* 0x14 */ s16 numSequencePlayers; + /* 0x18 */ f32 resampleRate; + /* 0x1C */ f32 updatesPerFrameInv; + /* 0x20 */ f32 unkUpdatesPerFrameScaled; + /* 0x24 */ f32 unk_24; +} AudioBufferParameters; // size = 0x28 + +typedef struct { + /* 0x0 */ u8* start; + /* 0x4 */ u8* cur; + /* 0x8 */ s32 size; + /* 0xC */ s32 count; +} AudioAllocPool; // size = 0x10 + +typedef struct { + /* 0x0 */ u8* ptr; + /* 0x4 */ u32 size; + /* 0x8 */ s16 tableType; + /* 0xA */ s16 id; +} AudioCacheEntry; // size = 0xC + +typedef struct { + /* 0x00 */ s8 inUse; + /* 0x01 */ s8 origMedium; + /* 0x02 */ u8 sampleBankId; + /* 0x03 */ char unk_03[0x5]; + /* 0x08 */ u8* allocatedAddr; + /* 0x0C */ void* sampleAddr; + /* 0x10 */ u32 size; +} SampleCacheEntry; // size = 0x14 + +typedef struct { + /* 0x000 */ AudioAllocPool pool; + /* 0x010 */ SampleCacheEntry entries[128]; + /* 0xA10 */ s32 size; +} AudioSampleCache; // size = 0xA14 + +typedef struct { + /* 0x00 */ u32 numEntries; + /* 0x04 */ AudioAllocPool pool; + /* 0x14 */ AudioCacheEntry entries[16]; +} AudioPersistentCache; // size = 0xD4 + +typedef struct { + /* 0x00 */ u32 nextSide; + /* 0x04 */ AudioAllocPool pool; + /* 0x14 */ AudioCacheEntry entries[2]; +} AudioTemporaryCache; // size = 0x3C + +typedef struct { + /* 0x000 */ AudioPersistentCache persistent; + /* 0x0D4 */ AudioTemporaryCache temporary; + /* 0x100 */ u8 unk_100[0x10]; +} AudioCache; // size = 0x110 + +typedef struct { + /* 0x0 */ u32 wantPersistent; + /* 0x4 */ u32 wantTemporary; +} AudioPoolSplit2; // size = 0x8 + +typedef struct { + /* 0x0 */ u32 wantSeq; + /* 0x4 */ u32 wantFont; + /* 0x8 */ u32 wantSample; +} AudioPoolSplit3; // size = 0xC + +typedef struct { + /* 0x0 */ u32 wantSeq; + /* 0x4 */ u32 wantFont; + /* 0x8 */ u32 wantSample; + /* 0xC */ u32 wantCustom; +} AudioPoolSplit4; // size = 0x10 + +typedef struct { + /* 0x00 */ u32 endAndMediumKey; + /* 0x04 */ SoundFontSample* sample; + /* 0x08 */ u8* ramAddr; + /* 0x0C */ u32 encodedInfo; + /* 0x10 */ s32 isFree; +} AudioPreloadReq; // size = 0x14 + +typedef struct { + union { + /* 0x0 */ u32 opArgs; + struct { + /* 0x0 */ u8 op; + /* 0x1 */ u8 arg0; + /* 0x2 */ u8 arg1; + /* 0x3 */ u8 arg2; + }; + }; + union { + /* 0x4 */ void* data; + /* 0x4 */ f32 asFloat; + /* 0x4 */ s32 asInt; + /* 0x4 */ u16 asUShort; + /* 0x4 */ s8 asSbyte; + /* 0x4 */ u8 asUbyte; + /* 0x4 */ u32 asUInt; + }; +} AudioCmd; // size = 0x8 + +typedef struct { + /* 0x00 */ s8 status; + /* 0x01 */ s8 delay; + /* 0x02 */ s8 medium; + /* 0x04 */ u8* ramAddr; + /* 0x08 */ u32 curDevAddr; + /* 0x0C */ u8* curRamAddr; + /* 0x10 */ u32 bytesRemaining; + /* 0x14 */ u32 chunkSize; + /* 0x18 */ s32 unkMediumParam; + /* 0x1C */ u32 retMsg; + /* 0x20 */ OSMesgQueue* retQueue; + /* 0x24 */ OSMesgQueue msgQueue; + /* 0x3C */ OSMesg msg; + /* 0x40 */ OSIoMesg ioMesg; +} AudioAsyncLoad; // size = 0x58 + +typedef struct { + /* 0x00 */ u8 medium; + /* 0x01 */ u8 seqOrFontId; + /* 0x02 */ u16 instId; + /* 0x04 */ s32 unkMediumParam; + /* 0x08 */ s32 curDevAddr; + /* 0x0C */ u8* curRamAddr; + /* 0x10 */ u8* ramAddr; + /* 0x14 */ s32 status; + /* 0x18 */ s32 bytesRemaining; + /* 0x1C */ s8* isDone; + /* 0x20 */ SoundFontSample sample; + /* 0x30 */ OSMesgQueue msgqueue; + /* 0x48 */ OSMesg msg; + /* 0x4C */ OSIoMesg ioMesg; +} AudioSlowLoad; // size = 0x64 + +typedef struct { + /* 0x00 */ u32 romAddr; + /* 0x04 */ u32 size; + /* 0x08 */ s8 medium; + /* 0x09 */ s8 cachePolicy; + /* 0x0A */ s16 shortData1; + /* 0x0C */ s16 shortData2; + /* 0x0E */ s16 shortData3; +} AudioTableEntry; // size = 0x10 + +typedef struct { + /* 0x00 */ s16 numEntries; + /* 0x02 */ s16 unkMediumParam; + /* 0x04 */ u32 romAddr; + /* 0x08 */ char pad[0x8]; + /* 0x10 */ AudioTableEntry entries[1]; // (dynamic size) +} AudioTable; // size >= 0x20 + +typedef struct { + /* 0x00 */ OSTask task; + /* 0x40 */ OSMesgQueue* taskQueue; + /* 0x44 */ void* unk_44; // probably a message that gets unused. + /* 0x48 */ char unk_48[0x8]; +} AudioTask; // size = 0x50 + +typedef struct { + /* 0x00 */ u8* ramAddr; + /* 0x04 */ u32 devAddr; + /* 0x08 */ u16 sizeUnused; + /* 0x0A */ u16 size; + /* 0x0C */ u8 unused; + /* 0x0D */ u8 reuseIndex; // position in sSampleDmaReuseQueue1/2, if ttl == 0 + /* 0x0E */ u8 ttl; // duration after which the DMA can be discarded +} SampleDma; // size = 0x10 + +typedef struct { + /* 0x0000 */ char unk_0000; + /* 0x0001 */ s8 numSynthesisReverbs; + /* 0x0002 */ u16 unk_2; + /* 0x0004 */ u16 unk_4; + /* 0x0006 */ char unk_0006[0xA]; + /* 0x0010 */ s16* curLoadedBook; + /* 0x0014 */ NoteSubEu* noteSubsEu; + /* 0x0018 */ SynthesisReverb synthesisReverbs[4]; + /* 0x0B58 */ char unk_0B58[0x30]; + /* 0x0B88 */ SoundFontSample* usedSamples[128]; + /* 0x0D88 */ AudioPreloadReq preloadSampleStack[128]; + /* 0x1788 */ s32 numUsedSamples; + /* 0x178C */ s32 preloadSampleStackTop; + /* 0x1790 */ AudioAsyncLoad asyncLoads[0x10]; + /* 0x1D10 */ OSMesgQueue asyncLoadUnkMediumQueue; + /* 0x1D28 */ char unk_1D08[0x40]; + /* 0x1D68 */ AudioAsyncLoad* curUnkMediumLoad; + /* 0x1D6C */ u32 slowLoadPos; + /* 0x1D70 */ AudioSlowLoad slowLoads[2]; + /* 0x1E38 */ OSPiHandle* cartHandle; + /* 0x1E2C */ OSPiHandle* driveHandle; + /* 0x1E40 */ OSMesgQueue externalLoadQueue; + /* 0x1E58 */ OSMesg externalLoadMesgBuf[0x10]; + /* 0x1E98 */ OSMesgQueue preloadSampleQueue; + /* 0x1EB0 */ OSMesg preloadSampleMesgBuf[0x10]; + /* 0x1EF0 */ OSMesgQueue currAudioFrameDmaQueue; + /* 0x1F08 */ OSMesg currAudioFrameDmaMesgBuf[0x40]; + /* 0x2008 */ OSIoMesg currAudioFrameDmaIoMesgBuf[0x40]; + /* 0x2608 */ OSMesgQueue syncDmaQueue; + /* 0x2620 */ OSMesg syncDmaMesg; + /* 0x2624 */ OSIoMesg syncDmaIoMesg; + /* 0x263C */ SampleDma* sampleDmas; + /* 0x2640 */ u32 sampleDmaCount; + /* 0x2644 */ u32 sampleDmaListSize1; + /* 0x2648 */ s32 unused2628; + /* 0x264C */ u8 sampleDmaReuseQueue1[0x100]; // read pos <= write pos, wrapping mod 256 + /* 0x274C */ u8 sampleDmaReuseQueue2[0x100]; + /* 0x284C */ u8 sampleDmaReuseQueue1RdPos; + /* 0x284D */ u8 sampleDmaReuseQueue2RdPos; + /* 0x284E */ u8 sampleDmaReuseQueue1WrPos; + /* 0x284F */ u8 sampleDmaReuseQueue2WrPos; + /* 0x2850 */ AudioTable* sequenceTable; + /* 0x2854 */ AudioTable* soundFontTable; + /* 0x2858 */ AudioTable* sampleBankTable; + /* 0x285C */ char unk_285C[0x4]; + /* 0x2860 */ u8* sequenceFontTable; + /* 0x2864 */ u16 numSequences; + /* 0x2868 */ SoundFont* soundFonts; + /* 0x286C */ AudioBufferParameters audioBufferParameters; + /* 0x2994 */ f32 unk_2870; + /* 0x2898 */ s32 sampleDmaBufSize1; + /* 0x289C */ s32 sampleDmaBufSize2; + /* 0x28A0 */ char unk_287C[0x10]; + /* 0x28B0 */ s32 sampleDmaBufSize; + /* 0x28B4 */ s32 maxAudioCmds; + /* 0x28B8 */ s32 numNotes; + /* 0x2898 */ s16 tempoInternalToExternal; + /* 0x28BE */ s8 soundMode; + /* 0x28C0 */ s32 totalTaskCnt; + /* 0x28C4 */ s32 curAudioFrameDmaCount; + /* 0x28C8 */ s32 rspTaskIdx; + /* 0x28CC */ s32 curAIBufIdx; + /* 0x28AC */ Acmd* abiCmdBufs[2]; + /* 0x28B4 */ Acmd* curAbiCmdBuf; + /* 0x28DC */ AudioTask* currTask; + /* 0x28C0 */ AudioTask rspTask[2]; + /* 0x2980 */ f32 unk_2960; + /* 0x2984*/ s32 refreshRate; + /* 0x2988 */ s16* aiBuffers[3]; + /* 0x2994 */ s16 aiBufLengths[3]; + /* 0x299C */ u32 audioRandom; + /* 0x29A0 */ s32 audioErrorFlags; + /* 0x29A4 */ volatile u32 resetTimer; + /* 0x29A8 */ u32 (*unk_29A8[4])(s8 value, SequenceChannel* channel); + /* 0x29B8 */ s8 unk_29B8; + /* 0x29BC */ s32 unk_29BC; // sMaxAbiCmdCnt + /* 0x29C0 */ AudioAllocPool audioSessionPool; + /* 0x29D0 */ AudioAllocPool externalPool; + /* 0x29E0 */ AudioAllocPool audioInitPool; + /* 0x29F0 */ AudioAllocPool notesAndBuffersPool; + /* 0x2A00 */ char unk_29D0[0x20]; // probably two unused pools + /* 0x2A20 */ AudioAllocPool cachePool; + /* 0x2A30 */ AudioAllocPool persistentCommonPool; + /* 0x2A40 */ AudioAllocPool temporaryCommonPool; + /* 0x2A50 */ AudioCache seqCache; + /* 0x2B60 */ AudioCache fontCache; + /* 0x2C70 */ AudioCache sampleBankCache; + /* 0x2D80 */ AudioAllocPool permanentPool; + /* 0x2D90 */ AudioCacheEntry permanentCache[32]; + /* 0x3690 */ AudioSampleCache persistentSampleCache; + /* 0x40A4 */ AudioSampleCache temporarySampleCache; + /* 0x4338 */ AudioPoolSplit4 sessionPoolSplit; + /* 0x4348 */ AudioPoolSplit2 cachePoolSplit; + /* 0x4350 */ AudioPoolSplit3 persistentCommonPoolSplit; + /* 0x435C */ AudioPoolSplit3 temporaryCommonPoolSplit; + /* 0x4368 */ u8 sampleFontLoadStatus[0x30]; + /* 0x4398 */ u8 fontLoadStatus[0x30]; + /* 0x43C8 */ u8 seqLoadStatus[0x80]; + /* 0x4448 */ volatile u8 resetStatus; + /* 0x4449 */ u8 audioResetSpecIdToLoad; + /* 0x444C */ s32 audioResetFadeOutFramesLeft; + /* 0x4450 */ f32* unk_3520; + /* 0x4454 */ u8* audioHeap; + /* 0x4458 */ u32 audioHeapSize; + /* 0x445C */ Note* notes; + /* 0x4460 */ SequencePlayer seqPlayers[5]; + /* 0x4B40 */ SequenceLayer sequenceLayers[80]; + /* 0x7840 */ SequenceChannel sequenceChannelNone; + /* 0x7924 */ s32 noteSubEuOffset; + /* 0x7928 */ AudioListItem layerFreeList; + /* 0x7938 */ NotePool noteFreeLists; + /* 0x7978 */ u8 cmdWrPos; + /* 0x7979 */ u8 cmdRdPos; + /* 0x797A */ u8 cmdQueueFinished; + /* 0x797C */ u16 unk_5BDC[4]; + /* 0x7984 */ char unk_7984[4]; + /* 0x7988 */ OSMesgQueue* audioResetQueueP; + /* 0x798C */ OSMesgQueue* taskStartQueueP; + /* 0x7990 */ OSMesgQueue* cmdProcQueueP; + /* 0x7994 */ OSMesgQueue taskStartQueue; + /* 0x79AC */ OSMesgQueue cmdProcQueue; + /* 0x79C4 */ OSMesgQueue audioResetQueue; + /* 0x79DC */ OSMesg taskStartMsgs[1]; + /* 0x79E0 */ OSMesg audioResetMesgs[1]; + /* 0x79E4 */ OSMesg cmdProcMsgs[4]; + /* 0x79F4 */ AudioCmd cmdBuf[0x100]; + /* 0x81F4 */ char unk_81F4[4]; +} AudioContext; // size = 0x81F8 + +typedef struct { + /* 0x00 */ u8 reverbVol; + /* 0x01 */ u8 unk_1; + /* 0x02 */ u8 pan; + /* 0x03 */ u8 unk_3; + /* 0x04 */ Stereo stereo; + /* 0x08 */ f32 frequency; + /* 0x0C */ f32 velocity; + /* 0x10 */ char unk_0C[0x4]; + /* 0x14 */ s16* filter; + /* 0x18 */ u8 unk_14; + /* 0x1A */ u16 unk_16; +} NoteSubAttributes; // size = 0x1A + +typedef struct { + /* 0x0 */ u32 heapSize; + /* 0x4 */ u32 initPoolSize; + /* 0x8 */ u32 permanentPoolSize; +} AudioContextInitSizes; // size = 0xC + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_10; + /* 0x10 */ f32 unk_14; + /* 0x14 */ f32 unk_18; + /* 0x18 */ u16 unk_0C; + /* 0x1A */ u16 unk_1C; +} unk_50_s; // size = 0x1C + +typedef struct { + /* 0x000 */ unk_50_s unk_50[0x10]; + /* 0x1C0 */ f32 volCur; + /* 0x1C4 */ f32 volTarget; + /* 0x1C8 */ f32 unk_08; + /* 0x1CC */ u32 unk_14; + /* 0x1D0 */ f32 unk_1C; + /* 0x1D4 */ f32 unk_20; + /* 0x1D8 */ f32 unk_24; + /* 0x1DC */ u32 unk_2C[8]; + /* 0x1FC */ u32 unk_25C; + /* 0x200 */ u16 unk_0C; + /* 0x202 */ u16 unk_18; + /* 0x204 */ u16 unk_28; + /* 0x206 */ u16 unk_250; + /* 0x208 */ u16 unk_252; + /* 0x20A */ u16 unk_254; + /* 0x20C */ u16 unk_256; + /* 0x20E */ u16 unk_258; + /* 0x210 */ u8 unk_260; + /* 0x211 */ u8 unk_261[0x1]; + /* 0x212 */ u8 volScales[0x4]; + /* 0x216 */ u8 volFadeTimer; + /* 0x217 */ u8 fadeVolUpdate; + /* 0x218 */ u8 unk_4C; + /* 0x219 */ u8 unk_4D; + /* 0x21A */ u8 unk_4E; + /* 0x21B */ u8 unk_21B; // New to MM +} unk_D_8016E750; // size = 0x21C + +typedef struct { + /* 0x0 */ u8 unk_0; + /* 0x1 */ u8 unk_1; // importance? +} Struct_8016E320; // size = 0x02 + +typedef enum { + /* 0 */ BANK_PLAYER, + /* 1 */ BANK_ITEM, + /* 2 */ BANK_ENV, + /* 3 */ BANK_ENEMY, + /* 4 */ BANK_SYSTEM, + /* 5 */ BANK_OCARINA, + /* 6 */ BANK_VOICE +} SoundBankTypes; + +typedef enum { + /* 0 */ SFX_STATE_EMPTY, + /* 1 */ SFX_STATE_QUEUED, + /* 2 */ SFX_STATE_READY, + /* 3 */ SFX_STATE_PLAYING_REFRESH, + /* 4 */ SFX_STATE_PLAYING_1, + /* 5 */ SFX_STATE_PLAYING_2 +} SfxState; + +typedef struct { + /* 0x00 */ f32* posX; + /* 0x04 */ f32* posY; + /* 0x08 */ f32* posZ; + /* 0x0C */ f32* freqScale; + /* 0x10 */ f32* vol; + /* 0x14 */ s8* reverbAdd; + /* 0x18 */ f32 dist; + /* 0x1C */ u32 priority; // lower is more prioritized + /* 0x20 */ u16 sfxParams; + /* 0x22 */ u16 sfxId; + /* 0x25 */ u8 sfxFlags; + /* 0x24 */ u8 sfxImportance; + /* 0x26 */ u8 state; // uses SfxState enum + /* 0x27 */ u8 freshness; + /* 0x28 */ u8 prev; + /* 0x29 */ u8 next; + /* 0x2A */ u8 channelIdx; + /* 0x2B */ u8 unk_2F; + /* 0x2C */ u8 token; +} SfxBankEntry; // size = 0x30 + +/* + * SFX IDs + * + * index 0000000111111111 observed in audio code + * & 200 0000001000000000 single bit + * & 400 0000010000000000 single bit + * & 800 0000100000000000 single bit, what we currently call SFX_FLAG + * & 600 0000011000000000 2 bits + * & A00 0000101000000000 2 bits + * & C00 0000110000000000 2 bits, observed in audio code + * & E00 0000111000000000 all 3 bits + * bank 1111000000000000 observed in audio code + */ + +#define SFX_BANK_SHIFT(sfxId) (((sfxId) >> 12) & 0xFF) + +#define SFX_BANK_MASK(sfxId) ((sfxId) & 0xF000) + +#define SFX_INDEX(sfxId) ((sfxId) & 0x03FF) +#define SFX_BANK(sfxId) SFX_BANK_SHIFT(SFX_BANK_MASK(sfxId)) + +typedef struct { + /* 0x0 */ u32 priority; // lower is more prioritized + /* 0x4 */ u8 entryIndex; +} ActiveSfx; // size = 0x08 + +typedef struct { + /* 0x0 */ u8 importance; + /* 0x1 */ u8 flags; + /* 0x2 */ u16 params; +} SfxParams; // size = 0x4 + +typedef struct { + /* 0x00 */ u16 sfxId; + /* 0x02 */ u8 token; + /* 0x04 */ s8* reverbAdd; + /* 0x08 */ Vec3f* pos; + /* 0x0C */ f32* freqScale; + /* 0x10 */ f32* vol; +} SoundRequest; // size = 0x14 + +/** + * Note: + * Flag for resolving C_RIGHT and C_LEFT only being two semitones apart + * 0x40 - BTN_Z is pressed to lower note by a semitone + * 0x80 - BTN_R is pressed to raise note by a semitone + */ + +typedef struct { + /* 0x0 */ u8 noteIdx; + /* 0x2 */ u16 length; // number of frames the note is sustained + /* 0x4 */ u8 volume; + /* 0x5 */ u8 vibrato; + /* 0x6 */ s8 bend; + /* 0x7 */ u8 BFlat4Flag; // BFlat4Flag See note above +} OcarinaNote; // size = 0x8 + +typedef struct { + /* 0x0 */ u8 numButtons; + /* 0x1 */ u8 buttonIdx[8]; +} OcarinaSongButtons; // size = 0x9 + +typedef struct { + /* 0x0 */ u8 buttonIdx; + /* 0x1 */ u8 state; + /* 0x2 */ u8 pos; +} OcarinaStaff; // size = 0x3 + +#endif diff --git a/include/z64bgcheck.h b/include/z64bgcheck.h index 7dc380bf2f..6ca0b66d54 100644 --- a/include/z64bgcheck.h +++ b/include/z64bgcheck.h @@ -1,10 +1,12 @@ -#ifndef _Z_BGCHECK_ -#define _Z_BGCHECK_ +#ifndef Z64_BGCHECK_H +#define Z64_BGCHECK_H struct GlobalContext; struct Actor; struct DynaPolyActor; +#define SS_NULL 0xFFFF + #define COLPOLY_NORMAL_FRAC (1.0f / SHT_MAX) #define COLPOLY_SNORMAL(x) ((s16)((x) * SHT_MAX)) #define COLPOLY_GET_NORMAL(n) ((n)*COLPOLY_NORMAL_FRAC) @@ -15,24 +17,54 @@ struct DynaPolyActor; #define BGACTOR_NEG_ONE -1 #define BG_ACTOR_MAX 50 +#define DYNA_WATERBOX_MAX 30 #define BGCHECK_SCENE BG_ACTOR_MAX +#define BGCHECK_Y_MAX 32000.0f #define BGCHECK_Y_MIN -32000.0f #define BGCHECK_XYZ_ABSMAX 32760.0f #define BGCHECK_SUBDIV_OVERLAP 50 #define BGCHECK_SUBDIV_MIN 150.0f -#define FUNC_80041EA4_RESPAWN 5 -#define FUNC_80041EA4_MOUNT_WALL 6 -#define FUNC_80041EA4_STOP 8 -#define FUNC_80041EA4_VOID_OUT 12 +#define WATERBOX_ROOM(p) ((((s32)p) >> 13) & 0x3F) -#define WATERBOX_ROOM(p) ((p >> 13) & 0x3F) +// bccFlags (bgcheck check flags) +#define BGCHECK_CHECK_WALL (1 << 0) +#define BGCHECK_CHECK_FLOOR (1 << 1) +#define BGCHECK_CHECK_CEILING (1 << 2) +#define BGCHECK_CHECK_ONE_FACE (1 << 3) +#define BGCHECK_CHECK_DYNA (1 << 4) +#define BGCHECK_CHECK_ALL \ + (BGCHECK_CHECK_WALL | BGCHECK_CHECK_FLOOR | BGCHECK_CHECK_CEILING | BGCHECK_CHECK_ONE_FACE | BGCHECK_CHECK_DYNA) + +// bciFlags (bgcheck ignore flags) +#define BGCHECK_IGNORE_NONE 0 +#define BGCHECK_IGNORE_CEILING (1 << 0) +#define BGCHECK_IGNORE_WALL (1 << 1) +#define BGCHECK_IGNORE_FLOOR (1 << 2) + +// xpFlags (poly exclusion flags) +#define COLPOLY_IGNORE_NONE 0 +#define COLPOLY_IGNORE_CAMERA (1 << 0) +#define COLPOLY_IGNORE_ENTITY (1 << 1) +#define COLPOLY_IGNORE_PROJECTILES (1 << 2) + +// Surface Types +#define COLPOLY_SURFACE_GROUND 0 +#define COLPOLY_SURFACE_SAND 1 +#define COLPOLY_SURFACE_SNOW 14 + +// CollisionContext flags +#define BGCHECK_FLAG_REVERSE_CONVEYOR_FLOW 1 typedef struct { - Vec3f scale; - Vec3s rot; - Vec3f pos; -} ScaleRotPos; + /* 0x0 */ Vec3s pos; +} BgVertex; // size = 0x6 + +typedef struct { + /* 0x00 */ Vec3f scale; + /* 0x0C */ Vec3s rot; + /* 0x14 */ Vec3f pos; +} ScaleRotPos; // size = 0x20 typedef struct CollisionPoly { /* 0x00 */ u16 type; @@ -53,30 +85,44 @@ typedef struct CollisionPoly { typedef struct { /* 0x00 */ u16 cameraSType; - /* 0x02 */ s16 numCameras; + /* 0x02 */ s16 unk_02; /* 0x04 */ Vec3s* camPosData; } CamData; typedef struct { - /* 0x00 */ s16 xMin; - /* 0x02 */ s16 ySurface; - /* 0x04 */ s16 zMin; - /* 0x06 */ s16 xLength; - /* 0x08 */ s16 zLength; - /* 0x0C */ u32 properties; - + /* 0x0 */ Vec3s minPos; + /* 0x6 */ s16 xLength; + /* 0x8 */ s16 zLength; + /* 0xC */ u32 properties; // 0x0008_0000 = ? - // 0x0007_E000 = Room Index, 0x3F = all rooms - // 0x0000_1F00 = Lighting Settings Index + // 0x0007_E000 = room index, 0x3F = all rooms + // 0x0000_1F00 = lighting setting index // 0x0000_00FF = CamData index } WaterBox; // size = 0x10 typedef struct { - u32 data[2]; + /* 0x0 */ u32 data[2]; - // Type 1 + // Word 0 + // 0x8000_0000 = horse blocked + // 0x4000_0000 = floor surface recessed by 1 unit + // 0x3C00_0000 = ? (floor property?) + // 0x03E0_0000 = ? (wall property?) + // 0x001C_0000 = ? + // 0x0003_E000 = ? + // 0x0000_1F00 = scene exit index + // 0x0000_00FF = CamData index + // Word 1 // 0x0800_0000 = wall damage -} SurfaceType; + // 0x07E0_0000 = conveyor direction + // 0x001C_0000 = conveyor speed + // 0x0002_0000 = is hookable surface + // 0x0001_F800 = echo/reverb + // 0x0000_07C0 = lighting setting index + // 0x0000_0030 = surface slope + // 0x0000_000F = type + +} SurfaceType; // size = 0x8 typedef struct { /* 0x00 */ Vec3s minBounds; // minimum coordinates of poly bounding box @@ -89,49 +135,54 @@ typedef struct { /* 0x20 */ CamData* cameraDataList; /* 0x24 */ u16 numWaterBoxes; /* 0x28 */ WaterBox* waterBoxes; -} CollisionHeader; // original name: BGDataInfo +} CollisionHeader; // size = 0x2C typedef struct { - s16 polyId; - u16 next; // next SSNode index -} SSNode; + /* 0x0 */ s16 polyId; + /* 0x2 */ u16 next; // index of the next SSNode in the list, or SS_NULL if last element +} SSNode; // size = 0x4 typedef struct { - u16 head; // first SSNode index -} SSList; + u16 head; // index of the first SSNode in the list, or SS_NULL if the list is empty +} SSList; // represents a linked list of type SSNode typedef struct { - /* 0x00 */ u16 max; // original name: short_slist_node_size - /* 0x02 */ u16 count; // original name: short_slist_node_last_index - /* 0x04 */ SSNode* tbl; // original name: short_slist_node_tbl - /* 0x08 */ u8* polyCheckTbl; // points to an array of bytes, one per static poly. Zero initialized when starting a - // bg check, and set to 1 if that poly has already been tested. -} SSNodeList; + /* 0x0 */ u16 max; + /* 0x2 */ u16 count; + /* 0x4 */ SSNode* tbl; + /* 0x8 */ u8* polyCheckTbl; +} SSNodeList; // size = 0xC typedef struct { - SSNode* tbl; - s32 count; - s32 max; -} DynaSSNodeList; + /* 0x0 */ SSNode* tbl; + /* 0x4 */ u32 count; + /* 0x8 */ s32 maxNodes; +} DynaSSNodeList; // size = 0xC typedef struct { - SSList floor; - SSList wall; - SSList ceiling; -} StaticLookup; + /* 0x0 */ s32 unk0; + /* 0x4 */ WaterBox* boxes; +} DynaWaterBoxList; // size = 0x8 typedef struct { - u16 polyStartIndex; - SSList ceiling; - SSList wall; - SSList floor; -} DynaLookup; + /* 0x0 */ SSList floor; + /* 0x2 */ SSList wall; + /* 0x4 */ SSList ceiling; +} StaticLookup; // size = 0x6 typedef struct { - /* 0x00 */ struct Actor* actor; + /* 0x0 */ s16 polyStartIndex; + /* 0x2 */ SSList ceiling; + /* 0x4 */ SSList wall; + /* 0x6 */ SSList floor; +} DynaLookup; // size = 0x8 + +typedef struct { + /* 0x00 */ Actor* actor; /* 0x04 */ CollisionHeader* colHeader; /* 0x08 */ DynaLookup dynaLookup; /* 0x10 */ u16 vtxStartIndex; + /* 0x12 */ u16 waterboxesStartIndex; /* 0x14 */ ScaleRotPos prevTransform; /* 0x34 */ ScaleRotPos curTransform; /* 0x54 */ Sphere16 boundingSphere; @@ -139,25 +190,20 @@ typedef struct { /* 0x60 */ f32 maxY; } BgActor; // size = 0x64 -typedef struct { - /* 0x0 */ UNK_TYPE1 pad0[0x4]; - /* 0x4 */ WaterBox* boxes; -} DynaSSWaterboxList; // size = 0x8 - typedef struct { /* 0x0000 */ u8 bitFlag; /* 0x0004 */ BgActor bgActors[BG_ACTOR_MAX]; - /* 0x138C */ u16 bgActorFlags[BG_ACTOR_MAX]; // & 0x0008 = no dyna ceiling + /* 0x138C */ u16 bgActorFlags[BG_ACTOR_MAX]; // bit 0 - Is mesh active /* 0x13F0 */ CollisionPoly* polyList; /* 0x13F4 */ Vec3s* vtxList; - /* 0x13F8 */ DynaSSWaterboxList waterboxes; + /* 0x13F8 */ DynaWaterBoxList waterBoxList; /* 0x1400 */ DynaSSNodeList polyNodes; /* 0x140C */ s32 polyNodesMax; /* 0x1410 */ s32 polyListMax; /* 0x1414 */ s32 vtxListMax; } DynaCollisionContext; // size = 0x1418 -typedef struct CollisionContext { +typedef struct { /* 0x00 */ CollisionHeader* colHeader; // scene's static collision /* 0x04 */ Vec3f minBounds; // minimum coordinates of collision bounding box /* 0x10 */ Vec3f maxBounds; // maximum coordinates of collision bounding box @@ -166,28 +212,46 @@ typedef struct CollisionContext { /* 0x34 */ Vec3f subdivLengthInv; // inverse of subdivision length /* 0x40 */ StaticLookup* lookupTbl; // 3d array of length subdivAmount /* 0x44 */ SSNodeList polyNodes; - /* 0x50 */ DynaCollisionContext dyna; - /* 0x1460 */ u32 memSize; // Size of all allocated memory plus CollisionContext - /* 0x146C */ u32 unk146C; + /* 0x0050 */ DynaCollisionContext dyna; + /* 0x1468 */ u32 memSize; // Size of all allocated memory plus CollisionContext + /* 0x146C */ u32 flags; // bit 0 reverses conveyor direction (i.e. water flow in Great Bay Temple) } CollisionContext; // size = 0x1470 typedef struct { /* 0x00 */ struct GlobalContext* globalCtx; - /* 0x04 */ struct CollisionContext* colCtx; + /* 0x04 */ CollisionContext* colCtx; /* 0x08 */ u16 xpFlags; /* 0x0C */ CollisionPoly** resultPoly; /* 0x10 */ f32 yIntersect; /* 0x14 */ Vec3f* pos; /* 0x18 */ s32* bgId; - /* 0x1C */ struct Actor* actor; - /* 0x20 */ u32 unk_20; - /* 0x24 */ f32 chkDist; - /* 0x28 */ DynaCollisionContext* dyna; - /* 0x2C */ SSList* ssList; -} DynaRaycast; + /* 0x1C */ s32 unk1C; + /* 0x20 */ struct Actor* actor; + /* 0x24 */ u32 unk_24; + /* 0x28 */ f32 checkDist; + /* 0x2C */ DynaCollisionContext* dyna; + /* 0x30 */ SSList* ssList; +} DynaRaycast; // size = 0x34 + +typedef struct +{ + /* 0x00 */ StaticLookup* lookup; + /* 0x04 */ SSList* ssList; + /* 0x08 */ CollisionContext* colCtx; + /* 0x0C */ u16 xpFlags1; + /* 0x0E */ u16 xpFlags2; + /* 0x10 */ Vec3f* posA; + /* 0x14 */ Vec3f* posB; + /* 0x18 */ Vec3f* outPos; + /* 0x1C */ CollisionPoly** outPoly; + /* 0x20 */ f32 outDistSq; + /* 0x24 */ f32 checkDist; + /* 0x28 */ s32 bccFlags; + /* 0x2C */ Actor* actor; +} StaticLineTest; // size = 0x30 typedef struct { - /* 0x00 */ struct CollisionContext* colCtx; + /* 0x00 */ CollisionContext* colCtx; /* 0x04 */ u16 xpFlags; /* 0x08 */ DynaCollisionContext* dyna; /* 0x0C */ SSList* ssList; @@ -195,9 +259,46 @@ typedef struct { /* 0x14 */ Vec3f* posB; /* 0x18 */ Vec3f* posResult; /* 0x1C */ CollisionPoly** resultPoly; - /* 0x20 */ s32 chkOneFace; // bccFlags & 0x8 - /* 0x24 */ f32* distSq; // distance from posA to poly squared - /* 0x28 */ f32 chkDist; // distance from poly -} DynaLineTest; + /* 0x20 */ s32 checkOneFace; // bccFlags & 0x8 + /* 0x24 */ f32* distSq; // distance from posA to poly squared + /* 0x28 */ f32 checkDist; // distance from poly + /* 0x2C */ Actor* actor; + /* 0x30 */ s32 bgId; +} DynaLineTest; // size = 0x34 +typedef struct { + /* 0x00 */ CollisionPoly* poly; + /* 0x04 */ Vec3s* vtxList; + /* 0x08 */ Vec3f* posA; + /* 0x0C */ Vec3f* posB; + /* 0x10 */ Vec3f* planeIntersect; + /* 0x14 */ s32 checkOneFace; + /* 0x18 */ f32 checkDist; +} BgLineVsPolyTest; // size = 0x1C + +typedef struct { + /* 0x0 */ s16 sceneId; + /* 0x4 */ u32 memSize; +} BgSpecialSceneMaxMemory; // size = 0x8 + +typedef struct { + /* 0x0 */ s16 sceneId; + /* 0x2 */ s16 maxNodes; + /* 0x4 */ s16 maxPolygons; + /* 0x6 */ s16 maxVertices; +} BgSpecialSceneMaxObjects; // size = 0x8 + +typedef struct { + /* 0x0 */ s16 sceneId; + /* 0x2 */ s16 xSubdivisions; + /* 0x4 */ s16 ySubdivisions; + /* 0x6 */ s16 zSubdivisions; + /* 0x8 */ s32 unk8; +} BgSpecialSceneMeshSubdivision; // size = 0xC + +typedef struct { + s16 sceneId; + Vec3s subdivAmount; + s32 nodeListMax; // if -1, dynamically compute max nodes +} BgCheckSceneSubdivisionEntry; #endif diff --git a/include/z64item.h b/include/z64item.h index a312e69619..82dc6e352f 100644 --- a/include/z64item.h +++ b/include/z64item.h @@ -327,6 +327,7 @@ typedef enum { /* 0x8D */ GI_MASK_BLAST, /* 0x8E */ GI_MASK_SCENTS, /* 0x8F */ GI_MASK_GIANT, + /* 0x92 */ GI_MILK = 0x92, /* 0x96 */ GI_MOON_TEAR = 0x96, /* 0x97 */ GI_DEED_LAND, /* 0x98 */ GI_DEED_SWAMP, diff --git a/include/z64jpeg.h b/include/z64jpeg.h new file mode 100644 index 0000000000..38183bfa90 --- /dev/null +++ b/include/z64jpeg.h @@ -0,0 +1,99 @@ +#ifndef Z64_JPEG_H +#define Z64_JPEG_H + +#include "PR/ultratypes.h" +#include "ultra64/message.h" +#include "PR/sched.h" + +typedef struct { + /* 0x00 */ u16 table[8*8]; +} JpegQuantizationTable; // size = 0x80 + +typedef struct { + /* 0x00 */ u8 codeOffs[16]; + /* 0x10 */ u16 codesA[16]; + /* 0x30 */ u16 codesB[16]; + /* 0x50 */ u8* symbols; +} JpegHuffmanTable; // size = 0x54 + +// this struct might be inaccurate but it's not used outside jpegutils.c +typedef struct { + /* 0x000 */ u8 codeOffs[16]; + /* 0x010 */ u16 dcCodes[120]; + /* 0x100 */ u16 acCodes[256]; +} JpegHuffmanTableOld; // size = 0x300 + +typedef struct { + /* 0x00 */ void* address; + /* 0x04 */ u32 mbCount; + /* 0x08 */ u32 mode; + /* 0x0C */ void* qTableYPtr; + /* 0x10 */ void* qTableUPtr; + /* 0x14 */ void* qTableVPtr; + /* 0x18 */ char unk_18[0x8]; +} JpegTaskData; // size = 0x20 + +typedef struct { + /* 0x000 */ JpegTaskData taskData; + /* 0x020 */ char yieldData[0x200]; + /* 0x220 */ JpegQuantizationTable qTableY; + /* 0x2A0 */ JpegQuantizationTable qTableU; + /* 0x320 */ JpegQuantizationTable qTableV; + /* 0x3A0 */ u8 codesLengths[0x110]; + /* 0x4B0 */ u16 codes[0x108]; + /* 0x6C0 */ u16 data[4][0x180]; +} JpegWork; // size = 0x12C0 + +typedef struct { + /* 0x00 */ void* imageData; + /* 0x04 */ u8 mode; + /* 0x05 */ u8 unk_05; + /* 0x08 */ JpegHuffmanTable* hTablePtrs[4]; + /* 0x18 */ u8 unk_18; +} JpegDecoder; // size = 0x1C + +typedef struct { + /* 0x00 */ u8 dqtCount; + /* 0x04 */ u8* dqtPtr[3]; + /* 0x10 */ u8 dhtCount; + /* 0x14 */ u8* dhtPtr[4]; + /* 0x24 */ void* imageData; + /* 0x28 */ u8 mode; // 0 if Y V0 is 1 and 2 if Y V0 is 2 + /* 0x30 */ OSScTask scTask; + /* 0x98 */ OSMesgQueue mq; + /* 0xB0 */ OSMesg msg; + /* 0xB4 */ JpegWork* workBuf; +} JpegContext; // size = 0xB8 + +typedef struct { + /* 0x00 */ u32 byteIdx; + /* 0x04 */ u8 bitIdx; + /* 0x05 */ u8 dontSkip; + /* 0x08 */ u32 curWord; + /* 0x0C */ s16 unk_0C; + /* 0x0E */ s16 unk_0E; + /* 0x10 */ s16 unk_10; +} JpegDecoderState; // size = 0x14 + + +void Jpeg_ScheduleDecoderTask(JpegContext* jpegCtx); +void Jpeg_CopyToZbuffer(u16* src, u16* zbuffer, s32 x, s32 y); +u16 Jpeg_GetUnalignedU16(u8* ptr); +void Jpeg_ParseMarkers(u8* ptr, JpegContext* jpegCtx); +s32 Jpeg_Decode(void* data, void* zbuffer, void* work, u32 workSize); + +void JpegUtils_ProcessQuantizationTable(u8* dqt, JpegQuantizationTable* qt, u8 count); +s32 JpegUtils_ParseHuffmanCodesLengths(u8* ptr, u8* codesLengths); +s32 JpegUtils_GetHuffmanCodes(u8* codesLengths, u16* codes); +s32 JpegUtils_SetHuffmanTable(u8* data, JpegHuffmanTable* ht, u16* codes); +u32 JpegUtils_ProcessHuffmanTableImpl(u8* data, JpegHuffmanTable* ht, u8* codesLengths, u16* codes, u8 isAc); +u32 JpegUtils_ProcessHuffmanTable(u8* dht, JpegHuffmanTable* ht, u8* codesLengths, u16* codes, u8 count); +void JpegUtils_SetHuffmanTableOld(u8* data, JpegHuffmanTableOld* ht, u8* codesLengths, u16* codes, s16 count, u8 isAc); +u32 JpegUtils_ProcessHuffmanTableImplOld(u8* dht, JpegHuffmanTableOld* ht, u8* codesLengths, u16* codes); + +s32 JpegDecoder_Decode(JpegDecoder* decoder, u16* mcuBuff, s32 count, u8 isFollowing, JpegDecoderState* state); +s32 JpegDecoder_ProcessMcu(JpegHuffmanTable* hTable0, JpegHuffmanTable* hTable1, u16* mcu, s16* unk); +s32 JpegDecoder_ParseNextSymbol(JpegHuffmanTable* hTable, s16* outCoeff, s8* outZeroCount); +u16 JpegDecoder_ReadBits(u8 len); + +#endif diff --git a/spec b/spec index 157e701328..b282930333 100644 --- a/spec +++ b/spec @@ -27,7 +27,6 @@ beginseg include "build/src/boot_O2_g3/fault.o" include "build/data/boot/fault.bss.o" include "build/src/boot_O2_g3/fault_drawer.o" - include "build/data/boot/fault_drawer.bss.o" include "build/src/boot_O2/boot_80084940.o" include "build/src/boot_O2/loadfragment.o" include "build/data/boot/loadfragment.data.o" @@ -170,7 +169,7 @@ beginseg include "build/src/libultra/voice/voicecontwrite20.o" include "build/src/libultra/io/crc.o" include "build/src/libultra/os/getactivequeue.o" - include "build/src/libultra/gu/normalize.o" + include "build/asm/boot/normalize.text.o" include "build/asm/boot/setcompare.text.o" include "build/asm/boot/getcompare.text.o" include "build/src/libultra/io/dpgetstat.o" @@ -195,8 +194,6 @@ beginseg include "build/src/libultra/io/pfsisplug.o" include "build/src/libultra/voice/voicegetstatus.o" include "build/src/libultra/io/cartrominit.o" - include "build/data/boot/cartrominit.data.o" - include "build/data/boot/cartrominit.bss.o" include "build/src/libultra/gu/guS2DInitBg.o" include "build/data/boot/guS2DInitBg.data.o" include "build/src/libultra/io/pfsselectbank.o" @@ -428,7 +425,7 @@ beginseg compress after "dmadata" include "build/src/code/z_en_a_keep.o" - include "build/data/code/z_en_a_keep.data.o" + include "build/data/code/rsp.data.o" include "build/data/code/code_801ADE60.data.o" include "build/data/code/code_801E3FA0.bss.o" include "build/src/code/z_en_item00.o" @@ -453,11 +450,8 @@ beginseg include "build/data/code/z_actor.bss.o" include "build/src/code/z_actor_dlftbls.o" include "build/src/code/z_bgcheck.o" - include "build/data/code/z_bgcheck.data.o" - include "build/data/code/z_bgcheck.bss.o" include "build/src/code/z_bg_collect.o" include "build/src/code/z_bg_item.o" - include "build/src/code/code_800CB000.o" include "build/src/code/z_camera.o" include "build/data/code/z_camera.data.o" include "build/data/code/z_camera.bss.o" @@ -493,8 +487,8 @@ beginseg include "build/src/code/z_horse.o" include "build/data/code/z_horse.data.o" include "build/src/code/z_jpeg.o" - include "build/data/code/z_jpeg.data.o" include "build/src/code/z_kaleido_setup.o" + include "build/data/code/z_kaleido_setup.data.o" include "build/src/code/z_kanfont.o" include "build/src/code/z_kankyo.o" include "build/data/code/z_kankyo.data.o" @@ -640,38 +634,50 @@ beginseg pad_text pad_text pad_text - include "build/src/code/audio_synthesis.o" - include "build/src/code/audio_heap.o" - include "build/data/code/code_801D2E80.data.o" + include "build/data/code/audio_data.data.o" + include "build/src/code/audio/audio_synthesis.o" + include "build/data/code/audio_synthesis.data.o" + include "build/src/code/audio/audio_heap.o" include "build/data/code/audio_heap.bss.o" - include "build/data/code/code_801D3D90.data.o" - include "build/src/code/audio_load.o" + include "build/src/code/audio/audio_load.o" + include "build/data/code/audio_load.data.o" include "build/data/code/audio_load.bss.o" - include "build/src/code/code_80192BE0.o" - include "build/src/code/code_80194710.o" - include "build/src/code/audio_playback.o" - include "build/src/code/audio_effects.o" - include "build/src/code/audio_seqplayer.o" + include "build/src/code/audio/code_80192BE0.o" + include "build/data/code/code_80192BE0.data.o" + include "build/src/code/audio/code_80194710.o" + include "build/src/code/audio/code_80194790.o" + include "build/data/code/code_80194790.data.o" + include "build/src/code/audio/audio_playback.o" + include "build/src/code/audio/audio_effects.o" + include "build/data/code/audio_effects.data.o" + include "build/src/code/audio/audio_seqplayer.o" + include "build/data/code/audio_seqplayer.data.o" + include "build/data/code/audio_dramStack.data.o" include "build/asm/code/code_8019AE40.text.o" // handwritten pad_text include "build/asm/code/code_8019AEC0.text.o" // handwritten - include "build/src/code/code_8019AF00.o" + include "build/src/code/audio/code_8019AF00.o" + include "build/data/code/code_8019AF00.data.o" include "build/data/code/code_8019AF00.bss.o" - include "build/data/code/code_801D55B0.data.o" - include "build/src/code/code_801A51F0.o" + include "build/src/code/audio/code_801A4EB0.o" + include "build/data/code/code_801A4EB0.data.o" + include "build/src/code/audio/code_801A51F0.o" include "build/data/code/code_801A51F0.data.o" include "build/data/code/code_801A51F0.bss.o" pad_text - include "build/src/code/code_801A5BD0.o" + include "build/src/code/audio/audio_sfx_params.o" + include "build/src/code/audio/code_801A5BD0.o" + include "build/data/code/code_801A5BD0.data.o" include "build/data/code/code_801A5BD0.bss.o" - include "build/src/code/code_801A7B10.o" + include "build/src/code/audio/code_801A7B10.o" + include "build/data/code/code_801A7B10.data.o" include "build/data/code/code_801A7B10.bss.o" - include "build/src/code/code_801AA020.o" - include "build/data/code/code_801AA020.bss.o" + include "build/data/code/audio_init_params.rodata.o" + include "build/src/code/jpegutils.o" + include "build/src/code/jpegdecoder.o" include_readonly "build/src/code/z_game_over.o" include "build/src/code/z_construct.o" - include "build/data/code/code_801D9090.data.o" - include "build/data/code/code_801E1180.rodata.o" + include "build/data/code/rsp.rodata.o" endseg beginseg @@ -1181,8 +1187,7 @@ beginseg name "ovl_Obj_Mure" compress include "build/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.o" - include "build/data/ovl_Obj_Mure/ovl_Obj_Mure.data.o" - include "build/data/ovl_Obj_Mure/ovl_Obj_Mure.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Mure/ovl_Obj_Mure_reloc.o" endseg beginseg @@ -1315,16 +1320,14 @@ beginseg name "ovl_En_Rr" compress include "build/src/overlays/actors/ovl_En_Rr/z_en_rr.o" - include "build/data/ovl_En_Rr/ovl_En_Rr.data.o" - include "build/data/ovl_En_Rr/ovl_En_Rr.reloc.o" + include "build/src/overlays/actors/ovl_En_Rr/ovl_En_Rr_reloc.o" endseg beginseg name "ovl_En_Fr" compress include "build/src/overlays/actors/ovl_En_Fr/z_en_fr.o" - include "build/data/ovl_En_Fr/ovl_En_Fr.data.o" - include "build/data/ovl_En_Fr/ovl_En_Fr.reloc.o" + include "build/src/overlays/actors/ovl_En_Fr/ovl_En_Fr_reloc.o" endseg beginseg @@ -1619,8 +1622,7 @@ beginseg name "ovl_En_Gm" compress include "build/src/overlays/actors/ovl_En_Gm/z_en_gm.o" - include "build/data/ovl_En_Gm/ovl_En_Gm.data.o" - include "build/data/ovl_En_Gm/ovl_En_Gm.reloc.o" + include "build/src/overlays/actors/ovl_En_Gm/ovl_En_Gm_reloc.o" endseg beginseg @@ -1719,16 +1721,14 @@ beginseg name "ovl_En_Stream" compress include "build/src/overlays/actors/ovl_En_Stream/z_en_stream.o" - include "build/data/ovl_En_Stream/ovl_En_Stream.data.o" - include "build/data/ovl_En_Stream/ovl_En_Stream.reloc.o" + include "build/src/overlays/actors/ovl_En_Stream/ovl_En_Stream_reloc.o" endseg beginseg name "ovl_En_Mm" compress include "build/src/overlays/actors/ovl_En_Mm/z_en_mm.o" - include "build/data/ovl_En_Mm/ovl_En_Mm.data.o" - include "build/data/ovl_En_Mm/ovl_En_Mm.reloc.o" + include "build/src/overlays/actors/ovl_En_Mm/ovl_En_Mm_reloc.o" endseg beginseg @@ -1790,8 +1790,7 @@ beginseg name "ovl_En_Kakasi" compress include "build/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.o" - include "build/data/ovl_En_Kakasi/ovl_En_Kakasi.data.o" - include "build/data/ovl_En_Kakasi/ovl_En_Kakasi.reloc.o" + include "build/src/overlays/actors/ovl_En_Kakasi/ovl_En_Kakasi_reloc.o" endseg beginseg @@ -2224,8 +2223,7 @@ beginseg name "ovl_En_Cow" compress include "build/src/overlays/actors/ovl_En_Cow/z_en_cow.o" - include "build/data/ovl_En_Cow/ovl_En_Cow.data.o" - include "build/data/ovl_En_Cow/ovl_En_Cow.reloc.o" + include "build/src/overlays/actors/ovl_En_Cow/ovl_En_Cow_reloc.o" endseg beginseg @@ -3285,8 +3283,7 @@ beginseg name "ovl_Dm_Stk" compress include "build/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.o" - include "build/data/ovl_Dm_Stk/ovl_Dm_Stk.data.o" - include "build/data/ovl_Dm_Stk/ovl_Dm_Stk.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Stk/ovl_Dm_Stk_reloc.o" endseg beginseg @@ -3747,9 +3744,7 @@ beginseg name "ovl_En_Tk" compress include "build/src/overlays/actors/ovl_En_Tk/z_en_tk.o" - include "build/data/ovl_En_Tk/ovl_En_Tk.data.o" - include "build/data/ovl_En_Tk/ovl_En_Tk.bss.o" - include "build/data/ovl_En_Tk/ovl_En_Tk.reloc.o" + include "build/src/overlays/actors/ovl_En_Tk/ovl_En_Tk_reloc.o" endseg beginseg @@ -3827,8 +3822,7 @@ beginseg name "ovl_En_Pm" compress include "build/src/overlays/actors/ovl_En_Pm/z_en_pm.o" - include "build/data/ovl_En_Pm/ovl_En_Pm.data.o" - include "build/data/ovl_En_Pm/ovl_En_Pm.reloc.o" + include "build/src/overlays/actors/ovl_En_Pm/ovl_En_Pm_reloc.o" endseg beginseg @@ -4939,8 +4933,7 @@ beginseg name "ovl_En_Hit_Tag" compress include "build/src/overlays/actors/ovl_En_Hit_Tag/z_en_hit_tag.o" - include "build/data/ovl_En_Hit_Tag/ovl_En_Hit_Tag.data.o" - include "build/data/ovl_En_Hit_Tag/ovl_En_Hit_Tag.reloc.o" + include "build/src/overlays/actors/ovl_En_Hit_Tag/ovl_En_Hit_Tag_reloc.o" endseg beginseg @@ -8861,14 +8854,16 @@ beginseg name "memerrmsg" compress romalign 0x1000 - include "build/baserom/memerrmsg.o" + include "build/assets/misc/memerrmsg/memerrmsg.o" + number 1 endseg beginseg name "locerrmsg" compress romalign 0x1000 - include "build/baserom/locerrmsg.o" + include "build/assets/misc/locerrmsg/locerrmsg.o" + number 1 endseg beginseg diff --git a/src/boot_O2_g3/CIC6105.c b/src/boot_O2_g3/CIC6105.c index 7e9d960bf6..4745ad5c89 100644 --- a/src/boot_O2_g3/CIC6105.c +++ b/src/boot_O2_g3/CIC6105.c @@ -1,6 +1,5 @@ #include "prevent_bss_reordering.h" #include "global.h" -#include "prevent_bss_reordering.h" UNK_TYPE4 D_8009BE30; UNK_TYPE4 D_8009BE34; diff --git a/src/boot_O2_g3/fault.c b/src/boot_O2_g3/fault.c index b32b5aa98a..c5af62f825 100644 --- a/src/boot_O2_g3/fault.c +++ b/src/boot_O2_g3/fault.c @@ -575,66 +575,59 @@ void Fault_DrawMemDump(u32 pc, u32 sp, u32 unk0, u32 unk1) { sFaultContext->faultActive = 1; } -#ifdef NON_MATCHING -// This function still needs a bit of work -void Fault_FindNextStackCall(u32** sp, u32** pc, u32** ra) { - u32* currentSp; - u32* currentPc; - u32* currentRa; - u32 lastInst; - u32 currInst; +void Fault_FindNextStackCall(uintptr_t* spPtr, uintptr_t* pcPtr, uintptr_t* raPtr) { + uintptr_t sp = *spPtr; + uintptr_t pc = *pcPtr; + uintptr_t ra = *raPtr; + u32 lastOpc; + u16 opcHi; + s16 opcLo; + u32 imm; - currentSp = *sp; - currentPc = *pc; - currentRa = *ra; - - if ((((u32)currentSp & 3) != 0) || (currentSp < (u32*)0x80000000) || (currentSp >= (u32*)0xC0000000) || - (((u32)currentRa & 3) != 0) || (currentRa < (u32*)0x80000000) || (currentRa >= (u32*)0xC0000000)) { - *sp = NULL; - *pc = NULL; - *ra = NULL; + if (sp & 3 || sp < 0x80000000 || sp >= 0xC0000000 || ra & 3 || ra < 0x80000000 || ra >= 0xC0000000) { + *spPtr = 0; + *pcPtr = 0; + *raPtr = 0; return; } - if ((((u32)currentPc & 3) != 0) || (currentPc < (u32*)0x80000000) || (currentPc >= (u32*)0xC0000000)) { - *pc = currentRa; + if (pc & 3 || pc < 0x80000000 || pc >= 0xC0000000) { + *pcPtr = ra; return; } - lastInst = 0; - while (1) { - currInst = *currentPc; - if (((currInst >> 0x10) & 0xFFFF) == 0x8FBF) { - currentRa = *(u32**)((u32)currentSp + (s16)currInst); - } else if (((currInst >> 0x10) & 0xFFFF) == 0x27BD) { - currentSp = (u32*)((u32)currentSp + (s16)currInst); - } else if (currInst == 0x42000018) { - currentSp = NULL; - currentPc = NULL; - currentRa = NULL; - break; - } + lastOpc = 0; + while (true) { + opcHi = *(uintptr_t*)pc >> 16; + opcLo = *(uintptr_t*)pc & 0xFFFF; + imm = opcLo; - if (lastInst == 0x03E00008) { - break; + if (opcHi == 0x8FBF) { + ra = *(uintptr_t*)(sp + imm); + } else if (opcHi == 0x27BD) { + sp += imm; + } else if (*(uintptr_t*)pc == 0x42000018) { + sp = 0; + pc = 0; + ra = 0; + goto end; } - - if ((lastInst >> 0x1A) == 2) { - currentPc = (u32*)((((u32)currentPc >> 0x1C) << 0x1C) | ((lastInst << 6) >> 4)); - break; + if (lastOpc == 0x3E00008) { + pc = ra; + goto end; + } else if ((lastOpc >> 26) == 2) { + pc = pc >> 28 << 28 | lastOpc << 6 >> 4; + goto end; } - - lastInst = currInst; - currentPc++; + lastOpc = *(uintptr_t*)pc; + pc += 4; } - *sp = currentSp; - *pc = currentPc; - *ra = currentRa; +end: + *spPtr = sp; + *pcPtr = pc; + *raPtr = ra; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/boot/fault/Fault_FindNextStackCall.s") -#endif void Fault_DrawStackTrace(OSThread* t, u32 flags) { s32 y; @@ -664,7 +657,7 @@ void Fault_DrawStackTrace(OSThread* t, u32 flags) { FaultDrawer_Printf(" -> ????????"); } - Fault_FindNextStackCall((u32**)&sp, (u32**)&pc, (u32**)&ra); + Fault_FindNextStackCall(&sp, &pc, &ra); } } @@ -695,7 +688,7 @@ void osSyncPrintfStackTrace(OSThread* t, u32 flags) { } osSyncPrintf("\n"); - Fault_FindNextStackCall((u32**)&sp, (u32**)&pc, (u32**)&ra); + Fault_FindNextStackCall(&sp, &pc, &ra); } } @@ -714,7 +707,7 @@ void Fault_CommitFB() { osViSetYScale(1.0f); osViSetMode(&osViModeNtscLan1); osViSetSpecialFeatures(0x42); // gama_disable|dither_fliter_enable_aa_mode3_disable - osViBlack(0); + osViBlack(false); if (sFaultContext->fb) { fb = sFaultContext->fb; @@ -751,32 +744,33 @@ void Fault_ProcessClients(void) { } #ifdef NON_MATCHING -// regalloc and ordering differences around the two bool variables (faultCustomOptions and faultCopyToLog) +// needs in-function static bss void Fault_SetOptionsFromController3(void) { - Input* input3; + static u32 faultCustomOptions; + Input* input3 = &sFaultContext->padInput[3]; u32 pad; u32 graphPC; u32 graphRA; u32 graphSP; - input3 = &sFaultContext->padInput[3]; - if (CHECK_BTN_ALL(input3->press.button, 0x80)) { - faultCustomOptions = faultCustomOptions == 0; + faultCustomOptions = !faultCustomOptions; } if (faultCustomOptions) { graphPC = sGraphThread.context.pc; graphRA = sGraphThread.context.ra; graphSP = sGraphThread.context.sp; - if (CHECK_BTN_ALL(input3->press.button, BTN_R)) { + if (CHECK_BTN_ALL(input3->cur.button, BTN_R)) { + static u32 faultCopyToLog; + faultCopyToLog = !faultCopyToLog; FaultDrawer_SetOsSyncPrintfEnabled(faultCopyToLog); } - if (CHECK_BTN_ALL(input3->press.button, BTN_A)) { + if (CHECK_BTN_ALL(input3->cur.button, BTN_A)) { osSyncPrintf("GRAPH PC=%08x RA=%08x STACK=%08x\n", graphPC, graphRA, graphSP); } - if (CHECK_BTN_ALL(input3->press.button, BTN_B)) { + if (CHECK_BTN_ALL(input3->cur.button, BTN_B)) { FaultDrawer_SetDrawerFB(osViGetNextFramebuffer(), 0x140, 0xF0); Fault_DrawRec(0, 0xD7, 0x140, 9, 1); FaultDrawer_SetCharPad(-2, 0); diff --git a/src/boot_O2_g3/fault_drawer.c b/src/boot_O2_g3/fault_drawer.c index 949faadf18..eacfc56d15 100644 --- a/src/boot_O2_g3/fault_drawer.c +++ b/src/boot_O2_g3/fault_drawer.c @@ -3,9 +3,11 @@ extern const u32 sFaultDrawerFont[]; +FaultDrawer sFaultDrawerStruct; + FaultDrawer* sFaultDrawContext = &sFaultDrawerStruct; FaultDrawer sFaultDrawerDefault = { - (u16*)0x803DA800, // fb - TODO map out buffers in this region and avoid hard-coded pointer + FAULT_FB_ADDRESS, // fb SCREEN_WIDTH, // w SCREEN_HEIGHT, // h 16, // yStart @@ -16,23 +18,23 @@ FaultDrawer sFaultDrawerDefault = { GPACK_RGBA5551(0, 0, 0, 0), // backColor 22, // cursorX 16, // cursorY - (u32*)sFaultDrawerFont, // font + sFaultDrawerFont, // font 8, // charW 8, // charH 0, // charWPad - 0, // charHPad + 0, // charHPad { // printColors - GPACK_RGBA5551(0, 0, 0, 1), - GPACK_RGBA5551(255, 0, 0, 1), - GPACK_RGBA5551(0, 255, 0, 1), - GPACK_RGBA5551(255, 255, 0, 1), - GPACK_RGBA5551(0, 0, 255, 1), - GPACK_RGBA5551(255, 0, 255, 1), - GPACK_RGBA5551(0, 255, 255, 1), - GPACK_RGBA5551(255, 255, 255, 1), - GPACK_RGBA5551(120, 120, 120, 1), - GPACK_RGBA5551(176, 176, 176, 1), + GPACK_RGBA5551(0, 0, 0, 1), // BLACK + GPACK_RGBA5551(255, 0, 0, 1), // RED + GPACK_RGBA5551(0, 255, 0, 1), // GREEN + GPACK_RGBA5551(255, 255, 0, 1), // YELLOW + GPACK_RGBA5551(0, 0, 255, 1), // BLUE + GPACK_RGBA5551(255, 0, 255, 1), // MAGENTA + GPACK_RGBA5551(0, 255, 255, 1), // CYAN + GPACK_RGBA5551(255, 255, 255, 1), // WHITE + GPACK_RGBA5551(120, 120, 120, 1), // DARK GRAY + GPACK_RGBA5551(176, 176, 176, 1), // LIGHT GRAY }, 0, // escCode 0, // osSyncPrintfEnabled @@ -47,7 +49,8 @@ void FaultDrawer_SetOsSyncPrintfEnabled(u32 enabled) { void FaultDrawer_DrawRecImpl(s32 xStart, s32 yStart, s32 xEnd, s32 yEnd, u16 color) { u16* fb; - s32 x, y; + s32 x; + s32 y; s32 xDiff = sFaultDrawContext->w - xStart; s32 yDiff = sFaultDrawContext->h - yStart; s32 xSize = xEnd - xStart + 1; @@ -74,7 +77,37 @@ void FaultDrawer_DrawRecImpl(s32 xStart, s32 yStart, s32 xEnd, s32 yEnd, u16 col } } -#pragma GLOBAL_ASM("asm/non_matchings/boot/fault_drawer/FaultDrawer_DrawChar.s") +void FaultDrawer_DrawChar(char c) { + s32 x; + s32 y; + u32 data; + s32 cursorX = sFaultDrawContext->cursorX; + s32 cursorY = sFaultDrawContext->cursorY; + s32 shift = c % 4; + const u32* dataPtr = &sFaultDrawContext->font[(((c / 8) * 16) + ((c & 4) >> 2))]; + u16* fb = sFaultDrawContext->fb + (sFaultDrawContext->w * cursorY) + cursorX; + + if ((sFaultDrawContext->xStart <= cursorX) && + ((sFaultDrawContext->charW + cursorX - 1) <= sFaultDrawContext->xEnd) && + (sFaultDrawContext->yStart <= cursorY) && + ((sFaultDrawContext->charH + cursorY - 1) <= sFaultDrawContext->yEnd)) { + for (y = 0; y < sFaultDrawContext->charH; y++) { + u32 mask = 0x10000000 << shift; + + data = *dataPtr; + for (x = 0; x < sFaultDrawContext->charW; x++) { + if (mask & data) { + fb[x] = sFaultDrawContext->foreColor; + } else if (sFaultDrawContext->backColor & 1) { + fb[x] = sFaultDrawContext->backColor; + } + mask >>= 4; + } + fb += sFaultDrawContext->w; + dataPtr += 2; + } + } +} s32 FaultDrawer_ColorToPrintColor(u16 color) { s32 i; @@ -142,12 +175,57 @@ void FaultDrawer_FillScreen() { FaultDrawer_SetCursor(sFaultDrawContext->xStart, sFaultDrawContext->yStart); } -#pragma GLOBAL_ASM("asm/non_matchings/boot/fault_drawer/FaultDrawer_FormatStringFunc.s") +void* FaultDrawer_FormatStringFunc(void* arg, const char* str, size_t count) { + for (; count != 0; count--, str++) { + if (sFaultDrawContext->escCode) { + sFaultDrawContext->escCode = false; + if (*str >= '1' && *str <= '9') { + FaultDrawer_SetForeColor(sFaultDrawContext->printColors[*str - '0']); + } + } else { + switch (*str) { + case '\n': + if (sFaultDrawContext->osSyncPrintfEnabled) { + osSyncPrintf("\n"); + } + + sFaultDrawContext->cursorX = sFaultDrawContext->w; + break; + case '\x1A': + sFaultDrawContext->escCode = true; + break; + default: + if (sFaultDrawContext->osSyncPrintfEnabled) { + osSyncPrintf("%c", *str); + } + + FaultDrawer_DrawChar(*str); + sFaultDrawContext->cursorX += sFaultDrawContext->charW + sFaultDrawContext->charWPad; + } + } + + if (sFaultDrawContext->cursorX >= (sFaultDrawContext->xEnd - sFaultDrawContext->charW)) { + sFaultDrawContext->cursorX = sFaultDrawContext->xStart; + sFaultDrawContext->cursorY += sFaultDrawContext->charH + sFaultDrawContext->charHPad; + if (sFaultDrawContext->yEnd - sFaultDrawContext->charH <= sFaultDrawContext->cursorY) { + if (sFaultDrawContext->inputCallback != NULL) { + sFaultDrawContext->inputCallback(); + FaultDrawer_FillScreen(); + } + sFaultDrawContext->cursorY = sFaultDrawContext->yStart; + } + } + } + + osWritebackDCacheAll(); + + return arg; +} const char D_80099080[] = "(null)"; -void FaultDrawer_VPrintf(const char* str, char* args) { // va_list - _Printf((PrintCallback)FaultDrawer_FormatStringFunc, sFaultDrawContext, str, args); +void FaultDrawer_VPrintf(const char* fmt, va_list ap) { + _Printf(FaultDrawer_FormatStringFunc, sFaultDrawContext, fmt, ap); } void FaultDrawer_Printf(const char* fmt, ...) { @@ -175,7 +253,7 @@ void FaultDrawer_SetDrawerFB(void* fb, u16 w, u16 h) { sFaultDrawContext->h = h; } -void FaultDrawer_SetInputCallback(void* callback) { +void FaultDrawer_SetInputCallback(FaultDrawerCallback callback) { sFaultDrawContext->inputCallback = callback; } diff --git a/src/boot_O2_g3/idle.c b/src/boot_O2_g3/idle.c index f2cded98c2..7a1d636431 100644 --- a/src/boot_O2_g3/idle.c +++ b/src/boot_O2_g3/idle.c @@ -19,11 +19,11 @@ OSMesgQueue gPiMgrCmdQ; void Idle_ClearMemory(void* begin, void* end) { if (begin < end) { - bzero(begin, (u32)end - (u32)begin); + bzero(begin, (uintptr_t)end - (uintptr_t)begin); } } -void Idle_InitFramebuffer(u32* ptr, u32 numBytes, u32 value) { +void Idle_InitFramebuffer(u32* ptr, size_t numBytes, u32 value) { s32 temp = sizeof(u32); while (numBytes) { @@ -36,7 +36,7 @@ void Idle_InitScreen(void) { Idle_InitFramebuffer((u32*)gFramebuffer1, 0x25800, 0x00010001); ViConfig_UpdateVi(0); osViSwapBuffer(gFramebuffer1); - osViBlack(0); + osViBlack(false); } void Idle_InitMemory(void) { @@ -52,7 +52,7 @@ void Idle_InitCodeAndMemory(void) { DmaRequest dmaReq; OSMesgQueue queue; OSMesg mesg; - u32 oldSize; + size_t oldSize; osCreateMesgQueue(&queue, &mesg, 1); @@ -71,7 +71,7 @@ void Idle_InitCodeAndMemory(void) { } void Main_ThreadEntry(void* arg) { - StackCheck_Init(&sIrqMgrStackInfo, sIrqMgrStack, sIrqMgrStack + sizeof(sIrqMgrStack), 0, 256, "irqmgr"); + StackCheck_Init(&sIrqMgrStackInfo, sIrqMgrStack, sIrqMgrStack + sizeof(sIrqMgrStack), 0, 0x100, "irqmgr"); IrqMgr_Init(&gIrqMgr, &sIrqMgrStackInfo, Z_PRIORITY_IRQMGR, 1); DmaMgr_Start(); Idle_InitCodeAndMemory(); @@ -87,15 +87,15 @@ void Idle_InitVideo(void) { gViConfigYScale = 1.0; switch (osTvType) { - case 1: + case OS_TV_NTSC: D_8009B290 = 2; gViConfigMode = osViModeNtscLan1; break; - case 2: + case OS_TV_MPAL: D_8009B290 = 30; gViConfigMode = osViModeMpalLan1; break; - case 0: + case OS_TV_PAL: D_8009B290 = 44; gViConfigMode = osViModeFpalLan1; gViConfigYScale = 0.833f; @@ -108,7 +108,7 @@ void Idle_InitVideo(void) { void Idle_ThreadEntry(void* arg) { Idle_InitVideo(); osCreatePiManager(150, &gPiMgrCmdQ, sPiMgrCmdBuff, ARRAY_COUNT(sPiMgrCmdBuff)); - StackCheck_Init(&sMainStackInfo, sMainStack, sMainStack + sizeof(sMainStack), 0, 1024, "main"); + StackCheck_Init(&sMainStackInfo, sMainStack, sMainStack + sizeof(sMainStack), 0, 0x400, "main"); osCreateThread(&gMainThread, Z_THREAD_ID_MAIN, Main_ThreadEntry, arg, sMainStack + sizeof(sMainStack), Z_PRIORITY_MAIN); osStartThread(&gMainThread); diff --git a/src/boot_O2_g3/viconfig.c b/src/boot_O2_g3/viconfig.c index d32fc9b918..6539421e69 100644 --- a/src/boot_O2_g3/viconfig.c +++ b/src/boot_O2_g3/viconfig.c @@ -3,13 +3,13 @@ void ViConfig_UpdateVi(u32 mode) { if (mode != 0) { switch (osTvType) { - case 2: + case OS_TV_MPAL: osViSetMode(&osViModeMpalLan1); break; - case 0: + case OS_TV_PAL: osViSetMode(&osViModePalLan1); break; - case 1: + case OS_TV_NTSC: default: osViSetMode(&osViModeNtscLan1); break; @@ -47,8 +47,8 @@ void ViConfig_UpdateVi(u32 mode) { void ViConfig_UpdateBlack(void) { if (gViConfigUseDefault != 0) { - osViBlack(1); + osViBlack(true); } else { - osViBlack(0); + osViBlack(false); } } diff --git a/src/boot_O2_g3/z_std_dma.c b/src/boot_O2_g3/z_std_dma.c index 2903b488f6..25fc8fbb08 100644 --- a/src/boot_O2_g3/z_std_dma.c +++ b/src/boot_O2_g3/z_std_dma.c @@ -9,12 +9,12 @@ OSMesg sDmaMgrMsgs[32]; OSThread sDmaMgrThread; u8 sDmaMgrStack[0x500]; -s32 DmaMgr_DMARomToRam(u32 rom, void* ram, size_t size) { +s32 DmaMgr_DMARomToRam(uintptr_t rom, void* ram, size_t size) { OSIoMesg ioMsg; OSMesgQueue queue; OSMesg msg[1]; s32 ret; - u32 buffSize = sDmaMgrDmaBuffSize; + size_t buffSize = sDmaMgrDmaBuffSize; osInvalDCache(ram, size); osCreateMesgQueue(&queue, msg, ARRAY_COUNT(msg)); @@ -23,7 +23,7 @@ s32 DmaMgr_DMARomToRam(u32 rom, void* ram, size_t size) { while (buffSize < size) { ioMsg.hdr.pri = 0; ioMsg.hdr.retQueue = &queue; - ioMsg.devAddr = (u32)rom; + ioMsg.devAddr = rom; ioMsg.dramAddr = ram; ioMsg.size = buffSize; ret = osEPiStartDma(gCartHandle, &ioMsg, 0); @@ -39,9 +39,9 @@ s32 DmaMgr_DMARomToRam(u32 rom, void* ram, size_t size) { } ioMsg.hdr.pri = 0; ioMsg.hdr.retQueue = &queue; - ioMsg.devAddr = (u32)rom; + ioMsg.devAddr = rom; ioMsg.dramAddr = ram; - ioMsg.size = (u32)size; + ioMsg.size = size; ret = osEPiStartDma(gCartHandle, &ioMsg, 0); if (ret) { goto END; @@ -109,11 +109,11 @@ const char* func_800809F4(u32 a0) { } void DmaMgr_ProcessMsg(DmaRequest* req) { - u32 vrom; + uintptr_t vrom; void* ram; size_t size; - u32 romStart; - u32 romSize; + uintptr_t romStart; + size_t romSize; DmaEntry* dmaEntry; s32 index; @@ -172,7 +172,7 @@ void DmaMgr_ThreadEntry(void* a0) { } } -s32 DmaMgr_SendRequestImpl(DmaRequest* request, void* vramStart, u32 vromStart, size_t size, UNK_TYPE4 unused, +s32 DmaMgr_SendRequestImpl(DmaRequest* request, void* vramStart, uintptr_t vromStart, size_t size, UNK_TYPE4 unused, OSMesgQueue* queue, OSMesg msg) { if (gIrqMgrResetStatus >= 2) { return -2; @@ -190,7 +190,7 @@ s32 DmaMgr_SendRequestImpl(DmaRequest* request, void* vramStart, u32 vromStart, return 0; } -s32 DmaMgr_SendRequest0(void* vramStart, u32 vromStart, size_t size) { +s32 DmaMgr_SendRequest0(void* vramStart, uintptr_t vromStart, size_t size) { DmaRequest req; OSMesgQueue queue; OSMesg msg[1]; diff --git a/src/code/audio_effects.c b/src/code/audio/audio_effects.c similarity index 100% rename from src/code/audio_effects.c rename to src/code/audio/audio_effects.c diff --git a/src/code/audio_heap.c b/src/code/audio/audio_heap.c similarity index 100% rename from src/code/audio_heap.c rename to src/code/audio/audio_heap.c diff --git a/src/code/audio_load.c b/src/code/audio/audio_load.c similarity index 100% rename from src/code/audio_load.c rename to src/code/audio/audio_load.c diff --git a/src/code/audio_playback.c b/src/code/audio/audio_playback.c similarity index 100% rename from src/code/audio_playback.c rename to src/code/audio/audio_playback.c diff --git a/src/code/audio_seqplayer.c b/src/code/audio/audio_seqplayer.c similarity index 100% rename from src/code/audio_seqplayer.c rename to src/code/audio/audio_seqplayer.c diff --git a/src/code/audio/audio_sfx_params.c b/src/code/audio/audio_sfx_params.c new file mode 100644 index 0000000000..dd23da443e --- /dev/null +++ b/src/code/audio/audio_sfx_params.c @@ -0,0 +1,497 @@ +#include "global.h" + +/** + * TODO: + * the number of #efined sfx's we have for each bank does not seem to line up with the + * number of SfxParam entries for each bank. So at some point either through hacking or + * decompilation/documentation of sequence 0, the sfxs should be verified, especially + * the ones that come at the end of the list (all the earlier sfxs in each bank seem fine). + * + * After that, defines should be paired with sfxparams to make it easier to look up + * specific sfxsparams for a a certain sfx i.e.: + * { 0x18, 0, 0x1 }, // NA_SE_EN_DODO_J_WALK + * { 0x30, 0, 0x1 }, // NA_SE_EN_DODO_J_CRY + * { 0x30, 0, 0x1 }, // NA_SE_EN_DODO_J_FIRE + */ + +SfxParams sEnemyBankParams[] = { + { 0x18, 0, 0x1 }, { 0x30, 0, 0x1 }, { 0x30, 0, 0x1 }, { 0x38, 0, 0x1 }, { 0x40, 0, 0x1 }, + { 0x30, 0, 0x3 }, { 0x36, 0, 0 }, { 0x38, 0, 0 }, { 0x40, 0, 0x3 }, { 0x58, 0, 0x3 }, + { 0x40, 0, 0x3 }, { 0x68, 0, 0x1003 }, { 0x40, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x40, 0, 0x3 }, + { 0x40, 0, 0x3 }, { 0x54, 0, 0xB }, { 0x54, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x40, 0, 0x3 }, + { 0x40, 0, 0x3 }, { 0x54, 0, 0x3 }, { 0x54, 0, 0x3 }, { 0x54, 0, 0x3 }, { 0x30, 0, 0x2003 }, + { 0x50, 0, 0x3 }, { 0x58, 0, 0x3 }, { 0x38, 0, 0x3 }, { 0x50, 0, 0x3 }, { 0x30, 0, 0x3 }, + { 0x38, 0, 0 }, { 0x48, 0, 0 }, { 0x30, 0, 0 }, { 0x40, 0, 0x1 }, { 0x18, 0, 0 }, + { 0x14, 0, 0 }, { 0x14, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x28, 0, 0x4000 }, + { 0x28, 0, 0 }, { 0x30, 0, 0x2 }, { 0x32, 0, 0x2 }, { 0x38, 0, 0x1 }, { 0x20, 0, 0 }, + { 0x40, 0, 0x1 }, { 0x18, 0, 0 }, { 0x28, 0, 0 }, { 0x18, 0, 0x40 }, { 0x30, 0, 0 }, + { 0x38, 0, 0x1 }, { 0x40, 0, 0x1 }, { 0x14, 0, 0 }, { 0x18, 0, 0x80 }, { 0x38, 0, 0x2 }, + { 0x34, 0, 0 }, { 0x28, 0, 0x1 }, { 0x30, 0, 0 }, { 0x38, 0, 0x1 }, { 0x40, 0, 0x1 }, + { 0x30, 0, 0 }, { 0x18, 0, 0 }, { 0x20, 0, 0 }, { 0x30, 0, 0 }, { 0x32, 0, 0 }, + { 0x20, 0, 0x1 }, { 0x37, 0, 0x1 }, { 0x38, 0, 0x1 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x40, 0, 0x2 }, { 0x38, 0, 0x2 }, { 0x20, 0, 0 }, { 0x18, 0, 0 }, { 0x40, 0, 0x4007 }, + { 0x40, 0, 0x1 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, + { 0x30, 0, 0 }, { 0x40, 0, 0 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x34, 0, 0 }, + { 0x34, 0, 0 }, { 0x36, 0, 0 }, { 0x30, 0, 0x3 }, { 0x28, 0, 0 }, { 0x30, 0, 0 }, + { 0x18, 0, 0 }, { 0x30, 0, 0 }, { 0x28, 0, 0xC0 }, { 0x30, 0, 0x40 }, { 0x38, 0, 0x41 }, + { 0x40, 0, 0x41 }, { 0x30, 0, 0 }, { 0x36, 0, 0 }, { 0x40, 0, 0x1 }, { 0x14, 0, 0 }, + { 0x30, 0, 0 }, { 0x20, 0, 0 }, { 0x40, 0, 0x1 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x4 }, + { 0x30, 0, 0x4 }, { 0x20, 0, 0x4 }, { 0x38, 0, 0x4 }, { 0x20, 0, 0x3 }, { 0x38, 0, 0x1 }, + { 0x40, 0, 0x1 }, { 0x14, 0, 0 }, { 0x30, 0, 0x3 }, { 0x20, 0, 0x1 }, { 0x20, 0, 0x1 }, + { 0x30, 0, 0x2 }, { 0x35, 0, 0x2 }, { 0x38, 0, 0x2 }, { 0x48, 0, 0x2 }, { 0x40, 0, 0x2 }, + { 0x45, 0, 0x81 }, { 0x34, 0, 0 }, { 0x40, 0, 0 }, { 0x20, 0, 0x2 }, { 0x28, 0, 0 }, + { 0x28, 0, 0 }, { 0x30, 0, 0 }, { 0x20, 0, 0x84 }, { 0x38, 0, 0x1 }, { 0x40, 0, 0x1 }, + { 0x20, 0, 0 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x4 }, { 0x40, 0, 0x4 }, { 0x40, 0, 0x3 }, + { 0x40, 0, 0x1 }, { 0x28, 0, 0x1 }, { 0x30, 0, 0x3 }, { 0x20, 0, 0 }, { 0x38, 0, 0x1 }, + { 0x30, 0, 0x4 }, { 0x30, 0, 0 }, { 0x20, 0, 0 }, { 0x20, 0, 0 }, { 0x38, 0, 0x2000 }, + { 0x30, 0, 0x3 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0 }, { 0x14, 0, 0 }, { 0x38, 0, 0x1 }, + { 0x40, 0, 0x1 }, { 0x14, 0, 0 }, { 0x20, 0, 0 }, { 0x20, 0, 0 }, { 0x30, 0, 0 }, + { 0x40, 0, 0x1 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0 }, { 0x37, 0, 0x1 }, { 0x40, 0, 0x1 }, + { 0x28, 0, 0x5 }, { 0x36, 0, 0x5 }, { 0x38, 0, 0x5 }, { 0x48, 0, 0x5 }, { 0x30, 0, 0x3 }, + { 0x28, 0, 0x2 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x34, 0, 0x3 }, { 0x38, 0, 0x3 }, + { 0x40, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0x3 }, { 0x38, 0, 0x3 }, + { 0x40, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x403 }, { 0x38, 0, 0x1 }, + { 0x30, 0, 0x43 }, { 0x30, 0, 0x3 }, { 0x20, 0, 0 }, { 0x34, 0, 0 }, { 0x18, 0, 0x80 }, + { 0x30, 0, 0 }, { 0x38, 0, 0 }, { 0x30, 0, 0 }, { 0x14, 0, 0 }, { 0x34, 0, 0 }, + { 0x40, 0, 0 }, { 0x30, 0, 0x3 }, { 0x20, 0, 0 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x28, 0, 0 }, { 0x30, 0, 0x80 }, { 0x40, 0, 0x1 }, { 0x40, 0, 0x1 }, + { 0x20, 0, 0 }, { 0x20, 0, 0 }, { 0x14, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x40, 0, 0x1 }, { 0x30, 0, 0 }, { 0x30, 0, 0x3 }, { 0x38, 0, 0x3 }, + { 0x40, 0, 0x3 }, { 0x48, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x34, 0, 0x3 }, { 0x48, 0, 0x3 }, + { 0x30, 0, 0x3 }, { 0x34, 0, 0x3 }, { 0x30, 0, 0x4083 }, { 0x30, 0, 0x4083 }, { 0x40, 0, 0x3 }, + { 0x38, 0, 0x1 }, { 0x30, 0, 0x1 }, { 0x28, 0, 0x3 }, { 0x28, 0, 0x3 }, { 0x30, 0, 0x3 }, + { 0x30, 0, 0x3 }, { 0x30, 0, 0x2003 }, { 0x38, 0, 0x1 }, { 0x20, 0, 0 }, { 0x34, 0, 0 }, + { 0x38, 0, 0x1 }, { 0x40, 0, 0x1 }, { 0x34, 0, 0x2000 }, { 0x20, 0, 0 }, { 0x38, 0, 0x42 }, + { 0x40, 0, 0x1 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x2 }, { 0x30, 0, 0x2 }, { 0x38, 0, 0x3 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x34, 0, 0 }, { 0x34, 0, 0x3 }, { 0x30, 0, 0x3 }, + { 0x24, 0, 0x40 }, { 0x30, 0, 0x3 }, { 0x28, 0, 0x82 }, { 0x40, 0, 0x3 }, { 0x40, 0, 0x3 }, + { 0x30, 0, 0x3 }, { 0x34, 0, 0x3 }, { 0x20, 0, 0x83 }, { 0x20, 0, 0 }, { 0x30, 0, 0x3 }, + { 0x20, 0, 0x80 }, { 0x30, 0, 0x83 }, { 0x18, 0, 0x83 }, { 0x34, 0, 0x83 }, { 0x30, 0, 0x83 }, + { 0x38, 0, 0x3 }, { 0x18, 0, 0x3 }, { 0x30, 0, 0x2000 }, { 0x38, 0, 0x3 }, { 0x30, 0, 0x3 }, + { 0x40, 0, 0x3 }, { 0x40, 0, 0x2004 }, { 0x38, 0, 0x5 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0x3 }, + { 0x30, 0, 0x80 }, { 0x30, 0, 0x5 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x82 }, { 0x30, 0, 0x3 }, + { 0x30, 0, 0x5 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x84 }, { 0x38, 0, 0x80 }, { 0x38, 0, 0x6083 }, + { 0x38, 0, 0x6083 }, { 0x38, 0, 0x6083 }, { 0x38, 0, 0x6083 }, { 0x40, 0, 0x4082 }, { 0x18, 0, 0x83 }, + { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x20, 0, 0x3 }, { 0x24, 0, 0x5 }, { 0x28, 0, 0x3 }, + { 0x30, 0, 0x3 }, { 0x30, 0, 0x5 }, { 0x30, 0, 0x5 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0x3 }, { 0x18, 0, 0x1 }, { 0x34, 0, 0x3 }, { 0x30, 0, 0x5 }, { 0x34, 0, 0x3 }, + { 0x34, 0, 0x3 }, { 0x34, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x1 }, + { 0x14, 0, 0 }, { 0x40, 0, 0x1 }, { 0x30, 0, 0x1 }, { 0x30, 0, 0x1 }, { 0x20, 0, 0x1 }, + { 0x38, 0, 0x3 }, { 0x30, 0, 0 }, { 0x40, 0, 0x4003 }, { 0x30, 0, 0x4003 }, { 0x38, 0, 0x3 }, + { 0x38, 0, 0x3 }, { 0x40, 0, 0x3 }, { 0x40, 0, 0x83 }, { 0x40, 0, 0x83 }, { 0x40, 0, 0x3 }, + { 0x21, 0, 0x4003 }, { 0x54, 0, 0x3 }, { 0x54, 0, 0x3 }, { 0x54, 0, 0x3 }, { 0x34, 0, 0x2 }, + { 0x58, 0, 0x3 }, { 0x68, 0, 0x3 }, { 0x50, 0, 0x40C3 }, { 0x14, 0, 0 }, { 0x20, 0, 0x1 }, + { 0x48, 0, 0x4080 }, { 0x30, 0, 0x4080 }, { 0x50, 0, 0x1 }, { 0x50, 0, 0x1 }, { 0x50, 0, 0 }, + { 0x50, 0, 0 }, { 0x68, 0, 0x3 }, { 0x58, 0, 0x3 }, { 0x90, 0, 0x3 }, { 0x48, 0, 0x3 }, + { 0x28, 0, 0x2 }, { 0x30, 0, 0 }, { 0x38, 0, 0x1 }, { 0x28, 0, 0x2 }, { 0x50, 0, 0x3 }, + { 0x50, 0, 0x3 }, { 0x50, 0, 0x3 }, { 0x40, 0, 0x4083 }, { 0x40, 0, 0x3 }, { 0x40, 0, 0x3 }, + { 0x40, 0, 0x3 }, { 0x40, 0, 0x3 }, { 0x54, 0, 0x3 }, { 0x40, 0, 0x3 }, { 0x40, 0, 0x3 }, + { 0x48, 0, 0x3 }, { 0x48, 0, 0x3 }, { 0x48, 0, 0x3 }, { 0x40, 0, 0x3 }, { 0x34, 0, 0x2 }, + { 0x34, 0, 0x2002 }, { 0x28, 0, 0x2 }, { 0x28, 0, 0x2 }, { 0x30, 0, 0x2 }, { 0x30, 0, 0x2 }, + { 0x38, 0, 0x2 }, { 0x38, 0, 0x2 }, { 0x48, 0, 0x2 }, { 0x10, 0, 0 }, { 0x34, 0, 0 }, + { 0x18, 0, 0 }, { 0x30, 0, 0 }, { 0x14, 0, 0 }, { 0x34, 0, 0 }, { 0x28, 0, 0x1 }, + { 0x38, 0, 0x1 }, { 0x40, 0, 0x1 }, { 0x30, 0, 0x1 }, { 0x38, 0, 0x1 }, { 0x36, 0, 0x1 }, + { 0x34, 0, 0x1 }, { 0x38, 0, 0x1 }, { 0x48, 0, 0x1 }, { 0x30, 0, 0x1 }, { 0x38, 0, 0x83 }, + { 0x30, 0, 0x3 }, { 0x20, 0, 0x2000 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0 }, { 0x40, 0, 0x1 }, + { 0x30, 0, 0 }, { 0x20, 0, 0 }, { 0x38, 0, 0x1 }, { 0x40, 0, 0x1 }, { 0x30, 0, 0 }, + { 0x30, 0, 0x2000 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x2 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, + { 0x18, 0, 0 }, { 0x28, 0, 0 }, { 0x34, 0, 0x2 }, { 0x34, 0, 0x2 }, { 0x34, 0, 0 }, + { 0x38, 0, 0x1 }, { 0x40, 0, 0x1 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x2 }, { 0x38, 0, 0 }, + { 0x48, 0, 0 }, { 0x28, 0, 0x4004 }, { 0x48, 0, 0x4 }, { 0x20, 0, 0x4 }, { 0x25, 0, 0x3 }, + { 0x40, 0, 0x2 }, { 0x18, 0, 0x80 }, { 0x44, 0, 0x3 }, { 0x44, 0, 0 }, { 0x18, 0, 0 }, + { 0x30, 0, 0 }, { 0x38, 0, 0x1 }, { 0x40, 0, 0x1 }, { 0x18, 0, 0x3 }, { 0x30, 0, 0x3 }, + { 0x38, 0, 0x43 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x36, 0, 0x3 }, + { 0x34, 0, 0x3 }, { 0x34, 0, 0x82 }, { 0x58, 0, 0x3 }, { 0x68, 0, 0x3 }, { 0x30, 0, 0x3 }, + { 0x30, 0, 0x3 }, { 0x34, 0, 0x2 }, { 0x34, 0, 0x3 }, { 0x40, 0, 0 }, { 0x30, 0, 0x3 }, + { 0x40, 0, 0x2000 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0xC0 }, { 0x30, 0, 0xC0 }, { 0x40, 0, 0 }, + { 0x30, 0, 0x3 }, { 0x28, 0, 0x3 }, { 0x40, 0, 0x3 }, { 0x40, 0, 0x3 }, { 0x30, 0, 0x3 }, + { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x38, 0, 0x3 }, { 0x48, 0, 0x3 }, + { 0x20, 0, 0x3 }, { 0x48, 0, 0x3 }, { 0x36, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, + { 0x38, 0, 0x3 }, { 0x38, 0, 0x3 }, { 0x20, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x44, 0, 0x3 }, + { 0x30, 0, 0x83 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x34, 0, 0x3 }, { 0x30, 0, 0x3 }, + { 0x30, 0, 0x3 }, { 0x20, 0, 0x2 }, { 0x34, 0, 0x3 }, { 0x20, 0, 0x83 }, { 0x30, 0, 0x4 }, + { 0x30, 0, 0x4042 }, { 0x40, 0, 0x4042 }, { 0x40, 0, 0x83 }, { 0x30, 0, 0x4042 }, { 0x30, 0, 0x4042 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x1 }, { 0x32, 0, 0x4082 }, { 0x32, 0, 0x3 }, + { 0x54, 0, 0x1 }, { 0x52, 0, 0 }, { 0x54, 0, 0x3 }, { 0x30, 0, 0 }, { 0x08, 0, 0x1 }, + { 0x30, 0, 0x1 }, { 0x30, 0, 0x3 }, { 0x54, 0, 0x3 }, { 0x54, 0, 0x2000 }, { 0x34, 0, 0x3 }, + { 0x54, 0, 0x2000 }, { 0x08, 0, 0 }, { 0x54, 0, 0 }, { 0x34, 0, 0 }, { 0x15, 0, 0 }, + { 0x35, 0, 0 }, { 0x48, 0, 0 }, { 0x38, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0xC2 }, + { 0x38, 0, 0x2 }, { 0x38, 0, 0x2 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0x1, 0x80 }, { 0x30, 0xB4, 0x6 }, { 0x30, 0, 0 }, + { 0x30, 0, 0x6 }, { 0x30, 0, 0x83 }, { 0x30, 0, 0 }, { 0x30, 0, 0x2 }, { 0x30, 0, 0x2 }, + { 0x30, 0, 0x2 }, { 0x48, 0, 0x2 }, { 0x28, 0, 0x1 }, { 0x36, 0, 0 }, { 0x38, 0, 0 }, + { 0x48, 0, 0 }, { 0x68, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x38, 0, 0x3 }, + { 0x48, 0, 0x3 }, { 0x58, 0, 0x3 }, { 0x68, 0, 0x3 }, { 0x29, 0, 0x3 }, { 0x54, 0, 0x3 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0x40 }, + { 0x30, 0, 0 }, { 0x68, 0, 0x3 }, { 0x30, 0, 0 }, { 0x45, 0, 0x2 }, { 0x40, 0, 0x4043 }, + { 0x40, 0, 0x4043 }, { 0x30, 0, 0x4043 }, { 0x30, 0, 0x4043 }, { 0x30, 0, 0x4043 }, { 0x30, 0, 0x4043 }, + { 0x30, 0, 0x4083 }, { 0x30, 0, 0x4083 }, { 0x30, 0, 0x4083 }, { 0x50, 0, 0x3 }, { 0x30, 0, 0x3 }, + { 0x30, 0, 0x3 }, { 0x10, 0, 0 }, { 0x54, 0, 0x3 }, { 0x50, 0, 0x3 }, { 0x50, 0, 0x3 }, + { 0x54, 0, 0x43 }, { 0x50, 0, 0x43 }, { 0x50, 0, 0x43 }, { 0x50, 0, 0x43 }, { 0x36, 0, 0x43 }, + { 0x34, 0, 0x43 }, { 0x34, 0, 0x83 }, { 0x36, 0, 0x43 }, { 0x35, 0, 0x43 }, { 0x34, 0, 0x83 }, + { 0x58, 0, 0x43 }, { 0x68, 0, 0x43 }, { 0x38, 0, 0x43 }, { 0x48, 0, 0x43 }, { 0x38, 0, 0x43 }, + { 0x48, 0, 0x43 }, { 0x34, 0, 0x83 }, { 0x34, 0, 0x4043 }, { 0x34, 0, 0x4043 }, { 0x34, 0, 0x83 }, + { 0x34, 0, 0x4043 }, { 0x50, 0, 0x43 }, { 0x34, 0, 0x43 }, { 0x50, 0, 0x43 }, { 0x36, 0, 0x43 }, + { 0x36, 0, 0x43 }, { 0x34, 0, 0x43 }, { 0x37, 0, 0x3 }, { 0x54, 0, 0x43 }, { 0x40, 0, 0x3 }, + { 0x40, 0, 0x3 }, { 0x57, 0, 0x3 }, { 0x34, 0, 0x2 }, { 0x40, 0, 0 }, { 0x32, 0, 0 }, + { 0x50, 0, 0x83 }, { 0x50, 0, 0x83 }, { 0x50, 0, 0x83 }, { 0x50, 0, 0x83 }, { 0x50, 0, 0x83 }, + { 0x58, 0, 0x83 }, { 0x58, 0, 0x83 }, { 0x68, 0, 0x3 }, { 0x68, 0, 0x3 }, { 0x48, 0, 0x3 }, + { 0x48, 0, 0x3 }, { 0x50, 0, 0x3 }, { 0x50, 0, 0x3 }, { 0x28, 0, 0x4 }, { 0x34, 0, 0x2 }, + { 0x30, 0, 0x4080 }, { 0x30, 0, 0x4080 }, { 0x30, 0, 0x4080 }, { 0x30, 0, 0x4080 }, { 0x30, 0, 0x1 }, + { 0x30, 0, 0x84 }, { 0x50, 0, 0x3 }, { 0x50, 0, 0x3 }, { 0x50, 0, 0x3 }, { 0x50, 0, 0x3 }, + { 0x58, 0, 0x3 }, { 0x58, 0, 0x3 }, { 0x68, 0, 0x3 }, { 0x50, 0, 0x3 }, { 0x50, 0, 0x3 }, + { 0x30, 0, 0x1 }, { 0x30, 0, 0x1 }, { 0x30, 0, 0x1 }, { 0x30, 0, 0x1 }, { 0x34, 0, 0x80 }, + { 0x34, 0, 0 }, { 0x34, 0, 0 }, { 0x34, 0, 0 }, { 0x34, 0, 0 }, { 0x34, 0, 0 }, + { 0x34, 0, 0 }, { 0x34, 0, 0 }, { 0x34, 0, 0 }, { 0x34, 0, 0 }, { 0x54, 0, 0 }, + { 0x34, 0, 0 }, { 0x34, 0, 0x2000 }, { 0x34, 0, 0x2000 }, { 0x34, 0, 0 }, { 0x30, 0, 0x5 }, + { 0x30, 0, 0x1 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x34, 0, 0x4083 }, { 0x34, 0, 0x4083 }, + { 0x30, 0, 0x4083 }, { 0x30, 0, 0x4083 }, { 0x34, 0, 0 }, { 0x30, 0, 0 }, { 0x34, 0, 0x1083 }, + { 0x30, 0, 0x1005 }, { 0x30, 0, 0x4080 }, { 0x34, 0, 0 }, { 0x34, 0, 0 }, { 0x30, 0, 0x6 }, + { 0x30, 0, 0x6 }, { 0x30, 0, 0x5 }, { 0x30, 0, 0x6 }, { 0x34, 0, 0 }, { 0x38, 0, 0 }, + { 0x48, 0, 0 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0x85 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0x80 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x40, 0, 0x2 }, { 0x32, 0, 0x80 }, + { 0x50, 0, 0x2 }, { 0x50, 0, 0x2 }, { 0x58, 0, 0x2 }, { 0x68, 0, 0x2 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x50, 0, 0x2 }, { 0x50, 0, 0x2 }, { 0x30, 0, 0x3 }, { 0x54, 0, 0x5 }, + { 0x28, 0, 0x5 }, { 0x78, 0, 0x2000 }, { 0x78, 0, 0x2000 }, { 0x50, 0, 0x3 }, { 0x58, 0, 0x3 }, + { 0x68, 0, 0x3 }, { 0x54, 0, 0x3 }, { 0x40, 0, 0x3 }, { 0x78, 0, 0x3 }, { 0x48, 0, 0 }, + { 0x30, 0, 0x83 }, { 0x30, 0, 0x83 }, { 0x30, 0, 0x83 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0xC3 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0x2000 }, + { 0x30, 0, 0x2000 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0x45 }, { 0x60, 0, 0x2 }, + { 0x70, 0, 0x2000 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0x80 }, + { 0x30, 0, 0x80 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0x80 }, + { 0x30, 0, 0x80 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x7 }, { 0x30, 0, 0x44 }, + { 0x30, 0, 0x44 }, { 0x30, 0, 0x83 }, { 0x48, 0, 0x3 }, { 0x58, 0, 0x3 }, { 0x30, 0, 0 }, + { 0x30, 0, 0x3 }, { 0x36, 0, 0 }, { 0x40, 0, 0x2 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, +}; + +SfxParams sPlayerBankParams[] = { + { 0x20, 0, 0x480 }, { 0x20, 0, 0x480 }, { 0x20, 0, 0x480 }, { 0x20, 0, 0x480 }, { 0x20, 0, 0x440 }, + { 0x20, 0, 0x440 }, { 0x20, 0, 0x440 }, { 0x20, 0, 0x440 }, { 0x20, 0, 0x480 }, { 0x20, 0, 0x440 }, + { 0x20, 0, 0x480 }, { 0x20, 0, 0x400 }, { 0x20, 0, 0x400 }, { 0x20, 0, 0x400 }, { 0x20, 0, 0x400 }, + { 0x20, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, + { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, + { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, + { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, + { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, + { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, + { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, + { 0x30, 0, 0x40 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, + { 0x40, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x40 }, + { 0x30, 0, 0x40 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0x40 }, + { 0x30, 0, 0x40 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0x40 }, + { 0x30, 0, 0x40 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x80, 0, 0 }, { 0x80, 0, 0 }, { 0x80, 0, 0 }, { 0x80, 0, 0 }, { 0x80, 0, 0 }, + { 0x80, 0, 0 }, { 0x80, 0, 0 }, { 0x80, 0, 0 }, { 0x80, 0, 0 }, { 0x80, 0, 0 }, + { 0x80, 0, 0 }, { 0x80, 0, 0 }, { 0x80, 0, 0 }, { 0x80, 0, 0 }, { 0x80, 0, 0 }, + { 0x80, 0, 0 }, { 0x30, 0, 0x440 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x1 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0xC00 }, + { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x20, 0, 0x80 }, { 0x20, 0, 0x80 }, + { 0x20, 0, 0x80 }, { 0x20, 0, 0x80 }, { 0x20, 0, 0x40 }, { 0x20, 0, 0x40 }, { 0x20, 0, 0x40 }, + { 0x20, 0, 0x40 }, { 0x20, 0, 0x80 }, { 0x20, 0, 0x80 }, { 0x20, 0, 0x80 }, { 0x20, 0, 0 }, + { 0x20, 0, 0 }, { 0x20, 0, 0 }, { 0x20, 0, 0 }, { 0x20, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x40, 0, 0 }, { 0x40, 0, 0 }, { 0x40, 0, 0 }, { 0x40, 0, 0 }, { 0x40, 0, 0 }, + { 0x40, 0, 0 }, { 0x40, 0, 0 }, { 0x40, 0, 0 }, { 0x40, 0, 0 }, { 0x40, 0, 0 }, + { 0x40, 0, 0 }, { 0x40, 0, 0 }, { 0x40, 0, 0 }, { 0x40, 0, 0 }, { 0x40, 0, 0 }, + { 0x40, 0, 0 }, { 0x30, 0, 0x440 }, { 0x30, 0, 0x440 }, { 0x30, 0, 0x440 }, { 0x30, 0, 0x440 }, + { 0x30, 0, 0x440 }, { 0x30, 0, 0x440 }, { 0x30, 0, 0x440 }, { 0x30, 0, 0x440 }, { 0x30, 0, 0x440 }, + { 0x30, 0, 0x440 }, { 0x30, 0, 0x440 }, { 0x30, 0, 0x440 }, { 0x30, 0, 0x440 }, { 0x30, 0, 0x440 }, + { 0x30, 0, 0x440 }, { 0x30, 0, 0x440 }, { 0x30, 0, 0xC00 }, { 0x30, 0, 0x4080 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x60, 0, 0x2 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x800 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0x403 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x400 }, + { 0x60, 0, 0x40 }, { 0x40, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x50, 0, 0x43 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x20, 0, 0x480 }, { 0x20, 0, 0x480 }, { 0x20, 0, 0x480 }, { 0x20, 0, 0x480 }, { 0x20, 0, 0x440 }, + { 0x20, 0, 0x440 }, { 0x20, 0, 0x440 }, { 0x20, 0, 0x440 }, { 0x20, 0, 0x480 }, { 0x20, 0, 0x440 }, + { 0x20, 0, 0x480 }, { 0x20, 0, 0x400 }, { 0x20, 0, 0x400 }, { 0x20, 0, 0x400 }, { 0x20, 0, 0x400 }, + { 0x20, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, + { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, + { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, + { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, + { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, + { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, + { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x20, 0, 0x480 }, { 0x20, 0, 0x480 }, + { 0x20, 0, 0x480 }, { 0x20, 0, 0x480 }, { 0x20, 0, 0x440 }, { 0x20, 0, 0x440 }, { 0x20, 0, 0x440 }, + { 0x20, 0, 0x440 }, { 0x20, 0, 0x480 }, { 0x20, 0, 0x440 }, { 0x20, 0, 0x480 }, { 0x20, 0, 0x400 }, + { 0x20, 0, 0x400 }, { 0x20, 0, 0x400 }, { 0x20, 0, 0x400 }, { 0x20, 0, 0x400 }, { 0x30, 0, 0x400 }, + { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, + { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, + { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, + { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, + { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, + { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, + { 0x40, 0, 0x440 }, { 0x20, 0, 0x480 }, { 0x20, 0, 0x480 }, { 0x20, 0, 0x480 }, { 0x20, 0, 0x480 }, + { 0x20, 0, 0x440 }, { 0x20, 0, 0x440 }, { 0x20, 0, 0x440 }, { 0x20, 0, 0x440 }, { 0x20, 0, 0x480 }, + { 0x20, 0, 0x440 }, { 0x20, 0, 0x480 }, { 0x20, 0, 0x400 }, { 0x20, 0, 0x400 }, { 0x20, 0, 0x400 }, + { 0x20, 0, 0x400 }, { 0x20, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, + { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, + { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, + { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, + { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, + { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, + { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x40, 0, 0x440 }, { 0x30, 0, 0x400 }, + { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, + { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, + { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, + { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x50, 0, 0x400 }, { 0x50, 0, 0x400 }, { 0x30, 0, 0x400 }, + { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, + { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, + { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x60, 0, 0x400 }, + { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, + { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, + { 0x30, 0, 0x4080 }, { 0x40, 0, 0x403 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, + { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, + { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x2400 }, { 0x30, 0, 0x2400 }, + { 0x30, 0, 0x2400 }, { 0x30, 0, 0x2400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x43 }, + { 0x30, 0, 0x43 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, + { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, + { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x400 }, +}; + +SfxParams sItemBankParams[] = { + { 0x30, 0, 0x8040 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x40, 0, 0x440 }, + { 0x30, 0, 0x440 }, { 0x60, 0, 0x83 }, { 0x30, 0, 0x440 }, { 0x80, 0, 0x43 }, { 0x30, 0, 0 }, + { 0x30, 0, 0x40 }, { 0x38, 0, 0x400 }, { 0x30, 0, 0x401 }, { 0x50, 0, 0x100 }, { 0x90, 0, 0x2 }, + { 0x50, 0, 0x2 }, { 0x30, 0, 0x400 }, { 0x40, 0, 0x2 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x34, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x60, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0x80 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0x400 }, { 0x20, 0, 0x400 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x400 }, + { 0x30, 0, 0x400 }, { 0x60, 0, 0x43 }, { 0x30, 0, 0x1 }, { 0x30, 0, 0x401 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0xA0, 0, 0x2 }, { 0xA0, 0, 0x2 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0x100 }, + { 0x60, 0, 0 }, { 0x60, 0, 0 }, { 0x60, 0, 0 }, { 0x30, 0, 0x400 }, { 0x30, 0, 0 }, + { 0x60, 0, 0x81 }, { 0x30, 0, 0 }, { 0x30, 0, 0x400 }, { 0x60, 0, 0x8003 }, { 0x60, 0, 0x8003 }, + { 0x60, 0, 0x8003 }, { 0x30, 0, 0x4000 }, { 0x30, 0, 0x4000 }, { 0x30, 0, 0x40 }, { 0x80, 0, 0x3 }, + { 0x80, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x80, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x80, 0, 0 }, { 0x80, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x40, 0, 0 }, + { 0x30, 0, 0 }, { 0x60, 0, 0x100 }, { 0x70, 0, 0 }, { 0x60, 0, 0 }, { 0x30, 0, 0x483 }, + { 0x30, 0, 0x40 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x60, 0, 0x2000 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, +}; + +SfxParams sEnvBankParams[] = { + { 0x70, 0, 0x640 }, { 0x80, 0, 0x40 }, { 0x30, 0, 0 }, { 0x60, 0, 0x40 }, { 0x60, 0, 0x40 }, + { 0x70, 0, 0x40 }, { 0x30, 0, 0x480 }, { 0x70, 0, 0x2 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0x40 }, + { 0x80, 0, 0x2 }, { 0xA0, 0, 0x3 }, { 0x30, 0, 0x103 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, + { 0x30, 0, 0x3 }, { 0x30, 0, 0x2 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0x40 }, { 0x50, 0, 0 }, + { 0x60, 0, 0x2 }, { 0x30, 0, 0x3 }, { 0x60, 0, 0 }, { 0x30, 0, 0x82 }, { 0x30, 0, 0 }, + { 0x40, 0, 0 }, { 0x68, 0, 0 }, { 0x58, 0, 0x40 }, { 0x60, 0, 0 }, { 0x70, 0, 0x3 }, + { 0x30, 0, 0x43 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0xA0, 0, 0x2008 }, { 0x20, 0, 0x2 }, + { 0x30, 0, 0 }, { 0x30, 0, 0x800 }, { 0x30, 0, 0x8800 }, { 0x30, 0, 0x8000 }, { 0x30, 0, 0x2 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x60, 0, 0 }, { 0x60, 0, 0x400 }, + { 0x30, 0, 0 }, { 0x80, 0, 0 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0x40 }, { 0x10, 0, 0 }, + { 0xA0, 0, 0x3 }, { 0x30, 0, 0x100 }, { 0x30, 0, 0x10 }, { 0x30, 0, 0x3 }, { 0x60, 0x40, 0x3 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x2 }, { 0x30, 0, 0 }, { 0xA0, 0, 0x3 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x3 }, { 0x70, 0, 0 }, { 0x60, 0, 0x8000 }, + { 0x30, 0, 0x8000 }, { 0x60, 0, 0 }, { 0x60, 0, 0 }, { 0x60, 0, 0 }, { 0x60, 0, 0 }, + { 0x30, 0, 0x2003 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x2010 }, { 0x30, 0, 0x40 }, + { 0x60, 0, 0 }, { 0x60, 0, 0x3 }, { 0x30, 0, 0 }, { 0x58, 0, 0x1 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x40, 0, 0 }, { 0x30, 0, 0xC3 }, { 0x70, 0, 0x2 }, { 0x60, 0, 0x2 }, + { 0x30, 0, 0 }, { 0x60, 0, 0x41 }, { 0x30, 0, 0x2 }, { 0x30, 0, 0 }, { 0x90, 0, 0x3 }, + { 0x90, 0, 0x3 }, { 0x30, 0, 0 }, { 0x30, 0, 0x2 }, { 0x30, 0, 0x3800 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x3 }, + { 0x30, 0, 0x40 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x803 }, + { 0x30, 0, 0 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x80 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x2 }, { 0x60, 0, 0 }, + { 0x30, 0, 0x640 }, { 0x30, 0, 0x2 }, { 0x30, 0, 0x2 }, { 0x80, 0, 0x2 }, { 0x40, 0, 0 }, + { 0x1C, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x60, 0, 0x4 }, { 0x30, 0, 0x800 }, + { 0x30, 0, 0x40 }, { 0x30, 0, 0 }, { 0x60, 0, 0 }, { 0x60, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x60, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, + { 0x80, 0, 0 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0x80 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0x800 }, { 0x30, 0, 0x800 }, { 0x30, 0, 0x2 }, { 0x30, 0, 0x3 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x20, 0, 0x3 }, + { 0x30, 0, 0 }, { 0x30, 0, 0x8000 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x70, 0, 0x2 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x50, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x2003 }, { 0x20, 0, 0 }, + { 0x30, 0, 0xC0 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0x2 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x2 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x6 }, { 0xA0, 0, 0x3 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0xC0 }, { 0x30, 0, 0x2 }, { 0x30, 0, 0x2 }, + { 0x30, 0, 0 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0 }, { 0x30, 0, 0x4083 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x60, 0, 0x83 }, + { 0x80, 0, 0x2000 }, { 0x50, 0, 0 }, { 0x60, 0, 0 }, { 0x90, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x60, 0, 0x2000 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0xA0, 0, 0x800 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0x2 }, { 0x30, 0, 0 }, { 0x30, 0, 0x3 }, { 0x20, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x2 }, { 0x30, 0, 0 }, + { 0x30, 0, 0x2 }, { 0x30, 0, 0x5 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x40, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x5 }, { 0x30, 0, 0xC2 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0 }, { 0x30, 0, 0x2 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x68, 0, 0x2 }, + { 0x30, 0, 0x2 }, { 0x30, 0, 0x4040 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x2 }, + { 0x30, 0, 0x2 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0xC0 }, { 0x80, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x2 }, { 0xA0, 0, 0xA003 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0 }, + { 0x30, 0, 0x85 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x60, 0, 0x2000 }, { 0x30, 0, 0 }, { 0x30, 0, 0x40 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0x2000 }, { 0x30, 0, 0x2 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0 }, { 0x30, 0, 0x40 }, + { 0x30, 0, 0x40 }, { 0x30, 0, 0x80 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0xC0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x80, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x43 }, + { 0x30, 0, 0x2000 }, { 0x30, 0, 0 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, + { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0x3 }, { 0xA0, 0, 0x4000 }, { 0x30, 0, 0x43 }, { 0x30, 0, 0x40 }, { 0x60, 0, 0x2 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x2080 }, { 0x30, 0, 0x2080 }, { 0x30, 0, 0x2000 }, + { 0x30, 0, 0 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x60, 0, 0 }, + { 0x30, 0, 0x2 }, { 0x30, 0, 0 }, { 0x30, 0, 0x2 }, { 0x30, 0, 0x80 }, { 0x60, 0, 0x42 }, + { 0x30, 0, 0x2000 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0x2000 }, + { 0x30, 0, 0 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0 }, { 0x30, 0, 0x2000 }, { 0x80, 0, 0 }, + { 0x80, 0, 0x3 }, { 0x80, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x80, 0, 0x2 }, { 0x80, 0, 0x2 }, + { 0x30, 0, 0 }, { 0x60, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x42 }, { 0x30, 0, 0x42 }, + { 0x30, 0, 0x43 }, { 0x60, 0x80, 0x2000 }, { 0x60, 0x80, 0x2000 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0x3 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x3 }, + { 0x30, 0, 0x2000 }, { 0x80, 0, 0x2000 }, { 0x80, 0, 0x3 }, { 0x30, 0, 0 }, { 0x30, 0, 0x2000 }, + { 0x30, 0, 0x2000 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x80, 0, 0x3 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0x43 }, + { 0x30, 0, 0x3 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0 }, { 0x30, 0, 0x2000 }, { 0x10, 0, 0x7 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0x2000 }, + { 0x58, 0, 0x60 }, { 0x60, 0, 0x3 }, { 0x60, 0, 0x3 }, { 0x60, 0, 0x3 }, { 0x70, 0, 0x3 }, + { 0x70, 0, 0x3 }, { 0x30, 0, 0 }, { 0x70, 0, 0x3 }, { 0x30, 0, 0x4 }, { 0x30, 0, 0x3 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x60, 0, 0 }, { 0x60, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0x80, 0 }, { 0x30, 0x80, 0x40 }, { 0x30, 0x80, 0x40 }, { 0x60, 0, 0x2000 }, { 0x70, 0, 0x2000 }, + { 0x30, 0, 0x80 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0x3 }, { 0x30, 0, 0 }, { 0x60, 0, 0x3 }, + { 0x70, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x40, 0, 0 }, { 0x58, 0, 0x40 }, { 0x58, 0, 0x40 }, + { 0x30, 0, 0x40 }, { 0x30, 0, 0x41 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, +}; + +SfxParams sSystemBankParams[] = { + { 0xC0, 0, 0 }, { 0xC0, 0, 0 }, { 0xB0, 0, 0x20 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x50, 0, 0 }, { 0x30, 0, 0x20 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x20, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x28, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x18, 0, 0 }, { 0x2C, 0, 0 }, { 0x2C, 0, 0 }, { 0x20, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x20, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x60, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x60, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0x20 }, { 0x60, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0xA0, 0, 0x8 }, { 0xA0, 0, 0x8 }, { 0x30, 0, 0 }, +}; + +SfxParams sOcarinaBankParams[] = { + { 0x30, 0, 0 }, { 0x30, 0, 0x20 }, { 0x30, 0, 0x642 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x2000 }, { 0x30, 0, 0x2000 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, +}; + +SfxParams sVoiceBankParams[] = { + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x20, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x442 }, + { 0x30, 0, 0x442 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x50, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x482 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x80, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x20, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x50, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x481 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0 }, { 0x60, 0, 0x20 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0 }, + { 0x30, 0, 0 }, { 0x30, 0, 0 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, + { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, + { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8000 }, { 0x30, 0, 0x8000 }, + { 0x30, 0, 0x8000 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, + { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, + { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, + { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, + { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8001 }, { 0x30, 0, 0x8043 }, { 0x30, 0, 0x8043 }, { 0x30, 0, 0x8043 }, + { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, + { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x8041 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x20, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x50, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x481 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x20, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x442 }, + { 0x30, 0, 0x442 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x50, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x482 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x80, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x20, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x50, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x482 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x80, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x442 }, + { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, { 0x20, 0, 0x442 }, { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, + { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, + { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, { 0x50, 0, 0x442 }, { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, + { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, + { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, { 0x30, 0, 0x482 }, { 0x30, 0, 0x442 }, + { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, { 0x30, 0, 0x442 }, { 0x80, 0, 0x442 }, { 0x30, 0, 0x442 }, + { 0x30, 0x80, 0x442 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, + { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, { 0x30, 0, 0x402 }, +}; + +SfxParams* gSfxParams[7] = { + sPlayerBankParams, sItemBankParams, sEnvBankParams, sEnemyBankParams, + sSystemBankParams, sOcarinaBankParams, sVoiceBankParams, +}; diff --git a/src/code/audio_synthesis.c b/src/code/audio/audio_synthesis.c similarity index 100% rename from src/code/audio_synthesis.c rename to src/code/audio/audio_synthesis.c diff --git a/src/code/code_80192BE0.c b/src/code/audio/code_80192BE0.c similarity index 100% rename from src/code/code_80192BE0.c rename to src/code/audio/code_80192BE0.c diff --git a/src/code/audio/code_80194710.c b/src/code/audio/code_80194710.c new file mode 100644 index 0000000000..090c5735b1 --- /dev/null +++ b/src/code/audio/code_80194710.c @@ -0,0 +1,5 @@ +#include "global.h" + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_80194710/func_80194710.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_80194710/func_80194750.s") diff --git a/src/code/audio/code_80194790.c b/src/code/audio/code_80194790.c new file mode 100644 index 0000000000..9ba2436deb --- /dev/null +++ b/src/code/audio/code_80194790.c @@ -0,0 +1,9 @@ +#include "global.h" + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_80194790/func_80194790.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_80194790/func_80194804.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_80194790/func_80194840.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_80194790/func_801948B0.s") diff --git a/src/code/code_8019AF00.c b/src/code/audio/code_8019AF00.c similarity index 95% rename from src/code/code_8019AF00.c rename to src/code/audio/code_8019AF00.c index 8f0d129ada..9354af1887 100644 --- a/src/code/code_8019AF00.c +++ b/src/code/audio/code_8019AF00.c @@ -296,7 +296,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2D54.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2DE0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_IsSequencePlaying.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2E54.s") @@ -411,19 +411,3 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4DF4.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4E64.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4EB0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4EB8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4FD8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A5080.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A50C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A5100.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A510C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A5118.s") diff --git a/src/code/audio/code_801A4EB0.c b/src/code/audio/code_801A4EB0.c new file mode 100644 index 0000000000..d3461c8f5e --- /dev/null +++ b/src/code/audio/code_801A4EB0.c @@ -0,0 +1,17 @@ +#include "global.h" + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A4EB0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A4EB8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A4FD8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A5080.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A50C0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A5100.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A510C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A5118.s") diff --git a/src/code/code_801A51F0.c b/src/code/audio/code_801A51F0.c similarity index 100% rename from src/code/code_801A51F0.c rename to src/code/audio/code_801A51F0.c diff --git a/src/code/code_801A5BD0.c b/src/code/audio/code_801A5BD0.c similarity index 100% rename from src/code/code_801A5BD0.c rename to src/code/audio/code_801A5BD0.c diff --git a/src/code/code_801A7B10.c b/src/code/audio/code_801A7B10.c similarity index 65% rename from src/code/code_801A7B10.c rename to src/code/audio/code_801A7B10.c index 7079968200..d2d9a71a21 100644 --- a/src/code/code_801A7B10.c +++ b/src/code/audio/code_801A7B10.c @@ -29,19 +29,3 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A99B8.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A9A74.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A9B10.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A9B78.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A9BFC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A9C68.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A9D10.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A9DCC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A9EA4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A9F4C.s") diff --git a/src/code/code_800CB000.c b/src/code/code_800CB000.c deleted file mode 100644 index 7642d35c42..0000000000 --- a/src/code/code_800CB000.c +++ /dev/null @@ -1,3 +0,0 @@ -#include "global.h" - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_800CB000/func_800CB000.s") diff --git a/src/code/code_8010C1B0.c b/src/code/code_8010C1B0.c index 12e0eadb47..2c1fd410f7 100644 --- a/src/code/code_8010C1B0.c +++ b/src/code/code_8010C1B0.c @@ -1,7 +1,7 @@ #include "global.h" // Blocks the current thread until all currently queued scheduler tasks have been completed -void func_8010C1B0(void) { +void MsgEvent_SendNullTask(void) { OSScTask task; OSMesgQueue queue; OSMesg msg; diff --git a/src/code/code_80194710.c b/src/code/code_80194710.c deleted file mode 100644 index aa4f784c4c..0000000000 --- a/src/code/code_80194710.c +++ /dev/null @@ -1,13 +0,0 @@ -#include "global.h" - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80194710/func_80194710.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80194710/func_80194750.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80194710/func_80194790.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80194710/func_80194804.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80194710/func_80194840.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80194710/func_801948B0.s") diff --git a/src/code/code_801AA020.c b/src/code/code_801AA020.c deleted file mode 100644 index 2144c6bcb5..0000000000 --- a/src/code/code_801AA020.c +++ /dev/null @@ -1,11 +0,0 @@ -#include "global.h" - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801AA020/D_801E1100.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801AA020/func_801AA020.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801AA020/func_801AA248.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801AA020/func_801AA3E4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801AA020/func_801AA520.s") diff --git a/src/code/jpegdecoder.c b/src/code/jpegdecoder.c new file mode 100644 index 0000000000..336e381f9e --- /dev/null +++ b/src/code/jpegdecoder.c @@ -0,0 +1,193 @@ +#include "z64jpeg.h" +#include "libc/stdbool.h" +#include "macros.h" + +u8* sJpegBitStreamPtr; +u32 sJpegBitStreamByteIdx; +u8 sJpegBitStreamBitIdx; +u8 sJpegBitStreamDontSkip; +u32 sJpegBitStreamCurWord; + +s32 JpegDecoder_Decode(JpegDecoder* decoder, u16* mcuBuff, s32 count, u8 isFollowing, JpegDecoderState* state) { + s16 pad; + s16 unk0; + s16 unk1; + s16 unk2; + u32 idx; + s32 inc; + u16 unkCount; + + JpegHuffmanTable* hTable0; + JpegHuffmanTable* hTable1; + JpegHuffmanTable* hTable2; + JpegHuffmanTable* hTable3; + + inc = 0; + sJpegBitStreamPtr = decoder->imageData; + if (decoder->mode == 0) { + unkCount = 2; + } else { + unkCount = 4; + if (decoder->unk_05 == 1) { + inc = 8 * 8 * 2; + } + } + + hTable0 = decoder->hTablePtrs[0]; + hTable1 = decoder->hTablePtrs[1]; + hTable2 = decoder->hTablePtrs[2]; + hTable3 = decoder->hTablePtrs[3]; + + if (!isFollowing) { + sJpegBitStreamByteIdx = 0; + sJpegBitStreamBitIdx = 32; + sJpegBitStreamCurWord = 0; + sJpegBitStreamDontSkip = 0; + unk0 = 0; + unk1 = 0; + unk2 = 0; + } else { + sJpegBitStreamByteIdx = state->byteIdx; + sJpegBitStreamBitIdx = state->bitIdx; + sJpegBitStreamCurWord = state->curWord; + sJpegBitStreamDontSkip = state->dontSkip; + unk0 = state->unk_0C; + unk1 = state->unk_0E; + unk2 = state->unk_10; + } + + while (count != 0) { + for (idx = 0; idx < unkCount; idx++) { + if (JpegDecoder_ProcessMcu(hTable0, hTable1, mcuBuff, &unk0)) { + return 2; + } + mcuBuff += 8 * 8; + } + + if (JpegDecoder_ProcessMcu(hTable2, hTable3, mcuBuff, &unk1)) { + return 2; + } + mcuBuff += 8 * 8; + + if (JpegDecoder_ProcessMcu(hTable2, hTable3, mcuBuff, &unk2)) { + return 2; + } + + count--; + mcuBuff += 8 * 8; + mcuBuff += inc; + } + + state->byteIdx = sJpegBitStreamByteIdx; + state->bitIdx = sJpegBitStreamBitIdx; + state->curWord = sJpegBitStreamCurWord; + state->dontSkip = sJpegBitStreamDontSkip; + state->unk_0C = unk0; + state->unk_0E = unk1; + state->unk_10 = unk2; + return 0; +} + +s32 JpegDecoder_ProcessMcu(JpegHuffmanTable* hTable0, JpegHuffmanTable* hTable1, u16* mcu, s16* unk) { + s8 i = 0; + s8 zeroCount; + s16 coeff; + + if (JpegDecoder_ParseNextSymbol(hTable0, &coeff, &zeroCount)) { + return true; + } + + *unk += coeff; + mcu[i++] = *unk; + while (i < 8 * 8) { + if (JpegDecoder_ParseNextSymbol(hTable1, &coeff, &zeroCount)) { + return true; + } + + if (coeff == 0) { + if (zeroCount == 0xF) { + while (zeroCount-- >= 0) { + mcu[i++] = 0; + } + } else { + while (i < 8 * 8) { + mcu[i++] = 0; + } + break; + } + } else { + while (0 < zeroCount--) { + mcu[i++] = 0; + } + mcu[i++] = coeff; + } + } + + return false; +} + +s32 JpegDecoder_ParseNextSymbol(JpegHuffmanTable* hTable, s16* outCoeff, s8* outZeroCount) { + u8 codeIdx; + u8 sym; + u16 codeOff = 0; + u16 buff = JpegDecoder_ReadBits(16); + + for (codeIdx = 0; codeIdx < ARRAY_COUNT(hTable->codesB); codeIdx++) { + if (hTable->codesB[codeIdx] == 0xFFFF) { + continue; + } + + codeOff = buff >> (15 - codeIdx); + if (codeOff <= hTable->codesB[codeIdx]) { + break; + } + } + + if (codeIdx >= ARRAY_COUNT(hTable->codesB)) { + return true; + } + + sym = hTable->symbols[hTable->codeOffs[codeIdx] + codeOff - hTable->codesA[codeIdx]]; + *outZeroCount = sym >> 4; + sym &= 0xF; + + sJpegBitStreamBitIdx += codeIdx - 15; + *outCoeff = 0; + if (sym) { + *outCoeff = JpegDecoder_ReadBits(sym); + if (*outCoeff < (1 << (sym - 1))) { + *outCoeff += (-1 << sym) + 1; + } + } + + return false; +} + +u16 JpegDecoder_ReadBits(u8 len) { + u8 byteCount; + u8 data; + s32 ret; + u32 temp; + ret = 0; // this is required for some reason + + for (byteCount = sJpegBitStreamBitIdx >> 3; byteCount > 0; byteCount--) { + data = sJpegBitStreamPtr[sJpegBitStreamByteIdx++]; + if (sJpegBitStreamDontSkip) { + if (data == 0) { + data = sJpegBitStreamPtr[sJpegBitStreamByteIdx++]; + } + } + + sJpegBitStreamDontSkip = (data == 0xFF) ? true : false; + + sJpegBitStreamCurWord <<= 8; + sJpegBitStreamCurWord |= data; + sJpegBitStreamBitIdx -= 8; + } + + ret = (sJpegBitStreamCurWord << (sJpegBitStreamBitIdx)); + temp = ret; + ret = temp >> -len; + sJpegBitStreamBitIdx += len; + return ret; +} diff --git a/src/code/jpegutils.c b/src/code/jpegutils.c new file mode 100644 index 0000000000..904643f46f --- /dev/null +++ b/src/code/jpegutils.c @@ -0,0 +1,155 @@ +#include "z64jpeg.h" +#include "libc/stdbool.h" +#include "macros.h" + +void JpegUtils_ProcessQuantizationTable(u8* dqt, JpegQuantizationTable* qt, u8 count) { + u8 i; + + for (i = 0; i < count; i++) { + u8 j; + + dqt++; + for (j = 0; j < ARRAY_COUNT(qt[i].table); j++) { + qt[i].table[j] = *dqt++; + } + } +} + +s32 JpegUtils_ParseHuffmanCodesLengths(u8* ptr, u8* codesLengths) { + u8 off = 1; + s16 count = 0; + s16 idx = 1; + + while (off <= 16) { + while (idx <= ptr[off - 1]) { + codesLengths[count++] = off; + idx++; + } + idx = 1; + off++; + } + + codesLengths[count] = 0; + return count; +} + +s32 JpegUtils_GetHuffmanCodes(u8* codesLengths, u16* codes) { + s16 idx = 0; + u16 code = 0; + u8 lastLen = codesLengths[0]; + + while (true) { + while (true) { + codes[idx++] = code++; + + if (codesLengths[idx] != lastLen) { + break; + } + } + + if (codesLengths[idx] == 0) { + break; + } + + while (true) { + if (code <<= 1, codesLengths[idx] == ++lastLen) { + break; + } + } + } + + return idx; +} + +s32 JpegUtils_SetHuffmanTable(u8* data, JpegHuffmanTable* ht, u16* codes) { + u8 idx; + u16 codeOff = 0; + + for (idx = 0; idx < 16; idx++) { + if (data[idx]) { + ht->codeOffs[idx] = codeOff; + ht->codesA[idx] = codes[codeOff]; + codeOff += data[idx] - 1; + ht->codesB[idx] = codes[codeOff]; + codeOff++; + } else { + ht->codesB[idx] = 0xFFFF; + } + } + + return codeOff; +} + +u32 JpegUtils_ProcessHuffmanTableImpl(u8* data, JpegHuffmanTable* ht, u8* codesLengths, u16* codes, u8 isAc) { + s16 ret; + s32 count = JpegUtils_ParseHuffmanCodesLengths(data, codesLengths); + s32 temp; + + ret = count; + if (count == 0 || (isAc && count > 0x100) || (!isAc && count > 0x10)) { + return 0; + } + if (ret != JpegUtils_GetHuffmanCodes(codesLengths, codes)) { + return 0; + } + if (temp = JpegUtils_SetHuffmanTable(data, ht, codes), temp != ret) { + return 0; + } + + return ret; +} + +u32 JpegUtils_ProcessHuffmanTable(u8* dht, JpegHuffmanTable* ht, u8* codesLengths, u16* codes, u8 count) { + u8 idx; + u32 codeCount; + + for (idx = 0; idx < count; idx++) { + u32 ac = (*dht++ >> 4); + + codeCount = JpegUtils_ProcessHuffmanTableImpl(dht, &ht[idx], codesLengths, codes, ac); + if (codeCount == 0) { + return true; + } + + dht += 16; + ht[idx].symbols = dht; + dht += codeCount; + } + return false; +} + +void JpegUtils_SetHuffmanTableOld(u8* data, JpegHuffmanTableOld* ht, u8* codesLengths, u16* codes, s16 count, u8 isAc) { + s16 idx; + u8 a; + + for (idx = 0; idx < count; idx++) { + a = data[idx]; + if (isAc) { + ht->acCodes[a] = codes[idx]; + ht->codeOffs[a] = codesLengths[idx]; + } else { + ht->dcCodes[a] = codes[idx]; + ht->codeOffs[a] = codesLengths[idx]; + } + } +} + +u32 JpegUtils_ProcessHuffmanTableImplOld(u8* dht, JpegHuffmanTableOld* ht, u8* codesLengths, u16* codes) { + u8 isAc = *dht++ >> 4; + s16 count2; + s32 count; + + count2 = count = JpegUtils_ParseHuffmanCodesLengths(dht, codesLengths); + + if (count == 0 || (isAc && count > 0x100) || (!isAc && count > 0x10)) { + return true; + } + + if (JpegUtils_GetHuffmanCodes(codesLengths, codes) != count2) { + return true; + } + + JpegUtils_SetHuffmanTableOld(dht + 0x10, ht, codesLengths, codes, count2, isAc); + + return false; +} diff --git a/src/code/sched.c b/src/code/sched.c index ecd984b056..927a48f66b 100644 --- a/src/code/sched.c +++ b/src/code/sched.c @@ -225,7 +225,7 @@ s32 Sched_TaskCheckFramebuffers(SchedContext* sched, OSScTask* task) { void* nextFB = osViGetNextFramebuffer(); void* curFB = osViGetCurrentFramebuffer(); - if (task == NULL || sched->pendingSwapBuf1 != NULL || (curFB == task->framebuffer->fb1 && curFB != nextFB)) { + if (task == NULL || sched->pendingSwapBuf1 != NULL || (curFB == TASK_FRAMEBUFFER(task)->fb1 && curFB != nextFB)) { return 0; } return 1; @@ -257,7 +257,7 @@ s32 Sched_Schedule(SchedContext* sched, OSScTask** spTask, OSScTask** dpTask, s3 } } } else if (ret == (OS_SC_SP | OS_SC_DP)) { - if (gfxTask->framebuffer == NULL || Sched_TaskCheckFramebuffers(sched, gfxTask)) { + if (TASK_FRAMEBUFFER(gfxTask) == NULL || Sched_TaskCheckFramebuffers(sched, gfxTask)) { *spTask = *dpTask = gfxTask; ret &= ~(OS_SC_SP | OS_SC_DP); sched->gfxListHead = sched->gfxListHead->next; @@ -271,7 +271,7 @@ s32 Sched_Schedule(SchedContext* sched, OSScTask** spTask, OSScTask** dpTask, s3 } void Sched_TaskUpdateFramebuffer(SchedContext* sched, OSScTask* task) { - sched->pendingSwapBuf1 = task->framebuffer; + sched->pendingSwapBuf1 = TASK_FRAMEBUFFER(task); if (sched->curBuf != NULL && sched->curBuf->updateRate2 > 0) { return; diff --git a/src/code/sys_initial_check.c b/src/code/sys_initial_check.c index 7b0a26cc89..84871255b8 100644 --- a/src/code/sys_initial_check.c +++ b/src/code/sys_initial_check.c @@ -1,17 +1,116 @@ +/** + * File: sys_initial_check.c + * Description: Functions for checking for the presence of the Expansion Pak and the correct TV type (PAL/NTSC/MPAL), + * and functions for printing error messages directly to screen if not found or incorrect. + * + * These checks are some of the first functions run in Main, before even setting up the system heap, and any image files + * are DMA'd directly to fixed RAM addresses. + */ #include "global.h" +#include "misc/locerrmsg/locerrmsg.h" +#include "misc/memerrmsg/memerrmsg.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_initial_check/Check_WriteRGBA16Pixel.s") +#define SIZEOF_LOCERRMSG (sizeof(gNotDesignedForSystemErrorTex)) +#define SIZEOF_MEMERRMSG (sizeof(gExpansionPakNotInstalledErrorTex) + sizeof(gSeeInstructionBookletErrorTex)) -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_initial_check/Check_WriteI4Pixel.s") +// Address with enough room after to load either of the error message image files before the fault screen buffer at the +// end of RDRAM +#define CHECK_ERRMSG_STATIC_SEGMENT (u8*)(FAULT_FB_ADDRESS - MAX(SIZEOF_LOCERRMSG, SIZEOF_MEMERRMSG)) -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_initial_check/Check_DrawI4Texture.s") +void Check_WriteRGBA16Pixel(u16* buffer, u32 x, u32 y, u32 value) { + if (value & RGBA16_PIXEL_OPAQUE) { + (&buffer[x])[y * SCREEN_WIDTH] = value; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_initial_check/Check_ClearRGBA16.s") +void Check_WriteI4Pixel(u16* buffer, u32 x, u32 y, u32 value) { + Check_WriteRGBA16Pixel(buffer, x, y, value * GPACK_RGBA5551(16, 16, 16, 0) + GPACK_RGBA5551(12, 12, 12, 1)); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_initial_check/Check_DrawExpansionPakErrorMessage.s") +/** + * x and y are the coordinates of the bottom-left corner. + */ +void Check_DrawI4Texture(u16* buffer, s32 x, s32 y, s32 width, s32 height, u8* texture) { + s32 v; + s32 u; + u8 pixelPair; + u8* pixelPairPtr = texture; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_initial_check/Check_DrawRegionLockErrorMessage.s") + // I4 textures are bitpacked 2 pixels per byte, so this writes a pair of pixels in each iteration using bitmasking. + for (v = 0; v < height; v++) { + for (u = 0; u < width; u += 2, pixelPairPtr++) { + pixelPair = *pixelPairPtr; + Check_WriteI4Pixel(buffer, x + u, y + v, pixelPair >> 4); + pixelPair = *pixelPairPtr; + Check_WriteI4Pixel(buffer, x + u + 1, y + v, pixelPair & 0xF); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_initial_check/Check_ExpansionPak.s") +void Check_ClearRGBA16(u16* buffer) { + u32 x; + u32 y; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_initial_check/Check_RegionIsSupported.s") + for (y = 0; y < SCREEN_HEIGHT; y++) { + for (x = 0; x < SCREEN_WIDTH; x++) { + Check_WriteRGBA16Pixel(buffer, x, y, 1); + } + } +} + +/** + * Draw error message textures directly to a screen buffer at the end of normal RDRAM + */ +void Check_DrawExpansionPakErrorMessage(void) { + DmaMgr_SendRequest0(CHECK_ERRMSG_STATIC_SEGMENT, SEGMENT_ROM_START(memerrmsg), SEGMENT_SIZE(memerrmsg)); + Check_ClearRGBA16((u16*)FAULT_FB_ADDRESS); + Check_DrawI4Texture((u16*)FAULT_FB_ADDRESS, 96, 71, 128, 37, CHECK_ERRMSG_STATIC_SEGMENT); + Check_DrawI4Texture((u16*)FAULT_FB_ADDRESS, 96, 127, 128, 37, + CHECK_ERRMSG_STATIC_SEGMENT + sizeof(gExpansionPakNotInstalledErrorTex)); + osWritebackDCacheAll(); + osViSwapBuffer((u16*)FAULT_FB_ADDRESS); + osViBlack(false); +} + +/** + * Draw error message texture directly to a screen buffer at the end of normal RDRAM + */ +void Check_DrawRegionLockErrorMessage(void) { + DmaMgr_SendRequest0(CHECK_ERRMSG_STATIC_SEGMENT, SEGMENT_ROM_START(locerrmsg), SEGMENT_SIZE(locerrmsg)); + Check_ClearRGBA16((u16*)FAULT_FB_ADDRESS); + Check_DrawI4Texture((u16*)FAULT_FB_ADDRESS, 56, 112, 208, 16, CHECK_ERRMSG_STATIC_SEGMENT); + osWritebackDCacheAll(); + osViSwapBuffer((u16*)FAULT_FB_ADDRESS); + osViBlack(false); +} + +/** + * If Expansion pak is not installed, display error message until console is turned off + */ +void Check_ExpansionPak(void) { + // Expansion pak installed + if (osMemSize >= 0x800000) { + return; + } + + Check_DrawExpansionPakErrorMessage(); + osDestroyThread(NULL); + while (true) {} +} + +/** + * If region is not NTSC or MPAL, display error message until console is turned off + */ +void Check_RegionIsSupported(void) { + s32 regionSupported = false; + + if ((osTvType == OS_TV_NTSC) || (osTvType == OS_TV_MPAL)) { + regionSupported = true; + } + + if (!regionSupported) { + Check_DrawRegionLockErrorMessage(); + osDestroyThread(NULL); + while (true) {} + } +} diff --git a/src/code/sys_math3d.c b/src/code/sys_math3d.c index f607295c19..50fd1211ec 100644 --- a/src/code/sys_math3d.c +++ b/src/code/sys_math3d.c @@ -2,7 +2,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_Normalize.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_80179678.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_PlaneVsLineSegClosestPoint.s") #pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_80179798.s") @@ -46,7 +46,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_Vec3fMagnitude.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_DistanceSquared.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_Vec3fDistSq.s") #pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_Distance.s") @@ -60,15 +60,15 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_CrossProduct.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_NormalVector.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_SurfaceNorm.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017A954.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_PointRelativeToCubeFaces.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017AA0C.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_PointRelativeToCubeEdges.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017ABBC.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_PointRelativeToCubeVertices.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017AD38.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_LineVsCube.s") #pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017B68C.s") @@ -80,51 +80,51 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017B9D8.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_NormalizedDistanceFromPlane.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_UDistPlaneToPos.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_NormalizedSignedDistanceFromPlane.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_DistPlaneToPos.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017BAD0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_TriChkPointParaYDist.s") #pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017BD98.s") #pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017BDE0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017BE30.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_TriChkPointParaYIntersectDist.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017BEE0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_TriChkPointParaYIntersectInsideTri.s") #pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017BF8C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017C008.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_TriChkLineSegParaYIntersect.s") #pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017C17C.s") #pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017C1F0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017C494.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_TriChkPointParaYIntersectInsideTri2.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017C540.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_TriChkPointParaXDist.s") #pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017C808.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017C850.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_TriChkPointParaXIntersect.s") #pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017C904.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017C980.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_TriChkLineSegParaXIntersect.s") #pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017CB08.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017CB7C.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_TriChkLineSegParaZDist.s") #pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017CEA8.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017CEF0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_TriChkPointParaZIntersect.s") #pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017CFA4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017D020.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_TriChkLineSegParaZIntersect.s") #pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017D1AC.s") @@ -148,7 +148,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017DA24.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_ColSphereLineSeg.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_LineVsSph.s") #pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017DD34.s") @@ -162,7 +162,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017F1A0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_ColSphereSphere.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_SphVsSph.s") #pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_ColSphereSphereIntersect.s") @@ -178,11 +178,11 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3d_ColTriTri.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017F9C0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_XZInSphere.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017FA34.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_XYInSphere.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017FAA8.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_YZInSphere.s") #pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017FB1C.s") diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 03a362fc66..42f67987a1 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -509,8 +509,8 @@ f32 Actor_YDistance(Actor* actor1, Actor* actor2) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B72E0.s") void func_800B72F8(DynaPolyActor* dpactor, f32 a1, s16 a2) { - dpactor->unk150 = a2; - dpactor->unk148 += a1; + dpactor->yRotation = a2; + dpactor->pushForce += a1; } #pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_IsLinkFacingActor.s") diff --git a/src/code/z_bg_collect.c b/src/code/z_bg_collect.c index 29c4cf7dae..0d4f4a21f6 100644 --- a/src/code/z_bg_collect.c +++ b/src/code/z_bg_collect.c @@ -1,33 +1,33 @@ #include "global.h" -void BgCheck2_UpdateActorPosition(CollisionContext* colCtx, s32 index, Actor* actor) { +void BgCheck2_UpdateActorPosition(CollisionContext* colCtx, s32 bgId, Actor* actor) { MtxF prevMatrix; MtxF prevMatrixInv; MtxF currMatrix; Vec3f newPos; Vec3f posWithInv; - if (BgCheck_IsActorMeshIndexValid(index) == 0) { + if (!DynaPoly_IsBgIdBgActor(bgId)) { return; } SkinMatrix_SetScaleRotateYRPTranslate( - &prevMatrix, colCtx->dyna.bgActors[index].prevTransform.scale.x, - colCtx->dyna.bgActors[index].prevTransform.scale.y, colCtx->dyna.bgActors[index].prevTransform.scale.z, - colCtx->dyna.bgActors[index].prevTransform.rot.x, colCtx->dyna.bgActors[index].prevTransform.rot.y, - colCtx->dyna.bgActors[index].prevTransform.rot.z, colCtx->dyna.bgActors[index].prevTransform.pos.x, - colCtx->dyna.bgActors[index].prevTransform.pos.y, colCtx->dyna.bgActors[index].prevTransform.pos.z); + &prevMatrix, colCtx->dyna.bgActors[bgId].prevTransform.scale.x, + colCtx->dyna.bgActors[bgId].prevTransform.scale.y, colCtx->dyna.bgActors[bgId].prevTransform.scale.z, + colCtx->dyna.bgActors[bgId].prevTransform.rot.x, colCtx->dyna.bgActors[bgId].prevTransform.rot.y, + colCtx->dyna.bgActors[bgId].prevTransform.rot.z, colCtx->dyna.bgActors[bgId].prevTransform.pos.x, + colCtx->dyna.bgActors[bgId].prevTransform.pos.y, colCtx->dyna.bgActors[bgId].prevTransform.pos.z); if (SkinMatrix_Invert(&prevMatrix, &prevMatrixInv) == 2) { return; } SkinMatrix_SetScaleRotateYRPTranslate( - &currMatrix, colCtx->dyna.bgActors[index].curTransform.scale.x, - colCtx->dyna.bgActors[index].curTransform.scale.y, colCtx->dyna.bgActors[index].curTransform.scale.z, - colCtx->dyna.bgActors[index].curTransform.rot.x, colCtx->dyna.bgActors[index].curTransform.rot.y, - colCtx->dyna.bgActors[index].curTransform.rot.z, colCtx->dyna.bgActors[index].curTransform.pos.x, - colCtx->dyna.bgActors[index].curTransform.pos.y, colCtx->dyna.bgActors[index].curTransform.pos.z); + &currMatrix, colCtx->dyna.bgActors[bgId].curTransform.scale.x, colCtx->dyna.bgActors[bgId].curTransform.scale.y, + colCtx->dyna.bgActors[bgId].curTransform.scale.z, colCtx->dyna.bgActors[bgId].curTransform.rot.x, + colCtx->dyna.bgActors[bgId].curTransform.rot.y, colCtx->dyna.bgActors[bgId].curTransform.rot.z, + colCtx->dyna.bgActors[bgId].curTransform.pos.x, colCtx->dyna.bgActors[bgId].curTransform.pos.y, + colCtx->dyna.bgActors[bgId].curTransform.pos.z); SkinMatrix_Vec3fMtxFMultXYZ(&prevMatrixInv, &actor->world.pos, &posWithInv); SkinMatrix_Vec3fMtxFMultXYZ(&currMatrix, &posWithInv, &newPos); @@ -35,14 +35,14 @@ void BgCheck2_UpdateActorPosition(CollisionContext* colCtx, s32 index, Actor* ac actor->world.pos = newPos; } -void BgCheck2_UpdateActorYRotation(CollisionContext* colCtx, s32 index, Actor* actor) { +void BgCheck2_UpdateActorYRotation(CollisionContext* colCtx, s32 bgId, Actor* actor) { s16 angleChange; - if (BgCheck_IsActorMeshIndexValid(index) == 0) { + if (!DynaPoly_IsBgIdBgActor(bgId)) { return; } - angleChange = colCtx->dyna.bgActors[index].curTransform.rot.y - colCtx->dyna.bgActors[index].prevTransform.rot.y; + angleChange = colCtx->dyna.bgActors[bgId].curTransform.rot.y - colCtx->dyna.bgActors[bgId].prevTransform.rot.y; if (actor->id == 0) { ((Player*)actor)->currentYaw += angleChange; @@ -52,51 +52,51 @@ void BgCheck2_UpdateActorYRotation(CollisionContext* colCtx, s32 index, Actor* a actor->world.rot.y += angleChange; } -void BgCheck2_AttachToMesh(CollisionContext* colCtx, Actor* actor, s32 index) { +void BgCheck2_AttachToMesh(CollisionContext* colCtx, Actor* actor, s32 bgId) { DynaPolyActor* meshActor; - if (BgCheck_IsActorMeshIndexValid(index) == 0) { + if (!DynaPoly_IsBgIdBgActor(bgId)) { return; } - meshActor = BgCheck_GetActorOfMesh(colCtx, index); + meshActor = DynaPoly_GetActor(colCtx, bgId); if (meshActor != NULL) { - func_800CAE88(meshActor); + DynaPolyActor_SetRidingFallingState(meshActor); if ((actor->flags & 0x4000000) == 0x4000000) { - func_800CAF24(meshActor); + DynaPolyActor_SetSwitchPressedState(meshActor); } if ((actor->flags & 0x20000) == 0x20000) { - func_800CAF38(meshActor); + DynaPolyActor_SetHeavySwitchPressedState(meshActor); } } } -u32 BgCheck2_UpdateActorAttachedToMesh(CollisionContext* colCtx, s32 index, Actor* actor) { +u32 BgCheck2_UpdateActorAttachedToMesh(CollisionContext* colCtx, s32 bgId, Actor* actor) { u32 wasUpdated = 0; DynaPolyActor* meshActor; - if (BgCheck_IsActorMeshIndexValid(index) == 0) { + if (!DynaPoly_IsBgIdBgActor(bgId)) { return 0; } - if (((colCtx->dyna.bgActorFlags[index] & 2) != 0) || ((colCtx->dyna.bgActorFlags[index] & 1) == 0)) { + if (colCtx->dyna.bgActorFlags[bgId] & 2 || !(colCtx->dyna.bgActorFlags[bgId] & 1)) { return 0; } - meshActor = BgCheck_GetActorOfMesh(colCtx, index); + meshActor = DynaPoly_GetActor(colCtx, bgId); if (meshActor == NULL) { return 0; } - if ((meshActor->unk154 & 1) != 0) { - BgCheck2_UpdateActorPosition(colCtx, index, actor); + if (meshActor->flags & 1) { + BgCheck2_UpdateActorPosition(colCtx, bgId, actor); wasUpdated = 1; } - if ((meshActor->unk154 & 2) != 0) { - BgCheck2_UpdateActorYRotation(colCtx, index, actor); + if (meshActor->flags & 2) { + BgCheck2_UpdateActorYRotation(colCtx, bgId, actor); wasUpdated = 1; } diff --git a/src/code/z_bg_item.c b/src/code/z_bg_item.c index 77cc014b44..74adbe6952 100644 --- a/src/code/z_bg_item.c +++ b/src/code/z_bg_item.c @@ -1,99 +1,141 @@ #include "global.h" -void BcCheck3_BgActorInit(DynaPolyActor* actor, UNK_TYPE4 param_2) { - actor->bgId = -1; - actor->unk148 = 0; - actor->unk14C = 0; - actor->unk154 = param_2; - actor->unk_158 = 0; +#define DYNAPOLY_STATE_NONE 0 +#define DYNAPOLY_STATE_RIDING_FALLING (1 << 0) +#define DYNAPOLY_STATE_RIDING_MOVING (1 << 1) +#define DYNAPOLY_STATE_RIDING_ROTATING (1 << 2) +#define DYNAPOLY_STATE_SWITCH_PRESSED (1 << 3) +#define DYNAPOLY_STATE_HEAVY_SWITCH_PRESSED (1 << 4) + +void DynaPolyActor_Init(DynaPolyActor* dynaActor, s32 flags) { + dynaActor->bgId = -1; + dynaActor->pushForce = 0.0f; + dynaActor->unk14C = 0.0f; + dynaActor->flags = flags; + dynaActor->stateFlags = DYNAPOLY_STATE_NONE; } -void BgCheck3_LoadMesh(GlobalContext* globalCtx, DynaPolyActor* actor, CollisionHeader* meshHeader) { - CollisionHeader* header; +void DynaPolyActor_LoadMesh(GlobalContext* globalCtx, DynaPolyActor* dynaActor, CollisionHeader* meshHeader) { + CollisionHeader* header = NULL; - header = NULL; - BgCheck_RelocateMeshHeader(meshHeader, &header); - actor->bgId = BgCheck_AddActorMesh(globalCtx, &globalCtx->colCtx.dyna, actor, header); + CollisionHeader_GetVirtual(meshHeader, &header); + dynaActor->bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &dynaActor->actor, header); } -void BgCheck3_ResetFlags(DynaPolyActor* actor) { - actor->unk_158 = 0; +void DynaPolyActor_ResetState(DynaPolyActor* dynaActor) { + dynaActor->stateFlags = DYNAPOLY_STATE_NONE; } -void func_800CAE88(DynaPolyActor* actor) { - actor->unk_158 |= 1; +void DynaPolyActor_SetRidingFallingState(DynaPolyActor* dynaActor) { + dynaActor->stateFlags |= DYNAPOLY_STATE_RIDING_FALLING; } -void func_800CAE9C(DynaPolyActor* actor) { - actor->unk_158 |= 2; +void DynaPolyActor_SetRidingMovingState(DynaPolyActor* dynaActor) { + dynaActor->stateFlags |= DYNAPOLY_STATE_RIDING_MOVING; } -void func_800CAEB0(CollisionContext* colCtx, s32 index) { - DynaPolyActor* actor; +void DynaPolyActor_SetRidingMovingStateByIndex(CollisionContext* colCtx, s32 bgId) { + DynaPolyActor* dynaActor = DynaPoly_GetActor(colCtx, bgId); - actor = BgCheck_GetActorOfMesh(colCtx, index); - if (actor != (DynaPolyActor*)0x0) { - func_800CAE9C(actor); + if (dynaActor != NULL) { + DynaPolyActor_SetRidingMovingState(dynaActor); } } -void func_800CAEE0(DynaPolyActor* actor) { - actor->unk_158 |= 4; +void DynaPolyActor_SetRidingRotatingState(DynaPolyActor* dynaActor) { + dynaActor->stateFlags |= DYNAPOLY_STATE_RIDING_ROTATING; } -void func_800CAEF4(CollisionContext* colCtx, s32 index) { - DynaPolyActor* actor; +void DynaPolyActor_SetRidingRotatingStateByIndex(CollisionContext* colCtx, s32 bgId) { + DynaPolyActor* dynaActor = DynaPoly_GetActor(colCtx, bgId); - actor = BgCheck_GetActorOfMesh(colCtx, index); - if (actor != (DynaPolyActor*)0x0) { - func_800CAEE0(actor); + if (dynaActor != NULL) { + DynaPolyActor_SetRidingRotatingState(dynaActor); } } -void func_800CAF24(DynaPolyActor* actor) { - actor->unk_158 |= 8; +void DynaPolyActor_SetSwitchPressedState(DynaPolyActor* dynaActor) { + dynaActor->stateFlags |= DYNAPOLY_STATE_SWITCH_PRESSED; } -void func_800CAF38(DynaPolyActor* actor) { - actor->unk_158 |= 0x10; +void DynaPolyActor_SetHeavySwitchPressedState(DynaPolyActor* dynaActor) { + dynaActor->stateFlags |= DYNAPOLY_STATE_HEAVY_SWITCH_PRESSED; } -s32 func_800CAF4C(DynaPolyActor* actor) { - if (actor->unk_158 & 1) { - return 1; +s32 DynaPolyActor_IsInRidingFallingState(DynaPolyActor* dynaActor) { + if (dynaActor->stateFlags & DYNAPOLY_STATE_RIDING_FALLING) { + return true; } else { - return 0; + return false; } } -s32 func_800CAF70(DynaPolyActor* actor) { - if (actor->unk_158 & 2) { - return 1; +s32 DynaPolyActor_IsInRidingMovingState(DynaPolyActor* dynaActor) { + if (dynaActor->stateFlags & DYNAPOLY_STATE_RIDING_MOVING) { + return true; } else { - return 0; + return false; } } -s32 func_800CAF94(DynaPolyActor* actor) { - if (actor->unk_158 & 4) { - return 1; +s32 DynaPolyActor_IsInRidingRotatingState(DynaPolyActor* dynaActor) { + if (dynaActor->stateFlags & DYNAPOLY_STATE_RIDING_ROTATING) { + return true; } else { - return 0; + return false; } } -s32 func_800CAFB8(DynaPolyActor* actor) { - if (actor->unk_158 & 8) { - return 1; +s32 DynaPolyActor_IsInSwitchPressedState(DynaPolyActor* dynaActor) { + if (dynaActor->stateFlags & DYNAPOLY_STATE_SWITCH_PRESSED) { + return true; } else { - return 0; + return false; } } -s32 func_800CAFDC(DynaPolyActor* actor) { - if (actor->unk_158 & 0x10) { - return 1; +s32 DynaPolyActor_IsInHeavySwitchPressedState(DynaPolyActor* dynaActor) { + if (dynaActor->stateFlags & DYNAPOLY_STATE_HEAVY_SWITCH_PRESSED) { + return true; } else { - return 0; + return false; } } + +s32 DynaPolyActor_ValidateMove(GlobalContext* globalCtx, DynaPolyActor* dynaActor, s16 startRadius, s16 endRadius, + s16 startHeight) { + Vec3f startPos; + Vec3f endPos; + Vec3f intersectionPos; + f32 sin = Math_SinS(dynaActor->yRotation); + f32 cos = Math_CosS(dynaActor->yRotation); + s32 bgId; + CollisionPoly* poly; + f32 adjustedStartRadius; + f32 adjustedEndRadius; + f32 sign = (0.0f <= dynaActor->pushForce) ? 1.0f : -1.0f; + + adjustedStartRadius = (f32)startRadius - 0.1f; + startPos.x = dynaActor->actor.world.pos.x + (adjustedStartRadius * cos); + startPos.y = dynaActor->actor.world.pos.y + startHeight; + startPos.z = dynaActor->actor.world.pos.z - (adjustedStartRadius * sin); + + adjustedEndRadius = (f32)endRadius - 0.1f; + endPos.x = sign * adjustedEndRadius * sin + startPos.x; + endPos.y = startPos.y; + endPos.z = sign * adjustedEndRadius * cos + startPos.z; + + if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &startPos, &endPos, &intersectionPos, &poly, true, false, false, + true, &bgId, &dynaActor->actor, 0.0f)) { + return false; + } + startPos.x = (dynaActor->actor.world.pos.x * 2.0f) - startPos.x; + startPos.z = (dynaActor->actor.world.pos.z * 2.0f) - startPos.z; + endPos.x = sign * adjustedEndRadius * sin + startPos.x; + endPos.z = sign * adjustedEndRadius * cos + startPos.z; + if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &startPos, &endPos, &intersectionPos, &poly, true, false, false, + true, &bgId, &dynaActor->actor, 0.0f)) { + return false; + } + return true; +} diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index e607b978a9..e5cb1ddb16 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -1,432 +1,4721 @@ #include "global.h" +#include "vt.h" -void BgCheck_PolygonLinkedListNodeInit(SSNode* node, s16* polyIndex, u16 next) { +#define DYNA_RAYCAST_FLOORS 1 +#define DYNA_RAYCAST_WALLS 2 +#define DYNA_RAYCAST_CEILINGS 4 + +static u32 sWallFlags[32] = { + 0, 1, 3, 5, 8, 16, 32, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static u16 sSurfaceTypeSfx[] = { + /* 0x00 */ NA_SE_PL_WALK_GROUND - SFX_FLAG, + /* 0x01 */ NA_SE_PL_WALK_SAND - SFX_FLAG, + /* 0x02 */ NA_SE_PL_WALK_CONCRETE - SFX_FLAG, + /* 0x03 */ NA_SE_PL_WALK_DIRT - SFX_FLAG, + /* 0x04 */ NA_SE_PL_WALK_WATER0 - SFX_FLAG, + /* 0x05 */ NA_SE_PL_WALK_WATER1 - SFX_FLAG, + /* 0x06 */ NA_SE_PL_WALK_WATER2 - SFX_FLAG, + /* 0x07 */ NA_SE_PL_WALK_MAGMA - SFX_FLAG, + /* 0x08 */ NA_SE_PL_WALK_GRASS - SFX_FLAG, + /* 0x09 */ NA_SE_PL_WALK_GLASS - SFX_FLAG, + /* 0x0A */ NA_SE_PL_WALK_LADDER - SFX_FLAG, + /* 0x0B */ NA_SE_PL_WALK_GROUND - SFX_FLAG, + /* 0x0C */ NA_SE_PL_WALK_ICE - SFX_FLAG, + /* 0x0D */ NA_SE_PL_WALK_IRON - SFX_FLAG, + /* 0x0E */ NA_SE_PL_WALK_SNOW - SFX_FLAG +}; + +static u8 D_801B46C0[] = { + /* 0x00 */ 1, + /* 0x01 */ 1, + /* 0x02 */ 0, + /* 0x03 */ 1, + /* 0x04 */ 0, + /* 0x05 */ 0, + /* 0x06 */ 0, + /* 0x07 */ 0, + /* 0x08 */ 0, + /* 0x09 */ 0, + /* 0x0A */ 0, + /* 0x0B */ 0, + /* 0x0C */ 0, + /* 0x0D */ 0, + /* 0x0E */ 1 +}; + +static s16 sSmallMemScenes[] = { + SCENE_F01, +}; + +typedef struct { + s16 sceneId; + u32 memSize; +} BgCheckSceneMemEntry; + +static BgCheckSceneMemEntry sSceneMemList[] = { + { SCENE_00KEIKOKU, 0xC800 }, +}; + +BgCheckSceneSubdivisionEntry sSceneSubdivisionList[] = { + { SCENE_00KEIKOKU, { 36, 1, 36 }, -1 }, + { SCENE_30GYOSON, { 40, 1, 40 }, -1 }, + { SCENE_31MISAKI, { 40, 1, 40 }, -1 }, +}; + +BgSpecialSceneMaxObjects sCustomDynapolyMem[] = { + { SCENE_21MITURINMAE, 1000, 600, 512 }, +}; + +char D_801ED950[80]; +char D_801ED9A0[80]; +Vec3f D_801ED9F0[3]; // polyVerts +Vec3f D_801EDA18[3]; // polyVerts //not ok, needs to be inlined to match +MtxF D_801EDA40; +Vec3f D_801EDA80[3]; // polyVerts +char D_801EDAA8[80]; +char D_801EDAF8[80]; +Vec3f D_801EDB48[3]; // polyVerts +Vec3f D_801EDB70[3]; +Plane D_801EDB98; +Sphere16 D_801EDBA8; +TriNorm D_801EDBB0; + +void BgCheck_GetStaticLookupIndicesFromPos(CollisionContext* colCtx, Vec3f* pos, Vec3i* sector); +f32 BgCheck_RaycastFloorDyna(DynaRaycast* dynaRaycast); +s32 BgCheck_SphVsDynaWall(CollisionContext* colCtx, u16 xpFlags, f32* outX, f32* outZ, Vec3f* pos, f32 radius, + CollisionPoly** outPoly, s32* outBgId, Actor* actor); +s32 BgCheck_CheckLineImpl(CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2, Vec3f* posA, Vec3f* posB, + Vec3f* posResult, CollisionPoly** outPoly, s32* outBgId, Actor* actor, f32 checkDist, + u32 bccFlags); +s32 BgCheck_CheckDynaCeiling(CollisionContext* colCtx, u16 xpFlags, f32* outY, Vec3f* pos, f32 checkDist, + CollisionPoly** outPoly, s32* outBgId, Actor* actor); +s32 BgCheck_CheckLineAgainstDyna(CollisionContext* colCtx, u16 xpFlags, Vec3f* posA, Vec3f* posB, Vec3f* posResult, + CollisionPoly** outPoly, f32* distSq, s32* outBgId, Actor* actor, f32 checkDist, + s32 bccFlags); +s32 BgCheck_SphVsFirstDynaPoly(CollisionContext* colCtx, u16 xpFlags, CollisionPoly** outPoly, s32* outBgId, + Vec3f* center, f32 radius, Actor* actor, u16 bciFlags); +void BgCheck_ResetPolyCheckTbl(SSNodeList* nodeList, s32 numPolys); +s32 BgCheck_PosInStaticBoundingBox(CollisionContext* colCtx, Vec3f* pos); + +void SSNode_SetValue(SSNode* node, s16* polyIndex, u16 next) { node->polyId = *polyIndex; node->next = next; } -void BgCheck_PolygonLinkedListResetHead(u16* head) { - *head = 0xFFFF; +void SSList_SetNull(SSList* ssList) { + ssList->head = SS_NULL; } -void BgCheck_ScenePolygonListsNodeInsert(SSNodeList* list, u16* head, s16* polyIndex) { +void SSNodeList_SetSSListHead(SSNodeList* list, SSList* ssList, s16* polyIndex) { u16 index; - index = BgCheck_ScenePolygonListsReserveNode(list); - BgCheck_PolygonLinkedListNodeInit(&list->tbl[index], polyIndex, *head); - *head = index; + index = SSNodeList_GetNextNodeIdx(list); + SSNode_SetValue(&list->tbl[index], polyIndex, ssList->head); + ssList->head = index; } -void BgCheck_PolygonLinkedListNodeInsert(DynaSSNodeList* list, u16* head, s16* polyIndex) { +void DynaSSNodeList_SetSSListHead(DynaSSNodeList* list, SSList* ssList, s16* polyIndex) { u16 index; - index = BgCheck_AllocPolygonLinkedListNode(list); - BgCheck_PolygonLinkedListNodeInit(&list->tbl[index], polyIndex, *head); - *head = index; + index = DynaSSNodeList_GetNextNodeIdx(list); + SSNode_SetValue(&list->tbl[index], polyIndex, ssList->head); + ssList->head = index; } -void BgCheck_PolygonLinkedListInit(GlobalContext* globalCtx, DynaSSNodeList* list) { +void DynaSSNodeList_Init(GlobalContext* globalCtx, DynaSSNodeList* list) { list->tbl = NULL; list->count = 0; } -void BgCheck_PolygonLinkedListAlloc(GlobalContext* globalCtx, DynaSSNodeList* list, u32 numNodes) { - list->tbl = (SSNode*)THA_AllocEndAlign(&globalCtx->state.heap, numNodes << 2, 0xfffffffe); - list->max = numNodes; +void DynaSSNodeList_Alloc(GlobalContext* globalCtx, DynaSSNodeList* list, u32 numNodes) { + list->tbl = (SSNode*)THA_AllocEndAlign(&globalCtx->state.heap, numNodes * sizeof(SSNode), -2); + list->maxNodes = numNodes; list->count = 0; } -void BgCheck_PolygonLinkedListReset(DynaSSNodeList* list) { +void DynaSSNodeList_ResetCount(DynaSSNodeList* list) { list->count = 0; } -u16 BgCheck_AllocPolygonLinkedListNode(DynaSSNodeList* list) { - u16 index; +u16 DynaSSNodeList_GetNextNodeIdx(DynaSSNodeList* list) { + u16 index = list->count++; - index = list->count++; - if (list->max <= index) { - return 0xffff; + if (list->maxNodes <= index) { + return SS_NULL; } return index; } -void BgCheck_CreateVec3fFromVertex(Vec3s* vertex, Vec3f* vector) { - vector->x = vertex->x; - vector->y = vertex->y; - vector->z = vertex->z; +void BgCheck_Vec3sToVec3f(Vec3s* src, Vec3f* dest) { + dest->x = src->x; + dest->y = src->y; + dest->z = src->z; } -void BgCheck_CreateVertexFromVec3f(Vec3s* vertex, Vec3f* vector) { - vertex->x = vector->x; - vertex->y = vector->y; - vertex->z = vector->z; +void BgCheck_Vec3fToVec3s(Vec3s* dest, Vec3f* src) { + dest->x = src->x; + dest->y = src->y; + dest->z = src->z; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800BFD84.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800BFDEC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_PolygonGetMinY.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_PolygonGetNormal.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C0094.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C01B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_CreateTriNormFromPolygon.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C02C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C0340.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C0474.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C0668.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C06A8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C074C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C07F0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_PolygonCollidesWithSphere.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_ScenePolygonListsInsertSorted.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_ScenePolygonListsInsert.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C0E74.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C10FC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C1238.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C12A4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C1B68.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C1D7C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C2008.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C20F4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C2310.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C2460.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C2514.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C25E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_GetPolyMinSubdivisions.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_GetPolyMaxSubdivisions.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_GetPolyMinMaxSubdivisions.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C2BE0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_SplitScenePolygonsIntoSubdivisions.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_GetIsDefaultSpecialScene.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_GetSpecialSceneMaxMemory.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_CalcSubdivisionSize.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_GetSpecialSceneMaxObjects.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_Init.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C3C00.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C3C14.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_GetActorMeshHeader.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C3C94.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C3D50.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C3F40.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C3FA0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C4000.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C4058.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C40B4.s") - -f32 func_800C411C(CollisionContext* colCtx, CollisionPoly** arg1, s32* arg2, Actor* actor, Vec3f* pos) { - return func_800C3D50(0, colCtx, 2, arg1, arg2, pos, actor, 28, 1.0f, 0); +f32 func_800BFD84(CollisionPoly* poly, f32 arg1, f32 arg2) { + return (COLPOLY_GET_NORMAL(poly->normal.x * arg1 + poly->normal.z * arg2) + poly->dist) / + COLPOLY_GET_NORMAL(-poly->normal.y); } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C4188.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C41E4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C4240.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C42A8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C4314.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C43CC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C4488.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C44F0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C455C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C45C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C4C74.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C4CD8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C4D3C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C4DA4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C4E10.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C4F38.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C4F84.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C4FD4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C5464.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C54AC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C5538.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C55C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C5650.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C56E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C576C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C57F8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C583C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C58C8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C5954.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C5A20.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C5A64.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_ScenePolygonListsInit.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_ScenePolygonListsAlloc.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C5B80.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_ScenePolygonListsReserveNode.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_ActorMeshParamsInit.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_SetActorMeshParams.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_AreActorMeshParamsEqual.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_ActorMeshPolyListsHeadsInit.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_ActorMeshPolyListsInit.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_ActorMeshVerticesIndexInit.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_ActorMeshWaterboxesIndexInit.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_ActorMeshInit.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_ActorMeshInitFromActor.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_HasActorMeshChanged.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_PolygonsInit.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_PolygonsAlloc.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_VerticesInit.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_VerticesListAlloc.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_WaterboxListInit.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_WaterboxListAlloc.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_ActorMeshUpdateParams.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_IsActorMeshIndexValid.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_DynaInit.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_DynaAlloc.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_AddActorMesh.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_GetActorOfMesh.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C62BC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C6314.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C636C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C63C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C641C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C6474.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_RemoveActorMesh.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C6554.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_CalcWaterboxDimensions.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_AddActorMeshToLists.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_ResetFlagsIfLoadedActor.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_Update.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C756C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_UpdateAllActorMeshes.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C76EC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C7974.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C7E40.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C8580.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C87D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C8A60.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C8BD0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C8DC0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C8EEC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C90AC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C921C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C9380.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_RelocateMeshHeaderPointers.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_RelocateMeshHeader.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_RelocateAllMeshHeaders.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C9640.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_GetPolygonAttributes.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C9704.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C9728.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C9770.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C97F8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C9844.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C98CC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C9924.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C99AC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C99D4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C99FC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C9A24.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C9A4C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C9A7C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C9AB0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C9AE4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C9B18.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C9B40.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C9B68.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C9B90.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C9BB8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C9BDC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C9C24.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C9C74.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C9C9C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C9CC4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C9CEC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C9D14.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C9D50.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C9D8C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C9DDC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C9E18.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C9E40.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C9E88.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800C9EBC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800CA1AC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800CA1E8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800CA22C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800CA568.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800CA634.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800CA648.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800CA6B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800CA6D8.s") - +/** + * Unused + */ +s32 func_800BFDEC(CollisionPoly* polyA, CollisionPoly* polyB, u32* outVtxId0, u32* outVtxId1) { + s32 vtxIdA[3]; + s32 vtxIdB[3]; + s32 i; + s32 j; + s32 count; + + *outVtxId0 = *outVtxId1 = 0; + for (i = 0; i < ARRAY_COUNT(vtxIdA); i++) { + vtxIdA[i] = COLPOLY_VTX_INDEX(polyA->vtxData[i]); + vtxIdB[i] = COLPOLY_VTX_INDEX(polyB->vtxData[i]); + } + + count = 0; + for (i = 0; i < 2; i++) { + for (j = i + 1; j < 3; j++) { + if (vtxIdA[i] == vtxIdB[j]) { + if (count == 0) { + *outVtxId0 = vtxIdA[i]; + } else if (count == 1) { + *outVtxId1 = vtxIdA[i]; + } + count++; + } + } + } + return count; +} + +s16 CollisionPoly_GetMinY(CollisionPoly* poly, Vec3s* vertices) { + s16 minY; + s32 a = COLPOLY_VTX_INDEX(poly->flags_vIA); + s32 b = COLPOLY_VTX_INDEX(poly->flags_vIB); + s32 c = poly->vIC; + + minY = vertices[a].y; + if (vertices[b].y < minY) { + minY = vertices[b].y; + } + if (minY < vertices[c].y) { + return minY; + } + return vertices[c].y; +} + +void CollisionPoly_GetNormalF(CollisionPoly* poly, f32* nx, f32* ny, f32* nz) { + *nx = COLPOLY_GET_NORMAL(poly->normal.x); + *ny = COLPOLY_GET_NORMAL(poly->normal.y); + *nz = COLPOLY_GET_NORMAL(poly->normal.z); +} + +/** + * Compute transform matrix mapping +y (up) to the collision poly's normal + */ +void func_800C0094(CollisionPoly* poly, f32 tx, f32 ty, f32 tz, MtxF* dest) { + f32 nx; + f32 ny; + f32 nz; + s32 pad; + f32 z_f14; + f32 phi_f14; + f32 phi_f12; + f32 inv_z_f14; + + if (poly == NULL) { + return; + } + CollisionPoly_GetNormalF(poly, &nx, &ny, &nz); + + z_f14 = sqrtf(SQ(ny) + SQ(nz)); + if (!IS_ZERO(z_f14)) { + inv_z_f14 = 1.0f / z_f14; + phi_f14 = ny * inv_z_f14; + phi_f12 = nz * inv_z_f14; + } else { + phi_f14 = 1.0f; + phi_f12 = 0.0f; + } + dest->xx = z_f14; + dest->xy = (-nx) * phi_f14; + dest->xz = (-nx) * phi_f12; + dest->yx = nx; + dest->yy = ny; + dest->yz = nz; + dest->zx = 0.0f; + dest->zy = -phi_f12; + dest->zz = phi_f14; + dest->wx = tx; + dest->wy = ty; + dest->wz = tz; + dest->xw = 0.0f; + dest->yw = 0.0f; + dest->zw = 0.0f; + dest->ww = 1.0f; +} + +f32 CollisionPoly_GetPointDistanceFromPlane(CollisionPoly* poly, Vec3f* point) { + return COLPOLY_GET_NORMAL(poly->normal.x * point->x + poly->normal.y * point->y + poly->normal.z * point->z) + + poly->dist; +} + +void CollisionPoly_GetVertices(CollisionPoly* poly, Vec3s* vtxList, Vec3f* dest) { + BgCheck_Vec3sToVec3f(&vtxList[COLPOLY_VTX_INDEX(poly->flags_vIA)], &dest[0]); + BgCheck_Vec3sToVec3f(&vtxList[COLPOLY_VTX_INDEX(poly->flags_vIB)], &dest[1]); + BgCheck_Vec3sToVec3f(&vtxList[poly->vIC], &dest[2]); +} + +void CollisionPoly_GetVerticesByBgId(CollisionPoly* poly, s32 bgId, CollisionContext* colCtx, Vec3f* dest) { + Vec3s* vtxList; + + if (poly == NULL || bgId > BG_ACTOR_MAX || dest == NULL) { + if (dest != NULL) { + // @bug: dest[2] x and y are not set to 0 + dest[0].x = dest[0].y = dest[0].z = dest[1].x = dest[1].y = dest[1].z = dest[2].z = 0.0f; + } + } else { + if (bgId == BGCHECK_SCENE) { + vtxList = colCtx->colHeader->vtxList; + } else { + vtxList = colCtx->dyna.vtxList; + } + CollisionPoly_GetVertices(poly, vtxList, dest); + } +} + +s32 CollisionPoly_CheckYIntersectApprox1(CollisionPoly* poly, Vec3s* vtxList, f32 x, f32 z, f32* yIntersect, + f32 checkDist) { + f32 nx; + f32 ny; + f32 nz; + Vec3s* vA; + Vec3s* vB; + Vec3s* vC; + + vA = &vtxList[COLPOLY_VTX_INDEX(poly->flags_vIA)]; + Math_Vec3s_ToVec3f(&D_801ED9F0[0], vA); + vB = &vtxList[COLPOLY_VTX_INDEX(poly->flags_vIB)]; + Math_Vec3s_ToVec3f(&D_801ED9F0[1], vB); + vC = &vtxList[poly->vIC]; + Math_Vec3s_ToVec3f(&D_801ED9F0[2], vC); + + nx = COLPOLY_GET_NORMAL(poly->normal.x); + ny = COLPOLY_GET_NORMAL(poly->normal.y); + nz = COLPOLY_GET_NORMAL(poly->normal.z); + + return Math3D_TriChkPointParaYIntersectDist(&D_801ED9F0[0], &D_801ED9F0[1], &D_801ED9F0[2], nx, ny, nz, poly->dist, + z, x, yIntersect, checkDist); +} + +/** + * Checks if point (`x`,`z`) is within `checkDist` of `poly`, computing `yIntersect` if true + * Determinant max 0.0f (checks if on or within poly) + */ +#ifdef NON_MATCHING +s32 CollisionPoly_CheckYIntersect(CollisionPoly* poly, Vec3s* vtxList, f32 x, f32 z, f32* yIntersect, f32 checkDist) { + static Vec3f polyVerts[3]; // D_801EDA18 + Vec3s* sVerts; + f32 nx; + f32 ny; + f32 nz; + + sVerts = &vtxList[COLPOLY_VTX_INDEX(poly->flags_vIA)]; + polyVerts[0].x = sVerts->x; + polyVerts[0].y = sVerts->y; + polyVerts[0].z = sVerts->z; + sVerts = &vtxList[COLPOLY_VTX_INDEX(poly->flags_vIB)]; + polyVerts[1].x = sVerts->x; + polyVerts[1].y = sVerts->y; + polyVerts[1].z = sVerts->z; + sVerts = &vtxList[poly->vIC]; + polyVerts[2].x = sVerts->x; + polyVerts[2].y = sVerts->y; + polyVerts[2].z = sVerts->z; + + if (!func_8017A304(&polyVerts[0], &polyVerts[1], &polyVerts[2], z, x, checkDist)) { + return 0; + } + nx = COLPOLY_GET_NORMAL(poly->normal.x); + ny = COLPOLY_GET_NORMAL(poly->normal.y); + nz = COLPOLY_GET_NORMAL(poly->normal.z); + return Math3D_TriChkPointParaYIntersectInsideTri2(&polyVerts[0], &polyVerts[1], &polyVerts[2], nx, ny, nz, + poly->dist, z, x, yIntersect, checkDist); +} +#else +s32 CollisionPoly_CheckYIntersect(CollisionPoly* poly, Vec3s* vtxList, f32 x, f32 z, f32* yIntersect, f32 checkDist); +#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/CollisionPoly_CheckYIntersect.s") +#endif + +s32 CollisionPoly_CheckYIntersectApprox2(CollisionPoly* poly, Vec3s* vtxList, f32 x, f32 z, f32* yIntersect) { + return CollisionPoly_CheckYIntersectApprox1(poly, vtxList, x, z, yIntersect, 1.0f); +} + +s32 CollisionPoly_CheckXIntersectApprox(CollisionPoly* poly, Vec3s* vtxList, f32 y, f32 z, f32* xIntersect) { + f32 nx; + f32 ny; + f32 nz; + + CollisionPoly_GetVertices(poly, vtxList, D_801EDA80); + CollisionPoly_GetNormalF(poly, &nx, &ny, &nz); + return Math3D_TriChkPointParaXIntersect(&D_801EDA80[0], &D_801EDA80[1], &D_801EDA80[2], nx, ny, nz, poly->dist, y, + z, xIntersect); +} + +s32 CollisionPoly_CheckZIntersectApprox(CollisionPoly* poly, Vec3s* vtxList, f32 x, f32 y, f32* zIntersect) { + f32 nx; + f32 ny; + f32 nz; + + CollisionPoly_GetVertices(poly, vtxList, D_801EDB48); + CollisionPoly_GetNormalF(poly, &nx, &ny, &nz); + return Math3D_TriChkPointParaZIntersect(&D_801EDB48[0], &D_801EDB48[1], &D_801EDB48[2], nx, ny, nz, poly->dist, x, + y, zIntersect); +} + +#ifdef NON_MATCHING +s32 CollisionPoly_LineVsPoly(BgLineVsPolyTest* a0) { + static Vec3f polyVerts[3]; // D_801EDB70 + static Plane plane; // D_801EDB98 + f32 planeDistA; + f32 planeDistB; + f32 planeDistDelta; + + plane.originDist = a0->poly->dist; + planeDistA = COLPOLY_GET_NORMAL(a0->poly->normal.x * a0->posA->x + a0->poly->normal.y * a0->posA->y + + a0->poly->normal.z * a0->posA->z) + + plane.originDist; + planeDistB = COLPOLY_GET_NORMAL(a0->poly->normal.x * a0->posB->x + a0->poly->normal.y * a0->posB->y + + a0->poly->normal.z * a0->posB->z) + + plane.originDist; + + planeDistDelta = planeDistA - planeDistB; + if ((planeDistA >= 0.0f && planeDistB >= 0.0f) || (planeDistA < 0.0f && planeDistB < 0.0f) || + ((a0->checkOneFace != 0) && (planeDistA < 0.0f && planeDistB > 0.0f)) || IS_ZERO(planeDistDelta)) { + return false; + } + + CollisionPoly_GetNormalF(a0->poly, &plane.normal.x, &plane.normal.y, &plane.normal.z); + CollisionPoly_GetVertices(a0->poly, a0->vtxList, polyVerts); + Math3D_Lerp(a0->posA, a0->posB, planeDistA / planeDistDelta, a0->planeIntersect); + + if ((fabsf(plane.normal.x) > 0.5f && + Math3D_TriChkPointParaXDist(&polyVerts[0], &polyVerts[1], &polyVerts[2], a0->planeIntersect->y, + a0->planeIntersect->z, 0.0f, a0->checkDist, plane.normal.x)) || + (fabsf(plane.normal.y) > 0.5f && + Math3D_TriChkPointParaYDist(&polyVerts[0], &polyVerts[1], &polyVerts[2], a0->planeIntersect->z, + a0->planeIntersect->x, 0.0f, a0->checkDist, plane.normal.y)) || + (fabsf(plane.normal.z) > 0.5f && + Math3D_TriChkLineSegParaZDist(&polyVerts[0], &polyVerts[1], &polyVerts[2], a0->planeIntersect->x, + a0->planeIntersect->y, 0.0f, a0->checkDist, plane.normal.z))) { + return true; + } + return false; +} +#else +s32 CollisionPoly_LineVsPoly(BgLineVsPolyTest* a0); +#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/CollisionPoly_LineVsPoly.s") +#endif + +#ifdef NON_MATCHING +// OK but .bss order issues +s32 CollisionPoly_SphVsPoly(CollisionPoly* poly, Vec3s* vtxList, Vec3f* center, f32 radius) { + static Sphere16 sphere; // D_801EDBA8 + static TriNorm tri; // D_801EDBB0 + Vec3f intersect; + + CollisionPoly_GetVertices(poly, vtxList, tri.vtx); + CollisionPoly_GetNormalF(poly, &tri.plane.normal.x, &tri.plane.normal.y, &tri.plane.normal.z); + tri.plane.originDist = poly->dist; + sphere.center.x = center->x; + sphere.center.y = center->y; + sphere.center.z = center->z; + sphere.radius = radius; + return Math3D_ColSphereTri(&sphere, &tri, &intersect); +} +#else +s32 CollisionPoly_SphVsPoly(CollisionPoly* poly, Vec3s* vtxList, Vec3f* center, f32 radius); +#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/CollisionPoly_SphVsPoly.s") +#endif + +#ifdef NON_MATCHING +/** + * Add poly to StaticLookup table + * Table is sorted by poly's smallest y vertex component + * `ssList` is the list to append a new poly to + * `polyList` is the CollisionPoly lookup list + * `vtxList` is the vertex lookup list + * `polyId` is the index of the poly in polyList to insert into the lookup table + */ +void StaticLookup_AddPolyToSSList(CollisionContext* colCtx, SSList* ssList, CollisionPoly* polyList, Vec3s* vtxList, + s16 polyId) { + SSNode* curNode; + SSNode* nextNode; + s32 polyYMin; + u16 newNodeId; + s16 curPolyId; + + // if list is null + if (ssList->head == SS_NULL) { + SSNodeList_SetSSListHead(&colCtx->polyNodes, ssList, &polyId); + return; + } + + polyYMin = CollisionPoly_GetMinY(&polyList[polyId], vtxList); + + curNode = &colCtx->polyNodes.tbl[ssList->head]; + curPolyId = curNode->polyId; + + // if the poly being inserted has a lower y than the first poly + if (polyYMin < vtxList[COLPOLY_VTX_INDEX(polyList[curPolyId].flags_vIA)].y && + polyYMin < vtxList[COLPOLY_VTX_INDEX(polyList[curPolyId].flags_vIB)].y && + polyYMin < vtxList[polyList[curPolyId].vIC].y) { + SSNodeList_SetSSListHead(&colCtx->polyNodes, ssList, &polyId); + return; + } + while (true) { + // if at the end of the list + if (curNode->next == SS_NULL) { + newNodeId = SSNodeList_GetNextNodeIdx(&colCtx->polyNodes); + SSNode_SetValue(&colCtx->polyNodes.tbl[newNodeId], &polyId, SS_NULL); + curNode->next = newNodeId; + break; + } + + nextNode = &colCtx->polyNodes.tbl[curNode->next]; + curPolyId = nextNode->polyId; + + // if the poly being inserted is lower than the next poly + if (polyYMin < vtxList[COLPOLY_VTX_INDEX(polyList[curPolyId].flags_vIA)].y && + polyYMin < vtxList[COLPOLY_VTX_INDEX(polyList[curPolyId].flags_vIB)].y && + polyYMin < vtxList[polyList[curPolyId].vIC].y) { + newNodeId = SSNodeList_GetNextNodeIdx(&colCtx->polyNodes); + SSNode_SetValue(&colCtx->polyNodes.tbl[newNodeId], &polyId, curNode->next); + curNode->next = newNodeId; + break; + } + curNode = nextNode; + } +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/StaticLookup_AddPolyToSSList.s") +#endif + +/** + * Add CollisionPoly to StaticLookup list + */ +void StaticLookup_AddPoly(StaticLookup* lookup, CollisionContext* colCtx, CollisionPoly* polyList, Vec3s* vtxList, + s16 index) { + if (polyList[index].normal.y > COLPOLY_SNORMAL(0.5f)) { + StaticLookup_AddPolyToSSList(colCtx, &lookup->floor, polyList, vtxList, index); + } else if (polyList[index].normal.y < COLPOLY_SNORMAL(-0.8f)) { + StaticLookup_AddPolyToSSList(colCtx, &lookup->ceiling, polyList, vtxList, index); + } else { + StaticLookup_AddPolyToSSList(colCtx, &lookup->wall, polyList, vtxList, index); + } +} + +/** + * Locates the closest static poly directly underneath `pos`, starting at list `ssList` + * returns yIntersect of the closest poly, or `yIntersectMin` + * stores the pointer of the closest poly to `outPoly` + * if (flags & 1), ignore polys with a normal.y < 0 (from vertical walls to ceilings) + */ +f32 BgCheck_RaycastFloorStaticList(CollisionContext* colCtx, u16 xpFlags, SSList* ssList, CollisionPoly** outPoly, + Vec3f* pos, f32 yIntersectMin, f32 checkDist, s32 flags, Actor* actor, s32 arg9) { + SSNode* curNode; + s32 polyId; + f32 result; + f32 yIntersect; + CollisionPoly* colPoly; + s32 pad; + + result = yIntersectMin; + if (ssList->head == SS_NULL) { + return result; + } + + curNode = &colCtx->polyNodes.tbl[ssList->head]; + + while (true) { + polyId = curNode->polyId; + colPoly = &colCtx->colHeader->polyList[polyId]; + + if (((flags & 1) && (colPoly->normal.y < 0)) || + ((arg9 & 0x20) && ((colCtx->colHeader->surfaceTypeList[colPoly->type].data[0] >> 0x1E) & 1)) || + COLPOLY_VIA_FLAG_TEST(colPoly->flags_vIA, xpFlags) || + (COLPOLY_VIA_FLAG_TEST(colPoly->flags_vIB, 4) && ((actor != NULL && actor->category != ACTORCAT_PLAYER) || + (actor == NULL && xpFlags != COLPOLY_IGNORE_CAMERA)))) { + if (curNode->next == SS_NULL) { + break; + } + curNode = &colCtx->polyNodes.tbl[curNode->next]; + continue; + } + + if (pos->y < colCtx->colHeader->vtxList[COLPOLY_VTX_INDEX(colPoly->flags_vIA)].y && + pos->y < colCtx->colHeader->vtxList[COLPOLY_VTX_INDEX(colPoly->flags_vIB)].y && + pos->y < colCtx->colHeader->vtxList[colPoly->vIC].y) { + break; + } + + if (CollisionPoly_CheckYIntersect(colPoly, colCtx->colHeader->vtxList, pos->x, pos->z, &yIntersect, + checkDist)) { + // if poly is closer to pos without going over + if (yIntersect < pos->y && result < yIntersect) { + result = yIntersect; + *outPoly = colPoly; + } + } + + if (curNode->next == SS_NULL) { + break; + } + curNode = &colCtx->polyNodes.tbl[curNode->next]; + } + return result; +} + +/** + * Locates the closest static poly directly underneath `pos` within `lookup`. + * returns yIntersect of the closest poly, or `yIntersectMin` + * stores the pointer of the closest poly to `outPoly` + */ +f32 BgCheck_RaycastFloorStatic(StaticLookup* lookup, CollisionContext* colCtx, u16 xpFlags, CollisionPoly** poly, + Vec3f* pos, u32 arg5, f32 checkDist, f32 yIntersectMin, Actor* actor) { + s32 flag; // skip polys with normal.y < 0 + f32 yIntersect = yIntersectMin; + + if (arg5 & 4) { + yIntersect = BgCheck_RaycastFloorStaticList(colCtx, xpFlags, &lookup->floor, poly, pos, yIntersect, checkDist, + 0, actor, arg5); + } + + if ((arg5 & 2) || (arg5 & 8)) { + flag = 0; + if (arg5 & 0x10) { + flag = 1; + } + yIntersect = BgCheck_RaycastFloorStaticList(colCtx, xpFlags, &lookup->wall, poly, pos, yIntersect, checkDist, + flag, actor, arg5); + } + + if (arg5 & 1) { + flag = 0; + if (arg5 & 0x10) { + flag = 1; + } + yIntersect = BgCheck_RaycastFloorStaticList(colCtx, xpFlags, &lookup->ceiling, poly, pos, yIntersect, checkDist, + flag, actor, arg5); + } + + return yIntersect; +} + +/** + * Compute wall displacement on `posX` and `posZ` + * sets `wallPolyPtr` to `poly` if `wallPolyPtr` is NULL + * returns true if `wallPolyPtr` was changed + * `invXZlength` is 1 / sqrt( sq(poly.normal.x) + sq(poly.normal.z) ) + */ +s32 BgCheck_ComputeWallDisplacement(CollisionContext* colCtx, CollisionPoly* poly, f32* posX, f32* posZ, f32 nx, f32 ny, + f32 nz, f32 invXZlength, f32 planeDist, f32 radius, CollisionPoly** wallPolyPtr) { + f32 displacement = (radius - planeDist) * invXZlength; + + *posX += displacement * nx; + *posZ += displacement * nz; + + if (*wallPolyPtr == NULL) { + *wallPolyPtr = poly; + return true; + } else { + return false; + } +} + +/** + * Performs collision detection on static poly walls within `lookup` on sphere `pos`, `radius` + * returns true if a collision was detected + * `outX` `outZ` return the displaced x,z coordinates, + * `outPoly` returns the pointer to the nearest poly collided with, or NULL + */ +s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16 xpFlags, f32* outX, f32* outZ, + Vec3f* pos, f32 radius, CollisionPoly** outPoly, Actor* actor) { + Vec3f resultPos; + f32 zTemp; + f32 xTemp; + f32 planeDist; + f32 intersect; + s32 result; + CollisionPoly* curPoly; + CollisionPoly* polyList; + SSNode* curNode; + f32 invNormalXZ; + Vec3s* vtxA; + Vec3s* vtxB; + Vec3s* vtxC; + s32 polyId; + f32 normalXZ; + f32 nx; + f32 ny; + f32 nz; + Vec3s* vtxList; + u16 pad; + f32 temp_f16; + f32 zMin; + f32 zMax; + f32 xMin; + f32 xMax; + + result = false; + if (lookup->wall.head == SS_NULL) { + return result; + } + resultPos = *pos; + + polyList = colCtx->colHeader->polyList; + vtxList = colCtx->colHeader->vtxList; + curNode = &colCtx->polyNodes.tbl[lookup->wall.head]; + + while (true) { + polyId = curNode->polyId; + curPoly = &polyList[polyId]; + vtxA = &vtxList[COLPOLY_VTX_INDEX(curPoly->flags_vIA)]; + vtxB = &vtxList[COLPOLY_VTX_INDEX(curPoly->flags_vIB)]; + vtxC = &vtxList[curPoly->vIC]; + + if (pos->y < vtxA->y && pos->y < vtxB->y && pos->y < vtxC->y) { + break; + } + + nx = COLPOLY_GET_NORMAL(curPoly->normal.x); + ny = COLPOLY_GET_NORMAL(curPoly->normal.y); + nz = COLPOLY_GET_NORMAL(curPoly->normal.z); + normalXZ = sqrtf(SQ(nx) + SQ(nz)); + planeDist = Math3D_DistPlaneToPos(nx, ny, nz, curPoly->dist, &resultPos); + if (radius < fabsf(planeDist) || COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIA, xpFlags) || + (COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIB, 4) && ((actor != NULL && actor->category != ACTORCAT_PLAYER) || + (actor == NULL && xpFlags != COLPOLY_IGNORE_CAMERA)))) { + if (curNode->next == SS_NULL) { + break; + } else { + curNode = &colCtx->polyNodes.tbl[curNode->next]; + continue; + } + } + + invNormalXZ = 1.0f / normalXZ; + temp_f16 = fabsf(nz) * invNormalXZ; + if (temp_f16 < 0.4f) { + if (curNode->next == SS_NULL) { + break; + } else { + curNode = &colCtx->polyNodes.tbl[curNode->next]; + continue; + } + } + + // compute curPoly zMin/zMax + zTemp = vtxA->z; + zMax = zMin = zTemp; + zTemp = vtxB->z; + + if (zTemp < zMin) { + zMin = zTemp; + } else if (zMax < zTemp) { + zMax = zTemp; + } + zTemp = vtxC->z; + if (zTemp < zMin) { + zMin = zTemp; + } else if (zTemp > zMax) { + zMax = zTemp; + } + + zMin -= radius; + zMax += radius; + + if (resultPos.z < zMin || resultPos.z > zMax) { + if (curNode->next == SS_NULL) { + break; + } else { + curNode = &colCtx->polyNodes.tbl[curNode->next]; + continue; + } + } + if (CollisionPoly_CheckZIntersectApprox(curPoly, vtxList, resultPos.x, pos->y, &intersect)) { + f32 test = intersect - resultPos.z; + + if (fabsf(test) <= radius / temp_f16) { + if (test * nz <= 4.0f) { + if (BgCheck_ComputeWallDisplacement(colCtx, curPoly, &resultPos.x, &resultPos.z, nx, ny, nz, + invNormalXZ, planeDist, radius, outPoly)) { + result = true; + } + } + } + } + if (curNode->next == SS_NULL) { + break; + } else { + curNode = &colCtx->polyNodes.tbl[curNode->next]; + } + } + + curNode = &colCtx->polyNodes.tbl[lookup->wall.head]; + + while (true) { + polyId = curNode->polyId; + curPoly = &polyList[polyId]; + vtxA = &vtxList[COLPOLY_VTX_INDEX(curPoly->flags_vIA)]; + vtxB = &vtxList[COLPOLY_VTX_INDEX(curPoly->flags_vIB)]; + vtxC = &vtxList[curPoly->vIC]; + + if (pos->y < vtxA->y && pos->y < vtxB->y && pos->y < vtxC->y) { + break; + } + + nx = COLPOLY_GET_NORMAL(curPoly->normal.x); + ny = COLPOLY_GET_NORMAL(curPoly->normal.y); + nz = COLPOLY_GET_NORMAL(curPoly->normal.z); + normalXZ = sqrtf(SQ(nx) + SQ(nz)); + planeDist = Math3D_DistPlaneToPos(nx, ny, nz, curPoly->dist, &resultPos); + if (radius < fabsf(planeDist) || COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIA, xpFlags) || + (COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIB, 4) && ((actor != NULL && actor->category != ACTORCAT_PLAYER) || + (actor == NULL && xpFlags != COLPOLY_IGNORE_CAMERA)))) { + if (curNode->next == SS_NULL) { + break; + } else { + curNode = &colCtx->polyNodes.tbl[curNode->next]; + continue; + } + } + + invNormalXZ = 1.0f / normalXZ; + temp_f16 = fabsf(nx) * invNormalXZ; + if (temp_f16 < 0.4f) { + if (curNode->next == SS_NULL) { + break; + } else { + curNode = &colCtx->polyNodes.tbl[curNode->next]; + continue; + } + } + + // compute curPoly xMin/xMax + xTemp = vtxA->x; + xMax = xMin = xTemp; + xTemp = vtxB->x; + + if (xTemp < xMin) { + xMin = xTemp; + } else if (xMax < xTemp) { + xMax = xTemp; + } + xTemp = vtxC->x; + if (xTemp < xMin) { + xMin = xTemp; + } else if (xMax < xTemp) { + xMax = xTemp; + } + + xMin -= radius; + xMax += radius; + + if (resultPos.x < xMin || xMax < resultPos.x) { + if (curNode->next == SS_NULL) { + break; + } else { + curNode = &colCtx->polyNodes.tbl[curNode->next]; + continue; + } + } + if (CollisionPoly_CheckXIntersectApprox(curPoly, vtxList, pos->y, resultPos.z, &intersect)) { + f32 test = intersect - resultPos.x; + + if (fabsf(test) <= radius / temp_f16) { + if (test * nx <= 4.0f) { + if (BgCheck_ComputeWallDisplacement(colCtx, curPoly, &resultPos.x, &resultPos.z, nx, ny, nz, + invNormalXZ, planeDist, radius, outPoly)) { + result = true; + } + } + } + } + if (curNode->next == SS_NULL) { + break; + } else { + curNode = &colCtx->polyNodes.tbl[curNode->next]; + continue; + } + } + + *outX = resultPos.x; + *outZ = resultPos.z; + return result; +} + +/** + * Tests for collision with a static poly ceiling + * returns true if a collision occurs, else false + * `outPoly` returns the poly collided with + * `outY` returns the y coordinate needed to not collide with `outPoly` + */ +#ifdef NON_MATCHING +s32 BgCheck_CheckStaticCeiling(StaticLookup* lookup, u16 xpFlags, CollisionContext* colCtx, f32* outY, Vec3f* pos, + f32 checkHeight, CollisionPoly** outPoly, Actor* actor) { + s32 result = false; + // u16 nextId; + CollisionPoly* curPoly; + CollisionPoly* polyList; + f32 ceilingY; + Vec3s* vtxList; + SSNode* curNode; + s32 curPolyId; + + if (lookup->ceiling.head == SS_NULL) { + return result; + } + curNode = &colCtx->polyNodes.tbl[lookup->ceiling.head]; + polyList = colCtx->colHeader->polyList; + vtxList = colCtx->colHeader->vtxList; + + *outY = pos->y; + + while (true) { + curPolyId = curNode->polyId; + curPoly = &polyList[curPolyId]; + if (COLPOLY_VIA_FLAG_TEST(colCtx->colHeader->polyList[curPolyId].flags_vIA, xpFlags) || + (COLPOLY_VIA_FLAG_TEST(colCtx->colHeader->polyList[curPolyId].flags_vIB, 4) && + ((actor != NULL && actor->category != ACTORCAT_PLAYER) || + (actor == NULL && xpFlags != COLPOLY_IGNORE_CAMERA)))) { + if (curNode->next == SS_NULL) { + break; + } else { + curNode = &colCtx->polyNodes.tbl[curNode->next]; + continue; + } + } + + if (CollisionPoly_CheckYIntersectApprox2(curPoly, vtxList, pos->x, pos->z, &ceilingY)) { + f32 intersectDist = ceilingY - *outY; + f32 ny = COLPOLY_GET_NORMAL(curPoly->normal.y); + + if (intersectDist > 0 && intersectDist < checkHeight && intersectDist * ny <= 0) { + *outY = ceilingY - checkHeight; + *outPoly = curPoly; + result = true; + } + } + if (curNode->next == SS_NULL) { + break; + } else { + curNode = &colCtx->polyNodes.tbl[curNode->next]; + continue; + } + } + return result; +} +#else +s32 BgCheck_CheckStaticCeiling(StaticLookup* lookup, u16 xpFlags, CollisionContext* colCtx, f32* outY, Vec3f* pos, + f32 checkHeight, CollisionPoly** outPoly, Actor* actor); +#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_CheckStaticCeiling.s") +#endif + +/** + * Tests if line `posA` to `posB` intersects with a static poly in list `ssList`. Uses polyCheckTbl + * returns true if such a poly exists, else false + * `outPoly` returns the pointer of the poly intersected + * `posB` and `outPos` returns the point of intersection with `outPoly` + * `outDistSq` returns the squared distance from `posA` to the point of intersect + */ +#ifdef NON_MATCHING +s32 BgCheck_CheckLineAgainstSSList(StaticLineTest* arg0) { + CollisionContext* colCtx; + s32 result; + Vec3f polyIntersect; // sp7C + SSNode* curNode; + u8* checkedPoly; + f32 minY; + f32 distSq; + BgLineVsPolyTest test; // sp50 + s16 polyId; + CollisionPoly* polyList; + + result = false; + if (arg0->ssList->head == SS_NULL) { + return result; + } + colCtx = arg0->colCtx; + curNode = &colCtx->polyNodes.tbl[arg0->ssList->head]; + polyList = colCtx->colHeader->polyList; + test.vtxList = colCtx->colHeader->vtxList; + test.posA = arg0->posA; + test.posB = arg0->posB; + test.planeIntersect = &polyIntersect; // reorder maybe + test.checkOneFace = (arg0->bccFlags & BGCHECK_CHECK_ONE_FACE) != 0; + test.checkDist = arg0->checkDist; + + while (true) { + polyId = curNode->polyId; + test.poly = &polyList[polyId]; + checkedPoly = &arg0->colCtx->polyNodes.polyCheckTbl[polyId]; + + if (*checkedPoly == true || + (arg0->xpFlags2 != 0 && !COLPOLY_VIA_FLAG_TEST(test.poly->flags_vIA, arg0->xpFlags2)) || + COLPOLY_VIA_FLAG_TEST(test.poly->flags_vIA, arg0->xpFlags1) || + (COLPOLY_VIA_FLAG_TEST(test.poly->flags_vIB, 4) && + ((arg0->actor != NULL && arg0->actor->category != ACTORCAT_PLAYER) || + (arg0->actor == NULL && arg0->xpFlags1 != COLPOLY_IGNORE_CAMERA)))) { + if (curNode->next == SS_NULL) { + break; + } else { + curNode = &colCtx->polyNodes.tbl[curNode->next]; + continue; + } + } + *checkedPoly = true; + minY = CollisionPoly_GetMinY(test.poly, test.vtxList); + if (test.posA->y < minY && test.posB->y < minY) { + break; + } + if (CollisionPoly_LineVsPoly(&test)) { + distSq = Math3D_Vec3fDistSq(test.posA, test.planeIntersect); + if (distSq < arg0->outDistSq) { + arg0->outDistSq = distSq; + *arg0->outPos = *test.planeIntersect; + *arg0->posB = *test.planeIntersect; + *arg0->outPoly = test.poly; + result = true; + } + } + if (curNode->next == SS_NULL) { + break; + } + curNode = &arg0->colCtx->polyNodes.tbl[curNode->next]; + } + return result; +} +#else +s32 BgCheck_CheckLineAgainstSSList(StaticLineTest* arg0); +#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_CheckLineAgainstSSList.s") +#endif + +/** + * Tests if line `posA` to `posB` intersects with a static poly in `lookup`. Uses polyCheckTbl + * returns true if such a poly exists, else false + * `outPoly` returns the pointer of the poly intersected + * `posB` and `outPos` returns the point of intersection with `outPoly` + * `outDistSq` returns the squared distance from `posA` to the point of intersect + */ +s32 BgCheck_CheckLineInSubdivision(StaticLineTest* arg0) { + s32 result = false; + + if ((arg0->bccFlags & BGCHECK_CHECK_FLOOR) && arg0->lookup->floor.head != SS_NULL) { + arg0->ssList = &arg0->lookup->floor; + if (BgCheck_CheckLineAgainstSSList(arg0)) { + result = true; + } + } + + if ((arg0->bccFlags & BGCHECK_CHECK_WALL) && arg0->lookup->wall.head != SS_NULL) { + arg0->ssList = &arg0->lookup->wall; + if (BgCheck_CheckLineAgainstSSList(arg0)) { + result = true; + } + } + + if ((arg0->bccFlags & BGCHECK_CHECK_CEILING) && arg0->lookup->ceiling.head != SS_NULL) { + arg0->ssList = &arg0->lookup->ceiling; + if (BgCheck_CheckLineAgainstSSList(arg0)) { + result = true; + } + } + return result; +} + +/** + * Get first static poly intersecting sphere `center` `radius` from list `node` + * returns true if any poly intersects the sphere, else returns false + * `outPoly` returns the pointer of the first poly found that intersects + */ +#ifdef NON_MATCHING +s32 BgCheck_SphVsFirstStaticPolyList(SSNode* node, u16 xpFlags, CollisionContext* colCtx, Vec3f* center, f32 radius, + CollisionPoly** outPoly, Actor* actor) { + Vec3s* vtxList; + CollisionPoly* polyList; + CollisionPoly* curPoly; + u16 nextId; + s16 curPolyId; + s32 pad; + + polyList = colCtx->colHeader->polyList; + vtxList = colCtx->colHeader->vtxList; + + while (true) { + curPolyId = node->polyId; + curPoly = &polyList[curPolyId]; + if (COLPOLY_VIA_FLAG_TEST(colCtx->colHeader->polyList[curPolyId].flags_vIA, xpFlags) || + (COLPOLY_VIA_FLAG_TEST(colCtx->colHeader->polyList[curPolyId].flags_vIB, 4) && + ((actor != NULL && actor->category != ACTORCAT_PLAYER) || + (actor == NULL && xpFlags != COLPOLY_IGNORE_CAMERA)))) { + if (node->next != SS_NULL) { + node = &colCtx->polyNodes.tbl[node->next]; + continue; + } + break; + } + + if (center->y + radius < vtxList[COLPOLY_VTX_INDEX(curPoly->flags_vIA)].y && + center->y + radius < vtxList[COLPOLY_VTX_INDEX(curPoly->flags_vIB)].y && + center->y + radius < vtxList[curPoly->vIC].y) { + break; + } + + if (CollisionPoly_SphVsPoly(curPoly, vtxList, center, radius)) { + *outPoly = curPoly; + return true; + } + if (node->next != SS_NULL) { + node = &colCtx->polyNodes.tbl[node->next]; + continue; + } + break; + } + return false; +} +#else +s32 BgCheck_SphVsFirstStaticPolyList(SSNode* node, u16 xpFlags, CollisionContext* colCtx, Vec3f* center, f32 radius, + CollisionPoly** outPoly, Actor* actor); +#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_SphVsFirstStaticPolyList.s") +#endif + +/** + * Get first static poly intersecting sphere `center` `radius` within `lookup` + * returns true if any poly intersects the sphere, else false + * `outPoly` returns the first poly found that intersects + */ +s32 BgCheck_SphVsFirstStaticPoly(StaticLookup* lookup, u16 xpFlags, CollisionContext* colCtx, Vec3f* center, f32 radius, + CollisionPoly** outPoly, u16 bciFlags, Actor* actor) { + if (lookup->floor.head != SS_NULL && !(bciFlags & BGCHECK_IGNORE_FLOOR) && + BgCheck_SphVsFirstStaticPolyList(&colCtx->polyNodes.tbl[lookup->floor.head], xpFlags, colCtx, center, radius, + outPoly, actor)) { + return true; + } + + if (lookup->wall.head != SS_NULL && !(bciFlags & BGCHECK_IGNORE_WALL) && + BgCheck_SphVsFirstStaticPolyList(&colCtx->polyNodes.tbl[lookup->wall.head], xpFlags, colCtx, center, radius, + outPoly, actor)) { + return true; + } + + if (lookup->ceiling.head != SS_NULL && !(bciFlags & BGCHECK_IGNORE_CEILING) && + BgCheck_SphVsFirstStaticPolyList(&colCtx->polyNodes.tbl[lookup->ceiling.head], xpFlags, colCtx, center, radius, + outPoly, actor)) { + return true; + } + + return false; +} + +/** + * Get StaticLookup from `pos` + * Does not return NULL + */ +StaticLookup* BgCheck_GetNearestStaticLookup(CollisionContext* colCtx, StaticLookup* lookupTbl, Vec3f* pos) { + Vec3i sector; + s32 subdivAmountX; + + BgCheck_GetStaticLookupIndicesFromPos(colCtx, pos, §or); + subdivAmountX = colCtx->subdivAmount.x; + return (sector.z * subdivAmountX) * colCtx->subdivAmount.y + lookupTbl + sector.x + sector.y * subdivAmountX; +} + +/** + * Get StaticLookup from `pos` + * Returns NULL if just outside the mesh bounding box + */ +StaticLookup* BgCheck_GetStaticLookup(CollisionContext* colCtx, StaticLookup* lookupTbl, Vec3f* pos) { + Vec3i sector; + s32 subdivAmountX; + + if (!BgCheck_PosInStaticBoundingBox(colCtx, pos)) { + return NULL; + } + BgCheck_GetStaticLookupIndicesFromPos(colCtx, pos, §or); + subdivAmountX = colCtx->subdivAmount.x; + return (sector.z * subdivAmountX) * colCtx->subdivAmount.y + lookupTbl + sector.x + sector.y * subdivAmountX; +} + +/** + * Get StaticLookup subdivision indices from `pos` + * `sector` returns the subdivision x,y,z indices containing or is nearest to `pos` + */ +void BgCheck_GetStaticLookupIndicesFromPos(CollisionContext* colCtx, Vec3f* pos, Vec3i* sector) { + sector->x = (pos->x - colCtx->minBounds.x) * colCtx->subdivLengthInv.x; + sector->y = (pos->y - colCtx->minBounds.y) * colCtx->subdivLengthInv.y; + sector->z = (pos->z - colCtx->minBounds.z) * colCtx->subdivLengthInv.z; + + if (sector->x < 0) { + sector->x = 0; + } else if (sector->x >= colCtx->subdivAmount.x) { + sector->x = colCtx->subdivAmount.x - 1; + } + + if (sector->y < 0) { + sector->y = 0; + } else if (sector->y >= colCtx->subdivAmount.y) { + sector->y = colCtx->subdivAmount.y - 1; + } + + if (sector->z < 0) { + sector->z = 0; + } else if (sector->z >= colCtx->subdivAmount.z) { + sector->z = colCtx->subdivAmount.z - 1; + } +} + +/** + * Get negative bias subdivision indices + * decrements indices if `pos` is within BGCHECK_SUBDIV_OVERLAP units of the negative subdivision boundary + * `sx`, `sy`, `sz` returns the subdivision x, y, z indices + */ +void BgCheck_GetSubdivisionMinBounds(CollisionContext* colCtx, Vec3f* pos, s32* sx, s32* sy, s32* sz) { + f32 dx = pos->x - colCtx->minBounds.x; + f32 dy = pos->y - colCtx->minBounds.y; + f32 dz = pos->z - colCtx->minBounds.z; + + *sx = dx * colCtx->subdivLengthInv.x; + *sy = dy * colCtx->subdivLengthInv.y; + *sz = dz * colCtx->subdivLengthInv.z; + + if (((s32)dx % (s32)colCtx->subdivLength.x < BGCHECK_SUBDIV_OVERLAP) && (*sx > 0)) { + *sx -= 1; + } + + if (((s32)dy % (s32)colCtx->subdivLength.y < BGCHECK_SUBDIV_OVERLAP) && (*sy > 0)) { + *sy -= 1; + } + + if (((s32)dz % (s32)colCtx->subdivLength.z < BGCHECK_SUBDIV_OVERLAP) && (*sz > 0)) { + *sz -= 1; + } +} + +/** + * Get positive bias subdivision indices + * increments indicies if `pos` is within BGCHECK_SUBDIV_OVERLAP units of the postive subdivision boundary + * `sx`, `sy`, `sz` returns the subdivision x, y, z indices + */ +void BgCheck_GetSubdivisionMaxBounds(CollisionContext* colCtx, Vec3f* pos, s32* sx, s32* sy, s32* sz) { + f32 dx = pos->x - colCtx->minBounds.x; + f32 dy = pos->y - colCtx->minBounds.y; + f32 dz = pos->z - colCtx->minBounds.z; + + *sx = dx * colCtx->subdivLengthInv.x; + *sy = dy * colCtx->subdivLengthInv.y; + *sz = dz * colCtx->subdivLengthInv.z; + + if (((s32)colCtx->subdivLength.x - BGCHECK_SUBDIV_OVERLAP < (s32)dx % (s32)colCtx->subdivLength.x) && + (*sx < colCtx->subdivAmount.x - 1)) { + *sx += 1; + } + + if (((s32)colCtx->subdivLength.y - BGCHECK_SUBDIV_OVERLAP < (s32)dy % (s32)colCtx->subdivLength.y) && + (*sy < colCtx->subdivAmount.y - 1)) { + *sy += 1; + } + + if (((s32)colCtx->subdivLength.z - BGCHECK_SUBDIV_OVERLAP < (s32)dz % (s32)colCtx->subdivLength.z) && + (*sz < colCtx->subdivAmount.z - 1)) { + *sz += 1; + } +} + +/** + * Calculate the subdivision index bounding box for CollisionPoly `polyId` + * `subdivMinX`, `subdivMinY`, `subdivMinZ` returns the minimum subdivision x, y, z indices + * `subdivMaxX`, `subdivMaxY`, `subdivMaxZ` returns the maximum subdivision x, y, z indices + */ +void BgCheck_GetPolySubdivisionBounds(CollisionContext* colCtx, Vec3s* vtxList, CollisionPoly* polyList, + s32* subdivMinX, s32* subdivMinY, s32* subdivMinZ, s32* subdivMaxX, + s32* subdivMaxY, s32* subdivMaxZ, s16 polyId) { + u16* vtxDataTemp; + Vec3f minVtx; + Vec3f maxVtx; + + f32 x; + f32 y; + f32 z; + + Vec3s* vtx; + s16 vtxId = COLPOLY_VTX_INDEX(polyList[polyId].vtxData[0]); + + Math_Vec3s_ToVec3f(&maxVtx, &vtxList[vtxId]); + Math_Vec3f_Copy(&minVtx, &maxVtx); + + for (vtxDataTemp = polyList[polyId].vtxData + 1; vtxDataTemp < polyList[polyId].vtxData + 3; vtxDataTemp++) { + vtxId = COLPOLY_VTX_INDEX(*vtxDataTemp); + vtx = &vtxList[vtxId]; + x = vtx->x; + y = vtx->y; + z = vtx->z; + + if (minVtx.x > x) { + minVtx.x = x; + } else if (maxVtx.x < x) { + maxVtx.x = x; + } + + if (minVtx.y > y) { + minVtx.y = y; + } else if (maxVtx.y < y) { + maxVtx.y = y; + } + + if (minVtx.z > z) { + minVtx.z = z; + } else if (maxVtx.z < z) { + maxVtx.z = z; + } + } + BgCheck_GetSubdivisionMinBounds(colCtx, &minVtx, subdivMinX, subdivMinY, subdivMinZ); + BgCheck_GetSubdivisionMaxBounds(colCtx, &maxVtx, subdivMaxX, subdivMaxY, subdivMaxZ); +} + +/** + * Test if poly `polyList`[`polyId`] intersects cube `min` `max` + * returns true if the poly intersects the cube, else false + */ +s32 BgCheck_PolyIntersectsSubdivision(Vec3f* min, Vec3f* max, CollisionPoly* polyList, Vec3s* vtxList, s16 polyId) { + f32 intersect; + Vec3f va2; + Vec3f vb2; + Vec3f vc2; + CollisionPoly* poly; + f32 nx; + f32 ny; + f32 nz; + f32 dist; + Vec3f va; + Vec3f vb; + Vec3f vc; + s32 flags[3]; + + flags[0] = flags[1] = 0; + poly = &polyList[polyId]; + + BgCheck_Vec3sToVec3f(&vtxList[COLPOLY_VTX_INDEX(poly->flags_vIA)], &va); + flags[0] = Math3D_PointRelativeToCubeFaces(&va, min, max); + if (flags[0] == 0) { + return true; + } + + BgCheck_Vec3sToVec3f(&vtxList[COLPOLY_VTX_INDEX(poly->flags_vIB)], &vb); + flags[1] = Math3D_PointRelativeToCubeFaces(&vb, min, max); + if (flags[1] == 0) { + return true; + } + + BgCheck_Vec3sToVec3f(&vtxList[poly->vIC], &vc); + flags[2] = Math3D_PointRelativeToCubeFaces(&vc, min, max); + if (flags[2] == 0) { + return true; + } + + if (flags[0] & flags[1] & flags[2]) { + return false; + } + + flags[0] |= Math3D_PointRelativeToCubeEdges(&va, min, max) << 8; + flags[1] |= Math3D_PointRelativeToCubeEdges(&vb, min, max) << 8; + flags[2] |= Math3D_PointRelativeToCubeEdges(&vc, min, max) << 8; + if (flags[0] & flags[1] & flags[2]) { + return false; + } + + flags[0] |= Math3D_PointRelativeToCubeVertices(&va, min, max) << 0x18; + flags[1] |= Math3D_PointRelativeToCubeVertices(&vb, min, max) << 0x18; + flags[2] |= Math3D_PointRelativeToCubeVertices(&vc, min, max) << 0x18; + if (flags[0] & flags[1] & flags[2]) { + return false; + } + + CollisionPoly_GetNormalF(poly, &nx, &ny, &nz); + dist = poly->dist; + + if (Math3D_TriChkLineSegParaYIntersect(&va, &vb, &vc, nx, ny, nz, dist, min->z, min->x, &intersect, min->y, + max->y) || + Math3D_TriChkLineSegParaYIntersect(&va, &vb, &vc, nx, ny, nz, dist, max->z, min->x, &intersect, min->y, + max->y) || + Math3D_TriChkLineSegParaYIntersect(&va, &vb, &vc, nx, ny, nz, dist, min->z, max->x, &intersect, min->y, + max->y) || + Math3D_TriChkLineSegParaYIntersect(&va, &vb, &vc, nx, ny, nz, dist, max->z, max->x, &intersect, min->y, + max->y)) { + return true; + } + if (Math3D_TriChkLineSegParaZIntersect(&va, &vb, &vc, nx, ny, nz, dist, min->x, min->y, &intersect, min->z, + max->z) || + Math3D_TriChkLineSegParaZIntersect(&va, &vb, &vc, nx, ny, nz, dist, min->x, max->y, &intersect, min->z, + max->z) || + Math3D_TriChkLineSegParaZIntersect(&va, &vb, &vc, nx, ny, nz, dist, max->x, min->y, &intersect, min->z, + max->z) || + Math3D_TriChkLineSegParaZIntersect(&va, &vb, &vc, nx, ny, nz, dist, max->x, max->y, &intersect, min->z, + max->z)) { + return true; + } + if (Math3D_TriChkLineSegParaXIntersect(&va, &vb, &vc, nx, ny, nz, dist, min->y, min->z, &intersect, min->x, + max->x) || + Math3D_TriChkLineSegParaXIntersect(&va, &vb, &vc, nx, ny, nz, dist, min->y, max->z, &intersect, min->x, + max->x) || + Math3D_TriChkLineSegParaXIntersect(&va, &vb, &vc, nx, ny, nz, dist, max->y, min->z, &intersect, min->x, + max->x) || + Math3D_TriChkLineSegParaXIntersect(&va, &vb, &vc, nx, ny, nz, dist, max->y, max->z, &intersect, min->x, + max->x)) { + return true; + } + + BgCheck_Vec3sToVec3f(&vtxList[COLPOLY_VTX_INDEX(poly->flags_vIA)], &va2); + BgCheck_Vec3sToVec3f(&vtxList[COLPOLY_VTX_INDEX(poly->flags_vIB)], &vb2); + BgCheck_Vec3sToVec3f(&vtxList[poly->vIC], &vc2); + if (Math3D_LineVsCube(min, max, &va2, &vb2) || Math3D_LineVsCube(min, max, &vb2, &vc2) || + Math3D_LineVsCube(min, max, &vc2, &va2)) { + return true; + } + return false; +} + +/** + * Initialize StaticLookup Table + * returns size of table, in bytes + */ +u32 BgCheck_InitStaticLookup(CollisionContext* colCtx, GlobalContext* globalCtx, StaticLookup* lookupTbl) { + Vec3s* vtxList; + CollisionPoly* polyList; + s32 polyMax; + s32 polyIdx; + s32 sx; + s32 sy; + s32 sz; + // subdivMin indices + s32 sxMin; + s32 syMin; + s32 szMin; + // subdivMax indices + s32 sxMax; + s32 syMax; + s32 szMax; + // subdiv min/max bounds for adding a poly + Vec3f curSubdivMin; + Vec3f curSubdivMax; + CollisionHeader* colHeader = colCtx->colHeader; + s32 pad[2]; + StaticLookup* iLookup; + StaticLookup* jLookup; + StaticLookup* lookup; + s32 sp98; + f32 subdivLengthX; + f32 subdivLengthY; + f32 subdivLengthZ; + + for (iLookup = lookupTbl; + iLookup < (colCtx->subdivAmount.x * colCtx->subdivAmount.y * colCtx->subdivAmount.z + lookupTbl); iLookup++) { + iLookup->floor.head = SS_NULL; + iLookup->wall.head = SS_NULL; + iLookup->ceiling.head = SS_NULL; + } + + polyMax = colHeader->numPolygons; + vtxList = colHeader->vtxList; + polyList = colHeader->polyList; + sp98 = colCtx->subdivAmount.x * colCtx->subdivAmount.y; + subdivLengthX = colCtx->subdivLength.x + (2 * BGCHECK_SUBDIV_OVERLAP); + subdivLengthY = colCtx->subdivLength.y + (2 * BGCHECK_SUBDIV_OVERLAP); + subdivLengthZ = colCtx->subdivLength.z + (2 * BGCHECK_SUBDIV_OVERLAP); + + for (polyIdx = 0; polyIdx < polyMax; polyIdx++) { + BgCheck_GetPolySubdivisionBounds(colCtx, vtxList, polyList, &sxMin, &syMin, &szMin, &sxMax, &syMax, &szMax, + polyIdx); + iLookup = szMin * sp98 + lookupTbl; + curSubdivMin.z = (colCtx->subdivLength.z * szMin + colCtx->minBounds.z) - BGCHECK_SUBDIV_OVERLAP; + curSubdivMax.z = curSubdivMin.z + subdivLengthZ; + + for (sz = szMin; sz < szMax + 1; sz++) { + jLookup = (colCtx->subdivAmount.x * syMin) + iLookup; + curSubdivMin.y = (colCtx->subdivLength.y * syMin + colCtx->minBounds.y) - BGCHECK_SUBDIV_OVERLAP; + curSubdivMax.y = curSubdivMin.y + subdivLengthY; + + for (sy = syMin; sy < syMax + 1; sy++) { + lookup = sxMin + jLookup; + curSubdivMin.x = (colCtx->subdivLength.x * sxMin + colCtx->minBounds.x) - BGCHECK_SUBDIV_OVERLAP; + curSubdivMax.x = curSubdivMin.x + subdivLengthX; + + for (sx = sxMin; sx < sxMax + 1; sx++) { + if (BgCheck_PolyIntersectsSubdivision(&curSubdivMin, &curSubdivMax, polyList, vtxList, polyIdx)) { + StaticLookup_AddPoly(lookup, colCtx, polyList, vtxList, polyIdx); + } + curSubdivMin.x += colCtx->subdivLength.x; + curSubdivMax.x += colCtx->subdivLength.x; + lookup++; + } + curSubdivMin.y += colCtx->subdivLength.y; + curSubdivMax.y += colCtx->subdivLength.y; + jLookup += colCtx->subdivAmount.x; + } + curSubdivMin.z += colCtx->subdivLength.z; + curSubdivMax.z += colCtx->subdivLength.z; + iLookup += sp98; + } + } + return colCtx->polyNodes.count * sizeof(SSNode); +} + +/** + * Returns whether the current scene should reserve less memory for it's collision lookup + */ +s32 BgCheck_IsSmallMemScene(GlobalContext* globalCtx) { + s16* i; + + for (i = sSmallMemScenes; i < sSmallMemScenes + ARRAY_COUNT(sSmallMemScenes); i++) { + if (globalCtx->sceneNum == *i) { + return true; + } + } + return false; +} + +/** + * Get custom scene memSize + */ +s32 BgCheck_TryGetCustomMemsize(s32 sceneId, u32* memSize) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(sSceneMemList); i++) { + if (sceneId == sSceneMemList[i].sceneId) { + *memSize = sSceneMemList[i].memSize; + return true; + } + } + return false; +} + +/** + * Compute subdivLength for scene mesh lookup, for a single dimension + */ +void BgCheck_SetSubdivisionDimension(f32 min, s32 subdivAmount, f32* max, f32* subdivLength, f32* subdivLengthInv) { + f32 length = (*max - min); + + *subdivLength = (s32)(length / subdivAmount) + 1; + *subdivLength = CLAMP_MIN(*subdivLength, BGCHECK_SUBDIV_MIN); + *subdivLengthInv = 1.0f / *subdivLength; + + *max = *subdivLength * subdivAmount + min; +} + +s32 BgCheck_GetSpecialSceneMaxObjects(GlobalContext* globalCtx, s32* maxNodes, s32* maxPolygons, s32* maxVertices) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(sCustomDynapolyMem); i++) { + if (globalCtx->sceneNum == sCustomDynapolyMem[i].sceneId) { + *maxNodes = sCustomDynapolyMem[i].maxNodes; + *maxPolygons = sCustomDynapolyMem[i].maxPolygons; + *maxVertices = sCustomDynapolyMem[i].maxVertices; + return true; + } + } + return false; +} + +/** + * Allocate CollisionContext + */ +#ifdef NON_MATCHING +void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, CollisionHeader* colHeader) { + u32 tblMax; + u32 memSize; + u32 lookupTblMemSize; + SSNodeList* nodeList; + s32 useCustomSubdivisions; + u32 customMemSize; + s32 customNodeListMax; + s32 i; + + customNodeListMax = -1; + colCtx->colHeader = colHeader; + colCtx->flags = 0; + + if (BgCheck_IsSmallMemScene(globalCtx)) { + colCtx->memSize = 0xF000; + colCtx->dyna.polyNodesMax = 1000; + colCtx->dyna.polyListMax = 512; + colCtx->dyna.vtxListMax = 512; + colCtx->subdivAmount.x = 16; + colCtx->subdivAmount.y = 4; + colCtx->subdivAmount.z = 16; + } else { + if (BgCheck_TryGetCustomMemsize(globalCtx->sceneNum, &customMemSize)) { + colCtx->memSize = customMemSize; + } else { + colCtx->memSize = 0x23000; + } + colCtx->dyna.polyNodesMax = 1000; + colCtx->dyna.polyListMax = 544; + colCtx->dyna.vtxListMax = 512; + BgCheck_GetSpecialSceneMaxObjects(globalCtx, &colCtx->dyna.polyNodesMax, &colCtx->dyna.polyListMax, + &colCtx->dyna.vtxListMax); + useCustomSubdivisions = false; + + for (i = 0; i < ARRAY_COUNT(sSceneSubdivisionList); i++) { + if (globalCtx->sceneNum == sSceneSubdivisionList[i].sceneId) { + colCtx->subdivAmount.x = sSceneSubdivisionList[i].subdivAmount.x; + colCtx->subdivAmount.y = sSceneSubdivisionList[i].subdivAmount.y; + colCtx->subdivAmount.z = sSceneSubdivisionList[i].subdivAmount.z; + useCustomSubdivisions = true; + customNodeListMax = sSceneSubdivisionList[i].nodeListMax; + } + } + if (useCustomSubdivisions == false) { + colCtx->subdivAmount.x = 16; + colCtx->subdivAmount.y = 4; + colCtx->subdivAmount.z = 16; + } + } + colCtx->lookupTbl = THA_AllocEndAlign( + &globalCtx->state.heap, + colCtx->subdivAmount.x * sizeof(StaticLookup) * colCtx->subdivAmount.y * colCtx->subdivAmount.z, ~1); + if (colCtx->lookupTbl == NULL) { + Fault_AddHungupAndCrash("../z_bgcheck.c", 3955); + } + colCtx->minBounds.x = colCtx->colHeader->minBounds.x; + colCtx->minBounds.y = colCtx->colHeader->minBounds.y; + colCtx->minBounds.z = colCtx->colHeader->minBounds.z; + colCtx->maxBounds.x = colCtx->colHeader->maxBounds.x; + colCtx->maxBounds.y = colCtx->colHeader->maxBounds.y; + colCtx->maxBounds.z = colCtx->colHeader->maxBounds.z; + BgCheck_SetSubdivisionDimension(colCtx->minBounds.x, colCtx->subdivAmount.x, &colCtx->maxBounds.x, + &colCtx->subdivLength.x, &colCtx->subdivLengthInv.x); + BgCheck_SetSubdivisionDimension(colCtx->minBounds.y, colCtx->subdivAmount.y, &colCtx->maxBounds.y, + &colCtx->subdivLength.y, &colCtx->subdivLengthInv.y); + BgCheck_SetSubdivisionDimension(colCtx->minBounds.z, colCtx->subdivAmount.z, &colCtx->maxBounds.z, + &colCtx->subdivLength.z, &colCtx->subdivLengthInv.z); + memSize = colCtx->subdivAmount.x * sizeof(StaticLookup) * colCtx->subdivAmount.y * colCtx->subdivAmount.z + + colCtx->colHeader->numPolygons * sizeof(u8) + colCtx->dyna.polyNodesMax * sizeof(SSNode) + + colCtx->dyna.polyListMax * sizeof(CollisionPoly) + colCtx->dyna.vtxListMax * sizeof(Vec3s) + + sizeof(CollisionContext); + if (customNodeListMax > 0) { + // tblMax is set without checking if customNodeListMax will result in a memory overflow + // this is a non-issue as long as sSceneSubdivisionList.nodeListMax is -1 + tblMax = customNodeListMax; + } else { + if (colCtx->memSize < memSize) { + Fault_AddHungupAndCrash("../z_bgcheck.c", 4011); + } + tblMax = (colCtx->memSize - memSize) / sizeof(SSNode); + } + + SSNodeList_Init(&colCtx->polyNodes); + SSNodeList_Alloc(globalCtx, &colCtx->polyNodes, tblMax, colCtx->colHeader->numPolygons); + + lookupTblMemSize = BgCheck_InitStaticLookup(colCtx, globalCtx, colCtx->lookupTbl); + + DynaPoly_Init(globalCtx, &colCtx->dyna); + DynaPoly_Alloc(globalCtx, &colCtx->dyna); +} +#else +void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, CollisionHeader* colHeader); +#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_Allocate.s") +#endif + +/** + * Enables CollisionContext wide flags + * Only used to reverse water flow in Great Bay Temple + */ +void BgCheck_SetContextFlags(CollisionContext* colCtx, u32 flags) { + colCtx->flags |= flags; +} + +/** + * Disables CollisionContext wide flags + * Only used to revert the reverse water flow in Great Bay Temple + */ +void BgCheck_UnsetContextFlags(CollisionContext* colCtx, u32 flags) { + colCtx->flags &= ~flags; +} + +/** + * original name: T_BGCheck_getBGDataInfo + */ +CollisionHeader* BgCheck_GetCollisionHeader(CollisionContext* colCtx, s32 bgId) { + if (bgId == BGCHECK_SCENE) { + return colCtx->colHeader; + } + if (bgId < 0 || bgId > BG_ACTOR_MAX) { + return NULL; + } + if (!(colCtx->dyna.bgActorFlags[bgId] & 1)) { + return NULL; + } + return colCtx->dyna.bgActors[bgId].colHeader; +} + +/** + * Test if pos is near collision boundaries + */ +s32 BgCheck_PosInStaticBoundingBox(CollisionContext* colCtx, Vec3f* pos) { + if (pos->x < (colCtx->minBounds.x - BGCHECK_SUBDIV_OVERLAP) || + (colCtx->maxBounds.x + BGCHECK_SUBDIV_OVERLAP) < pos->x || + pos->y < (colCtx->minBounds.y - BGCHECK_SUBDIV_OVERLAP) || + (colCtx->maxBounds.y + BGCHECK_SUBDIV_OVERLAP) < pos->y || + pos->z < (colCtx->minBounds.z - BGCHECK_SUBDIV_OVERLAP) || + (colCtx->maxBounds.z + BGCHECK_SUBDIV_OVERLAP) < pos->z) { + return false; + } + return true; +} + +/** + * Raycast Toward Floor + * returns the yIntersect of the nearest poly found directly below `pos`, or BGCHECK_Y_MIN if no floor detected + * returns the poly found in `outPoly`, and the bgId of the entity in `outBgId` + */ +f32 BgCheck_RaycastFloorImpl(GlobalContext* globalCtx, CollisionContext* colCtx, u16 xpFlags, CollisionPoly** outPoly, + s32* outBgId, Vec3f* pos, Actor* actor, u32 arg7, f32 checkDist, s32 arg9) { + f32 yIntersectDyna; + f32 yIntersect; + StaticLookup* lookupTbl; + Vec3f checkPos; + StaticLookup* lookup; + DynaRaycast dynaRaycast; + + *outBgId = BGCHECK_SCENE; + *outPoly = NULL; + lookupTbl = colCtx->lookupTbl; + yIntersect = BGCHECK_Y_MIN; + checkPos = *pos; + + while (true) { + if (checkPos.y < colCtx->minBounds.y) { + break; + } + lookup = BgCheck_GetStaticLookup(colCtx, lookupTbl, &checkPos); + if (lookup == NULL) { + checkPos.y -= colCtx->subdivLength.y; + continue; + } + yIntersect = + BgCheck_RaycastFloorStatic(lookup, colCtx, xpFlags, outPoly, pos, arg7, checkDist, BGCHECK_Y_MIN, actor); + if (yIntersect > BGCHECK_Y_MIN) { + break; + } + checkPos.y -= colCtx->subdivLength.y; + } + if (!(arg9 & 1)) { + dynaRaycast.globalCtx = globalCtx; + dynaRaycast.colCtx = colCtx; + dynaRaycast.xpFlags = xpFlags; + dynaRaycast.resultPoly = outPoly; + dynaRaycast.yIntersect = yIntersect; + dynaRaycast.pos = pos; + dynaRaycast.bgId = outBgId; + dynaRaycast.unk1C = 50; + dynaRaycast.actor = actor; + dynaRaycast.unk_24 = arg7; + dynaRaycast.checkDist = checkDist; + + yIntersectDyna = BgCheck_RaycastFloorDyna(&dynaRaycast); + if (yIntersect < yIntersectDyna) { + yIntersect = yIntersectDyna; + } + } + + if (yIntersect != BGCHECK_Y_MIN && func_800C9B68(colCtx, *outPoly, *outBgId)) { + yIntersect -= 1.0f; + } + return yIntersect; +} + +/** + * Public raycast toward floor + * returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected + */ +f32 BgCheck_CameraRaycastFloor1(CollisionContext* colCtx, CollisionPoly** outPoly, Vec3f* pos) { + s32 bgId; + + return BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_CAMERA, outPoly, &bgId, pos, NULL, 0x1C, 1.0f, 0); +} + +/** + * Public raycast toward floor + * returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected + */ +f32 BgCheck_EntityRaycastFloor1(CollisionContext* colCtx, CollisionPoly** outPoly, Vec3f* pos) { + s32 bgId; + + return BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, &bgId, pos, NULL, 0x1C, 1.0f, 0); +} + +/** + * Public raycast toward floor + * returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected + */ +f32 BgCheck_EntityRaycastFloor2(GlobalContext* globalCtx, CollisionContext* colCtx, CollisionPoly** outPoly, + Vec3f* pos) { + s32 bgId; + + return BgCheck_RaycastFloorImpl(globalCtx, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, &bgId, pos, NULL, 0x1C, 1.0f, 0); +} + +/** + * Public raycast toward floor + * returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected + */ +f32 BgCheck_EntityRaycastFloor2_1(GlobalContext* globalCtx, CollisionContext* colCtx, CollisionPoly** outPoly, + Vec3f* pos) { + s32 bgId; + + return BgCheck_RaycastFloorImpl(globalCtx, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, &bgId, pos, NULL, 0x1C, 1.0f, 1); +} + +/** + * Public raycast toward floor + * returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected + */ +f32 BgCheck_EntityRaycastFloor3(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Vec3f* pos) { + return BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, NULL, 0x1C, 1.0f, 0); +} + +/** + * Public raycast toward floor + * returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected + */ +f32 BgCheck_EntityRaycastFloor5(CollisionContext* colCtx, CollisionPoly** outPoly, s32* outBgId, Actor* actor, + Vec3f* pos) { + return BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, outBgId, pos, actor, 0x1C, 1.0f, 0); +} + +/** + * Public raycast toward floor + * returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected + */ +f32 BgCheck_EntityRaycastFloor5_2(GlobalContext* globalCtx, CollisionContext* colCtx, CollisionPoly** outPoly, + s32* bgId, Actor* actor, Vec3f* pos) { + return BgCheck_RaycastFloorImpl(globalCtx, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor, 0x1C, 1.0f, 0); +} + +/** + * Public raycast toward floor + * returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected + */ +f32 BgCheck_EntityRaycastFloor5_3(GlobalContext* globalCtx, CollisionContext* colCtx, CollisionPoly** outPoly, + s32* bgId, Actor* actor, Vec3f* pos) { + return BgCheck_RaycastFloorImpl(globalCtx, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor, 0x3C, 1.0f, 0); +} + +/** + * Public raycast toward floor + * returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected + */ +f32 BgCheck_EntityRaycastFloor6(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos, + f32 checkDist) { + return BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor, 0x1C, checkDist, 0); +} + +/** + * Public raycast toward floor + * returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected + */ +f32 BgCheck_EntityRaycastFloor7(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, + Vec3f* pos) { + return BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor, 0x06, 1.0f, 0); +} + +/** + * Public raycast toward floor + * returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected + */ +f32 BgCheck_AnyRaycastFloor1(CollisionContext* colCtx, CollisionPoly* outPoly, Vec3f* pos) { + CollisionPoly* tempPoly; + f32 result; + s32 bgId; + + result = BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_NONE, &tempPoly, &bgId, pos, NULL, 0x1C, 1.0f, 0); + + if (tempPoly != NULL) { + *outPoly = *tempPoly; + } + return result; +} + +/** + * Public raycast toward floor + * returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected + */ +f32 BgCheck_AnyRaycastFloor2(CollisionContext* colCtx, CollisionPoly* outPoly, s32* bgId, Vec3f* pos) { + CollisionPoly* tempPoly; + f32 result = BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_NONE, &tempPoly, bgId, pos, NULL, 0x1C, 1.0f, 0); + + if (tempPoly != NULL) { + *outPoly = *tempPoly; + } + return result; +} + +/** + * Public raycast toward floor + * returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected + */ +f32 BgCheck_CameraRaycastFloor2(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Vec3f* pos) { + return BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_CAMERA, outPoly, bgId, pos, NULL, 0x06, 1.0f, 0); +} + +/** + * Public raycast toward floor + * returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected + */ +f32 BgCheck_EntityRaycastFloor8(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, + Vec3f* pos) { + return BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor, 0x02, 1.0f, 0); +} + +/** + * Public raycast toward floor + * returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected + */ +f32 BgCheck_EntityRaycastFloor9(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Vec3f* pos) { + return BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, NULL, 0x06, 1.0f, 0); +} + +#ifdef NON_MATCHING +/** + * Tests if moving from `posPrev` to `posNext` will collide with a "wall" + * `radius` is used to form a sphere for collision detection purposes + * `checkHeight` is the positive height above posNext to perform certain checks + * returns true if a collision is detected, else false + * `outPoly` returns the closest poly detected, while `outBgId` returns the poly owner + */ +s32 BgCheck_CheckWallImpl(CollisionContext* colCtx, u16 xpFlags, Vec3f* posResult, Vec3f* posNext, Vec3f* posPrev, + f32 radius, CollisionPoly** outPoly, s32* outBgId, Actor* actor, f32 checkHeight, u8 argA) { + StaticLookup* lookupTbl; + f32 temp_f0; + s32 result; + CollisionPoly* poly; + // change between posPrev to posNext + f32 dx; + f32 dy; + f32 dz; + Vec3f sphCenter; + s32 dynaPolyCollision; + Vec3f posIntersect; + s32 bgId; + f32 temp_f0_2; + f32 f32temp; + f32 nx2, nz2; + Vec3f checkLineNext; + Vec3f checkLinePrev; + f32 n2XZDist; + f32 n3XZDist; + f32 nx3, nz3; + s32 bccFlags; + Vec3f posIntersect2; + s32 bgId2; + // unit normal of polygon + f32 nx; + f32 ny; + f32 nz; + + result = false; + *outBgId = BGCHECK_SCENE; + *outPoly = NULL; + lookupTbl = colCtx->lookupTbl; + *posResult = *posNext; + dx = posNext->x - posPrev->x; + dy = posNext->y - posPrev->y; + dz = posNext->z - posPrev->z; + + // if there's movement on the xz plane, and argA flag is 0, + if ((dx != 0.0f || dz != 0.0f) && (argA & 1) == 0) { + if ((checkHeight + dy) < 5.0f) { + //! @bug checkHeight is not applied to posPrev/posNext + result = BgCheck_CheckLineImpl(colCtx, xpFlags, COLPOLY_IGNORE_NONE, posPrev, posNext, &posIntersect, &poly, + &bgId, actor, 1.0f, BGCHECK_CHECK_ALL & ~BGCHECK_CHECK_CEILING); + if (result) { + ny = COLPOLY_GET_NORMAL(poly->normal.y); + // if poly is floor, push result underneath the floor + if (ny > 0.5f) { + posResult->x = posIntersect.x; + if (checkHeight > 1.0f) { + posResult->y = posIntersect.y - 1.0f; + } else { + posResult->y = posIntersect.y - checkHeight; + } + posResult->z = posIntersect.z; + if (actor != NULL) { + actor->bgCheckFlags |= 0x1000; + } + } + // poly is wall + else { + nx = COLPOLY_GET_NORMAL(poly->normal.x); + nz = COLPOLY_GET_NORMAL(poly->normal.z); + posResult->x = radius * nx + posIntersect.x; + posResult->y = radius * ny + posIntersect.y; + posResult->z = radius * nz + posIntersect.z; + } + *outPoly = poly; + *outBgId = bgId; + } + } else { + // if the radius is less than the distance travelled on the xz plane, also test for floor collisions + bccFlags = SQ(radius) < (SQ(dx) + SQ(dz)) + ? (BGCHECK_CHECK_ALL & ~BGCHECK_CHECK_CEILING) + : (BGCHECK_CHECK_ALL & ~BGCHECK_CHECK_FLOOR & ~BGCHECK_CHECK_CEILING); + + // perform a straight line test to see if a line at posNext.y + checkHeight from posPrev.xz to posNext.xz + // passes through any wall and possibly floor polys + checkLineNext = *posNext; + checkLineNext.y += checkHeight; + checkLinePrev = *posPrev; + checkLinePrev.y = checkLineNext.y; + result = BgCheck_CheckLineImpl(colCtx, xpFlags, COLPOLY_IGNORE_NONE, &checkLinePrev, &checkLineNext, + &posIntersect, &poly, &bgId, actor, 1.0f, bccFlags); + + if (result) { + nx2 = COLPOLY_GET_NORMAL(poly->normal.x); + nz2 = COLPOLY_GET_NORMAL(poly->normal.z); + n2XZDist = sqrtf(SQ(nx2) + SQ(nz2)); + + // if poly is not a "flat" floor or "flat" ceiling + if (!IS_ZERO(n2XZDist)) { + // normalize nx,nz and multiply each by the radius to go back to the other side of the wall + f32temp = 1.0f / n2XZDist; + temp_f0 = radius * f32temp; + posResult->x = temp_f0 * nx2 + posIntersect.x; + posResult->z = temp_f0 * nz2 + posIntersect.z; + *outPoly = poly; + *outBgId = bgId; + result = true; + if (COLPOLY_GET_NORMAL(poly->normal.y) > 0.5f) { + if (actor != NULL) { + actor->bgCheckFlags |= 0x1000; + } + } + } else { + result = false; + } + } + } + } + + sphCenter = *posResult; + dynaPolyCollision = false; + sphCenter.y += checkHeight; + // test if sphere (sphCenter, radius) collides with a dynamic wall, displacing the x/z coordinates + if (BgCheck_SphVsDynaWall(colCtx, xpFlags, &posResult->x, &posResult->z, &sphCenter, radius, outPoly, outBgId, + actor)) { + result = true; + dynaPolyCollision = true; + sphCenter = *posResult; + sphCenter.y += checkHeight; + } + // test if sphere (sphCenter, radius) collides with a static wall, displacing the x/z coordinates + if (BgCheck_PosInStaticBoundingBox(colCtx, posNext) && + // possible bug? if the sphere's radius is smaller than the distance to a subdivision boundary, some static + // polys will be missed + BgCheck_SphVsStaticWall(BgCheck_GetNearestStaticLookup(colCtx, lookupTbl, posResult), colCtx, xpFlags, + &posResult->x, &posResult->z, &sphCenter, radius, outPoly, actor)) { + *outBgId = BGCHECK_SCENE; + result = true; + } + // if a collision with a dyna poly was detected + if (dynaPolyCollision || *outBgId != BGCHECK_SCENE) { + if (BgCheck_CheckLineImpl(colCtx, xpFlags, COLPOLY_IGNORE_NONE, posPrev, posResult, &posIntersect2, &poly, + &bgId2, actor, 1.0f, BGCHECK_CHECK_ONE_FACE | BGCHECK_CHECK_WALL)) { + nx3 = COLPOLY_GET_NORMAL(poly->normal.x); + nz3 = COLPOLY_GET_NORMAL(poly->normal.z); + n3XZDist = sqrtf(SQ(nx3) + SQ(nz3)); + + // if poly is not a "flat" floor or "flat" ceiling + if (!IS_ZERO(n3XZDist)) { + // normalize nx,nz and multiply each by the radius to go back to the other side of the wall + f32temp = 1.0f / n3XZDist; + temp_f0_2 = radius * f32temp; + posResult->x = temp_f0_2 * nx3 + posIntersect2.x; + posResult->z = temp_f0_2 * nz3 + posIntersect2.z; + *outPoly = poly; + *outBgId = bgId2; + result = true; + } + } + } + return result; +} +#else +s32 BgCheck_CheckWallImpl(CollisionContext* colCtx, u16 xpFlags, Vec3f* posResult, Vec3f* posNext, Vec3f* posPrev, + f32 radius, CollisionPoly** outPoly, s32* outBgId, Actor* actor, f32 checkHeight, u8 argA); +#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_CheckWallImpl.s") +#endif + +/** + * Public. Tests if moving from `posPrev` to `posNext` will collide with a "wall" + * `radius` is used to form a sphere for collision detection purposes + * `checkHeight` is the positive height above posNext to perform certain checks + * returns true if a collision is detected, else false + * `outPoly` returns the closest poly detected + */ +s32 BgCheck_EntitySphVsWall1(CollisionContext* colCtx, Vec3f* posResult, Vec3f* posNext, Vec3f* posPrev, f32 radius, + CollisionPoly** outPoly, f32 checkHeight) { + s32 bgId; + + return BgCheck_CheckWallImpl(colCtx, COLPOLY_IGNORE_ENTITY, posResult, posNext, posPrev, radius, outPoly, &bgId, + NULL, checkHeight, 0); +} + +/** + * Public. Tests if moving from `posPrev` to `posNext` will collide with a "wall" + * `radius` is used to form a sphere for collision detection purposes + * `checkHeight` is the positive height above posNext to perform certain checks + * returns true if a collision is detected, else false + * `outPoly` returns the closest poly detected, while `outBgId` returns the poly owner + */ +s32 BgCheck_EntitySphVsWall2(CollisionContext* colCtx, Vec3f* posResult, Vec3f* posNext, Vec3f* posPrev, f32 radius, + CollisionPoly** outPoly, s32* outBgId, f32 checkHeight) { + return BgCheck_CheckWallImpl(colCtx, COLPOLY_IGNORE_ENTITY, posResult, posNext, posPrev, radius, outPoly, outBgId, + NULL, checkHeight, 0); +} + +/** + * Public. Tests if *moving from `posPrev` to `posNext` will collide with a "wall" + * `radius` is used to form a sphere for collision detection purposes + * `checkHeight` is the positive height above posNext to perform certain checks + * `actor` is the actor performing the check, allowing it to be skipped + * returns true if a collision is detected, else false + * `outPoly` returns the closest poly detected, while `outBgId` returns the poly owner + */ +s32 BgCheck_EntitySphVsWall3(CollisionContext* colCtx, Vec3f* posResult, Vec3f* posNext, Vec3f* posPrev, f32 radius, + CollisionPoly** outPoly, s32* outBgId, Actor* actor, f32 checkHeight) { + return BgCheck_CheckWallImpl(colCtx, COLPOLY_IGNORE_ENTITY, posResult, posNext, posPrev, radius, outPoly, outBgId, + actor, checkHeight, 0); +} + +/** + * Public. Tests if moving from `posPrev` to `posNext` will collide with a "wall" + * Skips a check that occurs only when moving on the xz plane + * `radius` is used to form a sphere for collision detection purposes + * `checkHeight` is the positive height above posNext to perform certain checks + * `actor` is the actor performing the check, allowing it to be skipped + * returns true if a collision is detected, else false + * `outPoly` returns the closest poly detected, while `outBgId` returns the poly owner + */ +s32 BgCheck_EntitySphVsWall4(CollisionContext* colCtx, Vec3f* posResult, Vec3f* posNext, Vec3f* posPrev, f32 radius, + CollisionPoly** outPoly, s32* outBgId, Actor* actor, f32 checkHeight) { + return BgCheck_CheckWallImpl(colCtx, COLPOLY_IGNORE_ENTITY, posResult, posNext, posPrev, radius, outPoly, outBgId, + actor, checkHeight, 1); +} + +/** + * Tests for collision with a ceiling poly + * `checkHeight` should be a positive value + * returns true if a collision occurs, else false + * `outPoly` returns the poly collided with, while `outBgId` returns the owner of the poly + * `outY` returns the y coordinate of pos needed to not collide with `outPoly` + */ +s32 BgCheck_CheckCeilingImpl(CollisionContext* colCtx, u16 xpFlags, f32* outY, Vec3f* pos, f32 checkHeight, + CollisionPoly** outPoly, s32* outBgId, Actor* actor) { + StaticLookup* lookupTbl; + StaticLookup* lookup; + s32 result; + Vec3f posTemp; + f32 tempY; + + *outBgId = BGCHECK_SCENE; + *outY = pos->y; + lookupTbl = colCtx->lookupTbl; + if (!BgCheck_PosInStaticBoundingBox(colCtx, pos)) { + return false; + } + + lookup = BgCheck_GetNearestStaticLookup(colCtx, lookupTbl, pos); + result = BgCheck_CheckStaticCeiling(lookup, xpFlags, colCtx, outY, pos, checkHeight, outPoly, actor); + + posTemp = *pos; + posTemp.y = *outY; + tempY = *outY; + + if (BgCheck_CheckDynaCeiling(colCtx, xpFlags, &tempY, &posTemp, checkHeight, outPoly, outBgId, actor)) { + *outY = tempY; + result = true; + } + return result; +} + +/** + * Tests for collision with any ceiling poly + * `checkHeight` must be a positive value + * returns true if a collision occurs, else false + * `outY` returns the displaced y coordinate needed to not collide with the poly + */ +s32 BgCheck_AnyCheckCeiling(CollisionContext* colCtx, f32* outY, Vec3f* pos, f32 checkHeight) { + CollisionPoly* poly; + s32 bgId; + + return BgCheck_CheckCeilingImpl(colCtx, COLPOLY_IGNORE_NONE, outY, pos, checkHeight, &poly, &bgId, NULL); +} + +/** + * Tests for collision with any entity solid ceiling poly + * `checkHeight` must be a positive value + * returns true if a collision occurs, else false + * `outY` returns the displaced y coordinate needed to not collide with the poly + */ +s32 BgCheck_EntityCheckCeiling(CollisionContext* colCtx, f32* outY, Vec3f* pos, f32 checkHeight, + CollisionPoly** outPoly, s32* outBgId, Actor* actor) { + return BgCheck_CheckCeilingImpl(colCtx, COLPOLY_IGNORE_ENTITY, outY, pos, checkHeight, outPoly, outBgId, actor); +} + +#ifdef NON_MATCHING +/** + * Tests if a line from `posA` to `posB` intersects with a poly + * returns true if it does, else false + * `posB`? `posResult` returns the point of intersection + * `outPoly` returns the pointer to the intersected poly, while `outBgId` returns the entity the poly belongs to + */ +s32 BgCheck_CheckLineImpl(CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2, Vec3f* posA, Vec3f* posB, + Vec3f* posResult, CollisionPoly** outPoly, s32* outBgId, Actor* actor, f32 checkDist, + u32 bccFlags) { + StaticLookup* lookupTbl; + StaticLookup* iLookup; + s32 subdivMin[3]; + s32 subdivMax[3]; + s32 i; + s32 result; + Vec3f posBTemp; + StaticLineTest checkLine; + Vec3f sectorMin; + Vec3f sectorMax; + s32 k; + StaticLookup* lookup; + s32 j; + StaticLookup* jLookup; + s32 temp_lo; + s32 pad[2]; + + lookupTbl = colCtx->lookupTbl; + posBTemp = *posB; + + *outBgId = BGCHECK_SCENE; + + BgCheck_ResetPolyCheckTbl(&colCtx->polyNodes, colCtx->colHeader->numPolygons); + BgCheck_GetStaticLookupIndicesFromPos(colCtx, posA, (Vec3i*)&subdivMin); + BgCheck_GetStaticLookupIndicesFromPos(colCtx, &posBTemp, (Vec3i*)&subdivMax); + *posResult = *posB; + checkLine.outDistSq = 1.0e38f; + *outPoly = NULL; + + checkLine.colCtx = colCtx; + checkLine.xpFlags2 = xpFlags2; + checkLine.posA = posA; + checkLine.posB = &posBTemp; + checkLine.outPoly = outPoly; + checkLine.xpFlags1 = xpFlags1; + checkLine.outPos = posResult; + checkLine.checkDist = checkDist; + checkLine.bccFlags = bccFlags; + checkLine.actor = actor; + result = false; + + if (subdivMin[0] != subdivMax[0] || subdivMin[1] != subdivMax[1] || subdivMin[2] != subdivMax[2]) { + for (i = 0; i < 3; i++) { + if (subdivMax[i] < subdivMin[i]) { + j = subdivMax[i]; + subdivMax[i] = subdivMin[i]; + subdivMin[i] = j; + } + } + temp_lo = colCtx->subdivAmount.x * colCtx->subdivAmount.y; + iLookup = lookupTbl + subdivMin[2] * temp_lo; + sectorMin.z = subdivMin[2] * colCtx->subdivLength.z + colCtx->minBounds.z; + sectorMax.z = colCtx->subdivLength.z + sectorMin.z; + + for (i = subdivMin[2]; i < subdivMax[2] + 1; i++) { + jLookup = iLookup + subdivMin[1] * colCtx->subdivAmount.x; + sectorMin.y = subdivMin[1] * colCtx->subdivLength.y + colCtx->minBounds.y; + sectorMax.y = colCtx->subdivLength.y + sectorMin.y; + + for (j = subdivMin[1]; j < subdivMax[1] + 1; j++) { + lookup = jLookup + subdivMin[0]; + sectorMin.x = subdivMin[0] * colCtx->subdivLength.x + colCtx->minBounds.x; + sectorMax.x = colCtx->subdivLength.x + sectorMin.x; + + for (k = subdivMin[0]; k < subdivMax[0] + 1; k++) { + if (Math3D_LineVsCube(§orMin, §orMax, posA, &posBTemp)) { + checkLine.lookup = lookup; + + if (BgCheck_CheckLineInSubdivision(&checkLine)) { + result = true; + } + } + lookup++; + sectorMin.x += colCtx->subdivLength.x; + sectorMax.x += colCtx->subdivLength.x; + } + jLookup += colCtx->subdivAmount.x; + sectorMin.y += colCtx->subdivLength.y; + sectorMax.y += colCtx->subdivLength.y; + } + iLookup += temp_lo; + sectorMin.z += colCtx->subdivLength.z; + sectorMax.z += colCtx->subdivLength.z; + } + } else if (BgCheck_PosInStaticBoundingBox(colCtx, posA) == false) { + return false; + } else { + checkLine.lookup = BgCheck_GetNearestStaticLookup(colCtx, lookupTbl, posA); + result = BgCheck_CheckLineInSubdivision(&checkLine); + if (result) { + checkLine.outDistSq = Math3D_Vec3fDistSq(posResult, posA); + } + } + if ((bccFlags & BGCHECK_CHECK_DYNA) && + BgCheck_CheckLineAgainstDyna(colCtx, xpFlags1, posA, &posBTemp, posResult, outPoly, &checkLine.outDistSq, + outBgId, actor, checkDist, bccFlags)) { + result = true; + } + return result; +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_CheckLineImpl.s") +#endif + +/** + * Get bccFlags + */ +u32 BgCheck_GetBccFlags(s32 checkWall, s32 checkFloor, s32 checkCeil, s32 checkOneFace, s32 checkDyna) { + u32 result = 0; + + if (checkWall) { + result = BGCHECK_CHECK_WALL; + } + if (checkFloor) { + result |= BGCHECK_CHECK_FLOOR; + } + if (checkCeil) { + result |= BGCHECK_CHECK_CEILING; + } + if (checkOneFace) { + result |= BGCHECK_CHECK_ONE_FACE; + } + if (checkDyna) { + result |= BGCHECK_CHECK_DYNA; + } + return result; +} + +/** + * Public. Tests if a line from `posA` to `posB` intersects with a poly + * returns true if it does, else false + */ +s32 BgCheck_CameraLineTest1(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, + CollisionPoly** outPoly, s32 checkWall, s32 checkFloor, s32 checkCeil, s32 checkOneFace, + s32* bgId) { + return BgCheck_CheckLineImpl(colCtx, COLPOLY_IGNORE_CAMERA, COLPOLY_IGNORE_NONE, posA, posB, posResult, outPoly, + bgId, NULL, 1.0f, + BgCheck_GetBccFlags(checkWall, checkFloor, checkCeil, checkOneFace, true)); +} + +/** + * Public. Tests if a line from `posA` to `posB` intersects with a poly + * returns true if it does, else false + */ +s32 BgCheck_CameraLineTest2(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, + CollisionPoly** outPoly, s32 checkWall, s32 checkFloor, s32 checkCeil, s32 checkOneFace, + s32* bgId) { + return BgCheck_CheckLineImpl(colCtx, COLPOLY_IGNORE_NONE, COLPOLY_IGNORE_CAMERA, posA, posB, posResult, outPoly, + bgId, NULL, 1.0f, + BgCheck_GetBccFlags(checkWall, checkFloor, checkCeil, checkOneFace, true)); +} + +/** + * Public. Tests if a line from `posA` to `posB` intersects with a poly + * returns true if it does, else false + */ +s32 BgCheck_EntityLineTest1(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, + CollisionPoly** outPoly, s32 checkWall, s32 checkFloor, s32 checkCeil, s32 checkOneFace, + s32* bgId) { + return BgCheck_CheckLineImpl(colCtx, COLPOLY_IGNORE_ENTITY, COLPOLY_IGNORE_NONE, posA, posB, posResult, outPoly, + bgId, NULL, 1.0f, + BgCheck_GetBccFlags(checkWall, checkFloor, checkCeil, checkOneFace, true)); +} + +/** + * Public. Tests if a line from `posA` to `posB` intersects with a poly + * returns true if it does, else false + */ +s32 BgCheck_EntityLineTest2(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, + CollisionPoly** outPoly, s32 checkWall, s32 checkFloor, s32 checkCeil, s32 checkOneFace, + s32* bgId, Actor* actor) { + return BgCheck_CheckLineImpl(colCtx, COLPOLY_IGNORE_ENTITY, COLPOLY_IGNORE_NONE, posA, posB, posResult, outPoly, + bgId, actor, 1.0f, + BgCheck_GetBccFlags(checkWall, checkFloor, checkCeil, checkOneFace, true)); +} + +/** + * Public. Tests if a line from `posA` to `posB` intersects with a poly + * returns true if it does, else false + */ +s32 BgCheck_EntityLineTest3(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, + CollisionPoly** outPoly, s32 checkWall, s32 checkFloor, s32 checkCeil, s32 checkOneFace, + s32* bgId, Actor* actor, f32 checkDist) { + return BgCheck_CheckLineImpl(colCtx, COLPOLY_IGNORE_ENTITY, COLPOLY_IGNORE_NONE, posA, posB, posResult, outPoly, + bgId, actor, checkDist, + BgCheck_GetBccFlags(checkWall, checkFloor, checkCeil, checkOneFace, true)); +} + +/** + * Public. Tests if a line from `posA` to `posB` intersects with a poly + * returns true if it does, else false + */ +s32 BgCheck_ProjectileLineTest(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, + CollisionPoly** outPoly, s32 checkWall, s32 checkFloor, s32 checkCeil, s32 checkOneFace, + s32* bgId) { + return BgCheck_CheckLineImpl(colCtx, COLPOLY_IGNORE_PROJECTILES, COLPOLY_IGNORE_NONE, posA, posB, posResult, + outPoly, bgId, NULL, 1.0f, + BgCheck_GetBccFlags(checkWall, checkFloor, checkCeil, checkOneFace, true)); +} + +/** + * Public. Tests if a line from `posA` to `posB` intersects with a poly + * returns true if it does, else false + */ +s32 BgCheck_AnyLineTest1(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, + s32 checkOneFace) { + return BgCheck_AnyLineTest2(colCtx, posA, posB, posResult, outPoly, true, true, true, checkOneFace); +} + +/** + * Public. Tests if a line from `posA` to `posB` intersects with a poly + * returns true if it does, else false + */ +s32 BgCheck_AnyLineTest2(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, + s32 checkWall, s32 checkFloor, s32 checkCeil, s32 checkOneFace) { + s32 bgId; + + return BgCheck_CheckLineImpl(colCtx, COLPOLY_IGNORE_NONE, COLPOLY_IGNORE_NONE, posA, posB, posResult, outPoly, + &bgId, NULL, 1.0f, + BgCheck_GetBccFlags(checkWall, checkFloor, checkCeil, checkOneFace, true)); +} + +/** + * Public. Tests if a line from `posA` to `posB` intersects with a poly + * returns true if it does, else false + */ +s32 BgCheck_AnyLineTest3(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, + s32 checkWall, s32 checkFloor, s32 checkCeil, s32 checkOneFace, s32* bgId) { + return BgCheck_CheckLineImpl(colCtx, COLPOLY_IGNORE_NONE, COLPOLY_IGNORE_NONE, posA, posB, posResult, outPoly, bgId, + NULL, 1.0f, BgCheck_GetBccFlags(checkWall, checkFloor, checkCeil, checkOneFace, true)); +} + +/** + * Get first poly intersecting sphere `center` `radius` + * ignores `actor` dyna poly + * returns true if any poly intersects the sphere, else false + * `outPoly` returns the pointer of the first poly found that intersects + * `outBgId` returns the bgId of the entity that owns `outPoly` + */ +s32 BgCheck_SphVsFirstPolyImpl(CollisionContext* colCtx, u16 xpFlags, CollisionPoly** outPoly, s32* outBgId, + Vec3f* center, f32 radius, Actor* actor, u16 bciFlags) { + StaticLookup* lookup; + + *outBgId = BGCHECK_SCENE; + lookup = BgCheck_GetStaticLookup(colCtx, colCtx->lookupTbl, center); + if (lookup == NULL) { + return false; + } else if (BgCheck_SphVsFirstStaticPoly(lookup, xpFlags, colCtx, center, radius, outPoly, bciFlags, actor) || + BgCheck_SphVsFirstDynaPoly(colCtx, xpFlags, outPoly, outBgId, center, radius, actor, bciFlags)) { + return true; + } + return false; +} + +/** + * Public get first poly intersecting sphere `center` `radius` + */ +s32 BgCheck_SphVsFirstPoly(CollisionContext* colCtx, Vec3f* center, f32 radius) { + CollisionPoly* poly; + s32 bgId; + + return BgCheck_SphVsFirstPolyImpl(colCtx, COLPOLY_IGNORE_NONE, &poly, &bgId, center, radius, NULL, + BGCHECK_IGNORE_NONE); +} + +/** + * Public get first wall poly intersecting sphere `center` `radius` + */ +s32 BgCheck_SphVsFirstWall(CollisionContext* colCtx, Vec3f* center, f32 radius) { + CollisionPoly* poly; + s32 bgId; + + return BgCheck_SphVsFirstPolyImpl(colCtx, COLPOLY_IGNORE_NONE, &poly, &bgId, center, radius, NULL, + BGCHECK_IGNORE_FLOOR | BGCHECK_IGNORE_CEILING); +} + +/** + * Init SSNodeList + */ +void SSNodeList_Init(SSNodeList* this) { + this->max = 0; + this->count = 0; + this->tbl = NULL; + this->polyCheckTbl = NULL; +} + +/** + * Allocate SSNodeList + * tblMax is the number of SSNode records to allocate + * numPolys is the number of polygons defined within the CollisionHeader + */ +void SSNodeList_Alloc(GlobalContext* globalCtx, SSNodeList* this, s32 tblMax, s32 numPolys) { + this->max = tblMax; + this->count = 0; + this->tbl = THA_AllocEndAlign(&globalCtx->state.heap, tblMax * sizeof(SSNode), -2); + this->polyCheckTbl = THA_AllocEndAlign16(&globalCtx->state.heap, numPolys * sizeof(u8)); + + if (this->polyCheckTbl == NULL) { + sprintf(D_801ED950, "this->polygon_check == NULL(game_alloc() MemoryAllocationError.)\n"); + sprintf(D_801ED9A0, "short_slist_node_size = %d/polygon_num = %d\n", tblMax, numPolys); + Fault_AddHungupAndCrashImpl(D_801ED950, D_801ED9A0); + } +} + +/** + * Get next SSNodeList SSNode + */ +SSNode* SSNodeList_GetNextNode(SSNodeList* this) { + SSNode* result = &this->tbl[this->count]; + + this->count++; + if (!(this->count < this->max)) { + return NULL; + } + return result; +} + +/** + * Get next SSNodeList SSNode index + */ +u16 SSNodeList_GetNextNodeIdx(SSNodeList* this) { + u16 new_index = this->count++; + + return new_index; +} + +/** + * Initialize ScaleRotPos + */ +void ScaleRotPos_Init(ScaleRotPos* srp) { + srp->scale.x = srp->scale.y = srp->scale.z = 1; + srp->rot.x = 0; + srp->rot.y = 0; + srp->rot.z = 0; + srp->pos.x = srp->pos.y = srp->pos.z = 0; +} + +/** + * Set ScaleRotPos + */ +void ScaleRotPos_SetValue(ScaleRotPos* srp, Vec3f* scale, Vec3s* rot, Vec3f* pos) { + srp->scale = *scale; + srp->rot = *rot; + srp->pos = *pos; +} + +/** + * ScaleRotPos equality test + */ +s32 ScaleRotPos_IsEqual(ScaleRotPos* a, ScaleRotPos* b) { + if (a->scale.x != b->scale.x || a->scale.y != b->scale.y || a->scale.z != b->scale.z || a->rot.x != b->rot.x || + a->rot.y != b->rot.y || a->rot.z != b->rot.z || a->pos.x != b->pos.x || a->pos.y != b->pos.y || + a->pos.z != b->pos.z) { + return false; + } + return true; +} + +/** + * Reset DynaLookup lists + */ +void DynaLookup_ResetLists(DynaLookup* dynaLookup) { + SSList_SetNull(&dynaLookup->ceiling); + SSList_SetNull(&dynaLookup->wall); + SSList_SetNull(&dynaLookup->floor); +} + +/** + * Reset DynaLookup + */ +void DynaLookup_Reset(DynaLookup* dynaLookup) { + dynaLookup->polyStartIndex = 0; + DynaLookup_ResetLists(dynaLookup); +} + +/** + * Reset vtxStartIndex + */ +void DynaLookup_ResetVtxStartIndex(u16* vtxStartIndex) { + *vtxStartIndex = 0; +} + +/** + * Reset waterBoxStartIndex + */ +void DynaLookup_ResetWaterBoxStartIndex(u16* waterBoxStartIndex) { + *waterBoxStartIndex = 0; +} + +/** + * Initialize BgActor + */ +void BgActor_Init(GlobalContext* globalCtx, BgActor* bgActor) { + bgActor->actor = NULL; + bgActor->colHeader = NULL; + ScaleRotPos_Init(&bgActor->prevTransform); + ScaleRotPos_Init(&bgActor->curTransform); + DynaLookup_Reset(&bgActor->dynaLookup); + DynaLookup_ResetVtxStartIndex(&bgActor->vtxStartIndex); + DynaLookup_ResetWaterBoxStartIndex(&bgActor->waterboxesStartIndex); + bgActor->boundingSphere.center.x = bgActor->boundingSphere.center.y = bgActor->boundingSphere.center.z = 0; + bgActor->boundingSphere.radius = 0; +} + +/** + * setActor internal + */ +void BgActor_SetActor(BgActor* bgActor, Actor* actor, CollisionHeader* colHeader) { + bgActor->actor = actor; + bgActor->colHeader = colHeader; + bgActor->prevTransform.scale = actor->scale; + bgActor->prevTransform.rot = actor->shape.rot; + bgActor->prevTransform.rot.x--; + bgActor->prevTransform.pos = actor->world.pos; + bgActor->curTransform.scale = actor->scale; + bgActor->curTransform.rot = actor->shape.rot; + bgActor->curTransform.pos = actor->world.pos; +} + +/** + * Test if the BgActor transform is the same + */ +s32 BgActor_IsTransformUnchanged(BgActor* bgActor) { + return ScaleRotPos_IsEqual(&bgActor->prevTransform, &bgActor->curTransform); +} + +/** + * NULL polyList + */ +void DynaPoly_NullPolyList(CollisionPoly** polyList) { + *polyList = NULL; +} + +/** + * Allocate dyna.polyList + */ +void DynaPoly_AllocPolyList(GlobalContext* globalCtx, CollisionPoly** polyList, s32 numPolys) { + *polyList = THA_AllocEndAlign(&globalCtx->state.heap, numPolys * sizeof(CollisionPoly), -2); +} + +/** + * NULL vtxList + */ +void DynaPoly_NullVtxList(Vec3s** vtxList) { + *vtxList = NULL; +} + +/** + * Allocate dyna.vtxList + */ +void DynaPoly_AllocVtxList(GlobalContext* globalCtx, Vec3s** vtxList, s32 numVtx) { + *vtxList = THA_AllocEndAlign(&globalCtx->state.heap, numVtx * sizeof(Vec3s), -2); +} + +/** + * Init dyna.waterBoxList + */ +void DynaPoly_InitWaterBoxList(DynaWaterBoxList* waterBoxList) { + waterBoxList->unk0 = 0; + waterBoxList->boxes = NULL; +} + +/** + * Allocate dyna.waterBoxList + */ +void DynaPoly_AllocWaterBoxList(GlobalContext* globalCtx, DynaWaterBoxList* waterBoxList, s32 numWaterBoxes) { + waterBoxList->boxes = THA_AllocEndAlign(&globalCtx->state.heap, numWaterBoxes * sizeof(WaterBox), -2); +} + +/** + * Update BgActor's prevTransform + */ +void DynaPoly_SetBgActorPrevTransform(GlobalContext* globalCtx, BgActor* bgActor) { + bgActor->prevTransform = bgActor->curTransform; +} + +/** + * Is BgActor Id + */ +s32 DynaPoly_IsBgIdBgActor(s32 bgId) { + if (bgId < 0 || bgId >= BG_ACTOR_MAX) { + return false; + } + return true; +} + +/** + * Init DynaCollisionContext + */ +void DynaPoly_Init(GlobalContext* globalCtx, DynaCollisionContext* dyna) { + dyna->bitFlag = DYNAPOLY_INVALIDATE_LOOKUP; + DynaPoly_NullPolyList(&dyna->polyList); + DynaPoly_NullVtxList(&dyna->vtxList); + DynaPoly_InitWaterBoxList(&dyna->waterBoxList); + DynaSSNodeList_Init(globalCtx, &dyna->polyNodes); +} + +/** + * Set DynaCollisionContext + */ +void DynaPoly_Alloc(GlobalContext* globalCtx, DynaCollisionContext* dyna) { + s32 i; + + for (i = 0; i < BG_ACTOR_MAX; i++) { + BgActor_Init(globalCtx, &dyna->bgActors[i]); + dyna->bgActorFlags[i] = 0; + } + DynaPoly_NullPolyList(&dyna->polyList); + DynaPoly_AllocPolyList(globalCtx, &dyna->polyList, dyna->polyListMax); + + DynaPoly_NullVtxList(&dyna->vtxList); + DynaPoly_AllocVtxList(globalCtx, &dyna->vtxList, dyna->vtxListMax); + + DynaPoly_InitWaterBoxList(&dyna->waterBoxList); + DynaPoly_AllocWaterBoxList(globalCtx, &dyna->waterBoxList, DYNA_WATERBOX_MAX); + + DynaSSNodeList_Init(globalCtx, &dyna->polyNodes); + DynaSSNodeList_Alloc(globalCtx, &dyna->polyNodes, dyna->polyNodesMax); +} + +/** + * Set BgActor + * original name: DynaPolyInfo_setActor + */ +s32 DynaPoly_SetBgActor(GlobalContext* globalCtx, DynaCollisionContext* dyna, Actor* actor, + CollisionHeader* colHeader) { + s32 bgId; + s32 foundSlot = false; + + for (bgId = 0; bgId < BG_ACTOR_MAX; bgId++) { + if (!(dyna->bgActorFlags[bgId] & 1)) { + dyna->bgActorFlags[bgId] |= 1; + foundSlot = true; + break; + } + } + + if (foundSlot == false) { + return BG_ACTOR_MAX; + } + + BgActor_SetActor(&dyna->bgActors[bgId], actor, colHeader); + dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP; + + dyna->bgActorFlags[bgId] &= ~2; + return bgId; +} + +/** + * Gets the actor assigned to `bgId` + */ +DynaPolyActor* DynaPoly_GetActor(CollisionContext* colCtx, s32 bgId) { + if (!DynaPoly_IsBgIdBgActor(bgId) || !(colCtx->dyna.bgActorFlags[bgId] & 1) || + colCtx->dyna.bgActorFlags[bgId] & 2) { + return NULL; + } + return (DynaPolyActor*)colCtx->dyna.bgActors[bgId].actor; +} + +void func_800C62BC(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId) { + if (DynaPoly_IsBgIdBgActor(bgId)) { + dyna->bgActorFlags[bgId] |= 4; + dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP; + } +} + +void func_800C6314(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId) { + if (DynaPoly_IsBgIdBgActor(bgId)) { + dyna->bgActorFlags[bgId] &= ~4; + dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP; + } +} + +void func_800C636C(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId) { + if (DynaPoly_IsBgIdBgActor(bgId)) { + dyna->bgActorFlags[bgId] |= 8; + dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP; + } +} + +void func_800C63C4(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId) { + if (DynaPoly_IsBgIdBgActor(bgId)) { + dyna->bgActorFlags[bgId] &= ~8; + dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP; + } +} + +void func_800C641C(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId) { + if (DynaPoly_IsBgIdBgActor(bgId)) { + dyna->bgActorFlags[bgId] |= 0x20; + dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP; + } +} + +void func_800C6474(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId) { + if (DynaPoly_IsBgIdBgActor(bgId)) { + dyna->bgActorFlags[bgId] &= ~0x20; + dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP; + } +} + +/** + * original name: DynaPolyInfo_delReserve + */ +void DynaPoly_DeleteBgActor(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId) { + DynaPolyActor* actor; + + if (DynaPoly_IsBgIdBgActor(bgId) == false) { + return; + } + actor = DynaPoly_GetActor(&globalCtx->colCtx, bgId); + if (actor != NULL) { + + actor->bgId = BGACTOR_NEG_ONE; + dyna->bgActors[bgId].actor = NULL; + dyna->bgActorFlags[bgId] |= 2; + } +} + +void func_800C6554(GlobalContext* globalCtx, DynaCollisionContext* dyna) { + dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP; +} + +void BgCheck_CalcWaterboxDimensions(Vec3f* minPos, Vec3f* maxXPos, Vec3f* maxZPos, Vec3s* minPosOut, s16* xLength, + s16* zLength) { + f32 temp; + + minPosOut->x = minPos->x; + minPosOut->y = minPos->y; + minPosOut->z = minPos->z; + + if (maxXPos->x < minPosOut->x) { + minPosOut->x = maxXPos->x; + } + if (maxXPos->y < minPosOut->y) { + minPosOut->y = maxXPos->y; + } + if (maxXPos->z < minPosOut->z) { + minPosOut->z = maxXPos->z; + } + + if (maxZPos->x < minPosOut->x) { + minPosOut->x = maxZPos->x; + } + if (maxZPos->y < minPosOut->y) { + minPosOut->y = maxZPos->y; + } + if (maxZPos->z < minPosOut->z) { + minPosOut->z = maxZPos->z; + } + + *xLength = minPos->x - minPosOut->x; + temp = maxXPos->x - minPosOut->x; + + if (*xLength < temp) { + *xLength = temp; + } + temp = maxZPos->x - minPosOut->x; + if (*xLength < temp) { + *xLength = temp; + } + *zLength = minPos->z - minPosOut->z; + + temp = maxXPos->z - minPosOut->z; + if (*zLength < temp) { + *zLength = temp; + } + temp = maxZPos->z - minPosOut->z; + if (*zLength < temp) { + *zLength = temp; + } +} + +#ifdef NON_MATCHING +/** + * original name: DynaPolyInfo_expandSRT + */ +void DynaPoly_ExpandSRT(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId, s32* vtxStartIndex, + s32* polyStartIndex, s32* waterBoxStartIndex) { + Actor* actor; + s32 pad; + s32 pad2; + f32 numVtxInverse; + s32 i; + Vec3f pos; // sp170 + Sphere16* sphere; + Vec3s* dVtxList; + Vec3s* point; + Vec3f newCenterPoint; // sp158 + + f32 newRadiusSq; + CollisionHeader* pbgdata; + Vec3f newVtx; // sp144 + Vec3f vtxA; // sp138 + Vec3f vtxB; // sp12C + Vec3f vtxC; // sp120 + Vec3f newNormal; + s32 wi; + Vec3f spB8; // waterbox ? + Vec3f spAC; + Vec3f spA0; // waterbox ? + Vec3f sp94; + Vec3f sp88; // waterbox ? + Vec3f sp7C; + WaterBox* waterBox; + + pbgdata = dyna->bgActors[bgId].colHeader; + sphere = &dyna->bgActors[bgId].boundingSphere; + actor = dyna->bgActors[bgId].actor; + dyna->bgActors[bgId].dynaLookup.polyStartIndex = *polyStartIndex; + dyna->bgActors[bgId].vtxStartIndex = *vtxStartIndex; + dyna->bgActors[bgId].waterboxesStartIndex = *waterBoxStartIndex; + pos = actor->world.pos; + pos.y += actor->shape.yOffset * actor->scale.y; + + ScaleRotPos_SetValue(&dyna->bgActors[bgId].curTransform, &actor->scale, &actor->shape.rot, &pos); + + if (dyna->bgActorFlags[bgId] & 4) { + return; + } + + if (!(DYNA_WATERBOX_MAX >= *waterBoxStartIndex + pbgdata->numWaterBoxes)) { + sprintf(D_801EDAA8, "water_poly Error:[MoveBG OSUGI!!!]"); + sprintf(D_801EDAF8, "num = %d > %d\n", *waterBoxStartIndex + pbgdata->numWaterBoxes, DYNA_WATERBOX_MAX); + Fault_AddHungupAndCrashImpl(D_801EDAA8, D_801EDAF8); + } + + if (!(dyna->polyListMax >= *polyStartIndex + pbgdata->numPolygons)) { + sprintf(D_801EDAA8, "bg_poly Error:[MoveBG OSUGI!!!]"); + sprintf(D_801EDAF8, "num = %d > %d\n", *polyStartIndex + pbgdata->numPolygons, dyna->polyListMax); + Fault_AddHungupAndCrashImpl(D_801EDAA8, D_801EDAF8); + } + + if (!(dyna->vtxListMax >= *vtxStartIndex + pbgdata->numVertices)) { + sprintf(D_801EDAA8, "bg_vert Error:[MoveBG OSUGI!!!]"); + sprintf(D_801EDAF8, "num = %d > %d\n", *vtxStartIndex + pbgdata->numVertices, dyna->vtxListMax); + Fault_AddHungupAndCrashImpl(D_801EDAA8, D_801EDAF8); + } + + if (!(dyna->bitFlag & DYNAPOLY_INVALIDATE_LOOKUP) && BgActor_IsTransformUnchanged(&dyna->bgActors[bgId])) { + s32 pi; + + for (pi = *polyStartIndex; pi < *polyStartIndex + pbgdata->numPolygons; pi++) { + CollisionPoly* poly = &dyna->polyList[pi]; + s16 normalY = poly->normal.y; + + if (normalY > COLPOLY_SNORMAL(0.5f)) { + if (!(dyna->bgActorFlags[bgId] & 0x20)) { + s16 polyIndex = pi; + + DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.floor, &polyIndex); + } + } else if (normalY < COLPOLY_SNORMAL(-0.8f)) { + if (!(dyna->bgActorFlags[bgId] & 8)) { + s16 polyIndex = pi; + + DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.ceiling, + &polyIndex); + } + } else { + s16 polyIndex = pi; + + DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.wall, &polyIndex); + } + } + + *polyStartIndex += pbgdata->numPolygons; + *vtxStartIndex += pbgdata->numVertices; + *waterBoxStartIndex += pbgdata->numWaterBoxes; + } else { + SkinMatrix_SetScaleRotateYRPTranslate( + &D_801EDA40, dyna->bgActors[bgId].curTransform.scale.x, dyna->bgActors[bgId].curTransform.scale.y, + dyna->bgActors[bgId].curTransform.scale.z, dyna->bgActors[bgId].curTransform.rot.x, + dyna->bgActors[bgId].curTransform.rot.y, dyna->bgActors[bgId].curTransform.rot.z, + dyna->bgActors[bgId].curTransform.pos.x, dyna->bgActors[bgId].curTransform.pos.y, + dyna->bgActors[bgId].curTransform.pos.z); + + if (pbgdata->numVertices != 0 && pbgdata->numPolygons != 0) { + numVtxInverse = 1.0f / pbgdata->numVertices; + newCenterPoint.x = newCenterPoint.y = newCenterPoint.z = 0.0f; + for (i = 0; i < pbgdata->numVertices; i++) { + Vec3f vtx; // spF4 + Vec3f vtxT; // spE8 Vtx after mtx transform + + Math_Vec3s_ToVec3f(&vtx, &pbgdata->vtxList[i]); + SkinMatrix_Vec3fMtxFMultXYZ(&D_801EDA40, &vtx, &vtxT); + BgCheck_Vec3fToVec3s(&dyna->vtxList[*vtxStartIndex + i], &vtxT); + + if (i == 0) { + dyna->bgActors[bgId].minY = dyna->bgActors[bgId].maxY = vtxT.y; + } else if (vtxT.y < dyna->bgActors[bgId].minY) { + dyna->bgActors[bgId].minY = vtxT.y; + } else if (dyna->bgActors[bgId].maxY < vtxT.y) { + dyna->bgActors[bgId].maxY = vtxT.y; + } + newCenterPoint.x += vtxT.x; + newCenterPoint.y += vtxT.y; + newCenterPoint.z += vtxT.z; + } + + newCenterPoint.x *= numVtxInverse; + newCenterPoint.y *= numVtxInverse; + newCenterPoint.z *= numVtxInverse; + sphere->center.x = newCenterPoint.x; + sphere->center.y = newCenterPoint.y; + sphere->center.z = newCenterPoint.z; + newRadiusSq = -100.0f; + + for (i = 0; i < pbgdata->numVertices; i++) { + f32 radiusSq; + s32 idx = *vtxStartIndex + i; + + newVtx.x = dyna->vtxList[idx].x; + newVtx.y = dyna->vtxList[idx].y; + newVtx.z = dyna->vtxList[idx].z; + radiusSq = Math3D_Vec3fDistSq(&newVtx, &newCenterPoint); + if (newRadiusSq < radiusSq) { + newRadiusSq = radiusSq; + } + } + + sphere->radius = sqrtf(newRadiusSq) * 1.1f; + + for (i = 0; i < pbgdata->numPolygons; i++) { + CollisionPoly* newPoly = &dyna->polyList[*polyStartIndex + i]; + f32 newNormMagnitude; + u32 vIA; + u32 vIB; + u32 vIC; + + *newPoly = pbgdata->polyList[i]; + + vIA = (COLPOLY_VTX_INDEX(newPoly->flags_vIA) + *vtxStartIndex); + vIB = (COLPOLY_VTX_INDEX(newPoly->flags_vIB) + *vtxStartIndex); + vIC = newPoly->vIC + *vtxStartIndex; + + newPoly->flags_vIA = vIA | ((*newPoly).flags_vIA & 0xE000); + newPoly->flags_vIB = vIB | ((*newPoly).flags_vIB & 0xE000); + newPoly->vIC = vIC; + dVtxList = dyna->vtxList; + vtxA.x = dVtxList[vIA].x; + vtxA.y = dVtxList[vIA].y; + vtxA.z = dVtxList[vIA].z; + vtxB.x = dVtxList[vIB].x; + vtxB.y = dVtxList[vIB].y; + vtxB.z = dVtxList[vIB].z; + vtxC.x = dVtxList[vIC].x; + vtxC.y = dVtxList[vIC].y; + vtxC.z = dVtxList[vIC].z; + Math3D_SurfaceNorm(&vtxA, &vtxB, &vtxC, &newNormal); + newNormMagnitude = Math3D_Vec3fMagnitude(&newNormal); + + if (!IS_ZERO(newNormMagnitude)) { + newNormal.x *= (1.0f / newNormMagnitude); + newNormal.y *= (1.0f / newNormMagnitude); + newNormal.z *= (1.0f / newNormMagnitude); + newPoly->normal.x = COLPOLY_SNORMAL(newNormal.x); + newPoly->normal.y = COLPOLY_SNORMAL(newNormal.y); + newPoly->normal.z = COLPOLY_SNORMAL(newNormal.z); + } + + newPoly->dist = -DOTXYZ(newNormal, dVtxList[vIA]); + if (newNormal.y > 0.5f) { + s16 polyId = *polyStartIndex + i; + + DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.floor, &polyId); + } else if (newNormal.y < -0.8f) { + s16 polyId = *polyStartIndex + i; + + DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.ceiling, &polyId); + } else { + s16 polyId = *polyStartIndex + i; + + DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.wall, &polyId); + } + } + } + + for (wi = 0; wi < pbgdata->numWaterBoxes; wi++) { + Math_Vec3s_ToVec3f(&spB8, &pbgdata->waterBoxes[wi].minPos); + Math_Vec3f_Copy(&spA0, &spB8); + spA0.x += pbgdata->waterBoxes[wi].xLength; + Math_Vec3f_Copy(&sp88, &spB8); + sp88.z += pbgdata->waterBoxes[wi].zLength; + SkinMatrix_Vec3fMtxFMultXYZ(&D_801EDA40, &spB8, &spAC); + SkinMatrix_Vec3fMtxFMultXYZ(&D_801EDA40, &spA0, &sp94); + SkinMatrix_Vec3fMtxFMultXYZ(&D_801EDA40, &sp88, &sp7C); + waterBox = &dyna->waterBoxList.boxes[*waterBoxStartIndex + wi]; + BgCheck_CalcWaterboxDimensions(&spAC, &sp94, &sp7C, &waterBox->minPos, &waterBox->xLength, + &waterBox->zLength); + waterBox->properties = pbgdata->waterBoxes[wi].properties; + } + + *polyStartIndex += pbgdata->numPolygons; + *vtxStartIndex += pbgdata->numVertices; + *waterBoxStartIndex += pbgdata->numWaterBoxes; + } +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/DynaPoly_ExpandSRT.s") +#endif + +void BgCheck_ResetFlagsIfLoadedActor(GlobalContext* globalCtx, DynaCollisionContext* dyna, Actor* actor) { + DynaPolyActor* dynaActor; + s32 i; + + for (i = 0; i < BG_ACTOR_MAX; i++) { + if ((dyna->bgActorFlags[i] & 1)) { + dynaActor = DynaPoly_GetActor(&globalCtx->colCtx, i); + if (dynaActor != NULL && &dynaActor->actor == actor) { + DynaPolyActor_ResetState((DynaPolyActor*)actor); + return; + } + } + } +} + +/** + * original name: DynaPolyInfo_setup + */ +void DynaPoly_Setup(GlobalContext* globalCtx, DynaCollisionContext* dyna) { + DynaPolyActor* actor; + s32 vtxStartIndex; + s32 polyStartIndex; + s32 waterBoxStartIndex; + s32 i; + + DynaSSNodeList_ResetCount(&dyna->polyNodes); + + for (i = 0; i < BG_ACTOR_MAX; i++) { + DynaLookup_ResetLists(&dyna->bgActors[i].dynaLookup); + } + + for (i = 0; i < BG_ACTOR_MAX; i++) { + if (dyna->bgActorFlags[i] & 2) { + // Initialize BgActor + dyna->bgActorFlags[i] = 0; + BgActor_Init(globalCtx, &dyna->bgActors[i]); + dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP; + } + if (dyna->bgActors[i].actor != NULL && dyna->bgActors[i].actor->update == NULL) { + // Delete BgActor + actor = DynaPoly_GetActor(&globalCtx->colCtx, i); + if (actor == NULL) { + return; + } + actor->bgId = BGACTOR_NEG_ONE; + dyna->bgActorFlags[i] = 0; + + BgActor_Init(globalCtx, &dyna->bgActors[i]); + dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP; + } + } + vtxStartIndex = 0; + polyStartIndex = 0; + waterBoxStartIndex = 0; + for (i = 0; i < BG_ACTOR_MAX; i++) { + if ((dyna->bgActorFlags[i] & 1) && !(dyna->bgActorFlags[i] & 2)) { + DynaPoly_ExpandSRT(globalCtx, dyna, i, &vtxStartIndex, &polyStartIndex, &waterBoxStartIndex); + } + } + dyna->bitFlag &= ~DYNAPOLY_INVALIDATE_LOOKUP; +} + +/** + * Compute the number of dynamic resources in use? + */ +void func_800C756C(DynaCollisionContext* dyna, s32* numPolygons, s32* numVertices, s32* numWaterBoxes) { + s32 i; + CollisionHeader* colHeader; + + *numPolygons = 0; + *numVertices = 0; + *numWaterBoxes = 0; + + for (i = 0; i < BG_ACTOR_MAX; i++) { + if ((dyna->bgActorFlags[i] & 1) && !(dyna->bgActorFlags[i] & 2) && !(dyna->bgActorFlags[i] & 4)) { + colHeader = dyna->bgActors[i].colHeader; + *numPolygons += colHeader->numPolygons; + *numVertices += colHeader->numVertices; + *numWaterBoxes += colHeader->numWaterBoxes; + } + } +} + +/** + * Update all BgActor's previous ScaleRotPos + */ +void DynaPoly_UpdateBgActorTransforms(GlobalContext* globalCtx, DynaCollisionContext* dyna) { + s32 i; + + for (i = 0; i < BG_ACTOR_MAX; i++) { + if (dyna->bgActorFlags[i] & 1) { + DynaPoly_SetBgActorPrevTransform(globalCtx, &dyna->bgActors[i]); + } + } +} + +/** + * Perform dyna poly raycast toward floor on a list of floor, wall, or ceiling polys + * `listType` specifies the poly list type (e.g. DYNA_RAYCAST_FLOORS) + */ +f32 BgCheck_RaycastFloorDynaList(DynaRaycast* dynaRaycast, u32 listType) { + CollisionPoly* polyList; + SSNode* curNode; + f32 result; + f32 yIntersect; + s16 id; + + result = dynaRaycast->yIntersect; + if (dynaRaycast->ssList->head == SS_NULL) { + return result; + } + polyList = dynaRaycast->dyna->polyList; + curNode = &dynaRaycast->dyna->polyNodes.tbl[dynaRaycast->ssList->head]; + + while (true) { + id = curNode->polyId; + if (COLPOLY_VIA_FLAG_TEST(polyList[id].flags_vIA, dynaRaycast->xpFlags) || + (COLPOLY_VIA_FLAG_TEST(polyList[id].flags_vIB, 4) && + ((dynaRaycast->actor != NULL && dynaRaycast->actor->category != ACTORCAT_PLAYER) || + (dynaRaycast->actor == NULL && dynaRaycast->xpFlags != COLPOLY_IGNORE_CAMERA))) || + ((dynaRaycast->unk_24 & 0x20) && func_800C9B68(dynaRaycast->colCtx, &polyList[id], dynaRaycast->unk1C))) { + if (curNode->next == SS_NULL) { + break; + } else { + curNode = &dynaRaycast->dyna->polyNodes.tbl[curNode->next]; + continue; + } + } + if ((listType & (DYNA_RAYCAST_WALLS | DYNA_RAYCAST_CEILINGS)) && (dynaRaycast->unk_24 & 0x10) && + COLPOLY_GET_NORMAL(polyList[id].normal.y) < 0.0f) { + if (curNode->next == SS_NULL) { + break; + } else { + curNode = &dynaRaycast->dyna->polyNodes.tbl[curNode->next]; + continue; + } + } + if (CollisionPoly_CheckYIntersectApprox1(&polyList[id], dynaRaycast->dyna->vtxList, dynaRaycast->pos->x, + dynaRaycast->pos->z, &yIntersect, dynaRaycast->checkDist) && + yIntersect < dynaRaycast->pos->y && result < yIntersect) { + result = yIntersect; + *dynaRaycast->resultPoly = &dynaRaycast->dyna->polyList[id]; + } + if (curNode->next == SS_NULL) { + break; + } else { + curNode = &dynaRaycast->dyna->polyNodes.tbl[curNode->next]; + continue; + } + } + return result; +} + +#ifdef NON_MATCHING +/** + * Perform dyna poly raycast toward floor + * returns the yIntersect of the poly found, or BGCHECK_Y_MIN if no poly is found + */ +f32 BgCheck_RaycastFloorDyna(DynaRaycast* dynaRaycast) { + s32 i; + f32 result; + f32 intersect2; + s32 i2; + s32 pauseState; + DynaPolyActor* dynaActor; + s32 pad; + Vec3f polyVtx[3]; + Vec3f polyNorm; + u32 polyIndex; + CollisionPoly* polyMin; + MtxF srpMtx; + f32 magnitude; + Vec3s* vtxList; + f32 polyDist; + Vec3f vtx; + f32 intersect; + ScaleRotPos* curTransform; + CollisionPoly* poly; + + result = BGCHECK_Y_MIN; + *dynaRaycast->bgId = BGCHECK_SCENE; + + for (i = 0; i < BG_ACTOR_MAX; i++) { + if (!(dynaRaycast->colCtx->dyna.bgActorFlags[i] & 1) || (dynaRaycast->colCtx->dyna.bgActorFlags[i] & 2)) { + continue; + } + + if (dynaRaycast->actor == dynaRaycast->colCtx->dyna.bgActors[i].actor || + dynaRaycast->pos->y < dynaRaycast->colCtx->dyna.bgActors[i].minY || + !Math3D_XZInSphere(&dynaRaycast->colCtx->dyna.bgActors[i].boundingSphere, dynaRaycast->pos->x, + dynaRaycast->pos->z)) { + continue; + } + + dynaRaycast->unk1C = i; + dynaRaycast->dyna = &dynaRaycast->colCtx->dyna; + if (dynaRaycast->unk_24 & BGCHECK_IGNORE_FLOOR) { + dynaRaycast->ssList = &dynaRaycast->colCtx->dyna.bgActors[i].dynaLookup.floor; + intersect2 = BgCheck_RaycastFloorDynaList(dynaRaycast, DYNA_RAYCAST_FLOORS); + + if (dynaRaycast->yIntersect < intersect2) { + dynaRaycast->yIntersect = intersect2; + *dynaRaycast->bgId = i; + result = intersect2; + } + } + if ((dynaRaycast->unk_24 & BGCHECK_IGNORE_WALL) || + (*dynaRaycast->resultPoly == NULL && (dynaRaycast->unk_24 & 8))) { + dynaRaycast->ssList = &dynaRaycast->colCtx->dyna.bgActors[i].dynaLookup.wall; + intersect2 = BgCheck_RaycastFloorDynaList(dynaRaycast, DYNA_RAYCAST_WALLS); + if (dynaRaycast->yIntersect < intersect2) { + + dynaRaycast->yIntersect = intersect2; + *dynaRaycast->bgId = i; + result = intersect2; + } + } + + if (dynaRaycast->unk_24 & BGCHECK_IGNORE_CEILING) { + dynaRaycast->ssList = &dynaRaycast->colCtx->dyna.bgActors[i].dynaLookup.ceiling; + intersect2 = BgCheck_RaycastFloorDynaList(dynaRaycast, DYNA_RAYCAST_CEILINGS); + if (dynaRaycast->yIntersect < intersect2) { + + dynaRaycast->yIntersect = intersect2; + *dynaRaycast->bgId = i; + result = intersect2; + } + } + } + + dynaActor = DynaPoly_GetActor(dynaRaycast->colCtx, *dynaRaycast->bgId); + if ((result != BGCHECK_Y_MIN) && (dynaActor != NULL) && (dynaRaycast->globalCtx != NULL)) { + pauseState = dynaRaycast->globalCtx->pauseCtx.state != 0; + if (!pauseState) { + pauseState = dynaRaycast->globalCtx->pauseCtx.debugState != 0; + } + if (!pauseState && (dynaRaycast->colCtx->dyna.bgActorFlags[*dynaRaycast->bgId] & 2)) { + curTransform = &dynaRaycast->dyna->bgActors[*dynaRaycast->bgId].curTransform; + polyMin = &dynaRaycast->dyna + ->polyList[(u16)dynaRaycast->dyna->bgActors[*dynaRaycast->bgId].dynaLookup.polyStartIndex]; + polyIndex = *dynaRaycast->resultPoly - polyMin; + poly = &dynaRaycast->dyna->bgActors[*dynaRaycast->bgId].colHeader->polyList[polyIndex]; + + SkinMatrix_SetScaleRotateYRPTranslate(&srpMtx, curTransform->scale.x, curTransform->scale.y, + curTransform->scale.z, curTransform->rot.x, curTransform->rot.y, + curTransform->rot.z, curTransform->pos.x, curTransform->pos.y, + curTransform->pos.z); + + vtxList = dynaRaycast->dyna->bgActors[*dynaRaycast->bgId].colHeader->vtxList; + + for (i2 = 0; i2 < 3; i2++) { + Math_Vec3s_ToVec3f(&vtx, &vtxList[COLPOLY_VTX_INDEX(poly->vtxData[i2])]); + SkinMatrix_Vec3fMtxFMultXYZ(&srpMtx, &vtx, &polyVtx[i2]); + } + Math3D_SurfaceNorm(&polyVtx[0], &polyVtx[1], &polyVtx[2], &polyNorm); + magnitude = Math3D_Vec3fMagnitude(&polyNorm); + + if (!IS_ZERO(magnitude)) { + polyNorm.x *= 1.0f / magnitude; + polyNorm.y *= 1.0f / magnitude; + polyNorm.z *= 1.0f / magnitude; + polyDist = -DOTXYZ(polyNorm, polyVtx[0]); + if (Math3D_TriChkPointParaYIntersectInsideTri( + &polyVtx[0], &polyVtx[1], &polyVtx[2], polyNorm.x, polyNorm.y, polyNorm.z, polyDist, + dynaRaycast->pos->z, dynaRaycast->pos->x, &intersect, dynaRaycast->checkDist)) { + if (fabsf(intersect - result) < 1.0f) { + + result = intersect; + } + } + } + } + } + return result; +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_RaycastFloorDyna.s") +#endif + +#ifdef NON_MATCHING +// regalloc, minor instruction ordering +/** + * Performs collision detection on a BgActor's wall polys on sphere `pos`, `radius` + * returns true if a collision was detected + * `outX` `outZ` return the displaced x,z coordinates + * `outPoly` returns the pointer to the nearest poly collided with, or NULL + * `outBgId` returns `bgId` if the poly SurfaceType's wall damage flag is not set, else ? + */ +s32 BgCheck_SphVsDynaWallInBgActor(CollisionContext* colCtx, u16 xpFlags, DynaCollisionContext* dyna, SSList* ssList, + f32* outX, f32* outZ, CollisionPoly** outPoly, s32* outBgId, Vec3f* pos, f32 radius, + s32 bgId, Actor* actor) { + f32 temp; + f32 intersect; + s32 result = false; + CollisionPoly* poly; + SSNode* curNode; + f32 nx; + f32 ny; + f32 nz; + Vec3f resultPos; + s16 polyId; + f32 zTemp; + f32 xTemp; + f32 normalXZ; + f32 invNormalXZ; + f32 planeDist; + f32 temp_f18; + f32 zIntersectDist; + f32 xIntersectDist; + f32 zMin; + f32 zMax; + f32 xMin; + f32 xMax; + + if (ssList->head == SS_NULL) { + return result; + } + + resultPos = *pos; + curNode = &dyna->polyNodes.tbl[ssList->head]; + + while (true) { + polyId = curNode->polyId; + poly = &dyna->polyList[polyId]; + CollisionPoly_GetNormalF(poly, &nx, &ny, &nz); + normalXZ = sqrtf(SQ(nx) + SQ(nz)); + + planeDist = Math3D_DistPlaneToPos(nx, ny, nz, poly->dist, &resultPos); + if (radius < fabsf(planeDist) || COLPOLY_VIA_FLAG_TEST(poly->flags_vIA, xpFlags) || + ((COLPOLY_VIA_FLAG_TEST(poly->flags_vIB, 4)) && ((actor != NULL && actor->category != ACTORCAT_PLAYER) || + (actor == NULL && xpFlags != COLPOLY_IGNORE_CAMERA)))) { + if (curNode->next == SS_NULL) { + break; + } else { + curNode = &dyna->polyNodes.tbl[curNode->next]; + continue; + } + } + invNormalXZ = 1.0f / normalXZ; + temp_f18 = fabsf(nz) * invNormalXZ; + if (temp_f18 < 0.4f) { + if (curNode->next == SS_NULL) { + break; + } else { + curNode = &dyna->polyNodes.tbl[curNode->next]; + continue; + } + } + + // compute poly zMin/zMax + zTemp = dyna->vtxList[COLPOLY_VTX_INDEX(poly->flags_vIA)].z; + zMax = zMin = zTemp; + + zTemp = dyna->vtxList[COLPOLY_VTX_INDEX(poly->flags_vIB)].z; + if (zTemp < zMin) { + zMin = zTemp; + } else if (zTemp > zMax) { + zMax = zTemp; + } + + zTemp = dyna->vtxList[poly->vIC].z; + if (zTemp < zMin) { + zMin = zTemp; + } else if (zMax < zTemp) { + zMax = zTemp; + } + + zMin -= radius; + zMax += radius; + if (resultPos.z < zMin || zMax < resultPos.z) { + if (curNode->next == SS_NULL) { + break; + } else { + curNode = &dyna->polyNodes.tbl[curNode->next]; + continue; + } + } + if (CollisionPoly_CheckZIntersectApprox(poly, dyna->vtxList, resultPos.x, pos->y, &intersect)) { + if (fabsf(intersect - resultPos.z) <= radius / temp_f18) { + if ((intersect - resultPos.z) * nz <= 4.0f) { + if (BgCheck_ComputeWallDisplacement(colCtx, poly, &resultPos.x, &resultPos.z, nx, ny, nz, + invNormalXZ, planeDist, radius, outPoly)) { + *outBgId = bgId; + } + result = true; + } + } + } + if (curNode->next == SS_NULL) { + break; + } + curNode = &dyna->polyNodes.tbl[curNode->next]; + } + + curNode = &dyna->polyNodes.tbl[ssList->head]; + while (true) { + polyId = curNode->polyId; + poly = &dyna->polyList[polyId]; + CollisionPoly_GetNormalF(poly, &nx, &ny, &nz); + normalXZ = sqrtf(SQ(nx) + SQ(nz)); + + planeDist = Math3D_DistPlaneToPos(nx, ny, nz, poly->dist, &resultPos); + if (radius < fabsf(planeDist) || COLPOLY_VIA_FLAG_TEST(poly->flags_vIA, xpFlags) || + (COLPOLY_VIA_FLAG_TEST(poly->flags_vIB, 4) && ((actor != NULL && actor->category != ACTORCAT_PLAYER) || + (actor == NULL && xpFlags != COLPOLY_IGNORE_CAMERA)))) { + if (curNode->next == SS_NULL) { + break; + } else { + curNode = &dyna->polyNodes.tbl[curNode->next]; + continue; + } + } + + invNormalXZ = 1.0f / normalXZ; + temp_f18 = fabsf(nx) * invNormalXZ; + if (temp_f18 < 0.4f) { + if (curNode->next == SS_NULL) { + break; + } else { + curNode = &dyna->polyNodes.tbl[curNode->next]; + continue; + } + } + + // compute poly xMin/xMax + xTemp = dyna->vtxList[COLPOLY_VTX_INDEX(poly->flags_vIA)].x; + xMax = xMin = xTemp; + xTemp = dyna->vtxList[COLPOLY_VTX_INDEX(poly->flags_vIB)].x; + + if (xTemp < xMin) { + xMin = xTemp; + } else if (xMax < xTemp) { + xMax = xTemp; + } + xTemp = dyna->vtxList[poly->vIC].x; + if (xTemp < xMin) { + xMin = xTemp; + } else if (xMax < xTemp) { + xMax = xTemp; + } + + xMin -= radius; + xMax += radius; + if (resultPos.x < xMin || xMax < resultPos.x) { + if (curNode->next == SS_NULL) { + break; + } else { + curNode = &dyna->polyNodes.tbl[curNode->next]; + continue; + } + } + + if (CollisionPoly_CheckXIntersectApprox(poly, dyna->vtxList, pos->y, resultPos.z, &intersect)) { + xIntersectDist = intersect - resultPos.x; + if (fabsf(xIntersectDist) <= radius / temp_f18) { + if (xIntersectDist * nx <= 4.0f) { + if (BgCheck_ComputeWallDisplacement(colCtx, poly, &resultPos.x, &resultPos.z, nx, ny, nz, + invNormalXZ, planeDist, radius, outPoly)) { + *outBgId = bgId; + } + result = true; + } + } + } + if (curNode->next == SS_NULL) { + break; + } + curNode = &dyna->polyNodes.tbl[curNode->next]; + } + *outX = resultPos.x; + *outZ = resultPos.z; + return result; +} +#else +s32 BgCheck_SphVsDynaWallInBgActor(CollisionContext* colCtx, u16 xpFlags, DynaCollisionContext* dyna, SSList* ssList, + f32* outX, f32* outZ, CollisionPoly** outPoly, s32* outBgId, Vec3f* pos, f32 radius, + s32 bgId, Actor* actor); +#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_SphVsDynaWallInBgActor.s") +#endif + +/** + * Performs collision detection on all dyna poly walls using sphere `pos`, `radius` + * returns true if a collision was detected + * `outX` `outZ` return the displaced x,z coordinates + * `outPoly` returns the pointer to the nearest poly collided with, or NULL + * `outBgId` returns the index of the BgActor that owns `outPoly` + * If `actor` is not NULL, an BgActor bound to that actor will be ignored + */ +s32 BgCheck_SphVsDynaWall(CollisionContext* colCtx, u16 xpFlags, f32* outX, f32* outZ, Vec3f* pos, f32 radius, + CollisionPoly** outPoly, s32* outBgId, Actor* actor) { + Vec3f resultPos; + s32 result; + f32 r; + f32 dz; + f32 dx; + BgActor* bgActor; + s32 i; + + result = false; + resultPos = *pos; + + for (i = 0; i < BG_ACTOR_MAX; i++) { + if (!(colCtx->dyna.bgActorFlags[i] & 1) || (colCtx->dyna.bgActorFlags[i] & 2)) { + continue; + } + if ((colCtx->dyna.bgActors + i)->actor == actor) { + continue; + } + bgActor = &colCtx->dyna.bgActors[i]; + + if (bgActor->minY > resultPos.y || bgActor->maxY < resultPos.y) { + continue; + } + + bgActor->boundingSphere.radius += (s16)radius; + + r = bgActor->boundingSphere.radius; + dx = bgActor->boundingSphere.center.x - resultPos.x; + dz = bgActor->boundingSphere.center.z - resultPos.z; + if (SQ(r) < (SQ(dx) + SQ(dz)) || (!Math3D_XYInSphere(&bgActor->boundingSphere, resultPos.x, resultPos.y) && + !Math3D_YZInSphere(&bgActor->boundingSphere, resultPos.y, resultPos.z))) { + bgActor->boundingSphere.radius -= (s16)radius; + continue; + } + bgActor->boundingSphere.radius -= (s16)radius; + if (BgCheck_SphVsDynaWallInBgActor(colCtx, xpFlags, &colCtx->dyna, + &(colCtx->dyna.bgActors + i)->dynaLookup.wall, outX, outZ, outPoly, outBgId, + &resultPos, radius, i, actor)) { + resultPos.x = *outX; + resultPos.z = *outZ; + result = true; + } + } + return result; +} + +/** + * Tests for collision with a dyna poly ceiling, starting at `ssList` + * returns true if a collision occurs, else false + * `outPoly` returns the poly collided with + * `outY` returns the y coordinate needed to not collide with `outPoly` + */ +s32 BgCheck_CheckDynaCeilingList(CollisionContext* colCtx, u16 xpFlags, DynaCollisionContext* dyna, SSList* ssList, + f32* outY, Vec3f* pos, f32 checkHeight, CollisionPoly** outPoly, Actor* actor, + s32 bgId) { + s16 polyId; + SSNode* curNode; + CollisionPoly* poly; + Vec3f testPos; + f32 ceilingY; + f32 sign; + f32 nx; + f32 ny; + f32 nz; + s32 result = false; + f32 intersectDist; + u16 padding; + + if (ssList->head == SS_NULL) { + return false; + } + curNode = &dyna->polyNodes.tbl[ssList->head]; + testPos = *pos; + + while (true) { + polyId = curNode->polyId; + poly = &dyna->polyList[polyId]; + if (COLPOLY_VIA_FLAG_TEST(poly->flags_vIA, xpFlags) || + (COLPOLY_VIA_FLAG_TEST(poly->flags_vIB, 4) && ((actor != NULL && actor->category != ACTORCAT_PLAYER) || + (actor == NULL && xpFlags != COLPOLY_IGNORE_CAMERA)))) { + if (curNode->next == SS_NULL) { + break; + } else { + curNode = &dyna->polyNodes.tbl[curNode->next]; + continue; + } + } + CollisionPoly_GetNormalF(poly, &nx, &ny, &nz); + if (checkHeight < Math3D_UDistPlaneToPos(nx, ny, nz, poly->dist, &testPos)) { + if (curNode->next == SS_NULL) { + break; + } else { + curNode = &dyna->polyNodes.tbl[curNode->next]; + continue; + } + } + if (CollisionPoly_CheckYIntersectApprox2(poly, dyna->vtxList, testPos.x, testPos.z, &ceilingY)) { + intersectDist = ceilingY - testPos.y; + if (testPos.y < ceilingY && intersectDist < checkHeight && intersectDist * ny <= 0.0f) { + sign = (0.0f <= ny) ? 1.0f : -1.0f; + testPos.y = (sign * checkHeight) + ceilingY; + result = true; + *outPoly = poly; + } + } + if (curNode->next == SS_NULL) { + break; + } else { + curNode = &dyna->polyNodes.tbl[curNode->next]; + continue; + } + } + *outY = testPos.y; + return result; +} + +/** + * Tests collision with a dyna poly ceiling + * returns true if a collision occurs, else false + * `outPoly` returns the poly collided with, while `outBgId` returns the id of the BgActor that owns the poly + * `outY` returns the y coordinate needed to not collide with `outPoly`, or `pos`.y + `checkDist` if no collision occurs + */ +s32 BgCheck_CheckDynaCeiling(CollisionContext* colCtx, u16 xpFlags, f32* outY, Vec3f* pos, f32 checkDist, + CollisionPoly** outPoly, s32* outBgId, Actor* actor) { + s32 i; + s32 result = false; + f32 resultY; + f32 tempY = checkDist + pos->y; + BgActor* bgActor; + CollisionPoly* poly; + + resultY = tempY; + + for (i = 0; i < BG_ACTOR_MAX; i++) { + if (!(colCtx->dyna.bgActorFlags[i] & 1) || (colCtx->dyna.bgActorFlags[i] & 2)) { + continue; + } + if (actor == colCtx->dyna.bgActors[i].actor) { + continue; + } + if (!Math3D_XZInSphere(&colCtx->dyna.bgActors[i].boundingSphere, pos->x, pos->z)) { + continue; + } + if (BgCheck_CheckDynaCeilingList(colCtx, xpFlags, &colCtx->dyna, &colCtx->dyna.bgActors[i].dynaLookup.ceiling, + &tempY, pos, checkDist, &poly, actor, i) && + tempY < resultY) { + + resultY = tempY; + *outPoly = poly; + *outBgId = i; + result = true; + } + } + *outY = resultY; + return result; +} + +/** + * Tests if DynaLineTest intersects with a poly + * returns true if a poly was intersected, else false + */ +s32 BgCheck_CheckLineAgainstBgActorSSList(DynaLineTest* dynaLineTest) { + f32 distSq; + s32 result; + SSNode* curNode; + Vec3f polyIntersect; + s16 polyId; + BgLineVsPolyTest test; + + result = false; + if (dynaLineTest->ssList->head == SS_NULL) { + return result; + } + curNode = &dynaLineTest->dyna->polyNodes.tbl[dynaLineTest->ssList->head]; + + test.vtxList = dynaLineTest->dyna->vtxList; + test.posA = dynaLineTest->posA; + test.posB = dynaLineTest->posB; + test.planeIntersect = &polyIntersect; + test.checkOneFace = dynaLineTest->checkOneFace; + test.checkDist = dynaLineTest->checkDist; + + while (true) { + polyId = curNode->polyId; + test.poly = &dynaLineTest->dyna->polyList[polyId]; + if (COLPOLY_VIA_FLAG_TEST(test.poly->flags_vIA, dynaLineTest->xpFlags) || + (COLPOLY_VIA_FLAG_TEST(test.poly->flags_vIB, 4) && + ((dynaLineTest->actor != NULL && dynaLineTest->actor->category != ACTORCAT_PLAYER) || + (dynaLineTest->actor == NULL && dynaLineTest->xpFlags != COLPOLY_IGNORE_CAMERA)))) { + if (curNode->next == SS_NULL) { + break; + } else { + curNode = &dynaLineTest->dyna->polyNodes.tbl[curNode->next]; + } + } else { + if (CollisionPoly_LineVsPoly(&test)) { + distSq = Math3D_Vec3fDistSq(dynaLineTest->posA, test.planeIntersect); + if (distSq < *dynaLineTest->distSq) { + *dynaLineTest->distSq = distSq; + *dynaLineTest->posResult = *test.planeIntersect; + *dynaLineTest->posB = *test.planeIntersect; + *dynaLineTest->resultPoly = test.poly; + result = true; + } + } + if (curNode->next == SS_NULL) { + break; + } else { + curNode = &dynaLineTest->dyna->polyNodes.tbl[curNode->next]; + } + } + } + return result; +} + +/** + * Tests if line `posA` `posB` intersects with a dyna poly within BgActor `bgId` + * `distSq` is the maximum squared distance to check for a collision + * returns true if an intersection occurred, else false + * `posB`? and `posResult` return the point of intersection + * `outPoly` returns the poly intersected + * `distSq` returns the squared distance of the intersection + */ +s32 BgCheck_CheckLineAgainstBgActor(CollisionContext* colCtx, u16 xpFlags, Vec3f* posA, Vec3f* posB, Vec3f* posResult, + CollisionPoly** outPoly, f32* distSq, s32 bgId, f32 checkDist, s32 bccFlags, + Actor* actor) { + s32 result = false; + DynaLineTest dynaLineTest; + + dynaLineTest.colCtx = colCtx; + dynaLineTest.xpFlags = xpFlags; + dynaLineTest.dyna = &colCtx->dyna; + dynaLineTest.posA = posA; + dynaLineTest.posB = posB; + dynaLineTest.posResult = posResult; + dynaLineTest.resultPoly = outPoly; + dynaLineTest.checkOneFace = (bccFlags & BGCHECK_CHECK_ONE_FACE) != 0; + dynaLineTest.distSq = distSq; + dynaLineTest.checkDist = checkDist; + dynaLineTest.actor = actor; + dynaLineTest.bgId = bgId; + + dynaLineTest.ssList = &colCtx->dyna.bgActors[bgId].dynaLookup.wall; + if (bccFlags & BGCHECK_CHECK_WALL) { + if (BgCheck_CheckLineAgainstBgActorSSList(&dynaLineTest)) { + result = true; + } + } + dynaLineTest.ssList = &colCtx->dyna.bgActors[bgId].dynaLookup.floor; + if (bccFlags & BGCHECK_CHECK_FLOOR) { + if (BgCheck_CheckLineAgainstBgActorSSList(&dynaLineTest)) { + result = true; + } + } + dynaLineTest.ssList = &colCtx->dyna.bgActors[bgId].dynaLookup.ceiling; + if (bccFlags & BGCHECK_CHECK_CEILING) { + if (BgCheck_CheckLineAgainstBgActorSSList(&dynaLineTest)) { + result = true; + } + } + return result; +} + +/** + * Tests if line from `posA` to `posB` passes through a dyna poly. + * returns true if so, otherwise false + * `outPoly` returns the pointer of the poly intersected. + * `outBgId` returns the BgActor index of the poly + */ +s32 BgCheck_CheckLineAgainstDyna(CollisionContext* colCtx, u16 xpFlags, Vec3f* posA, Vec3f* posB, Vec3f* posResult, + CollisionPoly** outPoly, f32* distSq, s32* outBgId, Actor* actor, f32 checkDist, + s32 bccFlags) { + s32 pad; + s32 i; + s32 result = false; + LineSegment line; + f32 ay; + f32 by; + + for (i = 0; i < BG_ACTOR_MAX; i++) { + if ((colCtx->dyna.bgActorFlags[i] & 1) && !(colCtx->dyna.bgActorFlags[i] & 2)) { + if (actor != colCtx->dyna.bgActors[i].actor) { + ay = posA->y; + by = posB->y; + if (!(ay < colCtx->dyna.bgActors[i].minY) || !(by < colCtx->dyna.bgActors[i].minY)) { + if (!(colCtx->dyna.bgActors[i].maxY < ay) || !(colCtx->dyna.bgActors[i].maxY < by)) { + line.a = *posA; + line.b = *posB; + if (Math3D_LineVsSph(&colCtx->dyna.bgActors[i].boundingSphere, &line) != 0) { + if (BgCheck_CheckLineAgainstBgActor(colCtx, xpFlags, posA, posB, posResult, outPoly, distSq, + i, checkDist, bccFlags, actor)) { + *outBgId = i; + result = true; + } + } + } + } + } + } + } + return result; +} + +/** + * Get first dyna poly intersecting sphere `center` `radius` from list `ssList` + * returns true if any poly intersects the sphere, else returns false + * `outPoly` returns the pointer of the first poly found that intersects + */ +s32 BgCheck_SphVsFirstDynaPolyList(CollisionContext* colCtx, u16 xpFlags, CollisionPoly** outPoly, Vec3f* center, + f32 radius, SSList* ssList, Actor* actor, s32 bgId) { + CollisionPoly* curPoly; + DynaCollisionContext* dyna; + SSNode* curNode; + s32 curPolyId; + + if (ssList->head == SS_NULL) { + return false; + } + dyna = &colCtx->dyna; + curNode = &dyna->polyNodes.tbl[ssList->head]; + while (true) { + curPolyId = curNode->polyId; + curPoly = &dyna->polyList[curPolyId]; + if (COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIA, xpFlags) || + (COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIB, 4) && ((actor != NULL && actor->category != ACTORCAT_PLAYER) || + (actor == NULL && xpFlags != COLPOLY_IGNORE_CAMERA)))) + + { + if (curNode->next == SS_NULL) { + break; + } else { + curNode = &dyna->polyNodes.tbl[curNode->next]; + continue; + } + } + if (CollisionPoly_SphVsPoly(curPoly, dyna->vtxList, center, radius)) { + *outPoly = curPoly; + return true; + } + if (curNode->next == SS_NULL) { + break; + } else { + curNode = &dyna->polyNodes.tbl[curNode->next]; + continue; + } + } + return false; +} + +/** + * Get first dyna poly intersecting sphere `center` `radius` from BgActor `bgId` + * returns true if any poly intersects the sphere, else false + * `outPoly` returns the pointer of the first poly found that intersects + */ +s32 BgCheck_SphVsFirstDynaPolyInBgActor(CollisionContext* colCtx, u16 xpFlags, CollisionPoly** outPoly, Vec3f* center, + f32 radius, s32 bgId, u16 bciFlags, Actor* actor) { + if (!(bciFlags & BGCHECK_IGNORE_CEILING)) { + if (BgCheck_SphVsFirstDynaPolyList(colCtx, xpFlags, outPoly, center, radius, + &colCtx->dyna.bgActors[bgId].dynaLookup.ceiling, actor, bgId)) { + return true; + } + } + if (!(bciFlags & BGCHECK_IGNORE_WALL)) { + if (BgCheck_SphVsFirstDynaPolyList(colCtx, xpFlags, outPoly, center, radius, + &colCtx->dyna.bgActors[bgId].dynaLookup.wall, actor, bgId)) { + return true; + } + } + if (!(bciFlags & BGCHECK_IGNORE_FLOOR)) { + if (BgCheck_SphVsFirstDynaPolyList(colCtx, xpFlags, outPoly, center, radius, + &colCtx->dyna.bgActors[bgId].dynaLookup.floor, actor, bgId)) { + return true; + } + } + return false; +} + +/** + * Gets first dyna poly intersecting sphere `center` `radius` + * returns true if poly detected, else false + * `outPoly` returns the first intersecting poly, while `outBgId` returns the BgActor index of that poly + */ +s32 BgCheck_SphVsFirstDynaPoly(CollisionContext* colCtx, u16 xpFlags, CollisionPoly** outPoly, s32* outBgId, + Vec3f* center, f32 radius, Actor* actor, u16 bciFlags) { + s32 i = 0; + Sphere16 testSphere; + + for (i = 0; i < BG_ACTOR_MAX; i++) { + if (!(colCtx->dyna.bgActorFlags[i] & 1) || (colCtx->dyna.bgActorFlags[i] & 2)) { + continue; + } + if (colCtx->dyna.bgActors[i].actor == actor) { + continue; + } + testSphere.center.x = center->x; + testSphere.center.y = center->y; + testSphere.center.z = center->z; + testSphere.radius = radius; + if (!Math3D_SphVsSph(&testSphere, &colCtx->dyna.bgActors[i].boundingSphere)) { + continue; + } + if (BgCheck_SphVsFirstDynaPolyInBgActor(colCtx, xpFlags, outPoly, center, radius, i, bciFlags, actor)) { + return true; + } + } + return false; +} + +/** + * SEGMENTED_TO_VIRTUAL CollisionHeader members + */ +void CollisionHeader_SegmentedToVirtual(CollisionHeader* colHeader) { + colHeader->vtxList = Lib_SegmentedToVirtual(colHeader->vtxList); + colHeader->polyList = Lib_SegmentedToVirtual(colHeader->polyList); + if (colHeader->surfaceTypeList) { + colHeader->surfaceTypeList = Lib_SegmentedToVirtual(colHeader->surfaceTypeList); + } + if (colHeader->cameraDataList) { + colHeader->cameraDataList = Lib_SegmentedToVirtual(colHeader->cameraDataList); + } + if (colHeader->waterBoxes) { + colHeader->waterBoxes = Lib_SegmentedToVirtual(colHeader->waterBoxes); + } +} + +/** + * Convert CollisionHeader Segmented to Virtual addressing + */ +void CollisionHeader_GetVirtual(CollisionHeader* colHeader, CollisionHeader** dest) { + *dest = Lib_SegmentedToVirtual(colHeader); + CollisionHeader_SegmentedToVirtual(*dest); +} + +/** + * SEGMENT_TO_VIRTUAL all active BgActor CollisionHeaders + */ +void BgCheck_InitCollisionHeaders(CollisionContext* colCtx, GlobalContext* globalCtx) { + DynaCollisionContext* dyna = &colCtx->dyna; + s32 i; + u16 flag; + + for (i = 0; i < BG_ACTOR_MAX; i++) { + flag = dyna->bgActorFlags[i]; + if ((flag & 1) && !(flag & 2)) { + Actor_SetObjectSegment(globalCtx, dyna->bgActors[i].actor); + CollisionHeader_SegmentedToVirtual(dyna->bgActors[i].colHeader); + } + } +} + +/** + * Reset SSNodeList polyCheckTbl + */ +void BgCheck_ResetPolyCheckTbl(SSNodeList* nodeList, s32 numPolys) { + u8* end = nodeList->polyCheckTbl + numPolys; + u8* t; + + for (t = nodeList->polyCheckTbl; t < end; t++) { + *t = 0; + } +} + +/** + * Get SurfaceType property set + */ +u32 SurfaceType_GetData(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId, s32 dataIdx) { + CollisionHeader* colHeader; + SurfaceType* surfaceTypes; + + colHeader = BgCheck_GetCollisionHeader(colCtx, bgId); + if (colHeader == NULL || poly == NULL) { + return 0; + } + surfaceTypes = colHeader->surfaceTypeList; + if (surfaceTypes == NULL) { + return 0; + } + return surfaceTypes[poly->type].data[dataIdx]; +} + +/** + * SurfaceType return CamData Index + */ +u32 SurfaceType_GetCamDataIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + return SurfaceType_GetData(colCtx, poly, bgId, 0) & 0xFF; +} + +/** + * CamData return camera setting + */ +u16 func_800C9728(CollisionContext* colCtx, u32 camId, s32 bgId) { + u16 result; + CollisionHeader* colHeader; + CamData* camData; + + colHeader = BgCheck_GetCollisionHeader(colCtx, bgId); + if (colHeader == NULL) { + return 0; + } + camData = colHeader->cameraDataList; + result = camData[camId].cameraSType; + return result; +} + +/** + * SurfaceType return camera setting + */ +u16 SurfaceType_GetCameraSetting(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + CollisionHeader* colHeader = BgCheck_GetCollisionHeader(colCtx, bgId); + CamData* camData; + SurfaceType* surfaceTypes; + + if (colHeader == NULL) { + return 0; + } + camData = colHeader->cameraDataList; + if (camData == NULL) { + return 0; + } + surfaceTypes = colHeader->surfaceTypeList; + if (surfaceTypes == NULL) { + return 0; + } + return func_800C9728(colCtx, SurfaceType_GetCamDataIndex(colCtx, poly, bgId), bgId); +} + +/** + * CamData get number of camera data blocks + */ +u16 func_800C97F8(CollisionContext* colCtx, u32 camId, s32 bgId) { + CollisionHeader* colHeader = BgCheck_GetCollisionHeader(colCtx, bgId); + CamData* camData; + + if (colHeader == NULL) { + return 0; + } + + camData = colHeader->cameraDataList; + if (camData == NULL) { + return 0; + } + return camData[camId].unk_02; +} + +/** + * SurfaceType get number of camera data blocks + */ +u16 func_800C9844(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + CollisionHeader* colHeader = BgCheck_GetCollisionHeader(colCtx, bgId); + CamData* camData; + SurfaceType* surfaceTypes; + + if (colHeader == NULL) { + return 0; + } + camData = colHeader->cameraDataList; + if (camData == NULL) { + return 0; + } + surfaceTypes = colHeader->surfaceTypeList; + if (surfaceTypes == NULL) { + return 0; + } + return func_800C97F8(colCtx, SurfaceType_GetCamDataIndex(colCtx, poly, bgId), bgId); +} + +/** + * CamData get camPosData + */ +Vec3s* func_800C98CC(CollisionContext* colCtx, s32 camId, s32 bgId) { + CollisionHeader* colHeader = BgCheck_GetCollisionHeader(colCtx, bgId); + CamData* cameraDataList; + + if (colHeader == NULL) { + return NULL; + } + cameraDataList = colHeader->cameraDataList; + if (cameraDataList == NULL) { + return NULL; + } + return Lib_SegmentedToVirtual(cameraDataList[camId].camPosData); +} + +/** + * SurfaceType Get camPosData + */ +Vec3s* SurfaceType_GetCamPosData(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + CollisionHeader* colHeader = BgCheck_GetCollisionHeader(colCtx, bgId); + CamData* camData; + SurfaceType* surfaceTypes; + + if (colHeader == NULL) { + return NULL; + } + camData = colHeader->cameraDataList; + if (camData == NULL) { + return NULL; + } + surfaceTypes = colHeader->surfaceTypeList; + if (surfaceTypes == NULL) { + return NULL; + } + return func_800C98CC(colCtx, SurfaceType_GetCamDataIndex(colCtx, poly, bgId), bgId); +} + +/** + * SurfaceType Get Scene Exit Index + */ +u32 SurfaceType_GetSceneExitIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 8 & 0x1F; +} + +/** + * SurfaceType Get ? Property (& 0x0003_E000) + */ +u32 func_800C99D4(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 13 & 0x1F; +} + +/** + * SurfaceType Get ? Property (& 0x001C_0000) + */ +u32 func_800C99FC(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 18 & 7; +} + +/** + * SurfaceType Get Wall Property (Internal) + */ +u32 func_800C9A24(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 21 & 0x1F; +} + +/** + * SurfaceType Get Wall Flags + */ +s32 func_800C9A4C(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + return sWallFlags[func_800C9A24(colCtx, poly, bgId)]; +} + +/** + * SurfaceType Is Wall Flag (1 << 0) Set + */ +s32 func_800C9A7C(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + return (func_800C9A4C(colCtx, poly, bgId) & 1) ? true : false; +} + +/** + * SurfaceType Is Wall Flag (1 << 1) Set + */ +s32 func_800C9AB0(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + return (func_800C9A4C(colCtx, poly, bgId) & 2) ? true : false; +} + +/** + * SurfaceType Is Wall Flag (1 << 2) Set + */ +s32 func_800C9AE4(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + return (func_800C9A4C(colCtx, poly, bgId) & 4) ? true : false; +} + +/** + * unused + */ +u32 func_800C9B18(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 26 & 0xF; +} + +/** + * SurfaceType Get Floor Property + */ +u32 func_800C9B40(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 26 & 0xF; +} + +/** + * SurfaceType Is Floor Minus 1 + */ +u32 func_800C9B68(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 30 & 1; +} + +/** + * SurfaceType Is Horse Blocked + */ +u32 SurfaceType_IsHorseBlocked(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 31 & 1; +} + +u32 func_800C9BB8(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + return SurfaceType_GetData(colCtx, poly, bgId, 1) & 0xF; +} + +/** + * SurfaceType Get Poly Sfx + */ +u16 SurfaceType_GetSfx(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + s32 id = func_800C9BB8(colCtx, poly, bgId); + + if (id < 0 || id > 14) { + return NA_SE_PL_WALK_GROUND - SFX_FLAG; + } + return sSurfaceTypeSfx[id]; +} + +/** + * SurfaceType Get ? (same indexer as Get Poly Sfx) + */ +s32 func_800C9C24(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId, s32 arg3) { + s32 id = func_800C9BB8(colCtx, poly, bgId); + + if (id < 0 || id > 14) { + return 0; + } + return D_801B46C0[id] & arg3; +} + +/** + * SurfaceType get terrain slope surface + */ +u32 SurfaceType_GetSlope(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + return SurfaceType_GetData(colCtx, poly, bgId, 1) >> 4 & 3; +} + +/** + * SurfaceType get surface lighting setting + */ +u32 SurfaceType_GetLightSettingIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + return SurfaceType_GetData(colCtx, poly, bgId, 1) >> 6 & 0x1F; +} + +/** + * SurfaceType get echo + */ +u32 SurfaceType_GetEcho(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + return SurfaceType_GetData(colCtx, poly, bgId, 1) >> 11 & 0x3F; +} + +/** + * SurfaceType Is Hookshot Surface + */ +u32 SurfaceType_IsHookshotSurface(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + return SurfaceType_GetData(colCtx, poly, bgId, 1) >> 17 & 1; +} + +/** + * CollisionPoly is ignored by entities + * Returns true if poly is ignored by entities, else false + */ +s32 SurfaceType_IsIgnoredByEntities(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + u32 flags; + + if (BgCheck_GetCollisionHeader(colCtx, bgId) == NULL) { + return true; + } + flags = poly->flags_vIA & 0x4000; + return !!flags; +} + +/** + * CollisionPoly is ignored by projectiles + * Returns true if poly is ignored by projectiles, else false + */ +s32 SurfaceType_IsIgnoredByProjectiles(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + u32 flags; + + if (BgCheck_GetCollisionHeader(colCtx, bgId) == NULL) { + return true; + } + flags = poly->flags_vIA & 0x8000; + return !!flags; +} + +/** + * CollisionPoly is conveyor enabled + * Returns true if `poly` is a conveyor surface, else false + */ +s32 SurfaceType_IsConveyor(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + u32 flags; + + if (BgCheck_GetCollisionHeader(colCtx, bgId) == NULL) { + return true; + } + if (poly == NULL) { + return false; + } + flags = poly->flags_vIB & 0x2000; + return !!flags; +} + +s32 func_800C9DDC(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + u32 flags; + + if (BgCheck_GetCollisionHeader(colCtx, bgId) == NULL) { + return true; + } + flags = poly->flags_vIB & 0x4000; + return !!flags; +} + +/** + * SurfaceType Get Conveyor Surface Speed + */ +u32 SurfaceType_GetConveyorSpeed(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + return SurfaceType_GetData(colCtx, poly, bgId, 1) >> 18 & 7; +} + +/** + * SurfaceType Get Conveyor Direction + * returns a value between 0-63, representing 360 / 64 degrees of rotation + */ +u32 SurfaceType_GetConveyorDirection(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + u32 data; + + data = SurfaceType_GetData(colCtx, poly, bgId, 1) >> 21; + if (colCtx->flags & 1) { + data += 0x20; + } + return data & 0x3F; +} + +/** + * SurfaceType is Wall Damage + */ +u32 SurfaceType_IsWallDamage(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + return (SurfaceType_GetData(colCtx, poly, bgId, 1) & 0x8000000) ? true : false; +} + +/** + * Internal. Get the water surface at point (`x`, `ySurface`, `z`). `ySurface` doubles as position y input + * returns true if point is within the xz boundaries of an active water box, else false + * `ySurface` returns the water box's surface, while `outWaterBox` returns a pointer to the WaterBox + */ +s32 WaterBox_GetSurfaceImpl(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, + WaterBox** outWaterBox, s32* bgId) { + CollisionHeader* colHeader; + u32 room; + WaterBox* curWaterBox; + s32 i; + + *bgId = BGCHECK_SCENE; + colHeader = colCtx->colHeader; + + if (colHeader->numWaterBoxes != 0 && colHeader->waterBoxes != NULL) { + for (curWaterBox = colHeader->waterBoxes; curWaterBox < colHeader->waterBoxes + colHeader->numWaterBoxes; + curWaterBox++) { + room = 0x3F & (curWaterBox->properties >> 13); + if (room == (u32)globalCtx->roomCtx.currRoom.num || room == 0x3F) { + if (curWaterBox->properties & 0x80000) { + continue; + } + if (curWaterBox->minPos.x < x && x < curWaterBox->minPos.x + curWaterBox->xLength) { + if (curWaterBox->minPos.z < z && z < curWaterBox->minPos.z + curWaterBox->zLength) { + *outWaterBox = curWaterBox; + *ySurface = curWaterBox->minPos.y; + return true; + } + } + } + } + } + + for (i = 0; i < BG_ACTOR_MAX; i++) { + if (colCtx->dyna.bgActorFlags[i] & 1) { + BgActor* bgActor; + if (colCtx->dyna.bgActorFlags[i] & 4) { + continue; + } + bgActor = &colCtx->dyna.bgActors[i]; + if (bgActor->colHeader->numWaterBoxes != 0 && bgActor->colHeader->waterBoxes != NULL) { + for (curWaterBox = colCtx->dyna.waterBoxList.boxes + bgActor->waterboxesStartIndex; + curWaterBox < colCtx->dyna.waterBoxList.boxes + bgActor->waterboxesStartIndex + + bgActor->colHeader->numWaterBoxes; + curWaterBox++) { + if (curWaterBox->properties & 0x80000) { + continue; + } + if (curWaterBox->minPos.x < x && x < curWaterBox->minPos.x + curWaterBox->xLength) { + if (curWaterBox->minPos.z < z && z < curWaterBox->minPos.z + curWaterBox->zLength) { + *outWaterBox = curWaterBox; + *ySurface = curWaterBox->minPos.y; + *bgId = i; + return true; + } + } + } + } + } + } + return false; +} + +s32 WaterBox_GetSurface1(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, + WaterBox** outWaterBox) { + WaterBox_GetSurface1_2(globalCtx, colCtx, x, z, ySurface, outWaterBox); +} + +s32 WaterBox_GetSurface1_2(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, + WaterBox** outWaterBox) { + s32 bgId; + return WaterBox_GetSurfaceImpl(globalCtx, colCtx, x, z, ySurface, outWaterBox, &bgId); +} + +#ifdef NON_MATCHING +/** + * Gets the first active WaterBox at `pos` where WaterBox.properties & 0x80000 == 0 + * `surfaceCheckDist` is the absolute y distance from the water surface to check + * returns the index of the waterbox found, or -1 if no waterbox is found + * `outWaterBox` returns the pointer to the waterbox found, or NULL if none is found + */ +s32 WaterBox_GetSurface2(GlobalContext* globalCtx, CollisionContext* colCtx, Vec3f* pos, f32 surfaceCheckDist, + WaterBox** outWaterBox, s32* bgId) { + CollisionHeader* colHeader; + s32 room; + s32 i; + WaterBox* waterBox; + + *bgId = BGCHECK_SCENE; + colHeader = colCtx->colHeader; + + //! @bug: check skips testing BgActor waterboxes + if (colHeader->numWaterBoxes == 0 || colHeader->waterBoxes == NULL) { + *outWaterBox = NULL; + return -1; + } + + for (i = 0; i < colHeader->numWaterBoxes; i++) { + waterBox = &colHeader->waterBoxes[i]; + + room = WATERBOX_ROOM(waterBox->properties); + if (!(room == globalCtx->roomCtx.currRoom.num || room == 0x3F)) { + continue; + } + if ((waterBox->properties & 0x80000)) { + continue; + } + if ((waterBox->minPos.x < pos->x && pos->x < waterBox->minPos.x + waterBox->xLength)) { + if ((waterBox->minPos.z < pos->z && pos->z < waterBox->minPos.z + waterBox->zLength)) { + if (pos->y - surfaceCheckDist < waterBox->minPos.y && waterBox->minPos.y < pos->y + surfaceCheckDist) { + *outWaterBox = waterBox; + return i; + } + } + } + } + + for (i = 0; i < BG_ACTOR_MAX; i++) { + WaterBox* iterator; + WaterBox* start; + BgActor* bgActor; + if (!(colCtx->dyna.bgActorFlags[i] & 1) || (colCtx->dyna.bgActorFlags[i] & 4) || + (colCtx->dyna.bgActorFlags[i] & 2)) { + continue; + } + bgActor = &colCtx->dyna.bgActors[i]; + for (iterator = colCtx->dyna.waterBoxList.boxes + bgActor->waterboxesStartIndex; + iterator < + colCtx->dyna.waterBoxList.boxes + bgActor->waterboxesStartIndex + bgActor->colHeader->numWaterBoxes; + iterator++) { + if (iterator->properties & 0x80000) { + continue; + } + if ((iterator->minPos.x < pos->x) && pos->x < iterator->minPos.x + iterator->xLength) { + if ((iterator->minPos.z < pos->z) && pos->z < iterator->minPos.z + iterator->zLength) { + if (pos->y - surfaceCheckDist < iterator->minPos.y && + iterator->minPos.y < pos->y + surfaceCheckDist) { + *bgId = i; + *outWaterBox = iterator; + return i; + } + } + } + } + } + + *outWaterBox = NULL; + return -1; +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/WaterBox_GetSurface2.s") +#endif + +f32 func_800CA568(CollisionContext* colCtx, s32 waterBoxId, s32 bgId) { + CollisionHeader* colHeader; + + colHeader = BgCheck_GetCollisionHeader(colCtx, bgId); + if ((colHeader == NULL) || (waterBoxId < 0) || (waterBoxId >= (s32)colHeader->numWaterBoxes)) { + return 0.0f; + } + if (bgId == BGCHECK_SCENE) { + return colCtx->colHeader->waterBoxes[waterBoxId].minPos.y; + } + return (&colCtx->dyna.waterBoxList.boxes[colCtx->dyna.bgActors[bgId].waterboxesStartIndex])[waterBoxId].minPos.y; +} + +/** + * WaterBox get CamData index + */ +u32 WaterBox_GetCamDataIndex(CollisionContext* colCtx, WaterBox* waterBox) { + u32 prop = waterBox->properties >> 0; + + return prop & 0xFF; +} + +/** + * WaterBox get CamData camera setting + */ +u16 WaterBox_GetCameraSetting(CollisionContext* colCtx, WaterBox* waterBox, s32 bgId) { + s32 pad[2]; + u16 result = 0; + CollisionHeader* colHeader; + CamData* camData; + s32 camId; + + colHeader = BgCheck_GetCollisionHeader(colCtx, bgId); + if (colHeader == NULL) { + return result; + } + camId = WaterBox_GetCamDataIndex(colCtx, waterBox); + camData = colHeader->cameraDataList; + + if (camData == NULL) { + return result; + } + + result = camData[camId].cameraSType; + return result; +} + +void func_800CA6B8(CollisionContext* colCtx, WaterBox* waterBox) { + WaterBox_GetCameraSetting(colCtx, waterBox, BGCHECK_SCENE); +} + +/** + * WaterBox get lighting settings + */ +u32 WaterBox_GetLightSettingIndex(CollisionContext* colCtx, WaterBox* waterBox) { + u32 prop = waterBox->properties >> 8; + + return prop & 0x1F; +} + +#ifdef NON_MATCHING +/** + * Get the water surface at point (`x`, `ySurface`, `z`). `ySurface` doubles as position y input + * same as WaterBox_GetSurfaceImpl, but tests if WaterBox properties & 0x80000 != 0 + * returns true if point is within the xz boundaries of an active water box, else false + * `ySurface` returns the water box's surface, while `outWaterBox` returns a pointer to the WaterBox + */ +s32 func_800CA6F0(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, + WaterBox** outWaterBox, s32* bgId) { + CollisionHeader* colHeader; + u32 room; + WaterBox* curWaterBox; + s32 i; + BgActor* bgActor; + + colHeader = colCtx->colHeader; + *outWaterBox = NULL; + *bgId = BGCHECK_SCENE; + + if (colHeader->numWaterBoxes == 0 || colHeader->waterBoxes == NULL) { + return false; + } + for (curWaterBox = colHeader->waterBoxes; curWaterBox < colHeader->waterBoxes + colHeader->numWaterBoxes; + curWaterBox++) { + room = WATERBOX_ROOM(curWaterBox->properties); + if (room == (u32)globalCtx->roomCtx.currRoom.num || room == 0x3F) { + if ((curWaterBox->properties & 0x80000) != 0) { + if (curWaterBox->minPos.x < x && x < curWaterBox->minPos.x + curWaterBox->xLength) { + if (curWaterBox->minPos.z < z && z < curWaterBox->minPos.z + curWaterBox->zLength) { + *outWaterBox = curWaterBox; + *ySurface = curWaterBox->minPos.y; + return true; + } + } + } + } + } + + for (i = 0; i < BG_ACTOR_MAX; i++) { + if ((colCtx->dyna.bgActorFlags[i] & 1) && !(colCtx->dyna.bgActorFlags[i] & 2)) { + WaterBox* boxes; + boxes = colCtx->dyna.waterBoxList.boxes; + bgActor = &colCtx->dyna.bgActors[i]; + if (bgActor->colHeader->numWaterBoxes != 0 && bgActor->colHeader->waterBoxes != NULL) { + for (curWaterBox = boxes + bgActor->waterboxesStartIndex; + curWaterBox < boxes + bgActor->waterboxesStartIndex + bgActor->colHeader->numWaterBoxes; + curWaterBox++) { + if ((curWaterBox->properties & 0x80000) != 0) { + if (curWaterBox->minPos.x < x && x < curWaterBox->minPos.x + curWaterBox->xLength) { + if (curWaterBox->minPos.z < z && z < curWaterBox->minPos.z + curWaterBox->zLength) { + *outWaterBox = curWaterBox; + *ySurface = curWaterBox->minPos.y; + *bgId = i; + return true; + } + } + } + } + } + } + } + return false; +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800CA6F0.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800CA9D0.s") +s32 func_800CA9D0(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, + WaterBox** outWaterBox) { + s32 bgId; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800CAA14.s") + return func_800CA6F0(globalCtx, colCtx, x, z, ySurface, outWaterBox, &bgId); +} + +/** + * Get the `closestPoint` to line (`pointA`, `pointB`) formed from the intersection of planes `polyA` and `polyB` + * returns true if the `closestPoint` exists, else returns false + */ +s32 func_800CAA14(CollisionPoly* polyA, CollisionPoly* polyB, Vec3f* pointA, Vec3f* pointB, Vec3f* closestPoint) { + f32 n1X; + f32 n1Y; + f32 n1Z; + f32 n2X; + f32 n2Y; + f32 n2Z; + s32 result; + + CollisionPoly_GetNormalF(polyA, &n1X, &n1Y, &n1Z); + CollisionPoly_GetNormalF(polyB, &n2X, &n2Y, &n2Z); + result = Math3D_PlaneVsLineSegClosestPoint(n1X, n1Y, n1Z, polyA->dist, n2X, n2Y, n2Z, polyB->dist, pointA, pointB, + closestPoint); + return result; +} diff --git a/src/code/z_collision_check.c b/src/code/z_collision_check.c index 059fbce09c..e11e6cbd74 100644 --- a/src/code/z_collision_check.c +++ b/src/code/z_collision_check.c @@ -941,7 +941,7 @@ s32 Collider_QuadSetNearestAC(GlobalContext* globalCtx, ColliderQuad* quad, Vec3 return 1; } Math_Vec3s_ToVec3f(&dcMid, &quad->dim.dcMid); - acDist = Math3D_DistanceSquared(&dcMid, hitPos); + acDist = Math3D_Vec3fDistSq(&dcMid, hitPos); if (acDist < quad->dim.acDist) { quad->dim.acDist = acDist; @@ -3510,7 +3510,7 @@ s32 CollisionCheck_LineOC_JntSph(GlobalContext* globalCtx, CollisionCheckContext D_801EDEB0.a = *a; D_801EDEB0.b = *b; - if (Math3D_ColSphereLineSeg(&element->dim.worldSphere, &D_801EDEB0) != 0) { + if (Math3D_LineVsSph(&element->dim.worldSphere, &D_801EDEB0) != 0) { return 1; } } @@ -3548,7 +3548,7 @@ s32 CollisionCheck_LineOC_Sphere(GlobalContext* globalCtx, CollisionCheckContext D_801EDFC8.a = *a; D_801EDFC8.b = *b; - if (Math3D_ColSphereLineSeg(&sphere->dim.worldSphere, &D_801EDFC8) != 0) { + if (Math3D_LineVsSph(&sphere->dim.worldSphere, &D_801EDFC8) != 0) { return 1; } diff --git a/src/code/z_common_data.c b/src/code/z_common_data.c index 88fa3e1037..26fd324a73 100644 --- a/src/code/z_common_data.c +++ b/src/code/z_common_data.c @@ -5,9 +5,9 @@ SaveContext gSaveContext; void SaveContext_Init(void) { bzero(&gSaveContext, sizeof(gSaveContext)); gSaveContext.playerForm = 0; - gSaveContext.seqIndex = 0xFF; + gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; gSaveContext.nightSeqIndex = 0xFF; - gSaveContext.unk_3F46 = 0; + gSaveContext.unk_3F46 = NA_BGM_GENERAL_SFX; gSaveContext.nextCutsceneIndex = 0xFFEF; gSaveContext.cutsceneTrigger = 0; gSaveContext.unk_3F4D = 0; diff --git a/src/code/z_elf_message.c b/src/code/z_elf_message.c index a674f4564d..7308b33f4e 100644 --- a/src/code/z_elf_message.c +++ b/src/code/z_elf_message.c @@ -1,3 +1,62 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_elf_message/func_800F05C0.s") +u16 ElfMessage_GetFirstCycleHint(GlobalContext* globalCtx) { + if (INV_CONTENT(ITEM_OCARINA) == ITEM_OCARINA) { + return 0; + } + if (CURRENT_DAY <= 0) { + return 0; + } + if (gSaveContext.weekEventReg[88] & 0x20) { + return 0; + } + if (gSaveContext.weekEventReg[79] & 0x10) { + if (gSaveContext.weekEventReg[8] & 0x40) { + return 0; + } + return 0x224; + } + if (!(gSaveContext.weekEventReg[8] & 0x80)) { + if (gSaveContext.weekEventReg[9] & 1) { + return 0x21E; + } + if (globalCtx->sceneNum == SCENE_YOUSEI_IZUMI) { + return 0; + } + return 0x21D; + } + if (gSaveContext.magicAcquired != true) { + return 0x21F; + } + if (INV_CONTENT(ITEM_DEED_LAND) == ITEM_DEED_LAND) { + if (globalCtx->sceneNum != SCENE_OKUJOU) { + return 0x244; + } + return 0; + } + if (INV_CONTENT(ITEM_MOON_TEAR) == ITEM_MOON_TEAR) { + if (gSaveContext.weekEventReg[86] & 4) { + return 0x242; + } + return 0x243; + } + if (gSaveContext.weekEventReg[74] & 0x20) { + return 0x223; + } + if (gSaveContext.weekEventReg[73] & 0x80) { + return 0x222; + } + if (gSaveContext.weekEventReg[73] & 0x20) { + return 0x221; + } + if (gSaveContext.weekEventReg[77] & 2) { + if (gSaveContext.weekEventReg[73] & 0x10) { + return 0x240; + } + return 0x241; + } + if ((gSaveContext.weekEventReg[86] & 2) || (gSaveContext.weekEventReg[73] & 0x40)) { + return 0x23F; + } + return 0x220; +} diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index 00d5be6388..acd827f8e9 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -460,7 +460,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 15.0f, 15.0f, 0x1D); - if (this->actor.floorHeight <= -32000.0f) { + if (this->actor.floorHeight <= BGCHECK_Y_MIN) { Actor_MarkForDeath(&this->actor); return; } diff --git a/src/code/z_fireobj.c b/src/code/z_fireobj.c index 816fec2be0..6e543d115a 100644 --- a/src/code/z_fireobj.c +++ b/src/code/z_fireobj.c @@ -94,7 +94,7 @@ void FireObj_StepSize(FireObj* fire) { void FireObj_UpdateStateTransitions(GlobalContext* globalCtx, FireObj* fire) { Player* player = GET_PLAYER(globalCtx); WaterBox* waterBox; - f32 sp44; + f32 waterY; s32 sp40 = 0; u8 nextState; Vec3f dist; @@ -113,8 +113,8 @@ void FireObj_UpdateStateTransitions(GlobalContext* globalCtx, FireObj* fire) { FireObj_SetState(fire, fire->dynamicSizeStep, nextState); } if ((fire->flags & 1) && (fire->state != FIRE_STATE_3) && - (func_800CA1E8(globalCtx, &globalCtx->colCtx, fire->position.x, fire->position.z, &sp44, &waterBox) != 0) && - ((fire->yScale * ((void)0, 6500.0f)) < (sp44 - fire->position.y))) { // Fake but IDK what else + WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, fire->position.x, fire->position.z, &waterY, &waterBox) && + ((fire->yScale * ((void)0, 6500.0f)) < (waterY - fire->position.y))) { // Fake but IDK what else FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_3); } if ((fire->flags & 2) && (player->itemActionParam == PLAYER_AP_STICK)) { diff --git a/src/code/z_game_over.c b/src/code/z_game_over.c index c510c1974b..979b28cbaa 100644 --- a/src/code/z_game_over.c +++ b/src/code/z_game_over.c @@ -45,7 +45,7 @@ void GameOver_Update(GlobalContext* globalCtx) { gSaveContext.unk_3DC0 = 2000; gSaveContext.naviTimer = 0; - gSaveContext.seqIndex = 0xFF; + gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; gSaveContext.nightSeqIndex = 0xFF; gSaveContext.eventInf[0] = 0; gSaveContext.eventInf[1] = 0; @@ -66,7 +66,7 @@ void GameOver_Update(GlobalContext* globalCtx) { gameOverCtx->state = GAMEOVER_DEATH_WAIT_GROUND; break; case GAMEOVER_DEATH_FADE_OUT: - if (func_801A8A50(1) != 32) { + if (func_801A8A50(1) != NA_BGM_GAME_OVER) { func_80169F78(globalCtx); if (gSaveContext.respawnFlag != -7) { gSaveContext.respawnFlag = -6; diff --git a/src/code/z_jpeg.c b/src/code/z_jpeg.c index 395a458350..c611ab1f87 100644 --- a/src/code/z_jpeg.c +++ b/src/code/z_jpeg.c @@ -1,11 +1,304 @@ -#include "global.h" +#include "z64jpeg.h" +#include "libc/stdbool.h" +#include "variables.h" +#include "functions.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_jpeg/func_800F42A0.s") +#define MARKER_ESCAPE 0x00 +#define MARKER_SOI 0xD8 +#define MARKER_SOF 0xC0 +#define MARKER_DHT 0xC4 +#define MARKER_DQT 0xDB +#define MARKER_DRI 0xDD +#define MARKER_SOS 0xDA +#define MARKER_APP0 0xE0 +#define MARKER_APP1 0xE1 +#define MARKER_APP2 0xE2 +#define MARKER_COM 0xFE +#define MARKER_EOI 0xD9 -#pragma GLOBAL_ASM("asm/non_matchings/code/z_jpeg/func_800F43BC.s") +/** + * Configures and schedules a JPEG decoder task and waits for it to finish. + */ +void Jpeg_ScheduleDecoderTask(JpegContext* jpegCtx) { + static OSTask_t sJpegTask = { + M_NJPEGTASK, // type + 0, // flags + NULL, // ucode_boot + 0, // ucode_boot_size + gJpegUCode, // ucode + 0x1000, // ucode_size + gJpegUCodeData, // ucode_data + 0x800, // ucode_data_size + NULL, // dram_stack + 0, // dram_stack_size + NULL, // output_buff + NULL, // output_buff_size + NULL, // data_ptr + sizeof(JpegTaskData), // data_size + NULL, // yield_data_ptr + 0x200, // yield_data_size + }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_jpeg/func_800F44F4.s") + JpegWork* workBuf = jpegCtx->workBuf; + s32 pad[2]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_jpeg/func_800F4540.s") + workBuf->taskData.address = &workBuf->data; + workBuf->taskData.mode = jpegCtx->mode; + workBuf->taskData.mbCount = 4; + workBuf->taskData.qTableYPtr = &workBuf->qTableY; + workBuf->taskData.qTableUPtr = &workBuf->qTableU; + workBuf->taskData.qTableVPtr = &workBuf->qTableV; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_jpeg/func_800F470C.s") + sJpegTask.flags = 0; + sJpegTask.ucodeBoot = SysUcode_GetUCodeBoot(); + sJpegTask.ucodeBootSize = SysUcode_GetUCodeBootSize(); + sJpegTask.yieldDataPtr = (u64*)&workBuf->yieldData; + sJpegTask.dataPtr = (u64*)&workBuf->taskData; + + jpegCtx->scTask.next = NULL; + jpegCtx->scTask.flags = OS_SC_NEEDS_RSP; + jpegCtx->scTask.msgQ = &jpegCtx->mq; + jpegCtx->scTask.msg = NULL; + jpegCtx->scTask.framebuffer = NULL; + jpegCtx->scTask.list.t = sJpegTask; + + osSendMesg(&gSchedContext.cmdQ, (OSMesg)&jpegCtx->scTask, OS_MESG_BLOCK); + Sched_SendEntryMsg(&gSchedContext); // osScKickEntryMsg + osRecvMesg(&jpegCtx->mq, NULL, OS_MESG_BLOCK); +} + +/** + * Copies a 16x16 block of decoded image data to the Z-buffer. + */ +void Jpeg_CopyToZbuffer(u16* src, u16* zbuffer, s32 x, s32 y) { + u16* dst = zbuffer + (((y * SCREEN_WIDTH) + x) * 16); + s32 i; + + for (i = 0; i < 16; i++) { + dst[0] = src[0]; + dst[1] = src[1]; + dst[2] = src[2]; + dst[3] = src[3]; + dst[4] = src[4]; + dst[5] = src[5]; + dst[6] = src[6]; + dst[7] = src[7]; + dst[8] = src[8]; + dst[9] = src[9]; + dst[10] = src[10]; + dst[11] = src[11]; + dst[12] = src[12]; + dst[13] = src[13]; + dst[14] = src[14]; + dst[15] = src[15]; + + src += 16; + dst += SCREEN_WIDTH; + } +} + +/** + * Reads an u16 from a possibly unaligned address in memory. + * + * Replaces unaligned 16-bit reads with a pair of aligned reads, allowing for reading the possibly + * unaligned values in JPEG header files. + */ +u16 Jpeg_GetUnalignedU16(u8* ptr) { + if (((u32)ptr & 1) == 0) { + // Read the value normally if it's aligned to a 16-bit address. + return *(u16*)ptr; + } else { + // Read unaligned values using two separate aligned memory accesses when it's not. + return *(u16*)(ptr - 1) << 8 | (*(u16*)(ptr + 1) >> 8); + } +} + +/** + * Parses the markers in the JPEG file, storing information such as the pointer to the image data + * in `jpegCtx` for later processing. + */ +void Jpeg_ParseMarkers(u8* ptr, JpegContext* jpegCtx) { + u32 exit = false; + + jpegCtx->dqtCount = 0; + jpegCtx->dhtCount = 0; + + while (true) { + if (exit) { + break; + } + + // 0xFF indicates the start of a JPEG marker, so look for the next. + if (*ptr++ == 0xFF) { + switch (*ptr++) { + case MARKER_ESCAPE: { + // Compressed value 0xFF is stored as 0xFF00 to escape it, so ignore it. + break; + } + case MARKER_SOI: { + // Start of Image + break; + } + case MARKER_APP0: { + // Application marker for JFIF + ptr += Jpeg_GetUnalignedU16(ptr); + break; + } + case MARKER_APP1: { + // Application marker for EXIF + ptr += Jpeg_GetUnalignedU16(ptr); + break; + } + case MARKER_APP2: { + ptr += Jpeg_GetUnalignedU16(ptr); + break; + } + case MARKER_DQT: { + // Define Quantization Table, stored for later processing + jpegCtx->dqtPtr[jpegCtx->dqtCount++] = ptr + 2; + ptr += Jpeg_GetUnalignedU16(ptr); + break; + } + case MARKER_DHT: { + // Define Huffman Table, stored for later processing + jpegCtx->dhtPtr[jpegCtx->dhtCount++] = ptr + 2; + ptr += Jpeg_GetUnalignedU16(ptr); + break; + } + case MARKER_DRI: { + // Define Restart Interval + ptr += Jpeg_GetUnalignedU16(ptr); + break; + } + case MARKER_SOF: { + // Start of Frame, stores important metadata of the image. + // Only used for extracting the sampling factors (jpegCtx->mode). + + if (ptr[9] == 0x21) { + // component Y : V0 == 1 + jpegCtx->mode = 0; + } else if (ptr[9] == 0x22) { + // component Y : V0 == 2 + jpegCtx->mode = 2; + } + ptr += Jpeg_GetUnalignedU16(ptr); + break; + } + case MARKER_SOS: { + // Start of Scan marker, indicates the start of the image data. + ptr += Jpeg_GetUnalignedU16(ptr); + jpegCtx->imageData = ptr; + break; + } + case MARKER_EOI: { + // End of Image + exit = true; + break; + } + default: { + ptr += Jpeg_GetUnalignedU16(ptr); + break; + } + } + } + } +} + +s32 Jpeg_Decode(void* data, void* zbuffer, void* work, u32 workSize) { + s32 y; + s32 x; + s32 j; + s32 i; + JpegContext jpegCtx; + JpegHuffmanTable hTables[4]; + JpegDecoder decoder; + JpegDecoderState state; + JpegWork* workBuff = work; + + if (workSize < sizeof(JpegWork)) { + return -1; + } + + osCreateMesgQueue(&jpegCtx.mq, &jpegCtx.msg, 1); + MsgEvent_SendNullTask(); + + jpegCtx.workBuf = workBuff; + + Jpeg_ParseMarkers(data, &jpegCtx); + + switch (jpegCtx.dqtCount) { + case 1: + JpegUtils_ProcessQuantizationTable(jpegCtx.dqtPtr[0], &workBuff->qTableY, 3); + break; + + case 2: + JpegUtils_ProcessQuantizationTable(jpegCtx.dqtPtr[0], &workBuff->qTableY, 1); + JpegUtils_ProcessQuantizationTable(jpegCtx.dqtPtr[1], &workBuff->qTableU, 1); + JpegUtils_ProcessQuantizationTable(jpegCtx.dqtPtr[1], &workBuff->qTableV, 1); + break; + + case 3: + JpegUtils_ProcessQuantizationTable(jpegCtx.dqtPtr[0], &workBuff->qTableY, 1); + JpegUtils_ProcessQuantizationTable(jpegCtx.dqtPtr[1], &workBuff->qTableU, 1); + JpegUtils_ProcessQuantizationTable(jpegCtx.dqtPtr[2], &workBuff->qTableV, 1); + break; + + default: + return -1; + } + + switch (jpegCtx.dhtCount) { + case 1: + if (JpegUtils_ProcessHuffmanTable(jpegCtx.dhtPtr[0], &hTables[0], workBuff->codesLengths, workBuff->codes, + 4)) { + return -1; + } + break; + + case 4: + // This chained if-else has printfs inside it on debug + if (JpegUtils_ProcessHuffmanTable(jpegCtx.dhtPtr[0], &hTables[0], workBuff->codesLengths, workBuff->codes, + 1)) { + } else if (JpegUtils_ProcessHuffmanTable(jpegCtx.dhtPtr[1], &hTables[1], workBuff->codesLengths, + workBuff->codes, 1)) { + } else if (JpegUtils_ProcessHuffmanTable(jpegCtx.dhtPtr[2], &hTables[2], workBuff->codesLengths, + workBuff->codes, 1)) { + } else if (!JpegUtils_ProcessHuffmanTable(jpegCtx.dhtPtr[3], &hTables[3], workBuff->codesLengths, + workBuff->codes, 1)) { + break; + } + return -1; + + default: + return -1; + } + + decoder.imageData = jpegCtx.imageData; + decoder.mode = jpegCtx.mode; + decoder.unk_05 = 2; + + decoder.hTablePtrs[0] = &hTables[0]; + decoder.hTablePtrs[1] = &hTables[1]; + decoder.hTablePtrs[2] = &hTables[2]; + decoder.hTablePtrs[3] = &hTables[3]; + decoder.unk_18 = 0; + + x = y = 0; + for (i = 0; i < 300; i += 4) { + if (!JpegDecoder_Decode(&decoder, (u16*)workBuff->data, 4, (i != 0), &state)) { + Jpeg_ScheduleDecoderTask(&jpegCtx); + + for (j = 0; j < 4; j++) { + Jpeg_CopyToZbuffer(workBuff->data[j], zbuffer, x, y); + x++; + + if (x >= 20) { + x = 0; + y++; + } + } + } + } + + return 0; +} diff --git a/src/code/z_quake.c b/src/code/z_quake.c index d08ff59931..9c5288139d 100644 --- a/src/code/z_quake.c +++ b/src/code/z_quake.c @@ -416,8 +416,9 @@ void Quake2_ClearType(s32 type) { } s32 Quake2_GetFloorQuake(Player* player) { - if (func_800C9D8C(&sQuake2Context.globalCtx->colCtx, player->actor.floorPoly, player->actor.floorBgId) == 0) { - return func_800C9E18(&sQuake2Context.globalCtx->colCtx, player->actor.floorPoly, player->actor.floorBgId); + if (!SurfaceType_IsConveyor(&sQuake2Context.globalCtx->colCtx, player->actor.floorPoly, player->actor.floorBgId)) { + return SurfaceType_GetConveyorSpeed(&sQuake2Context.globalCtx->colCtx, player->actor.floorPoly, + player->actor.floorBgId); } return 0; } diff --git a/src/code/z_scene.c b/src/code/z_scene.c index dd158ac070..6bebcf9386 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -204,7 +204,7 @@ void Scene_HeaderCmdColHeader(GlobalContext* globalCtx, SceneCmd* cmd) { colHeader->waterBoxes = (WaterBox*)Lib_SegmentedToVirtual(colHeader->waterBoxes); } - BgCheck_Init(&globalCtx->colCtx, globalCtx, colHeader); + BgCheck_Allocate(&globalCtx->colCtx, globalCtx, colHeader); } // SceneTableEntry Header Command 0x04: Room List @@ -449,7 +449,7 @@ void Scene_HeaderCmdSoundSettings(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->soundCtx.seqIndex = cmd->soundSettings.musicSeq; globalCtx->soundCtx.nightSeqIndex = cmd->soundSettings.nighttimeSFX; - if (gSaveContext.seqIndex == 0xFF || func_801A8A50(0) == 0x57) { + if (gSaveContext.seqIndex == (u8)NA_BGM_DISABLED || func_801A8A50(0) == NA_BGM_FINAL_HOURS) { audio_setBGM(cmd->soundSettings.bgmId); } } diff --git a/src/code/z_scene_proc.c b/src/code/z_scene_proc.c index bdd3ea1adf..57e2930a26 100644 --- a/src/code/z_scene_proc.c +++ b/src/code/z_scene_proc.c @@ -722,9 +722,9 @@ void Scene_DrawConfigGreatBayTemple(GlobalContext* globalCtx) { if (Flags_GetSwitch(globalCtx, 0x33) && Flags_GetSwitch(globalCtx, 0x34) && Flags_GetSwitch(globalCtx, 0x35) && Flags_GetSwitch(globalCtx, 0x36)) { - func_800C3C00(&globalCtx->colCtx, 1); + BgCheck_SetContextFlags(&globalCtx->colCtx, BGCHECK_FLAG_REVERSE_CONVEYOR_FLOW); } else { - func_800C3C14(&globalCtx->colCtx, 1); + BgCheck_UnsetContextFlags(&globalCtx->colCtx, BGCHECK_FLAG_REVERSE_CONVEYOR_FLOW); } dList = (Gfx*)GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Gfx) * 18); diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index ad3e93a5fc..7f79bb51c3 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -474,7 +474,7 @@ void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* joi } void func_80134148(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, - OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, UnkActorDraw unkDraw, + OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, UnkActorDrawOpa unkDraw, Actor* actor, Mtx** mtx) { StandardLimb* limb; Gfx* newDList; @@ -538,7 +538,7 @@ void func_80134148(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec } void func_801343C0(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, - OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, UnkActorDraw unkDraw, + OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, UnkActorDrawOpa unkDraw, Actor* actor) { StandardLimb* rootLimb; s32 pad; diff --git a/src/code/z_snap.c b/src/code/z_snap.c index 120861ff5f..1c0ab3a27d 100644 --- a/src/code/z_snap.c +++ b/src/code/z_snap.c @@ -113,11 +113,11 @@ s32 func_8013A530(GlobalContext* globalCtx, Actor* actor, s32 flag, Vec3f* pos, s16 x; s16 y; f32 distance; - CollisionPoly* unk1; + CollisionPoly* poly; Camera* camera; Actor* actors[2]; s32 ret = 0; - u32 unk2; + s32 bgId; camera = GET_ACTIVE_CAM(globalCtx); @@ -142,7 +142,8 @@ s32 func_8013A530(GlobalContext* globalCtx, Actor* actor, s32 flag, Vec3f* pos, ret |= 0x3d; } - if (func_800C576C(&globalCtx->colCtx, pos, &camera->eye, &screenSpace, &unk1, 1, 1, 1, 1, &unk2) != 0) { + if (BgCheck_ProjectileLineTest(&globalCtx->colCtx, pos, &camera->eye, &screenSpace, &poly, true, true, true, true, + &bgId)) { func_8013A41C(0x3c); ret |= 0x3c; } diff --git a/src/libultra/gu/normalize.c b/src/libultra/gu/normalize.c deleted file mode 100644 index 3fdbbe880a..0000000000 --- a/src/libultra/gu/normalize.c +++ /dev/null @@ -1,3 +0,0 @@ -#include "global.h" - -#pragma GLOBAL_ASM("asm/non_matchings/boot/normalize/guNormalize.s") diff --git a/src/libultra/io/aigetlen.c b/src/libultra/io/aigetlen.c index e3e7289aca..58d8db4875 100644 --- a/src/libultra/io/aigetlen.c +++ b/src/libultra/io/aigetlen.c @@ -1,5 +1,5 @@ #include "global.h" u32 osAiGetLength(void) { - return *(u32*)0xA4500004; + return HW_REG(AI_LEN_REG, u32); } diff --git a/src/libultra/io/aisetfreq.c b/src/libultra/io/aisetfreq.c index ef0a8d2deb..8702941b9a 100644 --- a/src/libultra/io/aisetfreq.c +++ b/src/libultra/io/aisetfreq.c @@ -1,3 +1,20 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/aisetfreq/osAiSetFrequency.s") +s32 osAiSetFrequency(u32 frequency) { + u8 bitrate; + f32 dacRateF = ((f32)osViClock / frequency) + 0.5f; + u32 dacRate = dacRateF; + + if (dacRate < 132) { + return -1; + } + + bitrate = (dacRate / 66); + if (bitrate > 16) { + bitrate = 16; + } + + HW_REG(AI_DACRATE_REG, u32) = dacRate - 1; + HW_REG(AI_BITRATE_REG, u32) = bitrate - 1; + return osViClock / (s32)dacRate; +} diff --git a/src/libultra/io/cartrominit.c b/src/libultra/io/cartrominit.c index 6b96905c74..0825b472cb 100644 --- a/src/libultra/io/cartrominit.c +++ b/src/libultra/io/cartrominit.c @@ -1,3 +1,63 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/cartrominit/osCartRomInit.s") +OSPiHandle CartRomHandle; + +OSPiHandle* osCartRomInit(void) { + register u32 initialConfig; + register s32 status; + register u32 prevInt; + register u32 lastLatency; + register u32 lastPageSize; + register u32 lastRelDuration; + register u32 lastPulse; + + static s32 sCartRomNeedsInit = true; + + __osPiGetAccess(); + + if (!sCartRomNeedsInit) { + __osPiRelAccess(); + return &CartRomHandle; + } + + sCartRomNeedsInit = false; + CartRomHandle.type = DEVICE_TYPE_CART; + CartRomHandle.baseAddress = 0xB0000000; + CartRomHandle.domain = 0; + CartRomHandle.speed = 0; + bzero(&CartRomHandle.transferInfo, sizeof(__OSTranxInfo)); + + /* Uses `status & PI_STATUS_ERROR` in OoT */ + while (status = HW_REG(PI_STATUS_REG, u32), status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY)) { + ; + } + + lastLatency = HW_REG(PI_BSD_DOM1_LAT_REG, u32); + lastPageSize = HW_REG(PI_BSD_DOM1_PGS_REG, u32); + lastRelDuration = HW_REG(PI_BSD_DOM1_RLS_REG, u32); + lastPulse = HW_REG(PI_BSD_DOM1_PWD_REG, u32); + + HW_REG(PI_BSD_DOM1_LAT_REG, u32) = 0xFF; + HW_REG(PI_BSD_DOM1_PGS_REG, u32) = 0; + HW_REG(PI_BSD_DOM1_RLS_REG, u32) = 3; + HW_REG(PI_BSD_DOM1_PWD_REG, u32) = 0xFF; + + initialConfig = HW_REG(CartRomHandle.baseAddress, u32); + CartRomHandle.latency = initialConfig & 0xFF; + CartRomHandle.pageSize = (initialConfig >> 0x10) & 0xF; + CartRomHandle.relDuration = (initialConfig >> 0x14) & 0xF; + CartRomHandle.pulse = (initialConfig >> 8) & 0xFF; + + HW_REG(PI_BSD_DOM1_LAT_REG, u32) = lastLatency; + HW_REG(PI_BSD_DOM1_PGS_REG, u32) = lastPageSize; + HW_REG(PI_BSD_DOM1_RLS_REG, u32) = lastRelDuration; + HW_REG(PI_BSD_DOM1_PWD_REG, u32) = lastPulse; + + prevInt = __osDisableInt(); + CartRomHandle.next = __osPiTable; + __osPiTable = &CartRomHandle; + __osRestoreInt(prevInt); + __osPiRelAccess(); + + return &CartRomHandle; +} diff --git a/src/libultra/io/crc.c b/src/libultra/io/crc.c index e2f3fb9912..acae7b4081 100644 --- a/src/libultra/io/crc.c +++ b/src/libultra/io/crc.c @@ -34,7 +34,7 @@ * \f[ m(X) X^n = Q(X) p(X) + R(X) \f] * (\f$ R(X) \f$ is the *remainder after dividing by \f$ p(X) \f$*). * - Therefore, \f$ m(X) X^n - R(X) \f$ is divisible by the generator polynomial. This means that if we append the - * binary number corresponding to \f$ R(X) \f$ to the message and rerun the algorithm, we will get 0 if now errors have + * binary number corresponding to \f$ R(X) \f$ to the message and rerun the algorithm, we will get 0 if no errors have * been introduced. * * diff --git a/src/libultra/io/dpgetstat.c b/src/libultra/io/dpgetstat.c index 763c6622e4..0c4b3073ba 100644 --- a/src/libultra/io/dpgetstat.c +++ b/src/libultra/io/dpgetstat.c @@ -1,5 +1,5 @@ #include "global.h" u32 osDpGetStatus(void) { - return *(u32*)0xA410000C; + return HW_REG(DPC_STATUS_REG, u32); } diff --git a/src/libultra/io/dpsetstat.c b/src/libultra/io/dpsetstat.c index c653a08173..d2655626c6 100644 --- a/src/libultra/io/dpsetstat.c +++ b/src/libultra/io/dpsetstat.c @@ -1,5 +1,5 @@ #include "global.h" void osDpSetStatus(u32 data) { - *(u32*)0xA410000C = data; + HW_REG(DPC_STATUS_REG, u32) = data; } diff --git a/src/libultra/io/epirawread.c b/src/libultra/io/epirawread.c index 317f7d63ec..df0c6b603b 100644 --- a/src/libultra/io/epirawread.c +++ b/src/libultra/io/epirawread.c @@ -1,6 +1,6 @@ #include "global.h" -s32 __osEPiRawReadIo(OSPiHandle* handle, u32 devAddr, u32* data) { +s32 __osEPiRawReadIo(OSPiHandle* handle, uintptr_t devAddr, u32* data) { s32 status; OSPiHandle* curHandle; diff --git a/src/libultra/io/epirawwrite.c b/src/libultra/io/epirawwrite.c index dc169ecf71..1e0e694a7e 100644 --- a/src/libultra/io/epirawwrite.c +++ b/src/libultra/io/epirawwrite.c @@ -1,12 +1,10 @@ #include "global.h" -s32 __osEPiRawWriteIo(OSPiHandle* handle, u32 devAddr, u32 data) { +s32 __osEPiRawWriteIo(OSPiHandle* handle, uintptr_t devAddr, u32 data) { s32 status; OSPiHandle* curHandle; - while (status = HW_REG(PI_STATUS_REG, u32), status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY)) { - ; - } + while (status = HW_REG(PI_STATUS_REG, u32), status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY)) {} if (__osCurrentHandle[handle->domain]->type != handle->type) { curHandle = __osCurrentHandle[handle->domain]; diff --git a/src/libultra/io/epiread.c b/src/libultra/io/epiread.c index efab23bbb3..5a2205bdc5 100644 --- a/src/libultra/io/epiread.c +++ b/src/libultra/io/epiread.c @@ -1,3 +1,11 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/epiread/osEPiReadIo.s") +s32 osEPiReadIo(OSPiHandle* handle, uintptr_t devAddr, u32* data) { + register s32 ret; + + __osPiGetAccess(); + ret = __osEPiRawReadIo(handle, devAddr, data); + __osPiRelAccess(); + + return ret; +} diff --git a/src/libultra/io/epiwrite.c b/src/libultra/io/epiwrite.c index a44fd169d8..2132507413 100644 --- a/src/libultra/io/epiwrite.c +++ b/src/libultra/io/epiwrite.c @@ -1,3 +1,11 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/epiwrite/osEPiWriteIo.s") +s32 osEPiWriteIo(OSPiHandle* handle, uintptr_t devAddr, u32 data) { + register s32 ret; + + __osPiGetAccess(); + ret = __osEPiRawWriteIo(handle, devAddr, data); + __osPiRelAccess(); + + return ret; +} diff --git a/src/libultra/io/pfsinitpak.c b/src/libultra/io/pfsinitpak.c index 6d8a59c1ae..cc226f834d 100644 --- a/src/libultra/io/pfsinitpak.c +++ b/src/libultra/io/pfsinitpak.c @@ -1,5 +1,124 @@ +#include "PR/pfs.h" #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/pfsinitpak/osPfsInitPak.s") +s32 __osPfsCheckRamArea(OSPfs* pfs); -#pragma GLOBAL_ASM("asm/non_matchings/boot/pfsinitpak/__osPfsCheckRamArea.s") +s32 osPfsInitPak(OSMesgQueue* queue, OSPfs* pfs, s32 channel) { + s32 ret; + u16 sum; + u16 isum; + u8 buf[BLOCKSIZE]; + __OSPackId* id; + __OSPackId newid; + + __osSiGetAccess(); + + ret = __osPfsGetStatus(queue, channel); + + __osSiRelAccess(); + + if (ret != 0) { + return ret; + } + + pfs->queue = queue; + pfs->channel = channel; + pfs->status = 0; + + ret = __osPfsCheckRamArea(pfs); + if (ret != 0) { + return ret; + } + + ret = __osPfsSelectBank(pfs, PFS_ID_BANK_256K); + if (ret != 0) { + return ret; + } + + ret = __osContRamRead(pfs->queue, pfs->channel, PFS_ID_0AREA, buf); + if (ret != 0) { + return ret; + } + + __osIdCheckSum((u16*)buf, &sum, &isum); + id = (__OSPackId*)buf; + if ((id->checksum != sum) || (id->invertedChecksum != isum)) { + ret = __osCheckPackId(pfs, id); + if (ret != 0) { + pfs->status |= PFS_ID_BROKEN; + return ret; + } + } + + if (!(id->deviceid & 1)) { + ret = __osRepairPackId(pfs, id, &newid); + if (ret != 0) { + if (ret == PFS_ERR_ID_FATAL) { + pfs->status |= PFS_ID_BROKEN; + } + return ret; + } + id = &newid; + if (!(id->deviceid & 1)) { + return PFS_ERR_DEVICE; + } + } + + bcopy(id, pfs->id, BLOCKSIZE); + + pfs->version = id->version; + pfs->banks = id->banks; + pfs->inodeStartPage = 1 + DEF_DIR_PAGES + (2 * pfs->banks); + pfs->dir_size = DEF_DIR_PAGES * PFS_ONE_PAGE; + pfs->inode_table = 1 * PFS_ONE_PAGE; + pfs->minode_table = (1 + pfs->banks) * PFS_ONE_PAGE; + pfs->dir_table = pfs->minode_table + (pfs->banks * PFS_ONE_PAGE); + + ret = __osContRamRead(pfs->queue, pfs->channel, PFS_LABEL_AREA, pfs->label); + if (ret != 0) { + return ret; + } + + ret = osPfsChecker(pfs); + pfs->status |= PFS_INITIALIZED; + + return ret; +} + +s32 __osPfsCheckRamArea(OSPfs* pfs) { + s32 i = 0; + s32 ret = 0; + u8 writeBuf[BLOCKSIZE]; + u8 readBuf[BLOCKSIZE]; + u8 saveReg[BLOCKSIZE]; + + ret = __osPfsSelectBank(pfs, PFS_ID_BANK_256K); + if (ret != 0) { + return ret; + } + + ret = __osContRamRead(pfs->queue, pfs->channel, 0, saveReg); + if (ret != 0) { + return ret; + } + + for (i = 0; i < BLOCKSIZE; i++) { + writeBuf[i] = i; + } + + ret = __osContRamWrite(pfs->queue, pfs->channel, 0, writeBuf, 0); + if (ret != 0) { + return ret; + } + + ret = __osContRamRead(pfs->queue, pfs->channel, 0, readBuf); + if (ret != 0) { + return ret; + } + + if (bcmp(writeBuf, readBuf, BLOCKSIZE) != 0) { + return PFS_ERR_DEVICE; + } + + return __osContRamWrite(pfs->queue, pfs->channel, 0, saveReg, 0); +} diff --git a/src/libultra/io/pfsselectbank.c b/src/libultra/io/pfsselectbank.c index 8353dc43c2..6cc43a4701 100644 --- a/src/libultra/io/pfsselectbank.c +++ b/src/libultra/io/pfsselectbank.c @@ -1,3 +1,18 @@ +#include "PR/pfs.h" #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/pfsselectbank/__osPfsSelectBank.s") +s32 __osPfsSelectBank(OSPfs* pfs, u8 bank) { + u8 buf[BLOCKSIZE]; + s32 i; + s32 ret = 0; + + for (i = 0; i < BLOCKSIZE; i++) { + buf[i] = bank; + } + + ret = __osContRamWrite(pfs->queue, pfs->channel, 0x8000 / BLOCKSIZE, buf, 0); + if (ret == 0) { + pfs->activebank = bank; + } + return ret; +} diff --git a/src/libultra/io/pirawdma.c b/src/libultra/io/pirawdma.c index 242a91c24e..07aa1b8221 100644 --- a/src/libultra/io/pirawdma.c +++ b/src/libultra/io/pirawdma.c @@ -1,23 +1,22 @@ #include "global.h" -s32 __osPiRawStartDma(s32 direction, u32 devAddr, void* dramAddr, size_t size) { - register int stat; +s32 __osPiRawStartDma(s32 direction, uintptr_t devAddr, void* dramAddr, size_t size) { + register int status = HW_REG(PI_STATUS_REG, u32); - stat = *(vu32*)0xA4600010; - while (stat & (2 | 1)) { - stat = *(vu32*)0xA4600010; + while (status & (PI_STATUS_IOBUSY | PI_STATUS_BUSY)) { + status = HW_REG(PI_STATUS_REG, u32); } - *(u32*)0xA4600000 = osVirtualToPhysical(dramAddr); + HW_REG(PI_DRAM_ADDR_REG, u32) = osVirtualToPhysical(dramAddr); - *(u32*)0xA4600004 = ((osRomBase | devAddr) & 0x1fffffff); + HW_REG(PI_CART_ADDR_REG, u32) = ((osRomBase | devAddr) & 0x1FFFFFFF); switch (direction) { - case 0: - *(u32*)0xA460000C = size - 1; + case OS_READ: + HW_REG(PI_WR_LEN_REG, u32) = size - 1; break; - case 1: - *(u32*)0xA4600008 = size - 1; + case OS_WRITE: + HW_REG(PI_RD_LEN_REG, u32) = size - 1; break; default: return -1; diff --git a/src/libultra/io/si.c b/src/libultra/io/si.c index 6de5874b90..563c682765 100644 --- a/src/libultra/io/si.c +++ b/src/libultra/io/si.c @@ -1,11 +1,11 @@ #include "global.h" -int __osSiDeviceBusy() { - register u32 status; - status = *(u32*)0xA4800018; - if (status & 3) { - return 1; +s32 __osSiDeviceBusy() { + register u32 status = HW_REG(SI_STATUS_REG, u32); + + if (status & (SI_STATUS_DMA_BUSY | SI_STATUS_IO_READ_BUSY)) { + return true; } else { - return 0; + return false; } } diff --git a/src/libultra/io/sirawdma.c b/src/libultra/io/sirawdma.c index ff57e21c23..eb62fa2a30 100644 --- a/src/libultra/io/sirawdma.c +++ b/src/libultra/io/sirawdma.c @@ -1,24 +1,24 @@ #include "global.h" s32 __osSiRawStartDma(s32 direction, void* dramAddr) { - if ((*(u32*)0xA4800018 & 0x3) != 0) { + if (HW_REG(SI_STATUS_REG, u32) & (SI_STATUS_DMA_BUSY | SI_STATUS_IO_READ_BUSY)) { return -1; } - if (direction == 1) { - osWritebackDCache(dramAddr, 64); + if (direction == OS_WRITE) { + osWritebackDCache(dramAddr, PIF_RAM_SIZE); } - *(u32*)0xA4800000 = osVirtualToPhysical(dramAddr); + HW_REG(SI_DRAM_ADDR_REG, u32) = osVirtualToPhysical(dramAddr); - if (direction == 0) { - *(u32*)0xA4800004 = 0x1FC007C0; + if (direction == OS_READ) { + HW_REG(SI_PIF_ADDR_RD64B_REG, void*) = (void*)PIF_RAM_START; } else { - *(u32*)0xA4800010 = 0x1FC007C0; + HW_REG(SI_PIF_ADDR_WR64B_REG, void*) = (void*)PIF_RAM_START; } - if (direction == 0) { - osInvalDCache(dramAddr, 64); + if (direction == OS_READ) { + osInvalDCache(dramAddr, PIF_RAM_SIZE); } return 0; } diff --git a/src/libultra/io/sp.c b/src/libultra/io/sp.c index db2e5b4511..c028c76927 100644 --- a/src/libultra/io/sp.c +++ b/src/libultra/io/sp.c @@ -5,6 +5,7 @@ s32 __osSpDeviceBusy(void) { if (status & (SP_STATUS_DMA_BUSY | SP_STATUS_DMA_FULL | SP_STATUS_IO_FULL)) { return true; + } else { + return false; } - return false; } diff --git a/src/libultra/io/spgetstat.c b/src/libultra/io/spgetstat.c index 98a3dc23b6..8987b2414a 100644 --- a/src/libultra/io/spgetstat.c +++ b/src/libultra/io/spgetstat.c @@ -1,5 +1,5 @@ #include "global.h" u32 __osSpGetStatus() { - return *(vu32*)0xA4040010; + return HW_REG(SP_STATUS_REG, u32); } diff --git a/src/libultra/io/sprawdma.c b/src/libultra/io/sprawdma.c index 95395a29d5..494f3db50d 100644 --- a/src/libultra/io/sprawdma.c +++ b/src/libultra/io/sprawdma.c @@ -1,17 +1,17 @@ #include "global.h" s32 __osSpRawStartDma(s32 direction, void* devAddr, void* dramAddr, size_t size) { - if (__osSpDeviceBusy() != 0) { + if (__osSpDeviceBusy()) { return -1; } - *(vu32*)0xA4040000 = devAddr; - *(vu32*)0xA4040004 = osVirtualToPhysical(dramAddr); + HW_REG(SP_MEM_ADDR_REG, u32) = devAddr; + HW_REG(SP_DRAM_ADDR_REG, u32) = osVirtualToPhysical(dramAddr); - if (direction == 0) { - *(vu32*)0xA404000C = size - 1; + if (direction == OS_READ) { + HW_REG(SP_WR_LEN_REG, u32) = size - 1; } else { - *(vu32*)0xA4040008 = size - 1; + HW_REG(SP_RD_LEN_REG, u32) = size - 1; } return 0; diff --git a/src/libultra/io/spsetstat.c b/src/libultra/io/spsetstat.c index 346577218d..eb183eab47 100644 --- a/src/libultra/io/spsetstat.c +++ b/src/libultra/io/spsetstat.c @@ -1,5 +1,5 @@ #include "global.h" void __osSpSetStatus(u32 data) { - *(vu32*)0xA4040010 = data; + HW_REG(SP_STATUS_REG, u32) = data; } diff --git a/src/libultra/io/vi.c b/src/libultra/io/vi.c index 7b64b4449b..ec0b1de700 100644 --- a/src/libultra/io/vi.c +++ b/src/libultra/io/vi.c @@ -17,7 +17,7 @@ void __osViInit(void) { __osViNext->modep = &osViModePalLan1; } else if (osTvType == OS_TV_MPAL) { __osViNext->modep = &osViModeMpalLan1; - } else { + } else { // OS_TV_NTSC or OS_TV_UNK28 __osViNext->modep = &osViModeNtscLan1; } diff --git a/src/libultra/io/viblack.c b/src/libultra/io/viblack.c index abc0b3b204..6b8fec9536 100644 --- a/src/libultra/io/viblack.c +++ b/src/libultra/io/viblack.c @@ -8,7 +8,7 @@ void osViBlack(u8 active) { if (active) { __osViNext->state |= 0x20; } else { - __osViNext->state &= 0xffdf; + __osViNext->state &= ~0x20; } __osRestoreInt(saveMask); diff --git a/src/libultra/io/visetspecial.c b/src/libultra/io/visetspecial.c index 6e7a6ac43a..a5ef1220a4 100644 --- a/src/libultra/io/visetspecial.c +++ b/src/libultra/io/visetspecial.c @@ -3,34 +3,33 @@ void osViSetSpecialFeatures(u32 func) { register u32 saveMask = __osDisableInt(); - if (func & 1) { - __osViNext->features |= 8; + if (func & OS_VI_GAMMA_ON) { + __osViNext->features |= OS_VI_GAMMA; } - if (func & 2) { - __osViNext->features &= ~8; + if (func & OS_VI_GAMMA_OFF) { + __osViNext->features &= ~OS_VI_GAMMA; } - if (func & 4) { - __osViNext->features |= 4; + if (func & OS_VI_GAMMA_DITHER_ON) { + __osViNext->features |= OS_VI_GAMMA_DITHER; } - if (func & 8) { + if (func & OS_VI_GAMMA_DITHER_OFF) { + __osViNext->features &= ~OS_VI_GAMMA_DITHER; + } + if (func & OS_VI_DIVOT_ON) { - __osViNext->features &= ~4; + __osViNext->features |= OS_VI_DIVOT; } - if (func & 0x10) { + if (func & OS_VI_DIVOT_OFF) { - __osViNext->features |= 0x10; + __osViNext->features &= ~OS_VI_DIVOT; } - if (func & 0x20) { - - __osViNext->features &= ~0x10; + if (func & OS_VI_DITHER_FILTER_ON) { + __osViNext->features |= OS_VI_DITHER_FILTER; + __osViNext->features &= ~(OS_VI_UNK100 | OS_VI_UNK200); } - if (func & 0x40) { - __osViNext->features |= 0x10000; - __osViNext->features &= ~0x300; - } - if (func & 0x80) { - __osViNext->features &= ~0x10000; - __osViNext->features |= __osViNext->modep->comRegs.ctrl & 0x300; + if (func & OS_VI_DITHER_FILTER_OFF) { + __osViNext->features &= ~OS_VI_DITHER_FILTER; + __osViNext->features |= __osViNext->modep->comRegs.ctrl & (OS_VI_UNK100 | OS_VI_UNK200); } __osViNext->state |= 8; diff --git a/src/libultra/rmon/xldtob.c b/src/libultra/rmon/xldtob.c index be5ad3acbf..65ffc7a92c 100644 --- a/src/libultra/rmon/xldtob.c +++ b/src/libultra/rmon/xldtob.c @@ -1,7 +1,275 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/xldtob/_Ldtob.s") +#define BUFF_LEN 0x20 -#pragma GLOBAL_ASM("asm/non_matchings/boot/xldtob/_Ldunscale.s") +s16 _Ldunscale(s16*, _Pft*); +void _Genld(_Pft*, u8, u8*, s16, s16); -#pragma GLOBAL_ASM("asm/non_matchings/boot/xldtob/_Genld.s") +const f64 digs[] = { 10e0L, 10e1L, 10e3L, 10e7L, 10e15L, 10e31L, 10e63L, 10e127L, 10e255L }; + +/* float properties */ +#define _D0 0 +#define _DBIAS 0x3ff +#define _DLONG 1 +#define _DOFF 4 +#define _FBIAS 0x7e +#define _FOFF 7 +#define _FRND 1 +#define _LBIAS 0x3ffe +#define _LOFF 15 +/* integer properties */ +#define _C2 1 +#define _CSIGN 1 +#define _ILONG 0 +#define _MBMAX 8 +#define NAN 2 +#define INF 1 +#define FINITE -1 +#define _DFRAC ((1 << _DOFF) - 1) +#define _DMASK (0x7fff & ~_DFRAC) +#define _DMAX ((1 << (15 - _DOFF)) - 1) +#define _DNAN (0x8000 | _DMAX << _DOFF | 1 << (_DOFF - 1)) +#define _DSIGN 0x8000 +#if _D0 == 3 +#define _D1 2 /* little-endian order */ +#define _D2 1 +#define _D3 0 +#else +#define _D1 1 /* big-endian order */ +#define _D2 2 +#define _D3 3 +#endif + +void _Ldtob(_Pft* args, u8 type) { + u8 buff[BUFF_LEN]; + u8* ptr = buff; + u32 sp70; + f64 val = args->v.ld; + /* maybe struct? */ + s16 err; + s16 nsig; + s16 exp; + s32 i; + s32 n; + f64 factor; + s32 gen; + s32 j; + s32 lo; + ldiv_t qr; + u8 drop; + s32 n2; + + if (args->prec < 0) { + args->prec = 6; + } else if (args->prec == 0 && (type == 'g' || type == 'G')) { + args->prec = 1; + } + err = _Ldunscale(&exp, (_Pft*)args); + if (err > 0) { + memcpy(args->s, err == 2 ? "NaN" : "Inf", args->n1 = 3); + return; + } + if (err == 0) { + nsig = 0; + exp = 0; + } else { + if (val < 0) { + val = -val; + } + exp = exp * 30103 / 0x000186A0 - 4; + if (exp < 0) { + n = (3 - exp) & ~3; + exp = -n; + for (i = 0; n > 0; n >>= 1, i++) { + if ((n & 1) != 0) { + val *= digs[i]; + } + } + } else if (exp > 0) { + factor = 1; + exp &= ~3; + + for (n = exp, i = 0; n > 0; n >>= 1, i++) { + if ((n & 1) != 0) { + factor *= digs[i]; + } + } + val /= factor; + } + gen = ((type == 'f') ? exp + 10 : 6) + args->prec; + if (gen > 0x13) { + gen = 0x13; + } + *ptr++ = '0'; + while (gen > 0 && 0 < val) { + lo = val; + if ((gen -= 8) > 0) { + val = (val - lo) * 1.0e8; + } + ptr = ptr + 8; + for (j = 8; lo > 0 && --j >= 0;) { + qr = ldiv(lo, 10); + *--ptr = qr.rem + '0'; + lo = qr.quot; + } + while (--j >= 0) { + ptr--; + *ptr = '0'; + } + ptr += 8; + } + + gen = ptr - &buff[1]; + for (ptr = &buff[1], exp += 7; *ptr == '0'; ptr++) { + --gen, --exp; + } + + nsig = ((type == 'f') ? exp + 1 : ((type == 'e' || type == 'E') ? 1 : 0)) + args->prec; + if (gen < nsig) { + nsig = gen; + } + if (nsig > 0) { + if (nsig < gen && ptr[nsig] > '4') { + drop = '9'; + } else { + drop = '0'; + } + + for (n2 = nsig; ptr[--n2] == drop;) { + nsig--; + } + if (drop == '9') { + ptr[n2]++; + } + if (n2 < 0) { + --ptr, ++nsig, ++exp; + } + } + } + _Genld((_Pft*)args, type, ptr, nsig, exp); +} + +s16 _Ldunscale(s16* pex, _Pft* px) { + u16* ps = (u16*)px; + s16 xchar = (ps[_D0] & _DMASK) >> _DOFF; + + if (xchar == _DMAX) { /* NaN or INF */ + *pex = 0; + return (s16)(ps[_D0] & _DFRAC || ps[_D1] || ps[_D2] || ps[_D3] ? NAN : INF); + } else if (0 < xchar) { + ps[_D0] = (ps[_D0] & ~_DMASK) | (_DBIAS << _DOFF); + *pex = xchar - (_DBIAS - 1); + return FINITE; + } + if (0 > xchar) { + return NAN; + } else { + *pex = 0; + return 0; + } +} + +void _Genld(_Pft* px, u8 code, u8* p, s16 nsig, s16 xexp) { + u8 point = '.'; + + if (nsig <= 0) { + nsig = 1, + + p = (u8*)"0"; + } + + if (code == 'f' || ((code == 'g' || code == 'G') && (-4 <= xexp) && (xexp < px->prec))) { /* 'f' format */ + ++xexp; /* change to leading digit count */ + if (code != 'f') { /* fixup for 'g' */ + if (!(px->flags & FLAGS_HASH) && nsig < px->prec) { + px->prec = nsig; + } + if ((px->prec -= xexp) < 0) { + px->prec = 0; + } + } + if (xexp <= 0) { /* digits only to right of point */ + px->s[px->n1++] = '0'; + if (0 < px->prec || px->flags & FLAGS_HASH) { + px->s[px->n1++] = point; + } + if (px->prec < -xexp) { + xexp = -px->prec; + } + px->nz1 = -xexp; + px->prec += xexp; + if (px->prec < nsig) { + nsig = px->prec; + } + memcpy(&px->s[px->n1], p, px->n2 = nsig); + px->nz2 = px->prec - nsig; + } else if (nsig < xexp) { /* zeros before point */ + memcpy(&px->s[px->n1], p, nsig); + px->n1 += nsig; + px->nz1 = xexp - nsig; + if (0 < px->prec || px->flags & FLAGS_HASH) { + px->s[px->n1] = point, ++px->n2; + } + px->nz2 = px->prec; + } else { /* enough digits before point */ + memcpy(&px->s[px->n1], p, xexp); + px->n1 += xexp; + nsig -= xexp; + if (0 < px->prec || px->flags & FLAGS_HASH) { + px->s[px->n1++] = point; + } + if (px->prec < nsig) { + nsig = px->prec; + } + memcpy(&px->s[px->n1], p + xexp, nsig); + px->n1 += nsig; + px->nz1 = px->prec - nsig; + } + } else { /* 'e' format */ + if (code == 'g' || code == 'G') { /* fixup for 'g' */ + if (nsig < px->prec) { + px->prec = nsig; + } + if (--px->prec < 0) { + px->prec = 0; + } + code = code == 'g' ? 'e' : 'E'; + } + px->s[px->n1++] = *p++; + if (0 < px->prec || px->flags & FLAGS_HASH) { + px->s[px->n1++] = point; + } + if (0 < px->prec) { /* put fraction digits */ + if (px->prec < --nsig) { + nsig = px->prec; + } + memcpy(&px->s[px->n1], p, nsig); + px->n1 += nsig; + px->nz1 = px->prec - nsig; + } + p = (u8*)&px->s[px->n1]; /* put exponent */ + *p++ = code; + if (0 <= xexp) { + *p++ = '+'; + } else { /* negative exponent */ + *p++ = '-'; + xexp = -xexp; + } + if (100 <= xexp) { /* put oversize exponent */ + if (1000 <= xexp) { + *p++ = xexp / 1000 + '0', xexp %= 1000; + } + *p++ = xexp / 100 + '0', xexp %= 100; + } + *p++ = xexp / 10 + '0', xexp %= 10; + *p++ = xexp + '0'; + px->n2 = p - (u8*)&px->s[px->n1]; + } + if ((px->flags & (FLAGS_ZERO | FLAGS_MINUS)) == FLAGS_ZERO) { /* pad with leading zeros */ + s32 n = px->n0 + px->n1 + px->nz1 + px->n2 + px->nz2; + + if (n < px->width) { + px->nz0 = px->width - n; + } + } +} diff --git a/src/libultra/rmon/xprintf.c b/src/libultra/rmon/xprintf.c index 313adc2e6b..6c538a2a8d 100644 --- a/src/libultra/rmon/xprintf.c +++ b/src/libultra/rmon/xprintf.c @@ -7,7 +7,7 @@ #define _PROUT(fmt, _size) \ if (_size > 0) { \ arg = (void*)pfn(arg, fmt, _size); \ - if (arg != 0) \ + if (arg != NULL) \ x.nchar += _size; \ else \ return x.nchar; \ diff --git a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c index a66535d79f..42834bb57e 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c @@ -232,8 +232,8 @@ void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx) { } } else { CollisionPoly* poly; - u32 bgId; - Vec3f sp78; + s32 bgId; + Vec3f posResult; Vec3f prevFrameDiff; Vec3f sp60; @@ -244,20 +244,23 @@ void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx) { sp60.x = this->unk1EC.x - (this->unk1E0.x - this->unk1EC.x); sp60.y = this->unk1EC.y - (this->unk1E0.y - this->unk1EC.y); sp60.z = this->unk1EC.z - (this->unk1E0.z - this->unk1EC.z); - if (func_800C55C4(&globalCtx->colCtx, &sp60, &this->unk1E0, &sp78, &poly, 1, 1, 1, 1, &bgId) != 0 && - (func_800B90AC(globalCtx, &this->actor, poly, bgId, &sp78) == 0 || - func_800C576C(&globalCtx->colCtx, &sp60, &this->unk1E0, &sp78, &poly, 1, 1, 1, 1, &bgId) != 0)) { - f32 sp5C = poly->normal.x * (1 / SHT_MAX); - f32 sp58 = poly->normal.z * (1 / SHT_MAX); + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &sp60, &this->unk1E0, &posResult, &poly, true, true, true, true, + &bgId) && + (func_800B90AC(globalCtx, &this->actor, poly, bgId, &posResult) == 0 || + BgCheck_ProjectileLineTest(&globalCtx->colCtx, &sp60, &this->unk1E0, &posResult, &poly, true, true, true, + true, &bgId))) { + f32 nx = COLPOLY_GET_NORMAL(poly->normal.x); + f32 nz = COLPOLY_GET_NORMAL(poly->normal.z); - Math_Vec3f_Copy(&this->actor.world.pos, &sp78); - this->actor.world.pos.x += 10.0f * sp5C; - this->actor.world.pos.z += 10.0f * sp58; + Math_Vec3f_Copy(&this->actor.world.pos, &posResult); + this->actor.world.pos.x += 10.0f * nx; + this->actor.world.pos.z += 10.0f * nz; this->timer = 1; - if (func_800C9CEC(&globalCtx->colCtx, poly, bgId)) { + if (SurfaceType_IsHookshotSurface(&globalCtx->colCtx, poly, bgId)) { { DynaPolyActor* dynaPolyActor; - if (bgId != 0x32 && (dynaPolyActor = BgCheck_GetActorOfMesh(&globalCtx->colCtx, bgId)) != NULL) { + if (bgId != BGCHECK_SCENE && + (dynaPolyActor = DynaPoly_GetActor(&globalCtx->colCtx, bgId)) != NULL) { ArmsHook_AttachHookToActor(this, &dynaPolyActor->actor); } } diff --git a/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c b/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c index 18b8a343c6..ff11631ef1 100644 --- a/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c +++ b/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c @@ -143,11 +143,11 @@ void BgCtowerGear_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); } if (type == WATER_WHEEL) { - BcCheck3_BgActorInit(&this->dyna, 3); - BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_06018588); + DynaPolyActor_Init(&this->dyna, 3); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &D_06018588); } else if (type == ORGAN) { - BcCheck3_BgActorInit(&this->dyna, 0); - BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_06016E70); + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &D_06016E70); func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); } } @@ -158,7 +158,7 @@ void BgCtowerGear_Destroy(Actor* thisx, GlobalContext* globalCtx) { type = BGCTOWERGEAR_GET_TYPE(this); if ((type == WATER_WHEEL) || (type == ORGAN)) { - BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); } } diff --git a/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c b/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c index 68371797b9..94868e0cd6 100644 --- a/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c +++ b/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c @@ -53,18 +53,18 @@ void BgCtowerRot_Init(Actor* thisx, GlobalContext* globalCtx) { Vec3f offset; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - BcCheck3_BgActorInit(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, 1); if (this->dyna.actor.params == CORRIDOR) { - BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_060142E8); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &D_060142E8); this->actionFunc = BgCtowerRot_CorridorRotate; return; } player = GET_PLAYER(globalCtx); if (this->dyna.actor.params == MAIN_DOOR) { - BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_06017410); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &D_06017410); this->dyna.actor.world.rot.y = this->dyna.actor.shape.rot.y + 0x4000; } else { - BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_06017650); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &D_06017650); this->dyna.actor.world.rot.y = this->dyna.actor.shape.rot.y - 0x4000; } Actor_CalcOffsetOrientedToDrawRotation(&this->dyna.actor, &offset, &player->actor.world.pos); @@ -81,7 +81,7 @@ void BgCtowerRot_Init(Actor* thisx, GlobalContext* globalCtx) { void BgCtowerRot_Destroy(Actor* thisx, GlobalContext* globalCtx) { BgCtowerRot* this = THIS; - BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); } void BgCtowerRot_CorridorRotate(BgCtowerRot* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.h b/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.h index 297a01cd87..28dafc099d 100644 --- a/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.h +++ b/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.h @@ -8,10 +8,11 @@ struct BgDanpeiMovebg; typedef void (*BgDanpeiMovebgActionFunc)(struct BgDanpeiMovebg*, GlobalContext*); typedef struct BgDanpeiMovebg { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ BgDanpeiMovebgActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x78]; + /* 0x0160 */ char unk_160[0x6C]; + /* 0x01CC */ u16 unk_1CC; + /* 0x01CE */ char unk_1CE[0xA]; } BgDanpeiMovebg; // size = 0x1D8 extern const ActorInit Bg_Danpei_Movebg_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Dkjail_Ivy/z_bg_dkjail_ivy.c b/src/overlays/actors/ovl_Bg_Dkjail_Ivy/z_bg_dkjail_ivy.c index 9071dd5208..c5757ad0dd 100644 --- a/src/overlays/actors/ovl_Bg_Dkjail_Ivy/z_bg_dkjail_ivy.c +++ b/src/overlays/actors/ovl_Bg_Dkjail_Ivy/z_bg_dkjail_ivy.c @@ -1,7 +1,7 @@ /* * File: z_bg_dkjail_ivy.c * Overlay: ovl_Bg_Dkjail_Ivy - * Description: Ivy in Deku Jail + * Description: Cuttable Ivy wall (beneath Woodfall Temple, Swamp Spider House) */ #include "z_bg_dkjail_ivy.h" diff --git a/src/overlays/actors/ovl_Bg_F40_Swlift/z_bg_f40_swlift.c b/src/overlays/actors/ovl_Bg_F40_Swlift/z_bg_f40_swlift.c index a4e20816b1..672ba1f464 100644 --- a/src/overlays/actors/ovl_Bg_F40_Swlift/z_bg_f40_swlift.c +++ b/src/overlays/actors/ovl_Bg_F40_Swlift/z_bg_f40_swlift.c @@ -1,7 +1,7 @@ /* * File: z_bg_f40_swlift.c * Overlay: ovl_Bg_F40_Swlift - * Description: + * Description: Unused Stone Tower vertically-oscillating platform */ #include "z_bg_f40_swlift.h" diff --git a/src/overlays/actors/ovl_Bg_Fu_Kaiten/z_bg_fu_kaiten.c b/src/overlays/actors/ovl_Bg_Fu_Kaiten/z_bg_fu_kaiten.c index f9447ba033..0d215f5c2e 100644 --- a/src/overlays/actors/ovl_Bg_Fu_Kaiten/z_bg_fu_kaiten.c +++ b/src/overlays/actors/ovl_Bg_Fu_Kaiten/z_bg_fu_kaiten.c @@ -36,9 +36,9 @@ void BgFuKaiten_Init(Actor* thisx, GlobalContext* globalCtx) { CollisionHeader* header = 0; Actor_SetScale(thisx, 1.0); - BcCheck3_BgActorInit(&THIS->bg, 3); - BgCheck_RelocateMeshHeader(&D_06002D30, &header); - THIS->bg.bgId = BgCheck_AddActorMesh(globalCtx, &globalCtx->colCtx.dyna, &THIS->bg, header); + DynaPolyActor_Init(&THIS->dyna, 3); + CollisionHeader_GetVirtual(&D_06002D30, &header); + THIS->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &THIS->dyna.actor, header); THIS->bouceHeight = 0.0; THIS->rotationSpeed = 0; @@ -47,23 +47,23 @@ void BgFuKaiten_Init(Actor* thisx, GlobalContext* globalCtx) { } void BgFuKaiten_Destroy(Actor* thisx, GlobalContext* globalCtx) { - BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, THIS->bg.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, THIS->dyna.bgId); } void BgFuKaiten_UpdateRotation(BgFuKaiten* this) { f32 f0; - this->bg.actor.shape.rot.y += this->rotationSpeed; + this->dyna.actor.shape.rot.y += this->rotationSpeed; if (this->rotationSpeed > 0) { f0 = this->rotationSpeed * .002f; - func_8019FAD8(&this->bg.actor.projectedPos, 8310, f0); + func_8019FAD8(&this->dyna.actor.projectedPos, 8310, f0); } } void BgFuKaiten_UpdateHeight(BgFuKaiten* this) { this->bounce += this->bounceSpeed; - this->bg.actor.world.pos.y = this->bg.actor.home.pos.y + this->elevation + this->bouceHeight; + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + this->elevation + this->bouceHeight; - this->bg.actor.world.pos.y -= this->bouceHeight * Math_CosS(this->bounce); + this->dyna.actor.world.pos.y -= this->bouceHeight * Math_CosS(this->bounce); } void BgFuKaiten_Update(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Bg_Fu_Kaiten/z_bg_fu_kaiten.h b/src/overlays/actors/ovl_Bg_Fu_Kaiten/z_bg_fu_kaiten.h index 94b582bb30..a7a589717b 100644 --- a/src/overlays/actors/ovl_Bg_Fu_Kaiten/z_bg_fu_kaiten.h +++ b/src/overlays/actors/ovl_Bg_Fu_Kaiten/z_bg_fu_kaiten.h @@ -6,7 +6,7 @@ struct BgFuKaiten; typedef struct BgFuKaiten { - /* 0x000 */ DynaPolyActor bg; + /* 0x000 */ DynaPolyActor dyna; /* 0x15C */ UNK_TYPE1 pad15C[0x4]; /* 0x160 */ f32 elevation; /* 0x164 */ f32 bouceHeight; diff --git a/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.c b/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.c index dbfe2eaf4a..15ac358ca6 100644 --- a/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.c +++ b/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.c @@ -1,7 +1,7 @@ /* * File: z_bg_fu_mizu.c * Overlay: ovl_Bg_Fu_Mizu - * Description: + * Description: Water in Honey and Darling's Second Day game */ #include "z_bg_fu_mizu.h" diff --git a/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c b/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c index d6f3bdcdb4..fceb27755e 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c +++ b/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c @@ -51,8 +51,8 @@ void BgHakaCurtain_Init(Actor* thisx, GlobalContext* globalCtx) { BgHakaCurtain* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - BcCheck3_BgActorInit(&this->dyna, 1); - BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_06001588); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &D_06001588); if (Actor_GetRoomCleared(globalCtx, this->dyna.actor.room)) { func_80B6DE80(this); return; @@ -63,7 +63,7 @@ void BgHakaCurtain_Init(Actor* thisx, GlobalContext* globalCtx) { void BgHakaCurtain_Destroy(Actor* thisx, GlobalContext* globalCtx) { BgHakaCurtain* this = THIS; - BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); } void func_80B6DC98(BgHakaCurtain* this) { diff --git a/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c b/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c index 6a610470ea..58ccf1cd91 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c +++ b/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c @@ -47,8 +47,8 @@ void BgHakaTomb_Init(Actor* thisx, GlobalContext* globalCtx) { BgHakaTomb* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - BcCheck3_BgActorInit(&this->dyna, 1); - BgCheck3_LoadMesh(globalCtx, &this->dyna, D_06000EE8); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, D_06000EE8); func_8013E3B8(&this->dyna.actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); func_80BD6624(this); } @@ -56,7 +56,7 @@ void BgHakaTomb_Init(Actor* thisx, GlobalContext* globalCtx) { void BgHakaTomb_Destroy(Actor* thisx, GlobalContext* globalCtx) { BgHakaTomb* this = THIS; - BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); } void func_80BD6624(BgHakaTomb* this) { diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c index 453bd919cc..77a0cb2eea 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c @@ -523,7 +523,7 @@ void func_80A9C058(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostU sp44.x = this->dyna.actor.home.pos.x + unkStruct1->unk_14.x; sp44.y = this->unk_16C + unkStruct1->unk_14.y; sp44.z = this->dyna.actor.home.pos.z + unkStruct1->unk_14.z; - func_8013ECE0(Math3D_DistanceSquared(&sp44, &GET_PLAYER(globalCtx)->actor.world.pos), 255, 20, 150); + func_8013ECE0(Math3D_Vec3fDistSq(&sp44, &GET_PLAYER(globalCtx)->actor.world.pos), 255, 20, 150); quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); Quake_SetSpeed(quake, 20000); Quake_SetQuakeValues(quake, 7, 0, 0, 0); @@ -704,8 +704,8 @@ void BgHakuginPost_Init(Actor* thisx, GlobalContext* globalCtx) { this->dyna.actor.world.rot.z = 0; this->dyna.actor.shape.rot.x = 0; this->dyna.actor.shape.rot.z = 0; - BcCheck3_BgActorInit(&this->dyna, 1); - BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_0600D3B0); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &D_0600D3B0); func_80A9B3BC(this, globalCtx); func_80A9CA94(this); } else { @@ -718,7 +718,7 @@ void BgHakuginPost_Destroy(Actor* thisx, GlobalContext* globalCtx) { BgHakuginPost* this = THIS; if (BGHAKUGINPOST_GET_7(&this->dyna.actor) == 7) { - BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); func_80A9AE3C(this, globalCtx); } } diff --git a/src/overlays/actors/ovl_Bg_Icicle/z_bg_icicle.c b/src/overlays/actors/ovl_Bg_Icicle/z_bg_icicle.c index 2695cb9967..653e125044 100644 --- a/src/overlays/actors/ovl_Bg_Icicle/z_bg_icicle.c +++ b/src/overlays/actors/ovl_Bg_Icicle/z_bg_icicle.c @@ -70,8 +70,8 @@ void BgIcicle_Init(Actor* thisx, GlobalContext* globalCtx) { s32 paramsMid; Actor_ProcessInitChain(thisx, sInitChain); - BcCheck3_BgActorInit(&this->dyna, 0); - BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_06000294); + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &D_06000294); Collider_InitAndSetCylinder(globalCtx, &this->collider, thisx, &sCylinderInit); Collider_UpdateCylinder(thisx, &this->collider); @@ -94,7 +94,7 @@ void BgIcicle_Init(Actor* thisx, GlobalContext* globalCtx) { void BgIcicle_Destroy(Actor* thisx, GlobalContext* globalCtx) { BgIcicle* this = THIS; - BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); Collider_DestroyCylinder(globalCtx, &this->collider); } diff --git a/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c b/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c index 8821fc5f40..1b222a2f8d 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c @@ -1,7 +1,7 @@ /* * File: z_bg_ikana_dharma.c * Overlay: ovl_Bg_Ikana_Dharma - * Description: Ikana Castle - Punchable Pillar Segments + * Description: Stone Tower Temple - Punchable Pillar Segments */ #include "z_bg_ikana_dharma.h" diff --git a/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c b/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c index 9d5a36ba56..503c09048a 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c @@ -67,8 +67,8 @@ void BgIkanaShutter_Init(Actor* thisx, GlobalContext* globalCtx) { BgIkanaShutter* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - BcCheck3_BgActorInit(&this->dyna, 0); - BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_06000F28); + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &D_06000F28); if (!((this->dyna.actor.params >> 8) & 1)) { if (BgIkanaShutter_AllSwitchesPressed(this, globalCtx)) { func_80BD599C(this); @@ -87,7 +87,7 @@ void BgIkanaShutter_Init(Actor* thisx, GlobalContext* globalCtx) { void BgIkanaShutter_Destroy(Actor* thisx, GlobalContext* globalCtx) { BgIkanaShutter* this = THIS; - BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); } void func_80BD5828(BgIkanaShutter* this) { diff --git a/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c b/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c index 5b68e1363c..10454f2cb1 100644 --- a/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c +++ b/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c @@ -115,8 +115,8 @@ void BgIkninSusceil_Init(Actor* thisx, GlobalContext* globalCtx) { BgIkninSusceil* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - BcCheck3_BgActorInit(&this->dyna, 1); - BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_0600CBAC); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &D_0600CBAC); this->animatedTexture = Lib_SegmentedToVirtual(&D_0600C670); func_80C0AC74(this); } @@ -124,7 +124,7 @@ void BgIkninSusceil_Init(Actor* thisx, GlobalContext* globalCtx) { void BgIkninSusceil_Destroy(Actor* thisx, GlobalContext* globalCtx) { BgIkninSusceil* this = THIS; - BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); } void func_80C0AB14(BgIkninSusceil* this) { diff --git a/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c b/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c index 8c6380aaf2..3bf7bf9889 100644 --- a/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c +++ b/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c @@ -74,18 +74,18 @@ void BgIknvObj_Init(Actor* thisx, GlobalContext* globalCtx) { break; case IKNV_OBJ_RAISED_DOOR: this->displayListPtr = D_06011880; - BcCheck3_BgActorInit(&this->dyna, 0); - BgCheck_RelocateMeshHeader(&D_060119D4, &colHeader); - this->dyna.bgId = BgCheck_AddActorMesh(globalCtx, &globalCtx->colCtx.dyna, &this->dyna, colHeader); + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&D_060119D4, &colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); this->actionFunc = BgIknvObj_UpdateRaisedDoor; this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 120.0f; break; case IKNV_OBJ_SAKON_DOOR: this->displayListPtr = D_060129C8; this->actionFunc = BgIknvObj_UpdateSakonDoor; - BcCheck3_BgActorInit(&this->dyna, 0); - BgCheck_RelocateMeshHeader(&D_06012CA4, &colHeader); - this->dyna.bgId = BgCheck_AddActorMesh(globalCtx, &globalCtx->colCtx.dyna, &this->dyna, colHeader); + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&D_06012CA4, &colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); Collider_UpdateCylinder(&this->dyna.actor, &this->collider); this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; @@ -108,7 +108,7 @@ void BgIknvObj_Destroy(Actor* thisx, GlobalContext* globalCtx) { return; } } - BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); } s32 func_80BD7CEC(BgIknvObj* this) { diff --git a/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c b/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c index 39b22417c2..cc92791fcc 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c +++ b/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c @@ -158,8 +158,8 @@ void BgKin2Fence_Init(Actor* thisx, GlobalContext* globalCtx) { s32 i = 0; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - BcCheck3_BgActorInit(&this->dyna, 0); - BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_06000908); + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &D_06000908); Collider_InitJntSph(globalCtx, &this->collider); Collider_SetJntSph(globalCtx, &this->collider, &this->dyna.actor, &sJntSphInit, this->colliderElements); Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, @@ -180,7 +180,7 @@ void BgKin2Fence_Init(Actor* thisx, GlobalContext* globalCtx) { void BgKin2Fence_Destroy(Actor* thisx, GlobalContext* globalCtx) { BgKin2Fence* this = THIS; - BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); Collider_DestroyJntSph(globalCtx, &this->collider); } diff --git a/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder.c b/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder.c index 0c391f43bd..0acccbc56a 100644 --- a/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder.c +++ b/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder.c @@ -61,17 +61,17 @@ void BgLadder_Init(Actor* thisx, GlobalContext* globalCtx) { // Has to be `thisx` instead of `&this->actor` to match this->switchFlag = GET_BGLADDER_SWITCHFLAG(thisx); thisx->params = GET_BGLADDER_SIZE(thisx); - BcCheck3_BgActorInit(&this->dyna, 0); + DynaPolyActor_Init(&this->dyna, 0); size = thisx->params; if (size == LADDER_SIZE_12RUNG) { - BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_060001D8); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &D_060001D8); } else if (size == LADDER_SIZE_16RUNG) { - BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_06000408); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &D_06000408); } else if (size == LADDER_SIZE_20RUNG) { - BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_06000638); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &D_06000638); } else if (size == LADDER_SIZE_24RUNG) { - BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_06000868); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &D_06000868); } else { Actor_MarkForDeath(&this->dyna.actor); return; @@ -94,7 +94,7 @@ void BgLadder_Init(Actor* thisx, GlobalContext* globalCtx) { void BgLadder_Destroy(Actor* thisx, GlobalContext* globalCtx) { BgLadder* this = THIS; - BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); } void BgLadder_ActionWait(BgLadder* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Bg_Lbfshot/z_bg_lbfshot.c b/src/overlays/actors/ovl_Bg_Lbfshot/z_bg_lbfshot.c index 2b77f73acf..c07f419f9e 100644 --- a/src/overlays/actors/ovl_Bg_Lbfshot/z_bg_lbfshot.c +++ b/src/overlays/actors/ovl_Bg_Lbfshot/z_bg_lbfshot.c @@ -38,13 +38,13 @@ void BgLbfshot_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); this->dyna.actor.uncullZoneForward = 4000.0f; - BcCheck3_BgActorInit(&this->dyna, 1); - BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_060014D8); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &D_060014D8); } void BgLbfshot_Destroy(Actor* thisx, GlobalContext* globalCtx) { BgLbfshot* this = THIS; - BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); } void BgLbfshot_Draw(Actor* thisx, GlobalContext* globalCtx) { func_800BDFC0(globalCtx, D_06000228); diff --git a/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c b/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c index 02e9517f5d..7499e35cde 100644 --- a/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c +++ b/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c @@ -41,13 +41,13 @@ extern Gfx D_06000040[]; // Lilypad model void BgLotus_Init(Actor* thisx, GlobalContext* globalCtx) { BgLotus* this = THIS; s32 pad; - s32 sp2C; + s32 bgId; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - BcCheck3_BgActorInit(&this->dyna, 1); - BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_06000A20); - this->dyna.actor.floorHeight = - func_800C411C(&globalCtx->colCtx, &thisx->floorPoly, &sp2C, &this->dyna.actor, &this->dyna.actor.world.pos); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &D_06000A20); + this->dyna.actor.floorHeight = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &thisx->floorPoly, &bgId, + &this->dyna.actor, &this->dyna.actor.world.pos); this->timer2 = 96; this->dyna.actor.world.rot.y = Rand_Next() >> 0x10; this->actionFunc = BgLotus_Wait; @@ -56,7 +56,7 @@ void BgLotus_Init(Actor* thisx, GlobalContext* globalCtx) { void BgLotus_Destroy(Actor* thisx, GlobalContext* globalCtx) { BgLotus* this = THIS; - BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); } void BgLotus_SetScaleXZ(BgLotus* this) { @@ -93,7 +93,7 @@ void BgLotus_Wait(BgLotus* this, GlobalContext* globalCtx) { } else { this->dyna.actor.world.pos.y = this->height; - if (func_800CAF70(&this->dyna)) { + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { if (this->hasSpawnedRipples == 0) { EffectSsGRipple_Spawn(globalCtx, &this->dyna.actor.world.pos, 1000, 1400, 0); EffectSsGRipple_Spawn(globalCtx, &this->dyna.actor.world.pos, 1000, 1400, 8); @@ -167,8 +167,8 @@ void BgLotus_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; WaterBox* waterBox; - func_800CA1E8(globalCtx, &globalCtx->colCtx, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.z, - &this->height, &waterBox); + WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.z, + &this->height, &waterBox); this->actionFunc(this, globalCtx); } diff --git a/src/overlays/actors/ovl_Bg_Market_Step/z_bg_market_step.c b/src/overlays/actors/ovl_Bg_Market_Step/z_bg_market_step.c index b5b13cd7c6..b5f8e9c49c 100644 --- a/src/overlays/actors/ovl_Bg_Market_Step/z_bg_market_step.c +++ b/src/overlays/actors/ovl_Bg_Market_Step/z_bg_market_step.c @@ -1,7 +1,7 @@ /* * File: z_bg_market_step.c * Overlay: ovl_Bg_Market_Step - * Description: West Clocktown - Stairs + * Description: West Clocktown - most scenery */ #include "z_bg_market_step.h" diff --git a/src/overlays/actors/ovl_Bg_Mbar_Chair/z_bg_mbar_chair.c b/src/overlays/actors/ovl_Bg_Mbar_Chair/z_bg_mbar_chair.c index 43022630a6..c805de05c9 100644 --- a/src/overlays/actors/ovl_Bg_Mbar_Chair/z_bg_mbar_chair.c +++ b/src/overlays/actors/ovl_Bg_Mbar_Chair/z_bg_mbar_chair.c @@ -41,14 +41,14 @@ void BgMbarChair_Init(Actor* thisx, GlobalContext* globalCtx) { BgMbarChair* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - BcCheck3_BgActorInit(&this->dyna, 0); - BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_060019B4); + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &D_060019B4); } void BgMbarChair_Destroy(Actor* thisx, GlobalContext* globalCtx) { BgMbarChair* this = THIS; - BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); } void BgMbarChair_Update(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.c b/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.c index 94a148c176..ecfc8ad021 100644 --- a/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.c +++ b/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.c @@ -1,7 +1,7 @@ /* * File: z_bg_open_shutter.c * Overlay: ovl_Bg_Open_Shutter - * Description: + * Description: Sliding doors in opening dungeon */ #include "z_bg_open_shutter.h" diff --git a/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c b/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c index 506b508b26..69ba3e6529 100644 --- a/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c +++ b/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c @@ -47,7 +47,8 @@ void BgTobira01_Open(BgTobira01* this, GlobalContext* globalCtx) { } } else if (!(gSaveContext.weekEventReg[88] & 0x40) && (this->timer == 0) && (globalCtx->actorCtx.unk1F5 != 0) && (globalCtx->actorCtx.unk1F4 == 0) && - (func_800C99AC(&globalCtx->colCtx, player->actor.floorPoly, player->actor.floorBgId) == 6)) { + (SurfaceType_GetSceneExitIndex(&globalCtx->colCtx, player->actor.floorPoly, player->actor.floorBgId) == + 6)) { this->playCutscene = true; this->unk_16C = 0; // this variable is not used anywhere else } @@ -78,8 +79,8 @@ void BgTobira01_Init(Actor* thisx, GlobalContext* globalCtx) { BgTobira01* this = THIS; s32 pad; - BcCheck3_BgActorInit(&this->dyna, 1); - BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_060011C0); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &D_060011C0); gSaveContext.weekEventReg[88] &= (u8)~0x40; Actor_SetScale(&this->dyna.actor, 1.0f); this->timer2 = gSaveContext.isNight; @@ -91,7 +92,7 @@ void BgTobira01_Destroy(Actor* thisx, GlobalContext* globalCtx) { BgTobira01* this = THIS; s32 pad; - BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); } void BgTobira01_Update(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.c b/src/overlays/actors/ovl_Boss_02/z_boss_02.c index 6b3c944f4b..32d75abba3 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -752,7 +752,7 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { spD0.y = 2000.0f; } - temp_f0 = func_800C3FA0(&globalCtx->colCtx, &spDC, &spD0); + temp_f0 = BgCheck_EntityRaycastFloor1(&globalCtx->colCtx, &spDC, &spD0); if (((this->unk_017C.y < temp_f0) && (temp_f0 <= this->unk_0188.y)) || ((temp_f0 < this->unk_017C.y) && (this->unk_0188.y <= temp_f0))) { this->unk_0170 = this->unk_017C; @@ -1005,7 +1005,7 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { } if (spB0->unk_0144 >= 10) { - Audio_QueueSeqCmd(0x8021); + Audio_QueueSeqCmd(NA_BGM_CLEAR_BOSS | 0x8000); } Audio_PlayActorSound2(&this->actor, NA_SE_EN_INBOSS_DEAD_OLD); @@ -1057,8 +1057,8 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { spD0.x = this->unk_0170.x + sp90.x; spD0.y = this->unk_0170.y + (1000.0f * D_809DF5B0); spD0.z = this->unk_0170.z + sp90.z; - if (func_800C40B4(&globalCtx->colCtx, &sp8C, &sp88, &spD0) != BGCHECK_Y_MIN) { - spA0 = func_800C3FA0(&globalCtx->colCtx, &sp8C, &spD0); + if (BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &sp8C, &sp88, &spD0) != BGCHECK_Y_MIN) { + spA0 = BgCheck_EntityRaycastFloor1(&globalCtx->colCtx, &sp8C, &spD0); Matrix_GetStateTranslationAndScaledZ(5.0f * D_809DF5B0, &sp70); sp70.y = 2.0f * D_809DF5B0; sp64.y = 0.3f * D_809DF5B0; @@ -1183,7 +1183,8 @@ void func_809DC218(Actor* thisx, GlobalContext* globalCtx) { sp24.y = 2000.0f; } - if ((this->actor.focus.pos.y < func_800C3FA0(&globalCtx->colCtx, &sp20, &sp24)) || (D_809E0422 != 0)) { + if ((this->actor.focus.pos.y < BgCheck_EntityRaycastFloor1(&globalCtx->colCtx, &sp20, &sp24)) || + (D_809E0422 != 0)) { this->actor.flags &= ~1; } else { this->actor.flags |= 1; @@ -1342,7 +1343,7 @@ void func_809DC78C(Actor* thisx, GlobalContext* globalCtx) { if (D_809E0430 != 0) { D_809E0430--; if (D_809E0430 == 0) { - Audio_QueueSeqCmd(0x801B); + Audio_QueueSeqCmd(NA_BGM_BOSS | 0x8000); } } } diff --git a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c index 17435de3d3..94bbef096f 100644 --- a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c +++ b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c @@ -1,7 +1,7 @@ /* * File: z_demo_effect.c * Overlay: ovl_Demo_Effect - * Description: Obtaining Masks (?) + * Description: Various cutscene effects (blue warp in, Great Fairy vanish, etc.) */ #include "z_demo_effect.h" diff --git a/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.c b/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.c index 1d39dc0222..71f0d92048 100644 --- a/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.c +++ b/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.c @@ -1,7 +1,7 @@ /* * File: z_demo_getitem.c * Overlay: ovl_Demo_Getitem - * Description: + * Description: Cutscene object for Great Fairy's Mask and Great Fairy's Sword */ #include "z_demo_getitem.h" diff --git a/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c b/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c index 2fb5a86dae..a22d0f8c68 100644 --- a/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c +++ b/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c @@ -1,7 +1,7 @@ /* * File: z_demo_syoten.c * Overlay: ovl_Demo_Syoten - * Description: + * Description: Ikana Canyon Cleansing Cutscene Effects */ #include "z_demo_syoten.h" diff --git a/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c b/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c index db345ab3aa..596945272c 100644 --- a/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c +++ b/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c @@ -1,7 +1,7 @@ /* * File: z_dm_char00.c * Overlay: ovl_Dm_Char00 - * Description: Tatl (cutscene) + * Description: Tatl and Tael (cutscene) */ #include "z_dm_char00.h" diff --git a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c index b98ad4329d..cf2d8b03b6 100644 --- a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c +++ b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c @@ -1,7 +1,7 @@ /* * File: z_dm_char01.c * Overlay: ovl_Dm_Char01 - * Description: Tatl and Tael (cutscene) + * Description: Woodfall scene objects (temple, water, walls, etc) */ #include "z_dm_char01.h" diff --git a/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c b/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c index 46ed5e6192..116b2732d0 100644 --- a/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c +++ b/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c @@ -1,7 +1,7 @@ /* * File: z_dm_char02.c * Overlay: ovl_Dm_Char02 - * Description: + * Description: Ocarina of Time (dropped from Skull Kid's hand) */ #include "z_dm_char02.h" diff --git a/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.c b/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.c index 6a09de8b54..e2c72238e3 100644 --- a/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.c +++ b/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.c @@ -1,7 +1,7 @@ /* * File: z_dm_char04.c * Overlay: ovl_Dm_Char04 - * Description: + * Description: Unused(?) Tatl and Tael actors */ #include "z_dm_char04.h" diff --git a/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.c b/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.c index 6dd180e21e..1518cd4b41 100644 --- a/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.c +++ b/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.c @@ -1,7 +1,7 @@ /* * File: z_dm_char06.c * Overlay: ovl_Dm_Char06 - * Description: Some unseen Mountain Village cutscene actor? + * Description: Mountain Village Snowy landscape fadeout in post-Snowhead thawing cutscene */ #include "z_dm_char06.h" diff --git a/src/overlays/actors/ovl_Dm_Char07/z_dm_char07.c b/src/overlays/actors/ovl_Dm_Char07/z_dm_char07.c index c80f7222d6..efb716667e 100644 --- a/src/overlays/actors/ovl_Dm_Char07/z_dm_char07.c +++ b/src/overlays/actors/ovl_Dm_Char07/z_dm_char07.c @@ -61,8 +61,8 @@ void DmChar07_Init(Actor* thisx, GlobalContext* globalCtx) { if (this->dyna.actor.params == DMCHAR07_STAGE) { Actor_SetScale(&this->dyna.actor, 0.1f); this->isStage = 1; - BcCheck3_BgActorInit(&this->dyna, 0); - BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_06006688); + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &D_06006688); } else { Actor_SetScale(&this->dyna.actor, 1.0f); } @@ -73,7 +73,7 @@ void DmChar07_Destroy(Actor* thisx, GlobalContext* globalCtx) { DmChar07* this = THIS; if (this->isStage) { - BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); } } diff --git a/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c b/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c index 9460d405a0..ccda78a8ea 100644 --- a/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c +++ b/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c @@ -1,7 +1,7 @@ /* * File: z_dm_sa.c * Overlay: ovl_Dm_Sa - * Description: + * Description: Glitched early version of Skull Kid stuck in a T-pose */ #include "z_dm_sa.h" diff --git a/src/overlays/actors/ovl_Dm_Statue/z_dm_statue.c b/src/overlays/actors/ovl_Dm_Statue/z_dm_statue.c index b3b3b3e282..8234deec66 100644 --- a/src/overlays/actors/ovl_Dm_Statue/z_dm_statue.c +++ b/src/overlays/actors/ovl_Dm_Statue/z_dm_statue.c @@ -1,7 +1,7 @@ /* * File: z_dm_statue.c * Overlay: ovl_Dm_Statue - * Description: Elegy of Emptiness - Beam of Light When Creating Statue + * Description: Pillars of water in Giant's Chamber */ #include "z_dm_statue.h" diff --git a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c index 154b1dba0d..bf934be08d 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c @@ -30,7 +30,96 @@ void func_80AA1C64(DmStk* this, GlobalContext* globalCtx); void func_80AA2720(DmStk* this, GlobalContext* globalCtx); void func_80AA27EC(DmStk* this, GlobalContext* globalCtx); -#if 0 +extern AnimationHeader D_0600055C; +extern AnimationHeader D_06001030; +extern AnimationHeader D_0600130C; +extern AnimationHeader D_06001374; +extern AnimationHeader D_06001EDC; +extern AnimationHeader D_06002774; +extern AnimationHeader D_06002CD8; +extern AnimationHeader D_06003068; +extern AnimationHeader D_060035C8; +extern AnimationHeader D_060039F0; +extern AnimationHeader D_06004554; +extern AnimationHeader D_06004580; +extern Gfx D_060046B0[]; +extern AnimationHeader D_060049C8; +extern AnimationHeader D_060051C0; +extern Gfx D_060053C0[]; +extern Gfx D_06005870[]; +extern AnimationHeader D_06005F44; +extern Gfx D_06006BB0[]; +extern AnimationHeader D_060070DC; +extern Gfx D_06007840[]; +extern Gfx D_060079F0[]; +extern Gfx D_060084C0[]; +extern UNK_TYPE D_06008658; +extern Gfx D_060087B0[]; +extern Gfx D_06008A80[]; +extern Gfx D_060090C0[]; +extern Gfx D_06009710[]; +extern Gfx D_06009AC0[]; +extern Gfx D_06009DA0[]; +extern Gfx D_0600A530[]; +extern Gfx D_0600A5C0[]; +extern Gfx D_0600AE30[]; +extern Gfx D_0600AEC0[]; +extern AnimationHeader D_0600BB2C; +extern AnimationHeader D_0600C270; +extern AnimationHeader D_0600C964; +extern Gfx D_0600CAD0[]; +extern AnimationHeader D_0600CBB8; +extern AnimationHeader D_0600D830; +extern AnimationHeader D_0600E6EC; +extern AnimationHeader D_0600EEC0; +extern AnimationHeader D_060101A4; +extern AnimationHeader D_06010B60; +extern AnimationHeader D_060110B4; +extern AnimationHeader D_06011FB0; +extern AnimationHeader D_06012A58; +extern FlexSkeletonHeader D_06013328; +extern AnimationHeader D_060141E4; +extern AnimationHeader D_06014920; +extern AnimationHeader D_06015028; +extern AnimationHeader D_06015C14; +extern AnimationHeader D_06016508; +extern Gfx D_06016620[]; +extern AnimationHeader D_06016910; +extern AnimationHeader D_06018ED0; +extern AnimationHeader D_0601AA80; +extern AnimationHeader D_0601C114; +extern AnimationHeader D_0601C21C; +extern AnimationHeader D_0601D008; +extern AnimationHeader D_0601D07C; +extern AnimationHeader D_0601D3D0; +extern AnimationHeader D_0601DDE0; +extern AnimationHeader D_0601EF50; +extern AnimationHeader D_0601F9E4; +extern AnimationHeader D_06020CAC; +extern AnimationHeader D_0602200C; +extern AnimationHeader D_0602336C; +extern AnimationHeader D_060259F4; +extern AnimationHeader D_060266C8; +extern AnimationHeader D_06026CF4; +extern AnimationHeader D_06027CF4; +extern AnimationHeader D_06028F28; +extern AnimationHeader D_06029A04; +extern AnimationHeader D_0602A2D8; +extern AnimationHeader D_0602AD54; +extern AnimationHeader D_0602DC64; +extern AnimationHeader D_0602E9A0; +extern AnimationHeader D_0602FA70; +extern AnimationHeader D_0603021C; +extern AnimationHeader D_06031210; +extern AnimationHeader D_060322FC; +extern AnimationHeader D_06032AE0; +extern AnimationHeader D_0603323C; +extern AnimationHeader D_06034FD8; +extern AnimationHeader D_06036964; +extern AnimationHeader D_06037B94; +extern AnimationHeader D_0603967C; +extern AnimationHeader D_0603A8F8; + const ActorInit Dm_Stk_InitVars = { ACTOR_DM_STK, ACTORCAT_ITEMACTION, @@ -43,18 +132,29 @@ const ActorInit Dm_Stk_InitVars = { (ActorFunc)DmStk_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80AA35A0 = { - { COLTYPE_HIT1, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT1, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 14, 38, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80AA35CC = { 1, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 1, 0, 0, 0, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_80AA35D8 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(1, 0xF), /* Deku Stick */ DMG_ENTRY(1, 0xF), /* Horse trample */ DMG_ENTRY(1, 0xF), @@ -89,98 +189,1677 @@ static DamageTable D_80AA35D8 = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -#endif +static ActorAnimationEntry sAnimations[] = { + { &D_0601C21C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, { &D_0601D3D0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &D_06001030, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &D_0601D008, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &D_0601D008, 1.0f, 0.0f, -1.0f, 0, 0.0f }, { &D_06015C14, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &D_060070DC, 1.0f, 0.0f, -1.0f, 0, 0.0f }, { &D_0600D830, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &D_0600055C, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &D_0600130C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &D_0600C270, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &D_0600CBB8, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &D_0601AA80, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &D_0601D07C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &D_06016910, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &D_06018ED0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &D_0601DDE0, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &D_0601EF50, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &D_0602DC64, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &D_0602E9A0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &D_0602DC64, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &D_0602E9A0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &D_060035C8, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &D_060049C8, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &D_060259F4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &D_060266C8, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &D_06026CF4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &D_0601C114, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &D_06004580, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &D_06020CAC, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &D_0602200C, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &D_0602336C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &D_06002774, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &D_06003068, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &D_060101A4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &D_06010B60, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &D_0602A2D8, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &D_0601F9E4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &D_06029A04, 1.0f, 0.0f, -1.0f, 0, 0.0f }, { &D_0602AD54, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &D_0600BB2C, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &D_0600C964, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &D_060110B4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &D_06011FB0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &D_06012A58, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &D_060141E4, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &D_0600E6EC, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &D_0600EEC0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &D_06027CF4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &D_06028F28, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &D_0603323C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, { &D_06031210, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &D_060322FC, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &D_06032AE0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &D_0603021C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, { &D_06036964, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &D_06016508, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &D_06015028, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &D_06014920, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &D_0602FA70, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &D_06037B94, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &D_0603967C, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &D_0603967C, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &D_0603A8F8, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &D_06034FD8, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &D_06005F44, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &D_06002CD8, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &D_060039F0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &D_06004554, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &D_060051C0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &D_06001374, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &D_06001EDC, 1.0f, 0.0f, -1.0f, 0, 0.0f }, +}; -extern ColliderCylinderInit D_80AA35A0; -extern CollisionCheckInfoInit2 D_80AA35CC; -extern DamageTable D_80AA35D8; +void func_80A9FDB0(DmStk* this, GlobalContext* globalCtx) { + s32 objectIdx; -extern UNK_TYPE D_06006BB0; -extern UNK_TYPE D_0600AEC0; -extern UNK_TYPE D_06013328; + if (((this->unk_2E0 >= 0) && (this->unk_2E0 <= 5)) || (this->unk_2E0 == 32) || (this->unk_2E0 == 33) || + (this->unk_2E0 == 40) || (this->unk_2E0 == 41)) { + objectIdx = this->unk_336; + } else if (this->unk_2E0 > 64) { + objectIdx = this->unk_338; + } else { + objectIdx = this->unk_337; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80A9FDB0.s") + if (objectIdx >= 0) { + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[objectIdx].segment); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80A9FE3C.s") +void func_80A9FE3C(DmStk* this, GlobalContext* globalCtx, SkelAnime* skelAnime, ActorAnimationEntry* animation, + u16 index) { + func_80A9FDB0(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80A9FED8.s") + animation += index; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80AA00CC.s") + Animation_Change(skelAnime, animation->animation, animation->playSpeed, animation->startFrame, + (animation->frameCount < 0.0f) ? Animation_GetLastFrame(&animation->animation->common) + : animation->frameCount, + animation->mode, animation->morphFrames); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80AA0100.s") +void func_80A9FED8(DmStk* this, GlobalContext* globalCtx) { + switch (globalCtx->csCtx.frames + 20) { + case 1195: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_APPEAR); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80AA0158.s") + case 1232: + case 1241: + case 1252: + case 1255: + case 1257: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_SHAKEHEAD); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80AA01C0.s") + case 1285: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL03_LAUGH_BIG); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80AA0264.s") + case 1343: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80AA0420.s") + case 1410: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_ON); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80AA05F0.s") + case 1603: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_WALK); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80AA0634.s") + case 1610: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_REVERSE); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80AA066C.s") + case 2095: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_SURPRISED); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80AA071C.s") + case 2190: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_JUMP); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80AA076C.s") + case 2212: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_ONGND); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80AA09DC.s") + case 2214: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL02_LAUGH_SHORT); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80AA0B08.s") + case 2250: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL06_SURPRISED); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_DOWN_K); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80AA0DA8.s") + case 2255: + case 2266: + case 2277: + case 2288: + case 2299: + case 2310: + case 2321: + case 2332: + case 2343: + case 2354: + case 2365: + case 2376: + case 2387: + case 2398: + case 2409: + case 2420: + case 2431: + case 2442: + case 2453: + case 2464: + case 2475: + case 2486: + case 2497: + case 2508: + case 2519: + case 2530: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_RIDE); + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80AA0E1C.s") +void func_80AA00CC(DmStk* this, GlobalContext* globalCtx) { + if (globalCtx->csCtx.frames == 535) { + func_8019F128(NA_SE_EV_CLOCK_TOWER_BELL); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80AA0E90.s") +void func_80AA0100(DmStk* this, GlobalContext* globalCtx) { + switch (globalCtx->csCtx.frames) { + case 78: + case 89: + case 100: + case 111: + case 122: + case 133: + case 144: + case 155: + case 166: + case 177: + case 188: + case 199: + case 210: + case 221: + case 232: + case 243: + case 254: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_RIDE); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/DmStk_Init.s") + case 173: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL03_LAUGH_BIG); + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/DmStk_Destroy.s") +void func_80AA0158(DmStk* this, GlobalContext* globalCtx) { + switch (globalCtx->csCtx.frames) { + case 18: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_GASAGOSO); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80AA16F4.s") + case 90: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_ON); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80AA1704.s") + case 142: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_EVIL_POWER); + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80AA1714.s") +void func_80AA01C0(DmStk* this, GlobalContext* globalCtx) { + switch (globalCtx->csCtx.frames) { + case 415: + func_801A479C(&this->actor.projectedPos, NA_SE_EN_STALKIDS_FLOAT, 100); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80AA17F8.s") + case 785: + func_8019F128(NA_SE_SY_STALKIDS_PSYCHO); + func_8019FE74(&D_801D6654, 0.0f, 150); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80AA18D8.s") + case 560: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL02_LAUGH_SHORT); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80AA192C.s") + case 890: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL21_PSYCHO_VOICE); + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80AA1998.s") +void func_80AA0264(DmStk* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80AA19EC.s") + switch (globalCtx->csCtx.frames) { + case 10: + func_801A479C(&this->actor.projectedPos, NA_SE_EN_STALKIDS_FLOAT, 50); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80AA1A50.s") + case 71: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_BODY); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80AA1AC8.s") + case 365: + func_801A0654(&this->actor.projectedPos, NA_SE_EN_STALKIDS_FLOAT, 0); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80AA1AF8.s") + case 650: + func_8019FE74(&D_801D6654, 0.0f, 80); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80AA1B9C.s") + case 265: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL03_LAUGH_BIG); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80AA1C64.s") + case 126: + Audio_PlayActorSound2(&player->actor, NA_SE_VO_DUMMY_150); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80AA1D1C.s") + case 197: + Audio_PlayActorSound2(&player->actor, NA_SE_VO_DUMMY_134); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80AA26CC.s") + case 207: + Audio_PlayActorSound2(&player->actor, NA_SE_VO_DUMMY_135); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80AA2720.s") + case 217: + Audio_PlayActorSound2(&player->actor, NA_SE_VO_DUMMY_136); + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80AA27EC.s") + if (player) {} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/DmStk_Update.s") + if ((globalCtx->csCtx.frames >= 263) && (globalCtx->csCtx.frames < 698)) { + Audio_PlayActorSound2(&player->actor, NA_SE_EN_STALKIDS_BODY_LEV - SFX_FLAG); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80AA2B14.s") +void func_80AA0420(DmStk* this, GlobalContext* globalCtx) { + static s32 D_80AA3CB8 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80AA2BC0.s") + switch (globalCtx->csCtx.frames) { + case 140: + func_801A479C(&this->actor.projectedPos, NA_SE_EN_STALKIDS_FLOAT, 80); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/func_80AA33A4.s") + case 258: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_TURN); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Stk/DmStk_Draw.s") + case 524: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_TURN); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL04_ANGER); + break; + + case 534: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_ROLL); + break; + + case 678: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_STRETCH); + break; + } + + if ((this->unk_2E0 == 31) && (globalCtx->csCtx.frames < 700)) { + if (Animation_OnFrame(&this->skelAnime, 5.0f) || Animation_OnFrame(&this->skelAnime, 25.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_OTEDAMA1); + } else if (Animation_OnFrame(&this->skelAnime, 17.0f) || Animation_OnFrame(&this->skelAnime, 40.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_OTEDAMA2); + } + } + + if (globalCtx->csCtx.frames >= 700) { + if (D_80AA3CB8 < 128) { + if ((D_80AA3CB8 & 0x1F) == 0) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL20_CALL_MOON); + } else if ((D_80AA3CB8 & 0x1F) == 16) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL20_CALL_MOON2); + } + D_80AA3CB8++; + } + } else { + D_80AA3CB8 = 0; + } +} + +void func_80AA05F0(DmStk* this, GlobalContext* globalCtx) { + if (globalCtx->csCtx.frames == 3) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL06_SURPRISED); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_DOWN_K); + } +} + +void func_80AA0634(DmStk* this, GlobalContext* globalCtx) { + if ((globalCtx->csCtx.frames >= 642) && (globalCtx->csCtx.frames < 845)) { + Audio_PlayActorSound2(&this->actor, NA_SE_NE_STAL23_COLD - SFX_FLAG); + } +} + +void func_80AA066C(DmStk* this, GlobalContext* globalCtx) { + switch (globalCtx->csCtx.frames) { + case 58: + case 61: + case 68: + case 72: + case 77: + case 79: + Audio_PlayActorSound2(&this->actor, NA_SE_PL_WALK_WATER2); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_WALK); + break; + + case 186: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_UP); + break; + + case 230: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL22_LAUGH_KID_L); + break; + } +} + +void func_80AA071C(DmStk* this, GlobalContext* globalCtx) { + switch (globalCtx->csCtx.frames) { + case 5: + func_801A4A28(12); + break; + + case 660: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_SHAKEHEAD); + break; + } +} + +void func_80AA076C(DmStk* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + switch (globalCtx->csCtx.frames) { + case 5: + func_801A4A28(12); + break; + + case 45: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_RIDE); + break; + + case 93: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + break; + + case 245: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_RIDE); + break; + + case 269: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL11_LAUGH_SHY2); + break; + + case 327: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_SHAKEHEAD); + break; + + case 455: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_RIDE); + break; + + case 1730: + Audio_QueueSeqCmd(0x141400FF); + break; + + case 1395: + func_800B8E58(&player->actor, NA_SE_VO_DUMMY_34); + break; + + case 1850: + Audio_QueueSeqCmd(0x42320000); + break; + + case 2000: + func_801A5BD0(0x7F); + break; + } + + if (this->unk_2E0 == 0) { + if (Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 17.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + } + + if (Animation_OnFrame(&this->skelAnime, 28.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_RIDE); + } + } else if (this->unk_2E0 == 71) { + if (Animation_OnFrame(&this->skelAnime, 2.0f) || Animation_OnFrame(&this->skelAnime, 6.0f) || + Animation_OnFrame(&this->skelAnime, 12.0f) || Animation_OnFrame(&this->skelAnime, 18.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + } + } else if ((this->unk_2E0 == 70) && + (Animation_OnFrame(&this->skelAnime, 16.0f) || Animation_OnFrame(&this->skelAnime, 23.0f))) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_NOSE); + } +} + +void func_80AA09DC(DmStk* this, GlobalContext* globalCtx) { + static s32 D_80AA3CBC = 0; + + switch (globalCtx->csCtx.frames) { + case 40: + func_801A479C(&this->actor.projectedPos, NA_SE_EN_STALKIDS_FLOAT, 80); + break; + + case 234: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_TURN); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL04_ANGER); + break; + + case 244: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_ROLL); + break; + + case 388: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_STRETCH); + break; + } + + if (globalCtx->csCtx.frames >= 408) { + if (D_80AA3CBC < 128) { + if ((D_80AA3CBC & 0x1F) == 0) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL20_CALL_MOON); + } else if ((D_80AA3CBC & 0x1F) == 16) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL20_CALL_MOON2); + } + D_80AA3CBC++; + } + } else { + D_80AA3CBC = 0; + } +} + +void func_80AA0B08(DmStk* this, GlobalContext* globalCtx) { + this->unk_310.x = this->actor.projectedPos.x; + this->unk_310.y = this->actor.projectedPos.y; + this->unk_310.z = this->actor.projectedPos.z; + + switch (globalCtx->csCtx.frames) { + case 64: + func_8019F1C0(&this->unk_310, NA_SE_EN_STAL06_SURPRISED); + break; + + case 327: + case 332: + case 335: + case 344: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + break; + + case 367: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_BODY_LEV); + break; + + case 470: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_HEADACHE); + break; + + case 486: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + func_8019F1C0(&this->unk_310, NA_SE_EN_STAL08_CRY_BIG); + break; + + case 496: + func_8019F1C0(&this->unk_310, NA_SE_EN_STAL09_SCREAM); + break; + + case 590: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + break; + + case 592: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_RIDE); + break; + + case 594: + func_8019F1C0(&this->unk_310, NA_SE_EN_STAL24_SCREAM2); + break; + } + + if (1) {} + + if ((globalCtx->csCtx.frames >= 62) && (globalCtx->csCtx.frames < 273)) { + if ((Rand_ZeroOne() < 0.75f) && ((globalCtx->state.frames % 2) != 0)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_EARTHQUAKE); + } + } + + if ((globalCtx->csCtx.frames >= 498) && (globalCtx->csCtx.frames < 577)) { + if ((globalCtx->state.frames % 4) == 0) { + if ((globalCtx->state.frames & 4) != 0) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_BODY_LEV); + } else { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + } + } + } + + if (globalCtx->csCtx.frames >= 290) { + func_8019F128(NA_SE_EV_KYOJIN_VOICE_SUCCESS - SFX_FLAG); + } +} + +void func_80AA0DA8(DmStk* this, GlobalContext* globalCtx) { + switch (globalCtx->csCtx.frames) { + case 551: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_PULLED); + break; + + case 711: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + break; + + case 716: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_ON); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_ONGND); + break; + } +} + +void func_80AA0E1C(DmStk* this, GlobalContext* globalCtx) { + switch (globalCtx->csCtx.frames) { + case 311: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_PULLED); + break; + + case 365: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + break; + + case 372: + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_ON); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_ONGND); + break; + } +} + +void func_80AA0E90(DmStk* this, GlobalContext* globalCtx) { + if (globalCtx->csCtx.state != 0) { + switch (globalCtx->sceneNum) { + case SCENE_LOST_WOODS: + if (gSaveContext.sceneSetupIndex == 1) { + func_80A9FED8(this, globalCtx); + } else if (gSaveContext.sceneSetupIndex == 0) { + func_80AA0100(this, globalCtx); + } else if ((gSaveContext.sceneSetupIndex == 2) && (globalCtx->csCtx.unk_12 == 0)) { + func_80AA0158(this, globalCtx); + } + break; + + case SCENE_CLOCKTOWER: + if (gSaveContext.sceneSetupIndex == 1) { + func_80AA00CC(this, globalCtx); + } + break; + + case SCENE_OPENINGDAN: + if (gSaveContext.sceneSetupIndex == 0) { + if (globalCtx->csCtx.unk_12 == 0) { + func_80AA01C0(this, globalCtx); + } else if (globalCtx->csCtx.unk_12 == 1) { + func_80AA0264(this, globalCtx); + } + } + break; + + case SCENE_OKUJOU: + if (gSaveContext.sceneSetupIndex == 0) { + if (globalCtx->csCtx.unk_12 == 0) { + func_80AA0420(this, globalCtx); + } else if (globalCtx->csCtx.unk_12 == 1) { + func_80AA05F0(this, globalCtx); + } else if (globalCtx->csCtx.unk_12 == 2) { + func_80AA09DC(this, globalCtx); + } else if (globalCtx->csCtx.unk_12 == 3) { + func_80AA0B08(this, globalCtx); + } + } else if (gSaveContext.sceneSetupIndex == 2) { + if (globalCtx->csCtx.unk_12 == 0) { + func_80AA0DA8(this, globalCtx); + } else if (globalCtx->csCtx.unk_12 == 1) { + func_80AA0E1C(this, globalCtx); + } + } + break; + + case SCENE_00KEIKOKU: + if (gSaveContext.sceneSetupIndex == 3) { + if (globalCtx->csCtx.unk_12 == 0) { + func_80AA0634(this, globalCtx); + } else if (globalCtx->csCtx.unk_12 == 2) { + func_80AA066C(this, globalCtx); + } + } else if (gSaveContext.sceneSetupIndex == 7) { + if (globalCtx->csCtx.unk_12 == 0) { + func_80AA071C(this, globalCtx); + } else if (globalCtx->csCtx.unk_12 == 1) { + func_80AA076C(this, globalCtx); + } + } + break; + } + } + + if (this->unk_2E0 == 1) { + if (Animation_OnFrame(&this->skelAnime, 2.0f) || Animation_OnFrame(&this->skelAnime, 6.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_WALK); + } + } else if (this->unk_2E0 == 19) { + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 13.0f) || + Animation_OnFrame(&this->skelAnime, 20.0f) || Animation_OnFrame(&this->skelAnime, 27.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_PL_CALM_HIT); + } + } else if (this->unk_2E0 == 14) { + if (Animation_OnFrame(&this->skelAnime, 3.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_PL_PUT_OUT_ITEM); + } + } else if (this->unk_2E0 == 15) { + if (Animation_OnFrame(&this->skelAnime, 14.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_UNSKILLFUL_OCARINA); + } + + if (Animation_OnFrame(&this->skelAnime, 45.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL01_LAUGH); + } + } +} + +void DmStk_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + DmStk* this = THIS; + + this->unk_33B = 1; + if (this->actor.params != 1) { + this->unk_33A = 0; + this->unk_336 = Object_GetIndex(&globalCtx->objectCtx, OBJECT_STK); + this->unk_337 = Object_GetIndex(&globalCtx->objectCtx, OBJECT_STK2); + this->unk_338 = Object_GetIndex(&globalCtx->objectCtx, OBJECT_STK3); + if (this->unk_336 < 0) { + Actor_MarkForDeath(&this->actor); + } + + this->unk_328 = 0; + this->unk_339 = 0; + this->unk_32C = 1; + this->unk_2E0 = 3; + this->unk_2E8 = globalCtx->lightCtx.unk7; + this->unk_2EC = globalCtx->lightCtx.unk8; + this->unk_2F0 = globalCtx->lightCtx.unk9; + + if ((globalCtx->sceneNum == SCENE_LOST_WOODS) && (gSaveContext.sceneSetupIndex == 1)) { + this->unk_2E4 = 0; + this->unk_2F8 = 0; + this->unk_2FC = 1000; + this->unk_300 = 1.0f; + this->actionFunc = func_80AA1704; + } else if (globalCtx->sceneNum == SCENE_OKUJOU) { + this->unk_2E4 = 255; + this->unk_2F8 = 996; + this->unk_2FC = 1000; + this->unk_300 = 0.7f; + this->unk_335 = 0; + + Collider_InitCylinder(globalCtx, &this->collider); + + if (gSaveContext.entranceIndex == 0x2C00) { + if (gSaveContext.sceneSetupIndex == 0) { + if (gSaveContext.unk_3DD0[3] == 0) { + func_8010E9F0(3, 300); + XREG(80) = 200; + XREG(81) = 115; + } + + if (gSaveContext.inventory.items[SLOT_OCARINA] == ITEM_NONE) { + sCylinderInit.base.colType = COLTYPE_WOOD; + this->actionFunc = func_80AA18D8; + } else { + sCylinderInit.base.colType = COLTYPE_WOOD; + this->actionFunc = func_80AA1998; + } + + } else if (gSaveContext.sceneSetupIndex == 3) { + this->unk_2E0 = 38; + if (gSaveContext.unk_3DD0[3] == 0) { + func_8010E9F0(3, 60); + XREG(80) = 200; + XREG(81) = 115; + } + this->actor.world.pos.y = 120.0f; + sCylinderInit.base.colType = COLTYPE_WOOD; + this->actionFunc = func_80AA27EC; + } else { + this->unk_2E0 = 38; + this->actionFunc = func_80AA16F4; + } + } else { + this->unk_33A = 1; + this->unk_2E0 = 38; + this->actor.world.pos.y = 120.0f; + sCylinderInit.base.colType = COLTYPE_WOOD; + this->actionFunc = func_80AA27EC; + } + + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + + } else if ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 0)) { + if (!(globalCtx->actorCtx.unk5 & 2)) { + Actor_MarkForDeath(&this->actor); + } + this->unk_32C = 2; + this->unk_2E4 = 255; + this->unk_2F8 = 996; + this->unk_2FC = 1000; + this->unk_300 = 0.7f; + this->unk_2E0 = 5; + this->actionFunc = func_80AA1714; + } else { + if ((globalCtx->sceneNum == SCENE_LOST_WOODS) && !func_800EE2F4(globalCtx)) { + Actor_MarkForDeath(&this->actor); + } + this->unk_32C = 2; + this->unk_2E4 = 255; + this->unk_2F8 = 996; + this->unk_2FC = 1000; + this->unk_300 = 0.7f; + this->actionFunc = func_80AA1704; + } + + this->unk_32D = 9; + this->unk_32E = 0; + this->unk_32F = 0; + this->unk_330 = 0; + this->unk_2E4 = this->unk_2E4; + this->actor.targetArrowOffset = 1100.0f; + this->unk_334 = 99; + ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 24.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06013328, NULL, NULL, NULL, 0); + func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); + } + + Actor_SetScale(&this->actor, 0.01f); + + if ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 3) && + (globalCtx->csCtx.unk_12 > 0)) { + globalCtx->envCtx.unk_17 = 15; + globalCtx->envCtx.unk_18 = 15; + } +} + +void DmStk_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void func_80AA16F4(DmStk* this, GlobalContext* globalCtx) { +} + +void func_80AA1704(DmStk* this, GlobalContext* globalCtx) { +} + +void func_80AA1714(DmStk* this, GlobalContext* globalCtx) { + Vec3f sp1C; + + if (!(gSaveContext.weekEventReg[74] & 0x20)) { + func_80169474(globalCtx, &this->actor.world.pos, &sp1C); + if (globalCtx->view.fovy < 25.0f) { + if ((sp1C.x >= 70.0f) && (sp1C.x < 250.0f) && (sp1C.y >= 30.0f) && (sp1C.y < 210.0f)) { + func_800FE484(); + this->actionFunc = func_80AA17F8; + } + } + } +} + +void func_80AA17F8(DmStk* this, GlobalContext* globalCtx) { + s16 sp1E = this->actor.cutscene; + s16 sp1C = ActorCutscene_GetAdditionalCutscene(sp1E); + s16 sp18 = ActorCutscene_GetAdditionalCutscene(sp1C); + s16 cutscene; + + if (gSaveContext.day < 3) { + cutscene = sp1E; + } else if ((gSaveContext.weekEventReg[8] & 0x40) || + ((CURRENT_DAY == 3) && (gSaveContext.time < CLOCK_TIME(6, 0)))) { + cutscene = sp18; + } else { + cutscene = sp1C; + } + + if (ActorCutscene_GetCanPlayNext(cutscene)) { + ActorCutscene_Start(cutscene, &this->actor); + func_800FE498(); + this->actionFunc = func_80AA1704; + } else { + ActorCutscene_SetIntentToPlay(cutscene); + } +} + +void func_80AA18D8(DmStk* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(9)) { + ActorCutscene_Start(9, &this->actor); + this->actionFunc = func_80AA192C; + } else { + ActorCutscene_SetIntentToPlay(9); + } +} + +void func_80AA192C(DmStk* this, GlobalContext* globalCtx) { + if (globalCtx->csCtx.state == 0) { + this->unk_2E0 = 33; + this->unk_32D = 3; + func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); + this->actionFunc = func_80AA2720; + } +} + +void func_80AA1998(DmStk* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(0xB)) { + ActorCutscene_Start(0xB, &this->actor); + this->actionFunc = func_80AA19EC; + } else { + ActorCutscene_SetIntentToPlay(0xB); + } +} + +void func_80AA19EC(DmStk* this, GlobalContext* globalCtx) { + if (globalCtx->csCtx.state == 0) { + this->unk_2E0 = 38; + func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); + this->actionFunc = func_80AA27EC; + } +} + +void func_80AA1A50(DmStk* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(0xA)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_DAMAGE); + ActorCutscene_Start(0xA, &this->actor); + this->actor.shape.rot.x = 0; + this->actor.world.rot.x = this->actor.shape.rot.x; + this->actor.shape.rot.y = this->actor.shape.rot.x; + this->actor.world.rot.y = this->actor.shape.rot.x; + this->actionFunc = func_80AA1AC8; + } else { + ActorCutscene_SetIntentToPlay(0xA); + } +} + +void func_80AA1AC8(DmStk* this, GlobalContext* globalCtx) { + if ((globalCtx->csCtx.state != 0) && (globalCtx->csCtx.frames > 20)) { + this->actionFunc = func_80AA27EC; + } +} + +void func_80AA1AF8(DmStk* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 sin; + + this->unk_32A += 0x4B0; + sin = Math_SinS(this->unk_32A) * 10.0f; + Math_SmoothStepToF(&this->actor.world.pos.y, 160.0f + sin, 0.2f, 1.0f, 0.0001f); + + this->actor.world.rot.y = Actor_YawBetweenActors(&this->actor, &player->actor); + this->actor.shape.rot.y = this->actor.world.rot.y; + + this->actor.world.rot.x = 0x1B58; + this->actor.shape.rot.x = this->actor.world.rot.x; +} + +void func_80AA1B9C(DmStk* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + func_80AA1AF8(this, globalCtx); + this->unk_339++; + if (this->unk_339 >= 3) { + this->unk_339 = 0; + if (!(player->stateFlags2 & 0x8000000)) { + func_801518B0(globalCtx, 0x2013, &this->actor); + } + } + + this->unk_2E0 = 39; + func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_DOWN_K); + this->actionFunc = func_80AA1C64; +} + +void func_80AA1C64(DmStk* this, GlobalContext* globalCtx) { + func_80AA1AF8(this, globalCtx); + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->unk_2E0 = 38; + func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); + this->actionFunc = func_80AA27EC; + } + + if ((this->collider.base.acFlags & AC_HIT) && (this->actor.colChkInfo.damageEffect == 0xF)) { + this->actionFunc = func_80AA1B9C; + } +} + +void func_80AA1D1C(DmStk* this, GlobalContext* globalCtx) { + s32 pad; + u32 temp_v0; + + if (func_800EE29C(globalCtx, 0x6B)) { + temp_v0 = func_800EE200(globalCtx, 0x6B); + + if (globalCtx->csCtx.frames == globalCtx->csCtx.npcActions[temp_v0]->startFrame) { + if (this->unk_334 != globalCtx->csCtx.npcActions[temp_v0]->unk0) { + this->unk_334 = globalCtx->csCtx.npcActions[temp_v0]->unk0; + if (globalCtx->sceneNum == SCENE_CLOCKTOWER) { + this->unk_32D = 6; + } else { + this->unk_32D = 9; + } + + switch (globalCtx->csCtx.npcActions[temp_v0]->unk0) { + case 0: + case 1: + this->unk_2E0 = 3; + break; + + case 2: + this->unk_2E0 = 1; + break; + + case 3: + this->unk_2E0 = 20; + break; + + case 4: + this->unk_2E0 = 18; + break; + + case 6: + this->unk_2E0 = 16; + this->unk_32D = 3; + break; + + case 7: + this->unk_2E0 = 14; + this->unk_32D = 3; + break; + + case 8: + this->unk_2E0 = 0; + break; + + case 9: + this->unk_2E0 = 3; + this->unk_32E = 1; + break; + + case 12: + this->unk_2E0 = 12; + this->unk_32D = 3; + break; + + case 13: + this->unk_2E0 = 27; + this->unk_32D = 3; + break; + + case 14: + this->unk_2E0 = 22; + break; + + case 15: + this->unk_2E0 = 23; + break; + + case 16: + this->unk_2E0 = 28; + break; + + case 17: + this->unk_2E0 = 7; + break; + + case 18: + this->unk_2E0 = 8; + break; + + case 19: + this->unk_2E0 = 10; + break; + + case 20: + this->unk_2E0 = 24; + break; + + case 21: + this->unk_2E0 = 26; + break; + + case 22: + this->unk_2E0 = 29; + if (gSaveContext.inventory.items[SLOT_OCARINA] == ITEM_NONE) { + this->unk_32D = 3; + } + break; + + case 23: + this->unk_2E0 = 30; + this->unk_32D = 4; + break; + + case 24: + this->unk_2E0 = 32; + if (gSaveContext.inventory.items[SLOT_OCARINA] == ITEM_NONE) { + this->unk_32D = 3; + } + break; + + case 25: + Actor_MarkForDeath(&this->actor); + break; + + case 26: + this->unk_2E0 = 34; + if (gSaveContext.inventory.items[SLOT_OCARINA] == ITEM_NONE) { + this->unk_32D = 3; + } + break; + + case 27: + this->unk_2E0 = 36; + if (gSaveContext.inventory.items[SLOT_OCARINA] == ITEM_NONE) { + this->unk_32D = 3; + } + break; + + case 28: + this->unk_2E0 = 37; + this->unk_32D = 4; + break; + + case 30: + this->unk_2E0 = 38; + break; + + case 31: + this->unk_2E0 = 39; + break; + + case 32: + this->unk_2E0 = 42; + break; + + case 33: + this->unk_2E0 = 44; + break; + + case 34: + this->unk_2E0 = 46; + break; + + case 35: + this->unk_2E0 = 48; + break; + + case 36: + this->unk_2E0 = 50; + break; + + case 37: + this->unk_2E0 = 51; + break; + + case 38: + this->unk_2E0 = 52; + break; + + case 39: + this->unk_2E0 = 54; + break; + + case 40: + this->unk_2E0 = 55; + break; + + case 41: + this->unk_2E0 = 40; + break; + + case 42: + this->unk_2E0 = 5; + break; + + case 43: + this->unk_2E0 = 56; + break; + + case 44: + this->unk_2E0 = 57; + break; + + case 45: + this->unk_2E0 = 58; + this->unk_32F = 1; + break; + + case 46: + this->unk_32D = 6; + this->unk_2E0 = 59; + break; + + case 47: + this->unk_2E0 = 60; + break; + + case 48: + this->unk_2E0 = 60; + break; + + case 49: + this->unk_2E0 = 65; + break; + + case 50: + this->unk_2E0 = 66; + break; + + case 51: + this->unk_2E0 = 68; + break; + + case 52: + this->unk_2E0 = 70; + break; + + case 53: + this->unk_2E0 = 60; + break; + + case 54: + this->unk_2E0 = 61; + break; + + case 55: + this->unk_2E0 = 62; + break; + + case 56: + this->unk_2E0 = 64; + break; + + case 57: + this->unk_2E0 = 65; + break; + + case 58: + this->unk_2E0 = 66; + break; + + case 59: + this->unk_2E0 = 68; + break; + + case 60: + this->unk_2E0 = 70; + break; + + case 5: + case 10: + break; + + default: + this->unk_2E0 = 0; + break; + } + + func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); + } + } + + func_800EDF24(&this->actor, globalCtx, temp_v0); + } else { + this->unk_334 = 99; + } + + if (this->unk_32E == 1) { + Math_SmoothStepToF(&this->unk_300, 0.7f, 0.1f, 0.007f, 0.005f); + if (this->unk_300 < 0.71f) { + this->unk_300 = 0.7f; + this->unk_2F8 = 800; + this->unk_32E++; + } + this->unk_2E8 = globalCtx->lightCtx.unk7 * this->unk_300; + this->unk_2EC = globalCtx->lightCtx.unk8 * this->unk_300; + this->unk_2F0 = globalCtx->lightCtx.unk9 * this->unk_300; + + } else if (this->unk_32E == 2) { + if (this->unk_2F8 < 996) { + this->unk_2F8 += 10; + } + + if (this->unk_2F8 > 996) { + this->unk_32E++; + this->unk_2F8 = 996; + } + } else if (this->unk_32E == 3) { + if (this->unk_2E4 < 128) { + this->unk_2E4 += 3; + } + + if (this->unk_2E4 < 255) { + this->unk_2E4 += 20; + } else { + this->unk_2E4 = 255; + this->unk_32E = 0; + } + } + + if (this->unk_32F == 1) { + if (this->unk_330 > 40) { + this->unk_32C = 3; + } + + this->unk_330++; + if (this->unk_330 >= 44) { + this->unk_2E4 -= 35; + if (this->unk_2E4 < 0) { + this->unk_2E4 = 0; + this->unk_32F = 0; + gSaveContext.weekEventReg[12] |= 4; + if (!(globalCtx->actorCtx.unk5 & 2)) { + Actor_MarkForDeath(&this->actor); + } else { + this->unk_33B = 0; + } + } + } + } + + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + switch (this->unk_2E0) { + case 2: + case 8: + case 10: + case 12: + case 14: + case 16: + case 18: + case 20: + case 22: + case 24: + case 30: + case 32: + case 34: + case 40: + case 42: + case 44: + case 46: + case 48: + case 52: + case 62: + case 66: + case 68: + case 70: + this->unk_2E0++; + func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); + break; + + case 26: + this->unk_2E0 = 3; + this->unk_32C = 1; + this->unk_32D = 9; + func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); + break; + } + } + + if (((this->unk_2E0 == 24) && (this->skelAnime.curFrame >= 16.0f)) || (this->unk_2E0 == 25) || + (this->unk_2E0 == 26)) { + this->unk_32C = 9; + this->unk_32D = 2; + } else if (((this->unk_2E0 >= 50) && (this->unk_2E0 < 56)) || ((this->unk_2E0 > 58) && (this->unk_2E0 <= 60)) || + ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 7))) { + this->unk_32C = 0; + if ((this->unk_2E0 == 52) || (this->unk_2E0 == 53)) { + this->unk_32D = 5; + } + } + + if (this->unk_2E0 == 64) { + this->unk_32C = 0; + } +} + +void func_80AA26CC(DmStk* this, GlobalContext* globalCtx) { + s32 pad; + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void func_80AA2720(DmStk* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (globalCtx->csCtx.state == 0) { + func_80AA1AF8(this, globalCtx); + this->actor.flags |= 1; + this->unk_328++; + if (this->unk_328 > 800) { + this->unk_328 = 0; + if (!(player->stateFlags2 & 0x8000000)) { + func_801518B0(globalCtx, 0x2014, &this->actor); + } + } + if ((this->collider.base.acFlags & AC_HIT) && (this->actor.colChkInfo.damageEffect == 0xF)) { + this->unk_335 = 1; + this->actionFunc = func_80AA1A50; + } + } +} + +void func_80AA27EC(DmStk* this, GlobalContext* globalCtx) { + if (globalCtx->csCtx.state == 0) { + func_80AA1AF8(this, globalCtx); + this->actor.flags |= 1; + + if (this->unk_2E0 == 33) { + this->actor.targetArrowOffset = 3100.0f; + } else { + this->actor.targetArrowOffset = 200.0f; + } + + if ((this->collider.base.acFlags & AC_HIT) && (this->actor.colChkInfo.damageEffect == 0xF)) { + this->unk_335 = 1; + this->actionFunc = func_80AA1B9C; + } + } +} + +void DmStk_Update(Actor* thisx, GlobalContext* globalCtx) { + DmStk* this = THIS; + u16 time; + + if (this->actor.params != 1) { + if (this->unk_2E0 == 33) { + Actor_SetHeight(&this->actor, 40.0f); + } else { + Actor_SetHeight(&this->actor, 6.0f); + } + + func_80A9FDB0(this, globalCtx); + + if (this->unk_2E0 != 61) { + SkelAnime_Update(&this->skelAnime); + } + + this->unk_2E4 = this->unk_2E4; + + this->actionFunc(this, globalCtx); + + if (globalCtx->sceneNum == SCENE_OKUJOU) { + func_80AA26CC(this, globalCtx); + } + + func_80AA1D1C(this, globalCtx); + func_80AA0E90(this, globalCtx); + + switch (this->unk_33A) { + case 1: + if (func_800B8718(&this->actor, globalCtx)) { + this->unk_33A = 2; + } else { + func_800B874C(&this->actor, globalCtx, this->actor.xzDistToPlayer, + fabsf(this->actor.playerHeightRel)); + } + break; + + case 2: + if (ActorCutscene_GetCanPlayNext(0x10)) { + this->unk_33A = 3; + ActorCutscene_Start(0x10, &this->actor); + this->actionFunc = func_80AA27EC; + } else { + ActorCutscene_SetIntentToPlay(0x10); + } + break; + + case 3: + if (globalCtx->csCtx.state == 0) { + this->unk_33A = 4; + } + break; + } + + if ((globalCtx->actorCtx.unk5 & 2) && (globalCtx->msgCtx.unk11F22 != 0) && + (globalCtx->msgCtx.unk11F04 == 0x5E6) && !FrameAdvance_IsEnabled(globalCtx) && + (globalCtx->sceneLoadFlag == 0) && (ActorCutscene_GetCurrentIndex() == -1) && + (globalCtx->csCtx.state == 0)) { + time = gSaveContext.time; + gSaveContext.time = (u16)REG(15) + time; + if (REG(15) != 0) { + time = gSaveContext.time; + gSaveContext.time = (u16)gSaveContext.unk_14 + time; + } + } + } + + if ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 3) && + (globalCtx->csCtx.unk_12 > 0)) { + globalCtx->envCtx.unk_17 = 15; + globalCtx->envCtx.unk_18 = 15; + } +} + +s32 DmStk_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + DmStk* this = THIS; + + if (limbIndex == 15) { + if ((this->unk_32D == 0) || (this->unk_32D == 1) || (this->unk_32D == 3)) { + *dList = NULL; + } + } else if (limbIndex == 12) { + switch (this->unk_32D) { + case 1: + case 2: + case 3: + case 4: + case 6: + *dList = NULL; + break; + + case 9: + if (this->unk_2E4 == 255) { + *dList = NULL; + } + break; + } + } else if (limbIndex == 17) { + *dList = NULL; + } + + return false; +} + +void DmStk_PostLimbDraw2(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { + s32 pad; + s32 pad2; + DmStk* this = THIS; + + if (limbIndex == 17) { + Matrix_GetStateTranslation(&this->unk_304); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if ((this->unk_2E0 == 69) || (this->unk_2E0 == 11) || (this->unk_2E0 == 71)) { + gSPDisplayList(POLY_OPA_DISP++, D_0600AEC0); + gSPDisplayList(POLY_OPA_DISP++, D_0600AE30); + } else { + gSPDisplayList(POLY_OPA_DISP++, D_0600A5C0); + gSPDisplayList(POLY_OPA_DISP++, D_0600A530); + } + + switch (this->unk_32C) { + case 0: + break; + + case 1: + if ((globalCtx->sceneNum == SCENE_LOST_WOODS) && (gSaveContext.sceneSetupIndex == 1) && + (globalCtx->csCtx.frames < 1400)) { + if (this->unk_2F8 == this->unk_2FC) { + this->unk_2FC = this->unk_2F8; + } + POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, this->unk_2E8, this->unk_2EC, this->unk_2F0, + this->unk_2F4, this->unk_2F8, this->unk_2FC); + gSPDisplayList(POLY_OPA_DISP++, D_06006BB0); + POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + } else { + gSPDisplayList(POLY_OPA_DISP++, D_06006BB0); + } + break; + + case 2: + gSPDisplayList(POLY_OPA_DISP++, D_06006BB0); + gSPDisplayList(POLY_OPA_DISP++, D_06005870); + + if (func_800EE29C(globalCtx, 0x201) && + (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x201)]->unk0 == 2) && (this->unk_337 >= 0)) { + Matrix_StatePush(); + Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->unk_337].segment); + + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->unk_337].segment); + + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&D_06008658)); + func_800BDFC0(globalCtx, D_06007840); + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->unk_336].segment); + + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->unk_336].segment); + + Matrix_StatePop(); + } + break; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + } else if (limbIndex == 15) { + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (this->unk_32D != 5) { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + } + + switch (this->unk_32D) { + case 0: + gSPDisplayList(POLY_OPA_DISP++, D_06009AC0); + gSPDisplayList(POLY_OPA_DISP++, D_060046B0); + break; + + case 1: + gSPDisplayList(POLY_OPA_DISP++, D_06009710); + gSPDisplayList(POLY_OPA_DISP++, D_060053C0); + break; + + case 3: + gSPDisplayList(POLY_OPA_DISP++, D_06009DA0); + + if ((globalCtx->sceneNum == SCENE_LOST_WOODS) && (gSaveContext.sceneSetupIndex == 1)) { + gSPDisplayList(POLY_OPA_DISP++, D_0600CAD0); + } + break; + + case 5: + Matrix_InsertTranslation(-20.0f, -660.0f, 860.0f, MTXMODE_APPLY); + Matrix_RotateY(0x6142, MTXMODE_APPLY); + Matrix_InsertXRotation_s(-0x1988, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, D_06006BB0); + break; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + } else if (limbIndex == 12) { + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + switch (this->unk_32D) { + case 0: + break; + + case 1: + gSPDisplayList(POLY_OPA_DISP++, D_060084C0); + break; + + case 2: + gSPDisplayList(POLY_OPA_DISP++, D_060090C0); + gSPDisplayList(POLY_OPA_DISP++, D_060079F0); + break; + + case 3: + if ((globalCtx->sceneNum != SCENE_LOST_WOODS) || (gSaveContext.sceneSetupIndex != 1)) { + gSPDisplayList(POLY_OPA_DISP++, D_0600CAD0); + } + gSPDisplayList(POLY_OPA_DISP++, D_060090C0); + break; + + case 4: + gSPDisplayList(POLY_OPA_DISP++, D_060090C0); + break; + + case 6: + gSPDisplayList(POLY_OPA_DISP++, D_06008A80); + gSPDisplayList(POLY_OPA_DISP++, D_06016620); + break; + + case 9: + if (this->unk_2E4 == 255) { + gSPDisplayList(POLY_OPA_DISP++, D_060087B0); + } + break; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void DmStk_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + DmStk* this = THIS; + + DmStk_PostLimbDraw2(globalCtx, limbIndex, dList, rot, &this->actor, NULL); +} + +void DmStk_Draw(Actor* thisx, GlobalContext* globalCtx) { + DmStk* this = THIS; + + if (this->unk_33B != 0) { + if (this->actor.params == 1) { + func_800BDFC0(globalCtx, D_06006BB0); + return; + } + + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->unk_336].segment); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + this->unk_2E4 = this->unk_2E4; + func_8012C28C(globalCtx->state.gfxCtx); + + if (this->unk_2E4 < 255) { + func_8012C2DC(globalCtx->state.gfxCtx); + Scene_SetRenderModeXlu(globalCtx, 1, 2); + + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->unk_2E4); + + POLY_XLU_DISP = + SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, DmStk_PostLimbDraw2, &this->actor, POLY_XLU_DISP); + } else { + Scene_SetRenderModeXlu(globalCtx, 0, 1); + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, DmStk_OverrideLimbDraw, DmStk_PostLimbDraw, &this->actor); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.h b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.h index 07459e717d..2b8c543831 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.h +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.h @@ -9,9 +9,37 @@ typedef void (*DmStkActionFunc)(struct DmStk*, GlobalContext*); typedef struct DmStk { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x14C]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ UNK_TYPE1 unk_188[0x108]; /* 0x0290 */ DmStkActionFunc actionFunc; - /* 0x0294 */ char unk_294[0xA8]; + /* 0x0294 */ ColliderCylinder collider; + /* 0x02E0 */ s16 unk_2E0; + /* 0x02E4 */ s32 unk_2E4; + /* 0x02E8 */ u32 unk_2E8; + /* 0x02EC */ u32 unk_2EC; + /* 0x02F0 */ u32 unk_2F0; + /* 0x02F4 */ s32 unk_2F4; + /* 0x02F8 */ s32 unk_2F8; + /* 0x02FC */ s32 unk_2FC; + /* 0x0300 */ f32 unk_300; + /* 0x0304 */ Vec3f unk_304; + /* 0x0310 */ Vec3f unk_310; + /* 0x031C */ UNK_TYPE1 unk31C[0xC]; + /* 0x0328 */ u16 unk_328; + /* 0x032A */ u16 unk_32A; + /* 0x032C */ u8 unk_32C; + /* 0x032D */ u8 unk_32D; + /* 0x032E */ u8 unk_32E; + /* 0x032F */ u8 unk_32F; + /* 0x0330 */ s32 unk_330; + /* 0x0334 */ u8 unk_334; + /* 0x0335 */ u8 unk_335; + /* 0x0336 */ s8 unk_336; + /* 0x0337 */ s8 unk_337; + /* 0x0338 */ s8 unk_338; + /* 0x0339 */ u8 unk_339; + /* 0x033A */ u8 unk_33A; + /* 0x033B */ u8 unk_33B; } DmStk; // size = 0x33C extern const ActorInit Dm_Stk_InitVars; diff --git a/src/overlays/actors/ovl_Eff_Change/z_eff_change.c b/src/overlays/actors/ovl_Eff_Change/z_eff_change.c index 339a080763..45a62ed729 100644 --- a/src/overlays/actors/ovl_Eff_Change/z_eff_change.c +++ b/src/overlays/actors/ovl_Eff_Change/z_eff_change.c @@ -1,7 +1,7 @@ /* * File: z_eff_change.c * Overlay: ovl_Eff_Change - * Description: + * Description: Elegy of Emptiness - Beam of Light When Creating Statue */ #include "z_eff_change.h" diff --git a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c index 3ca55d7b85..bf72f3721e 100644 --- a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c +++ b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c @@ -1,5 +1,5 @@ /* - * File z_eff_dust.c + * File: z_eff_dust.c * Overlay: ovl_Eff_Dust * Description: Dust effects */ diff --git a/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.c b/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.c index 7b982d25c2..faea4c4e42 100644 --- a/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.c +++ b/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.c @@ -1,5 +1,5 @@ /* - * File z_eff_kamejima_wave.c + * File: z_eff_kamejima_wave.c * Overlay: ovl_Eff_Kamejima_Wave * Description: Wave Created by Turtle Awakening */ diff --git a/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.c b/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.c index 7812faa9be..4f9138aa7f 100644 --- a/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.c +++ b/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.c @@ -1,5 +1,5 @@ /* - * File z_eff_lastday.c + * File: z_eff_lastday.c * Overlay: ovl_Eff_Lastday * Description: Moon Crash Cutscene Fire Wall */ diff --git a/src/overlays/actors/ovl_Eff_Stk/z_eff_stk.c b/src/overlays/actors/ovl_Eff_Stk/z_eff_stk.c index dcc61493a8..b02e52e571 100644 --- a/src/overlays/actors/ovl_Eff_Stk/z_eff_stk.c +++ b/src/overlays/actors/ovl_Eff_Stk/z_eff_stk.c @@ -1,5 +1,5 @@ /* - * File z_eff_stk.c + * File: z_eff_stk.c * Overlay: ovl_Eff_Stk * Description: Skullkid Effects (calling down moon / cursing Link) */ diff --git a/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.c b/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.c index 6ffafb311d..6da3885bea 100644 --- a/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.c +++ b/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.c @@ -1,7 +1,7 @@ /* - * File z_eff_zoraband.c + * File: z_eff_zoraband.c * Overlay: ovl_Eff_Zoraband - * Description: + * Description: Indigo-Go's (Mikau's healing cutscene) */ #include "z_eff_zoraband.h" diff --git a/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c b/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c index 7c7a39a2ca..d3d0317ae3 100644 --- a/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c +++ b/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c @@ -1,5 +1,5 @@ /* - * File z_elf_msg.c + * File: z_elf_msg.c * Overlay: ovl_Elf_Msg * Description: Tatl Hint (proximity-activated C-up hint?) */ diff --git a/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c b/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c index 014f61c43e..ece5b9a5c6 100644 --- a/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c +++ b/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c @@ -1,5 +1,5 @@ /* - * File z_elf_msg2.c + * File: z_elf_msg2.c * Overlay: ovl_Elf_Msg2 * Description: Tatl Hint (Z-target-activated C-up hint?) */ diff --git a/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c b/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c index 6e84cccf27..95942b815a 100644 --- a/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c +++ b/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c @@ -1,5 +1,5 @@ /* - * File z_elf_msg3.c + * File: z_elf_msg3.c * Overlay: ovl_Elf_Msg3 * Description: Tatl Message (Proximity-activated dialogue?) */ diff --git a/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.c b/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.c index eefe990635..c55591fbaf 100644 --- a/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.c +++ b/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.c @@ -1,5 +1,5 @@ /* - * File z_elf_msg4.c + * File: z_elf_msg4.c * Overlay: ovl_Elf_Msg4 * Description: Tatl Hint (another proximity-activated C-up hint?) */ diff --git a/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.c b/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.c index 371fa7f228..3fc56c89b6 100644 --- a/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.c +++ b/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.c @@ -1,5 +1,5 @@ /* - * File z_elf_msg5.c + * File: z_elf_msg5.c * Overlay: ovl_Elf_Msg5 * Description: Tatl Message (Another proximity-activated dialogue?) */ diff --git a/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c b/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c index ea9e79df6b..ecd927765f 100644 --- a/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c +++ b/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c @@ -1,5 +1,5 @@ /* - * File z_elf_msg6.c + * File: z_elf_msg6.c * Overlay: ovl_Elf_Msg6 * Description: Tatl Hint (another proximity-activated C-up hint?) */ diff --git a/src/overlays/actors/ovl_En_Ah/z_en_ah.c b/src/overlays/actors/ovl_En_Ah/z_en_ah.c index da77211529..19a2aaf2d3 100644 --- a/src/overlays/actors/ovl_En_Ah/z_en_ah.c +++ b/src/overlays/actors/ovl_En_Ah/z_en_ah.c @@ -1,5 +1,5 @@ /* - * File z_en_ah.c + * File: z_en_ah.c * Overlay: ovl_En_Ah * Description: Anju's Mother */ diff --git a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c index 191b35ec96..f2590f255b 100644 --- a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c +++ b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c @@ -1,7 +1,7 @@ /* - * File z_en_akindonuts.c + * File: z_en_akindonuts.c * Overlay: ovl_En_Akindonuts - * Description: Woodfall - Business Scrub + * Description: Trade quest Business Scrubs */ #include "z_en_akindonuts.h" diff --git a/src/overlays/actors/ovl_En_Al/z_en_al.c b/src/overlays/actors/ovl_En_Al/z_en_al.c index 66eb513b93..26961e4c78 100644 --- a/src/overlays/actors/ovl_En_Al/z_en_al.c +++ b/src/overlays/actors/ovl_En_Al/z_en_al.c @@ -1,5 +1,5 @@ /* - * File z_en_al.c + * File: z_en_al.c * Overlay: ovl_En_Al * Description: Madame Aroma */ diff --git a/src/overlays/actors/ovl_En_Am/z_en_am.c b/src/overlays/actors/ovl_En_Am/z_en_am.c index 37a38a9e83..355d37e59d 100644 --- a/src/overlays/actors/ovl_En_Am/z_en_am.c +++ b/src/overlays/actors/ovl_En_Am/z_en_am.c @@ -1,5 +1,5 @@ /* - * File z_en_am.c + * File: z_en_am.c * Overlay: ovl_En_Am * Description: Armos */ diff --git a/src/overlays/actors/ovl_En_An/z_en_an.c b/src/overlays/actors/ovl_En_An/z_en_an.c index 9611e2c765..43ea5744ab 100644 --- a/src/overlays/actors/ovl_En_An/z_en_an.c +++ b/src/overlays/actors/ovl_En_An/z_en_an.c @@ -1,5 +1,5 @@ /* - * File z_en_an.c + * File: z_en_an.c * Overlay: ovl_En_An * Description: Anju */ diff --git a/src/overlays/actors/ovl_En_And/z_en_and.c b/src/overlays/actors/ovl_En_And/z_en_and.c index 178674efd8..ad0291e7d4 100644 --- a/src/overlays/actors/ovl_En_And/z_en_and.c +++ b/src/overlays/actors/ovl_En_And/z_en_and.c @@ -1,5 +1,5 @@ /* - * File z_en_and.c + * File: z_en_and.c * Overlay: ovl_En_And * Description: Anju in Wedding Dress */ diff --git a/src/overlays/actors/ovl_En_Ani/z_en_ani.c b/src/overlays/actors/ovl_En_Ani/z_en_ani.c index 5571fe73c7..c125784207 100644 --- a/src/overlays/actors/ovl_En_Ani/z_en_ani.c +++ b/src/overlays/actors/ovl_En_Ani/z_en_ani.c @@ -1,7 +1,7 @@ /* - * File z_en_ani.c + * File: z_en_ani.c * Overlay: ovl_En_Ani - * Description: Part-Timer + * Description: Part-time worker */ #include "z_en_ani.h" diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c index fe0312f3b0..e434c69c2e 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c @@ -1,5 +1,5 @@ /* - * File z_en_aob_01.c + * File: z_en_aob_01.c * Overlay: ovl_En_Aob_01 * Description: Mamamu Yan */ diff --git a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c index bd2e07b570..bacb293950 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c @@ -1,5 +1,5 @@ /* - * File z_en_arrow.c + * File: z_en_arrow.c * Overlay: ovl_En_Arrow * Description: Arrows and other projectiles */ diff --git a/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c b/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c index 9e7f4be9cc..5eca6c796d 100644 --- a/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c +++ b/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c @@ -1,5 +1,5 @@ /* - * File z_en_attack_niw.c + * File: z_en_attack_niw.c * Overlay: ovl_En_Attack_Niw * Description: Attacking cucco */ diff --git a/src/overlays/actors/ovl_En_Az/z_en_az.c b/src/overlays/actors/ovl_En_Az/z_en_az.c index 5af1dac54d..c5f687498c 100644 --- a/src/overlays/actors/ovl_En_Az/z_en_az.c +++ b/src/overlays/actors/ovl_En_Az/z_en_az.c @@ -1,5 +1,5 @@ /* - * File z_en_az.c + * File: z_en_az.c * Overlay: ovl_En_Az * Description: Beaver Bros */ diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.c b/src/overlays/actors/ovl_En_Baba/z_en_baba.c index afe4f44cad..4593ec4b04 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.c +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.c @@ -1,5 +1,5 @@ /* - * File z_en_baba.c + * File: z_en_baba.c * Overlay: ovl_En_Baba * Description: Bomb Shop Lady */ diff --git a/src/overlays/actors/ovl_En_Bal/z_en_bal.c b/src/overlays/actors/ovl_En_Bal/z_en_bal.c index aa48ac9c63..dbfa561c61 100644 --- a/src/overlays/actors/ovl_En_Bal/z_en_bal.c +++ b/src/overlays/actors/ovl_En_Bal/z_en_bal.c @@ -1,7 +1,7 @@ /* - * File z_en_bal.c + * File: z_en_bal.c * Overlay: ovl_En_Bal - * Description: Tingle With Balloon + * Description: Tingle with Balloon */ #include "z_en_bal.h" diff --git a/src/overlays/actors/ovl_En_Bat/z_en_bat.c b/src/overlays/actors/ovl_En_Bat/z_en_bat.c index de2330bb80..a419d2901a 100644 --- a/src/overlays/actors/ovl_En_Bat/z_en_bat.c +++ b/src/overlays/actors/ovl_En_Bat/z_en_bat.c @@ -1,5 +1,5 @@ /* - * File z_en_bat.c + * File: z_en_bat.c * Overlay: ovl_En_Bat * Description: Bad Bat */ diff --git a/src/overlays/actors/ovl_En_Bb/z_en_bb.c b/src/overlays/actors/ovl_En_Bb/z_en_bb.c index cfbb8240ee..cd8c7cac87 100644 --- a/src/overlays/actors/ovl_En_Bb/z_en_bb.c +++ b/src/overlays/actors/ovl_En_Bb/z_en_bb.c @@ -1,5 +1,5 @@ /* - * File z_en_bb.c + * File: z_en_bb.c * Overlay: ovl_En_Bb * Description: Blue Bubble */ diff --git a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c index 5a393e7c28..0ee8d32e37 100644 --- a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c +++ b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c @@ -1,7 +1,7 @@ /* - * File z_en_bba_01.c + * File: z_en_bba_01.c * Overlay: ovl_En_Bba_01 - * Description: + * Description: Unused Bomb Shop Lady NPC */ #include "z_en_bba_01.h" diff --git a/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c index 97c44ce5f2..080579156d 100644 --- a/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c +++ b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c @@ -1,5 +1,5 @@ /* - * File z_en_bbfall.c + * File: z_en_bbfall.c * Overlay: ovl_En_Bbfall * Description: Red Bubble */ diff --git a/src/overlays/actors/ovl_En_Bee/z_en_bee.c b/src/overlays/actors/ovl_En_Bee/z_en_bee.c index eeb8af33c6..1bf4d8d8c5 100644 --- a/src/overlays/actors/ovl_En_Bee/z_en_bee.c +++ b/src/overlays/actors/ovl_En_Bee/z_en_bee.c @@ -1,5 +1,5 @@ /* - * File z_en_bee.c + * File: z_en_bee.c * Overlay: ovl_En_Bee * Description: Giant Bee */ diff --git a/src/overlays/actors/ovl_En_Bh/z_en_bh.c b/src/overlays/actors/ovl_En_Bh/z_en_bh.c index fdffeca260..ff6cb047d5 100644 --- a/src/overlays/actors/ovl_En_Bh/z_en_bh.c +++ b/src/overlays/actors/ovl_En_Bh/z_en_bh.c @@ -1,7 +1,7 @@ /* - * File z_en_bh.c + * File: z_en_bh.c * Overlay: ovl_En_Bh - * Description: Brown Bird + * Description: Brown Bird (on the Moon) */ #include "z_en_bh.h" diff --git a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c index 364e1205f0..65ef97e26c 100644 --- a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c +++ b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c @@ -1,5 +1,5 @@ /* - * File z_en_bigokuta.c + * File: z_en_bigokuta.c * Overlay: ovl_En_Bigokuta * Description: Big Octo */ diff --git a/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.c b/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.c index a1d663f61f..7608bed536 100644 --- a/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.c +++ b/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.c @@ -1,5 +1,5 @@ /* - * File z_en_bigpamet.c + * File: z_en_bigpamet.c * Overlay: ovl_En_Bigpamet * Description: Gekko & Snapper Miniboss - Snapper */ diff --git a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c index 42ac8d5108..ddc5742423 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c @@ -1,7 +1,7 @@ /* - * File z_en_bigpo.c - * Overlay: ovl_En_Bigpi - * Description: Big Poe. Leader of the Poes, found under Dampe's house and in Beneath the Well + * File: z_en_bigpo.c + * Overlay: ovl_En_Bigpo + * Description: Big Poe. Found under Dampe's house and in Beneath the Well */ #include "z_en_bigpo.h" @@ -449,7 +449,7 @@ void EnBigpo_SpawnCutsceneStage6(EnBigpo* this, GlobalContext* globalCtx) { void EnBigpo_SpawnCutsceneStage7(EnBigpo* this) { this->idleTimer = 15; if (this->unkBool204 == false) { - func_801A2E54(0x38); + func_801A2E54(NA_BGM_MINI_BOSS); this->unkBool204 = true; } this->actionFunc = EnBigpo_SpawnCutsceneStage8; @@ -535,7 +535,7 @@ void EnBigpo_WarpingIn(EnBigpo* this, GlobalContext* globalCtx) { if (this->idleTimer == 32) { this->mainColor.a = 255; // fully visible if (this->unkBool204 == false) { - func_801A2E54(0x38); + func_801A2E54(NA_BGM_MINI_BOSS); this->unkBool204 = true; } EnBigpo_SetupIdleFlying(this); diff --git a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c index 2d2ad5a3f8..f67e80980d 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c @@ -1,5 +1,5 @@ /* - * File z_en_bigslime.c + * File: z_en_bigslime.c * Overlay: ovl_En_Bigslime * Description: Mad Jelly (miniboss) */ diff --git a/src/overlays/actors/ovl_En_Bjt/z_en_bjt.c b/src/overlays/actors/ovl_En_Bjt/z_en_bjt.c index c09bb4ceab..f4814fac24 100644 --- a/src/overlays/actors/ovl_En_Bjt/z_en_bjt.c +++ b/src/overlays/actors/ovl_En_Bjt/z_en_bjt.c @@ -1,7 +1,7 @@ /* - * File z_en_bjt.c + * File: z_en_bjt.c * Overlay: ovl_En_Bjt - * Description: Hand in Toilet + * Description: ??? (Hand in toilet) */ #include "z_en_bjt.h" diff --git a/src/overlays/actors/ovl_En_Boj_01/z_en_boj_01.c b/src/overlays/actors/ovl_En_Boj_01/z_en_boj_01.c index 9a3304b8ae..e070bea5e9 100644 --- a/src/overlays/actors/ovl_En_Boj_01/z_en_boj_01.c +++ b/src/overlays/actors/ovl_En_Boj_01/z_en_boj_01.c @@ -1,5 +1,5 @@ /* - * File z_en_boj_01.c + * File: z_en_boj_01.c * Overlay: ovl_En_Boj_01 * Description: [Empty] */ diff --git a/src/overlays/actors/ovl_En_Boj_02/z_en_boj_02.c b/src/overlays/actors/ovl_En_Boj_02/z_en_boj_02.c index 19b384d7fc..9899a15e0d 100644 --- a/src/overlays/actors/ovl_En_Boj_02/z_en_boj_02.c +++ b/src/overlays/actors/ovl_En_Boj_02/z_en_boj_02.c @@ -1,5 +1,5 @@ /* - * File z_en_boj_02.c + * File: z_en_boj_02.c * Overlay: ovl_En_Boj_02 * Description: [Empty] */ diff --git a/src/overlays/actors/ovl_En_Boj_03/z_en_boj_03.c b/src/overlays/actors/ovl_En_Boj_03/z_en_boj_03.c index 4391e59fba..019f805389 100644 --- a/src/overlays/actors/ovl_En_Boj_03/z_en_boj_03.c +++ b/src/overlays/actors/ovl_En_Boj_03/z_en_boj_03.c @@ -1,5 +1,5 @@ /* - * File z_en_boj_03.c + * File: z_en_boj_03.c * Overlay: ovl_En_Boj_03 * Description: [Empty] */ diff --git a/src/overlays/actors/ovl_En_Boj_04/z_en_boj_04.c b/src/overlays/actors/ovl_En_Boj_04/z_en_boj_04.c index 4fea47b301..9952f706d2 100644 --- a/src/overlays/actors/ovl_En_Boj_04/z_en_boj_04.c +++ b/src/overlays/actors/ovl_En_Boj_04/z_en_boj_04.c @@ -1,5 +1,5 @@ /* - * File z_en_boj_04.c + * File: z_en_boj_04.c * Overlay: ovl_En_Boj_04 * Description: [Empty] */ diff --git a/src/overlays/actors/ovl_En_Boj_05/z_en_boj_05.c b/src/overlays/actors/ovl_En_Boj_05/z_en_boj_05.c index b327b381c5..a3a9dcff8e 100644 --- a/src/overlays/actors/ovl_En_Boj_05/z_en_boj_05.c +++ b/src/overlays/actors/ovl_En_Boj_05/z_en_boj_05.c @@ -1,5 +1,5 @@ /* - * File z_en_boj_05.c + * File: z_en_boj_05.c * Overlay: ovl_En_Boj_05 * Description: [Empty] */ diff --git a/src/overlays/actors/ovl_En_Bom/z_en_bom.c b/src/overlays/actors/ovl_En_Bom/z_en_bom.c index acb36d2588..d135e2b359 100644 --- a/src/overlays/actors/ovl_En_Bom/z_en_bom.c +++ b/src/overlays/actors/ovl_En_Bom/z_en_bom.c @@ -1,5 +1,5 @@ /* - * File z_en_bom.c + * File: z_en_bom.c * Overlay: ovl_En_Bom * Description: Bomb / Powder Keg */ diff --git a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c index 919fd57981..4ec8ae2b60 100644 --- a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c +++ b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c @@ -1,7 +1,7 @@ /* - * File z_en_bom_bowl_man.c + * File: z_en_bom_bowl_man.c * Overlay: ovl_En_Bom_Bowl_Man - * Description: Line of Bombers? + * Description: Line of Bombers when they teach you the password */ #include "z_en_bom_bowl_man.h" diff --git a/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c b/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c index 3dabe557bb..f02ab4ec69 100644 --- a/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c +++ b/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c @@ -1,5 +1,5 @@ /* - * File z_en_bom_chu.c + * File: z_en_bom_chu.c * Overlay: ovl_En_Bom_Chu * Description: Bombchus */ diff --git a/src/overlays/actors/ovl_En_Bombal/z_en_bombal.c b/src/overlays/actors/ovl_En_Bombal/z_en_bombal.c index 134dc1042d..09d0880c66 100644 --- a/src/overlays/actors/ovl_En_Bombal/z_en_bombal.c +++ b/src/overlays/actors/ovl_En_Bombal/z_en_bombal.c @@ -1,5 +1,5 @@ /* - * File z_en_bombal.c + * File: z_en_bombal.c * Overlay: ovl_En_Bombal * Description: Bombers - Majora Balloon */ diff --git a/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c b/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c index 4bd648deae..2ef45e65d4 100644 --- a/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c +++ b/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c @@ -1,5 +1,5 @@ /* - * File z_en_bombers.c + * File: z_en_bombers.c * Overlay: ovl_En_Bombers * Description: Bombers - Blue-Hatted Bomber */ diff --git a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c index 478b117d71..18aa562e7b 100644 --- a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c +++ b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c @@ -1,5 +1,5 @@ /* - * File z_en_bombers2.c + * File: z_en_bombers2.c * Overlay: ovl_En_Bombers2 * Description: Bombers - Hideout Guard */ diff --git a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c index e40ff2efbb..292469236e 100644 --- a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c +++ b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c @@ -1,5 +1,5 @@ /* - * File z_en_bombf.c + * File: z_en_bombf.c * Overlay: ovl_En_Bombf * Description: Bomb flower */ diff --git a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c index 0562e8dc41..5a003ef85d 100644 --- a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c +++ b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c @@ -1,5 +1,5 @@ /* - * File z_en_bomjima.c + * File: z_en_bomjima.c * Overlay: ovl_En_Bomjima * Description: Bombers - Jim */ diff --git a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c index f8c22c44ff..b052bb6af5 100644 --- a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c +++ b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c @@ -1,7 +1,7 @@ /* - * File z_en_bomjimb.c + * File: z_en_bomjimb.c * Overlay: ovl_En_Bomjimb - * Description: Bomber Jim B + * Description: Bombers when chasing them */ #include "z_en_bomjimb.h" diff --git a/src/overlays/actors/ovl_En_Boom/z_en_boom.c b/src/overlays/actors/ovl_En_Boom/z_en_boom.c index 99efd7f3d9..b6115a897d 100644 --- a/src/overlays/actors/ovl_En_Boom/z_en_boom.c +++ b/src/overlays/actors/ovl_En_Boom/z_en_boom.c @@ -1,5 +1,5 @@ /* - * File z_en_boom.c + * File: z_en_boom.c * Overlay: ovl_En_Boom * Description: Zora boomerangs */ diff --git a/src/overlays/actors/ovl_En_Box/z_en_box.c b/src/overlays/actors/ovl_En_Box/z_en_box.c index f3a2d835ce..7367f49bcc 100644 --- a/src/overlays/actors/ovl_En_Box/z_en_box.c +++ b/src/overlays/actors/ovl_En_Box/z_en_box.c @@ -1,5 +1,5 @@ /* - * File z_en_box.c + * File: z_en_box.c * Overlay: ovl_En_Box * Description: Chest */ diff --git a/src/overlays/actors/ovl_En_Bsb/z_en_bsb.c b/src/overlays/actors/ovl_En_Bsb/z_en_bsb.c index 0bb1f7e29e..2e6b31a351 100644 --- a/src/overlays/actors/ovl_En_Bsb/z_en_bsb.c +++ b/src/overlays/actors/ovl_En_Bsb/z_en_bsb.c @@ -1,5 +1,5 @@ /* - * File z_en_bsb.c + * File: z_en_bsb.c * Overlay: ovl_En_Bsb * Description: Captain Keeta */ diff --git a/src/overlays/actors/ovl_En_Bu/z_en_bu.c b/src/overlays/actors/ovl_En_Bu/z_en_bu.c index 4bd1e310f4..cb61799b9e 100644 --- a/src/overlays/actors/ovl_En_Bu/z_en_bu.c +++ b/src/overlays/actors/ovl_En_Bu/z_en_bu.c @@ -1,5 +1,5 @@ /* - * File z_en_bu.c + * File: z_en_bu.c * Overlay: ovl_En_Bu * Description: Unused dummied-out enemy */ diff --git a/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c b/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c index 4cddd0d54c..e6ff6864ad 100644 --- a/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c +++ b/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c @@ -1,7 +1,7 @@ /* - * File z_en_bubble.c + * File: z_en_bubble.c * Overlay: ovl_En_Bubble - * Description: Bubble (flying skull enemy) + * Description: Shabom (unused) */ #include "z_en_bubble.h" diff --git a/src/overlays/actors/ovl_En_Butte/z_en_butte.c b/src/overlays/actors/ovl_En_Butte/z_en_butte.c index e8b2dceb40..54dd34dbcd 100644 --- a/src/overlays/actors/ovl_En_Butte/z_en_butte.c +++ b/src/overlays/actors/ovl_En_Butte/z_en_butte.c @@ -1,5 +1,5 @@ /* - * File z_en_butte.c + * File: z_en_butte.c * Overlay: ovl_En_Butte * Description: Butterflies */ diff --git a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c index b7ad8e6f3e..ee13a00974 100644 --- a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c +++ b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c @@ -1,5 +1,5 @@ /* - * File z_en_clear_tag.c + * File: z_en_clear_tag.c * Overlay: ovl_En_Clear_Tag * Description: Various effects: explosions and pops, splashes, light rays */ @@ -642,7 +642,7 @@ void EnClearTag_UpdateEffects(EnClearTag* this, GlobalContext* globalCtx) { sphereCenter.y += 5.0f; // Check if the debris has hit the ground. - if (func_800C5A20(&globalCtx->colCtx, &sphereCenter, 11.0f)) { + if (BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &sphereCenter, 11.0f)) { effect->position.y = originalYPosition; // Bounce the debris effect. @@ -976,8 +976,8 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { * `ySurface` returns the water box's surface, while `outWaterBox` returns a pointer to the WaterBox */ ySurface = effect->position.y; - if (func_800CA1AC(globalCtx, &globalCtx->colCtx, effect->position.x + vec.x, effect->position.z + vec.z, - &ySurface, &waterBox)) { + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, effect->position.x + vec.x, + effect->position.z + vec.z, &ySurface, &waterBox)) { if ((effect->position.y - ySurface) < 200.0f) { // Draw the splash effect. Matrix_InsertTranslation(effect->position.x + vec.x, ySurface, effect->position.z + vec.z, diff --git a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c index fcb693e71d..698878d718 100644 --- a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c +++ b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c @@ -1,7 +1,7 @@ /* - * File z_en_cne_01.c + * File: z_en_cne_01.c * Overlay: ovl_En_Cne_01 - * Description: + * Description: Unused Market NPC */ #include "z_en_cne_01.h" diff --git a/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c b/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c index d6d7f41002..d65232214b 100644 --- a/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c +++ b/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c @@ -1,7 +1,7 @@ /* - * File z_en_col_man.c + * File: z_en_col_man.c * Overlay: ovl_En_Col_Man - * Description: Gives you a Piece of Heart when you touch it? + * Description: Piece of Heart spawned by Fish2 */ #include "z_en_col_man.h" diff --git a/src/overlays/actors/ovl_En_Cow/z_en_cow.c b/src/overlays/actors/ovl_En_Cow/z_en_cow.c index 84f6928a73..54eb091b76 100644 --- a/src/overlays/actors/ovl_En_Cow/z_en_cow.c +++ b/src/overlays/actors/ovl_En_Cow/z_en_cow.c @@ -1,5 +1,5 @@ /* - * File z_en_cow.c + * File: z_en_cow.c * Overlay: ovl_En_Cow * Description: Cow */ @@ -15,16 +15,18 @@ void EnCow_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnCow_Update(Actor* thisx, GlobalContext* globalCtx); void EnCow_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_8099CAA8(EnCow* this, GlobalContext* globalCtx); -void func_8099CB20(EnCow* this, GlobalContext* globalCtx); -void func_8099CB68(EnCow* this, GlobalContext* globalCtx); -void func_8099CBCC(EnCow* this, GlobalContext* globalCtx); -void func_8099CC68(EnCow* this, GlobalContext* globalCtx); -void func_8099CCF8(EnCow* this, GlobalContext* globalCtx); -void func_8099CDA0(EnCow* this, GlobalContext* globalCtx); -void func_8099CFAC(EnCow* this, GlobalContext* globalCtx); +void EnCow_TalkEnd(EnCow* this, GlobalContext* globalCtx); +void EnCow_GiveMilkEnd(EnCow* this, GlobalContext* globalCtx); +void EnCow_GiveMilkWait(EnCow* this, GlobalContext* globalCtx); +void EnCow_GiveMilk(EnCow* this, GlobalContext* globalCtx); +void EnCow_CheckForEmptyBottle(EnCow* this, GlobalContext* globalCtx); +void EnCow_Talk(EnCow* this, GlobalContext* globalCtx); +void EnCow_Idle(EnCow* this, GlobalContext* globalCtx); + +void EnCow_DoTail(EnCow* this, GlobalContext* globalCtx); +void EnCow_UpdateTail(Actor* this, GlobalContext* globalCtx); +void EnCow_DrawTail(Actor* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Cow_InitVars = { ACTOR_EN_COW, ACTORCAT_NPC, @@ -37,57 +39,404 @@ const ActorInit En_Cow_InitVars = { (ActorFunc)EnCow_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_8099D610 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -#endif +Vec3f D_8099D63C = { 0.0f, -1300.0f, 1100.0f }; -extern ColliderCylinderInit D_8099D610; +extern AnimationHeader D_060001CC; // gCowBodyChewAnim +extern FlexSkeletonHeader D_06004010; // gCowBodySkel +extern AnimationHeader D_06004264; // gCowBodyMoveHeadAnim +extern AnimationHeader D_06004348; // gCowTailIdleAnim +extern FlexSkeletonHeader D_06004C30; // gCowTailSkel +extern AnimationHeader D_06004E98; // gCowTailSwishAnim -extern UNK_TYPE D_060001CC; -extern UNK_TYPE D_06004010; -extern UNK_TYPE D_06004348; +void EnCow_RotatePoint(Vec3f* vec, s16 angle) { + f32 x = (Math_CosS(angle) * vec->x) + (Math_SinS(angle) * vec->z); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cow/func_8099C290.s") + vec->z = (-Math_SinS(angle) * vec->x) + (Math_CosS(angle) * vec->z); + vec->x = x; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cow/func_8099C328.s") +void EnCow_SetColliderPos(EnCow* this) { + Vec3f vec; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cow/func_8099C41C.s") + vec.x = vec.y = 0.0f; + vec.z = 30.0f; + EnCow_RotatePoint(&vec, this->actor.shape.rot.y); + this->colliders[0].dim.pos.x = this->actor.world.pos.x + vec.x; + this->colliders[0].dim.pos.y = this->actor.world.pos.y; + this->colliders[0].dim.pos.z = this->actor.world.pos.z + vec.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cow/EnCow_Init.s") + vec.x = vec.y = 0.0f; + vec.z = -20.0f; + EnCow_RotatePoint(&vec, this->actor.shape.rot.y); + this->colliders[1].dim.pos.x = this->actor.world.pos.x + vec.x; + this->colliders[1].dim.pos.y = this->actor.world.pos.y; + this->colliders[1].dim.pos.z = this->actor.world.pos.z + vec.z; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cow/EnCow_Destroy.s") +void EnCow_SetTailPos(EnCow* this) { + Vec3f vec; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cow/func_8099C880.s") + VEC_SET(vec, 0.0f, 57.0f, -36.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cow/func_8099CAA8.s") + EnCow_RotatePoint(&vec, this->actor.shape.rot.y); + this->actor.world.pos.x += vec.x; + this->actor.world.pos.y += vec.y; + this->actor.world.pos.z += vec.z; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cow/func_8099CB20.s") +void EnCow_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnCow* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cow/func_8099CB68.s") + ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 72.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cow/func_8099CBCC.s") + switch (EN_COW_TYPE(thisx)) { + case EN_COW_TYPE_DEFAULT: + case EN_COW_TYPE_ABDUCTED: + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06004010, NULL, this->jointTable, this->morphTable, + COW_LIMB_MAX); + Animation_PlayLoop(&this->skelAnime, &D_060001CC); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cow/func_8099CC68.s") + Collider_InitAndSetCylinder(globalCtx, &this->colliders[0], &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(globalCtx, &this->colliders[1], &this->actor, &sCylinderInit); + EnCow_SetColliderPos(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cow/func_8099CCF8.s") + this->actionFunc = EnCow_Idle; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cow/func_8099CDA0.s") + if (!(gSaveContext.weekEventReg[22] & 1) && (CURRENT_DAY != 1) && + (EN_COW_TYPE(thisx) == EN_COW_TYPE_ABDUCTED)) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cow/func_8099CFAC.s") + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_COW, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, + EN_COW_TYPE_TAIL); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cow/EnCow_Update.s") + this->animationTimer = Rand_ZeroFloat(1000.0f) + 40.0f; + this->animationCycle = 0; + this->actor.targetMode = 6; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cow/func_8099D3C0.s") + D_801BDAA4 = 0; + func_801A5080(4); + break; + case EN_COW_TYPE_TAIL: + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06004C30, NULL, this->jointTable, this->morphTable, + COW_LIMB_MAX); + Animation_PlayLoop(&this->skelAnime, &D_06004348); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cow/func_8099D4AC.s") + this->actor.update = EnCow_UpdateTail; + this->actor.draw = EnCow_DrawTail; + this->actionFunc = EnCow_DoTail; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cow/func_8099D4FC.s") + EnCow_SetTailPos(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cow/EnCow_Draw.s") + this->actor.flags &= ~EN_COW_FLAG_IS_TAIL; + this->animationTimer = Rand_ZeroFloat(1000.0f) + 40.0f; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cow/func_8099D59C.s") + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + Actor_SetScale(&this->actor, 0.01f); + this->flags = 0; + + gSaveContext.weekEventReg[87] &= (u8)~1; +} + +void EnCow_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnCow* this = THIS; + + if (this->actor.params == EN_COW_TYPE_DEFAULT) { //! @bug EN_COW_TYPE_ABDUCTED do not destroy their cylinders + Collider_DestroyCylinder(globalCtx, &this->colliders[0]); + Collider_DestroyCylinder(globalCtx, &this->colliders[1]); + } +} + +void EnCow_UpdateAnimation(EnCow* this, GlobalContext* globalCtx) { + if (this->animationTimer > 0) { + this->animationTimer--; + } else { + this->animationTimer = Rand_ZeroFloat(500.0f) + 40.0f; + Animation_Change(&this->skelAnime, &D_060001CC, 1.0f, this->skelAnime.curFrame, + Animation_GetLastFrame(&D_060001CC), ANIMMODE_ONCE, 1.0f); + } + if (this->actor.xzDistToPlayer < 150.0f) { + if (!(this->flags & EN_COW_FLAG_PLAYER_HAS_APPROACHED)) { + this->flags |= EN_COW_FLAG_PLAYER_HAS_APPROACHED; + if (this->skelAnime.animation == &D_060001CC) { + this->animationTimer = 0; + } + } + } + this->animationCycle++; + if (this->animationCycle > 0x30) { + this->animationCycle = 0; + } + + if (this->animationCycle < 0x20) { + this->actor.scale.x = ((Math_SinS(this->animationCycle * 0x400) * (1.0f / 100.0f)) + 1.0f) * 0.01f; + } else { + this->actor.scale.x = 0.01f; + } + + if (this->animationCycle > 0x10) { + this->actor.scale.y = ((Math_SinS((this->animationCycle * 0x400) - 0x4000) * (1.0f / 100.0f)) + 1.0f) * 0.01f; + } else { + this->actor.scale.y = 0.01f; + } +} + +void EnCow_TalkEnd(EnCow* this, GlobalContext* globalCtx) { + if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + this->actor.flags &= ~0x10000; + func_801477B4(globalCtx); + this->actionFunc = EnCow_Idle; + } +} + +void EnCow_GiveMilkEnd(EnCow* this, GlobalContext* globalCtx) { + if (func_800B867C(&this->actor, globalCtx)) { + this->actor.flags &= ~0x10000; + this->actionFunc = EnCow_Idle; + } +} + +void EnCow_GiveMilkWait(EnCow* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + this->actionFunc = EnCow_GiveMilkEnd; + } else { + func_800B8A1C(&this->actor, globalCtx, GI_MILK, 10000.0f, 100.0f); + } +} + +void EnCow_GiveMilk(EnCow* this, GlobalContext* globalCtx) { + if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + this->actor.flags &= ~0x10000; + func_801477B4(globalCtx); + this->actionFunc = EnCow_GiveMilkWait; + func_800B8A1C(&this->actor, globalCtx, GI_MILK, 10000.0f, 100.0f); + } +} + +void EnCow_CheckForEmptyBottle(EnCow* this, GlobalContext* globalCtx) { + if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if (func_80114E90()) { + func_80151938(globalCtx, 0x32C9); // Text to give milk. + this->actionFunc = EnCow_GiveMilk; + } else { + func_80151938(globalCtx, 0x32CA); // Text if you don't have an empty bottle. + this->actionFunc = EnCow_TalkEnd; + } + } +} + +void EnCow_Talk(EnCow* this, GlobalContext* globalCtx) { + if (func_800B84D0(&this->actor, globalCtx)) { + if (this->actor.textId == 0x32C8) { // Text to give milk after playing Epona's Song. + this->actionFunc = EnCow_CheckForEmptyBottle; + } else if (this->actor.textId == 0x32C9) { // Text to give milk. + this->actionFunc = EnCow_GiveMilk; + } else { + this->actionFunc = EnCow_TalkEnd; + } + } else { + this->actor.flags |= 0x10000; + func_800B8614(&this->actor, globalCtx, 170.0f); + this->actor.textId = 0x32C8; //! @bug textId is reset to this no matter the intial value + } + + EnCow_UpdateAnimation(this, globalCtx); +} + +void EnCow_Idle(EnCow* this, GlobalContext* globalCtx) { + if ((globalCtx->msgCtx.unk1202A == 0) || (globalCtx->msgCtx.unk1202A == 4)) { + if (D_801BDAA4 != 0) { + if (this->flags & EN_COW_FLAG_WONT_GIVE_MILK) { + this->flags &= ~EN_COW_FLAG_WONT_GIVE_MILK; + D_801BDAA4 = 0; + } else if ((this->actor.xzDistToPlayer < 150.0f) && + ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) < 25000) { + D_801BDAA4 = 0; + this->actionFunc = EnCow_Talk; + this->actor.flags |= 0x10000; + func_800B8614(&this->actor, globalCtx, 170.0f); + this->actor.textId = 0x32C8; // Text to give milk after playing Epona's Song. + + EnCow_UpdateAnimation(this, globalCtx); + return; + } else { + this->flags |= EN_COW_FLAG_WONT_GIVE_MILK; + } + } else { + this->flags &= ~EN_COW_FLAG_WONT_GIVE_MILK; + } + } + + if (this->actor.xzDistToPlayer < 150.0f && + ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) < 25000) { + if (func_801A5100() == 4) { + if (!(gSaveContext.weekEventReg[87] & 1)) { + gSaveContext.weekEventReg[87] |= 1; + if (func_80114E90()) { + this->actor.textId = 0x32C9; // Text to give milk. + } else { + this->actor.textId = 0x32CA; // Text if you don't have an empty bottle. + } + this->actor.flags |= 0x10000; + func_800B8614(&this->actor, globalCtx, 170.0f); + this->actionFunc = EnCow_Talk; + } + } else { + gSaveContext.weekEventReg[87] &= (u8)~1; + } + } + + EnCow_UpdateAnimation(this, globalCtx); +} + +void EnCow_DoTail(EnCow* this, GlobalContext* globalCtx) { + if (this->animationTimer > 0) { + this->animationTimer--; + } else { + this->animationTimer = Rand_ZeroFloat(200.0f) + 40.0f; + Animation_Change(&this->skelAnime, &D_06004348, 1.0f, this->skelAnime.curFrame, + Animation_GetLastFrame(&D_06004348), ANIMMODE_ONCE, 1.0f); + } + + if (this->actor.xzDistToPlayer < 150.0f && + ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) > 25000) { + if (!(this->flags & EN_COW_FLAG_PLAYER_HAS_APPROACHED)) { + this->flags |= EN_COW_FLAG_PLAYER_HAS_APPROACHED; + if (this->skelAnime.animation == &D_06004348) { + this->animationTimer = 0; + } + } + } +} + +void EnCow_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnCow* this = THIS; + s16 targetX; + s16 targetY; + Player* player = GET_PLAYER(globalCtx); + + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliders[0].base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliders[1].base); + + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + + if (SkelAnime_Update(&this->skelAnime)) { + if (this->skelAnime.animation == &D_060001CC) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_COW_CRY); + Animation_Change(&this->skelAnime, &D_06004264, 1.0f, 0.0f, Animation_GetLastFrame(&D_06004264), + ANIMMODE_ONCE, 1.0f); + } else { + Animation_Change(&this->skelAnime, &D_060001CC, 1.0f, 0.0f, Animation_GetLastFrame(&D_060001CC), + ANIMMODE_LOOP, 1.0f); + } + } + + this->actionFunc(this, globalCtx); + + if (this->actor.xzDistToPlayer < 150.0f && + ABS_ALT(Math_Vec3f_Yaw(&thisx->world.pos, &player->actor.world.pos)) < 0xC000) { + targetX = Math_Vec3f_Pitch(&thisx->focus.pos, &player->actor.focus.pos); + targetY = Math_Vec3f_Yaw(&thisx->focus.pos, &player->actor.focus.pos) - this->actor.shape.rot.y; + + if (targetX > 0x1000) { + targetX = 0x1000; + } else if (targetX < -0x1000) { + targetX = -0x1000; + } + + if (targetY > 0x2500) { + targetY = 0x2500; + } else if (targetY < -0x2500) { + targetY = -0x2500; + } + } else { + targetX = targetY = 0; + } + + Math_SmoothStepToS(&this->headTilt.x, targetX, 10, 200, 10); + Math_SmoothStepToS(&this->headTilt.y, targetY, 10, 200, 10); +} + +void EnCow_UpdateTail(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnCow* this = THIS; + + if (SkelAnime_Update(&this->skelAnime)) { + if (this->skelAnime.animation == &D_06004348) { + Animation_Change(&this->skelAnime, &D_06004E98, 1.0f, 0.0f, Animation_GetLastFrame(&D_06004E98), + ANIMMODE_ONCE, 1.0f); + } else { + Animation_Change(&this->skelAnime, &D_06004348, 1.0f, 0.0f, Animation_GetLastFrame(&D_06004348), + ANIMMODE_LOOP, 1.0f); + } + } + + this->actionFunc(this, globalCtx); +} + +s32 EnCow_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnCow* this = THIS; + + if (limbIndex == COW_LIMB_HEAD) { + rot->y += this->headTilt.y; + rot->x += this->headTilt.x; + } + if (limbIndex == COW_LIMB_NOSE_RING) { + *dList = NULL; + } + + return false; +} + +void EnCow_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnCow* this = THIS; + + if (limbIndex == COW_LIMB_HEAD) { + Matrix_MultiplyVector3fByState(&D_8099D63C, &this->actor.focus.pos); + } +} + +void EnCow_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnCow* this = THIS; + + func_8012C5B0(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnCow_OverrideLimbDraw, EnCow_PostLimbDraw, &this->actor); +} + +void EnCow_DrawTail(Actor* thisx, GlobalContext* globalCtx) { + EnCow* this = THIS; + + func_8012C5B0(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, NULL, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Cow/z_en_cow.h b/src/overlays/actors/ovl_En_Cow/z_en_cow.h index ecbd3a9e11..fd865cecbe 100644 --- a/src/overlays/actors/ovl_En_Cow/z_en_cow.h +++ b/src/overlays/actors/ovl_En_Cow/z_en_cow.h @@ -3,13 +3,42 @@ #include "global.h" +#define EN_COW_TYPE(thisx) ((thisx)->params & 0xF) + +#define EN_COW_FLAG_IS_TAIL (1 << 0) // This is never set but it is cleared for tail types +#define EN_COW_FLAG_PLAYER_HAS_APPROACHED (1 << 1) +#define EN_COW_FLAG_WONT_GIVE_MILK (1 << 2) + +typedef enum { + /* 0 */ EN_COW_TYPE_DEFAULT, + /* 1 */ EN_COW_TYPE_TAIL, + /* 2 */ EN_COW_TYPE_ABDUCTED, +} EnCowType; + struct EnCow; typedef void (*EnCowActionFunc)(struct EnCow*, GlobalContext*); +typedef enum { + /* 0 */ COW_LIMB_NONE, + /* 1 */ COW_LIMB_ROOT, + /* 2 */ COW_LIMB_HEAD, + /* 3 */ COW_LIMB_JAW, + /* 4 */ COW_LIMB_NOSE, + /* 5 */ COW_LIMB_NOSE_RING, + /* 6 */ COW_LIMB_MAX, +} ObjectCowLimbs; + typedef struct EnCow { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x130]; + /* 0x0144 */ ColliderCylinder colliders[2]; + /* 0x01DC */ SkelAnime skelAnime; + /* 0x0220 */ Vec3s jointTable[COW_LIMB_MAX]; + /* 0x0244 */ Vec3s morphTable[COW_LIMB_MAX]; + /* 0x0268 */ Vec3s headTilt; + /* 0x026E */ u16 flags; + /* 0x0270 */ u16 animationTimer; + /* 0x0272 */ u16 animationCycle; /* 0x0274 */ EnCowActionFunc actionFunc; } EnCow; // size = 0x278 diff --git a/src/overlays/actors/ovl_En_Crow/z_en_crow.c b/src/overlays/actors/ovl_En_Crow/z_en_crow.c index b4dead2436..be24037bfd 100644 --- a/src/overlays/actors/ovl_En_Crow/z_en_crow.c +++ b/src/overlays/actors/ovl_En_Crow/z_en_crow.c @@ -1,5 +1,5 @@ /* - * File z_en_crow.c + * File: z_en_crow.c * Overlay: ovl_En_Crow * Description: Guay */ diff --git a/src/overlays/actors/ovl_En_Death/z_en_death.c b/src/overlays/actors/ovl_En_Death/z_en_death.c index e47822ed88..ec6d57bbfa 100644 --- a/src/overlays/actors/ovl_En_Death/z_en_death.c +++ b/src/overlays/actors/ovl_En_Death/z_en_death.c @@ -1,5 +1,5 @@ /* - * File z_en_death.c + * File: z_en_death.c * Overlay: ovl_En_Death * Description: Gomess */ diff --git a/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.c b/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.c index 421495be73..288ce89a3b 100644 --- a/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.c +++ b/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.c @@ -1,5 +1,5 @@ /* - * File z_en_dekubaba.c + * File: z_en_dekubaba.c * Overlay: ovl_En_Dekubaba * Description: Deku Baba */ diff --git a/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c b/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c index a1cda6362d..b7e1609906 100644 --- a/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c +++ b/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c @@ -1,5 +1,5 @@ /* - * File z_en_demo_heishi.c + * File: z_en_demo_heishi.c * Overlay: ovl_En_Demo_heishi * Description: Unused(?) version of Shiro */ diff --git a/src/overlays/actors/ovl_En_Dg/z_en_dg.c b/src/overlays/actors/ovl_En_Dg/z_en_dg.c index 801a60012c..2c5a330ab7 100644 --- a/src/overlays/actors/ovl_En_Dg/z_en_dg.c +++ b/src/overlays/actors/ovl_En_Dg/z_en_dg.c @@ -946,19 +946,19 @@ void func_8098B464(EnDg* this, GlobalContext* globalCtx) { void func_8098B560(EnDg* this, GlobalContext* globalCtx) { Vec3f sp54; - Vec3f sp48; + Vec3f pos; s16 sp46 = 0; - WaterBox* sp40; - f32 sp3C; - s32 sp38; + WaterBox* waterBox; + f32 waterSurface; + CollisionPoly* poly; f32 sp34; sp54.x = this->actor.world.pos.x; sp54.y = this->actor.world.pos.y + this->actor.depthInWater; sp54.z = this->actor.world.pos.z + 20.0f; - sp48.x = (Math_SinS(this->actor.world.rot.y) * 50.0f) + this->actor.world.pos.x; - sp48.y = this->actor.home.pos.y + 100.0f; - sp48.z = (Math_CosS(this->actor.world.rot.y) * 50.0f) + this->actor.world.pos.z; + pos.x = (Math_SinS(this->actor.world.rot.y) * 50.0f) + this->actor.world.pos.x; + pos.y = this->actor.home.pos.y + 100.0f; + pos.z = (Math_CosS(this->actor.world.rot.y) * 50.0f) + this->actor.world.pos.z; if (DECR(this->unk_284) == 0) { if (!(this->unk_280 & 4)) { @@ -975,9 +975,9 @@ void func_8098B560(EnDg* this, GlobalContext* globalCtx) { this->actor.velocity.y = -0.5f; } - sp34 = func_800C4000(globalCtx, &globalCtx->colCtx, &sp38, &sp48); + sp34 = BgCheck_EntityRaycastFloor2(globalCtx, &globalCtx->colCtx, &poly, &pos); if (this->actor.bgCheckFlags & 8) { - if (!func_800CA1AC(globalCtx, &globalCtx->colCtx, sp48.x, sp48.z, &sp3C, &sp40)) { + if (!WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, pos.x, pos.z, &waterSurface, &waterBox)) { if (sp34 > -100.0f) { this->unk_280 &= ~4; this->actionFunc = func_8098B88C; @@ -985,7 +985,7 @@ void func_8098B560(EnDg* this, GlobalContext* globalCtx) { sp46 = this->actor.wallYaw; } } else if (sp34 > -100.0f) { - if (sp3C < sp34) { + if (waterSurface < sp34) { this->unk_280 &= ~4; this->actionFunc = func_8098B88C; } else { diff --git a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c index a73f5423ff..bf0f977b74 100644 --- a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c +++ b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c @@ -528,7 +528,7 @@ void func_8089B3D4(EnDinofos* this, GlobalContext* globalCtx) { Math_Vec3f_StepTo(&camera->eye, &this->unk_2BC, 10.0f); this->unk_290++; if (this->unk_290 == 10) { - func_801A2E54(0x38); + func_801A2E54(NA_BGM_MINI_BOSS); } sp28.x = this->actor.world.pos.x; @@ -547,7 +547,7 @@ void func_8089B3D4(EnDinofos* this, GlobalContext* globalCtx) { void func_8089B4A4(EnDinofos* this) { if (this->unk_290 < 10) { - func_801A2E54(0x38); + func_801A2E54(NA_BGM_MINI_BOSS); } Animation_PlayOnce(&this->skelAnime, &D_0600C974); this->unk_2BC.x = (Math_SinS(this->actor.shape.rot.y + 0x200) * 123.0f) + this->actor.world.pos.x; diff --git a/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c b/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c index 780ce1cda5..c6e7eb942b 100644 --- a/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c +++ b/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c @@ -1,7 +1,7 @@ /* * File: z_en_dnb.c * Overlay: ovl_En_Dnb - * Description: + * Description: Unused invisible snowy mountain that explodes? */ #include "z_en_dnb.h" @@ -108,8 +108,8 @@ void EnDnb_Init(Actor* thisx, GlobalContext* globalCtx) { s32 i; s16* alloc; - BcCheck3_BgActorInit(&this->dyna, 1); - BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_06004D8C); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &D_06004D8C); alloc = (s16*)Lib_SegmentedToVirtual(D_06004710); for (i = 0; i < ARRAY_COUNT(this->particles); i++) { @@ -122,7 +122,7 @@ void EnDnb_Init(Actor* thisx, GlobalContext* globalCtx) { void EnDnb_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnDnb* this = THIS; - BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); } void EnDnb_Update(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Dno/z_en_dno.c b/src/overlays/actors/ovl_En_Dno/z_en_dno.c index a99777edaa..a21f7df865 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.c +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.c @@ -136,7 +136,7 @@ void func_80A714B4(EnDno* this, GlobalContext* globalCtx) { do { actor = func_ActorCategoryIterateById(globalCtx, actor, ACTORCAT_BG, ACTOR_BG_CRACE_MOVEBG); if (actor != NULL) { - if (ENDNO_GET_F(actor) == ENDNO_GET_F_1) { + if ((s32)ENDNO_GET_F(actor) == ENDNO_GET_F_1) { Actor_SetSwitchFlag(globalCtx, ENDNO_GET_7F0(actor)); } actor = actor->next; @@ -709,8 +709,8 @@ void func_80A72C04(EnDno* this, GlobalContext* globalCtx) { func_8013DCE0(globalCtx, &this->unk_334, &this->actor, &this->unk_340, globalCtx->setupPathList, ENDNO_GET_7F(&this->actor), 1, 0, 1, 0); func_8013DF3C(globalCtx, &this->unk_340); - this->actor.world.rot.y = this->unk_340.unk_56; - this->actor.world.rot.x = this->unk_340.unk_54; + this->actor.world.rot.y = this->unk_340.unk_54.y; + this->actor.world.rot.x = this->unk_340.unk_54.x; Actor_SetSwitchFlag(globalCtx, ENDNO_GET_3F80(&this->actor)); this->actionFunc = func_80A730A0; } @@ -721,8 +721,8 @@ void func_80A72CF8(EnDno* this, GlobalContext* globalCtx) { this->actor.floorHeight, this->actor.world.pos.z, 0, 0, 0, 0x201); } -s32 func_80A72D8C(GlobalContext* globalCtx, EnDno_ActorUnkStruct* arg1) { - Actor* actor = arg1->unk_48; +s32 func_80A72D8C(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { + Actor* actor = arg1->actor; s32 pad; s32 ret = false; f32 sp38; @@ -748,21 +748,21 @@ s32 func_80A72D8C(GlobalContext* globalCtx, EnDno_ActorUnkStruct* arg1) { ret = true; } else { sp38 = actor->speedXZ / sqrtf(arg1->unk_4C); - sp2C = ABS(arg1->unk_54 - actor->world.rot.x); + sp2C = ABS(arg1->unk_54.x - actor->world.rot.x); temp_v0_2 = sp2C; temp_v0_2 *= sp38; temp_v0_2 += 0x71C; - sp2C = ABS(arg1->unk_56 - actor->world.rot.y); + sp2C = ABS(arg1->unk_54.y - actor->world.rot.y); - Math_ScaledStepToS(&actor->world.rot.x, arg1->unk_54, temp_v0_2); - Math_ScaledStepToS(&actor->world.rot.y, arg1->unk_56, (s32)(sp2C * sp38) + 0x71C); + Math_ScaledStepToS(&actor->world.rot.x, arg1->unk_54.x, temp_v0_2); + Math_ScaledStepToS(&actor->world.rot.y, arg1->unk_54.y, (s32)(sp2C * sp38) + 0x71C); } return ret; } -s32 func_80A72FAC(GlobalContext* globalCtx, EnDno_ActorUnkStruct* arg1) { - Actor* actor = arg1->unk_48; +s32 func_80A72FAC(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { + Actor* actor = arg1->actor; EnDno* dno = (EnDno*)actor; f32 sp24 = Math_CosS(-actor->world.rot.x) * actor->speedXZ; f32 sp20 = gFramerateDivisorHalf; diff --git a/src/overlays/actors/ovl_En_Dno/z_en_dno.h b/src/overlays/actors/ovl_En_Dno/z_en_dno.h index a99162694b..ed9ee52c64 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.h +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.h @@ -7,7 +7,7 @@ struct EnDno; typedef void (*EnDnoActionFunc)(struct EnDno*, GlobalContext*); -#define ENDNO_GET_F(thisx) (u32)((thisx)->params & 0xF) +#define ENDNO_GET_F(thisx) ((thisx)->params & 0xF) #define ENDNO_GET_7F(thisx) ((thisx)->params & 0x7F) #define ENDNO_GET_7F0(thisx) (((thisx)->params >> 4) & 0x7F) #define ENDNO_GET_3F80(thisx) (((thisx)->params >> 7) & 0x7F) @@ -34,7 +34,7 @@ typedef struct EnDno { /* 0x32C */ s32 unk_32C; /* 0x330 */ UNK_TYPE1 unk_330[0x4]; /* 0x334 */ Vec3f unk_334; - /* 0x340 */ EnDno_ActorUnkStruct unk_340; + /* 0x340 */ struct_8013DF3C_arg1 unk_340; /* 0x3AC */ s16 unk_3AC; /* 0x3AE */ s16 unk_3AE; /* 0x3B0 */ u16 unk_3B0; diff --git a/src/overlays/actors/ovl_En_Dns/z_en_dns.c b/src/overlays/actors/ovl_En_Dns/z_en_dns.c index 373e69880c..e75f1aa461 100644 --- a/src/overlays/actors/ovl_En_Dns/z_en_dns.c +++ b/src/overlays/actors/ovl_En_Dns/z_en_dns.c @@ -267,7 +267,7 @@ s32 func_8092CC68(GlobalContext* globalCtx) { if (!func_801690CC(globalCtx) && (player->actor.bgCheckFlags & 1) && (player->transformation != PLAYER_FORM_DEKU)) { bgId = player->actor.floorBgId; - if (func_800C99AC(&globalCtx->colCtx, player->actor.floorPoly, bgId) != 4) { + if (SurfaceType_GetSceneExitIndex(&globalCtx->colCtx, player->actor.floorPoly, bgId) != 4) { ret = true; } } diff --git a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c index 72e7ed6069..693ea4ec4f 100644 --- a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c +++ b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c @@ -366,7 +366,7 @@ void func_80876930(EnDodongo* this, GlobalContext* globalCtx, Vec3f* arg2) { s16 temp2; f32 temp3; - if (func_800C9BB8(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId) == 14) { + if (func_800C9BB8(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId) == COLPOLY_SURFACE_SNOW) { sp80 = &D_8087932C; sp7C = &D_80879330; } else { diff --git a/src/overlays/actors/ovl_En_Door/z_en_door.h b/src/overlays/actors/ovl_En_Door/z_en_door.h index 08ec52be68..1dbc470dc7 100644 --- a/src/overlays/actors/ovl_En_Door/z_en_door.h +++ b/src/overlays/actors/ovl_En_Door/z_en_door.h @@ -10,7 +10,7 @@ typedef void (*EnDoorActionFunc)(struct EnDoor*, GlobalContext*); typedef struct EnDoor { /* 0x0000 */ Actor actor; /* 0x0144 */ char unk_144[0x63]; - /* 0x01A7 */ s8 unk1A7; + /* 0x01A7 */ s8 unk_1A7; /* 0x01A8 */ char unk_1A8[0x20]; /* 0x01C8 */ EnDoorActionFunc actionFunc; } EnDoor; // size = 0x1CC diff --git a/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.c b/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.c index ab0c548884..1ca8d69fcc 100644 --- a/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.c +++ b/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.c @@ -1,7 +1,7 @@ /* * File: z_en_ds2n.c * Overlay: ovl_En_Ds2n - * Description: + * Description: Potion Shop Owner from OoT (unused) */ #include "z_en_ds2n.h" diff --git a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c index 644f2fedb4..1efecd2574 100644 --- a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c +++ b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c @@ -464,7 +464,7 @@ void EnElforg_FreeFloating(EnElforg* this, GlobalContext* globalCtx) { gSaveContext.inventory.strayFairies[gSaveContext.unk_48C8]++; func_801518B0(globalCtx, 0x11, NULL); if (gSaveContext.inventory.strayFairies[(void)0, gSaveContext.unk_48C8] >= 15) { - func_801A3098(0x922); + func_801A3098(NA_BGM_GET_ITEM | 0x900); } } } diff --git a/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c b/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c index 94641b569f..2672c209f2 100644 --- a/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c +++ b/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c @@ -1,7 +1,7 @@ /* * File: z_en_encount1.c * Overlay: ovl_En_Encount1 - * Description: + * Description: Spawner for Dragonflies, Skullfish, and Wallmasters */ #include "z_en_encount1.h" diff --git a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c index 6071137ce1..a5f6b1d7af 100644 --- a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c +++ b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c @@ -106,9 +106,9 @@ void EnEncount2_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; CollisionHeader* colHeader = NULL; - BcCheck3_BgActorInit(&this->dyna, 0); - BgCheck_RelocateMeshHeader(&D_06002420, &colHeader); - this->dyna.bgId = BgCheck_AddActorMesh(globalCtx, &globalCtx->colCtx.dyna, &this->dyna, colHeader); + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&D_06002420, &colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); ActorShape_Init(&this->dyna.actor.shape, 0.0f, func_800B3FC0, 25.0f); this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->dyna.actor, &sJntSphInit, &this->colElement); @@ -139,7 +139,7 @@ void EnEncount2_Init(Actor* thisx, GlobalContext* globalCtx) { void EnEncount2_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnEncount2* this = THIS; - BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); Collider_DestroyJntSph(globalCtx, &this->collider); } diff --git a/src/overlays/actors/ovl_En_Encount3/z_en_encount3.c b/src/overlays/actors/ovl_En_Encount3/z_en_encount3.c index 0a4a55c4b2..184eb8728b 100644 --- a/src/overlays/actors/ovl_En_Encount3/z_en_encount3.c +++ b/src/overlays/actors/ovl_En_Encount3/z_en_encount3.c @@ -1,7 +1,7 @@ /* * File: z_en_encount3.c * Overlay: ovl_En_Encount3 - * Description: + * Description: Garo spawner */ #include "z_en_encount3.h" diff --git a/src/overlays/actors/ovl_En_Encount4/z_en_encount4.c b/src/overlays/actors/ovl_En_Encount4/z_en_encount4.c index 5a0bc632ac..d4f6c44870 100644 --- a/src/overlays/actors/ovl_En_Encount4/z_en_encount4.c +++ b/src/overlays/actors/ovl_En_Encount4/z_en_encount4.c @@ -1,7 +1,7 @@ /* * File: z_en_encount4.c * Overlay: ovl_En_Encount4 - * Description: + * Description: Spawner for Stalchild and Fire Wall in Keeta chase */ #include "z_en_encount4.h" diff --git a/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.c b/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.c index 3206eef53f..e94c19f258 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.c +++ b/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.c @@ -1,7 +1,7 @@ /* * File: z_en_ending_hero.c * Overlay: ovl_En_Ending_Hero - * Description: + * Description: Mayor Dotour at wedding during the credits */ #include "z_en_ending_hero.h" diff --git a/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.c b/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.c index d6864d7410..045bf8deb2 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.c +++ b/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.c @@ -1,7 +1,7 @@ /* * File: z_en_ending_hero2.c * Overlay: ovl_En_Ending_Hero2 - * Description: + * Description: Viscen watching moon disappearance and wedding */ #include "z_en_ending_hero2.h" diff --git a/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.c b/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.c index 4a39d382ac..2f9c8391f3 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.c +++ b/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.c @@ -1,7 +1,7 @@ /* * File: z_en_ending_hero3.c * Overlay: ovl_En_Ending_Hero3 - * Description: + * Description: Mutoh watching moon disappearance and wedding */ #include "z_en_ending_hero3.h" diff --git a/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.c b/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.c index 46fca27d68..fd5eae6249 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.c +++ b/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.c @@ -1,7 +1,7 @@ /* * File: z_en_ending_hero4.c * Overlay: ovl_En_Ending_Hero4 - * Description: + * Description: Soldiers watching moon disappearance and Indigo-Go's */ #include "z_en_ending_hero4.h" diff --git a/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.c b/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.c index b7b3d6b8e4..77fc673085 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.c +++ b/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.c @@ -1,7 +1,7 @@ /* * File: z_en_ending_hero5.c * Overlay: ovl_En_Ending_Hero5 - * Description: + * Description: Carpenters watching moon disappearance and Indigo-Go's */ #include "z_en_ending_hero5.h" diff --git a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c index 6846bfb925..7b52e0a30b 100644 --- a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c +++ b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c @@ -268,7 +268,7 @@ s32 func_80B288E8(EnFish2* this, Vec3f vec, s32 arg2) { } s32 func_80B2899C(EnFish2* this, GlobalContext* globalCtx) { - if (func_800C5A64(&globalCtx->colCtx, &this->unk_2F4, this->unk_33C, &this->actor)) { + if (BgCheck_SphVsFirstWall(&globalCtx->colCtx, &this->unk_2F4, this->unk_33C)) { return true; } @@ -294,8 +294,8 @@ void func_80B289DC(EnFish2* this, GlobalContext* globalCtx) { this->actor.velocity.y = 0.0f; this->actor.gravity = 0.0f; } - } else if (func_800CA1AC(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, - &this->unk_334, &sp2C)) { + } else if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_334, &sp2C)) { if ((this->unk_334 != BGCHECK_Y_MIN) && (this->actor.world.pos.y < (this->unk_334 - this->unk_2D8))) { this->actor.velocity.y = this->actor.world.rot.x * 0.001f * -0.1f; if (this->actionFunc == func_80B297FC) { @@ -373,8 +373,9 @@ void func_80B28C14(EnFish2* this, GlobalContext* globalCtx) { } } - if ((this->unk_334 == BGCHECK_Y_MIN) && !func_800CA1AC(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, - this->actor.world.pos.z, &this->unk_334, &waterbox)) { + if ((this->unk_334 == BGCHECK_Y_MIN) && + !WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_334, &waterbox)) { this->unk_334 = this->actor.world.pos.y; } @@ -906,8 +907,8 @@ void func_80B2A498(EnFish2* this, GlobalContext* globalCtx) { (Animation_OnFrame(&this->skelAnime, 13.0f) || Animation_OnFrame(&this->skelAnime, 31.0f))) { WaterBox* sp78; - if (func_800CA1AC(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, - &this->unk_334, &sp78)) { + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_334, &sp78)) { Vec3f sp6C; s32 i; @@ -999,8 +1000,8 @@ void EnFish2_Update(Actor* thisx, GlobalContext* globalCtx2) { this->actor.world.pos.y = this->unk_2D4 + 0.1f; } - if (func_800CA1AC(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, - &this->unk_334, &sp6C)) { + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_334, &sp6C)) { if ((this->unk_334 != BGCHECK_Y_MIN) && (this->unk_334 - this->unk_2D8 < this->actor.world.pos.y)) { this->actor.world.pos.y = this->unk_334 - this->unk_2D8; } @@ -1012,8 +1013,8 @@ void EnFish2_Update(Actor* thisx, GlobalContext* globalCtx2) { f32 phi_f20 = 0; WaterBox* sp4C; - if (func_800CA1AC(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, - &this->unk_334, &sp4C)) { + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, + this->actor.world.pos.z, &this->unk_334, &sp4C)) { phi_f20 = D_80B2B3A8[temp_s0_2] + (this->unk_334 - this->unk_2D8); phi_f2 = D_80B2B3A8[temp_s0_2 + 1] + this->unk_2D4; } @@ -1136,7 +1137,7 @@ void func_80B2AF80(EnFish2* this, GlobalContext* globalCtx) { ptr->unk_04.y += 1.0f + ((Rand_ZeroOne() - 0.3f) * 1.2f); ptr->unk_04.z += (0.3f + (Rand_ZeroOne() * 0.5f)) - 0.55f; sp8C = ptr->unk_04.y; - if (!func_800CA1AC(globalCtx, &globalCtx->colCtx, ptr->unk_04.x, ptr->unk_04.z, &sp8C, &sp90)) { + if (!WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, ptr->unk_04.x, ptr->unk_04.z, &sp8C, &sp90)) { ptr->unk_00 = 0; } else if (sp8C < ptr->unk_04.y) { Vec3f sp7C; diff --git a/src/overlays/actors/ovl_En_Fr/z_en_fr.c b/src/overlays/actors/ovl_En_Fr/z_en_fr.c index fb8749a119..fb5b564510 100644 --- a/src/overlays/actors/ovl_En_Fr/z_en_fr.c +++ b/src/overlays/actors/ovl_En_Fr/z_en_fr.c @@ -14,7 +14,6 @@ void EnFr_Init(Actor* thisx, GlobalContext* globalCtx); void EnFr_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnFr_Update(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit En_Fr_InitVars = { ACTOR_EN_FR, ACTORCAT_ITEMACTION, @@ -27,10 +26,27 @@ const ActorInit En_Fr_InitVars = { (ActorFunc)NULL, }; -#endif +void EnFr_Init(Actor* thisx, GlobalContext* globalCtx) { + EnFr* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fr/EnFr_Init.s") + if (Flags_GetSwitch(globalCtx, ENFR_GET_SWITCHFLAG(&this->actor))) { + Actor_MarkForDeath(&this->actor); + } else { + this->actor.targetMode = ENFR_GET_TARGETMODE(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fr/EnFr_Destroy.s") +void EnFr_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fr/EnFr_Update.s") +void EnFr_Update(Actor* thisx, GlobalContext* globalCtx) { + EnFr* this = THIS; + + if (Flags_GetSwitch(globalCtx, ENFR_GET_SWITCHFLAG(&this->actor))) { + Actor_MarkForDeath(&this->actor); + } else if (this->actor.xyzDistToPlayerSq < SQ(IREG(29))) { + this->actor.flags &= ~0x40000000; + } else { + this->actor.flags |= 0x40000000; + } +} diff --git a/src/overlays/actors/ovl_En_Fr/z_en_fr.h b/src/overlays/actors/ovl_En_Fr/z_en_fr.h index ffc250d39b..f0de1936db 100644 --- a/src/overlays/actors/ovl_En_Fr/z_en_fr.h +++ b/src/overlays/actors/ovl_En_Fr/z_en_fr.h @@ -5,6 +5,9 @@ struct EnFr; +#define ENFR_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) +#define ENFR_GET_TARGETMODE(thisx) (((thisx)->params >> 7) & 0xF) + typedef struct EnFr { /* 0x000 */ Actor actor; } EnFr; // size = 0x144 diff --git a/src/overlays/actors/ovl_En_Fu/z_en_fu.c b/src/overlays/actors/ovl_En_Fu/z_en_fu.c index 550a54f620..558e1cf990 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -264,7 +264,7 @@ void func_80961D7C(GlobalContext* globalCtx) { EnBom* bomb = (EnBom*)explosive; if (bomb->actor.floorBgId != BGCHECK_SCENE) { - DynaPolyActor* fuKago = BgCheck_GetActorOfMesh(&globalCtx->colCtx, bomb->actor.floorBgId); + DynaPolyActor* fuKago = DynaPoly_GetActor(&globalCtx->colCtx, bomb->actor.floorBgId); if ((fuKago != NULL) && (fuKago->actor.id == ACTOR_EN_FU_KAGO)) { Math_SmoothStepToF(&bomb->actor.world.pos.x, fuKago->actor.world.pos.x, 0.1f, 1.0f, 0.5f); @@ -543,7 +543,7 @@ void func_80962660(EnFu* this, GlobalContext* globalCtx) { player->stateFlags1 |= 0x20; this->unk_53C = 0; func_800BDC5C(&this->skelAnime, sAnimations, 3); - func_801A2BB8(0x25); + func_801A2BB8(NA_BGM_MINI_GAME_2); if (this->unk_542 == 0) { if (this->unk_546 == 1) { func_80961EC8(globalCtx); @@ -781,7 +781,8 @@ void func_80962F4C(EnFu* this, GlobalContext* globalCtx) { func_801518B0(globalCtx, 0x288B, &this->actor); } - if ((!func_800CAF94((DynaPolyActor*)this->actor.child) && (player->actor.bgCheckFlags & 1)) || + if ((!DynaPolyActor_IsInRidingRotatingState((DynaPolyActor*)this->actor.child) && + (player->actor.bgCheckFlags & 1)) || (gSaveContext.unk_3DE0[4] < 1) || (this->unk_548 == this->unk_54C)) { player->stateFlags3 &= ~0x400000; func_80961E88(globalCtx); @@ -804,7 +805,7 @@ void func_80962F4C(EnFu* this, GlobalContext* globalCtx) { func_801A2C20(); gSaveContext.unk_3DE0[4] = 0; gSaveContext.unk_3DD0[4] = 5; - func_801A3098(0x922); + func_801A3098(NA_BGM_GET_ITEM | 0x900); func_8011B4E0(globalCtx, 1); this->unk_54A = 3; func_809632D0(this); diff --git a/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.c b/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.c index 590949028d..a27c5bdc4c 100644 --- a/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.c +++ b/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.c @@ -1,7 +1,7 @@ /* * File: z_en_gamelupy.c * Overlay: ovl_En_Gamelupy - * Description: Deku Scrub Playground - Large Green Rupee + * Description: Deku Scrub Playground Rupees */ #include "z_en_gamelupy.h" diff --git a/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c b/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c index 8125c9c33a..2f3209e975 100644 --- a/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c +++ b/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c @@ -1,7 +1,7 @@ /* * File: z_en_ge1.c * Overlay: ovl_En_Ge1 - * Description: + * Description: White-clad Gerudo Pirate */ #include "z_en_ge1.h" diff --git a/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c b/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c index 6e3b7ac6b9..d511788abc 100644 --- a/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c +++ b/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c @@ -1,7 +1,7 @@ /* * File: z_en_ge2.c * Overlay: ovl_En_Ge2 - * Description: Patrolling Pirate + * Description: Purple-clad Gerudo Pirate */ #include "z_en_ge2.h" diff --git a/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c b/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c index 9e891f708c..7c0bcd71fc 100644 --- a/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c +++ b/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c @@ -1,7 +1,7 @@ /* * File: z_en_ge3.c * Overlay: ovl_En_Ge3 - * Description: + * Description: Aviel */ #include "z_en_ge3.h" diff --git a/src/overlays/actors/ovl_En_Gm/z_en_gm.c b/src/overlays/actors/ovl_En_Gm/z_en_gm.c index bb81c00a0c..412bf7381a 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -5,6 +5,7 @@ */ #include "z_en_gm.h" +#include "overlays/actors/ovl_En_Door/z_en_door.h" #define FLAGS 0x00000019 @@ -18,7 +19,79 @@ void EnGm_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80950CDC(EnGm* this, GlobalContext* globalCtx); void func_80950DB8(EnGm* this, GlobalContext* globalCtx); -#if 0 +extern UNK_PTR D_06005028; +extern UNK_PTR D_060054A8; +extern UNK_PTR D_06005CE8; +extern UNK_PTR D_06006828; +extern UNK_PTR D_06006C68; +extern Gfx D_06007528[]; +extern FlexSkeletonHeader D_060078B0; +extern AnimationHeader D_06008090; +extern AnimationHeader D_0600898C; +extern AnimationHeader D_06009450; +extern AnimationHeader D_06009CDC; +extern AnimationHeader D_0600A5E0; +extern AnimationHeader D_0600A70C; +extern AnimationHeader D_0600AD18; +extern AnimationHeader D_0600B8B0; +extern AnimationHeader D_0600B990; +extern AnimationHeader D_0600BA80; +extern AnimationHeader D_0600C03C; + +static u32 D_80951820[] = { + 0x0D000101, 0x360A0061, 0x25020600, 0x09001902, 0x0900090A, 0x0D02090A, 0x090F0105, 0x0E090A09, 0x0F0F0E09, + 0x00090A18, 0x0E060009, 0x00060A00, 0x6C490209, 0x0A090F3D, 0x02090F0A, 0x0031020A, 0x000A0525, 0x020C0F0C, + 0x1419020C, 0x140C320D, 0x020C320C, 0x3701050E, 0x0C320C37, 0x0C0E0C14, 0x0C32160E, 0x0C0F0C14, 0x0B0E0A00, + 0x0A050A0E, 0x090F0A00, 0x150E090A, 0x090F090B, 0x00120085, 0x020A000A, 0x0579020A, 0x050A0A6D, 0x020A0A0A, + 0x1E61020A, 0x1E0A2855, 0x020A280A, 0x2D49020A, 0x2D0A373D, 0x020A370B, 0x2D31020B, 0x2D0B3725, 0x020B370C, + 0x0019020C, 0x000C0F0D, 0x020C0F0C, 0x1401050E, 0x0C0F0C14, 0x110E0C00, 0x0C0F1D0E, 0x0B370C00, 0x130E0B2D, + 0x0B371C0E, 0x0A370B2D, 0x020E0A2D, 0x0A371B0E, 0x0A280A2D, 0x120E0A1E, 0x0A281A0E, 0x0A0A0A1E, 0x010E0A05, + 0x0A0A190E, 0x0A000A05, 0x100A0015, 0x31020C37, 0x0D002502, 0x0D000D19, 0x19020D19, 0x15050D02, 0x15370505, + 0x01050E15, 0x37050505, 0x0E0D1915, 0x05030E0D, 0x000D191E, 0x0E0C370D, 0x0014050D, 0x000200AB, 0x01320100, + 0x880A0061, 0x31020600, 0x12002502, 0x12001500, 0x19021500, 0x150A0D02, 0x150A150F, 0x01050E15, 0x0A150F0F, + 0x0E150015, 0x0A180E12, 0x00150006, 0x0E060012, 0x00070A00, 0x6C250215, 0x0A150F19, 0x02150F15, 0x190D0215, + 0x19151E01, 0x050E1519, 0x151E0E0E, 0x150F1519, 0x170E150A, 0x150F0D0A, 0x00152502, 0x151E152D, 0x1902152D, + 0x160A0D02, 0x160A0600, 0x01050E16, 0x0A060005, 0x0E152D16, 0x0A1E0E15, 0x1E152D14, 0x050A0061, 0x19020600, + 0x12000D02, 0x12000600, 0x01050E00, 0x00000008, 0x0E060012, 0x00070505, +}; + +static s32 D_80951A0C[] = { + -1, 1, 4, 1, -1, 1, -1, -1, -1, 0, 2, 3, 5, 6, 8, 1, 0, 8, 3, 6, 0, 1, 4, 7, 0, 1, 2, 4, 5, 7, 1, +}; + +static s32 D_80951A88[] = { 0x0E2AB92D, 0x000A0C10 }; + +static s32 D_80951A90[] = { 0x0E2ABA2D, 0x000A0C10 }; + +static s32 D_80951A98[] = { + 0x00564000, 0x1A090000, 0x0E2AA40C, 0x09000017, 0x0E2AA52D, 0x000A0C09, 0x00001211, 0x56401009, + 0x00000E2A, 0xEC0C0900, 0x00170E2A, 0xED0C0900, 0x00180E2A, 0xEE2D000A, 0x0C090000, 0x12100000, +}; + +static s32 D_80951AD8[] = { + 0x00562000, 0xA1090000, 0x0E2AA60C, 0x09000017, 0x0E2AA70C, 0x09000018, 0x0E2AA80C, 0x09000017, + 0x0E2AA90C, 0x09000018, 0x0E2AAA0C, 0x09000017, 0x0E2AAB0C, 0x09000018, 0x0E2AAC0C, 0x09000017, + 0x0E2AAD0C, 0x0F2AAE0C, 0x09000017, 0x0E2AAF0C, 0x09000017, 0x0E2AB00C, 0x09000018, 0x0E2AB10C, + 0x09000017, 0x0E2AB20C, 0x09000017, 0x0E2AB30C, 0x09000017, 0x0E2AB40C, 0x09000018, 0x0E2AB50C, + 0x09000017, 0x0E2AB60C, 0x09000018, 0x0E2AB70C, 0x09000017, 0x0E2AB82D, 0x00082D00, 0x092D000A, + 0x0C115620, 0x12100900, 0x000E2AEA, 0x0C090000, 0x170E2AEB, 0x2D00082D, 0x000A0C09, 0x00001210, +}; + +static s32 D_80951B98[] = { + 0x004B0100, 0x42090000, 0x0900000E, 0x2B010C09, 0x0000170E, 0x2B020C09, 0x0000180E, + 0x2B030C09, 0x0000170E, 0x2B040C0F, 0x2B050C09, 0x0000180E, 0x2B060C09, 0x0000170E, + 0x2B072D00, 0x0A0C114B, 0x01150900, 0x0012100E, 0x2B082D00, 0x0A0C1210, +}; + +static s32 D_80951BE8[] = { + 0x09000000, 0x32010031, 0x00338000, 0x2C004B02, 0x000D0E2B, 0x132D000A, 0x0C114B02, 0x1900150E, 0x2B140C0F, + 0x2B150C0F, 0x2B160C0F, 0x2B170C0F, 0x2B180C15, 0x09000012, 0x100E2B12, 0x2D000A0C, 0x10000000, +}; + +static s32 D_80951C2C[] = { 0x0E295A2D, 0x000A0C10 }; + +static s32 D_80951C34[] = { 0x0E29622D, 0x000A0C10 }; + const ActorInit En_Gm_InitVars = { ACTOR_EN_GM, ACTORCAT_NPC, @@ -31,130 +104,1667 @@ const ActorInit En_Gm_InitVars = { (ActorFunc)EnGm_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80951C5C = { - { COLTYPE_HIT1, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT1, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 14, 62, 0, { 0, 0, 0 } }, }; -// static ColliderSphereInit sSphereInit = { -static ColliderSphereInit D_80951C88 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_SPHERE, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderSphereInit sSphereInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_SPHERE, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 20 }, 100 }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80951CB4 = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -#endif +static ActorAnimationEntryS D_80951CC0[13] = { + { &D_06009CDC, 1.0f, 0, -1, 0, 0 }, { &D_06009CDC, 1.0f, 0, -1, 0, -4 }, { &D_0600A5E0, 1.0f, 0, -1, 0, 0 }, + { &D_0600A70C, 1.0f, 0, 1, 0, 0 }, { &D_06008090, 1.0f, 0, -1, 0, 0 }, { &D_0600898C, 1.0f, 0, -1, 2, -4 }, + { &D_06009450, 1.0f, 0, -1, 2, -4 }, { &D_0600AD18, 1.0f, 0, -1, 0, 0 }, { &D_0600AD18, 1.0f, 0, -1, 0, -4 }, + { &D_0600B8B0, 1.0f, 0, -1, 2, 0 }, { &D_0600BA80, 1.0f, 0, -1, 0, -4 }, { &D_0600C03C, 1.0f, 0, -1, 0, -4 }, + { &D_0600B990, 1.0f, 0, -1, 0, -4 }, +}; -extern ColliderCylinderInit D_80951C5C; -extern ColliderSphereInit D_80951C88; -extern CollisionCheckInfoInit2 D_80951CB4; +Actor* func_8094DEE0(EnGm* this, GlobalContext* globalCtx, u8 arg2, s16 arg3) { + Actor* foundActor = NULL; + Actor* actor; -extern UNK_TYPE D_06007528; -extern UNK_TYPE D_060078B0; + while (true) { + actor = func_ActorCategoryIterateById(globalCtx, foundActor, arg2, arg3); + foundActor = actor; + if (actor == NULL) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_8094DEE0.s") + if ((this != (EnGm*)foundActor) && (foundActor->update != NULL)) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_8094DF90.s") + actor = actor->next; + if (actor == NULL) { + foundActor = NULL; + break; + } + foundActor = actor; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_8094DFF8.s") + return foundActor; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_8094E054.s") +EnDoor* func_8094DF90(GlobalContext* globalCtx, s32 arg1) { + s32 phi_a1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_8094E0F8.s") + switch (arg1) { + case 9: + case 13: + case 15: + phi_a1 = 11; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_8094E1DC.s") + case 10: + case 11: + case 16: + case 17: + phi_a1 = 17; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_8094E278.s") + case 12: + case 14: + case 20: + phi_a1 = 10; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_8094E2D0.s") + case 18: + case 19: + phi_a1 = 19; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_8094E454.s") + default: + phi_a1 = -1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_8094E4D0.s") + return (EnDoor*)func_8013A7C0(globalCtx, phi_a1); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_8094E52C.s") +s32 func_8094DFF8(EnGm* this, GlobalContext* globalCtx) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_8094E69C.s") + if (this->unk_262 < 0) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_8094EA34.s") + if (this->unk_262 >= 0) { + this->skelAnime.playSpeed = this->unk_3A8; + ret = SkelAnime_Update(&this->skelAnime); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_8094EB1C.s") + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_8094EDBC.s") +s32 func_8094E054(EnGm* this, GlobalContext* globalCtx, s32 arg2) { + s8 tmp = this->unk_262; + s32 phi_v1 = false; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_8094EE84.s") + if ((arg2 == 0) || (arg2 == 1)) { + if ((this->unk_3E8 != 0) && (this->unk_3E8 != 1)) { + phi_v1 = true; + } + } else if (arg2 != this->unk_3E8) { + phi_v1 = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_8094EFC4.s") + if (phi_v1) { + if (tmp >= 0) { + this->unk_3E8 = arg2; + ret = func_8013BC6C(&this->skelAnime, D_80951CC0, arg2); + this->unk_3A8 = this->skelAnime.playSpeed; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_8094F074.s") + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_8094F0E0.s") +s32 func_8094E0F8(EnGm* this, GlobalContext* globalCtx) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_8094F2E8.s") + if ((this->unk_260 != globalCtx->roomCtx.currRoom.num) && (globalCtx->roomCtx.unk31 == 0)) { + this->unk_260 = globalCtx->roomCtx.currRoom.num; + this->unk_262 = func_8013D924(0x248, globalCtx); + this->actor.draw = NULL; + this->unk_3FC = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_8094F3D0.s") + if (this->unk_3FC == 0) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_8094F4EC.s") + if ((this->unk_262 < 0) || !func_8013D8DC(this->unk_262, globalCtx)) { + ret = true; + } else { + this->actor.draw = EnGm_Draw; + if (this->unk_258 == 2) { + this->unk_268 = NULL; + this->unk_3B8 = 0; + } + this->unk_3FC = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_8094F53C.s") + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_8094F7D0.s") +void func_8094E1DC(EnGm* this, GlobalContext* globalCtx) { + s32 pad; + f32 temp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_8094F904.s") + if (this->unk_258 == 7) { + temp = this->colliderSphere.dim.modelSphere.radius * this->colliderSphere.dim.scale; + this->colliderSphere.dim.worldSphere.radius = temp; + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere.base); + } else { + Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_8094FAC4.s") +void func_8094E278(GlobalContext* globalCtx) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DM_CHAR07, 115.0f, 32.0f, -121.0f, 0, 0, 0, 3); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_8094FCC4.s") +void func_8094E2D0(EnGm* this) { + s32 phi_a1 = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_8094FD88.s") + if (this->unk_3A4 & 0x100) { + if (DECR(this->unk_3CC) == 0) { + switch (this->unk_3CA) { + case 1: + if ((this->unk_3CE == 5) || (this->unk_3CE == 2)) { + phi_a1 = true; + this->unk_3CE = 5; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_8094FE10.s") + case 2: + if ((this->unk_3CE == 4) || (this->unk_3CE == 2)) { + phi_a1 = true; + this->unk_3CE = 4; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_8094FF04.s") + case 3: + if (this->unk_3CE == 2) { + phi_a1 = true; + this->unk_3CE = 2; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_80950088.s") + case 4: + if (this->unk_3CE == 1) { + phi_a1 = true; + this->unk_3CE = 1; + } + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_80950120.s") + if (!phi_a1 && ((this->unk_3CE == 4) || (this->unk_3CE == 5))) { + this->unk_3CE = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_809501B8.s") + if (!phi_a1) { + this->unk_3CE++; + if (this->unk_3CE >= 4) { + if (this->unk_3CA == 0) { + this->unk_3CC = Rand_S16Offset(30, 30); + } else { + this->unk_3CC = 8; + } + this->unk_3CE = 0; + } + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_80950280.s") +s32 func_8094E454(EnGm* this, s16 arg1) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_80950388.s") + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(arg1); + } else if (ActorCutscene_GetCanPlayNext(arg1)) { + ActorCutscene_StartAndSetUnkLinkFields(arg1, &this->actor); + ret = true; + } else { + ActorCutscene_SetIntentToPlay(arg1); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_809503F8.s") +s16 func_8094E4D0(EnGm* this, s32 arg1) { + s32 i; + s16 cutscene = this->actor.cutscene; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_80950490.s") + for (i = 0; i < arg1; i++) { + cutscene = ActorCutscene_GetAdditionalCutscene(cutscene); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_80950690.s") + return cutscene; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_80950804.s") +s32 func_8094E52C(EnGm* this, GlobalContext* globalCtx) { + s32 pad; + s16 sp2A = func_8094E4D0(this, 0); + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_8095097C.s") + switch (this->unk_3E0) { + case 0: + if (!func_8094E454(this, sp2A)) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_80950C24.s") + case 2: + if (!(gSaveContext.weekEventReg[86] & 0x40) && (this->unk_3E0 == 2)) { + ActorCutscene_Stop(sp2A); + } else { + func_800E0308(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); + } + this->unk_3E0++; + ret = true; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_80950CDC.s") + case 1: + if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { + func_800E0308(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), this->actor.child); + } + this->unk_3E0++; + ret = true; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_80950DB8.s") + case 3: + ActorCutscene_Stop(sp2A); + this->unk_3E0++; + ret = true; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_80950F2C.s") + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/EnGm_Init.s") +s32 func_8094E69C(EnGm* this, GlobalContext* globalCtx) { + Camera* camera; + s16 sp4A = func_8094E4D0(this, 0); + s16 sp48; + Vec3f sp3C; + Vec3f sp30; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/EnGm_Destroy.s") + switch (this->unk_3E0) { + case 0: + Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHAIR_ROLL); + func_8094E054(this, globalCtx, 2); + this->unk_3E2 = 0; + this->unk_3E0++; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/EnGm_Update.s") + case 1: + if ((this->actor.child != NULL) || (this->actor.child->update != NULL)) { + Math_Vec3f_Copy(&sp3C, &this->actor.child->world.pos); + Math_Vec3f_Copy(&sp30, &this->actor.world.pos); + sp48 = Math_Vec3f_Yaw(&sp30, &sp3C); + this->unk_3E2++; + if (((this->actor.shape.rot.y / 364) != (sp48 / 364)) && (this->unk_3E2 < 20)) { + Math_ApproachS(&this->actor.shape.rot.y, sp48, 3, 0x2AA8); + } else { + this->actor.shape.rot.y = sp48; + this->unk_3A4 |= 0x20; + this->unk_3E2 = 0; + this->unk_3E0++; + ret = true; + } + } else { + this->unk_3A4 |= 0x20; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->unk_3E0++; + ret = true; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_809513AC.s") + case 2: + if (func_8094E454(this, sp4A)) { + case 4: + case 6: + camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp4A)); + func_800E0308(camera, &this->actor); + this->unk_3E0++; + ret = true; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_809514BC.s") + case 3: + case 5: + case 7: + if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { + camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp4A)); + func_800E0308(camera, this->actor.child); + } + this->unk_3E0++; + ret = true; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/func_80951594.s") + case 8: + Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHAIR_ROLL); + ActorCutscene_Stop(sp4A); + this->unk_3E2 = 0; + this->unk_3E0++; + break; + case 9: + sp48 = this->actor.world.rot.y; + this->unk_3E2++; + if (((this->actor.shape.rot.y / 364) != (sp48 / 364)) && (this->unk_3E2 < 20)) { + Math_ApproachS(&this->actor.shape.rot.y, sp48, 3, 0x2AA8); + this->unk_3A4 &= ~0x20; + } else { + func_8094E054(this, globalCtx, 1); + this->actor.shape.rot.y = sp48; + this->unk_3E0++; + this->unk_3E2 = 0; + ret = true; + } + break; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gm/EnGm_Draw.s") +s32 func_8094EA34(EnGm* this, GlobalContext* globalCtx) { + s32 pad[2]; + Actor* al; + Actor* toto; + + al = func_8094DEE0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AL); + toto = func_8094DEE0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_TOTO); + if ((al == NULL) || (al->update == NULL) || (toto == NULL) || (toto->update == NULL)) { + this->unk_3E0++; + return true; + } + + switch (this->unk_3E0) { + case 0: + case 2: + case 4: + case 6: + case 10: + case 14: + case 16: + this->unk_3E0++; + break; + + case 7: + case 9: + case 12: + this->actor.child = toto; + this->unk_3E0++; + break; + + case 1: + case 3: + case 5: + case 8: + case 11: + case 13: + case 15: + case 17: + this->actor.child = al; + this->unk_3E0++; + break; + + default: + this->unk_3E0++; + break; + } + + return true; +} + +s32 func_8094EB1C(EnGm* this, GlobalContext* globalCtx) { + s32 pad[2]; + s32 ret = false; + s16 oldYaw; + + switch (this->unk_3E0) { + case 0: + if ((gSaveContext.weekEventReg[50] & 1) || (gSaveContext.weekEventReg[51] & 0x80) || + (gSaveContext.weekEventReg[75] & 2)) { + ret = true; + break; + } + Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHAIR_ROLL); + func_8094E054(this, globalCtx, 2); + this->unk_3E2 = 0; + this->unk_3E0++; + + case 1: + oldYaw = this->actor.yawTowardsPlayer; + this->unk_3E2++; + if (((this->actor.shape.rot.y / 364) != (oldYaw / 364)) && (this->unk_3E2 < 20)) { + Math_ApproachS(&this->actor.shape.rot.y, oldYaw, 3, 0x2AA8); + } else { + this->actor.shape.rot.y = oldYaw; + this->unk_3A4 |= 0x20; + this->unk_3E2 = 0; + this->unk_3E0++; + ret = true; + } + break; + + case 2: + Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHAIR_ROLL); + this->unk_3E2 = 0; + this->unk_3E0++; + + case 3: + oldYaw = this->actor.world.rot.y; + this->unk_3E2++; + if (((this->actor.shape.rot.y / 364) != (oldYaw / 364)) && (this->unk_3E2 < 20)) { + Math_ApproachS(&this->actor.shape.rot.y, oldYaw, 3, 0x2AA8); + this->unk_3A4 &= ~0x20; + } else { + func_8094E054(this, globalCtx, 1); + this->actor.shape.rot.y = oldYaw; + this->unk_3E2 = 0; + this->unk_3E0++; + ret = true; + } + break; + } + return ret; +} + +s32* func_8094EDBC(EnGm* this, GlobalContext* globalCtx) { + switch (this->unk_258) { + case 1: + this->unk_3E4 = func_8094E52C; + return D_80951A98; + + case 2: + this->unk_3E4 = func_8094EA34; + return D_80951AD8; + + case 3: + this->unk_3E4 = func_8094E69C; + return D_80951B98; + + case 5: + this->unk_3E4 = func_8094EB1C; + return D_80951BE8; + + case 7: + return D_80951C2C; + + case 8: + return D_80951C34; + + case 6: + case 21: + case 23: + case 24: + case 25: + case 26: + case 27: + case 30: + return D_80951A88; + + case 12: + case 17: + case 19: + case 20: + case 22: + case 28: + case 29: + return D_80951A90; + + default: + break; + } + return NULL; +} + +s32 func_8094EE84(EnGm* this, GlobalContext* globalCtx) { + s32 ret = false; + + if (this->unk_3A4 & 7) { + if (func_800B84D0(&this->actor, globalCtx)) { + func_8013AED4(&this->unk_3A4, 0, 7); + this->unk_3E0 = 0; + this->unk_3E4 = NULL; + this->actor.child = this->unk_268; + this->unk_264 = func_8094EDBC(this, globalCtx); + + if ((this->unk_258 == 5) && !(gSaveContext.weekEventReg[50] & 1) && + !(gSaveContext.weekEventReg[51] & 0x80) && !(gSaveContext.weekEventReg[75] & 2)) { + this->unk_3A4 |= 0x20; + } else if ((this->unk_258 != 1) && (this->unk_258 != 5) && (this->unk_258 != 7)) { + this->unk_3A4 |= 0x20; + } + + if ((this->unk_258 == 3) && (gSaveContext.weekEventReg[75] & 1)) { + this->unk_3A4 &= ~0x20; + } + + this->actionFunc = func_80950DB8; + ret = true; + } + } + return ret; +} + +s32 func_8094EFC4(EnGm* this, GlobalContext* globalCtx) { + s32 ret = false; + + if (globalCtx->csCtx.state != 0) { + if (this->unk_3F8 == 0) { + if ((globalCtx->sceneNum == SCENE_MILK_BAR) && (gSaveContext.sceneSetupIndex == 2)) { + func_8094E054(this, globalCtx, 0); + this->unk_258 = 255; + } + this->unk_259 = 255; + this->unk_3F8 = 1; + } + ret = true; + } else if (this->unk_3F8 != 0) { + if (globalCtx->sceneNum == SCENE_MILK_BAR) { + this->unk_400 = 0; + } + this->unk_3F8 = 0; + } + return ret; +} + +Actor* func_8094F074(EnGm* this, GlobalContext* globalCtx) { + Actor* actor; + + switch (this->unk_258) { + case 1: + actor = func_8094DEE0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_RECEPGIRL); + break; + + case 2: + actor = this->unk_268; + break; + + case 3: + actor = func_8094DEE0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_TAB); + break; + + default: + actor = &GET_PLAYER(globalCtx)->actor; + break; + } + + return actor; +} + +void func_8094F0E0(EnGm* this) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + s16 sp32; + + Math_Vec3f_Copy(&sp40, &this->unk_268->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + sp32 = Math_Vec3f_Yaw(&sp34, &sp40); + Math_ApproachS(&this->unk_3BE, (sp32 - this->unk_3C2) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_3BE = CLAMP(this->unk_3BE, -0x1FFE, 0x1FFE); + + Math_ApproachS(&this->unk_3C2, (sp32 - this->unk_3BE) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_3C2 = CLAMP(this->unk_3C2, -0x1C70, 0x1C70); + + Math_Vec3f_Copy(&sp34, &this->actor.focus.pos); + + if (this->unk_268->id == ACTOR_PLAYER) { + sp40.y = ((Player*)this->unk_268)->bodyPartsPos[7].y + 3.0f; + } else { + Math_Vec3f_Copy(&sp40, &this->unk_268->focus.pos); + } + + Math_ApproachS(&this->unk_3BC, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_3C0, 4, 0x2AA8); + this->unk_3BC = CLAMP(this->unk_3BC, -0x1554, 0x1554); + + Math_ApproachS(&this->unk_3C0, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_3BC, 4, 0x2AA8); + this->unk_3C0 = CLAMP(this->unk_3C0, -0xE38, 0xE38); +} + +void func_8094F2E8(EnGm* this) { + if ((this->unk_3A4 & 0x20) && (this->unk_268 != NULL) && (this->unk_268->update != NULL)) { + if (DECR(this->unk_3C6) == 0) { + func_8094F0E0(this); + this->unk_3A4 &= ~0x200; + this->unk_3A4 |= 0x80; + return; + } + } + + if (this->unk_3A4 & 0x80) { + this->unk_3A4 &= ~0x80; + this->unk_3BC = 0; + this->unk_3BE = 0; + this->unk_3C0 = 0; + this->unk_3C2 = 0; + this->unk_3C6 = 20; + } else if (DECR(this->unk_3C6) == 0) { + this->unk_3A4 |= 0x200; + } +} + +void func_8094F3D0(EnGm* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 sp28 = func_80152498(&globalCtx->msgCtx); + s32 var = globalCtx->msgCtx.unk11F04; + + if ((&this->actor == player->targetActor) && ((var < 0xFF) || (var > 0x200)) && (sp28 == 3) && + (this->unk_3F0 == 3)) { + if ((globalCtx->state.frames % 3) == 0) { + if (this->unk_3AC == 120.0f) { + this->unk_3AC = 0.0f; + } else { + this->unk_3AC = 120.0f; + } + } + } else { + this->unk_3AC = 0.0f; + } + Math_SmoothStepToF(&this->unk_3B0, this->unk_3AC, 0.8f, 40.0f, 10.0f); + Matrix_InsertTranslation(this->unk_3B0, 0.0f, 0.0f, 1); + this->unk_3F0 = sp28; +} + +s32 func_8094F4EC(EnGm* this, GlobalContext* globalCtx) { + if ((this->unk_258 != 6) && (this->unk_3E8 == 12)) { + this->unk_3A4 &= ~0x2000; + func_8094E054(this, globalCtx, 8); + } + return true; +} + +s32 func_8094F53C(EnGm* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + u16 sp32 = globalCtx->msgCtx.unk11F04; + Actor* al = func_8094DEE0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AL); + Actor* toto = func_8094DEE0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_TOTO); + + if (player->stateFlags1 & 0x440) { + this->unk_3A4 |= 0x400; + if (this->unk_3A6 != sp32) { + switch (sp32) { + case 0x2B13: + func_8094E054(this, globalCtx, 2); + break; + + case 0x2B14: + case 0x2B18: + func_8094E054(this, globalCtx, 0); + break; + + case 0x2B16: + func_8094E054(this, globalCtx, 1); + break; + + case 0x2B15: + func_8094E054(this, globalCtx, 5); + break; + + case 0x2B17: + func_8094E054(this, globalCtx, 6); + break; + + default: + if ((this->unk_3E8 == 7) || (this->unk_3E8 == 8)) { + this->unk_3A4 |= 0x2000; + func_8094E054(this, globalCtx, 12); + } + break; + } + + switch (sp32) { + case 0x2AA6: + case 0x2AAF: + case 0x2AB4: + if ((al != NULL) && (al->update != NULL)) { + this->unk_268 = al; + } + break; + + case 0x2AAD: + case 0x2AB0: + case 0x2AB2: + if ((toto != NULL) && (toto->update != NULL)) { + this->unk_268 = toto; + } + break; + } + + if (sp32 == 0x2AA8) { + this->unk_3C8 = 0; + this->unk_3CA = 0; + this->unk_3CC = 8; + } + } + this->unk_3A6 = sp32; + } else if (this->unk_3A4 & 0x400) { + this->unk_18C = NULL; + this->unk_3A6 = 0; + this->unk_3A4 &= ~0x400; + this->unk_3CA = this->unk_3C8; + this->unk_3CC = 4; + func_8094F4EC(this, globalCtx); + } + + if (this->unk_18C != NULL) { + this->unk_18C(this, globalCtx); + } + + if ((this->unk_3E8 == 6) && !(globalCtx->actorCtx.unk5 & 0x20) && Animation_OnFrame(&this->skelAnime, 20.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_HANKO); + } + + return false; +} + +s32 func_8094F7D0(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2, u8 arg3, s16 arg4) { + u8 sp4F = ENGM_GET_FF(&this->actor); + Vec3s* sp48; + Vec3f sp3C; + Vec3f sp30; + Actor* actor; + s32 pad; + s32 ret = false; + + this->unk_234 = NULL; + actor = func_8094DEE0(this, globalCtx, arg3, arg4); + + if (D_80951A0C[arg2->unk0] >= 0) { + this->unk_234 = func_8013BB34(globalCtx, sp4F, D_80951A0C[arg2->unk0]); + } + + if ((actor != NULL) && (actor->update != NULL)) { + if (this->unk_234 != NULL) { + sp48 = (Vec3s*)Lib_SegmentedToVirtual(this->unk_234->points); + Math_Vec3s_ToVec3f(&sp3C, &sp48[this->unk_234->count - 2]); + Math_Vec3s_ToVec3f(&sp30, &sp48[this->unk_234->count - 1]); + this->actor.shape.shadowDraw = NULL; + this->actor.world.rot.y = Math_Vec3f_Yaw(&sp3C, &sp30); + Math_Vec3f_Copy(&this->actor.world.pos, &sp30); + ret = true; + } + } + return ret; +} + +s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + u16 sp56 = gSaveContext.time - 0x3FFC; + u8 sp55 = ENGM_GET_FF(&this->actor); + EnDoor* sp50; + Vec3s* sp4C; + Vec3f sp40; + Vec3f sp34; + s32 pad; + s32 ret = false; + + this->unk_234 = NULL; + sp50 = func_8094DF90(globalCtx, arg2->unk0); + + if (D_80951A0C[arg2->unk0] >= 0) { + this->unk_234 = func_8013BB34(globalCtx, sp55, D_80951A0C[arg2->unk0]); + } + + if ((sp50 != NULL) && (sp50->actor.update != NULL)) { + if (this->unk_234 != NULL) { + sp4C = (Vec3s*)Lib_SegmentedToVirtual(this->unk_234->points); + Math_Vec3s_ToVec3f(&sp40, &sp4C[0]); + Math_Vec3s_ToVec3f(&sp34, &sp4C[1]); + Math_Vec3f_Copy(&this->unk_278, &sp40); + Math_Vec3f_Copy(&this->unk_284, &sp34); + this->actor.world.rot.y = Math_Vec3f_Yaw(&sp40, &sp34); + Math_Vec3f_Copy(&this->actor.world.pos, &sp40); + + if (ABS_ALT(BINANG_SUB(this->actor.world.rot.y, sp50->actor.shape.rot.y)) <= 0x4000) { + this->unk_261 = -75; + } else { + this->unk_261 = 75; + } + + this->unk_3B8 = arg2->unk8 - arg2->unk4; + this->unk_3BA = sp56 - arg2->unk4; + this->actor.flags &= ~1; + this->unk_3A4 |= 0x100; + this->unk_3A4 |= 0x200; + func_8094E054(this, globalCtx, 7); + this->actor.gravity = 0.0f; + ret = true; + } + } + return ret; +} + +s32 func_8094FAC4(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + u16 sp2E = gSaveContext.time - 0x3FFC; + u16 phi_v1; + u8 sp2B = ENGM_GET_FF(&this->actor); + s32 pad; + s32 ret = false; + + this->unk_234 = NULL; + if (D_80951A0C[arg2->unk0] >= 0) { + this->unk_234 = func_8013BB34(globalCtx, sp2B, D_80951A0C[arg2->unk0]); + } + + if ((this->unk_234 != NULL) && (this->unk_234->count < 3)) { + this->unk_234 = NULL; + } + + if (this->unk_234 != NULL) { + if ((this->unk_258 < 9) && (this->unk_258 != 0) && (this->unk_3C4 >= 0)) { + phi_v1 = sp2E; + } else { + phi_v1 = arg2->unk4; + } + + if (arg2->unk8 < phi_v1) { + this->unk_248 = (phi_v1 - arg2->unk8) + 0xFFFF; + } else { + this->unk_248 = arg2->unk8 - phi_v1; + } + + this->unk_254 = sp2E - phi_v1; + phi_v1 = this->unk_234->count - 2; + this->unk_24C = this->unk_248 / phi_v1; + this->unk_250 = (this->unk_254 / this->unk_24C) + 2; + this->unk_3A4 &= ~0x8; + this->unk_3A4 &= ~0x10; + func_8013AED4(&this->unk_3A4, 3, 7); + this->unk_3A4 |= 0x100; + this->unk_3A4 |= 0x200; + func_8094E054(this, globalCtx, 7); + this->actor.gravity = -1.0f; + ret = true; + } + return ret; +} + +s32 func_8094FCC4(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + static Vec3f D_80951D90 = { 64.0f, 0.0f, -122.0f }; + s32 ret = false; + + if (func_8094F7D0(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_TAB)) { + if (this->unk_258 == 0) { + Math_Vec3f_Copy(&this->actor.world.pos, &D_80951D90); + func_8013AED4(&this->unk_3A4, 3, 7); + func_8094E054(this, globalCtx, 0); + } else { + func_8094E054(this, globalCtx, 9); + this->skelAnime.moveFlags = 0x10; + } + this->unk_3A4 |= 0x100; + this->unk_3A4 |= 0x200; + ret = true; + } + return ret; +} + +s32 func_8094FD88(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + s32 ret = false; + + if (func_8094F7D0(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_RECEPGIRL)) { + func_8094E054(this, globalCtx, 11); + func_8013AED4(&this->unk_3A4, 3, 7); + this->unk_3A4 |= 0x100; + this->unk_3A4 |= 0x200; + ret = true; + } + return ret; +} + +s32 func_8094FE10(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + s32 ret = false; + Actor* al; + + al = func_8094DEE0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AL); + if (func_8094F7D0(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_TOTO) && (al != NULL) && (al->update != NULL)) { + func_8094E054(this, globalCtx, 11); + func_8013AED4(&this->unk_3A4, 3, 7); + this->unk_268 = al; + if (!(gSaveContext.weekEventReg[86] & 0x20)) { + this->unk_3C8 = 2; + this->unk_3CA = 2; + this->unk_3CC = 8; + } + this->unk_3A4 |= (0x100 | 0x20); + this->unk_3A4 |= 0x200; + ret = true; + } + return ret; +} + +s32 func_8094FF04(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + static Vec3f D_80951D9C = { 64.0f, 0.0f, -122.0f }; + u8 sp4F = ENGM_GET_FF(&this->actor); + Vec3s* sp48; + Vec3f sp3C; + Vec3f sp30; + s32 pad; + s32 ret = false; + + this->unk_234 = NULL; + + if (D_80951A0C[arg2->unk0] >= 0) { + this->unk_234 = func_8013BB34(globalCtx, sp4F, D_80951A0C[arg2->unk0]); + } + + if (this->unk_234 != NULL) { + sp48 = (Vec3s*)Lib_SegmentedToVirtual(this->unk_234->points); + Math_Vec3s_ToVec3f(&sp3C, &sp48[this->unk_234->count - 2]); + Math_Vec3s_ToVec3f(&sp30, &sp48[this->unk_234->count - 1]); + this->actor.shape.shadowDraw = NULL; + this->actor.world.rot.y = Math_Vec3f_Yaw(&sp3C, &sp30); + if (this->unk_258 == 0) { + Math_Vec3f_Copy(&this->actor.world.pos, &D_80951D9C); + func_8013AED4(&this->unk_3A4, 3, 7); + this->unk_3C8 = 4; + this->unk_3CA = 4; + this->unk_3CC = 8; + func_8094E054(this, globalCtx, 0); + func_8094E278(globalCtx); + } else { + Math_Vec3f_Copy(&this->actor.world.pos, &sp30); + func_8094E054(this, globalCtx, 9); + this->skelAnime.moveFlags = 0x10; + } + this->unk_400 = 0; + this->unk_3A4 |= 0x100; + this->unk_3A4 |= 0x200; + ret = true; + } + return ret; +} + +s32 func_80950088(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + static Vec3f D_80951DA8 = { 278.0f, 0.0f, 223.0f }; + static Vec3s D_80951DB4 = { 0x0000, 0xC000, 0x0000 }; + s32 pad; + + Math_Vec3f_Copy(&this->actor.world.pos, &D_80951DA8); + Math_Vec3s_Copy(&this->actor.world.rot, &D_80951DB4); + Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); + func_8013AED4(&this->unk_3A4, 3, 7); + this->unk_3A4 |= (0x2000 | 0x100); + this->unk_3A4 |= 0x200; + func_8094E054(this, globalCtx, 12); + return true; +} + +s32 func_80950120(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + static Vec3f D_80951DBC = { -525.0f, 214.0f, 515.0f }; + static Vec3s D_80951DC8 = { 0x0000, 0x38E0, 0x0000 }; + s32 pad; + + Math_Vec3f_Copy(&this->actor.world.pos, &D_80951DBC); + Math_Vec3s_Copy(&this->actor.world.rot, &D_80951DC8); + Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); + func_8013AED4(&this->unk_3A4, 3, 7); + this->unk_3A4 |= (0x800 | 0x100); + this->unk_3A4 |= 0x200; + func_8094E054(this, globalCtx, 4); + return true; +} + +s32 func_809501B8(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + static Vec3f D_80951DD0 = { -334.0f, 225.0f, 903.0f }; + static Vec3s D_80951DDC = { 0x0000, 0x7FFF, 0x0000 }; + s32 pad; + + Math_Vec3f_Copy(&this->actor.world.pos, &D_80951DD0); + Math_Vec3s_Copy(&this->actor.world.rot, &D_80951DDC); + Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); + this->actor.targetMode = 6; + func_8013AED4(&this->unk_3A4, 3, 7); + this->unk_3A4 |= (0x1000 | 0x100); + this->unk_3A4 |= 0x200; + this->unk_3C8 = 3; + this->unk_3CA = 3; + this->unk_3CC = 8; + this->actor.targetMode = 6; + this->unk_3B4 = 60.0f; + func_8094E054(this, globalCtx, 10); + return true; +} + +s32 func_80950280(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + s32 phi_v1; + + this->actor.flags |= 1; + this->actor.targetMode = 0; + this->unk_3A4 = 0; + this->unk_3C8 = 0; + this->unk_3CA = 0; + this->unk_3CC = 8; + this->unk_3B4 = 40.0f; + + switch (arg2->unk0) { + case 1: + phi_v1 = func_8094FD88(this, globalCtx, arg2); + break; + + case 2: + phi_v1 = func_8094FE10(this, globalCtx, arg2); + break; + + case 3: + phi_v1 = func_8094FCC4(this, globalCtx, arg2); + break; + + case 5: + phi_v1 = func_8094FF04(this, globalCtx, arg2); + break; + + case 6: + phi_v1 = func_80950088(this, globalCtx, arg2); + break; + + case 7: + phi_v1 = func_809501B8(this, globalCtx, arg2); + break; + + case 8: + phi_v1 = func_80950120(this, globalCtx, arg2); + break; + + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + case 17: + case 18: + case 19: + case 20: + phi_v1 = func_8094F904(this, globalCtx, arg2); + break; + + case 21: + case 22: + case 23: + case 24: + case 25: + case 26: + case 27: + case 28: + case 29: + case 30: + phi_v1 = func_8094FAC4(this, globalCtx, arg2); + break; + + default: + phi_v1 = false; + break; + } + + return phi_v1; +} + +s32 func_80950388(EnGm* this, GlobalContext* globalCtx) { + Vec3f sp2C; + Vec3f sp20; + + if ((this->unk_268 != NULL) && (this->unk_268->update != NULL)) { + Math_Vec3f_Copy(&sp2C, &this->unk_268->world.pos); + Math_Vec3f_Copy(&sp20, &this->actor.world.pos); + this->actor.world.rot.y = Math_Vec3f_Yaw(&sp20, &sp2C); + } + + return false; +} + +s32 func_809503F8(EnGm* this, GlobalContext* globalCtx) { + s32 pad; + + if (this->unk_3E8 == 9) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->actor.shape.shadowDraw = func_800B3FC0; + func_8013AED4(&this->unk_3A4, 3, 7); + func_8094E054(this, globalCtx, 0); + } else { + AnimationContext_SetMoveActor(globalCtx, &this->actor, &this->skelAnime, 1.0f); + } + } + return false; +} + +s32 func_80950490(EnGm* this, GlobalContext* globalCtx) { + static s32 D_80951DE4[] = { + 1, 5, 5, 1, 6, 5, 1, 5, 6, 1, 5, 6, + }; + s32 pad; + + if ((gSaveContext.weekEventReg[50] & 1) || (gSaveContext.weekEventReg[51] & 0x80)) { + if (this->unk_400 == 0) { + this->unk_3C8 = 1; + this->unk_3CA = 1; + this->unk_3CC = 8; + this->unk_400 = 1; + func_8094E054(this, globalCtx, 3); + } + return false; + } + + this->unk_400 = 0; + + switch (this->unk_3E8) { + case 9: + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->actor.shape.shadowDraw = func_800B3FC0; + func_8013AED4(&this->unk_3A4, 3, 7); + this->unk_3C8 = 4; + this->unk_3CA = 4; + this->unk_3CC = 8; + func_8094E054(this, globalCtx, 0); + func_8094E278(globalCtx); + } else { + AnimationContext_SetMoveActor(globalCtx, &this->actor, &this->skelAnime, 1.0f); + } + break; + + case 5: + case 6: + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_8094E054(this, globalCtx, D_80951DE4[this->unk_3F4]); + this->unk_3F4++; + this->unk_3F4 %= 12; + this->unk_3DE = Rand_S16Offset(30, 30); + } + break; + + default: + if (DECR(this->unk_3DE) == 0) { + func_8094E054(this, globalCtx, D_80951DE4[this->unk_3F4]); + this->unk_3F4++; + this->unk_3F4 %= 12; + this->unk_3DE = Rand_S16Offset(30, 30); + } + break; + } + return false; +} + +s32 func_80950690(EnGm* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Actor* al; + Actor* toto; + + switch (this->unk_258) { + case 2: + al = func_8094DEE0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AL); + toto = func_8094DEE0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_TOTO); + if ((al != NULL) && (al->update != NULL) && (toto != NULL) && (toto->update != NULL) && + !(player->stateFlags1 & 0x40)) { + if (DECR(this->unk_3B8) == 0) { + if (al == this->unk_268) { + this->unk_268 = toto; + } else { + this->unk_268 = al; + } + this->unk_3B8 = Rand_S16Offset(60, 60); + } + } + break; + + case 7: + this->unk_3D0 += 992; + if (DECR(this->unk_3B8) == 0) { + Audio_PlayActorSound2(&this->actor, NA_SE_VO_GO_SLEEP); + this->unk_3B8 = 30; + } + break; + + case 8: + break; + } + + func_8013D9C8(globalCtx, this->unk_3D8, this->unk_3D2, ARRAY_COUNT(this->unk_3D2)); + + return false; +} + +s32 func_80950804(EnGm* this, GlobalContext* globalCtx) { + EnDoor* sp44; + Vec3f sp38; + s32 pad; + f32 temp_f0; + + sp44 = func_8094DF90(globalCtx, this->unk_258); + if (!func_8013AD6C(globalCtx) && (this->unk_3C4 != 0)) { + if ((sp44 != NULL) && (sp44->actor.update != NULL)) { + if ((this->unk_3BA / (f32)this->unk_3B8) <= 0.9f) { + sp44->unk_1A7 = this->unk_261; + } else { + sp44->unk_1A7 = 0; + } + } + + this->unk_3BA = CLAMP(this->unk_3BA, 0, this->unk_3B8); + temp_f0 = Math_Vec3f_DistXZ(&this->unk_278, &this->unk_284) / this->unk_3B8; + sp38.x = 0.0f; + sp38.y = 0.0f; + sp38.z = this->unk_3BA * temp_f0; + Lib_Vec3f_TranslateAndRotateY(&this->unk_278, this->actor.world.rot.y, &sp38, &this->actor.world.pos); + this->unk_3BA += this->unk_3C4; + if (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 13.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_PIRATE_WALK); + } + } + + return false; +} + +s32 func_8095097C(EnGm* this, GlobalContext* globalCtx) { + f32 sp7C[0x109]; + Vec3f sp70; + Vec3f sp64; + Vec3f sp58; + s32 sp54 = 0; + s32 sp50 = 0; + s32 pad2; + + func_8013AF00(sp7C, 3, this->unk_234->count + 3); + + if (!(this->unk_3A4 & 8)) { + sp58 = D_801D15B0; + func_8013B6B0(this->unk_234, &this->unk_244, &this->unk_254, this->unk_24C, this->unk_248, &this->unk_250, sp7C, + &sp58, this->unk_3C4); + func_8013B878(globalCtx, this->unk_234, this->unk_250, &sp58); + this->actor.world.pos.y = sp58.y; + this->unk_3A4 |= 8; + } else { + sp58 = this->unk_238; + } + + this->actor.world.pos.x = sp58.x; + this->actor.world.pos.z = sp58.z; + + if (func_8013AD6C(globalCtx)) { + sp54 = this->unk_254; + sp50 = this->unk_250; + sp58 = this->actor.world.pos; + } + + this->unk_238 = D_801D15B0; + + if (func_8013B6B0(this->unk_234, &this->unk_244, &this->unk_254, this->unk_24C, this->unk_248, &this->unk_250, sp7C, + &this->unk_238, this->unk_3C4)) { + this->unk_3A4 |= 0x10; + } else { + sp70 = this->actor.world.pos; + sp64 = this->unk_238; + this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); + } + + if (func_8013AD6C(globalCtx)) { + this->unk_254 = sp54; + this->unk_250 = sp50; + this->unk_238 = sp58; + } else if (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 13.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_PIRATE_WALK); + } + return false; +} + +void func_80950C24(EnGm* this, GlobalContext* globalCtx) { + switch (this->unk_258) { + case 1: + func_80950388(this, globalCtx); + break; + + case 2: + case 6: + case 7: + case 8: + func_80950690(this, globalCtx); + break; + + case 3: + func_809503F8(this, globalCtx); + break; + + case 5: + func_80950490(this, globalCtx); + break; + + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + case 17: + case 18: + case 19: + case 20: + func_80950804(this, globalCtx); + break; + + case 21: + case 22: + case 23: + case 24: + case 25: + case 26: + case 27: + case 28: + case 29: + case 30: + func_8095097C(this, globalCtx); + break; + } + + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x2AA8); +} + +void func_80950CDC(EnGm* this, GlobalContext* globalCtx) { + u32* unk_14 = &gSaveContext.unk_14; + struct_80133038_arg2 sp20; + + this->unk_3C4 = REG(15) + *unk_14; + + if (!func_80133038(globalCtx, (void*)&D_80951820, &sp20) || + ((this->unk_258 != sp20.unk0) && !func_80950280(this, globalCtx, &sp20))) { + this->actor.shape.shadowDraw = NULL; + this->actor.flags &= ~1; + sp20.unk0 = 0; + } else { + this->actor.shape.shadowDraw = func_800B3FC0; + this->actor.flags |= 1; + } + this->unk_258 = sp20.unk0; + this->unk_268 = func_8094F074(this, globalCtx); + func_80950C24(this, globalCtx); +} + +void func_80950DB8(EnGm* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + Actor* al; + + if (func_8010BF58(&this->actor, globalCtx, this->unk_264, this->unk_3E4, &this->unk_25C)) { + func_8013AED4(&this->unk_3A4, 3, 7); + al = func_8094DEE0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AL); + if ((this->unk_258 == 2) && (al != NULL) && (al->update != NULL)) { + this->unk_268 = al; + this->unk_3B8 = Rand_S16Offset(60, 60); + } else { + this->unk_3A4 &= ~0x20; + } + this->unk_3A4 |= 0x200; + this->unk_3C6 = 20; + this->unk_25C = 0; + this->actionFunc = func_80950CDC; + } else if ((this->unk_258 != 1) && (this->unk_258 != 2) && (this->unk_258 != 3) && (this->unk_258 != 5) && + (this->unk_258 != 7)) { + if ((this->unk_268 != NULL) && (this->unk_268->update != NULL)) { + Math_Vec3f_Copy(&sp40, &this->unk_268->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + Math_ApproachS(&this->actor.shape.rot.y, Math_Vec3f_Yaw(&sp34, &sp40), 4, 0x2AA8); + } + } + func_8013D9C8(globalCtx, this->unk_3D8, this->unk_3D2, 3); +} + +void func_80950F2C(EnGm* this, GlobalContext* globalCtx) { + s32 sp50[] = { + 0, + 0, + 3, + 2, + }; + Player* player = GET_PLAYER(globalCtx); + s32 pad; + Vec3f sp3C; + Vec3f sp30; + s32 sp2C; + s16 yaw; + + if (func_800EE29C(globalCtx, 0x20E)) { + sp2C = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x20E)]->unk0; + if (this->unk_259 != (sp2C & 0xFF)) { + if (sp2C == 3) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHAIR_ROLL); + } + this->unk_259 = sp2C; + func_8094E054(this, globalCtx, sp50[sp2C]); + } + + if ((this->unk_259 == 3) && (this->unk_268 != NULL) && (this->unk_268->update != NULL)) { + Math_Vec3f_Copy(&sp3C, &player->actor.world.pos); + Math_Vec3f_Copy(&sp30, &this->actor.world.pos); + yaw = Math_Vec3f_Yaw(&sp30, &sp3C); + if ((this->actor.shape.rot.y / 0x16C) != (yaw / 0x16C)) { + Math_ApproachS(&this->actor.shape.rot.y, yaw, 3, 0x2AA8); + this->unk_3A4 &= ~0x20; + } else { + this->actor.shape.rot.y = yaw; + } + } + } +} + +void EnGm_Init(Actor* thisx, GlobalContext* globalCtx) { + EnGm* this = THIS; + + if (func_8094DEE0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_GM)) { + Actor_MarkForDeath(&this->actor); + return; + } + + ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 22.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_060078B0, NULL, this->jointTable, this->morphTable, 20); + this->unk_3E8 = -1; + func_8094E054(this, globalCtx, 0); + Collider_InitAndSetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); + Collider_InitAndSetSphere(globalCtx, &this->colliderSphere, &this->actor, &sSphereInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); + Actor_SetScale(&this->actor, 0.01f); + this->actor.room = -1; + this->unk_260 = -128; + this->unk_3FC = 0; + this->unk_258 = 0; + this->actionFunc = func_80950CDC; + this->actionFunc(this, globalCtx); +} + +void EnGm_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnGm* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); + Collider_DestroySphere(globalCtx, &this->colliderSphere); +} + +void EnGm_Update(Actor* thisx, GlobalContext* globalCtx) { + EnGm* this = THIS; + + if (!func_8094E0F8(this, globalCtx)) { + if (!func_8094EE84(this, globalCtx) && func_8094EFC4(this, globalCtx)) { + func_80950F2C(this, globalCtx); + func_8094DFF8(this, globalCtx); + func_8094E2D0(this); + return; + } + + this->actionFunc(this, globalCtx); + + func_8094F53C(this, globalCtx); + + if (this->unk_258 != 0) { + func_8094DFF8(this, globalCtx); + func_8094E2D0(this); + func_8094F2E8(this); + func_8013C964(&this->actor, globalCtx, this->unk_3B4, 30.0f, 0, this->unk_3A4 & 7); + if ((this->unk_258 != 3) && (this->unk_258 != 5) && (this->unk_258 != 8)) { + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); + } + func_8094E1DC(this, globalCtx); + } + } +} + +s32 func_809513AC(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + s32 pad; + EnGm* this = THIS; + s32 phi_v0; + + if (limbIndex == 16) { + func_8094F3D0(this, globalCtx); + } + + switch (limbIndex) { + case 9: + phi_v0 = 0; + break; + + case 10: + phi_v0 = 1; + break; + + case 13: + phi_v0 = 2; + break; + + default: + phi_v0 = 9; + break; + } + + if ((this->unk_3A4 & 0x2000) && (phi_v0 < 9)) { + rot->y += (s16)(Math_SinS(this->unk_3D8[phi_v0]) * 200.0f); + rot->z += (s16)(Math_CosS(this->unk_3D2[phi_v0]) * 200.0f); + } + + return false; +} + +void func_809514BC(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f D_80951E24 = { 1400.0f, 0.0f, 0.0f }; + EnGm* this = THIS; + s32 pad[4]; + Vec3f sp30; + s32 pad2; + + if ((ActorCutscene_GetCurrentIndex() == -1) && (limbIndex == 16)) { + Matrix_MultiplyVector3fByState(&D_80951E24, &this->actor.focus.pos); + Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); + } + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if ((limbIndex == 15) && (this->unk_3A4 & 0x800)) { + gSPDisplayList(POLY_OPA_DISP++, D_06007528); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + if (limbIndex == 9) { + Matrix_MultiplyVector3fByState(&D_801D15B0, &sp30); + Math_Vec3f_ToVec3s(&this->colliderSphere.dim.worldSphere.center, &sp30); + } +} + +void func_80951594(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + EnGm* this = THIS; + s32 phi_v0 = 1; + s32 phi_v1 = 0; + + if (!(this->unk_3A4 & 0x200)) { + if (this->unk_3A4 & 0x80) { + phi_v0 = 1; + phi_v1 = 1; + } else { + phi_v0 = 0; + phi_v1 = 1; + } + } else { + phi_v0 = 0; + } + + if (limbIndex == 16) { + func_8013AD9C(BINANG_ADD(this->unk_3BC + this->unk_3C0, 0x4000), + BINANG_ADD(this->unk_3BE + this->unk_3C2 + this->actor.shape.rot.y, 0x4000), &this->unk_290, + &this->unk_2A8, phi_v1, phi_v0); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_290.x, this->unk_290.y, this->unk_290.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_2A8.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_2A8.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_2A8.z, MTXMODE_APPLY); + Matrix_StatePush(); + } else if (limbIndex == 9) { + func_8013AD9C(BINANG_ADD(this->unk_3C0, 0x4000), BINANG_ADD(this->unk_3C2 + this->actor.shape.rot.y, 0x4000), + &this->unk_29C, &this->unk_2AE, phi_v1, phi_v0); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_29C.x, this->unk_29C.y, this->unk_29C.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_2AE.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_2AE.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_2AE.z, MTXMODE_APPLY); + Matrix_StatePush(); + } +} + +void EnGm_Draw(Actor* thisx, GlobalContext* globalCtx) { + static UNK_PTR D_80951E30[] = { &D_060054A8, &D_06005028, &D_06006828, &D_06005028, &D_06005CE8, &D_06006C68 }; + EnGm* this = THIS; + + if ((this->unk_258 != 0) && (this->unk_262 >= 0)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80951E30[this->unk_3CE])); + + func_801343C0(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_809513AC, func_809514BC, func_80951594, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Gm/z_en_gm.h b/src/overlays/actors/ovl_En_Gm/z_en_gm.h index 1772547112..63b6b8f570 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.h +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.h @@ -6,12 +6,74 @@ struct EnGm; typedef void (*EnGmActionFunc)(struct EnGm*, GlobalContext*); +typedef s32 (*EnGmUnkFunc)(struct EnGm*, GlobalContext*); +typedef void (*EnGmUnkFunc2)(struct EnGm*, GlobalContext*); + +#define ENGM_GET_FF(thisx) ((thisx)->params & 0xFF) typedef struct EnGm { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnGmActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x278]; + /* 0x018C */ EnGmUnkFunc2 unk_18C; + /* 0x0190 */ ColliderCylinder colliderCylinder; + /* 0x01DC */ ColliderSphere colliderSphere; + /* 0x0234 */ Path* unk_234; + /* 0x0238 */ Vec3f unk_238; + /* 0x0244 */ f32 unk_244; + /* 0x0248 */ s32 unk_248; + /* 0x024C */ s32 unk_24C; + /* 0x0250 */ s32 unk_250; + /* 0x0254 */ s32 unk_254; + /* 0x0258 */ u8 unk_258; + /* 0x0259 */ u8 unk_259; + /* 0x025C */ s32 unk_25C; + /* 0x0260 */ s8 unk_260; + /* 0x0261 */ s8 unk_261; + /* 0x0262 */ s8 unk_262; + /* 0x0264 */ s32* unk_264; + /* 0x0268 */ Actor* unk_268; + /* 0x026C */ UNK_TYPE1 unk26C[0xC]; + /* 0x0278 */ Vec3f unk_278; + /* 0x0284 */ Vec3f unk_284; + /* 0x0290 */ Vec3f unk_290; + /* 0x029C */ Vec3f unk_29C; + /* 0x02A8 */ Vec3s unk_2A8; + /* 0x02AE */ Vec3s unk_2AE; + /* 0x02B4 */ Vec3s jointTable[20]; + /* 0x032C */ Vec3s morphTable[20]; + /* 0x03A4 */ u16 unk_3A4; + /* 0x03A6 */ u16 unk_3A6; + /* 0x03A8 */ f32 unk_3A8; + /* 0x03AC */ f32 unk_3AC; + /* 0x03B0 */ f32 unk_3B0; + /* 0x03B4 */ f32 unk_3B4; + /* 0x03B8 */ s16 unk_3B8; + /* 0x03BA */ s16 unk_3BA; + /* 0x03BC */ s16 unk_3BC; + /* 0x03BE */ s16 unk_3BE; + /* 0x03C0 */ s16 unk_3C0; + /* 0x03C2 */ s16 unk_3C2; + /* 0x03C4 */ s16 unk_3C4; + /* 0x03C6 */ s16 unk_3C6; + /* 0x03C8 */ s16 unk_3C8; + /* 0x03CA */ s16 unk_3CA; + /* 0x03CC */ s16 unk_3CC; + /* 0x03CE */ s16 unk_3CE; + /* 0x03D0 */ s16 unk_3D0; + /* 0x03D2 */ s16 unk_3D2[3]; + /* 0x03D8 */ s16 unk_3D8[3]; + /* 0x03DE */ s16 unk_3DE; + /* 0x03E0 */ s16 unk_3E0; + /* 0x03E2 */ s16 unk_3E2; + /* 0x03E4 */ EnGmUnkFunc unk_3E4; + /* 0x03E8 */ s32 unk_3E8; + /* 0x03EC */ UNK_TYPE1 unk3EC[0x4]; + /* 0x03F0 */ s32 unk_3F0; + /* 0x03F4 */ s32 unk_3F4; + /* 0x03F8 */ s32 unk_3F8; + /* 0x03FC */ s32 unk_3FC; + /* 0x0400 */ s32 unk_400; } EnGm; // size = 0x404 extern const ActorInit En_Gm_InitVars; diff --git a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c index e06c886893..22ea6a953e 100644 --- a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c +++ b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c @@ -472,17 +472,18 @@ s32 func_8093F6F8(EnGoroiwa* this, GlobalContext* globalCtx) { this->unk_1C4 = 0.0f; if (!(this->unk_1E5 & 0x20)) { - CollisionPoly* sp6C; + CollisionPoly* poly; Vec3f sp60; s32 pad[2]; - s32 sp54; + s32 bgId; Vec3f sp48; sp60.x = this->actor.world.pos.x; sp60.y = this->actor.world.pos.y + 50.0f; sp60.z = this->actor.world.pos.z; - temp_f14 = func_800C4188(globalCtx, &globalCtx->colCtx, &sp6C, &sp54, &this->actor, &sp60); + temp_f14 = + BgCheck_EntityRaycastFloor5_2(globalCtx, &globalCtx->colCtx, &poly, &bgId, &this->actor, &sp60); temp_f2 = temp_f14 - this->actor.world.pos.y; if (fabsf(temp_f2) < (fabsf(this->actor.velocity.y) + 0.01f)) { @@ -513,8 +514,8 @@ s32 func_8093F6F8(EnGoroiwa* this, GlobalContext* globalCtx) { WaterBox* sp44; f32 sp40; - if (func_800CA1E8(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp40, - &sp44)) { + if (WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &sp40, &sp44)) { if ((this->actor.world.pos.y + this->unk_1DC) <= sp40) { this->unk_1E5 |= 0x20; if (sp40 < (this->unk_1DC + sp78)) { @@ -1367,7 +1368,7 @@ void func_8094220C(EnGoroiwa* this, GlobalContext* globalCtx) { spC4.y = ptr->unk_00.y + 25.0f; spC4.z = ptr->unk_00.z; - ptr->unk_18 = func_800C411C(&globalCtx->colCtx, &ptr->unk_28, &spD0, &this->actor, &spC4); + ptr->unk_18 = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &ptr->unk_28, &spD0, &this->actor, &spC4); if (ptr->unk_10 <= 0.0f) { Matrix_InsertRotation(ptr->unk_1C, ptr->unk_1E, ptr->unk_20, 0); @@ -1449,7 +1450,7 @@ void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnGoroiwa* this = THIS; Player* player = GET_PLAYER(globalCtx); - s32 sp60; + s32 bgId; s32 sp5C = false; Vec3f sp50; f32 sp4C; @@ -1511,10 +1512,10 @@ void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx) { sp50.x = this->actor.world.pos.x; sp50.y = this->actor.world.pos.y + 50.0f; sp50.z = this->actor.world.pos.z; - this->actor.floorHeight = - func_800C411C(&globalCtx->colCtx, &this->actor.floorPoly, &sp60, &this->actor, &sp50); + this->actor.floorHeight = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, + &bgId, &this->actor, &sp50); if (this->actor.floorHeight > BGCHECK_Y_MIN) { - this->actor.floorBgId = sp60; + this->actor.floorBgId = bgId; if (this->actor.world.pos.y <= (this->actor.floorHeight + 2.0f)) { this->actor.bgCheckFlags |= 1; } else { diff --git a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c index 71e0c8cd0b..14a2ac839e 100644 --- a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c +++ b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c @@ -339,12 +339,12 @@ void EnGuruguru_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.params == 2) { if (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 100.0f) { - func_801A1DB8(&this->actor.projectedPos, 0x2E, 540.0f); + func_801A1DB8(&this->actor.projectedPos, NA_BGM_SONG_OF_STORMS, 540.0f); } return; } if (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 200.0f) { - func_801A1D44(&this->actor.projectedPos, 0x2E, 540.0f); + func_801A1D44(&this->actor.projectedPos, NA_BGM_SONG_OF_STORMS, 540.0f); } if (this->unusedTimer != 0) { this->unusedTimer--; diff --git a/src/overlays/actors/ovl_En_Heishi/z_en_heishi.c b/src/overlays/actors/ovl_En_Heishi/z_en_heishi.c index f25e8f7905..229c1b65dd 100644 --- a/src/overlays/actors/ovl_En_Heishi/z_en_heishi.c +++ b/src/overlays/actors/ovl_En_Heishi/z_en_heishi.c @@ -1,7 +1,7 @@ /* * File: z_en_heishi.c * Overlay: ovl_En_Heishi - * Description: Soldier + * Description: Soldier (Mayor's Residence only) */ #include "z_en_heishi.h" diff --git a/src/overlays/actors/ovl_En_Hg/z_en_hg.c b/src/overlays/actors/ovl_En_Hg/z_en_hg.c index e5a4448d04..d7eec060d9 100644 --- a/src/overlays/actors/ovl_En_Hg/z_en_hg.c +++ b/src/overlays/actors/ovl_En_Hg/z_en_hg.c @@ -364,7 +364,7 @@ void func_80BCFC0C(EnHg* this, GlobalContext* globalCtx) { } if (globalCtx->msgCtx.unk1202A == 3) { if (globalCtx->msgCtx.unk1202E == 7 && gSaveContext.playerForm == PLAYER_FORM_HUMAN) { - if (INV_CONTENT(0x41) == 0x41) { + if (INV_CONTENT(ITEM_MASK_GIBDO) == ITEM_MASK_GIBDO) { this->unk218 = 3; } else { this->unk218 = 1; diff --git a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c index a54b018618..1793384019 100644 --- a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c +++ b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c @@ -1,7 +1,7 @@ /* * File: z_en_hgo.c * Overlay: ovl_En_Hgo - * Description: Pamela's Father As a Gibdo + * Description: Pamela's Father (Gibdo) */ #include "z_en_hgo.h" diff --git a/src/overlays/actors/ovl_En_Hit_Tag/z_en_hit_tag.c b/src/overlays/actors/ovl_En_Hit_Tag/z_en_hit_tag.c index 0e61a4937e..3c7eac5ae8 100644 --- a/src/overlays/actors/ovl_En_Hit_Tag/z_en_hit_tag.c +++ b/src/overlays/actors/ovl_En_Hit_Tag/z_en_hit_tag.c @@ -14,9 +14,8 @@ void EnHitTag_Init(Actor* thisx, GlobalContext* globalCtx); void EnHitTag_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnHitTag_Update(Actor* thisx, GlobalContext* globalCtx); -void func_80BE20E8(EnHitTag* this, GlobalContext* globalCtx); +void EnHitTag_WaitForHit(EnHitTag* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Hit_Tag_InitVars = { ACTOR_EN_HIT_TAG, ACTORCAT_ITEMACTION, @@ -29,21 +28,65 @@ const ActorInit En_Hit_Tag_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BE21F0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 16, 32, 0, { 0, 0, 0 } }, }; -#endif +void EnHitTag_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnHitTag* this = THIS; -extern ColliderCylinderInit D_80BE21F0; + Actor_SetScale(&this->actor, 1.0f); + this->actionFunc = EnHitTag_WaitForHit; + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_UpdateCylinder(&this->actor, &this->collider); + if (Flags_GetSwitch(globalCtx, ENHITTAG_GET_SWITCHFLAG(thisx))) { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hit_Tag/EnHitTag_Init.s") +void EnHitTag_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHitTag* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hit_Tag/EnHitTag_Destroy.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hit_Tag/func_80BE20E8.s") +void EnHitTag_WaitForHit(EnHitTag* this, GlobalContext* globalCtx) { + Vec3f dropLocation; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hit_Tag/EnHitTag_Update.s") + if (this->collider.base.acFlags & AC_HIT) { + play_sound(NA_SE_SY_GET_RUPY); + Actor_MarkForDeath(&this->actor); + dropLocation.x = this->actor.world.pos.x; + dropLocation.y = this->actor.world.pos.y; + dropLocation.z = this->actor.world.pos.z; + + for (i = 0; i < 3; i++) { + Item_DropCollectible(globalCtx, &dropLocation, ITEM00_RUPEE_GREEN); + } + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void EnHitTag_Update(Actor* thisx, GlobalContext* globalCtx) { + EnHitTag* this = THIS; + this->actionFunc(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_En_Hit_Tag/z_en_hit_tag.h b/src/overlays/actors/ovl_En_Hit_Tag/z_en_hit_tag.h index 9af7edf1fe..2117cb27d9 100644 --- a/src/overlays/actors/ovl_En_Hit_Tag/z_en_hit_tag.h +++ b/src/overlays/actors/ovl_En_Hit_Tag/z_en_hit_tag.h @@ -7,9 +7,11 @@ struct EnHitTag; typedef void (*EnHitTagActionFunc)(struct EnHitTag*, GlobalContext*); +#define ENHITTAG_GET_SWITCHFLAG(thisx) (s32)(((thisx)->params & 0xFE00) >> 9) + typedef struct EnHitTag { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4C]; + /* 0x0144 */ ColliderCylinder collider; /* 0x0190 */ EnHitTagActionFunc actionFunc; } EnHitTag; // size = 0x194 diff --git a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c index 8eca23a7c8..423acc7bfc 100644 --- a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c +++ b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c @@ -1,7 +1,7 @@ /* * File: z_en_horse_game_check.c * Overlay: ovl_En_Horse_Game_Check - * Description: + * Description: Dirt patches you can jump over on Gorman Race Track */ #include "z_en_horse_game_check.h" diff --git a/src/overlays/actors/ovl_En_Hs2/z_en_hs2.c b/src/overlays/actors/ovl_En_Hs2/z_en_hs2.c index 3bc939d746..7efec2c4d3 100644 --- a/src/overlays/actors/ovl_En_Hs2/z_en_hs2.c +++ b/src/overlays/actors/ovl_En_Hs2/z_en_hs2.c @@ -1,7 +1,7 @@ /* * File: z_en_hs2.c * Overlay: ovl_En_Hs2 - * Description: Blue Target Spot + * Description: Blue Target Spot (?) */ #include "z_en_hs2.h" diff --git a/src/overlays/actors/ovl_En_In/z_en_in.c b/src/overlays/actors/ovl_En_In/z_en_in.c index 381dd693f8..910f7fc7bf 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -1,5 +1,5 @@ /* - * File z_en_in.c + * File: z_en_in.c * Overlay: ovl_En_In * Description: Gorman Bros */ @@ -187,7 +187,7 @@ static ActorAnimationEntryS sAnimations[] = { { &D_0601B3C4, 0.0f, 0, -1, 2, 0 }, { &D_0601B3C4, 1.0f, 0, -1, 0, -4 }, { &D_06019EB4, 1.0f, 0, -1, 2, -4 }, }; -static s16 D_808F6C0C[] = { +static u16 D_808F6C0C[] = { 4000, 4, 1, 3, 6000, 4, 1, 6, 4000, 4, 1, 3, 6000, 4, 1, 6, }; @@ -215,11 +215,11 @@ s32 func_808F3178(EnIn* this, GlobalContext* globalCtx) { this->unk260 = tmp = func_8013DB90(globalCtx, &this->unk248, -6.0f); if (this->unk260 != 0 && prevUnk260 == 0 && tmp & 0xFF) { - Audio_PlayActorSound2(&this->actor, 0x802); + Audio_PlayActorSound2(&this->actor, NA_SE_PL_WALK_CONCRETE); } this->unk261 = tmp = func_8013DB90(globalCtx, &this->unk254, -6.0f); if (this->unk261 != 0 && prevUnk261 == 0 && tmp & 0xFF) { - Audio_PlayActorSound2(&this->actor, 0x802); + Audio_PlayActorSound2(&this->actor, NA_SE_PL_WALK_CONCRETE); } return 0; } @@ -285,15 +285,15 @@ void func_808F3414(EnIn* this, GlobalContext* globalCtx) { sp30.x = player->actor.world.pos.x; sp30.y = player->bodyPartsPos[7].y + 3.0f; sp30.z = player->actor.world.pos.z; - func_8013D2E0(&sp30, &this->actor.focus, &this->actor.shape, &this->unk352, &this->unk358, &this->unk35E, - D_808F6C0C); + func_8013D2E0(&sp30, &this->actor.focus.pos, &this->actor.shape.rot, &this->unk352, &this->unk358, + &this->unk35E, D_808F6C0C); } else { - Math_SmoothStepToS(&this->unk352, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk354, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk358, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk35A, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk35E, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk360, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->unk352.x, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->unk352.y, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->unk358.x, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->unk358.y, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->unk35E.x, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->unk35E.y, 0, 4, 1000, 1); } func_808F322C(this, 3); func_808F3178(this, globalCtx); @@ -330,7 +330,7 @@ void func_808F3618(EnIn* this, GlobalContext* globalCtx) { void func_808F3690(EnIn* this, GlobalContext* globalCtx) { s16 sp36; - Vec3f sp28; // unsure if Vec3f, but it is probably size 0xC + Vec3f sp28; Math_SmoothStepToF(&this->actor.speedXZ, 1.0f, 0.4f, 1000.0f, 0.0f); sp36 = this->actor.speedXZ * 400.0f; @@ -860,7 +860,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 0x3475: SET_FLAGS_START_RACE; - func_800FD750(0x40); + func_800FD750(NA_BGM_HORSE); globalCtx->nextEntranceIndex = 0xCE50; globalCtx->unk_1887F = 5; globalCtx->sceneLoadFlag = 0x14; @@ -1107,7 +1107,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 0x3475: SET_FLAGS_START_RACE; - func_800FD750(0x40); + func_800FD750(NA_BGM_HORSE); globalCtx->nextEntranceIndex = 0xCE50; globalCtx->unk_1887F = 5; globalCtx->sceneLoadFlag = 0x14; @@ -1566,14 +1566,14 @@ s32 EnIn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, if (limbIndex == 16) { Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk35A, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->unk358, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk358.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-this->unk358.x, MTXMODE_APPLY); Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); func_808F6334(this, globalCtx); } if (limbIndex == 9) { - Matrix_RotateY(this->unk360, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk35E, MTXMODE_APPLY); + Matrix_RotateY(this->unk35E.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk35E.x, MTXMODE_APPLY); } if (limbIndex == 9 || limbIndex == 10 || limbIndex == 13) { rot->y += (s16)(Math_SinS(this->unk376[limbIndex]) * 200.0f); diff --git a/src/overlays/actors/ovl_En_In/z_en_in.h b/src/overlays/actors/ovl_En_In/z_en_in.h index ca67df4311..0a6f4be750 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.h +++ b/src/overlays/actors/ovl_En_In/z_en_in.h @@ -36,15 +36,10 @@ typedef struct EnIn { /* 0x261 */ u8 unk261; /* 0x262 */ Vec3s jointTable[20]; /* 0x2DA */ Vec3s morphTable[20]; - /* 0x352 */ s16 unk352; - /* 0x354 */ s16 unk354; - /* 0x356 */ char unk356[0x2]; - /* 0x358 */ s16 unk358; - /* 0x35A */ s16 unk35A; - /* 0x35C */ char unk35C[0x2]; - /* 0x35E */ s16 unk35E; - /* 0x360 */ s16 unk360; - /* 0x362 */ char unk362[0x14]; + /* 0x352 */ Vec3s unk352; + /* 0x358 */ Vec3s unk358; + /* 0x35E */ Vec3s unk35E; + /* 0x364 */ char unk364[0x12]; /* 0x376 */ s16 unk376[20]; /* 0x39E */ s16 unk39E[20]; /* 0x3C6 */ char unk3C6[0xBC]; diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index 42b9a6c91e..2d29831022 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -1,9 +1,9 @@ /* - * File z_en_invadepoh.c + * File: z_en_invadepoh.c * Overlay: ovl_En_Invadepoh * Description: Ranch nighttime actors */ - +#include "prevent_bss_reordering.h" #include "z_en_invadepoh.h" #include "overlays/actors/ovl_En_Door/z_en_door.h" @@ -906,7 +906,7 @@ s32 func_80B44234(EnInvadepoh* this, Vec3f* vec) { for (i = 0, arr = this->pathPoints; i < temp_s3; i++, arr++) { Math_Vec3s_ToVec3f(&sp48, arr); - distance = Math3D_DistanceSquared(&sp48, vec); + distance = Math3D_Vec3fDistSq(&sp48, vec); if (distance < min) { min = distance; ret = i; @@ -1384,8 +1384,8 @@ s32 func_80B45550(EnInvadepoh* this, GlobalContext* globalCtx, f32 range, s32 ar while (actorIterator != NULL) { if ((actorIterator->id == ACTOR_EN_DOOR) && (actorIterator->update != NULL) && (actorIterator->room == this->actor.room) && - Math3D_DistanceSquared(&actorIterator->world.pos, &this->actor.world.pos) < range) { - ((EnDoor*)actorIterator)->unk1A7 = arg3; + Math3D_Vec3fDistSq(&actorIterator->world.pos, &this->actor.world.pos) < range) { + ((EnDoor*)actorIterator)->unk_1A7 = arg3; retVal = true; break; } @@ -1435,7 +1435,7 @@ void func_80B457A0(EnInvadepoh* this) { for (i = 0; i < this->unk379; i++) { if ((D_80B50320[i] != NULL) && D_80B50320[i]->drawAlien) { - distanceSquared = Math3D_DistanceSquared(&D_80B50320[i]->actor.world.pos, &this->actor.world.pos); + distanceSquared = Math3D_Vec3fDistSq(&D_80B50320[i]->actor.world.pos, &this->actor.world.pos); if (distanceSquared < phi_f20) { phi_f20 = distanceSquared; phi_s5 = i; @@ -1699,7 +1699,7 @@ void func_80B4627C(EnInvadepoh* this, GlobalContext* globalCtx) { } else { func_80B454BC(this, globalCtx); func_80B452EC(this, globalCtx); - Audio_QueueSeqCmd(0x800D); + Audio_QueueSeqCmd(NA_BGM_ALIEN_INVASION | 0x8000); func_80B46F88(this); } } else if (D_80B4E940 == 3) { @@ -1987,7 +1987,7 @@ void func_80B46EE8(EnInvadepoh* this, GlobalContext* globalCtx) { this->actionTimer--; if (this->actionTimer <= 0) { ActorCutscene_Stop(D_80B50404[0]); - Audio_QueueSeqCmd(0x800D); + Audio_QueueSeqCmd(NA_BGM_ALIEN_INVASION | 0x8000); func_80B46F88(this); } } @@ -2036,7 +2036,7 @@ void func_80B470E0(EnInvadepoh* this) { void func_80B47108(EnInvadepoh* this, GlobalContext* globalCtx) { if (this->actionTimer == 100) { - func_801A3098(0x19); + func_801A3098(NA_BGM_CLEAR_EVENT); } this->actionTimer--; if (this->actionTimer <= 0) { @@ -2880,7 +2880,7 @@ void func_80B49454(EnInvadepoh* this, GlobalContext* globalCtx) { } Math_Vec3f_Sum(&D_80B4EDD0[this->unk3AC], &this->actor.home.pos, &sp30); - if (Math3D_DistanceSquared(&this->actor.world.pos, &sp30) < SQ(400.0f)) { + if (Math3D_Vec3fDistSq(&this->actor.world.pos, &sp30) < SQ(400.0f)) { this->actor.speedXZ *= 0.8f; } else { Math_StepToF(&this->actor.speedXZ, 170.0f, 21.0f); @@ -3614,7 +3614,7 @@ void func_80B4B564(EnInvadepoh* this, GlobalContext* globalCtx) { if (this->unk3BC >= 0) { Math_Vec3s_ToVec3f(&sp28, &this->pathPoints[this->unk3BC]); - temp_f0 = Math3D_DistanceSquared(&this->actor.world.pos, &sp28); + temp_f0 = Math3D_Vec3fDistSq(&this->actor.world.pos, &sp28); if (temp_f0 < SQ(80.0f)) { this->actor.speedXZ *= 0.85f; } else if (temp_f0 < SQ(150.0f)) { @@ -3808,7 +3808,7 @@ void func_80B4BC4C(EnInvadepoh* this, GlobalContext* globalCtx) { func_800B4AEC(globalCtx, &this->actor, 50.0f); func_80B4516C(this); Math_StepToS(&this->behaviorInfo.unk4C, 0xBB8, 0x1F5); - if (Math3D_DistanceSquared(&this->actor.prevPos, &this->actor.world.pos) > SQ(0.01f)) { + if (Math3D_Vec3fDistSq(&this->actor.prevPos, &this->actor.world.pos) > SQ(0.01f)) { Math_SmoothStepToS(&this->actor.shape.rot.y, Math_Vec3f_Yaw(&this->actor.prevPos, &this->actor.world.pos), 3, this->behaviorInfo.unk4C, 0x1F4); } diff --git a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c index 0843cb87b8..a7ed2025a7 100644 --- a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c +++ b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c @@ -1,7 +1,7 @@ /* * File: z_en_ishi.c * Overlay: ovl_En_Ishi - * Description: Rock + * Description: Liftable rocks and silver boulders */ #include "z_en_ishi.h" diff --git a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c index 0617bcdd37..631fc26e59 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -1,7 +1,7 @@ /* * File: z_en_kakasi.c * Overlay: ovl_En_Kakasi - * Description: Pierre + * Description: Pierre the Scarecorw */ #include "z_en_kakasi.h" @@ -15,28 +15,55 @@ void EnKakasi_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnKakasi_Update(Actor* thisx, GlobalContext* globalCtx); void EnKakasi_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_8096FCC4(EnKakasi* this, GlobalContext* globalCtx); -void func_8096FE00(EnKakasi* this, GlobalContext* globalCtx); -void func_8097006C(EnKakasi* this, GlobalContext* globalCtx); -void func_80970658(EnKakasi* this, GlobalContext* globalCtx); -void func_80970740(EnKakasi* this, GlobalContext* globalCtx); -void func_80970978(EnKakasi* this, GlobalContext* globalCtx); -void func_80970A9C(EnKakasi* this, GlobalContext* globalCtx); -void func_80970F20(EnKakasi* this, GlobalContext* globalCtx); -void func_80971064(EnKakasi* this, GlobalContext* globalCtx); -void func_80971430(EnKakasi* this, GlobalContext* globalCtx); -void func_809714BC(EnKakasi* this, GlobalContext* globalCtx); -void func_809717D0(EnKakasi* this, GlobalContext* globalCtx); -void func_8097185C(EnKakasi* this, GlobalContext* globalCtx); -void func_8097193C(EnKakasi* this, GlobalContext* globalCtx); -void func_80971A64(EnKakasi* this, GlobalContext* globalCtx); -void func_80971AD4(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_SetupPostSongLearnDialogue(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_InitTimeSkipDialogue(EnKakasi* this); +void EnKakasi_SetupIdleStanding(EnKakasi* this); + +void EnKakasi_8096F88C(GlobalContext* globalCtx, EnKakasi* this); + +void EnKakasi_TimeSkipDialogue(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_IdleStanding(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_OcarinaRemark(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_TeachingSong(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_PostSongLearnTwirl(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_PostSongLearnDialogue(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_SetupDigAway(EnKakasi* this); +void EnKakasi_DiggingAway(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_RisenDialogue(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_SetupIdleUnderground(EnKakasi* this); +void EnKakasi_IdleUnderground(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_SetupIdleRisen(EnKakasi* this); +void EnKakasi_IdleRisen(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_SetupRiseOutOfGround(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_RisingOutOfGround(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_DancingRemark(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_SetupDanceNightAway(EnKakasi* this); +void EnKakasi_DancingNightAway(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_DoNothing(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_RegularDialogue(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_SetupSongTeach(EnKakasi* this, GlobalContext* globalCtx); + +void EnKakasi_SetupDialogue(EnKakasi* this); + +void EnKakasi_LimbDraw(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, struct Actor* actor); -#if 0 -// static ColliderCylinderInit sCylinderInit = { static ColliderCylinderInit D_80971D80 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 20, 70, 0, { 0, 0, 0 } }, }; @@ -52,80 +79,1092 @@ const ActorInit En_Kakasi_InitVars = { (ActorFunc)EnKakasi_Draw, }; -#endif +static Vec3f D_80971DCC[] = { + { 0.0f, 60.0f, 60.0f }, { 40.0f, 40.0f, 50.0f }, { -40.0f, 40.0f, 50.0f }, + { 40.0f, 20.0f, 110.0f }, { -40.0f, 20.0f, 110.0f }, { 0.0f, 80.0f, 60.0f }, + { 50.0f, 40.0f, -30.0f }, { -50.0f, 40.0f, -30.0f }, { 0.0f, 50.0f, 60.0f }, +}; +Vec3f D_80971E38[] = { + { 0.0f, 55.0f, 60.0f }, { 0.0f, 55.0f, 60.0f }, { -80.0f, 35.0f, 15.0f }, { 80.0f, 45.0f, 15.0f }, + { -10.0f, 35.0f, 65.0f }, { 0.0f, 110.0f, 180.0f }, { 0.0f, 60.0f, 70.0f }, { 0.0f, 60.0f, 70.0f }, + { -80.0f, 50.0f, 40.0f }, { 0.0f, -10.0f, 50.0f }, { 80.0f, 50.0f, 40.0f }, { 0.0f, 120.0f, 40.0f }, + { 0.0f, 28.0f, -50.0f }, { 0.0f, 60.0f, 50.0f }, { 0.0f, 80.0f, 160.0f }, +}; -extern ColliderCylinderInit D_80971D80; +Vec3f D_80971EEC[] = { + { 12.0f, 1.0f, 2.0f }, { 12.0f, 1.0f, 2.0f }, { 2.0f, -6.0f, 0.0f }, { 12.0f, -6.0f, -10.0f }, + { -88.0f, 14.0, -10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, + { 0.0f, -10.0f, 0.0f }, { 0.0f, -10.0f, 0.0f }, { 0.0f, -10.0f, 0.0f }, { 0.0f, -10.0f, 0.0f }, + { 0.0f, -10.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, +}; -extern UNK_TYPE D_06000214; +Vec3f D_80971FA0[] = { + { -50.0f, 160.0f, -40.0f }, { -50.0f, 160.0f, -40.0f }, { -20.0f, 80.0f, 60.0f }, + { 57.0f, 60.0f, 120.0f }, { 27.0f, 80.0f, 60.0f }, { -3.0f, 50.0f, 70.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/EnKakasi_Destroy.s") +Vec3f D_80971FE8[] = { + { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { -10.0f, -5.0f, 0.0f }, + { 10.0f, -10.0f, 7.0f }, { 20.0f, 5.0f, 2.0f }, { 10.0f, 5.0f, 2.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/EnKakasi_Init.s") +// both use in digging away function +Vec3f D_80972030 = { -3.0f, 50.0f, 90.0f }; +Vec3f D_8097203C = { 10.0f, -15.0f, 2.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_8096F800.s") +typedef enum { + /* 0x0 */ ENKAKASI_ANIM_ARMS_CROSSED_ROCKING, // arms crossed and rocking back and forth + /* 0x1 */ ENKAKASI_ANIM_SIDEWAYS_SHAKING, + /* 0x2 */ ENKAKASI_ANIM_HOPPING_REGULAR, // bounce bounce bounce (repeat) + /* 0x3 */ ENKAKASI_ANIM_SPIN_REACH_OFFER, // spin and then reaching toward player + /* 0x4 */ ENKAKASI_ANIM_TWIRL, // slower cinimatic twirl + /* 0x5 */ ENKAKASI_ANIM_ARMS_CROSSED_STILL, // arms crossed but still, also some noise sfx + /* 0x6 */ ENKAKASI_ANIM_WAVE, // "wave" short sideways shake, stops early, partial? unused? + /* 0x7 */ ENKAKASI_ANIM_SLOWROLL, // partial bounch, ends looking left, OFFER anim takes over + /* 0x8 */ ENKAKASI_ANIM_IDLE, // slow stretching wiggle, ends in regular position +} EnKakasi_Animations; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_8096F88C.s") +extern AnimationHeader D_06007444; +extern AnimationHeader D_0600686C; +extern AnimationHeader D_060081A4; +extern AnimationHeader D_06007B90; +extern AnimationHeader D_060071EC; +extern AnimationHeader D_06007444; +extern AnimationHeader D_0600686C; +extern AnimationHeader D_060081A4; +extern AnimationHeader D_06000214; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_8096F8D8.s") +static AnimationHeader* kakasiAnimations[] = { + &D_06007444, &D_0600686C, &D_060081A4, &D_06007B90, &D_060071EC, &D_06007444, &D_0600686C, &D_060081A4, &D_06000214, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_8096FA18.s") +static u8 sAnimModes[] = { ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE, + ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_ONCE }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_8096FAAC.s") +void EnKakasi_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnKakasi* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_8096FBB8.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_8096FC8C.s") +extern FlexSkeletonHeader D_060065B0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_8096FCC4.s") +void EnKakasi_Init(Actor* thisx, GlobalContext* globalCtx) { + EnKakasi* this = THIS; + s32 tempCutscene; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_8096FDE8.s") + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &D_80971D80); + SkelAnime_InitFlex(globalCtx, &this->skelanime, &D_060065B0, &D_06000214, 0, 0, 0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_8096FE00.s") + this->songSummonDist = GET_KAKASI_SUMMON_DISTANCE(this) * 20.0f; + if (this->songSummonDist < 40.0f) { + this->songSummonDist = 40.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_80970008.s") + this->unkHeight = (this->actor.world.rot.z * 20.0f) + 60.0f; + this->actor.world.rot.z = 0; + this->actor.targetMode = 0; + if (this->actor.world.rot.x > 0 && this->actor.world.rot.x < 8) { + this->actor.targetMode = this->actor.world.rot.x - 1; + } + this->actor.shape.rot.y = this->actor.world.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_8097006C.s") + this->aboveGroundStatus = GET_KAKASI_ABOVE_GROUND(this); + this->actor.world.rot.x = 0; + this->actor.flags |= 0x400; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + Actor_SetScale(&this->actor, 0.01f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_809705E4.s") + i = 0; + tempCutscene = this->actor.cutscene; + while (tempCutscene != -1) { + // This might be a fake match, no others found yet + tempCutscene = ActorCutscene_GetAdditionalCutscene(this->actorCutscenes[i] = tempCutscene); + i++; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_80970658.s") + if (this->aboveGroundStatus) { + if (gSaveContext.weekEventReg[79] & 0x8) { + this->aboveGroundStatus = ENKAKASI_ABOVE_GROUND_TYPE; + this->songSummonDist = 80.0f; + EnKakasi_SetupIdleUnderground(this); + } else { + Actor_SetHeight(&this->actor, 60.0f); + this->unkFunc = EnKakasi_8096F88C; + if (gSaveContext.weekEventReg[83] & 0x1) { + EnKakasi_InitTimeSkipDialogue(this); + } else { + EnKakasi_SetupIdleStanding(this); + } + } + } else { + EnKakasi_SetupIdleUnderground(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_80970740.s") +void EnKakasi_SetAnimation(EnKakasi* this, s32 index) { + this->animIndex = index; + this->animeFrameCount = Animation_GetLastFrame(&kakasiAnimations[this->animIndex]->common); + // 1: regular playback speed, 0: starting frame + Animation_Change(&this->skelanime, kakasiAnimations[this->animIndex], 1.0f, 0.0f, this->animeFrameCount, + sAnimModes[this->animIndex], -4.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_80970978.s") +/* + * set by init, called... nowhere? left over from OOT? + */ +void EnKakasi_8096F88C(GlobalContext* globalCtx, EnKakasi* this) { + func_8013A530(globalCtx, &this->actor, 0x7, &this->actor.focus.pos, &this->actor.shape.rot, 280.0f, 1800.0f, -1); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_80970A10.s") +void EnKakasi_CheckAnimationSfx(EnKakasi* this) { + if (this->animIndex == ENKAKASI_ANIM_SIDEWAYS_SHAKING || this->animIndex == ENKAKASI_ANIM_ARMS_CROSSED_STILL) { + if (Animation_OnFrame(&this->skelanime, 1.0f) || Animation_OnFrame(&this->skelanime, 8.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_KAKASHI_SWING); + } + } + if (this->animIndex == ENKAKASI_ANIM_HOPPING_REGULAR || this->animIndex == ENKAKASI_ANIM_SLOWROLL) { + if (Animation_OnFrame(&this->skelanime, 4.0f) || Animation_OnFrame(&this->skelanime, 8.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_KAKASHI_SWING); + } + if (Animation_OnFrame(&this->skelanime, 1.0f) || Animation_OnFrame(&this->skelanime, 9.0f) || + Animation_OnFrame(&this->skelanime, 16.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_IT_KAKASHI_JUMP); + } + if (Animation_OnFrame(&this->skelanime, 18.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_KAKASHI_ROLL); + } + } + if (this->animIndex == ENKAKASI_ANIM_SPIN_REACH_OFFER || this->animIndex == ENKAKASI_ANIM_TWIRL) { + if (Animation_OnFrame(&this->skelanime, 1.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_KAKASH_LONGI_ROLL); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_80970A9C.s") +/* + * moves the player's position relative to scarecrow during song teach, also each frame of dance the night away + */ +void EnKakasi_CheckPlayerPosition(EnKakasi* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_80970F20.s") + if (globalCtx->sceneNum == SCENE_8ITEMSHOP) { + player->actor.world.pos.x = -50.0f; + player->actor.world.pos.z = 155.0f; + } else if (globalCtx->sceneNum == SCENE_TENMON_DAI) { + player->actor.world.pos.x = 60.0f; + player->actor.world.pos.z = -190.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_80970FF8.s") + Math_SmoothStepToS(&player->actor.shape.rot.y, (this->actor.yawTowardsPlayer + 0x8000), 5, 1000, 0); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_80971064.s") +/* + * this goes off every frame of dancing the night away, and song teaching + * something to do with cutscene camera? + */ +void func_8096FAAC(EnKakasi* this, GlobalContext* globalCtx) { + if (this->cutsceneCamId != MAIN_CAM) { + Math_ApproachF(&this->unk214.x, this->unk238.x, 0.4f, 4.0f); + Math_ApproachF(&this->unk214.y, this->unk238.y, 0.4f, 4.0f); + Math_ApproachF(&this->unk214.z, this->unk238.z, 0.4f, 4.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_80971430.s") + Math_ApproachF(&this->unk220.x, this->unk244.x, 0.4f, 4.0f); + Math_ApproachF(&this->unk220.y, this->unk244.y, 0.4f, 4.0f); + Math_ApproachF(&this->unk220.z, this->unk244.z, 0.4f, 4.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_80971440.s") + Math_ApproachF(&this->unk20C, this->unk210, 0.3f, 10.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_809714BC.s") + Play_CameraSetAtEye(globalCtx, this->cutsceneCamId, &this->unk220, &this->unk214); + func_80169940(globalCtx, this->cutsceneCamId, this->unk20C); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_80971794.s") +/* + * goes off every frame of song teach, but... doing what? + */ +void func_8096FBB8(EnKakasi* this, GlobalContext* globalCtx) { + if (globalCtx->msgCtx.unk12048 == 0 || globalCtx->msgCtx.unk12048 == 1 || globalCtx->msgCtx.unk12048 == 2 || + globalCtx->msgCtx.unk12048 == 3 || globalCtx->msgCtx.unk12048 == 4) { + // why not 0 < x < 4? fewer branches + this->unk190++; + } + if (this->unk190 != 0 && this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); + } + if (this->unk190 > 8) { + this->unk190 = 8; + } + if (this->unk190 != 0) { + Math_ApproachF(&this->skelanime.playSpeed, 1.0f, 0.1f, 0.2f); + this->actor.shape.rot.y += 0x800; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_809717D0.s") +void EnKakasi_InitTimeSkipDialogue(EnKakasi* this) { + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SLOWROLL); + this->actionFunc = EnKakasi_TimeSkipDialogue; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_8097185C.s") +void EnKakasi_TimeSkipDialogue(EnKakasi* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_8097193C.s") + if (gSaveContext.respawnFlag != -4 && gSaveContext.respawnFlag != -8) { + if (gSaveContext.time != CLOCK_TIME(6, 0) && gSaveContext.time != CLOCK_TIME(18, 0) && + !(gSaveContext.eventInf[1] & 0x80)) { -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_80971A38.s") + if (this->actor.textId == 0) { + // dialogue after skipped time 'did you feel that? went by in an instant' + this->actor.textId = 0x1653; + gSaveContext.weekEventReg[0x53] &= (u8)~1; + this->unkMsgState1AC = 5; + player->stateFlags1 |= 0x20; + this->actor.flags |= 0x10000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_80971A64.s") + if (func_800B84D0(&this->actor, globalCtx) != 0) { + player->stateFlags1 &= ~0x20; + this->unkState196 = 2; + this->actor.flags &= ~0x10000; + this->actionFunc = EnKakasi_RegularDialogue; + } else { + func_800B8500(&this->actor, globalCtx, 9999.9f, 9999.9f, -1); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_80971AD4.s") +void EnKakasi_SetupIdleStanding(EnKakasi* this) { + this->unkState196 = 0; + this->actionFunc = EnKakasi_IdleStanding; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/EnKakasi_Update.s") +void EnKakasi_IdleStanding(EnKakasi* this, GlobalContext* globalCtx) { + u32 saveContextDay = gSaveContext.day; + s16 passedValue1; + s16 passedValue2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_80971CE0.s") + // first talk to scarecrow dialogue + this->actor.textId = 0x1644; + if (func_800B8718(&this->actor, globalCtx) != 0) { + this->skelanime.playSpeed = 1.0f; + EnKakasi_SetupSongTeach(this, globalCtx); + return; + } + if (func_800B84D0(&this->actor, globalCtx) != 0) { + this->skelanime.playSpeed = 1.0f; + EnKakasi_SetupDialogue(this); + return; + } + if (globalCtx->actorCtx.unk5 & 0x4) { + func_800B8898(globalCtx, &this->actor, &passedValue1, &passedValue2); + if (this->actor.projectedPos.z > -20.0f && passedValue1 > 0 && passedValue1 < 0x140 && passedValue2 > 0 && + passedValue2 < 0xF0 && this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { + // faster shaking + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); + this->skelanime.playSpeed = 2.0f; + } + } else if (Player_GetMask(globalCtx) == PLAYER_MASK_KAMARO) { + if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); + this->skelanime.playSpeed = 2.0f; + } + } else if (saveContextDay == 3 && gSaveContext.isNight) { + this->skelanime.playSpeed = 1.0f; + if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { + EnKakasi_SetAnimation(this, 1); + } + } else if (this->animIndex != ENKAKASI_ANIM_IDLE) { + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_IDLE); + } + if (this->actor.xzDistToPlayer < 120.0f) { + func_800B8614(&this->actor, globalCtx, 100.0f); + func_800B874C(&this->actor, globalCtx, 100.0f, 80.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/EnKakasi_Draw.s") +void EnKakasi_SetupDialogue(EnKakasi* this) { + // bug? starts one animation then changes it a few lines down? + if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); + } + + this->unkMsgState1AC = 5; + this->unkState196 = 1; + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SPIN_REACH_OFFER); + this->actionFunc = EnKakasi_RegularDialogue; +} + +void EnKakasi_RegularDialogue(EnKakasi* this, GlobalContext* globalCtx) { + u32 saveContextDay = gSaveContext.day; + f32 currentAnimeFrame = this->skelanime.curFrame; + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 2000, 0); + // if first dialogue + if (this->actor.textId != 0x1644 && this->animeFrameCount <= currentAnimeFrame && + this->animIndex == ENKAKASI_ANIM_SLOWROLL) { + + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SPIN_REACH_OFFER); + this->unkCounter1A4 = 0; + } + + // if dialogue: oh sorry come back again + if (this->actor.textId == 0x1651 || this->actor.textId == 0x1659) { + if (this->animeFrameCount <= currentAnimeFrame && this->animIndex != ENKAKASI_ANIM_SPIN_REACH_OFFER) { + if (++this->unkCounter1A4 >= 2) { + this->unkCounter1A4 = 0; + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SPIN_REACH_OFFER); + } + } + } + + if (this->unkState1A8 == 2 && this->unkState196 == 2) { + func_800B7298(globalCtx, &this->actor, 0x49); + this->unkState1A8 = 0; + } + + if (this->unkMsgState1AC == func_80152498(&globalCtx->msgCtx) && func_80147624(globalCtx) != 0) { + func_801477B4(globalCtx); + if (this->unkMsgState1AC == 5) { + // bad song input + if (this->unkState196 == 2 && this->actor.textId == 0x1647) { + func_800B7298(globalCtx, &this->actor, 6); + } + + // after timeskip + if (this->actor.textId == 0x1653) { + u32 saveContextDay2 = gSaveContext.day; + + if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); + } + + if (saveContextDay2 == 3 && gSaveContext.isNight) { + // text: dangerous outside + this->actor.textId = 0x164F; + } else if (gSaveContext.isNight) { + // text: would you like to skip time? + this->actor.textId = 0x164E; + } else { + // text: would you like to skip time? 2 + this->actor.textId = 0x1645; + } + + func_80151938(globalCtx, this->actor.textId); + return; + + } else if (this->actor.textId == 0x165D || this->actor.textId == 0x165F || this->actor.textId == 0x1660 || + this->actor.textId == 0x1652) { + func_800B7298(globalCtx, &this->actor, 4); + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->actorCutscenes[0]); + this->actionFunc = EnKakasi_DancingRemark; + } else { + if (!ActorCutscene_GetCanPlayNext(this->actorCutscenes[0])) { + ActorCutscene_SetIntentToPlay(this->actorCutscenes[0]); + this->actionFunc = EnKakasi_DancingRemark; + } else { + ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[0], &this->actor); + this->cutsceneCamId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + this->actionFunc = EnKakasi_DancingRemark; + } + } + return; + + } else if (this->actor.textId == 0x1645 || this->actor.textId == 0x164E) { + this->actor.textId = 0x1650; // "Shall we dance? No Yes" + if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); + } + this->unkMsgState1AC = 4; + + } else if (this->actor.textId == 0x1644) { + if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); + } + if (gSaveContext.isNight) { + this->actor.textId = 0x164E; + } else { + this->actor.textId = 0x1645; + } + + } else if (this->actor.textId == 0x164F) { + if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); + } + this->actor.textId = 0x165A; + } else if (this->actor.textId == 0x1651) { + if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); + } + this->actor.textId = 0x1654; + } else if (this->actor.textId == 0x1654) { + this->actor.textId = 0x1655; + } else if (this->actor.textId == 0x1655) { + this->actor.textId = 0x1656; + this->unkMsgState1AC = 4; + } else if (this->actor.textId == 0x1658) { + this->actor.textId = 0x1659; + } else if (this->actor.textId == 0x165A) { + this->actor.textId = 0x165B; + } else if (this->actor.textId == 0x165B) { + this->actor.textId = 0x165C; + this->unkMsgState1AC = 4; + + } else if (this->actor.textId == 0x165E) { + this->actor.textId = 0x165F; + } else { + EnKakasi_SetupIdleStanding(this); + return; + } + } else { + this->unkMsgState1AC = 5; + + if (globalCtx->msgCtx.choiceIndex == 1) { + func_8019F208(); + if (this->actor.textId == 0x1656) { + this->actor.textId = 0x1658; + } else if (this->actor.textId == 0x165C) { + this->actor.textId = 0x165E; + } else if (saveContextDay == 3 && gSaveContext.isNight) { + this->actor.textId = 0x164F; + } else { + this->actor.textId = 0x1652; + } + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_HOPPING_REGULAR); + } else { + func_8019F230(); + if (this->actor.textId == 0x1656) { // would you like to learn a song? yes/no + this->actor.textId = 0x1657; + } else if (this->actor.textId == 0x165C) { // would you like to learn a song? yes/no + this->actor.textId = 0x165D; + } else { + this->actor.textId = 0x1651; + } + this->unkCounter1A4 = 0; + if (this->animIndex != ENKAKASI_ANIM_ARMS_CROSSED_ROCKING) { + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_ARMS_CROSSED_ROCKING); + } + } + } + func_80151938(globalCtx, this->actor.textId); + } +} + +void EnKakasi_SetupSongTeach(EnKakasi* this, GlobalContext* globalCtx) { + this->actor.textId = 0x1646; + func_801518B0(globalCtx, this->actor.textId, &this->actor); + this->cutsceneCamId = MAIN_CAM; + this->unk20C = 0.0f; + this->unk210 = 60.0f; + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_TWIRL); + this->unkState196 = 2; + this->actionFunc = EnKakasi_OcarinaRemark; +} + +/* + * you took out ocarina hes talking about how he wants to hear you play him a song + * before actually teaching + */ +void EnKakasi_OcarinaRemark(EnKakasi* this, GlobalContext* globalCtx) { + if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx) != 0) { + func_80152434(globalCtx, 0x35); + this->unkState1A8 = 0; + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->actorCutscenes[0]); + this->actionFunc = EnKakasi_TeachingSong; + + } else if (ActorCutscene_GetCanPlayNext(this->actorCutscenes[0]) == 0) { + ActorCutscene_SetIntentToPlay(this->actorCutscenes[0]); + this->actionFunc = EnKakasi_TeachingSong; + + } else { + this->unkState1A8 = 1; + ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[0], &this->actor); + this->cutsceneCamId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + Math_Vec3f_Copy(&this->unk22C, &this->actor.home.pos); + this->actionFunc = EnKakasi_TeachingSong; + } + } +} + +void EnKakasi_TeachingSong(EnKakasi* this, GlobalContext* globalCtx) { + Vec3f tempVec; + + EnKakasi_CheckPlayerPosition(this, globalCtx); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 1, 3000, 0); + if (this->unkState1A8 == 0) { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->actorCutscenes[0]); + return; + } + if (ActorCutscene_GetCanPlayNext(this->actorCutscenes[0]) == 0) { + ActorCutscene_SetIntentToPlay(this->actorCutscenes[0]); + return; + } + ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[0], &this->actor); + this->cutsceneCamId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + Math_Vec3f_Copy(&this->unk22C, &this->actor.home.pos); + this->unkState1A8 = 1; + this->unkState1A8 = 1; + } + + if (this->unkState1A8 == 1) { + this->unk22C.y = this->actor.home.pos.y + 50.0f; + this->unk238.x = D_80971DCC[this->unk190].x; + this->unk238.y = D_80971DCC[this->unk190].y; + this->unk238.z = D_80971DCC[this->unk190].z; + + Math_Vec3f_Copy(&tempVec, &this->unk238); + OLib_DbCameraVec3fSum(&this->actor.home, &tempVec, &this->unk238, 1); + Math_Vec3f_Copy(&this->unk244, &this->unk22C); + Math_Vec3f_Copy(&this->unk214, &this->unk238); + Math_Vec3f_Copy(&this->unk220, &this->unk244); + func_8096FAAC(this, globalCtx); + func_8096FBB8(this, globalCtx); + + if (globalCtx->msgCtx.unk1202A == 4) { // song failed + this->unk190 = 0; + this->unkCounter1A4 = 0; + ActorCutscene_Stop(this->actorCutscenes[0]); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_YASE_DEAD); + if (this) {} + this->unkState196 = 2; + this->cutsceneCamId = MAIN_CAM; + this->actor.textId = 0x1647; + this->unkState1A8 = 2; + this->unkMsgState1AC = 5; + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_ARMS_CROSSED_ROCKING); + this->actionFunc = EnKakasi_RegularDialogue; + + } else if (globalCtx->msgCtx.unk1202A == 3) { // song success + this->postTeachTimer = 30; + this->skelanime.playSpeed = 2.0f; + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_HOPPING_REGULAR); + this->actionFunc = EnKakasi_PostSongLearnTwirl; + } + } +} + +void EnKakasi_PostSongLearnTwirl(EnKakasi* this, GlobalContext* globalCtx) { + f32 animeFrame = this->skelanime.curFrame; + + if (this->postTeachTimer == 0 && this->animIndex != ENKAKASI_ANIM_TWIRL) { + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_TWIRL); + this->skelanime.playSpeed = 2.0f; + } + if (this->postTeachTimer == 0 && this->animIndex == ENKAKASI_ANIM_TWIRL && this->animeFrameCount <= animeFrame) { + EnKakasi_SetupPostSongLearnDialogue(this, globalCtx); + } +} + +void EnKakasi_SetupPostSongLearnDialogue(EnKakasi* this, GlobalContext* globalCtx) { + ActorCutscene_Stop(this->actorCutscenes[0]); + globalCtx->msgCtx.unk1202A = 4; + this->unk190 = 0; + this->unkCounter1A4 = 0; + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_HOPPING_REGULAR); + this->cutsceneCamId = MAIN_CAM; + this->unkMsgState1AC = 5; + this->unkState1A8 = 1; + this->actionFunc = EnKakasi_PostSongLearnDialogue; + this->unk20C = 0.0f; + this->unk210 = 60.0f; +} + +void EnKakasi_PostSongLearnDialogue(EnKakasi* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 tempAnimFrame = this->skelanime.curFrame; + Vec3f vec3fCopy; + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 1, 3000, 0); + Math_SmoothStepToS(&player->actor.shape.rot.y, this->actor.yawTowardsPlayer + 0x8000, 5, 1000, 0); + + if (this->unk190 == 0) { + func_801477B4(globalCtx); + func_800B7298(globalCtx, &this->actor, 0x56); + this->actor.textId = 0x1648; + func_801518B0(globalCtx, (this->actor.textId), &this->actor); + this->unkState1A8 = 0; + this->unk190 = 1; + } + + if (this->actor.textId == 0x1648 && this->animIndex == ENKAKASI_ANIM_HOPPING_REGULAR && + this->animeFrameCount <= tempAnimFrame) { + this->unkCounter1A4++; + if (this->unkCounter1A4 >= 2) { + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_ARMS_CROSSED_ROCKING); + } + } + + if (this->actor.textId == 0x164B && this->animIndex == ENKAKASI_ANIM_ARMS_CROSSED_ROCKING && + this->animeFrameCount <= tempAnimFrame) { + this->unkCounter1A4++; + if (this->unkCounter1A4 >= 2) { + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SPIN_REACH_OFFER); + } + } + + if (this->unkState1A8 == 0) { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->actorCutscenes[0]); + return; + } + if (ActorCutscene_GetCanPlayNext(this->actorCutscenes[0]) == 0) { + ActorCutscene_SetIntentToPlay(this->actorCutscenes[0]); + return; + } + Math_Vec3f_Copy(&this->unk22C, &this->actor.home.pos); + ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[0], &this->actor); + this->cutsceneCamId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + func_800B7298(globalCtx, &this->actor, 0x56); + this->unkState1A8 = 1; + } + + if (this->cutsceneCamId != MAIN_CAM) { + this->unk22C.y = this->actor.home.pos.y + 50.0f; + EnKakasi_CheckPlayerPosition(this, globalCtx); + this->unk238.x = D_80971FA0[this->unk190].x; + this->unk238.y = D_80971FA0[this->unk190].y; + this->unk238.z = D_80971FA0[this->unk190].z; + Math_Vec3f_Copy(&vec3fCopy, &this->unk238); + OLib_DbCameraVec3fSum(&this->actor.home, &vec3fCopy, &this->unk238, 1); + this->unk244.x = D_80971FE8[this->unk190].x + this->unk22C.x; + this->unk244.y = D_80971FE8[this->unk190].y + this->unk22C.y; + this->unk244.z = D_80971FE8[this->unk190].z + this->unk22C.z; + Math_Vec3f_Copy(&this->unk214, &this->unk238); + Math_Vec3f_Copy(&this->unk220, &this->unk244); + } + + func_8096FAAC(this, globalCtx); + + if (this->unkState1A8 != 0 && func_80152498(&globalCtx->msgCtx) == this->unkMsgState1AC && + func_80147624(globalCtx) != 0) { + + func_801477B4(globalCtx); + + if (this->unkMsgState1AC == 5) { + this->unk190++; + if (this->unk190 > 5) { + this->unk190 = 5; + } + + if (this->actor.textId == 0x1648) { + func_800B7298(globalCtx, &this->actor, 7); + this->actor.textId = 0x1649; + if (this->animIndex != ENKAKASI_ANIM_ARMS_CROSSED_ROCKING) { + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_ARMS_CROSSED_ROCKING); + } + + } else if (this->actor.textId == 0x1649) { + this->actor.textId = 0x1660; + this->unkMsgState1AC = 4; + + } else if (this->actor.textId == 0x164A) { + this->actor.textId = 0x164B; + + } else if (this->actor.textId == 0x164B) { + this->actor.textId = 0x164C; + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_TWIRL); + + } else { + if (this->actor.textId == 0x164C || this->actor.textId == 0x1661) { + EnKakasi_SetupDigAway(this); + return; + } + } + + } else { + this->unkMsgState1AC = 5; + if (globalCtx->msgCtx.choiceIndex == 1) { + func_8019F208(); // play 0x4808 sfx (decide) and calls func_801A75E8 + this->actor.textId = 0x164A; + } else { + func_8019F230(); // play 0x480A sfx (cancel) and calls func_801A75E8 + this->actor.textId = 0x1661; + } + } + func_80151938(globalCtx, this->actor.textId); + } +} + +/* + * talking before dancing the night away, and cutscene setup + */ +void EnKakasi_DancingRemark(EnKakasi* this, GlobalContext* globalCtx) { + u32 currentDay = gSaveContext.day; + + this->unkState196 = 3; + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->actorCutscenes[0]); + } else if (ActorCutscene_GetCanPlayNext(this->actorCutscenes[0]) == 0) { + ActorCutscene_SetIntentToPlay(this->actorCutscenes[0]); + } else { + ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[0], &this->actor); + this->cutsceneCamId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + if (currentDay == 3 && gSaveContext.isNight) { + EnKakasi_SetupDigAway(this); + } else { + func_801A2BB8(NA_BGM_SARIAS_SONG); + EnKakasi_SetupDanceNightAway(this); + } + } +} + +void EnKakasi_SetupDanceNightAway(EnKakasi* this) { + this->unk190 = 0; + this->unkCounter1A4 = 0; + this->unk20C = 0.0f; + this->unk210 = 60.0f; + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_TWIRL); + Math_Vec3f_Copy(&this->unk22C, &this->actor.home.pos); + func_8016566C(0xB4); + this->actionFunc = EnKakasi_DancingNightAway; +} + +void EnKakasi_DancingNightAway(EnKakasi* this, GlobalContext* globalCtx) { + f32 currentFrame; + Vec3f localVec3f; + Player* player; + + currentFrame = this->skelanime.curFrame; + EnKakasi_CheckPlayerPosition(this, globalCtx); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 1, 3000, 0); + this->unk22C.y = this->actor.home.pos.y + 50.0f; + + this->unk238.x = D_80971E38[this->unk190].x; + this->unk238.y = D_80971E38[this->unk190].y; + this->unk238.z = D_80971E38[this->unk190].z; + Math_Vec3f_Copy(&localVec3f, &this->unk238); + OLib_DbCameraVec3fSum(&this->actor.home, &localVec3f, &this->unk238, 1); + + if (1) {} + this->unk244.x = D_80971EEC[this->unk190].x + this->unk22C.x; + this->unk244.y = D_80971EEC[this->unk190].y + this->unk22C.y; + this->unk244.z = D_80971EEC[this->unk190].z + this->unk22C.z; + if (this->unk190 != 6 && this->unk190 != 7) { + Math_Vec3f_Copy(&this->unk214, &this->unk238); + Math_Vec3f_Copy(&this->unk220, &this->unk244); + } + if (this->unk190 >= 7 && this->unk190 != 0xE) { + this->actor.shape.rot.y += 0x800; + } + + func_8096FAAC(this, globalCtx); + + // switching through manual cutscene states + switch (this->unk190) { + case 0: + // twirling + this->unk204 = 0x28; + this->unk190++; + return; + case 1: + // end of twirl, start shaking back and forth + if (this->unk204 == 0 && this->animeFrameCount <= currentFrame) { + this->unk204 = 0x14; + this->unk190++; + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); + } + return; + case 2: + // camera view on the left + if (this->unk204 == 0) { + this->unk204 = 0x14; + this->unk190++; + } + return; + case 3: + // camera view on the right + if (this->unk204 == 0) { + this->unk204 = 0x14; + this->unk190++; + } + return; + case 4: + // camera view close up front + if (this->unk204 == 0) { + this->unk204 = 0x14; + this->unk190++; + } + return; + case 5: + // camera view zoomed out front + if (this->unk204 == 0) { + this->unk204 = 0xF; + this->unk190++; + } + return; + case 6: + // zoom in and sweep down in from case 5 + if (this->unk204 == 0) { + this->unk204 = 0xF; + this->unk190++; + } + return; + case 7: + // zoom in close from case 6 + if (this->unk204 == 0) { + this->unk204 = 0xA; + this->unk190++; + } + return; + + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + // multiple quick angle cuts viewing from multiple sides + if (this->unk204 == 0) { + this->unk190++; + this->unk204 = 0xA; + if (this->unk190 == 0xE) { + func_800B7298(globalCtx, &this->actor, 0x49); + func_80165690(); + this->unk204 = 0x14; + } + } + return; + case 14: + // goes off once for some camera changes, + // otherwise its the end when camera is back to normal and link is confused + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 1000, 0); + if (this->unk204 == 0) { + player = GET_PLAYER(globalCtx); + + func_80169DCC(globalCtx, 0, Entrance_CreateIndexFromSpawn(0), player->unk_3CE, 0xBFF, &player->unk_3C0, + player->unk_3CC); + func_80169EFC(globalCtx); + + if (0) {} + if (gSaveContext.time > CLOCK_TIME(18, 0) || gSaveContext.time < CLOCK_TIME(6, 0)) { + gSaveContext.time = CLOCK_TIME(6, 0); + gSaveContext.respawnFlag = -4; + gSaveContext.eventInf[2] |= 0x80; + } else { + gSaveContext.time = CLOCK_TIME(18, 0); + gSaveContext.respawnFlag = -8; + } + gSaveContext.weekEventReg[0x53] |= 1; + this->unk190 = 0; + this->actionFunc = EnKakasi_DoNothing; + } + } +} + +void EnKakasi_DoNothing(EnKakasi* this, GlobalContext* globalCtx) { +} + +void EnKakasi_SetupDigAway(EnKakasi* this) { + if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); + } + this->unk190 = 0; + this->unkCounter1A4 = 0; + this->unk210 = 60.0f; + this->unk20C = 60.0f; + Math_Vec3f_Copy(&this->unk22C, &this->actor.home.pos); + this->unkState196 = 4; + this->actionFunc = EnKakasi_DiggingAway; +} + +void EnKakasi_DiggingAway(EnKakasi* this, GlobalContext* globalCtx) { + Vec3f tempunk238; + Vec3f tempWorldPos; + + if (this->cutsceneCamId != MAIN_CAM) { + this->unk22C.y = this->actor.home.pos.y + 50.0f; + this->unk238.x = D_80972030.x; + this->unk238.y = D_80972030.y; + this->unk238.z = D_80972030.z; + + Math_Vec3f_Copy(&tempunk238, &this->unk238); + OLib_DbCameraVec3fSum(&this->actor.home, &tempunk238, &this->unk238, 1); + this->unk244.x = ((f32)D_8097203C.x) + this->unk22C.x; // cast req + this->unk244.y = ((f32)D_8097203C.y) + this->unk22C.y; + this->unk244.z = ((f32)D_8097203C.z) + this->unk22C.z; + Math_Vec3f_Copy(&this->unk214, &this->unk238); + Math_Vec3f_Copy(&this->unk220, &this->unk244); + func_8096FAAC(this, globalCtx); + } + + if (this->unkCounter1A4 < 15) { + this->unkCounter1A4++; + return; + } + + this->actor.shape.rot.y += 0x3000; + Math_SmoothStepToS(&this->unk190, 500, 5, 50, 0); + if ((globalCtx->gameplayFrames % 4) == 0) { + Math_Vec3f_Copy(&tempWorldPos, &this->actor.world.pos); + tempWorldPos.y = this->actor.floorHeight; + tempWorldPos.x += randPlusMinusPoint5Scaled(2.0f); + tempWorldPos.z += randPlusMinusPoint5Scaled(2.0f); + + if (globalCtx->sceneNum == SCENE_8ITEMSHOP) { + EffectSsGSplash_Spawn(globalCtx, &tempWorldPos, 0, 0, 0, randPlusMinusPoint5Scaled(100.0f) + 200.0f); + Audio_PlaySoundAtPosition(globalCtx, &tempWorldPos, 0x32, NA_SE_EV_BOMB_DROP_WATER); + + } else { + func_800BBDAC(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale - 20.0f, 5, + 4.0f, 200, 10, 1); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + } + } + + Math_ApproachF(&this->actor.shape.yOffset, -6000.0f, 0.5f, 200.0f); + if (fabsf(this->actor.shape.yOffset + 6000.0f) < 10.0f) { + gSaveContext.weekEventReg[79] |= 8; + func_800B7298(globalCtx, &this->actor, 6); + ActorCutscene_Stop(this->actorCutscenes[0]); + this->aboveGroundStatus = ENKAKASI_ABOVE_GROUND_TYPE; + this->songSummonDist = 80.0f; + EnKakasi_SetupIdleUnderground(this); + } +} + +void EnKakasi_SetupIdleUnderground(EnKakasi* this) { + this->actor.shape.yOffset = -7000.0; + this->actor.draw = NULL; + this->actor.flags |= 0x8000000; + this->unkState196 = 5; + this->actionFunc = EnKakasi_IdleUnderground; +} + +void EnKakasi_IdleUnderground(EnKakasi* this, GlobalContext* globalCtx) { + if ((gSaveContext.weekEventReg[79] & 0x8) && this->actor.xzDistToPlayer < this->songSummonDist && + (BREG(1) != 0 || globalCtx->msgCtx.unk1202A == 0xD)) { + this->actor.flags &= ~0x8000000; + globalCtx->msgCtx.unk1202A = 4; + this->actionFunc = EnKakasi_SetupRiseOutOfGround; + } +} + +void EnKakasi_SetupRiseOutOfGround(EnKakasi* this, GlobalContext* globalCtx) { + s32 cutsceneIndex; + + cutsceneIndex = 0; + if (this->aboveGroundStatus == ENKAKASI_ABOVE_GROUND_TYPE) { + cutsceneIndex = 1; + } + + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->actorCutscenes[cutsceneIndex]); + + } else if (ActorCutscene_GetCanPlayNext(this->actorCutscenes[cutsceneIndex]) == 0) { + ActorCutscene_SetIntentToPlay(this->actorCutscenes[cutsceneIndex]); + + } else { + ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[cutsceneIndex], &this->actor); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + this->actor.draw = EnKakasi_Draw; + this->unkState196 = 6; + this->actionFunc = EnKakasi_RisingOutOfGround; + } +} + +void EnKakasi_RisingOutOfGround(EnKakasi* this, GlobalContext* globalCtx) { + this->actor.shape.rot.y += 0x3000; + + if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); + } + if (this->actor.shape.yOffset < -10.0f) { + if ((globalCtx->gameplayFrames % 8) == 0) { + func_800BBDAC(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale - 20.0f, 10, + 8.0f, 500, 10, 1); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + } + Math_ApproachF(&this->actor.shape.yOffset, 0.0f, 0.5f, 200.0f); + } else { + EnKakasi_SetupIdleRisen(this); + } +} + +void EnKakasi_SetupIdleRisen(EnKakasi* this) { + // text: great to see you again + this->actor.textId = 0x164D; + this->unkState196 = 7; + this->actionFunc = EnKakasi_IdleRisen; + this->actor.shape.yOffset = 0.0f; +} + +void EnKakasi_IdleRisen(EnKakasi* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 1000, 0); + if (func_800B84D0(&this->actor, globalCtx)) { + this->actionFunc = EnKakasi_RisenDialogue; + } else { + func_800B8614(&this->actor, globalCtx, 70.0f); + } +} + +void EnKakasi_RisenDialogue(EnKakasi* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 1000, 0); + + if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx) != 0) { + func_801477B4(globalCtx); + EnKakasi_SetupIdleRisen(this); + } +} + +void EnKakasi_Update(Actor* thisx, GlobalContext* globalCtx) { + EnKakasi* this = THIS; + s32 pad; + + SkelAnime_Update(&this->skelanime); + if (this->actor.draw != NULL) { + EnKakasi_CheckAnimationSfx(this); + } + + this->actor.world.rot.y = this->actor.shape.rot.y; + DECR(this->postTeachTimer); + DECR(this->unk204); + + if (this->unkState196 != 5) { + if (this->unk1BC.x != 0.0f || this->unk1BC.z != 0.0f) { + Math_Vec3f_Copy(&this->actor.focus.pos, &this->unk1BC); + this->actor.focus.pos.y += 10.0f; + if (this->cutsceneCamId == MAIN_CAM) { + Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); + } else { + Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.home.rot); + } + } + } else { + Actor_SetHeight(&this->actor, this->unkHeight); + } + + this->actionFunc(this, globalCtx); + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 50.0f, 100.0f, 0x1C); + if (this->actor.draw != NULL) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void EnKakasi_LimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* actor) { + EnKakasi* this = (EnKakasi*)actor; + + if (limbIndex == 4) { + // what is D_801D15B0 ? we didn't have to define it, we store the output though + Matrix_MultiplyVector3fByState(&D_801D15B0, &this->unk1BC); + } +} + +void EnKakasi_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnKakasi* this = THIS; + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelanime.skeleton, this->skelanime.jointTable, this->skelanime.dListCount, + NULL, EnKakasi_LimbDraw, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.h b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.h index b9a18adc55..2cb4f6cba1 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.h +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.h @@ -6,14 +6,46 @@ struct EnKakasi; typedef void (*EnKakasiActionFunc)(struct EnKakasi*, GlobalContext*); +typedef void (*EnKakasiUnkFunc)(GlobalContext*, struct EnKakasi*); typedef struct EnKakasi { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4]; - /* 0x0148 */ EnKakasiActionFunc actionFunc; - /* 0x014C */ char unk_14C[0x154]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnKakasiUnkFunc unkFunc; // used for one z_snap calling function? + /* 0x148 */ EnKakasiActionFunc actionFunc; + /* 0x14C */ SkelAnime skelanime; + /* 0x190 */ s16 unk190; // camera index for song teaching angles? + /* 0x192 */ s16 postTeachTimer; + /* 0x194 */ s16 aboveGroundStatus; // from params, changed to 2 in init + /* 0x196 */ s16 unkState196; + /* 0x19A */ UNK_TYPE1 pad198[0x8]; + /* 0x1A0 */ s32 animIndex; + /* 0x1A4 */ s32 unkCounter1A4; // counter, counts up to F while he digs away, reused elsewhere + /* 0x1A8 */ s32 unkState1A8; + /* 0x1AC */ s16 unkMsgState1AC; // might be dialog state, compared against func(msgCtx) + /* 0x1AE */ s16 actorCutscenes[3]; + /* 0x1B4 */ f32 animeFrameCount; + /* 0x1B8 */ f32 unkHeight; + /* 0x1BC */ Vec3f unk1BC; // set by post limbdraw func for one limb + /* 0x1C8 */ UNK_TYPE1 pad1C8[0x3C]; + /* 0x204 */ s16 unk204; // set to A, F, 0x14, 0x28 frequently + /* 0x206 */ UNK_TYPE1 pad206[2]; + /* 0x208 */ s16 cutsceneCamId; + /* 0x20C */ f32 unk20C; // passed to unknown function + /* 0x210 */ f32 unk210; // used as a target for 20C to approach + /* 0x214 */ Vec3f unk214; // copied from unk238 regularly + /* 0x220 */ Vec3f unk220; //EnKakasi_TeachingSong + /* 0x22C */ Vec3f unk22C; //actor home copied to here + /* 0x238 */ Vec3f unk238; //copied from D_80971E38[unk190] + /* 0x244 */ Vec3f unk244; + /* 0x250 */ f32 songSummonDist; + /* 0x254 */ ColliderCylinder collider; } EnKakasi; // size = 0x2A0 extern const ActorInit En_Kakasi_InitVars; +#define ENKAKASI_ABOVE_GROUND_TYPE 2 + +#define GET_KAKASI_SUMMON_DISTANCE(this) ((this->actor.params >> 0x8) & 0xFF) +#define GET_KAKASI_ABOVE_GROUND(this) (this->actor.params & 0x1) + #endif // Z_EN_KAKASI_H diff --git a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c index c46ed77285..1b4d04e426 100644 --- a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c +++ b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c @@ -1,7 +1,7 @@ /* * File: z_en_kusa2.c * Overlay: ovl_En_Kusa2 - * Description: Keaton grass? + * Description: Keaton grass */ #include "z_en_kusa2.h" diff --git a/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c b/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c index 395dcbeed7..4a21cdefdf 100644 --- a/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c +++ b/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c @@ -1,7 +1,7 @@ /* * File: z_en_m_thunder.c * Overlay: ovl_En_M_Thunder - * Description: Spin attack effect + * Description: Spin attack and sword beams */ #include "z_en_m_thunder.h" diff --git a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c index eca46a8e85..92908ac6d9 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c @@ -751,7 +751,7 @@ void EnMa4_SetupHorsebackGameEnd(EnMa4* this, GlobalContext* globalCtx) { gSaveContext.weekEventReg[0x8] &= (u8)~0x01; this->actionFunc = EnMa4_HorsebackGameEnd; Audio_QueueSeqCmd(NA_BGM_STOP); - Audio_QueueSeqCmd(0x8041); + Audio_QueueSeqCmd(NA_BGM_HORSE_GOAL | 0x8000); } void EnMa4_HorsebackGameEnd(EnMa4* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c index 4c955f83fb..d89ed45821 100644 --- a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c +++ b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c @@ -903,7 +903,7 @@ void EnMaYto_SetupAfterMilkRunInit(EnMaYto* this) { if (gSaveContext.weekEventReg[0x34] & 1) { // if (ProtectedCremia) EnMaYto_SetFaceExpression(this, 3, 1); } else { - func_801A3098(9); + func_801A3098(NA_BGM_FAILURE_1); EnMaYto_SetFaceExpression(this, 5, 2); } this->actionFunc = EnMaYto_AfterMilkRunInit; diff --git a/src/overlays/actors/ovl_En_Minideath/z_en_minideath.c b/src/overlays/actors/ovl_En_Minideath/z_en_minideath.c index eb3a02eb38..6750c81da5 100644 --- a/src/overlays/actors/ovl_En_Minideath/z_en_minideath.c +++ b/src/overlays/actors/ovl_En_Minideath/z_en_minideath.c @@ -1,7 +1,7 @@ /* * File: z_en_minideath.c * Overlay: ovl_En_Minideath - * Description: Bats Surrounding Gomess? + * Description: Gomess's bats */ #include "z_en_minideath.h" diff --git a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c index 67c1d86593..9095d702b3 100644 --- a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c +++ b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c @@ -462,7 +462,7 @@ void EnMinifrog_BeginChoirCutscene(EnMinifrog* this, GlobalContext* globalCtx) { ActorCutscene_Start(this->actor.cutscene, &this->actor); this->actionFunc = EnMinifrog_SetupNextFrogChoir; this->timer = 5; - func_801A1F00(3, 0x5A); + func_801A1F00(3, NA_BGM_FROG_SONG); this->flags |= 0x100; globalCtx->setPlayerTalkAnim(globalCtx, &D_0400E2A8, 0); } else { diff --git a/src/overlays/actors/ovl_En_Mkk/z_en_mkk.c b/src/overlays/actors/ovl_En_Mkk/z_en_mkk.c index 73e2fc62da..1bedf7901f 100644 --- a/src/overlays/actors/ovl_En_Mkk/z_en_mkk.c +++ b/src/overlays/actors/ovl_En_Mkk/z_en_mkk.c @@ -1,7 +1,7 @@ /* * File: z_en_mkk.c * Overlay: ovl_En_Mkk - * Description: Makkurokurosuke / Black and White Boe + * Description: Black and White Boe (Name origin: Makkurokurosuke) */ #include "z_en_mkk.h" diff --git a/src/overlays/actors/ovl_En_Mm/z_en_mm.c b/src/overlays/actors/ovl_En_Mm/z_en_mm.c index 60cd432469..00bf38f8ab 100644 --- a/src/overlays/actors/ovl_En_Mm/z_en_mm.c +++ b/src/overlays/actors/ovl_En_Mm/z_en_mm.c @@ -18,10 +18,8 @@ void EnMm_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80965D3C(EnMm* this, GlobalContext* globalCtx); void func_80965DB4(EnMm* this, GlobalContext* globalCtx); void func_8096611C(EnMm* this, GlobalContext* globalCtx); - void EnMm_SetupAction(EnMm* this, EnMmActionFunc actionFunc); -#if 0 const ActorInit En_Mm_InitVars = { ACTOR_EN_MM, ACTORCAT_ITEMACTION, @@ -34,38 +32,190 @@ const ActorInit En_Mm_InitVars = { (ActorFunc)EnMm_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80966340 = { - { COLTYPE_METAL, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK2, { 0x00100000, 0x00, 0x00 }, { 0x01000202, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_METAL, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK2, + { 0x00100000, 0x00, 0x00 }, + { 0x01000202, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 6, 30, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8096636C[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32_DIV1000(gravity, -1200, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 270, ICHAIN_STOP), }; -#endif +void EnMm_SetupAction(EnMm* this, EnMmActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -extern ColliderCylinderInit D_80966340; -extern InitChainEntry D_8096636C[]; +void func_80965BBC(EnMm* this) { + EnMm_SetupAction(this, func_8096611C); + this->actor.room = -1; + if (this->actor.parent->id == ACTOR_PLAYER) { + gSaveContext.unk_1014 = 1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm/EnMm_SetupAction.s") +void EnMm_Init(Actor* thisx, GlobalContext* globalCtx) { + EnMm* this = THIS; + EnMmActionFunc action; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm/func_80965BBC.s") + if ((this->actor.params >= 0) && ((!(gSaveContext.weekEventReg[37] & 0x10)) || + (gSaveContext.weekEventReg[37] & 8) || (gSaveContext.unk_1014 != 0))) { + Actor_MarkForDeath(&this->actor); + return; + } + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 50.0f, func_800B3FC0, 1.2f); + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + if (this->actor.parent != NULL) { + func_80965BBC(this); + return; + } + if (this->actor.cutscene >= 0) { + action = func_80965D3C; + } else { + action = func_80965DB4; + } + EnMm_SetupAction(this, action); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm/EnMm_Init.s") +void EnMm_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnMm* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm/EnMm_Destroy.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm/func_80965D3C.s") +void func_80965D3C(EnMm* this, GlobalContext* globalCtx) { + s16 cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm/func_80965DB4.s") + if (ActorCutscene_GetCanPlayNext(cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(cutscene, &this->actor); + EnMm_SetupAction(this, func_80965DB4); + } else { + ActorCutscene_SetIntentToPlay(cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm/func_8096611C.s") +void func_80965DB4(EnMm* this, GlobalContext* globalCtx) { + s16 direction; + Vec3f sp50; + s16 unused; + f32 temp_f14; + f32 temp_f12; + f32 temp_f2; + s32 angle; + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm/EnMm_Update.s") + if (Actor_HasParent(&this->actor, globalCtx)) { + func_80965BBC(this); + Audio_PlayActorSound2(&this->actor, NA_SE_PL_PULL_UP_ROCK); + } else { + if ((this->actor.velocity.y > 0.0f) && (this->actor.bgCheckFlags & 0x10)) { + this->actor.velocity.y = 0.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm/EnMm_Draw.s") + if ((this->actor.speedXZ != 0.0f) && (this->actor.bgCheckFlags & 8)) { + angle = BINANG_SUB(this->actor.world.rot.y, BINANG_ROT180(this->actor.wallYaw)); + this->actor.world.rot.y += BINANG_SUB(0x8000, (s16)(angle * 2)); + this->actor.speedXZ *= 0.5f; + CollisionCheck_SpawnShieldParticles(globalCtx, &this->actor.world.pos); + Audio_PlayActorSound2(&this->actor, NA_SE_EV_HUMAN_BOUND); + } + + if (!(this->actor.bgCheckFlags & 1)) { + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.08f); + } else { + temp_f14 = Math_SinS(this->actor.world.rot.y) * this->actor.speedXZ; + temp_f12 = Math_CosS(this->actor.world.rot.y) * this->actor.speedXZ; + func_800B75A0(this->actor.floorPoly, &sp50, &unused); + temp_f14 += 3.0f * sp50.x; + temp_f12 += 3.0f * sp50.z; + temp_f2 = sqrtf(SQ(temp_f14) + SQ(temp_f12)); + + if ((temp_f2 < this->actor.speedXZ) || + (SurfaceType_GetSlope(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId) == 1)) { + this->actor.speedXZ = CLAMP_MAX(temp_f2, 16.0f); + this->actor.world.rot.y = Math_FAtan2F(temp_f12, temp_f14); + } + + if (!Math_StepToF(&this->actor.speedXZ, 0.0f, 1.0f)) { + direction = this->actor.world.rot.y; + if (ABS_ALT(BINANG_SUB(this->actor.world.rot.y, this->actor.shape.rot.y)) > 0x4000) { + direction = BINANG_ROT180(direction); + } + Math_ScaledStepToS(&this->actor.shape.rot.y, direction, this->actor.speedXZ * 100.0f); + this->unk_190 += (s16)(this->actor.speedXZ * 800.0f); + } + + if (this->actor.bgCheckFlags & 2) { + if (this->actor.velocity.y < -6.0f) { + this->actor.velocity.y *= -0.3f; + this->actor.bgCheckFlags &= ~1; + } + + Audio_PlayActorSound2(&this->actor, NA_SE_EV_HUMAN_BOUND); + } else { + func_800B8A1C(&this->actor, globalCtx, GI_NONE, 50.0f, 30.0f); + } + } + + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + } + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void func_8096611C(EnMm* this, GlobalContext* globalCtx) { + if (Actor_HasNoParent(&this->actor, globalCtx)) { + EnMm_SetupAction(this, func_80965DB4); + this->actor.room = globalCtx->roomCtx.currRoom.num; + this->actor.bgCheckFlags &= ~1; + Math_Vec3s_ToVec3f(&this->actor.prevPos, &this->actor.home.rot); + gSaveContext.unk_1014 = 0; + } else { + Math_Vec3f_ToVec3s(&this->actor.home.rot, &this->actor.parent->world.pos); + } + Math_ScaledStepToS(&this->unk_190, 0, 2000); +} + +void EnMm_Update(Actor* thisx, GlobalContext* globalCtx) { + EnMm* this = THIS; + + Collider_ResetCylinderAC(globalCtx, &this->collider.base); + this->actionFunc(this, globalCtx); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 10.0f, 20.0f, 31); + Actor_SetHeight(&this->actor, 20.0f); +} + +void EnMm_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnMm* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + func_8012C28C(globalCtx->state.gfxCtx); + if (this->unk_190 != 0) { + s16 rotY = this->actor.world.rot.y - this->actor.shape.rot.y; + + Matrix_RotateY(rotY, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_190, MTXMODE_APPLY); + Matrix_RotateY(-rotY, MTXMODE_APPLY); + } + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, &D_04055628); + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Mm/z_en_mm.h b/src/overlays/actors/ovl_En_Mm/z_en_mm.h index bfda85e4a3..d83ebc961e 100644 --- a/src/overlays/actors/ovl_En_Mm/z_en_mm.h +++ b/src/overlays/actors/ovl_En_Mm/z_en_mm.h @@ -9,10 +9,9 @@ typedef void (*EnMmActionFunc)(struct EnMm*, GlobalContext*); typedef struct EnMm { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x50]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ s16 unk_190; /* 0x0194 */ EnMmActionFunc actionFunc; } EnMm; // size = 0x198 -extern const ActorInit En_Mm_InitVars; - #endif // Z_EN_MM_H diff --git a/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c b/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c index 934e7b4271..789f308caa 100644 --- a/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c +++ b/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c @@ -1,7 +1,7 @@ /* * File: z_en_mt_tag.c * Overlay: ovl_En_Mt_tag - * Description: + * Description: Controls the Goron Race minigame */ #include "z_en_mt_tag.h" diff --git a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c index b7be4211bc..0969c123ab 100644 --- a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c +++ b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c @@ -125,7 +125,7 @@ s32 func_80A68860(EnMushi2* this, GlobalContext* globalCtx) { s32 pad; s32 sp40; CollisionPoly* sp3C; - f32 temp_f0 = func_800C411C(&globalCtx->colCtx, &sp3C, &sp40, &this->actor, &this->actor.world.pos); + f32 temp_f0 = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &sp3C, &sp40, &this->actor, &this->actor.world.pos); WaterBox* sp34; f32 sp30; @@ -133,7 +133,8 @@ s32 func_80A68860(EnMushi2* this, GlobalContext* globalCtx) { return true; } - return func_800CA1E8(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp30, &sp34); + return WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &sp30, &sp34); } s32 func_80A68910(EnMushi2* this, GlobalContext* globalCtx) { @@ -446,7 +447,7 @@ void func_80A69424(EnMushi2* this, GlobalContext* globalCtx) { s32 func_80A69468(EnMushi2* this, GlobalContext* globalCtx) { s32 pad; Vec3f sp68; - Vec3f sp5C; + Vec3f posB; Vec3f sp50; f32 x; f32 y; @@ -462,12 +463,12 @@ s32 func_80A69468(EnMushi2* this, GlobalContext* globalCtx) { y = (this->unk_328.y * 4.0f); z = (this->unk_328.z * 4.0f); - sp5C.x = (x + sp50.x) + this->actor.world.pos.x; - sp5C.y = (y + sp50.y) + this->actor.world.pos.y; - sp5C.z = (z + sp50.z) + this->actor.world.pos.z; + posB.x = (x + sp50.x) + this->actor.world.pos.x; + posB.y = (y + sp50.y) + this->actor.world.pos.y; + posB.z = (z + sp50.z) + this->actor.world.pos.z; - if (func_800C55C4(&globalCtx->colCtx, &this->actor.prevPos, &sp5C, &this->unk_33C, &this->unk_334, 1, 1, 1, 1, - &this->unk_338)) { + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.prevPos, &posB, &this->unk_33C, &this->poly, true, + true, true, true, &this->polyBgId)) { this->unk_30C |= 6; return true; } @@ -476,18 +477,19 @@ s32 func_80A69468(EnMushi2* this, GlobalContext* globalCtx) { s32 func_80A6958C(EnMushi2* this, GlobalContext* globalCtx) { s32 pad; - Vec3f sp48; - Vec3f sp3C; + Vec3f posA; + Vec3f posB; - sp48.x = (2.0f * this->unk_31C.x) + this->actor.world.pos.x; - sp48.y = (2.0f * this->unk_31C.y) + this->actor.world.pos.y; - sp48.z = (2.0f * this->unk_31C.z) + this->actor.world.pos.z; + posA.x = (2.0f * this->unk_31C.x) + this->actor.world.pos.x; + posA.y = (2.0f * this->unk_31C.y) + this->actor.world.pos.y; + posA.z = (2.0f * this->unk_31C.z) + this->actor.world.pos.z; - sp3C.x = (this->unk_31C.x * -4.0f) + this->actor.world.pos.x; - sp3C.y = (this->unk_31C.y * -4.0f) + this->actor.world.pos.y; - sp3C.z = (this->unk_31C.z * -4.0f) + this->actor.world.pos.z; + posB.x = (this->unk_31C.x * -4.0f) + this->actor.world.pos.x; + posB.y = (this->unk_31C.y * -4.0f) + this->actor.world.pos.y; + posB.z = (this->unk_31C.z * -4.0f) + this->actor.world.pos.z; - if (func_800C55C4(&globalCtx->colCtx, &sp48, &sp3C, &this->unk_33C, &this->unk_334, 1, 1, 1, 1, &this->unk_338)) { + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &posA, &posB, &this->unk_33C, &this->poly, true, true, true, true, + &this->polyBgId)) { this->unk_30C |= 0xA; return true; } @@ -496,21 +498,22 @@ s32 func_80A6958C(EnMushi2* this, GlobalContext* globalCtx) { s32 func_80A6969C(EnMushi2* this, GlobalContext* globalCtx) { s32 pad; - Vec3f sp50; - Vec3f sp44; + Vec3f posA; + Vec3f posB; Vec3f sp38; sp38.x = this->unk_31C.x * -4.0f; sp38.y = this->unk_31C.y * -4.0f; sp38.z = this->unk_31C.z * -4.0f; - Math_Vec3f_Sum(&sp38, &this->actor.world.pos, &sp50); + Math_Vec3f_Sum(&sp38, &this->actor.world.pos, &posA); - sp44.x = this->actor.prevPos.x + sp38.x + (this->unk_328.x * -4.0f); - sp44.y = this->actor.prevPos.y + sp38.y + (this->unk_328.y * -4.0f); - sp44.z = this->actor.prevPos.z + sp38.z + (this->unk_328.z * -4.0f); + posB.x = this->actor.prevPos.x + sp38.x + (this->unk_328.x * -4.0f); + posB.y = this->actor.prevPos.y + sp38.y + (this->unk_328.y * -4.0f); + posB.z = this->actor.prevPos.z + sp38.z + (this->unk_328.z * -4.0f); - if (func_800C55C4(&globalCtx->colCtx, &sp50, &sp44, &this->unk_33C, &this->unk_334, 1, 1, 1, 1, &this->unk_338)) { + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &posA, &posB, &this->unk_33C, &this->poly, true, true, true, true, + &this->polyBgId)) { this->unk_30C |= (0x10 | 0x2); return true; } @@ -519,8 +522,8 @@ s32 func_80A6969C(EnMushi2* this, GlobalContext* globalCtx) { void func_80A697C4(EnMushi2* this, GlobalContext* globalCtx) { s32 pad; - s32 sp38 = this->unk_334; - s32 sp34 = this->unk_338; + CollisionPoly* poly = this->poly; + s32 bgId = this->polyBgId; if (!(this->unk_30C & (0x10 | 0x4))) { WaterBox* sp30; @@ -531,8 +534,8 @@ void func_80A697C4(EnMushi2* this, GlobalContext* globalCtx) { func_80A6969C(this, globalCtx); } - if (func_800CA1E8(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp2C, - &sp30)) { + if (WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &sp2C, &sp30)) { this->actor.depthInWater = sp2C - this->actor.world.pos.y; if (this->actor.depthInWater >= 1.0f) { this->unk_30C |= 0x20; @@ -547,11 +550,11 @@ void func_80A697C4(EnMushi2* this, GlobalContext* globalCtx) { if (this->unk_30C & 4) { Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_33C); - if (func_80A691EC(this, this->unk_334, 0.4f) == 1) { + if (func_80A691EC(this, this->poly, 0.4f) == 1) { this->unk_30C &= ~0x4; } } else if (this->unk_30C & 0x10) { - if (func_80A691EC(this, this->unk_334, 0.4f) == 1) { + if (func_80A691EC(this, this->poly, 0.4f) == 1) { this->unk_30C &= ~0x10; Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_33C); } else { @@ -560,13 +563,13 @@ void func_80A697C4(EnMushi2* this, GlobalContext* globalCtx) { } else if (this->unk_30C & 8) { if (!(this->unk_30C & 0x20)) { Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_33C); - func_80A691EC(this, this->unk_334, -1.0f); + func_80A691EC(this, this->poly, -1.0f); } } else if (!(this->unk_30C & 2)) { Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.prevPos); Math_Vec3f_Copy(&this->unk_33C, &this->actor.prevPos); - this->unk_334 = sp38; - this->unk_338 = sp34; + this->poly = poly; + this->polyBgId = bgId; } } @@ -580,7 +583,7 @@ s32 func_80A699E4(EnMushi2* this, GlobalContext* globalCtx) { f32 y = (2.0f * this->unk_328.y) + this->actor.world.pos.y; f32 z = (2.0f * this->unk_328.z) + this->actor.world.pos.z; - if (func_800CA1E8(globalCtx, &globalCtx->colCtx, x, z, &sp3C, &sp40) && (y <= sp3C)) { + if (WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, x, z, &sp3C, &sp40) && (y <= sp3C)) { return true; } } @@ -676,13 +679,13 @@ void func_80A69D3C(EnMushi2* this) { s32 func_80A69EE4(EnMushi2* this, GlobalContext* globalCtx) { s32 pad; - WaterBox* sp30; - f32 sp2C; - s32 sp28; + WaterBox* waterBox; + f32 waterSurface; + s32 bgId; - if (func_800C9EBC(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp2C, &sp30, - &sp28) && - (this->actor.world.pos.y < sp2C)) { + if (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &waterSurface, &waterBox, &bgId) && + (this->actor.world.pos.y < waterSurface)) { return true; } return false; @@ -1083,8 +1086,8 @@ void func_80A6B0D8(EnMushi2* this, GlobalContext* globalCtx) { Vec3f sp48; s32 sp44 = 0; - if (this->unk_334 != 0) { - u32 temp_v0 = func_800C99D4(&globalCtx->colCtx, this->unk_334, this->unk_338); + if (this->poly != NULL) { + u32 temp_v0 = func_800C99D4(&globalCtx->colCtx, this->poly, this->polyBgId); if ((temp_v0 == 5) || (temp_v0 == 14) || (temp_v0 == 15)) { sp44 = 1; } @@ -1151,8 +1154,8 @@ void EnMushi2_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk_358 = 1.0f; } - temp = this->unk_338; - if ((temp != 50) && + temp = this->polyBgId; + if ((temp != BGCHECK_SCENE) && ((this->actionFunc == func_80A6A5C0) || (this->actionFunc == func_80A6A824) || (this->actionFunc == func_80A6A9E4) || (this->actionFunc == func_80A6B0D8)) && BgCheck2_UpdateActorAttachedToMesh(&globalCtx->colCtx, temp, &this->actor)) { @@ -1176,13 +1179,12 @@ void EnMushi2_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->unk_34C != 0) { sp4C = 0.0f; - this->unk_354 = Math3D_DistanceSquared(&this->actor.world.pos, &this->unk_34C->actor.world.pos); + this->unk_354 = Math3D_Vec3fDistSq(&this->actor.world.pos, &this->unk_34C->actor.world.pos); if (this->unk_354 < this->unk_350) { - f32 dist = Math3D_NormalizedSignedDistanceFromPlane( - COLPOLY_GET_NORMAL(this->unk_34C->actor.floorPoly->normal.x), - COLPOLY_GET_NORMAL(this->unk_34C->actor.floorPoly->normal.y), - COLPOLY_GET_NORMAL(this->unk_34C->actor.floorPoly->normal.z), this->unk_34C->actor.floorPoly->dist, - &this->actor.world.pos); + f32 dist = Math3D_DistPlaneToPos(COLPOLY_GET_NORMAL(this->unk_34C->actor.floorPoly->normal.x), + COLPOLY_GET_NORMAL(this->unk_34C->actor.floorPoly->normal.y), + COLPOLY_GET_NORMAL(this->unk_34C->actor.floorPoly->normal.z), + this->unk_34C->actor.floorPoly->dist, &this->actor.world.pos); if (fabsf(dist) < 3.0f) { sp4C = 1.9f; diff --git a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.h b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.h index 5a95ee49ae..f773cd7460 100644 --- a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.h +++ b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.h @@ -26,8 +26,8 @@ typedef struct EnMushi2 { /* 0x0310 */ Vec3f unk_310; /* 0x031C */ Vec3f unk_31C; /* 0x0328 */ Vec3f unk_328; - /* 0x0334 */ CollisionPoly* unk_334; - /* 0x0338 */ u32 unk_338; + /* 0x0334 */ CollisionPoly* poly; + /* 0x0338 */ s32 polyBgId; /* 0x033C */ Vec3f unk_33C; /* 0x0348 */ f32 unk_348; /* 0x034C */ struct ObjBean* unk_34C; diff --git a/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c b/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c index 86f477a0f4..4c3859efd5 100644 --- a/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c +++ b/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c @@ -1,7 +1,7 @@ /* * File: z_en_neo_reeba.c * Overlay: ovl_En_Neo_Reeba - * Description: Leevers + * Description: (New) Leevers */ #include "z_en_neo_reeba.h" diff --git a/src/overlays/actors/ovl_En_Niw/z_en_niw.c b/src/overlays/actors/ovl_En_Niw/z_en_niw.c index f72add584b..3eadcc15ec 100644 --- a/src/overlays/actors/ovl_En_Niw/z_en_niw.c +++ b/src/overlays/actors/ovl_En_Niw/z_en_niw.c @@ -810,7 +810,7 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 0x1F); - if ((this->actor.floorHeight <= BGCHECK_Y_MIN) || (this->actor.floorHeight >= 32000.0f)) { + if (this->actor.floorHeight <= BGCHECK_Y_MIN || this->actor.floorHeight >= BGCHECK_Y_MAX) { // if cucco is off the map? Vec3f camera; camera.x = globalCtx->view.at.x - globalCtx->view.eye.x; diff --git a/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c b/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c index 9d90c4ec61..d2140a16e3 100644 --- a/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c +++ b/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c @@ -94,7 +94,7 @@ void EnNutsball_Update(Actor* thisx, GlobalContext* globalCtx) { Vec3s worldRot; Vec3f spawnBurstPos; f32 spdXZ; - u32 bgId; + s32 bgId; CollisionPoly* poly; if (!(player->stateFlags1 & 0x300000C0)) { @@ -140,8 +140,8 @@ void EnNutsball_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 8) { if (func_800C9A4C(&globalCtx2->colCtx, this->actor.wallPoly, this->actor.wallBgId) & 0x30) { this->actor.bgCheckFlags &= ~8; - if (func_800C55C4(&globalCtx2->colCtx, &this->actor.prevPos, &worldPos, &this->actor.world.pos, &poly, - 1, 0, 0, 1, &bgId)) { + if (BgCheck_EntityLineTest1(&globalCtx2->colCtx, &this->actor.prevPos, &worldPos, + &this->actor.world.pos, &poly, true, false, false, true, &bgId)) { if (func_800C9A4C(&globalCtx2->colCtx, poly, bgId) & 0x30) { this->actor.world.pos.x += this->actor.velocity.x * 0.01f; this->actor.world.pos.z += this->actor.velocity.z * 0.01f; diff --git a/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c b/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c index 96f12dab29..9b0d89cddf 100644 --- a/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c +++ b/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c @@ -1,7 +1,7 @@ /* * File: z_en_okarina_effect.c * Overlay: ovl_En_Okarina_Effect - * Description: + * Description: Manages the storm created when playing Song of Storms */ #include "z_en_okarina_effect.h" diff --git a/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.c b/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.c index 0e4ebdd48a..1f93a97867 100644 --- a/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.c +++ b/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.c @@ -1,7 +1,7 @@ /* * File: z_en_onpuman.c * Overlay: ovl_En_Onpuman - * Description: Monkey Instrument Prompt + * Description: Monkey Instrument Prompt (unused) */ #include "z_en_onpuman.h" diff --git a/src/overlays/actors/ovl_En_Ot/z_en_ot.c b/src/overlays/actors/ovl_En_Ot/z_en_ot.c index b47fc80253..d6c95bad6e 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.c +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.c @@ -138,7 +138,7 @@ void func_80B5B2E0(GlobalContext* globalCtx, Vec3f* pos, s16 params, Vec3f* vec, void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnOt* this = THIS; - s32 sp74; + s32 bgId; s32 pad2; Vec3f sp64; Vec3f sp58; @@ -183,9 +183,9 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { switch (this->unk_344) { case 0: - this->actor.world.pos.y = - func_800C40B4(&globalCtx->colCtx, &this->actor.floorPoly, &sp74, &this->actor.world.pos) + - 50.0f; + this->actor.world.pos.y = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &this->actor.floorPoly, + &bgId, &this->actor.world.pos) + + 50.0f; if (gSaveContext.weekEventReg[84] & 0x10) { Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); Matrix_GetStateTranslationAndScaledZ(52.519997f, &sp64); @@ -242,7 +242,8 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { } else { Player* player = GET_PLAYER(globalCtx); - if (func_800C9B90(&globalCtx->colCtx, player->actor.floorPoly, player->actor.floorBgId)) { + if (SurfaceType_IsHorseBlocked(&globalCtx->colCtx, player->actor.floorPoly, + player->actor.floorBgId)) { Actor_SetScale(&this->actor, 0.0f); func_80B5C910(this, globalCtx); } else { @@ -822,9 +823,9 @@ void func_80B5D160(EnOt* this, GlobalContext* globalCtx) { } } -s32 func_80B5D37C(GlobalContext* globalCtx, EnDno_ActorUnkStruct* arg1) { +s32 func_80B5D37C(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { s32 pad; - EnOt* temp_s0 = (EnOt*)arg1->unk_48; + EnOt* temp_s0 = (EnOt*)arg1->actor; f32 sp24; f32 sp20; @@ -843,10 +844,10 @@ s32 func_80B5D37C(GlobalContext* globalCtx, EnDno_ActorUnkStruct* arg1) { return false; } -s32 func_80B5D470(GlobalContext* globalCtx, EnDno_ActorUnkStruct* arg1) { +s32 func_80B5D470(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { s32 pad; s32 ret; - Actor* temp_s1 = arg1->unk_48; + Actor* temp_s1 = arg1->actor; Vec3f sp50; Vec3f sp44; f32 temp; @@ -871,14 +872,14 @@ s32 func_80B5D470(GlobalContext* globalCtx, EnDno_ActorUnkStruct* arg1) { ret = true; } else { temp = SQ(temp_s1->speedXZ) / arg1->unk_50; - sp34 = ABS(arg1->unk_54 - temp_s1->world.rot.x); + sp34 = ABS(arg1->unk_54.x - temp_s1->world.rot.x); sp2C = (s32)(sp34 * temp) + 0xAAA; - sp34 = ABS(arg1->unk_56 - temp_s1->world.rot.y); + sp34 = ABS(arg1->unk_54.y - temp_s1->world.rot.y); - Math_SmoothStepToS(&temp_s1->world.rot.x, arg1->unk_54, 1, sp2C, 0); + Math_SmoothStepToS(&temp_s1->world.rot.x, arg1->unk_54.x, 1, sp2C, 0); sp2C = (s32)(sp34 * temp) + 0xAAA; - Math_SmoothStepToS(&temp_s1->world.rot.y, arg1->unk_56, 1, sp2C, 0); + Math_SmoothStepToS(&temp_s1->world.rot.y, arg1->unk_54.y, 1, sp2C, 0); Math_SmoothStepToS(&temp_s1->shape.rot.y, temp_s1->world.rot.y, 2, sp2C, 0); } @@ -1007,7 +1008,7 @@ void func_80B5DB6C(Actor* thisx, GlobalContext* globalCtx) { s32 sp4C = false; if (gSaveContext.weekEventReg[13] & 1) { - if (!func_800C9B90(&globalCtx->colCtx, player->actor.floorPoly, player->actor.floorBgId)) { + if (!SurfaceType_IsHorseBlocked(&globalCtx->colCtx, player->actor.floorPoly, player->actor.floorBgId)) { sp4C = true; } } @@ -1021,7 +1022,7 @@ void func_80B5DB6C(Actor* thisx, GlobalContext* globalCtx) { temp->actor.cutscene = this->actor.cutscene; this->unk_32C |= 8; } - } else if (func_800C9B90(&globalCtx->colCtx, player->actor.floorPoly, player->actor.floorBgId)) { + } else if (SurfaceType_IsHorseBlocked(&globalCtx->colCtx, player->actor.floorPoly, player->actor.floorBgId)) { player->unk_B2B = 29; } } diff --git a/src/overlays/actors/ovl_En_Ot/z_en_ot.h b/src/overlays/actors/ovl_En_Ot/z_en_ot.h index f0adb73e47..3a52b48c6c 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.h +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.h @@ -36,7 +36,7 @@ typedef struct EnOt { /* 0x01D8 */ Vec3s jointTable[19]; /* 0x024A */ Vec3s morphTable[19]; /* 0x02BC */ s32 animIdx; - /* 0x02C0 */ EnDno_ActorUnkStruct unk_2C0; + /* 0x02C0 */ struct_8013DF3C_arg1 unk_2C0; /* 0x032C */ u16 unk_32C; /* 0x0330 */ Vec3f unk_330; /* 0x033C */ s32 unk_33C; diff --git a/src/overlays/actors/ovl_En_Owl/z_en_owl.c b/src/overlays/actors/ovl_En_Owl/z_en_owl.c index 446b4c100e..514245a327 100644 --- a/src/overlays/actors/ovl_En_Owl/z_en_owl.c +++ b/src/overlays/actors/ovl_En_Owl/z_en_owl.c @@ -367,7 +367,7 @@ void func_8095AE60(EnOwl* this, GlobalContext* globalCtx) { void func_8095AEC0(EnOwl* this, GlobalContext* globalCtx) { func_8095A920(this, globalCtx); if (func_8095A978(this, globalCtx, 0x7D0, 360.0f, 200.0f)) { - func_801A3098(0x45); + func_801A3098(NA_BGM_OWL); this->actionFunc = func_8095AE60; } } @@ -396,7 +396,7 @@ void func_8095AF2C(EnOwl* this, GlobalContext* globalCtx) { void func_8095AFEC(EnOwl* this, GlobalContext* globalCtx) { func_8095A920(this, globalCtx); if (func_8095A978(this, globalCtx, 0xBF6, 200.0f, 100.0f)) { - func_801A3098(0x45); + func_801A3098(NA_BGM_OWL); this->actionFunc = func_8095AF2C; this->unk_406 = 0; this->actionFlags |= 0x40; @@ -511,7 +511,7 @@ void func_8095B574(EnOwl* this, GlobalContext* globalCtx) { func_8095A920(this, globalCtx); if (func_800B84D0(&this->actor, globalCtx)) { this->actionFunc = func_8095BA84; - func_801A3098(0x45); + func_801A3098(NA_BGM_OWL); this->actionFlags |= 0x40; this->unk_406 = 2; } else if (this->actor.xzDistToPlayer < 200.0f) { @@ -721,7 +721,7 @@ void func_8095BE0C(EnOwl* this, GlobalContext* globalCtx) { func_8095A920(this, globalCtx); if (func_800B84D0(&this->actor, globalCtx)) { this->actionFunc = func_8095BA84; - func_801A3098(0x45); + func_801A3098(NA_BGM_OWL); this->unk_406 = 1; this->actionFlags |= 0x40; } else if (this->actor.textId == 0xBF0) { diff --git a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c index db3f66030e..14ad82b2d7 100644 --- a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c +++ b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c @@ -486,7 +486,7 @@ void func_80BD9338(EnPamera* this, GlobalContext* globalCtx) { func_80BD84F0(this, globalCtx); actor = this->actor.child; if ((actor != NULL) && (actor->id == ACTOR_EN_DOOR)) { - ((EnDoor*)actor)->unk1A7 = -0x32; + ((EnDoor*)actor)->unk_1A7 = -0x32; } } @@ -590,9 +590,9 @@ void func_80BD9840(EnPamera* this, GlobalContext* globalCtx) { func_80BD9904(this); } if (gSaveContext.weekEventReg[14] & 4) { - func_801A0204(0x27); + func_801A0204(NA_BGM_MUSIC_BOX_HOUSE); } else { - func_801A0204(0x1F); + func_801A0204(NA_BGM_INSIDE_A_HOUSE); } } diff --git a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c index 12e234991a..8993cb14a4 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c @@ -370,7 +370,7 @@ void EnPametfrog_StopCutscene(EnPametfrog* this, GlobalContext* globalCtx) { void EnPametfrog_PlaceSnapper(EnPametfrog* this, GlobalContext* globalCtx) { CollisionPoly* poly; - u32 bgId; + s32 bgId; Vec3f vec1; Vec3f vec2; Vec3f vec3; @@ -386,7 +386,7 @@ void EnPametfrog_PlaceSnapper(EnPametfrog* this, GlobalContext* globalCtx) { vec3.x = this->actor.child->world.pos.x; vec3.y = this->actor.child->world.pos.y - 150.0f; vec3.z = this->actor.child->world.pos.z; - if (func_800C55C4(&globalCtx->colCtx, &vec2, &vec3, &vec1, &poly, 0, 1, 0, 1, &bgId) != 0) { + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &vec2, &vec3, &vec1, &poly, false, true, false, true, &bgId)) { this->actor.child->floorHeight = vec1.y; } else { this->actor.child->floorHeight = this->actor.home.pos.y; @@ -615,8 +615,8 @@ void EnPametfrog_WallCrawl(EnPametfrog* this, GlobalContext* globalCtx) { Vec3f worldPos1; Vec3f worldPos2; f32 doubleSpeedXZ; - u32 bgId1; - u32 bgId2; + s32 bgId1; + s32 bgId2; s32 isSuccess = false; if (this->freezeTimer > 0) { @@ -632,11 +632,13 @@ void EnPametfrog_WallCrawl(EnPametfrog* this, GlobalContext* globalCtx) { vec2.x = this->actor.world.pos.x - this->unk_2DC.x * 25.0f; vec2.y = this->actor.world.pos.y - this->unk_2DC.y * 25.0f; vec2.z = this->actor.world.pos.z - this->unk_2DC.z * 25.0f; - if (func_800C55C4(&globalCtx->colCtx, &vec1, &vec2, &worldPos2, &poly2, 1, 1, 1, 1, &bgId2) != 0) { + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &vec1, &vec2, &worldPos2, &poly2, true, true, true, true, + &bgId2)) { vec2.x = this->unk_2D0.x * doubleSpeedXZ + vec1.x; vec2.y = this->unk_2D0.y * doubleSpeedXZ + vec1.y; vec2.z = this->unk_2D0.z * doubleSpeedXZ + vec1.z; - if (func_800C55C4(&globalCtx->colCtx, &vec1, &vec2, &worldPos1, &poly1, 1, 1, 1, 1, &bgId1) != 0) { + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &vec1, &vec2, &worldPos1, &poly1, true, true, true, true, + &bgId1)) { isSuccess = func_8086A2CC(this, poly1); Math_Vec3f_Copy(&this->actor.world.pos, &worldPos1); this->actor.floorBgId = bgId1; @@ -742,7 +744,7 @@ void EnPametfrog_ClimbDownWall(EnPametfrog* this, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 1) { EnPametfrog_SetupRunToSnapper(this); - } else if (this->actor.floorHeight == -32000.0f) { + } else if (this->actor.floorHeight == BGCHECK_Y_MIN) { yaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos); this->actor.world.pos.x += 5.0f * Math_SinS(yaw); this->actor.world.pos.z += 5.0f * Math_CosS(yaw); @@ -1054,7 +1056,7 @@ void EnPametfrog_LookAround(EnPametfrog* this, GlobalContext* globalCtx) { this->actor.shape.rot.y = this->actor.world.rot.y; if (SkelAnime_Update(&this->skelAnime) && (func_801690CC(globalCtx) == 0)) { if (!this->unk_2AE) { - func_801A2E54(0x38); + func_801A2E54(NA_BGM_MINI_BOSS); this->unk_2AE = true; } EnPametfrog_SetupJumpToLink(this); @@ -1274,7 +1276,7 @@ void EnPametfrog_SetupTransitionGekkoSnapper(EnPametfrog* this, GlobalContext* g void EnPametfrog_TransitionGekkoSnapper(EnPametfrog* this, GlobalContext* globalCtx) { if (this->actor.params == GEKKO_INIT_SNAPPER) { - func_801A2E54(0x38); + func_801A2E54(NA_BGM_MINI_BOSS); EnPametfrog_SetupRunToSnapper(this); } } diff --git a/src/overlays/actors/ovl_En_Part/z_en_part.c b/src/overlays/actors/ovl_En_Part/z_en_part.c index 9e184b1d94..4f9a7e64ff 100644 --- a/src/overlays/actors/ovl_En_Part/z_en_part.c +++ b/src/overlays/actors/ovl_En_Part/z_en_part.c @@ -1,7 +1,7 @@ /* * File: z_en_part.c * Overlay: ovl_En_Part - * Description: + * Description: Enemy body parts (spawned when dying) */ #include "z_en_part.h" diff --git a/src/overlays/actors/ovl_En_Pm/z_en_pm.c b/src/overlays/actors/ovl_En_Pm/z_en_pm.c index be1efeaf7f..2cf6b353fa 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -1,10 +1,11 @@ /* * File: z_en_pm.c * Overlay: ovl_En_Pm - * Description: Postman delivering letters + * Description: Postman */ #include "z_en_pm.h" +#include "overlays/actors/ovl_En_Door/z_en_door.h" #define FLAGS 0x00000039 @@ -18,7 +19,181 @@ void EnPm_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80AFA4D0(EnPm* this, GlobalContext* globalCtx); void func_80AFA5FC(EnPm* this, GlobalContext* globalCtx); -#if 0 +extern AnimationHeader D_06000468; +extern AnimationHeader D_0600099C; +extern AnimationHeader D_06000FC4; +extern AnimationHeader D_06001F84; +extern AnimationHeader D_06002238; +extern UNK_PTR D_06002750; +extern UNK_PTR D_06002950; +extern Gfx D_06008348[]; +extern Gfx D_060083E0[]; +extern Gfx D_060085C8[]; +extern FlexSkeletonHeader D_060096E8; +extern AnimationHeader D_060099B4; +extern AnimationHeader D_0600A4E0; +extern AnimationHeader D_0600A8D8; +extern AnimationHeader D_0600B09C; +extern AnimationHeader D_0600BA78; +extern AnimationHeader D_0600C32C; +extern AnimationHeader D_0600C640; + +// Game scripts +static UNK_TYPE D_80AFAD80[] = { + 0x0D000102, 0x3B030900, 0x0C00010B, 0x030C000D, 0x0100F902, 0x0D010F00, 0x12020F00, 0x00050105, 0x0A002E06, + 0x0E0F0000, 0x0508050A, 0x006D3102, 0x0D010D04, 0x25020D04, 0x0D151902, 0x0E300E38, 0x0D020E38, 0x0F000105, + 0x0E0E380F, 0x00020E0E, 0x300E383E, 0x0E0D040D, 0x15350E0D, 0x010D0401, 0x0A006F31, 0x020D040D, 0x1525020D, + 0x150D2719, 0x020E260E, 0x300D020E, 0x300E3801, 0x050E0E30, 0x0E383D0E, 0x0E260E30, 0x3C0E0D15, 0x0D27370E, + 0x0D040D15, 0x360A006C, 0x31020D27, 0x0D382502, 0x0D380E00, 0x19020E1A, 0x0E1E0D02, 0x0E1E0E26, 0x01050E0E, + 0x1E0E263B, 0x0E0E1A0E, 0x1E0B0E0D, 0x380E000A, 0x0E0D270D, 0x38380A00, 0x613D020D, 0x380E0031, 0x020E000E, + 0x0825020E, 0x080E1219, 0x020E120E, 0x1A0D020E, 0x1A0E1E01, 0x050E0E1A, 0x0E1E0D0E, 0x0E120E1A, 0x3A0E0E08, + 0x0E12100E, 0x0E000E08, 0x390E0D38, 0x0E000C05, 0x0A002E06, 0x0E0C000D, 0x0109050A, 0x006D3102, 0x09000903, + 0x25020903, 0x09111902, 0x0B2B0B39, 0x0D020B39, 0x0C000105, 0x0E0B390C, 0x00020E0B, 0x2B0B3934, 0x0E090309, + 0x11260E09, 0x00090301, 0x0A006F61, 0x02090309, 0x11550209, 0x11091F49, 0x02091F09, 0x233D0209, 0x23093131, + 0x020A390B, 0x0B25020B, 0x0B0B1919, 0x020B190B, 0x1D0D020B, 0x1D0B2B01, 0x050E0B1D, 0x0B2B320E, 0x0B190B1D, + 0x070E0B0B, 0x0B19300E, 0x0A390B0B, 0x2F0E0923, 0x0931290E, 0x091F0923, 0x030E0911, 0x091F280E, 0x09030911, + 0x270A006E, 0x25020931, 0x0A031902, 0x0A030A07, 0x0D020A07, 0x0A150105, 0x0E0A070A, 0x152B0E0A, 0x030A0704, + 0x0E09310A, 0x032A0A00, 0x6C61020A, 0x150A2355, 0x020A230A, 0x2749020A, 0x270A353D, 0x020A350A, 0x3931020A, + 0x390B0B25, 0x020B0B0B, 0x1919020B, 0x190B1D0D, 0x020B1D0B, 0x2B01050E, 0x0B1D0B2B, 0x330E0B19, 0x0B1D070E, + 0x0B0B0B19, 0x310E0A39, 0x0B0B2E0E, 0x0A350A39, 0x060E0A27, 0x0A352D0E, 0x0A230A27, 0x050E0A15, 0x0A232C05, + 0x0D000201, 0xCF011C08, 0x00A50309, 0x000C00FE, 0xC6030C00, 0x0D01008C, 0x020D010F, 0x007E0200, 0x00020001, + 0x050A006D, 0x31020000, 0x00042502, 0x0004001F, 0x1902011D, 0x01380D02, 0x01380200, 0x01050E01, 0x38020002, + 0x0E011D01, 0x384F0E00, 0x04001F4A, 0x0E000000, 0x04010A00, 0x6F3D0200, 0x04001F31, 0x02001F00, 0x3A250200, + 0x3A010219, 0x02010201, 0x1D0D0201, 0x1D013801, 0x050E011D, 0x01384E0E, 0x0102011D, 0x4D0E003A, 0x0102120E, + 0x001F003A, 0x4C0E0004, 0x001F4B05, 0x0A002E03, 0x04000E05, 0x0A002E06, 0x0E0C000D, 0x01140503, 0x09000C00, + 0xFE21030C, 0x000D0101, 0x0C020D01, 0x11001202, 0x11000005, 0x01050A00, 0x2E060E11, 0x00000508, 0x050A006D, + 0x31020D01, 0x0D042502, 0x0D040D0F, 0x19021023, 0x10390D02, 0x10391100, 0x01050E10, 0x39110002, 0x0E102310, + 0x39490E0D, 0x040D0F3F, 0x0E0D010D, 0x04010A00, 0x6F31020D, 0x040D0F25, 0x020D0F0D, 0x1E19020D, 0x340E2D0D, + 0x02100F10, 0x2301050E, 0x100F1023, 0x480E0D34, 0x0E2D430E, 0x0D0F0D1E, 0x410E0D04, 0x0D0F400A, 0x006C1902, + 0x0D1E0D34, 0x0D020D34, 0x0E320105, 0x0E0D340E, 0x32440E0D, 0x1E0D3442, 0x0A007068, 0x020E2D0F, 0x055C0C00, + 0x0231020F, 0x050F1425, 0x020F140F, 0x1919020F, 0x190F280D, 0x020F2810, 0x0F01050E, 0x0F28100F, 0x510E0F19, + 0x0F28110E, 0x0F140F19, 0x500E0F05, 0x0F141702, 0x0F050F14, 0x1B020F14, 0x0F320F02, 0x0F32100F, 0x03040000, + 0x0E0F3210, 0x0F470E0F, 0x140F3219, 0x0E0F050F, 0x14170E0E, 0x2D0F0546, 0x050A002E, 0x060E0C00, 0x0D011505, + 0x0D000301, 0x6F011C08, 0x013F011C, 0x10010C03, 0x09000C00, 0xFCED030C, 0x000D0100, 0xF6020D01, 0x0F000F02, + 0x12000600, 0x01050A00, 0x2E030400, 0x18050A00, 0x6D31020D, 0x000D0125, 0x020D050D, 0x0F19020E, 0x2D0E370D, + 0x020E370F, 0x0001050E, 0x0E370F00, 0x020E0E2D, 0x0E37340E, 0x0D050D0F, 0x260E0D00, 0x0D01010A, 0x006F4902, + 0x0D050D0F, 0x3D020D0F, 0x0D193102, 0x0D190D23, 0x25020E0F, 0x0E191902, 0x0E190E23, 0x0D020E23, 0x0E2D0105, + 0x0E0E230E, 0x2D320E0E, 0x190E2330, 0x0E0E0F0E, 0x192F0E0D, 0x190D2329, 0x0E0D0F0D, 0x19280E0D, 0x050D0F27, + 0x0A006E19, 0x020D230D, 0x2D0D020D, 0x2D0D3701, 0x050E0D2D, 0x0D372B0E, 0x0D230D2D, 0x2A0A006C, 0x3D020D37, + 0x0E053102, 0x0E050E0F, 0x25020E0F, 0x0E191902, 0x0E190E23, 0x0D020E23, 0x0E2D0105, 0x0E0E230E, 0x2D330E0E, + 0x190E2331, 0x0E0E0F0E, 0x192E0E0E, 0x050E0F2D, 0x0E0D370E, 0x052C050A, 0x002E0304, 0x00160503, 0x09000C00, + 0xFBE1020C, 0x000D0116, 0x030D0111, 0x00FDD202, 0x12000600, 0x01050A00, 0x2E030400, 0x18050A00, 0x2E060E0C, + 0x000D0115, 0x05030900, 0x0C00FBB3, 0x020C000D, 0x0116030D, 0x010F00FE, 0xD5021200, 0x06000105, 0x0A002E03, + 0x04001805, 0x0A002E03, 0x04001405, 0x05000000, +}; + +static UNK_TYPE D_80AFB30C[] = { + 0x0A002E2E, 0x02000000, 0x0A220200, 0x0A000D19, 0x02000D00, 0x170D0200, 0x17001A01, 0x050E0017, 0x001A200E, + 0x000D0017, 0x5304001B, 0x0E000000, 0x0A520A00, 0x6D190200, 0x17001A0D, 0x02001A00, 0x2401050E, 0x001A0024, + 0x540E0017, 0x001A210A, 0x006F1902, 0x001A0024, 0x0D020024, 0x002E0105, 0x0E002400, 0x2E560E00, 0x1A002455, + 0x0A006C19, 0x02002E00, 0x380D0200, 0x38003B01, 0x050E0038, 0x003B220E, 0x002E0038, 0x570A0015, 0x25020038, + 0x003B1902, 0x003B0109, 0x0D020109, 0x01280105, 0x0E010901, 0x281C0E00, 0x3B010958, 0x0E003800, 0x3B240500, +}; + +static UNK_TYPE D_80AFB3C0[] = { + 0x0A006C19, 0x02000A00, 0x0D0D0200, 0x0D001701, 0x050E000D, 0x00175A0E, 0x000A000D, 0x230A0015, + 0x19020000, 0x000A0D02, 0x000A000D, 0x01050E00, 0x0A000D25, 0x0E000000, 0x0A590500, +}; + +static UNK_TYPE D_80AFB3FC[] = { + 0x0A006C19, 0x02120006, 0x000D0205, 0x00050A01, 0x050E0500, 0x050A5B0E, 0x12000600, 0x1D050000, +}; + +static UNK_TYPE D_80AFB41C[] = { + 0x0A006C0D, 0x02000000, 0x0A01050E, 0x0000000A, 0x5B050000, +}; + +static s32 D_80AFB430[] = { + -1, 0, 4, 1, 0, 0, 1, 4, -1, -1, 15, 5, 0, 3, -1, -1, 1, 2, 11, 3, -1, -1, -1, 0, 0, 0, 0, 0, 1, 12, -1, + -1, 2, 0, 10, 11, 0, 3, 1, 0, 1, 2, 0, 1, 0, 1, 2, 3, 4, 3, 5, 14, 3, 1, 0, 6, 4, 1, 2, 6, 7, 8, + 2, 1, 0, 6, 7, 9, 8, -1, 0, 1, 10, 3, 1, 0, 11, 12, 8, 2, 2, 3, 0, 1, 1, 0, 6, 9, 1, 2, 12, 13, +}; + +// Game scripts +static UNK_TYPE D_80AFB5A0[] = { + 0x00560800, 0x45090000, 0x170E28BA, 0x0C090000, 0x180E28BB, 0x0C090000, 0x170E28BC, 0x0C090000, 0x180E28BD, + 0x0C090000, 0x170E28BE, 0x0C090000, 0x180E28BF, 0x0C090000, 0x170E28C0, 0x2D00012D, 0x000B0C09, 0x00001156, + 0x08100900, 0x00170E29, 0x5C0C0900, 0x00180E29, 0x5D0C0900, 0x00170E29, 0x5E2D0001, 0x2D000B0C, 0x09000010, +}; + +static UNK_TYPE D_80AFB60C[] = { + 0x0E27742D, + 0x000B0C10, +}; + +static UNK_TYPE D_80AFB614[] = { + 0x0E27752D, + 0x000B0C10, +}; + +static UNK_TYPE D_80AFB61C[] = { + 0x0E27772D, + 0x000B0C10, +}; + +static UNK_TYPE D_80AFB624[] = { + 0x0E27782D, + 0x000B0C10, +}; + +static UNK_TYPE D_80AFB62C[] = { + 0x0E27792D, + 0x000B0C10, +}; + +static UNK_TYPE D_80AFB634[] = { + 0x0E27812D, + 0x000B0C10, +}; + +static UNK_TYPE D_80AFB63C[] = { + 0x0E277A2D, + 0x000B0C10, +}; + +static UNK_TYPE D_80AFB644[] = { + 0x0E27822D, + 0x000B0C11, + 0x58021000, +}; + +static UNK_TYPE D_80AFB650[] = { + 0x0E27832D, + 0x000B0C10, +}; + +static UNK_TYPE D_80AFB658[] = { + 0x25002E00, 0x1A005280, 0x000C0E27, 0x7C2D000B, 0x0C115280, 0x12100E27, 0x7D2D000B, 0x0C12100E, 0x277C0C0E, + 0x00FF1E00, 0x33000000, 0x1800282C, 0xFFFF0900, 0x000E277E, 0x2D000B0C, 0x11528011, 0x56012A00, 0x2E12102C, + 0x277D0C2F, 0x00002D00, 0x0B0C1152, 0x8012100E, 0x277D2D00, 0x0B0C1152, 0x80121000, +}; + +static UNK_TYPE D_80AFB6BC[] = { + 0x0900000E, 0x27A50C09, 0x0000170E, 0x27A60C09, 0x0000180E, 0x27A70C09, 0x0000170E, + 0x27A80C09, 0x0000180E, 0x27A90C09, 0x0000170E, 0x27AA0C09, 0x0000180E, 0x27AB0C09, + 0x0000170E, 0x27AC0C09, 0x0000180E, 0x27AD2D00, 0x0B2D0008, 0x0C115908, 0x09000010, +}; + +static UNK_TYPE D_80AFB710[] = { + 0x25003E00, 0x230E2780, 0x0C0F27AE, 0x0C120600, 0x84000013, 0x0084115A, 0x042F0000, + 0x2E2D000B, 0x2D00310C, 0x115A0110, 0x0E27802D, 0x000B0C11, 0x5A011210, +}; + +static UNK_TYPE D_80AFB744[] = { + 0x0E23692D, + 0x000B0C10, +}; + +static UNK_TYPE D_80AFB74C[] = { + 0x2CFFFF09, 0x00000E27, 0x7E2D000B, 0x0C115280, 0x1156012A, 0x002E1210, +}; + +static UNK_TYPE D_80AFB764[] = { + 0x2C277D2D, + 0x000B0C11, + 0x52801210, +}; + const ActorInit En_Pm_InitVars = { ACTOR_EN_PM, ACTORCAT_NPC, @@ -31,128 +206,1705 @@ const ActorInit En_Pm_InitVars = { (ActorFunc)EnPm_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80AFB790 = { - { COLTYPE_HIT1, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT1, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 14, 62, 0, { 0, 0, 0 } }, }; -// static ColliderSphereInit sSphereInit = { -static ColliderSphereInit D_80AFB7BC = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_SPHERE, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderSphereInit sSphereInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_SPHERE, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 26 }, 100 }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80AFB7E8 = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -#endif +static ActorAnimationEntryS sAnimations[] = { + { &D_06002238, 1.0f, 0, -1, 0, 0 }, { &D_06002238, 1.0f, 0, -1, 0, -4 }, { &D_0600A4E0, 1.0f, 0, -1, 2, 0 }, + { &D_0600B09C, 1.0f, 0, -1, 0, 0 }, { &D_0600B09C, 1.0f, 0, -1, 0, -4 }, { &D_0600BA78, 1.0f, 0, -1, 2, 0 }, + { &D_0600C32C, 1.0f, 0, -1, 0, -4 }, { &D_060099B4, 1.0f, 0, -1, 0, 0 }, { &D_06000FC4, 1.0f, 0, -1, 0, 0 }, + { &D_0600A8D8, 1.0f, 0, -1, 0, 0 }, { &D_0600099C, 1.0f, 0, -1, 0, 0 }, { &D_06001F84, 1.0f, 0, -1, 2, 0 }, + { &D_06000468, 1.0f, 0, -1, 0, 0 }, { &D_0600C640, 1.0f, 0, -1, 0, 0 }, +}; -extern ColliderCylinderInit D_80AFB790; -extern ColliderSphereInit D_80AFB7BC; -extern CollisionCheckInfoInit2 D_80AFB7E8; +s32 func_80AF7B40(void) { + if (gSaveContext.weekEventReg[90] & 1) { + return 4; + } -extern UNK_TYPE D_06008348; -extern UNK_TYPE D_060096E8; + if (gSaveContext.weekEventReg[89] & 0x40) { + return 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AF7B40.s") + if (gSaveContext.weekEventReg[89] & 8) { + return 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AF7BAC.s") + if (gSaveContext.weekEventReg[86] & 1) { + return 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AF7CB0.s") + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AF7D60.s") +s32 func_80AF7BAC(EnPm* this) { + switch (this->unk_38C) { + case 0: + if (gSaveContext.weekEventReg[86] & 1) { + D_801F4E78 = gSaveContext.time; + this->unk_38C++; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AF7DC4.s") + case 1: + if (gSaveContext.weekEventReg[89] & 8) { + D_801F4E78 = gSaveContext.time; + this->unk_38C++; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AF7E6C.s") + case 2: + if (gSaveContext.weekEventReg[89] & 0x40) { + D_801F4E78 = 0; + this->unk_38C++; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AF7E98.s") + case 3: + if (gSaveContext.weekEventReg[90] & 1) { + D_801F4E78 = gSaveContext.time; + this->unk_38C++; + } + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AF7F68.s") + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AF8040.s") +Actor* func_80AF7CB0(EnPm* this, GlobalContext* globalCtx, u8 actorCat, s16 actorId) { + Actor* phi_s0 = NULL; + Actor* actor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AF80F4.s") + while (true) { + actor = func_ActorCategoryIterateById(globalCtx, phi_s0, actorCat, actorId); + phi_s0 = actor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AF8170.s") + if (actor == NULL) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AF81E8.s") + if (((EnPm*)phi_s0 != this) && (actor->update != NULL)) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AF8348.s") + actor = actor->next; + if (actor == NULL) { + phi_s0 = NULL; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AF8478.s") + phi_s0 = actor; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AF8540.s") + return phi_s0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AF86F0.s") +Actor* func_80AF7D60(GlobalContext* globalCtx, s32 arg1) { + s32 phi_a1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AF87C4.s") + switch (arg1) { + case 1: + case 2: + case 32: + case 33: + phi_a1 = 1; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AF8890.s") + case 34: + case 35: + case 36: + case 37: + phi_a1 = 10; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AF898C.s") + case 10: + case 11: + case 12: + case 13: + phi_a1 = 11; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AF8AC8.s") + default: + return NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AF8BA8.s") + return func_8013A7C0(globalCtx, phi_a1); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AF8C68.s") +Actor* func_80AF7DC4(EnPm* this, GlobalContext* globalCtx, s32 arg2) { + Actor* phi_s0 = NULL; + Actor* actor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AF8D84.s") + while (true) { + actor = func_ActorCategoryIterateById(globalCtx, phi_s0, ACTORCAT_PROP, ACTOR_EN_PST); + phi_s0 = actor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AF8DD4.s") + if (actor == NULL) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AF8ED4.s") + if (((EnPm*)actor != this) && (actor->update != NULL) && (actor->params == (s16)arg2)) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AF9008.s") + actor = actor->next; + if (actor == NULL) { + phi_s0 = NULL; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AF91E8.s") + phi_s0 = actor; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AF94AC.s") + return phi_s0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AF95E8.s") +void func_80AF7E6C(EnPm* this) { + this->skelAnime.playSpeed = this->unk_35C; + SkelAnime_Update(&this->skelAnime); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AF98A0.s") +s32 func_80AF7E98(EnPm* this, s32 arg1) { + s32 phi_v1 = false; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AF992C.s") + switch (arg1) { + case 0: + case 1: + if ((this->unk_384 != 0) && (this->unk_384 != 1)) { + phi_v1 = true; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AF9A0C.s") + case 3: + case 4: + if ((this->unk_384 != 3) && (this->unk_384 != 4)) { + phi_v1 = true; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AF9AB0.s") + default: + if (arg1 != this->unk_384) { + phi_v1 = true; + } + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AF9B54.s") + if (phi_v1) { + this->unk_384 = arg1; + ret = func_8013BC6C(&this->skelAnime, sAnimations, arg1); + this->unk_35C = this->skelAnime.playSpeed; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AF9BF8.s") + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AF9D04.s") +void func_80AF7F68(EnPm* this, GlobalContext* globalCtx) { + f32 temp; + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AF9E7C.s") + switch (this->unk_258) { + case 9: + case 20: + case 21: + case 22: + case 24: + temp = this->colliderSphere.dim.modelSphere.radius * this->colliderSphere.dim.scale; + this->colliderSphere.dim.worldSphere.radius = temp; + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere.base); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AFA170.s") + default: + Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); + temp = this->actor.focus.pos.y - this->actor.world.pos.y; + this->colliderCylinder.dim.height = temp; + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AFA334.s") +Actor* func_80AF8040(EnPm* this, GlobalContext* globalCtx) { + Actor* actor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AFA438.s") + switch (this->unk_258) { + case 16: + actor = func_80AF7CB0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AN); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AFA4D0.s") + case 17: + actor = func_80AF7CB0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_TEST3); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AFA5FC.s") + case 28: + actor = func_80AF7CB0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AL); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AFA724.s") + case 3: + case 4: + case 5: + case 6: + case 7: + actor = func_80AF7DC4(this, globalCtx, this->unk_258 - 3); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/EnPm_Init.s") + case 19: + actor = func_80AF7DC4(this, globalCtx, 4); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/EnPm_Destroy.s") + case 18: + actor = func_80AF7DC4(this, globalCtx, 4); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/EnPm_Update.s") + default: + actor = &GET_PLAYER(globalCtx)->actor; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AFAA04.s") + return actor; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AFAA44.s") +s32 func_80AF80F4(EnPm* this, s16 arg1) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/func_80AFABAC.s") + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(arg1); + } else if (ActorCutscene_GetCanPlayNext(arg1)) { + ActorCutscene_StartAndSetUnkLinkFields(arg1, &this->actor); + ret = true; + } else { + ActorCutscene_SetIntentToPlay(arg1); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pm/EnPm_Draw.s") +s16 func_80AF8170(EnPm* this, s32 arg1) { + s32 i; + s16 cs = -1; + + if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { + cs = this->actor.child->cutscene; + + for (i = 0; i < arg1; i++) { + cs = ActorCutscene_GetAdditionalCutscene(cs); + } + } + return cs; +} + +s32 func_80AF81E8(EnPm* this, GlobalContext* globalCtx) { + s32 pad; + s16 sp2A = func_80AF8170(this, 0); + s32 ret = false; + + switch (this->unk_378) { + case 0: + if (!func_80AF80F4(this, sp2A)) { + break; + } + + case 2: + case 4: + case 6: + if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { + func_800E0308(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), this->actor.child); + } + this->unk_378++; + ret = true; + break; + + case 1: + case 3: + case 5: + if ((gSaveContext.weekEventReg[86] & 8) && (this->unk_378 == 3)) { + ActorCutscene_Stop(sp2A); + } else { + func_800E0308(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); + } + this->unk_378++; + ret = true; + break; + + case 7: + ActorCutscene_Stop(sp2A); + this->unk_378++; + ret = true; + break; + } + return ret; +} + +s32 func_80AF8348(EnPm* this, GlobalContext* globalCtx) { + s32 pad; + s16 sp2A = func_80AF8170(this, 0); + s32 ret = false; + + switch (this->unk_378) { + case 0: + if (!func_80AF80F4(this, sp2A)) { + break; + } + + case 2: + case 4: + case 6: + case 8: + func_800E0308(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); + this->unk_378++; + ret = true; + break; + + case 1: + case 3: + case 5: + case 7: + if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { + func_800E0308(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), this->actor.child); + } + this->unk_378++; + ret = true; + break; + + case 9: + ActorCutscene_Stop(sp2A); + this->unk_378++; + ret = true; + break; + } + + return ret; +} + +s32 func_80AF8478(EnPm* this, GlobalContext* globalCtx) { + s32 pad; + s32 ret = false; + + switch (this->unk_378) { + case 0: + func_80AF7E98(this, 2); + this->unk_356 &= ~0x20; + this->unk_356 |= 0x200; + this->unk_378++; + break; + + case 1: + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80AF7E98(this, 4); + this->unk_356 &= ~0x200; + this->unk_356 |= 0x20; + this->unk_378++; + ret = true; + } + break; + } + return ret; +} + +UNK_TYPE* func_80AF8540(EnPm* this, GlobalContext* globalCtx) { + switch (this->unk_258) { + case 28: + this->unk_37C = func_80AF8348; + return D_80AFB6BC; + + case 29: + return D_80AFB710; + + case 16: + this->unk_37C = func_80AF81E8; + return D_80AFB5A0; + + case 17: + return D_80AFB644; + + case 24: + if (this->unk_356 & 0x2000) { + this->unk_37C = func_80AF8478; + return D_80AFB74C; + } else if (this->unk_356 & 0x4000) { + return D_80AFB764; + } else { + this->unk_37C = func_80AF8478; + return D_80AFB658; + } + break; + + case 25: + return D_80AFB650; + + default: + if (Player_GetMask(globalCtx) == PLAYER_MASK_KAFEI) { + return D_80AFB744; + } + + switch (this->unk_258) { + case 9: + return D_80AFB614; + + case 14: + return D_80AFB624; + + case 20: + return D_80AFB61C; + + case 21: + return D_80AFB634; + + case 22: + return D_80AFB63C; + + case 18: + case 74: + case 75: + case 76: + case 77: + case 78: + case 79: + return D_80AFB62C; + + default: + return D_80AFB60C; + } + break; + } +} + +s32 func_80AF86F0(EnPm* this, GlobalContext* globalCtx) { + s32 ret = false; + + if ((this->unk_356 & 7) && func_800B84D0(&this->actor, globalCtx)) { + func_8013AED4(&this->unk_356, 0, 7); + this->unk_398 = 0; + this->unk_378 = 0; + this->unk_37C = NULL; + this->actor.child = this->unk_268; + this->unk_25C = func_80AF8540(this, globalCtx); + if ((this->unk_258 != 24) && (this->unk_258 != 9) && (this->unk_258 != 20) && (this->unk_258 != 21) && + (this->unk_258 != 22)) { + this->unk_356 |= 0x20; + } + this->actionFunc = func_80AFA5FC; + ret = true; + } + return ret; +} + +s32 func_80AF87C4(EnPm* this, GlobalContext* globalCtx) { + s32 ret = false; + + if ((globalCtx->csCtx.state != 0) && (globalCtx->sceneNum == SCENE_00KEIKOKU) && + (gSaveContext.sceneSetupIndex == 9) && (globalCtx->curSpawn == 1)) { + if (!this->unk_380) { + func_80AF7E98(this, 0); + this->unk_258 = 255; + this->unk_380 = true; + this->actor.speedXZ = 4.0f; + this->actor.gravity = -1.0f; + } + ret = true; + } else if (this->unk_380) { + this->unk_258 = 0; + this->unk_380 = false; + this->actor.speedXZ = 0.0f; + } + return ret; +} + +void func_80AF8890(EnPm* this, Gfx** gfx, s32 arg2) { + Matrix_StatePush(); + + switch (arg2) { + case 0: + if (this->unk_356 & 0x800) { + gSPDisplayList((*gfx)++, D_06008348); + } + break; + + case 1: + if (this->unk_356 & 0x1000) { + gSPDisplayList((*gfx)++, D_060085C8); + } + break; + + case 2: + if (this->unk_356 & 0x1000) { + gSPDisplayList((*gfx)++, D_060083E0); + } + break; + } + + Matrix_StatePop(); +} + +void func_80AF898C(EnPm* this) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + s32 pad2; + + Math_Vec3f_Copy(&sp40, &this->unk_268->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + Math_ApproachS(&this->unk_372, Math_Vec3f_Yaw(&sp34, &sp40) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_372 = CLAMP(this->unk_372, -0x1FFE, 0x1FFE); + Math_Vec3f_Copy(&sp34, &this->actor.focus.pos); + if (this->unk_268->id == ACTOR_PLAYER) { + sp40.y = ((Player*)this->unk_268)->bodyPartsPos[7].y + 3.0f; + } else { + Math_Vec3f_Copy(&sp40, &this->unk_268->focus.pos); + } + Math_ApproachS(&this->unk_370, Math_Vec3f_Pitch(&sp34, &sp40), 4, 0x2AA8); + this->unk_370 = CLAMP(this->unk_370, -0x1554, 0x1554); +} + +void func_80AF8AC8(EnPm* this) { + if ((this->unk_356 & 0x20) && (this->unk_268 != NULL) && (this->unk_268->update != NULL)) { + if (DECR(this->unk_376) == 0) { + func_80AF898C(this); + this->unk_356 &= ~0x200; + this->unk_356 |= 0x80; + return; + } + } + + if (this->unk_356 & 0x80) { + this->unk_356 &= ~0x80; + this->unk_370 = 0; + this->unk_372 = 0; + this->unk_376 = 20; + } else if (DECR(this->unk_376) == 0) { + this->unk_356 |= 0x200; + } +} + +void func_80AF8BA8(s32 arg0) { + static u16 D_80AFB8D4[] = { + 0x1B02, 0x1B04, 0x1B08, 0x1B10, 0x1B20, 0x0000, + }; + static u16 D_80AFB8E0[] = { + 0x1B40, 0x1B80, 0x1C01, 0x1C02, 0x1C04, 0x0000, + }; + s32 temp; + + if (!(gSaveContext.weekEventReg[88] & 2)) { + if (gSaveContext.weekEventReg[D_80AFB8D4[arg0] >> 8] & (D_80AFB8D4[arg0] & 0xFF)) { + switch (gSaveContext.day) { + case 2: + gSaveContext.weekEventReg[28] |= 8; + break; + + case 3: + gSaveContext.weekEventReg[28] |= 0x10; + break; + } + gSaveContext.weekEventReg[51] |= 2; + gSaveContext.weekEventReg[90] |= 8; + } + } + + temp = gSaveContext.weekEventReg[D_80AFB8E0[arg0] >> 8]; + gSaveContext.weekEventReg[D_80AFB8E0[arg0] >> 8] = temp | (D_80AFB8E0[arg0] & 0xFF); +} + +void func_80AF8C68(EnPm* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 sp28 = func_80152498(&globalCtx->msgCtx); + u16 temp_a0 = globalCtx->msgCtx.unk11F04; + + if ((player->targetActor == &this->actor) && ((temp_a0 < 255) || (temp_a0 > 512)) && (sp28 == 3) && + (this->unk_388 == 3)) { + if ((globalCtx->state.frames % 3) == 0) { + if (this->unk_360 == 120.0f) { + this->unk_360 = 0.0f; + } else { + this->unk_360 = 120.0f; + } + } + } else { + this->unk_360 = 0.0f; + } + Math_SmoothStepToF(&this->unk_364, this->unk_360, 0.8f, 40.0f, 10.0f); + Matrix_InsertTranslation(this->unk_364, 0.0f, 0.0f, 1); + this->unk_388 = sp28; +} + +s32 func_80AF8D84(EnPm* this, GlobalContext* globalCtx) { + switch (this->unk_384) { + case 10: + func_80AF7E98(this, 9); + break; + + case 7: + func_80AF7E98(this, 0); + break; + } + return true; +} + +s32 func_80AF8DD4(EnPm* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + u16 temp = globalCtx->msgCtx.unk11F04; + s32 pad; + + if (player->stateFlags1 & (0x400 | 0x40)) { + this->unk_356 |= 0x400; + if (this->unk_358 != temp) { + if ((this->unk_384 == 0) || (this->unk_384 == 1)) { + func_80AF7E98(this, 7); + } + if ((temp == 0x277C) || (temp == 0x277D)) { + func_80AF7E98(this, 10); + } + } + this->unk_358 = temp; + } else { + if (this->unk_356 & 0x400) { + this->unk_358 = 0; + this->unk_356 &= ~0x400; + func_80AF8D84(this, globalCtx); + } + } + + if (this->unk_18C != NULL) { + this->unk_18C(this, globalCtx); + } + + return 0; +} + +s32 func_80AF8ED4(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2, u8 actorCat, s16 actorId) { + u8 sp4F = this->actor.params & 0xFF; + Vec3s* sp48; + Vec3f sp3C; + Vec3f sp30; + Actor* sp2C; + s32 pad; + s32 ret = false; + + this->unk_234 = NULL; + sp2C = func_80AF7CB0(this, globalCtx, actorCat, actorId); + if (D_80AFB430[arg2->unk0] >= 0) { + this->unk_234 = func_8013BB34(globalCtx, sp4F, D_80AFB430[arg2->unk0]); + } + + if ((sp2C != NULL) && (sp2C->update != NULL)) { + if (this->unk_234 != NULL) { + sp48 = (Vec3s*)Lib_SegmentedToVirtual(this->unk_234->points); + Math_Vec3s_ToVec3f(&sp3C, &sp48[this->unk_234->count - 2]); + Math_Vec3s_ToVec3f(&sp30, &sp48[this->unk_234->count - 1]); + this->actor.shape.shadowDraw = NULL; + this->actor.world.rot.y = Math_Vec3f_Yaw(&sp3C, &sp30); + Math_Vec3f_Copy(&this->actor.world.pos, &sp30); + ret = true; + } + } + + return ret; +} + +s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + u16 sp56 = gSaveContext.time - 0x3FFC; + u8 sp55 = this->actor.params & 0xFF; + Actor* sp50; + Vec3s* sp4C; + Vec3f sp40; + Vec3f sp34; + s16 temp; + s32 ret = false; + + this->unk_234 = NULL; + sp50 = func_80AF7D60(globalCtx, arg2->unk0); + if (D_80AFB430[arg2->unk0] >= 0) { + this->unk_234 = func_8013BB34(globalCtx, sp55, D_80AFB430[arg2->unk0]); + } + + if ((sp50 != NULL) && (sp50->update != NULL)) { + if (this->unk_234 != 0) { + sp4C = (Vec3s*)Lib_SegmentedToVirtual(this->unk_234->points); + Math_Vec3s_ToVec3f(&sp40, &sp4C[0]); + Math_Vec3s_ToVec3f(&sp34, &sp4C[1]); + Math_Vec3f_Copy(&this->unk_26C, &sp40); + Math_Vec3f_Copy(&this->unk_278, &sp34); + this->actor.world.rot.y = Math_Vec3f_Yaw(&sp40, &sp34); + Math_Vec3f_Copy(&this->actor.world.pos, &sp40); + temp = this->actor.world.rot.y - sp50->shape.rot.y; + if (ABS_ALT(temp) <= 0x4000) { + this->unk_260 = -0x4B; + } else { + this->unk_260 = 0x4B; + } + + this->unk_36C = arg2->unk8 - arg2->unk4; + this->unk_36E = sp56 - arg2->unk4; + this->actor.flags &= ~1; + if (gSaveContext.weekEventReg[90] & 8) { + this->unk_356 |= 0x800; + } + this->unk_356 |= 0x9000; + this->unk_356 |= 0x200; + func_80AF7E98(this, 0); + this->actor.gravity = 0.0f; + ret = true; + } + } + return ret; +} + +s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + u16 sp2E = (u16)(gSaveContext.time - 0x3FFC); + u16 phi_v1; + u8 sp2B = this->actor.params & 0xFF; + s32 pad; + s32 ret = false; + + this->unk_234 = NULL; + + if (D_80AFB430[arg2->unk0] >= 0) { + this->unk_234 = func_8013BB34(globalCtx, sp2B, D_80AFB430[arg2->unk0]); + } + + if ((this->unk_234 != NULL) && (this->unk_234->count < 3)) { + this->unk_234 = NULL; + } + + if (this->unk_234 != 0) { + if ((this->unk_258 < 38) && (this->unk_258 != 0) && (this->unk_374 >= 0)) { + phi_v1 = sp2E; + } else { + phi_v1 = arg2->unk4; + } + + if (arg2->unk8 < phi_v1) { + this->unk_248 = (phi_v1 - arg2->unk8) + 0xFFFF; + } else { + this->unk_248 = arg2->unk8 - phi_v1; + } + + this->unk_254 = sp2E - phi_v1; + phi_v1 = this->unk_234->count - 2; + this->unk_24C = this->unk_248 / phi_v1; + this->unk_250 = (this->unk_254 / this->unk_24C) + 2; + this->unk_356 &= ~8; + this->unk_356 &= ~0x10; + if (this->unk_258 == 27) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_ROOM_CARTAIN); + Actor_UnsetSwitchFlag(globalCtx, 0); + } + + switch (arg2->unk0) { + case 83: + case 84: + case 85: + case 86: + case 87: + case 88: + case 89: + case 90: + this->unk_356 |= 0x9000; + this->unk_356 |= 0x200; + + case 82: + func_80AF7E98(this, 0); + break; + + case 91: + this->unk_356 |= 0x9000; + func_80AF7E98(this, 12); + break; + + default: + func_8013AED4(&this->unk_356, 3, 7); + func_80AF7E98(this, 0); + if (gSaveContext.weekEventReg[90] & 8) { + this->unk_356 |= 0x800; + } + this->unk_356 |= 0x9000; + this->unk_356 |= 0x200; + break; + } + + this->actor.gravity = -1.0f; + ret = true; + } + + return ret; +} + +s32 func_80AF94AC(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + u8 sp4F = this->actor.params & 0xFF; + Vec3f sp40; + Vec3f sp34; + Vec3s* sp30; + s32 pad; + s32 ret = false; + + this->unk_234 = NULL; + if (D_80AFB430[arg2->unk0] >= 0) { + this->unk_234 = func_8013BB34(globalCtx, sp4F, D_80AFB430[arg2->unk0]); + } + + if ((this->unk_234 != 0) && (this->unk_234->count >= 2)) { + sp30 = (Vec3s*)Lib_SegmentedToVirtual(this->unk_234->points); + Math_Vec3s_ToVec3f(&sp40, &sp30[0]); + Math_Vec3s_ToVec3f(&sp34, &sp30[1]); + this->actor.world.rot.y = Math_Vec3f_Yaw(&sp40, &sp34); + Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); + Math_Vec3f_Copy(&this->actor.world.pos, &sp40); + Math_Vec3f_Copy(&this->actor.prevPos, &sp40); + if (arg2->unk0 == 24) { + Actor_UnsetSwitchFlag(globalCtx, 0); + Actor_UnsetSwitchFlag(globalCtx, 1); + this->unk_394 = 0; + this->unk_368 = 60.0f; + func_80AF7E98(this, 9); + } + ret = true; + } + return ret; +} + +s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + u8 sp4F = this->actor.params & 0xFF; + Vec3f sp40; + Vec3f sp34; + Vec3s* sp30; + s32 pad; + s32 ret = false; + s32 phi_a3 = -1; + + switch (arg2->unk0) { + case 3: + case 4: + case 5: + case 6: + case 7: + phi_a3 = arg2->unk0 - 3; + break; + + case 19: + phi_a3 = 4; + break; + } + + if ((phi_a3 >= 0) && !func_80AF7DC4(this, globalCtx, phi_a3)) { + return ret; + } + + this->unk_234 = NULL; + phi_a3 = D_80AFB430[arg2->unk0]; + if (phi_a3 >= 0) { + this->unk_234 = func_8013BB34(globalCtx, sp4F, phi_a3); + } + + if ((this->unk_234 != 0) && (this->unk_234->count >= 2)) { + sp30 = (Vec3s*)Lib_SegmentedToVirtual(this->unk_234->points); + Math_Vec3s_ToVec3f(&sp40, &sp30[this->unk_234->count - 1]); + Math_Vec3s_ToVec3f(&sp34, &sp30[this->unk_234->count - 2]); + this->actor.world.rot.y = Math_Vec3f_Yaw(&sp34, &sp40); + Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); + Math_Vec3f_Copy(&this->actor.world.pos, &sp40); + Math_Vec3f_Copy(&this->actor.prevPos, &sp40); + + switch (arg2->unk0) { + case 27: + Audio_PlayActorSound2(&this->actor, NA_SE_EV_ROOM_CARTAIN); + Actor_SetSwitchFlag(globalCtx, 0); + this->unk_36C = 20; + func_8013AED4(&this->unk_356, 3, 7); + func_80AF7E98(this, 3); + break; + + case 3: + case 4: + case 5: + case 6: + case 7: + case 19: + this->unk_356 |= 0x9000; + func_80AF7E98(this, 11); + break; + + case 18: + this->unk_356 |= 0x9000; + this->unk_356 |= 0x800; + func_80AF7E98(this, 5); + break; + + case 23: + if (gSaveContext.weekEventReg[90] & 8) { + this->unk_356 |= 0x800; + } + gSaveContext.weekEventReg[60] |= 4; + + default: + if (arg2->unk0 == 0x1D) { + this->actor.world.rot.y = BINANG_ROT180(this->actor.world.rot.y); + } + func_8013AED4(&this->unk_356, 3, 7); + this->unk_356 |= 0x9000; + func_80AF7E98(this, 3); + break; + } + ret = true; + } + return ret; +} + +s32 func_80AF98A0(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + s32 ret = false; + + if (Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_MM3, 116.0f, 26.0f, -219.0f, 0, + -0x3F46, 0, 0) != NULL) { + Actor_MarkForDeath(&this->actor); + ret = true; + } + return ret; +} + +s32 func_80AF992C(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + static Vec3f D_80AFB8EC = { 116.0f, 26.0f, -219.0f }; + static Vec3s D_80AFB8F8 = { 0x0000, 0xC0BA, 0x0000 }; + s32 pad; + + Math_Vec3f_Copy(&this->actor.world.pos, &D_80AFB8EC); + Math_Vec3s_Copy(&this->actor.world.rot, &D_80AFB8F8); + Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); + func_8013AED4(&this->unk_356, 3, 7); + this->actor.targetMode = 6; + this->actor.gravity = -1.0f; + this->unk_368 = 80.0f; + if (arg2->unk0 == 14) { + this->unk_356 &= ~0x200; + func_80AF7E98(this, 13); + } else { + this->unk_356 &= ~0x200; + func_80AF7E98(this, 8); + } + return true; +} + +s32 func_80AF9A0C(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + s32 ret = false; + + if (func_80AF8ED4(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_AN)) { + func_8013AED4(&this->unk_356, 3, 7); + this->unk_356 |= 0x20; + this->unk_356 |= 0x9000; + if (this->unk_258 != 0) { + this->unk_356 |= 0x800; + func_80AF7E98(this, 5); + } else { + func_80AF7E98(this, 3); + } + ret = true; + } + return ret; +} + +s32 func_80AF9AB0(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + s32 ret = false; + + if (func_80AF8ED4(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_TEST3)) { + func_8013AED4(&this->unk_356, 3, 7); + this->unk_356 |= 0x20; + this->unk_356 |= 0x9000; + if (this->unk_258 != 0) { + this->unk_356 |= 0x800; + func_80AF7E98(this, 5); + } else { + func_80AF7E98(this, 3); + } + ret = true; + } + return ret; +} + +s32 func_80AF9B54(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + s32 ret = false; + + if (func_80AF8ED4(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_AL)) { + func_8013AED4(&this->unk_356, 3, 7); + this->unk_356 |= 0x9000; + this->unk_356 |= 0x20; + if (this->unk_258 != 0) { + this->unk_356 |= 0x800; + func_80AF7E98(this, 5); + } else { + func_80AF7E98(this, 3); + } + ret = true; + } + return ret; +} + +s32 func_80AF9BF8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + s32 ret; + + this->actor.flags |= 1; + this->actor.targetMode = 0; + this->unk_394 = 0; + this->unk_356 = 0; + this->unk_368 = 40.0f; + + switch (arg2->unk0) { + case 16: + ret = func_80AF9A0C(this, globalCtx, arg2); + break; + + case 17: + ret = func_80AF9AB0(this, globalCtx, arg2); + break; + + case 28: + ret = func_80AF9B54(this, globalCtx, arg2); + break; + + case 24: + ret = func_80AF94AC(this, globalCtx, arg2); + break; + + case 29: + ret = func_80AF95E8(this, globalCtx, arg2); + break; + + case 1: + case 2: + case 10: + case 11: + case 12: + case 13: + case 32: + case 33: + case 34: + case 35: + case 36: + case 37: + ret = func_80AF9008(this, globalCtx, arg2); + break; + + case 3: + case 4: + case 5: + case 6: + case 7: + case 18: + case 19: + case 23: + case 25: + case 27: + ret = func_80AF95E8(this, globalCtx, arg2); + break; + + case 8: + ret = func_80AF98A0(this, globalCtx, arg2); + break; + + case 9: + case 14: + case 20: + case 21: + case 22: + ret = func_80AF992C(this, globalCtx, arg2); + break; + + case 38: + case 39: + case 40: + case 41: + case 42: + case 43: + case 44: + case 45: + case 46: + case 47: + case 48: + case 49: + case 50: + case 51: + case 52: + case 53: + case 54: + case 55: + case 56: + case 57: + case 58: + case 59: + case 60: + case 61: + case 62: + case 63: + case 64: + case 65: + case 66: + case 67: + case 68: + case 69: + case 70: + case 71: + case 72: + case 73: + case 74: + case 75: + case 76: + case 77: + case 78: + case 79: + case 80: + case 81: + case 82: + case 83: + case 84: + case 85: + case 86: + case 87: + case 88: + case 89: + case 90: + case 91: + ret = func_80AF91E8(this, globalCtx, arg2); + break; + + default: + ret = false; + break; + } + return ret; +} + +s32 func_80AF9D04(EnPm* this, GlobalContext* globalCtx) { + EnDoor* sp44 = (EnDoor*)func_80AF7D60(globalCtx, this->unk_258); + Vec3f sp38; + Vec3f* sp28; + f32 temp; + + if (!func_8013AD6C(globalCtx) && (this->unk_374 != 0)) { + if ((sp44 != NULL) && (sp44->actor.update != NULL)) { + if (((f32)this->unk_36E / this->unk_36C) <= 0.9f) { + sp44->unk_1A7 = this->unk_260; + } else { + sp44->unk_1A7 = 0; + } + } + this->unk_36E = CLAMP(this->unk_36E, 0, this->unk_36C); + temp = Math_Vec3f_DistXZ(&this->unk_26C, &this->unk_278) / this->unk_36C; + sp38.x = 0.0f; + sp38.y = 0.0f; + sp38.z = this->unk_36E * temp; + Lib_Vec3f_TranslateAndRotateY(&this->unk_26C, this->actor.world.rot.y, &sp38, &this->actor.world.pos); + this->unk_36E += this->unk_374; + if (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 8.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_POSTMAN_WALK); + } + } + return false; +} + +s32 func_80AF9E7C(EnPm* this, GlobalContext* globalCtx) { + f32 sp7C[265]; + Vec3f sp70; + Vec3f sp64; + Vec3f sp58; + s32 sp54; + s32 sp50; + + sp50 = 0; + sp54 = 0; + + func_8013AF00(sp7C, 3, this->unk_234->count + 3); + if (!(this->unk_356 & 8)) { + sp58 = D_801D15B0; + func_8013B6B0(this->unk_234, &this->unk_244, &this->unk_254, this->unk_24C, this->unk_248, &this->unk_250, sp7C, + &sp58, this->unk_374); + func_8013B878(globalCtx, this->unk_234, this->unk_250, &sp58); + this->actor.world.pos.y = sp58.y; + this->unk_356 |= 8; + } else { + sp58 = this->unk_238; + } + + this->actor.world.pos.x = sp58.x; + this->actor.world.pos.z = sp58.z; + + if (func_8013AD6C(globalCtx)) { + sp54 = this->unk_254; + sp50 = this->unk_250; + sp58 = this->actor.world.pos; + } + + this->unk_238 = D_801D15B0; + + if (func_8013B6B0(this->unk_234, &this->unk_244, &this->unk_254, this->unk_24C, this->unk_248, &this->unk_250, sp7C, + &this->unk_238, this->unk_374)) { + this->unk_356 |= 0x10; + } else { + sp70 = this->actor.world.pos; + sp64 = this->unk_238; + this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); + } + + if (func_8013AD6C(globalCtx)) { + this->unk_254 = sp54; + this->unk_250 = sp50; + this->unk_238 = sp58; + } else if ((this->unk_258 != 91) && + (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 8.0f))) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_POSTMAN_WALK); + } + + if ((this->unk_356 & 0x10) && (this->unk_258 == 90)) { + u8 val = gSaveContext.weekEventReg[89] | 0x40; + + gSaveContext.weekEventReg[89] = val; + if (val == 0) { + gSaveContext.weekEventReg[89] |= 0x40; + } + } + + return false; +} + +s32 func_80AFA170(EnPm* this, GlobalContext* globalCtx) { + Vec3f sp34; + Vec3f sp28; + + switch (this->unk_258) { + case 28: + if (gSaveContext.time >= CLOCK_TIME(1, 39)) { + gSaveContext.weekEventReg[89] |= 8; + } + + case 16: + case 17: + case 18: + if ((this->unk_384 == 5) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80AF7E98(this, 6); + this->unk_36C = 40; + } else if ((this->unk_384 == 6) && (DECR(this->unk_36C) == 0)) { + this->unk_356 &= ~0x800; + func_80AF7E98(this, 4); + } + break; + + case 3: + case 4: + case 5: + case 6: + case 7: + case 19: + if ((this->unk_384 == 11) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80AF7E98(this, 4); + } + + if ((this->unk_384 == 11) && Animation_OnFrame(&this->skelAnime, 8.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_POSTMACHINE_HIT_OPEN); + } + + if (this->unk_258 == 19) { + func_80AF8BA8(4); + } else { + func_80AF8BA8(this->unk_258 - 3); + } + break; + } + + if ((this->unk_268 != NULL) && (this->unk_268->update != NULL)) { + Math_Vec3f_Copy(&sp34, &this->unk_268->world.pos); + Math_Vec3f_Copy(&sp28, &this->actor.world.pos); + this->actor.world.rot.y = Math_Vec3f_Yaw(&sp28, &sp34); + } + + return true; +} + +s32 func_80AFA334(EnPm* this, GlobalContext* globalCtx) { + s16 temp_v0; + + switch (this->unk_258) { + case 14: + case 24: + temp_v0 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + if (ABS_ALT(temp_v0) < 0x4000) { + func_8013AED4(&this->unk_356, 3, 7); + } else { + func_8013AED4(&this->unk_356, 0, 7); + } + break; + + case 27: + if (DECR(this->unk_36C) == 0) { + Actor_SetSwitchFlag(globalCtx, 1); + } + break; + + case 9: + case 20: + case 21: + case 22: + if (Animation_OnFrame(&this->skelAnime, 0.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_VO_NP_SLEEP_OUT); + } + break; + + case 29: + break; + } + + return false; +} + +void func_80AFA438(EnPm* this, GlobalContext* globalCtx) { + switch (this->unk_258) { + case 3: + case 4: + case 5: + case 6: + case 7: + case 16: + case 17: + case 18: + case 28: + func_80AFA170(this, globalCtx); + break; + + case 1: + case 2: + case 10: + case 11: + case 12: + case 13: + case 32: + case 33: + case 34: + case 35: + case 36: + case 37: + func_80AF9D04(this, globalCtx); + break; + + case 9: + case 14: + case 20: + case 21: + case 22: + case 23: + case 24: + case 25: + case 27: + case 29: + func_80AFA334(this, globalCtx); + break; + + case 38: + case 39: + case 40: + case 41: + case 42: + case 43: + case 44: + case 45: + case 46: + case 47: + case 48: + case 49: + case 50: + case 51: + case 52: + case 53: + case 54: + case 55: + case 56: + case 57: + case 58: + case 59: + case 60: + case 61: + case 62: + case 63: + case 64: + case 65: + case 66: + case 67: + case 68: + case 69: + case 70: + case 71: + case 72: + case 73: + case 74: + case 75: + case 76: + case 77: + case 78: + case 79: + case 80: + case 81: + case 82: + case 83: + case 84: + case 85: + case 86: + case 87: + case 88: + case 89: + case 90: + case 91: + func_80AF9E7C(this, globalCtx); + break; + } + + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x2AA8); +} + +void func_80AFA4D0(EnPm* this, GlobalContext* globalCtx) { + static UNK_PTR D_80AFB900[] = { + D_80AFAD80, D_80AFB30C, D_80AFB3C0, D_80AFB3FC, D_80AFB41C, + }; + u16 time = gSaveContext.time; + u16 sp3C = 0; + u32* unk_14 = &gSaveContext.unk_14; + struct_80133038_arg2 sp2C; + + this->unk_374 = REG(15) + *unk_14; + if (this->unk_38C != 0) { + time = gSaveContext.time - D_801F4E78; + sp3C = gSaveContext.time; + gSaveContext.time = time; + } + + if (!func_80133038(globalCtx, D_80AFB900[this->unk_38C], &sp2C) || + ((this->unk_258 != sp2C.unk0) && !func_80AF9BF8(this, globalCtx, &sp2C))) { + this->actor.shape.shadowDraw = NULL; + this->actor.flags &= ~1; + sp2C.unk0 = 0; + } else { + this->actor.shape.shadowDraw = func_800B3FC0; + this->actor.flags |= 1; + } + + this->unk_258 = sp2C.unk0; + this->unk_268 = func_80AF8040(this, globalCtx); + func_80AFA438(this, globalCtx); + if (this->unk_38C != 0) { + gSaveContext.time = sp3C; + } +} + +void func_80AFA5FC(EnPm* this, GlobalContext* globalCtx) { + s16 yaw; + Vec3f sp38; + Vec3f sp2C; + + if (func_8010BF58(&this->actor, globalCtx, this->unk_25C, this->unk_37C, &this->unk_264)) { + func_8013AED4(&this->unk_356, 3, 7); + this->unk_356 &= ~0x20; + this->unk_356 |= 0x200; + this->actor.child = NULL; + this->unk_376 = 20; + this->unk_264 = 0; + this->actionFunc = func_80AFA4D0; + return; + } + + if ((this->unk_258 != 9) && (this->unk_258 != 14) && (this->unk_258 != 16) && (this->unk_258 != 17) && + (this->unk_258 != 20) && (this->unk_258 != 21) && (this->unk_258 != 22) && (this->unk_258 != 24) && + (this->unk_258 != 25)) { + if ((this->unk_268 != NULL) && (this->unk_268->update != NULL)) { + Math_Vec3f_Copy(&sp38, &this->unk_268->world.pos); + Math_Vec3f_Copy(&sp2C, &this->actor.world.pos); + yaw = Math_Vec3f_Yaw(&sp2C, &sp38); + Math_ApproachS(&this->actor.shape.rot.y, yaw, 4, 0x2AA8); + } + } +} + +void func_80AFA724(EnPm* this, GlobalContext* globalCtx) { + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); + if (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 8.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_POSTMAN_WALK); + } +} + +void EnPm_Init(Actor* thisx, GlobalContext* globalCtx) { + EnPm* this = THIS; + + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 14.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_060096E8, NULL, this->jointTable, this->morphTable, 16); + this->unk_384 = -1; + func_80AF7E98(this, 0); + Collider_InitAndSetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); + Collider_InitAndSetSphere(globalCtx, &this->colliderSphere, &this->actor, &sSphereInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); + Actor_SetScale(&this->actor, 0.01f); + this->unk_38C = func_80AF7B40(); + this->unk_258 = 0; + this->unk_356 = 0; + this->actionFunc = func_80AFA4D0; + this->actionFunc(this, globalCtx); +} + +void EnPm_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnPm* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); + Collider_DestroySphere(globalCtx, &this->colliderSphere); +} + +void EnPm_Update(Actor* thisx, GlobalContext* globalCtx) { + EnPm* this = THIS; + + if (!func_80AF86F0(this, globalCtx) && func_80AF87C4(this, globalCtx)) { + func_80AFA724(this, globalCtx); + func_80AF7E6C(this); + func_80AF8AC8(this); + } else { + this->actionFunc(this, globalCtx); + func_80AF7BAC(this); + if (this->unk_258 != 0) { + func_80AF8DD4(this, globalCtx); + func_80AF7E6C(this); + func_80AF8AC8(this); + func_8013C964(&this->actor, globalCtx, this->unk_368, 30.0f, this->unk_394, this->unk_356 & 7); + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); + func_80AF7F68(this, globalCtx); + } + } +} + +s32 func_80AFAA04(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, + Gfx** gfx) { + EnPm* this = THIS; + + if (limbIndex == 15) { + func_80AF8C68(this, globalCtx); + } + return false; +} + +void func_80AFAA44(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { + EnPm* this = THIS; + s32 pad; + Vec3f sp2C; + + switch (limbIndex) { + case 15: + if (ActorCutscene_GetCurrentIndex() == -1) { + Matrix_MultiplyVector3fByState(&D_801D15B0, &this->actor.focus.pos); + Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); + } + if ((this->unk_356 & 0x8000) && !(gSaveContext.weekEventReg[90] & 4)) { + func_80AF8890(this, gfx, 1); + } + break; + + case 11: + if (this->unk_356 & 0x800) { + func_80AF8890(this, gfx, 0); + } + break; + + case 8: + if ((this->unk_258 == 9) || (this->unk_258 == 20) || (this->unk_258 == 21) || (this->unk_258 == 22)) { + Matrix_MultiplyVector3fByState(&D_801D15B0, &sp2C); + Math_Vec3f_ToVec3s(&this->colliderSphere.dim.worldSphere.center, &sp2C); + } else if (this->unk_258 == 24) { + Matrix_MultiplyVector3fByState(&D_801D15B0, &sp2C); + Math_Vec3f_ToVec3s(&this->colliderSphere.dim.worldSphere.center, &sp2C); + } + func_80AF8890(this, gfx, 2); + break; + } +} + +void func_80AFABAC(GlobalContext* globalCtx, s32 arg1, Actor* thisx, Gfx** gfx) { + EnPm* this = THIS; + s32 phi_v0; + s32 phi_v1; + + if (!(this->unk_356 & 0x200)) { + if (this->unk_356 & 0x80) { + phi_v1 = 1; + } else { + phi_v1 = 0; + } + phi_v0 = 1; + } else { + phi_v1 = 0; + phi_v0 = 0; + } + + if (arg1 == 15) { + func_8013AD9C(this->unk_370 + 0x4000, this->unk_372 + this->actor.shape.rot.y + 0x4000, &this->unk_284, + &this->unk_290, phi_v0, phi_v1); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_284.x, this->unk_284.y, this->unk_284.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_290.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_290.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_290.z, MTXMODE_APPLY); + Matrix_StatePush(); + } +} + +void EnPm_Draw(Actor* thisx, GlobalContext* globalCtx) { + static UNK_PTR D_80AFB914[] = { + &D_06002950, + &D_06002750, + }; + EnPm* this = THIS; + s32 pad; + + if (this->unk_258 != 0) { + func_8012C28C(globalCtx->state.gfxCtx); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Scene_SetRenderModeXlu(globalCtx, 0, 1); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80AFB914[0])); + + POLY_OPA_DISP = + func_8013AB00(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_80AFAA04, func_80AFAA44, func_80AFABAC, &this->actor, POLY_OPA_DISP); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Pm/z_en_pm.h b/src/overlays/actors/ovl_En_Pm/z_en_pm.h index 6e3024bf11..d571f43bd6 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.h +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.h @@ -6,12 +6,56 @@ struct EnPm; typedef void (*EnPmActionFunc)(struct EnPm*, GlobalContext*); +typedef s32 (*EnPmFunc)(struct EnPm*, GlobalContext*); +typedef s32 (*EnPmFunc2)(struct EnPm*, GlobalContext*); typedef struct EnPm { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnPmActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x214]; + /* 0x018C */ EnPmFunc2 unk_18C; + /* 0x0190 */ ColliderCylinder colliderCylinder; + /* 0x01DC */ ColliderSphere colliderSphere; + /* 0x0234 */ Path* unk_234; + /* 0x0238 */ Vec3f unk_238; + /* 0x0244 */ f32 unk_244; + /* 0x0248 */ s32 unk_248; + /* 0x024C */ s32 unk_24C; + /* 0x0250 */ s32 unk_250; + /* 0x0254 */ s32 unk_254; + /* 0x0258 */ u8 unk_258; + /* 0x026C */ UNK_TYPE* unk_25C; + /* 0x0260 */ s8 unk_260; + /* 0x0264 */ s32 unk_264; + /* 0x0268 */ Actor* unk_268; + /* 0x0268 */ Vec3f unk_26C; + /* 0x0278 */ Vec3f unk_278; + /* 0x0284 */ Vec3f unk_284; + /* 0x0290 */ Vec3s unk_290; + /* 0x0296 */ Vec3s jointTable[16]; + /* 0x02F6 */ Vec3s morphTable[16]; + /* 0x0356 */ u16 unk_356; + /* 0x0358 */ u16 unk_358; + /* 0x035C */ f32 unk_35C; + /* 0x0360 */ f32 unk_360; + /* 0x0364 */ f32 unk_364; + /* 0x0368 */ f32 unk_368; + /* 0x036C */ s16 unk_36C; + /* 0x036E */ s16 unk_36E; + /* 0x0370 */ s16 unk_370; + /* 0x0372 */ s16 unk_372; + /* 0x0374 */ s16 unk_374; + /* 0x0376 */ s16 unk_376; + /* 0x0378 */ s16 unk_378; + /* 0x037C */ EnPmFunc unk_37C; + /* 0x0380 */ s32 unk_380; + /* 0x0384 */ s32 unk_384; + /* 0x0388 */ s32 unk_388; + /* 0x038C */ s32 unk_38C; + /* 0x0390 */ UNK_TYPE1 unk390[0x4]; + /* 0x0394 */ s32 unk_394; + /* 0x0398 */ s32 unk_398; + /* 0x039C */ UNK_TYPE1 unk39C[0x4]; } EnPm; // size = 0x3A0 extern const ActorInit En_Pm_InitVars; diff --git a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c index 57fca7fd7b..1bb44aa022 100644 --- a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c +++ b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c @@ -901,8 +901,8 @@ void EnPoSisters_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnPoSisters* this = THIS; f32 temp_f2; - Vec3f sp40; - s32 sp3C; + Vec3f checkPos; + s32 bgId; if (this->collider.base.atFlags & AT_HIT) { this->collider.base.atFlags &= ~AT_HIT; @@ -925,10 +925,11 @@ void EnPoSisters_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->unk_191 & 0x10) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 0.0f, 5); } else { - sp40.x = this->actor.world.pos.x; - sp40.y = this->actor.world.pos.y + 10.0f; - sp40.z = this->actor.world.pos.z; - this->actor.floorHeight = func_800C411C(&globalCtx->colCtx, &this->actor.floorPoly, &sp3C, &this->actor, &sp40); + checkPos.x = this->actor.world.pos.x; + checkPos.y = this->actor.world.pos.y + 10.0f; + checkPos.z = this->actor.world.pos.z; + this->actor.floorHeight = + BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &bgId, &this->actor, &checkPos); } this->actor.shape.shadowAlpha = this->unk_229; diff --git a/src/overlays/actors/ovl_En_Rd/z_en_rd.c b/src/overlays/actors/ovl_En_Rd/z_en_rd.c index 696e360a6d..be62210ea0 100644 --- a/src/overlays/actors/ovl_En_Rd/z_en_rd.c +++ b/src/overlays/actors/ovl_En_Rd/z_en_rd.c @@ -1,7 +1,7 @@ /* * File: z_en_rd.c * Overlay: ovl_En_Rd - * Description: Dancing Redead/Gibdo + * Description: Redead/Gibdo (able to dance) */ #include "z_en_rd.h" diff --git a/src/overlays/actors/ovl_En_Rg/z_en_rg.c b/src/overlays/actors/ovl_En_Rg/z_en_rg.c index 6a2b734bd6..00f96e291a 100644 --- a/src/overlays/actors/ovl_En_Rg/z_en_rg.c +++ b/src/overlays/actors/ovl_En_Rg/z_en_rg.c @@ -1,7 +1,7 @@ /* * File: z_en_rg.c * Overlay: ovl_En_Rg - * Description: Racetrack Goron + * Description: Racing Goron */ #include "z_en_rg.h" diff --git a/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c b/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c index f104ff1b21..2dc6842c92 100644 --- a/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c +++ b/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c @@ -1,7 +1,7 @@ /* * File: z_en_river_sound.c * Overlay: ovl_En_River_Sound - * Description: + * Description: Various environment Sfx (e.g., ocean waves, gulls, waterfall, lava, etc) */ #include "z_en_river_sound.h" diff --git a/src/overlays/actors/ovl_En_Rr/z_en_rr.c b/src/overlays/actors/ovl_En_Rr/z_en_rr.c index 1d44f721ca..96e688bb4c 100644 --- a/src/overlays/actors/ovl_En_Rr/z_en_rr.c +++ b/src/overlays/actors/ovl_En_Rr/z_en_rr.c @@ -23,7 +23,11 @@ void func_808FB42C(EnRr* this, GlobalContext* globalCtx); void func_808FB680(EnRr* this, GlobalContext* globalCtx); void func_808FB710(EnRr* this, GlobalContext* globalCtx); -#if 0 +void func_808FAD1C(EnRr* this, GlobalContext* globalCtx); +void func_808FB398(EnRr* this, GlobalContext* globalCtx); + +extern Gfx D_06000470[]; + const ActorInit En_Rr_InitVars = { ACTOR_EN_RR, ACTORCAT_ENEMY, @@ -36,22 +40,47 @@ const ActorInit En_Rr_InitVars = { (ActorFunc)EnRr_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808FC150 = { - { COLTYPE_HIT0, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x20000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit1 = { + { + COLTYPE_HIT0, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x20000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 45, 60, 0, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808FC17C = { - { COLTYPE_HIT0, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x20000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_ON | BUMP_HOOKABLE, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_HIT0, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x20000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_NONE, + }, { 30, 45, -30, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_808FC1A8 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(3, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -86,11 +115,9 @@ static DamageTable D_808FC1A8 = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -// sColChkInfoInit -static CollisionCheckInfoInit D_808FC1C8 = { 3, 45, 60, 250 }; +static CollisionCheckInfoInit sColChkInfoInit = { 3, 45, 60, 250 }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808FC1D0[] = { +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 55, ICHAIN_CONTINUE), ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -400, ICHAIN_CONTINUE), @@ -98,72 +125,816 @@ static InitChainEntry D_808FC1D0[] = { ICHAIN_F32(targetArrowOffset, 30, ICHAIN_STOP), }; -#endif +void EnRr_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnRr* this = THIS; -extern ColliderCylinderInit D_808FC150; -extern ColliderCylinderInit D_808FC17C; -extern DamageTable D_808FC1A8; -extern CollisionCheckInfoInit D_808FC1C8; -extern InitChainEntry D_808FC1D0[]; + Actor_ProcessInitChain(&this->actor, sInitChain); + Collider_InitAndSetCylinder(globalCtx, &this->collider1, &this->actor, &sCylinderInit1); + Collider_InitAndSetCylinder(globalCtx, &this->collider2, &this->actor, &sCylinderInit2); + if (this->actor.params != ENRR_3) { + this->actor.scale.y = 0.015f; + this->actor.scale.x = 0.019f; + this->actor.scale.z = 0.019f; + } else { + this->actor.scale.y = 0.022499999f; + this->actor.scale.x = 0.028499998f; + this->actor.scale.z = 0.028499998f; + this->collider1.dim.radius = this->collider1.dim.radius * 1.5f; + this->collider1.dim.height = this->collider1.dim.height * 1.5f; + this->collider2.dim.radius = this->collider2.dim.radius * 1.5f; + this->collider2.dim.height = this->collider2.dim.height * 1.5f; + this->collider2.dim.yShift = this->collider2.dim.yShift * 1.5f; + } -extern UNK_TYPE D_06000470; + Collider_UpdateCylinder(&this->actor, &this->collider2); + Actor_SetHeight(&this->actor, this->actor.scale.y * 2000.0f); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rr/EnRr_Init.s") + if ((this->actor.params == ENRR_2) || (this->actor.params == ENRR_3)) { + this->actor.colChkInfo.health = 6; + if (this->actor.params == ENRR_2) { + this->actor.colChkInfo.mass = MASS_HEAVY; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rr/EnRr_Destroy.s") + this->actionFunc = func_808FAF94; + func_808FAD1C(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rr/func_808FA01C.s") +void EnRr_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnRr* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rr/func_808FA11C.s") + Collider_DestroyCylinder(globalCtx, &this->collider1); + Collider_DestroyCylinder(globalCtx, &this->collider2); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rr/func_808FA19C.s") +void func_808FA01C(EnRr* this, GlobalContext* globalCtx, ColliderCylinder* collider) { + if (this->actor.colChkInfo.damageEffect == 2) { + this->unk_220 = 0.85f; + this->unk_21C = 4.0f; + this->unk_1E0 = 0; + } else if (this->actor.colChkInfo.damageEffect == 4) { + this->unk_220 = 0.85f; + this->unk_21C = 4.0f; + this->unk_1E0 = 20; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, collider->info.bumper.hitPos.x, + collider->info.bumper.hitPos.y, collider->info.bumper.hitPos.z, 0, 0, 0, + CLEAR_TAG_LARGE_LIGHT_RAYS); + } else if (this->actor.colChkInfo.damageEffect == 5) { + this->unk_220 = 0.85f; + this->unk_21C = 4.0f; + this->unk_1E0 = 30; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rr/func_808FA238.s") +void func_808FA11C(EnRr* this) { + this->unk_1E0 = 10; + this->collider1.base.colType = COLTYPE_HIT3; + this->collider1.info.elemType = ELEMTYPE_UNK0; + this->unk_1EE = 80; + this->unk_220 = 0.85f; + this->unk_224 = 1.2750001f; + this->unk_21C = 1.0f; + this->actor.flags &= ~0x400; + func_800BCB70(&this->actor, 0x4000, 255, 0, 80); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rr/func_808FA260.s") +void func_808FA19C(EnRr* this, GlobalContext* globalCtx) { + this->unk_1EE = 0; + if (this->unk_1E0 == 10) { + this->unk_1E0 = 0; + this->collider1.base.colType = COLTYPE_HIT0; + this->collider1.info.elemType = ELEMTYPE_UNK1; + this->unk_21C = 0.0f; + func_800BF7CC(globalCtx, &this->actor, this->unk_234, 20, 2, this->actor.scale.y * 23.333334f, + this->actor.scale.y * 20.000002f); + this->actor.flags |= 0x400; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rr/func_808FA344.s") +void func_808FA238(EnRr* this, f32 arg1) { + this->actor.speedXZ = arg1; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_LIKE_WALK); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rr/func_808FA3F8.s") +void func_808FA260(EnRr* this) { + static f32 D_808FC1E4[] = { 0.0f, 500.0f, 750.0f, 1000.0f, 1000.0f }; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rr/func_808FA4F4.s") + this->unk_1E1 = 1; + this->unk_1E6 = 20; + this->unk_1F6 = 2500; + this->unk_210 = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rr/func_808FA6B8.s") + for (i = 0; i < ARRAY_COUNT(this->unk_324); i++) { + this->unk_324[i].unk_04 = D_808FC1E4[i]; + this->unk_324[i].unk_14 = 6000; + this->unk_324[i].unk_18 = 0; + this->unk_324[i].unk_0C = 0.8f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rr/func_808FA7AC.s") + this->actionFunc = func_808FB088; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rr/func_808FA870.s") + Audio_PlayActorSound2(&this->actor, NA_SE_EN_LIKE_UNARI); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rr/func_808FA910.s") +void func_808FA344(EnRr* this) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rr/func_808FA9CC.s") + this->unk_1E1 = 0; + this->unk_210 = 0.0f; + this->unk_1F6 = 2500; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rr/func_808FAA94.s") + for (i = 0; i < ARRAY_COUNT(this->unk_324); i++) { + this->unk_324[i].unk_04 = 0.0f; + this->unk_324[i].unk_14 = 0; + this->unk_324[i].unk_18 = 0; + this->unk_324[i].unk_0C = 1.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rr/func_808FAC80.s") + if (this->unk_1E2 != 0) { + this->unk_1E6 = 100; + this->actionFunc = func_808FB680; + } else { + this->unk_1E6 = 60; + this->actionFunc = func_808FAF94; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rr/func_808FAD1C.s") +void func_808FA3F8(EnRr* this, Player* player) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rr/func_808FAE50.s") + this->unk_1EA = 100; + this->unk_1FC = 20; + this->collider1.base.ocFlags1 &= ~OC1_TYPE_PLAYER; + this->actor.flags &= ~1; + this->unk_1F0 = 8; + this->unk_1E1 = 0; + this->actor.speedXZ = 0.0f; + this->unk_218 = 0.0f; + this->unk_210 = 0.0f; + this->unk_204 = 0.15f; + this->unk_20C = 0x200; + this->unk_1F6 = 5000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rr/func_808FAF94.s") + for (i = 0; i < ARRAY_COUNT(this->unk_324); i++) { + this->unk_324[i].unk_04 = 0.0f; + this->unk_324[i].unk_0C = 1.0f; + this->unk_324[i].unk_14 = 0; + this->unk_324[i].unk_18 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rr/func_808FB088.s") + this->actionFunc = func_808FB1C0; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_SUISEN_DRINK); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rr/func_808FB1C0.s") +void func_808FA4F4(EnRr* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + u32 sp38; + s32 sp34; + f32 sp30; + f32 sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rr/func_808FB2C0.s") + if (player->stateFlags2 & 0x80) { + player->actor.parent = NULL; + player->unk_AE8 = 100; + this->actor.flags |= 1; + this->unk_1F0 = 110; + this->unk_1F6 = 2500; + this->unk_210 = 0.0f; + this->unk_20C = 0x800; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rr/func_808FB398.s") + if (((this->unk_1E2 == 0) && (gSaveContext.playerForm == PLAYER_FORM_HUMAN)) && + (CUR_EQUIP_VALUE_VOID(EQUIP_SHIELD) == EQUIP_SHIELD)) { + sp34 = true; + this->unk_1E2 = func_8012ED78(globalCtx, 1); + } else { + sp34 = false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rr/func_808FB42C.s") + if (sp34 && (func_80152498(&globalCtx->msgCtx) == 0)) { + func_801518B0(globalCtx, 0xF6, NULL); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rr/func_808FB680.s") + if (this->actor.params == ENRR_0) { + sp38 = 8; + } else { + sp38 = 16; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rr/func_808FB710.s") + sp30 = this->actor.scale.x * 210.52632f; + sp2C = this->actor.scale.x * 631.579f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rr/func_808FB794.s") + player->actor.world.pos.x += sp30 * Math_SinS(this->actor.shape.rot.y); + player->actor.world.pos.y += sp2C; + player->actor.world.pos.z += sp30 * Math_CosS(this->actor.shape.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rr/EnRr_Update.s") + func_800B8D50(globalCtx, &this->actor, sp30, this->actor.shape.rot.y, sp2C, sp38); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_SUISEN_THROW); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rr/EnRr_Draw.s") +void func_808FA6B8(EnRr* this) { + s32 i; + + this->unk_1E1 = 0; + if (this->actor.colChkInfo.damageEffect == 5) { + this->unk_1EC = 80; + } else { + this->unk_1EC = 40; + } + func_800BCB70(&this->actor, 0x4000, 255, 0, this->unk_1EC); + + this->unk_1E6 = 20; + this->unk_1F6 = 2500; + this->unk_210 = 0.0f; + this->unk_204 = 0.0f; + this->unk_20C = 0.0f; + + for (i = 0; i < ARRAY_COUNT(this->unk_324); i++) { + this->unk_324[i].unk_04 = 0.0f; + this->unk_324[i].unk_0C = 1.0f; + this->unk_324[i].unk_14 = 0; + this->unk_324[i].unk_18 = 0; + } + + this->actionFunc = func_808FB398; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_LIKE_DAMAGE); +} + +void func_808FA7AC(EnRr* this) { + static f32 D_808FC1F8[] = { 0.0f, 500.0f, 750.0f, 1000.0f, 1000.0f, 0.0f }; + s32 i; + + this->unk_1F6 = 2500; + this->unk_1E1 = 1; + this->unk_1E6 = 10; + this->unk_210 = 0.0f; + + for (i = 0; i < ARRAY_COUNT(this->unk_324); i++) { + this->unk_324[i].unk_04 = D_808FC1F8[i]; + this->unk_324[i].unk_0C = 0.8f; + this->unk_324[i].unk_14 = 5000; + this->unk_324[i].unk_18 = 0; + } + + this->actionFunc = func_808FB2C0; +} + +void func_808FA870(EnRr* this) { + s32 i; + + this->unk_210 = 0.0f; + this->unk_204 = 0.15f; + this->unk_20C = 0x800; + this->unk_1F6 = 2500; + + for (i = 0; i < ARRAY_COUNT(this->unk_324); i++) { + this->unk_324[i].unk_04 = 0.0f; + this->unk_324[i].unk_0C = 1.0f; + this->unk_324[i].unk_14 = 0; + this->unk_324[i].unk_18 = 0; + } + + this->actionFunc = func_808FAF94; +} + +void func_808FA910(EnRr* this) { + s32 i; + + this->unk_1E4 = 0; + this->unk_214 = 0.0f; + func_800BCB70(&this->actor, 0x4000, 255, 0, 40); + this->unk_210 = 0.0f; + + for (i = 0; i < ARRAY_COUNT(this->unk_324); i++) { + this->unk_324[i].unk_04 = 0.0f; + this->unk_324[i].unk_14 = 0; + this->unk_324[i].unk_18 = 0; + } + + this->actionFunc = func_808FB42C; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_LIKE_DEAD); + this->actor.flags &= ~1; +} + +void func_808FA9CC(EnRr* this) { + s32 i; + + this->unk_1F2 = 0; + this->unk_1F4 = 0; + this->unk_1F6 = 2500; + this->unk_1F8 = 0; + this->unk_1FA = 0; + this->unk_200 = 0.0f; + this->unk_204 = 0.15f; + this->unk_208 = 0.0f; + this->unk_20C = 0x800; + + for (i = 0; i < ARRAY_COUNT(this->unk_324); i++) { + this->unk_324[i].unk_08 = 1.0f; + this->unk_324[i].unk_0C = 1.0f; + this->unk_324[i].unk_14 = 0; + this->unk_324[i].unk_16 = 0; + this->unk_324[i].unk_18 = 0; + } + + this->actionFunc = func_808FB710; +} + +s32 func_808FAA94(EnRr* this, GlobalContext* globalCtx) { + ColliderCylinder* sp2C; + s32 flag = (this->collider1.base.acFlags & AC_HIT) != 0; + + if (flag || (this->collider2.base.acFlags & AC_HIT)) { + if (flag) { + sp2C = &this->collider1; + } else { + sp2C = &this->collider2; + } + + this->collider1.base.acFlags &= ~AC_HIT; + this->collider2.base.acFlags &= ~AC_HIT; + + if ((this->unk_1E0 == 10) && (sp2C->info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + return false; + } + + if (this->actor.colChkInfo.damageEffect == 14) { + return false; + } + + func_800BE258(&this->actor, &sp2C->info); + func_808FA4F4(this, globalCtx); + func_808FA19C(this, globalCtx); + + if (!Actor_ApplyDamage(&this->actor)) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + if (this->actor.colChkInfo.damageEffect == 3) { + func_808FA11C(this); + this->collider1.base.acFlags &= ~AC_ON; + this->collider2.base.acFlags &= ~AC_ON; + func_808FA9CC(this); + } else { + func_808FA01C(this, globalCtx, sp2C); + func_808FA910(this); + } + } else if (this->actor.colChkInfo.damageEffect == 1) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + func_800BCB70(&this->actor, 0, 255, 0, 80); + this->unk_1EE = 80; + func_808FA9CC(this); + } else if (this->actor.colChkInfo.damageEffect == 3) { + func_808FA11C(this); + func_808FA9CC(this); + } else { + func_808FA01C(this, globalCtx, sp2C); + func_808FA6B8(this); + } + return true; + } + return false; +} + +void func_808FAC80(EnRr* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if ((this->unk_1F0 == 0) && ((this->collider2.base.atFlags & AT_HIT) || (this->collider1.base.atFlags & AT_HIT))) { + this->collider1.base.atFlags &= ~AT_HIT; + this->collider2.base.atFlags &= ~AT_HIT; + if (globalCtx->grabPlayer(globalCtx, player)) { + player->actor.parent = &this->actor; + func_808FA3F8(this, player); + } + } +} + +void func_808FAD1C(EnRr* this, GlobalContext* globalCtx) { + s32 i; + EnRrStruct* ptr; + + this->unk_1F2 = 0; + this->unk_1F4 = 0; + this->unk_1F6 = 2500; + this->unk_1F8 = 0; + this->unk_1FA = 0; + this->unk_200 = 0.0f; + this->unk_204 = 0.15f; + this->unk_208 = 0.0f; + this->unk_20C = 0x800; + + for (i = 0; i < ARRAY_COUNT(this->unk_324); i++) { + this->unk_324[i].unk_14 = 0; + this->unk_324[i].unk_16 = 0; + this->unk_324[i].unk_18 = 0; + + this->unk_324[i].unk_08 = 1.0f; + this->unk_324[i].unk_0C = 1.0f; + this->unk_324[i].unk_10 = this->unk_200; + } + + for (i = 1; i < ARRAY_COUNT(this->unk_324); i++) { + ptr = &this->unk_324[i]; + ptr->unk_14 = Math_CosS(this->unk_1F8 * i) * this->unk_208; + ptr->unk_18 = Math_SinS(this->unk_1FA * i) * this->unk_208; + } +} + +void func_808FAE50(EnRr* this, GlobalContext* globalCtx) { + s32 i; + EnRrStruct* ptr; + + if (this->actionFunc != func_808FB42C) { + for (i = 0; i < ARRAY_COUNT(this->unk_324); i++) { + ptr = &this->unk_324[i]; + ptr->unk_10 = Math_CosS(this->unk_1F2 + (i * 0x4000)) * this->unk_200; + } + + if (this->unk_1E1 == 0) { + for (i = 1; i < ARRAY_COUNT(this->unk_324); i++) { + ptr = &this->unk_324[i]; + ptr->unk_14 = Math_CosS(this->unk_1F2 + (i * this->unk_1F8)) * this->unk_208; + ptr->unk_18 = Math_SinS(this->unk_1F2 + (i * this->unk_1FA)) * this->unk_208; + } + } + } + + if (this->unk_1EE == 0) { + this->unk_1F2 += this->unk_1F4; + } +} + +void func_808FAF94(EnRr* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 10, 500, 0); + this->actor.world.rot.y = this->actor.shape.rot.y; + if ((this->unk_1E6 == 0) && !(player->stateFlags2 & 0x80) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && + (this->actor.xzDistToPlayer < (8421.053f * this->actor.scale.x))) { + func_808FA260(this); + } else if ((this->actor.xzDistToPlayer < 400.0f) && (this->actor.speedXZ == 0.0f)) { + func_808FA238(this, 2.0f); + } +} + +void func_808FB088(EnRr* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 10, 500, 0); + this->actor.world.rot.y = this->actor.shape.rot.y; + if (Player_GetMask(globalCtx) == PLAYER_MASK_STONE) { + func_808FA344(this); + return; + } + + switch (this->unk_1E1) { + case 1: + if (this->unk_1E6 == 0) { + this->unk_1E1 = 2; + } + break; + + case 2: + if (this->unk_1E6 == 0) { + this->unk_324[4].unk_0C = 1.5f; + this->unk_1E6 = 5; + this->unk_1E1 = 3; + } + break; + + case 3: + if (this->unk_1E6 == 0) { + this->unk_1E6 = 2; + this->unk_324[4].unk_04 = 2000.0f; + this->unk_1E1 = 4; + } + break; + + case 4: + if (this->unk_1E6 == 0) { + this->unk_324[4].unk_0C = 0.8f; + this->unk_1E6 = 20; + this->unk_1E1 = 5; + } + break; + + case 5: + if (this->unk_1E6 == 0) { + func_808FA344(this); + } + break; + } +} + +void func_808FB1C0(EnRr* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + func_8013ECE0(this->actor.xyzDistToPlayerSq, 120, 2, 120); + if (!(this->unk_1E4 & 7)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_EYEGOLE_DEMO_EYE); + } + + player->unk_AE8 = 0; + this->unk_1F0 = 8; + this->unk_1EA--; + + if (this->unk_1EA == 0) { + func_808FA7AC(this); + } else { + Math_StepToF(&player->actor.world.pos.x, this->unk_228.x, 30.0f); + Math_StepToF(&player->actor.world.pos.y, this->unk_228.y + this->unk_218, 30.0f); + Math_StepToF(&player->actor.world.pos.z, this->unk_228.z, 30.0f); + Math_StepToF(&this->unk_218, -(f32)this->collider1.dim.height, 5.0f); + } +} + +void func_808FB2C0(EnRr* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + this->unk_1E6--; + player->unk_AE8 = 0; + Math_StepToF(&player->actor.world.pos.x, this->unk_228.x, 30.0f); + Math_StepToF(&player->actor.world.pos.y, this->unk_228.y + this->unk_218, 30.0f); + Math_StepToF(&player->actor.world.pos.z, this->unk_228.z, 30.0f); + Math_StepToF(&this->unk_218, -(f32)this->collider1.dim.height, 5.0f); + if (this->unk_1E6 == 0) { + this->unk_1E1 = 0; + func_808FA4F4(this, globalCtx); + func_808FA344(this); + } +} + +void func_808FB398(EnRr* this, GlobalContext* globalCtx) { + s32 i; + s16 phi_v1; + + this->unk_1EC--; + if (this->unk_1EC == 0) { + func_808FA870(this); + return; + } + + if (this->unk_1E0 == 30) { + if (this->unk_1EC & 2) { + phi_v1 = 1000; + } else { + phi_v1 = -1000; + } + } else { + if (this->unk_1EC & 8) { + phi_v1 = 5000; + } else { + phi_v1 = -5000; + } + } + + for (i = 1; i < ARRAY_COUNT(this->unk_324); i++) { + this->unk_324[i].unk_18 = phi_v1; + } +} + +void func_808FB42C(EnRr* this, GlobalContext* globalCtx) { + s32 pad; + s32 i; + EnRrStruct* ptr; + f32 temp_f20; + + this->actor.colorFilterTimer = 40; + if (this->unk_1E4 < 40) { + for (i = 0; i < ARRAY_COUNT(this->unk_324); i++) { + ptr = &this->unk_324[i]; + Math_StepToF(&ptr->unk_04, (i + 59) - (this->unk_1E4 * 25.0f), 50.0f); + ptr->unk_0C = (SQ((f32)(4 - i)) * this->unk_1E4 * 0.003f) + 1.0f; + } + return; + } + + if (this->unk_1E4 >= 95) { + if (this->unk_1E2 != 0) { + Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_SHIELD_HERO); + } + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x90); + Actor_MarkForDeath(&this->actor); + } else if (this->unk_1E4 == 88) { + Vec3f sp74; + + sp74.x = this->actor.world.pos.x; + sp74.y = this->actor.world.pos.y + 20.0f; + sp74.z = this->actor.world.pos.z; + func_800B3030(globalCtx, &sp74, &D_801D15B0, &D_801D15B0, 100, 0, 0); + Audio_PlaySoundAtPosition(globalCtx, &sp74, 11, NA_SE_EN_EXTINCT); + } else { + temp_f20 = this->actor.scale.y * 66.66667f; + + Math_StepToF(&this->actor.scale.x, 0.0f, this->unk_214); + Math_StepToF(&this->unk_214, 0.001f * temp_f20, 0.00001f * temp_f20); + this->actor.scale.z = this->actor.scale.x; + } +} + +void func_808FB680(EnRr* this, GlobalContext* globalCtx) { + if (this->unk_1E6 == 0) { + this->actionFunc = func_808FAF94; + } else { + Math_SmoothStepToS(&this->actor.shape.rot.y, BINANG_ROT180(this->actor.yawTowardsPlayer), 10, 1000, 0); + this->actor.world.rot.y = this->actor.shape.rot.y; + if (this->actor.speedXZ == 0.0f) { + func_808FA238(this, 2.0f); + } + } +} + +void func_808FB710(EnRr* this, GlobalContext* globalCtx) { + this->unk_1EE--; + if (this->unk_1EE == 0) { + func_808FA19C(this, globalCtx); + func_808FA870(this); + this->actionFunc = func_808FAF94; + } else if ((this->actor.colChkInfo.health == 0) && (this->unk_1EE == 77)) { + func_808FA19C(this, globalCtx); + func_808FA910(this); + } +} + +void func_808FB794(EnRr* this, GlobalContext* globalCtx) { + Vec3f sp2C; + + if ((this->actor.depthInWater < this->collider1.dim.height) && (this->actor.depthInWater > 1.0f) && + ((globalCtx->gameplayFrames % 9) == 0)) { + sp2C.x = this->actor.world.pos.x; + sp2C.y = this->actor.world.pos.y + this->actor.depthInWater; + sp2C.z = this->actor.world.pos.z; + EffectSsGRipple_Spawn(globalCtx, &sp2C, this->actor.scale.x * 34210.527f, this->actor.scale.x * 60526.316f, 0); + } +} + +void EnRr_Update(Actor* thisx, GlobalContext* globalCtx) { + EnRr* this = THIS; + EnRrStruct* ptr; + s32 i; + + this->unk_1E4++; + + if (this->unk_1EE == 0) { + this->unk_1E8++; + } + + if (this->unk_1E6 != 0) { + this->unk_1E6--; + } + + if (this->unk_1F0 != 0) { + this->unk_1F0--; + } + + Actor_SetHeight(&this->actor, this->actor.scale.y * 2000.0f); + func_808FAE50(this, globalCtx); + + if (!func_808FAA94(this, globalCtx)) { + func_808FAC80(this, globalCtx); + } + + this->actionFunc(this, globalCtx); + + if (this->actor.params == ENRR_2) { + this->actor.speedXZ = 0.0f; + } else { + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.1f); + } + + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, this->collider1.dim.radius, 0.0f, 0x5D); + func_808FB794(this, globalCtx); + + if (this->unk_1FC > 0) { + Player* player = GET_PLAYER(globalCtx); + + if (!(player->stateFlags2 & 0x80)) { + this->unk_1FC--; + if (this->unk_1FC == 0) { + this->collider1.base.ocFlags1 |= OC1_TYPE_PLAYER; + } + } + } + + Collider_UpdateCylinder(&this->actor, &this->collider1); + + if ((this->actionFunc != func_808FB42C) && (this->actionFunc != func_808FB398)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + if ((this->unk_1F0 == 0) && (this->actionFunc == func_808FB088) && (this->unk_1EE == 0)) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + } else { + this->collider2.base.atFlags &= ~AT_HIT; + this->collider1.base.atFlags &= ~AT_HIT; + } + } else { + this->collider2.base.atFlags &= ~AT_HIT; + this->collider1.base.atFlags &= ~AT_HIT; + this->collider2.base.acFlags &= ~AC_HIT; + this->collider1.base.acFlags &= ~AC_HIT; + } + + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + + if (this->unk_1EE == 0) { + Math_ScaledStepToS(&this->unk_1F4, this->unk_1F6, 50); + Math_ScaledStepToS(&this->unk_1F8, 0x3000, 0xA4); + Math_ScaledStepToS(&this->unk_1FA, 0x1000, 0x29); + Math_StepToF(&this->unk_200, this->unk_204, 0.0015f); + Math_StepToF(&this->unk_208, this->unk_20C, 20.0f); + + for (i = 0; i < ARRAY_COUNT(this->unk_324); i++) { + ptr = &this->unk_324[i]; + Math_SmoothStepToS(&ptr->unk_1A.x, ptr->unk_14, 5, this->unk_210 * 1000.0f, 0); + Math_SmoothStepToS(&ptr->unk_1A.z, ptr->unk_18, 5, this->unk_210 * 1000.0f, 0); + Math_StepToF(&ptr->unk_08, ptr->unk_0C, this->unk_210 * 0.2f); + Math_StepToF(&ptr->unk_00, ptr->unk_04, this->unk_210 * 300.0f); + } + + Math_StepToF(&this->unk_210, 1.0f, 0.2f); + } + + if (this->unk_21C > 0.0f) { + if (this->unk_1E0 != 10) { + Math_StepToF(&this->unk_21C, 0.0f, 0.05f); + this->unk_220 = (this->unk_21C + 1.0f) * 0.425f; + this->unk_220 = CLAMP_MAX(this->unk_220, 0.85f); + } else if (!Math_StepToF(&this->unk_224, 0.85f, 0.02125f)) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } +} + +void EnRr_Draw(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnRr* this = THIS; + Mtx* matrix; + Vec3f* vecPtr; + s32 i; + EnRrStruct* ptr; + Vec3f spA4; + f32 temp_f20; + + matrix = GRAPH_ALLOC(globalCtx->state.gfxCtx, 256); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x0C, matrix); + gSPSegment(POLY_OPA_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (this->unk_1E8 * 0) & 0x7F, (this->unk_1E8 * 0) & 0x3F, + 0x20, 0x10, 1, (this->unk_1E8 * 0) & 0x3F, (this->unk_1E8 * -6) & 0x7F, 0x20, 0x10)); + + Matrix_StatePush(); + Matrix_Scale((1.0f + this->unk_324[0].unk_10) * this->unk_324[0].unk_08, 1.0f, + (1.0f + this->unk_324[0].unk_10) * this->unk_324[0].unk_08, MTXMODE_APPLY); + + vecPtr = &this->unk_234[0]; + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + Matrix_GetStateTranslationAndScaledZ(1842.1053f, vecPtr++); + Matrix_GetStateTranslationAndScaledZ(-1842.1053f, vecPtr++); + Matrix_GetStateTranslationAndScaledX(1842.1053f, vecPtr++); + Matrix_GetStateTranslationAndScaledX(-1842.1053f, vecPtr++); + Matrix_StatePop(); + + for (i = 1; i < ARRAY_COUNT(this->unk_324); i++) { + temp_f20 = this->unk_324[i].unk_08 * (this->unk_324[i].unk_10 + 1.0f); + ptr = &this->unk_324[i]; + + Matrix_InsertTranslation(0.0f, ptr->unk_00 + 1000.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertRotation(ptr->unk_1A.x, ptr->unk_1A.y, ptr->unk_1A.z, MTXMODE_APPLY); + Matrix_StatePush(); + Matrix_Scale(temp_f20, 1.0f, temp_f20, MTXMODE_APPLY); + Matrix_ToMtx(matrix); + + if ((i & 1) != 0) { + Matrix_RotateY(0x2000, MTXMODE_APPLY); + } + + Matrix_GetStateTranslationAndScaledZ(1842.1053f, vecPtr++); + Matrix_GetStateTranslationAndScaledZ(-1842.1053f, vecPtr++); + Matrix_GetStateTranslationAndScaledX(1842.1053f, vecPtr++); + Matrix_GetStateTranslationAndScaledX(-1842.1053f, vecPtr++); + Matrix_StatePop(); + matrix++; + if (i == 3) { + Matrix_GetStateTranslation(&spA4); + } + } + + Matrix_GetStateTranslation(&this->unk_228); + this->collider2.dim.pos.x = ((this->unk_228.x - spA4.x) * 0.85f) + spA4.x; + this->collider2.dim.pos.y = ((this->unk_228.y - spA4.y) * 0.85f) + spA4.y; + this->collider2.dim.pos.z = ((this->unk_228.z - spA4.z) * 0.85f) + spA4.z; + + gSPDisplayList(POLY_OPA_DISP++, D_06000470); + + func_800BE680(globalCtx, &this->actor, this->unk_234, ARRAY_COUNT(this->unk_234), + this->actor.scale.y * 66.66667f * this->unk_220, this->unk_224, this->unk_21C, this->unk_1E0); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Rr/z_en_rr.h b/src/overlays/actors/ovl_En_Rr/z_en_rr.h index d6df8a710e..0361074776 100644 --- a/src/overlays/actors/ovl_En_Rr/z_en_rr.h +++ b/src/overlays/actors/ovl_En_Rr/z_en_rr.h @@ -7,10 +7,59 @@ struct EnRr; typedef void (*EnRrActionFunc)(struct EnRr*, GlobalContext*); +enum { + /* 0 */ ENRR_0, + /* 1 */ ENRR_1, + /* 2 */ ENRR_2, + /* 3 */ ENRR_3, +}; + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ s16 unk_14; + /* 0x16 */ s16 unk_16; + /* 0x18 */ s16 unk_18; + /* 0x1A */ Vec3s unk_1A; +} EnRrStruct; // size = 0x20 + typedef struct EnRr { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnRrActionFunc actionFunc; - /* 0x0148 */ char unk_144[0x27C]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnRrActionFunc actionFunc; + /* 0x148 */ ColliderCylinder collider1; + /* 0x194 */ ColliderCylinder collider2; + /* 0x1E0 */ u8 unk_1E0; + /* 0x1E1 */ u8 unk_1E1; + /* 0x1E2 */ u8 unk_1E2; + /* 0x1E4 */ s16 unk_1E4; + /* 0x1E6 */ s16 unk_1E6; + /* 0x1E8 */ s16 unk_1E8; + /* 0x1EA */ s16 unk_1EA; + /* 0x1EC */ s16 unk_1EC; + /* 0x1EE */ s16 unk_1EE; + /* 0x1F0 */ s16 unk_1F0; + /* 0x1F2 */ s16 unk_1F2; + /* 0x1F4 */ s16 unk_1F4; + /* 0x1F6 */ s16 unk_1F6; + /* 0x1F8 */ s16 unk_1F8; + /* 0x1FA */ s16 unk_1FA; + /* 0x1FC */ s16 unk_1FC; + /* 0x200 */ f32 unk_200; + /* 0x204 */ f32 unk_204; + /* 0x208 */ f32 unk_208; + /* 0x20C */ f32 unk_20C; + /* 0x210 */ f32 unk_210; + /* 0x214 */ f32 unk_214; + /* 0x218 */ f32 unk_218; + /* 0x21C */ f32 unk_21C; + /* 0x220 */ f32 unk_220; + /* 0x224 */ f32 unk_224; + /* 0x228 */ Vec3f unk_228; + /* 0x234 */ Vec3f unk_234[20]; + /* 0x324 */ EnRrStruct unk_324[5]; } EnRr; // size = 0x3C4 extern const ActorInit En_Rr_InitVars; diff --git a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c index f021301210..7b4b928b7c 100644 --- a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c +++ b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c @@ -1,7 +1,7 @@ /* * File: z_en_rsn.c * Overlay: ovl_En_Rsn - * Description: Bomb Shop Man in the credits? + * Description: Bomb Shop Man in the credits */ #include "z_en_rsn.h" diff --git a/src/overlays/actors/ovl_En_Ru/z_en_ru.c b/src/overlays/actors/ovl_En_Ru/z_en_ru.c index 3a0acd4b60..f3edfa7c3e 100644 --- a/src/overlays/actors/ovl_En_Ru/z_en_ru.c +++ b/src/overlays/actors/ovl_En_Ru/z_en_ru.c @@ -1,7 +1,7 @@ /* * File: z_en_ru.c * Overlay: ovl_En_Ru - * Description: Ruto + * Description: OoT's Adult Ruto (unused) */ #include "z_en_ru.h" diff --git a/src/overlays/actors/ovl_En_Rz/z_en_rz.c b/src/overlays/actors/ovl_En_Rz/z_en_rz.c index e87dfa556b..26551895a6 100644 --- a/src/overlays/actors/ovl_En_Rz/z_en_rz.c +++ b/src/overlays/actors/ovl_En_Rz/z_en_rz.c @@ -1,7 +1,7 @@ /* * File: z_en_rz.c * Overlay: ovl_En_Rz - * Description: Rosa Sister + * Description: Rosa Sisters, Judo (red) and Marilla (blue) */ #include "z_en_rz.h" diff --git a/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c b/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c index 2c2f686526..b90ab3db92 100644 --- a/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c +++ b/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c @@ -1,7 +1,7 @@ /* * File: z_en_scopecoin.c * Overlay: ovl_En_Scopecoin - * Description: Telescope Coin + * Description: Termina Field rupees visible from the telescope */ #include "z_en_scopecoin.h" diff --git a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c index 400c180444..9e2a1579d7 100644 --- a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c +++ b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c @@ -1,7 +1,7 @@ /* * File: z_en_scopenuts.c * Overlay: ovl_En_Scopenuts - * Description: Astral Observatory - Business Scrub in Telescope + * Description: Business Scrub that sells you a Heart Piece */ #include "z_en_scopenuts.h" diff --git a/src/overlays/actors/ovl_En_Sda/z_en_sda.c b/src/overlays/actors/ovl_En_Sda/z_en_sda.c index 2059de5635..e423a2046b 100644 --- a/src/overlays/actors/ovl_En_Sda/z_en_sda.c +++ b/src/overlays/actors/ovl_En_Sda/z_en_sda.c @@ -1,7 +1,7 @@ /* * File: z_en_sda.c * Overlay: ovl_En_Sda - * Description: + * Description: Dynamic Shadow for Player */ #include "z_en_sda.h" diff --git a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c index 5d045ca750..827491ee12 100644 --- a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c +++ b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c @@ -1,7 +1,7 @@ /* * File: z_en_ssh.c * Overlay: ovl_En_Ssh - * Description: Cursed Man + * Description: Cursed Man (Swamp Spider House) */ #include "z_en_ssh.h" diff --git a/src/overlays/actors/ovl_En_St/z_en_st.c b/src/overlays/actors/ovl_En_St/z_en_st.c index 6f92e8e766..c8335d92c1 100644 --- a/src/overlays/actors/ovl_En_St/z_en_st.c +++ b/src/overlays/actors/ovl_En_St/z_en_st.c @@ -1,7 +1,7 @@ /* * File: z_en_st.c * Overlay: ovl_En_St - * Description: Skulltula + * Description: Skulltula (large suspended one) */ #include "z_en_st.h" diff --git a/src/overlays/actors/ovl_En_Sth2/z_en_sth2.c b/src/overlays/actors/ovl_En_Sth2/z_en_sth2.c index 42bfe23632..97b463567e 100644 --- a/src/overlays/actors/ovl_En_Sth2/z_en_sth2.c +++ b/src/overlays/actors/ovl_En_Sth2/z_en_sth2.c @@ -1,7 +1,7 @@ /* * File: z_en_sth2.c * Overlay: ovl_En_Sth2 - * Description: + * Description: Guy waving at the telescope in Termina Field */ #include "z_en_sth2.h" diff --git a/src/overlays/actors/ovl_En_Stream/z_en_stream.c b/src/overlays/actors/ovl_En_Stream/z_en_stream.c index 8e72ac31c7..6f20e1bd5b 100644 --- a/src/overlays/actors/ovl_En_Stream/z_en_stream.c +++ b/src/overlays/actors/ovl_En_Stream/z_en_stream.c @@ -1,7 +1,7 @@ /* * File: z_en_stream.c * Overlay: ovl_En_Stream - * Description: + * Description: Unused water vortex from OoT */ #include "z_en_stream.h" @@ -15,9 +15,8 @@ void EnStream_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnStream_Update(Actor* thisx, GlobalContext* globalCtx); void EnStream_Draw(Actor* thisx, GlobalContext* globalCtx); -void EnStream_SetupAction(EnStream* this, EnStreamActionFunc actionFunc); +void EnStream_WaitForPlayer(EnStream* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Stream_InitVars = { ACTOR_EN_STREAM, ACTORCAT_BG, @@ -30,29 +29,122 @@ const ActorInit En_Stream_InitVars = { (ActorFunc)EnStream_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80965B20[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 20, ICHAIN_STOP), }; -#endif +extern Gfx D_06000950[]; -extern InitChainEntry D_80965B20[]; +void EnStream_SetupAction(EnStream* this, EnStreamActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -extern UNK_TYPE D_06000950; +void EnStream_Init(Actor* thisx, GlobalContext* globalCtx) { + EnStream* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stream/EnStream_SetupAction.s") + this->size = EN_STREAM_SIZE(&this->actor); + Actor_ProcessInitChain(&this->actor, sInitChain); + if (this->size != EN_STREAM_SIZE_NORMAL && this->size == EN_STREAM_SIZE_SMALL) { + this->actor.scale.y = 0.01f; + } + EnStream_SetupAction(this, EnStream_WaitForPlayer); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stream/EnStream_Init.s") +void EnStream_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stream/EnStream_Destroy.s") +s32 EnStream_PlayerIsInRange(Vec3f* vortexWorldPos, Vec3f* playerWorldPos, Vec3f* posDifference, f32 vortexYScale) { + s32 ret = EN_STREAM_PLAYER_OUTSIDE_RANGE; + f32 smallConstant = 28.0f; + f32 upperBounds = 160 * vortexYScale * 50.0f; + f32 lowerBounds = 0 * vortexYScale * 50.0f; + f32 xzDist; + f32 range; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stream/func_809656D4.s") + posDifference->x = playerWorldPos->x - vortexWorldPos->x; + posDifference->y = playerWorldPos->y - vortexWorldPos->y; + posDifference->z = playerWorldPos->z - vortexWorldPos->z; + xzDist = sqrtf(SQ(posDifference->x) + SQ(posDifference->z)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stream/func_809657F4.s") + if (lowerBounds <= posDifference->y && posDifference->y <= upperBounds) { + posDifference->y -= lowerBounds; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stream/func_8096597C.s") + range = ((75.0f - smallConstant) * (posDifference->y / (upperBounds - lowerBounds))) + 28.0f; + if (xzDist <= range) { + ret = EN_STREAM_PLAYER_WITHIN_RANGE_INSIDE_VORTEX; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stream/EnStream_Update.s") + if (posDifference->y <= lowerBounds && xzDist <= 28.0f) { + ret = EN_STREAM_PLAYER_WITHIN_RANGE_BELOW_VORTEX; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stream/EnStream_Draw.s") + return ret; +} + +void EnStream_SuckPlayer(EnStream* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 pad48; + Vec3f posDifference; + f32 xzDist; + f32 yDistWithOffset; + s32 pad30[2]; + + if (EnStream_PlayerIsInRange(&this->actor.world.pos, &player->actor.world.pos, &posDifference, + this->actor.scale.y) != EN_STREAM_PLAYER_OUTSIDE_RANGE) { + xzDist = sqrtf(SQ(posDifference.x) + SQ(posDifference.z)); + yDistWithOffset = player->actor.world.pos.y - (this->actor.world.pos.y - 90.0f); + player->unk_B84 = Math_Atan2S(-posDifference.x, -posDifference.z); + if (xzDist > 3.0f) { + Math_SmoothStepToF(&player->unk_B80, 3.0f, 0.5f, xzDist, 0.0f); + } else { + player->unk_B80 = 0.0f; + Math_SmoothStepToF(&player->actor.world.pos.x, this->actor.world.pos.x, 0.5f, 3.0f, 0.0f); + Math_SmoothStepToF(&player->actor.world.pos.z, this->actor.world.pos.z, 0.5f, 3.0f, 0.0f); + } + if (yDistWithOffset > 0.0f) { + Math_SmoothStepToF(&player->actor.velocity.y, -3.0f, 0.7f, yDistWithOffset, 0.0f); + if (posDifference.y < -70.0f) { + player->stateFlags2 |= 0x80000000; + } + } + } else { + EnStream_SetupAction(this, EnStream_WaitForPlayer); + } +} + +void EnStream_WaitForPlayer(EnStream* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 pad; + Vec3f temp; + + if (EnStream_PlayerIsInRange(&this->actor.world.pos, &player->actor.world.pos, &temp, this->actor.scale.y) != + EN_STREAM_PLAYER_OUTSIDE_RANGE) { + EnStream_SetupAction(this, EnStream_SuckPlayer); + } +} + +void EnStream_Update(Actor* thisx, GlobalContext* globalCtx) { + EnStream* this = THIS; + + this->actionFunc(this, globalCtx); + func_800B8FE8(&this->actor, NA_SE_EV_WHIRLPOOL - SFX_FLAG); +} + +void EnStream_Draw(Actor* thisx, GlobalContext* globalCtx) { + u32 multipliedFrames; + u32 frames = globalCtx->gameplayFrames; + Gfx* gfx; + + OPEN_DISPS(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + gfx = POLY_XLU_DISP; + gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + multipliedFrames = frames * 20; + gSPSegment(&gfx[1], 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, frames * 30, -multipliedFrames, 64, 64, 1, multipliedFrames, + -multipliedFrames, 64, 64)); + gSPDisplayList(&gfx[2], D_06000950); + POLY_XLU_DISP = &gfx[3]; + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Stream/z_en_stream.h b/src/overlays/actors/ovl_En_Stream/z_en_stream.h index 3166c4aa2e..3948b70c9a 100644 --- a/src/overlays/actors/ovl_En_Stream/z_en_stream.h +++ b/src/overlays/actors/ovl_En_Stream/z_en_stream.h @@ -3,14 +3,33 @@ #include "global.h" +/** + * Even in OoT, where this actor was used, every single instance of it had + * a params of 0x0000, so it's hard to know how they intended to use this. + * In the final game, only an EN_STREAM_SIZE of 1 does anything different. + */ +#define EN_STREAM_SIZE(thisx) ((thisx)->params & 0xFF) + +typedef enum { + /* 0 */ EN_STREAM_SIZE_NORMAL, + /* 1 */ EN_STREAM_SIZE_SMALL, +} EnStreamSize; + +typedef enum { + /* 0 */ EN_STREAM_PLAYER_OUTSIDE_RANGE, + /* 1 */ EN_STREAM_PLAYER_WITHIN_RANGE_INSIDE_VORTEX, + /* 2 */ EN_STREAM_PLAYER_WITHIN_RANGE_BELOW_VORTEX, +} EnStreamPlayerLocation; + struct EnStream; typedef void (*EnStreamActionFunc)(struct EnStream*, GlobalContext*); typedef struct EnStream { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnStreamActionFunc actionFunc; - /* 0x0148 */ char unk_144[0x8]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnStreamActionFunc actionFunc; + /* 0x148 */ s32 size; + /* 0x14C */ UNK_TYPE1 unk_14C[0x4]; } EnStream; // size = 0x150 extern const ActorInit En_Stream_InitVars; diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index 6f6ec34c49..0e6b20f3dd 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -126,7 +126,7 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0xE), }; -static s16 D_80BAE800[] = { +static u16 D_80BAE800[] = { 4000, 4, 1, 3, 6000, 4, 1, 6, 4000, 4, 1, 3, 6000, 4, 1, 6, }; @@ -201,14 +201,14 @@ void EnSuttari_UpdateTime(void) { } s32 func_80BAA904(EnSuttari* this, GlobalContext* globalCtx) { - Vec3f sp2C; + Vec3f pos; s32 pad; - s32 sp24; + CollisionPoly* poly; - sp2C.x = (Math_SinS(this->actor.world.rot.y) * 50.0f) + this->actor.world.pos.x; - sp2C.y = this->actor.world.pos.y + 100.0f; - sp2C.z = (Math_CosS(this->actor.world.rot.y) * 50.0f) + this->actor.world.pos.z; - if (func_800C4000(globalCtx, &globalCtx->colCtx, &sp24, &sp2C) > -500.0f) { + pos.x = (Math_SinS(this->actor.world.rot.y) * 50.0f) + this->actor.world.pos.x; + pos.y = this->actor.world.pos.y + 100.0f; + pos.z = (Math_CosS(this->actor.world.rot.y) * 50.0f) + this->actor.world.pos.z; + if (BgCheck_EntityRaycastFloor2(globalCtx, &globalCtx->colCtx, &poly, &pos) > -500.0f) { return false; } return true; @@ -496,15 +496,15 @@ void func_80BAB4F0(EnSuttari* this, GlobalContext* globalCtx) { sp30.x = player->actor.world.pos.x; sp30.y = player->bodyPartsPos[7].y + 3.0f; sp30.z = player->actor.world.pos.z; - func_8013D2E0(&sp30, &this->actor.focus, &this->actor.shape, &this->unk2D6, &this->unk2DC, &this->unk2E2, - D_80BAE800); + func_8013D2E0(&sp30, &this->actor.focus.pos, &this->actor.shape.rot, &this->unk2D6, &this->unk2DC, + &this->unk2E2, D_80BAE800); } else { - Math_SmoothStepToS(&this->unk2D6, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->unk2D8, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->unk2DC, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->unk2DE, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->unk2E2, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->unk2E4, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->unk2D6.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->unk2D6.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->unk2DC.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->unk2DC.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->unk2E2.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->unk2E2.y, 0, 4, 0x3E8, 1); } } func_8013D9C8(globalCtx, this->unk2FA, this->unk31A, 16); @@ -530,29 +530,26 @@ s16 func_80BAB698(Path* path, s32 idx, Vec3f* pos, f32* distSQ) { s32 func_80BAB758(EnSuttari* this, Path* path, s32 arg2) { Vec3s* sp5C = Lib_SegmentedToVirtual(path->points); - s32 sp58; + s32 sp58 = path->count; + s32 idx = arg2; + s32 ret = false; f32 sp54; - s32 ret; - s32 pad4C; f32 sp48; f32 sp44; f32 sp40; f32 sp3C; Vec3f sp30; - if (sp5C[arg2].x) {} - sp58 = path->count; - ret = false; - Math_Vec3s_ToVec3f(&sp30, &sp5C[arg2]); - if (arg2 == 0) { + Math_Vec3s_ToVec3f(&sp30, &sp5C[idx]); + if (idx == 0) { sp54 = sp5C[1].x - sp5C[0].x; sp48 = sp5C[1].z - sp5C[0].z; - } else if (arg2 == sp58 - 1) { + } else if (idx == sp58 - 1) { sp54 = sp5C[sp58 - 1].x - sp5C[sp58 - 2].x; sp48 = sp5C[sp58 - 1].z - sp5C[sp58 - 2].z; } else { - sp54 = sp5C[arg2 + 1].x - sp5C[arg2 - 1].x; - sp48 = sp5C[arg2 + 1].z - sp5C[arg2 - 1].z; + sp54 = sp5C[idx + 1].x - sp5C[idx - 1].x; + sp48 = sp5C[idx + 1].z - sp5C[idx - 1].z; } func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(sp54, sp48)), &sp44, &sp40, &sp3C); if (((sp44 * this->actor.world.pos.x) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { @@ -706,7 +703,7 @@ s32 func_80BABDD8(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg this->unk434 = sp44 - unkStruct->unk4; this->unk436 = unkStruct->unk8 - unkStruct->unk4; if (unkStruct->unk0 != 10 && unkStruct->unk0 != 11) { - sp48->unk1A7 = 0x4B; + sp48->unk_1A7 = 0x4B; } Math_Vec3f_Copy(&this->unk438, &sp38); Math_Vec3f_Copy(&this->unk444, &sp2C); @@ -748,20 +745,18 @@ s32 func_80BABF64(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg } s32 func_80BABFD4(EnSuttari* this, GlobalContext* globalCtx) { - UNK_TYPE1 sp7C[0x424]; + f32 sp7C[265]; Vec3f sp70; Vec3f sp64; Vec3f sp58; - s32 sp54; - s32 sp50; + s32 sp54 = 0; + s32 sp50 = 0; s32 pad; - sp54 = 0; - sp50 = 0; - func_8013AF00(&sp7C, 3, this->unk404->count + 3); + func_8013AF00(sp7C, 3, this->unk404->count + 3); if (this->unk42C == 0) { sp58 = D_801D15B0; - func_8013B6B0(this->unk404, &this->unk414, &this->unk424, this->unk41C, this->unk418, &this->unk420, &sp7C, + func_8013B6B0(this->unk404, &this->unk414, &this->unk424, this->unk41C, this->unk418, &this->unk420, sp7C, &sp58, this->unk42A); func_8013B878(globalCtx, this->unk404, this->unk420, &sp58); this->actor.world.pos.y = sp58.y; @@ -777,7 +772,7 @@ s32 func_80BABFD4(EnSuttari* this, GlobalContext* globalCtx) { sp58 = this->actor.world.pos; } this->unk408 = D_801D15B0; - if (func_8013B6B0(this->unk404, &this->unk414, &this->unk424, this->unk41C, this->unk418, &this->unk420, &sp7C, + if (func_8013B6B0(this->unk404, &this->unk414, &this->unk424, this->unk41C, this->unk418, &this->unk420, sp7C, &this->unk408, this->unk42A)) { this->unk430 = 1; } else { @@ -989,12 +984,12 @@ void func_80BACA14(EnSuttari* this, GlobalContext* globalCtx) { func_80BAB434(this); if (player->transformation == PLAYER_FORM_GORON || player->transformation == PLAYER_FORM_ZORA) { if (this->actor.playerHeightRel < 60.0f && this->actor.xzDistToPlayer < 500.0f) { - this->unk3F2 = this->unk2DE; + this->unk3F2 = this->unk2DC.y; this->actionFunc = func_80BACBB0; } } else if ((player->transformation == PLAYER_FORM_HUMAN) && CUR_EQUIP_VALUE_VOID(EQUIP_SWORD) != 0) { if (func_800B84D0(&this->actor, globalCtx)) { - this->unk3F2 = this->unk2DE; + this->unk3F2 = this->unk2DC.y; func_80BAAB78(this, globalCtx); this->actionFunc = func_80BADA9C; } else if (this->actor.xzDistToPlayer < 200.0f) { @@ -1009,7 +1004,7 @@ void func_80BACBB0(EnSuttari* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s16 target; - this->unk3F2 = this->unk2DE; + this->unk3F2 = this->unk2DC.y; if (player->transformation == PLAYER_FORM_HUMAN || player->transformation == PLAYER_FORM_DEKU) { this->actionFunc = func_80BACA14; } @@ -1039,7 +1034,7 @@ void func_80BACBB0(EnSuttari* this, GlobalContext* globalCtx) { void func_80BACD2C(EnSuttari* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - this->unk3F2 = this->unk2DE; + this->unk3F2 = this->unk2DC.y; if (player->transformation == PLAYER_FORM_HUMAN || player->transformation == PLAYER_FORM_DEKU) { this->actionFunc = func_80BACA14; } @@ -1144,7 +1139,7 @@ void func_80BAD230(EnSuttari* this, GlobalContext* globalCtx) { this->textId = 0x2A31; func_801518B0(globalCtx, this->textId, &this->actor); this->flags1 |= 0x4000; - Audio_QueueSeqCmd(0x8003); + Audio_QueueSeqCmd(NA_BGM_CHASE | 0x8000); this->actionFunc = func_80BAD380; } else { ActorCutscene_SetIntentToPlay(this->cutscenes[1]); @@ -1209,7 +1204,7 @@ void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx) { this->flags2 |= 4; EnSuttari_SetNextEntrance(globalCtx, 0xD670); } else { - this->unk3F2 = this->unk2DE; + this->unk3F2 = this->unk2DC.y; Math_ApproachF(&this->actor.speedXZ, 4.0f, 0.2f, 0.5f); Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); func_80BAB374(this, globalCtx); @@ -1309,7 +1304,7 @@ void func_80BADA9C(EnSuttari* this, GlobalContext* globalCtx) { s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); if (this->flags1 & 1) { - this->unk3F2 = this->unk2DE; + this->unk3F2 = this->unk2DC.y; func_80BAA9B4(this); } else if ((this->animationIdx == 7) && (curFrame == frameCount)) { this->animationIdx = 1; @@ -1385,14 +1380,14 @@ void func_80BADE14(EnSuttari* this, GlobalContext* globalCtx) { if (this->unk1F4[1] == -0x63) { this->actor.speedXZ = 0.0f; } else { - this->unk3F2 = this->unk2DE; + this->unk3F2 = this->unk2DC.y; Math_ApproachF(&this->actor.speedXZ, 6.0f, 0.2f, 0.5f); } Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); } void func_80BADE8C(EnSuttari* this, GlobalContext* globalCtx) { - this->unk3F2 = this->unk2DE; + this->unk3F2 = this->unk2DC.y; Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 0); if (func_800B84D0(&this->actor, globalCtx)) { this->actor.flags &= ~0x10000; @@ -1409,7 +1404,7 @@ void func_80BADF3C(EnSuttari* this, GlobalContext* globalCtx) { if (this->unk1F4[0] == -0x63) { Actor_MarkForDeath(&this->actor); } - this->unk3F2 = this->unk2DE; + this->unk3F2 = this->unk2DC.y; if (DECR(this->unk3F6) == 0) { Math_ApproachF(&this->actor.speedXZ, 6.0f, 0.2f, 0.5f); } @@ -1480,13 +1475,13 @@ s32 EnSuttari_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL if (!(this->flags1 & 4)) { Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); Matrix_InsertXRotation_s(this->unk3F2, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->unk2DC, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-this->unk2DC.x, MTXMODE_APPLY); Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); } } if (limbIndex == 8) { - Matrix_InsertXRotation_s(-this->unk2E4, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->unk2E2, MTXMODE_APPLY); + Matrix_InsertXRotation_s(-this->unk2E2.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-this->unk2E2.x, MTXMODE_APPLY); } if (limbIndex == 8 || limbIndex == 9 || limbIndex == 0xC) { rot->y += (s16)(Math_SinS(this->unk2FA[limbIndex]) * 200.0f); diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h index 93423fe77c..9c62be60f6 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h @@ -27,15 +27,10 @@ typedef struct EnSuttari { /* 0x1FC */ UNK_TYPE1 unk_1FC[0x1A]; /* 0x216 */ Vec3s jointTable[16]; /* 0x276 */ Vec3s morphTable[16]; - /* 0x2D6 */ s16 unk2D6; - /* 0x2D8 */ s16 unk2D8; - /* 0x2DA */ UNK_TYPE1 unk_2DA[0x2]; - /* 0x2DC */ s16 unk2DC; - /* 0x2DE */ s16 unk2DE; - /* 0x2E0 */ UNK_TYPE1 unk_2E0[0x2]; - /* 0x2E2 */ s16 unk2E2; - /* 0x2E4 */ s16 unk2E4; - /* 0x2E6 */ UNK_TYPE1 unk_2E6[0x14]; + /* 0x2D6 */ Vec3s unk2D6; + /* 0x2DC */ Vec3s unk2DC; + /* 0x2E2 */ Vec3s unk2E2; + /* 0x2E8 */ UNK_TYPE1 unk_2E8[0x12]; /* 0x2FA */ s16 unk2FA[16]; /* 0x31A */ s16 unk31A[16]; /* 0x33A */ UNK_TYPE1 unk_33A[0xB6]; @@ -46,7 +41,7 @@ typedef struct EnSuttari { /* 0x3F8 */ Vec3f unk3F8; /* 0x404 */ Path* unk404; /* 0x408 */ Vec3f unk408; - /* 0x414 */ s32 unk414; + /* 0x414 */ f32 unk414; /* 0x418 */ s32 unk418; /* 0x41C */ s32 unk41C; /* 0x420 */ s32 unk420; diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index 9cc79183e0..221de85014 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -360,11 +360,12 @@ void func_808D93BC(EnSw* this) { this->actor.world.rot.x = -this->actor.world.rot.x; } -s32 func_808D9440(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, CollisionPoly** arg4, u32* arg5) { +s32 func_808D9440(GlobalContext* globalCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, + s32* bgId) { s32 ret = false; - if (func_800C55C4(&globalCtx->colCtx, arg1, arg2, arg3, arg4, 1, 1, 1, 1, arg5) && - !(func_800C9A4C(&globalCtx->colCtx, *arg4, *arg5) & 0x30)) { + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, posA, posB, posResult, outPoly, true, true, true, true, bgId) && + !(func_800C9A4C(&globalCtx->colCtx, *outPoly, *bgId) & 0x30)) { ret = true; } return ret; @@ -379,16 +380,16 @@ void func_808D94D0(EnSw* this, GlobalContext* globalCtx, s32 arg2, s32 arg3, s16 Vec3f sp84; Vec3f sp78; Vec3f sp6C; - u32 sp68; - u32 sp64; + s32 sp68; + s32 sp64; Actor* thisx = &this->actor; f32 temp_f20; s32 i; spA4 = NULL; spA0 = NULL; - sp68 = 50; - sp64 = 50; + sp68 = BGCHECK_SCENE; + sp64 = BGCHECK_SCENE; func_808D90F0(this, arg3, arg4); this->actor.speedXZ = this->unk_44C; temp_f20 = thisx->speedXZ * 2.0f; @@ -934,7 +935,7 @@ void func_808DAA60(EnSw* this, GlobalContext* globalCtx) { Vec3f sp34; f32 temp_f16; - sp44 = (Vec3s*)Lib_SegmentedToVirtual(this->unk_1E4->unk_04); + sp44 = (Vec3s*)Lib_SegmentedToVirtual(this->unk_1E4->points); sp40 = 0; if (DECR(this->unk_454) == 0) { @@ -1009,7 +1010,7 @@ void func_808DACF4(EnSw* this, GlobalContext* globalCtx) { if ((temp_f6 != 0) && (temp_f6 < (s32)sp4C)) { Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_374); this->unk_4A0 += this->unk_49C; - if ((this->unk_4A0 >= this->unk_1E4->unk_00) || (this->unk_4A0 < 0)) { + if ((this->unk_4A0 >= this->unk_1E4->count) || (this->unk_4A0 < 0)) { this->unk_49C = -this->unk_49C; this->unk_4A0 += this->unk_49C * 2; } diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.h b/src/overlays/actors/ovl_En_Sw/z_en_sw.h index b64b6d02a6..975e4e36d8 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.h +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.h @@ -11,17 +11,12 @@ typedef void (*EnSwActionFunc)(struct EnSw*, GlobalContext*); #define ENSW_GET_3FC(thisx) (((thisx)->params & 0x3FC) >> 2) #define ENSW_GET_FF00(thisx) ((((thisx)->params & 0xFF00) >> 8) & 0xFF) -typedef struct { - u8 unk_00; - s32 unk_04; -} EnSwUnkStruct; - typedef struct EnSw { /* 0x0000 */ Actor actor; /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnSwActionFunc actionFunc; /* 0x018C */ ColliderSphere collider; - /* 0x01E4 */ EnSwUnkStruct* unk_1E4; + /* 0x01E4 */ Path* unk_1E4; /* 0x01E8 */ Vec3s jointTable[30]; /* 0x029C */ Vec3s morphTable[30]; /* 0x0350 */ Vec3f unk_350; diff --git a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c index 5018c640fd..5137628056 100644 --- a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c +++ b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c @@ -337,7 +337,7 @@ void func_809C6C2C(EnSyatekiMan* this, GlobalContext* globalCtx) { func_80123F2C(globalCtx, 80); this->unk_26A = 1; this->actionFunc = func_809C80C0; - func_801A2BB8(0x25); + func_801A2BB8(NA_BGM_MINI_GAME_2); break; case 0xA32: @@ -657,7 +657,7 @@ void func_809C7620(EnSyatekiMan* this, GlobalContext* globalCtx) { func_80112AFC(globalCtx); func_80123F2C(globalCtx, 0x63); this->unk_26A = 1; - func_801A2BB8(0x25); + func_801A2BB8(NA_BGM_MINI_GAME_2); this->actionFunc = func_809C8808; break; @@ -1160,7 +1160,7 @@ void func_809C898C(EnSyatekiMan* this, GlobalContext* globalCtx) { func_801A2C20(); this->actionFunc = func_809C8BF0; if (this->unk_280 == 50) { - func_801A3098(0x922); + func_801A3098(NA_BGM_GET_ITEM | 0x900); func_8011B4E0(globalCtx, 1); } } diff --git a/src/overlays/actors/ovl_En_Test/z_en_test.c b/src/overlays/actors/ovl_En_Test/z_en_test.c index 516cf82582..2f13b66403 100644 --- a/src/overlays/actors/ovl_En_Test/z_en_test.c +++ b/src/overlays/actors/ovl_En_Test/z_en_test.c @@ -1,7 +1,7 @@ /* * File: z_en_test.c * Overlay: ovl_En_Test - * Description: + * Description: Various crater marks (e.g., Goron Link punch/pound, Moon's Tear crash, etc.) */ #include "z_en_test.h" diff --git a/src/overlays/actors/ovl_En_Test4/z_en_test4.c b/src/overlays/actors/ovl_En_Test4/z_en_test4.c index e872cc98a6..9e1417c841 100644 --- a/src/overlays/actors/ovl_En_Test4/z_en_test4.c +++ b/src/overlays/actors/ovl_En_Test4/z_en_test4.c @@ -1,7 +1,7 @@ /* * File: z_en_test4.c * Overlay: ovl_En_Test4 - * Description: Day transition effects + * Description: Three-Day Timer */ #include "z_en_test4.h" diff --git a/src/overlays/actors/ovl_En_Test6/z_en_test6.c b/src/overlays/actors/ovl_En_Test6/z_en_test6.c index 918a503f41..04365b5dd3 100644 --- a/src/overlays/actors/ovl_En_Test6/z_en_test6.c +++ b/src/overlays/actors/ovl_En_Test6/z_en_test6.c @@ -1,7 +1,7 @@ /* * File: z_en_test6.c * Overlay: ovl_En_Test6 - * Description: + * Description: Song of Time effects (Return to DotFD, invert, skip forward) */ #include "z_en_test6.h" diff --git a/src/overlays/actors/ovl_En_Test7/z_en_test7.c b/src/overlays/actors/ovl_En_Test7/z_en_test7.c index a5bca6c56f..81ab55e272 100644 --- a/src/overlays/actors/ovl_En_Test7/z_en_test7.c +++ b/src/overlays/actors/ovl_En_Test7/z_en_test7.c @@ -1,7 +1,7 @@ /* * File: z_en_test7.c * Overlay: ovl_En_Test7 - * Description: + * Description: Soaring effects (wings, sphere, etc) */ #include "z_en_test7.h" diff --git a/src/overlays/actors/ovl_En_Tite/z_en_tite.c b/src/overlays/actors/ovl_En_Tite/z_en_tite.c index 58e41b530b..61a12cfb0a 100644 --- a/src/overlays/actors/ovl_En_Tite/z_en_tite.c +++ b/src/overlays/actors/ovl_En_Tite/z_en_tite.c @@ -251,13 +251,13 @@ void func_80893BCC(EnTite* this, GlobalContext* globalCtx) { s32 j; if (this->actor.bgCheckFlags & 2) { - u32 temp_v0 = func_800C9BB8(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); + u32 surface = func_800C9BB8(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); - if ((temp_v0 == 0) || (temp_v0 == 1)) { + if ((surface == COLPOLY_SURFACE_GROUND) || (surface == COLPOLY_SURFACE_SAND)) { for (i = 5; i < ARRAY_COUNT(this->unk_2D0); i++) { func_800BBFB0(globalCtx, &this->unk_2D0[i], 1.0f, 2, 80, 15, 1); } - } else if (temp_v0 == 14) { + } else if (surface == COLPOLY_SURFACE_SNOW) { Vec3f* ptr; for (i = 5; i < ARRAY_COUNT(this->unk_2D0); i++) { diff --git a/src/overlays/actors/ovl_En_Tk/z_en_tk.c b/src/overlays/actors/ovl_En_Tk/z_en_tk.c index 6db72b0746..07bf625d21 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.c @@ -5,6 +5,8 @@ */ #include "z_en_tk.h" +#include "overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.h" +#include "overlays/actors/ovl_En_Door/z_en_door.h" #define FLAGS 0x00000009 @@ -15,20 +17,70 @@ void EnTk_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTk_Update(Actor* thisx, GlobalContext* globalCtx); void EnTk_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80AECA3C(EnTk* this, GlobalContext* globalCtx); void func_80AECA90(EnTk* this, GlobalContext* globalCtx); +void func_80AECB0C(EnTk* this, GlobalContext* globalCtx); void func_80AECB6C(EnTk* this, GlobalContext* globalCtx); +void func_80AECE0C(EnTk* this, GlobalContext* globalCtx); +s32 func_80AECE60(EnTk* this, GlobalContext* globalCtx); +s32 func_80AED354(EnTk* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2); +s32 func_80AED38C(EnTk* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2); +void func_80AED4F8(EnTk* this, GlobalContext* globalCtx); void func_80AED610(EnTk* this, GlobalContext* globalCtx); +void func_80AED898(EnTk* this, GlobalContext* globalCtx); void func_80AED940(EnTk* this, GlobalContext* globalCtx); void func_80AEDC4C(EnTk* this, GlobalContext* globalCtx); +void func_80AEDCBC(EnTk* this, GlobalContext* globalCtx); void func_80AEDD4C(EnTk* this, GlobalContext* globalCtx); +void func_80AEDE10(EnTk* this, GlobalContext* globalCtx); void func_80AEDF5C(EnTk* this, GlobalContext* globalCtx); +void func_80AEE2A8(EnTk* this, GlobalContext* globalCtx); void func_80AEE2C0(EnTk* this, GlobalContext* globalCtx); +void func_80AEE374(EnTk* this, GlobalContext* globalCtx); void func_80AEE414(EnTk* this, GlobalContext* globalCtx); +void func_80AEE478(EnTk* this, GlobalContext* globalCtx); void func_80AEE4D0(EnTk* this, GlobalContext* globalCtx); +void func_80AEE650(EnTk* this, GlobalContext* globalCtx); void func_80AEE6B8(EnTk* this, GlobalContext* globalCtx); +void func_80AEE784(EnTk* this, GlobalContext* globalCtx); void func_80AEE9B0(EnTk* this, GlobalContext* globalCtx); +void func_80AEEAD4(EnTk* this, GlobalContext* globalCtx); +void func_80AEEB88(EnTk* this, GlobalContext* globalCtx); +void func_80AEED38(EnTk* this, GlobalContext* globalCtx); +void func_80AEF048(EnTk* this, GlobalContext* globalCtx); +void func_80AEF094(EnTk* this, GlobalContext* globalCtx); +void func_80AEF15C(EnTk* this, GlobalContext* globalCtx); +void func_80AEF1B4(EnTk* this, GlobalContext* globalCtx); +void func_80AEF1C4(EnTk* this, GlobalContext* globalCtx); +void func_80AEF210(EnTk* this, GlobalContext* globalCtx); +void func_80AEF220(EnTk* this, GlobalContext* globalCtx); +void func_80AEF278(EnTk* this, GlobalContext* globalCtx); +void func_80AEF2C8(Actor* thisx, GlobalContext* globalCtx); +void func_80AEF2D8(Actor* thisx, GlobalContext* globalCtx); +void func_80AEF5F4(Actor* thisx, GlobalContext* globalCtx); + +extern AnimationHeader D_06001144; +extern AnimationHeader D_06001FA8; +extern AnimationHeader D_060020C8; +extern AnimationHeader D_060030A4; +extern AnimationHeader D_06003724; +extern AnimationHeader D_06003B10; +extern AnimationHeader D_06003FB8; +extern UNK_PTR D_06004390; +extern UNK_PTR D_06004B90; +extern UNK_PTR D_06005390; +extern Gfx D_0600B530[]; +extern FlexSkeletonHeader D_0600B9E8; + +static s32 D_80AF0050; + +static u32 D_80AEF800[] = { + 0x03060012, + 0x00000105, + 0x0E060012, + 0x00010500, +}; -#if 0 const ActorInit En_Tk_InitVars = { ACTOR_EN_TK, ACTORCAT_NPC, @@ -41,130 +93,1308 @@ const ActorInit En_Tk_InitVars = { (ActorFunc)EnTk_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80AEF830 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 30, 52, 0, { 0, 0, 0 } }, }; -#endif +// part of the collider?? +static u32 D_80AEF85C[] = { + 0x00000000, + 0x00000000, + 0xFF000000, +}; -extern ColliderCylinderInit D_80AEF830; +static struct_80B8E1A8 D_80AEF868[] = { + { &D_06001FA8, 1.0f, 0, -10.0f }, { &D_06001FA8, 2.0f, 0, -10.0f }, { &D_060030A4, 1.0f, 0, -10.0f }, + { &D_06001144, 1.0f, 2, -10.0f }, { &D_06003724, 1.0f, 2, -10.0f }, { &D_06003FB8, 1.0f, 0, -10.0f }, + { &D_060020C8, 1.0f, 0, -10.0f }, { &D_06003B10, 1.0f, 0, -10.0f }, +}; -extern UNK_TYPE D_0600B530; -extern UNK_TYPE D_0600B9E8; +static s32 D_80AEF8E8[2] = { 0, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEC460.s") +static f32 D_80AEF8F0[] = { + 0.637399971485f, 0.637399971485f, 0.637399971485f, 0.637399971485f, 0.637399971485f, 0.637399971485f, + 0.637399971485f, 0.637399971485f, 0.637399971485f, 0.637399971485f, 0.637399971485f, 0.637399971485f, + 1.88639998436f, 3.44770002365f, 5.29629993439f, 7.39470005035f, 9.60550022125f, 11.9537000656f, + 14.30189991f, 16.6000995636f, 18.8108997345f, 20.8342990875f, 22.6203994751f, 24.1441993713f, + 25.3057994843f, 25.3057994843f, 25.3057994843f, 25.3057994843f, 25.3057994843f, 25.3057994843f, + 25.3057994843f, 25.3057994843f, 25.3057994843f, 25.3057994843f, 25.3057994843f, 25.3057994843f, + 25.3057994843f, 26.5048999786f, 28.0412006378f, 29.9146995544f, 31.9881000519f, 34.2238998413f, + 36.572101593f, 38.932800293f, 41.28099823f, 43.5416984558f, 45.6276016235f, 47.4511985779f, + 49.0f, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEC524.s") +typedef struct { + /* 0x00 */ Actor* unk_00; + /* 0x04 */ f32 unk_04; +} EnTkStruct; // size = 0x8? -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEC658.s") +void func_80AEC460(EnTk* this) { + if (DECR(this->unk_2C4) == 0) { + this->unk_2C2++; + if (this->unk_2C2 >= 3) { + this->unk_2C0--; + if (this->unk_2C0 < 0) { + this->unk_2C4 = Rand_S16Offset(30, 30); + this->unk_2C0 = 2; + if (Rand_ZeroOne() > 0.5f) { + this->unk_2C0++; + } + } + this->unk_2C2 = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/EnTk_Init.s") +f32 func_80AEC524(f32 arg0) { + f32 temp_f0; + f32 ret; + s32 temp_a0; + s32 temp_a1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/EnTk_Destroy.s") + while ((arg0 >= ARRAY_COUNT(D_80AEF8F0)) || (arg0 < 0.0f)) { + if (arg0 >= ARRAY_COUNT(D_80AEF8F0)) { + arg0 -= ARRAY_COUNT(D_80AEF8F0); + } else if (arg0 < 0.0f) { + arg0 += ARRAY_COUNT(D_80AEF8F0); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AECA3C.s") + // temp_f0 always becomes 0 + temp_a1 = arg0; + temp_a0 = temp_a1 + 1; + temp_f0 = arg0 - temp_a1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AECA90.s") + if (arg0 != temp_a1) { + if (temp_a0 >= ARRAY_COUNT(D_80AEF8F0)) { + temp_a0 -= ARRAY_COUNT(D_80AEF8F0); + ret = (((D_80AEF8F0[temp_a0] + D_80AEF8F0[ARRAY_COUNT(D_80AEF8F0) - 1]) - D_80AEF8F0[temp_a1]) * temp_f0) + + D_80AEF8F0[temp_a1]; + } else { + ret = ((D_80AEF8F0[temp_a0] - D_80AEF8F0[temp_a1]) * temp_f0) + D_80AEF8F0[temp_a1]; + } + } else { + ret = D_80AEF8F0[temp_a1]; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AECB0C.s") +void func_80AEC658(SkelAnime* skelAnime, f32 arg1, f32 arg2, f32* arg3, f32* arg4) { + static f32 D_80AEF9B4[] = { 0.95f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 1.25f, 1.48f, 1.68f, 1.77f, 1.88f, 1.88f, 1.84f, + 1.77f, 1.62f, 1.43f, 1.22f, 0.93f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.96f, 1.23f, 1.5f, + 1.66f, 1.79f, 1.88f, 1.89f, 1.88f, 1.81f, 1.67f, 1.46f, 1.24f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AECB6C.s") + *arg3 = D_80AEF9B4[(s32)skelAnime->curFrame] * 0.5f * skelAnime->playSpeed * arg2; + *arg4 = (func_80AEC524(skelAnime->curFrame) - func_80AEC524(arg1)) * arg2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AECE0C.s") + while (*arg4 < 0.0f) { + *arg4 += D_80AEF8F0[(s32)skelAnime->animLength - 1] * arg2; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AECE60.s") +void EnTk_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnTk* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AED354.s") + this->unk_2B0 = ENTK_GET_F(&this->actor); + this->unk_2B1 = ENTK_GET_7F0(&this->actor); + Collider_InitCylinder(globalCtx, &this->collider); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AED38C.s") + if (Flags_GetSwitch(globalCtx, this->unk_2B1)) { + if (this->unk_2B0 == 0) { + Actor_MarkForDeath(&this->actor); + return; + } + } else if (this->unk_2B0 == 2) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AED4F8.s") + if ((this->unk_2B0 == 1) || (this->unk_2B0 == 3)) { + this->actor.flags &= ~(0x8 | 0x1); + this->actor.update = func_80AEF2C8; + this->actor.draw = NULL; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AED544.s") + ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 24.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600B9E8, NULL, this->jointTable, this->morphTable, 18); + Animation_Change(&this->skelAnime, &D_060030A4, 1.0f, 0.0f, Animation_GetLastFrame(&D_060030A4.common), 0, 0.0f); + this->unk_318 = 0; + this->unk_2D4 = -1; + Actor_SetScale(&this->actor, 0.01f); + this->actor.targetMode = 1; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AED610.s") + if (this->unk_2B0 == 2) { + this->unk_316 = 0; + this->actor.update = func_80AEF5F4; + func_80AECA3C(this, globalCtx); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AED898.s") + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->actor.gravity = -1.0f; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actor.flags |= 0x10; + func_8013E1C8(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); + func_8013E3B8(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AED940.s") + switch (this->unk_2B0) { + case 4: + if (D_80AF0050 != 0) { + Actor_MarkForDeath(&this->actor); + return; + } + D_80AF0050 = 1; + this->actor.room = -1; + this->actor.update = func_80AEF2D8; + this->unk_2D8 = 0.0f; + func_80AECB0C(this, globalCtx); + func_80AEF2D8(&this->actor, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEDBEC.s") + case 0: + this->unk_2D0 = -1; + this->unk_310 = 0; + this->unk_2E4 = 0; + func_80AED898(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEDC4C.s") + default: + Actor_MarkForDeath(&this->actor); + return; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEDCBC.s") +void EnTk_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnTk* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEDD4C.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEDDA0.s") +void func_80AECA3C(EnTk* this, GlobalContext* globalCtx) { + this->unk_316 = 0; + func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + this->actionFunc = func_80AECA90; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEDE10.s") +void func_80AECA90(EnTk* this, GlobalContext* globalCtx) { + if (func_800B84D0(&this->actor, globalCtx)) { + globalCtx->msgCtx.unk11F22 = 0; + globalCtx->msgCtx.unk11F10 = 0; + func_80AEDE10(this, globalCtx); + } else if (this->actor.xzDistToPlayer < 100.0f) { + func_800B8614(&this->actor, globalCtx, 100.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEDF5C.s") +void func_80AECB0C(EnTk* this, GlobalContext* globalCtx) { + this->actor.speedXZ = 0.0f; + this->unk_3CC = 0xFF; + this->unk_2DC = 0.0f; + func_8013E1C8(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); + this->actionFunc = func_80AECB6C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEE2A8.s") +void func_80AECB6C(EnTk* this, GlobalContext* globalCtx) { + f32 temp_f0; + s32 temp2; + s32 temp3; + f32 sp48; + f32 sp44; + u8 temp4; + struct_80133038_arg2 sp34; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEE2C0.s") + this->actor.textId = 0; + if (func_800B84D0(&this->actor, globalCtx)) { + globalCtx->msgCtx.unk11F22 = 0; + globalCtx->msgCtx.unk11F10 = 0; + func_80AED4F8(this, globalCtx); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEE300.s") + if (REG(15) != 0.0f) { + this->skelAnime.playSpeed = (f32)func_800FE620(globalCtx) / REG(15); + } else { + this->skelAnime.playSpeed = 0.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEE374.s") + if (this->unk_2CA & 0x10) { + func_8013E1C8(&this->skelAnime, D_80AEF868, 5, &this->unk_2D4); + sp48 = 1.0f; + sp44 = 22.0f; + } else { + func_80AEC658(&this->skelAnime, this->unk_320, 1.0f, &sp48, &sp44); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEE414.s") + temp2 = REG(15) * sp44; + temp_f0 = temp2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEE478.s") + this->unk_2DC += (REG(15) * sp44) - temp2; + temp3 = this->unk_2DC; + this->unk_3D0 = temp2 + temp3; + this->unk_2DC -= temp3; + this->unk_2E0 += REG(15); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEE4D0.s") + if (func_80133038(globalCtx, (UNK_TYPE*)D_80AEF800, &sp34)) { + if ((this->unk_3CC != sp34.unk0) && !func_80AED354(this, globalCtx, &sp34)) { + return; + } + temp4 = sp34.unk0; + } else { + sp34.unk0 = 0; + temp4 = sp34.unk0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEE650.s") + if (!temp4 && (this->unk_3CC != 0)) { + this->actor.draw = NULL; + this->actor.flags &= ~1; + } else if (temp4 && (this->unk_3CC == 0)) { + this->actor.flags |= 1; + this->actor.draw = EnTk_Draw; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEE6B8.s") + this->unk_3CC = sp34.unk0; + func_80AECE0C(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEE784.s") + if (this->unk_3CE & 8) { + this->actor.flags &= ~1; + this->actor.draw = NULL; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEE7E0.s") +void func_80AECE0C(EnTk* this, GlobalContext* globalCtx) { + if (this->unk_3CC != 0) { + if (1) {} + func_80AECE60(this, globalCtx); + } + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 4, 0x1555, 0xB6); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEE86C.s") +s32 func_80AECE60(EnTk* this, GlobalContext* globalCtx) { + EnDoor* sp4C4; + f32 spA0[265]; + Vec3f sp94; + Vec3f sp88; + Vec3f sp7C; + s32 sp78; + s32 sp74; + Actor* door2; + Actor* door1; + s32 pad2[1]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEE9B0.s") + func_8013AF00(spA0, 3, this->unk_3C8->count + 3); + if (!(this->unk_3CE & 4)) { + sp7C = D_801D15B0; + func_8013B6B0(this->unk_3C8, &this->unk_3E0, &this->unk_3F0, this->unk_3E8, this->unk_3E4, &this->unk_3EC, spA0, + &sp7C, this->unk_3D0); + func_8013B878(globalCtx, this->unk_3C8, this->unk_3EC, &sp7C); + this->actor.world.pos.y = sp7C.y; + } else { + sp7C = this->unk_3D4; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEEA4C.s") + this->actor.world.pos.x = sp7C.x; + this->actor.world.pos.z = sp7C.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEEAD4.s") + if (!(this->unk_3CE & 4)) { + Math_Vec3f_Copy(&this->actor.prevPos, &this->actor.world.pos); + this->unk_3CE |= 4; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEEB88.s") + if ((globalCtx->unk_18B4A != 0) || (this->unk_3D0 == 0)) { + sp78 = this->unk_3F0; + sp74 = this->unk_3EC; + sp7C = this->actor.world.pos; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEED38.s") + this->unk_3D4 = D_801D15B0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEF048.s") + if (func_8013B6B0(this->unk_3C8, &this->unk_3E0, &this->unk_3F0, this->unk_3E8, this->unk_3E4, &this->unk_3EC, spA0, + &this->unk_3D4, this->unk_3D0)) { + this->unk_3CE |= 8; + } else { + sp94 = this->actor.world.pos; + sp88 = this->unk_3D4; + this->actor.world.rot.y = Math_Vec3f_Yaw(&sp94, &sp88); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEF094.s") + if ((globalCtx->unk_18B4A != 0) || (this->unk_3D0 == 0)) { + this->unk_3F0 = sp78; + this->unk_3EC = sp74; + this->unk_3D4 = sp7C; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEF15C.s") + sp4C4 = NULL; + if (!(this->unk_2CA & 0xC00)) { + door1 = NULL; + label: + do { + door1 = func_ActorCategoryIterateById(globalCtx, door1, ACTORCAT_DOOR, ACTOR_EN_DOOR); + if (door1 != NULL) { + if (Actor_XZDistanceBetweenActors(&this->actor, door1) <= 120.0f) { + if (ABS(BINANG_SUB(Actor_YawToPoint(&this->actor, &door1->world.pos), this->actor.shape.rot.y)) <= + 0x2000) { + this->unk_2CA |= 0x400; + sp4C4 = (EnDoor*)door1; + break; + } + } + door1 = door1->next; + } + } while (door1 != NULL); + } else { + door2 = NULL; + do { + door2 = func_ActorCategoryIterateById(globalCtx, door2, ACTORCAT_DOOR, ACTOR_EN_DOOR); + if (door2 != NULL) { + if (Actor_XZDistanceBetweenActors(&this->actor, door2) <= 160.0f) { + sp4C4 = (EnDoor*)door2; + break; + } + door2 = door2->next; + } + } while (door2 != NULL); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEF1B4.s") + if ((sp4C4 != NULL) && (this->unk_2CA & 0x400)) { + Vec3f sp5C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEF1C4.s") + Actor_CalcOffsetOrientedToDrawRotation(&this->actor, &sp5C, &sp4C4->actor.world.pos); + sp4C4->unk_1A7 = 2; + if (sp5C.z < -20.0f) { + this->unk_2CA &= ~0x400; + this->unk_2CA |= 0x800; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEF210.s") + if (sp4C4 != NULL) { + if ((this->unk_2CA & 0x800) && (sp4C4->unk_1A7 == 0)) { + this->unk_2CA &= ~0x800; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEF220.s") + if (!(this->unk_3CE & 8) && !(this->unk_2CA & 0x10) && (this->actor.xzDistToPlayer < 100.0f)) { + func_8013E8F8(&this->actor, globalCtx, 100.0f, 100.0f, 0, 0x4000, 0x4000); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEF278.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEF2C8.s") +s32 func_80AED354(EnTk* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + s32 phi_v1 = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEF2D8.s") + if (arg2->unk0 != 0) { + phi_v1 = func_80AED38C(this, globalCtx, arg2); + } + return phi_v1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/EnTk_Update.s") +s32 func_80AED38C(EnTk* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + u16 sp1E = gSaveContext.time - 0x3FFC; + u8 params = ENTK_GET_F800(&this->actor); + u16 phi_a1; + s32 idx = arg2->unk0 - 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEF5F4.s") + this->unk_3C8 = func_8013BB34(globalCtx, params, D_80AEF8E8[idx + 1]); + if (this->unk_3C8 == 0) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEF65C.s") + if ((this->unk_3CC <= 0) && (this->unk_3CC != 0) && (this->unk_3D0 >= 0)) { + phi_a1 = sp1E; + } else { + phi_a1 = arg2->unk4; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/func_80AEF6A4.s") + this->unk_3E4 = arg2->unk8 - phi_a1; + this->unk_3F0 = sp1E - phi_a1; + phi_a1 = this->unk_3C8->count - 2; + this->unk_3E8 = this->unk_3E4 / phi_a1; + this->unk_3EC = (this->unk_3F0 / this->unk_3E8) + 2; + this->unk_3CE &= ~4; + this->unk_3CE &= ~8; + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tk/EnTk_Draw.s") +void func_80AED4F8(EnTk* this, GlobalContext* globalCtx) { + func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + this->actionFunc = func_80AED610; +} + +void func_80AED544(EnTk* this, GlobalContext* globalCtx) { + if (!(gSaveContext.weekEventReg[31] & 0x10)) { + func_801518B0(globalCtx, 0x13FE, &this->actor); + gSaveContext.weekEventReg[31] |= 0x10; + } else if (gSaveContext.time < CLOCK_TIME(9, 0)) { + func_801518B0(globalCtx, 0x13FF, &this->actor); + } else if (gSaveContext.time < CLOCK_TIME(12, 0)) { + func_801518B0(globalCtx, 0x1400, &this->actor); + } else if (gSaveContext.time < CLOCK_TIME(15, 0)) { + func_801518B0(globalCtx, 0x1401, &this->actor); + } else { + func_801518B0(globalCtx, 0x1402, &this->actor); + } +} + +void func_80AED610(EnTk* this, GlobalContext* globalCtx) { + if ((this->unk_2D4 == 4) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_8013E1C8(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); + } + + switch (func_80152498(&globalCtx->msgCtx)) { + case 0: + if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer - 0x1555, 0x71C)) { + if (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN) { + func_8013E1C8(&this->skelAnime, D_80AEF868, 4, &this->unk_2D4); + func_801518B0(globalCtx, 0x13FD, &this->actor); + } else if (CURRENT_DAY != 2) { + func_80AED544(this, globalCtx); + } else if (!Flags_GetSwitch(globalCtx, ENTK_GET_7F0(&this->actor))) { + func_801518B0(globalCtx, 0x1403, &this->actor); + } else if (gSaveContext.weekEventReg[60] & 2) { + func_80AED544(this, globalCtx); + } else { + func_801518B0(globalCtx, 0x1413, &this->actor); + } + break; + } + + case 1: + case 2: + case 3: + break; + + case 4: + case 5: + case 6: + if (func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.unk11F04) { + case 0x13FD: + this->unk_2CA |= 0x10; + func_8013E1C8(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); + this->skelAnime.playSpeed = 10.0f; + this->actionFunc = func_80AECB6C; + break; + + case 0x13FE: + func_80151938(globalCtx, 0x13FF); + break; + + case 0x1413: + func_801159EC(30); + gSaveContext.weekEventReg[60] |= 2; + func_80151938(globalCtx, 0x13FF); + break; + + case 0x13FF: + case 0x1400: + case 0x1401: + case 0x1402: + case 0x1403: + case 0x1404: + case 0x1405: + case 0x1406: + case 0x1407: + case 0x1408: + case 0x1409: + case 0x140A: + case 0x140B: + case 0x140C: + case 0x140D: + case 0x140E: + case 0x140F: + case 0x1410: + case 0x1411: + case 0x1412: + default: + func_8013E1C8(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); + this->actionFunc = func_80AECB6C; + break; + } + } + break; + } +} + +void func_80AED898(EnTk* this, GlobalContext* globalCtx) { + this->unk_316 = 0; + this->actor.speedXZ = 0.0f; + if (this->unk_2CA & 0x1000) { + if ((this->unk_2D4 == 4) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_8013E1C8(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); + } + } else { + func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + } + this->actionFunc = func_80AED940; +} + +void func_80AED940(EnTk* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Actor* actor; + Vec3f sp44; + + if ((this->unk_2D4 != 4) && (this->unk_2D4 != 7)) { + s16 temp_v0 = (this->actor.shape.rot.y - this->actor.yawTowardsPlayer) + 0x1555; + + if (ABS(temp_v0) < 0x1800) { + Math_SmoothStepToS(&this->unk_31C, temp_v0, 3, 0x71C, 0); + } else { + Math_SmoothStepToS(&this->unk_31C, 0, 3, 0x71C, 0); + } + + Math_Vec3f_Copy(&sp44, &player->actor.world.pos); + sp44.y = player->bodyPartsPos[7].y + 3.0f; + temp_v0 = Math_Vec3f_Pitch(&this->actor.focus.pos, &sp44); + if (ABS(temp_v0) < 0x800) { + Math_SmoothStepToS(&this->unk_31A, temp_v0, 3, 0x16C, 0); + } else { + Math_SmoothStepToS(&this->unk_31A, 0, 3, 0x16C, 0); + } + } + + if ((this->unk_2D4 == 4) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_8013E1C8(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); + } + + if (!(this->unk_2CA & 0x40)) { + actor = NULL; + + do { + actor = func_ActorCategoryIterateById(globalCtx, actor, ACTORCAT_NPC, ACTOR_EN_TK); + if (actor != NULL) { + if (ENTK_GET_F(actor) == 1) { + Math_Vec3f_Copy(&this->unk_2EC, &actor->world.pos); + Math_Vec3s_Copy(&this->unk_2F8, &actor->world.rot); + Actor_MarkForDeath(actor); + this->unk_2CA |= 0x40; + break; + } + actor = actor->next; + } + } while (actor != NULL); + } + + if (func_800B84D0(&this->actor, globalCtx)) { + this->unk_2CA &= ~0x80; + this->actor.flags &= ~0x10000; + globalCtx->msgCtx.unk11F22 = 0; + globalCtx->msgCtx.unk11F10 = 0; + func_80AEDE10(this, globalCtx); + } else if (!(this->unk_2CA & 0x80)) { + if (this->actor.xzDistToPlayer < 100.0f) { + func_8013E8F8(&this->actor, globalCtx, 100.0f, 100.0f, 0, 0x4000, 0x4000); + } + } else { + func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0); + } +} + +void func_80AEDBEC(EnTk* this, GlobalContext* globalCtx) { + this->actor.params = -1; + this->unk_2E8 = 0; + this->actor.speedXZ = 0.0f; + func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + this->actionFunc = func_80AEDC4C; +} + +void func_80AEDC4C(EnTk* this, GlobalContext* globalCtx) { + if ((this->actor.params >= 0) && func_8013E2D4(&this->actor, this->cutscenes[1], this->actor.params, 0)) { + this->unk_2E8 = ActorCutscene_GetLength(this->cutscenes[1]); + func_80151938(globalCtx, 0x1411); + func_80AEDCBC(this, globalCtx); + } +} + +void func_80AEDCBC(EnTk* this, GlobalContext* globalCtx) { + this->actor.speedXZ = 10.0f; + func_8013E1C8(&this->skelAnime, D_80AEF868, 5, &this->unk_2D4); + Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_2EC); + Math_Vec3f_Copy(&this->actor.prevPos, &this->unk_2EC); + Math_Vec3s_Copy(&this->actor.world.rot, &this->unk_2F8); + Math_Vec3s_Copy(&this->actor.shape.rot, &this->unk_2F8); + this->actionFunc = func_80AEDD4C; +} + +void func_80AEDD4C(EnTk* this, GlobalContext* globalCtx) { + this->unk_2E8--; + if (this->unk_2E8 <= 0) { + ActorCutscene_Stop(this->cutscenes[1]); + func_801477B4(globalCtx); + Actor_MarkForDeath(&this->actor); + } +} + +void func_80AEDDA0(EnTk* this, GlobalContext* globalCtx) { + this->actor.speedXZ = 0.0f; + func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + this->actor.flags |= 0x10000; + this->unk_2CA |= 0x80; + this->actionFunc = func_80AED940; +} + +void func_80AEDE10(EnTk* this, GlobalContext* globalCtx) { + switch (this->unk_2B0) { + case 0: + if (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN) { + this->unk_2E6 = 0x1404; + break; + } + + switch (this->unk_310) { + case 0: + this->unk_2CA &= ~0x1000; + if (!(gSaveContext.weekEventReg[52] & 0x80)) { + this->unk_2E6 = 0x1405; + } else { + this->unk_2E6 = 0x140B; + } + break; + + case 2: + this->unk_2E6 = 0x140D; + break; + + case 4: + func_801518B0(globalCtx, 0x140F, &this->actor); + func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + break; + + case 3: + func_801518B0(globalCtx, 0x1410, &this->actor); + func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + break; + } + break; + + case 2: + this->unk_2E6 = 0x1414; + break; + } + + this->actionFunc = func_80AEDF5C; +} + +void func_80AEDF5C(EnTk* this, GlobalContext* globalCtx) { + if ((this->unk_2D4 == 4) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_8013E1C8(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); + } + + switch (func_80152498(&globalCtx->msgCtx)) { + case 0: + switch (this->unk_2E6) { + case 0x1404: + case 0x1405: + case 0x140B: + case 0x140D: + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer - 0x1555, 1, 0x71C, 0); + this->actor.world.rot.y = this->actor.shape.rot.y; + if (!Math_SmoothStepToS(&this->unk_31A, 0, 3, 0x16C, 10) && + !Math_SmoothStepToS(&this->unk_31C, 0, 3, 0x71C, 10) && + (this->actor.shape.rot.y == (s16)(this->actor.yawTowardsPlayer - 0x1555))) { + if (this->unk_2E6 == 0x1404) { + func_8013E1C8(&this->skelAnime, D_80AEF868, 4, &this->unk_2D4); + } else { + func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + } + func_801518B0(globalCtx, this->unk_2E6, &this->actor); + } + break; + + case 0x1414: + func_801518B0(globalCtx, this->unk_2E6, &this->actor); + break; + } + break; + + case 1: + case 2: + case 3: + break; + + case 4: + case 5: + case 6: + if (func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.unk11F04) { + case 0x1404: + this->unk_2CA |= 0x1000; + func_80AED898(this, globalCtx); + break; + + case 0x1405: + func_80151938(globalCtx, 0x1406); + break; + + case 0x1406: + func_80151938(globalCtx, 0x1407); + break; + + case 0x1407: + if (globalCtx->msgCtx.choiceIndex == 0) { + func_8019F208(); + func_80151938(globalCtx, 0x1409); + } else { + func_8019F230(); + func_80151938(globalCtx, 0x1408); + } + break; + + case 0x1408: + func_80151938(globalCtx, 0x1407); + break; + + case 0x1409: + func_80151938(globalCtx, 0x140A); + break; + + case 0x140A: + gSaveContext.weekEventReg[52] |= 0x80; + + case 0x140B: + func_80AEE784(this, globalCtx); + break; + + case 0x140D: + this->unk_2CA |= 2; + if (globalCtx->msgCtx.choiceIndex == 0) { + func_8019F208(); + globalCtx->msgCtx.unk11F22 = 0x44; + func_80AEE2A8(this, globalCtx); + } else { + func_8019F230(); + func_80151938(globalCtx, 0x140E); + } + break; + + case 0x140E: + case 0x140F: + case 0x1410: + func_80AEE784(this, globalCtx); + break; + + case 0x1414: + func_80AECA3C(this, globalCtx); + break; + } + } + break; + } +} + +void func_80AEE2A8(EnTk* this, GlobalContext* globalCtx) { + this->actionFunc = func_80AEE2C0; +} + +void func_80AEE2C0(EnTk* this, GlobalContext* globalCtx) { + if (func_8013E2D4(&this->actor, this->cutscenes[0], 0x7C, 0)) { + func_80AEE374(this, globalCtx); + } +} + +s32 func_80AEE300(GlobalContext* globalCtx, Actor* arg1, Actor* arg2, void* _arg3) { + EnTkStruct* arg3 = (EnTkStruct*)_arg3; + f32 temp_f0; + + if ((arg2 != arg1) && (ENTK_GET_F(arg2) == 3)) { + temp_f0 = Actor_DistanceBetweenActors(arg1, arg2); + if (temp_f0 < arg3->unk_04) { + arg3->unk_00 = arg2; + arg3->unk_04 = temp_f0; + } + } + return false; +} + +void func_80AEE374(EnTk* this, GlobalContext* globalCtx) { + EnTkStruct sp30; + + sp30.unk_00 = NULL; + sp30.unk_04 = FLT_MAX; + + func_8013E640(globalCtx, &this->actor, NULL, ACTORCAT_NPC, ACTOR_EN_TK, &sp30, func_80AEE300); + if (sp30.unk_00 == 0) { + Actor_MarkForDeath(&this->actor); + } else { + this->unk_2CC = Actor_YawToPoint(&this->actor, &sp30.unk_00->world.pos); + this->actionFunc = func_80AEE414; + } +} + +void func_80AEE414(EnTk* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->unk_2CC, 2, 0xE38, 0x5B); + this->actor.world.rot.y = this->actor.shape.rot.y; + if (this->actor.shape.rot.y == this->unk_2CC) { + func_80AEE478(this, globalCtx); + } +} + +void func_80AEE478(EnTk* this, GlobalContext* globalCtx) { + this->unk_310 = 2; + func_8013E1C8(&this->skelAnime, D_80AEF868, 3, &this->unk_2D4); + this->actionFunc = func_80AEE4D0; +} + +void func_80AEE4D0(EnTk* this, GlobalContext* globalCtx) { + Actor* bigPoe; + + if ((this->skelAnime.curFrame > 33.0f) && (this->skelAnime.curFrame < 41.0f)) { + func_800BBFB0(globalCtx, &this->unk_2B4, 10.0f, 2, 50, 30, 1); + } + + if (Animation_OnFrame(&this->skelAnime, 33.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_DIG_UP); + } + + if (!(this->unk_2CA & 0x20)) { + if (Animation_OnFrame(&this->skelAnime, 37.0f)) { + bigPoe = NULL; + do { + bigPoe = func_ActorCategoryIterateById(globalCtx, bigPoe, ACTORCAT_PROP, ACTOR_EN_BIGPO); + + if (bigPoe != NULL) { + if ((bigPoe->params == 3) && (Actor_DistanceBetweenActors(&this->actor, bigPoe) < 80.0f)) { + bigPoe->params = 4; + this->unk_2CA |= 0x20; + this->unk_2E4++; + } + bigPoe = bigPoe->next; + } + } while (bigPoe != NULL); + } + } + + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80AEE650(this, globalCtx); + } +} + +void func_80AEE650(EnTk* this, GlobalContext* globalCtx) { + if (this->unk_36C < ARRAY_COUNT(this->unk_324)) { + Math_Vec3f_Copy(&this->unk_324[this->unk_36C], &this->actor.world.pos); + this->unk_36C++; + } + this->actionFunc = func_80AEE6B8; +} + +void func_80AEE6B8(EnTk* this, GlobalContext* globalCtx) { + if (this->unk_2CA & 0x20) { + if (this->unk_2E4 >= 3) { + ActorCutscene_Stop(this->cutscenes[0]); + func_801477B4(globalCtx); + func_80AEDBEC(this, globalCtx); + } else if (func_8013E2D4(&this->actor, 0x7C, this->cutscenes[0], 0)) { + this->unk_310 = 3; + func_80AEDE10(this, globalCtx); + this->unk_2CA &= ~0x20; + } + } else if (func_8013E2D4(&this->actor, 0x7C, this->cutscenes[0], 0)) { + this->unk_310 = 4; + func_80AEDE10(this, globalCtx); + } +} + +void func_80AEE784(EnTk* this, GlobalContext* globalCtx) { + this->unk_2D0 = -1; + this->unk_310 = 1; + Math_Vec3s_Copy(&this->actor.world.rot, &this->actor.shape.rot); + func_80AEEAD4(this, globalCtx); + this->actionFunc = func_80AEE9B0; +} + +s32 func_80AEE7E0(Vec3f* arg0, f32 arg1, Vec3f* arg2, s32 arg3) { + s32 i; + s32 ret = true; + + for (i = 0; i < arg3; i++) { + if (Math_Vec3f_DistXZ(arg0, &arg2[i]) < arg1) { + ret = false; + break; + } + } + return ret; +} + +s32 func_80AEE86C(EnTk* this, GlobalContext* globalCtx) { + static Vec3f D_80AEFA78 = { 0.0f, 20.0f, 32.0f }; + s32 pad; + s32 ret = false; + s32 pad2; + CollisionPoly* sp38; + s32 sp34; + Vec3f sp28; + + Lib_Vec3f_TranslateAndRotateY(&this->actor.world.pos, this->actor.shape.rot.y, &D_80AEFA78, &sp28); + if ((BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &sp38, &sp34, &sp28) != BGCHECK_Y_MIN) && + (func_800C9BB8(&globalCtx->colCtx, sp38, sp34) == 1) && (this->unk_2D0 == (u32)1) && + (this->actor.xyzDistToPlayerSq <= SQ(115.0f)) && + func_80AEE7E0(&this->actor.world.pos, 100.0f, this->unk_324, this->unk_36C) && + (((this->unk_2CA & 2) && (Math_Vec3f_DistXZ(&this->unk_300, &sp28) >= 100.0f)) || !(this->unk_2CA & 2)) && + !func_801690CC(globalCtx)) { + Math_Vec3f_Copy(&this->unk_300, &sp28); + ret = true; + } + return ret; +} + +void func_80AEE9B0(EnTk* this, GlobalContext* globalCtx) { + this->unk_30C(this, globalCtx); + + func_80AEEAD4(this, globalCtx); + if (Math_Vec3f_DistXZ(&this->actor.world.pos, &this->unk_300) >= 100.0f) { + this->unk_2CA &= ~2; + } + + if (func_80AEE86C(this, globalCtx)) { + this->unk_310 = 2; + func_80AEDDA0(this, globalCtx); + } +} + +s32 func_80AEEA4C(EnTk* this, GlobalContext* globalCtx) { + s32 ret; + + if (this->unk_2CA & 1) { + ret = 3; + } else if (this->actor.xyzDistToPlayerSq < SQ(60.0f)) { + ret = 0; + } else if (this->actor.isTargeted || (globalCtx->actorCtx.targetContext.unk_94 == &this->actor) || + (this->actor.xyzDistToPlayerSq < SQ(80.0f))) { + ret = 1; + } else { + ret = 2; + } + return ret; +} + +void func_80AEEAD4(EnTk* this, GlobalContext* globalCtx) { + s32 sp24 = func_80AEEA4C(this, globalCtx); + + if (sp24 != this->unk_2D0) { + switch (sp24) { + case 0: + func_80AEF220(this, globalCtx); + break; + + case 1: + func_80AEF048(this, globalCtx); + break; + + case 2: + func_80AEEB88(this, globalCtx); + break; + + case 3: + func_80AEF15C(this, globalCtx); + break; + + case 4: + func_80AEF1C4(this, globalCtx); + break; + } + this->unk_2D0 = sp24; + } +} + +void func_80AEEB88(EnTk* this, GlobalContext* globalCtx) { + s32 sp74; + Vec3f sp68; + s32 i; + f32 temp; + + for (i = 0; i < 8; i++) { + sp68.x = Math_SinS(this->actor.world.rot.y + (i * 0x2000)) * 80.0f; + sp68.z = Math_CosS(this->actor.world.rot.y + (i * 0x2000)) * 80.0f; + + sp68.x += this->actor.world.pos.x; + sp68.y = this->actor.world.pos.y + 50.0f; + sp68.z += this->actor.world.pos.z; + + temp = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &this->actor.floorPoly, &sp74, &sp68) - + this->actor.world.pos.y; + if (temp <= -80.0f) { + break; + } + } + + if (i == 8) { + this->unk_2CC = BINANG_ROT180((Rand_Centered() * 0x8000) + this->actor.yawTowardsPlayer); + } else { + this->unk_2CC = this->actor.world.rot.y + (i * 0x2000); + } + + this->unk_2C6 = 100; + func_8013E1C8(&this->skelAnime, D_80AEF868, 1, &this->unk_2D4); + this->unk_30C = func_80AEED38; +} + +void func_80AEED38(EnTk* this, GlobalContext* globalCtx) { + f32 sp64; + Vec3f sp58; + s16 sp56 = this->actor.shape.rot.y; + Vec3f sp48; + Vec3f sp3C; + + Math_Vec3f_Copy(&sp58, &this->actor.world.pos); + sp58.x += (Math_SinS(sp56) * 20.0f); + sp58.y += 30.0f; + sp58.z += Math_CosS(sp56) * 20.0f; + + if (BgCheck_SphVsFirstWall(&globalCtx->colCtx, &sp58, 20.0f)) { + Math_Vec3f_Copy(&sp48, &this->actor.world.pos); + sp56 = BINANG_ADD(this->actor.shape.rot.y, 0x4000); + sp48.x += (Math_SinS(sp56) * 20.0f); + sp48.y += 30.0f; + sp48.z += Math_CosS(sp56) * 20.0f; + + Math_Vec3f_Copy(&sp3C, &this->actor.world.pos); + sp56 = BINANG_SUB(this->actor.shape.rot.y, 0x4000); + sp3C.x += (Math_SinS(sp56) * 20.0f); + sp3C.y += 30.0f; + sp3C.z += Math_CosS(sp56) * 20.0f; + + if (BgCheck_SphVsFirstWall(&globalCtx->colCtx, &sp48, 20.0f)) { + if (BgCheck_SphVsFirstWall(&globalCtx->colCtx, &sp3C, 20.0f)) { + this->unk_2CC = this->actor.shape.rot.y - 0x4000; + } else { + this->unk_2CC = this->actor.shape.rot.y - 0x4000; + } + } else { + this->unk_2CC = this->actor.shape.rot.y + 0x4000; + } + } + + if (this->unk_2CA & 0x200) { + func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + } else { + func_8013E1C8(&this->skelAnime, D_80AEF868, 1, &this->unk_2D4); + func_80AEC658(&this->skelAnime, this->unk_320, 1.0f, &this->actor.speedXZ, &sp64); + } + + if (this->actor.speedXZ > 0.5f) { + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2CC, 2, 0xAAA, 1); + this->actor.shape.rot.y = this->actor.world.rot.y; + } + + if (!func_80152498(&globalCtx->msgCtx) && !func_801690CC(globalCtx) && (this->unk_2C6-- <= 0)) { + func_801518B0(globalCtx, 0x140C, NULL); + this->unk_2CA |= 0x4000; + this->unk_2C6 = 200; + } +} + +void func_80AEF048(EnTk* this, GlobalContext* globalCtx) { + func_8013E1C8(&this->skelAnime, D_80AEF868, 1, &this->unk_2D4); + this->unk_30C = func_80AEF094; +} + +void func_80AEF094(EnTk* this, GlobalContext* globalCtx) { + f32 sp2C; + + if (this->unk_2CA & 0x200) { + func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + } else { + func_8013E1C8(&this->skelAnime, D_80AEF868, 1, &this->unk_2D4); + func_80AEC658(&this->skelAnime, this->unk_320, 1.0f, &this->actor.speedXZ, &sp2C); + } + + if (this->actor.speedXZ >= 0.5f) { + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 2, 0x38E, 1); + this->actor.shape.rot.y = this->actor.world.rot.y; + } +} + +void func_80AEF15C(EnTk* this, GlobalContext* globalCtx) { + this->actor.speedXZ = 0.0f; + func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + this->unk_30C = func_80AEF1B4; +} + +void func_80AEF1B4(EnTk* this, GlobalContext* globalCtx) { +} + +void func_80AEF1C4(EnTk* this, GlobalContext* globalCtx) { + func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + this->unk_30C = func_80AEF210; +} + +void func_80AEF210(EnTk* this, GlobalContext* globalCtx) { +} + +void func_80AEF220(EnTk* this, GlobalContext* globalCtx) { + this->actor.speedXZ = 0.0f; + func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + this->unk_30C = func_80AEF278; +} + +void func_80AEF278(EnTk* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer - 0x1555, 3, 0x1C7, 0); + this->actor.world.rot.y = this->actor.shape.rot.y; +} + +void func_80AEF2C8(Actor* thisx, GlobalContext* globalCtx) { +} + +void func_80AEF2D8(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnTk* this = THIS; + + if (this->actor.draw != NULL) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + this->unk_320 = this->skelAnime.curFrame; + SkelAnime_Update(&this->skelAnime); + + if ((this->actor.draw != NULL) && ((this->unk_2D4 == 0) || (this->unk_2D4 == 1)) && + (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 24.0f))) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOLON_WALK); + } + + this->actionFunc(this, globalCtx); + + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 0.0f, 4); + func_80AEC460(this); +} + +void EnTk_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnTk* this = THIS; + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + this->unk_320 = this->skelAnime.curFrame; + SkelAnime_Update(&this->skelAnime); + func_80AEC460(this); + + if (((this->unk_2D4 == 0) || (this->unk_2D4 == 1)) && + (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 24.0f))) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOLON_WALK); + } + + this->unk_2CA &= ~1; + + if (this->actor.floorBgId != BGCHECK_SCENE) { + BgDanpeiMovebg* platform = (BgDanpeiMovebg*)DynaPoly_GetActor(&globalCtx->colCtx, this->actor.floorBgId); + + if (platform != NULL) { + if (platform->dyna.actor.id == ACTOR_BG_DANPEI_MOVEBG) { + platform->unk_1CC |= 1; + if (platform->unk_1CC & 2) { + this->unk_2CA |= 1; + } + } + } else { + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); + Math_Vec3f_Copy(&this->actor.prevPos, &this->actor.home.pos); + } + } + + this->actionFunc(this, globalCtx); + + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 0.0f, 5); + + if ((this->unk_2B0 == 0) && + (func_800C9B40(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId) == 12)) { + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.prevPos); + this->unk_2CA |= 0x200; + this->actor.velocity.y = 0.0f; + } else { + this->unk_2CA &= ~0x200; + } + + if (!(this->unk_2CA & 0x200)) { + if (!(this->actor.bgCheckFlags & 1)) { + func_800B9010(&this->actor, NA_SE_EV_HONEYCOMB_FALL - SFX_FLAG); + } else if (this->actor.bgCheckFlags & 2) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_HUMAN_BOUND); + } + } +} + +void func_80AEF5F4(Actor* thisx, GlobalContext* globalCtx) { + EnTk* this = THIS; + + this->unk_316 += 0x46C8; + this->unk_318 = Math_SinS(this->unk_316) * 900.0f; + this->actionFunc(this, globalCtx); +} + +s32 func_80AEF65C(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnTk* this = THIS; + + if (limbIndex == 16) { + rot->z += this->unk_31A; + rot->y += this->unk_31C; + } + return false; +} + +void func_80AEF6A4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f D_80AEFA84 = { 0.0f, 0.0f, 4600.0f }; + EnTk* this = THIS; + + if (this->unk_2B0 != 2) { + switch (limbIndex) { + case 16: + Matrix_GetStateTranslation(&this->actor.focus.pos); + break; + + case 14: + Matrix_MultiplyVector3fByState(&D_80AEFA84, &this->unk_2B4); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPDisplayList(POLY_OPA_DISP++, D_0600B530); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + break; + } + } +} + +void EnTk_Draw(Actor* thisx, GlobalContext* globalCtx) { + static UNK_PTR D_80AEFA90[] = { + &D_06004390, + &D_06004B90, + &D_06005390, + }; + s32 pad; + EnTk* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + POLY_OPA_DISP = Gfx_CallSetupDL(POLY_OPA_DISP, 25); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80AEFA90[this->unk_2C2])); + + Matrix_RotateY(this->unk_318, MTXMODE_APPLY); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_80AEF65C, func_80AEF6A4, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Tk/z_en_tk.h b/src/overlays/actors/ovl_En_Tk/z_en_tk.h index 0f79cba14c..119ae2b2bb 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.h +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.h @@ -6,12 +6,61 @@ struct EnTk; typedef void (*EnTkActionFunc)(struct EnTk*, GlobalContext*); +typedef void (*EnTkUnkFunc)(struct EnTk*, GlobalContext*); + +#define ENTK_GET_F(thisx) ((thisx)->params & 0xF) +#define ENTK_GET_7F0(thisx) (((thisx)->params >> 4) & 0x7F) +#define ENTK_GET_F800(thisx) ((((thisx)->params >> 0xB) & 0x1F) & 0xFF) typedef struct EnTk { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnTkActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x268]; + /* 0x018C */ ColliderCylinder collider; + /* 0x01D8 */ Vec3s jointTable[18]; + /* 0x0244 */ Vec3s morphTable[18]; + /* 0x02B0 */ s8 unk_2B0; + /* 0x02B1 */ s8 unk_2B1; + /* 0x02B4 */ Vec3f unk_2B4; + /* 0x02C0 */ s16 unk_2C0; + /* 0x02C2 */ s16 unk_2C2; + /* 0x02C4 */ s16 unk_2C4; + /* 0x02C6 */ s16 unk_2C6; + /* 0x02C8 */ UNK_TYPE1 unk2C8[0x2]; + /* 0x02CA */ u16 unk_2CA; + /* 0x02CC */ s16 unk_2CC; + /* 0x02D0 */ s32 unk_2D0; + /* 0x02D4 */ s32 unk_2D4; + /* 0x02D8 */ f32 unk_2D8; + /* 0x02DC */ f32 unk_2DC; + /* 0x02E0 */ s32 unk_2E0; + /* 0x02E4 */ s16 unk_2E4; + /* 0x02E6 */ u16 unk_2E6; + /* 0x02E8 */ s16 unk_2E8; + /* 0x02EC */ Vec3f unk_2EC; + /* 0x02F8 */ Vec3s unk_2F8; + /* 0x0300 */ Vec3f unk_300; + /* 0x030C */ EnTkUnkFunc unk_30C; + /* 0x0310 */ s16 unk_310; + /* 0x0312 */ s16 cutscenes[2]; + /* 0x0316 */ s16 unk_316; + /* 0x0318 */ s16 unk_318; + /* 0x031A */ s16 unk_31A; + /* 0x031C */ s16 unk_31C; + /* 0x0320 */ f32 unk_320; + /* 0x0324 */ Vec3f unk_324[6]; + /* 0x036C */ s32 unk_36C; + /* 0x0370 */ UNK_TYPE1 unk370[0x58]; + /* 0x03C8 */ Path* unk_3C8; + /* 0x03CC */ u8 unk_3CC; + /* 0x03CE */ u16 unk_3CE; + /* 0x03D0 */ s32 unk_3D0; + /* 0x03D4 */ Vec3f unk_3D4; + /* 0x03E0 */ f32 unk_3E0; + /* 0x03E4 */ s32 unk_3E4; + /* 0x03E8 */ s32 unk_3E8; + /* 0x03EC */ s32 unk_3EC; + /* 0x03F0 */ s32 unk_3F0; } EnTk; // size = 0x3F4 extern const ActorInit En_Tk_InitVars; diff --git a/src/overlays/actors/ovl_En_Torch/z_en_torch.c b/src/overlays/actors/ovl_En_Torch/z_en_torch.c index 786942bcf2..b5c891af0a 100644 --- a/src/overlays/actors/ovl_En_Torch/z_en_torch.c +++ b/src/overlays/actors/ovl_En_Torch/z_en_torch.c @@ -1,7 +1,7 @@ /* * File: z_en_torch.c * Overlay: ovl_En_Torch - * Description: Treasure chest (grotto) + * Description: Grotto chest spawner */ #include "z_en_torch.h" diff --git a/src/overlays/actors/ovl_En_Toto/z_en_toto.c b/src/overlays/actors/ovl_En_Toto/z_en_toto.c index ef3fdf7dcf..0acdc04856 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.c +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.c @@ -612,7 +612,7 @@ s32 func_80BA47E0(EnToto* this, GlobalContext* globalCtx) { s32 func_80BA49A4(EnToto* this, GlobalContext* globalCtx) { func_800B7298(globalCtx, NULL, 0x44); - func_801A31EC(0x54, 4, this->unk2B3 ^ 0xF); + func_801A31EC(NA_BGM_BALLAD_OF_THE_WIND_FISH, 4, this->unk2B3 ^ 0xF); this->unk2B1 = 4; return 0; } @@ -621,8 +621,8 @@ s32 func_80BA4A00(EnToto* this, GlobalContext* globalCtx) { Actor* actor; if (DECR(this->unk2B1) == 0) { - if (!func_801A2DE0(0x54)) { - actor = (Actor*)GET_PLAYER(globalCtx); // Needed for regalloc, possible FAKE MATCH + if (!Audio_IsSequencePlaying(NA_BGM_BALLAD_OF_THE_WIND_FISH)) { + actor = &GET_PLAYER(globalCtx)->actor; actor = actor->next; while (actor != NULL) { Actor_MarkForDeath(actor); diff --git a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c index 9306f4cc87..e74a5dd4d6 100644 --- a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c +++ b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c @@ -1,7 +1,7 @@ /* * File: z_en_trt2.c * Overlay: ovl_En_Trt2 - * Description: + * Description: Kotake in Southern Swamp and Woods of Mystery */ #include "z_en_trt2.h" diff --git a/src/overlays/actors/ovl_En_Wf/z_en_wf.c b/src/overlays/actors/ovl_En_Wf/z_en_wf.c index 0ff4d527b4..fac66b679a 100644 --- a/src/overlays/actors/ovl_En_Wf/z_en_wf.c +++ b/src/overlays/actors/ovl_En_Wf/z_en_wf.c @@ -1,7 +1,7 @@ /* * File: z_en_wf.c * Overlay: ovl_En_Wf - * Description: Wolfos + * Description: Wolfos and White Wolfos */ #include "z_en_wf.h" diff --git a/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c b/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c index d961ffc1b3..d2b5e03788 100644 --- a/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c +++ b/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c @@ -1,7 +1,7 @@ /* * File: z_en_zl4.c * Overlay: ovl_En_Zl4 - * Description: + * Description: Glitched early version of Skull Kid stuck in a T-pose */ #include "z_en_zl4.h" diff --git a/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c b/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c index 551a5d7a0d..c5c0c16ead 100644 --- a/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c +++ b/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c @@ -1,7 +1,7 @@ /* * File: z_item_etcetera.c * Overlay: ovl_Item_Etcetera - * Description: + * Description: Leftover OoT Collectible Items (bottle, key, Fire Arrow, etc.) */ #include "z_item_etcetera.h" diff --git a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c index ccc7e487de..7d0068a52b 100644 --- a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c +++ b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c @@ -1,7 +1,7 @@ /* * File: z_mir_ray.c * Overlay: ovl_Mir_Ray - * Description: Mirror Shield Face & Light Ray + * Description: Reflectible light ray (unused, somewhat broken) */ #include "z_mir_ray.h" diff --git a/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.c b/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.c index 19a1e299bc..d9eb30b4fe 100644 --- a/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.c +++ b/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.c @@ -1,7 +1,7 @@ /* * File: z_mir_ray2.c * Overlay: ovl_Mir_Ray2 - * Description: + * Description: Reflectable light ray (static beam) */ #include "z_mir_ray2.h" diff --git a/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c b/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c index 0159996d86..d68880f2d1 100644 --- a/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c +++ b/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c @@ -1,7 +1,7 @@ /* * File: z_mir_ray3.c * Overlay: ovl_Mir_Ray3 - * Description: + * Description: Mirror shield reflection and glow */ #include "z_mir_ray3.h" diff --git a/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c b/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c index 2b4b762f7b..2b3a3189fc 100644 --- a/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c +++ b/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c @@ -133,8 +133,8 @@ s32 func_80ACBA60(ObjAqua* this, GlobalContext* globalCtx) { f32 ySurface; s32 bgId; - if (func_800C9EBC(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &ySurface, - &waterBox, &bgId) && + if (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &ySurface, &waterBox, &bgId) && (this->actor.world.pos.y < ySurface)) { return true; } diff --git a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c index 953f70e432..18ff5d8dc9 100644 --- a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c +++ b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c @@ -1,7 +1,7 @@ /* * File: z_obj_bean.c * Overlay: ovl_Obj_Bean - * Description: Floating Bean Plant / Dirt Patch + * Description: Floating Bean Plant / Soft Soil */ #include "z_obj_bean.h" diff --git a/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c b/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c index de7f30fbd6..55b8f301f5 100644 --- a/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c +++ b/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c @@ -264,8 +264,8 @@ void func_80A35BD4(Actor* thisx, GlobalContext* globalCtx) { void ObjBell_Init(Actor* thisx, GlobalContext* globalCtx) { ObjBell* this = THIS; - BcCheck3_BgActorInit(&this->dyna, 0); - BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_06001BA8); + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &D_06001BA8); Actor_SetScale(&this->dyna.actor, 0.08f); Collider_InitAndSetSphere(globalCtx, &this->collider1, &this->dyna.actor, &sCylinderInit1); Collider_InitAndSetSphere(globalCtx, &this->collider2, &this->dyna.actor, &sCylinderInit2); @@ -275,7 +275,7 @@ void ObjBell_Init(Actor* thisx, GlobalContext* globalCtx) { void ObjBell_Destroy(Actor* thisx, GlobalContext* globalCtx) { ObjBell* this = THIS; - BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); Collider_DestroySphere(globalCtx, &this->collider1); Collider_DestroySphere(globalCtx, &this->collider2); } diff --git a/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c b/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c index 88ae429458..176f961be8 100644 --- a/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c +++ b/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c @@ -1,7 +1,7 @@ /* * File: z_obj_blockstop.c * Overlay: ovl_Obj_Blockstop - * Description: + * Description: Push Block Trigger - Blockstop switch triggered by pushblock (Snowhead) */ #include "z_obj_blockstop.h" diff --git a/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c b/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c index 7c6580aaf5..c1e74ce532 100644 --- a/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c +++ b/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c @@ -1,7 +1,7 @@ /* * File: z_obj_chikuwa.c * Overlay: ovl_Obj_Chikuwa - * Description: Falling Block Row + * Description: Falling row of blocks (unused) */ #include "z_obj_chikuwa.h" diff --git a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c index c8eff2da69..4a82c76098 100644 --- a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c +++ b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c @@ -1,7 +1,7 @@ /* * File: z_obj_comb.c * Overlay: ovl_Obj_Comb - * Description: Honeycomb + * Description: Beehive */ #include "z_obj_comb.h" diff --git a/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.c b/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.c index 9fa0026fea..91e4e24c7b 100644 --- a/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.c +++ b/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.c @@ -1,7 +1,7 @@ /* * File: z_obj_danpeilift.c * Overlay: ovl_Obj_Danpeilift - * Description: Deku Shrine & Snowhead Temple Elevator + * Description: Deku Shrine & Snowhead Temple floating blocks */ #include "z_obj_danpeilift.h" diff --git a/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c b/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c index 4acf001815..0d4432ddd5 100644 --- a/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c +++ b/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c @@ -1,7 +1,7 @@ /* * File: z_obj_entotu.c * Overlay: ovl_Obj_Entotu - * Description: Clock tower chimney Expelling Smoke + * Description: Clock Town Smoking Chimney */ #include "z_obj_entotu.h" diff --git a/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c b/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c index e4d9707be2..a4eb9ad9ac 100644 --- a/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c +++ b/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c @@ -88,7 +88,7 @@ void ObjEtcetera_Init(Actor* thisx, GlobalContext* globalCtx) { pos.x = this->dyna.actor.world.pos.x; pos.y = this->dyna.actor.world.pos.y + 10.0f; pos.z = this->dyna.actor.world.pos.z; - func_800C411C(&globalCtx->colCtx, &this->dyna.actor.floorPoly, &floorBgId, &this->dyna.actor, &pos); + BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->dyna.actor.floorPoly, &floorBgId, &this->dyna.actor, &pos); this->dyna.actor.floorBgId = floorBgId; Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); Collider_UpdateCylinder(&this->dyna.actor, &this->collider); @@ -101,7 +101,7 @@ void ObjEtcetera_Init(Actor* thisx, GlobalContext* globalCtx) { void ObjEtcetera_Destroy(Actor* thisx, GlobalContext* globalCtx) { ObjEtcetera* this = THIS; - BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); Collider_DestroyCylinder(globalCtx, &this->collider); } @@ -147,7 +147,7 @@ void ObjEtcetera_Idle(ObjEtcetera* this, GlobalContext* globalCtx) { this->oscillationTimer = minOscillationTimer; } } else { - if (func_800CAF70(&this->dyna)) { + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { if (!(this->burrowFlag & 1)) { // Player is walking onto the Deku Flower, or falling on it from a height this->oscillationTimer = 10; @@ -175,7 +175,7 @@ void ObjEtcetera_Idle(ObjEtcetera* this, GlobalContext* globalCtx) { } void ObjEtcetera_PlaySmallFlutterAnimation(ObjEtcetera* this, GlobalContext* globalCtx) { - if (func_800CAF70(&this->dyna)) { + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { this->burrowFlag |= 1; } else { this->burrowFlag &= ~1; @@ -190,11 +190,11 @@ void ObjEtcetera_PlaySmallFlutterAnimation(ObjEtcetera* this, GlobalContext* glo void ObjEtcetera_DoIntenseOscillation(ObjEtcetera* this, GlobalContext* globalCtx) { // In order to match, we are seemingly required to access scale.x at one point // without using this. We can create a thisx or dyna pointer to achieve that, but - // it's more likely they used dyna given that func_800CAF70 takes a DynaPolyActor. + // it's more likely they used dyna given that DynaPolyActor_IsInRidingMovingState takes a DynaPolyActor. DynaPolyActor* dyna = &this->dyna; f32 scaleTemp; - if (func_800CAF70(dyna)) { + if (DynaPolyActor_IsInRidingMovingState(dyna)) { this->burrowFlag |= 1; } else { this->burrowFlag &= ~1; @@ -233,12 +233,12 @@ void ObjEtcetera_Setup(ObjEtcetera* this, GlobalContext* globalCtx) { if (Object_IsLoaded(&globalCtx->objectCtx, this->objIndex)) { this->dyna.actor.objBankIndex = this->objIndex; Actor_SetObjectSegment(globalCtx, &this->dyna.actor); - BcCheck3_BgActorInit(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, 1); thisCollisionHeader = collisionHeaders[type]; if (thisCollisionHeader != 0) { - BgCheck_RelocateMeshHeader(thisCollisionHeader, &colHeader); + CollisionHeader_GetVirtual(thisCollisionHeader, &colHeader); } - this->dyna.bgId = BgCheck_AddActorMesh(globalCtx, &globalCtx->colCtx.dyna, &this->dyna, colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); type = DEKU_FLOWER_TYPE(&this->dyna.actor); switch (type) { @@ -292,7 +292,7 @@ void ObjEtcetera_Update(Actor* thisx, GlobalContext* globalCtx) { if (floorBgId == BGCHECK_SCENE) { floorPoly = this->dyna.actor.floorPoly; if (floorPoly != NULL && this->burrowFlag & 1) { - func_800FAAB4(globalCtx, func_800C9C9C(&globalCtx->colCtx, floorPoly, floorBgId)); + func_800FAAB4(globalCtx, SurfaceType_GetLightSettingIndex(&globalCtx->colCtx, floorPoly, floorBgId)); } } this->actionFunc(this, globalCtx); diff --git a/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c b/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c index b2b6242823..b4f05d8ab3 100644 --- a/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c +++ b/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c @@ -1,7 +1,7 @@ /* * File: z_obj_funen.c * Overlay: ovl_Obj_Funen - * Description: + * Description: Unused(?) Stone Tower smoke */ #include "z_obj_funen.h" diff --git a/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c b/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c index 7a20bab743..4cfc3fcf7b 100644 --- a/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c +++ b/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c @@ -1,5 +1,5 @@ /* - * File z_obj_ghaka.c + * File: z_obj_ghaka.c * Overlay: ovl_Obj_Ghaka * Description: Darmani's Gravestone */ @@ -87,12 +87,12 @@ void func_80B3C39C(ObjGhaka* this, GlobalContext* globalCtx) { } } } - if (this->dyna.unk148 < 0.0f && !(gSaveContext.weekEventReg[20] & 0x20) && + if (this->dyna.pushForce < 0.0f && !(gSaveContext.weekEventReg[20] & 0x20) && player->transformation == PLAYER_FORM_GORON) { func_80B3C2B0(this); } else { player->stateFlags2 &= ~0x10; - this->dyna.unk148 = 0.0f; + this->dyna.pushForce = 0.0f; } } @@ -136,7 +136,7 @@ void func_80B3C624(ObjGhaka* this, GlobalContext* globalCtx) { if (stepTemp) { player->stateFlags2 &= ~0x10; - this->dyna.unk148 = 0.0f; + this->dyna.pushForce = 0.0f; func_80B3C2C4(this, globalCtx); gSaveContext.weekEventReg[20] |= 0x20; func_80B3C260(this); @@ -153,9 +153,9 @@ void ObjGhaka_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->dyna.actor, D_80B3C96C); Actor_SetScale(&this->dyna.actor, 0.1f); - BcCheck3_BgActorInit(&this->dyna, 1); - BgCheck_RelocateMeshHeader(&D_06003CD0, &colHeader); - this->dyna.bgId = BgCheck_AddActorMesh(globalCtx, &globalCtx->colCtx.dyna, &this->dyna, colHeader); + DynaPolyActor_Init(&this->dyna, 1); + CollisionHeader_GetVirtual(&D_06003CD0, &colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 0x4); if (this->dyna.actor.floorPoly == 0) { Actor_MarkForDeath(&this->dyna.actor); @@ -169,7 +169,7 @@ void ObjGhaka_Init(Actor* thisx, GlobalContext* globalCtx) { void ObjGhaka_Destroy(Actor* thisx, GlobalContext* globalCtx) { ObjGhaka* this = THIS; - BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); } void ObjGhaka_Update(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c index 88d20d49b3..8dc01d386e 100644 --- a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c +++ b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c @@ -1,7 +1,7 @@ /* * File: z_obj_grass.c * Overlay: ovl_Obj_Grass - * Description: + * Description: "Master" instance of grass for unit spawned by Obj_Grass_Unit */ #include "z_obj_grass.h" diff --git a/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c b/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c index a603509fa6..af5ebd44a9 100644 --- a/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c +++ b/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c @@ -1,7 +1,7 @@ /* * File: z_obj_grass_carry.c * Overlay: ovl_Obj_Grass_Carry - * Description: + * Description: Grass that the player is holding (spawned by Obj_Grass_Unit) */ #include "z_obj_grass_carry.h" diff --git a/src/overlays/actors/ovl_Obj_Grass_Unit/z_obj_grass_unit.c b/src/overlays/actors/ovl_Obj_Grass_Unit/z_obj_grass_unit.c index e3787849f4..88beb7a6b8 100644 --- a/src/overlays/actors/ovl_Obj_Grass_Unit/z_obj_grass_unit.c +++ b/src/overlays/actors/ovl_Obj_Grass_Unit/z_obj_grass_unit.c @@ -1,7 +1,7 @@ /* * File: z_obj_grass_unit.c * Overlay: ovl_Obj_Grass_Unit - * Description: + * Description: Spawner for circular patch of grass */ #include "z_obj_grass_unit.h" diff --git a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c index 069eb3a669..9784e212c5 100644 --- a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c +++ b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c @@ -1,7 +1,7 @@ /* * File: z_obj_hamishi.c * Overlay: ovl_Obj_Hamishi - * Description: Hammer Stone + * Description: Bronze boulder */ #include "z_obj_hamishi.h" diff --git a/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c b/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c index 9632088b77..0b32504fa1 100644 --- a/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c +++ b/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c @@ -78,13 +78,13 @@ void ObjHgdoor_Init(Actor* thisx, GlobalContext* globalCtx) { CollisionHeader* header = NULL; Actor_SetScale(&this->dyna.actor, 0.1f); - BcCheck3_BgActorInit(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, 1); if (OBJHGDOOR_IS_RIGHT_DOOR(&this->dyna.actor)) { - BgCheck_RelocateMeshHeader(&D_06001D10, &header); + CollisionHeader_GetVirtual(&D_06001D10, &header); } else { - BgCheck_RelocateMeshHeader(&D_060018C0, &header); + CollisionHeader_GetVirtual(&D_060018C0, &header); } - this->dyna.bgId = BgCheck_AddActorMesh(globalCtx, &globalCtx->colCtx.dyna, &this->dyna, header); + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, header); this->rotation = 0; this->timer = 0; this->cutscene = this->dyna.actor.cutscene; @@ -94,7 +94,7 @@ void ObjHgdoor_Init(Actor* thisx, GlobalContext* globalCtx) { void ObjHgdoor_Destroy(Actor* thisx, GlobalContext* globalCtx) { ObjHgdoor* this = THIS; - BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); } void ObjHgdoor_SetupCheckShouldOpen(ObjHgdoor* this) { diff --git a/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c b/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c index 3a61c41e8b..cca1b99224 100644 --- a/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c +++ b/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c @@ -47,8 +47,8 @@ void ObjHsStump_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); this->isHidden = OBJHSSTUMP_GET_ISHIDDEN(thisx); this->switchFlag = OBJHSSTUMP_GET_SWITCHFLAG(thisx); // Must be thisx to match - BcCheck3_BgActorInit(&this->dyna, 1); - BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_060011B0); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &D_060011B0); switch (this->isHidden) { case true: if (Flags_GetSwitch(globalCtx, this->switchFlag)) { @@ -136,7 +136,7 @@ void ObjHsStump_Appear(ObjHsStump* this, GlobalContext* globalCtx) { void ObjHsStump_Destroy(Actor* thisx, GlobalContext* globalCtx) { ObjHsStump* this = THIS; - BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); } void ObjHsStump_Update(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c index 31bde1d512..6731feda71 100644 --- a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c +++ b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c @@ -1,7 +1,7 @@ /* * File: z_obj_hugebombiwa.c * Overlay: ovl_Obj_Hugebombiwa - * Description: Boulder Blocking Goron Racetrack + * Description: Boulder Blocking Goron Racetrack/Milk Road */ #include "z_obj_hugebombiwa.h" diff --git a/src/overlays/actors/ovl_Obj_Kepn_Koya/z_obj_kepn_koya.c b/src/overlays/actors/ovl_Obj_Kepn_Koya/z_obj_kepn_koya.c index 9b3d19051a..65a39be35b 100644 --- a/src/overlays/actors/ovl_Obj_Kepn_Koya/z_obj_kepn_koya.c +++ b/src/overlays/actors/ovl_Obj_Kepn_Koya/z_obj_kepn_koya.c @@ -40,9 +40,9 @@ void ObjKepnKoya_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); Actor_SetScale(&this->dyna.actor, 0.1f); - BcCheck3_BgActorInit(&this->dyna, 0); - BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_0600805C); - if (this->dyna.bgId == 0x32) { + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &D_0600805C); + if (this->dyna.bgId == BG_ACTOR_MAX) { Actor_MarkForDeath(&this->dyna.actor); } } @@ -50,7 +50,7 @@ void ObjKepnKoya_Init(Actor* thisx, GlobalContext* globalCtx) { void ObjKepnKoya_Destroy(Actor* thisx, GlobalContext* globalCtx) { ObjKepnKoya* this = THIS; - BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); } void ObjKepnKoya_Update(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c b/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c index 2d3ea6d4eb..204b506630 100644 --- a/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c +++ b/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c @@ -298,7 +298,7 @@ void ObjKibako_Idle(ObjKibako* this, GlobalContext* globalCtx) { } if ((this->actor.colChkInfo.mass != MASS_IMMOVABLE) && - (Math3D_DistanceSquared(&this->actor.world.pos, &this->actor.prevPos) < 0.01f)) { + (Math3D_Vec3fDistSq(&this->actor.world.pos, &this->actor.prevPos) < 0.01f)) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; } @@ -333,7 +333,7 @@ void ObjKibako_SetupHeld(ObjKibako* this) { void ObjKibako_Held(ObjKibako* this, GlobalContext* globalCtx) { s32 pad; Vec3f pos; - s32 sp2C; + s32 bgId; func_80926394(this, globalCtx); if (Actor_HasNoParent(&this->actor, globalCtx)) { @@ -352,7 +352,8 @@ void ObjKibako_Held(ObjKibako* this, GlobalContext* globalCtx) { pos.x = this->actor.world.pos.x; pos.y = this->actor.world.pos.y + 20.0f; pos.z = this->actor.world.pos.z; - this->actor.floorHeight = func_800C411C(&globalCtx->colCtx, &this->actor.floorPoly, &sp2C, &this->actor, &pos); + this->actor.floorHeight = + BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &bgId, &this->actor, &pos); } } diff --git a/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c b/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c index 87d3f91457..69bfaad18c 100644 --- a/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c +++ b/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c @@ -149,10 +149,10 @@ void ObjKibako2_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; ObjKibako2Contents contents = KIBAKO2_CONTENTS(&this->dyna.actor); - BcCheck3_BgActorInit(&this->dyna, 0); + DynaPolyActor_Init(&this->dyna, 0); Collider_InitCylinder(globalCtx, &this->collider); Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_06000B70); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &D_06000B70); Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); Collider_UpdateCylinder(&this->dyna.actor, &this->collider); this->dyna.actor.home.rot.z = 0; @@ -177,7 +177,7 @@ void ObjKibako2_Destroy(Actor* thisx, GlobalContext* globalCtx) { ObjKibako2* this = THIS; Collider_DestroyCylinder(globalCtx, &this->collider); - BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); } s32 ObjKibako2_ShouldBreak(ObjKibako2* this) { @@ -190,12 +190,12 @@ s32 ObjKibako2_ShouldBreak(ObjKibako2* this) { if (ac != NULL) { if (this->collider.info.acHitInfo->toucher.dmgFlags & (1 << 31)) { // Powder Keg - if (Math3D_DistanceSquared(&this->dyna.actor.world.pos, &ac->world.pos) < SQ(160.0f)) { + if (Math3D_Vec3fDistSq(&this->dyna.actor.world.pos, &ac->world.pos) < SQ(160.0f)) { shouldBreak = true; } } else if (this->collider.info.acHitInfo->toucher.dmgFlags & (1 << 3)) { // Explosives - if (Math3D_DistanceSquared(&this->dyna.actor.world.pos, &ac->world.pos) < SQ(100.0f)) { + if (Math3D_Vec3fDistSq(&this->dyna.actor.world.pos, &ac->world.pos) < SQ(100.0f)) { shouldBreak = true; } } else if (this->collider.info.acHitInfo->toucher.dmgFlags & (1 << 8 | 1 << 10)) { diff --git a/src/overlays/actors/ovl_Obj_Lightblock/z_obj_lightblock.c b/src/overlays/actors/ovl_Obj_Lightblock/z_obj_lightblock.c index d955a5aa3a..9f4b8c2b0d 100644 --- a/src/overlays/actors/ovl_Obj_Lightblock/z_obj_lightblock.c +++ b/src/overlays/actors/ovl_Obj_Lightblock/z_obj_lightblock.c @@ -91,12 +91,12 @@ void ObjLightblock_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); Actor_SetScale(&this->dyna.actor, typeVars->scale); - BcCheck3_BgActorInit(&this->dyna, 0); + DynaPolyActor_Init(&this->dyna, 0); Collider_InitCylinder(globalCtx, &this->collider); if (Flags_GetSwitch(globalCtx, LIGHTBLOCK_DESTROYED(&this->dyna.actor))) { Actor_MarkForDeath(&this->dyna.actor); } else { - BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_06000B80); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &D_06000B80); Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); Collider_UpdateCylinder(&this->dyna.actor, &this->collider); this->collider.dim.radius = typeVars->radius; @@ -110,7 +110,7 @@ void ObjLightblock_Init(Actor* thisx, GlobalContext* globalCtx) { void ObjLightblock_Destroy(Actor* thisx, GlobalContext* globalCtx) { ObjLightblock* this = THIS; - BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); Collider_DestroyCylinder(globalCtx, &this->collider); } diff --git a/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.c b/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.c index f0cc27a9c9..19c0787927 100644 --- a/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.c +++ b/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.c @@ -1,7 +1,7 @@ /* * File: z_obj_makekinsuta.c * Overlay: ovl_Obj_Makekinsuta - * Description: Dirt Patch with Skulltula hiding in it + * Description: Swamp Spider House - Soft soil with Skulltula hiding in it */ #include "z_obj_makekinsuta.h" diff --git a/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.c b/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.c index a704f2773c..e864e86b42 100644 --- a/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.c +++ b/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.c @@ -85,7 +85,7 @@ void ObjMakeoshihiki_Update(Actor* thisx, GlobalContext* globalCtx) { } else { for (loopPathIndex = 0; loopPathIndex < this->pathCount; loopPathIndex++) { Math_Vec3s_ToVec3f(&pathPointF, &this->pathPoints[loopPathIndex]); - if (Math3D_DistanceSquared(&this->actor.child->world.pos, &pathPointF) < SQ(0.5f)) { + if (Math3D_Vec3fDistSq(&this->actor.child->world.pos, &pathPointF) < SQ(0.5f)) { ObjMakeoshihiki_SetSwitchFlags(this, globalCtx, loopPathIndex); return; } diff --git a/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c b/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c index fa1101ea02..9b7582f85a 100644 --- a/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c +++ b/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c @@ -1,5 +1,5 @@ /* - * File z_obj_moon_stone.c + * File: z_obj_moon_stone.c * Overlay: ovl_Obj_Moon_Stone * Description: Moon's Tear */ diff --git a/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c b/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c index 41446b8055..0e510d6b31 100644 --- a/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c +++ b/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c @@ -1,7 +1,7 @@ /* * File: z_obj_mu_pict.c * Overlay: ovl_Obj_Mu_Pict - * Description: + * Description: Handles dialogue for checking the Garo/Gibdo poster in the Music Box House */ #include "z_obj_mu_pict.h" diff --git a/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.c b/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.c index 7191ca259d..1519f92eba 100644 --- a/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.c +++ b/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.c @@ -14,11 +14,12 @@ void ObjMure_Init(Actor* thisx, GlobalContext* globalCtx); void ObjMure_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjMure_Update(Actor* thisx, GlobalContext* globalCtx); -void func_808D7FFC(ObjMure* this, GlobalContext* globalCtx); -void func_808D8014(ObjMure* this, GlobalContext* globalCtx); -void func_808D8678(ObjMure* this, GlobalContext* globalCtx); +void ObjMure_InitialAction(ObjMure* this, GlobalContext* globalCtx); +void ObjMure_CulledState(ObjMure* this, GlobalContext* globalCtx); +void ObjMure_ActiveState(ObjMure* this, GlobalContext* globalCtx); +void ObjMure_KillActors(ObjMure* this, GlobalContext* globalCtx); +void ObjMure_CheckChildren(ObjMure* this, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Mure_InitVars = { ACTOR_OBJ_MURE, ACTORCAT_ITEMACTION, @@ -31,53 +32,368 @@ const ActorInit Obj_Mure_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808D87BC[] = { +static f32 sZClip[] = { + 1600.0f, 1600.0f, 1000.0f, 1000.0f, 1000.0f, +}; + +static s32 sMaxChildSpawns[] = { + 12, + 9, + 8, + 0, +}; + +static s16 sSpawnActorIds[] = { + ACTOR_EN_KUSA, 0, ACTOR_EN_FISH, ACTOR_EN_INSECT, ACTOR_EN_BUTTE, +}; + +static s16 sSpawnParams[] = { + 0, 2, -1, 0, -1, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 1200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 1200, ICHAIN_STOP), }; -#endif +typedef enum { + /* 0 */ OBJMURE_TYPE_GRASS, + /* 1 */ OBJMURE_TYPE_UNDEFINED, + /* 2 */ OBJMURE_TYPE_FISH, + /* 3 */ OBJMURE_TYPE_BUGS, + /* 4 */ OBJMURE_TYPE_BUTTERFLY, + /* 5 */ OBJMURE_TYPE_MAX +} ObjMureType; -extern InitChainEntry D_808D87BC[]; +typedef enum { + /* 0 */ OBJMURE_CHILD_STATE_0, + /* 1 */ OBJMURE_CHILD_STATE_DEAD, + /* 2 */ OBJMURE_CHILD_STATE_2 +} ObjMureChildState; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure/func_808D78D0.s") +s32 func_808D78D0(ObjMure* this, GlobalContext* globalCtx) { + if (this->type == OBJMURE_TYPE_FISH || this->type == OBJMURE_TYPE_BUGS || this->type == OBJMURE_TYPE_BUTTERFLY) { + Actor_ProcessInitChain(&this->actor, sInitChain); + } else { + return false; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure/func_808D7928.s") +s32 func_808D7928(ObjMure* this, GlobalContext* globalCtx) { + if (!func_808D78D0(this, globalCtx)) { + return false; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure/ObjMure_Init.s") +void ObjMure_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjMure* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure/ObjMure_Destroy.s") + this->chNum = OBJ_MURE_GET_CHNUM(this->actor.params); + this->ptn = OBJ_MURE_GET_PTN(this->actor.params); + this->svNum = OBJ_MURE_GET_SVNUM(this->actor.params); + this->type = OBJ_MURE_GET_TYPE(this->actor.params); + if (this->ptn >= 4) { + Actor_MarkForDeath(&this->actor); + return; + } + if (this->type >= OBJMURE_TYPE_MAX) { + Actor_MarkForDeath(&this->actor); + return; + } + if (!func_808D7928(this, globalCtx)) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actionFunc = ObjMure_InitialAction; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure/func_808D7A14.s") +void ObjMure_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure/func_808D7A40.s") +s32 ObjMure_GetMaxChildSpawns(ObjMure* this) { + if (this->chNum == 0) { + return sMaxChildSpawns[this->ptn]; + } + return this->chNum; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure/func_808D7A68.s") +void ObjMure_GetSpawnPos(Vec3f* outPos, Vec3f* inPos, s32 ptn, s32 idx) { + *outPos = *inPos; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure/func_808D7C64.s") +void ObjMure_SpawnActors0(Actor* thisx, GlobalContext* globalCtx) { + ObjMure* this = THIS; + s32 i; + Vec3f pos; + s32 pad; + s32 maxChildren = ObjMure_GetMaxChildSpawns(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure/func_808D7DC4.s") + for (i = 0; i < maxChildren; i++) { + switch (this->childrenStates[i]) { + case OBJMURE_CHILD_STATE_DEAD: + break; + case OBJMURE_CHILD_STATE_2: + ObjMure_GetSpawnPos(&pos, &this->actor.world.pos, this->ptn, i); + this->children[i] = Actor_SpawnAsChildAndCutscene( + &globalCtx->actorCtx, globalCtx, sSpawnActorIds[this->type], pos.x, pos.y, pos.z, + this->actor.world.rot.x, this->actor.world.rot.y, this->actor.world.rot.z, sSpawnParams[this->type], + this->actor.cutscene, this->actor.unk20, NULL); + if (this->children[i] != NULL) { + if (this->type == 0x90) { + ((ObjMureChild*)this->children[i])->unk_197 = 1; + } + this->children[i]->room = this->actor.room; + } + break; + default: + ObjMure_GetSpawnPos(&pos, &this->actor.world.pos, this->ptn, i); + this->children[i] = Actor_SpawnAsChildAndCutscene( + &globalCtx->actorCtx, globalCtx, sSpawnActorIds[this->type], pos.x, pos.y, pos.z, + this->actor.world.rot.x, this->actor.world.rot.y, this->actor.world.rot.z, sSpawnParams[this->type], + this->actor.cutscene, this->actor.unk20, NULL); + if (this->children[i] != NULL) { + this->children[i]->room = this->actor.room; + } + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure/func_808D7E14.s") +void ObjMure_SpawnActors1(ObjMure* this, GlobalContext* globalCtx) { + GlobalContext* globalCtx2 = globalCtx; + Actor* actor = &this->actor; + Vec3f spawnPos; + s32 maxChildren = ObjMure_GetMaxChildSpawns(this); + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure/func_808D7F0C.s") + for (i = 0; i < maxChildren; i++) { + ObjMure_GetSpawnPos(&spawnPos, &actor->world.pos, this->ptn, i); + this->children[i] = Actor_SpawnAsChildAndCutscene( + &globalCtx->actorCtx, globalCtx, sSpawnActorIds[this->type], spawnPos.x, spawnPos.y, spawnPos.z, + actor->world.rot.x, actor->world.rot.y, actor->world.rot.z, + (this->type == OBJMURE_TYPE_BUTTERFLY && i == 0) ? 1 : sSpawnParams[this->type], this->actor.cutscene, + this->actor.unk20, NULL); + if (this->children[i] != NULL) { + this->childrenStates[i] = OBJMURE_CHILD_STATE_0; + this->children[i]->room = actor->room; + } else { + this->childrenStates[i] = OBJMURE_CHILD_STATE_DEAD; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure/func_808D7F2C.s") +void ObjMure_SpawnActors(ObjMure* this, GlobalContext* globalCtx) { + switch (this->svNum) { + case 0: + ObjMure_SpawnActors0(&this->actor, globalCtx); + break; + case 1: + ObjMure_SpawnActors1(this, globalCtx); + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure/func_808D7FFC.s") +void ObjMure_KillActorsImpl(ObjMure* this, GlobalContext* globalCtx) { + s32 maxChildren = ObjMure_GetMaxChildSpawns(this); + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure/func_808D8014.s") + for (i = 0; i < maxChildren; i++) { + switch (this->childrenStates[i]) { + case OBJMURE_CHILD_STATE_DEAD: + this->children[i] = NULL; + break; + case OBJMURE_CHILD_STATE_2: + if (this->children[i] != NULL) { + Actor_MarkForDeath(this->children[i]); + this->children[i] = NULL; + } + break; + default: + if (this->children[i] != NULL) { + if (Actor_HasParent(this->children[i], globalCtx)) { + this->children[i] = NULL; + } else { + Actor_MarkForDeath(this->children[i]); + this->children[i] = NULL; + } + } + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure/func_808D8074.s") +void ObjMure_KillActors(ObjMure* this, GlobalContext* globalCtx) { + ObjMure_KillActorsImpl(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure/func_808D814C.s") +void ObjMure_CheckChildren(ObjMure* this, GlobalContext* globalCtx) { + s32 maxChildren = ObjMure_GetMaxChildSpawns(this); + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure/func_808D82CC.s") + for (i = 0; i < maxChildren; i++) { + if (this->children[i] != NULL) { + if (this->childrenStates[i] == OBJMURE_CHILD_STATE_0) { + if (this->children[i]->update != NULL) { + if ((this->type == 0x90) && (((ObjMureChild*)this->children[i])->unk_197 != 0)) { + this->childrenStates[i] = OBJMURE_CHILD_STATE_2; + } + } else { + this->childrenStates[i] = OBJMURE_CHILD_STATE_DEAD; + this->children[i] = NULL; + } + } else if (this->childrenStates[i] == OBJMURE_CHILD_STATE_2 && this->children[i]->update == NULL) { + this->childrenStates[i] = OBJMURE_CHILD_STATE_DEAD; + this->children[i] = NULL; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure/func_808D84F4.s") +void ObjMure_InitialAction(ObjMure* this, GlobalContext* globalCtx) { + this->actionFunc = ObjMure_CulledState; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure/func_808D8678.s") +void ObjMure_CulledState(ObjMure* this, GlobalContext* globalCtx) { + if (fabsf(this->actor.projectedPos.z) < sZClip[this->type]) { + this->actionFunc = ObjMure_ActiveState; + this->actor.flags |= 0x10; + ObjMure_SpawnActors(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure/ObjMure_Update.s") +void ObjMure_SetFollowTargets(ObjMure* this, f32 randMax) { + s32 index; + s32 maxChildren = ObjMure_GetMaxChildSpawns(this); + s32 i; + + for (i = 0; i < maxChildren; i++) { + if (this->children[i] != NULL) { + this->children[i]->child = NULL; + if (Rand_ZeroOne() <= randMax) { + index = Rand_ZeroOne() * (maxChildren - 0.5f); + if (i != index) { + this->children[i]->child = this->children[index]; + } + } + } + } +} + +/** + * Selects a child that will follow after the player + * `idx1` is the index + 1 of the child that will follow the player. If `idx1` is zero, no actor will follow the player + */ +void ObjMure_SetChildToFollowPlayer(ObjMure* this, s32 idx1) { + s32 maxChildren = ObjMure_GetMaxChildSpawns(this); + s32 i; + s32 i2; + s32 j; + + for (i = 0, i2 = 0; i < maxChildren; i++) { + if (this->children[i] != NULL) { + if (i2 < idx1) { + i2++; + this->children[i]->child = this->children[i]; + for (j = 0; j < maxChildren; j++) { + if (i != j && this->children[j]->child == this->children[i]) { + this->children[j]->child = NULL; + } + } + } else if (this->children[i]->child == this->children[i]) { + this->children[i]->child = NULL; + } + } + } +} + +// Fish, Bugs +void ObjMure_GroupBehavior0(ObjMure* this, GlobalContext* globalCtx) { + if (this->unk_19C <= 0) { + if (this->unk_19E) { + this->unk_19E = false; + ObjMure_SetFollowTargets(this, (Rand_ZeroOne() * 0.5f) + 0.1f); + if (this->actor.xzDistToPlayer < 60.0f) { + this->unk_19C = (s32)(Rand_ZeroOne() * 5.5f) + 4; + } else { + this->unk_19C = (s32)(Rand_ZeroOne() * 40.5f) + 4; + } + } else { + this->unk_19E = true; + if (this->actor.xzDistToPlayer < 60.0f) { + this->unk_19C = (s32)(Rand_ZeroOne() * 10.5f) + 4; + ObjMure_SetFollowTargets(this, (Rand_ZeroOne() * 0.2f) + 0.8f); + } else { + this->unk_19C = (s32)(Rand_ZeroOne() * 10.5f) + 4; + ObjMure_SetFollowTargets(this, (Rand_ZeroOne() * 0.2f) + 0.6f); + } + } + } + if (this->actor.xzDistToPlayer < 120.0f) { + this->unk_1A0++; + } else { + this->unk_1A0 = 0; + } + if (this->unk_1A0 >= 80) { + ObjMure_SetChildToFollowPlayer(this, 1); + } else { + ObjMure_SetChildToFollowPlayer(this, 0); + } +} + +// Butterflies +void ObjMure_GroupBehavior1(ObjMure* this, GlobalContext* globalCtx) { + s32 maxChildren; + s32 i; + + if (this->unk_19C <= 0) { + if (this->unk_19E) { + this->unk_19E = false; + ObjMure_SetFollowTargets(this, Rand_ZeroOne() * 0.2f); + if (this->actor.xzDistToPlayer < 60.0f) { + this->unk_19C = (s32)(Rand_ZeroOne() * 5.5f) + 4; + } else { + this->unk_19C = (s32)(Rand_ZeroOne() * 40.5f) + 4; + } + } else { + this->unk_19E = true; + ObjMure_SetFollowTargets(this, Rand_ZeroOne() * 0.7f); + this->unk_19C = (s32)(Rand_ZeroOne() * 10.5f) + 4; + } + } + + maxChildren = ObjMure_GetMaxChildSpawns(this); + for (i = 0; i < maxChildren; i++) { + if (this->children[i] != NULL) { + if (this->children[i]->child != NULL && this->children[i]->child->update == NULL) { + this->children[i]->child = NULL; + } + } + } +} + +static ObjMureActionFunc sTypeGroupBehaviorFunc[] = { + NULL, NULL, ObjMure_GroupBehavior0, ObjMure_GroupBehavior0, ObjMure_GroupBehavior1, +}; + +void ObjMure_ActiveState(ObjMure* this, GlobalContext* globalCtx) { + ObjMure_CheckChildren(this, globalCtx); + if (sZClip[this->type] + 40.0f <= fabsf(this->actor.projectedPos.z)) { + this->actionFunc = ObjMure_CulledState; + this->actor.flags &= ~0x10; + ObjMure_KillActors(this, globalCtx); + } else if (sTypeGroupBehaviorFunc[this->type] != NULL) { + sTypeGroupBehaviorFunc[this->type](this, globalCtx); + } +} + +void ObjMure_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjMure* this = THIS; + + if (this->unk_19C > 0) { + this->unk_19C--; + } + this->actionFunc(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.h b/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.h index dfb6e10c7c..1cb9a653a1 100644 --- a/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.h +++ b/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.h @@ -7,12 +7,33 @@ struct ObjMure; typedef void (*ObjMureActionFunc)(struct ObjMure*, GlobalContext*); +#define OBJMURE_MAX_SPAWNS 15 + +typedef struct { + Actor actor; + /* 0x144 */ char unk_144[0x53]; + /* 0x197 */ u8 unk_197; +} ObjMureChild; + typedef struct ObjMure { /* 0x0000 */ Actor actor; /* 0x0144 */ ObjMureActionFunc actionFunc; - /* 0x0148 */ char unk_144[0x5C]; + /* 0x0148 */ s16 chNum; + /* 0x014A */ s16 ptn; + /* 0x014C */ s16 svNum; + /* 0x014E */ s16 type; + /* 0x0150 */ Actor* children[OBJMURE_MAX_SPAWNS]; + /* 0x018C */ u8 childrenStates[OBJMURE_MAX_SPAWNS]; + /* 0x019C */ s16 unk_19C; + /* 0x019E */ s16 unk_19E; + /* 0x01A0 */ s16 unk_1A0; } ObjMure; // size = 0x1A4 extern const ActorInit Obj_Mure_InitVars; +#define OBJ_MURE_GET_CHNUM(params) ((params >> 12) & 0xF) +#define OBJ_MURE_GET_PTN(params) ((params >> 8) & 0x7) +#define OBJ_MURE_GET_SVNUM(params) ((params >> 5) & 0x3) +#define OBJ_MURE_GET_TYPE(params) (params & 0x1F) + #endif // Z_OBJ_MURE_H diff --git a/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.c b/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.c index fe7d900624..66dbd49fbd 100644 --- a/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.c +++ b/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.c @@ -1,7 +1,7 @@ /* * File: z_obj_ocarinalift.c * Overlay: ovl_Obj_Ocarinalift - * Description: Elevator With Triforce Texture + * Description: Elevator With Triforce Texture (unused?) */ #include "z_obj_ocarinalift.h" diff --git a/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c b/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c index eb9202197b..041e869826 100644 --- a/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c +++ b/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c @@ -70,8 +70,8 @@ void ObjRaillift_Init(Actor* thisx, GlobalContext* globalCtx) { thisx->world.rot.x = 0; thisx->shape.rot.z = 0; thisx->world.rot.z = 0; - BcCheck3_BgActorInit(&this->dyna, 1); - BgCheck3_LoadMesh(globalCtx, &this->dyna, sColHeaders[type]); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, sColHeaders[type]); this->speed = OBJRAILLIFT_GET_SPEED(thisx); if (this->speed < 0.0f) { this->speed = -this->speed; @@ -107,7 +107,7 @@ void ObjRaillift_Init(Actor* thisx, GlobalContext* globalCtx) { void ObjRaillift_Destroy(Actor* thisx, GlobalContext* globalCtx) { ObjRaillift* this = THIS; - BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); } void ObjRaillift_DoNothing(ObjRaillift* this, GlobalContext* globalCtx) { @@ -187,7 +187,7 @@ void ObjRaillift_Move(ObjRaillift* this, GlobalContext* globalCtx) { Will teleport to what ever curpoint is set to */ void ObjRaillift_Teleport(ObjRaillift* this, GlobalContext* globalCtx) { - if (!func_800CAF70(&this->dyna)) { + if (!DynaPolyActor_IsInRidingMovingState(&this->dyna)) { ObjRaillift_UpdatePosition(this, this->curPoint); func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); this->actionFunc = ObjRaillift_Move; @@ -237,7 +237,7 @@ void ObjRaillift_Update(Actor* thisx, GlobalContext* globalCtx) { s32 requiredScopeTemp; this->isWeightOnPrev = this->isWeightOn; - if (func_800CAF70(&this->dyna)) { + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { this->isWeightOn = true; } else { this->isWeightOn = false; diff --git a/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.c b/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.c index 80cad625f4..61bc5570c6 100644 --- a/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.c +++ b/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.c @@ -1,7 +1,7 @@ /* * File: z_obj_shutter.c * Overlay: ovl_Obj_Shutter - * Description: + * Description: Unused West Clock Town bank closing shutter */ #include "z_obj_shutter.h" diff --git a/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c b/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c index e0e1c99a4e..cf7c484311 100644 --- a/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c +++ b/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c @@ -1,7 +1,7 @@ /* * File: z_obj_spinyroll.c * Overlay: ovl_Obj_Spinyroll - * Description: Spike-Covered Log + * Description: Horizontal Spike-Covered Log */ #include "z_obj_spinyroll.h" diff --git a/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.c b/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.c index bc56c60d2b..3d94f31b6f 100644 --- a/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.c +++ b/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.c @@ -1,7 +1,7 @@ /* * File: z_obj_swprize.c * Overlay: ovl_Obj_Swprize - * Description: Spawner for dirt square prize? + * Description: Spawns item drop from soft soil */ #include "z_obj_swprize.h" diff --git a/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c index 03e96013a3..3eb50153be 100644 --- a/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c +++ b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c @@ -155,8 +155,8 @@ void ObjSyokudai_Update(Actor* thisx, GlobalContext* globalCtx2) { this->pendingAction = OBJ_SYOKUDAI_PENDING_ACTION_NONE; } } else { - if (func_800CA1E8(globalCtx, &globalCtx->colCtx, thisx->world.pos.x, thisx->world.pos.z, &waterSurface, - &waterBox) && + if (WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, thisx->world.pos.x, thisx->world.pos.z, &waterSurface, + &waterBox) && ((waterSurface - thisx->world.pos.y) > OBJ_SYOKUDAI_FLAME_HEIGHT)) { this->snuffTimer = OBJ_SYOKUDAI_SNUFF_OUT; diff --git a/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c b/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c index 22bcddc570..837c05ae9f 100644 --- a/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c +++ b/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c @@ -195,9 +195,9 @@ void ObjTokeiStep_Init(Actor* thisx, GlobalContext* globalCtx) { ObjTokeiStep* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - BcCheck3_BgActorInit(&this->dyna, 0); + DynaPolyActor_Init(&this->dyna, 0); if ((globalCtx->sceneNum == 0x6F) && (gSaveContext.sceneSetupIndex == 2) && (globalCtx->csCtx.unk_12 == 0)) { - BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_06000968); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &D_06000968); ObjTokeiStep_InitSteps(this); ObjTokeiStep_SetupBeginOpen(this); } else if (!((CURRENT_DAY != 3) || (gSaveContext.time >= 0x4000)) || gSaveContext.day >= 4) { @@ -205,7 +205,7 @@ void ObjTokeiStep_Init(Actor* thisx, GlobalContext* globalCtx) { ObjTokeiStep_InitStepsOpen(this); ObjTokeiStep_SetupDoNothingOpen(this); } else { - BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_06000968); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &D_06000968); ObjTokeiStep_InitSteps(this); ObjTokeiStep_SetupDoNothing(this); } @@ -214,7 +214,7 @@ void ObjTokeiStep_Init(Actor* thisx, GlobalContext* globalCtx) { void ObjTokeiStep_Destroy(Actor* thisx, GlobalContext* globalCtx) { ObjTokeiStep* this = THIS; - BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); } void ObjTokeiStep_SetupBeginOpen(ObjTokeiStep* this) { diff --git a/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.c b/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.c index 5a84ec663c..325bd3f3ea 100644 --- a/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.c +++ b/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.c @@ -1,7 +1,7 @@ /* * File: z_obj_toudai.c * Overlay: ovl_Obj_Toudai - * Description: Clock Tower Spotlight + * Description: Unused early Clock Tower Spotlight */ #include "z_obj_toudai.h" diff --git a/src/overlays/actors/ovl_Obj_Visiblock/z_obj_visiblock.c b/src/overlays/actors/ovl_Obj_Visiblock/z_obj_visiblock.c index 23178e9c1f..427400f99a 100644 --- a/src/overlays/actors/ovl_Obj_Visiblock/z_obj_visiblock.c +++ b/src/overlays/actors/ovl_Obj_Visiblock/z_obj_visiblock.c @@ -40,14 +40,14 @@ void ObjVisiblock_Init(Actor* thisx, GlobalContext* globalCtx) { ObjVisiblock* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - BcCheck3_BgActorInit(&this->dyna, 0); - BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_06000AD0); + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &D_06000AD0); } void ObjVisiblock_Destroy(Actor* thisx, GlobalContext* globalCtx) { ObjVisiblock* this = THIS; - BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); } void ObjVisiblock_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c index df293030a6..c830c29d9f 100644 --- a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c +++ b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c @@ -1,7 +1,7 @@ /* * File: z_obj_vspinyroll.c * Overlay: ovl_Obj_Vspinyroll - * Description: Spiked rollers + * Description: Vertical Spiked rollers */ #include "z_obj_vspinyroll.h" diff --git a/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.c b/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.c index 55e14fb154..3c0fce6314 100644 --- a/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.c +++ b/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.c @@ -1,7 +1,7 @@ /* * File: z_obj_y2lift.c * Overlay: ovl_Obj_Y2lift - * Description: + * Description: Unused elevator platform */ #include "z_obj_y2lift.h" diff --git a/src/overlays/actors/ovl_Obj_Y2shutter/z_obj_y2shutter.c b/src/overlays/actors/ovl_Obj_Y2shutter/z_obj_y2shutter.c index 6eb1cffa79..c9850690d2 100644 --- a/src/overlays/actors/ovl_Obj_Y2shutter/z_obj_y2shutter.c +++ b/src/overlays/actors/ovl_Obj_Y2shutter/z_obj_y2shutter.c @@ -1,7 +1,7 @@ /* * File: z_obj_y2shutter.c * Overlay: ovl_Obj_Y2shutter - * Description: + * Description: Pirates' Fortress sliding grate */ #include "z_obj_y2shutter.h" diff --git a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c index 2787b2ef4c..ce88071314 100644 --- a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c +++ b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c @@ -1,7 +1,7 @@ /* * File: z_object_kankyo.c * Overlay: ovl_Object_Kankyo - * Description: + * Description: Snow, rain in Skull Kid backstory cutscene, and bubbles deep in Pinnacle Rock */ #include "z_object_kankyo.h" diff --git a/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c b/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c index bd9b0c4e47..4b1e1d8bae 100644 --- a/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c +++ b/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c @@ -1,7 +1,7 @@ /* * File: z_oceff_spot.c * Overlay: ovl_Oceff_Spot - * Description: + * Description: Sun's Song Ocarina Effect */ #include "z_oceff_spot.h" diff --git a/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c b/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c index 14860ee61f..781e506058 100644 --- a/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c +++ b/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c @@ -1,7 +1,7 @@ /* * File: z_oceff_storm.c * Overlay: ovl_Oceff_Storm - * Description: + * Description: Song of Storms Ocarina Effect */ #include "z_oceff_storm.h" diff --git a/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c b/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c index 087dd5ecf1..b5dd2f290a 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c +++ b/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c @@ -1,7 +1,7 @@ /* * File: z_oceff_wipe.c * Overlay: ovl_Oceff_Wipe - * Description: + * Description: Song of Time Ocarina Effect */ #include "z_oceff_wipe.h" diff --git a/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c b/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c index 1caac073e0..aee5dd446e 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c +++ b/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c @@ -1,7 +1,7 @@ /* * File: z_oceff_wipe2.c * Overlay: ovl_Oceff_Wipe2 - * Description: + * Description: Epona's Song Ocarina Effect */ #include "z_oceff_wipe2.h" diff --git a/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c b/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c index cf0fabe942..0ef0a25e88 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c +++ b/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c @@ -1,7 +1,7 @@ /* * File: z_oceff_wipe3.c * Overlay: ovl_Oceff_Wipe3 - * Description: + * Description: Unused OoT Saria's Song Ocarina Effect */ #include "z_oceff_wipe3.h" diff --git a/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c b/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c index 99e9e20489..b9a89614bc 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c +++ b/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c @@ -1,7 +1,7 @@ /* * File: z_oceff_wipe4.c * Overlay: ovl_Oceff_Wipe4 - * Description: + * Description: Scarecrow's Song Ocarina Effect */ #include "z_oceff_wipe4.h" diff --git a/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c b/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c index 637d91cc7a..8cac4317d2 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c +++ b/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c @@ -1,7 +1,7 @@ /* * File: z_oceff_wipe5.c * Overlay: ovl_Oceff_Wipe5 - * Description: + * Description: Sonata/Lullaby/Bossa Nova/Elegy/Oath Ocarina Effect */ #include "z_oceff_wipe5.h" diff --git a/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c b/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c index 365475ac22..c14a59e9f4 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c +++ b/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c @@ -1,7 +1,7 @@ /* * File: z_oceff_wipe6.c * Overlay: ovl_Oceff_Wipe6 - * Description: + * Description: Song of Soaring Ocarina Effect */ #include "z_oceff_wipe6.h" diff --git a/src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.c b/src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.c index 1adf9d44ca..f031303435 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.c +++ b/src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.c @@ -1,7 +1,7 @@ /* * File: z_oceff_wipe7.c * Overlay: ovl_Oceff_Wipe7 - * Description: + * Description: Song of Healing Ocarina Effect */ #include "z_oceff_wipe7.h" diff --git a/src/overlays/gamestates/ovl_select/z_select.c b/src/overlays/gamestates/ovl_select/z_select.c index 550bbbc8e0..1cae35a850 100644 --- a/src/overlays/gamestates/ovl_select/z_select.c +++ b/src/overlays/gamestates/ovl_select/z_select.c @@ -45,7 +45,7 @@ void Select_LoadGame(SelectContext* this, u32 entranceIndex, s32 opt) { } gSaveContext.respawn[0].entranceIndex = 0xFFFF; - gSaveContext.seqIndex = 0xFF; + gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; gSaveContext.nightSeqIndex = 0xFF; gSaveContext.showTitleCard = true; gSaveContext.respawnFlag = 0; diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.c index ed732fc3db..62a85c8633 100644 --- a/src/overlays/gamestates/ovl_title/z_title.c +++ b/src/overlays/gamestates/ovl_title/z_title.c @@ -127,7 +127,7 @@ void Title_Main(GameState* thisx) { Title_UpdateCounters(this); Title_Draw(&this->gameState); if (this->exit) { - gSaveContext.seqIndex = 0xFF; + gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; gSaveContext.nightSeqIndex = 0xFF; gSaveContext.gameMode = 1; diff --git a/tools/disasm/disasm.py b/tools/disasm/disasm.py old mode 100644 new mode 100755 index 8c6c868241..5f8aae37d9 --- a/tools/disasm/disasm.py +++ b/tools/disasm/disasm.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import argparse, ast, math, os, re, struct +import bisect from mips_isa import * from multiprocessing import Pool @@ -88,11 +89,11 @@ multiply_referenced_rodata = set() # rodata with more than 1 reference outside o files = set() # vram start of file vrom_variables = list() # (name,addr) +vrom_addrs = set() # set of addrs from vrom_variables, for faster lookup functions_ast = None variables_ast = None - -vars_cache = {} # (address: variable + addend) +variable_addrs = None def proper_name(symbol, in_data=False, is_symbol=True): # hacks @@ -116,7 +117,7 @@ def proper_name(symbol, in_data=False, is_symbol=True): return functions_ast[symbol][0] elif symbol in variables_ast.keys(): return variables_ast[symbol][0] - elif symbol in [addr for _,addr in vrom_variables]: + elif symbol in vrom_addrs: # prefer "start" vrom symbols if symbol in [addr for name,addr in vrom_variables if "SegmentRomStart" in name]: return [name for name,addr in vrom_variables if "SegmentRomStart" in name and addr == symbol][0] @@ -124,8 +125,15 @@ def proper_name(symbol, in_data=False, is_symbol=True): return [name for name,addr in vrom_variables if addr == symbol][0] # addends - if is_symbol and symbol in vars_cache.keys(): - return vars_cache[symbol] + if is_symbol: + symbol_index = bisect.bisect(variable_addrs, symbol) + if symbol_index: + vram_addr = variable_addrs[symbol_index-1] + symbol_name, _, _, symbol_size = variables_ast[vram_addr] + + if vram_addr < symbol < vram_addr + symbol_size: + return f"{symbol_name} + 0x{symbol-vram_addr:X}" + # generated names if symbol in functions and not in_data: @@ -142,7 +150,7 @@ def proper_name(symbol, in_data=False, is_symbol=True): def lookup_name(symbol, word): # hacks for vrom variables in data - if word in [addr for _,addr in vrom_variables]: + if word in vrom_addrs: if word == 0: # no makerom segment start return "0x00000000" if symbol in [0x801AE4A0, # effect table @@ -1112,13 +1120,8 @@ with open("tools/disasm/functions.txt", "r") as infile: with open("tools/disasm/variables.txt", "r") as infile: variables_ast = ast.literal_eval(infile.read()) -# Precompute variable addends for all variables, this uses a lot of memory but the lookups later are fast +# Find floats, doubles, and strings for var in sorted(variables_ast.keys()): - for i in range(var, var + variables_ast[var][3], 1): - addend = i - var - assert addend >= 0 - vars_cache.update({i : f"{variables_ast[var][0]}" + (f" + 0x{addend:X}" if addend > 0 else "")}) - # also add to floats, doubles & strings var_type = variables_ast[var][1] if var_type == "f64": @@ -1164,6 +1167,9 @@ for segment in files_spec: if segment[3][-1][1] not in variables_ast: variables_ast.update({segment[3][-1][1] : (f"_{segment[0]}SegmentEnd","u8","[]",0x1)}) +# Construct variable_addrs, now that variable_addrs is fully constructed +variable_addrs = sorted(variables_ast.keys()) + pool = Pool(jobs) # Find symbols for each segment for segment in files_spec: @@ -1219,6 +1225,9 @@ for segment in files_spec: i += 1 dmadata_entry = dmadata[i*0x10:(i+1)*0x10] +# Construct vrom_addrs, now that vrom_variables is fully constructed +vrom_addrs = {addr for _, addr in vrom_variables} + def disassemble_makerom(segment): os.makedirs(f"{ASM_OUT}/makerom/", exist_ok=True) rom_header = segment[3][0][4] diff --git a/tools/disasm/files.txt b/tools/disasm/files.txt index 8dc09cca4a..86f3f7f74f 100644 --- a/tools/disasm/files.txt +++ b/tools/disasm/files.txt @@ -366,7 +366,6 @@ 0x800BFB80 : "z_bgcheck", 0x800CAAD0 : "z_bg_collect", 0x800CAE10 : "z_bg_item", - 0x800CB000 : "code_800CB000", 0x800CB210 : "z_camera", 0x800E03A0 : "z_collision_btltbls", 0x800E0400 : "[PADDING]", @@ -485,6 +484,7 @@ 0x8018EB60 : "audio_load", 0x80192BE0 : "code_80192BE0", 0x80194710 : "code_80194710", + 0x80194790 : "code_80194790", 0x80194930 : "audio_playback", 0x80196A00 : "audio_effects", 0x801974D0 : "audio_seqplayer", @@ -492,16 +492,18 @@ 0x8019AEB0 : "[PADDING]", 0x8019AEC0 : "code_8019AEC0", 0x8019AF00 : "code_8019AF00", + 0x801A4EB0 : "code_801A4EB0", 0x801A51F0 : "code_801A51F0", 0x801A5BC0 : "[PADDING]", 0x801A5BD0 : "code_801A5BD0", 0x801A7B10 : "code_801A7B10", - 0x801AA020 : "code_801AA020", + 0x801A9B10 : "jpegutils", + 0x801AA020 : "jpegdecoder", 0x801AA610 : "z_game_over", 0x801AAAA0 : "z_construct", # .data section - 0x801AAAB0 : "z_en_a_keep", + 0x801AAAB0 : "rsp", 0x801ADE60 : "", 0x801ADEC0 : "z_en_item00", 0x801AE240 : "z_eff_blure", @@ -528,6 +530,7 @@ 0x801BD910 : "", 0x801BDA70 : "z_horse", 0x801BDAC0 : "z_jpeg", + 0x801BDB00 : "z_kaleido_setup", 0x801BDB30 : "z_kanfont", 0x801BDB90 : "z_kankyo", 0x801BE960 : "z_lib", @@ -574,11 +577,20 @@ 0x801D15D0 : "sys_math_atan", 0x801D1DE0 : "sys_matrix", 0x801D1E70 : "", - 0x801D2E80 : "", # audio_heap? - 0x801D3D90 : "", - 0x801D55B0 : "", + 0x801D2E80 : "audio_data", + 0x801D5FB0 : "audio_synthesis", + 0x801D5FE0 : "audio_load", + 0x801D5FF0 : "code_80192BE0", + 0x801D6010 : "code_80194790", + 0x801D6190 : "audio_effects", + 0x801D61A0 : "audio_seqplayer", + 0x801D6200 : "audio_dramStack", + 0x801D6600 : "code_8019AF00", + 0x801D8BE0 : "code_801A4EB0", 0x801D8E50 : "code_801A51F0", - 0x801D9090 : "", + 0x801D9090 : "audio_sound_params", + 0x801DB470 : "code_801A5BD0", + 0x801DB4C0 : "code_801A7B10", # .rodata section 0x801DBDF0 : "z_en_item00", @@ -592,7 +604,7 @@ 0x801DC9D0 : "z_actor", 0x801DCBB0 : "z_actor_dlftbls", 0x801DCC00 : "z_bgcheck", - 0x801DCDB0 : "code_800CB000", + 0x801DCDB0 : "z_bg_item", 0x801DCDC0 : "z_camera", 0x801DD5C0 : "z_collision_check", 0x801DD600 : "z_debug_mode", @@ -659,9 +671,9 @@ 0x801E0EC0 : "code_801A51F0", 0x801E1050 : "code_801A5BD0", 0x801E1070 : "code_801A7B10", - 0x801E1100 : "code_801AA020", + 0x801E1100 : "audio_init_params", 0x801E1110 : "z_game_over", - 0x801E1180 : "", + 0x801E1180 : "rsp", # .bss section 0x801E3FA0 : "code_801E3FA0", @@ -715,9 +727,9 @@ 0x801FD140 : "audio_load", 0x801FD1F0 : "code_8019AF00", 0x801FD5A0 : "code_801A51F0", - 0x801FE7C0 : "code_801A5BD0", + 0x801FD710 : "code_801A5BD0", 0x801FFD00 : "code_801A7B10", - 0x80208E90 : "code_801AA020", + 0x80208E90 : "jpegdecoder", 0x80208EA0 : "gfxbuffers", 0x8024A4C0 : "buffers", }, diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 2c54d0f6b6..84a1d22859 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -899,162 +899,162 @@ 0x800BFA78:("ActorOverlayTable_FaultAddrConv",), 0x800BFAE8:("ActorOverlayTable_Init",), 0x800BFB40:("ActorOverlayTable_Cleanup",), - 0x800BFB80:("BgCheck_PolygonLinkedListNodeInit",), - 0x800BFB9C:("BgCheck_PolygonLinkedListResetHead",), - 0x800BFBAC:("BgCheck_ScenePolygonListsNodeInsert",), - 0x800BFC04:("BgCheck_PolygonLinkedListNodeInsert",), - 0x800BFC5C:("BgCheck_PolygonLinkedListInit",), - 0x800BFC70:("BgCheck_PolygonLinkedListAlloc",), - 0x800BFCC0:("BgCheck_PolygonLinkedListReset",), - 0x800BFCCC:("BgCheck_AllocPolygonLinkedListNode",), - 0x800BFCFC:("BgCheck_CreateVec3fFromVertex",), - 0x800BFD40:("BgCheck_CreateVertexFromVec3f",), + 0x800BFB80:("SSNode_SetValue",), + 0x800BFB9C:("SSList_SetNull",), + 0x800BFBAC:("SSNodeList_SetSSListHead",), + 0x800BFC04:("DynaSSNodeList_SetSSListHead",), + 0x800BFC5C:("DynaSSNodeList_Init",), + 0x800BFC70:("DynaSSNodeList_Alloc",), + 0x800BFCC0:("DynaSSNodeList_ResetCount",), + 0x800BFCCC:("DynaSSNodeList_GetNextNodeIdx",), + 0x800BFCFC:("BgCheck_Vec3sToVec3f",), + 0x800BFD40:("BgCheck_Vec3fToVec3s",), 0x800BFD84:("func_800BFD84",), 0x800BFDEC:("func_800BFDEC",), - 0x800BFFC4:("BgCheck_PolygonGetMinY",), - 0x800C003C:("BgCheck_PolygonGetNormal",), + 0x800BFFC4:("CollisionPoly_GetMinY",), + 0x800C003C:("CollisionPoly_GetNormalF",), 0x800C0094:("func_800C0094",), - 0x800C01B8:("func_800C01B8",), - 0x800C0220:("BgCheck_CreateTriNormFromPolygon",), - 0x800C02C0:("func_800C02C0",), - 0x800C0340:("func_800C0340",), - 0x800C0474:("func_800C0474",), - 0x800C0668:("func_800C0668",), - 0x800C06A8:("func_800C06A8",), - 0x800C074C:("func_800C074C",), - 0x800C07F0:("func_800C07F0",), - 0x800C0AF0:("BgCheck_PolygonCollidesWithSphere",), - 0x800C0BC0:("BgCheck_ScenePolygonListsInsertSorted",), - 0x800C0DE0:("BgCheck_ScenePolygonListsInsert",), - 0x800C0E74:("func_800C0E74",), - 0x800C10FC:("func_800C10FC",), - 0x800C1238:("func_800C1238",), - 0x800C12A4:("func_800C12A4",), - 0x800C1B68:("func_800C1B68",), - 0x800C1D7C:("func_800C1D7C",), - 0x800C2008:("func_800C2008",), - 0x800C20F4:("func_800C20F4",), - 0x800C2310:("func_800C2310",), - 0x800C2460:("func_800C2460",), - 0x800C2514:("func_800C2514",), - 0x800C25E0:("func_800C25E0",), - 0x800C26C0:("BgCheck_GetPolyMinSubdivisions",), - 0x800C2864:("BgCheck_GetPolyMaxSubdivisions",), - 0x800C2A30:("BgCheck_GetPolyMinMaxSubdivisions",), - 0x800C2BE0:("func_800C2BE0",), - 0x800C3334:("BgCheck_SplitScenePolygonsIntoSubdivisions",), - 0x800C3734:("BgCheck_GetIsDefaultSpecialScene",), - 0x800C3778:("BgCheck_GetSpecialSceneMaxMemory",), - 0x800C37BC:("BgCheck_CalcSubdivisionSize",), + 0x800C01B8:("CollisionPoly_GetPointDistanceFromPlane",), + 0x800C0220:("CollisionPoly_GetVertices",), + 0x800C02C0:("CollisionPoly_GetVerticesByBgId",), + 0x800C0340:("CollisionPoly_CheckYIntersectApprox1",), + 0x800C0474:("CollisionPoly_CheckYIntersect",), + 0x800C0668:("CollisionPoly_CheckYIntersectApprox2",), + 0x800C06A8:("CollisionPoly_CheckXIntersectApprox",), + 0x800C074C:("CollisionPoly_CheckZIntersectApprox",), + 0x800C07F0:("CollisionPoly_LineVsPoly",), + 0x800C0AF0:("CollisionPoly_SphVsPoly",), + 0x800C0BC0:("StaticLookup_AddPolyToSSList",), + 0x800C0DE0:("StaticLookup_AddPoly",), + 0x800C0E74:("BgCheck_RaycastFloorStaticList",), + 0x800C10FC:("BgCheck_RaycastFloorStatic",), + 0x800C1238:("BgCheck_ComputeWallDisplacement",), + 0x800C12A4:("BgCheck_SphVsStaticWall",), + 0x800C1B68:("BgCheck_CheckStaticCeiling",), + 0x800C1D7C:("BgCheck_CheckLineAgainstSSList",), + 0x800C2008:("BgCheck_CheckLineInSubdivision",), + 0x800C20F4:("BgCheck_SphVsFirstStaticPolyList",), + 0x800C2310:("BgCheck_SphVsFirstStaticPoly",), + 0x800C2460:("BgCheck_GetNearestStaticLookup",), + 0x800C2514:("BgCheck_GetStaticLookup",), + 0x800C25E0:("BgCheck_GetStaticLookupIndicesFromPos",), + 0x800C26C0:("BgCheck_GetSubdivisionMinBounds",), + 0x800C2864:("BgCheck_GetSubdivisionMaxBounds",), + 0x800C2A30:("BgCheck_GetPolySubdivisionBounds",), + 0x800C2BE0:("BgCheck_PolyIntersectsSubdivision",), + 0x800C3334:("BgCheck_InitStaticLookup",), + 0x800C3734:("BgCheck_IsSmallMemScene",), + 0x800C3778:("BgCheck_TryGetCustomMemsize",), + 0x800C37BC:("BgCheck_SetSubdivisionDimension",), 0x800C3844:("BgCheck_GetSpecialSceneMaxObjects",), - 0x800C389C:("BgCheck_Init",), - 0x800C3C00:("func_800C3C00",), - 0x800C3C14:("func_800C3C14",), - 0x800C3C2C:("BgCheck_GetActorMeshHeader",), - 0x800C3C94:("func_800C3C94",), - 0x800C3D50:("func_800C3D50",), - 0x800C3F40:("func_800C3F40",), - 0x800C3FA0:("func_800C3FA0",), - 0x800C4000:("func_800C4000",), - 0x800C4058:("func_800C4058",), - 0x800C40B4:("func_800C40B4",), - 0x800C411C:("func_800C411C",), - 0x800C4188:("func_800C4188",), - 0x800C41E4:("func_800C41E4",), - 0x800C4240:("func_800C4240",), - 0x800C42A8:("func_800C42A8",), - 0x800C4314:("func_800C4314",), - 0x800C43CC:("func_800C43CC",), - 0x800C4488:("func_800C4488",), - 0x800C44F0:("func_800C44F0",), - 0x800C455C:("func_800C455C",), - 0x800C45C4:("func_800C45C4",), - 0x800C4C74:("func_800C4C74",), - 0x800C4CD8:("func_800C4CD8",), - 0x800C4D3C:("func_800C4D3C",), - 0x800C4DA4:("func_800C4DA4",), - 0x800C4E10:("func_800C4E10",), - 0x800C4F38:("func_800C4F38",), - 0x800C4F84:("func_800C4F84",), - 0x800C4FD4:("func_800C4FD4",), - 0x800C5464:("func_800C5464",), - 0x800C54AC:("func_800C54AC",), - 0x800C5538:("func_800C5538",), - 0x800C55C4:("func_800C55C4",), - 0x800C5650:("func_800C5650",), - 0x800C56E0:("func_800C56E0",), - 0x800C576C:("func_800C576C",), - 0x800C57F8:("func_800C57F8",), - 0x800C583C:("func_800C583C",), - 0x800C58C8:("func_800C58C8",), - 0x800C5954:("func_800C5954",), - 0x800C5A20:("func_800C5A20",), - 0x800C5A64:("func_800C5A64",), - 0x800C5AAC:("BgCheck_ScenePolygonListsInit",), - 0x800C5AC4:("BgCheck_ScenePolygonListsAlloc",), - 0x800C5B80:("func_800C5B80",), - 0x800C5BBC:("BgCheck_ScenePolygonListsReserveNode",), - 0x800C5BD0:("BgCheck_ActorMeshParamsInit",), - 0x800C5C0C:("BgCheck_SetActorMeshParams",), - 0x800C5C5C:("BgCheck_AreActorMeshParamsEqual",), - 0x800C5D30:("BgCheck_ActorMeshPolyListsHeadsInit",), - 0x800C5D70:("BgCheck_ActorMeshPolyListsInit",), - 0x800C5D90:("BgCheck_ActorMeshVerticesIndexInit",), - 0x800C5D9C:("BgCheck_ActorMeshWaterboxesIndexInit",), - 0x800C5DA8:("BgCheck_ActorMeshInit",), - 0x800C5E10:("BgCheck_ActorMeshInitFromActor",), - 0x800C5EC8:("BgCheck_HasActorMeshChanged",), - 0x800C5EF0:("BgCheck_PolygonsInit",), - 0x800C5EFC:("BgCheck_PolygonsAlloc",), - 0x800C5F38:("BgCheck_VerticesInit",), - 0x800C5F44:("BgCheck_VerticesListAlloc",), - 0x800C5F8C:("BgCheck_WaterboxListInit",), - 0x800C5F9C:("BgCheck_WaterboxListAlloc",), - 0x800C5FD8:("BgCheck_ActorMeshUpdateParams",), - 0x800C6024:("BgCheck_IsActorMeshIndexValid",), - 0x800C6044:("BgCheck_DynaInit",), - 0x800C6098:("BgCheck_DynaAlloc",), - 0x800C6188:("BgCheck_AddActorMesh",), - 0x800C6248:("BgCheck_GetActorOfMesh",), + 0x800C389C:("BgCheck_Allocate",), + 0x800C3C00:("BgCheck_SetContextFlags",), + 0x800C3C14:("BgCheck_UnsetContextFlags",), + 0x800C3C2C:("BgCheck_GetCollisionHeader",), + 0x800C3C94:("BgCheck_PosInStaticBoundingBox",), + 0x800C3D50:("BgCheck_RaycastFloorImpl",), + 0x800C3F40:("BgCheck_CameraRaycastFloor1",), + 0x800C3FA0:("BgCheck_EntityRaycastFloor1",), + 0x800C4000:("BgCheck_EntityRaycastFloor2",), + 0x800C4058:("BgCheck_EntityRaycastFloor2_1",), + 0x800C40B4:("BgCheck_EntityRaycastFloor3",), + 0x800C411C:("BgCheck_EntityRaycastFloor5",), + 0x800C4188:("BgCheck_EntityRaycastFloor5_2",), + 0x800C41E4:("BgCheck_EntityRaycastFloor5_3",), + 0x800C4240:("BgCheck_EntityRaycastFloor6",), + 0x800C42A8:("BgCheck_EntityRaycastFloor7",), + 0x800C4314:("BgCheck_AnyRaycastFloor1",), + 0x800C43CC:("BgCheck_AnyRaycastFloor2",), + 0x800C4488:("BgCheck_CameraRaycastFloor2",), + 0x800C44F0:("BgCheck_EntityRaycastFloor8",), + 0x800C455C:("BgCheck_EntityRaycastFloor9",), + 0x800C45C4:("BgCheck_CheckWallImpl",), + 0x800C4C74:("BgCheck_EntitySphVsWall1",), + 0x800C4CD8:("BgCheck_EntitySphVsWall2",), + 0x800C4D3C:("BgCheck_EntitySphVsWall3",), + 0x800C4DA4:("BgCheck_EntitySphVsWall4",), + 0x800C4E10:("BgCheck_CheckCeilingImpl",), + 0x800C4F38:("BgCheck_AnyCheckCeiling",), + 0x800C4F84:("BgCheck_EntityCheckCeiling",), + 0x800C4FD4:("BgCheck_CheckLineImpl",), + 0x800C5464:("BgCheck_GetBccFlags",), + 0x800C54AC:("BgCheck_CameraLineTest1",), + 0x800C5538:("BgCheck_CameraLineTest2",), + 0x800C55C4:("BgCheck_EntityLineTest1",), + 0x800C5650:("BgCheck_EntityLineTest2",), + 0x800C56E0:("BgCheck_EntityLineTest3",), + 0x800C576C:("BgCheck_ProjectileLineTest",), + 0x800C57F8:("BgCheck_AnyLineTest1",), + 0x800C583C:("BgCheck_AnyLineTest2",), + 0x800C58C8:("BgCheck_AnyLineTest3",), + 0x800C5954:("BgCheck_SphVsFirstPolyImpl",), + 0x800C5A20:("BgCheck_SphVsFirstPoly",), + 0x800C5A64:("BgCheck_SphVsFirstWall",), + 0x800C5AAC:("SSNodeList_Init",), + 0x800C5AC4:("SSNodeList_Alloc",), + 0x800C5B80:("SSNodeList_GetNextNode",), + 0x800C5BBC:("SSNodeList_GetNextNodeIdx",), + 0x800C5BD0:("ScaleRotPos_Init",), + 0x800C5C0C:("ScaleRotPos_SetValue",), + 0x800C5C5C:("ScaleRotPos_Equals",), + 0x800C5D30:("DynaLookup_ResetLists",), + 0x800C5D70:("DynaLookup_Reset",), + 0x800C5D90:("DynaLookup_ResetVtxStartIndex",), + 0x800C5D9C:("DynaLookup_ResetWaterBoxStartIndex",), + 0x800C5DA8:("BgActor_Init",), + 0x800C5E10:("BgActor_SetActor",), + 0x800C5EC8:("BgActor_IsTransformUnchanged",), + 0x800C5EF0:("DynaPoly_NullPolyList",), + 0x800C5EFC:("DynaPoly_AllocPolyList",), + 0x800C5F38:("DynaPoly_NullVtxList",), + 0x800C5F44:("DynaPoly_AllocVtxList",), + 0x800C5F8C:("DynaPoly_InitWaterBoxList",), + 0x800C5F9C:("DynaPoly_AllocWaterBoxList",), + 0x800C5FD8:("DynaPoly_SetBgActorPrevTransform",), + 0x800C6024:("DynaPoly_IsBgIdBgActor",), + 0x800C6044:("DynaPoly_Init",), + 0x800C6098:("DynaPoly_Alloc",), + 0x800C6188:("DynaPoly_SetBgActor",), + 0x800C6248:("DynaPoly_GetActor",), 0x800C62BC:("func_800C62BC",), 0x800C6314:("func_800C6314",), 0x800C636C:("func_800C636C",), 0x800C63C4:("func_800C63C4",), 0x800C641C:("func_800C641C",), 0x800C6474:("func_800C6474",), - 0x800C64CC:("BgCheck_RemoveActorMesh",), + 0x800C64CC:("DynaPoly_DeleteBgActor",), 0x800C6554:("func_800C6554",), 0x800C656C:("BgCheck_CalcWaterboxDimensions",), - 0x800C6838:("BgCheck_AddActorMeshToLists",), + 0x800C6838:("DynaPoly_ExpandSRT",), 0x800C734C:("BgCheck_ResetFlagsIfLoadedActor",), - 0x800C73E4:("BgCheck_Update",), + 0x800C73E4:("DynaPoly_Setup",), 0x800C756C:("func_800C756C",), - 0x800C765C:("BgCheck_UpdateAllActorMeshes",), - 0x800C76EC:("func_800C76EC",), - 0x800C7974:("func_800C7974",), - 0x800C7E40:("func_800C7E40",), - 0x800C8580:("func_800C8580",), - 0x800C87D0:("func_800C87D0",), - 0x800C8A60:("func_800C8A60",), - 0x800C8BD0:("func_800C8BD0",), - 0x800C8DC0:("func_800C8DC0",), - 0x800C8EEC:("func_800C8EEC",), - 0x800C90AC:("func_800C90AC",), - 0x800C921C:("func_800C921C",), - 0x800C9380:("func_800C9380",), - 0x800C94E0:("BgCheck_RelocateMeshHeaderPointers",), - 0x800C9564:("BgCheck_RelocateMeshHeader",), - 0x800C9598:("BgCheck_RelocateAllMeshHeaders",), - 0x800C9640:("func_800C9640",), - 0x800C9694:("BgCheck_GetPolygonAttributes",), - 0x800C9704:("func_800C9704",), + 0x800C765C:("DynaPoly_UpdateBgActorTransforms",), + 0x800C76EC:("BgCheck_RaycastFloorDynaList",), + 0x800C7974:("BgCheck_RaycastFloorDyna",), + 0x800C7E40:("BgCheck_SphVsDynaWallInBgActor",), + 0x800C8580:("BgCheck_SphVsDynaWall",), + 0x800C87D0:("BgCheck_CheckDynaCeilingList",), + 0x800C8A60:("BgCheck_CheckDynaCeiling",), + 0x800C8BD0:("BgCheck_CheckLineAgainstBgActorSSList",), + 0x800C8DC0:("BgCheck_CheckLineAgainstBgActor",), + 0x800C8EEC:("BgCheck_CheckLineAgainstDyna",), + 0x800C90AC:("BgCheck_SphVsFirstDynaPolyList",), + 0x800C921C:("BgCheck_SphVsFirstDynaPolyInBgActor",), + 0x800C9380:("BgCheck_SphVsFirstDynaPoly",), + 0x800C94E0:("CollisionHeader_SegmentedToVirtual",), + 0x800C9564:("CollisionHeader_GetVirtual",), + 0x800C9598:("BgCheck_InitCollisionHeaders",), + 0x800C9640:("BgCheck_ResetPolyCheckTbl",), + 0x800C9694:("SurfaceType_GetData",), + 0x800C9704:("SurfaceType_GetCamDataIndex",), 0x800C9728:("func_800C9728",), - 0x800C9770:("func_800C9770",), + 0x800C9770:("SurfaceType_GetCameraSetting",), 0x800C97F8:("func_800C97F8",), 0x800C9844:("func_800C9844",), 0x800C98CC:("func_800C98CC",), - 0x800C9924:("func_800C9924",), - 0x800C99AC:("func_800C99AC",), + 0x800C9924:("SurfaceType_GetCamPosData",), + 0x800C99AC:("SurfaceType_GetSceneExitIndex",), 0x800C99D4:("func_800C99D4",), 0x800C99FC:("func_800C99FC",), 0x800C9A24:("func_800C9A24",), @@ -1065,30 +1065,30 @@ 0x800C9B18:("func_800C9B18",), 0x800C9B40:("func_800C9B40",), 0x800C9B68:("func_800C9B68",), - 0x800C9B90:("func_800C9B90",), + 0x800C9B90:("SurfaceType_IsHorseBlocked",), 0x800C9BB8:("func_800C9BB8",), - 0x800C9BDC:("func_800C9BDC",), + 0x800C9BDC:("SurfaceType_GetSfx",), 0x800C9C24:("func_800C9C24",), - 0x800C9C74:("func_800C9C74",), - 0x800C9C9C:("func_800C9C9C",), - 0x800C9CC4:("func_800C9CC4",), - 0x800C9CEC:("func_800C9CEC",), - 0x800C9D14:("func_800C9D14",), - 0x800C9D50:("func_800C9D50",), - 0x800C9D8C:("func_800C9D8C",), + 0x800C9C74:("SurfaceType_GetSlope",), + 0x800C9C9C:("SurfaceType_GetLightSettingIndex",), + 0x800C9CC4:("SurfaceType_GetEcho",), + 0x800C9CEC:("SurfaceType_IsHookshotSurface",), + 0x800C9D14:("SurfaceType_IsIgnoredByEntities",), + 0x800C9D50:("SurfaceType_IsIgnoredByProjectiles",), + 0x800C9D8C:("SurfaceType_IsConveyor",), 0x800C9DDC:("func_800C9DDC",), - 0x800C9E18:("func_800C9E18",), - 0x800C9E40:("func_800C9E40",), - 0x800C9E88:("func_800C9E88",), - 0x800C9EBC:("func_800C9EBC",), - 0x800CA1AC:("func_800CA1AC",), - 0x800CA1E8:("func_800CA1E8",), - 0x800CA22C:("func_800CA22C",), + 0x800C9E18:("SurfaceType_GetConveyorSpeed",), + 0x800C9E40:("SurfaceType_GetConveyorDirection",), + 0x800C9E88:("SurfaceType_IsWallDamage",), + 0x800C9EBC:("WaterBox_GetSurfaceImpl",), + 0x800CA1AC:("WaterBox_GetSurface1",), + 0x800CA1E8:("WaterBox_GetSurface1_2",), + 0x800CA22C:("WaterBox_GetSurface2",), 0x800CA568:("func_800CA568",), - 0x800CA634:("func_800CA634",), - 0x800CA648:("func_800CA648",), + 0x800CA634:("WaterBox_GetCamDataIndex",), + 0x800CA648:("WaterBox_GetCameraSetting",), 0x800CA6B8:("func_800CA6B8",), - 0x800CA6D8:("func_800CA6D8",), + 0x800CA6D8:("WaterBox_GetLightSettingIndex",), 0x800CA6F0:("func_800CA6F0",), 0x800CA9D0:("func_800CA9D0",), 0x800CAA14:("func_800CAA14",), @@ -1096,22 +1096,22 @@ 0x800CAC0C:("BgCheck2_UpdateActorYRotation",), 0x800CACA0:("BgCheck2_AttachToMesh",), 0x800CAD2C:("BgCheck2_UpdateActorAttachedToMesh",), - 0x800CAE10:("BcCheck3_BgActorInit",), - 0x800CAE34:("BgCheck3_LoadMesh",), - 0x800CAE7C:("BgCheck3_ResetFlags",), - 0x800CAE88:("func_800CAE88",), - 0x800CAE9C:("func_800CAE9C",), - 0x800CAEB0:("func_800CAEB0",), - 0x800CAEE0:("func_800CAEE0",), - 0x800CAEF4:("func_800CAEF4",), - 0x800CAF24:("func_800CAF24",), - 0x800CAF38:("func_800CAF38",), - 0x800CAF4C:("func_800CAF4C",), - 0x800CAF70:("func_800CAF70",), - 0x800CAF94:("func_800CAF94",), - 0x800CAFB8:("func_800CAFB8",), - 0x800CAFDC:("func_800CAFDC",), - 0x800CB000:("func_800CB000",), + 0x800CAE10:("DynaPolyActor_Init",), + 0x800CAE34:("DynaPolyActor_LoadMesh",), + 0x800CAE7C:("DynaPolyActor_ResetState",), + 0x800CAE88:("DynaPolyActor_SetRidingFallingState",), + 0x800CAE9C:("DynaPolyActor_SetRidingMovingState",), + 0x800CAEB0:("DynaPolyActor_SetRidingMovingStateByIndex",), + 0x800CAEE0:("DynaPolyActor_SetRidingRotatingState",), + 0x800CAEF4:("DynaPolyActor_SetRidingRotatingStateByIndex",), + 0x800CAF24:("DynaPolyActor_SetSwitchPressedState",), + 0x800CAF38:("DynaPolyActor_SetHeavySwitchPressedState",), + 0x800CAF4C:("DynaPolyActor_IsInRidingFallingState",), + 0x800CAF70:("DynaPolyActor_IsInRidingMovingState",), + 0x800CAF94:("DynaPolyActor_IsInRidingRotatingState",), + 0x800CAFB8:("DynaPolyActor_IsInSwitchPressedState",), + 0x800CAFDC:("DynaPolyActor_IsInHeavySwitchPressedState",), + 0x800CB000:("DynaPolyActor_ValidateMove",), 0x800CB210:("Camera_fabsf",), 0x800CB240:("Camera_LengthVec3f",), 0x800CB270:("func_800CB270",), @@ -1615,7 +1615,7 @@ 0x800F048C:("func_800F048C",), 0x800F0568:("Audio_PlaySoundAtPosition",), 0x800F0590:("func_800F0590",), - 0x800F05C0:("func_800F05C0",), + 0x800F05C0:("ElfMessage_GetFirstCycleHint",), 0x800F07C0:("func_800F07C0",), 0x800F0888:("func_800F0888",), 0x800F0944:("func_800F0944",), @@ -1693,11 +1693,11 @@ 0x800F40A0:("func_800F40A0",), 0x800F415C:("func_800F415C",), 0x800F41E4:("func_800F41E4",), - 0x800F42A0:("func_800F42A0",), - 0x800F43BC:("func_800F43BC",), - 0x800F44F4:("func_800F44F4",), - 0x800F4540:("func_800F4540",), - 0x800F470C:("func_800F470C",), + 0x800F42A0:("Jpeg_ScheduleDecoderTask",), + 0x800F43BC:("Jpeg_CopyToZbuffer",), + 0x800F44F4:("Jpeg_GetUnalignedU16",), + 0x800F4540:("Jpeg_ParseMarkers",), + 0x800F470C:("Jpeg_Decode",), 0x800F4A10:("func_800F4A10",), 0x800F4C0C:("func_800F4C0C",), 0x800F4E20:("func_800F4E20",), @@ -2064,7 +2064,7 @@ 0x8010C0C0:("Nmi_Init",), 0x8010C164:("Nmi_SetPrenmiStart",), 0x8010C19C:("Nmi_GetPrenmiHasStarted",), - 0x8010C1B0:("func_8010C1B0",), + 0x8010C1B0:("MsgEvent_SendNullTask",), 0x8010C230:("OLib_Vec3fDist",), 0x8010C274:("OLib_Vec3fDistOutDiff",), 0x8010C2D0:("OLib_Vec3fDistXZ",), @@ -3256,7 +3256,7 @@ 0x80179594:("Rand_ZeroFloat",), 0x801795C0:("randPlusMinusPoint5Scaled",), 0x801795F0:("Math3D_Normalize",), - 0x80179678:("func_80179678",), + 0x80179678:("Math3D_PlaneVsLineSegClosestPoint",), 0x80179798:("func_80179798",), 0x80179A44:("func_80179A44",), 0x80179B34:("func_80179B34",), @@ -3278,46 +3278,46 @@ 0x8017A678:("Math3D_XZDistance",), 0x8017A6A8:("Math3D_LengthSquared",), 0x8017A6D4:("Math3D_Vec3fMagnitude",), - 0x8017A6F8:("Math3D_DistanceSquared",), + 0x8017A6F8:("Math3D_Vec3fDistSq",), 0x8017A720:("Math3D_Distance",), 0x8017A740:("Math3D_DistanceS",), 0x8017A7B8:("func_8017A7B8",), 0x8017A7F8:("func_8017A7F8",), 0x8017A838:("func_8017A838",), 0x8017A878:("Math3D_CrossProduct",), - 0x8017A8EC:("Math3D_NormalVector",), - 0x8017A954:("func_8017A954",), - 0x8017AA0C:("func_8017AA0C",), - 0x8017ABBC:("func_8017ABBC",), - 0x8017AD38:("func_8017AD38",), + 0x8017A8EC:("Math3D_SurfaceNorm",), + 0x8017A954:("Math3D_PointRelativeToCubeFaces",), + 0x8017AA0C:("Math3D_PointRelativeToCubeEdges",), + 0x8017ABBC:("Math3D_PointRelativeToCubeVertices",), + 0x8017AD38:("Math3D_LineVsCube",), 0x8017B68C:("func_8017B68C",), 0x8017B7F8:("func_8017B7F8",), 0x8017B884:("Math3D_UnitNormalVector",), 0x8017B998:("Math3D_SignedDistanceFromPlane",), 0x8017B9D8:("func_8017B9D8",), - 0x8017BA14:("Math3D_NormalizedDistanceFromPlane",), - 0x8017BA4C:("Math3D_NormalizedSignedDistanceFromPlane",), - 0x8017BAD0:("func_8017BAD0",), + 0x8017BA14:("Math3D_UDistPlaneToPos",), + 0x8017BA4C:("Math3D_DistPlaneToPos",), + 0x8017BAD0:("Math3D_TriChkPointParaYDist",), 0x8017BD98:("func_8017BD98",), 0x8017BDE0:("func_8017BDE0",), - 0x8017BE30:("func_8017BE30",), - 0x8017BEE0:("func_8017BEE0",), + 0x8017BE30:("Math3D_TriChkPointParaYIntersectDist",), + 0x8017BEE0:("Math3D_TriChkPointParaYIntersectInsideTri",), 0x8017BF8C:("func_8017BF8C",), - 0x8017C008:("func_8017C008",), + 0x8017C008:("Math3D_TriChkLineSegParaYIntersect",), 0x8017C17C:("func_8017C17C",), 0x8017C1F0:("func_8017C1F0",), - 0x8017C494:("func_8017C494",), - 0x8017C540:("func_8017C540",), + 0x8017C494:("Math3D_TriChkPointParaYIntersectInsideTri2",), + 0x8017C540:("Math3D_TriChkPointParaXDist",), 0x8017C808:("func_8017C808",), - 0x8017C850:("func_8017C850",), + 0x8017C850:("Math3D_TriChkPointParaXIntersect",), 0x8017C904:("func_8017C904",), - 0x8017C980:("func_8017C980",), + 0x8017C980:("Math3D_TriChkLineSegParaXIntersect",), 0x8017CB08:("func_8017CB08",), - 0x8017CB7C:("func_8017CB7C",), + 0x8017CB7C:("Math3D_TriChkLineSegParaZDist",), 0x8017CEA8:("func_8017CEA8",), - 0x8017CEF0:("func_8017CEF0",), + 0x8017CEF0:("Math3D_TriChkPointParaZIntersect",), 0x8017CFA4:("func_8017CFA4",), - 0x8017D020:("func_8017D020",), + 0x8017D020:("Math3D_TriChkLineSegParaZIntersect",), 0x8017D1AC:("func_8017D1AC",), 0x8017D220:("func_8017D220",), 0x8017D2FC:("func_8017D2FC",), @@ -3329,14 +3329,14 @@ 0x8017D814:("func_8017D814",), 0x8017D91C:("func_8017D91C",), 0x8017DA24:("func_8017DA24",), - 0x8017DB2C:("Math3D_ColSphereLineSeg",), + 0x8017DB2C:("Math3D_LineVsSph",), 0x8017DD34:("func_8017DD34",), 0x8017DE74:("Math3D_ColSphereTri",), 0x8017E294:("func_8017E294",), 0x8017E350:("func_8017E350",), 0x8017ED20:("Math3D_ColCylinderTri",), 0x8017F1A0:("func_8017F1A0",), - 0x8017F1C0:("Math3D_ColSphereSphere",), + 0x8017F1C0:("Math3D_SphVsSph",), 0x8017F1E0:("Math3D_ColSphereSphereIntersect",), 0x8017F200:("Math3D_ColSphereSphereIntersectAndDistance",), 0x8017F2CC:("Math3D_ColSphereCylinderDistance",), @@ -3344,9 +3344,9 @@ 0x8017F45C:("Math3D_ColCylinderCylinderAmount",), 0x8017F47C:("Math3D_ColCylinderCylinderAmountAndDistance",), 0x8017F64C:("Math3d_ColTriTri",), - 0x8017F9C0:("func_8017F9C0",), - 0x8017FA34:("func_8017FA34",), - 0x8017FAA8:("func_8017FAA8",), + 0x8017F9C0:("Math3D_XZInSphere",), + 0x8017FA34:("Math3D_XYInSphere",), + 0x8017FAA8:("Math3D_YZInSphere",), 0x8017FB1C:("func_8017FB1C",), 0x8017FD44:("func_8017FD44",), 0x8017FEB0:("Math_GetAtan2Tbl",), @@ -3951,7 +3951,7 @@ 0x801A2C44:("func_801A2C44",), 0x801A2C88:("func_801A2C88",), 0x801A2D54:("func_801A2D54",), - 0x801A2DE0:("func_801A2DE0",), + 0x801A2DE0:("Audio_IsSequencePlaying",), 0x801A2E54:("func_801A2E54",), 0x801A2ED8:("func_801A2ED8",), 0x801A2F88:("func_801A2F88",), @@ -4067,18 +4067,18 @@ 0x801A982C:("func_801A982C",), 0x801A99B8:("func_801A99B8",), 0x801A9A74:("func_801A9A74",), - 0x801A9B10:("func_801A9B10",), - 0x801A9B78:("func_801A9B78",), - 0x801A9BFC:("func_801A9BFC",), - 0x801A9C68:("func_801A9C68",), - 0x801A9D10:("func_801A9D10",), - 0x801A9DCC:("func_801A9DCC",), - 0x801A9EA4:("func_801A9EA4",), - 0x801A9F4C:("func_801A9F4C",), - 0x801AA020:("func_801AA020",), - 0x801AA248:("func_801AA248",), - 0x801AA3E4:("func_801AA3E4",), - 0x801AA520:("func_801AA520",), + 0x801A9B10:("JpegUtils_ProcessQuantizationTable",), + 0x801A9B78:("JpegUtils_ParseHuffmanCodesLengths",), + 0x801A9BFC:("JpegUtils_GetHuffmanCodes",), + 0x801A9C68:("JpegUtils_SetHuffmanTable",), + 0x801A9D10:("JpegUtils_ProcessHuffmanTableImpl",), + 0x801A9DCC:("JpegUtils_ProcessHuffmanTable",), + 0x801A9EA4:("JpegUtils_SetHuffmanTableOld",), + 0x801A9F4C:("JpegUtils_ProcessHuffmanTableImplOld",), + 0x801AA020:("JpegDecoder_Decode",), + 0x801AA248:("JpegDecoder_ProcessMcu",), + 0x801AA3E4:("JpegDecoder_ParseNextSymbol",), + 0x801AA520:("JpegDecoder_ReadBits",), 0x801AA610:("GameOver_Init",), 0x801AA624:("GameOver_FadeLights",), 0x801AA68C:("GameOver_Update",), @@ -6401,21 +6401,21 @@ 0x808D7928:("func_808D7928",), 0x808D7954:("ObjMure_Init",), 0x808D7A04:("ObjMure_Destroy",), - 0x808D7A14:("func_808D7A14",), - 0x808D7A40:("func_808D7A40",), - 0x808D7A68:("func_808D7A68",), - 0x808D7C64:("func_808D7C64",), - 0x808D7DC4:("func_808D7DC4",), - 0x808D7E14:("func_808D7E14",), - 0x808D7F0C:("func_808D7F0C",), - 0x808D7F2C:("func_808D7F2C",), - 0x808D7FFC:("func_808D7FFC",), - 0x808D8014:("func_808D8014",), - 0x808D8074:("func_808D8074",), - 0x808D814C:("func_808D814C",), - 0x808D82CC:("func_808D82CC",), - 0x808D84F4:("func_808D84F4",), - 0x808D8678:("func_808D8678",), + 0x808D7A14:("ObjMure_GetMaxChildSpawns",), + 0x808D7A40:("ObjMure_GetSpawnPos",), + 0x808D7A68:("ObjMure_SpawnActors0",), + 0x808D7C64:("ObjMure_SpawnActors1",), + 0x808D7DC4:("ObjMure_SpawnActors",), + 0x808D7E14:("ObjMure_KillActorsImpl",), + 0x808D7F0C:("ObjMure_KillActors",), + 0x808D7F2C:("ObjMure_CheckChildren",), + 0x808D7FFC:("ObjMure_InitialAction",), + 0x808D8014:("ObjMure_CulledState",), + 0x808D8074:("ObjMure_SetFollowTargets",), + 0x808D814C:("ObjMure_SetChildToFollowPlayer",), + 0x808D82CC:("ObjMure_GroupBehavior0",), + 0x808D84F4:("ObjMure_GroupBehavior1",), + 0x808D8678:("ObjMure_ActiveState",), 0x808D8720:("ObjMure_Update",), 0x808D8940:("func_808D8940",), 0x808D8B58:("func_808D8B58",), @@ -7888,9 +7888,9 @@ 0x80965650:("EnStream_SetupAction",), 0x8096565C:("EnStream_Init",), 0x809656C4:("EnStream_Destroy",), - 0x809656D4:("func_809656D4",), - 0x809657F4:("func_809657F4",), - 0x8096597C:("func_8096597C",), + 0x809656D4:("EnStream_PlayerIsInRange",), + 0x809657F4:("EnStream_SuckPlayer",), + 0x8096597C:("EnStream_WaitForPlayer",), 0x809659D0:("EnStream_Update",), 0x80965A04:("EnStream_Draw",), 0x80965BB0:("EnMm_SetupAction",), @@ -8016,37 +8016,37 @@ 0x8096F4DC:("BgF40Swlift_Draw",), 0x8096F5E0:("EnKakasi_Destroy",), 0x8096F60C:("EnKakasi_Init",), - 0x8096F800:("func_8096F800",), - 0x8096F88C:("func_8096F88C",), + 0x8096F800:("EnKakasi_SetAnimation",), + 0x8096F88C:("EnKakasi_8096F88C",), 0x8096F8D8:("func_8096F8D8",), 0x8096FA18:("func_8096FA18",), 0x8096FAAC:("func_8096FAAC",), 0x8096FBB8:("func_8096FBB8",), - 0x8096FC8C:("func_8096FC8C",), - 0x8096FCC4:("func_8096FCC4",), - 0x8096FDE8:("func_8096FDE8",), - 0x8096FE00:("func_8096FE00",), - 0x80970008:("func_80970008",), - 0x8097006C:("func_8097006C",), + 0x8096FC8C:("EnKakasi_InitTimeSkipDialogue",), + 0x8096FCC4:("EnKakasi_TimeSkipDialogue",), + 0x8096FDE8:("EnKakasi_SetupIdleStanding",), + 0x8096FE00:("EnKakasi_IdleStanding",), + 0x80970008:("EnKakasi_SetupDialogue",), + 0x8097006C:("EnKakasi_RegularDialogue",), 0x809705E4:("func_809705E4",), 0x80970658:("func_80970658",), 0x80970740:("func_80970740",), 0x80970978:("func_80970978",), - 0x80970A10:("func_80970A10",), - 0x80970A9C:("func_80970A9C",), - 0x80970F20:("func_80970F20",), - 0x80970FF8:("func_80970FF8",), - 0x80971064:("func_80971064",), - 0x80971430:("func_80971430",), + 0x80970A10:("EnKakasi_SetupPostSongLearnDialogue",), + 0x80970A9C:("EnKakasi_PostSongLearnDialogue",), + 0x80970F20:("EnKakasi_DancingRemark",), + 0x80970FF8:("EnKakasi_SetupDanceNightAway",), + 0x80971064:("EnKakasi_DancingNightAway",), + 0x80971430:("EnKakasi_DoNothing",), 0x80971440:("func_80971440",), 0x809714BC:("func_809714BC",), 0x80971794:("func_80971794",), 0x809717D0:("func_809717D0",), - 0x8097185C:("func_8097185C",), - 0x8097193C:("func_8097193C",), - 0x80971A38:("func_80971A38",), - 0x80971A64:("func_80971A64",), - 0x80971AD4:("func_80971AD4",), + 0x8097185C:("EnKakasi_SetupRiseOutOfGround",), + 0x8097193C:("EnKakasi_RisingOutOfGround",), + 0x80971A38:("EnKakasi_SetupIdleRisen",), + 0x80971A64:("EnKakasi_IdleRisen",), + 0x80971AD4:("EnKakasi_RisenDialogue",), 0x80971B48:("EnKakasi_Update",), 0x80971CE0:("func_80971CE0",), 0x80971D20:("EnKakasi_Draw",), @@ -11502,9 +11502,9 @@ 0x80AA2720:("func_80AA2720",), 0x80AA27EC:("func_80AA27EC",), 0x80AA2884:("DmStk_Update",), - 0x80AA2B14:("func_80AA2B14",), - 0x80AA2BC0:("func_80AA2BC0",), - 0x80AA33A4:("func_80AA33A4",), + 0x80AA2B14:("DmStk_OverrideLimbDraw",), + 0x80AA2BC0:("DmStk_PostLimbDraw2",), + 0x80AA33A4:("DmStk_PostLimbDraw",), 0x80AA33CC:("DmStk_Draw",), 0x80AA5580:("func_80AA5580",), 0x80AA561C:("func_80AA561C",), @@ -16068,7 +16068,7 @@ 0x80BE1E9C:("EnNimotsu_Draw",), 0x80BE2030:("EnHitTag_Init",), 0x80BE20BC:("EnHitTag_Destroy",), - 0x80BE20E8:("func_80BE20E8",), + 0x80BE20E8:("EnHitTag_WaitForHit",), 0x80BE21A0:("EnHitTag_Update",), 0x80BE2260:("func_80BE2260",), 0x80BE2330:("func_80BE2330",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index cdff64742b..870579debc 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -78,7 +78,7 @@ 0x80098060:("D_80098060","__OSViContext","[2]",0x60), 0x800980C0:("__osViCurr","__OSViContext*","",0x4), 0x800980C4:("__osViNext","__OSViContext*","",0x4), - 0x800980D0:("D_800980D0","UNK_TYPE4","",0x4), + 0x800980D0:("sCartRomNeedsInit","UNK_TYPE4","",0x4), 0x800980E0:("osViModeFpalLan1","OSViMode","",0x50), 0x80098130:("ldigs","u8","[]",0x14), 0x80098144:("udigs","u8","[]",0x14), @@ -367,7 +367,7 @@ 0x80186028:("D_80186028","s16","[1316]",0xa48), 0x801AAAB0:("D_801AAAB0","UNK_TYPE1","",0x1), 0x801ABAB0:("D_801ABAB0","UNK_TYPE1","",0x1), - 0x801AD370:("D_801AD370","UNK_TYPE1","",0x1), + 0x801AD370:("gJpegUCode","UNK_TYPE1","",0x1), 0x801ADE60:("En_A_Obj_InitVars","ActorInit","",0x20), 0x801ADE80:("enAObjCylinderInit","ColliderCylinderInit","",0x2c), 0x801ADEAC:("enAObjInitVar","ActorInitVar","",0x4), @@ -453,14 +453,8 @@ 0x801AEFC0:("D_801AEFC0","UNK_TYPE1","",0x1), 0x801AEFD0:("gActorOverlayTable","ActorOverlay","[ACTOR_ID_MAX]",0x5640), 0x801B4610:("gMaxActorId","s32","",0x4), - 0x801B4620:("D_801B4620","u32","[32]",0x80), - 0x801B46A0:("D_801B46A0","u16","[16]",0x20), - 0x801B46C0:("D_801B46C0","u8","[16]",0x10), - 0x801B46D0:("bgSpecialSceneParamsDefault","s16","[1]",0x2), - 0x801B46D2:("D_801B46D2","UNK_TYPE1","",0x1), - 0x801B46D4:("bgSpecialSceneMaxMemory","BgSpecialSceneMaxMemory","[1]",0x8), - 0x801B46DC:("bgSpecialSceneMeshSubdivisions","BgSpecialSceneMeshSubdivision","[3]",0x24), - 0x801B4700:("bgSpecialSceneMaxObjects","BgSpecialSceneMaxObjects","[1]",0x8), + 0x801B46DC:("sSceneSubdivisionList","BgCheckSceneSubdivisionEntry","[3]",0x24), + 0x801B4700:("sCustomDynapolyMem","BgSpecialSceneMaxObjects","[1]",0x8), 0x801B4708:("D_801B4708","UNK_TYPE1","",0x1), 0x801B4710:("D_801B4710","UNK_TYPE1","",0x1), 0x801B4738:("D_801B4738","UNK_TYPE1","",0x1), @@ -2274,11 +2268,9 @@ 0x801D4D90:("D_801D4D90","UNK_PTR","",0x4), 0x801D4D98:("D_801D4D98","UNK_PTR","",0x4), 0x801D4DB0:("D_801D4DB0","UNK_PTR","",0x4), - 0x801D4DB4:("D_801D4DB4","UNK_TYPE1","",0x1), - 0x801D4FB4:("D_801D4FB4","UNK_TYPE1","",0x1), - 0x801D51B4:("D_801D51B4","UNK_TYPE4","",0x4), - 0x801D53B4:("D_801D53B4","UNK_TYPE4","",0x4), - 0x801D55B4:("D_801D55B4","UNK_TYPE1","",0x1), + 0x801D4DB4:("D_801D4DB4","f32","[256]",0x400), + 0x801D51B4:("D_801D51B4","f32","[256]",0x400), + 0x801D55B4:("D_801D55B4","f32","[128]",0x200), 0x801D57B4:("D_801D57B4","UNK_TYPE1","",0x1), 0x801D57C4:("D_801D57C4","UNK_TYPE1","",0x1), 0x801D57D4:("D_801D57D4","UNK_TYPE1","",0x1), @@ -2287,12 +2279,11 @@ 0x801D5824:("D_801D5824","UNK_TYPE2","",0x2), 0x801D58A2:("D_801D58A2","UNK_TYPE2","",0x2), 0x801D58AA:("D_801D58AA","UNK_TYPE1","",0x1), - 0x801D5928:("D_801D5928","UNK_TYPE1","",0x1), - 0x801D5B24:("D_801D5B24","UNK_TYPE1","",0x1), - 0x801D5B28:("D_801D5B28","UNK_TYPE1","",0x1), - 0x801D5D24:("D_801D5D24","UNK_TYPE1","",0x1), - 0x801D5D28:("D_801D5D28","UNK_TYPE1","",0x1), - 0x801D5F24:("D_801D5F24","UNK_TYPE1","",0x1), + 0x801D5928:("D_801D5928","f32","[128]",0x200), + 0x801D5B28:("D_801D5B28","f32","[128]",0x200), + 0x801D5D28:("D_801D5D28","f32","[128]",0x200), + 0x801D5F28:("D_801D5F28","s16","[64]",0x80), + 0x801D5FB0:("D_801D5FB0","UNK_TYPE4","",0x4), 0x801D5FB4:("D_801D5FB4","UNK_TYPE4","",0x4), 0x801D5FB8:("D_801D5FB8","UNK_TYPE4","",0x4), 0x801D5FBC:("D_801D5FBC","UNK_TYPE4","",0x4), @@ -2311,11 +2302,11 @@ 0x801D6014:("D_801D6014","UNK_TYPE1","",0x1), 0x801D6028:("D_801D6028","UNK_TYPE1","",0x1), 0x801D6098:("D_801D6098","UNK_TYPE1","",0x1), - 0x801D6100:("D_801D6100","UNK_TYPE1","",0x1), 0x801D6188:("D_801D6188","UNK_PTR","",0x4), 0x801D618C:("D_801D618C","UNK_PTR","",0x4), 0x801D6190:("D_801D6190","f32","",0x4), 0x801D6194:("D_801D6194","UNK_TYPE4","",0x4), + 0x801D61A0:("D_801D61A0","u8","[96]",0x60), 0x801D6200:("D_801D6200","UNK_TYPE1","",0x1), 0x801D6600:("D_801D6600","UNK_TYPE1","",0x1), 0x801D6608:("D_801D6608","UNK_TYPE1","",0x1), @@ -2442,14 +2433,14 @@ 0x801D8E48:("D_801D8E48","UNK_TYPE1","",0x1), 0x801D8E50:("D_801D8E50","UNK_TYPE1","",0x1), 0x801D8F70:("D_801D8F70","UNK_TYPE1","",0x1), - 0x801D9090:("D_801D9090","UNK_TYPE1","",0x1), - 0x801D9C10:("D_801D9C10","UNK_TYPE1","",0x1), - 0x801DA350:("D_801DA350","UNK_TYPE1","",0x1), - 0x801DA510:("D_801DA510","UNK_TYPE1","",0x1), - 0x801DAC50:("D_801DAC50","UNK_TYPE1","",0x1), - 0x801DADD0:("D_801DADD0","UNK_TYPE1","",0x1), - 0x801DAE10:("D_801DAE10","UNK_TYPE1","",0x1), - 0x801DB450:("D_801DB450","UNK_PTR","",0x4), + 0x801D9090:("sEnemyBankParams","UNK_TYPE1","",0x1), + 0x801D9C10:("sPlayerBankParams","UNK_TYPE1","",0x1), + 0x801DA350:("sItemBankParams","UNK_TYPE1","",0x1), + 0x801DA510:("sEnvBankParams","UNK_TYPE1","",0x1), + 0x801DAC50:("sSystemBankParams","UNK_TYPE1","",0x1), + 0x801DADD0:("sOcarinaBankParams","UNK_TYPE1","",0x1), + 0x801DAE10:("sVoiceBankParams","UNK_TYPE1","",0x1), + 0x801DB450:("gSfxParams","UNK_PTR","",0x4), 0x801DB470:("D_801DB470","UNK_TYPE1","",0x1), 0x801DB474:("D_801DB474","UNK_TYPE1","",0x1), 0x801DB478:("D_801DB478","UNK_PTR","[7]",0x1c), @@ -2481,7 +2472,7 @@ 0x801DB8B8:("D_801DB8B8","UNK_TYPE1","",0x1), 0x801DB900:("D_801DB900","UNK_TYPE1","",0x1), 0x801DB930:("D_801DB930","UNK_PTR","",0x4), - 0x801DB958:("D_801DB958","s8018CFAC","[21]",0x498), + 0x801DB958:("D_801DB958","AudioSpec","[21]",0x498), 0x801DBDF0:("D_801DBDF0","f32","",0x4), 0x801DBDF4:("jtbl_801DBDF4","UNK_PTR","",0x4), 0x801DBE68:("D_801DBE68","f32","",0x4), @@ -3897,15 +3888,9 @@ 0x801E2160:("D_801E2160","UNK_TYPE1","",0x1), 0x801E3790:("D_801E3790","UNK_TYPE1","",0x1), 0x801E3BB0:("D_801E3BB0","UNK_TYPE1","",0x1), - 0x801E3F40:("D_801E3F40","UNK_TYPE1","",0x1), + 0x801E3F40:("gJpegUCodeData","UNK_TYPE1","",0x1), 0x801E3FA0:("D_801E3FA0","UNK_TYPE1","",0x1), - 0x801E3FB0:("sEffTable","EffTables","",0x98e0), - 0x801E4514:("D_801E4514","UNK_TYPE1","",0x1), - 0x801E4E08:("D_801E4E08","UNK_TYPE1","",0x1), - 0x801E531C:("D_801E531C","UNK_TYPE1","",0x1), - 0x801E69E0:("D_801E69E0","UNK_TYPE1","",0x1), - 0x801E9AA0:("D_801E9AA0","UNK_TYPE1","",0x1), - 0x801ED4C0:("D_801ED4C0","UNK_TYPE1","",0x1), + 0x801E3FB0:("sEffTable","EffTables","",0x98E0), 0x801ED890:("D_801ED890","UNK_TYPE1","",0x1), 0x801ED894:("D_801ED894","UNK_TYPE1","",0x1), 0x801ED8A0:("D_801ED8A0","UNK_TYPE1","",0x1), @@ -3927,34 +3912,17 @@ 0x801ED940:("D_801ED940","FaultAddrConvClient","",0xc), 0x801ED950:("D_801ED950","char","[80]",0x50), 0x801ED9A0:("D_801ED9A0","char","[80]",0x50), - 0x801ED9F0:("D_801ED9F0","Vec3f","",0xc), - 0x801ED9FC:("D_801ED9FC","Vec3f","",0xc), - 0x801EDA08:("D_801EDA08","Vec3f","",0xc), - 0x801EDA18:("D_801EDA18","Vec3f","",0xc), - 0x801EDA24:("D_801EDA24","Vec3f","",0xc), - 0x801EDA30:("D_801EDA30","Vec3f","",0xc), + 0x801ED9F0:("D_801ED9F0","Vec3f","[3]",0x24), + 0x801EDA18:("D_801EDA18","Vec3f","[3]",0x24), 0x801EDA40:("D_801EDA40","MtxF","",0x40), - 0x801EDA80:("D_801EDA80","Vec3f","",0xc), - 0x801EDA8C:("D_801EDA8C","Vec3f","",0xc), - 0x801EDA98:("D_801EDA98","Vec3f","",0xc), + 0x801EDA80:("D_801EDA80","Vec3f","[3]",0x24), 0x801EDAA8:("D_801EDAA8","char","[80]",0x50), 0x801EDAF8:("D_801EDAF8","char","[80]",0x50), - 0x801EDB48:("D_801EDB48","Vec3f","",0xc), - 0x801EDB54:("D_801EDB54","Vec3f","",0xc), - 0x801EDB60:("D_801EDB60","Vec3f","",0xc), - 0x801EDB70:("D_801EDB70","Vec3f","",0xc), - 0x801EDB7C:("D_801EDB7C","Vec3f","",0xc), - 0x801EDB88:("D_801EDB88","Vec3f","",0xc), - 0x801EDB98:("D_801EDB98","f32","",0x4), - 0x801EDB9C:("D_801EDB9C","f32","",0x4), - 0x801EDBA0:("D_801EDBA0","f32","",0x4), - 0x801EDBA4:("D_801EDBA4","UNK_TYPE1","",0x1), + 0x801EDB48:("D_801EDB48","Vec3f","[3]",0x24), + 0x801EDB70:("D_801EDB70","Vec3f","[3]",0x24), + 0x801EDB98:("D_801EDB98","Plane","",0x10), 0x801EDBA8:("D_801EDBA8","Sphere16","",0x8), 0x801EDBB0:("D_801EDBB0","TriNorm","",0x34), - 0x801EDBD4:("D_801EDBD4","UNK_TYPE1","",0x1), - 0x801EDBD8:("D_801EDBD8","UNK_TYPE1","",0x1), - 0x801EDBDC:("D_801EDBDC","UNK_TYPE1","",0x1), - 0x801EDBE0:("D_801EDBE0","UNK_TYPE1","",0x1), 0x801EDBF0:("D_801EDBF0","s16","",0x2), 0x801EDBF4:("D_801EDBF4","UNK_TYPE1","",0x1), 0x801EDBF8:("D_801EDBF8","UNK_TYPE1","",0x1), @@ -4434,7 +4402,7 @@ 0x801FE4C0:("D_801FE4C0","UNK_TYPE1","",0x1), 0x801FE640:("D_801FE640","UNK_TYPE1","",0x1), 0x801FE6D0:("D_801FE6D0","UNK_TYPE1","",0x1), - 0x801FE7C0:("D_801FE7C0","s801FE7C0","[1]",0x14), + 0x801FE7C0:("D_801FE7C0","SoundRequest","[1]",0x14), 0x801FFBC0:("D_801FFBC0","UNK_TYPE1","",0x1), 0x801FFBC8:("D_801FFBC8","UNK_TYPE1","",0x1), 0x801FFBD0:("D_801FFBD0","UNK_TYPE1","",0x1), @@ -4588,11 +4556,11 @@ 0x80208E6C:("D_80208E6C","UNK_TYPE4","",0x4), 0x80208E70:("D_80208E70","UNK_TYPE4","",0x4), 0x80208E74:("D_80208E74","UNK_TYPE4","",0x4), - 0x80208E90:("D_80208E90","UNK_TYPE1","",0x1), - 0x80208E94:("D_80208E94","UNK_TYPE1","",0x1), - 0x80208E98:("D_80208E98","UNK_TYPE1","",0x1), - 0x80208E99:("D_80208E99","UNK_TYPE1","",0x1), - 0x80208E9C:("D_80208E9C","UNK_TYPE1","",0x1), + 0x80208E90:("sJpegBitStreamPtr","UNK_TYPE1","",0x1), + 0x80208E94:("sJpegBitStreamByteIdx","UNK_TYPE1","",0x1), + 0x80208E98:("sJpegBitStreamBitIdx","UNK_TYPE1","",0x1), + 0x80208E99:("sJpegBitStreamDontSkip","UNK_TYPE1","",0x1), + 0x80208E9C:("sJpegBitStreamCurWord","UNK_TYPE1","",0x1), 0x80208EA0:("gGfxSPTaskYieldBuffer","u8","[OS_YIELD_DATA_SIZE]",0xC00), 0x80209AA0:("gGfxSPTaskStack","u8","[0x400]",0x400), 0x80209EA0:("gGfxPools","GfxPool","[2]",0x40620), @@ -7156,7 +7124,6 @@ 0x808D784C:("D_808D784C","f32","",0x4), 0x808D7850:("D_808D7850","f32","",0x4), 0x808D8760:("Obj_Mure_InitVars","UNK_TYPE1","",0x1), - 0x808D8780:("D_808D8780","UNK_TYPE1","",0x1), 0x808DB9C0:("En_Sw_InitVars","UNK_TYPE1","",0x1), 0x808DB9E0:("D_808DB9E0","UNK_TYPE1","",0x1), 0x808DBA0C:("D_808DBA0C","UNK_PTR","",0x4), @@ -7920,11 +7887,6 @@ 0x8090DC1C:("D_8090DC1C","f32","",0x4), 0x8090DC20:("D_8090DC20","f32","",0x4), 0x8090DC24:("D_8090DC24","f32","",0x4), - 0x8090DC30:("enFishingOverlayInfo","OverlayRelocationSection","",0x14), - 0x8090DC44:("enFishingOverlayRelocations","u32","[2393]",0x2564), - 0x809101AC:("enFishingOverlayInfoOffset","u32","",0x4), - 0x80910000:("D_80910000","UNK_TYPE1","",0x1), - 0x80910001:("D_80910001","UNK_TYPE1","",0x1), 0x809101B0:("D_809101B0","f32","",0x4), 0x809101B4:("D_809101B4","f32","",0x4), 0x809101B8:("D_809101B8","UNK_TYPE1","",0x1), @@ -10997,9 +10959,6 @@ 0x80A0C55C:("D_80A0C55C","f32","",0x4), 0x80A0C560:("D_80A0C560","f32","",0x4), 0x80A0C7C0:("En_Boj_05_InitVars","UNK_TYPE1","",0x1), - 0x80A0C7E0:("enBoj05OverlayInfo","OverlayRelocationSection","",0x14), - 0x80A0C7F4:("enBoj05OverlayRelocations","u32","[4]",0x10), - 0x80A0C80C:("enBoj05OverlayInfoOffset","u32","",0x4), 0x80A10860:("sAnimationsBombShopkeeper","UNK_PTR","",0x4), 0x80A10890:("En_Sob1_InitVars","UNK_TYPE1","",0x1), 0x80A108B0:("sObjectIds","UNK_TYPE2","",0x2), @@ -12659,9 +12618,6 @@ 0x80A8B440:("jtbl_D_80A8B440","UNK_PTR","",0x4), 0x80A8B478:("jtbl_D_80A8B478","UNK_PTR","",0x4), 0x80A8B48C:("jtbl_D_80A8B48C","UNK_PTR","",0x4), - 0x80A8B4A0:("enTruOverlayInfo","OverlayRelocationSection","",0x14), - 0x80A8B4B4:("enTruOverlayRelocations","u32","[174]",0x2b8), - 0x80A8B76C:("enTruOverlayInfoOffset","u32","",0x4), 0x80A8FE10:("sAnimations","UNK_TYPE1","",0x1), 0x80A8FEB0:("En_Trt_InitVars","UNK_TYPE1","",0x1), 0x80A8FED0:("sActorScale","UNK_TYPE4","",0x4), @@ -13143,9 +13099,6 @@ 0x80AC027C:("jtbl_80AC027C","UNK_PTR","",0x4), 0x80AC0300:("jtbl_80AC0300","UNK_PTR","",0x4), 0x80AC03E4:("jtbl_80AC03E4","UNK_PTR","",0x4), - 0x80AC0400:("enMa4OverlayInfo","OverlayRelocationSection","",0x14), - 0x80AC0414:("enMa4OverlayRelocations","u32","[262]",0x418), - 0x80AC082C:("enMa4OverlayInfoOffset","u32","",0x4), 0x80AC1090:("En_Twig_InitVars","UNK_TYPE1","",0x1), 0x80AC10B0:("D_80AC10B0","UNK_TYPE1","",0x1), 0x80AC10BC:("D_80AC10BC","UNK_TYPE2","",0x2), diff --git a/tools/m2ctx.py b/tools/m2ctx.py index a095c2811c..16087885b3 100755 --- a/tools/m2ctx.py +++ b/tools/m2ctx.py @@ -7,6 +7,46 @@ script_dir = os.path.dirname(os.path.realpath(__file__)) root_dir = script_dir + "/../" src_dir = root_dir + "src/" +# Read through the processes context and replace whatever +def custom_replacements(output): + output = output.splitlines() + + i = 0 + while i < len(output): + line = output[i] + + ############### actorLists[2].first -> Player* ############### + if "typedef struct ActorListEntry " in line: + actorListText = "" + i += 1 + while not output[i].startswith("}"): + actorListText += output[i] + i += 1 + actorCats = [ + "actorSwitch", + "bg", + "player", + "explosive", + "npc", + "enemy", + "prop", + "itemAction", + "misc", + "boss", + "door", + "chest", + ] + actorList = [] + for x in range(12): + actorList.append(actorListText.replace("first;", f"{actorCats[x]};") + "\n") + if x == 2: + actorList[x] = actorList[x].replace("Actor*", "Player*") + elif "ActorListEntry actorList[12];" in line: + output[i] = "struct {\n" + "".join(actorList) + "};" + ######################################################## + + i += 1 + return "\n".join(output) def get_c_dir(dirname): for root, dirs, files in os.walk(src_dir): @@ -42,6 +82,8 @@ def main(): description="Creates a ctx.c file for mips2c. " "Output will be saved as oot/ctx.c") parser.add_argument('filepath', help="path of c file to be processed") + parser.add_argument("--custom", "-c", dest="custom", action="store_true", default=False, + help="Apply custom replacements to the output to help aid m2c output") args = parser.parse_args() if args.filepath: @@ -59,6 +101,9 @@ def main(): output = import_c_file(c_file_path) + if args.custom: + output = custom_replacements(output) + with open(os.path.join(root_dir, "ctx.c"), "w", encoding="UTF-8") as f: f.write(output) diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 9737ede4dd..fba05738ec 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -610,22 +610,22 @@ asm/non_matchings/code/z_bg_collect/BgCheck2_UpdateActorPosition.s,BgCheck2_Upda asm/non_matchings/code/z_bg_collect/BgCheck2_UpdateActorYRotation.s,BgCheck2_UpdateActorYRotation,0x800CAC0C,0x25 asm/non_matchings/code/z_bg_collect/BgCheck2_AttachToMesh.s,BgCheck2_AttachToMesh,0x800CACA0,0x23 asm/non_matchings/code/z_bg_collect/BgCheck2_UpdateActorAttachedToMesh.s,BgCheck2_UpdateActorAttachedToMesh,0x800CAD2C,0x39 -asm/non_matchings/code/z_bg_item/BcCheck3_BgActorInit.s,BcCheck3_BgActorInit,0x800CAE10,0x9 -asm/non_matchings/code/z_bg_item/BgCheck3_LoadMesh.s,BgCheck3_LoadMesh,0x800CAE34,0x12 -asm/non_matchings/code/z_bg_item/BgCheck3_ResetFlags.s,BgCheck3_ResetFlags,0x800CAE7C,0x3 -asm/non_matchings/code/z_bg_item/func_800CAE88.s,func_800CAE88,0x800CAE88,0x5 -asm/non_matchings/code/z_bg_item/func_800CAE9C.s,func_800CAE9C,0x800CAE9C,0x5 -asm/non_matchings/code/z_bg_item/func_800CAEB0.s,func_800CAEB0,0x800CAEB0,0xC -asm/non_matchings/code/z_bg_item/func_800CAEE0.s,func_800CAEE0,0x800CAEE0,0x5 -asm/non_matchings/code/z_bg_item/func_800CAEF4.s,func_800CAEF4,0x800CAEF4,0xC -asm/non_matchings/code/z_bg_item/func_800CAF24.s,func_800CAF24,0x800CAF24,0x5 -asm/non_matchings/code/z_bg_item/func_800CAF38.s,func_800CAF38,0x800CAF38,0x5 -asm/non_matchings/code/z_bg_item/func_800CAF4C.s,func_800CAF4C,0x800CAF4C,0x9 -asm/non_matchings/code/z_bg_item/func_800CAF70.s,func_800CAF70,0x800CAF70,0x9 -asm/non_matchings/code/z_bg_item/func_800CAF94.s,func_800CAF94,0x800CAF94,0x9 -asm/non_matchings/code/z_bg_item/func_800CAFB8.s,func_800CAFB8,0x800CAFB8,0x9 -asm/non_matchings/code/z_bg_item/func_800CAFDC.s,func_800CAFDC,0x800CAFDC,0x9 -asm/non_matchings/code/code_800CB000/func_800CB000.s,func_800CB000,0x800CB000,0x84 +asm/non_matchings/code/z_bg_item/DynaPoly_Init.s,DynaPoly_Init,0x800CAE10,0x9 +asm/non_matchings/code/z_bg_item/DynaPoly_LoadMesh.s,DynaPoly_LoadMesh,0x800CAE34,0x12 +asm/non_matchings/code/z_bg_item/DynaPoly_ResetState.s,DynaPoly_ResetState,0x800CAE7C,0x3 +asm/non_matchings/code/z_bg_item/DynaPoly_SetRidingFallingState.s,DynaPoly_SetRidingFallingState,0x800CAE88,0x5 +asm/non_matchings/code/z_bg_item/DynaPoly_SetRidingMovingState.s,DynaPoly_SetRidingMovingState,0x800CAE9C,0x5 +asm/non_matchings/code/z_bg_item/DynaPoly_SetRidingMovingStateByIndex.s,DynaPoly_SetRidingMovingStateByIndex,0x800CAEB0,0xC +asm/non_matchings/code/z_bg_item/DynaPoly_SetRidingRotatingState.s,DynaPoly_SetRidingRotatingState,0x800CAEE0,0x5 +asm/non_matchings/code/z_bg_item/DynaPoly_SetRidingRotatingStateByIndex.s,DynaPoly_SetRidingRotatingStateByIndex,0x800CAEF4,0xC +asm/non_matchings/code/z_bg_item/DynaPoly_SetSwitchPressedState.s,DynaPoly_SetSwitchPressedState,0x800CAF24,0x5 +asm/non_matchings/code/z_bg_item/DynaPoly_SetHeavySwitchPressedState.s,DynaPoly_SetHeavySwitchPressedState,0x800CAF38,0x5 +asm/non_matchings/code/z_bg_item/DynaPoly_IsInRidingFallingState.s,DynaPoly_IsInRidingFallingState,0x800CAF4C,0x9 +asm/non_matchings/code/z_bg_item/DynaPoly_IsInRidingMovingState.s,DynaPoly_IsInRidingMovingState,0x800CAF70,0x9 +asm/non_matchings/code/z_bg_item/DynaPoly_IsInRidingRotatingState.s,DynaPoly_IsInRidingRotatingState,0x800CAF94,0x9 +asm/non_matchings/code/z_bg_item/DynaPoly_IsInSwitchPressedState.s,DynaPoly_IsInSwitchPressedState,0x800CAFB8,0x9 +asm/non_matchings/code/z_bg_item/DynaPoly_IsInHeavySwitchPressedState.s,DynaPoly_IsInHeavySwitchPressedState,0x800CAFDC,0x9 +asm/non_matchings/code/z_bg_item/DynaPoly_ValidateMove.s,DynaPoly_ValidateMove,0x800CB000,0x84 asm/non_matchings/code/z_camera/Camera_fabsf.s,Camera_fabsf,0x800CB210,0xC asm/non_matchings/code/z_camera/Camera_LengthVec3f.s,Camera_LengthVec3f,0x800CB240,0xC asm/non_matchings/code/z_camera/func_800CB270.s,func_800CB270,0x800CB270,0x30 @@ -1207,11 +1207,11 @@ asm/non_matchings/code/z_horse/func_800F3ED4.s,func_800F3ED4,0x800F3ED4,0x73 asm/non_matchings/code/z_horse/func_800F40A0.s,func_800F40A0,0x800F40A0,0x2F asm/non_matchings/code/z_horse/func_800F415C.s,func_800F415C,0x800F415C,0x22 asm/non_matchings/code/z_horse/func_800F41E4.s,func_800F41E4,0x800F41E4,0x2F -asm/non_matchings/code/z_jpeg/func_800F42A0.s,func_800F42A0,0x800F42A0,0x47 -asm/non_matchings/code/z_jpeg/func_800F43BC.s,func_800F43BC,0x800F43BC,0x4E -asm/non_matchings/code/z_jpeg/func_800F44F4.s,func_800F44F4,0x800F44F4,0x13 -asm/non_matchings/code/z_jpeg/func_800F4540.s,func_800F4540,0x800F4540,0x73 -asm/non_matchings/code/z_jpeg/func_800F470C.s,func_800F470C,0x800F470C,0xC1 +asm/non_matchings/code/z_jpeg/Jpeg_ScheduleDecoderTask.s,Jpeg_ScheduleDecoderTask,0x800F42A0,0x47 +asm/non_matchings/code/z_jpeg/Jpeg_CopyToZbuffer.s,Jpeg_CopyToZbuffer,0x800F43BC,0x4E +asm/non_matchings/code/z_jpeg/Jpeg_GetUnalignedU16.s,Jpeg_GetUnalignedU16,0x800F44F4,0x13 +asm/non_matchings/code/z_jpeg/Jpeg_ParseMarkers.s,Jpeg_ParseMarkers,0x800F4540,0x73 +asm/non_matchings/code/z_jpeg/Jpeg_Decode.s,Jpeg_Decode,0x800F470C,0xC1 asm/non_matchings/code/z_kaleido_setup/func_800F4A10.s,func_800F4A10,0x800F4A10,0x7F asm/non_matchings/code/z_kaleido_setup/func_800F4C0C.s,func_800F4C0C,0x800F4C0C,0x85 asm/non_matchings/code/z_kaleido_setup/func_800F4E20.s,func_800F4E20,0x800F4E20,0x42 @@ -1578,7 +1578,7 @@ asm/non_matchings/code/z_msgevent/func_8010BF58.s,func_8010BF58,0x8010BF58,0x5A asm/non_matchings/code/z_nmi_buff/Nmi_Init.s,Nmi_Init,0x8010C0C0,0x29 asm/non_matchings/code/z_nmi_buff/Nmi_SetPrenmiStart.s,Nmi_SetPrenmiStart,0x8010C164,0xE asm/non_matchings/code/z_nmi_buff/Nmi_GetPrenmiHasStarted.s,Nmi_GetPrenmiHasStarted,0x8010C19C,0x5 -asm/non_matchings/code/z_nmi_buff/func_8010C1B0.s,func_8010C1B0,0x8010C1B0,0x20 +asm/non_matchings/code/z_nmi_buff/MsgEvent_SendNullTask.s,MsgEvent_SendNullTask,0x8010C1B0,0x20 asm/non_matchings/code/z_olib/OLib_Vec3fDist.s,OLib_Vec3fDist,0x8010C230,0x11 asm/non_matchings/code/z_olib/OLib_Vec3fDistOutDiff.s,OLib_Vec3fDistOutDiff,0x8010C274,0x17 asm/non_matchings/code/z_olib/OLib_Vec3fDistXZ.s,OLib_Vec3fDistXZ,0x8010C2D0,0xD @@ -2907,10 +2907,10 @@ asm/non_matchings/code/sys_matrix/func_8018219C.s,func_8018219C,0x8018219C,0x4A asm/non_matchings/code/sys_matrix/func_801822C4.s,func_801822C4,0x801822C4,0x4A asm/non_matchings/code/sys_matrix/Matrix_InsertRotationAroundUnitVector_f.s,Matrix_InsertRotationAroundUnitVector_f,0x801823EC,0x118 asm/non_matchings/code/sys_matrix/Matrix_InsertRotationAroundUnitVector_s.s,Matrix_InsertRotationAroundUnitVector_s,0x8018284C,0x111 -asm/non_matchings/code/sys_matrix/SysUcode_GetUCodeBoot.s,SysUcode_GetUCodeBoot,0x80182C90,0x4 -asm/non_matchings/code/sys_matrix/SysUcode_GetUCodeBootSize.s,SysUcode_GetUCodeBootSize,0x80182CA0,0x7 -asm/non_matchings/code/sys_matrix/SysUcode_GetUCode.s,SysUcode_GetUCode,0x80182CBC,0x4 -asm/non_matchings/code/sys_matrix/SysUcode_GetUCodeData.s,SysUcode_GetUCodeData,0x80182CCC,0x5 +asm/non_matchings/code/sys_ucode/SysUcode_GetUCodeBoot.s,SysUcode_GetUCodeBoot,0x80182C90,0x4 +asm/non_matchings/code/sys_ucode/SysUcode_GetUCodeBootSize.s,SysUcode_GetUCodeBootSize,0x80182CA0,0x7 +asm/non_matchings/code/sys_ucode/SysUcode_GetUCode.s,SysUcode_GetUCode,0x80182CBC,0x4 +asm/non_matchings/code/sys_ucode/SysUcode_GetUCodeData.s,SysUcode_GetUCodeData,0x80182CCC,0x5 asm/non_matchings/code/sys_ucode/func_80182CE0.s,func_80182CE0,0x80182CE0,0xD0 asm/non_matchings/code/sys_ucode/func_80183020.s,func_80183020,0x80183020,0xE asm/non_matchings/code/sys_ucode/func_80183058.s,func_80183058,0x80183058,0x6 @@ -3469,7 +3469,7 @@ asm/non_matchings/code/code_8019AF00/func_801A2C20.s,func_801A2C20,0x801A2C20,0x asm/non_matchings/code/code_8019AF00/func_801A2C44.s,func_801A2C44,0x801A2C44,0x11 asm/non_matchings/code/code_8019AF00/func_801A2C88.s,func_801A2C88,0x801A2C88,0x33 asm/non_matchings/code/code_8019AF00/func_801A2D54.s,func_801A2D54,0x801A2D54,0x23 -asm/non_matchings/code/code_8019AF00/func_801A2DE0.s,func_801A2DE0,0x801A2DE0,0x1D +asm/non_matchings/code/code_8019AF00/Audio_IsSequencePlaying.s,Audio_IsSequencePlaying,0x801A2DE0,0x1D asm/non_matchings/code/code_8019AF00/func_801A2E54.s,func_801A2E54,0x801A2E54,0x21 asm/non_matchings/code/code_8019AF00/func_801A2ED8.s,func_801A2ED8,0x801A2ED8,0x2C asm/non_matchings/code/code_8019AF00/func_801A2F88.s,func_801A2F88,0x801A2F88,0xF @@ -3585,18 +3585,18 @@ asm/non_matchings/code/code_801A7B10/func_801A9768.s,func_801A9768,0x801A9768,0x asm/non_matchings/code/code_801A7B10/func_801A982C.s,func_801A982C,0x801A982C,0x63 asm/non_matchings/code/code_801A7B10/func_801A99B8.s,func_801A99B8,0x801A99B8,0x2F asm/non_matchings/code/code_801A7B10/func_801A9A74.s,func_801A9A74,0x801A9A74,0x27 -asm/non_matchings/code/code_801A7B10/func_801A9B10.s,func_801A9B10,0x801A9B10,0x1A -asm/non_matchings/code/code_801A7B10/func_801A9B78.s,func_801A9B78,0x801A9B78,0x21 -asm/non_matchings/code/code_801A7B10/func_801A9BFC.s,func_801A9BFC,0x801A9BFC,0x1B -asm/non_matchings/code/code_801A7B10/func_801A9C68.s,func_801A9C68,0x801A9C68,0x2A -asm/non_matchings/code/code_801A7B10/func_801A9D10.s,func_801A9D10,0x801A9D10,0x2F -asm/non_matchings/code/code_801A7B10/func_801A9DCC.s,func_801A9DCC,0x801A9DCC,0x36 -asm/non_matchings/code/code_801A7B10/func_801A9EA4.s,func_801A9EA4,0x801A9EA4,0x2A -asm/non_matchings/code/code_801A7B10/func_801A9F4C.s,func_801A9F4C,0x801A9F4C,0x35 -asm/non_matchings/code/code_801AA020/func_801AA020.s,func_801AA020,0x801AA020,0x8A -asm/non_matchings/code/code_801AA020/func_801AA248.s,func_801AA248,0x801AA248,0x67 -asm/non_matchings/code/code_801AA020/func_801AA3E4.s,func_801AA3E4,0x801AA3E4,0x4F -asm/non_matchings/code/code_801AA020/func_801AA520.s,func_801AA520,0x801AA520,0x3C +asm/non_matchings/code/jpegutils/JpegUtils_ProcessQuantizationTable.s,JpegUtils_ProcessQuantizationTable,0x801A9B10,0x1A +asm/non_matchings/code/jpegutils/JpegUtils_ParseHuffmanCodesLengths.s,JpegUtils_ParseHuffmanCodesLengths,0x801A9B78,0x21 +asm/non_matchings/code/jpegutils/JpegUtils_GetHuffmanCodes.s,JpegUtils_GetHuffmanCodes,0x801A9BFC,0x1B +asm/non_matchings/code/jpegutils/JpegUtils_SetHuffmanTable.s,JpegUtils_SetHuffmanTable,0x801A9C68,0x2A +asm/non_matchings/code/jpegutils/JpegUtils_ProcessHuffmanTableImpl.s,JpegUtils_ProcessHuffmanTableImpl,0x801A9D10,0x2F +asm/non_matchings/code/jpegutils/JpegUtils_ProcessHuffmanTable.s,JpegUtils_ProcessHuffmanTable,0x801A9DCC,0x36 +asm/non_matchings/code/jpegutils/JpegUtils_SetHuffmanTableOld.s,JpegUtils_SetHuffmanTableOld,0x801A9EA4,0x2A +asm/non_matchings/code/jpegutils/JpegUtils_ProcessHuffmanTableImplOld.s,JpegUtils_ProcessHuffmanTableImplOld,0x801A9F4C,0x35 +asm/non_matchings/code/jpegdecoder/JpegDecoder_Decode.s,JpegDecoder_Decode,0x801AA020,0x8A +asm/non_matchings/code/jpegdecoder/JpegDecoder_ProcessMcu.s,JpegDecoder_ProcessMcu,0x801AA248,0x67 +asm/non_matchings/code/jpegdecoder/JpegDecoder_ParseNextSymbol.s,JpegDecoder_ParseNextSymbol,0x801AA3E4,0x4F +asm/non_matchings/code/jpegdecoder/JpegDecoder_ReadBits.s,JpegDecoder_ReadBits,0x801AA520,0x3C asm/non_matchings/code/z_game_over/GameOver_Init.s,GameOver_Init,0x801AA610,0x5 asm/non_matchings/code/z_game_over/GameOver_FadeLights.s,GameOver_FadeLights,0x801AA624,0x1A asm/non_matchings/code/z_game_over/GameOver_Update.s,GameOver_Update,0x801AA68C,0x105 diff --git a/tools/warnings_count/check_new_warnings.sh b/tools/warnings_count/check_new_warnings.sh index 7a196c28be..27cda1b250 100755 --- a/tools/warnings_count/check_new_warnings.sh +++ b/tools/warnings_count/check_new_warnings.sh @@ -32,18 +32,30 @@ Check for new warnings created. Optional arguments: -h Display this message and exit. + -f Run full build process -j N use N jobs (does not support plain -j because you shouldn't use it anyway) " } jobs=1 +full= +run="make clean + make uncompressed" -while getopts "hj:" opt + + +while getopts "hfj:" opt do case $opt in h) show_help exit 0 ;; + f) full="true" + run="make distclean + make setup + make disasm + make all" + ;; j) j_option_arg="$OPTARG" if [[ ! "${j_option_arg}" =~ ^[0-9]*$ ]] then @@ -61,10 +73,7 @@ shift $(($OPTIND - 1)) # Confirm run with -j jobs echo "This will run - make distclean - make setup - make disasm - make all + $run using $jobs threads. This may take some time." read -r -p "Is this okay? [Y/n]" response response=${response,,} # tolower @@ -90,16 +99,20 @@ make_warnings () { && rm tools/warnings_count/warnings_temp.txt } +if [[ $full ]]; then + make distclean + make_warnings setup setup + make_warnings disasm disasm + make_warnings all build +else + make clean + make_warnings uncompressed build +fi -make distclean -make_warnings setup setup -make_warnings disasm disasm -make_warnings all build -echo " -$(tput ${TPUTTERM} setaf 3)(lots of make output ${TPUTTERM} here...) -$RST" -$COMPARE_WARNINGS setup -$COMPARE_WARNINGS disasm +if [[ $full ]]; then + $COMPARE_WARNINGS setup + $COMPARE_WARNINGS disasm +fi $COMPARE_WARNINGS build diff --git a/undefined_syms.txt b/undefined_syms.txt index 058ec41a8f..e3cb90acdc 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -4,8 +4,8 @@ D_80000000 = 0x80000000; // __osExceptionPreamble D_80000004 = 0x80000004; // __osExceptionPreamble D_80000008 = 0x80000008; // __osExceptionPreamble D_8000000C = 0x8000000C; // __osExceptionPreamble -D_80000010 = 0x80000010; // -D_80000020 = 0x80000020; // +D_80000010 = 0x80000010; // +D_80000020 = 0x80000020; // osTvType = 0x80000300; osRomType = 0x80000304; @@ -1339,10 +1339,26 @@ D_06001788 = 0x06001788; // ovl_Dm_Stk +D_0600055C = 0x0600055C; +D_06001030 = 0x06001030; +D_0600130C = 0x0600130C; +D_06001374 = 0x06001374; +D_06001EDC = 0x06001EDC; +D_06002774 = 0x06002774; +D_06002CD8 = 0x06002CD8; +D_06003068 = 0x06003068; +D_060035C8 = 0x060035C8; +D_060039F0 = 0x060039F0; +D_06004554 = 0x06004554; +D_06004580 = 0x06004580; D_060046B0 = 0x060046B0; +D_060049C8 = 0x060049C8; +D_060051C0 = 0x060051C0; D_060053C0 = 0x060053C0; D_06005870 = 0x06005870; +D_06005F44 = 0x06005F44; D_06006BB0 = 0x06006BB0; +D_060070DC = 0x060070DC; D_06007840 = 0x06007840; D_060079F0 = 0x060079F0; D_060084C0 = 0x060084C0; @@ -1357,9 +1373,61 @@ D_0600A530 = 0x0600A530; D_0600A5C0 = 0x0600A5C0; D_0600AE30 = 0x0600AE30; D_0600AEC0 = 0x0600AEC0; +D_0600BB2C = 0x0600BB2C; +D_0600C270 = 0x0600C270; +D_0600C964 = 0x0600C964; D_0600CAD0 = 0x0600CAD0; +D_0600CBB8 = 0x0600CBB8; +D_0600D830 = 0x0600D830; +D_0600E6EC = 0x0600E6EC; +D_0600EEC0 = 0x0600EEC0; +D_060101A4 = 0x060101A4; +D_06010B60 = 0x06010B60; +D_060110B4 = 0x060110B4; +D_06011FB0 = 0x06011FB0; +D_06012A58 = 0x06012A58; D_06013328 = 0x06013328; +D_060141E4 = 0x060141E4; +D_06014920 = 0x06014920; +D_06015028 = 0x06015028; +D_06015C14 = 0x06015C14; +D_06016508 = 0x06016508; D_06016620 = 0x06016620; +D_06016910 = 0x06016910; +D_06018ED0 = 0x06018ED0; +D_0601AA80 = 0x0601AA80; +D_0601C114 = 0x0601C114; +D_0601C21C = 0x0601C21C; +D_0601D008 = 0x0601D008; +D_0601D07C = 0x0601D07C; +D_0601D3D0 = 0x0601D3D0; +D_0601DDE0 = 0x0601DDE0; +D_0601EF50 = 0x0601EF50; +D_0601F9E4 = 0x0601F9E4; +D_06020CAC = 0x06020CAC; +D_0602200C = 0x0602200C; +D_0602336C = 0x0602336C; +D_060259F4 = 0x060259F4; +D_060266C8 = 0x060266C8; +D_06026CF4 = 0x06026CF4; +D_06027CF4 = 0x06027CF4; +D_06028F28 = 0x06028F28; +D_06029A04 = 0x06029A04; +D_0602A2D8 = 0x0602A2D8; +D_0602AD54 = 0x0602AD54; +D_0602DC64 = 0x0602DC64; +D_0602E9A0 = 0x0602E9A0; +D_0602FA70 = 0x0602FA70; +D_0603021C = 0x0603021C; +D_06031210 = 0x06031210; +D_060322FC = 0x060322FC; +D_06032AE0 = 0x06032AE0; +D_0603323C = 0x0603323C; +D_06034FD8 = 0x06034FD8; +D_06036964 = 0x06036964; +D_06037B94 = 0x06037B94; +D_0603967C = 0x0603967C; +D_0603A8F8 = 0x0603A8F8; // ovl_Dm_Tsg @@ -2390,8 +2458,24 @@ D_060079C0 = 0x060079C0; // ovl_En_Gm +D_06005028 = 0x06005028; +D_060054A8 = 0x060054A8; +D_06005CE8 = 0x06005CE8; +D_06006828 = 0x06006828; +D_06006C68 = 0x06006C68; D_06007528 = 0x06007528; D_060078B0 = 0x060078B0; +D_06008090 = 0x06008090; +D_0600898C = 0x0600898C; +D_06009450 = 0x06009450; +D_06009CDC = 0x06009CDC; +D_0600A5E0 = 0x0600A5E0; +D_0600A70C = 0x0600A70C; +D_0600AD18 = 0x0600AD18; +D_0600B8B0 = 0x0600B8B0; +D_0600B990 = 0x0600B990; +D_0600BA80 = 0x0600BA80; +D_0600C03C = 0x0600C03C; // ovl_En_Go @@ -2723,6 +2807,15 @@ D_0600D828 = 0x0600D828; D_06000214 = 0x06000214; D_060065B0 = 0x060065B0; +D_06007444 = 0x06007444; +D_0600686C = 0x0600686C; +D_060081A4 = 0x060081A4; +D_06007B90 = 0x06007B90; +D_060071EC = 0x060071EC; +D_06007444 = 0x06007444; +D_0600686C = 0x0600686C; +D_060081A4 = 0x060081A4; +D_06000214 = 0x06000214; // ovl_En_Kame @@ -3187,6 +3280,20 @@ D_06008348 = 0x06008348; D_060083E0 = 0x060083E0; D_060085C8 = 0x060085C8; D_060096E8 = 0x060096E8; +D_06002238 = 0x06002238; +D_0600A4E0 = 0x0600A4E0; +D_0600B09C = 0x0600B09C; +D_0600BA78 = 0x0600BA78; +D_0600C32C = 0x0600C32C; +D_060099B4 = 0x060099B4; +D_06000FC4 = 0x06000FC4; +D_0600A8D8 = 0x0600A8D8; +D_0600099C = 0x0600099C; +D_06001F84 = 0x06001F84; +D_06000468 = 0x06000468; +D_0600C640 = 0x0600C640; +D_06002950 = 0x06002950; +D_06002750 = 0x06002750; // ovl_En_Poh @@ -3674,7 +3781,16 @@ D_06002100 = 0x06002100; // ovl_En_Tk +D_06001144 = 0x06001144; +D_06001FA8 = 0x06001FA8; +D_060020C8 = 0x060020C8; D_060030A4 = 0x060030A4; +D_06003724 = 0x06003724; +D_06003B10 = 0x06003B10; +D_06003FB8 = 0x06003FB8; +D_06004390 = 0x06004390; +D_06004B90 = 0x06004B90; +D_06005390 = 0x06005390; D_0600B530 = 0x0600B530; D_0600B9E8 = 0x0600B9E8;