From 1af942ae12499c90bb4ebe2d37988d2234f8605e Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Fri, 30 Sep 2022 07:49:35 -0400 Subject: [PATCH 01/25] Audio Sequences: Scene/Ambience/SeqFlags Functions OK (#1033) * import audio scene seq docs * cleanup * fix scene cmd * small fixes * more PR suggestions * missed comment * rename spot to resume * cleanup comments * SEQ_IO_VAL_NONE * Empty-Commit * another PR suggestion --- include/functions.h | 54 +- include/sequence.h | 210 +-- include/variables.h | 4 +- include/z64.h | 9 +- include/z64audio.h | 11 +- include/z64save.h | 4 +- include/z64scene.h | 16 +- src/code/audio/audio_seqplayer.c | 12 +- src/code/audio/code_8019AF00.c | 1656 +++++++++++------ src/code/audio/code_801A5BD0.c | 2 +- src/code/audio/code_801A7B10.c | 4 +- src/code/game.c | 2 +- src/code/graph.c | 2 +- src/code/z_common_data.c | 4 +- src/code/z_demo.c | 30 +- src/code/z_game_over.c | 6 +- src/code/z_scene.c | 9 +- src/overlays/actors/ovl_Boss_04/z_boss_04.c | 4 +- src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c | 4 +- .../actors/ovl_Door_Shutter/z_door_shutter.c | 2 +- .../actors/ovl_En_Aob_01/z_en_aob_01.c | 2 +- src/overlays/actors/ovl_En_Az/z_en_az.c | 4 +- src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c | 16 +- src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.h | 2 +- .../actors/ovl_En_Bigslime/z_en_bigslime.c | 4 +- .../actors/ovl_En_Bomjimb/z_en_bomjimb.c | 2 +- src/overlays/actors/ovl_En_Box/z_en_box.c | 2 +- .../actors/ovl_En_Dinofos/z_en_dinofos.c | 6 +- .../actors/ovl_En_Elforg/z_en_elforg.c | 2 +- src/overlays/actors/ovl_En_Fu/z_en_fu.c | 4 +- src/overlays/actors/ovl_En_Ik/z_en_ik.c | 4 +- .../actors/ovl_En_Invadepoh/z_en_invadepoh.c | 2 +- .../actors/ovl_En_Ma_Yto/z_en_ma_yto.c | 2 +- src/overlays/actors/ovl_En_Mm3/z_en_mm3.c | 2 +- src/overlays/actors/ovl_En_Owl/z_en_owl.c | 8 +- .../actors/ovl_En_Pametfrog/z_en_pametfrog.c | 8 +- .../z_en_syateki_dekunuts.c | 2 +- .../ovl_En_Syateki_Man/z_en_syateki_man.c | 6 +- .../ovl_En_Syateki_Wf/z_en_syateki_wf.c | 2 +- src/overlays/actors/ovl_En_Test6/z_en_test6.c | 2 +- src/overlays/actors/ovl_En_Test7/z_en_test7.c | 6 +- .../actors/ovl_En_Warp_tag/z_en_warp_tag.c | 4 +- src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c | 2 +- src/overlays/actors/ovl_Obj_Um/z_obj_um.c | 6 +- src/overlays/gamestates/ovl_select/z_select.c | 4 +- src/overlays/gamestates/ovl_title/z_title.c | 4 +- tools/disasm/functions.txt | 58 +- tools/disasm/variables.txt | 18 +- tools/namefixer.py | 13 + tools/sizes/code_functions.csv | 58 +- 50 files changed, 1445 insertions(+), 855 deletions(-) diff --git a/include/functions.h b/include/functions.h index 05fd4ed453..67ad8ec3cd 100644 --- a/include/functions.h +++ b/include/functions.h @@ -3158,7 +3158,7 @@ OcarinaStaff* AudioOcarina_GetPlaybackStaff(void); void AudioOcarina_TerminaWallGenerateNotes(void); void AudioOcarina_PlayLongScarecrowAfterCredits(void); -void func_8019E014(void); +void Audio_Update(void); // void func_8019E110(void); void AudioSfx_SetProperties(u8 bankId, u8 entryIndex, u8 channelIndex); void play_sound(u16 sfxId); @@ -3224,31 +3224,27 @@ void func_801A1F88(void); void func_801A1FB4(u8 playerIndex, Vec3f* pos, u16 seqId, f32 maxDist); // void func_801A2090(void); void func_801A246C(u8 param_1, u8 param_2); -// void func_801A2544(void); -// void func_801A257C(void); -void func_801A25E4(u16 seqId, u8 dayMinusOne); -// void func_801A2670(void); -// void func_801A2778(void); +void Audio_PlayMorningSceneSequence(u16 seqId, u8 dayMinusOne); +void Audio_PlaySceneSequence(u16 seqId, u8 dayMinusOne); // void func_801A27E8(void); // void func_801A281C(void); void func_801A29D4(UNK_TYPE arg0, f32 arg1, UNK_TYPE arg2); void func_801A2BB8(s32 seqId); void func_801A2C20(void); // void func_801A2C44(void); -void func_801A2C88(u16 seqId); -void func_801A2D54(u16 seqId); +void Audio_PlaySequenceInCutscene(u16 seqId); +void Audio_StopSequenceInCutscene(u16 seqId); s32 Audio_IsSequencePlaying(u8 seqId); -void func_801A2E54(s32 bgmId); -void func_801A2ED8(void); -// void func_801A2F88(void); +void Audio_PlayBgm_StorePrevBgm(u16 seqId); +void Audio_RestorePrevBgm(void); // void func_801A3000(void); // void func_801A3038(void); -void func_801A3098(u16 seqId); +void Audio_PlayFanfare(u16 seqId); // void func_801A312C(void); void func_801A31EC(u16 seqId, s8 arg1, u8 arg2); -// void func_801A3238(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5); -// void func_801A32CC(void); -// void func_801A3590(void); +void Audio_PlaySequenceWithSeqPlayerIO(s8 playerIndex, u16 seqId, u8 fadeTimer, s8 ioPort, u8 ioData); +void Audio_SetSequenceMode(u8 seqMode); +void Audio_UpdateEnemyBgmVolume(f32 dist); u8 func_801A3950(s32 playerIndex, s32 isChannelIOSet); u8 func_801A39F8(void); void func_801A3A7C(s32 arg0); @@ -3261,11 +3257,11 @@ void func_801A3CD8(s8 param_1); void func_801A3D98(s8 audioSetting); // void func_801A3E38(void); // void func_801A3EC0(void); -void Audio_SetCutsceneFlag(u8 flag); +void Audio_SetCutsceneFlag(s8 flag); // void func_801A3F6C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); // void func_801A3FB4(void); // void func_801A3FFC(UNK_TYPE1 param_1); -void audio_setBGM(u32 bgmID); +void Audio_SetSpec(u32 specId); void func_801A4058(UNK_TYPE arg0); // void func_801A41C8(void); // void func_801A41F8(void); @@ -3276,15 +3272,13 @@ void func_801A4058(UNK_TYPE arg0); void Audio_SetSfxVolumeExceptSystemAndOcarinaBanks(u8 arg0); void func_801A4428(u8 reverbIndex); void Audio_PreNMI(void); -// void func_801A44C4(void); +// void Audio_ResetRequestedSceneSeqId(void); // void func_801A44D4(void); s32 func_801A46F8(void); void func_801A4748(Vec3f* pos, u16 sfxId); void func_801A479C(Vec3f* arg0, u16 sfxId, s32 arg2); -void func_801A47DC(u8 channelIndexRange, u8 port, u8 val); -// void func_801A48E0(void); -void func_801A4A28(u8 natureSeqId); -// void Audio_SetNatureAmbienceRandomBend(void); +void Audio_SetAmbienceChannelIO(u8 channelIndexRange, u8 ioPort, u8 ioData); +void Audio_PlayAmbience(u8 ambienceId); void Audio_Init(void); void func_801A4D00(void); // void func_801A4D50(void); @@ -3297,7 +3291,7 @@ void func_801A4D00(void); // void func_801A4FD8(void); void func_801A5080(u16 arg0); u16 func_801A5100(void); -// void func_801A5118(void); +void func_801A5118(void); UNK_TYPE func_801A51F0(UNK_TYPE arg0); // void func_801A5228(void); // void func_801A5390(void); @@ -3328,17 +3322,17 @@ u8 AudioSfx_IsPlaying(u32 sfxId); void AudioSfx_Reset(void); void Audio_StartSequence(u8 playerIndex, u8 seqId, u8 seqArgs, u16 fadeTimer); -// void func_801A7D04(void); +void Audio_StopSequence(u8 playerIndex, u16 fadeTimer); // void func_801A7D84(void); void Audio_QueueSeqCmd(u32 cmd); -// void func_801A89D0(void); -s32 func_801A8A50(s32 param1); -// void func_801A8ABC(void); +void func_801A89D0(void); +u16 Audio_GetActiveSequence(u8 playerIndex); +s32 func_801A8ABC(u32 cmdVal, u32 cmdMask); void Audio_SetVolumeScale(u8 playerIndex, u8 scaleIndex, u8 targetVol, u8 volFadeTimer); -// void func_801A8D5C(void); +void func_801A8D5C(void); // void func_801A8E90(void); -// void func_801A9768(void); -// void func_801A982C(void); +u8 func_801A9768(void); +u8 func_801A982C(void); // void func_801A99B8(void); // void func_801A9A74(void); diff --git a/include/sequence.h b/include/sequence.h index d46e96aea9..857609d4b2 100644 --- a/include/sequence.h +++ b/include/sequence.h @@ -4,7 +4,7 @@ #define NA_BGM_STOP 0x100000FF #define NA_BGM_GENERAL_SFX 0x00 // General Sound Effects -#define NA_BGM_NATURE_AMBIENCE 0x01 // Ambient background noises +#define NA_BGM_AMBIENCE 0x01 // Ambient background noises #define NA_BGM_TERMINA_FIELD 0x02 // Termina Field #define NA_BGM_CHASE 0x03 // Forest Chase #define NA_BGM_MAJORAS_THEME 0x04 // Majora's Theme "STALKID" @@ -40,7 +40,7 @@ #define NA_BGM_GET_ITEM 0x22 // Item Catch #define NA_BGM_GATE_OPEN 0x23 // Clock Town Day 2 Duplicate of #16. In MM3D, it shares its filename with the Door of Time song from OoT #define NA_BGM_GET_HEART 0x24 // Complete a Heart Piece -#define NA_BGM_MINI_GAME_2 0x25 // Playing Minigame +#define NA_BGM_TIMED_MINI_GAME 0x25 // Playing a timed Minigame #define NA_BGM_GORON_RACE 0x26 // Goron Race #define NA_BGM_MUSIC_BOX_HOUSE 0x27 // Music Box House "ORGEL_HOUSE" #define NA_BGM_FAIRY_FOUNTAIN 0x28 // Fairy's Fountain In MM3D, it shares its filename with the Door of Time song from OoT "GODESS" @@ -134,11 +134,12 @@ #define NA_BGM_DISABLED 0xFFFF typedef enum { - /* 0 */ SEQ_PLAYER_BGM_MAIN, - /* 1 */ SEQ_PLAYER_FANFARE, - /* 2 */ SEQ_PLAYER_SFX, - /* 3 */ SEQ_PLAYER_BGM_SUB, - /* 4 */ SEQ_PLAYER_NATURE + /* 0 */ SEQ_PLAYER_BGM_MAIN, + /* 1 */ SEQ_PLAYER_FANFARE, + /* 2 */ SEQ_PLAYER_SFX, + /* 3 */ SEQ_PLAYER_BGM_SUB, + /* 4 */ SEQ_PLAYER_AMBIENCE, + /* 0xFF */ SEQ_PLAYER_INVALID = 0xFF } SequencePlayerId; typedef enum { @@ -160,119 +161,120 @@ typedef enum { } ChannelIOPort; typedef enum { - /* 0x0 */ NATURE_CHANNEL_STREAM_0, - /* 0x1 */ NATURE_CHANNEL_CRITTER_0, - /* 0x2 */ NATURE_CHANNEL_CRITTER_1, - /* 0x3 */ NATURE_CHANNEL_CRITTER_2, - /* 0x4 */ NATURE_CHANNEL_CRITTER_3, - /* 0x5 */ NATURE_CHANNEL_CRITTER_4, - /* 0x6 */ NATURE_CHANNEL_CRITTER_5, - /* 0x7 */ NATURE_CHANNEL_CRITTER_6, - /* 0x8 */ NATURE_CHANNEL_CRITTER_7, - /* 0xC */ NATURE_CHANNEL_STREAM_1 = 12, - /* 0xD */ NATURE_CHANNEL_UNK, - /* 0xE */ NATURE_CHANNEL_RAIN, - /* 0xF */ NATURE_CHANNEL_LIGHTNING -} NatureChannelIdx; // playerIdx = 4 + /* 0x0 */ AMBIENCE_CHANNEL_STREAM_0, + /* 0x1 */ AMBIENCE_CHANNEL_CRITTER_0, + /* 0x2 */ AMBIENCE_CHANNEL_CRITTER_1, + /* 0x3 */ AMBIENCE_CHANNEL_CRITTER_2, + /* 0x4 */ AMBIENCE_CHANNEL_CRITTER_3, + /* 0x5 */ AMBIENCE_CHANNEL_CRITTER_4, + /* 0x6 */ AMBIENCE_CHANNEL_CRITTER_5, + /* 0x7 */ AMBIENCE_CHANNEL_CRITTER_6, + /* 0x8 */ AMBIENCE_CHANNEL_CRITTER_7, + /* 0xC */ AMBIENCE_CHANNEL_STREAM_1 = 12, + /* 0xD */ AMBIENCE_CHANNEL_SOUND_MODE, + /* 0xE */ AMBIENCE_CHANNEL_RAIN, + /* 0xF */ AMBIENCE_CHANNEL_LIGHTNING +} AmbienceChannelIndex; // playerIndex = SEQ_PLAYER_AMBIENCE typedef enum { - /* 0x00 */ NATURE_AMBIENCE_0, - /* 0x01 */ NATURE_AMBIENCE_1, - /* 0x02 */ NATURE_AMBIENCE_2, - /* 0x03 */ NATURE_AMBIENCE_3, - /* 0x04 */ NATURE_AMBIENCE_4, - /* 0x05 */ NATURE_AMBIENCE_5, - /* 0x06 */ NATURE_AMBIENCE_6, - /* 0x07 */ NATURE_AMBIENCE_7, - /* 0x08 */ NATURE_AMBIENCE_8, - /* 0x09 */ NATURE_AMBIENCE_9, - /* 0x0A */ NATURE_AMBIENCE_A, - /* 0x0B */ NATURE_AMBIENCE_B, - /* 0x0C */ NATURE_AMBIENCE_C, - /* 0x0D */ NATURE_AMBIENCE_D, - /* 0x0E */ NATURE_AMBIENCE_E, - /* 0x0F */ NATURE_AMBIENCE_F, - /* 0x10 */ NATURE_AMBIENCE_10, - /* 0x11 */ NATURE_AMBIENCE_11, - /* 0x12 */ NATURE_AMBIENCE_12, - /* 0x13 */ NATURE_AMBIENCE_13 -} NatureAmbienceId; // playerIdx = 4 + /* 0x00 */ AMBIENCE_ID_00, + /* 0x01 */ AMBIENCE_ID_01, + /* 0x02 */ AMBIENCE_ID_02, + /* 0x03 */ AMBIENCE_ID_03, + /* 0x04 */ AMBIENCE_ID_04, + /* 0x05 */ AMBIENCE_ID_05, + /* 0x06 */ AMBIENCE_ID_06, + /* 0x07 */ AMBIENCE_ID_07, + /* 0x08 */ AMBIENCE_ID_08, + /* 0x09 */ AMBIENCE_ID_09, + /* 0x0A */ AMBIENCE_ID_0A, + /* 0x0B */ AMBIENCE_ID_0B, + /* 0x0C */ AMBIENCE_ID_0C, + /* 0x0D */ AMBIENCE_ID_0D, + /* 0x0E */ AMBIENCE_ID_0E, + /* 0x0F */ AMBIENCE_ID_0F, + /* 0x10 */ AMBIENCE_ID_10, + /* 0x11 */ AMBIENCE_ID_11, + /* 0x12 */ AMBIENCE_ID_12, + /* 0x13 */ AMBIENCE_ID_13, + /* 0xFF */ AMBIENCE_ID_DISABLED = 0xFF +} AmbienceId; // playerIndex = SEQ_PLAYER_AMBIENCE typedef enum { - /* 0x00 */ NATURE_STREAM_0, - /* 0x01 */ NATURE_STREAM_1, - /* 0x02 */ NATURE_STREAM_2, - /* 0x03 */ NATURE_STREAM_3 -} NatureStreamId; + /* 0x00 */ AMBIENCE_STREAM_0, + /* 0x01 */ AMBIENCE_STREAM_1, + /* 0x02 */ AMBIENCE_STREAM_2, + /* 0x03 */ AMBIENCE_STREAM_3 +} AmbienceStreamId; typedef enum { - /* 0x00 */ NATURE_CRITTER_00, - /* 0x01 */ NATURE_CRITTER_01, - /* 0x02 */ NATURE_CRITTER_02, - /* 0x03 */ NATURE_CRITTER_03, - /* 0x04 */ NATURE_CRITTER_04, - /* 0x05 */ NATURE_CRITTER_05, - /* 0x06 */ NATURE_CRITTER_06, - /* 0x07 */ NATURE_CRITTER_07, - /* 0x08 */ NATURE_CRITTER_08, - /* 0x09 */ NATURE_CRITTER_09, - /* 0x0A */ NATURE_CRITTER_10, - /* 0x0B */ NATURE_CRITTER_11, - /* 0x0C */ NATURE_CRITTER_12, - /* 0x0D */ NATURE_CRITTER_13, - /* 0x0E */ NATURE_CRITTER_14, - /* 0x0F */ NATURE_CRITTER_15, - /* 0x10 */ NATURE_CRITTER_16, - /* 0x11 */ NATURE_CRITTER_17, - /* 0x12 */ NATURE_CRITTER_18, - /* 0x13 */ NATURE_CRITTER_19 -} NatureAmimalId; + /* 0x00 */ AMBIENCE_CRITTER_00, + /* 0x01 */ AMBIENCE_CRITTER_01, + /* 0x02 */ AMBIENCE_CRITTER_02, + /* 0x03 */ AMBIENCE_CRITTER_03, + /* 0x04 */ AMBIENCE_CRITTER_04, + /* 0x05 */ AMBIENCE_CRITTER_05, + /* 0x06 */ AMBIENCE_CRITTER_06, + /* 0x07 */ AMBIENCE_CRITTER_07, + /* 0x08 */ AMBIENCE_CRITTER_08, + /* 0x09 */ AMBIENCE_CRITTER_09, + /* 0x0A */ AMBIENCE_CRITTER_10, + /* 0x0B */ AMBIENCE_CRITTER_11, + /* 0x0C */ AMBIENCE_CRITTER_12, + /* 0x0D */ AMBIENCE_CRITTER_13, + /* 0x0E */ AMBIENCE_CRITTER_14, + /* 0x0F */ AMBIENCE_CRITTER_15, + /* 0x10 */ AMBIENCE_CRITTER_16, + /* 0x11 */ AMBIENCE_CRITTER_17, + /* 0x12 */ AMBIENCE_CRITTER_18, + /* 0x13 */ AMBIENCE_CRITTER_19 +} AmbienceCritterId; -#define NATURE_IO_CRITTER_0_TYPE(type) NATURE_CHANNEL_CRITTER_0, CHANNEL_IO_PORT_2, type -#define NATURE_IO_CRITTER_0_BEND_PITCH(bend) NATURE_CHANNEL_CRITTER_0, CHANNEL_IO_PORT_3, bend -#define NATURE_IO_CRITTER_0_NUM_LAYERS(num) NATURE_CHANNEL_CRITTER_0, CHANNEL_IO_PORT_4, num -#define NATURE_IO_CRITTER_0_PORT5(reverb) NATURE_CHANNEL_CRITTER_0, CHANNEL_IO_PORT_5, reverb +#define AMBIENCE_IO_CRITTER_0_TYPE(type) AMBIENCE_CHANNEL_CRITTER_0, CHANNEL_IO_PORT_2, type +#define AMBIENCE_IO_CRITTER_0_BEND_PITCH(bend) AMBIENCE_CHANNEL_CRITTER_0, CHANNEL_IO_PORT_3, bend +#define AMBIENCE_IO_CRITTER_0_NUM_LAYERS(num) AMBIENCE_CHANNEL_CRITTER_0, CHANNEL_IO_PORT_4, num +#define AMBIENCE_IO_CRITTER_0_PORT5(reverb) AMBIENCE_CHANNEL_CRITTER_0, CHANNEL_IO_PORT_5, reverb -#define NATURE_IO_CRITTER_1_TYPE(type) NATURE_CHANNEL_CRITTER_1, CHANNEL_IO_PORT_2, type -#define NATURE_IO_CRITTER_1_BEND_PITCH(bend) NATURE_CHANNEL_CRITTER_1, CHANNEL_IO_PORT_3, bend -#define NATURE_IO_CRITTER_1_NUM_LAYERS(num) NATURE_CHANNEL_CRITTER_1, CHANNEL_IO_PORT_4, num -#define NATURE_IO_CRITTER_1_PORT5(reverb) NATURE_CHANNEL_CRITTER_1, CHANNEL_IO_PORT_5, reverb +#define AMBIENCE_IO_CRITTER_1_TYPE(type) AMBIENCE_CHANNEL_CRITTER_1, CHANNEL_IO_PORT_2, type +#define AMBIENCE_IO_CRITTER_1_BEND_PITCH(bend) AMBIENCE_CHANNEL_CRITTER_1, CHANNEL_IO_PORT_3, bend +#define AMBIENCE_IO_CRITTER_1_NUM_LAYERS(num) AMBIENCE_CHANNEL_CRITTER_1, CHANNEL_IO_PORT_4, num +#define AMBIENCE_IO_CRITTER_1_PORT5(reverb) AMBIENCE_CHANNEL_CRITTER_1, CHANNEL_IO_PORT_5, reverb -#define NATURE_IO_CRITTER_2_TYPE(type) NATURE_CHANNEL_CRITTER_2, CHANNEL_IO_PORT_2, type -#define NATURE_IO_CRITTER_2_BEND_PITCH(bend) NATURE_CHANNEL_CRITTER_2, CHANNEL_IO_PORT_3, bend -#define NATURE_IO_CRITTER_2_NUM_LAYERS(num) NATURE_CHANNEL_CRITTER_2, CHANNEL_IO_PORT_4, num -#define NATURE_IO_CRITTER_2_PORT5(reverb) NATURE_CHANNEL_CRITTER_2, CHANNEL_IO_PORT_5, reverb +#define AMBIENCE_IO_CRITTER_2_TYPE(type) AMBIENCE_CHANNEL_CRITTER_2, CHANNEL_IO_PORT_2, type +#define AMBIENCE_IO_CRITTER_2_BEND_PITCH(bend) AMBIENCE_CHANNEL_CRITTER_2, CHANNEL_IO_PORT_3, bend +#define AMBIENCE_IO_CRITTER_2_NUM_LAYERS(num) AMBIENCE_CHANNEL_CRITTER_2, CHANNEL_IO_PORT_4, num +#define AMBIENCE_IO_CRITTER_2_PORT5(reverb) AMBIENCE_CHANNEL_CRITTER_2, CHANNEL_IO_PORT_5, reverb -#define NATURE_IO_CRITTER_3_TYPE(type) NATURE_CHANNEL_CRITTER_3, CHANNEL_IO_PORT_2, type -#define NATURE_IO_CRITTER_3_BEND_PITCH(bend) NATURE_CHANNEL_CRITTER_3, CHANNEL_IO_PORT_3, bend -#define NATURE_IO_CRITTER_3_NUM_LAYERS(num) NATURE_CHANNEL_CRITTER_3, CHANNEL_IO_PORT_4, num -#define NATURE_IO_CRITTER_3_PORT5(reverb) NATURE_CHANNEL_CRITTER_3, CHANNEL_IO_PORT_5, reverb +#define AMBIENCE_IO_CRITTER_3_TYPE(type) AMBIENCE_CHANNEL_CRITTER_3, CHANNEL_IO_PORT_2, type +#define AMBIENCE_IO_CRITTER_3_BEND_PITCH(bend) AMBIENCE_CHANNEL_CRITTER_3, CHANNEL_IO_PORT_3, bend +#define AMBIENCE_IO_CRITTER_3_NUM_LAYERS(num) AMBIENCE_CHANNEL_CRITTER_3, CHANNEL_IO_PORT_4, num +#define AMBIENCE_IO_CRITTER_3_PORT5(reverb) AMBIENCE_CHANNEL_CRITTER_3, CHANNEL_IO_PORT_5, reverb -#define NATURE_IO_CRITTER_4_TYPE(type) NATURE_CHANNEL_CRITTER_4, CHANNEL_IO_PORT_2, type -#define NATURE_IO_CRITTER_4_BEND_PITCH(bend) NATURE_CHANNEL_CRITTER_4, CHANNEL_IO_PORT_3, bend -#define NATURE_IO_CRITTER_4_NUM_LAYERS(num) NATURE_CHANNEL_CRITTER_4, CHANNEL_IO_PORT_4, num -#define NATURE_IO_CRITTER_4_PORT5(reverb) NATURE_CHANNEL_CRITTER_4, CHANNEL_IO_PORT_5, reverb +#define AMBIENCE_IO_CRITTER_4_TYPE(type) AMBIENCE_CHANNEL_CRITTER_4, CHANNEL_IO_PORT_2, type +#define AMBIENCE_IO_CRITTER_4_BEND_PITCH(bend) AMBIENCE_CHANNEL_CRITTER_4, CHANNEL_IO_PORT_3, bend +#define AMBIENCE_IO_CRITTER_4_NUM_LAYERS(num) AMBIENCE_CHANNEL_CRITTER_4, CHANNEL_IO_PORT_4, num +#define AMBIENCE_IO_CRITTER_4_PORT5(reverb) AMBIENCE_CHANNEL_CRITTER_4, CHANNEL_IO_PORT_5, reverb -#define NATURE_IO_CRITTER_5_TYPE(type) NATURE_CHANNEL_CRITTER_5, CHANNEL_IO_PORT_2, type -#define NATURE_IO_CRITTER_5_BEND_PITCH(bend) NATURE_CHANNEL_CRITTER_5, CHANNEL_IO_PORT_3, bend -#define NATURE_IO_CRITTER_5_NUM_LAYERS(num) NATURE_CHANNEL_CRITTER_5, CHANNEL_IO_PORT_4, num -#define NATURE_IO_CRITTER_5_PORT5(reverb) NATURE_CHANNEL_CRITTER_5, CHANNEL_IO_PORT_5, reverb +#define AMBIENCE_IO_CRITTER_5_TYPE(type) AMBIENCE_CHANNEL_CRITTER_5, CHANNEL_IO_PORT_2, type +#define AMBIENCE_IO_CRITTER_5_BEND_PITCH(bend) AMBIENCE_CHANNEL_CRITTER_5, CHANNEL_IO_PORT_3, bend +#define AMBIENCE_IO_CRITTER_5_NUM_LAYERS(num) AMBIENCE_CHANNEL_CRITTER_5, CHANNEL_IO_PORT_4, num +#define AMBIENCE_IO_CRITTER_5_PORT5(reverb) AMBIENCE_CHANNEL_CRITTER_5, CHANNEL_IO_PORT_5, reverb -#define NATURE_IO_CRITTER_6_TYPE(type) NATURE_CHANNEL_CRITTER_6, CHANNEL_IO_PORT_2, type -#define NATURE_IO_CRITTER_6_BEND_PITCH(bend) NATURE_CHANNEL_CRITTER_6, CHANNEL_IO_PORT_3, bend -#define NATURE_IO_CRITTER_6_NUM_LAYERS(num) NATURE_CHANNEL_CRITTER_6, CHANNEL_IO_PORT_4, num -#define NATURE_IO_CRITTER_6_PORT5(reverb) NATURE_CHANNEL_CRITTER_6, CHANNEL_IO_PORT_5, reverb +#define AMBIENCE_IO_CRITTER_6_TYPE(type) AMBIENCE_CHANNEL_CRITTER_6, CHANNEL_IO_PORT_2, type +#define AMBIENCE_IO_CRITTER_6_BEND_PITCH(bend) AMBIENCE_CHANNEL_CRITTER_6, CHANNEL_IO_PORT_3, bend +#define AMBIENCE_IO_CRITTER_6_NUM_LAYERS(num) AMBIENCE_CHANNEL_CRITTER_6, CHANNEL_IO_PORT_4, num +#define AMBIENCE_IO_CRITTER_6_PORT5(reverb) AMBIENCE_CHANNEL_CRITTER_6, CHANNEL_IO_PORT_5, reverb -#define NATURE_IO_STREAM_0_TYPE(type) NATURE_CHANNEL_STREAM_0, CHANNEL_IO_PORT_2, type -#define NATURE_IO_STREAM_0_PORT3(data) NATURE_CHANNEL_STREAM_0, CHANNEL_IO_PORT_3, data -#define NATURE_IO_STREAM_0_PORT4(data) NATURE_CHANNEL_STREAM_0, CHANNEL_IO_PORT_4, data +#define AMBIENCE_IO_STREAM_0_TYPE(type) AMBIENCE_CHANNEL_STREAM_0, CHANNEL_IO_PORT_2, type +#define AMBIENCE_IO_STREAM_0_PORT3(data) AMBIENCE_CHANNEL_STREAM_0, CHANNEL_IO_PORT_3, data +#define AMBIENCE_IO_STREAM_0_PORT4(data) AMBIENCE_CHANNEL_STREAM_0, CHANNEL_IO_PORT_4, data -#define NATURE_IO_STREAM_1_TYPE(type) NATURE_CHANNEL_STREAM_1, CHANNEL_IO_PORT_2, type -#define NATURE_IO_STREAM_1_PORT3(data) NATURE_CHANNEL_STREAM_1, CHANNEL_IO_PORT_3, data -#define NATURE_IO_STREAM_1_PORT4(data) NATURE_CHANNEL_STREAM_1, CHANNEL_IO_PORT_4, data +#define AMBIENCE_IO_STREAM_1_TYPE(type) AMBIENCE_CHANNEL_STREAM_1, CHANNEL_IO_PORT_2, type +#define AMBIENCE_IO_STREAM_1_PORT3(data) AMBIENCE_CHANNEL_STREAM_1, CHANNEL_IO_PORT_3, data +#define AMBIENCE_IO_STREAM_1_PORT4(data) AMBIENCE_CHANNEL_STREAM_1, CHANNEL_IO_PORT_4, data -#define NATURE_IO_RAIN_PORT4(data) NATURE_CHANNEL_RAIN, CHANNEL_IO_PORT_4, data +#define AMBIENCE_IO_RAIN_PORT4(data) AMBIENCE_CHANNEL_RAIN, CHANNEL_IO_PORT_4, data -#define NATURE_IO_ENTRIES_END 0xFF +#define AMBIENCE_IO_ENTRIES_END 0xFF #endif diff --git a/include/variables.h b/include/variables.h index 07e80b2ca4..c7ea263f2a 100644 --- a/include/variables.h +++ b/include/variables.h @@ -3416,7 +3416,7 @@ extern s32 D_801FD120; // extern UNK_TYPE1 D_801FD434; // extern UNK_TYPE1 D_801FD435; // extern UNK_TYPE1 D_801FD436; -// extern UNK_TYPE1 D_801FD438; +// extern UNK_TYPE1 sPrevAmbienceSeqId; // extern UNK_TYPE1 D_801FD43A; // extern UNK_TYPE1 D_801FD43B; // extern UNK_TYPE1 D_801FD43E; @@ -3477,7 +3477,7 @@ extern ActiveSfx gActiveSfx[7][3]; // extern UNK_TYPE1 D_8020001E; // extern UNK_TYPE1 D_802000C9; // extern UNK_TYPE1 D_802000D4; -// extern UNK_TYPE1 D_80200140; +extern ActiveSequence gActiveSeqs[]; // extern UNK_TYPE1 D_8020034A; // extern UNK_TYPE1 D_80200B88; // extern UNK_TYPE1 D_80200BBA; diff --git a/include/z64.h b/include/z64.h index 69e89d629f..5589e7cad5 100644 --- a/include/z64.h +++ b/include/z64.h @@ -1056,10 +1056,9 @@ struct FireObj { }; // size = 0x8B typedef struct { - /* 0x0 */ u8 seqIndex; - /* 0x1 */ u8 nightSeqIndex; - /* 0x2 */ u8 unk_02; -} SoundContext; // size = 0x3 + /* 0x0 */ u8 seqId; + /* 0x1 */ u8 ambienceId; +} SequenceContext; // size = 0x2 typedef struct { /* 0x0 */ s32 enabled; @@ -1095,7 +1094,7 @@ struct PlayState { /* 0x00800 */ Camera* cameraPtrs[NUM_CAMS]; /* 0x00810 */ s16 activeCamId; /* 0x00812 */ s16 nextCamera; - /* 0x00814 */ SoundContext soundCtx; + /* 0x00814 */ SequenceContext sequenceCtx; /* 0x00818 */ LightContext lightCtx; /* 0x00828 */ FrameAdvanceContext frameAdvCtx; /* 0x00830 */ CollisionContext colCtx; diff --git a/include/z64audio.h b/include/z64audio.h index fc9bf9f4c9..c5045e34ff 100644 --- a/include/z64audio.h +++ b/include/z64audio.h @@ -9,6 +9,7 @@ #define IS_SEQUENCE_CHANNEL_VALID(ptr) ((uintptr_t)(ptr) != (uintptr_t)&gAudioContext.sequenceChannelNone) #define SEQ_NUM_CHANNELS 16 +#define SEQ_IO_VAL_NONE -1 typedef enum { /* 0 */ SEQPLAYER_STATE_0, @@ -51,9 +52,9 @@ typedef enum { typedef enum { /* 0 */ SOUNDMODE_STEREO, /* 1 */ SOUNDMODE_HEADSET, - /* 2 */ SOUNDMODE_SURROUND, + /* 2 */ SOUNDMODE_SURROUND_EXTERNAL, /* 3 */ SOUNDMODE_MONO, - /* 4 */ SOUNDMODE_SURROUND_EXTERNAL, + /* 4 */ SOUNDMODE_SURROUND, } SoundMode; typedef enum { @@ -1068,7 +1069,7 @@ typedef struct { /* 0x204 */ u16 unk_28; /* 0x206 */ u16 unk_250; /* 0x208 */ u16 unk_252; - /* 0x20A */ u16 unk_254; + /* 0x20A */ u16 seqId; /* 0x20C */ u16 unk_256; /* 0x20E */ u16 unk_258; /* 0x210 */ u8 unk_260; @@ -1080,7 +1081,7 @@ typedef struct { /* 0x219 */ u8 unk_4D; /* 0x21A */ u8 unk_4E; /* 0x21B */ u8 unk_21B; -} unk_D_8016E750; // size = 0x21C +} ActiveSequence; // size = 0x21C typedef struct { /* 0x0 */ u8 unk_0; @@ -1095,7 +1096,7 @@ typedef enum { /* 4 */ BANK_SYSTEM, /* 5 */ BANK_OCARINA, /* 6 */ BANK_VOICE -} SoundBankTypes; +} SfxBankType; typedef enum { /* 0 */ SFX_STATE_EMPTY, diff --git a/include/z64save.h b/include/z64save.h index 15984d45c3..df78cc169a 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -327,8 +327,8 @@ typedef struct SaveContext { /* 0x3EF8 */ s16 timerX[TIMER_ID_MAX]; // "event_xp" /* 0x3F06 */ s16 timerY[TIMER_ID_MAX]; // "event_yp" /* 0x3F14 */ s16 unk_3F14; // "character_change" - /* 0x3F16 */ u8 seqIndex; // "old_bgm" - /* 0x3F17 */ u8 nightSeqIndex; // "old_env" + /* 0x3F16 */ u8 seqId; // "old_bgm" + /* 0x3F17 */ u8 ambienceId; // "old_env" /* 0x3F18 */ u8 buttonStatus[6]; // "button_item" /* 0x3F1E */ u8 hudVisibilityForceButtonAlphasByStatus; // if btn alphas are updated through Interface_UpdateButtonAlphas, instead update them through Interface_UpdateButtonAlphasByStatus "ck_fg" /* 0x3F20 */ u16 nextHudVisibility; // triggers the hud to change visibility to the requested value. Reset to HUD_VISIBILITY_IDLE when target is reached "alpha_type" diff --git a/include/z64scene.h b/include/z64scene.h index 6b8849381b..18d7b81f98 100644 --- a/include/z64scene.h +++ b/include/z64scene.h @@ -153,16 +153,16 @@ typedef struct { typedef struct { /* 0x0 */ u8 code; - /* 0x1 */ u8 bgmId; - /* 0x2 */ UNK_TYPE1 pad2[4]; - /* 0x6 */ u8 nighttimeSFX; - /* 0x7 */ u8 musicSeq; + /* 0x1 */ u8 specId; + /* 0x2 */ UNK_TYPE1 unk_02[4]; + /* 0x6 */ u8 ambienceId; + /* 0x7 */ u8 seqId; } SCmdSoundSettings; // size = 0x8 typedef struct { /* 0x0 */ u8 code; /* 0x1 */ u8 data1; - /* 0x2 */ UNK_TYPE1 pad2[5]; + /* 0x2 */ UNK_TYPE1 unk_02[5]; /* 0x7 */ u8 echo; } SCmdEchoSettings; // size = 0x8 @@ -817,7 +817,7 @@ typedef enum { /* 0x1D */ SCENE_CMD_ID_UNUSED_1D, /* 0x1E */ SCENE_CMD_ID_MINIMAP_COMPASS_ICON_INFO, /* 0x1F */ SCENE_CMD_MAX -} SceneCommandTypeID; +} SceneCommandTypeId; #define SCENE_CMD_SPAWN_LIST(numSpawns, spawnList) \ { SCENE_CMD_ID_SPAWN_LIST, numSpawns, CMD_PTR(spawnList) } @@ -887,8 +887,8 @@ typedef enum { #define SCENE_CMD_END() \ { SCENE_CMD_ID_END, 0, CMD_W(0) } -#define SCENE_CMD_SOUND_SETTINGS(audioSessionId, nighttimeSfx, bgmId) \ - { SCENE_CMD_ID_SOUND_SETTINGS, audioSessionId, CMD_BBBB(0, 0, nighttimeSfx, bgmId) } +#define SCENE_CMD_SOUND_SETTINGS(specId, ambienceId, seqId) \ + { SCENE_CMD_ID_SOUND_SETTINGS, specId, CMD_BBBB(0, 0, ambienceId, seqId) } #define SCENE_CMD_ECHO_SETTINGS(echo) \ { SCENE_CMD_ID_ECHO_SETTINGS, 0, CMD_BBBB(0, 0, 0, echo) } diff --git a/src/code/audio/audio_seqplayer.c b/src/code/audio/audio_seqplayer.c index ea5c5ed5e4..a8573e33d2 100644 --- a/src/code/audio/audio_seqplayer.c +++ b/src/code/audio/audio_seqplayer.c @@ -315,7 +315,7 @@ void AudioSeq_InitSequenceChannel(SequenceChannel* channel) { channel->freqScale = 1.0f; for (i = 0; i < ARRAY_COUNT(channel->soundScriptIO); i++) { - channel->soundScriptIO[i] = -1; + channel->soundScriptIO[i] = SEQ_IO_VAL_NONE; } channel->unused = false; @@ -1791,12 +1791,12 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { case 0x10: // channel: load sample if (lowBits < 8) { - channel->soundScriptIO[lowBits] = -1; + channel->soundScriptIO[lowBits] = SEQ_IO_VAL_NONE; if (AudioLoad_SlowLoadSample(channel->fontId, scriptState->value, &channel->soundScriptIO[lowBits]) == -1) {} } else { lowBits -= 8; - channel->soundScriptIO[lowBits] = -1; + channel->soundScriptIO[lowBits] = SEQ_IO_VAL_NONE; if (AudioLoad_SlowLoadSample(channel->fontId, channel->unk_22 + 0x100, &channel->soundScriptIO[lowBits]) == -1) {} } @@ -1805,7 +1805,7 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { case 0x60: // channel: io read value scriptState->value = channel->soundScriptIO[lowBits]; if (lowBits < 2) { - channel->soundScriptIO[lowBits] = -1; + channel->soundScriptIO[lowBits] = SEQ_IO_VAL_NONE; } break; @@ -2150,7 +2150,7 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) { case 0x80: // seqPlayer: io read value seqScript->value = seqPlayer->soundScriptIO[cmdLowBits]; if (cmdLowBits < 2) { - seqPlayer->soundScriptIO[cmdLowBits] = -1; + seqPlayer->soundScriptIO[cmdLowBits] = SEQ_IO_VAL_NONE; } break; @@ -2286,7 +2286,7 @@ void AudioSeq_InitSequencePlayer(SequencePlayer* seqPlayer) { seqPlayer->applyBend = false; for (j = 0; j < ARRAY_COUNT(seqPlayer->soundScriptIO); j++) { - seqPlayer->soundScriptIO[j] = -1; + seqPlayer->soundScriptIO[j] = SEQ_IO_VAL_NONE; } seqPlayer->muteFlags = MUTE_FLAGS_SOFTEN | MUTE_FLAGS_STOP_NOTES; diff --git a/src/code/audio/code_8019AF00.c b/src/code/audio/code_8019AF00.c index b896facbc8..007d7ca856 100644 --- a/src/code/audio/code_8019AF00.c +++ b/src/code/audio/code_8019AF00.c @@ -5,12 +5,6 @@ typedef struct { /* 0x1 */ s8 y; } OcarinaControlStick; // size = 0x2 -typedef struct { - /* 0x0 */ u16 playerIO; - /* 0x2 */ u16 channelMask; - /* 0x4 */ u8 channelIO[3 * 33 + 1]; -} NatureAmbienceDataIO; // size = 0x68 - typedef struct { /* 0x0 */ Vec3f* pos; /* 0x4 */ f32 freqScale; @@ -67,8 +61,30 @@ typedef struct { } FreqLerp; // size = 0x10 s32 AudioOcarina_MemoryGameNextNote(void); + +void AudioSfx_ProcessSfxSettings(void); +void func_8019FEDC(void); +void Audio_StepFreqLerp(FreqLerp* lerp); + s32 Audio_SetGanonsTowerBgmVolume(u8 targetVolume); -void func_801A3238(s8 playerIndex, u16 seqId, u8 fadeTimer, s8 arg3, u8 arg4); + +void Audio_StartMorningSceneSequence(u16 seqId); +void Audio_StartSceneSequence(u16 seqId); +void Audio_PlaySequenceWithSeqPlayerIO(s8 playerIndex, u16 seqId, u8 fadeTimer, s8 arg3, u8 arg4); +void func_801A4428(u8 reverbIndex); +void func_801A3038(void); +void Audio_PlayAmbience(u8 ambienceId); +void Audio_SetSfxVolumeExceptSystemAndOcarinaBanks(u8 volume); + +void Audio_UpdateRiverSoundVolumes(void); +void func_801A1290(void); +void func_801A1904(void); +void func_801A1E0C(void); +void func_801A2090(void); +void Audio_UpdateSceneSequenceResumePoint(void); +void func_801A312C(void); +void func_801A3AC0(void); +void Audio_ResetRequestedSceneSeqId(void); // Sfx bss SfxSettings sSfxSettings[8]; @@ -90,7 +106,7 @@ u8 sGanonsTowerVol; f32* sSfxVolumeCur; f32 sSfxVolumeTarget; f32 sSfxVolumeRate; -u16 sSceneSeqId1; +u16 sRequestedSceneSeqId; SfxChannelState sSfxChannelState[16]; // Sequence bss @@ -99,7 +115,7 @@ u8 D_801FD3A9; u8 sRiverSoundBgmTimer; u8 sFanfareState; u16 sFanfareSeqId; -u8 sMuteOnlySfxAndNatureSeq; +u8 sMuteOnlySfxAndAmbienceSeq; u8 sAllPlayersMutedExceptOcaAndSys; u8 sAudioPauseState; u8 sSpatialSeqIsActive[4]; @@ -125,7 +141,7 @@ u8 sSpatialSubBgmFadeTimer; u8 D_801FD434; u8 sSpatialSeqPlayerIndex; u8 sSpatialSeqFadeTimer; -u16 D_801FD438; +u16 sPrevAmbienceSeqId; // AudioOcarina bss OcarinaStaff sPlayingStaff; @@ -202,11 +218,14 @@ s8 sAudioCodeReverb = 0; // Sequence Data u8 sPrevSeqMode = 0; -f32 sAudioEnemyDist = 0.0f; -s8 sAudioEnemyVol = 127; +f32 sBgmEnemyDist = 0.0f; +s8 sBgmEnemyVolume = 127; u16 sPrevMainBgmSeqId = NA_BGM_DISABLED; -u8 sBgmPlayerIOPort7 = 0; -u8 sSceneSeqId2 = NA_BGM_GENERAL_SFX; + +#define SEQ_RESUME_POINT_NONE 0xC0 +u8 sSeqResumePoint = 0; +u8 sPrevSceneSeqId = NA_BGM_GENERAL_SFX; + u32 sNumFramesStill = 0; u32 sNumFramesMoving = 0; u8 sAudioBaseFilter = 0; @@ -217,768 +236,893 @@ s8 gUnderwaterSfxReverbAdd = 0; Vec3f* sRiverSoundBgmPos = NULL; f32 sRiverSoundXZDistToPlayer = 2000.0f; u8 sObjSoundMainBgmSeqId = NA_BGM_GENERAL_SFX; + +// Allows enemy bgm +#define SEQ_FLAG_ENEMY (1 << 0) + +#define SEQ_FLAG_FANFARE (1 << 1) +#define SEQ_FLAG_FANFARE_KAMARO (1 << 2) + +// required for Audio_RestorePrevBgm to restore a sequence after Audio_PlayBgm_StorePrevBgm +#define SEQ_FLAG_RESTORE (1 << 3) + +/** + * These two sequence flags work together to implement a “resume playing from where you left off” system for scene + * sequences when leaving and returning to a scene. For a scene to resume playing from the point where it left off, it + * must have `SEQ_FLAG_RESUME` attached to it. Then, if the scene changes and the new scene sequence contain + * `SEQ_FLAG_RESUME_PREV`, the point from the previous scene sequence will be stored. Then, when returning to the + * scene with the sequence `SEQ_FLAG_RESUME`, then the sequence will resume playing from where it left off. + * + * TODO: Confirm which sequences properly implement this system after sequence extraction + */ +#define SEQ_FLAG_RESUME (1 << 4) +#define SEQ_FLAG_RESUME_PREV (1 << 5) + +/** + * Will write a value of 1 to ioPort 7 when called through the scene. How it's used depends on the sequence: + * NA_BGM_FILE_SELECT - ioPort 7 skips the harp intro when a value of 1 is written to it. + */ +#define SEQ_FLAG_SKIP_HARP_INTRO (1 << 6) + +// Unused, repurposed for SubBgm +#define SEQ_FLAG_NO_AMBIENCE (1 << 7) + u8 sSeqFlags[] = { - 0x3, // NA_BGM_GENERAL_SFX - 0x1, // NA_BGM_NATURE_AMBIENCE - 0x1, // NA_BGM_TERMINA_FIELD - 0x8, // NA_BGM_CHASE - 0, // NA_BGM_MAJORAS_THEME - 0, // NA_BGM_CLOCK_TOWER - 0x1, // NA_BGM_STONE_TOWER_TEMPLE - 0x1, // NA_BGM_INV_STONE_TOWER_TEMPLE - 0x2, // NA_BGM_FAILURE_0 - 0x2, // NA_BGM_FAILURE_1 - 0, // NA_BGM_HAPPY_MASK_SALESMAN - 0, // NA_BGM_SONG_OF_HEALING - 0x1, // NA_BGM_SWAMP_REGION - 0, // NA_BGM_ALIEN_INVASION - 0x2, // NA_BGM_SWAMP_CRUISE - 0, // NA_BGM_SHARPS_CURSE - 0x1, // NA_BGM_GREAT_BAY_REGION - 0x1, // NA_BGM_IKANA_REGION - 0, // NA_BGM_DEKU_KING - 0x1, // NA_BGM_MOUNTAIN_REGION - 0, // NA_BGM_PIRATES_FORTRESS - 0, // NA_BGM_CLOCK_TOWN_DAY_1 - 0, // NA_BGM_CLOCK_TOWN_DAY_2 - 0, // NA_BGM_CLOCK_TOWN_DAY_3 - 0x40, // NA_BGM_FILE_SELECT - 0x10, // NA_BGM_CLEAR_EVENT - 0, // NA_BGM_ENEMY - 0x8, // NA_BGM_BOSS - 0x1, // NA_BGM_WOODFALL_TEMPLE - 0, // NA_BGM_MARKET - 0, // NA_BGM_OPENING - 0x20, // NA_BGM_INSIDE_A_HOUSE - 0x2, // NA_BGM_GAME_OVER - 0, // NA_BGM_CLEAR_BOSS - 0x2, // NA_BGM_GET_ITEM - 0x2, // NA_BGM_GATE_OPEN - 0x2, // NA_BGM_GET_HEART - 0x8, // NA_BGM_TIMED_MINI_GAME - 0, // NA_BGM_GORON_RACE - 0, // NA_BGM_MUSIC_BOX_HOUSE - 0, // NA_BGM_FAIRY_FOUNTAIN - 0, // NA_BGM_ZELDAS_LULLABY - 0, // NA_BGM_ROSA_SISTERS - 0x2, // NA_BGM_OPEN_CHEST - 0, // NA_BGM_MARINE_RESEARCH_LAB - 0x40, // NA_BGM_GIANTS_THEME - 0, // NA_BGM_SONG_OF_STORMS - 0, // NA_BGM_ROMANI_RANCH - 0, // NA_BGM_GORON_VILLAGE - 0, // NA_BGM_MAYORS_OFFICE - 0x2, // NA_BGM_OCA_EPONA - 0x2, // NA_BGM_OCA_SUNS - 0x2, // NA_BGM_OCA_TIME - 0x2, // NA_BGM_OCA_STORM - 0x10, // NA_BGM_ZORA_HALL - 0x2, // NA_BGM_GET_NEW_MASK - 0x8, // NA_BGM_MINI_BOSS - 0x2, // NA_BGM_GET_SMALL_ITEM - 0, // NA_BGM_ASTRAL_OBSERVATORY - 0x1, // NA_BGM_CAVERN - 0x11, // NA_BGM_MILK_BAR - 0x2, // NA_BGM_ZELDA_APPEAR - 0, // NA_BGM_SARIAS_SONG - 0, // NA_BGM_GORON_GOAL - 0, // NA_BGM_HORSE - 0, // NA_BGM_HORSE_GOAL - 0, // NA_BGM_INGO - 0, // NA_BGM_KOTAKE_POTION_SHOP - 0x20, // NA_BGM_SHOP - 0x2, // NA_BGM_OWL - 0x20, // NA_BGM_MINI_GAME - 0x2, // NA_BGM_OCA_SOARING - 0x2, // NA_BGM_OCA_HEALING - 0x2, // NA_BGM_INVERTED_SONG_OF_TIME - 0x2, // NA_BGM_SONG_OF_DOUBLE_TIME - 0x2, // NA_BGM_SONATA_OF_AWAKENING - 0x2, // NA_BGM_GORON_LULLABY - 0x2, // NA_BGM_NEW_WAVE_BOSSA_NOVA - 0x2, // NA_BGM_ELEGY_OF_EMPTINESS - 0x2, // NA_BGM_OATH_TO_ORDER - 0, // NA_BGM_SWORD_TRAINING_HALL - 0x2, // NA_BGM_GORON_LULLABY_INTRO - 0x2, // NA_BGM_OCA_FAIRY - 0x2, // NA_BGM_BREMEN_MARCH - 0x2, // NA_BGM_BALLAD_OF_THE_WIND_FISH - 0x8, // NA_BGM_SONG_OF_SOARING - 0, // NA_BGM_MILK_BAR_DUPLICATE - 0, // NA_BGM_FINAL_HOURS - 0x2, // NA_BGM_MIKAU_RIFF - 0x2, // NA_BGM_MIKAU_FINALE - 0, // NA_BGM_FROG_SONG - 0x2, // NA_BGM_OCA_SONATA - 0x2, // NA_BGM_OCA_LULLABY - 0x2, // NA_BGM_OCA_NEW_WAVE - 0x2, // NA_BGM_OCA_ELEGY - 0x2, // NA_BGM_OCA_OATH - 0, // NA_BGM_MAJORAS_LAIR - 0x2, // NA_BGM_OCA_LULLABY_INTRO - 0x2, // NA_BGM_OCA_GUITAR_BASS_SESSION - 0x2, // NA_BGM_PIANO_SESSION - 0x2, // NA_BGM_INDIGO_GO_SESSION - 0x1, // NA_BGM_SNOWHEAD_TEMPLE - 0x1, // NA_BGM_GREAT_BAY_TEMPLE - 0x2, // NA_BGM_NEW_WAVE_SAXOPHONE - 0x2, // NA_BGM_NEW_WAVE_VOCAL - 0, // NA_BGM_MAJORAS_WRATH - 0, // NA_BGM_MAJORAS_INCARNATION - 0, // NA_BGM_MAJORAS_MASK - 0x2, // NA_BGM_BASS_PLAY - 0x2, // NA_BGM_DRUMS_PLAY - 0x2, // NA_BGM_PIANO_PLAY - 0x1, // NA_BGM_IKANA_CASTLE - 0, // NA_BGM_GATHERING_GIANTS - 0x4, // NA_BGM_KAMARO_DANCE - 0, // NA_BGM_CREMIA_CARRIAGE - 0x2, // NA_BGM_KEATON_QUIZ - 0, // NA_BGM_END_CREDITS_1 - 0, // NA_BGM_OPENING_LOOP - 0, // NA_BGM_TITLE_THEME - 0x2, // NA_BGM_DUNGEON_APPEAR - 0x2, // NA_BGM_WOODFALL_CLEAR - 0x2, // NA_BGM_SNOWHEAD_CLEAR - 0, // - 0, // NA_BGM_INTO_THE_MOON - 0, // NA_BGM_GOODBYE_GIANT - 0, // NA_BGM_TATL_AND_TAEL - 0, // NA_BGM_MOONS_DESTRUCTION - 0, // NA_BGM_END_CREDITS_2 + SEQ_FLAG_FANFARE | SEQ_FLAG_ENEMY, // NA_BGM_GENERAL_SFX + SEQ_FLAG_ENEMY, // NA_BGM_AMBIENCE + SEQ_FLAG_ENEMY, // NA_BGM_TERMINA_FIELD + SEQ_FLAG_RESTORE, // NA_BGM_CHASE + 0, // NA_BGM_MAJORAS_THEME + 0, // NA_BGM_CLOCK_TOWER + SEQ_FLAG_ENEMY, // NA_BGM_STONE_TOWER_TEMPLE + SEQ_FLAG_ENEMY, // NA_BGM_INV_STONE_TOWER_TEMPLE + SEQ_FLAG_FANFARE, // NA_BGM_FAILURE_0 + SEQ_FLAG_FANFARE, // NA_BGM_FAILURE_1 + 0, // NA_BGM_HAPPY_MASK_SALESMAN + 0, // NA_BGM_SONG_OF_HEALING + SEQ_FLAG_ENEMY, // NA_BGM_SWAMP_REGION + 0, // NA_BGM_ALIEN_INVASION + SEQ_FLAG_FANFARE, // NA_BGM_SWAMP_CRUISE + 0, // NA_BGM_SHARPS_CURSE + SEQ_FLAG_ENEMY, // NA_BGM_GREAT_BAY_REGION + SEQ_FLAG_ENEMY, // NA_BGM_IKANA_REGION + 0, // NA_BGM_DEKU_KING + SEQ_FLAG_ENEMY, // NA_BGM_MOUNTAIN_REGION + 0, // NA_BGM_PIRATES_FORTRESS + 0, // NA_BGM_CLOCK_TOWN_DAY_1 + 0, // NA_BGM_CLOCK_TOWN_DAY_2 + 0, // NA_BGM_CLOCK_TOWN_DAY_3 + SEQ_FLAG_SKIP_HARP_INTRO, // NA_BGM_FILE_SELECT + SEQ_FLAG_RESUME, // NA_BGM_CLEAR_EVENT + 0, // NA_BGM_ENEMY + SEQ_FLAG_RESTORE, // NA_BGM_BOSS + SEQ_FLAG_ENEMY, // NA_BGM_WOODFALL_TEMPLE + 0, // NA_BGM_MARKET + 0, // NA_BGM_OPENING + SEQ_FLAG_RESUME_PREV, // NA_BGM_INSIDE_A_HOUSE + SEQ_FLAG_FANFARE, // NA_BGM_GAME_OVER + 0, // NA_BGM_CLEAR_BOSS + SEQ_FLAG_FANFARE, // NA_BGM_GET_ITEM + SEQ_FLAG_FANFARE, // NA_BGM_GATE_OPEN + SEQ_FLAG_FANFARE, // NA_BGM_GET_HEART + SEQ_FLAG_RESTORE, // NA_BGM_TIMED_MINI_GAME + 0, // NA_BGM_GORON_RACE + 0, // NA_BGM_MUSIC_BOX_HOUSE + 0, // NA_BGM_FAIRY_FOUNTAIN + 0, // NA_BGM_ZELDAS_LULLABY + 0, // NA_BGM_ROSA_SISTERS + SEQ_FLAG_FANFARE, // NA_BGM_OPEN_CHEST + 0, // NA_BGM_MARINE_RESEARCH_LAB + SEQ_FLAG_SKIP_HARP_INTRO, // NA_BGM_GIANTS_THEME + 0, // NA_BGM_SONG_OF_STORMS + 0, // NA_BGM_ROMANI_RANCH + 0, // NA_BGM_GORON_VILLAGE + 0, // NA_BGM_MAYORS_OFFICE + SEQ_FLAG_FANFARE, // NA_BGM_OCA_EPONA + SEQ_FLAG_FANFARE, // NA_BGM_OCA_SUNS + SEQ_FLAG_FANFARE, // NA_BGM_OCA_TIME + SEQ_FLAG_FANFARE, // NA_BGM_OCA_STORM + SEQ_FLAG_RESUME, // NA_BGM_ZORA_HALL + SEQ_FLAG_FANFARE, // NA_BGM_GET_NEW_MASK + SEQ_FLAG_RESTORE, // NA_BGM_MINI_BOSS + SEQ_FLAG_FANFARE, // NA_BGM_GET_SMALL_ITEM + 0, // NA_BGM_ASTRAL_OBSERVATORY + SEQ_FLAG_ENEMY, // NA_BGM_CAVERN + SEQ_FLAG_RESUME | SEQ_FLAG_ENEMY, // NA_BGM_MILK_BAR + SEQ_FLAG_FANFARE, // NA_BGM_ZELDA_APPEAR + 0, // NA_BGM_SARIAS_SONG + 0, // NA_BGM_GORON_GOAL + 0, // NA_BGM_HORSE + 0, // NA_BGM_HORSE_GOAL + 0, // NA_BGM_INGO + 0, // NA_BGM_KOTAKE_POTION_SHOP + SEQ_FLAG_RESUME_PREV, // NA_BGM_SHOP + SEQ_FLAG_FANFARE, // NA_BGM_OWL + SEQ_FLAG_RESUME_PREV, // NA_BGM_MINI_GAME + SEQ_FLAG_FANFARE, // NA_BGM_OCA_SOARING + SEQ_FLAG_FANFARE, // NA_BGM_OCA_HEALING + SEQ_FLAG_FANFARE, // NA_BGM_INVERTED_SONG_OF_TIME + SEQ_FLAG_FANFARE, // NA_BGM_SONG_OF_DOUBLE_TIME + SEQ_FLAG_FANFARE, // NA_BGM_SONATA_OF_AWAKENING + SEQ_FLAG_FANFARE, // NA_BGM_GORON_LULLABY + SEQ_FLAG_FANFARE, // NA_BGM_NEW_WAVE_BOSSA_NOVA + SEQ_FLAG_FANFARE, // NA_BGM_ELEGY_OF_EMPTINESS + SEQ_FLAG_FANFARE, // NA_BGM_OATH_TO_ORDER + 0, // NA_BGM_SWORD_TRAINING_HALL + SEQ_FLAG_FANFARE, // NA_BGM_GORON_LULLABY_INTRO + SEQ_FLAG_FANFARE, // NA_BGM_OCA_FAIRY + SEQ_FLAG_FANFARE, // NA_BGM_BREMEN_MARCH + SEQ_FLAG_FANFARE, // NA_BGM_BALLAD_OF_THE_WIND_FISH + SEQ_FLAG_RESTORE, // NA_BGM_SONG_OF_SOARING + 0, // NA_BGM_MILK_BAR_DUPLICATE + 0, // NA_BGM_FINAL_HOURS + SEQ_FLAG_FANFARE, // NA_BGM_MIKAU_RIFF + SEQ_FLAG_FANFARE, // NA_BGM_MIKAU_FINALE + 0, // NA_BGM_FROG_SONG + SEQ_FLAG_FANFARE, // NA_BGM_OCA_SONATA + SEQ_FLAG_FANFARE, // NA_BGM_OCA_LULLABY + SEQ_FLAG_FANFARE, // NA_BGM_OCA_NEW_WAVE + SEQ_FLAG_FANFARE, // NA_BGM_OCA_ELEGY + SEQ_FLAG_FANFARE, // NA_BGM_OCA_OATH + 0, // NA_BGM_MAJORAS_LAIR + SEQ_FLAG_FANFARE, // NA_BGM_OCA_LULLABY_INTRO + SEQ_FLAG_FANFARE, // NA_BGM_OCA_GUITAR_BASS_SESSION + SEQ_FLAG_FANFARE, // NA_BGM_PIANO_SESSION + SEQ_FLAG_FANFARE, // NA_BGM_INDIGO_GO_SESSION + SEQ_FLAG_ENEMY, // NA_BGM_SNOWHEAD_TEMPLE + SEQ_FLAG_ENEMY, // NA_BGM_GREAT_BAY_TEMPLE + SEQ_FLAG_FANFARE, // NA_BGM_NEW_WAVE_SAXOPHONE + SEQ_FLAG_FANFARE, // NA_BGM_NEW_WAVE_VOCAL + 0, // NA_BGM_MAJORAS_WRATH + 0, // NA_BGM_MAJORAS_INCARNATION + 0, // NA_BGM_MAJORAS_MASK + SEQ_FLAG_FANFARE, // NA_BGM_BASS_PLAY + SEQ_FLAG_FANFARE, // NA_BGM_DRUMS_PLAY + SEQ_FLAG_FANFARE, // NA_BGM_PIANO_PLAY + SEQ_FLAG_ENEMY, // NA_BGM_IKANA_CASTLE + 0, // NA_BGM_GATHERING_GIANTS + SEQ_FLAG_FANFARE_KAMARO, // NA_BGM_KAMARO_DANCE + 0, // NA_BGM_CREMIA_CARRIAGE + SEQ_FLAG_FANFARE, // NA_BGM_KEATON_QUIZ + 0, // NA_BGM_END_CREDITS_1 + 0, // NA_BGM_OPENING_LOOP + 0, // NA_BGM_TITLE_THEME + SEQ_FLAG_FANFARE, // NA_BGM_DUNGEON_APPEAR + SEQ_FLAG_FANFARE, // NA_BGM_WOODFALL_CLEAR + SEQ_FLAG_FANFARE, // NA_BGM_SNOWHEAD_CLEAR + 0, // + 0, // NA_BGM_INTO_THE_MOON + 0, // NA_BGM_GOODBYE_GIANT + 0, // NA_BGM_TATL_AND_TAEL + 0, // NA_BGM_MOONS_DESTRUCTION + 0, // NA_BGM_END_CREDITS_2 }; -s8 sSpecReverbs[20] = { +s8 sSpecReverbs[] = { 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; -NatureAmbienceDataIO sNatureAmbienceData[20] = { - // natureSeqId: 0 +#define AMBIENCE_CHANNEL_PROPERTIES_ENTRIES_MAX 33 + +typedef struct { + /* 0x0 */ u16 initChannelMask; // bitwise flag for 16 channels, channels to initialize + /* 0x2 */ u16 initMuteChannelMask; // bitwise flag for 16 channels, channels to mute upon initialization + /* 0x4 */ u8 channelProperties[3 * AMBIENCE_CHANNEL_PROPERTIES_ENTRIES_MAX + 1]; +} AmbienceDataIO; // size = 0x68 + +AmbienceDataIO sAmbienceData[20] = { + // AMBIENCE_ID_00 { - 0xC0FF, // PlayerIO Data - 0xC0FE, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | + (1 << AMBIENCE_CHANNEL_CRITTER_2) | (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | + (1 << AMBIENCE_CHANNEL_CRITTER_5) | (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | (1 << AMBIENCE_CHANNEL_CRITTER_2) | + (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | (1 << AMBIENCE_CHANNEL_CRITTER_5) | + (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_IO_STREAM_0_PORT3(0), // Channel 1 - NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_09), - NATURE_IO_CRITTER_0_BEND_PITCH(64), - NATURE_IO_CRITTER_0_NUM_LAYERS(0), - NATURE_IO_CRITTER_0_PORT5(32), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_09), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(64), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_0_PORT5(32), // Channel 2 - NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_04), - NATURE_IO_CRITTER_1_BEND_PITCH(0), - NATURE_IO_CRITTER_1_NUM_LAYERS(1), - NATURE_IO_CRITTER_1_PORT5(16), + AMBIENCE_IO_CRITTER_1_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_1_BEND_PITCH(0), + AMBIENCE_IO_CRITTER_1_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_1_PORT5(16), // Channel 3 - NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_10), - NATURE_IO_CRITTER_2_BEND_PITCH(112), - NATURE_IO_CRITTER_2_NUM_LAYERS(1), - NATURE_IO_CRITTER_2_PORT5(48), + AMBIENCE_IO_CRITTER_2_TYPE(AMBIENCE_CRITTER_10), + AMBIENCE_IO_CRITTER_2_BEND_PITCH(112), + AMBIENCE_IO_CRITTER_2_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_2_PORT5(48), // Channel 4 - NATURE_IO_CRITTER_3_TYPE(NATURE_CRITTER_03), - NATURE_IO_CRITTER_3_BEND_PITCH(127), - NATURE_IO_CRITTER_3_NUM_LAYERS(0), - NATURE_IO_CRITTER_3_PORT5(16), + AMBIENCE_IO_CRITTER_3_TYPE(AMBIENCE_CRITTER_03), + AMBIENCE_IO_CRITTER_3_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_3_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_3_PORT5(16), // Channel 5 - NATURE_IO_CRITTER_4_TYPE(NATURE_CRITTER_00), - NATURE_IO_CRITTER_4_BEND_PITCH(127), - NATURE_IO_CRITTER_4_NUM_LAYERS(1), - NATURE_IO_CRITTER_4_PORT5(16), + AMBIENCE_IO_CRITTER_4_TYPE(AMBIENCE_CRITTER_00), + AMBIENCE_IO_CRITTER_4_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_4_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_4_PORT5(16), // Channel 6 - NATURE_IO_CRITTER_5_TYPE(NATURE_CRITTER_01), - NATURE_IO_CRITTER_5_BEND_PITCH(127), - NATURE_IO_CRITTER_5_NUM_LAYERS(3), - NATURE_IO_CRITTER_5_PORT5(16), + AMBIENCE_IO_CRITTER_5_TYPE(AMBIENCE_CRITTER_01), + AMBIENCE_IO_CRITTER_5_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_5_NUM_LAYERS(3), + AMBIENCE_IO_CRITTER_5_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 1 + // AMBIENCE_ID_01 { - 0xC0FF, // PlayerIO Data - 0xC0FE, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | + (1 << AMBIENCE_CHANNEL_CRITTER_2) | (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | + (1 << AMBIENCE_CHANNEL_CRITTER_5) | (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | (1 << AMBIENCE_CHANNEL_CRITTER_2) | + (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | (1 << AMBIENCE_CHANNEL_CRITTER_5) | + (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_IO_STREAM_0_PORT3(0), // Channel 1 - NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), - NATURE_IO_CRITTER_0_BEND_PITCH(64), - NATURE_IO_CRITTER_0_NUM_LAYERS(0), - NATURE_IO_CRITTER_0_PORT5(32), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(64), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_0_PORT5(32), // Channel 2 - NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_16), - NATURE_IO_CRITTER_1_BEND_PITCH(0), - NATURE_IO_CRITTER_1_NUM_LAYERS(1), - NATURE_IO_CRITTER_1_PORT5(16), + AMBIENCE_IO_CRITTER_1_TYPE(AMBIENCE_CRITTER_16), + AMBIENCE_IO_CRITTER_1_BEND_PITCH(0), + AMBIENCE_IO_CRITTER_1_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_1_PORT5(16), // Channel 3 - NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_12), - NATURE_IO_CRITTER_2_BEND_PITCH(112), - NATURE_IO_CRITTER_2_NUM_LAYERS(0), - NATURE_IO_CRITTER_2_PORT5(48), + AMBIENCE_IO_CRITTER_2_TYPE(AMBIENCE_CRITTER_12), + AMBIENCE_IO_CRITTER_2_BEND_PITCH(112), + AMBIENCE_IO_CRITTER_2_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_2_PORT5(48), // Channel 4 - NATURE_IO_CRITTER_3_TYPE(NATURE_CRITTER_15), - NATURE_IO_CRITTER_3_BEND_PITCH(127), - NATURE_IO_CRITTER_3_NUM_LAYERS(1), - NATURE_IO_CRITTER_3_PORT5(16), + AMBIENCE_IO_CRITTER_3_TYPE(AMBIENCE_CRITTER_15), + AMBIENCE_IO_CRITTER_3_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_3_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_3_PORT5(16), // Channel 5 - NATURE_IO_CRITTER_4_TYPE(NATURE_CRITTER_06), - NATURE_IO_CRITTER_4_BEND_PITCH(127), - NATURE_IO_CRITTER_4_NUM_LAYERS(1), - NATURE_IO_CRITTER_4_PORT5(16), + AMBIENCE_IO_CRITTER_4_TYPE(AMBIENCE_CRITTER_06), + AMBIENCE_IO_CRITTER_4_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_4_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_4_PORT5(16), // Channel 6 - NATURE_IO_CRITTER_5_TYPE(NATURE_CRITTER_01), - NATURE_IO_CRITTER_5_BEND_PITCH(127), - NATURE_IO_CRITTER_5_NUM_LAYERS(3), - NATURE_IO_CRITTER_5_PORT5(16), + AMBIENCE_IO_CRITTER_5_TYPE(AMBIENCE_CRITTER_01), + AMBIENCE_IO_CRITTER_5_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_5_NUM_LAYERS(3), + AMBIENCE_IO_CRITTER_5_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 2 + // AMBIENCE_ID_02 { - 0xC0FF, // PlayerIO Data - 0xC0FE, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | + (1 << AMBIENCE_CHANNEL_CRITTER_2) | (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | + (1 << AMBIENCE_CHANNEL_CRITTER_5) | (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | (1 << AMBIENCE_CHANNEL_CRITTER_2) | + (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | (1 << AMBIENCE_CHANNEL_CRITTER_5) | + (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_IO_STREAM_0_PORT3(0), // Channel 1 - NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), - NATURE_IO_CRITTER_0_BEND_PITCH(64), - NATURE_IO_CRITTER_0_NUM_LAYERS(0), - NATURE_IO_CRITTER_0_PORT5(48), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(64), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_0_PORT5(48), // Channel 2 - NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_10), - NATURE_IO_CRITTER_1_BEND_PITCH(0), - NATURE_IO_CRITTER_1_NUM_LAYERS(1), - NATURE_IO_CRITTER_1_PORT5(16), + AMBIENCE_IO_CRITTER_1_TYPE(AMBIENCE_CRITTER_10), + AMBIENCE_IO_CRITTER_1_BEND_PITCH(0), + AMBIENCE_IO_CRITTER_1_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_1_PORT5(16), // Channel 3 - NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_04), - NATURE_IO_CRITTER_2_BEND_PITCH(48), - NATURE_IO_CRITTER_2_NUM_LAYERS(1), - NATURE_IO_CRITTER_2_PORT5(32), + AMBIENCE_IO_CRITTER_2_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_2_BEND_PITCH(48), + AMBIENCE_IO_CRITTER_2_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_2_PORT5(32), // Channel 4 - NATURE_IO_CRITTER_3_TYPE(NATURE_CRITTER_03), - NATURE_IO_CRITTER_3_BEND_PITCH(127), - NATURE_IO_CRITTER_3_NUM_LAYERS(0), - NATURE_IO_CRITTER_3_PORT5(16), + AMBIENCE_IO_CRITTER_3_TYPE(AMBIENCE_CRITTER_03), + AMBIENCE_IO_CRITTER_3_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_3_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_3_PORT5(16), // Channel 5 - NATURE_IO_CRITTER_4_TYPE(NATURE_CRITTER_01), - NATURE_IO_CRITTER_4_BEND_PITCH(64), - NATURE_IO_CRITTER_4_NUM_LAYERS(1), - NATURE_IO_CRITTER_4_PORT5(0), + AMBIENCE_IO_CRITTER_4_TYPE(AMBIENCE_CRITTER_01), + AMBIENCE_IO_CRITTER_4_BEND_PITCH(64), + AMBIENCE_IO_CRITTER_4_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_4_PORT5(0), // Channel 6 - NATURE_IO_CRITTER_5_TYPE(NATURE_CRITTER_04), - NATURE_IO_CRITTER_5_BEND_PITCH(127), - NATURE_IO_CRITTER_5_NUM_LAYERS(0), - NATURE_IO_CRITTER_5_PORT5(63), + AMBIENCE_IO_CRITTER_5_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_5_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_5_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_5_PORT5(63), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 3 + // AMBIENCE_ID_03 { - 0xC0FF, // PlayerIO Data - 0xC0FE, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | + (1 << AMBIENCE_CHANNEL_CRITTER_2) | (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | + (1 << AMBIENCE_CHANNEL_CRITTER_5) | (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | (1 << AMBIENCE_CHANNEL_CRITTER_2) | + (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | (1 << AMBIENCE_CHANNEL_CRITTER_5) | + (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_IO_STREAM_0_PORT3(0), // Channel 1 - NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_09), - NATURE_IO_CRITTER_0_BEND_PITCH(64), - NATURE_IO_CRITTER_0_NUM_LAYERS(0), - NATURE_IO_CRITTER_0_PORT5(32), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_09), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(64), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_0_PORT5(32), // Channel 2 - NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_04), - NATURE_IO_CRITTER_1_BEND_PITCH(64), - NATURE_IO_CRITTER_1_NUM_LAYERS(0), - NATURE_IO_CRITTER_1_PORT5(48), + AMBIENCE_IO_CRITTER_1_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_1_BEND_PITCH(64), + AMBIENCE_IO_CRITTER_1_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_1_PORT5(48), // Channel 3 - NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_10), - NATURE_IO_CRITTER_2_BEND_PITCH(32), - NATURE_IO_CRITTER_2_NUM_LAYERS(1), - NATURE_IO_CRITTER_2_PORT5(32), + AMBIENCE_IO_CRITTER_2_TYPE(AMBIENCE_CRITTER_10), + AMBIENCE_IO_CRITTER_2_BEND_PITCH(32), + AMBIENCE_IO_CRITTER_2_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_2_PORT5(32), // Channel 4 - NATURE_IO_CRITTER_3_TYPE(NATURE_CRITTER_14), - NATURE_IO_CRITTER_3_BEND_PITCH(64), - NATURE_IO_CRITTER_3_NUM_LAYERS(1), - NATURE_IO_CRITTER_3_PORT5(16), + AMBIENCE_IO_CRITTER_3_TYPE(AMBIENCE_CRITTER_14), + AMBIENCE_IO_CRITTER_3_BEND_PITCH(64), + AMBIENCE_IO_CRITTER_3_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_3_PORT5(16), // Channel 5 - NATURE_IO_CRITTER_4_TYPE(NATURE_CRITTER_00), - NATURE_IO_CRITTER_4_BEND_PITCH(127), - NATURE_IO_CRITTER_4_NUM_LAYERS(1), - NATURE_IO_CRITTER_4_PORT5(16), + AMBIENCE_IO_CRITTER_4_TYPE(AMBIENCE_CRITTER_00), + AMBIENCE_IO_CRITTER_4_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_4_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_4_PORT5(16), // Channel 6 - NATURE_IO_CRITTER_5_TYPE(NATURE_CRITTER_01), - NATURE_IO_CRITTER_5_BEND_PITCH(127), - NATURE_IO_CRITTER_5_NUM_LAYERS(3), - NATURE_IO_CRITTER_5_PORT5(16), + AMBIENCE_IO_CRITTER_5_TYPE(AMBIENCE_CRITTER_01), + AMBIENCE_IO_CRITTER_5_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_5_NUM_LAYERS(3), + AMBIENCE_IO_CRITTER_5_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 4 + // AMBIENCE_ID_04 { - 0xC0FF, // PlayerIO Data - 0xC0FE, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | + (1 << AMBIENCE_CHANNEL_CRITTER_2) | (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | + (1 << AMBIENCE_CHANNEL_CRITTER_5) | (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | (1 << AMBIENCE_CHANNEL_CRITTER_2) | + (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | (1 << AMBIENCE_CHANNEL_CRITTER_5) | + (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(0), + AMBIENCE_IO_STREAM_0_PORT3(0), // Channel 1 - NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), - NATURE_IO_CRITTER_0_BEND_PITCH(64), - NATURE_IO_CRITTER_0_NUM_LAYERS(0), - NATURE_IO_CRITTER_0_PORT5(32), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(64), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_0_PORT5(32), // Channel 2 - NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_02), - NATURE_IO_CRITTER_1_BEND_PITCH(64), - NATURE_IO_CRITTER_1_NUM_LAYERS(1), - NATURE_IO_CRITTER_1_PORT5(16), + AMBIENCE_IO_CRITTER_1_TYPE(AMBIENCE_CRITTER_02), + AMBIENCE_IO_CRITTER_1_BEND_PITCH(64), + AMBIENCE_IO_CRITTER_1_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_1_PORT5(16), // Channel 3 - NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_12), - NATURE_IO_CRITTER_2_BEND_PITCH(112), - NATURE_IO_CRITTER_2_NUM_LAYERS(1), - NATURE_IO_CRITTER_2_PORT5(48), + AMBIENCE_IO_CRITTER_2_TYPE(AMBIENCE_CRITTER_12), + AMBIENCE_IO_CRITTER_2_BEND_PITCH(112), + AMBIENCE_IO_CRITTER_2_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_2_PORT5(48), // Channel 4 - NATURE_IO_CRITTER_3_TYPE(NATURE_CRITTER_13), - NATURE_IO_CRITTER_3_BEND_PITCH(64), - NATURE_IO_CRITTER_3_NUM_LAYERS(1), - NATURE_IO_CRITTER_3_PORT5(16), + AMBIENCE_IO_CRITTER_3_TYPE(AMBIENCE_CRITTER_13), + AMBIENCE_IO_CRITTER_3_BEND_PITCH(64), + AMBIENCE_IO_CRITTER_3_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_3_PORT5(16), // Channel 5 - NATURE_IO_CRITTER_4_TYPE(NATURE_CRITTER_01), - NATURE_IO_CRITTER_4_BEND_PITCH(64), - NATURE_IO_CRITTER_4_NUM_LAYERS(1), - NATURE_IO_CRITTER_4_PORT5(16), + AMBIENCE_IO_CRITTER_4_TYPE(AMBIENCE_CRITTER_01), + AMBIENCE_IO_CRITTER_4_BEND_PITCH(64), + AMBIENCE_IO_CRITTER_4_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_4_PORT5(16), // Channel 6 - NATURE_IO_CRITTER_5_TYPE(NATURE_CRITTER_02), - NATURE_IO_CRITTER_5_BEND_PITCH(112), - NATURE_IO_CRITTER_5_NUM_LAYERS(0), - NATURE_IO_CRITTER_5_PORT5(48), + AMBIENCE_IO_CRITTER_5_TYPE(AMBIENCE_CRITTER_02), + AMBIENCE_IO_CRITTER_5_BEND_PITCH(112), + AMBIENCE_IO_CRITTER_5_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_5_PORT5(48), // Channel 14 - NATURE_IO_RAIN_PORT4(63), + AMBIENCE_IO_RAIN_PORT4(63), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 5 + // AMBIENCE_ID_05 { - 0xC0FF, // PlayerIO Data - 0xC0FE, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | + (1 << AMBIENCE_CHANNEL_CRITTER_2) | (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | + (1 << AMBIENCE_CHANNEL_CRITTER_5) | (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | (1 << AMBIENCE_CHANNEL_CRITTER_2) | + (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | (1 << AMBIENCE_CHANNEL_CRITTER_5) | + (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_IO_STREAM_0_PORT3(0), // Channel 1 - NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_09), - NATURE_IO_CRITTER_0_BEND_PITCH(64), - NATURE_IO_CRITTER_0_NUM_LAYERS(0), - NATURE_IO_CRITTER_0_PORT5(32), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_09), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(64), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_0_PORT5(32), // Channel 2 - NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_04), - NATURE_IO_CRITTER_1_BEND_PITCH(0), - NATURE_IO_CRITTER_1_NUM_LAYERS(1), - NATURE_IO_CRITTER_1_PORT5(16), + AMBIENCE_IO_CRITTER_1_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_1_BEND_PITCH(0), + AMBIENCE_IO_CRITTER_1_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_1_PORT5(16), // Channel 3 - NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_10), - NATURE_IO_CRITTER_2_BEND_PITCH(112), - NATURE_IO_CRITTER_2_NUM_LAYERS(1), - NATURE_IO_CRITTER_2_PORT5(48), + AMBIENCE_IO_CRITTER_2_TYPE(AMBIENCE_CRITTER_10), + AMBIENCE_IO_CRITTER_2_BEND_PITCH(112), + AMBIENCE_IO_CRITTER_2_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_2_PORT5(48), // Channel 4 - NATURE_IO_CRITTER_3_TYPE(NATURE_CRITTER_13), - NATURE_IO_CRITTER_3_BEND_PITCH(127), - NATURE_IO_CRITTER_3_NUM_LAYERS(0), - NATURE_IO_CRITTER_3_PORT5(63), + AMBIENCE_IO_CRITTER_3_TYPE(AMBIENCE_CRITTER_13), + AMBIENCE_IO_CRITTER_3_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_3_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_3_PORT5(63), // Channel 5 - NATURE_IO_CRITTER_4_TYPE(NATURE_CRITTER_00), - NATURE_IO_CRITTER_4_BEND_PITCH(127), - NATURE_IO_CRITTER_4_NUM_LAYERS(1), - NATURE_IO_CRITTER_4_PORT5(16), + AMBIENCE_IO_CRITTER_4_TYPE(AMBIENCE_CRITTER_00), + AMBIENCE_IO_CRITTER_4_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_4_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_4_PORT5(16), // Channel 6 - NATURE_IO_CRITTER_5_TYPE(NATURE_CRITTER_01), - NATURE_IO_CRITTER_5_BEND_PITCH(127), - NATURE_IO_CRITTER_5_NUM_LAYERS(3), - NATURE_IO_CRITTER_5_PORT5(16), + AMBIENCE_IO_CRITTER_5_TYPE(AMBIENCE_CRITTER_01), + AMBIENCE_IO_CRITTER_5_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_5_NUM_LAYERS(3), + AMBIENCE_IO_CRITTER_5_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 6 + // AMBIENCE_ID_06 { - 0xC0FF, // PlayerIO Data - 0xC0FE, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | + (1 << AMBIENCE_CHANNEL_CRITTER_2) | (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | + (1 << AMBIENCE_CHANNEL_CRITTER_5) | (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | (1 << AMBIENCE_CHANNEL_CRITTER_2) | + (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | (1 << AMBIENCE_CHANNEL_CRITTER_5) | + (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_IO_STREAM_0_PORT3(0), // Channel 1 - NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_11), - NATURE_IO_CRITTER_0_BEND_PITCH(112), - NATURE_IO_CRITTER_0_NUM_LAYERS(0), - NATURE_IO_CRITTER_0_PORT5(48), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_11), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(112), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_0_PORT5(48), // Channel 2 - NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_15), - NATURE_IO_CRITTER_1_BEND_PITCH(112), - NATURE_IO_CRITTER_1_NUM_LAYERS(0), - NATURE_IO_CRITTER_1_PORT5(63), + AMBIENCE_IO_CRITTER_1_TYPE(AMBIENCE_CRITTER_15), + AMBIENCE_IO_CRITTER_1_BEND_PITCH(112), + AMBIENCE_IO_CRITTER_1_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_1_PORT5(63), // Channel 3 - NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_11), - NATURE_IO_CRITTER_2_BEND_PITCH(48), - NATURE_IO_CRITTER_2_NUM_LAYERS(1), - NATURE_IO_CRITTER_2_PORT5(16), + AMBIENCE_IO_CRITTER_2_TYPE(AMBIENCE_CRITTER_11), + AMBIENCE_IO_CRITTER_2_BEND_PITCH(48), + AMBIENCE_IO_CRITTER_2_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_2_PORT5(16), // Channel 4 - NATURE_IO_CRITTER_3_TYPE(NATURE_CRITTER_14), - NATURE_IO_CRITTER_3_BEND_PITCH(48), - NATURE_IO_CRITTER_3_NUM_LAYERS(1), - NATURE_IO_CRITTER_3_PORT5(16), + AMBIENCE_IO_CRITTER_3_TYPE(AMBIENCE_CRITTER_14), + AMBIENCE_IO_CRITTER_3_BEND_PITCH(48), + AMBIENCE_IO_CRITTER_3_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_3_PORT5(16), // Channel 5 - NATURE_IO_CRITTER_4_TYPE(NATURE_CRITTER_11), - NATURE_IO_CRITTER_4_BEND_PITCH(127), - NATURE_IO_CRITTER_4_NUM_LAYERS(0), - NATURE_IO_CRITTER_4_PORT5(32), + AMBIENCE_IO_CRITTER_4_TYPE(AMBIENCE_CRITTER_11), + AMBIENCE_IO_CRITTER_4_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_4_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_4_PORT5(32), // Channel 6 - NATURE_IO_CRITTER_5_TYPE(NATURE_CRITTER_02), - NATURE_IO_CRITTER_5_BEND_PITCH(127), - NATURE_IO_CRITTER_5_NUM_LAYERS(0), - NATURE_IO_CRITTER_5_PORT5(48), + AMBIENCE_IO_CRITTER_5_TYPE(AMBIENCE_CRITTER_02), + AMBIENCE_IO_CRITTER_5_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_5_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_5_PORT5(48), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 7 + // AMBIENCE_ID_07 { - 0xC001, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_IO_STREAM_0_PORT3(0), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 8 + // AMBIENCE_ID_08 { - 0xC003, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_IO_STREAM_0_PORT3(0), // Channel 1 - NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_01), - NATURE_IO_CRITTER_0_BEND_PITCH(127), - NATURE_IO_CRITTER_0_NUM_LAYERS(3), - NATURE_IO_CRITTER_0_PORT5(16), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_01), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(3), + AMBIENCE_IO_CRITTER_0_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 9 + // AMBIENCE_ID_09 { - 0xC00F, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | + (1 << AMBIENCE_CHANNEL_CRITTER_2) | (1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_IO_STREAM_0_PORT3(0), // Channel 1 - NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_16), - NATURE_IO_CRITTER_0_BEND_PITCH(0), - NATURE_IO_CRITTER_0_NUM_LAYERS(2), - NATURE_IO_CRITTER_0_PORT5(16), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_16), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(0), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(2), + AMBIENCE_IO_CRITTER_0_PORT5(16), // Channel 2 - NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_12), - NATURE_IO_CRITTER_1_BEND_PITCH(112), - NATURE_IO_CRITTER_1_NUM_LAYERS(0), - NATURE_IO_CRITTER_1_PORT5(48), + AMBIENCE_IO_CRITTER_1_TYPE(AMBIENCE_CRITTER_12), + AMBIENCE_IO_CRITTER_1_BEND_PITCH(112), + AMBIENCE_IO_CRITTER_1_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_1_PORT5(48), // Channel 3 - NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_15), - NATURE_IO_CRITTER_2_BEND_PITCH(127), - NATURE_IO_CRITTER_2_NUM_LAYERS(1), - NATURE_IO_CRITTER_2_PORT5(16), + AMBIENCE_IO_CRITTER_2_TYPE(AMBIENCE_CRITTER_15), + AMBIENCE_IO_CRITTER_2_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_2_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_2_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 10 + // AMBIENCE_ID_0A { - 0xC081, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_1), - NATURE_IO_STREAM_0_PORT3(8), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_1), + AMBIENCE_IO_STREAM_0_PORT3(8), // Channel 7 - NATURE_IO_CRITTER_6_TYPE(NATURE_CRITTER_11), - NATURE_IO_CRITTER_6_BEND_PITCH(112), - NATURE_IO_CRITTER_6_NUM_LAYERS(2), - NATURE_IO_CRITTER_6_PORT5(32), + AMBIENCE_IO_CRITTER_6_TYPE(AMBIENCE_CRITTER_11), + AMBIENCE_IO_CRITTER_6_BEND_PITCH(112), + AMBIENCE_IO_CRITTER_6_NUM_LAYERS(2), + AMBIENCE_IO_CRITTER_6_PORT5(32), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 11 + // AMBIENCE_ID_0B { - 0xC00F, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | + (1 << AMBIENCE_CHANNEL_CRITTER_2) | (1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_3), - NATURE_IO_STREAM_0_PORT3(8), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_3), + AMBIENCE_IO_STREAM_0_PORT3(8), // Channel 1 - NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_01), - NATURE_IO_CRITTER_0_BEND_PITCH(127), - NATURE_IO_CRITTER_0_NUM_LAYERS(3), - NATURE_IO_CRITTER_0_PORT5(16), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_01), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(3), + AMBIENCE_IO_CRITTER_0_PORT5(16), // Channel 2 - NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_00), - NATURE_IO_CRITTER_1_BEND_PITCH(127), - NATURE_IO_CRITTER_1_NUM_LAYERS(2), - NATURE_IO_CRITTER_1_PORT5(16), + AMBIENCE_IO_CRITTER_1_TYPE(AMBIENCE_CRITTER_00), + AMBIENCE_IO_CRITTER_1_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_1_NUM_LAYERS(2), + AMBIENCE_IO_CRITTER_1_PORT5(16), // Channel 3 - NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_06), - NATURE_IO_CRITTER_2_BEND_PITCH(127), - NATURE_IO_CRITTER_2_NUM_LAYERS(1), - NATURE_IO_CRITTER_2_PORT5(16), + AMBIENCE_IO_CRITTER_2_TYPE(AMBIENCE_CRITTER_06), + AMBIENCE_IO_CRITTER_2_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_2_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_2_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 12 + // AMBIENCE_ID_0C { - 0xC007, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | + (1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), // Channel 1 - NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_00), - NATURE_IO_CRITTER_0_BEND_PITCH(127), - NATURE_IO_CRITTER_0_NUM_LAYERS(1), - NATURE_IO_CRITTER_0_PORT5(16), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_00), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_0_PORT5(16), // Channel 2 - NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_01), - NATURE_IO_CRITTER_1_BEND_PITCH(127), - NATURE_IO_CRITTER_1_NUM_LAYERS(3), - NATURE_IO_CRITTER_1_PORT5(16), + AMBIENCE_IO_CRITTER_1_TYPE(AMBIENCE_CRITTER_01), + AMBIENCE_IO_CRITTER_1_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_1_NUM_LAYERS(3), + AMBIENCE_IO_CRITTER_1_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 13 + // AMBIENCE_ID_0D { - 0xC003, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_IO_STREAM_0_PORT3(0), // Channel 1 - NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), - NATURE_IO_CRITTER_0_BEND_PITCH(0), - NATURE_IO_CRITTER_0_NUM_LAYERS(1), - NATURE_IO_CRITTER_0_PORT5(16), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(0), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_0_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 14 + // AMBIENCE_ID_0E { - 0xC003, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_IO_STREAM_0_PORT3(0), // Channel 1 - NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), - NATURE_IO_CRITTER_0_BEND_PITCH(0), - NATURE_IO_CRITTER_0_NUM_LAYERS(1), - NATURE_IO_CRITTER_0_PORT5(16), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(0), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_0_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 15 + // AMBIENCE_ID_0F { - 0xC003, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_IO_STREAM_0_PORT3(0), // Channel 1 - NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), - NATURE_IO_CRITTER_0_BEND_PITCH(0), - NATURE_IO_CRITTER_0_NUM_LAYERS(1), - NATURE_IO_CRITTER_0_PORT5(16), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(0), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_0_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 16 + // AMBIENCE_ID_10 { - 0xC003, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_IO_STREAM_0_PORT3(0), // Channel 1 - NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), - NATURE_IO_CRITTER_0_BEND_PITCH(0), - NATURE_IO_CRITTER_0_NUM_LAYERS(1), - NATURE_IO_CRITTER_0_PORT5(16), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(0), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_0_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 17 + // AMBIENCE_ID_11 { - 0xC003, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_IO_STREAM_0_PORT3(0), // Channel 1 - NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), - NATURE_IO_CRITTER_0_BEND_PITCH(0), - NATURE_IO_CRITTER_0_NUM_LAYERS(1), - NATURE_IO_CRITTER_0_PORT5(16), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(0), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_0_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 18 + // AMBIENCE_ID_12 { - 0xC000, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 19 + // AMBIENCE_ID_13 { - 0xC003, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_IO_STREAM_0_PORT3(0), // Channel 1 - NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), - NATURE_IO_CRITTER_0_BEND_PITCH(0), - NATURE_IO_CRITTER_0_NUM_LAYERS(1), - NATURE_IO_CRITTER_0_PORT5(16), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(0), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_0_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, @@ -3256,7 +3400,7 @@ u8 sRequestCustomSequence = false; void AudioOcarina_SetCustomSequence(void) { // Never passes true as sRequestCustomSequence is never set true if (sRequestCustomSequence && gAudioContext.seqPlayers[SEQ_PLAYER_FANFARE].enabled && - ((u8)gAudioContext.seqPlayers[SEQ_PLAYER_FANFARE].soundScriptIO[0] == 0xFF)) { + ((u8)gAudioContext.seqPlayers[SEQ_PLAYER_FANFARE].soundScriptIO[0] == (u8)SEQ_IO_VAL_NONE)) { gAudioContext.seqPlayers[SEQ_PLAYER_FANFARE].seqData = sCustomSequenceScript; sRequestCustomSequence = false; } @@ -3477,17 +3621,46 @@ void AudioOcarina_ResetStaffs(void) { D_801D8534 = 0; } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019DFF8.s") +void Audio_Noop1(s32 arg0) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019E000.s") +void Audio_Noop2(s32 arg0, s32 arg1) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019E00C.s") +void Audio_Noop3(void) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019E014.s") +void Audio_Update(void) { + if ((func_801A9768() == 0) && (func_801A982C() == 0)) { + AudioOcarina_SetCustomSequence(); + AudioOcarina_Update(); + func_801A5118(); + Audio_StepFreqLerp(&sRiverFreqScaleLerp); + Audio_StepFreqLerp(&sWaterfallFreqScaleLerp); + Audio_UpdateRiverSoundVolumes(); + Audio_UpdateSceneSequenceResumePoint(); + func_801A312C(); + func_8019FEDC(); + func_801A1E0C(); + func_801A1904(); + func_801A2090(); + func_801A3AC0(); + func_801A1290(); + Audio_ResetRequestedSceneSeqId(); + AudioSfx_ProcessRequests(); + func_801A89D0(); + AudioSfx_ProcessActiveSfx(); + func_801A8D5C(); + AudioSfx_ProcessSfxSettings(); + AudioThread_ScheduleProcessCmds(); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019E0FC.s") +void Audio_Noop4(s32 arg0) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019E104.s") +void Audio_Noop5(s32 arg0, s32 arg1) { +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019E110.s") @@ -3582,7 +3755,7 @@ s8 AudioSfx_ComputeReverb(u8 bankId, u8 entryIndex, u8 channelIndex) { if (IS_SEQUENCE_CHANNEL_VALID(gAudioContext.seqPlayers[SEQ_PLAYER_SFX].channels[channelIndex])) { scriptAdd = gAudioContext.seqPlayers[SEQ_PLAYER_SFX].channels[channelIndex]->soundScriptIO[1]; - if (gAudioContext.seqPlayers[SEQ_PLAYER_SFX].channels[channelIndex]->soundScriptIO[1] < 0) { + if (gAudioContext.seqPlayers[SEQ_PLAYER_SFX].channels[channelIndex]->soundScriptIO[1] <= SEQ_IO_VAL_NONE) { scriptAdd = 0; } } @@ -3815,7 +3988,7 @@ void AudioSfx_SetProperties(u8 bankId, u8 entryIndex, u8 channelIndex) { case BANK_ENV: case BANK_ENEMY: case BANK_VOICE: - if (sSoundMode == SOUNDMODE_SURROUND) { + if (sSoundMode == SOUNDMODE_SURROUND_EXTERNAL) { combFilterGain = AudioSfx_ComputeCombFilter(*entry->posY, entry->sfxParams); } // fallthrough @@ -3826,7 +3999,7 @@ void AudioSfx_SetProperties(u8 bankId, u8 entryIndex, u8 channelIndex) { panSigned = AudioSfx_ComputePanSigned(*entry->posX, *entry->posZ, entry->token); freqScale = AudioSfx_ComputeFreqScale(bankId, entryIndex) * *entry->freqScale; - if (sSoundMode == SOUNDMODE_SURROUND) { + if (sSoundMode == SOUNDMODE_SURROUND_EXTERNAL) { if (*entry->posZ >= 0.0f) { if (*entry->posZ < 200.0f) { zVolume = 32.0f - ((*entry->posZ / 300.0f) * 32.0f); @@ -3859,7 +4032,7 @@ void AudioSfx_SetProperties(u8 bankId, u8 entryIndex, u8 channelIndex) { ((entry->sfxFlags & SFX_FLAG2_APPLY_LOWPASS_FILTER) >> 2)) * 2); filter &= 0xFF; - } else if ((sSoundMode == SOUNDMODE_SURROUND) && !(entry->sfxParams & SFX_FLAG_VOLUME_NO_DIST)) { + } else if ((sSoundMode == SOUNDMODE_SURROUND_EXTERNAL) && !(entry->sfxParams & SFX_FLAG_VOLUME_NO_DIST)) { filter = AudioSfx_ComputeSurroundSoundFilter(behindScreenZ, entry, panSigned); } break; @@ -4189,7 +4362,7 @@ s32 Audio_SetGanonsTowerBgmVolume(u8 targetVolume) { gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIndex]) { // soundScriptIO[5] was set to 0x40 in channels 0, 1, and 4 (BGM no longer in OoT) if ((u8)gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIndex]->soundScriptIO[5] != - 0xFF) { + (u8)SEQ_IO_VAL_NONE) { // Higher volume leads to lower reverb reverb = (((u16)gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIndex]->soundScriptIO[5] - @@ -4350,9 +4523,51 @@ void Audio_ClearSariaBgmAtPos(Vec3f* pos) { } } -u8 sBgmPlayers[2] = { SEQ_PLAYER_BGM_MAIN, SEQ_PLAYER_BGM_SUB }; -void Audio_SplitBgmChannels(s8 volumeSplit); -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_SplitBgmChannels.s") +/** + * Turns on and off channels from both bgm players in a way that splits + * equally between the two bgm channels. Split based on note priority + */ +void Audio_SplitBgmChannels(s8 volumeSplit) { + u8 volume; + u8 notePriority; + u16 channelBits; + u8 sBgmPlayers[2] = { SEQ_PLAYER_BGM_MAIN, SEQ_PLAYER_BGM_SUB }; + u8 i; + u8 channelIndex; + + if ((Audio_GetActiveSequence(SEQ_PLAYER_FANFARE) == NA_BGM_DISABLED) && + (Audio_GetActiveSequence(SEQ_PLAYER_BGM_SUB) != NA_BGM_ROMANI_RANCH)) { + for (i = 0; i < ARRAY_COUNT(sBgmPlayers); i++) { + if (i == 0) { + // Main Bgm SeqPlayer + volume = volumeSplit; + } else { + // Sub Bgm SeqPlayer + volume = 0x7F - volumeSplit; + } + + if (volume > 100) { + notePriority = 11; + } else if (volume < 20) { + notePriority = 2; + } else { + notePriority = ((volume - 20) / 10) + 2; + } + + channelBits = 0; + for (channelIndex = 0; channelIndex < SEQ_NUM_CHANNELS; channelIndex++) { + if (gAudioContext.seqPlayers[sBgmPlayers[i]].channels[channelIndex]->notePriority < notePriority) { + // If the note currently playing in the channel is a high enough priority, + // then keep the channel on by setting a channelBit + // If this condition fails, then the channel will be shut off + channelBits += (1 << channelIndex); + } + } + + Audio_QueueSeqCmd(0xA0000000 | ((u32)(sBgmPlayers[i]) << 24) | ((u32)(channelBits))); + } + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0E44.s") @@ -4404,7 +4619,7 @@ void Audio_PlaySariaBgm(Vec3f* pos, u16 seqId, u16 distMax) { if (sRiverSoundBgmPos == NULL) { sRiverSoundBgmPos = pos; - func_801A3238(SEQ_PLAYER_BGM_SUB, seqId, 0, 7, 2); + Audio_PlaySequenceWithSeqPlayerIO(SEQ_PLAYER_BGM_SUB, seqId, 0, 7, 2); } else { prevDist = sqrtf(SQ(sRiverSoundBgmPos->z) + SQ(sRiverSoundBgmPos->x)); if (dist < prevDist) { @@ -4441,15 +4656,80 @@ void Audio_ClearSariaBgm2(void) { #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A246C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2544.s") +void Audio_PlayMorningSceneSequence(u16 seqId, u8 dayMinusOne) { + Audio_StartMorningSceneSequence(seqId); + Audio_QueueSeqCmd(0x70000000 | ((u32)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u32)(4) << 0x10) | (u32)(dayMinusOne)); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A257C.s") +void Audio_StartMorningSceneSequence(u16 seqId) { + if (seqId != NA_BGM_AMBIENCE) { + Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_AMBIENCE) << 24) | ((0) << 16)); + Audio_StartSceneSequence(seqId); + Audio_PlaySequenceWithSeqPlayerIO(SEQ_PLAYER_BGM_MAIN, seqId, 0, 0, 1); + } else { + Audio_PlayAmbience(AMBIENCE_ID_08); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A25E4.s") +void Audio_PlaySceneSequence(u16 seqId, u8 dayMinusOne) { + if (sRequestedSceneSeqId != seqId) { + if (seqId == NA_BGM_AMBIENCE) { + Audio_PlayAmbience(AMBIENCE_ID_08); + } else if ((seqId != NA_BGM_FINAL_HOURS) || (sPrevMainBgmSeqId == NA_BGM_DISABLED)) { + Audio_StartSceneSequence(seqId); + Audio_QueueSeqCmd(0x70000000 | ((u32)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u32)(4) << 0x10) | + (u32)(dayMinusOne)); + } + sRequestedSceneSeqId = seqId; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2670.s") +void Audio_StartSceneSequence(u16 seqId) { + u8 fadeInDuration = 0; + u8 skipHarpIntro; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2778.s") + if ((sSeqFlags[sPrevSceneSeqId] & SEQ_FLAG_RESUME_PREV) && (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_RESUME)) { + // Resume the sequence from the point where it left off last time it was played in the scene + if ((sSeqResumePoint & 0x3F) != 0) { + fadeInDuration = 30; + } + + // Write the sequence resumePoint to resume from into ioPort 7 + Audio_PlaySequenceWithSeqPlayerIO(SEQ_PLAYER_BGM_MAIN, seqId, fadeInDuration, 7, sSeqResumePoint); + + sSeqResumePoint = 0; + } else { + // Start the sequence from the beginning + + // Writes to ioPort 7. See `SEQ_FLAG_SKIP_HARP_INTRO` for writing a value of 1 to ioPort 7. + if (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_SKIP_HARP_INTRO) { + skipHarpIntro = 1; + } else { + skipHarpIntro = (u8)SEQ_IO_VAL_NONE; + } + Audio_PlaySequenceWithSeqPlayerIO(SEQ_PLAYER_BGM_MAIN, seqId, 0, 7, skipHarpIntro); + + if (!(sSeqFlags[seqId] & SEQ_FLAG_RESUME_PREV)) { + // Reset the sequence resumePoint + sSeqResumePoint = SEQ_RESUME_POINT_NONE; + } + } + sPrevSceneSeqId = seqId & 0xFF; +} + +void Audio_UpdateSceneSequenceResumePoint(void) { + u16 seqId = Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN); + + if ((seqId != NA_BGM_DISABLED) && (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_RESUME)) { + if (sSeqResumePoint != SEQ_RESUME_POINT_NONE) { + // Get the current point to resume from + sSeqResumePoint = gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[3]; + } else { + // Initialize the point to resume from to the start of the sequence + sSeqResumePoint = 0; + } + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A27E8.s") @@ -4463,35 +4743,238 @@ void Audio_ClearSariaBgm2(void) { #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2C44.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2C88.s") +void Audio_PlaySequenceInCutscene(u16 seqId) { + if (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_FANFARE) { + Audio_PlayFanfare(seqId); + } else if (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_FANFARE_KAMARO) { + Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_FANFARE) << 24) | ((u32)(0) << 0x10) | (u32)(seqId)); + } else if (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_NO_AMBIENCE) { + Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_BGM_SUB) << 24) | ((u32)(0) << 0x10) | (u32)(seqId)); + } else { + Audio_PlaySequenceWithSeqPlayerIO(SEQ_PLAYER_BGM_MAIN, seqId, 0, 7, SEQ_IO_VAL_NONE); + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 1, 0x7F, 0); + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 3, 0x7F, 0); + Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_FANFARE) << 24) | ((0) << 16)); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2D54.s") +void Audio_StopSequenceInCutscene(u16 seqId) { + if (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_FANFARE) { + Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_FANFARE) << 24) | ((0) << 16)); + } else if (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_FANFARE_KAMARO) { + Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_FANFARE) << 24) | ((0) << 16)); + } else if (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_NO_AMBIENCE) { + Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_BGM_SUB) << 24) | ((0) << 16)); + } else { + Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_BGM_MAIN) << 24) | ((0) << 16)); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_IsSequencePlaying.s") +s32 Audio_IsSequencePlaying(u8 seqId) { + u8 playerIndex = SEQ_PLAYER_BGM_MAIN; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2E54.s") + if (sSeqFlags[seqId & 0xFF] & SEQ_FLAG_FANFARE) { + playerIndex = SEQ_PLAYER_FANFARE; + } else if (sSeqFlags[seqId & 0xFF] & SEQ_FLAG_FANFARE_KAMARO) { + playerIndex = SEQ_PLAYER_FANFARE; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2ED8.s") + if (seqId == (Audio_GetActiveSequence(playerIndex) & 0xFF)) { + return true; + } else { + return false; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2F88.s") +void Audio_PlayBgm_StorePrevBgm(u16 seqId) { + u16 curSeqId = Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN); -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2FC4.s") + if (curSeqId == NA_BGM_DISABLED) { + curSeqId = NA_BGM_GENERAL_SFX; + } + + if (curSeqId != seqId) { + Audio_SetSequenceMode(SEQ_MODE_IGNORE); + + // Ensure the sequence about to be stored isn't also storing a separate sequence + if (!(sSeqFlags[curSeqId] & SEQ_FLAG_RESTORE)) { + sPrevMainBgmSeqId = curSeqId; + } + + Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u32)(0) << 0x10) | (u32)(seqId + 0x8000)); + } +} + +/** + * To be used in conjunction with Audio_PlayBgm_StorePrevBgm + */ +void Audio_RestorePrevBgm(void) { + if ((Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN) != NA_BGM_DISABLED) && + (sSeqFlags[Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN) & 0xFF] & SEQ_FLAG_RESTORE)) { + if ((sPrevMainBgmSeqId == NA_BGM_DISABLED) || (sPrevMainBgmSeqId == NA_BGM_GENERAL_SFX)) { + Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_BGM_MAIN) << 24) | ((0) << 16)); + } else { + if (sPrevMainBgmSeqId == NA_BGM_AMBIENCE) { + sPrevMainBgmSeqId = sPrevAmbienceSeqId; + } + Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u32)(0) << 0x10) | + (u32)(sPrevMainBgmSeqId + 0x8000)); + } + sPrevMainBgmSeqId = NA_BGM_DISABLED; + } +} + +// Unused +void Audio_PlayAmbience_StorePrevBgm(u8 ambienceId) { + u16 seqId = Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN); + + if (seqId != NA_BGM_AMBIENCE) { + sPrevMainBgmSeqId = seqId; + } + + Audio_PlayAmbience(ambienceId); +} + +// Unused +void Audio_ForceRestorePreviousBgm(void) { + if (sPrevMainBgmSeqId != NA_BGM_DISABLED) { + Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u32)(0) << 0x10) | + (u32)(sPrevMainBgmSeqId + 0x8000)); + } + + sPrevMainBgmSeqId = NA_BGM_DISABLED; +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3000.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3038.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3098.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_PlayFanfare.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A312C.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A31EC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3238.s") +void Audio_PlaySequenceWithSeqPlayerIO(s8 playerIndex, u16 seqId, u8 fadeInDuration, s8 ioPort, u8 ioData) { + u16 flaggedSeqId; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A32CC.s") + Audio_QueueSeqCmd(0x70000000 | ((u32)(playerIndex) << 24) | ((u32)(ioPort) << 0x10) | (u32)(ioData)); + if ((seqId & 0xFF) < 2) { + flaggedSeqId = seqId; + } else { + flaggedSeqId = seqId | 0x8000; + } + Audio_QueueSeqCmd(0x00000000 | ((u32)(playerIndex) << 24) | ((u32)(fadeInDuration) << 0x10) | (u32)(flaggedSeqId)); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3590.s") +void Audio_SetSequenceMode(u8 seqMode) { + s32 volumeFadeInTimer; + u16 seqId; + u8 volumeFadeOutTimer; + + if ((sPrevMainBgmSeqId == NA_BGM_DISABLED) && (sPrevMainBgmSeqId == NA_BGM_DISABLED)) { + // clang-format off + if (sAudioCutsceneFlag || sSpatialSeqIsActive[SEQ_PLAYER_BGM_SUB]) { \ + seqMode = SEQ_MODE_IGNORE; + } + // clang-format on + + seqId = gActiveSeqs[SEQ_PLAYER_BGM_MAIN].seqId; + + if ((seqId == NA_BGM_DISABLED) || (sSeqFlags[(u8)(seqId & 0xFF)] & SEQ_FLAG_ENEMY) || + ((sPrevSeqMode & 0x7F) == SEQ_MODE_ENEMY)) { + if (seqMode != (sPrevSeqMode & 0x7F)) { + if (seqMode == SEQ_MODE_ENEMY) { + // If only seqMode = SEQ_MODE_ENEMY (Start) + if (gActiveSeqs[SEQ_PLAYER_BGM_SUB].volScales[1] - sBgmEnemyVolume < 0) { + volumeFadeInTimer = -(gActiveSeqs[SEQ_PLAYER_BGM_SUB].volScales[1] - sBgmEnemyVolume); + } else { + volumeFadeInTimer = gActiveSeqs[SEQ_PLAYER_BGM_SUB].volScales[1] - sBgmEnemyVolume; + } + + Audio_SetVolumeScale(SEQ_PLAYER_BGM_SUB, 3, sBgmEnemyVolume, volumeFadeInTimer); + Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_BGM_SUB) << 24) | ((u32)(10) << 0x10) | + (u32)(NA_BGM_ENEMY | 0x800)); + + if (seqId >= NA_BGM_TERMINA_FIELD) { + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 3, 0x7F - sBgmEnemyVolume, 10); + Audio_SplitBgmChannels(sBgmEnemyVolume); + } + } else if ((sPrevSeqMode & 0x7F) == SEQ_MODE_ENEMY) { + // If only sPrevSeqMode = SEQ_MODE_ENEMY (End) + Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_BGM_SUB) << 24) | ((10) << 16)); + + if (seqMode == SEQ_MODE_IGNORE) { + volumeFadeOutTimer = 0; + } else { + volumeFadeOutTimer = 10; + } + + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 3, 0x7F, volumeFadeOutTimer); + Audio_SplitBgmChannels(0); + } + + sPrevSeqMode = seqMode + 0x80; + } else { + if (seqMode == SEQ_MODE_ENEMY) { + // If both seqMode = sPrevSeqMode = SEQ_MODE_ENEMY + if ((Audio_GetActiveSequence(SEQ_PLAYER_BGM_SUB) == NA_BGM_DISABLED) && + (seqId != NA_BGM_DISABLED) && (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_ENEMY)) { + Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_BGM_SUB) << 24) | ((u32)(10) << 0x10) | + (u32)(NA_BGM_ENEMY | 0x800)); + sPrevSeqMode = seqMode + 0x80; + } + } + } + } else { + // Remnant of OoT's Hyrule Field Sequence + if (seqMode == SEQ_MODE_DEFAULT) { + if (sPrevSeqMode == SEQ_MODE_STILL) { + sNumFramesMoving = 0; + } + sNumFramesStill = 0; + sNumFramesMoving++; + } else { + sNumFramesStill++; + } + + if ((seqMode == SEQ_MODE_STILL) && (sNumFramesStill < 30) && (sNumFramesMoving > 20)) { + seqMode = SEQ_MODE_DEFAULT; + } + + sPrevSeqMode = seqMode; + Audio_QueueSeqCmd(0x70000000 | ((u32)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u32)(2) << 0x10) | (u32)(seqMode)); + } + } +} + +void Audio_UpdateEnemyBgmVolume(f32 dist) { + f32 adjDist; + u16 seqId = gActiveSeqs[SEQ_PLAYER_BGM_MAIN].seqId; + + if (sPrevSeqMode == (SEQ_MODE_ENEMY | 0x80)) { + if (dist != sBgmEnemyDist) { + // clamp (dist - 150.0f) between 0 and 350 + if (dist < 150.0f) { + adjDist = 0.0f; + } else if (dist > 500.0f) { + adjDist = 350.0f; + } else { + adjDist = dist - 150.0f; + } + + sBgmEnemyVolume = ((350.0f - adjDist) * 127.0f) / 350.0f; + Audio_SetVolumeScale(SEQ_PLAYER_BGM_SUB, 3, sBgmEnemyVolume, 10); + + if ((seqId >= NA_BGM_TERMINA_FIELD) && !(sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_FANFARE_KAMARO)) { + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 3, (0x7F - sBgmEnemyVolume), 10); + } + } + + Audio_SplitBgmChannels(sBgmEnemyVolume); + } + sBgmEnemyDist = dist; +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A36F0.s") @@ -4521,7 +5004,9 @@ void Audio_ClearSariaBgm2(void) { #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3EC0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_SetCutsceneFlag.s") +void Audio_SetCutsceneFlag(s8 flag) { + sAudioCutsceneFlag = flag; +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3F6C.s") @@ -4529,7 +5014,7 @@ void Audio_ClearSariaBgm2(void) { #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3FFC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/audio_setBGM.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_SetSpec.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4058.s") @@ -4551,7 +5036,9 @@ void Audio_ClearSariaBgm2(void) { #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_PreNMI.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A44C4.s") +void Audio_ResetRequestedSceneSeqId(void) { + sRequestedSceneSeqId = NA_BGM_DISABLED; +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A44D4.s") @@ -4562,14 +5049,111 @@ f32 sSfxOriginalPos[] = { 0.0f, 0.0f, 0.0f }; #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A479C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A47DC.s") +void Audio_SetAmbienceChannelIO(u8 channelIndexRange, u8 ioPort, u8 ioData) { + u8 firstChannelIndex; + u8 lastChannelIndex; + u8 channelIndex; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A48E0.s") + if ((gActiveSeqs[SEQ_PLAYER_AMBIENCE].seqId != NA_BGM_AMBIENCE) && func_801A8ABC(NA_BGM_AMBIENCE, 0xF00000FF)) { + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4A28.s") + // channelIndexRange = 01 on ioPort 1 + if ((((channelIndexRange << 8) + (u32)ioPort) == ((1 << 8) | (u32)1)) && + (Audio_GetActiveSequence(SEQ_PLAYER_BGM_SUB) != NA_BGM_ROMANI_RANCH)) { + D_801FD3A8 = 0; + } -u32 Audio_SetNatureAmbienceRandomBend(u8 seqScriptValIn, SequenceChannel* channel); -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_SetNatureAmbienceRandomBend.s") + firstChannelIndex = channelIndexRange >> 4; + lastChannelIndex = channelIndexRange & 0xF; + + if (firstChannelIndex == 0) { + firstChannelIndex = channelIndexRange & 0xF; + } + + for (channelIndex = firstChannelIndex; channelIndex <= lastChannelIndex; channelIndex++) { + Audio_QueueSeqCmd(0x80000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(ioPort) << 16) | + ((u32)(channelIndex) << 8) | (u32)(ioData)); + } +} + +void Audio_StartAmbience(u16 initChannelMask, u16 initMuteChannelMask) { + u8 channelIndex; + + Audio_QueueSeqCmd(0x70000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(SEQ_PLAYER_IO_PORT_0) << 0x10) | + (u32)(1)); + Audio_QueueSeqCmd(0x70000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(SEQ_PLAYER_IO_PORT_4) << 0x10) | + (u32)((u8)(initChannelMask >> 8))); + Audio_QueueSeqCmd(0x70000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(SEQ_PLAYER_IO_PORT_5) << 0x10) | + (u32)((u8)(initChannelMask & 0xFF))); + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 0, 0x7F, 1); + + if ((Audio_GetActiveSequence(SEQ_PLAYER_AMBIENCE) != NA_BGM_DISABLED) && + (Audio_GetActiveSequence(SEQ_PLAYER_AMBIENCE) != NA_BGM_AMBIENCE)) { + Audio_StopSequence(SEQ_PLAYER_AMBIENCE, 0); + AudioThread_QueueCmdS32(0xF8 << 24, 0); + } + + if (Audio_GetActiveSequence(SEQ_PLAYER_BGM_SUB) == (NA_BGM_ENEMY | 0x800)) { + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 3, 0x7F, 1); + } + + Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(0) << 0x10) | (u32)(NA_BGM_AMBIENCE)); + + for (channelIndex = 0; channelIndex < 16; channelIndex++) { + if (!(initMuteChannelMask & (1 << channelIndex)) && (initChannelMask & (1 << channelIndex))) { + Audio_QueueSeqCmd(0x80000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(CHANNEL_IO_PORT_1) << 16) | + ((u32)(channelIndex) << 8) | (u32)(1)); + } + } +} + +void Audio_PlayAmbience(u8 ambienceId) { + u8 i = 0; + u8 channelIndex; + u8 ioPort; + u8 ioData; + + if (!((gActiveSeqs[SEQ_PLAYER_AMBIENCE].seqId != NA_BGM_DISABLED) && + (sSeqFlags[gActiveSeqs[SEQ_PLAYER_AMBIENCE].seqId & 0xFF & 0xFF] & SEQ_FLAG_NO_AMBIENCE))) { + if (gActiveSeqs[SEQ_PLAYER_AMBIENCE].seqId != NA_BGM_AMBIENCE) { + sPrevAmbienceSeqId = gActiveSeqs[SEQ_PLAYER_AMBIENCE].seqId; + } + + Audio_StartAmbience(sAmbienceData[ambienceId].initChannelMask, sAmbienceData[ambienceId].initMuteChannelMask); + + while ((sAmbienceData[ambienceId].channelProperties[i] != 0xFF) && + (i < ARRAY_COUNT(sAmbienceData[ambienceId].channelProperties))) { + channelIndex = sAmbienceData[ambienceId].channelProperties[i++]; + ioPort = sAmbienceData[ambienceId].channelProperties[i++]; + ioData = sAmbienceData[ambienceId].channelProperties[i++]; + Audio_QueueSeqCmd(0x80000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(ioPort) << 16) | + ((u32)(channelIndex) << 8) | (u32)(ioData)); + } + + Audio_QueueSeqCmd(0x80000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(CHANNEL_IO_PORT_7) << 16) | + ((u32)(AMBIENCE_CHANNEL_SOUND_MODE) << 8) | (u32)(sSoundMode)); + } +} + +u32 Audio_SetAmbienceRandomBend(u8 seqScriptValIn, SequenceChannel* channel) { + u32 seqScriptValOut = seqScriptValIn; + + gAudioContext.seqPlayers[SEQ_PLAYER_AMBIENCE].applyBend = true; + + if ((seqScriptValIn == 0) || (seqScriptValIn == 0xFF)) { + gAudioContext.seqPlayers[SEQ_PLAYER_AMBIENCE].bend = 1.0f; + } else { + seqScriptValOut = AudioThread_NextRandom(); + gAudioContext.seqPlayers[SEQ_PLAYER_AMBIENCE].bend = 1.0293 - ((gAudioContext.audioRandom & 0xF) / 144.0f); + + return seqScriptValOut; + } + +#ifdef AVOID_UB + return seqScriptValOut; +#endif +} void Audio_Init(void) { AudioLoad_Init(NULL, 0); @@ -4587,7 +5171,7 @@ void AudioSfx_Init(u16 fadeTimer) { } AudioThread_QueueCmdS32(0xE4000000, AudioSfx_SetFreqAndStereoBits); - AudioThread_QueueCmdS32(0xE4000001, Audio_SetNatureAmbienceRandomBend); + AudioThread_QueueCmdS32(0xE4000001, Audio_SetAmbienceRandomBend); } #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4D00.s") diff --git a/src/code/audio/code_801A5BD0.c b/src/code/audio/code_801A5BD0.c index 4cf1147bfa..d769708299 100644 --- a/src/code/audio/code_801A5BD0.c +++ b/src/code/audio/code_801A5BD0.c @@ -671,7 +671,7 @@ void AudioSfx_PlayActiveSfx(u8 bankId) { // "one-frame" sfx entry->state = SFX_STATE_PLAYING_ONE_FRAME; } - } else if ((u8)channel->soundScriptIO[1] == 0xFF) { + } else if ((u8)channel->soundScriptIO[1] == (u8)SEQ_IO_VAL_NONE) { // Signal from seq 0 that the sfx is finished playing. Remove entry AudioSfx_RemoveBankEntry(bankId, entryIndex); } else if (entry->state == SFX_STATE_PLAYING_REFRESH) { diff --git a/src/code/audio/code_801A7B10.c b/src/code/audio/code_801A7B10.c index f2f37a0138..3f84460362 100644 --- a/src/code/audio/code_801A7B10.c +++ b/src/code/audio/code_801A7B10.c @@ -2,7 +2,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/Audio_StartSequence.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A7D04.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/Audio_StopSequence.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A7D84.s") @@ -10,7 +10,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A89D0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A8A50.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/Audio_GetActiveSequence.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A8ABC.s") diff --git a/src/code/game.c b/src/code/game.c index da21de17f4..73352379f6 100644 --- a/src/code/game.c +++ b/src/code/game.c @@ -225,7 +225,7 @@ void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* g void GameState_Destroy(GameState* gameState) { AudioMgr_StopAllSfxExceptSystem(); - func_8019E014(); + Audio_Update(); osRecvMesg(&gameState->gfxCtx->queue, NULL, OS_MESG_BLOCK); if (gameState->destroy != NULL) { diff --git a/src/code/graph.c b/src/code/graph.c index 654d2c5f76..869740e4b3 100644 --- a/src/code/graph.c +++ b/src/code/graph.c @@ -232,7 +232,7 @@ void Graph_UpdateGame(GameState* gameState) { Game_UpdateInput(gameState); Game_IncrementFrameCount(gameState); if (SREG(20) < 3) { - func_8019E014(); + Audio_Update(); } } diff --git a/src/code/z_common_data.c b/src/code/z_common_data.c index c970282a89..0e682231f4 100644 --- a/src/code/z_common_data.c +++ b/src/code/z_common_data.c @@ -6,8 +6,8 @@ void SaveContext_Init(void) { bzero(&gSaveContext, sizeof(SaveContext)); gSaveContext.save.playerForm = 0; - gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; - gSaveContext.nightSeqIndex = 0xFF; + gSaveContext.seqId = (u8)NA_BGM_DISABLED; + gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; gSaveContext.unk_3F46 = NA_BGM_GENERAL_SFX; gSaveContext.nextCutsceneIndex = 0xFFEF; gSaveContext.cutsceneTrigger = 0; diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 4453bd6748..69995db164 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -152,7 +152,7 @@ void Cutscene_Command_Misc(PlayState* play, CutsceneContext* csCtx, CsCmdBase* c break; case 0x2: if (isStartFrame) { - func_801A47DC(NATURE_CHANNEL_LIGHTNING, CHANNEL_IO_PORT_0, 0); + Audio_SetAmbienceChannelIO(AMBIENCE_CHANNEL_LIGHTNING, CHANNEL_IO_PORT_0, 0); Environment_AddLightningBolts(play, 3); D_801F4E68 = 1; } @@ -376,14 +376,14 @@ void Cutscene_Command_SetLighting(PlayState* play, CutsceneContext* csCtx, CsCmd // Command 0x12C: Plays a sequence (Background music or Fanfare) void Cutscene_Command_PlaySequence(PlayState* play, CutsceneContext* csCtx, CsCmdSequenceChange* cmd) { if (csCtx->frames == cmd->startFrame) { - func_801A2C88(cmd->sequence - 1); + Audio_PlaySequenceInCutscene(cmd->sequence - 1); } } // Command 0x12D: Stops a sequence (Background music or Fanfare) void Cutscene_Command_StopSequence(PlayState* play, CutsceneContext* csCtx, CsCmdSequenceChange* cmd) { if ((csCtx->frames >= cmd->startFrame) && (cmd->endFrame >= csCtx->frames)) { - func_801A2D54(cmd->sequence - 1); + Audio_StopSequenceInCutscene(cmd->sequence - 1); } } @@ -403,9 +403,7 @@ void Cutscene_Command_FadeSequence(PlayState* play, CutsceneContext* csCtx, CsCm // Command 0x12E: Play Ambience sequence void Cutscene_Command_PlayAmbienceSequence(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) { if (csCtx->frames == cmd->startFrame) { - // Audio_PlayNatureAmbienceSequence - // nightSeqIndex is natureAmbienceId - func_801A4A28(play->soundCtx.nightSeqIndex); + Audio_PlayAmbience(play->sequenceCtx.ambienceId); } } @@ -455,29 +453,27 @@ void func_800EADB0(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) { break; case 4: - // func_801A246C(SEQ_PLAYER_NATURE, TYPE_1); - func_801A246C(SEQ_PLAYER_NATURE, 1); + // func_801A246C(SEQ_PLAYER_AMBIENCE, TYPE_1); + func_801A246C(SEQ_PLAYER_AMBIENCE, 1); break; case 5: - // func_801A246C(SEQ_PLAYER_NATURE, TYPE_0); - func_801A246C(SEQ_PLAYER_NATURE, 0); + // func_801A246C(SEQ_PLAYER_AMBIENCE, TYPE_0); + func_801A246C(SEQ_PLAYER_AMBIENCE, 0); break; case 6: - // func_801A246C(SEQ_PLAYER_NATURE, TYPE_2); - func_801A246C(SEQ_PLAYER_NATURE, 2); + // func_801A246C(SEQ_PLAYER_AMBIENCE, TYPE_2); + func_801A246C(SEQ_PLAYER_AMBIENCE, 2); break; case 7: - // Audio_GetActiveSequence - seqId = func_801A8A50(0); + seqId = Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN); break; case 8: if (seqId != NA_BGM_DISABLED) { - // Audio_PlayBgmForDayScene - func_801A25E4(seqId, dayMinusOne); + Audio_PlaySceneSequence(seqId, dayMinusOne); } break; } @@ -647,7 +643,7 @@ void Cutscene_Command_Terminator(PlayState* play, CutsceneContext* csCtx, CsCmdB // Command 0x15F: Chooses between a cutscene or a rotating mask depending on whether the player has the corresponding // mask void Cutscene_Command_ChooseCreditsScenes(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) { - if ((csCtx->frames >= cmd->startFrame) && (func_801A3950(0, true) != 0xFF)) { + if ((csCtx->frames >= cmd->startFrame) && (func_801A3950(SEQ_PLAYER_BGM_MAIN, true) != 0xFF)) { switch (cmd->base) { case 1: Cutscene_TerminatorImpl(play, csCtx, cmd); diff --git a/src/code/z_game_over.c b/src/code/z_game_over.c index 9fc3dee25b..776dc75d76 100644 --- a/src/code/z_game_over.c +++ b/src/code/z_game_over.c @@ -46,8 +46,8 @@ void GameOver_Update(PlayState* play) { gSaveContext.unk_3DC0 = 2000; gSaveContext.save.playerData.tatlTimer = 0; - gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; - gSaveContext.nightSeqIndex = 0xFF; + gSaveContext.seqId = (u8)NA_BGM_DISABLED; + gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; gSaveContext.eventInf[0] = 0; gSaveContext.eventInf[1] = 0; gSaveContext.eventInf[2] = 0; @@ -67,7 +67,7 @@ void GameOver_Update(PlayState* play) { gameOverCtx->state = GAMEOVER_DEATH_WAIT_GROUND; break; case GAMEOVER_DEATH_FADE_OUT: - if (func_801A8A50(1) != NA_BGM_GAME_OVER) { + if (Audio_GetActiveSequence(SEQ_PLAYER_FANFARE) != NA_BGM_GAME_OVER) { func_80169F78(&play->state); if (gSaveContext.respawnFlag != -7) { gSaveContext.respawnFlag = -6; diff --git a/src/code/z_scene.c b/src/code/z_scene.c index a3a4e331dd..ce5ddf7694 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -436,11 +436,12 @@ void Scene_HeaderCmd09(PlayState* play, SceneCmd* cmd) { // SceneTableEntry Header Command 0x15: Sound Settings= void Scene_HeaderCmdSoundSettings(PlayState* play, SceneCmd* cmd) { - play->soundCtx.seqIndex = cmd->soundSettings.musicSeq; - play->soundCtx.nightSeqIndex = cmd->soundSettings.nighttimeSFX; + play->sequenceCtx.seqId = cmd->soundSettings.seqId; + play->sequenceCtx.ambienceId = cmd->soundSettings.ambienceId; - if (gSaveContext.seqIndex == (u8)NA_BGM_DISABLED || func_801A8A50(0) == NA_BGM_FINAL_HOURS) { - audio_setBGM(cmd->soundSettings.bgmId); + if (gSaveContext.seqId == (u8)NA_BGM_DISABLED || + Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN) == NA_BGM_FINAL_HOURS) { + Audio_SetSpec(cmd->soundSettings.specId); } } diff --git a/src/overlays/actors/ovl_Boss_04/z_boss_04.c b/src/overlays/actors/ovl_Boss_04/z_boss_04.c index ca8ad214f5..f26bc505f5 100644 --- a/src/overlays/actors/ovl_Boss_04/z_boss_04.c +++ b/src/overlays/actors/ovl_Boss_04/z_boss_04.c @@ -521,7 +521,7 @@ void func_809ED224(Boss04* this) { this->unk_2C8 = 200; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ME_DEAD); this->actor.flags &= ~ACTOR_FLAG_1; - func_801A2ED8(); + Audio_RestorePrevBgm(); this->unk_1F6 = 10; } @@ -759,7 +759,7 @@ void Boss04_Update(Actor* thisx, PlayState* play2) { if (D_809EE4D0 != 0) { D_809EE4D0--; if (D_809EE4D0 == 0) { - func_801A2E54(0x38); + Audio_PlayBgm_StorePrevBgm(NA_BGM_MINI_BOSS); } } 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 5988d1913e..9a0f95004c 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c @@ -670,7 +670,7 @@ void DmStk_PlaySfxForPlayingWithFairiesCutscene(DmStk* this, PlayState* play) { void DmStk_PlaySfxForEndingCutsceneFirstPart(DmStk* this, PlayState* play) { switch (play->csCtx.frames) { case 5: - func_801A4A28(12); + Audio_PlayAmbience(AMBIENCE_ID_0C); break; case 660: @@ -688,7 +688,7 @@ void DmStk_PlaySfxForEndingCutsceneSecondPart(DmStk* this, PlayState* play) { switch (play->csCtx.frames) { case 5: - func_801A4A28(12); + Audio_PlayAmbience(AMBIENCE_ID_0C); break; case 45: diff --git a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c index 6bf8adc727..65df579cea 100644 --- a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c +++ b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c @@ -537,7 +537,7 @@ void func_808A1784(DoorShutter* this, PlayState* play) { } else { DoorShutter_SetupAction(this, func_808A1090); } - func_801A2ED8(); + Audio_RestorePrevBgm(); } } 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 33f8225d35..575cf2d353 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 @@ -671,7 +671,7 @@ void func_809C2730(EnAob01* this, PlayState* play) { void func_809C2788(EnAob01* this, PlayState* play) { this->unk_2D2 |= 0x20; if (func_809C25E4(this, play)) { - if (func_801A8A50(0) != 0x41) { + if (Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN) != NA_BGM_HORSE_GOAL) { play->nextEntrance = ENTRANCE(DOGGY_RACETRACK, 1); gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & (u8)~7) | 3; play->transitionType = TRANS_TYPE_64; 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 4834256d6e..3f35a5e353 100644 --- a/src/overlays/actors/ovl_En_Az/z_en_az.c +++ b/src/overlays/actors/ovl_En_Az/z_en_az.c @@ -1426,7 +1426,7 @@ void func_80A97AB4(EnAz* this, PlayState* play) { if (play->msgCtx.choiceIndex == 0) { func_8019F208(); play->msgCtx.msgMode = 0x44; - func_800FD750(NA_BGM_MINI_GAME_2); + func_800FD750(NA_BGM_TIMED_MINI_GAME); func_80A94AB8(this, play, 1); func_80A979DC(this, play); } else { @@ -1466,7 +1466,7 @@ void func_80A97C4C(EnAz* this, PlayState* play) { func_80A97410(this, play); if ((this->unk_2FA == 1) || (this->unk_2FA == 3) || (this->unk_2FA == 6) || (this->unk_2FA == 8)) { gSaveContext.save.weekEventReg[24] &= (u8)~1; - func_800FD750(NA_BGM_MINI_GAME_2); + func_800FD750(NA_BGM_TIMED_MINI_GAME); play->nextEntrance = Entrance_CreateFromSpawn(1); gSaveContext.nextCutsceneIndex = 0; play->transitionTrigger = TRANS_TRIGGER_START; 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 20a868bc61..62e1df422a 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c @@ -220,7 +220,7 @@ void EnBigpo_Init(Actor* thisx, PlayState* play2) { if (thisx->params == ENBIGPO_REGULAR) { // the well poe, starts immediately thisx->flags &= ~ACTOR_FLAG_10; // always update OFF - this->unkBool204 = true; + this->storePrevBgm = true; EnBigpo_InitWellBigpo(this); } else if (thisx->params == ENBIGPO_SUMMONED) { // dampe type EnBigpo_InitDampeMainPo(this); @@ -439,9 +439,9 @@ void EnBigpo_SpawnCutsceneStage6(EnBigpo* this, PlayState* play) { */ void EnBigpo_SpawnCutsceneStage7(EnBigpo* this) { this->idleTimer = 15; - if (this->unkBool204 == false) { - func_801A2E54(NA_BGM_MINI_BOSS); - this->unkBool204 = true; + if (this->storePrevBgm == false) { + Audio_PlayBgm_StorePrevBgm(NA_BGM_MINI_BOSS); + this->storePrevBgm = true; } this->actionFunc = EnBigpo_SpawnCutsceneStage8; } @@ -525,9 +525,9 @@ void EnBigpo_WarpingIn(EnBigpo* this, PlayState* play) { this->mainColor.a = this->idleTimer * (255.0f / 32.0f); if (this->idleTimer == 32) { this->mainColor.a = 255; // fully visible - if (this->unkBool204 == false) { - func_801A2E54(NA_BGM_MINI_BOSS); - this->unkBool204 = true; + if (this->storePrevBgm == false) { + Audio_PlayBgm_StorePrevBgm(NA_BGM_MINI_BOSS); + this->storePrevBgm = true; } EnBigpo_SetupIdleFlying(this); } @@ -1124,7 +1124,7 @@ s32 EnBigpo_ApplyDamage(EnBigpo* this, PlayState* play) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DEAD); Enemy_StartFinishingBlow(play, &this->actor); if (this->actor.params == ENBIGPO_SUMMONED) { // dampe type - func_801A2ED8(); + Audio_RestorePrevBgm(); } } else { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DAMAGE); diff --git a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.h b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.h index 9117bd97c5..9b84784f46 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.h +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.h @@ -30,7 +30,7 @@ typedef struct EnBigpo { /* 0x188 */ Vec3s jointTable[ENBIGPO_LIMBCOUNT]; /* 0x1C4 */ Vec3s morphTable[ENBIGPO_LIMBCOUNT]; /* 0x200 */ EnBigPoActionFunc actionFunc; - /* 0x204 */ u8 unkBool204; // need to know what func_801A2E54 does to know what this is + /* 0x204 */ u8 storePrevBgm; /* 0x206 */ s16 idleTimer; // frame counter /* 0x208 */ s16 unk208; // facing rotY? /* 0x20A */ s16 rotVelocity; 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 6cc0b2e72b..98212382bf 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c @@ -1005,7 +1005,7 @@ void EnBigslime_CallMinislime(EnBigslime* this, PlayState* play) { } else if (this->isAnimUpdate) { Animation_PlayLoop(&this->skelAnime, &gGekkoNervousIdleAnim); EnBigslime_UpdateCameraIntroCs(this, play, 25); - func_801A2E54(0x38); + Audio_PlayBgm_StorePrevBgm(NA_BGM_MINI_BOSS); EnBigslime_InitFallMinislime(this); play->envCtx.lightSettingOverride = 0xFF; this->callTimer = 35; @@ -2620,7 +2620,7 @@ void EnBigslime_ApplyDamageEffectGekko(EnBigslime* this, PlayState* play) { if (this->actor.colChkInfo.damageEffect != BIGSLIME_DMGEFF_HOOKSHOT) { if (Actor_ApplyDamage(&this->actor) == 0) { func_800BE504(&this->actor, &this->gekkoCollider); - func_801A2ED8(); + Audio_RestorePrevBgm(); Enemy_StartFinishingBlow(play, &this->actor); this->gekkoCollider.base.acFlags &= ~AC_ON; EnBigslime_GekkoThaw(this, play); 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 a9d9756bea..25f5de3e1d 100644 --- a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c +++ b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c @@ -691,7 +691,7 @@ void func_80C02740(EnBomjimb* this, PlayState* play) { gSaveContext.save.bombersCaughtNum++; if (gSaveContext.save.bombersCaughtNum > 4) { - func_801A3098(0x922); + Audio_PlayFanfare(NA_BGM_GET_ITEM | 0x900); } else { Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_PIECE_OF_HEART); } 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 10c28b6eb6..bc33adc0ca 100644 --- a/src/overlays/actors/ovl_En_Box/z_en_box.c +++ b/src/overlays/actors/ovl_En_Box/z_en_box.c @@ -482,7 +482,7 @@ void EnBox_WaitOpen(EnBox* this, PlayState* play) { this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, this->dyna.actor.shape.rot.x, this->dyna.actor.shape.rot.y, this->dyna.actor.shape.rot.z, -1); - func_801A3098(0x2B | 0x900); + Audio_PlayFanfare(NA_BGM_OPEN_CHEST | 0x900); } if (this->getItemId == GI_STRAY_FAIRY) { 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 c17acf8cc9..bf2f5e7ce1 100644 --- a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c +++ b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c @@ -511,7 +511,7 @@ void func_8089B3D4(EnDinofos* this, PlayState* play) { Math_Vec3f_StepTo(&subCam->eye, &this->unk_2BC, 10.0f); this->unk_290++; if (this->unk_290 == 10) { - func_801A2E54(NA_BGM_MINI_BOSS); + Audio_PlayBgm_StorePrevBgm(NA_BGM_MINI_BOSS); } subCamAt.x = this->actor.world.pos.x; @@ -530,7 +530,7 @@ void func_8089B3D4(EnDinofos* this, PlayState* play) { void func_8089B4A4(EnDinofos* this) { if (this->unk_290 < 10) { - func_801A2E54(NA_BGM_MINI_BOSS); + Audio_PlayBgm_StorePrevBgm(NA_BGM_MINI_BOSS); } Animation_PlayOnce(&this->skelAnime, &object_dinofos_Anim_00C974); this->unk_2BC.x = (Math_SinS(this->actor.shape.rot.y + 0x200) * 123.0f) + this->actor.world.pos.x; @@ -1279,7 +1279,7 @@ s32 func_8089D60C(EnDinofos* this, PlayState* play) { } if (this->actor.cutscene != -1) { - func_801A2ED8(); + Audio_RestorePrevBgm(); } } 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 fa465afbec..12d804fbaf 100644 --- a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c +++ b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c @@ -493,7 +493,7 @@ void EnElforg_FreeFloating(EnElforg* this, PlayState* play) { // You found a Stray Fairy! Message_StartTextbox(play, 0x11, NULL); if (gSaveContext.save.inventory.strayFairies[(void)0, gSaveContext.dungeonIndex] >= 15) { - func_801A3098(NA_BGM_GET_ITEM | 0x900); + Audio_PlayFanfare(NA_BGM_GET_ITEM | 0x900); } } } 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 8ab640253a..c0be813614 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -538,7 +538,7 @@ void func_80962660(EnFu* this, PlayState* play) { player->stateFlags1 |= 0x20; this->unk_53C = 0; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); - func_801A2BB8(NA_BGM_MINI_GAME_2); + func_801A2BB8(NA_BGM_TIMED_MINI_GAME); if (this->unk_542 == 0) { if (this->unk_546 == 1) { func_80961EC8(play); @@ -799,7 +799,7 @@ void func_80962F4C(EnFu* this, PlayState* play) { func_801A2C20(); gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] = SECONDS_TO_TIMER(0); gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_STOP; - func_801A3098(NA_BGM_GET_ITEM | 0x900); + Audio_PlayFanfare(NA_BGM_GET_ITEM | 0x900); func_8011B4E0(play, 1); this->unk_54A = 3; func_809632D0(this); diff --git a/src/overlays/actors/ovl_En_Ik/z_en_ik.c b/src/overlays/actors/ovl_En_Ik/z_en_ik.c index d71e4c1935..ffd45eaf96 100644 --- a/src/overlays/actors/ovl_En_Ik/z_en_ik.c +++ b/src/overlays/actors/ovl_En_Ik/z_en_ik.c @@ -387,7 +387,7 @@ void EnIk_Idle(EnIk* this, PlayState* play) { } } else if (this->colliderCylinder.base.acFlags & AC_HIT) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_ARMOR_HIT); - func_801A2E54(NA_BGM_MINI_BOSS); + Audio_PlayBgm_StorePrevBgm(NA_BGM_MINI_BOSS); this->actor.hintId = TATL_HINT_ID_IRON_KNUCKLE; this->colliderCylinder.base.acFlags &= ~AC_HIT; this->invincibilityFrames = 12; @@ -786,7 +786,7 @@ void EnIk_UpdateDamage(EnIk* this, PlayState* play) { isArmorBroken = true; } else { Enemy_StartFinishingBlow(play, &this->actor); - func_801A2ED8(); + Audio_RestorePrevBgm(); } } if (isArmorBroken == true) { 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 2ac1672352..2050c7316e 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -1989,7 +1989,7 @@ void func_80B470E0(EnInvadepoh* this) { void func_80B47108(EnInvadepoh* this, PlayState* play) { if (this->actionTimer == 100) { - func_801A3098(NA_BGM_CLEAR_EVENT); + Audio_PlayFanfare(NA_BGM_CLEAR_EVENT); } this->actionTimer--; if (this->actionTimer <= 0) { 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 e90b2decc9..49d7a06fb5 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 @@ -881,7 +881,7 @@ void EnMaYto_SetupAfterMilkRunInit(EnMaYto* this) { if (gSaveContext.save.weekEventReg[52] & 1) { // if (ProtectedCremia) EnMaYto_SetFaceExpression(this, 3, 1); } else { - func_801A3098(NA_BGM_FAILURE_1); + Audio_PlayFanfare(NA_BGM_FAILURE_1); EnMaYto_SetFaceExpression(this, 5, 2); } this->actionFunc = EnMaYto_AfterMilkRunInit; diff --git a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c index 6909183f38..ac3c8322e3 100644 --- a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c +++ b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c @@ -303,7 +303,7 @@ void func_80A6F5E4(EnMm3* this, PlayState* play) { this->unk_2AC--; if (this->unk_2AC == 0) { if (gSaveContext.timerCurTimes[TIMER_ID_POSTMAN] == SECONDS_TO_TIMER(10)) { - func_801A3098(0x922); + Audio_PlayFanfare(NA_BGM_GET_ITEM | 0x900); } else { play_sound(NA_SE_SY_ERROR); } 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 f1bfcd57fb..8b636787d1 100644 --- a/src/overlays/actors/ovl_En_Owl/z_en_owl.c +++ b/src/overlays/actors/ovl_En_Owl/z_en_owl.c @@ -356,7 +356,7 @@ void func_8095AE60(EnOwl* this, PlayState* play) { void func_8095AEC0(EnOwl* this, PlayState* play) { func_8095A920(this, play); if (func_8095A978(this, play, 0x7D0, 360.0f, 200.0f)) { - func_801A3098(NA_BGM_OWL); + Audio_PlayFanfare(NA_BGM_OWL); this->actionFunc = func_8095AE60; } } @@ -385,7 +385,7 @@ void func_8095AF2C(EnOwl* this, PlayState* play) { void func_8095AFEC(EnOwl* this, PlayState* play) { func_8095A920(this, play); if (func_8095A978(this, play, 0xBF6, 200.0f, 100.0f)) { - func_801A3098(NA_BGM_OWL); + Audio_PlayFanfare(NA_BGM_OWL); this->actionFunc = func_8095AF2C; this->unk_406 = 0; this->actionFlags |= 0x40; @@ -500,7 +500,7 @@ void func_8095B574(EnOwl* this, PlayState* play) { func_8095A920(this, play); if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_8095BA84; - func_801A3098(NA_BGM_OWL); + Audio_PlayFanfare(NA_BGM_OWL); this->actionFlags |= 0x40; this->unk_406 = 2; } else if (this->actor.xzDistToPlayer < 200.0f) { @@ -713,7 +713,7 @@ void func_8095BE0C(EnOwl* this, PlayState* play) { func_8095A920(this, play); if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_8095BA84; - func_801A3098(NA_BGM_OWL); + Audio_PlayFanfare(NA_BGM_OWL); this->unk_406 = 1; this->actionFlags |= 0x40; } else if (this->actor.textId == 0xBF0) { 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 b1b3d9cbc9..4be8ad3c15 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c @@ -1035,7 +1035,7 @@ void EnPametfrog_LookAround(EnPametfrog* this, PlayState* play) { this->actor.shape.rot.y = this->actor.world.rot.y; if (SkelAnime_Update(&this->skelAnime) && !Play_InCsMode(play)) { if (!this->unk_2AE) { - func_801A2E54(NA_BGM_MINI_BOSS); + Audio_PlayBgm_StorePrevBgm(NA_BGM_MINI_BOSS); this->unk_2AE = true; } EnPametfrog_SetupJumpToLink(this); @@ -1255,7 +1255,7 @@ void EnPametfrog_SetupTransitionGekkoSnapper(EnPametfrog* this, PlayState* play) void EnPametfrog_TransitionGekkoSnapper(EnPametfrog* this, PlayState* play) { if (this->actor.params == GEKKO_INIT_SNAPPER) { - func_801A2E54(NA_BGM_MINI_BOSS); + Audio_PlayBgm_StorePrevBgm(NA_BGM_MINI_BOSS); EnPametfrog_SetupRunToSnapper(this); } } @@ -1267,7 +1267,7 @@ void EnPametfrog_ApplyDamageEffect(EnPametfrog* this, PlayState* play) { !(this->collider.elements->info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { if (this->actor.params == GEKKO_PRE_SNAPPER) { if (Actor_ApplyDamage(&this->actor) == 0) { - func_801A2ED8(); + Audio_RestorePrevBgm(); } if (this->actor.colChkInfo.damageEffect == GEKKO_DMGEFF_ZORA_BARRIER) { @@ -1303,7 +1303,7 @@ void EnPametfrog_ApplyDamageEffect(EnPametfrog* this, PlayState* play) { EnPametfrog_ApplyMagicArrowEffects(this, play); Enemy_StartFinishingBlow(play, &this->actor); this->actor.flags &= ~ACTOR_FLAG_1; - func_801A2ED8(); + Audio_RestorePrevBgm(); EnPametfrog_SetupCutscene(this); } else if (this->actor.colChkInfo.damageEffect == GEKKO_DMGEFF_ZORA_BARRIER) { EnPametfrog_ApplyElectricStun(this); diff --git a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c index 1d504dc621..5a25038083 100644 --- a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c +++ b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c @@ -377,7 +377,7 @@ void EnSyatekiDekunuts_Update(Actor* thisx, PlayState* play) { if ((this->actionFunc != func_80A2BF18) && (this->unk_1D8 < this->unk_1EE) && (this->unk_1D8 > 10)) { if ((this->collider.base.acFlags & AC_HIT) && (this->unk_1E2 == 1)) { if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) == 1) { - func_801A3098(NA_BGM_GET_ITEM | 0x900); + Audio_PlayFanfare(NA_BGM_GET_ITEM | 0x900); } else { play_sound(NA_SE_SY_TRE_BOX_APPEAR); } 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 a504ab5212..42f205bca4 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 @@ -395,7 +395,7 @@ void EnSyatekiMan_Swamp_HandleNormalMessage(EnSyatekiMan* this, PlayState* play) func_80123F2C(play, 80); this->shootingGameState = SG_GAME_STATE_RUNNING; this->actionFunc = EnSyatekiMan_Swamp_StartGame; - func_801A2BB8(NA_BGM_MINI_GAME_2); + func_801A2BB8(NA_BGM_TIMED_MINI_GAME); break; case 0xA32: // You have to try harder! @@ -753,7 +753,7 @@ void EnSyatekiMan_Town_HandleNormalMessage(EnSyatekiMan* this, PlayState* play) func_80112AFC(play); func_80123F2C(play, 0x63); this->shootingGameState = SG_GAME_STATE_RUNNING; - func_801A2BB8(NA_BGM_MINI_GAME_2); + func_801A2BB8(NA_BGM_TIMED_MINI_GAME); this->actionFunc = EnSyatekiMan_Town_StartGame; break; @@ -1349,7 +1349,7 @@ void EnSyatekiMan_Town_RunGame(EnSyatekiMan* this, PlayState* play) { func_801A2C20(); this->actionFunc = EnSyatekiMan_Town_EndGame; if (this->score == 50) { - func_801A3098(NA_BGM_GET_ITEM | 0x900); + Audio_PlayFanfare(NA_BGM_GET_ITEM | 0x900); func_8011B4E0(play, 1); } } diff --git a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c index 647b211829..b6a0f9ed40 100644 --- a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c +++ b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c @@ -424,7 +424,7 @@ void EnSyatekiWf_Update(Actor* thisx, PlayState* play2) { this->unk_34C.base.acFlags &= ~AC_HIT; this->actor.colChkInfo.health -= 2; if (this->actor.colChkInfo.health == 0) { - func_801A3098(NA_BGM_GET_ITEM | 0x900); + Audio_PlayFanfare(NA_BGM_GET_ITEM | 0x900); func_80A20858(this, play); } else { play_sound(NA_SE_SY_TRE_BOX_APPEAR); 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 ba375f583d..c0f0a3e89e 100644 --- a/src/overlays/actors/ovl_En_Test6/z_en_test6.c +++ b/src/overlays/actors/ovl_En_Test6/z_en_test6.c @@ -690,7 +690,7 @@ void func_80A92188(EnTest6* this, PlayState* play) { break; case 110: - func_801A3098(0x4A); + Audio_PlayFanfare(NA_BGM_SONG_OF_DOUBLE_TIME); break; case 38: 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 fcbb0223b6..e1223cddb4 100644 --- a/src/overlays/actors/ovl_En_Test7/z_en_test7.c +++ b/src/overlays/actors/ovl_En_Test7/z_en_test7.c @@ -409,7 +409,7 @@ void EnTest7_Init(Actor* thisx, PlayState* play2) { } else { func_80AF082C(this, func_80AF19A8); EnTest7_SetupAction(this, func_80AF2854); - func_801A2E54(NA_BGM_SONG_OF_SOARING); + Audio_PlayBgm_StorePrevBgm(NA_BGM_SONG_OF_SOARING); } if (play->playerActorCsIds[8] == -1) { @@ -677,8 +677,8 @@ void func_80AF2350(EnTest7* this, PlayState* play) { play->transitionTrigger = TRANS_TRIGGER_START; play->transitionType = TRANS_TYPE_02; - gSaveContext.seqIndex = 0xFF; - gSaveContext.nightSeqIndex = 0xFF; + gSaveContext.seqId = (u8)NA_BGM_DISABLED; + gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; } void func_80AF24D8(EnTest7* this, PlayState* play, f32 arg2) { diff --git a/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c b/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c index 4f302e2687..1ba5e6ebcd 100644 --- a/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c +++ b/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c @@ -247,8 +247,8 @@ void EnWarpTag_GrottoReturn(EnWarptag* this, PlayState* play) { func_8019F128(NA_SE_OC_SECRET_HOLE_OUT); func_801A4058(5); if (1) {} - gSaveContext.seqIndex = 0xFF; - gSaveContext.nightSeqIndex = 0xFF; + gSaveContext.seqId = (u8)NA_BGM_DISABLED; + gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; } } diff --git a/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c b/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c index 6c6d6e02ad..6cc8e2d048 100644 --- a/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c +++ b/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c @@ -60,7 +60,7 @@ void ObjDemo_Init(Actor* thisx, PlayState* play) { } void func_80983634(PlayState* play) { - if ((play->sceneId == SCENE_CASTLE) && (func_801A8A50(0) == NA_BGM_IKANA_CASTLE)) { + if ((play->sceneId == SCENE_CASTLE) && (Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN) == NA_BGM_IKANA_CASTLE)) { Audio_QueueSeqCmd(0x100100FF); } } diff --git a/src/overlays/actors/ovl_Obj_Um/z_obj_um.c b/src/overlays/actors/ovl_Obj_Um/z_obj_um.c index 9bae7169e0..7cb4f310f7 100644 --- a/src/overlays/actors/ovl_Obj_Um/z_obj_um.c +++ b/src/overlays/actors/ovl_Obj_Um/z_obj_um.c @@ -751,7 +751,7 @@ void ObjUm_Init(Actor* thisx, PlayState* play) { ObjUm_SetupAction(this, ObjUm_PostMilkRunStartCs); this->unk_354 = 0; ObjUm_RotatePlayer(this, play, 0); - func_801A3098(NA_BGM_CLEAR_EVENT); + Audio_PlayFanfare(NA_BGM_CLEAR_EVENT); } else { this->type = OBJ_UM_TYPE_TERMINA_FIELD; ObjUm_SetupAction(this, ObjUm_TerminaFieldIdle); @@ -1295,9 +1295,9 @@ void ObjUm_RunMinigame(ObjUm* this, PlayState* play) { switch (ObjUm_UpdatePath(this, play)) { case OBJUM_PATH_STATE_1: case OBJUM_PATH_STATE_FINISH: - gSaveContext.seqIndex = 0xFF; + gSaveContext.seqId = (u8)NA_BGM_DISABLED; gSaveContext.save.weekEventReg[31] &= (u8)~0x80; - gSaveContext.nightSeqIndex = 0xFF; + gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; if (!(gSaveContext.save.weekEventReg[52] & 1) && !(gSaveContext.save.weekEventReg[52] & 2)) { if (!this->areAllPotsBroken) { diff --git a/src/overlays/gamestates/ovl_select/z_select.c b/src/overlays/gamestates/ovl_select/z_select.c index 5d418c0fce..6ae0f5b6c3 100644 --- a/src/overlays/gamestates/ovl_select/z_select.c +++ b/src/overlays/gamestates/ovl_select/z_select.c @@ -41,8 +41,8 @@ void MapSelect_LoadGame(MapSelectState* this, u32 entrance, s32 spawn) { } gSaveContext.respawn[RESPAWN_MODE_DOWN].entrance = 0xFFFF; - gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; - gSaveContext.nightSeqIndex = 0xFF; + gSaveContext.seqId = (u8)NA_BGM_DISABLED; + gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; gSaveContext.showTitleCard = true; gSaveContext.respawnFlag = 0; gSaveContext.respawn[RESPAWN_MODE_GORON].entrance = 0xFF; diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.c index 352997f944..62d2a36d06 100644 --- a/src/overlays/gamestates/ovl_title/z_title.c +++ b/src/overlays/gamestates/ovl_title/z_title.c @@ -128,8 +128,8 @@ void ConsoleLogo_Main(GameState* thisx) { ConsoleLogo_UpdateCounters(this); ConsoleLogo_Draw(&this->state); if (this->exit) { - gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; - gSaveContext.nightSeqIndex = 0xFF; + gSaveContext.seqId = (u8)NA_BGM_DISABLED; + gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; gSaveContext.gameMode = 1; STOP_GAMESTATE(&this->state); diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 825059e332..571812b3f5 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -3851,12 +3851,12 @@ 0x8019D8E4:("AudioOcarina_CreateCustomSequence",), 0x8019DF28:("AudioOcarina_ResetInstrument",), 0x8019DF64:("AudioOcarina_ResetStaffs",), - 0x8019DFF8:("func_8019DFF8",), - 0x8019E000:("func_8019E000",), - 0x8019E00C:("func_8019E00C",), - 0x8019E014:("func_8019E014",), - 0x8019E0FC:("func_8019E0FC",), - 0x8019E104:("func_8019E104",), + 0x8019DFF8:("Audio_Noop1",), + 0x8019E000:("Audio_Noop2",), + 0x8019E00C:("Audio_Noop3",), + 0x8019E014:("Audio_Update",), + 0x8019E0FC:("Audio_Noop4",), + 0x8019E104:("Audio_Noop5",), 0x8019E110:("func_8019E110",), 0x8019E14C:("AudioSfx_ComputeVolume",), 0x8019E324:("AudioSfx_ComputeReverb",), @@ -3938,32 +3938,32 @@ 0x801A21FC:("Audio_PlaySariaBgm",), 0x801A2460:("Audio_ClearSariaBgm2",), 0x801A246C:("func_801A246C",), - 0x801A2544:("func_801A2544",), - 0x801A257C:("func_801A257C",), - 0x801A25E4:("func_801A25E4",), - 0x801A2670:("func_801A2670",), - 0x801A2778:("func_801A2778",), + 0x801A2544:("Audio_PlayMorningSceneSequence",), + 0x801A257C:("Audio_StartMorningSceneSequence",), + 0x801A25E4:("Audio_PlaySceneSequence",), + 0x801A2670:("Audio_StartSceneSequence",), + 0x801A2778:("Audio_UpdateSceneSequenceResumePoint",), 0x801A27E8:("func_801A27E8",), 0x801A281C:("func_801A281C",), 0x801A29D4:("func_801A29D4",), 0x801A2BB8:("func_801A2BB8",), 0x801A2C20:("func_801A2C20",), 0x801A2C44:("func_801A2C44",), - 0x801A2C88:("func_801A2C88",), - 0x801A2D54:("func_801A2D54",), + 0x801A2C88:("Audio_PlaySequenceInCutscene",), + 0x801A2D54:("Audio_StopSequenceInCutscene",), 0x801A2DE0:("Audio_IsSequencePlaying",), - 0x801A2E54:("func_801A2E54",), - 0x801A2ED8:("func_801A2ED8",), - 0x801A2F88:("func_801A2F88",), - 0x801A2FC4:("func_801A2FC4",), + 0x801A2E54:("Audio_PlayBgm_StorePrevBgm",), + 0x801A2ED8:("Audio_RestorePrevBgm",), + 0x801A2F88:("Audio_PlayAmbience_StorePrevBgm",), + 0x801A2FC4:("Audio_ForceRestorePreviousBgm",), 0x801A3000:("func_801A3000",), 0x801A3038:("func_801A3038",), - 0x801A3098:("func_801A3098",), + 0x801A3098:("Audio_PlayFanfare",), 0x801A312C:("func_801A312C",), 0x801A31EC:("func_801A31EC",), - 0x801A3238:("func_801A3238",), - 0x801A32CC:("func_801A32CC",), - 0x801A3590:("func_801A3590",), + 0x801A3238:("Audio_PlaySequenceWithSeqPlayerIO",), + 0x801A32CC:("Audio_SetSequenceMode",), + 0x801A3590:("Audio_UpdateEnemyBgmVolume",), 0x801A36F0:("func_801A36F0",), 0x801A3950:("func_801A3950",), 0x801A39F8:("func_801A39F8",), @@ -3982,7 +3982,7 @@ 0x801A3F6C:("func_801A3F6C",), 0x801A3FB4:("func_801A3FB4",), 0x801A3FFC:("func_801A3FFC",), - 0x801A400C:("audio_setBGM",), + 0x801A400C:("Audio_SetSpec",), 0x801A4058:("func_801A4058",), 0x801A41C8:("func_801A41C8",), 0x801A41F8:("func_801A41F8",), @@ -3993,15 +3993,15 @@ 0x801A4380:("Audio_SetSfxVolumeExceptSystemAndOcarinaBanks",), 0x801A4428:("func_801A4428",), 0x801A44A4:("Audio_PreNMI",), - 0x801A44C4:("func_801A44C4",), + 0x801A44C4:("Audio_ResetRequestedSceneSeqId",), 0x801A44D4:("func_801A44D4",), 0x801A46F8:("func_801A46F8",), 0x801A4748:("func_801A4748",), 0x801A479C:("func_801A479C",), - 0x801A47DC:("func_801A47DC",), - 0x801A48E0:("func_801A48E0",), - 0x801A4A28:("func_801A4A28",), - 0x801A4B80:("Audio_SetNatureAmbienceRandomBend",), + 0x801A47DC:("Audio_SetAmbienceChannelIO",), + 0x801A48E0:("Audio_StartAmbience",), + 0x801A4A28:("Audio_PlayAmbience",), + 0x801A4B80:("Audio_SetAmbienceRandomBend",), 0x801A4C30:("Audio_Init",), 0x801A4C54:("AudioSfx_Init",), 0x801A4D00:("func_801A4D00",), @@ -4053,11 +4053,11 @@ 0x801A78E4:("AudioSfx_IsPlaying",), 0x801A794C:("AudioSfx_Reset",), 0x801A7B10:("Audio_StartSequence",), - 0x801A7D04:("func_801A7D04",), + 0x801A7D04:("Audio_StopSequence",), 0x801A7D84:("func_801A7D84",), 0x801A89A8:("Audio_QueueSeqCmd",), 0x801A89D0:("func_801A89D0",), - 0x801A8A50:("func_801A8A50",), + 0x801A8A50:("Audio_GetActiveSequence",), 0x801A8ABC:("func_801A8ABC",), 0x801A8B14:("func_801A8B14",), 0x801A8B2C:("func_801A8B2C",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index daa1356f21..edf51ff57c 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -2280,11 +2280,11 @@ 0x801D66B8:("sAudioEnvReverb","UNK_TYPE1","",0x1), 0x801D66BC:("sAudioCodeReverb","UNK_TYPE1","",0x1), 0x801D66C0:("sPrevSeqMode","UNK_TYPE1","",0x1), - 0x801D66C4:("sAudioEnemyDist","f32","",0x4), - 0x801D66C8:("sAudioEnemyVol","UNK_TYPE1","",0x1), + 0x801D66C4:("sBgmEnemyDist","f32","",0x4), + 0x801D66C8:("sBgmEnemyVolume","UNK_TYPE1","",0x1), 0x801D66CC:("sPrevMainBgmSeqId","UNK_TYPE2","",0x2), - 0x801D66D0:("sBgmPlayerIOPort7","UNK_TYPE1","",0x1), - 0x801D66D4:("sSceneSeqId2","UNK_TYPE1","",0x1), + 0x801D66D0:("sSeqResumePoint","UNK_TYPE1","",0x1), + 0x801D66D4:("sPrevSceneSeqId","UNK_TYPE1","",0x1), 0x801D66D8:("sNumFramesStill","UNK_TYPE4","",0x4), 0x801D66DC:("sNumFramesMoving","UNK_TYPE4","",0x4), 0x801D66E0:("sAudioBaseFilter","UNK_TYPE1","",0x1), @@ -2297,7 +2297,7 @@ 0x801D66FC:("sObjSoundMainBgmSeqId","UNK_TYPE1","",0x1), 0x801D6700:("sSeqFlags","UNK_TYPE1","",0x1), 0x801D6780:("sSpecReverbs","UNK_TYPE1","",0x1), - 0x801D6794:("sNatureAmbienceData","UNK_TYPE1","",0x1), + 0x801D6794:("sAmbienceData","UNK_TYPE1","",0x1), 0x801D6FB4:("sIsOcarinaInputEnabled","UNK_TYPE1","",0x1), 0x801D6FB8:("sOcarinaInstrumentId","UNK_TYPE1","",0x1), 0x801D6FBC:("sCurOcarinaPitch","UNK_TYPE1","",0x1), @@ -4255,14 +4255,14 @@ 0x801FD294:("sSfxVolumeCur","UNK_TYPE1","",0x1), 0x801FD298:("sSfxVolumeTarget","UNK_TYPE1","",0x1), 0x801FD29C:("sSfxVolumeRate","UNK_TYPE1","",0x1), - 0x801FD2A0:("sSceneSeqId1","UNK_TYPE1","",0x1), + 0x801FD2A0:("sRequestedSceneSeqId","UNK_TYPE1","",0x1), 0x801FD2A8:("sSfxChannelState","UNK_TYPE1","",0x1), 0x801FD3A8:("D_801FD3A8","UNK_TYPE1","",0x1), 0x801FD3A9:("D_801FD3A9","UNK_TYPE1","",0x1), 0x801FD3AA:("sRiverSoundBgmTimer","UNK_TYPE1","",0x1), 0x801FD3AB:("sFanfareState","UNK_TYPE1","",0x1), 0x801FD3AC:("sFanfareSeqId","UNK_TYPE1","",0x1), - 0x801FD3AE:("sMuteOnlySfxAndNatureSeq","UNK_TYPE1","",0x1), + 0x801FD3AE:("sMuteOnlySfxAndAmbienceSeq","UNK_TYPE1","",0x1), 0x801FD3AF:("sAllPlayersMutedExceptOcaAndSys","UNK_TYPE1","",0x1), 0x801FD3B0:("sAudioPauseState","UNK_TYPE1","",0x1), 0x801FD3B4:("sSpatialSeqIsActive","u8","[4]",0x4), @@ -4288,7 +4288,7 @@ 0x801FD434:("D_801FD434","UNK_TYPE1","",0x1), 0x801FD435:("sSpatialSeqPlayerIndex","UNK_TYPE1","",0x1), 0x801FD436:("sSpatialSeqFadeTimer","UNK_TYPE1","",0x1), - 0x801FD438:("D_801FD438","UNK_TYPE1","",0x1), + 0x801FD438:("sPrevAmbienceSeqId","UNK_TYPE1","",0x1), 0x801FD43A:("sPlayingStaff","OcarinaStaff","",0x3), 0x801FD43E:("sPlaybackStaff","OcarinaStaff","",0x3), 0x801FD442:("sRecordingStaff","OcarinaStaff","",0x3), @@ -4346,7 +4346,7 @@ 0x8020001E:("D_8020001E","UNK_TYPE1","",0x1), 0x802000C9:("D_802000C9","UNK_TYPE1","",0x1), 0x802000D4:("D_802000D4","UNK_TYPE1","",0x1), - 0x80200140:("D_80200140","UNK_TYPE1","",0x1), + 0x80200140:("gActiveSeqs","UNK_TYPE1","",0x1), 0x8020034A:("D_8020034A","UNK_TYPE1","",0x1), 0x80200B88:("D_80200B88","UNK_TYPE1","",0x1), 0x80200BBA:("D_80200BBA","UNK_TYPE1","",0x1), diff --git a/tools/namefixer.py b/tools/namefixer.py index eab13f0b95..f78717d40b 100755 --- a/tools/namefixer.py +++ b/tools/namefixer.py @@ -148,6 +148,17 @@ wordReplace = { "func_801A5BD0": "AudioSfx_MuteBanks", "func_801A72CC": "AudioSfx_StopByPos", "Audio_StopSfxByPos": "AudioSfx_StopByPos", + "func_801A3098": "Audio_PlayFanfare", + "func_801A8A50": "Audio_GetActiveSequence", + "func_801A2E54": "Audio_PlayBgm_StorePrevBgm", + "func_801A2ED8": "Audio_RestorePrevBgm", + "func_801A2544": "Audio_PlayMorningSceneSequence", + "func_801A25E4": "Audio_PlaySceneSequence", + "func_801A3238": "Audio_PlaySequenceWithSeqPlayerIO", + "func_801A32CC": "Audio_SetSequenceMode", + "func_801A3590": "Audio_UpdateEnemyBgmVolume", + "func_801A47DC": "Audio_SetAmbienceChannelIO", + "func_801A4A28": "Audio_PlayAmbience", "func_801A7328": "AudioSfx_StopByPosAndId", "func_801A75E8": "AudioSfx_StopById", "SkelAnime_LodDrawLimb": "SkelAnime_DrawLimbLod", @@ -690,6 +701,8 @@ wordReplace = { "gSaveContext.unk_3F30": "gSaveContext.magicFillTarget", "gSaveContext.unk_3F2C": "gSaveContext.magicFlag", "gSaveContext.save.entranceIndex": "gSaveContext.save.entrance", + "gSaveContext.seqIndex": "gSaveContext.seqId", + "gSaveContext.nightSeqIndex": "gSaveContext.ambienceId", "player->unk_A87": "player->exchangeItemId", "player->leftHandActor": "player->heldActor", diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index ecdba5264a..dcb030e31f 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -3367,12 +3367,12 @@ asm/non_matchings/code/code_8019AF00/AudioOcarina_PlayCustomSequence.s,AudioOcar asm/non_matchings/code/code_8019AF00/AudioOcarina_CreateCustomSequence.s,AudioOcarina_CreateCustomSequence,0x8019D8E4,0x191 asm/non_matchings/code/code_8019AF00/AudioOcarina_ResetInstrument.s,AudioOcarina_ResetInstrument,0x8019DF28,0xF asm/non_matchings/code/code_8019AF00/AudioOcarina_ResetStaffs.s,AudioOcarina_ResetStaffs,0x8019DF64,0x25 -asm/non_matchings/code/code_8019AF00/func_8019DFF8.s,func_8019DFF8,0x8019DFF8,0x2 -asm/non_matchings/code/code_8019AF00/func_8019E000.s,func_8019E000,0x8019E000,0x3 -asm/non_matchings/code/code_8019AF00/func_8019E00C.s,func_8019E00C,0x8019E00C,0x2 -asm/non_matchings/code/code_8019AF00/func_8019E014.s,func_8019E014,0x8019E014,0x3A -asm/non_matchings/code/code_8019AF00/func_8019E0FC.s,func_8019E0FC,0x8019E0FC,0x2 -asm/non_matchings/code/code_8019AF00/func_8019E104.s,func_8019E104,0x8019E104,0x3 +asm/non_matchings/code/code_8019AF00/Audio_Noop1.s,Audio_Noop1,0x8019DFF8,0x2 +asm/non_matchings/code/code_8019AF00/Audio_Noop2.s,Audio_Noop2,0x8019E000,0x3 +asm/non_matchings/code/code_8019AF00/Audio_Noop3.s,Audio_Noop3,0x8019E00C,0x2 +asm/non_matchings/code/code_8019AF00/Audio_Update.s,Audio_Update,0x8019E014,0x3A +asm/non_matchings/code/code_8019AF00/Audio_Noop4.s,Audio_Noop4,0x8019E0FC,0x2 +asm/non_matchings/code/code_8019AF00/Audio_Noop5.s,Audio_Noop5,0x8019E104,0x3 asm/non_matchings/code/code_8019AF00/func_8019E110.s,func_8019E110,0x8019E110,0xF asm/non_matchings/code/code_8019AF00/AudioSfx_ComputeVolume.s,AudioSfx_ComputeVolume,0x8019E14C,0x76 asm/non_matchings/code/code_8019AF00/AudioSfx_ComputeReverb.s,AudioSfx_ComputeReverb,0x8019E324,0x63 @@ -3454,32 +3454,32 @@ asm/non_matchings/code/code_8019AF00/func_801A2090.s,func_801A2090,0x801A2090,0x asm/non_matchings/code/code_8019AF00/Audio_PlaySariaBgm.s,Audio_PlaySariaBgm,0x801A21FC,0x99 asm/non_matchings/code/code_8019AF00/Audio_ClearSariaBgm2.s,Audio_ClearSariaBgm2,0x801A2460,0x3 asm/non_matchings/code/code_8019AF00/func_801A246C.s,func_801A246C,0x801A246C,0x36 -asm/non_matchings/code/code_8019AF00/func_801A2544.s,func_801A2544,0x801A2544,0xE -asm/non_matchings/code/code_8019AF00/func_801A257C.s,func_801A257C,0x801A257C,0x1A -asm/non_matchings/code/code_8019AF00/func_801A25E4.s,func_801A25E4,0x801A25E4,0x23 -asm/non_matchings/code/code_8019AF00/func_801A2670.s,func_801A2670,0x801A2670,0x42 -asm/non_matchings/code/code_8019AF00/func_801A2778.s,func_801A2778,0x801A2778,0x1C +asm/non_matchings/code/code_8019AF00/Audio_PlayMorningSceneSequence.s,Audio_PlayMorningSceneSequence,0x801A2544,0xE +asm/non_matchings/code/code_8019AF00/Audio_StartMorningSceneSequence.s,Audio_StartMorningSceneSequence,0x801A257C,0x1A +asm/non_matchings/code/code_8019AF00/Audio_PlaySceneSequence.s,Audio_PlaySceneSequence,0x801A25E4,0x23 +asm/non_matchings/code/code_8019AF00/Audio_StartSceneSequence.s,Audio_StartSceneSequence,0x801A2670,0x42 +asm/non_matchings/code/code_8019AF00/Audio_UpdateSceneSequenceResumePoint.s,Audio_UpdateSceneSequenceResumePoint,0x801A2778,0x1C asm/non_matchings/code/code_8019AF00/func_801A27E8.s,func_801A27E8,0x801A27E8,0xD asm/non_matchings/code/code_8019AF00/func_801A281C.s,func_801A281C,0x801A281C,0x6E asm/non_matchings/code/code_8019AF00/func_801A29D4.s,func_801A29D4,0x801A29D4,0x79 asm/non_matchings/code/code_8019AF00/func_801A2BB8.s,func_801A2BB8,0x801A2BB8,0x1A asm/non_matchings/code/code_8019AF00/func_801A2C20.s,func_801A2C20,0x801A2C20,0x9 asm/non_matchings/code/code_8019AF00/func_801A2C44.s,func_801A2C44,0x801A2C44,0x11 -asm/non_matchings/code/code_8019AF00/func_801A2C88.s,func_801A2C88,0x801A2C88,0x33 -asm/non_matchings/code/code_8019AF00/func_801A2D54.s,func_801A2D54,0x801A2D54,0x23 +asm/non_matchings/code/code_8019AF00/Audio_PlaySequenceInCutscene.s,Audio_PlaySequenceInCutscene,0x801A2C88,0x33 +asm/non_matchings/code/code_8019AF00/Audio_StopSequenceInCutscene.s,Audio_StopSequenceInCutscene,0x801A2D54,0x23 asm/non_matchings/code/code_8019AF00/Audio_IsSequencePlaying.s,Audio_IsSequencePlaying,0x801A2DE0,0x1D -asm/non_matchings/code/code_8019AF00/func_801A2E54.s,func_801A2E54,0x801A2E54,0x21 -asm/non_matchings/code/code_8019AF00/func_801A2ED8.s,func_801A2ED8,0x801A2ED8,0x2C -asm/non_matchings/code/code_8019AF00/func_801A2F88.s,func_801A2F88,0x801A2F88,0xF -asm/non_matchings/code/code_8019AF00/func_801A2FC4.s,func_801A2FC4,0x801A2FC4,0xF +asm/non_matchings/code/code_8019AF00/Audio_PlayBgm_StorePrevBgm.s,Audio_PlayBgm_StorePrevBgm,0x801A2E54,0x21 +asm/non_matchings/code/code_8019AF00/Audio_RestorePrevBgm.s,Audio_RestorePrevBgm,0x801A2ED8,0x2C +asm/non_matchings/code/code_8019AF00/Audio_PlayAmbience_StorePrevBgm.s,Audio_PlayAmbience_StorePrevBgm,0x801A2F88,0xF +asm/non_matchings/code/code_8019AF00/Audio_ForceRestorePreviousBgm.s,Audio_ForceRestorePreviousBgm,0x801A2FC4,0xF asm/non_matchings/code/code_8019AF00/func_801A3000.s,func_801A3000,0x801A3000,0xE asm/non_matchings/code/code_8019AF00/func_801A3038.s,func_801A3038,0x801A3038,0x18 -asm/non_matchings/code/code_8019AF00/func_801A3098.s,func_801A3098,0x801A3098,0x25 +asm/non_matchings/code/code_8019AF00/Audio_PlayFanfare.s,Audio_PlayFanfare,0x801A3098,0x25 asm/non_matchings/code/code_8019AF00/func_801A312C.s,func_801A312C,0x801A312C,0x30 asm/non_matchings/code/code_8019AF00/func_801A31EC.s,func_801A31EC,0x801A31EC,0x13 -asm/non_matchings/code/code_8019AF00/func_801A3238.s,func_801A3238,0x801A3238,0x25 -asm/non_matchings/code/code_8019AF00/func_801A32CC.s,func_801A32CC,0x801A32CC,0xB1 -asm/non_matchings/code/code_8019AF00/func_801A3590.s,func_801A3590,0x801A3590,0x58 +asm/non_matchings/code/code_8019AF00/Audio_PlaySequenceWithSeqPlayerIO.s,Audio_PlaySequenceWithSeqPlayerIO,0x801A3238,0x25 +asm/non_matchings/code/code_8019AF00/Audio_SetSequenceMode.s,Audio_SetSequenceMode,0x801A32CC,0xB1 +asm/non_matchings/code/code_8019AF00/Audio_UpdateEnemyBgmVolume.s,Audio_UpdateEnemyBgmVolume,0x801A3590,0x58 asm/non_matchings/code/code_8019AF00/func_801A36F0.s,func_801A36F0,0x801A36F0,0x98 asm/non_matchings/code/code_8019AF00/func_801A3950.s,func_801A3950,0x801A3950,0x2A asm/non_matchings/code/code_8019AF00/func_801A39F8.s,func_801A39F8,0x801A39F8,0x21 @@ -3498,7 +3498,7 @@ asm/non_matchings/code/code_8019AF00/Audio_SetCutsceneFlag.s,Audio_SetCutsceneFl asm/non_matchings/code/code_8019AF00/func_801A3F6C.s,func_801A3F6C,0x801A3F6C,0x12 asm/non_matchings/code/code_8019AF00/func_801A3FB4.s,func_801A3FB4,0x801A3FB4,0x12 asm/non_matchings/code/code_8019AF00/func_801A3FFC.s,func_801A3FFC,0x801A3FFC,0x4 -asm/non_matchings/code/code_8019AF00/audio_setBGM.s,audio_setBGM,0x801A400C,0x13 +asm/non_matchings/code/code_8019AF00/Audio_SetSpec.s,Audio_SetSpec,0x801A400C,0x13 asm/non_matchings/code/code_8019AF00/func_801A4058.s,func_801A4058,0x801A4058,0x5C asm/non_matchings/code/code_8019AF00/func_801A41C8.s,func_801A41C8,0x801A41C8,0xC asm/non_matchings/code/code_8019AF00/func_801A41F8.s,func_801A41F8,0x801A41F8,0x29 @@ -3509,15 +3509,15 @@ asm/non_matchings/code/code_8019AF00/func_801A4348.s,func_801A4348,0x801A4348,0x asm/non_matchings/code/code_8019AF00/Audio_SetSfxVolumeExceptSystemAndOcarinaBanks.s,Audio_SetSfxVolumeExceptSystemAndOcarinaBanks,0x801A4380,0x2A asm/non_matchings/code/code_8019AF00/func_801A4428.s,func_801A4428,0x801A4428,0x1F asm/non_matchings/code/code_8019AF00/Audio_PreNMI.s,Audio_PreNMI,0x801A44A4,0x8 -asm/non_matchings/code/code_8019AF00/func_801A44C4.s,func_801A44C4,0x801A44C4,0x4 +asm/non_matchings/code/code_8019AF00/Audio_ResetRequestedSceneSeqId.s,Audio_ResetRequestedSceneSeqId,0x801A44C4,0x4 asm/non_matchings/code/code_8019AF00/func_801A44D4.s,func_801A44D4,0x801A44D4,0x89 asm/non_matchings/code/code_8019AF00/func_801A46F8.s,func_801A46F8,0x801A46F8,0x14 asm/non_matchings/code/code_8019AF00/func_801A4748.s,func_801A4748,0x801A4748,0x15 asm/non_matchings/code/code_8019AF00/func_801A479C.s,func_801A479C,0x801A479C,0x10 -asm/non_matchings/code/code_8019AF00/func_801A47DC.s,func_801A47DC,0x801A47DC,0x41 -asm/non_matchings/code/code_8019AF00/func_801A48E0.s,func_801A48E0,0x801A48E0,0x52 -asm/non_matchings/code/code_8019AF00/func_801A4A28.s,func_801A4A28,0x801A4A28,0x56 -asm/non_matchings/code/code_8019AF00/Audio_SetNatureAmbienceRandomBend.s,Audio_SetNatureAmbienceRandomBend,0x801A4B80,0x2C +asm/non_matchings/code/code_8019AF00/Audio_SetAmbienceChannelIO.s,Audio_SetAmbienceChannelIO,0x801A47DC,0x41 +asm/non_matchings/code/code_8019AF00/Audio_StartAmbience.s,Audio_StartAmbience,0x801A48E0,0x52 +asm/non_matchings/code/code_8019AF00/Audio_PlayAmbience.s,Audio_PlayAmbience,0x801A4A28,0x56 +asm/non_matchings/code/code_8019AF00/Audio_SetAmbienceRandomBend.s,Audio_SetAmbienceRandomBend,0x801A4B80,0x2C asm/non_matchings/code/code_8019AF00/Audio_Init.s,Audio_Init,0x801A4C30,0x9 asm/non_matchings/code/code_8019AF00/AudioSfx_Init.s,AudioSfx_Init,0x801A4C54,0x2B asm/non_matchings/code/code_8019AF00/func_801A4D00.s,func_801A4D00,0x801A4D00,0x14 @@ -3569,11 +3569,11 @@ asm/non_matchings/code/code_801A5BD0/AudioSfx_ProcessActiveSfx.s,AudioSfx_Proces asm/non_matchings/code/code_801A5BD0/AudioSfx_IsPlaying.s,AudioSfx_IsPlaying,0x801A78E4,0x1A asm/non_matchings/code/code_801A5BD0/AudioSfx_Reset.s,AudioSfx_Reset,0x801A794C,0x71 asm/non_matchings/code/code_801A7B10/Audio_StartSequence.s,Audio_StartSequence,0x801A7B10,0x7D -asm/non_matchings/code/code_801A7B10/func_801A7D04.s,func_801A7D04,0x801A7D04,0x20 +asm/non_matchings/code/code_801A7B10/Audio_StopSequence.s,Audio_StopSequence,0x801A7D04,0x20 asm/non_matchings/code/code_801A7B10/func_801A7D84.s,func_801A7D84,0x801A7D84,0x309 asm/non_matchings/code/code_801A7B10/Audio_QueueSeqCmd.s,Audio_QueueSeqCmd,0x801A89A8,0xA asm/non_matchings/code/code_801A7B10/func_801A89D0.s,func_801A89D0,0x801A89D0,0x20 -asm/non_matchings/code/code_801A7B10/func_801A8A50.s,func_801A8A50,0x801A8A50,0x1B +asm/non_matchings/code/code_801A7B10/Audio_GetActiveSequence.s,Audio_GetActiveSequence,0x801A8A50,0x1B asm/non_matchings/code/code_801A7B10/func_801A8ABC.s,func_801A8ABC,0x801A8ABC,0x16 asm/non_matchings/code/code_801A7B10/func_801A8B14.s,func_801A8B14,0x801A8B14,0x6 asm/non_matchings/code/code_801A7B10/func_801A8B2C.s,func_801A8B2C,0x801A8B2C,0x29 From 6ff53e448b669b2894f543868367a4a65ebf8a69 Mon Sep 17 00:00:00 2001 From: SonicDcer <96613413+sonicdcer@users.noreply.github.com> Date: Fri, 30 Sep 2022 11:50:59 -0300 Subject: [PATCH 02/25] ovl_Oceff_Wipe OK (#1008) * ovl_Oceff_Wipe Decompiled * format * format * pr review * renaming * renamings * renamings * magic * pr review --- assets/xml/overlays/ovl_Oceff_Wipe.xml | 10 ++ spec | 4 +- .../actors/ovl_Oceff_Wipe/z_oceff_wipe.c | 99 +++++++++++++++++-- .../actors/ovl_Oceff_Wipe/z_oceff_wipe.h | 7 +- 4 files changed, 110 insertions(+), 10 deletions(-) create mode 100644 assets/xml/overlays/ovl_Oceff_Wipe.xml diff --git a/assets/xml/overlays/ovl_Oceff_Wipe.xml b/assets/xml/overlays/ovl_Oceff_Wipe.xml new file mode 100644 index 0000000000..17a056175a --- /dev/null +++ b/assets/xml/overlays/ovl_Oceff_Wipe.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/spec b/spec index 0b500363a4..6b4395bb1b 100644 --- a/spec +++ b/spec @@ -1730,9 +1730,7 @@ beginseg name "ovl_Oceff_Wipe" compress include "build/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.o" - include "build/data/ovl_Oceff_Wipe/ovl_Oceff_Wipe.data.o" - include "build/data/ovl_Oceff_Wipe/ovl_Oceff_Wipe.bss.o" - include "build/data/ovl_Oceff_Wipe/ovl_Oceff_Wipe.reloc.o" + include "build/src/overlays/actors/ovl_Oceff_Wipe/ovl_Oceff_Wipe_reloc.o" endseg beginseg 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 661c13a1b0..ef1fa10350 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c +++ b/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c @@ -15,7 +15,6 @@ void OceffWipe_Destroy(Actor* thisx, PlayState* play); void OceffWipe_Update(Actor* thisx, PlayState* play); void OceffWipe_Draw(Actor* thisx, PlayState* play); -#if 0 const ActorInit Oceff_Wipe_InitVars = { ACTOR_OCEFF_WIPE, ACTORCAT_ITEMACTION, @@ -28,12 +27,100 @@ const ActorInit Oceff_Wipe_InitVars = { (ActorFunc)OceffWipe_Draw, }; -#endif +UNK_TYPE4 D_80977200; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe/OceffWipe_Init.s") +void OceffWipe_Init(Actor* thisx, PlayState* play) { + OceffWipe* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe/OceffWipe_Destroy.s") + Actor_SetScale(&this->actor, 0.1f); + this->counter = 0; + this->actor.world.pos = GET_ACTIVE_CAM(play)->eye; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe/OceffWipe_Update.s") +void OceffWipe_Destroy(Actor* thisx, PlayState* play) { + OceffWipe* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe/OceffWipe_Draw.s") + Magic_Reset(play); + play->msgCtx.unk120B0 = 0; +} + +void OceffWipe_Update(Actor* thisx, PlayState* play) { + OceffWipe* this = THIS; + + this->actor.world.pos = GET_ACTIVE_CAM(play)->eye; + if (this->counter < 100) { + this->counter++; + } else { + Actor_MarkForDeath(&this->actor); + } +} + +#include "assets/overlays/ovl_Oceff_Wipe/ovl_Oceff_Wipe.c" + +static u8 sAlphaIndices[] = { + 0x01, 0x10, 0x22, 0x01, 0x20, 0x12, 0x01, 0x20, 0x12, 0x01, + 0x10, 0x22, 0x01, 0x20, 0x12, 0x01, 0x12, 0x21, 0x01, 0x02, +}; + +void OceffWipe_Draw(Actor* thisx, PlayState* play) { + u32 scroll = play->state.frames & 0xFF; + OceffWipe* this = THIS; + f32 z; + s32 pad; + u8 alphaTable[3]; + s32 i; + Vec3f eye = GET_ACTIVE_CAM(play)->eye; + Vtx* vtxPtr; + Vec3f quakeOffset; + + Camera_GetQuakeOffset(&quakeOffset, GET_ACTIVE_CAM(play)); + + OPEN_DISPS(play->state.gfxCtx); + + if (this->counter < 32) { + z = Math_SinS(this->counter << 9) * 1360.0f; + } else { + z = 1360.0f; + } + + if (this->counter >= 80) { + alphaTable[0] = 0; + alphaTable[1] = (100 - this->counter) * 8; + alphaTable[2] = (100 - this->counter) * 12; + } else { + alphaTable[0] = 0; + alphaTable[1] = 160; + alphaTable[2] = 255; + } + + for (i = 0; i < 20; i++) { + vtxPtr = sSongOfTimeFrustumVtx; + vtxPtr[i * 2 + 0].v.cn[3] = alphaTable[(sAlphaIndices[i] & 0xF0) >> 4]; + vtxPtr[i * 2 + 1].v.cn[3] = alphaTable[sAlphaIndices[i] & 0xF]; + } + + func_8012C2DC(play->state.gfxCtx); + + Matrix_Translate(eye.x + quakeOffset.x, eye.y + quakeOffset.y, eye.z + quakeOffset.z, MTXMODE_NEW); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + Matrix_ReplaceRotation(&play->billboardMtxF); + Matrix_RotateXS(0x708, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -z, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (this->actor.params != OCEFF_WIPE_ZL) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 170, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 150, 255, 128); + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 100, 0, 255, 128); + } + + gSPDisplayList(POLY_XLU_DISP++, sSongOfTimeFrustumMaterialDL); + gSPDisplayList(POLY_XLU_DISP++, Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, 0 - scroll, scroll * -2, 32, + 32, 1, 0 - scroll, scroll * -2, 32, 32)); + gSPDisplayList(POLY_XLU_DISP++, sSongOfTimeFrustumModelDL); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.h b/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.h index 5b7e348375..6828c996d3 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.h +++ b/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.h @@ -3,11 +3,16 @@ #include "global.h" +typedef enum { + /* 0x0 */ OCEFF_WIPE_ZL, + /* 0x1 */ OCEFF_WIPE_SOT +} OceffWipeType; + struct OceffWipe; typedef struct OceffWipe { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x4]; + /* 0x144 */ s16 counter; } OceffWipe; // size = 0x148 extern const ActorInit Oceff_Wipe_InitVars; From 1be5a7d2c7e63880faaf10d359c15ada7673f386 Mon Sep 17 00:00:00 2001 From: SonicDcer <96613413+sonicdcer@users.noreply.github.com> Date: Fri, 30 Sep 2022 12:37:01 -0300 Subject: [PATCH 03/25] ovl_Oceff_Wipe5 OK (#1011) * progress * progress * ovl_Oceff_Wipe5 OK * Co-authored-by: Derek-Hensley hensley.derek58@gmail.com * Co-authored-by: Synray synray@users.noreply.github.com * Co-authored-by: darkeye darkeye@users.noreply.github.com * pr review * pr review * Magic_Reset * fixes --- assets/xml/overlays/ovl_Oceff_Wipe5.xml | 9 ++ spec | 4 +- .../actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c | 103 +++++++++++++++++- .../actors/ovl_Oceff_Wipe5/z_oceff_wipe5.h | 4 +- 4 files changed, 110 insertions(+), 10 deletions(-) create mode 100644 assets/xml/overlays/ovl_Oceff_Wipe5.xml diff --git a/assets/xml/overlays/ovl_Oceff_Wipe5.xml b/assets/xml/overlays/ovl_Oceff_Wipe5.xml new file mode 100644 index 0000000000..52f197428b --- /dev/null +++ b/assets/xml/overlays/ovl_Oceff_Wipe5.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/spec b/spec index 6b4395bb1b..b4a8a61082 100644 --- a/spec +++ b/spec @@ -4363,9 +4363,7 @@ beginseg name "ovl_Oceff_Wipe5" compress include "build/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.o" - include "build/data/ovl_Oceff_Wipe5/ovl_Oceff_Wipe5.data.o" - include "build/data/ovl_Oceff_Wipe5/ovl_Oceff_Wipe5.bss.o" - include "build/data/ovl_Oceff_Wipe5/ovl_Oceff_Wipe5.reloc.o" + include "build/src/overlays/actors/ovl_Oceff_Wipe5/ovl_Oceff_Wipe5_reloc.o" endseg beginseg 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 1bef04db8b..951ba1c39a 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c +++ b/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c @@ -15,7 +15,6 @@ void OceffWipe5_Destroy(Actor* thisx, PlayState* play); void OceffWipe5_Update(Actor* thisx, PlayState* play); void OceffWipe5_Draw(Actor* thisx, PlayState* play); -#if 0 const ActorInit Oceff_Wipe5_InitVars = { ACTOR_OCEFF_WIPE5, ACTORCAT_ITEMACTION, @@ -28,12 +27,104 @@ const ActorInit Oceff_Wipe5_InitVars = { (ActorFunc)OceffWipe5_Draw, }; -#endif +UNK_TYPE4 D_80BC9260; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe5/OceffWipe5_Init.s") +void OceffWipe5_Init(Actor* thisx, PlayState* play) { + OceffWipe5* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe5/OceffWipe5_Destroy.s") + Actor_SetScale(&this->actor, 1.0f); + this->counter = 0; + this->actor.world.pos = play->cameraPtrs[play->activeCamId]->eye; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe5/OceffWipe5_Update.s") +void OceffWipe5_Destroy(Actor* thisx, PlayState* play) { + OceffWipe5* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe5/OceffWipe5_Draw.s") + Magic_Reset(play); + play->msgCtx.unk120B0 = 0; +} + +void OceffWipe5_Update(Actor* thisx, PlayState* play) { + OceffWipe5* this = THIS; + + this->actor.world.pos = GET_ACTIVE_CAM(play)->eye; + if (this->counter < 100) { + this->counter++; + } else { + Actor_MarkForDeath(&this->actor); + } +} + +#include "assets/overlays/ovl_Oceff_Wipe5/ovl_Oceff_Wipe5.c" + +static u8 sPrimColors[] = { + 255, 255, 200, 255, 255, 200, 200, 255, 255, 255, 255, 200, 255, 200, 255, +}; + +static u8 sEnvColors[] = { + 50, 200, 0, 255, 50, 0, 0, 100, 255, 255, 150, 0, 255, 0, 200, +}; + +void OceffWipe5_Draw(Actor* thisx, PlayState* play) { + OceffWipe5* this = THIS; + f32 z; + s32 pad; + s32 i; + s32 pad2; + Vec3f activeCamEye = GET_ACTIVE_CAM(play)->eye; + Camera* cam = GET_ACTIVE_CAM(play); + Vec3f quakeOffset; + u8 alpha; + s32 colorIndex = OCEFF_WIPE5_GET_SONG_TYPE(thisx) * 3; + f32 phi_fv1 = 1220.0f; + + if ((((OCEFF_WIPE5_GET_SONG_TYPE(thisx) == 2) && (play->sceneId == SCENE_LABO)) && + ((play->csCtx.currentCsIndex == 0) || (play->csCtx.currentCsIndex == 1))) && + (play->csCtx.state != 0)) { + phi_fv1 = 1150.0f; + } + + if (colorIndex >= 13) { + colorIndex = 0; + } + + Camera_GetQuakeOffset(&quakeOffset, cam); + + if (this->counter < 32) { + z = Math_SinS(this->counter << 9) * phi_fv1; + } else { + z = phi_fv1; + } + + if (this->counter >= 80) { + alpha = 12 * (100 - this->counter); + } else { + alpha = 255; + } + for (i = 1; i < ARRAY_COUNT(gOceff5Vtx); i += 2) { + gOceff5Vtx[i].v.cn[3] = alpha; + } + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C2DC(play->state.gfxCtx); + + Matrix_Translate(activeCamEye.x + quakeOffset.x, activeCamEye.y + quakeOffset.y, activeCamEye.z + quakeOffset.z, + MTXMODE_NEW); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + Matrix_ReplaceRotation(&play->billboardMtxF); + Matrix_RotateXS(0x708, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -z, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, sPrimColors[colorIndex], sPrimColors[colorIndex + 1], + sPrimColors[colorIndex + 2], 255); + gDPSetEnvColor(POLY_XLU_DISP++, sEnvColors[colorIndex], sEnvColors[colorIndex + 1], sEnvColors[colorIndex + 2], + 255); + + AnimatedMat_Draw(play, gOceff5TexAnim); + + gSPDisplayList(POLY_XLU_DISP++, &gOceff5DL); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.h b/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.h index 063d0386b8..05424ea1ef 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.h +++ b/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.h @@ -3,11 +3,13 @@ #include "global.h" +#define OCEFF_WIPE5_GET_SONG_TYPE(thisx) ((thisx)->params & 0xF) + struct OceffWipe5; typedef struct OceffWipe5 { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x4]; + /* 0x144 */ s16 counter; } OceffWipe5; // size = 0x148 extern const ActorInit Oceff_Wipe5_InitVars; From 42a8bf68765830f94e2625eef6c5d52f648a9664 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Fri, 30 Sep 2022 12:15:43 -0700 Subject: [PATCH 04/25] Document BgCraceMovebg (sliding doors in Deku Shrine) and object_crace_object (#1101) * Document BgCraceMovebg (sliding doors in Deku Shrine) and object_crace_object * Respond to Elliptic's review * Fix build issue * Respond to Elliptic's second review * ACTUALLY put the BSS above the data, forgot the InitVars were data * Respond to hensldm's review --- assets/xml/objects/object_crace_object.xml | 9 +- .../ovl_Bg_Crace_Movebg/z_bg_crace_movebg.c | 334 ++++++++++-------- .../ovl_Bg_Crace_Movebg/z_bg_crace_movebg.h | 35 +- src/overlays/actors/ovl_En_Dno/z_en_dno.c | 27 +- src/overlays/actors/ovl_En_Dno/z_en_dno.h | 21 +- tools/disasm/functions.txt | 32 +- tools/disasm/variables.txt | 10 +- 7 files changed, 265 insertions(+), 203 deletions(-) diff --git a/assets/xml/objects/object_crace_object.xml b/assets/xml/objects/object_crace_object.xml index 06c007989d..af0cb89e0a 100644 --- a/assets/xml/objects/object_crace_object.xml +++ b/assets/xml/objects/object_crace_object.xml @@ -1,8 +1,9 @@  + - - - - + + + + diff --git a/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.c b/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.c index 1a0cb50586..9a4f0849a7 100644 --- a/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.c +++ b/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.c @@ -5,6 +5,7 @@ */ #include "z_bg_crace_movebg.h" +#include "overlays/actors/ovl_En_Dno/z_en_dno.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,22 +16,30 @@ void BgCraceMovebg_Destroy(Actor* thisx, PlayState* play); void BgCraceMovebg_Update(Actor* thisx, PlayState* play); void BgCraceMovebg_Draw(Actor* thisx, PlayState* play); -s32 func_80A7090C(PlayState* play); -void func_80A70970(BgCraceMovebg* this, PlayState* play); -void func_80A7099C(BgCraceMovebg* this, PlayState* play); -void func_80A709E4(BgCraceMovebg* this, PlayState* play); -void func_80A70A08(BgCraceMovebg* this, PlayState* play); -void func_80A70A84(BgCraceMovebg* this, PlayState* play); -void func_80A70A9C(BgCraceMovebg* this, PlayState* play); -void func_80A70C04(BgCraceMovebg* this, PlayState* play); -void func_80A70D74(BgCraceMovebg* this, PlayState* play); -void func_80A70DA8(BgCraceMovebg* this, PlayState* play); -void func_80A70E2C(BgCraceMovebg* this, PlayState* play); -void func_80A70E70(BgCraceMovebg* this, PlayState* play); -void func_80A70F14(BgCraceMovebg* this, PlayState* play); -void func_80A70F2C(BgCraceMovebg* this, PlayState* play); -void func_80A70FF4(BgCraceMovebg* this, PlayState* play); -void func_80A71040(BgCraceMovebg* this, PlayState* play); +s32 BgCraceMovebg_GetRaceStatus(PlayState* play); +void BgCraceMovebg_OpeningDoor_SetupIdle(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_OpeningDoor_Idle(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_OpeningDoor_SetupOpen(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_OpeningDoor_Open(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_OpeningDoor_SetupDoNothing(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_OpeningDoor_DoNothing(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_ClosingDoor_CheckIfPlayerIsBeyondDoor(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_ClosingDoor_SetupIdle(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_ClosingDoor_Idle(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_ClosingDoor_SetupWaitToClose(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_ClosingDoor_WaitToClose(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_ClosingDoor_SetupClose(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_ClosingDoor_Close(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_ClosingDoor_SetupDoNothing(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_ClosingDoor_DoNothing(BgCraceMovebg* this, PlayState* play); + +typedef enum { + /* 0 */ BG_CRACE_MOVEBG_RACE_STATUS_BUTLER_NOT_PRESENT, + /* 1 */ BG_CRACE_MOVEBG_RACE_STATUS_FIRST_RACE, + /* 2 */ BG_CRACE_MOVEBG_RACE_STATUS_SUBSEQUENT_RACE +} BgCraceMovebgRaceStatus; + +u8 sIsLoaded[32]; const ActorInit Bg_Crace_Movebg_InitVars = { ACTOR_BG_CRACE_MOVEBG, @@ -44,13 +53,14 @@ const ActorInit Bg_Crace_Movebg_InitVars = { (ActorFunc)BgCraceMovebg_Draw, }; -static u8 D_80A710A0 = 0; -static u8 D_80A710A4 = 0; +static u8 sHasInitializedIsLoaded = 0; +static u8 sLoadedDoorCount = 0; + static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), }; -static Vec3f D_80A710AC[] = { 0.0f, 0.0f, 1.0f }; -u8 D_80A711B0[32]; + +static Vec3f sUnitVecZ = { 0.0f, 0.0f, 1.0f }; void BgCraceMovebg_Init(Actor* thisx, PlayState* play) { BgCraceMovebg* this = THIS; @@ -58,122 +68,138 @@ void BgCraceMovebg_Init(Actor* thisx, PlayState* play) { s32 j; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - if (D_80A710A0 == 0) { - for (i = 0; i < ARRAY_COUNT(D_80A711B0); i++) { - D_80A711B0[i] = 0; + if (!sHasInitializedIsLoaded) { + for (i = 0; i < ARRAY_COUNT(sIsLoaded); i++) { + sIsLoaded[i] = 0; } - D_80A710A0 = 1; + sHasInitializedIsLoaded = true; } DynaPolyActor_Init(&this->dyna, 1); - DynaPolyActor_LoadMesh(play, &this->dyna, &object_crace_object_Colheader_000E00); + DynaPolyActor_LoadMesh(play, &this->dyna, &gDekuShrineSlidingDoorCol); - this->unk184 = this->dyna.actor.world.rot.x; - this->unk16C = this->dyna.actor.world.rot.z; + this->index = BG_CRACE_MOVEBG_GET_INDEX(&this->dyna.actor); + this->openSpeed = BG_CRACE_MOVEBG_GET_OPEN_SPEED(&this->dyna.actor); this->dyna.actor.world.rot.x = 0; this->dyna.actor.world.rot.z = 0; this->dyna.actor.home.rot.x = 0; this->dyna.actor.home.rot.z = 0; this->dyna.actor.flags |= ACTOR_FLAG_10000000; - switch (BGCRACEMOVEBG_GET_F(&this->dyna.actor)) { - case 0: - case 2: - for (j = 0; j < D_80A710A4; j++) { - if (D_80A711B0[j] == this->unk184) { - this->unk170 |= 8; + switch (BG_CRACE_MOVEBG_GET_TYPE(&this->dyna.actor)) { + case BG_CRACE_MOVEBG_TYPE_CLOSING: + case BG_CRACE_MOVEBG_TYPE_UNUSED_CLOSING: + for (j = 0; j < sLoadedDoorCount; j++) { + if (sIsLoaded[j] == this->index) { + this->stateFlags |= BG_CRACE_MOVEBG_FLAG_ALREADY_LOADED; Actor_MarkForDeath(&this->dyna.actor); return; } } - if (D_80A710A4 < ARRAY_COUNT(D_80A711B0)) { - D_80A711B0[(s32)D_80A710A4++] = this->unk184; + + if (sLoadedDoorCount < ARRAY_COUNT(sIsLoaded)) { + sIsLoaded[(s32)sLoadedDoorCount] = this->index; + sLoadedDoorCount++; } + this->dyna.actor.room = -1; - switch (func_80A7090C(play)) { - case 0: - func_80A70D74(this, play); + switch (BgCraceMovebg_GetRaceStatus(play)) { + case BG_CRACE_MOVEBG_RACE_STATUS_BUTLER_NOT_PRESENT: + BgCraceMovebg_ClosingDoor_SetupIdle(this, play); break; - case 1: - func_80A70D74(this, play); + + case BG_CRACE_MOVEBG_RACE_STATUS_FIRST_RACE: + BgCraceMovebg_ClosingDoor_SetupIdle(this, play); break; - case 2: - Flags_UnsetSwitch(play, BGCRACEMOVEBG_GET_7F0(&this->dyna.actor) + 1); - func_80A70D74(this, play); + + case BG_CRACE_MOVEBG_RACE_STATUS_SUBSEQUENT_RACE: + // Makes sure no lingering switch flags are set from the last time the player did a race. + Flags_UnsetSwitch(play, BG_CRACE_MOVEBG_GET_SWITCH_FLAG(&this->dyna.actor) + 1); + BgCraceMovebg_ClosingDoor_SetupIdle(this, play); break; } break; - case 1: - func_80A70970(this, play); + + case BG_CRACE_MOVEBG_TYPE_OPENING: + BgCraceMovebg_OpeningDoor_SetupIdle(this, play); break; + default: Actor_MarkForDeath(&this->dyna.actor); break; } } -s32 func_80A7090C(PlayState* play) { +s32 BgCraceMovebg_GetRaceStatus(PlayState* play) { s32 pad; - s32 returnVal = 0; - Actor* tempActor = SubS_FindActor(play, NULL, ACTORCAT_NPC, ACTOR_EN_DNO); + s32 raceStatus = BG_CRACE_MOVEBG_RACE_STATUS_BUTLER_NOT_PRESENT; + Actor* butler = SubS_FindActor(play, NULL, ACTORCAT_NPC, ACTOR_EN_DNO); - if (tempActor != NULL) { - if (Flags_GetSwitch(play, BGCRACEMOVEBG_GET_3F80(tempActor))) { - returnVal = 2; + if (butler != NULL) { + if (Flags_GetSwitch(play, EN_DNO_GET_RACE_STARTED_SWITCH_FLAG(butler))) { + raceStatus = BG_CRACE_MOVEBG_RACE_STATUS_SUBSEQUENT_RACE; } else { - returnVal = 1; + raceStatus = BG_CRACE_MOVEBG_RACE_STATUS_FIRST_RACE; } } - return returnVal; + + return raceStatus; } -void func_80A70970(BgCraceMovebg* this, PlayState* play) { - this->unk164 = 0.0f; - this->unk160 = 0.0f; - this->actionFunc = func_80A7099C; +void BgCraceMovebg_OpeningDoor_SetupIdle(BgCraceMovebg* this, PlayState* play) { + this->targetDoorHeight = 0.0f; + this->doorHeight = 0.0f; this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; + this->actionFunc = BgCraceMovebg_OpeningDoor_Idle; } -void func_80A7099C(BgCraceMovebg* this, PlayState* play) { - if (Flags_GetSwitch(play, BGCRACEMOVEBG_GET_7F0(&this->dyna.actor))) { - func_80A709E4(this, play); +/** + * Wait for this door's switch flag to be set, then start opening. + */ +void BgCraceMovebg_OpeningDoor_Idle(BgCraceMovebg* this, PlayState* play) { + if (Flags_GetSwitch(play, BG_CRACE_MOVEBG_GET_SWITCH_FLAG(&this->dyna.actor))) { + BgCraceMovebg_OpeningDoor_SetupOpen(this, play); } } -void func_80A709E4(BgCraceMovebg* this, PlayState* play) { - this->actionFunc = func_80A70A08; - this->unk164 = 180.0f; +void BgCraceMovebg_OpeningDoor_SetupOpen(BgCraceMovebg* this, PlayState* play) { + this->targetDoorHeight = 180.0f; + this->actionFunc = BgCraceMovebg_OpeningDoor_Open; } -void func_80A70A08(BgCraceMovebg* this, PlayState* play) { +/** + * Silde open, then do nothing. + */ +void BgCraceMovebg_OpeningDoor_Open(BgCraceMovebg* this, PlayState* play) { func_800B9010(&this->dyna.actor, NA_SE_EV_STONEDOOR_OPEN_S - SFX_FLAG); - Math_SmoothStepToF(&this->unk160, this->unk164, 2.0f, this->unk16C, 0.01f); - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + this->unk160; - if (this->unk160 == this->unk164) { - func_80A70A84(this, play); + Math_SmoothStepToF(&this->doorHeight, this->targetDoorHeight, 2.0f, this->openSpeed, 0.01f); + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + this->doorHeight; + if (this->doorHeight == this->targetDoorHeight) { + BgCraceMovebg_OpeningDoor_SetupDoNothing(this, play); } } -void func_80A70A84(BgCraceMovebg* this, PlayState* play) { - this->actionFunc = func_80A70A9C; +void BgCraceMovebg_OpeningDoor_SetupDoNothing(BgCraceMovebg* this, PlayState* play) { + this->actionFunc = BgCraceMovebg_OpeningDoor_DoNothing; } -void func_80A70A9C(BgCraceMovebg* this, PlayState* play) { +void BgCraceMovebg_OpeningDoor_DoNothing(BgCraceMovebg* this, PlayState* play) { } void BgCraceMovebg_Destroy(Actor* thisx, PlayState* play) { BgCraceMovebg* this = THIS; DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); - if (!(this->unk170 & 0x8)) { - switch (BGCRACEMOVEBG_GET_F(&this->dyna.actor)) { - case 0: - case 2: - Flags_UnsetSwitch(play, BGCRACEMOVEBG_GET_7F0(thisx)); - Flags_UnsetSwitch(play, BGCRACEMOVEBG_GET_7F0(thisx) + 1); + if (!(this->stateFlags & BG_CRACE_MOVEBG_FLAG_ALREADY_LOADED)) { + switch (BG_CRACE_MOVEBG_GET_TYPE(&this->dyna.actor)) { + case BG_CRACE_MOVEBG_TYPE_CLOSING: + case BG_CRACE_MOVEBG_TYPE_UNUSED_CLOSING: + Flags_UnsetSwitch(play, BG_CRACE_MOVEBG_GET_SWITCH_FLAG(thisx)); + Flags_UnsetSwitch(play, BG_CRACE_MOVEBG_GET_SWITCH_FLAG(thisx) + 1); break; - case 1: - Flags_UnsetSwitch(play, BGCRACEMOVEBG_GET_7F0(thisx)); + + case BG_CRACE_MOVEBG_TYPE_OPENING: + Flags_UnsetSwitch(play, BG_CRACE_MOVEBG_GET_SWITCH_FLAG(thisx)); break; } } @@ -183,117 +209,147 @@ void BgCraceMovebg_Update(Actor* thisx, PlayState* play) { BgCraceMovebg* this = THIS; s32 pad; Player* player = GET_PLAYER(play); - s16 tempRot; + s16 yawDiff; - switch (BGCRACEMOVEBG_GET_F(&this->dyna.actor)) { - case 0: - case 2: - tempRot = this->dyna.actor.yawTowardsPlayer - this->dyna.actor.home.rot.y; - if ((tempRot >= -0x4000) && (tempRot <= 0x4000)) { + switch (BG_CRACE_MOVEBG_GET_TYPE(&this->dyna.actor)) { + case BG_CRACE_MOVEBG_TYPE_CLOSING: + case BG_CRACE_MOVEBG_TYPE_UNUSED_CLOSING: + yawDiff = this->dyna.actor.yawTowardsPlayer - this->dyna.actor.home.rot.y; + if ((yawDiff >= -0x4000) && (yawDiff <= 0x4000)) { this->dyna.actor.shape.rot.y = this->dyna.actor.home.rot.y; } else { this->dyna.actor.shape.rot.y = this->dyna.actor.home.rot.y + 0x8000; } + break; + default: - this->actionFunc(this, play); - Math_Vec3f_Copy(&this->unk188, &player->bodyPartsPos[0]); + break; } + + this->actionFunc(this, play); + Math_Vec3f_Copy(&this->prevPlayerPos, &player->bodyPartsPos[0]); } -void func_80A70C04(BgCraceMovebg* this, PlayState* play) { +/** + * Updates this door's flags if the player has moved beyond it. If the door is of type + * BG_CRACE_MOVEBG_TYPE_UNUSED_CLOSING, then nothing happens here, so the door never + * knows the player has moved beyond it. + */ +void BgCraceMovebg_ClosingDoor_CheckIfPlayerIsBeyondDoor(BgCraceMovebg* this, PlayState* play) { s32 pad; Player* player = GET_PLAYER(play); Vec3f intersect; - Vec3f diff; + Vec3f posDiff; - if ((BGCRACEMOVEBG_GET_F(&this->dyna.actor) != 2) && - SubS_LineSegVsPlane(&this->dyna.actor.home.pos, &this->dyna.actor.home.rot, D_80A710AC, &this->unk188, + if ((BG_CRACE_MOVEBG_GET_TYPE(&this->dyna.actor) != BG_CRACE_MOVEBG_TYPE_UNUSED_CLOSING) && + SubS_LineSegVsPlane(&this->dyna.actor.home.pos, &this->dyna.actor.home.rot, &sUnitVecZ, &this->prevPlayerPos, &player->bodyPartsPos[0], &intersect)) { Matrix_RotateYS(-this->dyna.actor.home.rot.y, MTXMODE_NEW); - Math_Vec3f_Diff(&player->bodyPartsPos[0], &this->dyna.actor.home.pos, &diff); - Matrix_MultVec3f(&diff, &this->unk178); - if (fabsf(this->unk178.x) < 100.0f && this->unk178.y >= -10.0f && this->unk178.y <= 180.0f) { - if (this->unk178.z < 0.0f) { - Flags_SetSwitch(play, BGCRACEMOVEBG_GET_7F0(&this->dyna.actor) + 1); - this->unk170 |= 2; + Math_Vec3f_Diff(&player->bodyPartsPos[0], &this->dyna.actor.home.pos, &posDiff); + Matrix_MultVec3f(&posDiff, &this->intersectionOffsetFromHome); + + if (fabsf(this->intersectionOffsetFromHome.x) < 100.0f && this->intersectionOffsetFromHome.y >= -10.0f && + this->intersectionOffsetFromHome.y <= 180.0f) { + if (this->intersectionOffsetFromHome.z < 0.0f) { + Flags_SetSwitch(play, BG_CRACE_MOVEBG_GET_SWITCH_FLAG(&this->dyna.actor) + 1); + this->stateFlags |= BG_CRACE_MOVEBG_FLAG_PLAYER_IS_BEYOND_DOOR; } else { - Flags_UnsetSwitch(play, BGCRACEMOVEBG_GET_7F0(&this->dyna.actor) + 1); - this->unk170 &= ~2; + Flags_UnsetSwitch(play, BG_CRACE_MOVEBG_GET_SWITCH_FLAG(&this->dyna.actor) + 1); + this->stateFlags &= ~BG_CRACE_MOVEBG_FLAG_PLAYER_IS_BEYOND_DOOR; } } } } -void func_80A70D74(BgCraceMovebg* this, PlayState* play) { - this->unk164 = 180.0f; - this->unk160 = 180.0f; - this->actionFunc = func_80A70DA8; +void BgCraceMovebg_ClosingDoor_SetupIdle(BgCraceMovebg* this, PlayState* play) { + this->targetDoorHeight = 180.0f; + this->doorHeight = 180.0f; this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 180.0f; + this->actionFunc = BgCraceMovebg_ClosingDoor_Idle; } -void func_80A70DA8(BgCraceMovebg* this, PlayState* play) { - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + this->unk160; - func_80A70C04(this, play); - if (this->unk170 & 1) { - func_80A70E2C(this, play); +/** + * Wait for the Deku Butler to move beyond the door, or wait for this door's switch flag + * to be set. In either case, start closing; how long to wait before closing depends on + * what triggered it to close. + */ +void BgCraceMovebg_ClosingDoor_Idle(BgCraceMovebg* this, PlayState* play) { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + this->doorHeight; + BgCraceMovebg_ClosingDoor_CheckIfPlayerIsBeyondDoor(this, play); + + if (this->stateFlags & BG_CRACE_MOVEBG_FLAG_BUTLER_IS_BEYOND_DOOR) { + BgCraceMovebg_ClosingDoor_SetupWaitToClose(this, play); } - if (Flags_GetSwitch(play, BGCRACEMOVEBG_GET_7F0(&this->dyna.actor))) { - func_80A70F14(this, play); + + if (Flags_GetSwitch(play, BG_CRACE_MOVEBG_GET_SWITCH_FLAG(&this->dyna.actor))) { + BgCraceMovebg_ClosingDoor_SetupClose(this, play); } } -void func_80A70E2C(BgCraceMovebg* this, PlayState* play) { - this->unk174 = BGCRACEMOVEBG_GET_F800(&this->dyna.actor) * 10; - this->unk164 = 180.0f; - this->unk160 = 180.0f; - this->actionFunc = func_80A70E70; +void BgCraceMovebg_ClosingDoor_SetupWaitToClose(BgCraceMovebg* this, PlayState* play) { + this->closeWaitTimer = BG_CRACE_MOVEBG_GET_CLOSE_WAIT_TIMER(&this->dyna.actor) * 10; + this->targetDoorHeight = 180.0f; + this->doorHeight = 180.0f; + this->actionFunc = BgCraceMovebg_ClosingDoor_WaitToClose; } -void func_80A70E70(BgCraceMovebg* this, PlayState* play) { - if (this->unk174 > 0) { - this->unk174--; +/** + * Wait until the closeWaitTimer reaches 0, then set the door's switch flag and start closing. + */ +void BgCraceMovebg_ClosingDoor_WaitToClose(BgCraceMovebg* this, PlayState* play) { + if (this->closeWaitTimer > 0) { + this->closeWaitTimer--; } - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + this->unk160; - func_80A70C04(this, play); - if (this->unk174 <= 0) { - this->unk160 = 180.0f; - this->unk164 = 0.0f; + + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + this->doorHeight; + BgCraceMovebg_ClosingDoor_CheckIfPlayerIsBeyondDoor(this, play); + + if (this->closeWaitTimer <= 0) { + this->doorHeight = 180.0f; + this->targetDoorHeight = 0.0f; this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 180.0f; - Flags_SetSwitch(play, BGCRACEMOVEBG_GET_7F0(&this->dyna.actor)); - func_80A70F14(this, play); + Flags_SetSwitch(play, BG_CRACE_MOVEBG_GET_SWITCH_FLAG(&this->dyna.actor)); + BgCraceMovebg_ClosingDoor_SetupClose(this, play); } } -void func_80A70F14(BgCraceMovebg* this, PlayState* play) { - this->actionFunc = func_80A70F2C; +void BgCraceMovebg_ClosingDoor_SetupClose(BgCraceMovebg* this, PlayState* play) { + this->actionFunc = BgCraceMovebg_ClosingDoor_Close; } -void func_80A70F2C(BgCraceMovebg* this, PlayState* play) { - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + this->unk160; - func_80A70C04(this, play); - if (Math_StepToF(&this->unk160, 0.0f, 1.0f)) { - if (!(this->unk170 & 2) && !Flags_GetSwitch(play, BGCRACEMOVEBG_GET_7F0(&this->dyna.actor) + 1)) { +/** + * Slowly slide closed, then check to see if the player is beyond the door. If the player has + * not moved beyond the door, trigger a voidout. Otherwise, do nothing. + */ +void BgCraceMovebg_ClosingDoor_Close(BgCraceMovebg* this, PlayState* play) { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + this->doorHeight; + BgCraceMovebg_ClosingDoor_CheckIfPlayerIsBeyondDoor(this, play); + + if (Math_StepToF(&this->doorHeight, 0.0f, 1.0f)) { + if (!(this->stateFlags & BG_CRACE_MOVEBG_FLAG_PLAYER_IS_BEYOND_DOOR) && + !Flags_GetSwitch(play, BG_CRACE_MOVEBG_GET_SWITCH_FLAG(&this->dyna.actor) + 1)) { play->unk_18845 = 1; func_80169FDC(&play->state); play_sound(NA_SE_OC_ABYSS); } - func_80A70FF4(this, play); + + BgCraceMovebg_ClosingDoor_SetupDoNothing(this, play); } else { func_800B9010(&this->dyna.actor, NA_SE_EV_STONEDOOR_CLOSE_S - SFX_FLAG); } } -void func_80A70FF4(BgCraceMovebg* this, PlayState* play) { - this->unk164 = 0.0f; - this->unk160 = 0.0f; +void BgCraceMovebg_ClosingDoor_SetupDoNothing(BgCraceMovebg* this, PlayState* play) { + this->targetDoorHeight = 0.0f; + this->doorHeight = 0.0f; this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); - this->actionFunc = func_80A71040; + this->actionFunc = BgCraceMovebg_ClosingDoor_DoNothing; } -void func_80A71040(BgCraceMovebg* this, PlayState* play) { +void BgCraceMovebg_ClosingDoor_DoNothing(BgCraceMovebg* this, PlayState* play) { } void BgCraceMovebg_Draw(Actor* thisx, PlayState* play) { - Gfx_DrawDListOpa(play, object_crace_object_DL_0003A0); + Gfx_DrawDListOpa(play, gDekuShrineSlidingDoorDL); } diff --git a/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.h b/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.h index 4faca7ba2e..fb24b10d39 100644 --- a/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.h +++ b/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.h @@ -8,23 +8,34 @@ struct BgCraceMovebg; typedef void (*BgCraceMovebgActionFunc)(struct BgCraceMovebg*, PlayState*); -#define BGCRACEMOVEBG_GET_F(thisx) (((thisx)->params) & 0xF) -#define BGCRACEMOVEBG_GET_7F0(thisx) (((thisx)->params >> 4) & 0x7F) -#define BGCRACEMOVEBG_GET_3F80(thisx) (((thisx)->params >> 7) & 0x7F) -#define BGCRACEMOVEBG_GET_F800(thisx) (((thisx)->params >> 0xB) & 0x1F) +#define BG_CRACE_MOVEBG_GET_TYPE(thisx) (((thisx)->params) & 0xF) +#define BG_CRACE_MOVEBG_GET_SWITCH_FLAG(thisx) (((thisx)->params >> 4) & 0x7F) +#define BG_CRACE_MOVEBG_GET_CLOSE_WAIT_TIMER(thisx) (((thisx)->params >> 0xB) & 0x1F) +#define BG_CRACE_MOVEBG_GET_INDEX(thisx) ((thisx)->world.rot.x) +#define BG_CRACE_MOVEBG_GET_OPEN_SPEED(thisx) ((thisx)->world.rot.z) + +#define BG_CRACE_MOVEBG_FLAG_BUTLER_IS_BEYOND_DOOR (1 << 0) +#define BG_CRACE_MOVEBG_FLAG_PLAYER_IS_BEYOND_DOOR (1 << 1) +#define BG_CRACE_MOVEBG_FLAG_ALREADY_LOADED (1 << 3) + +typedef enum { + /* 0 */ BG_CRACE_MOVEBG_TYPE_CLOSING, + /* 1 */ BG_CRACE_MOVEBG_TYPE_OPENING, + /* 2 */ BG_CRACE_MOVEBG_TYPE_UNUSED_CLOSING // Not triggered to close by the Deku Butler, and triggers a voidout no matter which side of the door they're on. +} BgCraceMovebgType; typedef struct BgCraceMovebg { /* 0x000 */ DynaPolyActor dyna; /* 0x15C */ BgCraceMovebgActionFunc actionFunc; - /* 0x160 */ f32 unk160; - /* 0x164 */ f32 unk164; + /* 0x160 */ f32 doorHeight; + /* 0x164 */ f32 targetDoorHeight; /* 0x168 */ UNK_TYPE1 pad168[0x4]; - /* 0x16C */ f32 unk16C; - /* 0x170 */ s32 unk170; - /* 0x174 */ s32 unk174; - /* 0x178 */ Vec3f unk178; - /* 0x184 */ u8 unk184; - /* 0x188 */ Vec3f unk188; + /* 0x16C */ f32 openSpeed; + /* 0x170 */ s32 stateFlags; + /* 0x174 */ s32 closeWaitTimer; + /* 0x178 */ Vec3f intersectionOffsetFromHome; + /* 0x184 */ u8 index; + /* 0x188 */ Vec3f prevPlayerPos; } BgCraceMovebg; // size = 0x194 extern const ActorInit Bg_Crace_Movebg_InitVars; 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 9b421dfd49..5877c5fd21 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.c +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.c @@ -122,8 +122,8 @@ void func_80A714B4(EnDno* this, PlayState* play) { do { actor = SubS_FindActor(play, actor, ACTORCAT_BG, ACTOR_BG_CRACE_MOVEBG); if (actor != NULL) { - if (ENDNO_GET_F(actor) == ENDNO_GET_F_1) { - Flags_SetSwitch(play, ENDNO_GET_7F0(actor)); + if (BG_CRACE_MOVEBG_GET_TYPE(actor) == BG_CRACE_MOVEBG_TYPE_OPENING) { + Flags_SetSwitch(play, BG_CRACE_MOVEBG_GET_SWITCH_FLAG(actor)); } actor = actor->next; } @@ -152,14 +152,15 @@ void func_80A715DC(EnDno* this, PlayState* play) { do { crace = (BgCraceMovebg*)SubS_FindActor(play, &crace->dyna.actor, ACTORCAT_BG, ACTOR_BG_CRACE_MOVEBG); if (crace != NULL) { - if (ENDNO_GET_F(&crace->dyna.actor) == ENDNO_GET_F_0 && !(crace->unk170 & 1)) { + if (BG_CRACE_MOVEBG_GET_TYPE(&crace->dyna.actor) == BG_CRACE_MOVEBG_TYPE_CLOSING && + !(crace->stateFlags & BG_CRACE_MOVEBG_FLAG_BUTLER_IS_BEYOND_DOOR)) { if (SubS_LineSegVsPlane(&crace->dyna.actor.home.pos, &crace->dyna.actor.home.rot, &D_80A73B2C, &this->actor.prevPos, &this->actor.world.pos, &sp88)) { Math_Vec3f_Diff(&this->actor.world.pos, &crace->dyna.actor.home.pos, &sp7C); Matrix_RotateYS(-crace->dyna.actor.home.rot.y, MTXMODE_NEW); Matrix_MultVec3f(&sp7C, &sp70); if ((fabsf(sp70.x) < 100.0f) && (sp70.y >= -10.0f) && (sp70.y <= 180.0f) && (sp70.z < 0.0f)) { - crace->unk170 |= 1; + crace->stateFlags |= BG_CRACE_MOVEBG_FLAG_BUTLER_IS_BEYOND_DOOR; } } } @@ -174,7 +175,7 @@ void func_80A71788(EnDno* this, PlayState* play) { do { actor = SubS_FindActor(play, actor, ACTORCAT_BG, ACTOR_BG_CRACE_MOVEBG); if (actor != NULL) { - Flags_UnsetSwitch(play, ENDNO_GET_7F0(actor)); + Flags_UnsetSwitch(play, BG_CRACE_MOVEBG_GET_SWITCH_FLAG(actor)); actor = actor->next; } } while (actor != NULL); @@ -212,8 +213,8 @@ void EnDno_Init(Actor* thisx, PlayState* play) { this->unk_468 = 99; this->skelAnime.playSpeed = 0.0f; - switch (ENDNO_GET_C000(thisx)) { - case ENDNO_GET_C000_0: + switch (EN_DNO_GET_C000(thisx)) { + case EN_DNO_GET_C000_0: func_80A71788(this, play); if (!(gSaveContext.save.weekEventReg[23] & 0x20) || (gSaveContext.save.weekEventReg[93] & 2)) { Actor_MarkForDeath(thisx); @@ -228,7 +229,7 @@ void EnDno_Init(Actor* thisx, PlayState* play) { } break; - case ENDNO_GET_C000_1: + case EN_DNO_GET_C000_1: if (gSaveContext.save.weekEventReg[23] & 0x20) { Actor_MarkForDeath(thisx); } else { @@ -502,7 +503,7 @@ void func_80A72438(EnDno* this, PlayState* play) { this->unk_452 = 1; SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 14, &this->unk_32C); this->actor.textId = 0; - if (Flags_GetSwitch(play, ENDNO_GET_3F80(&this->actor))) { + if (Flags_GetSwitch(play, EN_DNO_GET_RACE_STARTED_SWITCH_FLAG(&this->actor))) { this->unk_454 = 1.0f; } this->actionFunc = func_80A724B8; @@ -549,7 +550,7 @@ void func_80A725F8(EnDno* this, PlayState* play) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 5, &this->unk_32C); } } else if ((this->unk_32C == 5) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - if (Flags_GetSwitch(play, ENDNO_GET_3F80(&this->actor))) { + if (Flags_GetSwitch(play, EN_DNO_GET_RACE_STARTED_SWITCH_FLAG(&this->actor))) { Message_StartTextbox(play, 0x801, &this->actor); } else if (Player_GetMask(play) == PLAYER_MASK_SCENTS) { Message_StartTextbox(play, 0x806, &this->actor); @@ -692,13 +693,13 @@ void func_80A72C04(EnDno* this, PlayState* play) { this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); Math_Vec3f_Copy(&this->unk_334, &this->actor.world.pos); SubS_ActorPathing_Init(play, &this->unk_334, &this->actor, &this->actorPath, play->setupPathList, - ENDNO_GET_7F(&this->actor), 1, 0, 1, 0); + EN_DNO_GET_7F(&this->actor), 1, 0, 1, 0); SubS_ActorPathing_ComputePointInfo(play, &this->actorPath); this->actor.world.rot.y = this->actorPath.rotToCurPoint.y; this->actor.world.rot.x = this->actorPath.rotToCurPoint.x; - Flags_SetSwitch(play, ENDNO_GET_3F80(&this->actor)); + Flags_SetSwitch(play, EN_DNO_GET_RACE_STARTED_SWITCH_FLAG(&this->actor)); this->actionFunc = func_80A730A0; } @@ -820,7 +821,7 @@ void func_80A73244(EnDno* this, PlayState* play) { this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); this->unk_328 = 2; this->actor.speedXZ = 0.0f; - Flags_UnsetSwitch(play, ENDNO_GET_3F80(&this->actor)); + Flags_UnsetSwitch(play, EN_DNO_GET_RACE_STARTED_SWITCH_FLAG(&this->actor)); gSaveContext.timerStates[TIMER_ID_MINIGAME_1] = TIMER_STATE_STOP; this->unk_44E = 0; this->actionFunc = func_80A732C8; 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 bf357cad67..2e417a7a02 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.h +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.h @@ -7,21 +7,14 @@ struct EnDno; typedef void (*EnDnoActionFunc)(struct EnDno*, PlayState*); -#define ENDNO_GET_F(thisx) ((thisx)->params & 0xF) -#define ENDNO_GET_7F(thisx) ((thisx)->params & 0x7F) -#define ENDNO_GET_7F0(thisx) (((thisx)->params >> 4) & 0x7F) -#define ENDNO_GET_3F80(thisx) (((thisx)->params >> 7) & 0x7F) -#define ENDNO_GET_C000(thisx) (((thisx)->params >> 0xE) & 0x3) +#define EN_DNO_GET_7F(thisx) ((thisx)->params & 0x7F) +#define EN_DNO_GET_RACE_STARTED_SWITCH_FLAG(thisx) (((thisx)->params >> 7) & 0x7F) +#define EN_DNO_GET_C000(thisx) (((thisx)->params >> 0xE) & 0x3) -enum { - /* 0x0 */ ENDNO_GET_F_0, - /* 0x1 */ ENDNO_GET_F_1, -}; - -enum { - /* 0x0 */ ENDNO_GET_C000_0, - /* 0x1 */ ENDNO_GET_C000_1, -}; +typedef enum { + /* 0x0 */ EN_DNO_GET_C000_0, + /* 0x1 */ EN_DNO_GET_C000_1, +} EnDnoUnkC000; typedef struct EnDno { /* 0x000 */ Actor actor; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 571812b3f5..4415b571dc 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -10960,24 +10960,24 @@ 0x80A702B0:("EnMm3_PostLimbDraw",), 0x80A702F0:("EnMm3_Draw",), 0x80A706F0:("BgCraceMovebg_Init",), - 0x80A7090C:("func_80A7090C",), - 0x80A70970:("func_80A70970",), - 0x80A7099C:("func_80A7099C",), - 0x80A709E4:("func_80A709E4",), - 0x80A70A08:("func_80A70A08",), - 0x80A70A84:("func_80A70A84",), - 0x80A70A9C:("func_80A70A9C",), + 0x80A7090C:("BgCraceMovebg_GetRaceStatus",), + 0x80A70970:("BgCraceMovebg_OpeningDoor_SetupIdle",), + 0x80A7099C:("BgCraceMovebg_OpeningDoor_WaitToOpen",), + 0x80A709E4:("BgCraceMovebg_OpeningDoor_SetupOpen",), + 0x80A70A08:("BgCraceMovebg_OpeningDoor_Open",), + 0x80A70A84:("BgCraceMovebg_OpeningDoor_SetupDoNothing",), + 0x80A70A9C:("BgCraceMovebg_OpeningDoor_DoNothing",), 0x80A70AAC:("BgCraceMovebg_Destroy",), 0x80A70B60:("BgCraceMovebg_Update",), - 0x80A70C04:("func_80A70C04",), - 0x80A70D74:("func_80A70D74",), - 0x80A70DA8:("func_80A70DA8",), - 0x80A70E2C:("func_80A70E2C",), - 0x80A70E70:("func_80A70E70",), - 0x80A70F14:("func_80A70F14",), - 0x80A70F2C:("func_80A70F2C",), - 0x80A70FF4:("func_80A70FF4",), - 0x80A71040:("func_80A71040",), + 0x80A70C04:("BgCraceMovebg_ClosingDoor_CheckIfPlayerIsBeyondDoor",), + 0x80A70D74:("BgCraceMovebg_ClosingDoor_SetupIdle",), + 0x80A70DA8:("BgCraceMovebg_ClosingDoor_Idle",), + 0x80A70E2C:("BgCraceMovebg_ClosingDoor_SetupWaitToClose",), + 0x80A70E70:("BgCraceMovebg_ClosingDoor_WaitToClose",), + 0x80A70F14:("BgCraceMovebg_ClosingDoor_SetupClose",), + 0x80A70F2C:("BgCraceMovebg_ClosingDoor_Close",), + 0x80A70FF4:("BgCraceMovebg_ClosingDoor_SetupDoNothing",), + 0x80A71040:("BgCraceMovebg_ClosingDoor_DoNothing",), 0x80A71050:("BgCraceMovebg_Draw",), 0x80A711D0:("func_80A711D0",), 0x80A71424:("func_80A71424",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index edf51ff57c..3578b52a5b 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -12095,12 +12095,12 @@ 0x80A70510:("jtbl_80A70510","UNK_PTR","",0x4), 0x80A7056C:("jtbl_80A7056C","UNK_PTR","",0x4), 0x80A71080:("Bg_Crace_Movebg_InitVars","UNK_TYPE1","",0x1), - 0x80A710A0:("D_80A710A0","UNK_TYPE1","",0x1), - 0x80A710A4:("D_80A710A4","UNK_TYPE1","",0x1), - 0x80A710A8:("D_80A710A8","UNK_TYPE1","",0x1), - 0x80A710AC:("D_80A710AC","UNK_TYPE1","",0x1), + 0x80A710A0:("sHasInitializedIsLoaded","UNK_TYPE1","",0x1), + 0x80A710A4:("sLoadedDoorCount","UNK_TYPE1","",0x1), + 0x80A710A8:("sInitChain","UNK_TYPE1","",0x1), + 0x80A710AC:("sUnitVecZ","UNK_TYPE1","",0x1), 0x80A710C0:("D_80A710C0","f32","",0x4), - 0x80A711B0:("D_80A711B0","UNK_TYPE1","",0x1), + 0x80A711B0:("sIsLoaded","UNK_TYPE1","",0x1), 0x80A739A0:("D_80A739A0","UNK_PTR","",0x4), 0x80A73AE0:("En_Dno_InitVars","UNK_TYPE1","",0x1), 0x80A73B00:("D_80A73B00","UNK_TYPE1","",0x1), From 15b9f83bd8980cbc3fc27373cba72826946395da Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Fri, 30 Sep 2022 13:17:34 -0700 Subject: [PATCH 05/25] Document object_dnj (Deku Butler) (#1100) --- assets/xml/objects/object_dnj.xml | 174 ++++++++-------- src/overlays/actors/ovl_En_Dno/z_en_dno.c | 242 ++++++++++++++-------- src/overlays/actors/ovl_En_Dno/z_en_dno.h | 7 +- 3 files changed, 246 insertions(+), 177 deletions(-) diff --git a/assets/xml/objects/object_dnj.xml b/assets/xml/objects/object_dnj.xml index 95b563913f..3b4f27579d 100644 --- a/assets/xml/objects/object_dnj.xml +++ b/assets/xml/objects/object_dnj.xml @@ -1,86 +1,96 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 5877c5fd21..685c3a5116 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.c +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.c @@ -11,7 +11,6 @@ #include "z_en_dno.h" #include "overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.h" #include "objects/gameplay_keep/gameplay_keep.h" -#include "objects/object_dnj/object_dnj.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -44,17 +43,50 @@ void func_80A732C8(EnDno* this, PlayState* play); s32 EnDno_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx); void EnDno_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx); +typedef enum { + /* 0 */ EN_DNO_ANIM_START_RACE_START, + /* 1 */ EN_DNO_ANIM_START_RACE_END, + /* 2 */ EN_DNO_ANIM_FLY, + /* 3 */ EN_DNO_ANIM_FAREWELL, + /* 4 */ EN_DNO_ANIM_GREETING, + /* 5 */ EN_DNO_ANIM_GREETING_WITH_CANDLE, + /* 6 */ EN_DNO_ANIM_PRAYER_LOOP, + /* 7 */ EN_DNO_ANIM_CLOSE_PARASOL, + /* 8 */ EN_DNO_ANIM_OPEN_PARASOL, + /* 9 */ EN_DNO_ANIM_IMPLORE_LOOP, + /* 10 */ EN_DNO_ANIM_IMPLORE_END, + /* 11 */ EN_DNO_ANIM_TALK, + /* 12 */ EN_DNO_ANIM_TALK_WITH_PARSOL_AND_CANDLE, + /* 13 */ EN_DNO_ANIM_IDLE, + /* 14 */ EN_DNO_ANIM_IDLE_WITH_CANDLE, + /* 15 */ EN_DNO_ANIM_PRAYER_START, + /* 16 */ EN_DNO_ANIM_IMPLORE_START, + /* 17 */ EN_DNO_ANIM_SHOCK_START, + /* 18 */ EN_DNO_ANIM_SHOCK_LOOP, + /* 19 */ EN_DNO_ANIM_GRIEVE, +} EnDnoAnimation; + static AnimationSpeedInfo sAnimations[] = { - { &object_dnj_Anim_000470, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dnj_Anim_0008F0, 1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_dnj_Anim_000F6C, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_dnj_Anim_001A50, 1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_dnj_Anim_002530, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dnj_Anim_003320, 1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_dnj_Anim_0036D0, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_dnj_Anim_0041CC, 1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_dnj_Anim_004DD8, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dnj_Anim_005F98, 1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_dnj_Anim_006488, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dnj_Anim_0073E4, 1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_dnj_Anim_0077A8, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_dnj_Anim_007CA4, 1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_dnj_Anim_008324, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_dnj_Anim_008AE4, 1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_dnj_Anim_009100, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dnj_Anim_0051E4, 1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_dnj_Anim_005E20, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_dnj_Anim_006F84, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gDekuButlerStartRaceStartAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gDekuButlerStartRaceEndAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gDekuButlerFlyAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gDekuButlerFarewellAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gDekuButlerGreetingAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gDekuButlerGreetingWithCandleAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gDekuButlerPrayerLoopAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gDekuButlerCloseParasolAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gDekuButlerOpenParasolAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gDekuButlerImploreLoopAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gDekuButlerImploreEndAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gDekuButlerTalkAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gDekuButlerTalkWithParasolAndCandleAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gDekuButlerIdleAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gDekuButlerIdleWithCandleAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gDekuButlerPrayerStartAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gDekuButlerImploreStartAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gDekuButlerShockStartAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gDekuButlerShockLoopAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gDekuButlerGrieveAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, }; const ActorInit En_Dno_InitVars = { @@ -199,14 +231,15 @@ void EnDno_Init(Actor* thisx, PlayState* play) { if (actor == NULL) { Actor_ProcessInitChain(thisx, sInitChain); ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 21.0f); - SkelAnime_InitFlex(play, &this->skelAnime, &object_dnj_Skel_00E1F8, &object_dnj_Anim_007CA4, - this->jointTable, this->morphTable, 28); + SkelAnime_InitFlex(play, &this->skelAnime, &gDekuButlerSkel, &gDekuButlerIdleAnim, this->jointTable, + this->morphTable, DEKU_BUTLER_LIMB_MAX); Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, thisx, &sCylinderInit); Actor_UpdateBgCheckInfo(play, thisx, 0.0f, 0.0f, 0.0f, 4); - Animation_Change(&this->skelAnime, sAnimations[14].animation, 1.0f, 0.0f, - Animation_GetLastFrame(sAnimations[14].animation), sAnimations[14].mode, - sAnimations[14].morphFrames); + Animation_Change(&this->skelAnime, sAnimations[EN_DNO_ANIM_IDLE_WITH_CANDLE].animation, 1.0f, 0.0f, + Animation_GetLastFrame(sAnimations[EN_DNO_ANIM_IDLE_WITH_CANDLE].animation), + sAnimations[EN_DNO_ANIM_IDLE_WITH_CANDLE].mode, + sAnimations[EN_DNO_ANIM_IDLE_WITH_CANDLE].morphFrames); this->unk_3BE = 0x3E93; this->unk_3C0 = 60.0f; this->unk_3B0 = 0; @@ -219,7 +252,8 @@ void EnDno_Init(Actor* thisx, PlayState* play) { if (!(gSaveContext.save.weekEventReg[23] & 0x20) || (gSaveContext.save.weekEventReg[93] & 2)) { Actor_MarkForDeath(thisx); } else { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 14, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IDLE_WITH_CANDLE, + &this->animIndex); thisx->room = -1; gSaveContext.timerStates[TIMER_ID_MINIGAME_1] = TIMER_STATE_STOP; this->lightNode = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfo); @@ -233,7 +267,8 @@ void EnDno_Init(Actor* thisx, PlayState* play) { if (gSaveContext.save.weekEventReg[23] & 0x20) { Actor_MarkForDeath(thisx); } else { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IDLE, + &this->animIndex); this->unk_460 = SubS_FindActor(play, NULL, ACTORCAT_NPC, ACTOR_EN_DNQ); if (this->unk_460 == NULL) { Actor_MarkForDeath(thisx); @@ -261,7 +296,7 @@ void EnDno_Destroy(Actor* thisx, PlayState* play) { void func_80A71B04(EnDno* this, PlayState* play) { this->unk_452 = 0; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 19, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_GRIEVE, &this->animIndex); this->actionFunc = EnDno_DoNothing; } @@ -274,54 +309,57 @@ void func_80A71B68(EnDno* this, PlayState* play) { if (CHECK_QUEST_ITEM(QUEST_SONG_SONATA)) { if (gSaveContext.save.weekEventReg[27] & 1) { if (!(this->unk_3B0 & 0x20)) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 6, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_PRAYER_LOOP, + &this->animIndex); this->actor.shape.rot.y = Actor_YawBetweenActors(&this->actor, this->unk_460); } } else { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IDLE, &this->animIndex); } } else { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IDLE, &this->animIndex); } this->actionFunc = func_80A71C3C; } void func_80A71C3C(EnDno* this, PlayState* play) { - switch (this->unk_32C) { - case 9: - case 16: - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 10, &this->unk_32C); + switch (this->animIndex) { + case EN_DNO_ANIM_IMPLORE_LOOP: + case EN_DNO_ANIM_IMPLORE_START: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IMPLORE_END, &this->animIndex); break; - case 3: - case 10: + case EN_DNO_ANIM_FAREWELL: + case EN_DNO_ANIM_IMPLORE_END: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IDLE, &this->animIndex); } break; - case 11: - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 15, &this->unk_32C); + case EN_DNO_ANIM_TALK: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_PRAYER_START, &this->animIndex); break; - case 15: + case EN_DNO_ANIM_PRAYER_START: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 6, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_PRAYER_LOOP, + &this->animIndex); } - case 6: + case EN_DNO_ANIM_PRAYER_LOOP: Math_SmoothStepToS(&this->actor.shape.rot.y, Actor_YawBetweenActors(&this->actor, this->unk_460), 2, 0xE38, 0x222); break; } - if ((this->unk_32C == 13) && (this->actor.xzDistToPlayer <= 120.0f)) { + if ((this->animIndex == EN_DNO_ANIM_IDLE) && (this->actor.xzDistToPlayer <= 120.0f)) { func_80A71424(&this->unk_466, 0, this->actor.yawTowardsPlayer, this->actor.shape.rot.y, 0x2000, 0x16C); } else { Math_ScaledStepToS(&this->unk_466, 0, 0x16C); } - if ((this->unk_32C != 3) && (this->unk_32C != 15) && (this->unk_32C != 6)) { + if ((this->animIndex != EN_DNO_ANIM_FAREWELL) && (this->animIndex != EN_DNO_ANIM_PRAYER_START) && + (this->animIndex != EN_DNO_ANIM_PRAYER_LOOP)) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 0x222); } @@ -366,7 +404,8 @@ void func_80A71F18(EnDno* this, PlayState* play) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xE38)) { switch (this->textId) { case 0x80B: - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 16, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IMPLORE_START, + &this->animIndex); case 0x811: Message_StartTextbox(play, this->textId, &this->actor); @@ -374,10 +413,13 @@ void func_80A71F18(EnDno* this, PlayState* play) { case 0x80C: case 0x80F: - if (this->unk_32C == 13) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 4, &this->unk_32C); - } else if ((this->unk_32C == 4) && (this->skelAnime.curFrame == this->skelAnime.endFrame)) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 11, &this->unk_32C); + if (this->animIndex == EN_DNO_ANIM_IDLE) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_GREETING, + &this->animIndex); + } else if ((this->animIndex == EN_DNO_ANIM_GREETING) && + (this->skelAnime.curFrame == this->skelAnime.endFrame)) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_TALK, + &this->animIndex); Message_StartTextbox(play, this->textId, &this->actor); } break; @@ -387,19 +429,21 @@ void func_80A71F18(EnDno* this, PlayState* play) { case TEXT_STATE_3: if (play->msgCtx.currentTextId == 0x80B) { - switch (this->unk_32C) { - case 16: + switch (this->animIndex) { + case EN_DNO_ANIM_IMPLORE_START: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 9, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IMPLORE_LOOP, + &this->animIndex); } Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_YawBetweenActors(&this->actor, this->unk_460), 0x71C); break; - case 10: + case EN_DNO_ANIM_IMPLORE_END: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { func_801477B4(play); - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IDLE, + &this->animIndex); func_80A71B68(this, play); } break; @@ -412,24 +456,27 @@ void func_80A71F18(EnDno* this, PlayState* play) { case TEXT_STATE_DONE: switch (play->msgCtx.currentTextId) { case 0x80B: - switch (this->unk_32C) { - case 16: + switch (this->animIndex) { + case EN_DNO_ANIM_IMPLORE_START: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 9, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IMPLORE_LOOP, + &this->animIndex); } break; - case 9: + case EN_DNO_ANIM_IMPLORE_LOOP: if (Message_ShouldAdvance(play)) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 10, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IMPLORE_END, + &this->animIndex); play->msgCtx.msgMode = 0x44; } break; - case 10: + case EN_DNO_ANIM_IMPLORE_END: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { func_801477B4(play); - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IDLE, + &this->animIndex); func_80A71B68(this, play); } break; @@ -449,13 +496,15 @@ void func_80A71F18(EnDno* this, PlayState* play) { break; case 0x80E: - if (this->unk_32C == 11) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 3, &this->unk_32C); - } else if (this->unk_32C == 3) { + if (this->animIndex == EN_DNO_ANIM_TALK) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_FAREWELL, + &this->animIndex); + } else if (this->animIndex == EN_DNO_ANIM_FAREWELL) { if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IDLE, + &this->animIndex); } - } else if ((this->unk_32C == 13) && Message_ShouldAdvance(play)) { + } else if ((this->animIndex == EN_DNO_ANIM_IDLE) && Message_ShouldAdvance(play)) { func_801477B4(play); func_80A71B68(this, play); } @@ -475,14 +524,16 @@ void func_80A71F18(EnDno* this, PlayState* play) { break; } - switch (this->unk_32C) { - case 11: - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 15, &this->unk_32C); + switch (this->animIndex) { + case EN_DNO_ANIM_TALK: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_PRAYER_START, + &this->animIndex); break; - case 15: + case EN_DNO_ANIM_PRAYER_START: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 6, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_PRAYER_LOOP, + &this->animIndex); } break; } @@ -501,7 +552,7 @@ void func_80A71F18(EnDno* this, PlayState* play) { void func_80A72438(EnDno* this, PlayState* play) { this->unk_452 = 1; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 14, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IDLE_WITH_CANDLE, &this->animIndex); this->actor.textId = 0; if (Flags_GetSwitch(play, EN_DNO_GET_RACE_STARTED_SWITCH_FLAG(&this->actor))) { this->unk_454 = 1.0f; @@ -545,11 +596,13 @@ void func_80A725F8(EnDno* this, PlayState* play) { case TEXT_STATE_NONE: switch (this->unk_328) { case 0: - if (this->unk_32C == 14) { + if (this->animIndex == EN_DNO_ANIM_IDLE_WITH_CANDLE) { if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x2D8)) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 5, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, + EN_DNO_ANIM_GREETING_WITH_CANDLE, &this->animIndex); } - } else if ((this->unk_32C == 5) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + } else if ((this->animIndex == EN_DNO_ANIM_GREETING_WITH_CANDLE) && + Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { if (Flags_GetSwitch(play, EN_DNO_GET_RACE_STARTED_SWITCH_FLAG(&this->actor))) { Message_StartTextbox(play, 0x801, &this->actor); } else if (Player_GetMask(play) == PLAYER_MASK_SCENTS) { @@ -557,7 +610,8 @@ void func_80A725F8(EnDno* this, PlayState* play) { } else { Message_StartTextbox(play, 0x800, &this->actor); } - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 14, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IDLE_WITH_CANDLE, + &this->animIndex); } break; @@ -578,7 +632,7 @@ void func_80A725F8(EnDno* this, PlayState* play) { case TEXT_STATE_CLOSING: case TEXT_STATE_3: if (((play->msgCtx.currentTextId == 0x800) || (play->msgCtx.currentTextId == 0x801)) && - (this->unk_32C == 8)) { + (this->animIndex == EN_DNO_ANIM_OPEN_PARASOL)) { Math_SmoothStepToF(&this->unk_454, 1.0f, 1.0f, 0.1f, 0.01f); if (this->skelAnime.curFrame <= 23.0f) { this->unk_452 = 3; @@ -592,7 +646,8 @@ void func_80A725F8(EnDno* this, PlayState* play) { } if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 12, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, + EN_DNO_ANIM_TALK_WITH_PARSOL_AND_CANDLE, &this->animIndex); Message_StartTextbox(play, 0x803, &this->actor); } } @@ -608,7 +663,8 @@ void func_80A725F8(EnDno* this, PlayState* play) { play->msgCtx.msgMode = 0x44; this->unk_452 = 1; this->unk_454 = 0.0f; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 8, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_OPEN_PARASOL, + &this->animIndex); } break; @@ -632,15 +688,17 @@ void func_80A725F8(EnDno* this, PlayState* play) { break; case 0x804: - if (this->unk_32C == 14) { + if (this->animIndex == EN_DNO_ANIM_IDLE_WITH_CANDLE) { if (Message_ShouldAdvance(play)) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 5, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, + EN_DNO_ANIM_GREETING_WITH_CANDLE, &this->animIndex); if (!(this->unk_3B0 & 0x40)) { func_80A72CF8(this, play); this->unk_3B0 |= 0x40; } } - } else if ((this->unk_32C == 5) && (this->skelAnime.curFrame == this->skelAnime.endFrame)) { + } else if ((this->animIndex == EN_DNO_ANIM_GREETING_WITH_CANDLE) && + (this->skelAnime.curFrame == this->skelAnime.endFrame)) { func_801477B4(play); func_80A72438(this, play); } @@ -661,7 +719,7 @@ void func_80A725F8(EnDno* this, PlayState* play) { } void func_80A72AE4(EnDno* this, PlayState* play) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_START_RACE_START, &this->animIndex); func_80A714B4(this, play); this->actionFunc = func_80A72B3C; } @@ -688,7 +746,7 @@ void func_80A72BA4(EnDno* this, PlayState* play) { } void func_80A72C04(EnDno* this, PlayState* play) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_START_RACE_START, &this->animIndex); this->actor.flags |= ACTOR_FLAG_8000000; this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); Math_Vec3f_Copy(&this->unk_334, &this->actor.world.pos); @@ -767,27 +825,26 @@ s32 EnDno_ActorPathing_Move(PlayState* play, ActorPathing* actorPath) { } void func_80A730A0(EnDno* this, PlayState* play) { - f32 temp_f10; s32 phi_a2; if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { phi_a2 = -1; - switch (this->unk_32C) { - case 0: + switch (this->animIndex) { + case EN_DNO_ANIM_START_RACE_START: if (this->unk_44E >= 20) { - phi_a2 = 1; + phi_a2 = EN_DNO_ANIM_START_RACE_END; } else { this->unk_44E = 20; } break; - case 1: - phi_a2 = 2; + case EN_DNO_ANIM_START_RACE_END: + phi_a2 = EN_DNO_ANIM_FLY; break; } if (phi_a2 >= 0) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, phi_a2, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, phi_a2, &this->animIndex); } } @@ -799,8 +856,7 @@ void func_80A730A0(EnDno* this, PlayState* play) { this->actorPath.pointOffset.y = 0.0f; this->actorPath.pointOffset.z = 0.0f; Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_334); - temp_f10 = (4.0f + Math_SinS(this->unk_3AE)) * Math_SinS(this->unk_3AC); - this->actor.world.pos.y += temp_f10; + this->actor.world.pos.y += Math_SinS(this->unk_3AC) * (4.0f + Math_SinS(this->unk_3AE)); this->unk_3AC += 4500; this->unk_3AE += 1000; this->actor.shape.rot.y = this->actor.yawTowardsPlayer; @@ -834,11 +890,12 @@ void func_80A732C8(EnDno* this, PlayState* play) { if (Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0x71C)) { this->unk_3B0 |= 4; this->unk_44E = 3; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 7, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_CLOSE_PARASOL, &this->animIndex); } } else if (this->unk_44E == 3) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 14, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IDLE_WITH_CANDLE, + &this->animIndex); func_80A72438(this, play); } else { if (this->skelAnime.curFrame >= 20.0f) { @@ -880,15 +937,16 @@ void func_80A73408(EnDno* this, PlayState* play) { } if (sp33) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, phi_a2, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, phi_a2, &this->animIndex); } } Cutscene_ActorTranslateAndYaw(&this->actor, play, temp_v0); } - if ((Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) && (this->unk_32C == 17)) { + if ((Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) && + (this->animIndex == EN_DNO_ANIM_SHOCK_START)) { if (0) {}; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 18, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_SHOCK_LOOP, &this->animIndex); } } @@ -982,7 +1040,7 @@ void EnDno_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, gSPMatrix(gfxOpa, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfxOpa[1], *dList); - POLY_OPA_DISP = gfxOpa + 2; + POLY_OPA_DISP = &gfxOpa[2]; CLOSE_DISPS(play->state.gfxCtx); } @@ -1007,7 +1065,7 @@ void EnDno_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, gDPSetEnvColor(&gfxXlu[3], 255, 0, 0, 0); gSPDisplayList(&gfxXlu[4], gEffFire1DL); - POLY_XLU_DISP = gfxXlu + 5; + POLY_XLU_DISP = &gfxXlu[5]; Matrix_Pop(); 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 2e417a7a02..db07a969b8 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.h +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.h @@ -2,6 +2,7 @@ #define Z_EN_DNO_H #include "global.h" +#include "objects/object_dnj/object_dnj.h" struct EnDno; @@ -21,10 +22,10 @@ typedef struct EnDno { /* 0x144 */ EnDnoActionFunc actionFunc; /* 0x148 */ SkelAnime skelAnime; /* 0x18C */ ColliderCylinder collider; - /* 0x1D8 */ Vec3s jointTable[28]; - /* 0x280 */ Vec3s morphTable[28]; + /* 0x1D8 */ Vec3s jointTable[DEKU_BUTLER_LIMB_MAX]; + /* 0x280 */ Vec3s morphTable[DEKU_BUTLER_LIMB_MAX]; /* 0x328 */ s32 unk_328; - /* 0x32C */ s32 unk_32C; + /* 0x32C */ s32 animIndex; /* 0x330 */ UNK_TYPE1 unk_330[0x4]; /* 0x334 */ Vec3f unk_334; /* 0x340 */ ActorPathing actorPath; From b080fb370032738769467242c7a1a7945f972836 Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Fri, 30 Sep 2022 20:51:49 -0400 Subject: [PATCH 06/25] z_kaleido_mask.c Ok and Documented (Pause Menu Mask Page) (#1093) * import mask docs * cleanup * some PR * fix merge from master * fix merge * move cursor result --- include/z64.h | 11 +- include/z64save.h | 2 +- src/code/flg_set.c | 8 +- src/code/z_sram_NES.c | 4 +- src/overlays/actors/ovl_En_Js/z_en_js.c | 32 +- .../ovl_kaleido_scope/z_kaleido_debug.c | 4 +- .../ovl_kaleido_scope/z_kaleido_item.c | 161 ++-- .../ovl_kaleido_scope/z_kaleido_mask.c | 827 +++++++++++++++++- .../ovl_kaleido_scope/z_kaleido_scope.h | 22 + tools/disasm/functions.txt | 6 +- tools/disasm/variables.txt | 18 +- 11 files changed, 930 insertions(+), 165 deletions(-) diff --git a/include/z64.h b/include/z64.h index 5589e7cad5..96302ed0c8 100644 --- a/include/z64.h +++ b/include/z64.h @@ -440,13 +440,12 @@ typedef struct { /* 0x220 */ f32 unk_220; /* 0x224 */ u16 alpha; /* 0x226 */ s16 offsetY; - /* 0x228 */ s32 unk_228; - /* 0x22C */ s32 unk_22C; - /* 0x230 */ s32 stickRelX; - /* 0x234 */ s32 stickRelY; + /* 0x228 */ UNK_TYPE1 unk_228[0x8]; + /* 0x230 */ s32 stickAdjX; + /* 0x234 */ s32 stickAdjY; /* 0x238 */ s16 cursorPoint[5]; - /* 0x242 */ s16 cursorX[5]; - /* 0x24C */ s16 cursorY[5]; + /* 0x242 */ s16 cursorXIndex[5]; + /* 0x24C */ s16 cursorYIndex[5]; /* 0x256 */ s16 unk_256; /* 0x258 */ s16 cursorSpecialPos; /* 0x25A */ s16 pageSwitchTimer; diff --git a/include/z64save.h b/include/z64save.h index df78cc169a..74cf31c8e3 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -368,7 +368,7 @@ typedef struct SaveContext { /* 0x3F64 */ f32 screenScale; // "framescale_scale" /* 0x3F68 */ CycleSceneFlags cycleSceneFlags[120]; // Scene flags that are temporarily stored over the duration of a single 3-day cycle /* 0x48C8 */ u16 dungeonIndex; // "scene_id_mix" - /* 0x48CA */ u8 maskMaskBit[27]; // "mask_mask_bit", masks given away on the Moon + /* 0x48CA */ u8 masksGivenOnMoon[27]; // bit-packed, masks given away on the Moon. "mask_mask_bit" } SaveContext; // size = 0x48C8 typedef enum ButtonStatus { diff --git a/src/code/flg_set.c b/src/code/flg_set.c index 0bc9781602..a22b62a0ef 100644 --- a/src/code/flg_set.c +++ b/src/code/flg_set.c @@ -1,6 +1,6 @@ /** * File: flg_set.c - * Description: Event Editor, used to view and edit weekEventReg, eventInf and maskMaskBit flags. + * Description: Event Editor, used to view and edit weekEventReg, eventInf and masksGivenOnMoon flags. * Controls: * + Left and Right: select different flags/bits in array element * + Up and Down: select array element (byte) 1 up/down @@ -123,9 +123,9 @@ static FlagSetEntry sFlagEntries[] = { { &gSaveContext.eventInf[6], "event_inf[6]" }, { &gSaveContext.eventInf[7], "event_inf[7]" }, - { &gSaveContext.maskMaskBit[0], "mask_mask_bit[0]" }, - { &gSaveContext.maskMaskBit[1], "mask_mask_bit[1]" }, - { &gSaveContext.maskMaskBit[2], "mask_mask_bit[2]" }, + { &gSaveContext.masksGivenOnMoon[0], "mask_mask_bit[0]" }, + { &gSaveContext.masksGivenOnMoon[1], "mask_mask_bit[1]" }, + { &gSaveContext.masksGivenOnMoon[2], "mask_mask_bit[2]" }, { NULL, NULL }, // used in the code to detect array end }; diff --git a/src/code/z_sram_NES.c b/src/code/z_sram_NES.c index 73b0a0af09..6f90061461 100644 --- a/src/code/z_sram_NES.c +++ b/src/code/z_sram_NES.c @@ -292,8 +292,8 @@ void Sram_SaveEndOfCycle(PlayState* play) { gSaveContext.cycleSceneFlags[i].collectible = 0; } - for (i = 0; i < ARRAY_COUNT(gSaveContext.maskMaskBit); i++) { - gSaveContext.maskMaskBit[i] = 0; + for (i = 0; i < ARRAY_COUNT(gSaveContext.masksGivenOnMoon); i++) { + gSaveContext.masksGivenOnMoon[i] = 0; } if (gSaveContext.save.weekEventReg[84] & 0x20) { diff --git a/src/overlays/actors/ovl_En_Js/z_en_js.c b/src/overlays/actors/ovl_En_Js/z_en_js.c index 4e35a51587..457f62d77e 100644 --- a/src/overlays/actors/ovl_En_Js/z_en_js.c +++ b/src/overlays/actors/ovl_En_Js/z_en_js.c @@ -272,7 +272,7 @@ s32 func_80968E38(s32 arg0) { s32 i; s32 count; u8 mask; - u8* maskMaskBit = gSaveContext.maskMaskBit; + u8* masksGivenOnMoon = gSaveContext.masksGivenOnMoon; if (((arg0 < 0) || (arg0 >= 9))) { return 0; @@ -282,21 +282,21 @@ s32 func_80968E38(s32 arg0) { arg0 *= 3; for (mask = 1, i = 0; i < 8; i++, mask <<= 1) { - if (maskMaskBit[arg0] & mask) { + if (masksGivenOnMoon[arg0] & mask) { count++; } } arg0++; for (mask = 1, i = 0; i < 8; i++, mask <<= 1) { - if (maskMaskBit[arg0] & mask) { + if (masksGivenOnMoon[arg0] & mask) { count++; } } arg0++; for (mask = 1, i = 0; i < 5; i++, mask <<= 1) { - if (maskMaskBit[arg0] & mask) { + if (masksGivenOnMoon[arg0] & mask) { count++; } } @@ -373,15 +373,15 @@ s32 EnJs_GetRemainingMasks(void) { } void EnJs_TakeMask(s32 actionParams, s32 childType) { - u8* maskMaskBit = gSaveContext.maskMaskBit; + u8* masksGivenOnMoon = gSaveContext.masksGivenOnMoon; s32 temp = 0; if ((childType >= 0) && (childType < 9)) { actionParams -= PLAYER_AP_MASK_TRUTH; childType *= 3; if (actionParams < 8) { - maskMaskBit[childType] |= 1 << actionParams; - maskMaskBit[temp] |= 1 << actionParams; + masksGivenOnMoon[childType] |= 1 << actionParams; + masksGivenOnMoon[temp] |= 1 << actionParams; return; } @@ -389,8 +389,8 @@ void EnJs_TakeMask(s32 actionParams, s32 childType) { childType++; temp++; if (actionParams < 8) { - maskMaskBit[childType] |= 1 << actionParams; - maskMaskBit[temp] |= 1 << actionParams; + masksGivenOnMoon[childType] |= 1 << actionParams; + masksGivenOnMoon[temp] |= 1 << actionParams; return; } @@ -398,8 +398,8 @@ void EnJs_TakeMask(s32 actionParams, s32 childType) { childType++; temp++; if (actionParams < 6) { - maskMaskBit[childType] |= 1 << actionParams; - maskMaskBit[temp] |= 1 << actionParams; + masksGivenOnMoon[childType] |= 1 << actionParams; + masksGivenOnMoon[temp] |= 1 << actionParams; } } } @@ -457,15 +457,15 @@ s32 func_8096933C(s32 arg0) { } void func_80969400(s32 arg0) { - u8* maskMaskBit = gSaveContext.maskMaskBit; - u8* temp_v0 = &gSaveContext.maskMaskBit[arg0 * 3]; + u8* masksGivenOnMoon = gSaveContext.masksGivenOnMoon; + u8* temp_v0 = &gSaveContext.masksGivenOnMoon[arg0 * 3]; if ((arg0 >= 0) && (arg0 < 9)) { - maskMaskBit[0] &= ~temp_v0[0]; - maskMaskBit[1] &= ~temp_v0[1]; + masksGivenOnMoon[0] &= ~temp_v0[0]; + masksGivenOnMoon[1] &= ~temp_v0[1]; temp_v0[2] &= 0xF; - maskMaskBit[2] &= ~temp_v0[2]; + masksGivenOnMoon[2] &= ~temp_v0[2]; temp_v0[0] = 0; temp_v0[1] = 0; diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_debug.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_debug.c index 9f6a58a860..c1f67b0797 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_debug.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_debug.c @@ -663,8 +663,8 @@ void KaleidoScope_UpdateInventoryEditor(PlayState* play) { s16 value; s32 dBtnInput = input->cur.button & (BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT); - pauseCtx->stickRelX = input->rel.stick_x; - pauseCtx->stickRelY = input->rel.stick_y; + pauseCtx->stickAdjX = input->rel.stick_x; + pauseCtx->stickAdjY = input->rel.stick_y; // Handles navigating the menu to different sections with the D-Pad // When the same direction is held, registers the input periodically based on a timer diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.c index 7f57ac7a39..be23b56dec 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.c @@ -7,13 +7,6 @@ #include "z_kaleido_scope.h" #include "interface/parameter_static/parameter_static.h" -typedef enum { - /* 0 */ EQUIP_STATE_MAGIC_ARROW_GROW_ORB, - /* 1 */ EQUIP_STATE_MAGIC_ARROW_MOVE_TO_BOW_SLOT, - /* 2 */ EQUIP_STATE_MAGIC_ARROW_HOVER_OVER_BOW_SLOT, - /* 3 */ EQUIP_STATE_MOVE_TO_C_BTN -} EquipState; - s16 sEquipState = EQUIP_STATE_MAGIC_ARROW_GROW_ORB; // Timer to hold magic arrow icon over magic arrow slot before moving when equipping. @@ -355,8 +348,8 @@ void KaleidoScope_UpdateItemCursor(PlayState* play) { u16 cursorSlot; u8 magicArrowIndex; s16 cursorPoint; - s16 cursorX; - s16 cursorY; + s16 cursorXIndex; + s16 cursorYIndex; s16 oldCursorPoint; s16 moveCursorResult; s16 pad2; @@ -366,7 +359,7 @@ void KaleidoScope_UpdateItemCursor(PlayState* play) { if ((pauseCtx->state == 6) && (pauseCtx->unk_200 == 0) && (pauseCtx->pageIndex == PAUSE_ITEM) && !pauseCtx->itemDescriptionOn) { - moveCursorResult = 0; + moveCursorResult = PAUSE_CURSOR_RESULT_NONE; oldCursorPoint = pauseCtx->cursorPoint[PAUSE_ITEM]; cursorItem = pauseCtx->cursorItem[PAUSE_ITEM]; @@ -376,87 +369,87 @@ void KaleidoScope_UpdateItemCursor(PlayState* play) { // cursor is currently on a slot pauseCtx->cursorColorSet = 2; - if (ABS_ALT(pauseCtx->stickRelX) > 30) { + if (ABS_ALT(pauseCtx->stickAdjX) > 30) { cursorPoint = pauseCtx->cursorPoint[PAUSE_ITEM]; - cursorX = pauseCtx->cursorX[PAUSE_ITEM]; - cursorY = pauseCtx->cursorY[PAUSE_ITEM]; + cursorXIndex = pauseCtx->cursorXIndex[PAUSE_ITEM]; + cursorYIndex = pauseCtx->cursorYIndex[PAUSE_ITEM]; // Search for slot to move to - while (moveCursorResult == 0) { - if (pauseCtx->stickRelX < -30) { + while (moveCursorResult == PAUSE_CURSOR_RESULT_NONE) { + if (pauseCtx->stickAdjX < -30) { // move cursor left pauseCtx->unk_298 = 4.0f; - if (pauseCtx->cursorX[PAUSE_ITEM] != 0) { - pauseCtx->cursorX[PAUSE_ITEM]--; + if (pauseCtx->cursorXIndex[PAUSE_ITEM] != 0) { + pauseCtx->cursorXIndex[PAUSE_ITEM]--; pauseCtx->cursorPoint[PAUSE_ITEM]--; - moveCursorResult = 1; + moveCursorResult = PAUSE_CURSOR_RESULT_SLOT; } else { - pauseCtx->cursorX[PAUSE_ITEM] = cursorX; - pauseCtx->cursorY[PAUSE_ITEM]++; + pauseCtx->cursorXIndex[PAUSE_ITEM] = cursorXIndex; + pauseCtx->cursorYIndex[PAUSE_ITEM]++; - if (pauseCtx->cursorY[PAUSE_ITEM] >= 4) { - pauseCtx->cursorY[PAUSE_ITEM] = 0; + if (pauseCtx->cursorYIndex[PAUSE_ITEM] >= 4) { + pauseCtx->cursorYIndex[PAUSE_ITEM] = 0; } pauseCtx->cursorPoint[PAUSE_ITEM] = - pauseCtx->cursorX[PAUSE_ITEM] + (pauseCtx->cursorY[PAUSE_ITEM] * 6); + pauseCtx->cursorXIndex[PAUSE_ITEM] + (pauseCtx->cursorYIndex[PAUSE_ITEM] * 6); if (pauseCtx->cursorPoint[PAUSE_ITEM] >= 24) { - pauseCtx->cursorPoint[PAUSE_ITEM] = pauseCtx->cursorX[PAUSE_ITEM]; + pauseCtx->cursorPoint[PAUSE_ITEM] = pauseCtx->cursorXIndex[PAUSE_ITEM]; } - if (cursorY == pauseCtx->cursorY[PAUSE_ITEM]) { - pauseCtx->cursorX[PAUSE_ITEM] = cursorX; + if (cursorYIndex == pauseCtx->cursorYIndex[PAUSE_ITEM]) { + pauseCtx->cursorXIndex[PAUSE_ITEM] = cursorXIndex; pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_LEFT); - moveCursorResult = 2; + moveCursorResult = PAUSE_CURSOR_RESULT_SPECIAL_POS; } } - } else if (pauseCtx->stickRelX > 30) { + } else if (pauseCtx->stickAdjX > 30) { // move cursor right pauseCtx->unk_298 = 4.0f; - if (pauseCtx->cursorX[PAUSE_ITEM] <= 4) { - pauseCtx->cursorX[PAUSE_ITEM]++; + if (pauseCtx->cursorXIndex[PAUSE_ITEM] <= 4) { + pauseCtx->cursorXIndex[PAUSE_ITEM]++; pauseCtx->cursorPoint[PAUSE_ITEM]++; - moveCursorResult = 1; + moveCursorResult = PAUSE_CURSOR_RESULT_SLOT; } else { - pauseCtx->cursorX[PAUSE_ITEM] = cursorX; - pauseCtx->cursorY[PAUSE_ITEM]++; + pauseCtx->cursorXIndex[PAUSE_ITEM] = cursorXIndex; + pauseCtx->cursorYIndex[PAUSE_ITEM]++; - if (pauseCtx->cursorY[PAUSE_ITEM] >= 4) { - pauseCtx->cursorY[PAUSE_ITEM] = 0; + if (pauseCtx->cursorYIndex[PAUSE_ITEM] >= 4) { + pauseCtx->cursorYIndex[PAUSE_ITEM] = 0; } pauseCtx->cursorPoint[PAUSE_ITEM] = - pauseCtx->cursorX[PAUSE_ITEM] + (pauseCtx->cursorY[PAUSE_ITEM] * 6); + pauseCtx->cursorXIndex[PAUSE_ITEM] + (pauseCtx->cursorYIndex[PAUSE_ITEM] * 6); if (pauseCtx->cursorPoint[PAUSE_ITEM] >= 24) { - pauseCtx->cursorPoint[PAUSE_ITEM] = pauseCtx->cursorX[PAUSE_ITEM]; + pauseCtx->cursorPoint[PAUSE_ITEM] = pauseCtx->cursorXIndex[PAUSE_ITEM]; } - if (cursorY == pauseCtx->cursorY[PAUSE_ITEM]) { - pauseCtx->cursorX[PAUSE_ITEM] = cursorX; + if (cursorYIndex == pauseCtx->cursorYIndex[PAUSE_ITEM]) { + pauseCtx->cursorXIndex[PAUSE_ITEM] = cursorXIndex; pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_RIGHT); - moveCursorResult = 2; + moveCursorResult = PAUSE_CURSOR_RESULT_SPECIAL_POS; } } } } - if (moveCursorResult == 1) { + if (moveCursorResult == PAUSE_CURSOR_RESULT_SLOT) { cursorItem = gSaveContext.save.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]]; } } } else if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) { - if (pauseCtx->stickRelX > 30) { + if (pauseCtx->stickAdjX > 30) { func_80821A04(play); - cursorY = 0; - cursorX = 0; + cursorYIndex = 0; + cursorXIndex = 0; cursorPoint = 0; // top row, left column (SLOT_OCARINA) // Search for slot to move to @@ -464,24 +457,24 @@ void KaleidoScope_UpdateItemCursor(PlayState* play) { // Check if current cursor has an item in its slot if (gSaveContext.save.inventory.items[cursorPoint] != ITEM_NONE) { pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; - pauseCtx->cursorX[PAUSE_ITEM] = cursorX; - pauseCtx->cursorY[PAUSE_ITEM] = cursorY; - moveCursorResult = 1; + pauseCtx->cursorXIndex[PAUSE_ITEM] = cursorXIndex; + pauseCtx->cursorYIndex[PAUSE_ITEM] = cursorYIndex; + moveCursorResult = PAUSE_CURSOR_RESULT_SLOT; break; } // move 1 row down and retry - cursorY++; + cursorYIndex++; cursorPoint += 6; - if (cursorY < 4) { + if (cursorYIndex < 4) { continue; } // move 1 column right and retry - cursorY = 0; - cursorPoint = cursorX + 1; - cursorX = cursorPoint; - if (cursorX < 6) { + cursorYIndex = 0; + cursorPoint = cursorXIndex + 1; + cursorXIndex = cursorPoint; + if (cursorXIndex < 6) { continue; } @@ -491,35 +484,35 @@ void KaleidoScope_UpdateItemCursor(PlayState* play) { } } } else { // PAUSE_CURSOR_PAGE_RIGHT - if (pauseCtx->stickRelX < -30) { + if (pauseCtx->stickAdjX < -30) { func_80821A04(play); - cursorX = 5; + cursorXIndex = 5; cursorPoint = 5; // top row, right columne (SLOT_TRADE_DEED) - cursorY = 0; + cursorYIndex = 0; // Search for slot to move to while (true) { // Check if current cursor has an item in its slot if (gSaveContext.save.inventory.items[cursorPoint] != ITEM_NONE) { pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; - pauseCtx->cursorX[PAUSE_ITEM] = cursorX; - pauseCtx->cursorY[PAUSE_ITEM] = cursorY; - moveCursorResult = 1; + pauseCtx->cursorXIndex[PAUSE_ITEM] = cursorXIndex; + pauseCtx->cursorYIndex[PAUSE_ITEM] = cursorYIndex; + moveCursorResult = PAUSE_CURSOR_RESULT_SLOT; break; } // move 1 row down and retry - cursorY++; + cursorYIndex++; cursorPoint += 6; - if (cursorY < 4) { + if (cursorYIndex < 4) { continue; } // move 1 column left and retry - cursorY = 0; - cursorPoint = cursorX - 1; - cursorX = cursorPoint; - if (cursorX >= 0) { + cursorYIndex = 0; + cursorPoint = cursorXIndex - 1; + cursorXIndex = cursorPoint; + if (cursorXIndex >= 0) { continue; } @@ -532,35 +525,35 @@ void KaleidoScope_UpdateItemCursor(PlayState* play) { if (pauseCtx->cursorSpecialPos == 0) { // move cursor up/down - if (ABS_ALT(pauseCtx->stickRelY) > 30) { - moveCursorResult = 0; + if (ABS_ALT(pauseCtx->stickAdjY) > 30) { + moveCursorResult = PAUSE_CURSOR_RESULT_NONE; cursorPoint = pauseCtx->cursorPoint[PAUSE_ITEM]; - cursorY = pauseCtx->cursorY[PAUSE_ITEM]; + cursorYIndex = pauseCtx->cursorYIndex[PAUSE_ITEM]; - while (moveCursorResult == 0) { - if (pauseCtx->stickRelY > 30) { + while (moveCursorResult == PAUSE_CURSOR_RESULT_NONE) { + if (pauseCtx->stickAdjY > 30) { // move cursor up - moveCursorResult = 2; - if (pauseCtx->cursorY[PAUSE_ITEM] != 0) { - pauseCtx->cursorY[PAUSE_ITEM]--; + moveCursorResult = PAUSE_CURSOR_RESULT_SPECIAL_POS; + if (pauseCtx->cursorYIndex[PAUSE_ITEM] != 0) { + pauseCtx->cursorYIndex[PAUSE_ITEM]--; pauseCtx->unk_298 = 4.0f; pauseCtx->cursorPoint[PAUSE_ITEM] -= 6; - moveCursorResult = 1; + moveCursorResult = PAUSE_CURSOR_RESULT_SLOT; } else { - pauseCtx->cursorY[PAUSE_ITEM] = cursorY; + pauseCtx->cursorYIndex[PAUSE_ITEM] = cursorYIndex; pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; } - } else if (pauseCtx->stickRelY < -30) { + } else if (pauseCtx->stickAdjY < -30) { // move cursor down - moveCursorResult = 2; - if (pauseCtx->cursorY[PAUSE_ITEM] < 3) { - pauseCtx->cursorY[PAUSE_ITEM]++; + moveCursorResult = PAUSE_CURSOR_RESULT_SPECIAL_POS; + if (pauseCtx->cursorYIndex[PAUSE_ITEM] < 3) { + pauseCtx->cursorYIndex[PAUSE_ITEM]++; pauseCtx->unk_298 = 4.0f; pauseCtx->cursorPoint[PAUSE_ITEM] += 6; - moveCursorResult = 1; + moveCursorResult = PAUSE_CURSOR_RESULT_SLOT; } else { - pauseCtx->cursorY[PAUSE_ITEM] = cursorY; + pauseCtx->cursorYIndex[PAUSE_ITEM] = cursorYIndex; pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; } } @@ -570,9 +563,9 @@ void KaleidoScope_UpdateItemCursor(PlayState* play) { cursorSlot = pauseCtx->cursorPoint[PAUSE_ITEM]; pauseCtx->cursorColorSet = 2; - if (moveCursorResult == 1) { + if (moveCursorResult == PAUSE_CURSOR_RESULT_SLOT) { cursorItem = gSaveContext.save.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]]; - } else if (moveCursorResult != 2) { + } else if (moveCursorResult != PAUSE_CURSOR_RESULT_SPECIAL_POS) { cursorItem = gSaveContext.save.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]]; } @@ -683,7 +676,7 @@ void KaleidoScope_UpdateItemCursor(PlayState* play) { (msgCtx->msgLength == 0)) { // Give description on item through a message box pauseCtx->itemDescriptionOn = true; - if (pauseCtx->cursorY[PAUSE_ITEM] < 2) { + if (pauseCtx->cursorYIndex[PAUSE_ITEM] < 2) { func_801514B0(play, 0x1700 + pauseCtx->cursorItem[PAUSE_ITEM], 3); } else { func_801514B0(play, 0x1700 + pauseCtx->cursorItem[PAUSE_ITEM], 1); diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_mask.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_mask.c index f8f61c5dc4..cedcbf8f32 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_mask.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_mask.c @@ -1,59 +1,810 @@ /* * File: z_kaleido_mask.c * Overlay: ovl_kaleido_scope - * Description: + * Description: Pause Menu - Mask Page */ #include "z_kaleido_scope.h" +#include "interface/parameter_static/parameter_static.h" -extern UNK_TYPE D_02001360; -extern UNK_TYPE D_020044A0; -extern UNK_TYPE D_02004AA0; -extern UNK_TYPE D_0200B998; -extern UNK_TYPE D_08062000; -extern UNK_TYPE D_08064340; -extern UNK_TYPE D_0B000000; -extern UNK_TYPE D_0C000000; -extern UNK_TYPE D_0C006C00; +s16 sMaskEquipState = EQUIP_STATE_MAGIC_ARROW_GROW_ORB; -s32 D_8082B600 = 0; +// Timer to hold magic arrow icon over magic arrow slot before moving when equipping. +s16 sMaskEquipMagicArrowSlotHoldTimer = 0; -s32 D_8082B604 = 0; +// Number of frames to move icon from slot to target position when equipping. +s16 sMaskEquipAnimTimer = 10; -s16 D_8082B608 = 10; - -s32 D_8082B60C[] = { - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00010000, - 0x00000001, 0x00000000, 0x00010000, 0x00000001, 0x00000000, 0x00010000, 0x00000001, 0x00000000, - 0x00010000, 0x00000001, 0x00000000, 0x00010000, 0x00000001, 0x00000000, 0x00010000, 0x00000001, - 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, +u8 gMaskPlayerFormSlotRestrictions[PLAYER_FORM_MAX][NUM_MASK_SLOTS] = { + // Fierce Deity + { + false, // SLOT_MASK_POSTMAN + false, // SLOT_MASK_ALL_NIGHT + false, // SLOT_MASK_BLAST + false, // SLOT_MASK_STONE + false, // SLOT_MASK_GREAT_FAIRY + false, // SLOT_MASK_DEKU + false, // SLOT_MASK_KEATON + false, // SLOT_MASK_BREMEN + false, // SLOT_MASK_BUNNY + false, // SLOT_MASK_DON_GERO + false, // SLOT_MASK_SCENTS + false, // SLOT_MASK_GORON + false, // SLOT_MASK_ROMANI + false, // SLOT_MASK_CIRCUS_LEADER + false, // SLOT_MASK_KAFEIS_MASK + false, // SLOT_MASK_COUPLE + false, // SLOT_MASK_TRUTH + false, // SLOT_MASK_ZORA + false, // SLOT_MASK_KAMARO + false, // SLOT_MASK_GIBDO + false, // SLOT_MASK_GARO + false, // SLOT_MASK_CAPTAIN + false, // SLOT_MASK_GIANT + true, // SLOT_MASK_FIERCE_DEITY + }, + // Goron + { + false, // SLOT_MASK_POSTMAN + false, // SLOT_MASK_ALL_NIGHT + false, // SLOT_MASK_BLAST + false, // SLOT_MASK_STONE + false, // SLOT_MASK_GREAT_FAIRY + true, // SLOT_MASK_DEKU + false, // SLOT_MASK_KEATON + false, // SLOT_MASK_BREMEN + false, // SLOT_MASK_BUNNY + false, // SLOT_MASK_DON_GERO + false, // SLOT_MASK_SCENTS + true, // SLOT_MASK_GORON + false, // SLOT_MASK_ROMANI + false, // SLOT_MASK_CIRCUS_LEADER + false, // SLOT_MASK_KAFEIS_MASK + false, // SLOT_MASK_COUPLE + false, // SLOT_MASK_TRUTH + true, // SLOT_MASK_ZORA + false, // SLOT_MASK_KAMARO + false, // SLOT_MASK_GIBDO + false, // SLOT_MASK_GARO + false, // SLOT_MASK_CAPTAIN + false, // SLOT_MASK_GIANT + true, // SLOT_MASK_FIERCE_DEITY + }, + // Zora + { + false, // SLOT_MASK_POSTMAN + false, // SLOT_MASK_ALL_NIGHT + false, // SLOT_MASK_BLAST + false, // SLOT_MASK_STONE + false, // SLOT_MASK_GREAT_FAIRY + true, // SLOT_MASK_DEKU + false, // SLOT_MASK_KEATON + false, // SLOT_MASK_BREMEN + false, // SLOT_MASK_BUNNY + false, // SLOT_MASK_DON_GERO + false, // SLOT_MASK_SCENTS + true, // SLOT_MASK_GORON + false, // SLOT_MASK_ROMANI + false, // SLOT_MASK_CIRCUS_LEADER + false, // SLOT_MASK_KAFEIS_MASK + false, // SLOT_MASK_COUPLE + false, // SLOT_MASK_TRUTH + true, // SLOT_MASK_ZORA + false, // SLOT_MASK_KAMARO + false, // SLOT_MASK_GIBDO + false, // SLOT_MASK_GARO + false, // SLOT_MASK_CAPTAIN + false, // SLOT_MASK_GIANT + true, // SLOT_MASK_FIERCE_DEITY + }, + // Deku + { + false, // SLOT_MASK_POSTMAN + false, // SLOT_MASK_ALL_NIGHT + false, // SLOT_MASK_BLAST + false, // SLOT_MASK_STONE + false, // SLOT_MASK_GREAT_FAIRY + true, // SLOT_MASK_DEKU + false, // SLOT_MASK_KEATON + false, // SLOT_MASK_BREMEN + false, // SLOT_MASK_BUNNY + false, // SLOT_MASK_DON_GERO + false, // SLOT_MASK_SCENTS + true, // SLOT_MASK_GORON + false, // SLOT_MASK_ROMANI + false, // SLOT_MASK_CIRCUS_LEADER + false, // SLOT_MASK_KAFEIS_MASK + false, // SLOT_MASK_COUPLE + false, // SLOT_MASK_TRUTH + true, // SLOT_MASK_ZORA + false, // SLOT_MASK_KAMARO + false, // SLOT_MASK_GIBDO + false, // SLOT_MASK_GARO + false, // SLOT_MASK_CAPTAIN + false, // SLOT_MASK_GIANT + true, // SLOT_MASK_FIERCE_DEITY + }, + // Human + { + true, // SLOT_MASK_POSTMAN + true, // SLOT_MASK_ALL_NIGHT + true, // SLOT_MASK_BLAST + true, // SLOT_MASK_STONE + true, // SLOT_MASK_GREAT_FAIRY + true, // SLOT_MASK_DEKU + true, // SLOT_MASK_KEATON + true, // SLOT_MASK_BREMEN + true, // SLOT_MASK_BUNNY + true, // SLOT_MASK_DON_GERO + true, // SLOT_MASK_SCENTS + true, // SLOT_MASK_GORON + true, // SLOT_MASK_ROMANI + true, // SLOT_MASK_CIRCUS_LEADER + true, // SLOT_MASK_KAFEIS_MASK + true, // SLOT_MASK_COUPLE + true, // SLOT_MASK_TRUTH + true, // SLOT_MASK_ZORA + true, // SLOT_MASK_KAMARO + true, // SLOT_MASK_GIBDO + true, // SLOT_MASK_GARO + true, // SLOT_MASK_CAPTAIN + true, // SLOT_MASK_GIANT + true, // SLOT_MASK_FIERCE_DEITY + }, }; -s32 D_8082B684[] = { - 0x01010004, 0x02020180, 0x01040210, 0x00100201, 0x00080110, 0x02040220, 0x00400080, 0x00020102, 0x00010240, - 0x01200108, 0x00200140, 0x02080280, 0x00FF0064, 0x00FF0000, 0x00000064, 0x00FF0000, 0x000000FF, 0x00640000, +#define SET_MOON_MASK_BIT(masksGivenOnMoonIndex, masksGivenOnMoonFlag) \ + ((masksGivenOnMoonIndex) << 8 | (masksGivenOnMoonFlag)) +#define CHECK_GIVEN_MASK_ON_MOON(maskIndex) \ + (gSaveContext.masksGivenOnMoon[sMasksGivenOnMoonBits[maskIndex] >> 8] & (u8)sMasksGivenOnMoonBits[maskIndex]) + +u16 sMasksGivenOnMoonBits[] = { + SET_MOON_MASK_BIT(1, 0x1), // SLOT_MASK_POSTMAN + SET_MOON_MASK_BIT(0, 0x4), // SLOT_MASK_ALL_NIGHT + SET_MOON_MASK_BIT(2, 0x2), // SLOT_MASK_BLAST + SET_MOON_MASK_BIT(1, 0x80), // SLOT_MASK_STONE + SET_MOON_MASK_BIT(1, 0x4), // SLOT_MASK_GREAT_FAIRY + SET_MOON_MASK_BIT(2, 0x10), // SLOT_MASK_DEKU + SET_MOON_MASK_BIT(0, 0x10), // SLOT_MASK_KEATON + SET_MOON_MASK_BIT(2, 0x1), // SLOT_MASK_BREMEN + SET_MOON_MASK_BIT(0, 0x8), // SLOT_MASK_BUNNY + SET_MOON_MASK_BIT(1, 0x10), // SLOT_MASK_DON_GERO + SET_MOON_MASK_BIT(2, 0x4), // SLOT_MASK_SCENTS + SET_MOON_MASK_BIT(2, 0x20), // SLOT_MASK_GORON + SET_MOON_MASK_BIT(0, 0x40), // SLOT_MASK_ROMANI + SET_MOON_MASK_BIT(0, 0x80), // SLOT_MASK_CIRCUS_LEADER + SET_MOON_MASK_BIT(0, 0x2), // SLOT_MASK_KAFEIS_MASK + SET_MOON_MASK_BIT(1, 0x2), // SLOT_MASK_COUPLE + SET_MOON_MASK_BIT(0, 0x1), // SLOT_MASK_TRUTH + SET_MOON_MASK_BIT(2, 0x40), // SLOT_MASK_ZORA + SET_MOON_MASK_BIT(1, 0x20), // SLOT_MASK_KAMARO + SET_MOON_MASK_BIT(1, 0x8), // SLOT_MASK_GIBDO + SET_MOON_MASK_BIT(0, 0x20), // SLOT_MASK_GARO + SET_MOON_MASK_BIT(1, 0x40), // SLOT_MASK_CAPTAIN + SET_MOON_MASK_BIT(2, 0x8), // SLOT_MASK_GIANT + SET_MOON_MASK_BIT(2, 0X80), // SLOT_MASK_FIERCE_DEITY }; -u8 D_8082B6CC[] = { 0x35, 0x33, 0x34, 0x32, 0xFF }; +s16 sMaskMagicArrowEffectsR[] = { 255, 100, 255 }; +s16 sMaskMagicArrowEffectsG[] = { 0, 100, 255 }; +s16 sMaskMagicArrowEffectsB[] = { 0, 255, 100 }; -s16 D_8082B6D4[] = { - 0x0294, - 0x0384, - 0x0474, - 0x0000, +void KaleidoScope_DrawMaskSelect(PlayState* play) { + PauseContext* pauseCtx = &play->pauseCtx; + u16 i; + u16 j; + + OPEN_DISPS(play->state.gfxCtx); + + KaleidoScope_SetCursorVtx(pauseCtx, pauseCtx->cursorSlot[PAUSE_MASK] * 4, pauseCtx->maskVtx); + + func_8012C8AC(play->state.gfxCtx); + + // Draw a white box around the items that are equipped on the C buttons + // Loop over c-buttons (i) and vtx offset (j) + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + for (i = 0, j = NUM_MASK_SLOTS * 4; i < 3; i++, j += 4) { + if (GET_CUR_FORM_BTN_ITEM(i + 1) != ITEM_NONE) { + if (GET_CUR_FORM_BTN_SLOT(i + 1) >= NUM_ITEM_SLOTS) { + gSPVertex(POLY_OPA_DISP++, &pauseCtx->maskVtx[j], 4, 0); + POLY_OPA_DISP = func_8010DC58(POLY_OPA_DISP, gEquippedItemOutlineTex, 32, 32, 0); + } + } + } + + gDPPipeSync(POLY_OPA_DISP++); + + // Draw the item icons + // Loop over slots (i) and vtx offset (j) + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + for (j = 0, i = 0; i < NUM_MASK_SLOTS; i++, j += 4) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + + if (((void)0, gSaveContext.save.inventory.items[i + NUM_ITEM_SLOTS]) != ITEM_NONE) { + if (!CHECK_GIVEN_MASK_ON_MOON(i)) { + if ((pauseCtx->unk_200 == 0) && (pauseCtx->pageIndex == PAUSE_MASK) && + (pauseCtx->cursorSpecialPos == 0) && + gMaskPlayerFormSlotRestrictions[(void)0, gSaveContext.save.playerForm][i]) { + if ((sMaskEquipState == EQUIP_STATE_MAGIC_ARROW_HOVER_OVER_BOW_SLOT) && (i == SLOT_ARROW_ICE)) { + // Possible bug: + // Supposed to be `SLOT_BOW`, unchanged from OoT, instead increase size of ice arrow icon + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, + sMaskMagicArrowEffectsR[pauseCtx->equipTargetItem - 0xB5], + sMaskMagicArrowEffectsG[pauseCtx->equipTargetItem - 0xB5], + sMaskMagicArrowEffectsB[pauseCtx->equipTargetItem - 0xB5], pauseCtx->alpha); + + pauseCtx->maskVtx[j + 0].v.ob[0] = pauseCtx->maskVtx[j + 2].v.ob[0] = + pauseCtx->maskVtx[j + 0].v.ob[0] - 2; + pauseCtx->maskVtx[j + 1].v.ob[0] = pauseCtx->maskVtx[j + 3].v.ob[0] = + pauseCtx->maskVtx[j + 0].v.ob[0] + 32; + pauseCtx->maskVtx[j + 0].v.ob[1] = pauseCtx->maskVtx[j + 1].v.ob[1] = + pauseCtx->maskVtx[j + 0].v.ob[1] + 2; + pauseCtx->maskVtx[j + 2].v.ob[1] = pauseCtx->maskVtx[j + 3].v.ob[1] = + pauseCtx->maskVtx[j + 0].v.ob[1] - 32; + + } else if (i == pauseCtx->cursorSlot[PAUSE_MASK]) { + // Increase the size of the selected item + pauseCtx->maskVtx[j + 0].v.ob[0] = pauseCtx->maskVtx[j + 2].v.ob[0] = + pauseCtx->maskVtx[j + 0].v.ob[0] - 2; + pauseCtx->maskVtx[j + 1].v.ob[0] = pauseCtx->maskVtx[j + 3].v.ob[0] = + pauseCtx->maskVtx[j + 0].v.ob[0] + 32; + pauseCtx->maskVtx[j + 0].v.ob[1] = pauseCtx->maskVtx[j + 1].v.ob[1] = + pauseCtx->maskVtx[j + 0].v.ob[1] + 2; + pauseCtx->maskVtx[j + 2].v.ob[1] = pauseCtx->maskVtx[j + 3].v.ob[1] = + pauseCtx->maskVtx[j + 0].v.ob[1] - 32; + } + } + + gSPVertex(POLY_OPA_DISP++, &pauseCtx->maskVtx[j + 0], 4, 0); + KaleidoScope_DrawQuadTextureRGBA32( + play->state.gfxCtx, gItemIcons[((void)0, gSaveContext.save.inventory.items[i + NUM_ITEM_SLOTS])], + 32, 32, 0); + } + } + } + + CLOSE_DISPS(play->state.gfxCtx); +} + +u8 sMaskPlayerFormItems[] = { + ITEM_MASK_FIERCE_DEITY, ITEM_MASK_GORON, ITEM_MASK_ZORA, ITEM_MASK_DEKU, ITEM_NONE, }; -s16 D_8082B6DC[] = { - 0x044C, - 0x0398, - 0x044C, - 0x0000, -}; +void KaleidoScope_UpdateMaskCursor(PlayState* play) { + Input* input = CONTROLLER1(&play->state); + PauseContext* pauseCtx = &play->pauseCtx; + MessageContext* msgCtx = &play->msgCtx; + u16 vtxIndex; + u16 cursorItem; + u16 cursorSlot; + s16 cursorPoint; + s16 cursorXIndex; + s16 cursorYIndex; + s16 oldCursorPoint; + s16 moveCursorResult; + s16 pad2; -s16 D_8082B6E4 = 0; + pauseCtx->cursorColorSet = 0; + pauseCtx->nameColorSet = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_8081FF80.s") + if ((pauseCtx->state == 6) && (pauseCtx->unk_200 == 0) && (pauseCtx->pageIndex == PAUSE_MASK) && + !pauseCtx->itemDescriptionOn) { + moveCursorResult = PAUSE_CURSOR_RESULT_NONE; + oldCursorPoint = pauseCtx->cursorPoint[PAUSE_MASK]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_808204AC.s") + cursorItem = pauseCtx->cursorItem[PAUSE_MASK]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80820FA4.s") + // Move cursor left/right + if (pauseCtx->cursorSpecialPos == 0) { + // cursor is currently on a slot + pauseCtx->cursorColorSet = 2; + + if (ABS_ALT(pauseCtx->stickAdjX) > 30) { + cursorPoint = pauseCtx->cursorPoint[PAUSE_MASK]; + cursorXIndex = pauseCtx->cursorXIndex[PAUSE_MASK]; + cursorYIndex = pauseCtx->cursorYIndex[PAUSE_MASK]; + + // Search for slot to move to + while (moveCursorResult == PAUSE_CURSOR_RESULT_NONE) { + if (pauseCtx->stickAdjX < -30) { + // move cursor left + pauseCtx->unk_298 = 4.0f; + if (pauseCtx->cursorXIndex[PAUSE_MASK] != 0) { + pauseCtx->cursorXIndex[PAUSE_MASK]--; + pauseCtx->cursorPoint[PAUSE_MASK]--; + moveCursorResult = PAUSE_CURSOR_RESULT_SLOT; + } else { + pauseCtx->cursorYIndex[PAUSE_MASK]++; + + if (pauseCtx->cursorYIndex[PAUSE_MASK] >= 4) { + pauseCtx->cursorYIndex[PAUSE_MASK] = 0; + } + + pauseCtx->cursorPoint[PAUSE_MASK] = + pauseCtx->cursorXIndex[PAUSE_MASK] + (pauseCtx->cursorYIndex[PAUSE_MASK] * 6); + + if (pauseCtx->cursorPoint[PAUSE_MASK] >= NUM_MASK_SLOTS) { + pauseCtx->cursorPoint[PAUSE_MASK] = pauseCtx->cursorXIndex[PAUSE_MASK]; + } + + if (cursorYIndex == pauseCtx->cursorYIndex[PAUSE_MASK]) { + pauseCtx->cursorXIndex[PAUSE_MASK] = cursorXIndex; + pauseCtx->cursorPoint[PAUSE_MASK] = cursorPoint; + + KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_LEFT); + + moveCursorResult = PAUSE_CURSOR_RESULT_SPECIAL_POS; + } + } + } else if (pauseCtx->stickAdjX > 30) { + // move cursor right + pauseCtx->unk_298 = 4.0f; + if (pauseCtx->cursorXIndex[PAUSE_MASK] <= 4) { + pauseCtx->cursorXIndex[PAUSE_MASK]++; + pauseCtx->cursorPoint[PAUSE_MASK]++; + moveCursorResult = PAUSE_CURSOR_RESULT_SLOT; + } else { + pauseCtx->cursorYIndex[PAUSE_MASK]++; + + if (pauseCtx->cursorYIndex[PAUSE_MASK] >= 4) { + pauseCtx->cursorYIndex[PAUSE_MASK] = 0; + } + + pauseCtx->cursorPoint[PAUSE_MASK] = + pauseCtx->cursorXIndex[PAUSE_MASK] + (pauseCtx->cursorYIndex[PAUSE_MASK] * 6); + + if (pauseCtx->cursorPoint[PAUSE_MASK] >= NUM_MASK_SLOTS) { + pauseCtx->cursorPoint[PAUSE_MASK] = pauseCtx->cursorXIndex[PAUSE_MASK]; + } + + if (cursorYIndex == pauseCtx->cursorYIndex[PAUSE_MASK]) { + pauseCtx->cursorXIndex[PAUSE_MASK] = cursorXIndex; + pauseCtx->cursorPoint[PAUSE_MASK] = cursorPoint; + + KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_RIGHT); + + moveCursorResult = PAUSE_CURSOR_RESULT_SPECIAL_POS; + } + } + } + } + + if (moveCursorResult == PAUSE_CURSOR_RESULT_SLOT) { + cursorItem = gSaveContext.save.inventory.items[pauseCtx->cursorPoint[PAUSE_MASK] + NUM_ITEM_SLOTS]; + if (CHECK_GIVEN_MASK_ON_MOON(pauseCtx->cursorPoint[PAUSE_MASK])) { + cursorItem = ITEM_NONE; + } + } + } + } else if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) { + if (pauseCtx->stickAdjX > 30) { + func_80821A04(play); + cursorYIndex = 0; + cursorXIndex = 0; + cursorPoint = 0; // top row, left column (SLOT_MASK_POSTMAN) + + // Search for slot to move to + while (true) { + // Check if current cursor has an item in its slot + if ((gSaveContext.save.inventory.items[cursorPoint + NUM_ITEM_SLOTS] != ITEM_NONE) && + !CHECK_GIVEN_MASK_ON_MOON(cursorPoint)) { + pauseCtx->cursorPoint[PAUSE_MASK] = cursorPoint; + pauseCtx->cursorXIndex[PAUSE_MASK] = cursorXIndex; + pauseCtx->cursorYIndex[PAUSE_MASK] = cursorYIndex; + moveCursorResult = PAUSE_CURSOR_RESULT_SLOT; + break; + } + + // move 1 row down and retry + cursorYIndex++; + cursorPoint += 6; + if (cursorYIndex < 4) { + continue; + } + + // move 1 column right and retry + cursorYIndex = 0; + cursorPoint = cursorXIndex + 1; + cursorXIndex = cursorPoint; + if (cursorXIndex < 6) { + continue; + } + + // No item available + KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_RIGHT); + break; + } + } + } else { // PAUSE_CURSOR_PAGE_RIGHT + //! FAKE: + if (1) {} + if (pauseCtx->stickAdjX < -30) { + func_80821A04(play); + cursorXIndex = 5; + cursorPoint = 5; // top row, right column (SLOT_MASK_DEKU) + cursorYIndex = 0; + + // Search for slot to move to + while (true) { + // Check if current cursor has an item in its slot + if ((gSaveContext.save.inventory.items[cursorPoint + NUM_ITEM_SLOTS] != ITEM_NONE) && + !CHECK_GIVEN_MASK_ON_MOON(cursorPoint)) { + pauseCtx->cursorPoint[PAUSE_MASK] = cursorPoint; + pauseCtx->cursorXIndex[PAUSE_MASK] = cursorXIndex; + pauseCtx->cursorYIndex[PAUSE_MASK] = cursorYIndex; + moveCursorResult = PAUSE_CURSOR_RESULT_SLOT; + break; + } + + // move 1 row down and retry + cursorYIndex++; + cursorPoint += 6; + if (cursorYIndex < 4) { + continue; + } + + // move 1 column left and retry + cursorYIndex = 0; + cursorPoint = cursorXIndex - 1; + cursorXIndex = cursorPoint; + if (cursorXIndex >= 0) { + continue; + } + + // No item available + KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_LEFT); + break; + } + } + } + + if (pauseCtx->cursorSpecialPos == 0) { + // move cursor up/down + if (ABS_ALT(pauseCtx->stickAdjY) > 30) { + moveCursorResult = PAUSE_CURSOR_RESULT_NONE; + + cursorPoint = pauseCtx->cursorPoint[PAUSE_MASK]; + cursorYIndex = pauseCtx->cursorYIndex[PAUSE_MASK]; + + while (moveCursorResult == PAUSE_CURSOR_RESULT_NONE) { + if (pauseCtx->stickAdjY > 30) { + // move cursor up + moveCursorResult = PAUSE_CURSOR_RESULT_SPECIAL_POS; + if (pauseCtx->cursorYIndex[PAUSE_MASK] != 0) { + pauseCtx->unk_298 = 4.0f; + pauseCtx->cursorYIndex[PAUSE_MASK]--; + pauseCtx->cursorPoint[PAUSE_MASK] -= 6; + moveCursorResult = PAUSE_CURSOR_RESULT_SLOT; + } else { + pauseCtx->cursorYIndex[PAUSE_MASK] = cursorYIndex; + pauseCtx->cursorPoint[PAUSE_MASK] = cursorPoint; + } + } else if (pauseCtx->stickAdjY < -30) { + // move cursor down + moveCursorResult = PAUSE_CURSOR_RESULT_SPECIAL_POS; + if (pauseCtx->cursorYIndex[PAUSE_MASK] < 3) { + pauseCtx->unk_298 = 4.0f; + pauseCtx->cursorYIndex[PAUSE_MASK]++; + pauseCtx->cursorPoint[PAUSE_MASK] += 6; + moveCursorResult = PAUSE_CURSOR_RESULT_SLOT; + } else { + pauseCtx->cursorYIndex[PAUSE_MASK] = cursorYIndex; + pauseCtx->cursorPoint[PAUSE_MASK] = cursorPoint; + } + } + } + } + + cursorSlot = pauseCtx->cursorPoint[PAUSE_MASK]; + pauseCtx->cursorColorSet = 2; + + if (moveCursorResult == PAUSE_CURSOR_RESULT_SLOT) { + cursorItem = gSaveContext.save.inventory.items[pauseCtx->cursorPoint[PAUSE_MASK] + NUM_ITEM_SLOTS]; + if (CHECK_GIVEN_MASK_ON_MOON(pauseCtx->cursorPoint[PAUSE_MASK])) { + cursorItem = ITEM_NONE; + } + } else if (moveCursorResult != PAUSE_CURSOR_RESULT_SPECIAL_POS) { + cursorItem = gSaveContext.save.inventory.items[pauseCtx->cursorPoint[PAUSE_MASK] + NUM_ITEM_SLOTS]; + if (CHECK_GIVEN_MASK_ON_MOON(pauseCtx->cursorPoint[PAUSE_MASK])) { + cursorItem = ITEM_NONE; + } + } + + if (cursorItem == ITEM_NONE) { + cursorItem = PAUSE_ITEM_NONE; + pauseCtx->cursorColorSet = 0; + } + + if ((cursorItem != PAUSE_ITEM_NONE) && (msgCtx->msgLength == 0)) { + if (gSaveContext.buttonStatus[EQUIP_SLOT_A] == BTN_DISABLED) { + gSaveContext.buttonStatus[EQUIP_SLOT_A] = BTN_ENABLED; + gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); + } + } else if (gSaveContext.buttonStatus[EQUIP_SLOT_A] != BTN_DISABLED) { + gSaveContext.buttonStatus[EQUIP_SLOT_A] = BTN_DISABLED; + gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); + } + + pauseCtx->cursorItem[PAUSE_MASK] = cursorItem; + pauseCtx->cursorSlot[PAUSE_MASK] = cursorSlot; + if (cursorItem != PAUSE_ITEM_NONE) { + // Equip item to the C buttons + if ((pauseCtx->debugEditor == DEBUG_EDITOR_NONE) && !pauseCtx->itemDescriptionOn && + (pauseCtx->state == 6) && (pauseCtx->unk_200 == 0) && + CHECK_BTN_ANY(input->press.button, BTN_CLEFT | BTN_CDOWN | BTN_CRIGHT)) { + + // Ensure that a mask is not unequipped while being used + if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + if (((Player_GetCurMaskItemId(play) != ITEM_NONE) && + (Player_GetCurMaskItemId(play) == BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT))) || + ((sMaskPlayerFormItems[((void)0, gSaveContext.save.playerForm)] != ITEM_NONE) && + (sMaskPlayerFormItems[((void)0, gSaveContext.save.playerForm)] == + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT)))) { + play_sound(NA_SE_SY_ERROR); + return; + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN)) { + if (((Player_GetCurMaskItemId(play) != ITEM_NONE) && + (Player_GetCurMaskItemId(play) == BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN))) || + ((sMaskPlayerFormItems[((void)0, gSaveContext.save.playerForm)] != ITEM_NONE) && + (sMaskPlayerFormItems[((void)0, gSaveContext.save.playerForm)] == + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN)))) { + play_sound(NA_SE_SY_ERROR); + return; + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + if (((Player_GetCurMaskItemId(play) != ITEM_NONE) && + (Player_GetCurMaskItemId(play) == BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT))) || + ((sMaskPlayerFormItems[((void)0, gSaveContext.save.playerForm)] != ITEM_NONE) && + (sMaskPlayerFormItems[((void)0, gSaveContext.save.playerForm)] == + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT)))) { + play_sound(NA_SE_SY_ERROR); + return; + } + } + + if ((Player_GetEnvTimerType(play) >= PLAYER_ENV_TIMER_UNDERWATER_FLOOR) && + (Player_GetEnvTimerType(play) <= PLAYER_ENV_TIMER_UNDERWATER_FREE) && + ((cursorSlot == (SLOT_MASK_DEKU - NUM_ITEM_SLOTS)) || + (cursorSlot == (SLOT_MASK_GORON - NUM_ITEM_SLOTS)))) { + play_sound(NA_SE_SY_ERROR); + return; + } + + if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + pauseCtx->equipTargetCBtn = PAUSE_EQUIP_C_LEFT; + } else if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN)) { + pauseCtx->equipTargetCBtn = PAUSE_EQUIP_C_DOWN; + } else if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + pauseCtx->equipTargetCBtn = PAUSE_EQUIP_C_RIGHT; + } + + // Equip item to the C buttons + pauseCtx->equipTargetItem = cursorItem; + pauseCtx->equipTargetSlot = cursorSlot + NUM_ITEM_SLOTS; + pauseCtx->unk_200 = 0xF; + vtxIndex = cursorSlot * 4; + pauseCtx->equipAnimX = pauseCtx->maskVtx[vtxIndex].v.ob[0] * 10; + pauseCtx->equipAnimY = pauseCtx->maskVtx[vtxIndex].v.ob[1] * 10; + pauseCtx->equipAnimAlpha = 255; + sMaskEquipMagicArrowSlotHoldTimer = 0; + sMaskEquipState = EQUIP_STATE_MOVE_TO_C_BTN; + sMaskEquipAnimTimer = 10; + play_sound(NA_SE_SY_DECIDE); + } else if ((pauseCtx->debugEditor == DEBUG_EDITOR_NONE) && (pauseCtx->state == 6) && + (pauseCtx->unk_200 == 0) && CHECK_BTN_ALL(input->press.button, BTN_A) && + (msgCtx->msgLength == 0)) { + // Give description on item through a message box + pauseCtx->itemDescriptionOn = true; + if (pauseCtx->cursorYIndex[PAUSE_MASK] < 2) { + func_801514B0(play, 0x1700 + pauseCtx->cursorItem[PAUSE_MASK], 3); + } else { + func_801514B0(play, 0x1700 + pauseCtx->cursorItem[PAUSE_MASK], 1); + } + } + } + } else { + pauseCtx->cursorItem[PAUSE_MASK] = PAUSE_ITEM_NONE; + } + + if (oldCursorPoint != pauseCtx->cursorPoint[PAUSE_MASK]) { + play_sound(NA_SE_SY_CURSOR); + } + } else if ((pauseCtx->unk_200 == 0xF) && (pauseCtx->pageIndex == PAUSE_MASK)) { + pauseCtx->cursorColorSet = 2; + } +} + +s16 sMaskCButtonPosX[] = { 660, 900, 1140 }; +s16 sMaskCButtonPosY[] = { 1100, 920, 1100 }; + +void KaleidoScope_UpdateMaskEquip(PlayState* play) { + static s16 sMaskEquipMagicArrowBowSlotHoldTimer = 0; + PauseContext* pauseCtx = &play->pauseCtx; + Vtx* bowItemVtx; + u16 offsetX; + u16 offsetY; + + // Grow glowing orb when equipping magic arrows + if (sMaskEquipState == EQUIP_STATE_MAGIC_ARROW_GROW_ORB) { + pauseCtx->equipAnimAlpha += 14; + if (pauseCtx->equipAnimAlpha > 255) { + pauseCtx->equipAnimAlpha = 254; + sMaskEquipState++; + } + // Hover over magic arrow slot when the next state is reached + sMaskEquipMagicArrowSlotHoldTimer = 5; + return; + } + + if (sMaskEquipState == EQUIP_STATE_MAGIC_ARROW_HOVER_OVER_BOW_SLOT) { + sMaskEquipMagicArrowBowSlotHoldTimer--; + + if (sMaskEquipMagicArrowBowSlotHoldTimer == 0) { + pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + sMaskEquipAnimTimer = 6; + pauseCtx->equipAnimScale = 320; + pauseCtx->equipAnimShrinkRate = 40; + sMaskEquipState++; + play_sound(NA_SE_SY_SYNTH_MAGIC_ARROW); + } + return; + } + + if (sMaskEquipState == EQUIP_STATE_MAGIC_ARROW_MOVE_TO_BOW_SLOT) { + bowItemVtx = &pauseCtx->itemVtx[12]; + offsetX = ABS_ALT(pauseCtx->equipAnimX - bowItemVtx->v.ob[0] * 10) / sMaskEquipAnimTimer; + offsetY = ABS_ALT(pauseCtx->equipAnimY - bowItemVtx->v.ob[1] * 10) / sMaskEquipAnimTimer; + } else { + offsetX = ABS_ALT(pauseCtx->equipAnimX - sMaskCButtonPosX[pauseCtx->equipTargetCBtn]) / sMaskEquipAnimTimer; + offsetY = ABS_ALT(pauseCtx->equipAnimY - sMaskCButtonPosY[pauseCtx->equipTargetCBtn]) / sMaskEquipAnimTimer; + } + + if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipAnimAlpha < 254)) { + pauseCtx->equipAnimAlpha += 14; + if (pauseCtx->equipAnimAlpha > 255) { + pauseCtx->equipAnimAlpha = 254; + } + sMaskEquipMagicArrowSlotHoldTimer = 5; + return; + } + + if (sMaskEquipMagicArrowSlotHoldTimer == 0) { + pauseCtx->equipAnimScale -= pauseCtx->equipAnimShrinkRate / sMaskEquipAnimTimer; + pauseCtx->equipAnimShrinkRate -= pauseCtx->equipAnimShrinkRate / sMaskEquipAnimTimer; + + // Update coordinates of item icon while being equipped + if (sMaskEquipState == EQUIP_STATE_MAGIC_ARROW_MOVE_TO_BOW_SLOT) { + // target is the bow slot + if (pauseCtx->equipAnimX >= (pauseCtx->itemVtx[12].v.ob[0] * 10)) { + pauseCtx->equipAnimX -= offsetX; + } else { + pauseCtx->equipAnimX += offsetX; + } + + if (pauseCtx->equipAnimY >= (pauseCtx->itemVtx[12].v.ob[1] * 10)) { + pauseCtx->equipAnimY -= offsetY; + } else { + pauseCtx->equipAnimY += offsetY; + } + } else { + // target is the c button + if (pauseCtx->equipAnimX >= sMaskCButtonPosX[pauseCtx->equipTargetCBtn]) { + pauseCtx->equipAnimX -= offsetX; + } else { + pauseCtx->equipAnimX += offsetX; + } + + if (pauseCtx->equipAnimY >= sMaskCButtonPosY[pauseCtx->equipTargetCBtn]) { + pauseCtx->equipAnimY -= offsetY; + } else { + pauseCtx->equipAnimY += offsetY; + } + } + + sMaskEquipAnimTimer--; + if (sMaskEquipAnimTimer == 0) { + if (sMaskEquipState == EQUIP_STATE_MAGIC_ARROW_MOVE_TO_BOW_SLOT) { + sMaskEquipState++; + sMaskEquipMagicArrowBowSlotHoldTimer = 4; + return; + } + + // Equip mask onto c buttons + if (pauseCtx->equipTargetCBtn == PAUSE_EQUIP_C_LEFT) { + // Swap if mask is already equipped on CDown or CRight. + if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) & 0xFF) != ITEM_NONE) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_DOWN); + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = ITEM_NONE; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = SLOT_NONE; + } + } else if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) & 0xFF) != ITEM_NONE) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_RIGHT); + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = ITEM_NONE; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT) = SLOT_NONE; + } + } + + // Equip mask on CLeft + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = pauseCtx->equipTargetItem; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT) = pauseCtx->equipTargetSlot; + Interface_LoadItemIconImpl(play, EQUIP_SLOT_C_LEFT); + } else if (pauseCtx->equipTargetCBtn == PAUSE_EQUIP_C_DOWN) { + // Swap if mask is already equipped on CLeft or CRight. + if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) & 0xFF) != ITEM_NONE) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_LEFT); + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = ITEM_NONE; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT) = SLOT_NONE; + } + } else if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) & 0xFF) != ITEM_NONE) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_RIGHT); + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = ITEM_NONE; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT) = SLOT_NONE; + } + } + + // Equip mask on CDown + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = pauseCtx->equipTargetItem; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = pauseCtx->equipTargetSlot; + Interface_LoadItemIconImpl(play, EQUIP_SLOT_C_DOWN); + } else { // (pauseCtx->equipTargetCBtn == PAUSE_EQUIP_C_RIGHT) + // Swap if mask is already equipped on CLeft or CDown. + if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) & 0xFF) != ITEM_NONE) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_LEFT); + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = ITEM_NONE; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT) = SLOT_NONE; + } + } else if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) & 0xFF) != ITEM_NONE) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_DOWN); + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = ITEM_NONE; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = SLOT_NONE; + } + } + + // Equip mask on CRight + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = pauseCtx->equipTargetItem; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT) = pauseCtx->equipTargetSlot; + Interface_LoadItemIconImpl(play, EQUIP_SLOT_C_RIGHT); + } + + // Reset params + pauseCtx->unk_200 = 0; + sMaskEquipAnimTimer = 10; + pauseCtx->equipAnimScale = 320; + pauseCtx->equipAnimShrinkRate = 40; + } + } else { + sMaskEquipMagicArrowSlotHoldTimer--; + if (sMaskEquipMagicArrowSlotHoldTimer == 0) { + pauseCtx->equipAnimAlpha = 255; + } + } +} diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h index 19e3c8719c..94724154f9 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h @@ -22,6 +22,13 @@ typedef enum { /* 2 */ PAUSE_EQUIP_C_RIGHT } PauseEquipCButton; +typedef enum { + /* 0 */ EQUIP_STATE_MAGIC_ARROW_GROW_ORB, + /* 1 */ EQUIP_STATE_MAGIC_ARROW_MOVE_TO_BOW_SLOT, + /* 2 */ EQUIP_STATE_MAGIC_ARROW_HOVER_OVER_BOW_SLOT, + /* 3 */ EQUIP_STATE_MOVE_TO_C_BTN +} EquipState; + typedef enum { /* 0 */ DEBUG_EDITOR_NONE, /* 1 */ DEBUG_EDITOR_INVENTORY_INIT, @@ -29,6 +36,16 @@ typedef enum { /* 3 */ DEBUG_EDITOR_EVENTS } DebugEditor; +// To be used for Item-Page cursor and Mask-Page cursor +typedef enum { + /* 0 */ PAUSE_CURSOR_RESULT_NONE, + /* 1 */ PAUSE_CURSOR_RESULT_SLOT, + /* 2 */ PAUSE_CURSOR_RESULT_SPECIAL_POS +} PauseMoveCursorResult; + +#define NUM_ITEM_SLOTS 24 +#define NUM_MASK_SLOTS 24 + #define PAUSE_PROMPT_YES 0 #define PAUSE_PROMPT_NO 4 @@ -43,6 +60,11 @@ void KaleidoScope_DrawItemSelect(PlayState* play); void KaleidoScope_UpdateItemCursor(PlayState* play); void KaleidoScope_UpdateItemEquip(PlayState* play); +// Mask +void KaleidoScope_DrawMaskSelect(PlayState* play); +void KaleidoScope_UpdateMaskCursor(PlayState* play); +void KaleidoScope_UpdateMaskEquip(PlayState* play); + // Debug void KaleidoScope_DrawInventoryEditor(PlayState* play); void KaleidoScope_UpdateInventoryEditor(PlayState* play); diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 4415b571dc..4bcf89f809 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -4214,9 +4214,9 @@ 0x8081E118:("func_8081E118",), 0x8081E7D8:("func_8081E7D8",), 0x8081FB1C:("func_8081FB1C",), - 0x8081FF80:("func_8081FF80",), - 0x808204AC:("func_808204AC",), - 0x80820FA4:("func_80820FA4",), + 0x8081FF80:("KaleidoScope_DrawMaskSelect",), + 0x808204AC:("KaleidoScope_UpdateMaskCursor",), + 0x80820FA4:("KaleidoScope_UpdateMaskEquip",), 0x80821730:("KaleidoScope_UpdatePrompt",), 0x80821900:("func_80821900",), 0x8082192C:("func_8082192C",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 3578b52a5b..ff7987c6f5 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -4725,15 +4725,15 @@ 0x8082B5CC:("D_8082B5CC","UNK_TYPE1","",0x1), 0x8082B5E0:("D_8082B5E0","UNK_TYPE1","",0x1), 0x8082B5F4:("D_8082B5F4","UNK_TYPE2","",0x2), - 0x8082B600:("D_8082B600","UNK_TYPE2","",0x2), - 0x8082B604:("D_8082B604","UNK_TYPE2","",0x2), - 0x8082B608:("D_8082B608","UNK_TYPE2","",0x2), - 0x8082B60C:("D_8082B60C","UNK_TYPE1","",0x1), - 0x8082B684:("D_8082B684","UNK_TYPE2","",0x2), - 0x8082B6CC:("D_8082B6CC","UNK_TYPE1","",0x1), - 0x8082B6D4:("D_8082B6D4","UNK_TYPE1","",0x1), - 0x8082B6DC:("D_8082B6DC","UNK_TYPE1","",0x1), - 0x8082B6E4:("D_8082B6E4","UNK_TYPE2","",0x2), + 0x8082B600:("sMaskEquipState","UNK_TYPE2","",0x2), + 0x8082B604:("sMaskEquipMagicArrowSlotHoldTimer","UNK_TYPE2","",0x2), + 0x8082B608:("sMaskEquipAnimTimer","UNK_TYPE2","",0x2), + 0x8082B60C:("gMaskPlayerFormSlotRestrictions","UNK_TYPE1","",0x1), + 0x8082B684:("sMasksGivenOnMoonBits","UNK_TYPE2","",0x2), + 0x8082B6CC:("sMaskPlayerFormItems","UNK_TYPE1","",0x1), + 0x8082B6D4:("sMaskCButtonPosX","UNK_TYPE1","",0x1), + 0x8082B6DC:("sMaskCButtonPosY","UNK_TYPE1","",0x1), + 0x8082B6E4:("sMaskEquipMagicArrowBowSlotHoldTimer","UNK_TYPE2","",0x2), 0x8082B6F0:("sPromptAlphaTargets","UNK_TYPE1","",0x1), 0x8082B6F4:("sPromptAlphaTargetIndex","UNK_TYPE2","",0x2), 0x8082B6F8:("sPromptAlphaTimer","UNK_TYPE2","",0x2), From ab5fd663ccddc0670773a047f4a30bf014a7dad4 Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Fri, 30 Sep 2022 22:01:39 -0400 Subject: [PATCH 07/25] Quake & Distortion Cleanup (#1102) * quake cleanup * cleanup * more cleanup * remove cast * q comes before r... * unname goron function, leave it to another PR * PR Suggestions --- include/functions.h | 37 +-- include/z64.h | 57 ---- include/z64bgcheck.h | 5 - include/z64quake.h | 69 ++++ src/code/z_actor.c | 23 +- src/code/z_bgcheck.c | 16 +- src/code/z_camera.c | 1 + src/code/z_demo.c | 7 +- src/code/z_play.c | 1 + src/code/z_quake.c | 298 +++++++++++------- .../ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c | 24 +- .../ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c | 10 +- .../z_bg_ikana_rotaryroom.c | 25 +- .../ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c | 12 +- .../ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c | 10 +- .../ovl_Bg_Open_Shutter/z_bg_open_shutter.c | 22 +- .../actors/ovl_Boss_Hakugin/z_boss_hakugin.c | 1 + .../actors/ovl_Door_Shutter/z_door_shutter.c | 14 +- src/overlays/actors/ovl_En_Ani/z_en_ani.c | 13 +- .../actors/ovl_En_Bigpamet/z_en_bigpamet.c | 15 +- .../actors/ovl_En_Bigslime/z_en_bigslime.c | 11 +- src/overlays/actors/ovl_En_Go/z_en_go.c | 13 +- .../actors/ovl_En_Goroiwa/z_en_goroiwa.c | 10 +- src/overlays/actors/ovl_En_Ishi/z_en_ishi.c | 10 +- .../actors/ovl_En_Pametfrog/z_en_pametfrog.c | 26 +- .../actors/ovl_En_Pametfrog/z_en_pametfrog.h | 2 +- .../ovl_En_Stop_heishi/z_en_stop_heishi.c | 1 + src/overlays/actors/ovl_En_Test6/z_en_test6.c | 13 +- .../actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c | 17 +- .../actors/ovl_Obj_Dhouse/z_obj_dhouse.c | 27 +- .../actors/ovl_Obj_Hariko/z_obj_hariko.c | 1 + .../ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c | 16 +- src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c | 12 +- .../ovl_Obj_Tokei_Step/z_obj_tokei_step.c | 10 +- .../actors/ovl_player_actor/z_player.c | 1 + .../ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c | 2 +- tools/disasm/functions.txt | 24 +- tools/disasm/variables.txt | 2 +- tools/namefixer.py | 5 +- tools/sizes/code_functions.csv | 22 +- 40 files changed, 496 insertions(+), 389 deletions(-) create mode 100644 include/z64quake.h diff --git a/include/functions.h b/include/functions.h index 67ad8ec3cd..b19b75af99 100644 --- a/include/functions.h +++ b/include/functions.h @@ -745,8 +745,8 @@ s16 Actor_TestFloorInDirection(Actor* actor, PlayState* play, f32 distance, s16 s32 Actor_IsTargeted(PlayState* play, Actor* actor); s32 Actor_OtherIsTargeted(PlayState* play, Actor* actor); void func_800BC620(Vec3f* arg0, Vec3f* arg1, u8 alpha, PlayState* play); -void func_800BC770(PlayState* play, s16 y, s16 countdown); -void func_800BC7D8(PlayState* play, s16 y, s16 countdown, s16 speed); +void Actor_AddQuake(PlayState* play, s16 verticalMag, s16 countdown); +void Actor_AddQuakeWithSpeed(PlayState* play, s16 verticalMag, s16 countdown, s16 speed); void func_800BC848(Actor* actor, PlayState* play, s16 y, s16 countdown); void Actor_DrawDoorLock(PlayState* play, s32 frame, s32 type); void Actor_SetColorFilter(Actor* actor, u16 colorFlag, u16 colorIntensityMax, u16 xluFlag, u16 duration); @@ -923,7 +923,7 @@ u32 SurfaceType_GetEcho(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) u32 SurfaceType_IsHookshotSurface(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); s32 SurfaceType_IsIgnoredByEntities(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); s32 SurfaceType_IsIgnoredByProjectiles(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -s32 SurfaceType_GetConveyorType(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +s32 SurfaceType_IsFloorConveyor(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); s32 func_800C9DDC(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); u32 SurfaceType_GetConveyorSpeed(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); u32 SurfaceType_GetConveyorDirection(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); @@ -1958,37 +1958,6 @@ s32 func_80128640(PlayState* play, Player* player, Gfx* dlist); void func_80128B74(PlayState* play, Player* player, s32 limbIndex); void func_80128BD0(PlayState* play, s32 limbIndex, Gfx** dList1, Gfx** dList2, Vec3s* rot, Actor* actor); -f32 Quake_Random(void); -void Quake_UpdateShakeInfo(QuakeRequest* req, ShakeInfo* shake, f32 verticalPertubation, f32 horizontalPertubation); -s16 Quake_Callback1(QuakeRequest* req, ShakeInfo* shake); -s16 Quake_Callback5(QuakeRequest* req, ShakeInfo* shake); -s16 Quake_Callback6(QuakeRequest* req, ShakeInfo* shake); -s16 Quake_Callback3(QuakeRequest* req, ShakeInfo* shake); -s16 Quake_Callback2(QuakeRequest* req, ShakeInfo* shake); -s16 Quake_Callback4(QuakeRequest* req, ShakeInfo* shake); -s16 Quake_GetFreeIndex(void); -QuakeRequest* Quake_AddImpl(Camera* camera, u32 callbackIdx); -void Quake_Remove(QuakeRequest* req); -QuakeRequest* Quake_GetRequest(s16 idx); -u32 Quake_SetValue(s16 idx, s16 valueType, s16 value); -u32 Quake_SetSpeed(s16 idx, s16 value); -u32 Quake_SetCountdown(s16 idx, s16 value); -s16 Quake_GetCountdown(s16 idx); -u32 Quake_SetQuakeValues(s16 idx, s16 verticalMag, s16 horizontalMag, s16 zoom, s16 rollOffset); -u32 Quake_SetQuakeValues2(s16 idx, s16 isShakePerpendicular, Vec3s shakePlaneOffset); -void Quake_Init(void); -s16 Quake_Add(Camera* camera, u32 callbackIdx); -u32 Quake_RemoveFromIdx(s16 idx); -s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData); -void Distortion_Init(PlayState* play); -void Distortion_SetCountdown(s16 countdown); -s16 Distortion_GetCountdown(void); -s16 Distortion_GetType(void); -void Distortion_SetType(s32 type); -void Distortion_ClearType(s32 type); -s32 Distortion_GetUnderwaterCurrentSpeed(Player* player); -void Distortion_Update(void); -s32 Quake_NumActiveQuakes(void); Gfx* Gfx_SetFog(Gfx* gfx, s32 r, s32 g, s32 b, s32 a, s32 n, s32 f); Gfx* Gfx_SetFogWithSync(Gfx* gfx, s32 r, s32 g, s32 b, s32 a, s32 n, s32 f); Gfx* Gfx_SetFog2(Gfx* gfx, s32 r, s32 g, s32 b, s32 a, s32 n, s32 f); diff --git a/include/z64.h b/include/z64.h index 96302ed0c8..ceb91bfb80 100644 --- a/include/z64.h +++ b/include/z64.h @@ -896,63 +896,6 @@ typedef s32 (*ColChkLineFunc)(PlayState*, CollisionCheckContext*, Collider*, Vec typedef void(*room_draw_func)(PlayState* play, Room* room, u32 flags); -typedef struct { - /* 0x00 */ Vec3f atOffset; - /* 0x0C */ Vec3f eyeOffset; - /* 0x18 */ s16 rollOffset; - /* 0x1A */ s16 zoom; -} ShakeInfo; // size = 0x1C - -typedef struct { - /* 0x00 */ s16 randIdx; - /* 0x02 */ s16 countdownMax; - /* 0x04 */ Camera* camera; - /* 0x08 */ u32 callbackIdx; - /* 0x0C */ s16 verticalMag; - /* 0x0E */ s16 horizontalMag; - /* 0x10 */ s16 zoom; - /* 0x12 */ s16 rollOffset; - /* 0x14 */ Vec3s shakePlaneOffset; // angle deviations from shaking in the perpendicular plane - /* 0x1A */ s16 speed; - /* 0x1C */ s16 isShakePerpendicular; - /* 0x1E */ s16 countdown; - /* 0x20 */ s16 camId; -} QuakeRequest; // size = 0x24 - -typedef struct { - /* 0x00 */ Vec3f atOffset; - /* 0x0C */ Vec3f eyeOffset; - /* 0x18 */ s16 rollOffset; - /* 0x1A */ s16 zoom; - /* 0x1C */ f32 max; // Set to scaled max data of struct (mag for Vec3f), never used -} QuakeCamCalc; // size = 0x20 - -typedef s16 (*QuakeCallbackFunc)(QuakeRequest*, ShakeInfo*); - -#define QUAKE_SPEED (1 << 0) -#define QUAKE_VERTICAL_MAG (1 << 1) -#define QUAKE_HORIZONTAL_MAG (1 << 2) -#define QUAKE_ZOOM (1 << 3) -#define QUAKE_ROLL_OFFSET (1 << 4) -#define QUAKE_SHAKE_PLANE_OFFSET_X (1 << 5) -#define QUAKE_SHAKE_PLANE_OFFSET_Y (1 << 6) -#define QUAKE_SHAKE_PLANE_OFFSET_Z (1 << 7) -#define QUAKE_COUNTDOWN (1 << 8) -#define QUAKE_IS_SHAKE_PERPENDICULAR (1 << 9) - -typedef struct { - /* 0x0 */ PlayState* play; - /* 0x4 */ s32 type; // bitfield, highest set bit determines type - /* 0x8 */ s16 countdown; - /* 0xA */ s16 state; -} DistortionContext; // size = 0xC - -typedef enum { - /* 0 */ DISTORTION_INACTIVE, - /* 1 */ DISTORTION_ACTIVE, - /* 2 */ DISTORTION_SETUP -} DistortionState; - typedef struct { /* 0x000 */ u8 controllers; // bit 0 is set if controller 1 is plugged in, etc. /* 0x001 */ UNK_TYPE1 pad1[0x13]; diff --git a/include/z64bgcheck.h b/include/z64bgcheck.h index b42938354c..c2a9bab7ce 100644 --- a/include/z64bgcheck.h +++ b/include/z64bgcheck.h @@ -56,11 +56,6 @@ struct DynaPolyActor; // CollisionContext flags #define BGCHECK_FLAG_REVERSE_CONVEYOR_FLOW 1 -typedef enum { - /* 0 */ CONVEYOR_WATER, - /* 1 */ CONVEYOR_FLOOR -} ConveyorType; - typedef struct { /* 0x0 */ Vec3s pos; } BgVertex; // size = 0x6 diff --git a/include/z64quake.h b/include/z64quake.h new file mode 100644 index 0000000000..468f56793d --- /dev/null +++ b/include/z64quake.h @@ -0,0 +1,69 @@ +#ifndef Z64QUAKE_H +#define Z64QUAKE_H + +#include "z64math.h" + +struct PlayState; +struct Camera; + +typedef struct { + /* 0x00 */ Vec3f atOffset; + /* 0x0C */ Vec3f eyeOffset; + /* 0x18 */ s16 rollOffset; + /* 0x1A */ s16 zoom; + /* 0x1C */ f32 max; // Set to scaled max data of struct (mag for Vec3f), never used +} QuakeCamCalc; // size = 0x20 + +#define QUAKE_SPEED (1 << 0) +#define QUAKE_VERTICAL_MAG (1 << 1) +#define QUAKE_HORIZONTAL_MAG (1 << 2) +#define QUAKE_ZOOM (1 << 3) +#define QUAKE_ROLL_OFFSET (1 << 4) +#define QUAKE_SHAKE_PLANE_OFFSET_X (1 << 5) +#define QUAKE_SHAKE_PLANE_OFFSET_Y (1 << 6) +#define QUAKE_SHAKE_PLANE_OFFSET_Z (1 << 7) +#define QUAKE_COUNTDOWN (1 << 8) +#define QUAKE_IS_SHAKE_PERPENDICULAR (1 << 9) + +typedef enum { + /* 1 */ QUAKE_TYPE_1 = 1, + /* 2 */ QUAKE_TYPE_2, + /* 3 */ QUAKE_TYPE_3, + /* 4 */ QUAKE_TYPE_4, + /* 5 */ QUAKE_TYPE_5, + /* 6 */ QUAKE_TYPE_6 +} QuakeType; + +u32 Quake_SetValue(s16 quakeIndex, s16 valueType, s16 value); +u32 Quake_SetSpeed(s16 quakeIndex, s16 speed); +u32 Quake_SetCountdown(s16 quakeIndex, s16 countdown); +s16 Quake_GetCountdown(s16 quakeIndex); +u32 Quake_SetQuakeValues(s16 quakeIndex, s16 verticalMag, s16 horizontalMag, s16 zoom, s16 rollOffset); +u32 Quake_SetQuakeValues2(s16 quakeIndex, s16 isShakePerpendicular, Vec3s shakePlaneOffset); +s16 Quake_Add(Camera* camera, u32 type); +s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData); +u32 Quake_Remove(s16 quakeIndex); +s32 Quake_NumActiveQuakes(void); +void Quake_Init(void); + +#define DISTORTION_TYPE_0 (1 << 0) +#define DISTORTION_TYPE_2 (1 << 2) +#define DISTORTION_TYPE_3 (1 << 3) +#define DISTORTION_TYPE_4 (1 << 4) +#define DISTORTION_TYPE_5 (1 << 5) +#define DISTORTION_TYPE_6 (1 << 6) +#define DISTORTION_TYPE_7 (1 << 7) +#define DISTORTION_TYPE_8 (1 << 8) +#define DISTORTION_TYPE_9 (1 << 9) +#define DISTORTION_TYPE_A (1 << 10) +#define DISTORTION_TYPE_B (1 << 11) + +void Distortion_SetCountdown(s16 countdown); +s16 Distortion_GetCountdown(void); +s16 Distortion_GetType(void); +void Distortion_SetType(s32 type); +void Distortion_ClearType(s32 type); +void Distortion_Init(PlayState* play); +void Distortion_Update(void); + +#endif diff --git a/src/code/z_actor.c b/src/code/z_actor.c index e82e5d2b9c..389f7a0516 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -5,6 +5,7 @@ #include "global.h" #include "z64load.h" +#include "z64quake.h" #include "z64rumble.h" #include "overlays/actors/ovl_En_Horse/z_en_horse.h" #include "overlays/actors/ovl_En_Part/z_en_part.h" @@ -3777,20 +3778,20 @@ void func_800BC620(Vec3f* arg0, Vec3f* arg1, u8 alpha, PlayState* play) { CLOSE_DISPS(play->state.gfxCtx); } -void func_800BC770(PlayState* play, s16 y, s16 countdown) { - s16 idx = Quake_Add(&play->mainCamera, 3); +void Actor_AddQuake(PlayState* play, s16 verticalMag, s16 countdown) { + s16 quakeIndex = Quake_Add(&play->mainCamera, QUAKE_TYPE_3); - Quake_SetSpeed(idx, 20000); - Quake_SetQuakeValues(idx, y, 0, 0, 0); - Quake_SetCountdown(idx, countdown); + Quake_SetSpeed(quakeIndex, 20000); + Quake_SetQuakeValues(quakeIndex, verticalMag, 0, 0, 0); + Quake_SetCountdown(quakeIndex, countdown); } -void func_800BC7D8(PlayState* play, s16 y, s16 countdown, s16 speed) { - s16 idx = Quake_Add(&play->mainCamera, 3); +void Actor_AddQuakeWithSpeed(PlayState* play, s16 verticalMag, s16 countdown, s16 speed) { + s16 quakeIndex = Quake_Add(&play->mainCamera, QUAKE_TYPE_3); - Quake_SetSpeed(idx, speed); - Quake_SetQuakeValues(idx, y, 0, 0, 0); - Quake_SetCountdown(idx, countdown); + Quake_SetSpeed(quakeIndex, speed); + Quake_SetQuakeValues(quakeIndex, verticalMag, 0, 0, 0); + Quake_SetCountdown(quakeIndex, countdown); } // Actor_RequestRumble? @@ -3800,7 +3801,7 @@ void func_800BC848(Actor* actor, PlayState* play, s16 y, s16 countdown) { } else { Rumble_Request(actor->xyzDistToPlayerSq, 180, 20, 100); } - func_800BC770(play, y, countdown); + Actor_AddQuake(play, y, countdown); } typedef struct { diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index 130fdc9706..7f4247b0d2 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -4331,18 +4331,22 @@ s32 SurfaceType_IsIgnoredByProjectiles(CollisionContext* colCtx, CollisionPoly* } /** - * SurfaceType Get Conveyor Surface Type - * Return type 0 (CONVEYOR_WATER) if 'poly' is a surface that will only move player underwater - * Return type 1 (CONVEYOR_FLOOR) if `poly` is a surface that must be stood on to move player + * Checks if poly is a floor conveyor + * + * A conveyor surface is enabled with non-zero speed. + * When enabled, the conveyor will exhibit two types of behaviour depending on the return value: + * + * If true, then it is a floor conveyor and will push player only while being stood on + * If false, then it is a water conveyor and will push player only while in water */ -s32 SurfaceType_GetConveyorType(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { +s32 SurfaceType_IsFloorConveyor(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { u32 flags; if (BgCheck_GetCollisionHeader(colCtx, bgId) == NULL) { - return CONVEYOR_FLOOR; + return true; } if (poly == NULL) { - return CONVEYOR_WATER; + return false; } flags = poly->flags_vIB & 0x2000; return !!flags; diff --git a/src/code/z_camera.c b/src/code/z_camera.c index 027b78a4a4..c26947b218 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -1,4 +1,5 @@ #include "global.h" +#include "z64quake.h" /** * Returns the absolute value for floats diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 69995db164..7dd357fbd4 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -1,4 +1,5 @@ #include "global.h" +#include "z64quake.h" #include "z64rumble.h" #include "overlays/gamestates/ovl_daytelop/z_daytelop.h" @@ -191,7 +192,7 @@ void Cutscene_Command_Misc(PlayState* play, CutsceneContext* csCtx, CsCmdBase* c case 0x8: func_8019F128(NA_SE_EV_EARTHQUAKE_LAST - SFX_FLAG); if (isStartFrame) { - sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(play), 6); + sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_6); Quake_SetSpeed(sCutsceneQuakeIndex, 22000); Quake_SetQuakeValues(sCutsceneQuakeIndex, 6, 4, 0, 0); Quake_SetCountdown(sCutsceneQuakeIndex, 800); @@ -281,7 +282,7 @@ void Cutscene_Command_Misc(PlayState* play, CutsceneContext* csCtx, CsCmdBase* c case 0x1A: func_8019F128(NA_SE_EV_EARTHQUAKE_LAST2 - SFX_FLAG); if (isStartFrame) { - sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(play), 6); + sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_6); Quake_SetSpeed(sCutsceneQuakeIndex, 30000); Quake_SetQuakeValues(sCutsceneQuakeIndex, 20, 10, 0, 0); Quake_SetCountdown(sCutsceneQuakeIndex, 800); @@ -333,7 +334,7 @@ void Cutscene_Command_Misc(PlayState* play, CutsceneContext* csCtx, CsCmdBase* c case 0x24: func_8019F128(NA_SE_EV_EARTHQUAKE_LAST - SFX_FLAG); if (isStartFrame) { - sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(play), 6); + sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_6); Quake_SetSpeed(sCutsceneQuakeIndex, 22000); Quake_SetQuakeValues(sCutsceneQuakeIndex, 2, 1, 0, 0); Quake_SetCountdown(sCutsceneQuakeIndex, 800); diff --git a/src/code/z_play.c b/src/code/z_play.c index bb04f23c00..06ec9c21e9 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -1,4 +1,5 @@ #include "global.h" +#include "z64quake.h" #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80165460.s") diff --git a/src/code/z_quake.c b/src/code/z_quake.c index 7caa0f4261..2b66a39f8a 100644 --- a/src/code/z_quake.c +++ b/src/code/z_quake.c @@ -1,7 +1,46 @@ #include "global.h" +#include "z64quake.h" + +typedef struct { + /* 0x00 */ s16 randIndex; + /* 0x02 */ s16 countdownMax; + /* 0x04 */ Camera* camera; + /* 0x08 */ u32 type; + /* 0x0C */ s16 verticalMag; + /* 0x0E */ s16 horizontalMag; + /* 0x10 */ s16 zoom; + /* 0x12 */ s16 rollOffset; + /* 0x14 */ Vec3s shakePlaneOffset; // angle deviations from shaking in the perpendicular plane + /* 0x1A */ s16 speed; + /* 0x1C */ s16 isShakePerpendicular; + /* 0x1E */ s16 countdown; + /* 0x20 */ s16 camId; +} QuakeRequest; // size = 0x24 + +typedef struct { + /* 0x0 */ PlayState* play; + /* 0x4 */ s32 type; // bitfield, highest set bit determines type + /* 0x8 */ s16 countdown; + /* 0xA */ s16 state; +} DistortionRequest; // size = 0xC + +typedef struct { + /* 0x00 */ Vec3f atOffset; + /* 0x0C */ Vec3f eyeOffset; + /* 0x18 */ s16 rollOffset; + /* 0x1A */ s16 zoom; +} ShakeInfo; // size = 0x1C + +typedef s16 (*QuakeCallbackFunc)(QuakeRequest*, ShakeInfo*); + +typedef enum { + /* 0 */ DISTORTION_INACTIVE, + /* 1 */ DISTORTION_ACTIVE, + /* 2 */ DISTORTION_SETUP +} DistortionState; QuakeRequest sQuakeRequest[4]; -DistortionContext sDistortionContext; +DistortionRequest sDistortionRequest; static s16 sIsQuakeInitialized = true; static s16 sQuakeRequestCount = 0; @@ -51,7 +90,7 @@ void Quake_UpdateShakeInfo(QuakeRequest* req, ShakeInfo* shake, f32 verticalPert shake->zoom = req->zoom * verticalPertubation; } -s16 Quake_Callback1(QuakeRequest* req, ShakeInfo* shake) { +s16 Quake_CallbackType1(QuakeRequest* req, ShakeInfo* shake) { if (req->countdown > 0) { f32 perpendicularPertubation = Math_SinS(req->speed * req->countdown); @@ -61,7 +100,7 @@ s16 Quake_Callback1(QuakeRequest* req, ShakeInfo* shake) { return req->countdown; } -s16 Quake_Callback5(QuakeRequest* req, ShakeInfo* shake) { +s16 Quake_CallbackType5(QuakeRequest* req, ShakeInfo* shake) { if (req->countdown > 0) { f32 perpendicularPertubation = Math_SinS(req->speed * req->countdown); @@ -71,7 +110,7 @@ s16 Quake_Callback5(QuakeRequest* req, ShakeInfo* shake) { return req->countdown; } -s16 Quake_Callback6(QuakeRequest* req, ShakeInfo* shake) { +s16 Quake_CallbackType6(QuakeRequest* req, ShakeInfo* shake) { f32 perpendicularPertubation; req->countdown--; @@ -80,7 +119,7 @@ s16 Quake_Callback6(QuakeRequest* req, ShakeInfo* shake) { return 1; } -s16 Quake_Callback3(QuakeRequest* req, ShakeInfo* shake) { +s16 Quake_CallbackType3(QuakeRequest* req, ShakeInfo* shake) { if (req->countdown > 0) { f32 perpendicularPertubation = Math_SinS(req->speed * req->countdown) * ((f32)req->countdown / (f32)req->countdownMax); @@ -91,7 +130,7 @@ s16 Quake_Callback3(QuakeRequest* req, ShakeInfo* shake) { return req->countdown; } -s16 Quake_Callback2(QuakeRequest* req, ShakeInfo* shake) { +s16 Quake_CallbackType2(QuakeRequest* req, ShakeInfo* shake) { if (req->countdown > 0) { f32 perpendicularPertubation = Quake_Random(); @@ -101,7 +140,7 @@ s16 Quake_Callback2(QuakeRequest* req, ShakeInfo* shake) { return req->countdown; } -s16 Quake_Callback4(QuakeRequest* req, ShakeInfo* shake) { +s16 Quake_CallbackType4(QuakeRequest* req, ShakeInfo* shake) { if (req->countdown > 0) { f32 perpendicularPertubation = Quake_Random() * ((f32)req->countdown / (f32)req->countdownMax); @@ -117,7 +156,7 @@ s16 Quake_GetFreeIndex(void) { s32 min = 0x10000; for (i = 0; i < ARRAY_COUNT(sQuakeRequest); i++) { - if (sQuakeRequest[i].callbackIdx == 0) { + if (sQuakeRequest[i].type == 0) { ret = i; break; } @@ -131,43 +170,43 @@ s16 Quake_GetFreeIndex(void) { return ret; } -QuakeRequest* Quake_AddImpl(Camera* camera, u32 callbackIdx) { - s16 idx = Quake_GetFreeIndex(); - QuakeRequest* req = &sQuakeRequest[idx]; +QuakeRequest* Quake_AddImpl(Camera* camera, u32 type) { + s16 index = Quake_GetFreeIndex(); + QuakeRequest* req = &sQuakeRequest[index]; __osMemset(req, 0, sizeof(QuakeRequest)); req->camera = camera; req->camId = camera->camId; - req->callbackIdx = callbackIdx; + req->type = type; req->isShakePerpendicular = true; - req->randIdx = ((s16)(Rand_ZeroOne() * (f32)0x10000) & ~3) + idx; + req->randIndex = ((s16)(Rand_ZeroOne() * 0x10000) & ~3) + index; sQuakeRequestCount++; return req; } -void Quake_Remove(QuakeRequest* req) { - req->callbackIdx = 0; +void Quake_RemoveRequest(QuakeRequest* req) { + req->type = 0; req->countdown = -1; sQuakeRequestCount--; } -QuakeRequest* Quake_GetRequest(s16 idx) { - QuakeRequest* req = &sQuakeRequest[idx & 3]; +QuakeRequest* Quake_GetRequest(s16 quakeIndex) { + QuakeRequest* req = &sQuakeRequest[quakeIndex & 3]; - if (req->callbackIdx == 0) { + if (req->type == 0) { return NULL; } - if (idx != req->randIdx) { + if (quakeIndex != req->randIndex) { return NULL; } return req; } -u32 Quake_SetValue(s16 idx, s16 valueType, s16 value) { - QuakeRequest* req = Quake_GetRequest(idx); +u32 Quake_SetValue(s16 quakeIndex, s16 valueType, s16 value) { + QuakeRequest* req = Quake_GetRequest(quakeIndex); if (req == NULL) { return false; @@ -176,62 +215,75 @@ u32 Quake_SetValue(s16 idx, s16 valueType, s16 value) { case QUAKE_SPEED: req->speed = value; break; + case QUAKE_VERTICAL_MAG: req->verticalMag = value; break; + case QUAKE_HORIZONTAL_MAG: req->horizontalMag = value; break; + case QUAKE_ZOOM: req->zoom = value; break; + case QUAKE_ROLL_OFFSET: req->rollOffset = value; break; + case QUAKE_SHAKE_PLANE_OFFSET_X: req->shakePlaneOffset.x = value; break; + case QUAKE_SHAKE_PLANE_OFFSET_Y: req->shakePlaneOffset.y = value; break; + case QUAKE_SHAKE_PLANE_OFFSET_Z: req->shakePlaneOffset.z = value; break; + case QUAKE_COUNTDOWN: req->countdown = value; req->countdownMax = req->countdown; break; + case QUAKE_IS_SHAKE_PERPENDICULAR: req->isShakePerpendicular = value; break; + + default: + break; } + return true; } } -u32 Quake_SetSpeed(s16 idx, s16 value) { - QuakeRequest* req = Quake_GetRequest(idx); +u32 Quake_SetSpeed(s16 quakeIndex, s16 speed) { + QuakeRequest* req = Quake_GetRequest(quakeIndex); if (req != NULL) { - req->speed = value; + req->speed = speed; return true; } return false; } -u32 Quake_SetCountdown(s16 idx, s16 value) { - QuakeRequest* req = Quake_GetRequest(idx); +u32 Quake_SetCountdown(s16 quakeIndex, s16 countdown) { + QuakeRequest* req = Quake_GetRequest(quakeIndex); if (req != NULL) { - req->countdown = value; + req->countdown = countdown; req->countdownMax = req->countdown; return true; } return false; } -s16 Quake_GetCountdown(s16 idx) { - QuakeRequest* req = Quake_GetRequest(idx); +s16 Quake_GetCountdown(s16 quakeIndex) { + QuakeRequest* req = Quake_GetRequest(quakeIndex); if (req != NULL) { return req->countdown; @@ -239,8 +291,8 @@ s16 Quake_GetCountdown(s16 idx) { return 0; } -u32 Quake_SetQuakeValues(s16 idx, s16 verticalMag, s16 horizontalMag, s16 zoom, s16 rollOffset) { - QuakeRequest* req = Quake_GetRequest(idx); +u32 Quake_SetQuakeValues(s16 quakeIndex, s16 verticalMag, s16 horizontalMag, s16 zoom, s16 rollOffset) { + QuakeRequest* req = Quake_GetRequest(quakeIndex); if (req != NULL) { req->verticalMag = verticalMag; @@ -252,8 +304,8 @@ u32 Quake_SetQuakeValues(s16 idx, s16 verticalMag, s16 horizontalMag, s16 zoom, return false; } -u32 Quake_SetQuakeValues2(s16 idx, s16 isShakePerpendicular, Vec3s shakePlaneOffset) { - QuakeRequest* req = Quake_GetRequest(idx); +u32 Quake_SetQuakeValues2(s16 quakeIndex, s16 isShakePerpendicular, Vec3s shakePlaneOffset) { + QuakeRequest* req = Quake_GetRequest(quakeIndex); if (req != NULL) { req->isShakePerpendicular = isShakePerpendicular; @@ -267,29 +319,35 @@ void Quake_Init(void) { s16 i; for (i = 0; i < ARRAY_COUNT(sQuakeRequest); i++) { - sQuakeRequest[i].callbackIdx = 0; + sQuakeRequest[i].type = 0; sQuakeRequest[i].countdown = 0; } sIsQuakeInitialized = true; sQuakeRequestCount = 0; } -s16 Quake_Add(Camera* camera, u32 callbackIdx) { - return Quake_AddImpl(camera, callbackIdx)->randIdx; +s16 Quake_Add(Camera* camera, u32 type) { + return Quake_AddImpl(camera, type)->randIndex; } -u32 Quake_RemoveFromIdx(s16 idx) { - QuakeRequest* req = Quake_GetRequest(idx); +u32 Quake_Remove(s16 index) { + QuakeRequest* req = Quake_GetRequest(index); if (req != NULL) { - Quake_Remove(req); + Quake_RemoveRequest(req); return true; } return false; } static QuakeCallbackFunc sQuakeCallbacks[] = { - NULL, Quake_Callback1, Quake_Callback2, Quake_Callback3, Quake_Callback4, Quake_Callback5, Quake_Callback6, + NULL, + Quake_CallbackType1, + Quake_CallbackType2, + Quake_CallbackType3, + Quake_CallbackType4, + Quake_CallbackType5, + Quake_CallbackType6, }; s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData) { @@ -299,7 +357,7 @@ s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData) { f32 absSpeedDiv; f32 maxCurr; f32 maxNext; - s32 idx; + s32 index; s32 ret; u32 eq; Vec3f originVec; @@ -323,16 +381,16 @@ s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData) { } ret = 0; - for (idx = 0; idx < ARRAY_COUNT(sQuakeRequest); idx++) { - req = &sQuakeRequest[idx]; - if (req->callbackIdx != 0) { + for (index = 0; index < ARRAY_COUNT(sQuakeRequest); index++) { + req = &sQuakeRequest[index]; + if (req->type != 0) { if (play->cameraPtrs[req->camId] == NULL) { - Quake_Remove(req); + Quake_RemoveRequest(req); } else { eq = (camera->camId != req->camera->camId); absSpeedDiv = ABS(req->speed) / (f32)0x8000; - if (sQuakeCallbacks[req->callbackIdx](req, &shake) == 0) { - Quake_Remove(req); + if (sQuakeCallbacks[req->type](req, &shake) == 0) { + Quake_RemoveRequest(req); } else if (eq == 0) { if (fabsf(camData->atOffset.x) < fabsf(shake.atOffset.x)) { camData->atOffset.x = shake.atOffset.x; @@ -383,35 +441,35 @@ s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData) { } void Distortion_Init(PlayState* play) { - sDistortionContext.play = play; + sDistortionRequest.play = play; View_ClearDistortion(&play->view); - sDistortionContext.type = 0; - sDistortionContext.countdown = 0; - sDistortionContext.state = DISTORTION_INACTIVE; + sDistortionRequest.type = 0; + sDistortionRequest.countdown = 0; + sDistortionRequest.state = DISTORTION_INACTIVE; } void Distortion_SetCountdown(s16 countdown) { - sDistortionContext.countdown = countdown; - sDistortionContext.state = DISTORTION_SETUP; + sDistortionRequest.countdown = countdown; + sDistortionRequest.state = DISTORTION_SETUP; } s16 Distortion_GetCountdown(void) { - return sDistortionContext.countdown; + return sDistortionRequest.countdown; } s16 Distortion_GetType(void) { - return sDistortionContext.type; + return sDistortionRequest.type; } void Distortion_SetType(s32 type) { - if (sDistortionContext.type < type) { - sDistortionContext.type = type; + if (sDistortionRequest.type < type) { + sDistortionRequest.type = type; } } void Distortion_ClearType(s32 type) { - if (sDistortionContext.type == type) { - sDistortionContext.type = 0; + if (sDistortionRequest.type == type) { + sDistortionRequest.type = 0; } } @@ -419,9 +477,9 @@ void Distortion_ClearType(s32 type) { * Checks that the bg surface is an underwater conveyor type and if so, returns the conveyor speed */ s32 Distortion_GetUnderwaterCurrentSpeed(Player* player) { - if (SurfaceType_GetConveyorType(&sDistortionContext.play->colCtx, player->actor.floorPoly, - player->actor.floorBgId) == CONVEYOR_WATER) { - return SurfaceType_GetConveyorSpeed(&sDistortionContext.play->colCtx, player->actor.floorPoly, + if (!SurfaceType_IsFloorConveyor(&sDistortionRequest.play->colCtx, player->actor.floorPoly, + player->actor.floorBgId)) { + return SurfaceType_GetConveyorSpeed(&sDistortionRequest.play->colCtx, player->actor.floorPoly, player->actor.floorBgId); } return 0; @@ -446,14 +504,14 @@ void Distortion_Update(void) { f32 zScale; f32 speed; Player* player; - PlayState* play = sDistortionContext.play; + PlayState* play = sDistortionRequest.play; PosRot playerPosRot; Camera* camera = GET_ACTIVE_CAM(play); f32 speedRatio = CLAMP_MAX(camera->speedRatio, 1.0f); - if (sDistortionContext.type != 0) { - if (sDistortionContext.type & 0x800) { - sDistortionContext.countdown = 2; + if (sDistortionRequest.type != 0) { + if (sDistortionRequest.type & DISTORTION_TYPE_B) { + sDistortionRequest.countdown = 2; depthPhase = 0x3F0; screenPlanePhase = 0x156; @@ -469,11 +527,11 @@ void Distortion_Update(void) { zScale = 0.0f; speed = 0.6f; - xyScaleFactor = zScaleFactor = sDistortionContext.countdown / 60.0f; + xyScaleFactor = zScaleFactor = sDistortionRequest.countdown / 60.0f; speedScaleFactor = 1.0f; - } else if (sDistortionContext.type & 0x400) { - if (sDistortionContext.state == DISTORTION_SETUP) { - countdownMax = sDistortionContext.countdown; + } else if (sDistortionRequest.type & DISTORTION_TYPE_A) { + if (sDistortionRequest.state == DISTORTION_SETUP) { + countdownMax = sDistortionRequest.countdown; depthPhase = 0x3F0; screenPlanePhase = 0x156; } @@ -490,11 +548,11 @@ void Distortion_Update(void) { zScale = 0.0f; speed = 0.4f; - xyScaleFactor = zScaleFactor = ((f32)countdownMax - sDistortionContext.countdown) / (f32)countdownMax; + xyScaleFactor = zScaleFactor = ((f32)countdownMax - sDistortionRequest.countdown) / (f32)countdownMax; speedScaleFactor = 0.5f; - } else if (sDistortionContext.type & 0x200) { - if (sDistortionContext.state == DISTORTION_SETUP) { - countdownMax = sDistortionContext.countdown; + } else if (sDistortionRequest.type & DISTORTION_TYPE_9) { + if (sDistortionRequest.state == DISTORTION_SETUP) { + countdownMax = sDistortionRequest.countdown; depthPhase = 0x1FC; screenPlanePhase = 0x156; } @@ -511,11 +569,11 @@ void Distortion_Update(void) { zScale = 0.0f; speed = 0.1f; - xyScaleFactor = zScaleFactor = ((f32)countdownMax - sDistortionContext.countdown) / (f32)countdownMax; + xyScaleFactor = zScaleFactor = ((f32)countdownMax - sDistortionRequest.countdown) / (f32)countdownMax; speedScaleFactor = 1.0f; - } else if (sDistortionContext.type & 0x100) { - if (sDistortionContext.state == DISTORTION_SETUP) { - countdownMax = sDistortionContext.countdown; + } else if (sDistortionRequest.type & DISTORTION_TYPE_8) { + if (sDistortionRequest.state == DISTORTION_SETUP) { + countdownMax = sDistortionRequest.countdown; depthPhase = 0x2710; screenPlanePhase = 0x3E8; } @@ -532,15 +590,15 @@ void Distortion_Update(void) { zScale = 0.01f; speed = 1.5f; - if (sDistortionContext.countdown < 5) { - xyScaleFactor = zScaleFactor = ((f32)countdownMax - sDistortionContext.countdown) / (f32)countdownMax; + if (sDistortionRequest.countdown < 5) { + xyScaleFactor = zScaleFactor = ((f32)countdownMax - sDistortionRequest.countdown) / (f32)countdownMax; } else { xyScaleFactor = zScaleFactor = 0.0f; } speedScaleFactor = 1.0f; - } else if (sDistortionContext.type & 0x80) { - if (sDistortionContext.state == DISTORTION_SETUP) { - countdownMax = sDistortionContext.countdown; + } else if (sDistortionRequest.type & DISTORTION_TYPE_7) { + if (sDistortionRequest.state == DISTORTION_SETUP) { + countdownMax = sDistortionRequest.countdown; depthPhase = 0x4B0; screenPlanePhase = 0x7D0; } @@ -557,11 +615,11 @@ void Distortion_Update(void) { zScale = 0.01f; speed = 1.5f; - xyScaleFactor = zScaleFactor = sDistortionContext.countdown / (f32)countdownMax; + xyScaleFactor = zScaleFactor = sDistortionRequest.countdown / (f32)countdownMax; speedScaleFactor = 1.0f; - } else if (sDistortionContext.type & 0x40) { - if (sDistortionContext.state == DISTORTION_SETUP) { - countdownMax = sDistortionContext.countdown; + } else if (sDistortionRequest.type & DISTORTION_TYPE_6) { + if (sDistortionRequest.state == DISTORTION_SETUP) { + countdownMax = sDistortionRequest.countdown; depthPhase = 0x9C4; screenPlanePhase = 0xBB8; } @@ -578,15 +636,15 @@ void Distortion_Update(void) { zScale = 0.01f; speed = 1.3f; - if (sDistortionContext.countdown < 4) { - xyScaleFactor = zScaleFactor = sDistortionContext.countdown / (f32)countdownMax; + if (sDistortionRequest.countdown < 4) { + xyScaleFactor = zScaleFactor = sDistortionRequest.countdown / (f32)countdownMax; } else { xyScaleFactor = zScaleFactor = 0.0f; } speedScaleFactor = 1.0f; - } else if (sDistortionContext.type & 0x20) { - sDistortionContext.countdown = 2; - if (sDistortionContext.state == DISTORTION_SETUP) { + } else if (sDistortionRequest.type & DISTORTION_TYPE_5) { + sDistortionRequest.countdown = 2; + if (sDistortionRequest.state == DISTORTION_SETUP) { depthPhase = 0x9C4; screenPlanePhase = 0xBB8; } @@ -609,9 +667,9 @@ void Distortion_Update(void) { zScaleFactor = 1.0f; xyScaleFactor = 1.0f; speedScaleFactor = 1.0f; - } else if (sDistortionContext.type & 0x10) { - if (sDistortionContext.state == DISTORTION_SETUP) { - countdownMax = sDistortionContext.countdown; + } else if (sDistortionRequest.type & DISTORTION_TYPE_4) { + if (sDistortionRequest.state == DISTORTION_SETUP) { + countdownMax = sDistortionRequest.countdown; depthPhase = 0x760; screenPlanePhase = 0x1BC; } @@ -628,14 +686,14 @@ void Distortion_Update(void) { zScale = 0.2f; speed = 0.25f; - countdownRatio = sDistortionContext.countdown / (f32)countdownMax; + countdownRatio = sDistortionRequest.countdown / (f32)countdownMax; zScaleFactor = xyScaleFactor = countdownRatio; speedScaleFactor = 1.0f; - } else if (sDistortionContext.type & 8) { + } else if (sDistortionRequest.type & DISTORTION_TYPE_3) { depthPhase = 0x3F0; screenPlanePhase = 0x156; - sDistortionContext.countdown = 2; + sDistortionRequest.countdown = 2; player = GET_PLAYER(play); if (player != NULL) { @@ -656,18 +714,21 @@ void Distortion_Update(void) { zScale = 0.03f; speed = 0.33f; break; + case 2: xScale = -0.06f; yScale = 0.1f; zScale = 0.03f; speed = 0.33f; break; + case 1: xScale = -0.06f; yScale = 0.1f; zScale = 0.03f; speed = 0.33f; break; + default: xScale = -0.06f; yScale = 0.1f; @@ -683,11 +744,11 @@ void Distortion_Update(void) { } zScaleFactor = -xyScaleFactor; speedScaleFactor = 1.0f; - } else if (sDistortionContext.type & 4) { + } else if (sDistortionRequest.type & DISTORTION_TYPE_2) { depthPhase = 0x3F0; screenPlanePhase = 0x156; - sDistortionContext.countdown = 2; + sDistortionRequest.countdown = 2; player = GET_PLAYER(play); depthPhaseStep = 359.2f; @@ -703,18 +764,21 @@ void Distortion_Update(void) { zScale = 0.08f; speed = 0.18f; break; + case 2: xScale = 0.12f; yScale = 0.12f; zScale = 0.08f; speed = 0.12f; break; + case 1: xScale = 0.12f; yScale = 0.12f; zScale = 0.08f; speed = 0.08f; break; + default: xScale = 0.12f; yScale = 0.12f; @@ -731,12 +795,12 @@ void Distortion_Update(void) { xyScaleFactor = speedScaleFactor = (waterYScaleFactor * 0.15f) + 0.35f + (speedRatio * 0.4f); zScaleFactor = 0.9f - xyScaleFactor; - } else if (sDistortionContext.type & 1) { + } else if (sDistortionRequest.type & DISTORTION_TYPE_0) { // Gives a small mirage-like appearance depthPhase = 0x3F0; screenPlanePhase = 0x156; - sDistortionContext.countdown = 2; + sDistortionRequest.countdown = 2; depthPhaseStep = 0.0f; screenPlanePhaseStep = 150.0f; @@ -759,29 +823,29 @@ void Distortion_Update(void) { depthPhase += CAM_DEG_TO_BINANG(depthPhaseStep); screenPlanePhase += CAM_DEG_TO_BINANG(screenPlanePhaseStep); - View_SetDistortionDirRot(&sDistortionContext.play->view, + View_SetDistortionDirRot(&sDistortionRequest.play->view, Math_CosS(depthPhase) * (DEGF_TO_RADF(rotX) * xyScaleFactor), Math_SinS(depthPhase) * (DEGF_TO_RADF(rotY) * xyScaleFactor), Math_SinS(screenPlanePhase) * (DEGF_TO_RADF(rotZ) * zScaleFactor)); - View_SetDistortionScale(&sDistortionContext.play->view, + View_SetDistortionScale(&sDistortionRequest.play->view, (Math_SinS(screenPlanePhase) * (xScale * xyScaleFactor)) + 1.0f, (Math_CosS(screenPlanePhase) * (yScale * xyScaleFactor)) + 1.0f, (Math_CosS(depthPhase) * (zScale * zScaleFactor)) + 1.0f); - View_SetDistortionSpeed(&sDistortionContext.play->view, speed * speedScaleFactor); + View_SetDistortionSpeed(&sDistortionRequest.play->view, speed * speedScaleFactor); - sDistortionContext.state = DISTORTION_ACTIVE; + sDistortionRequest.state = DISTORTION_ACTIVE; - } else if (sDistortionContext.state != DISTORTION_INACTIVE) { + } else if (sDistortionRequest.state != DISTORTION_INACTIVE) { View_ClearDistortion(&play->view); - sDistortionContext.state = DISTORTION_INACTIVE; - sDistortionContext.countdown = 0; + sDistortionRequest.state = DISTORTION_INACTIVE; + sDistortionRequest.countdown = 0; } - if (sDistortionContext.countdown != 0) { - sDistortionContext.countdown--; - if (sDistortionContext.countdown == 0) { - sDistortionContext.type = 0; + if (sDistortionRequest.countdown != 0) { + sDistortionRequest.countdown--; + if (sDistortionRequest.countdown == 0) { + sDistortionRequest.type = 0; } } } @@ -790,16 +854,16 @@ s32 Quake_NumActiveQuakes(void) { QuakeRequest* req = sQuakeRequest; s32 numActiveQuakes = 0; - if (req[0].callbackIdx != 0) { + if (req[0].type != 0) { numActiveQuakes++; } - if (req[1].callbackIdx != 0) { + if (req[1].type != 0) { numActiveQuakes++; } - if (req[2].callbackIdx != 0) { + if (req[2].type != 0) { numActiveQuakes++; } - if (req[3].callbackIdx != 0) { + if (req[3].type != 0) { numActiveQuakes++; } diff --git a/src/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 0c273c739a..ec2fd9e9cd 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c @@ -6,6 +6,7 @@ #include "prevent_bss_reordering.h" #include "z_bg_hakugin_post.h" +#include "z64quake.h" #include "z64rumble.h" #include "objects/object_hakugin_obj/object_hakugin_obj.h" @@ -509,7 +510,7 @@ void func_80A9C058(BgHakuginPost* this, PlayState* play, BgHakuginPostUnkStruct* s32 pad; Vec3f sp44; s32 pad2[2]; - s16 quake; + s16 quakeIndex; if (this->unk_170 == 0) { for (i = 0; i < unkStruct->count; i++) { @@ -520,10 +521,12 @@ void func_80A9C058(BgHakuginPost* this, PlayState* play, BgHakuginPostUnkStruct* sp44.y = this->unk_16C + unkStruct1->unk_14.y; sp44.z = this->dyna.actor.home.pos.z + unkStruct1->unk_14.z; Rumble_Request(Math3D_Vec3fDistSq(&sp44, &GET_PLAYER(play)->actor.world.pos), 255, 20, 150); - quake = Quake_Add(GET_ACTIVE_CAM(play), 3); - Quake_SetSpeed(quake, 20000); - Quake_SetQuakeValues(quake, 7, 0, 0, 0); - Quake_SetCountdown(quake, 12); + + quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + Quake_SetSpeed(quakeIndex, 20000); + Quake_SetQuakeValues(quakeIndex, 7, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 12); + if (this->unk_179 <= 0) { func_8019F128(NA_SE_EV_STONEDOOR_STOP); this->unk_179 = 40; @@ -538,15 +541,16 @@ void func_80A9C18C(BgHakuginPost* this, PlayState* play) { s32 pad; Player* player = GET_PLAYER(play); Camera* activeCam = GET_ACTIVE_CAM(play); - s16 quake; + s16 quakeIndex; Rumble_Request(Math3D_XZDistanceSquared(player->actor.world.pos.x, player->actor.world.pos.z, this->dyna.actor.home.pos.x, this->dyna.actor.home.pos.z), 255, 20, 150); - quake = Quake_Add(activeCam, 3); - Quake_SetSpeed(quake, 17232); - Quake_SetQuakeValues(quake, 6, 0, 0, 0); - Quake_SetCountdown(quake, 20); + + quakeIndex = Quake_Add(activeCam, QUAKE_TYPE_3); + Quake_SetSpeed(quakeIndex, 17232); + Quake_SetQuakeValues(quakeIndex, 6, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 20); } void func_80A9C228(BgHakuginPost* this, PlayState* play, BgHakuginPostUnkStruct* unkStruct) { 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 e619aa7e0c..4f1434dc22 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c @@ -5,6 +5,7 @@ */ #include "z_bg_ikana_dharma.h" +#include "z64quake.h" #include "assets/objects/object_ikana_obj/object_ikana_obj.h" #define FLAGS (ACTOR_FLAG_10) @@ -226,11 +227,12 @@ void BgIkanaDharma_Update(Actor* thisx, PlayState* play) { Actor_MoveWithGravity(&this->dyna.actor); Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 4); if (this->dyna.actor.bgCheckFlags & 2) { - s16 quake = Quake_Add(GET_ACTIVE_CAM(play), 3); + s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + + Quake_SetSpeed(quakeIndex, 21536); + Quake_SetQuakeValues(quakeIndex, 4, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 12); - Quake_SetSpeed(quake, 21536); - Quake_SetQuakeValues(quake, 4, 0, 0, 0); - Quake_SetCountdown(quake, 12); Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); } } else { diff --git a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c index 77bf925314..fb29ca2bba 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c @@ -5,6 +5,7 @@ */ #include "z_bg_ikana_rotaryroom.h" +#include "z64quake.h" #include "overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.h" #include "overlays/actors/ovl_En_Torch2/z_en_torch2.h" #include "overlays/actors/ovl_En_Water_Effect/z_en_water_effect.h" @@ -831,11 +832,11 @@ void func_80B81A80(Actor* thisx, PlayState* play) { func_80B81B84(this); } else if (this->unk_584 == 15) { - s16 sp26 = Quake_Add(GET_ACTIVE_CAM(play), 3); + s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); - Quake_SetSpeed(sp26, 0x7B30); - Quake_SetQuakeValues(sp26, 6, 0, 100, 0); - Quake_SetCountdown(sp26, 22); + Quake_SetSpeed(quakeIndex, 31536); + Quake_SetQuakeValues(quakeIndex, 6, 0, 100, 0); + Quake_SetCountdown(quakeIndex, 22); } } @@ -858,11 +859,11 @@ void func_80B81BA0(Actor* thisx, PlayState* play) { thisx->shape.rot.x += 0x1F4; if (!(this->unk_584 & 7)) { - s16 quake = Quake_Add(GET_ACTIVE_CAM(play), 3); + s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); - Quake_SetSpeed(quake, 0x7B30); - Quake_SetQuakeValues(quake, (s32)(Rand_ZeroOne() * 2.5f) + 3, 0, 10, 0); - Quake_SetCountdown(quake, 15); + Quake_SetSpeed(quakeIndex, 31536); + Quake_SetQuakeValues(quakeIndex, (s32)(Rand_ZeroOne() * 2.5f) + 3, 0, 10, 0); + Quake_SetCountdown(quakeIndex, 15); } if (Flags_GetSwitch(play, BGIKANAROTARYROOM_GET_FE(&this->dyna.actor))) { @@ -928,11 +929,11 @@ void func_80B81DC8(Actor* thisx, PlayState* play) { ActorCutscene_Stop(this->dyna.actor.cutscene); func_80B818B4(this); } else if (this->unk_584 == 19) { - s16 quake = Quake_Add(GET_ACTIVE_CAM(play), 3); + s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); - Quake_SetSpeed(quake, 0x4E20); - Quake_SetQuakeValues(quake, 5, 0, 40, 60); - Quake_SetCountdown(quake, 17); + Quake_SetSpeed(quakeIndex, 20000); + Quake_SetQuakeValues(quakeIndex, 5, 0, 40, 60); + Quake_SetCountdown(quakeIndex, 17); } } 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 ec17965c67..b3da7b2bf8 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c @@ -5,6 +5,7 @@ */ #include "z_bg_ikana_shutter.h" +#include "z64quake.h" #include "objects/object_ikana_obj/object_ikana_obj.h" #define FLAGS (ACTOR_FLAG_10) @@ -144,16 +145,17 @@ void func_80BD59F8(BgIkanaShutter* this) { void func_80BD5A18(BgIkanaShutter* this, PlayState* play) { s32 pad[2]; - s16 quake; + s16 quakeIndex; this->dyna.actor.velocity.y += -5.0f; this->dyna.actor.velocity.y *= 0.978f; this->dyna.actor.world.pos.y += this->dyna.actor.velocity.y; if (this->dyna.actor.world.pos.y <= this->dyna.actor.home.pos.y) { - quake = Quake_Add(GET_ACTIVE_CAM(play), 3); - Quake_SetSpeed(quake, 0x5420); - Quake_SetQuakeValues(quake, 4, 0, 0, 0); - Quake_SetCountdown(quake, 12); + quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + Quake_SetSpeed(quakeIndex, 21536); + Quake_SetQuakeValues(quakeIndex, 4, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 12); + func_80BD5828(this); } } 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 0bc385cb7b..017f9ef04b 100644 --- a/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c +++ b/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c @@ -5,6 +5,7 @@ */ #include "z_bg_iknin_susceil.h" +#include "z64quake.h" #include "z64rumble.h" #include "objects/object_ikninside_obj/object_ikninside_obj.h" @@ -70,11 +71,12 @@ void func_80C0A838(BgIkninSusceil* this, PlayState* play) { void func_80C0A86C(BgIkninSusceil* this, PlayState* play, s16 verticalMag, s16 countdown, s32 arg4) { s32 pad; - s16 quake = Quake_Add(GET_ACTIVE_CAM(play), 3); + s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + + Quake_SetSpeed(quakeIndex, 31536); + Quake_SetQuakeValues(quakeIndex, verticalMag, 0, 0, 0); + Quake_SetCountdown(quakeIndex, countdown); - Quake_SetSpeed(quake, 0x7B30); - Quake_SetQuakeValues(quake, verticalMag, 0, 0, 0); - Quake_SetCountdown(quake, countdown); if (arg4 == 1) { Rumble_Request(SQ(100.0f), 255, 20, 150); } else if (arg4 == 2) { 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 b54e7a5832..22cf4968f1 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 @@ -6,6 +6,7 @@ #include "z_bg_open_shutter.h" #include "objects/object_open_obj/object_open_obj.h" +#include "z64quake.h" #include "z64rumble.h" #define FLAGS (ACTOR_FLAG_10) @@ -105,7 +106,7 @@ void BgOpenShutter_Destroy(Actor* thisx, PlayState* play) { } void func_80ACAD88(BgOpenShutter* this, PlayState* play) { - s32 quake; + s32 doorDirection; if (this->unk_15C != 0) { Player* player = GET_PLAYER(play); @@ -118,10 +119,10 @@ void func_80ACAD88(BgOpenShutter* this, PlayState* play) { } else { Player* player = GET_PLAYER(play); - quake = func_80ACABA8(this, play); - if (quake > 0) { + doorDirection = func_80ACABA8(this, play); + if (doorDirection > 0) { player->doorType = 2; - player->doorDirection = quake; + player->doorDirection = doorDirection; player->doorActor = &this->dyna.actor; func_80122F28(player); } @@ -142,18 +143,21 @@ void func_80ACAE5C(BgOpenShutter* this, PlayState* play) { void func_80ACAEF0(BgOpenShutter* this, PlayState* play) { s32 pad; - s16 quake; + s16 quakeIndex; Math_StepToF(&this->dyna.actor.velocity.y, 20.0f, 8.0f); if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, this->dyna.actor.velocity.y)) { this->dyna.actor.floorHeight = this->dyna.actor.home.pos.y; Actor_SpawnFloorDustRing(play, &this->dyna.actor, &this->dyna.actor.world.pos, 60.0f, 10, 8.0f, 500, 10, true); Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BIGWALL_BOUND); - quake = Quake_Add(Play_GetCamera(play, CAM_ID_MAIN), 3); - Quake_SetSpeed(quake, -0x7F18); - Quake_SetQuakeValues(quake, 2, 0, 0, 0); - Quake_SetCountdown(quake, 10); + + quakeIndex = Quake_Add(Play_GetCamera(play, CAM_ID_MAIN), QUAKE_TYPE_3); + Quake_SetSpeed(quakeIndex, -32536); + Quake_SetQuakeValues(quakeIndex, 2, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 10); + Rumble_Request(this->dyna.actor.xyzDistToPlayerSq, 180, 20, 100); + this->unk_15C = 0; this->actionFunc = func_80ACAD88; } diff --git a/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.c b/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.c index 75f530c483..efb46a8928 100644 --- a/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.c +++ b/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.c @@ -5,6 +5,7 @@ */ #include "z_boss_hakugin.h" +#include "z64quake.h" #include "z64rumble.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) diff --git a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c index 65df579cea..b2ffe1dcb3 100644 --- a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c +++ b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c @@ -5,6 +5,7 @@ */ #include "z_door_shutter.h" +#include "z64quake.h" #include "z64rumble.h" #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_bdoor/object_bdoor.h" @@ -599,7 +600,7 @@ s32 func_808A1A70(DoorShutter* this) { } void func_808A1B48(DoorShutter* this, PlayState* play) { - s16 quake; + s16 quakeIndex; if (func_808A1A70(this)) { if (this->actor.velocity.y > 20.0f) { @@ -607,11 +608,14 @@ void func_808A1B48(DoorShutter* this, PlayState* play) { Actor_SpawnFloorDustRing(play, &this->actor, &this->actor.world.pos, 45.0f, 10, 8.0f, 500, 10, 0); } Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BIGWALL_BOUND); - quake = Quake_Add(Play_GetCamera(play, CAM_ID_MAIN), 3); - Quake_SetSpeed(quake, -32536); - Quake_SetQuakeValues(quake, 2, 0, 0, 0); - Quake_SetCountdown(quake, 10); + + quakeIndex = Quake_Add(Play_GetCamera(play, CAM_ID_MAIN), QUAKE_TYPE_3); + Quake_SetSpeed(quakeIndex, -32536); + Quake_SetQuakeValues(quakeIndex, 2, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 10); + Rumble_Request(this->actor.xyzDistToPlayerSq, 180, 20, 100); + func_808A1884(this, play); } } 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 88ddcd0f80..ec464815ee 100644 --- a/src/overlays/actors/ovl_En_Ani/z_en_ani.c +++ b/src/overlays/actors/ovl_En_Ani/z_en_ani.c @@ -6,6 +6,7 @@ */ #include "z_en_ani.h" +#include "z64quake.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) @@ -209,7 +210,7 @@ void EnAni_LandOnFoot(EnAni* this, PlayState* play) { void EnAni_FallToGround(EnAni* this, PlayState* play) { s32 pad; - s16 quakeValue; + s16 quakeIndex; if (this->actor.bgCheckFlags & 1) { // hit the ground this->actor.flags &= ~ACTOR_FLAG_10; @@ -219,10 +220,12 @@ void EnAni_FallToGround(EnAni* this, PlayState* play) { // the animation gets cut short, (first 16 frames only) only the landing part is seen Animation_Change(&this->skelAnime, &gAniLandingThenStandingUpAnim, 1.0f, 0.0f, 16.0f, ANIMMODE_ONCE, 0.0f); this->stateFlags |= ANI_STATE_WRITHING; - quakeValue = Quake_Add(play->cameraPtrs[CAM_ID_MAIN], 3); - Quake_SetSpeed(quakeValue, 0x6978); - Quake_SetQuakeValues(quakeValue, 7, 0, 0, 0); - Quake_SetCountdown(quakeValue, 0x14); + + quakeIndex = Quake_Add(play->cameraPtrs[CAM_ID_MAIN], QUAKE_TYPE_3); + Quake_SetSpeed(quakeIndex, 27000); + Quake_SetQuakeValues(quakeIndex, 7, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 20); + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_HAMMER_HIT); } 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 d24b2df497..bf6e46e36a 100644 --- a/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.c +++ b/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.c @@ -5,6 +5,7 @@ */ #include "z_en_bigpamet.h" +#include "z64quake.h" #include "z64rumble.h" #include "overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h" #include "objects/gameplay_keep/gameplay_keep.h" @@ -518,7 +519,7 @@ void func_80A28760(EnBigpamet* this) { } void func_80A287E8(EnBigpamet* this, PlayState* play) { - s16 quake; + s16 quakeIndex; this->actor.shape.rot.y += 0x3B00; func_800B9010(&this->actor, NA_SE_EN_B_PAMET_ROLL - SFX_FLAG); @@ -538,12 +539,16 @@ void func_80A287E8(EnBigpamet* this, PlayState* play) { } if (this->actor.bgCheckFlags & 8) { - quake = Quake_Add(GET_ACTIVE_CAM(play), 3); + quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + this->actor.velocity.y = this->unk_29E * 0.375f; - Quake_SetSpeed(quake, 0x4E20); - Quake_SetQuakeValues(quake, 15, 0, 0, 0); - Quake_SetCountdown(quake, 10); + + Quake_SetSpeed(quakeIndex, 20000); + Quake_SetQuakeValues(quakeIndex, 15, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 10); + Rumble_Request(this->actor.xyzDistToPlayerSq, 180, 20, 100); + func_80A27B58(this); func_80A27DD8(this, play); func_80A28970(this); 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 98212382bf..e569970519 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c @@ -5,6 +5,7 @@ */ #include "z_en_bigslime.h" +#include "z64quake.h" #include "z64rumble.h" #include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #include "objects/object_bigslime/object_bigslime.h" @@ -743,12 +744,14 @@ void EnBigslime_EndThrowMinislime(EnBigslime* this) { void EnBigslime_BreakIntoMinislime(EnBigslime* this, PlayState* play) { s32 i; - s16 quake = Quake_Add(GET_ACTIVE_CAM(play), 3); + s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + + Quake_SetSpeed(quakeIndex, 20000); + Quake_SetQuakeValues(quakeIndex, 15, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 15); - Quake_SetSpeed(quake, 20000); - Quake_SetQuakeValues(quake, 15, 0, 0, 0); - Quake_SetCountdown(quake, 15); Rumble_Request(this->actor.xyzDistToPlayerSq, 180, 20, 100); + this->bigslimeCollider[0].base.atFlags &= ~AT_ON; this->gekkoCollider.base.acFlags &= ~(AC_ON | AC_HIT); diff --git a/src/overlays/actors/ovl_En_Go/z_en_go.c b/src/overlays/actors/ovl_En_Go/z_en_go.c index 5fc1d4c70c..2b855edab2 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -5,6 +5,7 @@ */ #include "z_en_go.h" +#include "z64quake.h" #include "objects/object_oF1d_map/object_oF1d_map.h" #include "objects/object_hakugin_demo/object_hakugin_demo.h" #include "objects/object_taisou/object_taisou.h" @@ -1045,16 +1046,16 @@ s32 func_80A13564(EnGo* this, f32 arg1, f32 arg2, s32 arg3) { return ret; } -void func_80A136B8(PlayState* play, s16 arg1, s16 arg2, s16 arg3) { - s16 sp26 = Quake_Add(Play_GetCamera(play, CAM_ID_MAIN), 3); +void func_80A136B8(PlayState* play, s16 speed, s16 verticalMag, s16 countdown) { + s16 quakeIndex = Quake_Add(Play_GetCamera(play, CAM_ID_MAIN), QUAKE_TYPE_3); - Quake_SetCountdown(sp26, arg3); - Quake_SetSpeed(sp26, arg1); - Quake_SetQuakeValues(sp26, arg2, 0, 0, 0); + Quake_SetCountdown(quakeIndex, countdown); + Quake_SetSpeed(quakeIndex, speed); + Quake_SetQuakeValues(quakeIndex, verticalMag, 0, 0, 0); } void func_80A13728(EnGo* this, PlayState* play) { - func_80A136B8(play, 0x6C77, 7, 20); + func_80A136B8(play, 27767, 7, 20); play->actorCtx.unk2 = 4; Actor_Spawn(&play->actorCtx, play, ACTOR_EN_TEST, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); 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 df491dd224..1f173114de 100644 --- a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c +++ b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c @@ -5,6 +5,7 @@ */ #include "z_en_goroiwa.h" +#include "z64quake.h" #include "objects/object_goroiwa/object_goroiwa.h" #include "objects/gameplay_keep/gameplay_keep.h" @@ -450,10 +451,11 @@ s32 func_8093F6F8(EnGoroiwa* this, PlayState* play) { if ((this->actor.velocity.y < 0.0f) && (this->actor.world.pos.y <= sp7C)) { if (this->unk_1CA == 0) { if (this->actor.xzDistToPlayer < 400.0f) { - s16 sp72 = Quake_Add(GET_ACTIVE_CAM(play), 3); - Quake_SetSpeed(sp72, 0x4350); - Quake_SetQuakeValues(sp72, 3, 0, 0, 0); - Quake_SetCountdown(sp72, 7); + s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + + Quake_SetSpeed(quakeIndex, 17232); + Quake_SetQuakeValues(quakeIndex, 3, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 7); } this->unk_1C4 = 0.0f; 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 26c5bbbbc5..57c18ad7b3 100644 --- a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c +++ b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c @@ -5,6 +5,7 @@ */ #include "z_en_ishi.h" +#include "z64quake.h" #include "z64rumble.h" #include "objects/gameplay_field_keep/gameplay_field_keep.h" #include "objects/gameplay_keep/gameplay_keep.h" @@ -594,11 +595,12 @@ void func_8095EBDC(EnIshi* this, PlayState* play) { } if (sp70 == 1) { - s16 quake = Quake_Add(GET_ACTIVE_CAM(play), 3); + s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + + Quake_SetSpeed(quakeIndex, 17232); + Quake_SetQuakeValues(quakeIndex, 3, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 7); - Quake_SetSpeed(quake, 0x4350); - Quake_SetQuakeValues(quake, 3, 0, 0, 0); - Quake_SetCountdown(quake, 7); Rumble_Request(this->actor.xyzDistToPlayerSq, 255, 20, 150); } 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 4be8ad3c15..0582b7ca83 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c @@ -5,6 +5,7 @@ */ #include "z_en_pametfrog.h" +#include "z64quake.h" #include "z64rumble.h" #include "overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.h" #include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" @@ -1222,11 +1223,14 @@ void EnPametfrog_SetupSnapperSpawn(EnPametfrog* this, PlayState* play) { // Zooms in on Snapper spawn point Play_SetCameraAtEye(play, this->subCamId, &subCamAt, &subCamEye); - this->quake = Quake_Add(GET_ACTIVE_CAM(play), 6); - Quake_SetSpeed(this->quake, 18000); - Quake_SetQuakeValues(this->quake, 2, 0, 0, 0); - Quake_SetCountdown(this->quake, 15); + + this->quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_6); + Quake_SetSpeed(this->quakeIndex, 18000); + Quake_SetQuakeValues(this->quakeIndex, 2, 0, 0, 0); + Quake_SetCountdown(this->quakeIndex, 15); + Rumble_Request(this->actor.xyzDistToPlayerSq, 120, 20, 10); + this->timer = 40; this->actionFunc = EnPametfrog_SnapperSpawn; } @@ -1244,12 +1248,16 @@ void EnPametfrog_SnapperSpawn(EnPametfrog* this, PlayState* play) { void EnPametfrog_SetupTransitionGekkoSnapper(EnPametfrog* this, PlayState* play) { this->actor.params = GEKKO_GET_SNAPPER; - Quake_RemoveFromIdx(this->quake); - this->quake = Quake_Add(GET_ACTIVE_CAM(play), 3); - Quake_SetSpeed(this->quake, 20000); - Quake_SetQuakeValues(this->quake, 17, 0, 0, 0); - Quake_SetCountdown(this->quake, 12); + + Quake_Remove(this->quakeIndex); + + this->quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + Quake_SetSpeed(this->quakeIndex, 20000); + Quake_SetQuakeValues(this->quakeIndex, 17, 0, 0, 0); + Quake_SetCountdown(this->quakeIndex, 12); + Rumble_Request(this->actor.xyzDistToPlayerSq, 255, 20, 150); + this->actionFunc = EnPametfrog_TransitionGekkoSnapper; } diff --git a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h index 3f3e82165b..81af171299 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h @@ -32,7 +32,7 @@ typedef struct EnPametfrog { /* 0x2AE */ u8 unk_2AE; // True/False /* 0x2B0 */ s16 cutscene; /* 0x2B2 */ s16 params; - /* 0x2B4 */ s16 quake; + /* 0x2B4 */ s16 quakeIndex; /* 0x2B6 */ s16 timer; /* 0x2B8 */ s16 spinYaw; /* 0x2BA */ s16 subCamId; diff --git a/src/overlays/actors/ovl_En_Stop_heishi/z_en_stop_heishi.c b/src/overlays/actors/ovl_En_Stop_heishi/z_en_stop_heishi.c index ec412ce794..062422026b 100644 --- a/src/overlays/actors/ovl_En_Stop_heishi/z_en_stop_heishi.c +++ b/src/overlays/actors/ovl_En_Stop_heishi/z_en_stop_heishi.c @@ -5,6 +5,7 @@ */ #include "z_en_stop_heishi.h" +#include "z64quake.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) 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 c0f0a3e89e..23dccca0fb 100644 --- a/src/overlays/actors/ovl_En_Test6/z_en_test6.c +++ b/src/overlays/actors/ovl_En_Test6/z_en_test6.c @@ -5,6 +5,7 @@ */ #include "z_en_test6.h" +#include "z64quake.h" #include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_200000 | ACTOR_FLAG_2000000) @@ -396,7 +397,7 @@ void func_80A916F0(EnTest6* this, PlayState* play) { ActorCutscene_Stop(play->playerActorCsIds[8]); func_800B7298(play, NULL, 6); func_80A90C34(); - Distortion_ClearType(0x20); + Distortion_ClearType(DISTORTION_TYPE_5); Actor_MarkForDeath(&this->actor); } @@ -462,7 +463,7 @@ void func_80A91760(EnTest6* this, PlayState* play) { } } func_80A90C08(0x78); - Distortion_SetType(0x20); + Distortion_SetType(DISTORTION_TYPE_5); Distortion_SetCountdown(80); play->unk_18844 = 1; this->unk_274 = 95; @@ -517,7 +518,7 @@ void func_80A91760(EnTest6* this, PlayState* play) { if (this->unk_27A == 10) { this->unk_14C = 0.1f; func_80A90C34(); - Distortion_ClearType(0x20); + Distortion_ClearType(DISTORTION_TYPE_5); play->unk_18844 = 0; if (this->unk_254 != NULL) { ZeldaArena_Free(this->unk_254); @@ -617,7 +618,7 @@ void func_80A92118(EnTest6* this, PlayState* play) { ActorCutscene_Stop(play->playerActorCsIds[8]); func_800B7298(play, NULL, 6); func_80A90C34(); - Distortion_ClearType(0x20); + Distortion_ClearType(DISTORTION_TYPE_5); Actor_MarkForDeath(&this->actor); } @@ -684,7 +685,7 @@ void func_80A92188(EnTest6* this, PlayState* play) { case 115: func_80A90C08(0x14); - Distortion_SetType(0x20); + Distortion_SetType(DISTORTION_TYPE_5); Distortion_SetCountdown(90); this->unk_274 = 2; break; @@ -715,7 +716,7 @@ void func_80A92188(EnTest6* this, PlayState* play) { case 14: case 15: func_80A90C08(0x32); - Distortion_ClearType(0x20); + Distortion_ClearType(DISTORTION_TYPE_5); this->unk_274 = 0; break; 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 769266e973..5fc5d6b319 100644 --- a/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c +++ b/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c @@ -5,6 +5,7 @@ */ #include "z_obj_chikuwa.h" +#include "z64quake.h" #include "objects/object_d_lift/object_d_lift.h" #define FLAGS (ACTOR_FLAG_10) @@ -158,9 +159,9 @@ void ObjChikuwa_Update(Actor* thisx, PlayState* play) { ObjChikuwa* this = THIS; ObjChikuwaStruct* temp; f32 temp_fs0; - s16 var_s2; + s16 quakeVerticalMag; s32 i; - s32 quake; + s32 quakeIndex; this->unk_29E++; @@ -173,16 +174,16 @@ void ObjChikuwa_Update(Actor* thisx, PlayState* play) { func_809B17D0(play, this, &temp->unk_00); temp_fs0 = Math3D_Vec3fDistSq(&temp->unk_00, &GET_PLAYER(play)->actor.world.pos); if (temp_fs0 < SQ(240.0f)) { - quake = Quake_Add(GET_ACTIVE_CAM(play), 3); + quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); if (temp_fs0 < SQ(120.0f)) { - var_s2 = 4; + quakeVerticalMag = 4; } else { - var_s2 = 3; + quakeVerticalMag = 3; } - Quake_SetSpeed(quake, 0x4350); - Quake_SetQuakeValues(quake, var_s2, 0, 0, 0); - Quake_SetCountdown(quake, 7); + Quake_SetSpeed(quakeIndex, 17232); + Quake_SetQuakeValues(quakeIndex, quakeVerticalMag, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 7); } } } diff --git a/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c b/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c index 0502074929..77b704a6c7 100644 --- a/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c +++ b/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c @@ -5,6 +5,7 @@ */ #include "z_obj_dhouse.h" +#include "z64quake.h" #include "objects/object_dhouse/object_dhouse.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_400000) @@ -454,23 +455,23 @@ void func_80B139D8(ObjDhouse* this) { void func_80B139F4(ObjDhouse* this, PlayState* play) { Camera* camera = GET_ACTIVE_CAM(play); - s16 quake; + s16 quakeIndex; if (this->unk_1370 == 117) { - quake = Quake_Add(camera, 3); - Quake_SetSpeed(quake, 20000); - Quake_SetQuakeValues(quake, 8, 0, 0, 0); - Quake_SetCountdown(quake, 17); + quakeIndex = Quake_Add(camera, QUAKE_TYPE_3); + Quake_SetSpeed(quakeIndex, 20000); + Quake_SetQuakeValues(quakeIndex, 8, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 17); } else if (this->unk_1370 == 105) { - quake = Quake_Add(camera, 3); - Quake_SetSpeed(quake, 20000); - Quake_SetQuakeValues(quake, 7, 0, 0, 0); - Quake_SetCountdown(quake, 20); + quakeIndex = Quake_Add(camera, QUAKE_TYPE_3); + Quake_SetSpeed(quakeIndex, 20000); + Quake_SetQuakeValues(quakeIndex, 7, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 20); } else if (this->unk_1370 == 90) { - quake = Quake_Add(camera, 3); - Quake_SetSpeed(quake, 20000); - Quake_SetQuakeValues(quake, 5, 0, 0, 0); - Quake_SetCountdown(quake, 62); + quakeIndex = Quake_Add(camera, QUAKE_TYPE_3); + Quake_SetSpeed(quakeIndex, 20000); + Quake_SetQuakeValues(quakeIndex, 5, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 62); } this->unk_1370--; diff --git a/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c b/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c index c0537940c3..467dfa8b8a 100644 --- a/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c +++ b/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c @@ -5,6 +5,7 @@ */ #include "z_obj_hariko.h" +#include "z64quake.h" #include "assets/objects/object_hariko/object_hariko.h" #define FLAGS (ACTOR_FLAG_20 | ACTOR_FLAG_2000000) 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 19d35ffffb..38f3164e38 100644 --- a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c +++ b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c @@ -5,6 +5,7 @@ */ #include "z_obj_hugebombiwa.h" +#include "z64quake.h" #include "z64rumble.h" #include "objects/object_bombiwa/object_bombiwa.h" @@ -292,13 +293,14 @@ void func_80A54600(PlayState* play, Vec3f* arg1, f32 arg2, f32 arg3) { } } -void func_80A54980(ObjHugebombiwa* this, PlayState* play, s32 arg2) { +void ObjHugebombiwa_AddQuake(ObjHugebombiwa* this, PlayState* play, s32 quakeVerticalMag) { s32 pad[2]; - s16 quake = Quake_Add(GET_ACTIVE_CAM(play), 3); + s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + + Quake_SetSpeed(quakeIndex, 20000); + Quake_SetQuakeValues(quakeIndex, quakeVerticalMag, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 7); - Quake_SetSpeed(quake, 0x4E20); - Quake_SetQuakeValues(quake, arg2, 0, 0, 0); - Quake_SetCountdown(quake, 7); Rumble_Request(this->actor.xyzDistToPlayerSq, 255, 20, 150); } @@ -514,7 +516,7 @@ void func_80A55064(ObjHugebombiwa* this, PlayState* play) { ptr->unk_24 = 1; func_80A53E60(play, &ptr->unk_0C, ptr->unk_18, ptr->unk_00.y * 9.8f); if ((play->gameplayFrames % 4) == 0) { - func_80A54980(this, play, (s32)(Rand_ZeroOne() * 5.5f) + 1); + ObjHugebombiwa_AddQuake(this, play, (s32)(Rand_ZeroOne() * 5.5f) + 1); } } } @@ -610,7 +612,7 @@ void func_80A55564(ObjHugebombiwa* this, PlayState* play) { ptr->unk_24 = 1; func_80A54600(play, &ptr->unk_0C, ptr->unk_18, ptr->unk_00.y * 10.1f); if ((play->gameplayFrames % 4) == 0) { - func_80A54980(this, play, (s32)(Rand_ZeroOne() * 5.5f) + 1); + ObjHugebombiwa_AddQuake(this, play, (s32)(Rand_ZeroOne() * 5.5f) + 1); } } } diff --git a/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c b/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c index f7056b147b..4668bfffd4 100644 --- a/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c +++ b/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c @@ -5,6 +5,7 @@ */ #include "z_obj_lift.h" +#include "z64quake.h" #include "objects/object_d_lift/object_d_lift.h" #define FLAGS (ACTOR_FLAG_10) @@ -125,17 +126,18 @@ void func_8093D760(ObjLift* this) { void func_8093D7A0(ObjLift* this, PlayState* play) { s32 pad; - s16 quake; + s16 quakeIndex; if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { if (this->timer <= 0) { if (OBJLIFT_GET_7(&this->dyna.actor) == 7) { func_8093D9C0(this); } else { - quake = Quake_Add(GET_ACTIVE_CAM(play), 1); - Quake_SetSpeed(quake, 10000); - Quake_SetQuakeValues(quake, 2, 0, 0, 0); - Quake_SetCountdown(quake, 20); + quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_1); + Quake_SetSpeed(quakeIndex, 10000); + Quake_SetQuakeValues(quakeIndex, 2, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 20); + func_8093D88C(this); } } 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 62cb402758..2c8e42c7d0 100644 --- a/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c +++ b/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c @@ -5,6 +5,7 @@ */ #include "z_obj_tokei_step.h" +#include "z64quake.h" #include "z64rumble.h" #include "objects/object_tokei_step/object_tokei_step.h" @@ -62,11 +63,12 @@ void ObjTokeiStep_SetSysMatrix(ObjTokeiStepPanel* panel) { void ObjTokeiStep_AddQuake(ObjTokeiStep* this, PlayState* play) { s32 pad[2]; - s16 quake = Quake_Add(GET_ACTIVE_CAM(play), 3); + s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + + Quake_SetSpeed(quakeIndex, 20000); + Quake_SetQuakeValues(quakeIndex, 1, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 7); - Quake_SetSpeed(quake, 20000); - Quake_SetQuakeValues(quake, 1, 0, 0, 0); - Quake_SetCountdown(quake, 7); Rumble_Request(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); } diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index e8a8728027..681438463a 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -5,6 +5,7 @@ */ #include "global.h" +#include "z64quake.h" #include "z64rumble.h" #define THIS ((Player*)thisx) diff --git a/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c b/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c index 9dab9c61ad..bd8a40ed8f 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c +++ b/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c @@ -91,7 +91,7 @@ void EffectSsBubble_Update(PlayState* play2, u32 index, EffectSs* this) { BgCheck_EntityRaycastFloor2_1(play, &play->colCtx, &colPoly, &this->pos); speed = SurfaceType_GetConveyorSpeed(&play->colCtx, colPoly, BGCHECK_SCENE); - if ((speed != 0) && !SurfaceType_GetConveyorType(&play->colCtx, colPoly, BGCHECK_SCENE)) { + if ((speed != 0) && !SurfaceType_IsFloorConveyor(&play->colCtx, colPoly, BGCHECK_SCENE)) { direction = SurfaceType_GetConveyorDirection(&play->colCtx, colPoly, BGCHECK_SCENE) << 0xA; rVecAdjMax = sVecAdjMaximums[speed - 1]; this->rVecAdjX = Math_SinS(direction) * rVecAdjMax; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 4bcf89f809..3b949a49c9 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -859,8 +859,8 @@ 0x800BC5B8:("Actor_IsTargeted",), 0x800BC5EC:("Actor_OtherIsTargeted",), 0x800BC620:("func_800BC620",), - 0x800BC770:("func_800BC770",), - 0x800BC7D8:("func_800BC7D8",), + 0x800BC770:("Actor_AddQuake",), + 0x800BC7D8:("Actor_AddQuakeWithSpeed",), 0x800BC848:("func_800BC848",), 0x800BC8B8:("Actor_DrawDoorLock",), 0x800BCB50:("Actor_SpawnShieldParticlesMetal",), @@ -1075,7 +1075,7 @@ 0x800C9CEC:("SurfaceType_IsHookshotSurface",), 0x800C9D14:("SurfaceType_IsIgnoredByEntities",), 0x800C9D50:("SurfaceType_IsIgnoredByProjectiles",), - 0x800C9D8C:("SurfaceType_GetConveyorType",), + 0x800C9D8C:("SurfaceType_IsFloorConveyor",), 0x800C9DDC:("func_800C9DDC",), 0x800C9E18:("SurfaceType_GetConveyorSpeed",), 0x800C9E40:("SurfaceType_GetConveyorDirection",), @@ -2282,15 +2282,15 @@ 0x8012A038:("PreNMI_Init",), 0x8012A080:("Quake_Random",), 0x8012A0AC:("Quake_UpdateShakeInfo",), - 0x8012A2B8:("Quake_Callback1",), - 0x8012A340:("Quake_Callback5",), - 0x8012A3B4:("Quake_Callback6",), - 0x8012A438:("Quake_Callback3",), - 0x8012A4D0:("Quake_Callback2",), - 0x8012A540:("Quake_Callback4",), + 0x8012A2B8:("Quake_CallbackType1",), + 0x8012A340:("Quake_CallbackType5",), + 0x8012A3B4:("Quake_CallbackType6",), + 0x8012A438:("Quake_CallbackType3",), + 0x8012A4D0:("Quake_CallbackType2",), + 0x8012A540:("Quake_CallbackType4",), 0x8012A5D8:("Quake_GetFreeIndex",), 0x8012A638:("Quake_AddImpl",), - 0x8012A6F0:("Quake_Remove",), + 0x8012A6F0:("Quake_RemoveRequest",), 0x8012A718:("Quake_GetRequest",), 0x8012A774:("Quake_SetValue",), 0x8012A8A8:("Quake_SetSpeed",), @@ -2300,7 +2300,7 @@ 0x8012A9E0:("Quake_SetQuakeValues2",), 0x8012AA48:("Quake_Init",), 0x8012AA9C:("Quake_Add",), - 0x8012AAC0:("Quake_RemoveFromIdx",), + 0x8012AAC0:("Quake_Remove",), 0x8012AB08:("Quake_Calc",), 0x8012AE68:("Distortion_Init",), 0x8012AEAC:("Distortion_SetCountdown",), @@ -10620,7 +10620,7 @@ 0x80A53E60:("func_80A53E60",), 0x80A541F4:("func_80A541F4",), 0x80A54600:("func_80A54600",), - 0x80A54980:("func_80A54980",), + 0x80A54980:("ObjHugebombiwa_AddQuake",), 0x80A54A0C:("func_80A54A0C",), 0x80A54AC0:("ObjHugebombiwa_Init",), 0x80A54BC4:("ObjHugebombiwa_Destroy",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index ff7987c6f5..9e02cf981b 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -4015,7 +4015,7 @@ 0x801F59F4:("D_801F59F4","UNK_TYPE1","",0x1), 0x801F59F8:("D_801F59F8","UNK_TYPE1","",0x1), 0x801F5A00:("sQuakeRequest","QuakeRequest","[4]",0x90), - 0x801F5A90:("sDistortionContext","DistortionContext","",0xc), + 0x801F5A90:("sDistortionRequest","DistortionRequest","",0xc), 0x801F5AA0:("sMatAnimStep","s32","",0x4), 0x801F5AA4:("sMatAnimFlags","u32","",0x4), 0x801F5AA8:("sMatAnimAlphaRatio","f32","",0x4), diff --git a/tools/namefixer.py b/tools/namefixer.py index f78717d40b..b432879716 100755 --- a/tools/namefixer.py +++ b/tools/namefixer.py @@ -295,6 +295,7 @@ wordReplace = { "func_800BC8B8": "Actor_DrawDoorLock", "func_800B86C8": "Actor_ChangeFocus", "func_800B90F4": "Actor_DeactivateLens", + "func_800BC770": "Actor_AddQuake", "zelda_malloc": "ZeldaArena_Malloc", "zelda_mallocR": "ZeldaArena_MallocR", "zelda_realloc": "ZeldaArena_Realloc", @@ -411,6 +412,7 @@ wordReplace = { "BgCheck_RelocateMeshHeader": "CollisionHeader_GetVirtual", "BgCheck_RelocateAllMeshHeaders": "BgCheck_InitCollisionHeaders", "BgCheck_GetPolygonAttributes": "SurfaceType_GetData", + "SurfaceType_GetConveyorType": "SurfaceType_IsFloorConveyor", "func_800C9704": "SurfaceType_GetBgCamIndex", "func_800C9924": "BgCheck_GetBgCamFuncData", "func_800C99AC": "SurfaceType_GetSceneExitIndex", @@ -422,7 +424,7 @@ wordReplace = { "func_800C9CEC": "SurfaceType_IsHookshotSurface", "func_800C9D14": "SurfaceType_IsIgnoredByEntities", "func_800C9D50": "SurfaceType_IsIgnoredByProjectiles", - "func_800C9D8C": "SurfaceType_GetConveyorType", + "func_800C9D8C": "SurfaceType_IsFloorConveyor", "func_800C9E18": "SurfaceType_GetConveyorSpeed", "func_800C9E40": "SurfaceType_GetConveyorDirection", "func_800C9E88": "SurfaceType_IsWallDamage", @@ -545,6 +547,7 @@ wordReplace = { "Quake2_SetCountdown": "Distortion_SetCountdown", "func_800BE680": "Actor_DrawDamageEffects", "func_8012F22C": "Inventory_GetSkullTokenCount", + "Quake_RemoveFromIdx": "Quake_Remove", "func_8013AB00": "SubS_DrawTransformFlex", "func_8013A860": "SubS_DrawTransformFlexLimb", diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index dcb030e31f..968fa65d37 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -373,8 +373,8 @@ asm/non_matchings/code/z_actor/Actor_TestFloorInDirection.s,Actor_TestFloorInDir asm/non_matchings/code/z_actor/Actor_IsTargeted.s,Actor_IsTargeted,0x800BC5B8,0xD asm/non_matchings/code/z_actor/Actor_OtherIsTargeted.s,Actor_OtherIsTargeted,0x800BC5EC,0xD asm/non_matchings/code/z_actor/func_800BC620.s,func_800BC620,0x800BC620,0x54 -asm/non_matchings/code/z_actor/func_800BC770.s,func_800BC770,0x800BC770,0x1A -asm/non_matchings/code/z_actor/func_800BC7D8.s,func_800BC7D8,0x800BC7D8,0x1C +asm/non_matchings/code/z_actor/Actor_AddQuake.s,Actor_AddQuake,0x800BC770,0x1A +asm/non_matchings/code/z_actor/Actor_AddQuakeWithSpeed.s,Actor_AddQuakeWithSpeed,0x800BC7D8,0x1C asm/non_matchings/code/z_actor/func_800BC848.s,func_800BC848,0x800BC848,0x1C asm/non_matchings/code/z_actor/Actor_DrawDoorLock.s,Actor_DrawDoorLock,0x800BC8B8,0xA6 asm/non_matchings/code/z_actor/Actor_SpawnShieldParticlesMetal.s,Actor_SpawnShieldParticlesMetal,0x800BCB50,0x8 @@ -589,7 +589,7 @@ asm/non_matchings/code/z_bgcheck/SurfaceType_GetEcho.s,SurfaceType_GetEcho,0x800 asm/non_matchings/code/z_bgcheck/SurfaceType_IsHookshotSurface.s,SurfaceType_IsHookshotSurface,0x800C9CEC,0xA asm/non_matchings/code/z_bgcheck/SurfaceType_IsIgnoredByEntities.s,SurfaceType_IsIgnoredByEntities,0x800C9D14,0xF asm/non_matchings/code/z_bgcheck/SurfaceType_IsIgnoredByProjectiles.s,SurfaceType_IsIgnoredByProjectiles,0x800C9D50,0xF -asm/non_matchings/code/z_bgcheck/SurfaceType_GetConveyorType.s,SurfaceType_GetConveyorType,0x800C9D8C,0x14 +asm/non_matchings/code/z_bgcheck/SurfaceType_IsFloorConveyor.s,SurfaceType_IsFloorConveyor,0x800C9D8C,0x14 asm/non_matchings/code/z_bgcheck/func_800C9DDC.s,func_800C9DDC,0x800C9DDC,0xF asm/non_matchings/code/z_bgcheck/SurfaceType_GetConveyorSpeed.s,SurfaceType_GetConveyorSpeed,0x800C9E18,0xA asm/non_matchings/code/z_bgcheck/SurfaceType_GetConveyorDirection.s,SurfaceType_GetConveyorDirection,0x800C9E40,0x12 @@ -1796,15 +1796,15 @@ asm/non_matchings/code/z_prenmi/PreNMI_Destroy.s,PreNMI_Destroy,0x8012A02C,0x3 asm/non_matchings/code/z_prenmi/PreNMI_Init.s,PreNMI_Init,0x8012A038,0x12 asm/non_matchings/code/z_quake/Quake_Random.s,Quake_Random,0x8012A080,0xB asm/non_matchings/code/z_quake/Quake_UpdateShakeInfo.s,Quake_UpdateShakeInfo,0x8012A0AC,0x83 -asm/non_matchings/code/z_quake/Quake_Callback1.s,Quake_Callback1,0x8012A2B8,0x22 -asm/non_matchings/code/z_quake/Quake_Callback5.s,Quake_Callback5,0x8012A340,0x1D -asm/non_matchings/code/z_quake/Quake_Callback6.s,Quake_Callback6,0x8012A3B4,0x21 -asm/non_matchings/code/z_quake/Quake_Callback3.s,Quake_Callback3,0x8012A438,0x26 -asm/non_matchings/code/z_quake/Quake_Callback2.s,Quake_Callback2,0x8012A4D0,0x1C -asm/non_matchings/code/z_quake/Quake_Callback4.s,Quake_Callback4,0x8012A540,0x26 +asm/non_matchings/code/z_quake/Quake_CallbackType1.s,Quake_CallbackType1,0x8012A2B8,0x22 +asm/non_matchings/code/z_quake/Quake_CallbackType5.s,Quake_CallbackType5,0x8012A340,0x1D +asm/non_matchings/code/z_quake/Quake_CallbackType6.s,Quake_CallbackType6,0x8012A3B4,0x21 +asm/non_matchings/code/z_quake/Quake_CallbackType3.s,Quake_CallbackType3,0x8012A438,0x26 +asm/non_matchings/code/z_quake/Quake_CallbackType2.s,Quake_CallbackType2,0x8012A4D0,0x1C +asm/non_matchings/code/z_quake/Quake_CallbackType4.s,Quake_CallbackType4,0x8012A540,0x26 asm/non_matchings/code/z_quake/Quake_GetFreeIndex.s,Quake_GetFreeIndex,0x8012A5D8,0x18 asm/non_matchings/code/z_quake/Quake_AddImpl.s,Quake_AddImpl,0x8012A638,0x2E -asm/non_matchings/code/z_quake/Quake_Remove.s,Quake_Remove,0x8012A6F0,0xA +asm/non_matchings/code/z_quake/Quake_RemoveRequest.s,Quake_RemoveRequest,0x8012A6F0,0xA asm/non_matchings/code/z_quake/Quake_GetRequest.s,Quake_GetRequest,0x8012A718,0x17 asm/non_matchings/code/z_quake/Quake_SetValue.s,Quake_SetValue,0x8012A774,0x4D asm/non_matchings/code/z_quake/Quake_SetSpeed.s,Quake_SetSpeed,0x8012A8A8,0x12 @@ -1814,7 +1814,7 @@ asm/non_matchings/code/z_quake/Quake_SetQuakeValues.s,Quake_SetQuakeValues,0x801 asm/non_matchings/code/z_quake/Quake_SetQuakeValues2.s,Quake_SetQuakeValues2,0x8012A9E0,0x1A asm/non_matchings/code/z_quake/Quake_Init.s,Quake_Init,0x8012AA48,0x15 asm/non_matchings/code/z_quake/Quake_Add.s,Quake_Add,0x8012AA9C,0x9 -asm/non_matchings/code/z_quake/Quake_RemoveFromIdx.s,Quake_RemoveFromIdx,0x8012AAC0,0x12 +asm/non_matchings/code/z_quake/Quake_Remove.s,Quake_Remove,0x8012AAC0,0x12 asm/non_matchings/code/z_quake/Quake_Calc.s,Quake_Calc,0x8012AB08,0xD8 asm/non_matchings/code/z_quake/Distortion_Init.s,Distortion_Init,0x8012AE68,0x11 asm/non_matchings/code/z_quake/Distortion_SetCountdown.s,Distortion_SetCountdown,0x8012AEAC,0xA From 4935ec7ba1f5c25d44f956174be058a150196d25 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Fri, 30 Sep 2022 19:34:28 -0700 Subject: [PATCH 08/25] Rename SetupIndex to Layer (#1099) * Rename setupIndex to Layer * () --- include/functions.h | 2 +- include/z64save.h | 2 +- include/z64scene.h | 2 +- src/code/z_demo.c | 12 +++--- src/code/z_parameter.c | 4 +- src/code/z_scene.c | 4 +- .../actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c | 2 +- .../actors/ovl_Dm_Char00/z_dm_char00.c | 26 ++++++------- .../actors/ovl_Dm_Char01/z_dm_char01.c | 8 ++-- .../actors/ovl_Dm_Char05/z_dm_char05.c | 6 +-- .../actors/ovl_Dm_Opstage/z_dm_opstage.c | 2 +- src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c | 38 +++++++++---------- src/overlays/actors/ovl_En_Dnk/z_en_dnk.c | 2 +- src/overlays/actors/ovl_En_Elf/z_en_elf.c | 6 +-- src/overlays/actors/ovl_En_Fall/z_en_fall.c | 7 ++-- src/overlays/actors/ovl_En_Giant/z_en_giant.c | 2 +- src/overlays/actors/ovl_En_Gm/z_en_gm.c | 2 +- src/overlays/actors/ovl_En_Go/z_en_go.c | 6 +-- .../actors/ovl_En_Hanabi/z_en_hanabi.c | 6 +-- src/overlays/actors/ovl_En_Hg/z_en_hg.c | 4 +- src/overlays/actors/ovl_En_Hgo/z_en_hgo.c | 2 +- src/overlays/actors/ovl_En_Horse/z_en_horse.c | 4 +- .../z_en_horse_link_child.c | 2 +- src/overlays/actors/ovl_En_Jg/z_en_jg.c | 3 +- src/overlays/actors/ovl_En_Ma4/z_en_ma4.c | 2 +- src/overlays/actors/ovl_En_Mag/z_en_mag.c | 2 +- src/overlays/actors/ovl_En_Osn/z_en_osn.c | 2 +- src/overlays/actors/ovl_En_Pm/z_en_pm.c | 2 +- .../actors/ovl_En_Rail_Skb/z_en_rail_skb.c | 2 +- src/overlays/actors/ovl_En_Skb/z_en_skb.c | 2 +- src/overlays/actors/ovl_En_Zog/z_en_zog.c | 3 +- .../actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c | 2 +- .../ovl_Obj_Tokei_Step/z_obj_tokei_step.c | 3 +- .../actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c | 22 ++++------- .../gamestates/ovl_opening/z_opening.c | 2 +- tools/disasm/functions.txt | 2 +- tools/namefixer.py | 4 +- tools/sizes/code_functions.csv | 2 +- 38 files changed, 99 insertions(+), 107 deletions(-) diff --git a/include/functions.h b/include/functions.h index b19b75af99..99e030cde6 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1356,7 +1356,7 @@ void Cutscene_ActorTranslate(Actor* actor, PlayState* play, s32 actorActionIndex void Cutscene_ActorTranslateAndYaw(Actor* actor, PlayState* play, s32 actorActionIndex); void Cutscene_ActorTranslateAndYawSmooth(Actor* actor, PlayState* play, s32 actorActionIndex); void Cutscene_ActorTranslateXZAndYawSmooth(Actor* actor, PlayState* play, s32 actorActionIndex); -s32 Cutscene_GetSceneSetupIndex(PlayState* play); +s32 Cutscene_GetSceneLayer(PlayState* play); s32 Cutscene_GetActorActionIndex(PlayState* play, u16 actorActionCmd); s32 Cutscene_CheckActorAction(PlayState* play, u16 actorActionCmd); u8 Cutscene_IsPlaying(PlayState* play); diff --git a/include/z64save.h b/include/z64save.h index 74cf31c8e3..c357479722 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -304,7 +304,7 @@ typedef struct SaveContext { /* 0x3CA6 */ u8 unk_3CA6; /* 0x3CA7 */ u8 unk_3CA7; // "day_night_flag" /* 0x3CA8 */ s32 gameMode; // "mode" - /* 0x3CAC */ s32 sceneSetupIndex; // "counter" + /* 0x3CAC */ s32 sceneLayer; // "counter" /* 0x3CB0 */ s32 respawnFlag; // "restart_flag" /* 0x3CB4 */ RespawnData respawn[RESPAWN_MODE_MAX]; // "restart_data" /* 0x3DB4 */ f32 entranceSpeed; // "player_wipe_speedF" diff --git a/include/z64scene.h b/include/z64scene.h index 18d7b81f98..9658c4f4d2 100644 --- a/include/z64scene.h +++ b/include/z64scene.h @@ -767,7 +767,7 @@ typedef enum { /* * 0xFE00: Index into sSceneEntranceTable (Scene) * 0x01F0: Index into the scenes specific entrance table (Spawn) -* 0x000F: Index into the specific entrance table (Layer), stored seperately in sceneSetupIndex +* 0x000F: Index into the specific entrance table (Layer), stored seperately in sceneLayer */ #define ENTRANCE(scene, spawn) ((((ENTR_SCENE_##scene) & 0x7F) << 9) | (((spawn) & 0x1F) << 4)) diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 7dd357fbd4..6c83e83915 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -1497,7 +1497,7 @@ void func_800EDBE0(PlayState* play) { sp24 = play->loadedScene; if ((sp24->titleTextId != 0) && gSaveContext.showTitleCard) { if ((Entrance_GetTransitionFlags(((void)0, gSaveContext.save.entrance) + - ((void)0, gSaveContext.sceneSetupIndex)) & + ((void)0, gSaveContext.sceneLayer)) & 0x4000) != 0) { func_80151A68(play, sp24->titleTextId); } @@ -1608,13 +1608,13 @@ void Cutscene_ActorTranslateXZAndYawSmooth(Actor* actor, PlayState* play, s32 ac actor->shape.rot.y = actor->world.rot.y; } -s32 Cutscene_GetSceneSetupIndex(PlayState* play) { - s32 sceneSetupIndex = 0; +s32 Cutscene_GetSceneLayer(PlayState* play) { + s32 sceneLayer = 0; - if (gSaveContext.sceneSetupIndex > 0) { - sceneSetupIndex = gSaveContext.sceneSetupIndex; + if (gSaveContext.sceneLayer > 0) { + sceneLayer = gSaveContext.sceneLayer; } - return sceneSetupIndex; + return sceneLayer; } s32 Cutscene_GetActorActionIndex(PlayState* play, u16 actorActionCmd) { diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index eb110c0c7d..3a2da402c7 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -2264,7 +2264,7 @@ void Magic_Update(PlayState* play) { // Add magic until magicFillTarget is reached gSaveContext.save.playerData.magic += 0x10; - if ((gSaveContext.gameMode == 0) && (gSaveContext.sceneSetupIndex < 4)) { + if ((gSaveContext.gameMode == 0) && (gSaveContext.sceneLayer < 4)) { play_sound(NA_SE_SY_GAUGE_UP - SFX_FLAG); } @@ -2863,7 +2863,7 @@ void Interface_DrawTimers(PlayState* play) { if (sTimerId == TIMER_ID_MOON_CRASH) { gSaveContext.save.day = 4; - if ((play->sceneId == SCENE_OKUJOU) && (gSaveContext.sceneSetupIndex == 3)) { + if ((play->sceneId == SCENE_OKUJOU) && (gSaveContext.sceneLayer == 3)) { play->nextEntrance = ENTRANCE(TERMINA_FIELD, 1); gSaveContext.nextCutsceneIndex = 0xFFF0; play->transitionTrigger = TRANS_TRIGGER_START; diff --git a/src/code/z_scene.c b/src/code/z_scene.c index ce5ddf7694..7b88d4520f 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -455,9 +455,9 @@ void Scene_HeaderCmdAltHeaderList(PlayState* play, SceneCmd* cmd) { SceneCmd** altHeaderList; SceneCmd* altHeader; - if (gSaveContext.sceneSetupIndex != 0) { + if (gSaveContext.sceneLayer != 0) { altHeaderList = Lib_SegmentedToVirtual(cmd->altHeaders.segment); - altHeader = altHeaderList[gSaveContext.sceneSetupIndex - 1]; + altHeader = altHeaderList[gSaveContext.sceneLayer - 1]; if (altHeader != NULL) { Scene_ProcessHeader(play, Lib_SegmentedToVirtual(altHeader)); 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 81397039df..c0e9bdc42b 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 @@ -131,7 +131,7 @@ void BgIknvObj_UpdateWaterwheel(BgIknvObj* this, PlayState* play) { func_800B9010(&this->dyna.actor, NA_SE_EV_WOOD_WATER_WHEEL - SFX_FLAG); } - if ((play->csCtx.state != 0) && (gSaveContext.sceneSetupIndex == 1) && (play->csCtx.currentCsIndex == 4) && + if ((play->csCtx.state != 0) && (gSaveContext.sceneLayer == 1) && (play->csCtx.currentCsIndex == 4) && (play->csCtx.frames == 1495)) { func_8019F128(NA_SE_EV_DOOR_UNLOCK); } 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 cd130e218f..82e5157f61 100644 --- a/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c +++ b/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c @@ -451,13 +451,13 @@ void func_80AA5EBC(DmChar00* this, PlayState* play) { if (play->csCtx.state != 0) { switch (play->sceneId) { case SCENE_LOST_WOODS: - if (gSaveContext.sceneSetupIndex == 1) { + if (gSaveContext.sceneLayer == 1) { func_80AA561C(this, play); } break; case SCENE_OPENINGDAN: - if (gSaveContext.sceneSetupIndex == 0) { + if (gSaveContext.sceneLayer == 0) { if (play->csCtx.currentCsIndex == 0) { func_80AA5720(this, play); } else if (play->csCtx.currentCsIndex == 1) { @@ -469,7 +469,7 @@ void func_80AA5EBC(DmChar00* this, PlayState* play) { break; case SCENE_OKUJOU: - if (gSaveContext.sceneSetupIndex == 0) { + if (gSaveContext.sceneLayer == 0) { if (play->csCtx.currentCsIndex == 0) { func_80AA58CC(this, play); } else if (play->csCtx.currentCsIndex == 1) { @@ -477,7 +477,7 @@ void func_80AA5EBC(DmChar00* this, PlayState* play) { } else if (play->csCtx.currentCsIndex == 2) { func_80AA5960(this, play); } - } else if (gSaveContext.sceneSetupIndex == 2) { + } else if (gSaveContext.sceneLayer == 2) { if (play->csCtx.currentCsIndex == 0) { func_80AA59E4(this, play); } else if (play->csCtx.currentCsIndex == 1) { @@ -487,13 +487,13 @@ void func_80AA5EBC(DmChar00* this, PlayState* play) { break; case SCENE_00KEIKOKU: - if (gSaveContext.sceneSetupIndex == 3) { + if (gSaveContext.sceneLayer == 3) { if (play->csCtx.currentCsIndex == 0) { func_80AA5AF4(this, play); } else if (play->csCtx.currentCsIndex == 2) { func_80AA5E2C(this, play); } - } else if (gSaveContext.sceneSetupIndex == 7) { + } else if (gSaveContext.sceneLayer == 7) { if (play->csCtx.currentCsIndex == 0) { func_80AA5BF8(this, play); } else if (play->csCtx.currentCsIndex == 1) { @@ -503,19 +503,19 @@ void func_80AA5EBC(DmChar00* this, PlayState* play) { break; case SCENE_MITURIN: - if ((gSaveContext.sceneSetupIndex == 0) && (play->csCtx.currentCsIndex == 1)) { + if ((gSaveContext.sceneLayer == 0) && (play->csCtx.currentCsIndex == 1)) { func_80AA5DC8(this, play); } break; case SCENE_INSIDETOWER: - if ((gSaveContext.sceneSetupIndex == 0) && (play->csCtx.currentCsIndex == 0)) { + if ((gSaveContext.sceneLayer == 0) && (play->csCtx.currentCsIndex == 0)) { func_80AA5D10(this, play); } break; case SCENE_PIRATE: - if ((gSaveContext.sceneSetupIndex == 0) && (play->csCtx.currentCsIndex == 0)) { + if ((gSaveContext.sceneLayer == 0) && (play->csCtx.currentCsIndex == 0)) { func_80AA5D6C(this, play); } break; @@ -853,7 +853,7 @@ void func_80AA62FC(DmChar00* this, PlayState* play) { void func_80AA67F8(DmChar00* this, PlayState* play) { Player* player = GET_PLAYER(play); - if ((play->csCtx.state == 0) && (gSaveContext.sceneSetupIndex == 0) && (play->csCtx.currentCsIndex == 1)) { + if ((play->csCtx.state == 0) && (gSaveContext.sceneLayer == 0) && (play->csCtx.currentCsIndex == 1)) { if (this->unk_261 != 42) { this->unk_261 = 42; func_80AA5580(&this->skelAnime, &sAnimationInfo[this->unk_261], 0); @@ -914,9 +914,9 @@ void DmChar00_Draw(Actor* thisx, PlayState* play2) { s32 pad; Gfx* gfx = GRAPH_ALLOC(play->state.gfxCtx, sizeof(Gfx) * 4); - if ((play->csCtx.state == 0) && ((play->sceneId != SCENE_OPENINGDAN) || (gSaveContext.sceneSetupIndex != 0) || - (play->roomCtx.curRoom.num != 0) || (play->csCtx.currentCsIndex != 1) || - (DMCHAR00_GET(&this->actor) != DMCHAR00_0))) { + if ((play->csCtx.state == 0) && + ((play->sceneId != SCENE_OPENINGDAN) || (gSaveContext.sceneLayer != 0) || (play->roomCtx.curRoom.num != 0) || + (play->csCtx.currentCsIndex != 1) || (DMCHAR00_GET(&this->actor) != DMCHAR00_0))) { return; } 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 900530f4d8..2f715afed4 100644 --- a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c +++ b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c @@ -73,7 +73,7 @@ void DmChar01_Init(Actor* thisx, PlayState* play) { break; } - if (gSaveContext.sceneSetupIndex == 0) { + if (gSaveContext.sceneLayer == 0) { play->envCtx.unk_1F = 5; play->envCtx.unk_20 = 5; } @@ -87,7 +87,7 @@ void DmChar01_Init(Actor* thisx, PlayState* play) { DynaPolyActor_LoadMesh(play, &this->dyna, &gWoodfallSceneryPoisonWaterDamageCol); this->unk_34D = true; - if (gSaveContext.sceneSetupIndex == 1) { + if (gSaveContext.sceneLayer == 1) { this->unk_34C = 1; this->actionFunc = func_80AA8C28; } else { @@ -97,7 +97,7 @@ void DmChar01_Init(Actor* thisx, PlayState* play) { break; case DMCHAR01_1: - if ((gSaveContext.save.weekEventReg[20] & 2) || (gSaveContext.sceneSetupIndex == 1)) { + if ((gSaveContext.save.weekEventReg[20] & 2) || (gSaveContext.sceneLayer == 1)) { this->unk_34C = 1; this->actionFunc = func_80AA8F1C; } else { @@ -411,7 +411,7 @@ void DmChar01_Draw(Actor* thisx, PlayState* play) { break; case 1: - if (gSaveContext.sceneSetupIndex == 1) { + if (gSaveContext.sceneLayer == 1) { AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&gWoodfallSceneryPurifiedWaterTexAnim)); Gfx_DrawDListOpa(play, gWoodfallSceneryFloorDL); Gfx_DrawDListXlu(play, gWoodfallSceneryPurifiedWaterDL); diff --git a/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c b/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c index c0cb242812..5b66138138 100644 --- a/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c +++ b/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c @@ -545,7 +545,7 @@ void func_80AAD4A8(DmChar05* this, PlayState* play) { } } else if (DMCHAR05_GET(&this->actor) == DMCHAR05_3) { if (play->sceneId == SCENE_OKUJOU) { - if (gSaveContext.sceneSetupIndex == 2) { + if (gSaveContext.sceneLayer == 2) { if (play->csCtx.currentCsIndex == 0) { func_80AAD3F8(this, play); } else if (play->csCtx.currentCsIndex == 1) { @@ -553,11 +553,11 @@ void func_80AAD4A8(DmChar05* this, PlayState* play) { } } } else if (play->sceneId == SCENE_SPOT00) { - if (gSaveContext.sceneSetupIndex == 9) { + if (gSaveContext.sceneLayer == 9) { if ((play->csCtx.currentCsIndex == 0) && (play->csCtx.frames == 255)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EVIL_POWER); } - } else if ((gSaveContext.sceneSetupIndex == 0xB) && (play->csCtx.frames == 115)) { + } else if ((gSaveContext.sceneLayer == 0xB) && (play->csCtx.frames == 115)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EVIL_POWER_PREDEMO); } } diff --git a/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c b/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c index 910293b77f..7a41429714 100644 --- a/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c +++ b/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c @@ -95,7 +95,7 @@ void DmOpstage_Update(Actor* thisx, PlayState* play) { DmOpstage* this = THIS; this->actionFunc(this, play); - if ((play->sceneId == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 0) && (play->csCtx.frames == 480)) { + if ((play->sceneId == SCENE_SPOT00) && (gSaveContext.sceneLayer == 0) && (play->csCtx.frames == 480)) { // This actor is responsible for playing the fairy sound during the exposition in the intro, // during the transition to Lost Woods, before Ocarina gets stolen. func_8019F128(NA_SE_EV_NAVY_FLY_REBIRTH); 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 9a0f95004c..2be56dda3c 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c @@ -919,23 +919,23 @@ void DmStk_PlaySfxForCutscenes(DmStk* this, PlayState* play) { if (play->csCtx.state != 0) { switch (play->sceneId) { case SCENE_LOST_WOODS: - if (gSaveContext.sceneSetupIndex == 1) { + if (gSaveContext.sceneLayer == 1) { DmStk_PlaySfxForIntroCutsceneFirstPart(this, play); - } else if (gSaveContext.sceneSetupIndex == 0) { + } else if (gSaveContext.sceneLayer == 0) { DmStk_PlaySfxForIntroCutsceneSecondPart(this, play); - } else if ((gSaveContext.sceneSetupIndex == 2) && (play->csCtx.currentCsIndex == 0)) { + } else if ((gSaveContext.sceneLayer == 2) && (play->csCtx.currentCsIndex == 0)) { DmStk_PlaySfxForObtainingMajorasMaskCutscene(this, play); } break; case SCENE_CLOCKTOWER: - if (gSaveContext.sceneSetupIndex == 1) { + if (gSaveContext.sceneLayer == 1) { DmStk_PlaySfxForTitleCutscene(this, play); } break; case SCENE_OPENINGDAN: - if (gSaveContext.sceneSetupIndex == 0) { + if (gSaveContext.sceneLayer == 0) { if (play->csCtx.currentCsIndex == 0) { DmStk_PlaySfxForCurseCutsceneFirstPart(this, play); } else if (play->csCtx.currentCsIndex == 1) { @@ -945,7 +945,7 @@ void DmStk_PlaySfxForCutscenes(DmStk* this, PlayState* play) { break; case SCENE_OKUJOU: - if (gSaveContext.sceneSetupIndex == 0) { + if (gSaveContext.sceneLayer == 0) { if (play->csCtx.currentCsIndex == 0) { DmStk_PlaySfxForClockTowerIntroCutsceneVersion1(this, play); } else if (play->csCtx.currentCsIndex == 1) { @@ -955,7 +955,7 @@ void DmStk_PlaySfxForCutscenes(DmStk* this, PlayState* play) { } else if (play->csCtx.currentCsIndex == 3) { DmStk_PlaySfxForCutsceneAfterPlayingOathToOrder(this, play); } - } else if (gSaveContext.sceneSetupIndex == 2) { + } else if (gSaveContext.sceneLayer == 2) { if (play->csCtx.currentCsIndex == 0) { DmStk_PlaySfxForMoonWarpCutsceneVersion1(this, play); } else if (play->csCtx.currentCsIndex == 1) { @@ -965,13 +965,13 @@ void DmStk_PlaySfxForCutscenes(DmStk* this, PlayState* play) { break; case SCENE_00KEIKOKU: - if (gSaveContext.sceneSetupIndex == 3) { + if (gSaveContext.sceneLayer == 3) { if (play->csCtx.currentCsIndex == 0) { DmStk_PlaySfxForShiveringInRainCutscene(this, play); } else if (play->csCtx.currentCsIndex == 2) { DmStk_PlaySfxForPlayingWithFairiesCutscene(this, play); } - } else if (gSaveContext.sceneSetupIndex == 7) { + } else if (gSaveContext.sceneLayer == 7) { if (play->csCtx.currentCsIndex == 0) { DmStk_PlaySfxForEndingCutsceneFirstPart(this, play); } else if (play->csCtx.currentCsIndex == 1) { @@ -1028,7 +1028,7 @@ void DmStk_Init(Actor* thisx, PlayState* play) { this->fogG = play->lightCtx.unk8; this->fogB = play->lightCtx.unk9; - if ((play->sceneId == SCENE_LOST_WOODS) && (gSaveContext.sceneSetupIndex == 1)) { + if ((play->sceneId == SCENE_LOST_WOODS) && (gSaveContext.sceneLayer == 1)) { this->alpha = 0; this->fogN = 0; this->fogF = 1000; @@ -1044,7 +1044,7 @@ void DmStk_Init(Actor* thisx, PlayState* play) { Collider_InitCylinder(play, &this->collider); if (gSaveContext.save.entrance == ENTRANCE(CLOCK_TOWER_ROOFTOP, 0)) { - if (gSaveContext.sceneSetupIndex == 0) { + if (gSaveContext.sceneLayer == 0) { if (gSaveContext.timerStates[TIMER_ID_MOON_CRASH] == TIMER_STATE_OFF) { // Starts a 5 minute (300 second) timer until the moon falls. Interface_StartTimer(TIMER_ID_MOON_CRASH, 300); @@ -1060,7 +1060,7 @@ void DmStk_Init(Actor* thisx, PlayState* play) { this->actionFunc = DmStk_ClockTower_StartIntroCutsceneVersion2; } - } else if (gSaveContext.sceneSetupIndex == 3) { + } else if (gSaveContext.sceneLayer == 3) { this->animIndex = SK_ANIM_FLOATING_ARMS_CROSSED; if (gSaveContext.timerStates[TIMER_ID_MOON_CRASH] == TIMER_STATE_OFF) { // This code is called when the Giants fail to stop the moon. @@ -1088,7 +1088,7 @@ void DmStk_Init(Actor* thisx, PlayState* play) { Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - } else if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 0)) { + } else if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 0)) { if (!(play->actorCtx.flags & ACTORCTX_FLAG_1)) { Actor_MarkForDeath(&this->actor); } @@ -1127,7 +1127,7 @@ void DmStk_Init(Actor* thisx, PlayState* play) { Actor_SetScale(&this->actor, 0.01f); - if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 3) && (play->csCtx.currentCsIndex > 0)) { + if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 3) && (play->csCtx.currentCsIndex > 0)) { play->envCtx.unk_17 = 15; play->envCtx.unk_18 = 15; } @@ -1684,7 +1684,7 @@ void DmStk_UpdateCutscenes(DmStk* this, PlayState* play) { this->handType = SK_HAND_TYPE_HOLDING_MAJORAS_MASK; } else if (((this->animIndex >= SK_ANIM_HUDDLE_WITH_FAIRIES) && (this->animIndex <= SK_ANIM_DRAW)) || ((this->animIndex >= SK_ANIM_PLAY_FLUTE) && (this->animIndex <= SK_ANIM_CARTWHEEL)) || - ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 7))) { + ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 7))) { this->maskType = SK_MASK_TYPE_NO_MASK; if ((this->animIndex == SK_ANIM_HOLD_UP_MASK_START) || (this->animIndex == SK_ANIM_HOLD_UP_MASK_LOOP)) { this->handType = SK_HAND_TYPE_HOLDING_MAJORAS_MASK_AND_FLUTE; @@ -1823,7 +1823,7 @@ void DmStk_Update(Actor* thisx, PlayState* play) { } } - if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 3) && (play->csCtx.currentCsIndex > 0)) { + if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 3) && (play->csCtx.currentCsIndex > 0)) { play->envCtx.unk_17 = 15; play->envCtx.unk_18 = 15; } @@ -1886,7 +1886,7 @@ void DmStk_PostLimbDraw2(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot break; case SK_MASK_TYPE_NORMAL: - if ((play->sceneId == SCENE_LOST_WOODS) && (gSaveContext.sceneSetupIndex == 1) && + if ((play->sceneId == SCENE_LOST_WOODS) && (gSaveContext.sceneLayer == 1) && (play->csCtx.frames < 1400)) { if (this->fogN == this->fogF) { this->fogF = this->fogN; @@ -1948,7 +1948,7 @@ void DmStk_PostLimbDraw2(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot case SK_HAND_TYPE_HOLDING_OCARINA: gSPDisplayList(POLY_OPA_DISP++, gSkullKidOcarinaHoldingRightHand); - if ((play->sceneId == SCENE_LOST_WOODS) && (gSaveContext.sceneSetupIndex == 1)) { + if ((play->sceneId == SCENE_LOST_WOODS) && (gSaveContext.sceneLayer == 1)) { gSPDisplayList(POLY_OPA_DISP++, gSkullKidOcarinaOfTimeDL); } break; @@ -1986,7 +1986,7 @@ void DmStk_PostLimbDraw2(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot break; case SK_HAND_TYPE_HOLDING_OCARINA: - if ((play->sceneId != SCENE_LOST_WOODS) || (gSaveContext.sceneSetupIndex != 1)) { + if ((play->sceneId != SCENE_LOST_WOODS) || (gSaveContext.sceneLayer != 1)) { gSPDisplayList(POLY_OPA_DISP++, gSkullKidOcarinaOfTimeDL); } gSPDisplayList(POLY_OPA_DISP++, gSkullKidTwoFingersExtendedLeftHand); diff --git a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c index 0086742925..50a027efa3 100644 --- a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c +++ b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c @@ -448,7 +448,7 @@ void func_80A52074(EnDnk* this, PlayState* play) { void func_80A52134(EnDnk* this, PlayState* play) { if ((play->csCtx.state != 0) && (ENDNK_GET_3C(&this->actor) == 4) && (play->sceneId == SCENE_SPOT00) && - (gSaveContext.sceneSetupIndex == 2)) { + (gSaveContext.sceneLayer == 2)) { func_80A52074(this, play); } } diff --git a/src/overlays/actors/ovl_En_Elf/z_en_elf.c b/src/overlays/actors/ovl_En_Elf/z_en_elf.c index f551373676..c9b3939804 100644 --- a/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ b/src/overlays/actors/ovl_En_Elf/z_en_elf.c @@ -903,14 +903,14 @@ void func_8088E850(EnElf* this, PlayState* play) { func_8088D660(this, &nextPos, 0.2f); } - if ((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 0) && + if ((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneLayer == 0) && (play->csCtx.currentCsIndex == 0) && ((play->csCtx.frames == 149) || (play->csCtx.frames == 381) || (play->csCtx.frames == 591))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); } - if ((play->sceneId == SCENE_SECOM) && (gSaveContext.sceneSetupIndex == 0) && - (play->csCtx.currentCsIndex == 4) && (play->csCtx.frames == 95)) { + if ((play->sceneId == SCENE_SECOM) && (gSaveContext.sceneLayer == 0) && (play->csCtx.currentCsIndex == 4) && + (play->csCtx.frames == 95)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); } } else { diff --git a/src/overlays/actors/ovl_En_Fall/z_en_fall.c b/src/overlays/actors/ovl_En_Fall/z_en_fall.c index 54ea52a459..d7d3e446e2 100644 --- a/src/overlays/actors/ovl_En_Fall/z_en_fall.c +++ b/src/overlays/actors/ovl_En_Fall/z_en_fall.c @@ -315,8 +315,7 @@ void EnFall_Setup(EnFall* this, PlayState* play) { void EnFall_CrashingMoon_HandleGiantsCutscene(EnFall* this, PlayState* play) { static s32 sGiantsCutsceneState = 0; - if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 1) && - (play->csCtx.currentCsIndex == 0)) { + if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 1) && (play->csCtx.currentCsIndex == 0)) { switch (sGiantsCutsceneState) { case 0: if (play->csCtx.state != 0) { @@ -409,7 +408,7 @@ void EnFall_StoppedClosedMouthMoon_PerformCutsceneActions(EnFall* this, PlayStat } } - if (play->sceneId == SCENE_OKUJOU && gSaveContext.sceneSetupIndex == 2) { + if ((play->sceneId == SCENE_OKUJOU) && (gSaveContext.sceneLayer == 2)) { switch (play->csCtx.currentCsIndex) { case 0: switch (play->csCtx.frames) { @@ -575,7 +574,7 @@ void EnFall_Fireball_SetPerVertexAlpha(f32 fireballAlpha) { void EnFall_Fireball_Update(Actor* thisx, PlayState* play) { EnFall* this = THIS; - if (play->sceneId == SCENE_00KEIKOKU && gSaveContext.sceneSetupIndex == 0 && play->csCtx.currentCsIndex == 2) { + if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 0) && (play->csCtx.currentCsIndex == 2)) { play->skyboxCtx.rotY -= 0.05f; } diff --git a/src/overlays/actors/ovl_En_Giant/z_en_giant.c b/src/overlays/actors/ovl_En_Giant/z_en_giant.c index 7021b0e0cf..7d2819ff9c 100644 --- a/src/overlays/actors/ovl_En_Giant/z_en_giant.c +++ b/src/overlays/actors/ovl_En_Giant/z_en_giant.c @@ -220,7 +220,7 @@ void EnGiant_Init(Actor* thisx, PlayState* play) { this->sfxId = 0xFFFF; if (GIANT_TYPE_IS_CHAMBER_OR_ENDING(type)) { - switch (gSaveContext.sceneSetupIndex) { + switch (gSaveContext.sceneLayer) { case 0: case 10: this->sfxId = NA_SE_EV_KYOJIN_GRATITUDE2 - SFX_FLAG; 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 b10f78ac30..c85815ee74 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -762,7 +762,7 @@ s32 func_8094EFC4(EnGm* this, PlayState* play) { if (play->csCtx.state != 0) { if (this->unk_3F8 == 0) { - if ((play->sceneId == SCENE_MILK_BAR) && (gSaveContext.sceneSetupIndex == 2)) { + if ((play->sceneId == SCENE_MILK_BAR) && (gSaveContext.sceneLayer == 2)) { func_8094E054(this, play, 0); this->unk_258 = 255; } diff --git a/src/overlays/actors/ovl_En_Go/z_en_go.c b/src/overlays/actors/ovl_En_Go/z_en_go.c index 2b855edab2..8692fbba1c 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -539,7 +539,7 @@ s32 func_80A1222C(EnGo* this, PlayState* play) { (play->msgCtx.lastPlayedSong == OCARINA_SONG_GORON_LULLABY) && (this->unk_3EC == 0) && (this->actor.xzDistToPlayer < 400.0f)) || (!(gSaveContext.save.weekEventReg[22] & 4) && (play->sceneId == SCENE_16GORON_HOUSE) && - (gSaveContext.sceneSetupIndex == 0) && (this->unk_3EC == 0) && (play->csCtx.currentCsIndex == 1))) { + (gSaveContext.sceneLayer == 0) && (this->unk_3EC == 0) && (play->csCtx.currentCsIndex == 1))) { ret = true; } return ret; @@ -711,7 +711,7 @@ s32 func_80A12868(EnGo* this, PlayState* play) { s32 func_80A12954(EnGo* this, PlayState* play) { if ((ENGO_GET_F(&this->actor) == ENGO_F_4) && (play->csCtx.state != 0) && (this->actor.draw != NULL) && - (play->sceneId == SCENE_10YUKIYAMANOMURA2) && (gSaveContext.sceneSetupIndex == 1) && + (play->sceneId == SCENE_10YUKIYAMANOMURA2) && (gSaveContext.sceneLayer == 1) && (play->csCtx.currentCsIndex == 0)) { if (this->unk_3F0 == 0) { this->actor.flags &= ~ACTOR_FLAG_1; @@ -1412,7 +1412,7 @@ void func_80A144F4(EnGo* this, PlayState* play) { void func_80A145AC(EnGo* this, PlayState* play) { if ((ENGO_GET_70(&this->actor) == ENGO_70_1) && - (((play->sceneId == SCENE_10YUKIYAMANOMURA2) && (gSaveContext.sceneSetupIndex == 1) && + (((play->sceneId == SCENE_10YUKIYAMANOMURA2) && (gSaveContext.sceneLayer == 1) && (play->csCtx.currentCsIndex == 0)) || !(gSaveContext.save.weekEventReg[21] & 8))) { this->actor.child = func_80A13400(this, play); diff --git a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c index cf32db0bc0..f9085e8253 100644 --- a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c +++ b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c @@ -323,15 +323,15 @@ void func_80B23910(EnHanabi* this, PlayState* play) { } void func_80B23934(EnHanabi* this, PlayState* play) { - if ((gSaveContext.save.entrance == ENTRANCE(TERMINA_FIELD, 1)) && (gSaveContext.sceneSetupIndex == 7)) { + if ((gSaveContext.save.entrance == ENTRANCE(TERMINA_FIELD, 1)) && (gSaveContext.sceneLayer == 7)) { if (play->csCtx.frames > 1650) { func_80B236C8(this, play); func_800B8FE8(&this->actor, NA_SE_EV_FIREWORKS_LAUNCH - SFX_FLAG); } } - if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 7) && - (play->csCtx.currentCsIndex == 0) && (play->csCtx.frames == 610)) { + if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 7) && (play->csCtx.currentCsIndex == 0) && + (play->csCtx.frames == 610)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_KYOJIN_GROAN); } } 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 83e0935f5c..07b2564873 100644 --- a/src/overlays/actors/ovl_En_Hg/z_en_hg.c +++ b/src/overlays/actors/ovl_En_Hg/z_en_hg.c @@ -158,8 +158,8 @@ void func_80BCF398(EnHg* this, PlayState* play) { !Cutscene_CheckActorAction(play, 0x1E3)) { func_80BCF468(this); } - if ((gSaveContext.sceneSetupIndex == 0 && play->csCtx.currentCsIndex == 0) && - (play->csCtx.frames == 20 || play->csCtx.frames == 60)) { + if ((gSaveContext.sceneLayer == 0) && (play->csCtx.currentCsIndex == 0) && + ((play->csCtx.frames == 20) || (play->csCtx.frames == 60))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_HALF_REDEAD_SURPRISE); } } 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 83fbe5988c..53e4e91c34 100644 --- a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c +++ b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c @@ -287,7 +287,7 @@ s32 func_80BD0898(EnHgo* this, PlayState* play) { case 1: if ((Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) && (this->unk_312 == 0)) { this->unk_312 = 1; - if ((gSaveContext.sceneSetupIndex == 0) && + if ((gSaveContext.sceneLayer == 0) && ((play->csCtx.currentCsIndex == 2) || (play->csCtx.currentCsIndex == 4))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_GBVO02); } diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.c b/src/overlays/actors/ovl_En_Horse/z_en_horse.c index 4388c7c739..a9b233aa53 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -793,7 +793,7 @@ void EnHorse_Init(Actor* thisx, PlayState* play2) { } if (((play->sceneId == SCENE_KOEPONARACE) && (GET_RACE_FLAGS == 1)) || - ((gSaveContext.save.entrance == ENTRANCE(ROMANI_RANCH, 0)) && Cutscene_GetSceneSetupIndex(play))) { + ((gSaveContext.save.entrance == ENTRANCE(ROMANI_RANCH, 0)) && Cutscene_GetSceneLayer(play))) { this->stateFlags |= ENHORSE_FLAG_25; } @@ -1569,7 +1569,7 @@ void EnHorse_Stopping(EnHorse* this, PlayState* play) { if ((this->stateFlags & ENHORSE_STOPPING_NEIGH_SOUND) && (this->skin.skelAnime.curFrame > 29.0f)) { this->actor.speedXZ = 0.0f; if ((Rand_ZeroOne() > 0.5f) && - ((gSaveContext.save.entrance != ENTRANCE(ROMANI_RANCH, 0)) || !Cutscene_GetSceneSetupIndex(play))) { + ((gSaveContext.save.entrance != ENTRANCE(ROMANI_RANCH, 0)) || !Cutscene_GetSceneLayer(play))) { if (this->stateFlags & ENHORSE_DRAW) { if (this->type == HORSE_TYPE_2) { Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); diff --git a/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.c b/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.c index 398bac6ca8..d5b23bdaea 100644 --- a/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.c +++ b/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.c @@ -158,7 +158,7 @@ void EnHorseLinkChild_Init(Actor* thisx, PlayState* play) { this->unk_1E8 = 0; this->unk_1E4 = 0; - if (gSaveContext.sceneSetupIndex >= 4) { + if (gSaveContext.sceneLayer >= 4) { func_808DEFE8(this); } else { func_808DEFE8(this); diff --git a/src/overlays/actors/ovl_En_Jg/z_en_jg.c b/src/overlays/actors/ovl_En_Jg/z_en_jg.c index b7ad5c9ddc..60ebb2474b 100644 --- a/src/overlays/actors/ovl_En_Jg/z_en_jg.c +++ b/src/overlays/actors/ovl_En_Jg/z_en_jg.c @@ -948,8 +948,7 @@ void EnJg_Init(Actor* thisx, PlayState* play) { Actor_SetScale(&this->actor, 0.01f); if (!EN_JG_IS_IN_GORON_SHRINE(thisx)) { - if ((play->sceneId == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 7) && - (play->csCtx.currentCsIndex == 0)) { + if ((play->sceneId == SCENE_SPOT00) && (gSaveContext.sceneLayer == 7) && (play->csCtx.currentCsIndex == 0)) { // This is the elder that appears in the cutscene for learning the full Goron Lullaby. this->animIndex = EN_JG_ANIM_IDLE; this->action = EN_JG_ACTION_LULLABY_INTRO_CS; 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 47f0997eb2..0860857c86 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c @@ -207,7 +207,7 @@ void EnMa4_Init(Actor* thisx, PlayState* play) { this->hasBow = false; } - if (Cutscene_GetSceneSetupIndex(play) != 0) { // if (sceneSetupIndex != 0) + if (Cutscene_GetSceneLayer(play) != 0) { EnMa4_ChangeAnim(this, 0); this->state = MA4_STATE_HORSEBACKGAME; EnMa4_InitHorsebackGame(this, play); diff --git a/src/overlays/actors/ovl_En_Mag/z_en_mag.c b/src/overlays/actors/ovl_En_Mag/z_en_mag.c index da72fc3088..b7199cb1db 100644 --- a/src/overlays/actors/ovl_En_Mag/z_en_mag.c +++ b/src/overlays/actors/ovl_En_Mag/z_en_mag.c @@ -393,7 +393,7 @@ void EnMag_Update(Actor* thisx, PlayState* play) { play->transitionType = TRANS_TYPE_02; play->nextEntrance = ENTRANCE(CUTSCENE, 0); gSaveContext.save.cutscene = 0; - gSaveContext.sceneSetupIndex = 0; + gSaveContext.sceneLayer = 0; } this->unk11F54 = 15; this->unk11F56 = 25; diff --git a/src/overlays/actors/ovl_En_Osn/z_en_osn.c b/src/overlays/actors/ovl_En_Osn/z_en_osn.c index fd3146032c..1f9cb3da82 100644 --- a/src/overlays/actors/ovl_En_Osn/z_en_osn.c +++ b/src/overlays/actors/ovl_En_Osn/z_en_osn.c @@ -731,7 +731,7 @@ void func_80AD16A8(EnOsn* this, PlayState* play) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->unk_1EC); } - if ((this->unk_1EC == 5) && (play->sceneId == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 0xB) && + if ((this->unk_1EC == 5) && (play->sceneId == SCENE_SPOT00) && (gSaveContext.sceneLayer == 0xB) && (play->csCtx.frames == 400)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_OMVO00); } 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 75bcbc8e80..1f5aebe64b 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -1017,7 +1017,7 @@ s32 func_80AF86F0(EnPm* this, PlayState* play) { s32 func_80AF87C4(EnPm* this, PlayState* play) { s32 ret = false; - if ((play->csCtx.state != 0) && (play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 9) && + if ((play->csCtx.state != 0) && (play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 9) && (play->curSpawn == 1)) { if (!this->unk_380) { func_80AF7E98(this, 0); diff --git a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c index 088e06149b..bfb7014844 100644 --- a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c +++ b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c @@ -296,7 +296,7 @@ void EnRailSkb_Init(Actor* thisx, PlayState* play) { this->unk_3F8 = 0; } - if ((play->sceneId == SCENE_BOTI) && (gSaveContext.sceneSetupIndex == 1) && (play->csCtx.currentCsIndex == 0)) { + if ((play->sceneId == SCENE_BOTI) && (gSaveContext.sceneLayer == 1) && (play->csCtx.currentCsIndex == 0)) { this->actor.flags |= ACTOR_FLAG_100000; } diff --git a/src/overlays/actors/ovl_En_Skb/z_en_skb.c b/src/overlays/actors/ovl_En_Skb/z_en_skb.c index ea4f7be32b..d0c02e4fa9 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.c +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.c @@ -230,7 +230,7 @@ void EnSkb_Init(Actor* thisx, PlayState* play) { this->unk_3D6 = ENSKB_GET_F0(&this->actor); this->actor.floorHeight = this->actor.world.pos.y; - if ((play->sceneId == SCENE_BOTI) && (gSaveContext.sceneSetupIndex == 1) && (play->csCtx.currentCsIndex == 0)) { + if ((play->sceneId == SCENE_BOTI) && (gSaveContext.sceneLayer == 1) && (play->csCtx.currentCsIndex == 0)) { this->actor.flags |= ACTOR_FLAG_100000; } diff --git a/src/overlays/actors/ovl_En_Zog/z_en_zog.c b/src/overlays/actors/ovl_En_Zog/z_en_zog.c index bda36c0b6b..0ea1d448f5 100644 --- a/src/overlays/actors/ovl_En_Zog/z_en_zog.c +++ b/src/overlays/actors/ovl_En_Zog/z_en_zog.c @@ -206,8 +206,7 @@ void EnZog_Init(Actor* thisx, PlayState* play) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; if ((ENZOG_GET_F(&this->actor) != ENZOG_F_2) && (INV_CONTENT(ITEM_MASK_ZORA) == ITEM_MASK_ZORA) && - ((play->csCtx.currentCsIndex != 2) || (gSaveContext.sceneSetupIndex != 0) || - (play->sceneId != SCENE_30GYOSON))) { + ((play->csCtx.currentCsIndex != 2) || (gSaveContext.sceneLayer != 0) || (play->sceneId != SCENE_30GYOSON))) { Actor_MarkForDeath(&this->actor); return; } diff --git a/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c b/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c index 7758fc5bc9..33de741002 100644 --- a/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c +++ b/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c @@ -36,7 +36,7 @@ void ObjJgGakki_Init(Actor* thisx, PlayState* play2) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); SkelAnime_Init(play, &this->skelAnime, &gGoronElderDrumSkel, NULL, NULL, NULL, 0); - if (((play->sceneId == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 7)) && (play->csCtx.currentCsIndex == 0)) { + if (((play->sceneId == SCENE_SPOT00) && (gSaveContext.sceneLayer == 7)) && (play->csCtx.currentCsIndex == 0)) { Animation_Change(&this->skelAnime, &gGoronElderDrumTakeOutAnim, 1.0f, frameCount, frameCount, ANIMMODE_ONCE, 0.0f); } else if ((play->sceneId == SCENE_17SETUGEN) || (play->sceneId == SCENE_10YUKIYAMANOMURA)) { 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 2c8e42c7d0..6d49230430 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,8 +195,7 @@ void ObjTokeiStep_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 0); - if ((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && - (play->csCtx.currentCsIndex == 0)) { + if ((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneLayer == 2) && (play->csCtx.currentCsIndex == 0)) { DynaPolyActor_LoadMesh(play, &this->dyna, &gClocktowerPanelCol); ObjTokeiStep_InitSteps(this); ObjTokeiStep_SetupBeginOpen(this); diff --git a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c index 34d43d354b..421f5dcf0b 100644 --- a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c +++ b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c @@ -121,10 +121,8 @@ void ObjTokeidai_ExteriorGear_Init(ObjTokeidai* this, PlayState* play) { this->opaDList = gClockTowerExteriorGearDL; ObjTokeidai_SetupClockOrExteriorGear(this); - if (((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && - (play->csCtx.currentCsIndex == 0)) || - ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && - (play->csCtx.currentCsIndex == 0))) { + if (((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneLayer == 2) && (play->csCtx.currentCsIndex == 0)) || + ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 2) && (play->csCtx.currentCsIndex == 0))) { ObjTokeidai_SetupTowerOpening(this); } else if ((CURRENT_DAY == 3 && gSaveContext.save.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) { this->actionFunc = ObjTokeidai_ExteriorGear_OpenedIdle; @@ -140,10 +138,8 @@ void ObjTokeidai_TowerClock_Init(ObjTokeidai* this, PlayState* play) { this->actor.draw = ObjTokeidai_Clock_Draw; ObjTokeidai_Clock_Init(this); - if (((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && - (play->csCtx.currentCsIndex == 0)) || - ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && - (play->csCtx.currentCsIndex == 0))) { + if (((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneLayer == 2) && (play->csCtx.currentCsIndex == 0)) || + ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 2) && (play->csCtx.currentCsIndex == 0))) { ObjTokeidai_SetupTowerOpening(this); } else if ((CURRENT_DAY == 3 && gSaveContext.save.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) { this->actor.world.pos.y += (this->actor.scale.y * 5191.0f) - 50.0f; @@ -175,10 +171,8 @@ void ObjTokeidai_Counterweight_Init(ObjTokeidai* this, PlayState* play) { this->spotlightIntensity = 0; } - if (((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && - (play->csCtx.currentCsIndex == 0)) || - ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && - (play->csCtx.currentCsIndex == 0))) { + if (((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneLayer == 2) && (play->csCtx.currentCsIndex == 0)) || + ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 2) && (play->csCtx.currentCsIndex == 0))) { this->spotlightIntensity = 0; ObjTokeidai_SetupTowerOpening(this); @@ -448,9 +442,9 @@ void ObjTokeidai_TowerOpening_EndCutscene(ObjTokeidai* this, PlayState* play) { if (Cutscene_CheckActorAction(play, 132) != 0 && play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 132)]->action == 5) { gSaveContext.save.weekEventReg[8] |= 0x40; - if (((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && + if (((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneLayer == 2) && (play->csCtx.currentCsIndex == 0)) || - ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && + ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 2) && (play->csCtx.currentCsIndex == 0))) { Audio_SetCutsceneFlag(false); gSaveContext.save.cutscene = 0; diff --git a/src/overlays/gamestates/ovl_opening/z_opening.c b/src/overlays/gamestates/ovl_opening/z_opening.c index b7e5ec3788..42336b9bca 100644 --- a/src/overlays/gamestates/ovl_opening/z_opening.c +++ b/src/overlays/gamestates/ovl_opening/z_opening.c @@ -17,7 +17,7 @@ void TitleSetup_SetupTitleScreen(TitleSetupState* this) { gSaveContext.save.entrance = sOpeningEntrances[D_801BB12C]; gSaveContext.nextCutsceneIndex = gSaveContext.save.cutscene = sOpeningCutscenes[D_801BB12C]; - gSaveContext.sceneSetupIndex = 0; + gSaveContext.sceneLayer = 0; gSaveContext.save.time = CLOCK_TIME(8, 0); gSaveContext.save.day = 1; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 3b949a49c9..b71390a057 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -1578,7 +1578,7 @@ 0x800EDF24:("Cutscene_ActorTranslateAndYaw",), 0x800EDF78:("Cutscene_ActorTranslateAndYawSmooth",), 0x800EE0CC:("Cutscene_ActorTranslateXZAndYawSmooth",), - 0x800EE1D8:("Cutscene_GetSceneSetupIndex",), + 0x800EE1D8:("Cutscene_GetSceneLayer",), 0x800EE200:("Cutscene_GetActorActionIndex",), 0x800EE29C:("Cutscene_CheckActorAction",), 0x800EE2F4:("Cutscene_IsPlaying",), diff --git a/tools/namefixer.py b/tools/namefixer.py index b432879716..a5d13493b2 100755 --- a/tools/namefixer.py +++ b/tools/namefixer.py @@ -533,10 +533,11 @@ wordReplace = { "func_800EDF24": "Cutscene_ActorTranslateAndYaw", "func_800EDF78": "Cutscene_ActorTranslateAndYawSmooth", "func_800EE0CC": "Cutscene_ActorTranslateXZAndYawSmooth", - "func_800EE1D8": "Cutscene_GetSceneSetupIndex", + "func_800EE1D8": "Cutscene_GetSceneLayer", "func_800EE200": "Cutscene_GetActorActionIndex", "func_800EE29C": "Cutscene_CheckActorAction", "func_800EE2F4": "Cutscene_IsPlaying", + "Cutscene_GetSceneSetupIndex": "Cutscene_GetSceneLayer", "func_801343C0": "SkelAnime_DrawTransformFlexOpa", "func_80134148": "SkelAnime_DrawTransformFlexLimbOpa", "func_80114E90": "Inventory_HasEmptyBottle", @@ -704,6 +705,7 @@ wordReplace = { "gSaveContext.unk_3F30": "gSaveContext.magicFillTarget", "gSaveContext.unk_3F2C": "gSaveContext.magicFlag", "gSaveContext.save.entranceIndex": "gSaveContext.save.entrance", + "gSaveContext.sceneSetupIndex": "gSaveContext.sceneLayer", "gSaveContext.seqIndex": "gSaveContext.seqId", "gSaveContext.nightSeqIndex": "gSaveContext.ambienceId", diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 968fa65d37..33b82cef00 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -1092,7 +1092,7 @@ asm/non_matchings/code/z_demo/Cutscene_ActorTranslate.s,Cutscene_ActorTranslate, asm/non_matchings/code/z_demo/Cutscene_ActorTranslateAndYaw.s,Cutscene_ActorTranslateAndYaw,0x800EDF24,0x15 asm/non_matchings/code/z_demo/Cutscene_ActorTranslateAndYawSmooth.s,Cutscene_ActorTranslateAndYawSmooth,0x800EDF78,0x55 asm/non_matchings/code/z_demo/Cutscene_ActorTranslateXZAndYawSmooth.s,Cutscene_ActorTranslateXZAndYawSmooth,0x800EE0CC,0x43 -asm/non_matchings/code/z_demo/Cutscene_GetSceneSetupIndex.s,Cutscene_GetSceneSetupIndex,0x800EE1D8,0xA +asm/non_matchings/code/z_demo/Cutscene_GetSceneLayer.s,Cutscene_GetSceneLayer,0x800EE1D8,0xA asm/non_matchings/code/z_demo/Cutscene_GetActorActionIndex.s,Cutscene_GetActorActionIndex,0x800EE200,0x27 asm/non_matchings/code/z_demo/Cutscene_CheckActorAction.s,Cutscene_CheckActorAction,0x800EE29C,0x16 asm/non_matchings/code/z_demo/Cutscene_IsPlaying.s,Cutscene_IsPlaying,0x800EE2F4,0xB From bbc8aec36a6359025892dc2c4d477c5aa6554c3d Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Fri, 30 Sep 2022 19:55:05 -0700 Subject: [PATCH 09/25] (Mostly) document EnSyatekiDekunuts (Shooting Gallery Deku Scrub) (#1095) * (Mostly) document EnSyatekiDekunuts (Shooting Gallery Deku Scrub) * Respond to Elliptic's review --- .../ovl_En_Syateki_Crow/z_en_syateki_crow.c | 10 +- .../ovl_En_Syateki_Crow/z_en_syateki_crow.h | 4 +- .../z_en_syateki_dekunuts.c | 358 ++++++++++-------- .../z_en_syateki_dekunuts.h | 33 +- .../ovl_En_Syateki_Man/z_en_syateki_man.c | 27 +- .../ovl_En_Syateki_Wf/z_en_syateki_wf.c | 6 +- .../ovl_En_Syateki_Wf/z_en_syateki_wf.h | 4 +- tools/disasm/functions.txt | 34 +- tools/disasm/variables.txt | 18 +- 9 files changed, 280 insertions(+), 214 deletions(-) diff --git a/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c b/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c index 6b05f739d1..f3bce9c4f6 100644 --- a/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c +++ b/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c @@ -83,7 +83,7 @@ void EnSyatekiCrow_Init(Actor* thisx, PlayState* play2) { path = &play->setupPathList[path->unk1]; } - for (i = 0; i < EN_SYATEKI_CROW_GET_NUMBER(&this->actor); i++) { + for (i = 0; i < EN_SYATEKI_CROW_GET_INDEX(&this->actor); i++) { path = &play->setupPathList[path->unk1]; } @@ -95,7 +95,7 @@ void EnSyatekiCrow_Init(Actor* thisx, PlayState* play2) { this->collider.elements[0].dim.worldSphere.radius = sJntSphInit.elements[0].dim.modelSphere.radius; ActorShape_Init(&this->actor.shape, 2000.0f, ActorShadow_DrawCircle, 20.0f); - if ((path == NULL) || (EN_SYATEKI_CROW_GET_NUMBER(&this->actor) >= 0x80)) { + if ((path == NULL) || (EN_SYATEKI_CROW_GET_INDEX(&this->actor) >= 0x80)) { Actor_MarkForDeath(&this->actor); return; } @@ -133,7 +133,7 @@ void EnSyatekiCrow_WaitForSpawn(EnSyatekiCrow* this, PlayState* play) { EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; if ((syatekiMan->shootingGameState == SG_GAME_STATE_RUNNING) && (this->isActive == true) && - (syatekiMan->guayFlags & (1 << EN_SYATEKI_CROW_GET_NUMBER(&this->actor)))) { + (syatekiMan->guayFlags & (1 << EN_SYATEKI_CROW_GET_INDEX(&this->actor)))) { EnSyatekiCrow_SetupWaitToMove(this); } else if (syatekiMan->shootingGameState != SG_GAME_STATE_RUNNING) { this->isActive = true; @@ -202,7 +202,7 @@ void EnSyatekiCrow_Fly(EnSyatekiCrow* this, PlayState* play) { this->currentPointIndex++; } else { this->isActive = false; - syatekiMan->guayFlags &= ~(1 << EN_SYATEKI_CROW_GET_NUMBER(&this->actor)); + syatekiMan->guayFlags &= ~(1 << EN_SYATEKI_CROW_GET_INDEX(&this->actor)); EnSyatekiCrow_SetupWaitForSpawn(this); } @@ -241,7 +241,7 @@ void EnSyatekiCrow_Dead(EnSyatekiCrow* this, PlayState* play) { if (this->deathTimer > 20) { func_800B3030(play, &this->actor.world.pos, &sZeroVec, &sZeroVec, this->actor.scale.x * 10000.0f, 0, 0); syatekiMan->guayHitCounter++; - syatekiMan->guayFlags &= ~(1 << EN_SYATEKI_CROW_GET_NUMBER(&this->actor)); + syatekiMan->guayFlags &= ~(1 << EN_SYATEKI_CROW_GET_INDEX(&this->actor)); EnSyatekiCrow_SetupWaitForSpawn(this); } diff --git a/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.h b/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.h index e70a3dd216..f7a8762853 100644 --- a/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.h +++ b/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.h @@ -6,8 +6,8 @@ #define EN_SYATEKI_CROW_GET_WAIT_MOD(thisx) ((thisx)->params & 0xF) #define EN_SYATEKI_CROW_GET_SPEED_MOD(thisx) (((thisx)->params & 0xF0) >> 4) -#define EN_SYATEKI_CROW_GET_NUMBER(thisx) (((thisx)->params & 0xFF00) >> 8) -#define EN_SYATEKI_CROW_PARAMS(number, speedMod, waitMod) (((number << 8) & 0xFF00) | ((speedMod << 4) & 0xF0) | (waitMod & 0xF)) +#define EN_SYATEKI_CROW_GET_INDEX(thisx) (((thisx)->params & 0xFF00) >> 8) +#define EN_SYATEKI_CROW_PARAMS(index, speedMod, waitMod) (((index << 8) & 0xFF00) | ((speedMod << 4) & 0xF0) | (waitMod & 0xF)) struct EnSyatekiCrow; diff --git a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c index 5a25038083..5e6f5925a9 100644 --- a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c +++ b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c @@ -17,22 +17,27 @@ void EnSyatekiDekunuts_Destroy(Actor* thisx, PlayState* play); void EnSyatekiDekunuts_Update(Actor* thisx, PlayState* play); void EnSyatekiDekunuts_Draw(Actor* thisx, PlayState* play); -void func_80A2BE54(EnSyatekiDekunuts* this); -void func_80A2BF18(EnSyatekiDekunuts* this, PlayState* play); -void func_80A2BFC4(EnSyatekiDekunuts* this); -void func_80A2C0F8(EnSyatekiDekunuts* this, PlayState* play); -void func_80A2C150(EnSyatekiDekunuts* this); -void func_80A2C168(EnSyatekiDekunuts* this, PlayState* play); -void func_80A2C1AC(EnSyatekiDekunuts* this); -void func_80A2C208(EnSyatekiDekunuts* this, PlayState* play); -void func_80A2C27C(EnSyatekiDekunuts* this); -void func_80A2C2E0(EnSyatekiDekunuts* this, PlayState* play); -void func_80A2C33C(EnSyatekiDekunuts* this, PlayState* play); -void func_80A2C3AC(EnSyatekiDekunuts* this); -void func_80A2C3F0(EnSyatekiDekunuts* this, PlayState* play); -void func_80A2C478(EnSyatekiDekunuts* this); -void func_80A2C48C(EnSyatekiDekunuts* this, PlayState* play); -void func_80A2C5DC(EnSyatekiDekunuts* this, PlayState* play); +void EnSyatekiDekunuts_SetupWaitForSpawn(EnSyatekiDekunuts* this); +void EnSyatekiDekunuts_WaitForSpawn(EnSyatekiDekunuts* this, PlayState* play); +void EnSyatekiDekunuts_SetupSpawn(EnSyatekiDekunuts* this); +void EnSyatekiDekunuts_Spawn(EnSyatekiDekunuts* this, PlayState* play); +void EnSyatekiDekunuts_SetupWaitToEmerge(EnSyatekiDekunuts* this); +void EnSyatekiDekunuts_WaitToEmerge(EnSyatekiDekunuts* this, PlayState* play); +void EnSyatekiDekunuts_SetupEmerge(EnSyatekiDekunuts* this); +void EnSyatekiDekunuts_Emerge(EnSyatekiDekunuts* this, PlayState* play); +void EnSyatekiDekunuts_SetupLookAround(EnSyatekiDekunuts* this); +void EnSyatekiDekunuts_LookAround(EnSyatekiDekunuts* this, PlayState* play); +void EnSyatekiDekunuts_BonusLookAround(EnSyatekiDekunuts* this, PlayState* play); +void EnSyatekiDekunuts_SetupBurrow(EnSyatekiDekunuts* this); +void EnSyatekiDekunuts_Burrow(EnSyatekiDekunuts* this, PlayState* play); +void EnSyatekiDekunuts_SetupGameEnd(EnSyatekiDekunuts* this); +void EnSyatekiDekunuts_GameEnd(EnSyatekiDekunuts* this, PlayState* play); +void EnSyatekiDekunuts_Dead(EnSyatekiDekunuts* this, PlayState* play); + +typedef enum { + /* 0 */ EN_SYATEKI_DEKUNUTS_HEADDRESS_TYPE_NORMAL, + /* 1 */ EN_SYATEKI_DEKUNUTS_HEADDRESS_TYPE_FLIPPED_UP, +} EnSyatekiDekunutsHeaddressType; const ActorInit En_Syateki_Dekunuts_InitVars = { ACTOR_EN_SYATEKI_DEKUNUTS, @@ -66,7 +71,17 @@ static ColliderCylinderInit sCylinderInit = { { 48, 80, 0, { 0, 0, 0 } }, }; -static Cylinder16 D_80A2CADC[] = { { 24, 40, 0, { 0, 0, 0 } } }; +static Cylinder16 sBonusDekuScrubColliderDimensions[] = { { 24, 40, 0, { 0, 0, 0 } } }; + +typedef enum { + /* 0 */ EN_SYATEKI_DEKUNUTS_ANIM_UP, + /* 1 */ EN_SYATEKI_DEKUNUTS_ANIM_BURROW, + /* 2 */ EN_SYATEKI_DEKUNUTS_ANIM_IDLE, // unused + /* 3 */ EN_SYATEKI_DEKUNUTS_ANIM_LOOK_AROUND, + /* 4 */ EN_SYATEKI_DEKUNUTS_ANIM_DAMAGE, + /* 5 */ EN_SYATEKI_DEKUNUTS_ANIM_DIE, + /* 6 */ EN_SYATEKI_DEKUNUTS_ANIM_UNBURROW, // unused +} EnSyatekiDekunutsAnimation; static AnimationInfo sAnimationInfo[] = { { &gDekuScrubUpAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, @@ -85,10 +100,10 @@ static InitChainEntry sInitChain[] = { }; void EnSyatekiDekunuts_Init(Actor* thisx, PlayState* play2) { - static s32 D_80A2CB9C = 1; + static s32 sDrawFlowers = true; // This makes it so only one EnSyatekiDekunuts draws all the flowers. EnSyatekiDekunuts* this = THIS; PlayState* play = play2; - s32 phi_v0; + s32 unkPathComparison; Path* path; EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; s32 i; @@ -97,16 +112,16 @@ void EnSyatekiDekunuts_Init(Actor* thisx, PlayState* play2) { Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); - if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) == 1) { + if (EN_SYATEKI_DEKUNUTS_GET_TYPE(&this->actor) == EN_SYATEKI_DEKUNUTS_TYPE_BONUS) { Actor_SetScale(&this->actor, 0.01f); - this->collider.dim = D_80A2CADC[0]; - phi_v0 = 3; + this->collider.dim = sBonusDekuScrubColliderDimensions[0]; + unkPathComparison = 3; } else { Actor_SetScale(&this->actor, 0.02f); - phi_v0 = 1; + unkPathComparison = 1; } - while (path->unk2 != phi_v0) { + while (path->unk2 != unkPathComparison) { path = &play->setupPathList[path->unk1]; } @@ -114,29 +129,30 @@ void EnSyatekiDekunuts_Init(Actor* thisx, PlayState* play2) { path = &play->setupPathList[path->unk1]; } - if (D_80A2CB9C == 1) { - this->unk_1EC = 1; - D_80A2CB9C = 0; + if (sDrawFlowers == true) { + this->shouldDrawFlowers = true; + sDrawFlowers = false; } else { - this->unk_1EC = 0; + this->shouldDrawFlowers = false; } Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); SkelAnime_Init(play, &this->skelAnime, &gDekuScrubSkel, &gDekuScrubBurrowAnim, this->jointTable, this->morphTable, DEKU_SCRUB_LIMB_MAX); + if (path == NULL) { Actor_MarkForDeath(&this->actor); return; } - this->unk_1E4 = Lib_SegmentedToVirtual(path->points); - this->unk_1E8 = EN_SYATEKI_DEKUNUTS_GET_NUMBER(&this->actor); - this->unk_1EA = path->count; - this->unk_1D8 = 0; + this->flowerPos = Lib_SegmentedToVirtual(path->points); + this->index = EN_SYATEKI_DEKUNUTS_GET_INDEX(&this->actor); + this->flowerCount = path->count; + this->timer = 0; this->unk_1DC = 0; - this->unk_1DA = 0; - func_80A2BE54(this); + this->waitTimer = 0; + EnSyatekiDekunuts_SetupWaitForSpawn(this); } void EnSyatekiDekunuts_Destroy(Actor* thisx, PlayState* play) { @@ -145,7 +161,7 @@ void EnSyatekiDekunuts_Destroy(Actor* thisx, PlayState* play) { Collider_DestroyCylinder(play, &this->collider); } -void func_80A2BE54(EnSyatekiDekunuts* this) { +void EnSyatekiDekunuts_SetupWaitForSpawn(EnSyatekiDekunuts* this) { Animation_PlayOnceSetSpeed(&this->skelAnime, &gDekuScrubUpAnim, 0.0f); this->actor.speedXZ = 0.0f; @@ -153,218 +169,252 @@ void func_80A2BE54(EnSyatekiDekunuts* this) { this->actor.prevPos = this->actor.home.pos; this->actor.shape.rot = this->actor.world.rot; - this->unk_1D8 = 0; + this->timer = 0; this->unk_1DC = 0; - if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) != 1) { - this->unk_1E2 = 1; + if (EN_SYATEKI_DEKUNUTS_GET_TYPE(&this->actor) != EN_SYATEKI_DEKUNUTS_TYPE_BONUS) { + this->isAlive = true; } - this->actionFunc = func_80A2BF18; + this->actionFunc = EnSyatekiDekunuts_WaitForSpawn; } -void func_80A2BF18(EnSyatekiDekunuts* this, PlayState* play) { +/** + * Waits until the shooting gallery man sets the appropriate Deku Scrub flag to spawn. + */ +void EnSyatekiDekunuts_WaitForSpawn(EnSyatekiDekunuts* this, PlayState* play) { EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; - if ((syatekiMan->shootingGameState == SG_GAME_STATE_RUNNING) && (this->unk_1E2 == 1) && - ((syatekiMan->dekuScrubFlags & (1 << this->unk_1E8)) != 0)) { - func_80A2BFC4(this); + if ((syatekiMan->shootingGameState == SG_GAME_STATE_RUNNING) && (this->isAlive == true) && + (syatekiMan->dekuScrubFlags & (1 << this->index))) { + EnSyatekiDekunuts_SetupSpawn(this); } else if (syatekiMan->shootingGameState != SG_GAME_STATE_RUNNING) { - this->unk_1E2 = 1; + this->isAlive = true; } - if ((syatekiMan->dekuScrubFlags == 0) && (syatekiMan->guayFlags == 0) && - (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) != 1)) { - this->unk_1E2 = 1; + if (!syatekiMan->dekuScrubFlags && !syatekiMan->guayFlags && + (EN_SYATEKI_DEKUNUTS_GET_TYPE(&this->actor) != EN_SYATEKI_DEKUNUTS_TYPE_BONUS)) { + this->isAlive = true; } } -void func_80A2BFC4(EnSyatekiDekunuts* this) { - Vec3f sp14; +/** + * Positions the Deku Scrub to match up with its flower, then sets it up to start waiting. + */ +void EnSyatekiDekunuts_SetupSpawn(EnSyatekiDekunuts* this) { + Vec3f pos; EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; - this->unk_1D8 = 0; - sp14.x = this->unk_1E4[this->unk_1E8].x; - sp14.y = this->unk_1E4[this->unk_1E8].y; - sp14.z = this->unk_1E4[this->unk_1E8].z; - this->actor.world.pos = this->actor.prevPos = sp14; + this->timer = 0; + pos.x = this->flowerPos[this->index].x; + pos.y = this->flowerPos[this->index].y; + pos.z = this->flowerPos[this->index].z; + this->actor.world.pos = this->actor.prevPos = pos; this->actor.world.rot.y = this->actor.yawTowardsPlayer; this->actor.shape.rot.y = this->actor.yawTowardsPlayer; - this->unk_1EE = 140 - (syatekiMan->currentWave * 20); + this->timeToBurrow = 140 - (syatekiMan->currentWave * 20); - if ((syatekiMan->currentWave & 1) != 0) { - this->unk_1F0 = 1; - this->unk_1F2 = 0; + if ((syatekiMan->currentWave % 2) != 0) { + this->headdressType = EN_SYATEKI_DEKUNUTS_HEADDRESS_TYPE_FLIPPED_UP; + this->headdressRotZ = 0; } else { - this->unk_1F0 = 0; + this->headdressType = EN_SYATEKI_DEKUNUTS_HEADDRESS_TYPE_NORMAL; } - this->actionFunc = func_80A2C0F8; + this->actionFunc = EnSyatekiDekunuts_Spawn; } -void func_80A2C0F8(EnSyatekiDekunuts* this, PlayState* play) { +/** + * Waits 20 frames, then plays a sound and starts the process of making the Deku Scrubs emerge. + */ +void EnSyatekiDekunuts_Spawn(EnSyatekiDekunuts* this, PlayState* play) { EnSyatekiMan* syatekiMan; - if (this->unk_1DA > 20) { + if (this->waitTimer > 20) { syatekiMan = (EnSyatekiMan*)this->actor.parent; Actor_PlaySfxAtPos(&syatekiMan->actor, NA_SE_EN_NUTS_DAMAGE); - this->unk_1DA = 0; - func_80A2C150(this); + this->waitTimer = 0; + EnSyatekiDekunuts_SetupWaitToEmerge(this); } else { - this->unk_1DA++; + this->waitTimer++; } } -void func_80A2C150(EnSyatekiDekunuts* this) { - this->unk_1D8 = 0; - this->actionFunc = func_80A2C168; +void EnSyatekiDekunuts_SetupWaitToEmerge(EnSyatekiDekunuts* this) { + this->timer = 0; + this->actionFunc = EnSyatekiDekunuts_WaitToEmerge; } -void func_80A2C168(EnSyatekiDekunuts* this, PlayState* play) { - if (this->unk_1DA > 20) { - func_80A2C1AC(this); - this->unk_1DA = 0; +/** + * Waits 20 frames, then makes the Deku Scrubs emerge from underground. + */ +void EnSyatekiDekunuts_WaitToEmerge(EnSyatekiDekunuts* this, PlayState* play) { + if (this->waitTimer > 20) { + EnSyatekiDekunuts_SetupEmerge(this); + this->waitTimer = 0; } else { - this->unk_1DA++; + this->waitTimer++; } } -void func_80A2C1AC(EnSyatekiDekunuts* this) { +void EnSyatekiDekunuts_SetupEmerge(EnSyatekiDekunuts* this) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_SYATEKI_DEKUNUTS_ANIM_UP); this->actor.shape.rot.y = this->actor.yawTowardsPlayer; this->actor.world.rot.y = this->actor.yawTowardsPlayer; - this->actionFunc = func_80A2C208; + this->actionFunc = EnSyatekiDekunuts_Emerge; } -void func_80A2C208(EnSyatekiDekunuts* this, PlayState* play) { +/** + * Waits until the animation for coming out of the ground is done playing, then makes the + * Deku Scrubs look around. If the headdress should be flipped up, then this will also + * adjust the headdress's rotation. + */ +void EnSyatekiDekunuts_Emerge(EnSyatekiDekunuts* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80A2C27C(this); + EnSyatekiDekunuts_SetupLookAround(this); } - if (this->unk_1F0 == 1) { - Math_SmoothStepToS(&this->unk_1F2, -0x8000, 5, 0x1000, 0x100); + if (this->headdressType == EN_SYATEKI_DEKUNUTS_HEADDRESS_TYPE_FLIPPED_UP) { + Math_SmoothStepToS(&this->headdressRotZ, -0x8000, 5, 0x1000, 0x100); } - this->unk_1D8++; + this->timer++; } -void func_80A2C27C(EnSyatekiDekunuts* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); - if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) != 1) { - this->actionFunc = func_80A2C2E0; +void EnSyatekiDekunuts_SetupLookAround(EnSyatekiDekunuts* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_SYATEKI_DEKUNUTS_ANIM_LOOK_AROUND); + if (EN_SYATEKI_DEKUNUTS_GET_TYPE(&this->actor) != EN_SYATEKI_DEKUNUTS_TYPE_BONUS) { + this->actionFunc = EnSyatekiDekunuts_LookAround; } else { - this->actionFunc = func_80A2C33C; + this->actionFunc = EnSyatekiDekunuts_BonusLookAround; } } -void func_80A2C2E0(EnSyatekiDekunuts* this, PlayState* play) { +/** + * Looks around back and forth until the timer reaches the time to burrow or until the game ends. + * No matter which occurs, the Deku Scrubs burrow underground afterwards. + */ +void EnSyatekiDekunuts_LookAround(EnSyatekiDekunuts* this, PlayState* play) { EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; - if ((this->unk_1EE < this->unk_1D8) || (syatekiMan->shootingGameState != SG_GAME_STATE_RUNNING)) { - func_80A2C3AC(this); + if ((this->timeToBurrow < this->timer) || (syatekiMan->shootingGameState != SG_GAME_STATE_RUNNING)) { + EnSyatekiDekunuts_SetupBurrow(this); } - this->unk_1D8++; + this->timer++; } -void func_80A2C33C(EnSyatekiDekunuts* this, PlayState* play) { +/** + * Looks around back and forth until the game ends, then burrow underground afterwards. + */ +void EnSyatekiDekunuts_BonusLookAround(EnSyatekiDekunuts* this, PlayState* play) { EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + // There are some cases where the minigame timer can reach 0, but the shooting game state is + // still SG_GAME_STATE_RUNNING. This check just makes absolutely sure that once the game is + // over, these Deku Scrubs will burrow. if ((gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_1] <= SECONDS_TO_TIMER(0)) || (syatekiMan->shootingGameState != SG_GAME_STATE_RUNNING)) { - func_80A2C3AC(this); + EnSyatekiDekunuts_SetupBurrow(this); } - if (this->unk_1D8 < 11) { - this->unk_1D8++; + if (this->timer <= 10) { + this->timer++; } } -void func_80A2C3AC(EnSyatekiDekunuts* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); - this->actionFunc = func_80A2C3F0; +void EnSyatekiDekunuts_SetupBurrow(EnSyatekiDekunuts* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_SYATEKI_DEKUNUTS_ANIM_BURROW); + this->actionFunc = EnSyatekiDekunuts_Burrow; } -void func_80A2C3F0(EnSyatekiDekunuts* this, PlayState* play) { +/** + * Burrow underground. After 160 frames have passed since the Deku Scrub first emerged *and* + * after the burrowing animation is complete, this sets up the Deku Scrub to emerge again. + */ +void EnSyatekiDekunuts_Burrow(EnSyatekiDekunuts* this, PlayState* play) { EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; if (syatekiMan->shootingGameState == SG_GAME_STATE_RUNNING) { - if (this->unk_1D8 > 160 && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - this->unk_1D8 = 0; - func_80A2C150(this); + if ((this->timer > 160) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->timer = 0; + EnSyatekiDekunuts_SetupWaitToEmerge(this); } else { - this->unk_1D8++; + this->timer++; } } else { - func_80A2C478(this); + EnSyatekiDekunuts_SetupGameEnd(this); } } -void func_80A2C478(EnSyatekiDekunuts* this) { - this->actionFunc = func_80A2C48C; +void EnSyatekiDekunuts_SetupGameEnd(EnSyatekiDekunuts* this) { + this->actionFunc = EnSyatekiDekunuts_GameEnd; } -void func_80A2C48C(EnSyatekiDekunuts* this, PlayState* play) { - if (this->unk_1DA > 20) { - func_80A2BE54(this); - this->unk_1DA = 0; +/** + * Waits 20 frames, then resets the Deku Scrub back to its initial state. + */ +void EnSyatekiDekunuts_GameEnd(EnSyatekiDekunuts* this, PlayState* play) { + if (this->waitTimer > 20) { + EnSyatekiDekunuts_SetupWaitForSpawn(this); + this->waitTimer = 0; } else { - this->unk_1DA++; + this->waitTimer++; } } -void func_80A2C4D0(EnSyatekiDekunuts* this, PlayState* play) { - static Vec3f D_80A2CBA0 = { 0.0f, 20.0f, 0.0f }; - static Vec3f D_80A2CBAC = { 0.0f, 0.0f, 0.0f }; +void EnSyatekiDekunuts_SetupDead(EnSyatekiDekunuts* this, PlayState* play) { + static Vec3f sVelocity = { 0.0f, 20.0f, 0.0f }; + static Vec3f sAccel = { 0.0f, 0.0f, 0.0f }; EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; - if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) == 1) { - EffectSsExtra_Spawn(play, &this->actor.world.pos, &D_80A2CBA0, &D_80A2CBAC, 5, 2); + if (EN_SYATEKI_DEKUNUTS_GET_TYPE(&this->actor) == EN_SYATEKI_DEKUNUTS_TYPE_BONUS) { + EffectSsExtra_Spawn(play, &this->actor.world.pos, &sVelocity, &sAccel, 5, 2); syatekiMan->score += 100; syatekiMan->perGameVar2.bonusDekuScrubHitCounter++; } else { - EffectSsExtra_Spawn(play, &this->actor.world.pos, &D_80A2CBA0, &D_80A2CBAC, 5, 0); + EffectSsExtra_Spawn(play, &this->actor.world.pos, &sVelocity, &sAccel, 5, 0); syatekiMan->score += 30; syatekiMan->dekuScrubHitCounter++; } Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DAMAGE); - this->unk_1E2 = 0; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 4); - this->unk_1D8 = 160; - this->actionFunc = func_80A2C5DC; + this->isAlive = false; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_SYATEKI_DEKUNUTS_ANIM_DAMAGE); + this->timer = 160; + this->actionFunc = EnSyatekiDekunuts_Dead; } -void func_80A2C5DC(EnSyatekiDekunuts* this, PlayState* play) { - static Color_RGBA8 D_80A2CBB8 = { 255, 255, 255, 255 }; - static Color_RGBA8 D_80A2CBBC = { 150, 150, 150, 0 }; +void EnSyatekiDekunuts_Dead(EnSyatekiDekunuts* this, PlayState* play) { + static Color_RGBA8 sPrimColor = { 255, 255, 255, 255 }; + static Color_RGBA8 sEnvColor = { 150, 150, 150, 0 }; EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - if (this->unk_1D8 == 160) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 5); + if (this->timer == 160) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_SYATEKI_DEKUNUTS_ANIM_DIE); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DEAD); - this->unk_1D8--; - } else if (this->unk_1D8 < 160) { - Vec3f sp40; + this->timer--; + } else if (this->timer < 160) { + Vec3f pos; - sp40.x = this->actor.world.pos.x; - sp40.y = this->actor.world.pos.y + 18.0f; - sp40.z = this->actor.world.pos.z; - EffectSsDeadDb_Spawn(play, &sp40, &gZeroVec3f, &gZeroVec3f, &D_80A2CBB8, &D_80A2CBBC, 200, 0, 13); + pos.x = this->actor.world.pos.x; + pos.y = this->actor.world.pos.y + 18.0f; + pos.z = this->actor.world.pos.z; + EffectSsDeadDb_Spawn(play, &pos, &gZeroVec3f, &gZeroVec3f, &sPrimColor, &sEnvColor, 200, 0, 13); SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 30, NA_SE_EN_EXTINCT); - sp40.y = this->actor.world.pos.y + 10.0f; - EffectSsHahen_SpawnBurst(play, &sp40, 3.0f, 0, 12, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); + pos.y = this->actor.world.pos.y + 10.0f; + EffectSsHahen_SpawnBurst(play, &pos, 3.0f, 0, 12, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); - if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) != 1) { - syatekiMan->dekuScrubFlags &= ~(1 << this->unk_1E8); + if (EN_SYATEKI_DEKUNUTS_GET_TYPE(&this->actor) != EN_SYATEKI_DEKUNUTS_TYPE_BONUS) { + syatekiMan->dekuScrubFlags &= ~(1 << this->index); } - func_80A2BE54(this); + EnSyatekiDekunuts_SetupWaitForSpawn(this); } - } else if (this->unk_1D8 < 160) { - this->unk_1D8--; + } else if (this->timer < 160) { + this->timer--; } } @@ -374,16 +424,17 @@ void EnSyatekiDekunuts_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); - if ((this->actionFunc != func_80A2BF18) && (this->unk_1D8 < this->unk_1EE) && (this->unk_1D8 > 10)) { - if ((this->collider.base.acFlags & AC_HIT) && (this->unk_1E2 == 1)) { - if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) == 1) { + if ((this->actionFunc != EnSyatekiDekunuts_WaitForSpawn) && (this->timer < this->timeToBurrow) && + (this->timer > 10)) { + if ((this->collider.base.acFlags & AC_HIT) && (this->isAlive == true)) { + if (EN_SYATEKI_DEKUNUTS_GET_TYPE(&this->actor) == EN_SYATEKI_DEKUNUTS_TYPE_BONUS) { Audio_PlayFanfare(NA_BGM_GET_ITEM | 0x900); } else { play_sound(NA_SE_SY_TRE_BOX_APPEAR); } this->collider.base.acFlags &= ~AC_HIT; - func_80A2C4D0(this, play); + EnSyatekiDekunuts_SetupDead(this, play); } Collider_UpdateCylinder(&this->actor, &this->collider); @@ -399,8 +450,9 @@ s32 EnSyatekiDekunuts_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dLi Actor* thisx) { EnSyatekiDekunuts* this = THIS; - if ((limbIndex == DEKU_SCRUB_LIMB_HEADDRESS) && (this->unk_1F0 == 1)) { - rot->z += this->unk_1F2; + if ((limbIndex == DEKU_SCRUB_LIMB_HEADDRESS) && + (this->headdressType == EN_SYATEKI_DEKUNUTS_HEADDRESS_TYPE_FLIPPED_UP)) { + rot->z += this->headdressRotZ; } return false; @@ -408,24 +460,24 @@ s32 EnSyatekiDekunuts_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dLi void EnSyatekiDekunuts_Draw(Actor* thisx, PlayState* play) { EnSyatekiDekunuts* this = THIS; - Vec3f temp_f20; + Vec3f flowerPos; s32 i; - if (this->actionFunc != func_80A2BF18) { + if (this->actionFunc != EnSyatekiDekunuts_WaitForSpawn) { SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSyatekiDekunuts_OverrideLimbDraw, NULL, &this->actor); } - if (this->unk_1EC == 1) { - for (i = 0; i < this->unk_1EA; i++) { - temp_f20.x = this->unk_1E4[i].x; - temp_f20.y = this->unk_1E4[i].y; - temp_f20.z = this->unk_1E4[i].z; + if (this->shouldDrawFlowers == true) { + for (i = 0; i < this->flowerCount; i++) { + flowerPos.x = this->flowerPos[i].x; + flowerPos.y = this->flowerPos[i].y; + flowerPos.z = this->flowerPos[i].z; OPEN_DISPS(play->state.gfxCtx); func_8012C28C(play->state.gfxCtx); - Matrix_Translate(temp_f20.x, temp_f20.y, temp_f20.z, MTXMODE_NEW); + Matrix_Translate(flowerPos.x, flowerPos.y, flowerPos.z, MTXMODE_NEW); Matrix_Scale(0.02f, 0.02f, 0.02f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gDekuScrubFlowerDL); diff --git a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.h b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.h index 447dcaee70..51baf398f3 100644 --- a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.h +++ b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.h @@ -4,10 +4,15 @@ #include "global.h" #include "objects/object_dekunuts/object_dekunuts.h" -#define EN_SYATEKI_DEKUNUTS_GET_PARAM_F(thisx) ((thisx)->params & 0xF) -#define EN_SYATEKI_DEKUNUTS_GET_NUMBER(thisx) (((thisx)->params & 0xF0) >> 4) +#define EN_SYATEKI_DEKUNUTS_GET_TYPE(thisx) ((thisx)->params & 0xF) +#define EN_SYATEKI_DEKUNUTS_GET_INDEX(thisx) (((thisx)->params & 0xF0) >> 4) #define EN_SYATEKI_DEKUNUTS_GET_PARAM_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) -#define EN_SYATEKI_DEKUNUTS_PARAMS(unkFF00, number, unkF) (((unkFF00 << 8) & 0xFF00) | ((number << 4) & 0xF0) | (unkF & 0xF)) +#define EN_SYATEKI_DEKUNUTS_PARAMS(unkFF00, index, type) (((unkFF00 << 8) & 0xFF00) | ((index << 4) & 0xF0) | (type & 0xF)) + +typedef enum { + /* 0 */ EN_SYATEKI_DEKUNUTS_TYPE_NORMAL, // Worth 30 points + /* 1 */ EN_SYATEKI_DEKUNUTS_TYPE_BONUS, // Worth 100 points +} EnSyatekiDekunutsType; struct EnSyatekiDekunuts; @@ -18,18 +23,18 @@ typedef struct EnSyatekiDekunuts { /* 0x144 */ SkelAnime skelAnime; /* 0x188 */ EnSyatekiDekunutsActionFunc actionFunc; /* 0x18C */ ColliderCylinder collider; - /* 0x1D8 */ s16 unk_1D8; - /* 0x1DA */ s16 unk_1DA; - /* 0x1CD */ s16 unk_1DC; + /* 0x1D8 */ s16 timer; + /* 0x1DA */ s16 waitTimer; + /* 0x1CD */ s16 unk_1DC; // Initialized, but never used /* 0x1DE */ UNK_TYPE1 unk_1DE[0x4]; - /* 0x1E2 */ s16 unk_1E2; - /* 0x1E4 */ Vec3s* unk_1E4; - /* 0x1E8 */ s16 unk_1E8; - /* 0x1EA */ s16 unk_1EA; - /* 0x1EC */ s16 unk_1EC; - /* 0x1EE */ s16 unk_1EE; - /* 0x1F0 */ s16 unk_1F0; - /* 0x1F2 */ s16 unk_1F2; + /* 0x1E2 */ s16 isAlive; + /* 0x1E4 */ Vec3s* flowerPos; + /* 0x1E8 */ s16 index; + /* 0x1EA */ s16 flowerCount; + /* 0x1EC */ s16 shouldDrawFlowers; + /* 0x1EE */ s16 timeToBurrow; + /* 0x1F0 */ s16 headdressType; + /* 0x1F2 */ s16 headdressRotZ; /* 0x1F4 */ Vec3s jointTable[DEKU_SCRUB_LIMB_MAX]; /* 0x230 */ Vec3s morphTable[DEKU_SCRUB_LIMB_MAX]; /* 0x26C */ UNK_TYPE1 unk_26C[0x4]; 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 42f205bca4..838eaa2a54 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 @@ -103,13 +103,20 @@ typedef struct { static SwampTargetActorEntry sNormalSwampTargetActorList[] = { { ACTOR_EN_SYATEKI_WF, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_WF_PARAMS(1, 3, 0) }, { ACTOR_EN_SYATEKI_WF, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_WF_PARAMS(0, 2, 0) }, - { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_DEKUNUTS_PARAMS(0, 0, 0) }, - { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_DEKUNUTS_PARAMS(0, 1, 0) }, - { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_DEKUNUTS_PARAMS(0, 2, 0) }, - { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_DEKUNUTS_PARAMS(0, 3, 0) }, - { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_DEKUNUTS_PARAMS(0, 4, 0) }, - { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_DEKUNUTS_PARAMS(0, 0, 1) }, - { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_DEKUNUTS_PARAMS(0, 1, 1) }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, + EN_SYATEKI_DEKUNUTS_PARAMS(0, 0, EN_SYATEKI_DEKUNUTS_TYPE_NORMAL) }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, + EN_SYATEKI_DEKUNUTS_PARAMS(0, 1, EN_SYATEKI_DEKUNUTS_TYPE_NORMAL) }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, + EN_SYATEKI_DEKUNUTS_PARAMS(0, 2, EN_SYATEKI_DEKUNUTS_TYPE_NORMAL) }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, + EN_SYATEKI_DEKUNUTS_PARAMS(0, 3, EN_SYATEKI_DEKUNUTS_TYPE_NORMAL) }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, + EN_SYATEKI_DEKUNUTS_PARAMS(0, 4, EN_SYATEKI_DEKUNUTS_TYPE_NORMAL) }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, + EN_SYATEKI_DEKUNUTS_PARAMS(0, 0, EN_SYATEKI_DEKUNUTS_TYPE_BONUS) }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, + EN_SYATEKI_DEKUNUTS_PARAMS(0, 1, EN_SYATEKI_DEKUNUTS_TYPE_BONUS) }, { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_CROW_PARAMS(0, 0, 0) }, { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_CROW_PARAMS(1, 0, 0) }, { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_CROW_PARAMS(2, 0, 0) }, @@ -129,8 +136,10 @@ static SwampTargetActorEntry sNormalSwampTargetActorList[] = { static SwampTargetActorEntry sUnusedSwampTargetActorList[] = { { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_CROW_PARAMS(0, 0, 0) }, { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_CROW_PARAMS(1, 0, 0) }, - { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_DEKUNUTS_PARAMS(0, 0, 1) }, - { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_DEKUNUTS_PARAMS(0, 1, 1) }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, + EN_SYATEKI_DEKUNUTS_PARAMS(0, 0, EN_SYATEKI_DEKUNUTS_TYPE_BONUS) }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, + EN_SYATEKI_DEKUNUTS_PARAMS(0, 1, EN_SYATEKI_DEKUNUTS_TYPE_BONUS) }, { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_CROW_PARAMS(2, 0, 2) }, { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_CROW_PARAMS(3, 0, 2) }, { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_CROW_PARAMS(0, 0, 3) }, diff --git a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c index b6a0f9ed40..c9caedf014 100644 --- a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c +++ b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c @@ -151,7 +151,7 @@ void EnSyatekiWf_Init(Actor* thisx, PlayState* play) { path = &play->setupPathList[path->unk1]; } - for (i = 0; i < EN_SYATEKI_WF_GET_NUMBER(&this->actor); i++) { + for (i = 0; i < EN_SYATEKI_WF_GET_INDEX(&this->actor); i++) { path = &play->setupPathList[path->unk1]; } @@ -224,7 +224,7 @@ void func_80A201CC(EnSyatekiWf* this) { this->actor.draw = NULL; this->unk_2A4 = 1; this->unk_298 = 0; - syatekiMan->wolfosFlags &= ~(1 << EN_SYATEKI_WF_GET_NUMBER(&this->actor)); + syatekiMan->wolfosFlags &= ~(1 << EN_SYATEKI_WF_GET_INDEX(&this->actor)); this->actionFunc = func_80A20284; } @@ -236,7 +236,7 @@ void func_80A20284(EnSyatekiWf* this, PlayState* play) { if ((syatekiMan->shootingGameState == SG_GAME_STATE_RUNNING) && (this->unk_298 == 1)) { func_80A200E0(this); func_80A2030C(this); - } else if (syatekiMan->wolfosFlags & (1 << EN_SYATEKI_WF_GET_NUMBER(&this->actor))) { + } else if (syatekiMan->wolfosFlags & (1 << EN_SYATEKI_WF_GET_INDEX(&this->actor))) { this->unk_298 = 1; } } diff --git a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.h b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.h index 4de182a106..9e01dca3dd 100644 --- a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.h +++ b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.h @@ -5,8 +5,8 @@ #include "objects/object_wf/object_wf.h" #define EN_SYATEKI_WF_GET_PARAM_F0(thisx) (((thisx)->params & 0xF0) >> 4) -#define EN_SYATEKI_WF_GET_NUMBER(thisx) (((thisx)->params & 0xFF00) >> 8) -#define EN_SYATEKI_WF_PARAMS(number, unkF0, unused) (((number << 8) & 0xFF00) | ((unkF0 << 4) & 0xF0) | (unused & 0xF)) +#define EN_SYATEKI_WF_GET_INDEX(thisx) (((thisx)->params & 0xFF00) >> 8) +#define EN_SYATEKI_WF_PARAMS(index, unkF0, unused) (((index << 8) & 0xFF00) | ((unkF0 << 4) & 0xF0) | (unused & 0xF)) struct EnSyatekiWf; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index b71390a057..519550a83b 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -10063,23 +10063,23 @@ 0x80A2B390:("BgDblueMovebg_Draw",), 0x80A2BC00:("EnSyatekiDekunuts_Init",), 0x80A2BE28:("EnSyatekiDekunuts_Destroy",), - 0x80A2BE54:("func_80A2BE54",), - 0x80A2BF18:("func_80A2BF18",), - 0x80A2BFC4:("func_80A2BFC4",), - 0x80A2C0F8:("func_80A2C0F8",), - 0x80A2C150:("func_80A2C150",), - 0x80A2C168:("func_80A2C168",), - 0x80A2C1AC:("func_80A2C1AC",), - 0x80A2C208:("func_80A2C208",), - 0x80A2C27C:("func_80A2C27C",), - 0x80A2C2E0:("func_80A2C2E0",), - 0x80A2C33C:("func_80A2C33C",), - 0x80A2C3AC:("func_80A2C3AC",), - 0x80A2C3F0:("func_80A2C3F0",), - 0x80A2C478:("func_80A2C478",), - 0x80A2C48C:("func_80A2C48C",), - 0x80A2C4D0:("func_80A2C4D0",), - 0x80A2C5DC:("func_80A2C5DC",), + 0x80A2BE54:("EnSyatekiDekunuts_SetupWaitForSpawn",), + 0x80A2BF18:("EnSyatekiDekunuts_WaitForSpawn",), + 0x80A2BFC4:("EnSyatekiDekunuts_SetupSpawn",), + 0x80A2C0F8:("EnSyatekiDekunuts_Spawn",), + 0x80A2C150:("EnSyatekiDekunuts_SetupWaitToEmerge",), + 0x80A2C168:("EnSyatekiDekunuts_WaitToEmerge",), + 0x80A2C1AC:("EnSyatekiDekunuts_SetupEmerge",), + 0x80A2C208:("EnSyatekiDekunuts_Emerge",), + 0x80A2C27C:("EnSyatekiDekunuts_SetupLookAround",), + 0x80A2C2E0:("EnSyatekiDekunuts_LookAround",), + 0x80A2C33C:("EnSyatekiDekunuts_BonusLookAround",), + 0x80A2C3AC:("EnSyatekiDekunuts_SetupBurrow",), + 0x80A2C3F0:("EnSyatekiDekunuts_Burrow",), + 0x80A2C478:("EnSyatekiDekunuts_SetupGameEnd",), + 0x80A2C48C:("EnSyatekiDekunuts_GameEnd",), + 0x80A2C4D0:("EnSyatekiDekunuts_SetupDead",), + 0x80A2C5DC:("EnSyatekiDekunuts_Dead",), 0x80A2C78C:("EnSyatekiDekunuts_Update",), 0x80A2C8A0:("EnSyatekiDekunuts_OverrideLimbDraw",), 0x80A2C8E8:("EnSyatekiDekunuts_Draw",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 9e02cf981b..eac44b02df 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -11112,15 +11112,15 @@ 0x80A2BBF4:("D_80A2BBF4","UNK_TYPE1","",0x1), 0x80A2BBF5:("D_80A2BBF5","UNK_TYPE1","",0x1), 0x80A2CA90:("En_Syateki_Dekunuts_InitVars","UNK_TYPE1","",0x1), - 0x80A2CAB0:("D_80A2CAB0","UNK_TYPE1","",0x1), - 0x80A2CADC:("D_80A2CADC","UNK_TYPE4","",0x4), - 0x80A2CAE8:("D_80A2CAE8","UNK_PTR","",0x4), - 0x80A2CB90:("D_80A2CB90","UNK_TYPE1","",0x1), - 0x80A2CB9C:("D_80A2CB9C","UNK_TYPE4","",0x4), - 0x80A2CBA0:("D_80A2CBA0","UNK_TYPE1","",0x1), - 0x80A2CBAC:("D_80A2CBAC","UNK_TYPE1","",0x1), - 0x80A2CBB8:("D_80A2CBB8","UNK_TYPE1","",0x1), - 0x80A2CBBC:("D_80A2CBBC","UNK_TYPE1","",0x1), + 0x80A2CAB0:("sCylinderInit","UNK_TYPE1","",0x1), + 0x80A2CADC:("sBonusDekuScrubColliderDimensions","UNK_TYPE4","",0x4), + 0x80A2CAE8:("sAnimationInfo","UNK_PTR","",0x4), + 0x80A2CB90:("sInitChain","UNK_TYPE1","",0x1), + 0x80A2CB9C:("sDrawFlowers","UNK_TYPE4","",0x4), + 0x80A2CBA0:("sVelocity","UNK_TYPE1","",0x1), + 0x80A2CBAC:("sAccel","UNK_TYPE1","",0x1), + 0x80A2CBB8:("sPrimColor","UNK_TYPE1","",0x1), + 0x80A2CBBC:("sEnvColor","UNK_TYPE1","",0x1), 0x80A2CBC0:("D_80A2CBC0","f32","",0x4), 0x80A2D1C0:("Elf_Msg3_InitVars","UNK_TYPE1","",0x1), 0x80A2D1E0:("D_80A2D1E0","UNK_TYPE1","",0x1), From c3c08e944cc9548726b73a0d699ede34ba4e1017 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sat, 1 Oct 2022 08:14:06 -0700 Subject: [PATCH 10/25] EnWiz (Wizrobe) OK and documented, EnWizFire (Wizrobe Magic) documented, object_wiz documented (#1054) * Good start * Limb draw stuff OK * A ton more functions * func_80A477E8 OK * func_80A456A0 OK * func_80A460A4 OK * func_80A46990 OK * func_80A46414 OK * EnWiz_Update OK * func_80A45CD8 OK Co-authored-by: petrie911 * EnWiz_Draw OK * Use generated reloc and object symbols * Document object stuff related to Wizzrobe itself * Some more names * A bunch more names * Name even more stuff (sensing a pattern?) * Document damage tables and damage effects * Bunch of stuff mostly related to ghosts * Name all struct vars and functions * Fix WizFire build issue * Split up dmgFlags * Apparently it's spelled "Wizrobe" in this game * Name all assets EXCEPT the ones used by wiz_fire * Apparently, the blob is vertices * Name all remaining variables * Some function comments * (Probably) the final touches on EnWiz docs before PR * Name a ton of stuff in EnWizFire * Finish naming everything in EnWizFire * Finish documentation * Respond to Engineer's clean-up review * Respond to Anghelo's first review * Use TATL_HINT_ID enum * Enum comments for animations, and better names for some damage effects * Fix build after merging master * Respond to Elliptic's review * Define INITIAL_CUR_PLATFORM_INDEX * Drop _CUR_ from the name * Rename one of the enum values * Respond to Elliptic's WizFire review * Every switch has a default --- assets/xml/objects/object_wiz.xml | 242 ++- spec | 3 +- src/overlays/actors/ovl_En_Fz/z_en_fz.c | 4 +- src/overlays/actors/ovl_En_Wiz/z_en_wiz.c | 1607 +++++++++++++++-- src/overlays/actors/ovl_En_Wiz/z_en_wiz.h | 73 +- .../actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c | 33 +- .../actors/ovl_En_Wiz_Brock/z_en_wiz_brock.h | 11 +- .../actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c | 716 ++++---- .../actors/ovl_En_Wiz_Fire/z_en_wiz_fire.h | 83 +- tools/disasm/functions.txt | 72 +- tools/disasm/variables.txt | 32 +- undefined_syms.txt | 8 - 12 files changed, 2178 insertions(+), 706 deletions(-) diff --git a/assets/xml/objects/object_wiz.xml b/assets/xml/objects/object_wiz.xml index 2928083aa2..51fcae3a79 100644 --- a/assets/xml/objects/object_wiz.xml +++ b/assets/xml/objects/object_wiz.xml @@ -1,102 +1,148 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spec b/spec index b4a8a61082..9ad5e4cca9 100644 --- a/spec +++ b/spec @@ -2715,8 +2715,7 @@ beginseg name "ovl_En_Wiz" compress include "build/src/overlays/actors/ovl_En_Wiz/z_en_wiz.o" - include "build/data/ovl_En_Wiz/ovl_En_Wiz.data.o" - include "build/data/ovl_En_Wiz/ovl_En_Wiz.reloc.o" + include "build/src/overlays/actors/ovl_En_Wiz/ovl_En_Wiz_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Fz/z_en_fz.c b/src/overlays/actors/ovl_En_Fz/z_en_fz.c index 198166b007..58d5a6f5fc 100644 --- a/src/overlays/actors/ovl_En_Fz/z_en_fz.c +++ b/src/overlays/actors/ovl_En_Fz/z_en_fz.c @@ -241,10 +241,10 @@ void EnFz_Destroy(Actor* thisx, PlayState* play) { Collider_DestroyCylinder(play, &this->collider3); if ((this->actor.parent != NULL) && (this->unk_BC4 == 0) && (this->actor.parent->id == ACTOR_EN_WIZ) && - (this->actor.parent->update != NULL) && (((EnWiz*)this->actor.parent)->unk_448 != 0)) { + (this->actor.parent->update != NULL) && (((EnWiz*)this->actor.parent)->freezard != NULL)) { EnWiz* wiz = (EnWiz*)this->actor.parent; - wiz->unk_448 = 0; + wiz->freezard = NULL; } } diff --git a/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c b/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c index 82cc5f2e27..0abf1fe565 100644 --- a/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c +++ b/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c @@ -1,10 +1,12 @@ /* * File: z_en_wiz.c * Overlay: ovl_En_Wiz - * Description: Wizzrobe + * Description: Wizrobe */ #include "z_en_wiz.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.h" #define FLAGS \ (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_1000 | ACTOR_FLAG_100000 | \ @@ -17,7 +19,67 @@ void EnWiz_Destroy(Actor* thisx, PlayState* play); void EnWiz_Update(Actor* thisx, PlayState* play); void EnWiz_Draw(Actor* thisx, PlayState* play); -#if 0 +void EnWiz_StartIntroCutscene(EnWiz* this, PlayState* play); +void EnWiz_SetupAppear(EnWiz* this, PlayState* play); +void EnWiz_Appear(EnWiz* this, PlayState* play); +void EnWiz_SetupDance(EnWiz* this); +void EnWiz_Dance(EnWiz* this, PlayState* play); +void EnWiz_SetupSecondPhaseCutscene(EnWiz* this, PlayState* play); +void EnWiz_SecondPhaseCutscene(EnWiz* this, PlayState* play); +void EnWiz_SetupWindUp(EnWiz* this); +void EnWiz_WindUp(EnWiz* this, PlayState* play); +void EnWiz_SetupAttack(EnWiz* this); +void EnWiz_Attack(EnWiz* this, PlayState* play); +void EnWiz_SetupDisappear(EnWiz* this); +void EnWiz_Disappear(EnWiz* this, PlayState* play); +void EnWiz_Damaged(EnWiz* this, PlayState* play); +void EnWiz_SetupDead(EnWiz* this); +void EnWiz_Dead(EnWiz* this, PlayState* play); + +// This number is almost-entirely arbirary, with the only requirement being +// that cannot be a valid curPlatformIndex. Any negative number, or any number +// larger than 10, would work just as well. +#define INITIAL_PLATFORM_INDEX 777 + +typedef enum { + /* 1 */ EN_WIZ_ACTION_APPEAR = 1, + /* 2 */ EN_WIZ_ACTION_RUN_BETWEEN_PLATFORMS, + /* 3 */ EN_WIZ_ACTION_DISAPPEAR, + /* 4 */ EN_WIZ_ACTION_DAMAGED, + /* 5 */ EN_WIZ_ACTION_DEAD, + /* 6 */ EN_WIZ_ACTION_BURST_INTO_FLAMES, + /* 7 */ EN_WIZ_ACTION_RUN_IN_CIRCLES, + /* 8 */ EN_WIZ_ACTION_ATTACK, + /* 9 */ EN_WIZ_ACTION_DANCE, +} EnWizAction; + +typedef enum { + /* 0 */ EN_WIZ_INTRO_CS_NOT_STARTED, + /* 1 */ EN_WIZ_INTRO_CS_CAMERA_MOVE_TO_PLATFORM, + /* 2 */ EN_WIZ_INTRO_CS_APPEAR, + /* 3 */ EN_WIZ_INTRO_CS_CAMERA_SPIN_TO_FACE_WIZROBE, + /* 4 */ EN_WIZ_INTRO_CS_WAIT_BEFORE_RUN, + /* 5 */ EN_WIZ_INTRO_CS_RUN_IN_CIRCLES, + /* 6 */ EN_WIZ_INTRO_CS_DISAPPEAR, + /* 7 */ EN_WIZ_INTRO_CS_END +} EnWizIntroCutsceneState; + +typedef enum { + /* 0 */ EN_WIZ_FIGHT_STATE_FIRST_PHASE, + /* 1 */ EN_WIZ_FIGHT_STATE_SECOND_PHASE_CUTSCENE, + /* 2 */ EN_WIZ_FIGHT_STATE_SECOND_PHASE_GHOSTS_COPY_WIZROBE, + /* 3 */ EN_WIZ_FIGHT_STATE_SECOND_PHASE_GHOSTS_RUN_AROUND, +} EnWizFightState; + +typedef enum { + /* 0 */ EN_WIZ_ANIM_IDLE, + /* 1 */ EN_WIZ_ANIM_RUN, + /* 2 */ EN_WIZ_ANIM_DANCE, + /* 3 */ EN_WIZ_ANIM_WIND_UP, + /* 4 */ EN_WIZ_ANIM_ATTACK, + /* 5 */ EN_WIZ_ANIM_DAMAGE, +} EnWizAnimation; + const ActorInit En_Wiz_InitVars = { ACTOR_EN_WIZ, ACTORCAT_ENEMY, @@ -30,199 +92,1470 @@ const ActorInit En_Wiz_InitVars = { (ActorFunc)EnWiz_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[10] = { -static ColliderJntSphElementInit D_80A48B50[10] = { +static ColliderJntSphElementInit sJntSphElementsInit[10] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0x01000202, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, }, - { 1, { { 0, 0, 0 }, 0 }, 1 }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0x01000202, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, + { WIZROBE_LIMB_PELVIS, { { 0, 0, 0 }, 0 }, 1 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 1, { { 0, 0, 0 }, 0 }, 0 }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { WIZROBE_LIMB_PELVIS, { { 0, 0, 0 }, 0 }, 0 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 1, { { 0, 0, 0 }, 0 }, 0 }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { WIZROBE_LIMB_PELVIS, { { 0, 0, 0 }, 0 }, 0 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 1, { { 0, 0, 0 }, 0 }, 0 }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { WIZROBE_LIMB_PELVIS, { { 0, 0, 0 }, 0 }, 0 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 1, { { 0, 0, 0 }, 0 }, 0 }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { WIZROBE_LIMB_PELVIS, { { 0, 0, 0 }, 0 }, 0 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 1, { { 0, 0, 0 }, 0 }, 0 }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { WIZROBE_LIMB_PELVIS, { { 0, 0, 0 }, 0 }, 0 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 1, { { 0, 0, 0 }, 0 }, 0 }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { WIZROBE_LIMB_PELVIS, { { 0, 0, 0 }, 0 }, 0 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 1, { { 0, 0, 0 }, 0 }, 0 }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { WIZROBE_LIMB_PELVIS, { { 0, 0, 0 }, 0 }, 0 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 1, { { 0, 0, 0 }, 0 }, 0 }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { WIZROBE_LIMB_PELVIS, { { 0, 0, 0 }, 0 }, 0 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 1, { { 0, 0, 0 }, 0 }, 0 }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { WIZROBE_LIMB_PELVIS, { { 0, 0, 0 }, 0 }, 0 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80A48CB8 = { - { COLTYPE_HIT2, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - ARRAY_COUNT(sJntSphElementsInit), D_80A48B50, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT2, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sJntSphElementsInit), + sJntSphElementsInit, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A48CC8 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0xF7CFFFFF, 0x08, 0x04 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0xF7CFFFFF, 0x08, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 35, 130, 0, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_80A48CF4 = { - /* Deku Nut */ DMG_ENTRY(0, 0x1), - /* Deku Stick */ DMG_ENTRY(1, 0xF), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(1, 0xF), - /* Zora boomerang */ DMG_ENTRY(1, 0xF), - /* Normal arrow */ DMG_ENTRY(1, 0xF), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(1, 0xF), - /* Goron punch */ DMG_ENTRY(1, 0xF), - /* Sword */ DMG_ENTRY(1, 0xF), - /* Goron pound */ DMG_ENTRY(3, 0xF), - /* Fire arrow */ DMG_ENTRY(1, 0x2), - /* Ice arrow */ DMG_ENTRY(2, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(0, 0x0), - /* Deku spin */ DMG_ENTRY(1, 0xF), - /* Deku bubble */ DMG_ENTRY(1, 0xF), - /* Deku launch */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x1), - /* Zora barrier */ DMG_ENTRY(0, 0x0), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0xF), - /* Zora punch */ DMG_ENTRY(1, 0xF), - /* Spin attack */ DMG_ENTRY(1, 0xF), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0xF), +typedef enum { + /* 0x0 */ EN_WIZ_DMGEFF_IMMUNE, // Deals no damage + /* 0x1 */ EN_WIZ_DMGEFF_UNK1, // Deals no damage. Was probably originally intended for destroying ghosts. + /* 0x2 */ EN_WIZ_DMGEFF_FIRE, // Damages and sets Ice Wizrobes on fire + /* 0x3 */ EN_WIZ_DMGEFF_FREEZE, // Damages and surrounds Fire Wizrobes with ice + /* 0x4 */ EN_WIZ_DMGEFF_LIGHT_ORB, // Damages and surrounds the Wizrobe with light orbs + /* 0xF */ EN_WIZ_DMGEFF_NONE = 0xF, // Deals regular damage and has no special effect +} EnWizDamageEffect; + +static DamageTable sFireWizrobeDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, EN_WIZ_DMGEFF_UNK1), + /* Deku Stick */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Explosives */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* UNK_DMG_D_06 */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Hookshot */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Goron punch */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(3, EN_WIZ_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(1, EN_WIZ_DMGEFF_FIRE), + /* Ice arrow */ DMG_ENTRY(2, EN_WIZ_DMGEFF_FREEZE), + /* Light arrow */ DMG_ENTRY(2, EN_WIZ_DMGEFF_LIGHT_ORB), + /* Goron spikes */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Deku spin */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Deku bubble */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, EN_WIZ_DMGEFF_UNK1), + /* Zora barrier */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Normal shield */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Light ray */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Thrown object */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Normal Roll */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Unblockable */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Powder Keg */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), }; -// static DamageTable sDamageTable = { -static DamageTable D_80A48D14 = { - /* Deku Nut */ DMG_ENTRY(0, 0x1), - /* Deku Stick */ DMG_ENTRY(1, 0xF), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(1, 0xF), - /* Zora boomerang */ DMG_ENTRY(1, 0xF), - /* Normal arrow */ DMG_ENTRY(1, 0xF), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(1, 0xF), - /* Goron punch */ DMG_ENTRY(2, 0xF), - /* Sword */ DMG_ENTRY(1, 0xF), - /* Goron pound */ DMG_ENTRY(3, 0xF), - /* Fire arrow */ DMG_ENTRY(2, 0x2), - /* Ice arrow */ DMG_ENTRY(1, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(0, 0x0), - /* Deku spin */ DMG_ENTRY(1, 0xF), - /* Deku bubble */ DMG_ENTRY(1, 0xF), - /* Deku launch */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x1), - /* Zora barrier */ DMG_ENTRY(0, 0x0), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0xF), - /* Zora punch */ DMG_ENTRY(1, 0xF), - /* Spin attack */ DMG_ENTRY(1, 0xF), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0xF), +static DamageTable sIceWizrobeDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, EN_WIZ_DMGEFF_UNK1), + /* Deku Stick */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Explosives */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* UNK_DMG_D_06 */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Hookshot */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Goron punch */ DMG_ENTRY(2, EN_WIZ_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(3, EN_WIZ_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(2, EN_WIZ_DMGEFF_FIRE), + /* Ice arrow */ DMG_ENTRY(1, EN_WIZ_DMGEFF_FREEZE), + /* Light arrow */ DMG_ENTRY(2, EN_WIZ_DMGEFF_LIGHT_ORB), + /* Goron spikes */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Deku spin */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Deku bubble */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, EN_WIZ_DMGEFF_UNK1), + /* Zora barrier */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Normal shield */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Light ray */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Thrown object */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Normal Roll */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Unblockable */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Powder Keg */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), }; -#endif +void EnWiz_Init(Actor* thisx, PlayState* play) { + s32 pad; + EnWiz* this = THIS; -extern ColliderJntSphElementInit D_80A48B50[10]; -extern ColliderJntSphInit D_80A48CB8; -extern ColliderCylinderInit D_80A48CC8; -extern DamageTable D_80A48CF4; -extern DamageTable D_80A48D14; + SkelAnime_InitFlex(play, &this->skelAnime, &gWizrobeSkel, &gWizrobeIdleAnim, this->jointTable, this->morphTable, + WIZROBE_LIMB_MAX); + SkelAnime_InitFlex(play, &this->ghostSkelAnime, &gWizrobeSkel, &gWizrobeIdleAnim, this->ghostBaseJointTable, + this->ghostMorphTable, WIZROBE_LIMB_MAX); + Actor_SetScale(&this->actor, 0.0f); + this->platformLightAlpha = 0; + this->alpha = 255; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.targetMode = 3; + this->unk_450 = 1.0f; + this->actor.shape.yOffset = 700.0f; + Collider_InitAndSetJntSph(play, &this->ghostColliders, &this->actor, &sJntSphInit, this->ghostColliderElements); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + this->staffFlameScroll = Rand_S16Offset(0, 7); + this->switchFlag = EN_WIZ_GET_SWITCHFLAG(&this->actor); + this->type = EN_WIZ_GET_TYPE(&this->actor); -extern UNK_TYPE D_0600211C; -extern UNK_TYPE D_060025F0; -extern UNK_TYPE D_060066C0; + if (this->switchFlag == 0x7F) { + this->switchFlag = -1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/EnWiz_Init.s") + if ((this->type == EN_WIZ_TYPE_FIRE) || (this->type == EN_WIZ_TYPE_FIRE_NO_BGM)) { + this->actor.colChkInfo.damageTable = &sFireWizrobeDamageTable; + this->actor.colChkInfo.health = 8; + this->actor.flags &= ~ACTOR_FLAG_100000; + } else { + this->actor.colChkInfo.damageTable = &sIceWizrobeDamageTable; + this->actor.colChkInfo.health = 6; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/EnWiz_Destroy.s") + if ((this->switchFlag >= 0) && (Flags_GetSwitch(play, this->switchFlag))) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A455C4.s") + this->actor.hintId = TATL_HINT_ID_WIZROBE; + this->curPlatformIndex = INITIAL_PLATFORM_INDEX; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A456A0.s") + // Setting the radius and scale to zero here effectively disables all of the ghost colliders. + this->ghostColliders.elements[0].dim.modelSphere.radius = 0; + this->ghostColliders.elements[0].dim.scale = 0.0f; + this->ghostColliders.elements[0].dim.modelSphere.center.x = 0; + this->ghostColliders.elements[0].dim.modelSphere.center.y = 0; + this->ghostColliders.elements[0].dim.modelSphere.center.z = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A45CD8.s") + this->actionFunc = EnWiz_StartIntroCutscene; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A460A4.s") +void EnWiz_Destroy(Actor* thisx, PlayState* play) { + s32 pad; + EnWiz* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A46280.s") + Collider_DestroyCylinder(play, &this->collider); + Collider_DestroyJntSph(play, &this->ghostColliders); + if (this->type != EN_WIZ_TYPE_FIRE_NO_BGM) { + Audio_RestorePrevBgm(); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A462F8.s") +static AnimationHeader* sAnimations[] = { + &gWizrobeIdleAnim, // EN_WIZ_ANIM_IDLE + &gWizrobeRunAnim, // EN_WIZ_ANIM_RUN + &gWizrobeDanceAnim, // EN_WIZ_ANIM_DANCE + &gWizrobeWindUpAnim, // EN_WIZ_ANIM_WIND_UP + &gWizrobeAttackAnim, // EN_WIZ_ANIM_ATTACK + &gWizrobeDamageAnim, // EN_WIZ_ANIM_DAMAGE +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A46414.s") +static u8 sAnimationModes[] = { + ANIMMODE_LOOP, // EN_WIZ_ANIM_IDLE + ANIMMODE_LOOP, // EN_WIZ_ANIM_RUN + ANIMMODE_LOOP, // EN_WIZ_ANIM_DANCE + ANIMMODE_LOOP, // EN_WIZ_ANIM_WIND_UP + ANIMMODE_LOOP, // EN_WIZ_ANIM_ATTACK + ANIMMODE_ONCE, // EN_WIZ_ANIM_DAMAGE +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A4668C.s") +void EnWiz_ChangeAnim(EnWiz* this, s32 animIndex, s32 updateGhostAnim) { + this->endFrame = Animation_GetLastFrame(sAnimations[animIndex]); + Animation_Change(&this->skelAnime, sAnimations[animIndex], 1.0f, 0.0f, this->endFrame, sAnimationModes[animIndex], + -2.0f); + if (updateGhostAnim) { + Animation_Change(&this->ghostSkelAnime, sAnimations[animIndex], 1.0f, 0.0f, this->endFrame, + sAnimationModes[animIndex], -2.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A46764.s") +/** + * Responsible for moving the camera around and making the Wizrobe run in circles during the intro cutscene. + */ +void EnWiz_HandleIntroCutscene(EnWiz* this, PlayState* play) { + Camera* subCam; + Vec3f eyeNext; + Vec3f atNext; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A468CC.s") + if (this->introCutsceneState < EN_WIZ_INTRO_CS_DISAPPEAR) { + subCam = Play_GetCamera(play, this->subCamId); + switch (this->introCutsceneState) { + case EN_WIZ_INTRO_CS_NOT_STARTED: + this->introCutsceneTimer = 100; + this->introCutsceneCameraAngle = this->actor.world.rot.y; + this->introCutsceneState++; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A46990.s") + case EN_WIZ_INTRO_CS_CAMERA_MOVE_TO_PLATFORM: + Math_Vec3f_Copy(&eyeNext, &this->actor.world.pos); + Math_Vec3f_Copy(&atNext, &this->actor.world.pos); + eyeNext.x += Math_SinS(this->introCutsceneCameraAngle) * 200.0f; + eyeNext.y += 100.0f; + eyeNext.z += Math_CosS(this->introCutsceneCameraAngle) * 200.0f; + atNext.y += 80.0f; + Math_ApproachF(&subCam->eye.x, eyeNext.x, 0.3f, 30.0f); + Math_ApproachF(&subCam->eye.z, eyeNext.z, 0.3f, 30.0f); + Math_ApproachF(&subCam->at.x, atNext.x, 0.3f, 30.0f); + Math_ApproachF(&subCam->at.z, atNext.z, 0.3f, 30.0f); + subCam->eye.y = eyeNext.y; + subCam->at.y = atNext.y; + if ((fabsf(subCam->eye.x - eyeNext.x) < 2.0f) && (fabsf(subCam->eye.y - eyeNext.y) < 2.0f) && + (fabsf(subCam->eye.z - eyeNext.z) < 2.0f) && (fabsf(subCam->at.x - atNext.x) < 2.0f) && + (fabsf(subCam->at.y - atNext.y) < 2.0f) && (fabsf(subCam->at.z - atNext.z) < 2.0f)) { + Player* player = GET_PLAYER(play); + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A46C88.s") + this->actor.world.rot.y = this->actor.shape.rot.y = + Math_Vec3f_Yaw(&this->actor.world.pos, &player->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A46CC4.s") + for (i = 0; i < this->platformCount; i++) { + this->ghostRot[i].y = Math_Vec3f_Yaw(&this->ghostPos[i], &player->actor.world.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A46DDC.s") + EnWiz_ChangeAnim(this, EN_WIZ_ANIM_IDLE, true); + this->shouldStartTimer = false; + this->targetPlatformLightAlpha = 255; + Math_Vec3f_Copy(&this->platformLightPos, &this->actor.world.pos); + if (this->fightState == EN_WIZ_FIGHT_STATE_FIRST_PHASE) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_UNARI); + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_VOICE - SFX_FLAG); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A46E24.s") + this->introCutsceneTimer = 40; + this->introCutsceneState++; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A47000.s") + case EN_WIZ_INTRO_CS_APPEAR: + if (this->introCutsceneTimer == 0) { + this->introCutsceneTimer = 20; + this->introCutsceneState++; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A470D8.s") + case EN_WIZ_INTRO_CS_CAMERA_SPIN_TO_FACE_WIZROBE: + Math_Vec3f_Copy(&eyeNext, &this->actor.world.pos); + Math_Vec3f_Copy(&atNext, &this->actor.world.pos); + eyeNext.x += Math_SinS(this->actor.world.rot.y) * 160.0f; + eyeNext.y += 70.0f; + eyeNext.z += Math_CosS(this->actor.world.rot.y) * 140.0f; + atNext.x += -10.0f; + atNext.y += 100.0f; + Math_ApproachF(&subCam->eye.x, eyeNext.x, 0.3f, 30.0f); + Math_ApproachF(&subCam->eye.z, eyeNext.z, 0.3f, 30.0f); + Math_ApproachF(&subCam->at.x, atNext.x, 0.3f, 30.0f); + Math_ApproachF(&subCam->at.z, atNext.z, 0.3f, 30.0f); + subCam->eye.y = eyeNext.y; + subCam->at.y = atNext.y; + if (this->introCutsceneTimer == 0) { + this->introCutsceneTimer = 10; + this->introCutsceneState++; + this->introCutsceneCameraAngle = this->actor.world.rot.y; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A47298.s") + case EN_WIZ_INTRO_CS_WAIT_BEFORE_RUN: + if (this->introCutsceneTimer == 0) { + EnWiz_ChangeAnim(this, EN_WIZ_ANIM_RUN, false); + this->rotationalVelocity = 0; + this->introCutsceneTimer = 34; + this->introCutsceneState++; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A473B8.s") + case EN_WIZ_INTRO_CS_RUN_IN_CIRCLES: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_RUN - SFX_FLAG); + if (this->introCutsceneTimer == 0) { + this->animLoopCounter = this->introCutsceneCameraAngle = 0; + this->introCutsceneState = EN_WIZ_INTRO_CS_DISAPPEAR; + } else { + Math_SmoothStepToS(&this->rotationalVelocity, 0x1388, 0x64, 0x3E8, 0x3E8); + this->actor.world.rot.y += this->rotationalVelocity; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A4767C.s") + Math_Vec3f_Copy(&eyeNext, &this->actor.world.pos); + Math_Vec3f_Copy(&atNext, &this->actor.world.pos); + eyeNext.x += Math_SinS(this->introCutsceneCameraAngle) * 200.0f; + eyeNext.y += 100.0f; + eyeNext.z += Math_CosS(this->introCutsceneCameraAngle) * 200.0f; + atNext.y += 80.0f; + Math_ApproachF(&subCam->eye.x, eyeNext.x, 0.3f, 30.0f); + Math_ApproachF(&subCam->eye.z, eyeNext.z, 0.3f, 30.0f); + Math_ApproachF(&subCam->at.x, atNext.x, 0.3f, 30.0f); + Math_ApproachF(&subCam->at.z, atNext.z, 0.3f, 30.0f); + subCam->eye.y = eyeNext.y; + subCam->at.y = atNext.y; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A476C8.s") + default: + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A477E8.s") + if (this->musicStartTimer < 11) { + this->musicStartTimer++; + if ((this->type != EN_WIZ_TYPE_FIRE_NO_BGM) && (this->musicStartTimer == 11)) { + Audio_PlayBgm_StorePrevBgm(NA_BGM_MINI_BOSS); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/EnWiz_Update.s") +/** + * Chooses which platform the Wizrobe should appear at, and updates its position accordingly. + * It also updates the position and alpha of all the ghosts. + */ +void EnWiz_SelectPlatform(EnWiz* this, PlayState* play) { + Actor* prop; + s32 i; + s32 j; + s16 ghostAlpha; + s16 type; + s16 curPlatformIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A47FCC.s") + for (i = 0; i < ARRAY_COUNT(this->platforms); i++) { + this->platforms[i] = NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A48138.s") + prop = play->actorCtx.actorLists[ACTORCAT_PROP].first; + i = 0; + while (prop != NULL) { + if (prop->id != ACTOR_EN_WIZ_BROCK) { + prop = prop->next; + continue; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/EnWiz_Draw.s") + this->platforms[i] = prop; + i++; + if (this->action != EN_WIZ_ACTION_BURST_INTO_FLAMES) { + type = this->type; + if (type == EN_WIZ_TYPE_FIRE_NO_BGM) { + type = EN_WIZ_TYPE_FIRE; + } + + prop->colChkInfo.health = type + EN_WIZ_BROCK_PLATFORM_TYPE_FIRE; + prop = prop->next; + } else { + prop->colChkInfo.health = EN_WIZ_BROCK_PLATFORM_TYPE_INACTIVE; + prop = prop->next; + } + } + + if (this->action != EN_WIZ_ACTION_DEAD) { + this->platformCount = i; + if (i < 0) { + i = 0; + } else if (this->platformCount > 10) { + this->platformCount = 10; + } + + curPlatformIndex = Rand_ZeroFloat(i); + while ((this->curPlatformIndex == curPlatformIndex) || ((s16)i == curPlatformIndex)) { + curPlatformIndex = Rand_ZeroFloat(i); + if (1) {} + } + + this->curPlatformIndex = curPlatformIndex; + switch (this->fightState) { + case EN_WIZ_FIGHT_STATE_FIRST_PHASE: + Math_Vec3f_Copy(&this->actor.world.pos, &this->platforms[curPlatformIndex]->world.pos); + break; + + case EN_WIZ_FIGHT_STATE_SECOND_PHASE_CUTSCENE: + Math_Vec3f_Copy(&this->actor.world.pos, &this->platforms[0]->world.pos); + for (i = 0, ghostAlpha = 128; i < this->platformCount; i++, ghostAlpha -= 10) { + Math_Vec3f_Copy(&this->ghostPos[i], &this->actor.world.pos); + this->ghostAlpha[i] = ghostAlpha; + } + break; + + default: + Math_Vec3f_Copy(&this->actor.world.pos, &this->platforms[curPlatformIndex]->world.pos); + for (i--; i >= 0; i--) { + if (curPlatformIndex != i) { + Math_Vec3f_Copy(&this->ghostPos[i], &this->platforms[i]->world.pos); + this->ghostRot[i] = this->actor.world.rot; + this->ghostAlpha[i] = 100; + this->ghostNextPlatformIndex[i] = i; + for (j = 0; j < ARRAY_COUNT(this->jointTable); j++) { + this->ghostJointTables[i][j] = this->jointTable[j]; + } + } else { + Math_Vec3f_Copy(&this->ghostPos[i], &gZeroVec3f); + } + } + break; + } + } +} + +/** + * Makes the ghosts run around the room from platform to platform. + */ +void EnWiz_MoveGhosts(EnWiz* this) { + s32 i; + s32 ghostNextPlatformIndex; + s32 playSfx = false; + + for (i = 0; i < this->platformCount; i++) { + if (this->ghostPos[i].x != 0.0f && this->ghostPos[i].z != 0.0f) { + f32 diffX; + f32 diffZ; + + ghostNextPlatformIndex = this->ghostNextPlatformIndex[i]; + diffX = this->platforms[ghostNextPlatformIndex]->world.pos.x - this->ghostPos[i].x; + diffZ = this->platforms[ghostNextPlatformIndex]->world.pos.z - this->ghostPos[i].z; + playSfx++; + + if (sqrtf(SQ(diffX) + SQ(diffZ)) < 30.0f) { + this->ghostNextPlatformIndex[i]--; + if (this->ghostNextPlatformIndex[i] < 0) { + this->ghostNextPlatformIndex[i] = this->platformCount - 1; + } + } + + ghostNextPlatformIndex = this->ghostNextPlatformIndex[i]; + Math_ApproachF(&this->ghostPos[i].x, this->platforms[ghostNextPlatformIndex]->world.pos.x, 0.3f, 30.0f); + Math_ApproachF(&this->ghostPos[i].y, this->platforms[ghostNextPlatformIndex]->world.pos.y, 0.3f, 30.0f); + Math_ApproachF(&this->ghostPos[i].z, this->platforms[ghostNextPlatformIndex]->world.pos.z, 0.3f, 30.0f); + this->ghostRot[i].y = + Math_Vec3f_Yaw(&this->ghostPos[i], &this->platforms[ghostNextPlatformIndex]->world.pos); + } + } + + if (playSfx) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_RUN - SFX_FLAG); + } +} + +void EnWiz_StartIntroCutscene(EnWiz* this, PlayState* play) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetFlag(this->actor.cutscene, &this->actor); + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->actor.cutscene); + this->actor.flags |= ACTOR_FLAG_100000; + EnWiz_SetupAppear(this, play); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +void EnWiz_SetupAppear(EnWiz* this, PlayState* play) { + Player* player = GET_PLAYER(play); + s32 i; + s16 angle; + + this->action = EN_WIZ_ACTION_APPEAR; + + if (this->timer == 0) { + EnWiz_SelectPlatform(this, play); + + if (this->introCutsceneState != EN_WIZ_INTRO_CS_NOT_STARTED) { + angle = Math_Vec3f_Yaw(&this->actor.world.pos, &player->actor.world.pos); + this->actor.shape.rot.y = angle; + this->actor.world.rot.y = angle; + for (i = 0; i < this->platformCount; i++) { + this->ghostRot[i].y = Math_Vec3f_Yaw(&this->ghostPos[i], &player->actor.world.pos); + } + + EnWiz_ChangeAnim(this, EN_WIZ_ANIM_IDLE, true); + this->shouldStartTimer = false; + this->targetPlatformLightAlpha = 255; + Math_Vec3f_Copy(&this->platformLightPos, &this->actor.world.pos); + + if (this->fightState == EN_WIZ_FIGHT_STATE_FIRST_PHASE) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_UNARI); + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_VOICE - SFX_FLAG); + } + } + + this->actionFunc = EnWiz_Appear; + } +} + +/** + * Makes the Wizrobe grow in scale and become more opaque. + * During the first phase, it also increases the alpha for the platform's light. + * If the player gets too close during the first phase, this will set up the Wizrobe to disappear. + */ +void EnWiz_Appear(EnWiz* this, PlayState* play) { + Vec3f staffTargetFlameScale = { 0.006f, 0.006f, 0.006f }; + Player* player = GET_PLAYER(play); + + EnWiz_HandleIntroCutscene(this, play); + + if (this->introCutsceneState >= EN_WIZ_INTRO_CS_APPEAR) { + SkelAnime_Update(&this->skelAnime); + + if ((this->fightState == EN_WIZ_FIGHT_STATE_FIRST_PHASE) && + (this->introCutsceneState >= EN_WIZ_INTRO_CS_DISAPPEAR) && + ((this->actor.xzDistToPlayer < 200.0f) || + ((player->unk_D57 != 0) && + ((ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y)) < 0x7D0)) && + (ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, BINANG_ADD(player->actor.shape.rot.y, 0x8000))) < + 0x7D0)))) { + EnWiz_SetupDisappear(this); + } else { + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0xA, 0xBB8, 0); + + if (this->fightState == EN_WIZ_FIGHT_STATE_FIRST_PHASE) { + Math_SmoothStepToS(&this->platformLightAlpha, this->targetPlatformLightAlpha, 10, 10, 10); + if (!this->shouldStartTimer) { + this->timer = 20; + this->shouldStartTimer = true; + } + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_VOICE - SFX_FLAG); + } + + if (this->timer == 0) { + Math_ApproachF(&this->scale, 0.015f, 0.05f, 0.01f); + Math_SmoothStepToS(&this->alpha, 255, 1, 5, 0); + } + + if (this->scale < 0.0138f) { + return; + } else { + this->action = EN_WIZ_ACTION_RUN_IN_CIRCLES; + this->actor.flags &= ~ACTOR_FLAG_8000000; + this->ghostColliders.elements[0].info.bumper.dmgFlags = 0x1013A22; + Math_Vec3f_Copy(&this->staffTargetFlameScale, &staffTargetFlameScale); + this->targetPlatformLightAlpha = 0; + + if (this->introCutsceneState == EN_WIZ_INTRO_CS_DISAPPEAR) { + this->timer = 0; + this->introCutsceneTimer = 20; + EnWiz_SetupDisappear(this); + } else if (this->introCutsceneState >= EN_WIZ_INTRO_CS_END) { + if (this->fightState == EN_WIZ_FIGHT_STATE_SECOND_PHASE_CUTSCENE) { + this->actionFunc = EnWiz_SetupSecondPhaseCutscene; + } else { + EnWiz_SetupDance(this); + } + } + } + } + } +} + +void EnWiz_SetupDance(EnWiz* this) { + EnWiz_ChangeAnim(this, EN_WIZ_ANIM_DANCE, false); + Math_ApproachF(&this->scale, 0.015f, 0.05f, 0.001f); + this->rotationalVelocity = 0; + this->animLoopCounter = 0; + this->action = EN_WIZ_ACTION_DANCE; + if (this->fightState >= EN_WIZ_FIGHT_STATE_SECOND_PHASE_GHOSTS_COPY_WIZROBE) { + Animation_Change(&this->ghostSkelAnime, &gWizrobeRunAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gWizrobeRunAnim), + ANIMMODE_LOOP, 0.0f); + this->fightState = EN_WIZ_FIGHT_STATE_SECOND_PHASE_GHOSTS_RUN_AROUND; + } + + Math_SmoothStepToS(&this->alpha, 255, 1, 5, 0); + this->actionFunc = EnWiz_Dance; +} + +/** + * Makes the Wizrobe spin around and dance until there are no active projectiles + * and it completes at least three loops of its dancing animation. + */ +void EnWiz_Dance(EnWiz* this, PlayState* play) { + f32 curFrame = this->skelAnime.curFrame; + s32 i; + + Math_SmoothStepToS(&this->alpha, 255, 1, 5, 0); + Math_ApproachF(&this->scale, 0.015f, 0.05f, 0.001f); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_RUN - SFX_FLAG); + this->actor.world.rot.y += this->rotationalVelocity; + if (this->fightState >= EN_WIZ_FIGHT_STATE_SECOND_PHASE_GHOSTS_RUN_AROUND) { + EnWiz_MoveGhosts(this); + } else { + for (i = 0; i < this->platformCount; i++) { + this->ghostRot[i].y += this->rotationalVelocity; + } + } + + Math_SmoothStepToS(&this->rotationalVelocity, 0x1388, 0x64, 0x3E8, 0x3E8); + Math_SmoothStepToS(&this->platformLightAlpha, this->targetPlatformLightAlpha, 20, 50, 10); + if (this->endFrame <= curFrame) { + if (this->animLoopCounter < 10) { + this->animLoopCounter++; + } + } + + if ((this->animLoopCounter >= 3) && (!this->hasActiveProjectile)) { + this->targetPlatformLightAlpha = 0; + EnWiz_SetupWindUp(this); + } +} + +void EnWiz_SetupSecondPhaseCutscene(EnWiz* this, PlayState* play) { + s16 secondPhaseCutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + + if (!ActorCutscene_GetCanPlayNext(secondPhaseCutscene)) { + ActorCutscene_SetIntentToPlay(secondPhaseCutscene); + } else { + ActorCutscene_StartAndSetFlag(secondPhaseCutscene, &this->actor); + this->subCamId = ActorCutscene_GetCurrentSubCamId(secondPhaseCutscene); + this->actor.flags |= ACTOR_FLAG_100000; + EnWiz_ChangeAnim(this, EN_WIZ_ANIM_DANCE, false); + this->action = EN_WIZ_ACTION_RUN_BETWEEN_PLATFORMS; + this->nextPlatformIndex = 1; + this->hasRunToEveryPlatform = false; + Math_SmoothStepToS(&this->alpha, 255, 1, 5, 0); + this->actionFunc = EnWiz_SecondPhaseCutscene; + } +} + +/** + * Makes the Wizrobe run between every platform in the room once before returning to its + * original platform and disappearing. Ghosts trail behind the Wizrobe as it runs. + */ +void EnWiz_SecondPhaseCutscene(EnWiz* this, PlayState* play) { + Camera* subCam; + s32 i; + + Math_SmoothStepToS(&this->alpha, 255, 1, 5, 0); + subCam = Play_GetCamera(play, this->subCamId); + Math_Vec3f_Copy(&subCam->at, &this->actor.focus.pos); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_RUN - SFX_FLAG); + if (this->platforms[this->nextPlatformIndex] != NULL) { + f32 diffX = this->actor.world.pos.x - this->platforms[this->nextPlatformIndex]->world.pos.x; + f32 diffZ = this->actor.world.pos.z - this->platforms[this->nextPlatformIndex]->world.pos.z; + s32 pad; + + if (sqrtf(SQ(diffX) + SQ(diffZ)) < 30.0f) { + if (!this->hasRunToEveryPlatform) { + this->nextPlatformIndex++; + if (this->nextPlatformIndex >= this->platformCount) { + this->hasRunToEveryPlatform = true; + this->nextPlatformIndex = 0; + } + } else { + f32 diffX = this->actor.world.pos.x - this->ghostPos[this->platformCount].x; + f32 diffZ = this->actor.world.pos.z - this->ghostPos[this->platformCount].z; + s32 pad; + s32 i; + + this->actor.flags |= ACTOR_FLAG_8000000; + if (sqrtf(SQ(diffX) + SQ(diffZ)) < 20.0f) { + for (i = 0; i < this->platformCount; i++) { + Math_Vec3f_Copy(&this->ghostPos[i], &gZeroVec3f); + } + + this->nextPlatformIndex = 0; + this->platformCount = 0; + this->fightState = EN_WIZ_FIGHT_STATE_SECOND_PHASE_GHOSTS_COPY_WIZROBE; + this->timer = 0; + ActorCutscene_Stop(ActorCutscene_GetAdditionalCutscene(this->actor.cutscene)); + this->actor.flags &= ~ACTOR_FLAG_100000; + EnWiz_SetupDisappear(this); + return; + } + } + } + } + + Math_Vec3f_Copy(this->ghostPos, &this->actor.world.pos); + this->ghostRot[0].y = this->actor.world.rot.y; + Math_ApproachF(&this->actor.world.pos.x, this->platforms[this->nextPlatformIndex]->world.pos.x, 0.3f, 30.0f); + Math_ApproachF(&this->actor.world.pos.y, this->platforms[this->nextPlatformIndex]->world.pos.y, 0.3f, 30.0f); + Math_ApproachF(&this->actor.world.pos.z, this->platforms[this->nextPlatformIndex]->world.pos.z, 0.3f, 30.0f); + for (i = this->platformCount; i > 0; i--) { + Math_Vec3f_Copy(&this->ghostPos[i], &this->ghostPos[i - 1]); + this->ghostRot[i].y = this->ghostRot[i - 1].y; + } + + this->actor.world.rot.y = + Math_Vec3f_Yaw(&this->actor.world.pos, &this->platforms[this->nextPlatformIndex]->world.pos); +} + +void EnWiz_SetupWindUp(EnWiz* this) { + EnWiz_ChangeAnim(this, EN_WIZ_ANIM_WIND_UP, false); + this->animLoopCounter = 0; + this->actionFunc = EnWiz_WindUp; +} + +/** + * Plays the wind up animation for at least two animation loops before attacking. + */ +void EnWiz_WindUp(EnWiz* this, PlayState* play) { + f32 curFrame = this->skelAnime.curFrame; + s32 i; + + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0xC8, 0x1F40, 0x1388); + if (this->fightState >= EN_WIZ_FIGHT_STATE_SECOND_PHASE_GHOSTS_RUN_AROUND) { + EnWiz_MoveGhosts(this); + } else { + for (i = 0; i < this->platformCount; i++) { + Math_SmoothStepToS(&this->ghostRot[i].y, this->actor.yawTowardsPlayer, 0xC8, 0x1F40, 0x1388); + } + } + + if (this->endFrame <= curFrame) { + this->animLoopCounter++; + if (this->animLoopCounter >= 2) { + EnWiz_SetupAttack(this); + } + } + + Math_SmoothStepToS(&this->platformLightAlpha, this->targetPlatformLightAlpha, 10, 10, 10); +} + +void EnWiz_SetupAttack(EnWiz* this) { + EnWiz_ChangeAnim(this, EN_WIZ_ANIM_ATTACK, false); + this->timer = 0; + this->shouldStartTimer = false; + this->action = EN_WIZ_ACTION_ATTACK; + this->actionFunc = EnWiz_Attack; +} + +/** + * Spawns an EnWizFire projectile that is pointed at the player, then disappears. + */ +void EnWiz_Attack(EnWiz* this, PlayState* play) { + f32 curFrame = this->skelAnime.curFrame; + + if (this->fightState >= EN_WIZ_FIGHT_STATE_SECOND_PHASE_GHOSTS_RUN_AROUND) { + EnWiz_MoveGhosts(this); + } + + if (this->timer == 0) { + if ((Animation_OnFrame(&this->skelAnime, 6.0f)) && (!this->hasActiveProjectile)) { + Player* player = GET_PLAYER(play); + Vec3f pos; + s32 type = this->type; + + Math_Vec3f_Copy(&pos, &this->actor.world.pos); + pos.x += Math_SinS(this->actor.world.rot.y) * 40.0f; + pos.y += 60.0f; + pos.z += Math_CosS(this->actor.world.rot.y) * 40.0f; + if (type == EN_WIZ_TYPE_FIRE_NO_BGM) { + type = EN_WIZ_TYPE_FIRE; + } + + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_WIZ_FIRE, pos.x, pos.y, pos.z, + Math_Vec3f_Pitch(&pos, &player->actor.world.pos), + Math_Vec3f_Yaw(&pos, &player->actor.world.pos), 0, type * 4); + this->hasActiveProjectile = true; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_MAGIC_FIRE); + } + + if ((curFrame >= 8.0f) && !this->shouldStartTimer) { + this->timer = 3; + this->shouldStartTimer = true; + } + + if (this->endFrame <= curFrame) { + EnWiz_SetupDisappear(this); + } + } +} + +void EnWiz_SetupDisappear(EnWiz* this) { + if (this->action != EN_WIZ_ACTION_DAMAGED) { + this->rotationalVelocity = 0x2710; + this->timer = 0; + EnWiz_ChangeAnim(this, EN_WIZ_ANIM_IDLE, false); + this->action = EN_WIZ_ACTION_DISAPPEAR; + } else { + this->rotationalVelocity = 0x2710; + this->actor.world.rot.y += this->rotationalVelocity; + } + + this->targetPlatformLightAlpha = 0; + this->actor.flags |= ACTOR_FLAG_8000000; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_DISAPPEAR); + Math_SmoothStepToS(&this->rotationalVelocity, 0x1388, 0x64, 0x3E8, 0x3E8); + this->actor.world.rot.y += this->rotationalVelocity; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actionFunc = EnWiz_Disappear; +} + +/** + * Spin the Wizrobe around and shrink it so that it disappears into its platform. + * Afterwards, set it up to appear again. + */ +void EnWiz_Disappear(EnWiz* this, PlayState* play) { + s32 i; + + Math_SmoothStepToS(&this->rotationalVelocity, 0, 0xA, 0xBB8, 0x14); + this->actor.world.rot.y += this->rotationalVelocity; + if ((this->fightState == EN_WIZ_FIGHT_STATE_FIRST_PHASE) || (this->action == EN_WIZ_ACTION_DAMAGED)) { + Math_ApproachZeroF(&this->scale, 0.3f, 0.01f); + Math_SmoothStepToS(&this->platformLightAlpha, this->targetPlatformLightAlpha, 5, 50, 0); + } else { + Math_ApproachZeroF(&this->scale, 0.3f, 0.001f); + Math_SmoothStepToS(&this->platformLightAlpha, this->targetPlatformLightAlpha, 10, 50, 0); + for (i = 0; i < this->platformCount; i++) { + this->ghostRot[i].y += this->rotationalVelocity; + } + } + + Math_Vec3f_Copy(&this->staffTargetFlameScale, &gZeroVec3f); + if (this->scale < 0.001f) { + this->scale = 0.0f; + + if ((this->introCutsceneState == EN_WIZ_INTRO_CS_DISAPPEAR) && (this->introCutsceneTimer == 0)) { + this->introCutsceneState = EN_WIZ_INTRO_CS_END; + ActorCutscene_Stop(this->actor.cutscene); + this->actor.flags &= ~ACTOR_FLAG_100000; + } + + if (this->introCutsceneState != EN_WIZ_INTRO_CS_DISAPPEAR) { + this->alpha = 0; + if (this->fightState == EN_WIZ_FIGHT_STATE_FIRST_PHASE) { + this->ghostColliders.elements[0].info.bumper.dmgFlags = 0x1000202; + } + + this->actor.flags |= ACTOR_FLAG_1; + this->actionFunc = EnWiz_SetupAppear; + } + } +} + +void EnWiz_SetupDamaged(EnWiz* this, PlayState* play) { + EnWiz_ChangeAnim(this, EN_WIZ_ANIM_DAMAGE, false); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + this->timer = 20; + + if ((this->fightState != EN_WIZ_FIGHT_STATE_FIRST_PHASE) && (this->actor.colChkInfo.health <= 0)) { + Enemy_StartFinishingBlow(play, &this->actor); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_DEAD); + this->timer = 0; + this->actor.flags &= ~ACTOR_FLAG_1; + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_DAMAGE); + } + + this->scale = 0.015f; + this->platformCount = 0; + this->targetPlatformLightAlpha = 0; + if ((this->drawDmgEffTimer != 0) && + ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) || (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_LIGHT_ORBS))) { + this->timer = 0; + } + + this->rotationalVelocity = 0x4E20; + if ((this->drawDmgEffTimer != 0) && (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_SFX)) { + this->rotationalVelocity = 0; + this->timer = 0; + } + + this->action = EN_WIZ_ACTION_DAMAGED; + this->actionFunc = EnWiz_Damaged; +} + +/** + * Spins the Wizrobe around quickly and makes it jump in the air if it was defeated or if + * it was damaged in a certain way. Afterwards, the Wizrobe either disappears or dies. + */ +void EnWiz_Damaged(EnWiz* this, PlayState* play) { + s32 i; + + if ((this->drawDmgEffTimer < 50) && (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_SFX)) { + Actor_SpawnIceEffects(play, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), 2, 1.0f, 0.7f); + this->drawDmgEffTimer = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->rotationalVelocity = 0x4E20; + this->actor.velocity.y = 30.0f; + this->actor.gravity = -3.0f; + } + + if ((this->drawDmgEffTimer != 0) && (this->drawDmgEffTimer < 30) && + ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) || (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_LIGHT_ORBS))) { + this->actor.velocity.y = 30.0f; + this->actor.gravity = -3.0f; + this->drawDmgEffTimer = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + } else if (!this->isDead && (this->fightState != EN_WIZ_FIGHT_STATE_FIRST_PHASE) && + (this->actor.colChkInfo.health <= 0)) { + this->actor.velocity.y = 30.0f; + this->actor.gravity = -3.0f; + this->isDead = true; + } + + this->actor.world.rot.y += this->rotationalVelocity; + Math_SmoothStepToS(&this->rotationalVelocity, 0, 0xA, 0xBB8, 0x14); + for (i = 0; i < this->platformCount; i++) { + this->ghostRot[i].y += this->rotationalVelocity; + } + + if ((this->timer == 1) || + ((this->actor.velocity.y < 0.0f) && + (this->actor.world.pos.y < (this->platforms[this->curPlatformIndex]->world.pos.y + 11.0f)))) { + this->timer = 0; + this->actor.velocity.y = 0.0f; + this->actor.gravity = 0.0f; + this->drawDmgEffTimer = this->timer; + this->drawDmgEffType = this->timer; + + if (this->actor.colChkInfo.health <= 0) { + if (this->fightState == EN_WIZ_FIGHT_STATE_FIRST_PHASE) { + this->fightState = EN_WIZ_FIGHT_STATE_SECOND_PHASE_CUTSCENE; + if ((this->type == EN_WIZ_TYPE_FIRE) || (this->type == EN_WIZ_TYPE_FIRE_NO_BGM)) { + this->actor.colChkInfo.health = 8; + } else { + this->actor.colChkInfo.health = 6; + } + + EnWiz_SetupDisappear(this); + } else { + EnWiz_SetupDead(this); + } + } else { + EnWiz_SetupDisappear(this); + } + + this->actor.flags |= ACTOR_FLAG_8000000; + } + + Math_SmoothStepToS(&this->platformLightAlpha, this->targetPlatformLightAlpha, 20, 50, 10); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(play, &this->actor, 35.0f, 40.0f, 40.0f, 0x1F); +} + +void EnWiz_SetupDead(EnWiz* this) { + EnWiz_ChangeAnim(this, EN_WIZ_ANIM_DAMAGE, false); + this->rotationalVelocity = 0x2710; + this->action = EN_WIZ_ACTION_DEAD; + this->timer = 0; + this->actionFunc = EnWiz_Dead; +} + +/** + * Slows the Wizrobe's rotation to a stop, then makes it burst into flames. + * If the Wizrobe has a switch flag, it will set that switch flag when it dies. + */ +void EnWiz_Dead(EnWiz* this, PlayState* play) { + s32 i; + + this->actor.world.rot.y += this->rotationalVelocity; + Math_SmoothStepToS(&this->rotationalVelocity, 0, 0xA, 0xBB8, 0x14); + if (this->rotationalVelocity < 0x1E) { + Math_SmoothStepToS(&this->alpha, 0, 10, 30, 20); + for (i = 0; i < this->platformCount; i++) { + Math_SmoothStepToS(&this->ghostAlpha[i], 0, 10, 30, 20); + } + + this->action = EN_WIZ_ACTION_BURST_INTO_FLAMES; + } + + if (this->alpha < 30) { + EnWiz_SelectPlatform(this, play); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 50, NA_SE_EN_EXTINCT); + Actor_MarkForDeath(&this->actor); + if (this->switchFlag >= 0) { + Flags_SetSwitch(play, this->switchFlag); + } + } +} + +static Color_RGBA8 sDustPrimColor = { 250, 250, 250, 255 }; +static Color_RGBA8 sDustEnvTimer = { 180, 180, 180, 255 }; + +void EnWiz_UpdateDamage(EnWiz* this, PlayState* play) { + s32 i; + s32 attackDealsDamage = false; + + if (this->collider.base.acFlags & AC_HIT) { + this->ghostColliders.base.acFlags &= ~AC_HIT; + if (this->action < EN_WIZ_ACTION_RUN_IN_CIRCLES) { + return; + } + + switch (this->actor.colChkInfo.damageEffect) { + case EN_WIZ_DMGEFF_NONE: + attackDealsDamage = true; + break; + + case EN_WIZ_DMGEFF_FIRE: + if (this->type == EN_WIZ_TYPE_ICE) { + this->drawDmgEffTimer = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + } + + attackDealsDamage = true; + break; + + case EN_WIZ_DMGEFF_FREEZE: + if ((this->type == EN_WIZ_TYPE_FIRE) || (this->type == EN_WIZ_TYPE_FIRE_NO_BGM)) { + this->drawDmgEffTimer = 80; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_SFX; + this->drawDmgEffScale = 0.0f; + this->drawDmgEffFrozenSteamScale = 1.5f; + } + + Actor_ApplyDamage(&this->actor); + EnWiz_SetupDamaged(this, play); + break; + + case EN_WIZ_DMGEFF_LIGHT_ORB: + if (((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_SFX) && + (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) || + (this->drawDmgEffTimer == 0)) { + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->actor.focus.pos.x, + this->actor.focus.pos.y, this->actor.focus.pos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); + this->drawDmgEffTimer = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + attackDealsDamage = true; + } + break; + } + + this->alpha = 255; + if (attackDealsDamage) { + Actor_ApplyDamage(&this->actor); + EnWiz_SetupDamaged(this, play); + return; + } + } + + if ((this->platformCount != 0) && (this->fightState != EN_WIZ_FIGHT_STATE_SECOND_PHASE_CUTSCENE)) { + for (i = 0; i < this->platformCount; i++) { + Vec3f accel; + Vec3f velocity; + Vec3f pos; + f32 scaleStep; + s32 j; + + // If the player throws a Deku Nut or hits a ghost's collider (something that is impossible + // in the final game, since EnWiz_Init effectively disables them), then the below code will + // "destroy" the ghost by turning into a cloud of smoke. + if ((iREG(50) != 0) || (this->ghostColliders.elements[i + 1].info.bumperFlags & BUMP_HIT)) { + //! @bug: If a single ghost is destroyed, then changing the fight state here will cause + //! strange behavior; the ghosts will stand still and pretend to attack the player like + //! the real Wizrobe. Since Deku Nuts destroy all ghosts at once, and since the ghost + //! colliders are effectively disabled, this doesn't cause any problems in the final + //! game, but it becomes an issue if the ghost colliders are enabled. + this->fightState = EN_WIZ_FIGHT_STATE_SECOND_PHASE_GHOSTS_COPY_WIZROBE; + this->ghostColliders.base.acFlags &= ~BUMP_HIT; + if (this->ghostPos[i].x != .0f || this->ghostPos[i].z != .0f) { + for (j = 0; j < 9; j++) { + accel.x = 0.0f; + accel.y = 1.0f; + accel.z = 0.0f; + velocity.x = 0.0f; + velocity.y = 1.0f; + velocity.z = 0.0f; + scaleStep = Rand_S16Offset(20, 10); + Math_Vec3f_Copy(&pos, &this->ghostPos[i]); + pos.x += (f32)Rand_S16Offset(20, 20) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1); + pos.y += 70.0f + randPlusMinusPoint5Scaled(30.0f); + pos.z += (f32)Rand_S16Offset(20, 20) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1); + func_800B0DE0(play, &pos, &velocity, &accel, &sDustPrimColor, &sDustEnvTimer, + Rand_S16Offset(350, 100), scaleStep); + } + + SoundSource_PlaySfxAtFixedWorldPos(play, &this->ghostPos[i], 50, NA_SE_EN_WIZ_LAUGH); + Math_Vec3f_Copy(&this->ghostPos[i], &gZeroVec3f); + } + } + } + } +} + +void EnWiz_Update(Actor* thisx, PlayState* play) { + s32 pad; + EnWiz* this = THIS; + s32 i; + s32 j; + + if (this->action != EN_WIZ_ACTION_APPEAR) { + SkelAnime_Update(&this->skelAnime); + SkelAnime_Update(&this->ghostSkelAnime); + } + + Actor_SetFocus(&this->actor, 60.0f); + Actor_SetScale(&this->actor, this->scale); + EnWiz_UpdateDamage(this, play); + this->actionFunc(this, play); + + this->actor.shape.rot.y = this->actor.world.rot.y; + + DECR(this->timer); + DECR(this->introCutsceneTimer); + DECR(this->drawDmgEffTimer); + + this->collider.dim.radius = 35; + this->collider.dim.height = 130; + this->collider.dim.yShift = 0; + if (this->action >= EN_WIZ_ACTION_RUN_IN_CIRCLES) { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->ghostColliders.base); + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + } + + Math_ApproachF(&this->staffFlameScale.x, this->staffTargetFlameScale.x, 0.3f, 0.002f); + Math_ApproachF(&this->staffFlameScale.y, this->staffTargetFlameScale.y, 0.3f, 0.002f); + Math_ApproachF(&this->staffFlameScale.z, this->staffTargetFlameScale.z, 0.3f, 0.002f); + + if (this->fightState == EN_WIZ_FIGHT_STATE_FIRST_PHASE) { + this->platformCount = 0; + } else if (this->fightState == EN_WIZ_FIGHT_STATE_SECOND_PHASE_GHOSTS_RUN_AROUND) { + for (i = 0; i < this->platformCount; i++) { + for (j = 0; j < ARRAY_COUNT(this->ghostBaseJointTable); j++) { + this->ghostJointTables[i][j] = this->ghostBaseJointTable[j]; + } + } + } else { + for (i = 0; i < this->platformCount; i++) { + for (j = 0; j < ARRAY_COUNT(this->jointTable); j++) { + this->ghostJointTables[i][j] = this->jointTable[j]; + } + } + } +} + +void EnWiz_PostLimbDrawOpa(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + Vec3f staffFlamePos = { 0.0f, 0.0f, 0.0f }; + EnWiz* this = THIS; + + if (limbIndex == WIZROBE_LIMB_STAFF) { + staffFlamePos.x = 7300.0f; + staffFlamePos.y = -1500.0f; + if (this->action != EN_WIZ_ACTION_DANCE) { + staffFlamePos.y = 0.0f; + staffFlamePos.x = 5300.0f; + } + + Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_MultVec3f(&staffFlamePos, &this->staffFlamePos); + } + + Collider_UpdateSpheres(limbIndex, &this->ghostColliders); + + if ((limbIndex == WIZROBE_LIMB_PELVIS) || (limbIndex == WIZROBE_LIMB_TORSO) || + (limbIndex == WIZROBE_LIMB_LEFT_UPPER_ARM) || (limbIndex == WIZROBE_LIMB_LEFT_FOREARM) || + (limbIndex == WIZROBE_LIMB_RIGHT_UPPER_ARM) || (limbIndex == WIZROBE_LIMB_RIGHT_FOREARM) || + (limbIndex == WIZROBE_LIMB_NECK) || (limbIndex == WIZROBE_LIMB_HEAD) || (limbIndex == WIZROBE_LIMB_JAW) || + (limbIndex == WIZROBE_LIMB_LEFT_SHIN) || (limbIndex == WIZROBE_LIMB_RIGHT_SHIN) || + (limbIndex == WIZROBE_LIMB_LOINCLOTH)) { + Matrix_MultZero(&this->bodyPartsPos[this->bodyPartsPosIndex]); + this->bodyPartsPosIndex++; + if (this->bodyPartsPosIndex >= ARRAY_COUNT(this->bodyPartsPos)) { + this->bodyPartsPosIndex = 0; + } + } +} + +void EnWiz_PostLimbDrawXlu(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { + Vec3f staffFlamePos = { 0.0f, 0.0f, 0.0f }; + s32 pad; + EnWiz* this = THIS; + + if (this->action != EN_WIZ_ACTION_BURST_INTO_FLAMES) { + if (limbIndex == WIZROBE_LIMB_STAFF) { + staffFlamePos.x = 7300.0f; + staffFlamePos.y = -1500.0f; + if (this->action != EN_WIZ_ACTION_DANCE) { + staffFlamePos.y = 0.0f; + staffFlamePos.x = 5300.0f; + } + + Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_MultVec3f(&staffFlamePos, &this->staffFlamePos); + } + } else { + if (this->timer == 0) { + Vec3f flamePos; + + Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_MultVec3f(&staffFlamePos, &flamePos); + flamePos.x += randPlusMinusPoint5Scaled(4.0f); + flamePos.y += randPlusMinusPoint5Scaled(7.0f); + flamePos.z += randPlusMinusPoint5Scaled(5.0f); + func_800B3030(play, &flamePos, &gZeroVec3f, &gZeroVec3f, ((Rand_ZeroFloat(1.0f) * 50.0f) + 70.0f), 10, 1); + SoundSource_PlaySfxAtFixedWorldPos(play, &flamePos, 10, NA_SE_EN_EXTINCT); + } + + if ((limbIndex >= WIZROBE_LIMB_RIGHT_FOOT) && (this->timer == 0)) { + this->timer = 4; + } + } + + if ((limbIndex == WIZROBE_LIMB_PELVIS) || (limbIndex == WIZROBE_LIMB_TORSO) || + (limbIndex == WIZROBE_LIMB_LEFT_UPPER_ARM) || (limbIndex == WIZROBE_LIMB_LEFT_FOREARM) || + (limbIndex == WIZROBE_LIMB_RIGHT_UPPER_ARM) || (limbIndex == WIZROBE_LIMB_RIGHT_FOREARM) || + (limbIndex == WIZROBE_LIMB_NECK) || (limbIndex == WIZROBE_LIMB_HEAD) || (limbIndex == WIZROBE_LIMB_JAW) || + (limbIndex == WIZROBE_LIMB_LEFT_SHIN) || (limbIndex == WIZROBE_LIMB_RIGHT_SHIN) || + (limbIndex == WIZROBE_LIMB_LOINCLOTH)) { + Matrix_MultZero(&this->bodyPartsPos[this->bodyPartsPosIndex]); + this->bodyPartsPosIndex++; + if (this->bodyPartsPosIndex >= ARRAY_COUNT(this->bodyPartsPos)) { + this->bodyPartsPosIndex = 0; + } + } +} + +void EnWiz_Draw(Actor* thisx, PlayState* play) { + s32 pad; + EnWiz* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + + if ((this->action == EN_WIZ_ACTION_BURST_INTO_FLAMES) || (this->alpha != 255)) { + Scene_SetRenderModeXlu(play, 1, 2); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->alpha); + POLY_XLU_DISP = + SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, EnWiz_PostLimbDrawXlu, &this->actor, POLY_XLU_DISP); + } else { + Scene_SetRenderModeXlu(play, 0, 1); + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, this->alpha); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, EnWiz_PostLimbDrawOpa, &this->actor); + } + + if (this->drawDmgEffTimer != 0) { + f32 drawDmgEffAlpha = this->drawDmgEffTimer * 0.05f; + + if ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_SFX) || + (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) { + this->drawDmgEffScale += 0.3f; + if (this->drawDmgEffScale > 0.5f) { + this->drawDmgEffScale = 0.5f; + } + + Math_ApproachF(&this->drawDmgEffFrozenSteamScale, this->drawDmgEffScale, 0.1f, 0.04f); + } else { + this->drawDmgEffScale = 0.8f; + this->drawDmgEffFrozenSteamScale = 0.8f; + } + + Actor_DrawDamageEffects(play, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), + this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, drawDmgEffAlpha, + this->drawDmgEffType); + } + + if (this->platformCount > 0) { + s32 i; + s16 platformCount; + + Matrix_Push(); + + platformCount = this->platformCount; + if (this->fightState == EN_WIZ_FIGHT_STATE_SECOND_PHASE_CUTSCENE) { + platformCount = 10; + } + + for (i = 0; i < platformCount; i++) { + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + + if ((this->ghostPos[i].x != 0.0f) && (this->ghostPos[i].z != 0.0f)) { + Matrix_Translate(this->ghostPos[i].x, this->ghostPos[i].y + 10.0f, this->ghostPos[i].z, MTXMODE_NEW); + Matrix_Scale(this->scale, this->scale, this->scale, MTXMODE_APPLY); + Matrix_RotateYS(this->ghostRot[i].y, MTXMODE_APPLY); + Matrix_RotateXS(this->ghostRot[i].x, MTXMODE_APPLY); + Matrix_RotateZS(this->ghostRot[i].z, MTXMODE_APPLY); + Scene_SetRenderModeXlu(play, 1, 2); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->ghostAlpha[i]); + POLY_XLU_DISP = + SkelAnime_DrawFlex(play, this->ghostSkelAnime.skeleton, this->ghostJointTables[i], + this->ghostSkelAnime.dListCount, NULL, NULL, &this->actor, POLY_XLU_DISP); + this->ghostColliders.elements[i + 1].dim.worldSphere.center.x = this->ghostPos[i].x; + this->ghostColliders.elements[i + 1].dim.worldSphere.center.y = this->ghostPos[i].y + 50.0f; + this->ghostColliders.elements[i + 1].dim.worldSphere.center.z = this->ghostPos[i].z; + this->ghostColliders.elements[i + 1].dim.worldSphere.radius = + this->ghostColliders.elements[0].dim.modelSphere.radius; + this->ghostColliders.elements[i + 1].dim.scale = this->ghostColliders.elements[0].dim.scale; + } + } + + Matrix_Pop(); + } + + func_8012C2DC(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + + // Draw the light emanating from the Wizrobe's platform + if (this->fightState == EN_WIZ_FIGHT_STATE_FIRST_PHASE) { + Matrix_Push(); + + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&gWizrobePlatformLightTexAnim)); + Matrix_Translate(this->platformLightPos.x, this->platformLightPos.y, this->platformLightPos.z, MTXMODE_NEW); + Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, this->platformLightAlpha); + + if ((this->type == EN_WIZ_TYPE_FIRE) || (this->type == EN_WIZ_TYPE_FIRE_NO_BGM)) { + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 100, 255); + } else { + gDPSetEnvColor(POLY_XLU_DISP++, 50, 0, 255, 255); + } + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gWizrobePlatformLightDL); + + Matrix_Pop(); + } + + // Draw the flame at the tip of the Wizrobe's staff + Matrix_Translate(this->staffFlamePos.x, this->staffFlamePos.y, this->staffFlamePos.z, MTXMODE_NEW); + Matrix_Scale(this->staffFlameScale.x, this->staffFlameScale.y, this->staffFlameScale.z, MTXMODE_APPLY); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, + ((this->staffFlameScroll * 10) - (play->state.frames * 20)) % 512, 32, 128)); + gDPPipeSync(POLY_XLU_DISP++); + + if ((this->type == EN_WIZ_TYPE_FIRE) || (this->type == EN_WIZ_TYPE_FIRE_NO_BGM)) { + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 170, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 50, 0, 255); + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 170, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 50, 255, 255); + } + + Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Wiz/z_en_wiz.h b/src/overlays/actors/ovl_En_Wiz/z_en_wiz.h index a1ae32032c..3d18abab25 100644 --- a/src/overlays/actors/ovl_En_Wiz/z_en_wiz.h +++ b/src/overlays/actors/ovl_En_Wiz/z_en_wiz.h @@ -2,6 +2,16 @@ #define Z_EN_WIZ_H #include "global.h" +#include "objects/object_wiz/object_wiz.h" + +#define EN_WIZ_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) +#define EN_WIZ_GET_TYPE(thisx) (((thisx)->params >> 8) & 0xFF) + +typedef enum { + /* 0 */ EN_WIZ_TYPE_FIRE, + /* 1 */ EN_WIZ_TYPE_ICE, + /* 2 */ EN_WIZ_TYPE_FIRE_NO_BGM, // does not request the mini-boss BGM +} EnWizType; struct EnWiz; @@ -9,15 +19,62 @@ typedef void (*EnWizActionFunc)(struct EnWiz*, PlayState*); typedef struct EnWiz { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x268]; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[WIZROBE_LIMB_MAX]; + /* 0x200 */ Vec3s morphTable[WIZROBE_LIMB_MAX]; + /* 0x278 */ SkelAnime ghostSkelAnime; + /* 0x2BC */ Vec3s ghostBaseJointTable[WIZROBE_LIMB_MAX]; + /* 0x334 */ Vec3s ghostMorphTable[WIZROBE_LIMB_MAX]; /* 0x3AC */ EnWizActionFunc actionFunc; - /* 0x3B0 */ char unk_3B0[0xA]; - /* 0x3BA */ s16 unk_3BA; - /* 0x3BC */ char unk_3BC[0x8C]; - /* 0x448 */ s32 unk_448; - /* 0x44C */ char unk_44C[0x2FE]; - /* 0x74A */ s16 unk_74A; - /* 0x74C */ char unk_74C[0x634]; + /* 0x3B0 */ s16 action; + /* 0x3B2 */ s16 timer; + /* 0x3B4 */ s16 introCutsceneTimer; + /* 0x3B6 */ s16 fightState; + /* 0x3B8 */ s16 staffFlameScroll; + /* 0x3BA */ s16 hasActiveProjectile; + /* 0x3BC */ s16 hasRunToEveryPlatform; // used for the second phase cutscene to make sure the Wizrobe visits every platform + /* 0x3BE */ s16 unk_3BE; // unused, inferred from surrounding members + /* 0x3C0 */ s16 rotationalVelocity; + /* 0x3C2 */ s16 alpha; + /* 0x3C4 */ s16 platformLightAlpha; + /* 0x3C6 */ s16 targetPlatformLightAlpha; + /* 0x3C8 */ s16 introCutsceneCameraAngle; + /* 0x3CA */ u8 shouldStartTimer; + /* 0x3CB */ u8 introCutsceneState; + /* 0x3CC */ s32 musicStartTimer; + /* 0x3D0 */ f32 endFrame; + /* 0x3D4 */ f32 scale; + /* 0x3D8 */ Vec3f staffFlamePos; + /* 0x3E4 */ Vec3f staffFlameScale; + /* 0x3F0 */ Vec3f staffTargetFlameScale; + /* 0x3FC */ Vec3f unk_3FC; // unused, inferred from surrounding members + /* 0x408 */ Vec3f unk_408; // unused, inferred from surrounding members + /* 0x414 */ Vec3f platformLightPos; + /* 0x420 */ Actor* platforms[10]; + /* 0x448 */ Actor* freezard; + /* 0x44C */ s16 animLoopCounter; + /* 0x450 */ f32 unk_450; // set to 1.0f, but never used + /* 0x454 */ ColliderJntSph ghostColliders; + /* 0x474 */ ColliderJntSphElement ghostColliderElements[10]; + /* 0x6F4 */ ColliderCylinder collider; + /* 0x740 */ s32 platformCount; + /* 0x744 */ s32 nextPlatformIndex; // used for the second phase cutscene to dictate where the Wizrobe should run to next + /* 0x748 */ s16 curPlatformIndex; + /* 0x74A */ s16 type; + /* 0x74C */ s16 switchFlag; + /* 0x74E */ s16 subCamId; + /* 0x750 */ s16 isDead; + /* 0x752 */ s16 drawDmgEffTimer; + /* 0x754 */ s16 drawDmgEffType; + /* 0x758 */ f32 drawDmgEffScale; + /* 0x75C */ f32 drawDmgEffFrozenSteamScale; + /* 0x760 */ Vec3f bodyPartsPos[12]; + /* 0x7F0 */ s16 bodyPartsPosIndex; + /* 0x7F2 */ s16 ghostAlpha[10]; + /* 0x806 */ s16 ghostNextPlatformIndex[10]; + /* 0x81C */ Vec3f ghostPos[10]; + /* 0x894 */ Vec3s ghostRot[10]; + /* 0x8D0 */ Vec3s ghostJointTables[10][WIZROBE_LIMB_MAX]; } EnWiz; // size = 0xD80 extern const ActorInit En_Wiz_InitVars; diff --git a/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c b/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c index d49e71c08c..ce13687a7c 100644 --- a/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c +++ b/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c @@ -1,7 +1,7 @@ /* * File: z_en_wiz_brock.c * Overlay: ovl_En_Wiz_Brock - * Description: Wizzrobe Warp Platform + * Description: Wizrobe Warp Platform */ #include "z_en_wiz_brock.h" @@ -11,13 +11,6 @@ #define THIS ((EnWizBrock*)thisx) -typedef enum { - PLATFORM_TYPE_INACTIVE, - PLATFORM_TYPE_FIRE, - PLATFORM_TYPE_ICE, - PLATFORM_TYPE_MAX, -} PlatformType; - void EnWizBrock_Init(Actor* thisx, PlayState* play); void EnWizBrock_Destroy(Actor* thisx, PlayState* play); void EnWizBrock_Update(Actor* thisx, PlayState* play); @@ -26,7 +19,7 @@ void EnWizBrock_Draw(Actor* thisx, PlayState* play); void EnWizBrock_SetupUpdateStatus(EnWizBrock* this, PlayState* play); void EnWizBrock_UpdateStatus(EnWizBrock* this, PlayState* play); -s16 platformCount = 0; +s16 sPlatformIndex = 0; const ActorInit En_Wiz_Brock_InitVars = { ACTOR_EN_WIZ_BROCK, @@ -45,13 +38,13 @@ void EnWizBrock_Init(Actor* thisx, PlayState* play) { CollisionHeader* colHeader = NULL; DynaPolyActor_Init(&this->dyna, 0); - CollisionHeader_GetVirtual(&object_wiz_Colheader_001690, &colHeader); + CollisionHeader_GetVirtual(&gWizrobePlatformCol, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; this->dyna.actor.colChkInfo.health = 3; this->unk_1A6 = 0; Actor_SetScale(&this->dyna.actor, 0.01f); - this->platformNum = platformCount++; + this->platformIndex = sPlatformIndex++; this->actionFunc = EnWizBrock_SetupUpdateStatus; this->dyna.actor.scale.x = this->dyna.actor.scale.y = this->dyna.actor.scale.z = 0.01f; this->alpha = 255.0f; @@ -68,12 +61,12 @@ void EnWizBrock_SetupUpdateStatus(EnWizBrock* this, PlayState* play) { } /** - * @brief Checks the platform status, when the Wizzrobe is defeated, which triggers timer to + * @brief Checks the platform status, when the Wizrobe is defeated, which triggers timer to * count up to 30 at which point the platforms are despawned. */ void EnWizBrock_UpdateStatus(EnWizBrock* this, PlayState* play) { - if (this->platformType == PLATFORM_TYPE_INACTIVE) { - if (this->dyna.actor.colChkInfo.health != PLATFORM_TYPE_MAX) { + if (this->platformType == EN_WIZ_BROCK_PLATFORM_TYPE_INACTIVE) { + if (this->dyna.actor.colChkInfo.health != EN_WIZ_BROCK_PLATFORM_TYPE_MAX) { this->platformType = this->dyna.actor.colChkInfo.health; } } @@ -115,30 +108,30 @@ void EnWizBrock_Draw(Actor* thisx, PlayState* play) { Scene_SetRenderModeXlu(play, 0, 1); gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); - Gfx_DrawDListOpa(play, gWizzrobePlatform); + Gfx_DrawDListOpa(play, gWizrobePlatformDL); } else { Scene_SetRenderModeXlu(play, 1, 2); gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, (s16)this->alpha); - Gfx_DrawDListXlu(play, gWizzrobePlatform); + Gfx_DrawDListXlu(play, gWizrobePlatformDL); } CLOSE_DISPS(play->state.gfxCtx); - if (this->platformType != PLATFORM_TYPE_INACTIVE) { + if (this->platformType != EN_WIZ_BROCK_PLATFORM_TYPE_INACTIVE) { OPEN_DISPS(play->state.gfxCtx); - AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&gWizzrobePlatformTexAnim)); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&gWizrobePlatformCenterTexAnim)); gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 255, 255); - if (this->platformType == PLATFORM_TYPE_FIRE) { + if (this->platformType == EN_WIZ_BROCK_PLATFORM_TYPE_FIRE) { gDPSetEnvColor(POLY_XLU_DISP++, 255, 00, 100, (s16)this->alpha); } else { gDPSetEnvColor(POLY_XLU_DISP++, 50, 00, 255, (s16)this->alpha); } gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, &gWizzrobePlatformCenter); + gSPDisplayList(POLY_XLU_DISP++, &gWizrobePlatformCenterDL); CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.h b/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.h index 0f01506976..3b23d08b0f 100644 --- a/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.h +++ b/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.h @@ -3,6 +3,13 @@ #include "global.h" +typedef enum { + /* 0 */ EN_WIZ_BROCK_PLATFORM_TYPE_INACTIVE, + /* 1 */ EN_WIZ_BROCK_PLATFORM_TYPE_FIRE, + /* 2 */ EN_WIZ_BROCK_PLATFORM_TYPE_ICE, + /* 3 */ EN_WIZ_BROCK_PLATFORM_TYPE_MAX, +} EnWizBrockPlatformType; + struct EnWizBrock; typedef void (*EnWizBrockActionFunc)(struct EnWizBrock*, PlayState*); @@ -12,8 +19,8 @@ typedef struct EnWizBrock { /* 0x15C */ UNK_TYPE1 unk_15C[0x44]; /* 0x1A0 */ EnWizBrockActionFunc actionFunc; /* 0x1A4 */ s16 timer; // Counter for despawing blocks (Max of 37) - /* 0x1A6 */ s16 unk_1A6; // TODO: set but not used maybe used in wizzrobe? - /* 0x1A8 */ s16 platformNum; // Numeric identifier for platform + /* 0x1A6 */ s16 unk_1A6; // set to 0, but never used + /* 0x1A8 */ s16 platformIndex; // Numeric identifier for platform /* 0x1AA */ s16 platformType; // Determines element type for platform (ice/fire) /* 0x1AC */ f32 alpha; } EnWizBrock; // size = 0x1B0 diff --git a/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c b/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c index 666a5156bd..eea112f894 100644 --- a/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c +++ b/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c @@ -1,7 +1,7 @@ /* * File: z_en_wiz_fire.c * Overlay: ovl_En_Wiz_Fire - * Description: Wizzrobe Fire/Ice Attack + * Description: Wizrobe Fire/Ice Attack */ #include "z_en_wiz_fire.h" @@ -17,18 +17,25 @@ void EnWizFire_Destroy(Actor* thisx, PlayState* play); void EnWizFire_Update(Actor* thisx, PlayState* play); void EnWizFire_Draw(Actor* thisx, PlayState* play); -void func_80A4984C(EnWizFire* this, PlayState* play); -void func_80A49A44(EnWizFire* this, PlayState* play); -void func_80A49F38(EnWizFire* this, PlayState* play); -void func_80A49FD8(EnWizFire* this, PlayState* play); -void func_80A4A11C(EnWizFire* this, PlayState* play); -void func_80A4A608(EnWizFire* this, PlayState* play); -void func_80A4BAB4(Actor* thisx, PlayState* play); -void func_80A4BC74(EnWizFire* this, Vec3f* arg1, Vec3f* arg2); -void func_80A4BDDC(EnWizFire* this, PlayState* play); -void func_80A4BF78(EnWizFire* this, PlayState* play); +void EnWiz_SetupMoveMagicProjectile(EnWizFire* this, PlayState* play); +void EnWiz_MoveMagicProjectile(EnWizFire* this, PlayState* play); +void EnWiz_SetupSmallFlame(EnWizFire* this, PlayState* play); +void EnWiz_SmallFlame(EnWizFire* this, PlayState* play); +void EnWiz_Pool(EnWizFire* this, PlayState* play); +void EnWiz_KillMagicProjectile(EnWizFire* this, PlayState* play); +void EnWizFire_DrawSmallFlame(Actor* thisx, PlayState* play); +void EnWizFire_InitializeEffect(EnWizFire* this, Vec3f* pos, Vec3f* accel); +void EnWizFire_UpdateEffects(EnWizFire* this, PlayState* play); +void EnWizFire_DrawEffects(EnWizFire* this, PlayState* play); -static s32 D_80A4C1C0 = 0; +typedef enum { + /* 0 */ EN_WIZ_FIRE_ACTION_MOVE_MAGIC_PROJECTILE, + /* 1 */ EN_WIZ_FIRE_ACTION_SMALL_FLAME, + /* 2 */ EN_WIZ_FIRE_ACTION_POOL, + /* 3 */ EN_WIZ_FIRE_ACTION_KILL_MAGIC_PROJECTILE, +} EnWizFireAction; + +static s32 sPoolHitByIceArrow = false; const ActorInit En_Wiz_Fire_InitVars = { ACTOR_EN_WIZ_FIRE, @@ -66,48 +73,52 @@ void EnWizFire_Init(Actor* thisx, PlayState* play) { EnWizFire* this = THIS; Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); - this->unk_162 = this->actor.params; + this->type = EN_WIZ_FIRE_GET_TYPE(&this->actor); this->actor.targetMode = 3; - this->unk_172 = 10; - this->unk_1FC = 255.0f; + this->wallCheckTimer = 10; + this->alpha = 255.0f; this->actor.flags &= ~ACTOR_FLAG_1; if (!Player_HasMirrorShieldEquipped(play)) { this->collider.info.toucher.dmgFlags = 0x20000000; } - switch (this->unk_162) { - case 4: - this->unk_166 = 1; + switch (this->type) { + case EN_WIZ_FIRE_TYPE_ICE_MAGIC_PROJECTILE: + this->isIceType = true; this->collider.info.toucher.damage = 8; this->collider.info.toucher.effect = 2; this->collider.info.bumper.dmgFlags = (0x1000000 | 0x800 | 0x200 | 0x2); - this->unk_162 = 0; - - case 0: - if (this->unk_162 == 4) { - this->unk_162 = 0; + this->type = EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE; + // fallthrough + case EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE: + if (this->type == EN_WIZ_FIRE_TYPE_ICE_MAGIC_PROJECTILE) { + this->type = EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE; this->collider.info.toucher.damage = 8; } - - case 1: - case 3: - this->actionFunc = func_80A4984C; + // fallthrough + case EN_WIZ_FIRE_TYPE_ARCING_MAGIC_PROJECTILE: + case EN_WIZ_FIRE_TYPE_REFLECTED_MAGIC_PROJECTILE: + this->actionFunc = EnWiz_SetupMoveMagicProjectile; break; - case 2: - this->actor.draw = func_80A4BAB4; - this->unk_170 = Rand_S16Offset(0, 10000); - this->unk_160 = 1; + case EN_WIZ_FIRE_TYPE_SMALL_FLAME: + this->actor.draw = EnWizFire_DrawSmallFlame; + this->smallFlameScroll = Rand_S16Offset(0, 10000); + this->action = EN_WIZ_FIRE_ACTION_SMALL_FLAME; this->collider.info.toucher.damage = 2; - this->actionFunc = func_80A49F38; + this->actionFunc = EnWiz_SetupSmallFlame; + break; + + default: + break; } } void EnWizFire_Destroy(Actor* thisx, PlayState* play) { EnWizFire* this = THIS; - if (this->unk_162 == 0) { + if (this->type == EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) { play->envCtx.lightSettings.fogColor[2] = 0; play->envCtx.lightSettings.fogColor[1] = play->envCtx.lightSettings.fogColor[2]; play->envCtx.lightSettings.fogColor[0] = play->envCtx.lightSettings.fogColor[2]; @@ -122,146 +133,159 @@ void EnWizFire_Destroy(Actor* thisx, PlayState* play) { play->envCtx.lightSettings.ambientColor[0] = play->envCtx.lightSettings.fogColor[2]; play->envCtx.lightSettings.fogNear = play->envCtx.lightSettings.fogColor[2]; } + Collider_DestroyCylinder(play, &this->collider); } -void func_80A4984C(EnWizFire* this, PlayState* play) { - Vec3f sp44 = { 0.0f, 0.0f, 0.0f }; +void EnWiz_SetupMoveMagicProjectile(EnWizFire* this, PlayState* play) { + Vec3f velocity = { 0.0f, 0.0f, 0.0f }; s32 i; - for (i = 0; i < ARRAY_COUNT(this->unk_178); i++) { - this->unk_178[i] = this->actor.world.pos; + for (i = 0; i < ARRAY_COUNT(this->magicProjectilePos); i++) { + this->magicProjectilePos[i] = this->actor.world.pos; } - this->unk_16E = 0; + this->lowestUsedIndex = 0; + Matrix_Push(); Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_NEW); Matrix_RotateXS(this->actor.world.rot.x, MTXMODE_APPLY); - if (this->unk_162 != 0) { - sp44.z = randPlusMinusPoint5Scaled(2.0f) + 8.0f; + if (this->type != EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) { + velocity.z = randPlusMinusPoint5Scaled(2.0f) + 8.0f; } else { - sp44.z = 12.0f; + velocity.z = 12.0f; } - Matrix_MultVec3f(&sp44, &this->actor.velocity); + Matrix_MultVec3f(&velocity, &this->actor.velocity); Matrix_Pop(); + this->actor.world.rot.x = this->actor.world.rot.y = this->actor.world.rot.z = 0; - this->unk_168 = 50; - if (this->unk_162 != 0) { + this->timer = 50; + + if (this->type != EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) { this->actor.velocity.y = 10.0f; this->actor.gravity = -1.0f; - this->unk_150 = 0.01f; + this->targetScale = 0.01f; } else { - this->unk_150 = 0.02f; - this->unk_168 = 100; + this->targetScale = 0.02f; + this->timer = 100; } - this->unk_160 = 0; - this->actionFunc = func_80A49A44; + + this->action = EN_WIZ_FIRE_ACTION_MOVE_MAGIC_PROJECTILE; + this->actionFunc = EnWiz_MoveMagicProjectile; } -void func_80A49A44(EnWizFire* this, PlayState* play) { - Vec3f sp54 = { 0.0f, 0.0f, 0.0f }; +/** + * Moves all types of magic projectiles around, including arcing ones created by the + * Fire Wizrobe's attack or ones reflected by the Mirror Shield. + */ +void EnWiz_MoveMagicProjectile(EnWizFire* this, PlayState* play) { + Vec3f velocity = { 0.0f, 0.0f, 0.0f }; this->actor.world.rot.z += 5000; - if (this->unk_162 != 0) { - this->unk_150 = 0.01f; + if (this->type != EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) { + this->targetScale = 0.01f; } else { - this->unk_150 = 0.02f; + this->targetScale = 0.02f; } - if ((this->unk_168 == 0) && (this->unk_14C < 0.001f)) { + if ((this->timer == 0) && (this->scale < 0.001f)) { Math_Vec3f_Copy(&this->actor.velocity, &gZeroVec3f); - this->unk_160 = 3; - this->unk_16A = 0; - this->actionFunc = func_80A4A608; + this->action = EN_WIZ_FIRE_ACTION_KILL_MAGIC_PROJECTILE; + this->increaseLowestUsedIndexTimer = 0; + this->actionFunc = EnWiz_KillMagicProjectile; return; } - if (this->unk_168 == 0) { - this->unk_150 = 0.0f; + if (this->timer == 0) { + this->targetScale = 0.0f; } - Math_ApproachF(&this->unk_14C, this->unk_150, 0.2f, 0.01f); + Math_ApproachF(&this->scale, this->targetScale, 0.2f, 0.01f); - if (this->unk_172 == 0) { - if ((this->actor.bgCheckFlags & 8) && (this->unk_162 == 0) && (this->unk_168 != 0) && + if (this->wallCheckTimer == 0) { + if ((this->actor.bgCheckFlags & 8) && (this->type == EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) && (this->timer != 0) && (this->actor.bgCheckFlags & 8)) { - D_80A4C1C0 = 0; - this->unk_168 = 0; - this->unk_150 = 0.0f; + sPoolHitByIceArrow = false; + this->timer = 0; + this->targetScale = 0.0f; } } - if ((this->actor.bgCheckFlags & 1) && (this->unk_16A == 0)) { + if ((this->actor.bgCheckFlags & 1) && (this->poolTimer == 0)) { s32 i; - s16 phi_s0; - s32 temp; + s16 arcingProjectileRotY; + s32 pad; - if (this->unk_162 == 1) { - this->unk_16A = 10; + if (this->type == EN_WIZ_FIRE_TYPE_ARCING_MAGIC_PROJECTILE) { + this->increaseLowestUsedIndexTimer = 10; Matrix_Push(); Matrix_RotateYS((s16)randPlusMinusPoint5Scaled(0x100) + this->actor.world.rot.y, MTXMODE_NEW); - sp54.z = randPlusMinusPoint5Scaled(2.0f) + 8.0f; - Matrix_MultVec3f(&sp54, &this->actor.velocity); + velocity.z = randPlusMinusPoint5Scaled(2.0f) + 8.0f; + Matrix_MultVec3f(&velocity, &this->actor.velocity); Matrix_Pop(); this->actor.velocity.y = 6.0f; this->actor.gravity = -0.7f; - if (this->unk_164 == 0) { + if (!this->hasSpawnedSmallFlame) { Actor_Spawn(&play->actorCtx, play, ACTOR_EN_WIZ_FIRE, this->actor.world.pos.x, - this->actor.world.pos.y - 10.0f, this->actor.world.pos.z, 0, 0, 0, 2); - this->unk_164 = 1; + this->actor.world.pos.y - 10.0f, this->actor.world.pos.z, 0, 0, 0, + EN_WIZ_FIRE_TYPE_SMALL_FLAME); + this->hasSpawnedSmallFlame = true; } - this->unk_168 = 0; - this->unk_14C = 0.0f; + this->timer = 0; + this->scale = 0.0f; Math_Vec3f_Copy(&this->actor.velocity, &gZeroVec3f); - this->unk_160 = 3; - this->unk_16A = 0; - this->actionFunc = func_80A4A608; + this->action = EN_WIZ_FIRE_ACTION_KILL_MAGIC_PROJECTILE; + this->increaseLowestUsedIndexTimer = 0; + this->actionFunc = EnWiz_KillMagicProjectile; return; } - if ((this->unk_162 == 0) && (this->unk_168 != 0)) { + if ((this->type == EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) && (this->timer != 0)) { if (this->actor.floorBgId == BGCHECK_SCENE) { - this->unk_16A = 100; - if (this->unk_166 == 0) { - phi_s0 = 0; + this->poolTimer = 100; + if (!this->isIceType) { + arcingProjectileRotY = 0; for (i = 0; i < 5; i++) { Actor_Spawn(&play->actorCtx, play, ACTOR_EN_WIZ_FIRE, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, phi_s0, 0, 1); - phi_s0 += BINANG_ADD((s32)randPlusMinusPoint5Scaled(0x1000), 0x3333); + this->actor.world.pos.y, this->actor.world.pos.z, 0, arcingProjectileRotY, 0, + EN_WIZ_FIRE_TYPE_ARCING_MAGIC_PROJECTILE); + arcingProjectileRotY += BINANG_ADD((s32)randPlusMinusPoint5Scaled(0x1000), 0x3333); } Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_EXPLOSION); - this->unk_16A = Rand_S16Offset(70, 30); - if (this->unk_16A != 0) { + this->poolTimer = Rand_S16Offset(70, 30); + if (this->poolTimer != 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_EXP - SFX_FLAG); } - } else if (this->unk_16A != 0) { + } else if (this->poolTimer != 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } + Math_Vec3f_Copy(&this->actor.velocity, &gZeroVec3f); - this->unk_168 = 0; - this->unk_160 = 2; - this->unk_14C = 0.0f; - this->actionFunc = func_80A4A11C; + this->timer = 0; + this->action = EN_WIZ_FIRE_ACTION_POOL; + this->scale = 0.0f; + this->actionFunc = EnWiz_Pool; } + return; } } - if ((this->unk_162 != 3) && (this->unk_168 != 0)) { + if ((this->type != EN_WIZ_FIRE_TYPE_REFLECTED_MAGIC_PROJECTILE) && (this->timer != 0)) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; if (this->collider.info.acHitInfo->toucher.dmgFlags == 0x1000) { - this->unk_168 = 0; - this->unk_148 = 1; + this->timer = 0; + this->hitByIceArrow = true; SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 50, NA_SE_EV_ICE_MELT); } } @@ -272,104 +296,111 @@ void func_80A49A44(EnWizFire* this, PlayState* play) { this->collider.base.atFlags |= AT_TYPE_PLAYER; this->collider.info.toucher.dmgFlags = 0x20; this->collider.info.toucher.damage = 2; - this->unk_168 = 100; - this->unk_162 = 3; + this->timer = 100; + this->type = EN_WIZ_FIRE_TYPE_REFLECTED_MAGIC_PROJECTILE; this->actor.velocity.x *= -1.0f; this->actor.velocity.y *= -0.5f; this->actor.velocity.z *= -1.0f; if ((this->actor.parent != NULL) && (this->actor.parent->id == ACTOR_EN_WIZ) && (this->actor.parent->update != NULL)) { - ((EnWiz*)this->actor.parent)->unk_3BA = 0; + ((EnWiz*)this->actor.parent)->hasActiveProjectile = false; } } } } -void func_80A49F38(EnWizFire* this, PlayState* play) { - this->unk_150 = 0.02f; - this->unk_168 = Rand_S16Offset(50, 50); - this->unk_154 = randPlusMinusPoint5Scaled(1.0f) * 0.007f; - this->unk_158 = randPlusMinusPoint5Scaled(1.0f) * 0.005f; - this->unk_15C = randPlusMinusPoint5Scaled(1.0f) * 0.007f; - this->actionFunc = func_80A49FD8; +void EnWiz_SetupSmallFlame(EnWizFire* this, PlayState* play) { + this->targetScale = 0.02f; + this->timer = Rand_S16Offset(50, 50); + this->scaleMod.x = randPlusMinusPoint5Scaled(1.0f) * 0.007f; + this->scaleMod.y = randPlusMinusPoint5Scaled(1.0f) * 0.005f; + this->scaleMod.z = randPlusMinusPoint5Scaled(1.0f) * 0.007f; + this->actionFunc = EnWiz_SmallFlame; } -void func_80A49FD8(EnWizFire* this, PlayState* play) { - if (this->unk_168 > 10) { - Math_ApproachF(&this->unk_14C, this->unk_150, 0.3f, 0.01f); +/** + * Manages the small flame that is created when the arcing projectiles from the Fire Wizrobe's + * attack hit the floor. + */ +void EnWiz_SmallFlame(EnWizFire* this, PlayState* play) { + if (this->timer > 10) { + Math_ApproachF(&this->scale, this->targetScale, 0.3f, 0.01f); } else { - Math_ApproachF(&this->unk_14C, 2.0f * this->unk_150, 0.2f, 0.002f); - Math_ApproachZeroF(&this->unk_1FC, 1.0f, 35.0f); - if ((this->unk_168 == 0) && (this->unk_1FC < 2.0f)) { + Math_ApproachF(&this->scale, 2.0f * this->targetScale, 0.2f, 0.002f); + Math_ApproachZeroF(&this->alpha, 1.0f, 35.0f); + if ((this->timer == 0) && (this->alpha < 2.0f)) { Actor_MarkForDeath(&this->actor); } return; } if (this->collider.base.acFlags & AC_HIT) { - if (this->unk_168 != 0) { + if (this->timer != 0) { this->collider.base.acFlags &= ~AC_HIT; - if (this->unk_168 > 10) { - this->unk_168 -= 10; + if (this->timer > 10) { + this->timer -= 10; } if (this->collider.info.acHitInfo->toucher.dmgFlags == 0x1000) { - this->unk_168 = 0; - this->unk_148 = 1; + this->timer = 0; + this->hitByIceArrow = true; SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 50, NA_SE_EV_ICE_MELT); } } } - if (this->unk_168 != 0) { + if (this->timer != 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BURN_OUT - SFX_FLAG); } } -void func_80A4A11C(EnWizFire* this, PlayState* play) { +/** + * Manages the pool of fire or ice that is created when a magic projectile hits the floor. + */ +void EnWiz_Pool(EnWizFire* this, PlayState* play) { s32 pad; if ((this->actor.parent != NULL) && (this->actor.parent->id == ACTOR_EN_WIZ) && (this->actor.parent->update != NULL) && (this->actor.parent->colChkInfo.health == 0)) { - this->unk_16A = 0; - this->unk_174 = 1; + this->poolTimer = 0; + this->playerHitByIceProjectile = true; } - this->unk_16E++; + this->lowestUsedIndex++; - if (this->unk_16E > 10) { - this->unk_16E = 10; + if (this->lowestUsedIndex > 10) { + this->lowestUsedIndex = 10; } - if (this->unk_16A != 0) { - Math_ApproachF(&this->unk_200, 60.0f, 0.5f, 10.0f); - if (this->unk_166 == 1) { - Vec3f sp40 = { 0.0f, 0.0f, 0.0f }; - Vec3f sp34; + if (this->poolTimer != 0) { + Math_ApproachF(&this->blendScale, 60.0f, 0.5f, 10.0f); + if (this->isIceType == true) { + Vec3f accel = { 0.0f, 0.0f, 0.0f }; + Vec3f pos; - sp40.x = randPlusMinusPoint5Scaled(3.0f) / 10.0f; - sp40.y = 0.23f; - sp40.z = randPlusMinusPoint5Scaled(3.0f) / 10.0f; + accel.x = randPlusMinusPoint5Scaled(3.0f) / 10.0f; + accel.y = 0.23f; + accel.z = randPlusMinusPoint5Scaled(3.0f) / 10.0f; - Math_Vec3f_Copy(&sp34, &this->actor.world.pos); - sp34.x += randPlusMinusPoint5Scaled(150.0f); - sp34.z += randPlusMinusPoint5Scaled(150.0f); + Math_Vec3f_Copy(&pos, &this->actor.world.pos); + pos.x += randPlusMinusPoint5Scaled(150.0f); + pos.z += randPlusMinusPoint5Scaled(150.0f); - Math_ApproachF(&this->unk_1F0, 0.022f, 0.3f, 0.01f); - this->collider.dim.radius = this->unk_1F0 * 4300.0f; + Math_ApproachF(&this->poolScale, 0.022f, 0.3f, 0.01f); + this->collider.dim.radius = this->poolScale * 4300.0f; this->collider.dim.height = 30; this->collider.dim.yShift = 15; - func_80A4BC74(this, &sp34, &sp40); + EnWizFire_InitializeEffect(this, &pos, &accel); Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); return; } - Math_ApproachF(&this->unk_1F0, 0.02f, 0.3f, 0.002f); - Math_ApproachF(&this->unk_1F8, 0.02f, 0.3f, 0.002f); - Math_ApproachF(&this->unk_1F4, 0.02f, 0.3f, 0.2f); - this->collider.dim.radius = this->unk_1F0 * 4000.0f; - this->collider.dim.height = this->unk_1F4 * 1850.0f; + Math_ApproachF(&this->poolScale, 0.02f, 0.3f, 0.002f); + Math_ApproachF(&this->fireSmokeScale, 0.02f, 0.3f, 0.002f); + Math_ApproachF(&this->bigFlameScale, 0.02f, 0.3f, 0.2f); + this->collider.dim.radius = this->poolScale * 4000.0f; + this->collider.dim.height = this->bigFlameScale * 1850.0f; this->collider.dim.yShift = -15; if (this->collider.dim.height < 2) { @@ -378,231 +409,228 @@ void func_80A4A11C(EnWizFire* this, PlayState* play) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; - if ((D_80A4C1C0 == 0) && (this->collider.info.acHitInfo->toucher.dmgFlags == 0x1000)) { - D_80A4C1C0 = 1; - this->unk_148 = 1; - this->unk_16A = 0; + if (!sPoolHitByIceArrow && (this->collider.info.acHitInfo->toucher.dmgFlags == 0x1000)) { + sPoolHitByIceArrow = true; + this->hitByIceArrow = true; + this->poolTimer = 0; SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 50, NA_SE_EV_ICE_MELT); } } + this->actor.world.pos.y = this->actor.floorHeight + 10.0f; Actor_SetFocus(&this->actor, 0.0f); return; } - Math_ApproachZeroF(&this->unk_200, 0.2f, 3.0f); + Math_ApproachZeroF(&this->blendScale, 0.2f, 3.0f); - if (this->unk_166 == 1) { - Math_ApproachZeroF(&this->unk_1F0, 0.046f, 0.001f); + if (this->isIceType == true) { + Math_ApproachZeroF(&this->poolScale, 0.046f, 0.001f); Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); - if (this->unk_164 == 0) { - if ((this->actor.parent != NULL) && (this->actor.parent->id == ACTOR_EN_WIZ) && (this->unk_1F0 < 0.05f)) { + if (!this->shouldPoolFadeOut) { + if ((this->actor.parent != NULL) && (this->actor.parent->id == ACTOR_EN_WIZ) && (this->poolScale < 0.05f)) { EnWiz* wiz = (EnWiz*)this->actor.parent; this->collider.dim.yShift = -15; - this->unk_164 = 1; - wiz->unk_3BA = 0; + this->shouldPoolFadeOut = true; + wiz->hasActiveProjectile = false; } } - if ((this->unk_164 != 0) && (this->unk_1F0 < 0.05f)) { - Math_ApproachZeroF(&this->unk_1FC, 1.0f, 5.0f); + if (this->shouldPoolFadeOut && (this->poolScale < 0.05f)) { + Math_ApproachZeroF(&this->alpha, 1.0f, 5.0f); } - if ((this->unk_1F0 < 0.001f) && (this->unk_204 < 0.001f)) { - D_80A4C1C0 = 0; + if ((this->poolScale < 0.001f) && (this->blendScaleFrac < 0.001f)) { + sPoolHitByIceArrow = false; Actor_MarkForDeath(&this->actor); } + return; } - Math_ApproachZeroF(&this->unk_1F4, 0.1f, 0.01f); + Math_ApproachZeroF(&this->bigFlameScale, 0.1f, 0.01f); - if (this->unk_1F4 < 0.01f) { - Math_ApproachZeroF(&this->unk_1FC, 1.0f, 10.0f); - if ((this->unk_1FC < 10.0f) && (this->unk_204 < 0.001f)) { - D_80A4C1C0 = 0; - if ((this->actor.parent != NULL) && (this->unk_162 == 0) && (this->actor.parent->id == ACTOR_EN_WIZ) && - (this->actor.parent->update != NULL)) { + if (this->bigFlameScale < 0.01f) { + Math_ApproachZeroF(&this->alpha, 1.0f, 10.0f); + if ((this->alpha < 10.0f) && (this->blendScaleFrac < 0.001f)) { + sPoolHitByIceArrow = false; + if ((this->actor.parent != NULL) && (this->type == EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) && + (this->actor.parent->id == ACTOR_EN_WIZ) && (this->actor.parent->update != NULL)) { EnWiz* wiz = (EnWiz*)this->actor.parent; - wiz->unk_3BA = 0; + wiz->hasActiveProjectile = false; } + Actor_MarkForDeath(&this->actor); } } } -void func_80A4A608(EnWizFire* this, PlayState* play) { - if (this->unk_16A == 0) { - this->unk_16A = 2; - this->unk_16E++; - if (this->unk_16E >= 6) { - if ((this->actor.parent != NULL) && (this->unk_162 == 0) && (this->actor.parent->id == ACTOR_EN_WIZ)) { +void EnWiz_KillMagicProjectile(EnWizFire* this, PlayState* play) { + if (this->increaseLowestUsedIndexTimer == 0) { + this->increaseLowestUsedIndexTimer = 2; + this->lowestUsedIndex++; + if (this->lowestUsedIndex >= 6) { + if ((this->actor.parent != NULL) && (this->type == EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) && + (this->actor.parent->id == ACTOR_EN_WIZ)) { EnWiz* wiz = (EnWiz*)this->actor.parent; - D_80A4C1C0 = 0; + sPoolHitByIceArrow = false; if (wiz->actor.update != NULL) { - wiz->unk_3BA = 0; + wiz->hasActiveProjectile = false; } } + Actor_MarkForDeath(&this->actor); } } } void EnWizFire_Update(Actor* thisx, PlayState* play2) { - static Color_RGB8 D_80A4C234[] = { - { 100, 40, 40 }, { 180, 0x78, 80 }, { 155, 80, 80 }, { 125, 20, 0 }, - { 0, 0, 0 }, { 200, 250, 250 }, { 100, 250, 250 }, { 225, 255, 235 }, + // These are AmbientColor, DiffuseColor1, DiffuseColor2, and fogColor + static Color_RGB8 lightSettingsColors[] = { + { 100, 40, 40 }, { 180, 120, 80 }, { 155, 80, 80 }, { 125, 20, 0 }, // Fire + { 0, 0, 0 }, { 200, 250, 250 }, { 100, 250, 250 }, { 225, 255, 235 }, // Ice }; - static Color_RGBA8 D_80A4C24C = { 250, 250, 250, 255 }; - static Color_RGBA8 D_80A4C250 = { 180, 180, 180, 255 }; PlayState* play = play2; EnWizFire* this = THIS; Player* player = GET_PLAYER(play); s32 j; - s16 temp_s0; - s16 idx; + s16 randomScale; + s16 index; - Actor_SetScale(&this->actor, this->unk_14C); - func_80A4BDDC(this, play); - this->unk_204 = this->unk_200 / 60.0f; + Actor_SetScale(&this->actor, this->scale); + EnWizFire_UpdateEffects(this, play); + this->blendScaleFrac = this->blendScale / 60.0f; - if (this->unk_162 == 0) { + if (this->type == EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) { Actor* wiz = this->actor.parent; - if ((wiz != NULL) && (wiz->id == ACTOR_EN_WIZ) && (wiz->update != NULL) && (((EnWiz*)wiz)->unk_74A != 2)) { - f32 phi_f0; + if ((wiz != NULL) && (wiz->id == ACTOR_EN_WIZ) && (wiz->update != NULL) && + (((EnWiz*)wiz)->type != EN_WIZ_TYPE_FIRE_NO_BGM)) { + f32 fogNear; - idx = this->unk_166 * 4; - - phi_f0 = 970.0f; - if (this->unk_166 == 0) { - phi_f0 = 968.0f; + index = this->isIceType * 4; + fogNear = 970.0f; + if (!this->isIceType) { + fogNear = 968.0f; } - play->envCtx.lightSettings.fogNear = (phi_f0 - (s16)play->envCtx.unk_C4.fogNear) * this->unk_204; + play->envCtx.lightSettings.fogNear = (fogNear - (s16)play->envCtx.unk_C4.fogNear) * this->blendScaleFrac; play->envCtx.lightSettings.ambientColor[0] = - ((f32)D_80A4C234[idx].r - play->envCtx.unk_C4.ambientColor[0]) * this->unk_204; + ((f32)lightSettingsColors[index].r - play->envCtx.unk_C4.ambientColor[0]) * this->blendScaleFrac; play->envCtx.lightSettings.ambientColor[1] = - ((f32)D_80A4C234[idx].g - play->envCtx.unk_C4.ambientColor[1]) * this->unk_204; + ((f32)lightSettingsColors[index].g - play->envCtx.unk_C4.ambientColor[1]) * this->blendScaleFrac; play->envCtx.lightSettings.ambientColor[2] = - ((f32)D_80A4C234[idx].b - play->envCtx.unk_C4.ambientColor[2]) * this->unk_204; + ((f32)lightSettingsColors[index].b - play->envCtx.unk_C4.ambientColor[2]) * this->blendScaleFrac; - idx++; + index++; play->envCtx.lightSettings.diffuseColor1[0] = - ((f32)D_80A4C234[idx].r - play->envCtx.unk_C4.diffuseColor1[0]) * this->unk_204; + ((f32)lightSettingsColors[index].r - play->envCtx.unk_C4.diffuseColor1[0]) * this->blendScaleFrac; play->envCtx.lightSettings.diffuseColor1[1] = - ((f32)D_80A4C234[idx].g - play->envCtx.unk_C4.diffuseColor1[1]) * this->unk_204; + ((f32)lightSettingsColors[index].g - play->envCtx.unk_C4.diffuseColor1[1]) * this->blendScaleFrac; play->envCtx.lightSettings.diffuseColor1[2] = - ((f32)D_80A4C234[idx].b - play->envCtx.unk_C4.diffuseColor1[2]) * this->unk_204; + ((f32)lightSettingsColors[index].b - play->envCtx.unk_C4.diffuseColor1[2]) * this->blendScaleFrac; - idx++; + index++; play->envCtx.lightSettings.diffuseColor2[0] = - ((f32)D_80A4C234[idx].r - play->envCtx.unk_C4.diffuseColor[0]) * this->unk_204; + ((f32)lightSettingsColors[index].r - play->envCtx.unk_C4.diffuseColor[0]) * this->blendScaleFrac; play->envCtx.lightSettings.diffuseColor2[1] = - ((f32)D_80A4C234[idx].g - play->envCtx.unk_C4.diffuseColor[1]) * this->unk_204; + ((f32)lightSettingsColors[index].g - play->envCtx.unk_C4.diffuseColor[1]) * this->blendScaleFrac; play->envCtx.lightSettings.diffuseColor2[2] = - ((f32)D_80A4C234[idx].b - play->envCtx.unk_C4.diffuseColor[2]) * this->unk_204; + ((f32)lightSettingsColors[index].b - play->envCtx.unk_C4.diffuseColor[2]) * this->blendScaleFrac; - idx++; + index++; play->envCtx.lightSettings.fogColor[0] = - ((f32)D_80A4C234[idx].r - play->envCtx.unk_C4.fogColor[0]) * this->unk_204; + ((f32)lightSettingsColors[index].r - play->envCtx.unk_C4.fogColor[0]) * this->blendScaleFrac; play->envCtx.lightSettings.fogColor[1] = - ((f32)D_80A4C234[idx].g - play->envCtx.unk_C4.fogColor[1]) * this->unk_204; + ((f32)lightSettingsColors[index].g - play->envCtx.unk_C4.fogColor[1]) * this->blendScaleFrac; play->envCtx.lightSettings.fogColor[2] = - ((f32)D_80A4C234[idx].b - play->envCtx.unk_C4.fogColor[2]) * this->unk_204; + ((f32)lightSettingsColors[index].b - play->envCtx.unk_C4.fogColor[2]) * this->blendScaleFrac; } } - this->unk_170++; + this->smallFlameScroll++; this->actionFunc(this, play); this->actor.shape.yOffset = 10.0f; Actor_UpdatePos(&this->actor); - this->unk_178[0] = this->actor.world.pos; + this->magicProjectilePos[0] = this->actor.world.pos; - for (j = 8; j >= 0; j--) { - this->unk_178[j + 1] = this->unk_178[j]; + for (j = ARRAY_COUNT(this->magicProjectilePos) - 2; j >= 0; j--) { + this->magicProjectilePos[j + 1] = this->magicProjectilePos[j]; } this->actor.velocity.y += this->actor.gravity; - if (this->unk_172 != 0) { - this->unk_172--; - } - - if (this->unk_168 != 0) { - this->unk_168--; - } - - if (this->unk_16C != 0) { - this->unk_16C--; - } - - if (this->unk_16A != 0) { - this->unk_16A--; - } + DECR(this->wallCheckTimer); + DECR(this->timer); + DECR(this->steamSpawnTimer); + DECR(this->poolTimer); Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 5.0f, 10, 0x1D); - if (((this->unk_148 != 0) || (D_80A4C1C0 != 0)) && (this->unk_16C == 0)) { - Vec3f sp70; - Vec3f sp64; - Vec3f sp58; - f32 sp54; + if ((this->hitByIceArrow || sPoolHitByIceArrow) && (this->steamSpawnTimer == 0)) { + Vec3f accel; + Vec3f velocity; + Vec3f pos; + f32 scaleStep; s32 i; - sp70.x = 0.0f; - sp70.y = 1.0f; - sp70.z = 0.0f; - sp64.x = 0.0f; - sp64.y = 1.0f; - sp64.z = 0.0f; + accel.x = 0.0f; + accel.y = 1.0f; + accel.z = 0.0f; + velocity.x = 0.0f; + velocity.y = 1.0f; + velocity.z = 0.0f; - sp54 = Rand_S16Offset(20, 10); - if (this->unk_162 == 0) { - sp54 = Rand_S16Offset(40, 20); + scaleStep = Rand_S16Offset(20, 10); + if (this->type == EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) { + scaleStep = Rand_S16Offset(40, 20); } - this->unk_16C = Rand_S16Offset(2, 2); + this->steamSpawnTimer = Rand_S16Offset(2, 2); for (i = 0; i < 2; i++) { - temp_s0 = Rand_S16Offset(20, 20); - sp58.x = ((f32)((Rand_ZeroOne() < 0.5f) ? -1 : 1) * temp_s0) + this->actor.world.pos.x; - sp58.y = (Rand_ZeroOne() * 20.0f) + this->actor.floorHeight; - temp_s0 = Rand_S16Offset(20, 20); - sp58.z = ((f32)((Rand_ZeroOne() < .5f) ? -1 : 1) * temp_s0) + this->actor.world.pos.z; - func_800B0DE0(play, &sp58, &sp64, &sp70, &D_80A4C24C, &D_80A4C250, Rand_S16Offset(350, 100), sp54); + static Color_RGBA8 sSteamPrimColor = { 250, 250, 250, 255 }; + static Color_RGBA8 sSteamEnvColor = { 180, 180, 180, 255 }; + + randomScale = Rand_S16Offset(20, 20); + pos.x = ((f32)((Rand_ZeroOne() < 0.5f) ? -1 : 1) * randomScale) + this->actor.world.pos.x; + pos.y = (Rand_ZeroOne() * 20.0f) + this->actor.floorHeight; + randomScale = Rand_S16Offset(20, 20); + pos.z = ((f32)((Rand_ZeroOne() < .5f) ? -1 : 1) * randomScale) + this->actor.world.pos.z; + func_800B0DE0(play, &pos, &velocity, &accel, &sSteamPrimColor, &sSteamEnvColor, Rand_S16Offset(350, 100), + scaleStep); } } - if (this->unk_160 < 2) { - this->collider.dim.radius = (this->unk_14C * 15.0f) + 25.0f; - this->collider.dim.height = (this->unk_14C * 15.0f) + 25.0f; - this->collider.dim.yShift = (this->unk_14C * -0.75f) - 5.0f; + if (this->action < EN_WIZ_FIRE_ACTION_POOL) { + this->collider.dim.radius = (this->scale * 15.0f) + 25.0f; + this->collider.dim.height = (this->scale * 15.0f) + 25.0f; + this->collider.dim.yShift = (this->scale * -0.75f) - 5.0f; } - if (this->unk_162 == 2) { + if (this->type == EN_WIZ_FIRE_TYPE_SMALL_FLAME) { this->collider.dim.radius = 10; - this->collider.dim.height = this->unk_14C * 5000.0f; + this->collider.dim.height = this->scale * 5000.0f; this->collider.dim.yShift = 0; } if (this->collider.base.atFlags & AT_HIT) { this->collider.base.atFlags &= ~AT_HIT; - if (this->unk_162 == 0) { + if (this->type == EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_LAUGH2); if (player->invincibilityTimer > 0) { player->invincibilityTimer += 40; - if (this->unk_166 != 0) { + if (this->isIceType) { player->invincibilityTimer += 50; - this->unk_174 = 1; + this->playerHitByIceProjectile = true; } } } @@ -612,7 +640,8 @@ void EnWizFire_Update(Actor* thisx, PlayState* play2) { player->unk_AE8 = 90; } - if ((this->unk_148 == 0) && (D_80A4C1C0 == 0) && ((this->unk_162 != 0) || (this->unk_1FC > 200.0f))) { + if (!this->hitByIceArrow && !sPoolHitByIceArrow && + ((this->type != EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) || (this->alpha > 200.0f))) { Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); if (player->invincibilityTimer == 0) { @@ -621,61 +650,63 @@ void EnWizFire_Update(Actor* thisx, PlayState* play2) { } } -void func_80A4B0C8(EnWizFire* this, PlayState* play) { +void EnWizFire_DrawIcePool(EnWizFire* this, PlayState* play) { s32 pad; OPEN_DISPS(play->state.gfxCtx); - if ((this->unk_162 == 0) && (this->unk_160 == 2)) { + if ((this->type == EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) && (this->action == EN_WIZ_FIRE_ACTION_POOL)) { func_8012C28C(play->state.gfxCtx); func_8012C2DC(play->state.gfxCtx); Matrix_Translate(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_Scale(this->unk_1F0, this->unk_1F0, this->unk_1F0, MTXMODE_APPLY); + Matrix_Scale(this->poolScale, this->poolScale, this->poolScale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPPipeSync(POLY_XLU_DISP++); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s8)this->unk_1FC); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s8)this->alpha); gDPSetEnvColor(POLY_XLU_DISP++, 0, 40, 30, 80); - gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_005190); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 215, 215, 215, (s8)this->unk_1FC); + gSPDisplayList(POLY_XLU_DISP++, gWizrobeIcePoolDL); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 215, 215, 215, (s8)this->alpha); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 128); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(play->state.gfxCtx, 0, -play->state.frames & 0x7F, -play->state.frames & 0x7F, 0x20, - 0x40, 1, play->state.frames & 0xFF, play->state.frames & 0xFF, 0x10, 0x10)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, -play->state.frames & 0x7F, -play->state.frames & 0x7F, 32, + 64, 1, play->state.frames & 0xFF, play->state.frames & 0xFF, 16, 16)); Matrix_RotateYS(0, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_005750); + gSPDisplayList(POLY_XLU_DISP++, gWizrobeIcePoolShineDL); } - func_80A4BF78(this, play); + EnWizFire_DrawEffects(this, play); CLOSE_DISPS(play->state.gfxCtx); } -void func_80A4B33C(EnWizFire* this, PlayState* play2) { +void EnWizFire_DrawFirePoolAndFlame(EnWizFire* this, PlayState* play2) { PlayState* play = play2; OPEN_DISPS(play->state.gfxCtx); - if ((this->unk_162 == 0) && (this->unk_160 == 2)) { + if ((this->type == EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) && (this->action == EN_WIZ_FIRE_ACTION_POOL)) { func_8012C28C(play->state.gfxCtx); func_8012C2DC(play->state.gfxCtx); + Matrix_Push(); Matrix_Translate(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_Scale(this->unk_1F0, this->unk_1F0, this->unk_1F0, MTXMODE_APPLY); + Matrix_Scale(this->poolScale, this->poolScale, this->poolScale, MTXMODE_APPLY); gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(play->state.gfxCtx, 0, -play->state.frames % 128, 0, 0x20, 0x20, 1, (play->state.frames * 2) % 128, 0, 0x20, 0x20)); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPPipeSync(POLY_XLU_DISP++); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 100, 40, 0, (s8)this->unk_1FC); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 100, 40, 0, (s8)this->alpha); gDPSetEnvColor(POLY_XLU_DISP++, 255, 245, 255, 128); - gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_003120); + gSPDisplayList(POLY_XLU_DISP++, gWizrobeFirePoolDL); Matrix_Pop(); + Matrix_Push(); Matrix_Translate(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, MTXMODE_NEW); Matrix_ReplaceRotation(&play->billboardMtxF); @@ -684,16 +715,17 @@ void func_80A4B33C(EnWizFire* this, PlayState* play2) { Gfx_TwoTexScroll(play->state.gfxCtx, 0, play->state.frames % 128, (-play->state.frames * 6) % 256, 0x20, 0x40, 1, (play->state.frames * 2) % 128, (-play->state.frames * 6) % 256, 0x20, 0x40)); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 80, 0, 0, (s8)this->unk_1FC); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 80, 0, 0, (s8)this->alpha); gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, 100); - Matrix_Scale(this->unk_1F8, this->unk_1F8, this->unk_1F8, MTXMODE_APPLY); + Matrix_Scale(this->fireSmokeScale, this->fireSmokeScale, this->fireSmokeScale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_003640); + gSPDisplayList(POLY_XLU_DISP++, gWizrobeFireSmokeDL); Matrix_Pop(); + Matrix_Translate(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, MTXMODE_NEW); Matrix_ReplaceRotation(&play->billboardMtxF); @@ -704,10 +736,10 @@ void func_80A4B33C(EnWizFire* this, PlayState* play2) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 200, 235, 240, 128); - Matrix_Scale(this->unk_1F4, this->unk_1F4, this->unk_1F4, MTXMODE_APPLY); + Matrix_Scale(this->bigFlameScale, this->bigFlameScale, this->bigFlameScale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_003FC0); + gSPDisplayList(POLY_XLU_DISP++, gWizrobeBigFlameDL); } CLOSE_DISPS(play->state.gfxCtx); @@ -724,11 +756,11 @@ void EnWizFire_Draw(Actor* thisx, PlayState* play2) { func_8012C2DC(play->state.gfxCtx); Matrix_Push(); - for (i = 9; i >= this->unk_16E; i--) { - f32 temp_f20 = this->actor.scale.x - (i * -0.0019f); + for (i = ARRAY_COUNT(this->magicProjectilePos) - 1; i >= this->lowestUsedIndex; i--) { + f32 scale = this->actor.scale.x - (i * -0.0019f); - if (temp_f20 > 0.0f) { - if (this->unk_166 == 0) { + if (scale > 0.0f) { + if (!this->isIceType) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255 - (i * 25), 0, 255 - (i * 25)); gDPSetEnvColor(POLY_XLU_DISP++, 255 - (i * 25), 0, 0, 0); } else { @@ -736,14 +768,14 @@ void EnWizFire_Draw(Actor* thisx, PlayState* play2) { gDPSetEnvColor(POLY_XLU_DISP++, 220, 255, 235, 0); } - Matrix_Translate(this->unk_178[i].x, this->unk_178[i].y + this->actor.shape.yOffset, this->unk_178[i].z, - MTXMODE_NEW); - Matrix_Scale(temp_f20, temp_f20, temp_f20, MTXMODE_APPLY); + Matrix_Translate(this->magicProjectilePos[i].x, this->magicProjectilePos[i].y + this->actor.shape.yOffset, + this->magicProjectilePos[i].z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); Matrix_ReplaceRotation(&play->billboardMtxF); Matrix_RotateZS(this->actor.world.rot.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_002B40); + gSPDisplayList(POLY_XLU_DISP++, gWizrobeMagicProjectileDL); } } @@ -751,92 +783,92 @@ void EnWizFire_Draw(Actor* thisx, PlayState* play2) { CLOSE_DISPS(play->state.gfxCtx); - if (this->unk_166 == 0) { - func_80A4B33C(this, play); + if (!this->isIceType) { + EnWizFire_DrawFirePoolAndFlame(this, play); } else { - func_80A4B0C8(this, play); + EnWizFire_DrawIcePool(this, play); } } -void func_80A4BAB4(Actor* thisx, PlayState* play) { +void EnWizFire_DrawSmallFlame(Actor* thisx, PlayState* play) { s32 pad; EnWizFire* this = THIS; OPEN_DISPS(play->state.gfxCtx); Matrix_Translate(this->actor.world.pos.x, this->actor.floorHeight + 20.0f, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_Scale(this->unk_14C + this->unk_154, this->unk_14C + this->unk_158, this->unk_14C + this->unk_15C, + Matrix_Scale(this->scale + this->scaleMod.x, this->scale + this->scaleMod.y, this->scale + this->scaleMod.z, MTXMODE_APPLY); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 0x20, 0x20, 1, this->unk_170 & 0x7F, - (-this->unk_170 * 10) & 0x7F, 0x20, 0x20)); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 100, 50, 0, (s8)this->unk_1FC); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 32, 1, this->smallFlameScroll & 0x7F, + (-this->smallFlameScroll * 10) & 0x7F, 32, 32)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 100, 50, 0, (s8)this->alpha); gDPSetEnvColor(POLY_XLU_DISP++, 200, 235, 245, 255); Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_002630); + gSPDisplayList(POLY_XLU_DISP++, gWizrobeSmallFlameDL); CLOSE_DISPS(play->state.gfxCtx); } -void func_80A4BC74(EnWizFire* this, Vec3f* arg1, Vec3f* arg2) { +void EnWizFire_InitializeEffect(EnWizFire* this, Vec3f* pos, Vec3f* accel) { s16 i; - EnWizFireStruct* ptr = this->unk_254; + EnWizFireEffect* effect = &this->effects[0]; - for (i = 0; i < ARRAY_COUNT(this->unk_254); i++, ptr++) { - if (ptr->unk_00 == 0) { - ptr->unk_00 = 1; - Math_Vec3f_Copy(&ptr->unk_1C, &gZeroVec3f); - ptr->unk_01 = Rand_ZeroFloat(100.0f); - ptr->unk_10 = *arg1; - ptr->unk_28 = *arg2; - ptr->unk_0C = (Rand_ZeroFloat(5.0f) + 20.0f) * 0.001f; - ptr->unk_08 = 0; - ptr->unk_06 = 0; + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (!effect->isEnabled) { + effect->isEnabled = true; + Math_Vec3f_Copy(&effect->velocity, &gZeroVec3f); + effect->smokeScroll = Rand_ZeroFloat(100.0f); + effect->pos = *pos; + effect->accel = *accel; + effect->scale = (Rand_ZeroFloat(5.0f) + 20.0f) * 0.001f; + effect->shouldDecreaseAlpha = 0; + effect->alpha = 0; break; } } } -void func_80A4BDDC(EnWizFire* this, PlayState* play) { +void EnWizFire_UpdateEffects(EnWizFire* this, PlayState* play) { s32 i; - EnWizFireStruct* ptr = &this->unk_254[0]; + EnWizFireEffect* effect = &this->effects[0]; - for (i = 0; i < ARRAY_COUNT(this->unk_254); i++, ptr++) { - if (ptr->unk_00 != 0) { - ptr->unk_01++; + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isEnabled) { + effect->smokeScroll++; - ptr->unk_10.x += ptr->unk_1C.x; - ptr->unk_10.y += ptr->unk_1C.y; - ptr->unk_10.z += ptr->unk_1C.z; + effect->pos.x += effect->velocity.x; + effect->pos.y += effect->velocity.y; + effect->pos.z += effect->velocity.z; - ptr->unk_1C.x += ptr->unk_28.x; - ptr->unk_1C.y += ptr->unk_28.y; - ptr->unk_1C.z += ptr->unk_28.z; + effect->velocity.x += effect->accel.x; + effect->velocity.y += effect->accel.y; + effect->velocity.z += effect->accel.z; - if (ptr->unk_08 == 0) { - ptr->unk_06 += 10; - if (ptr->unk_06 >= 100) { - ptr->unk_08 = 1; + if (!effect->shouldDecreaseAlpha) { + effect->alpha += 10; + if (effect->alpha >= 100) { + effect->shouldDecreaseAlpha = true; } } else { - ptr->unk_06 -= 8; - if (ptr->unk_06 <= 0) { - ptr->unk_06 = 0; - ptr->unk_00 = 0; + effect->alpha -= 8; + if (effect->alpha <= 0) { + effect->alpha = 0; + effect->isEnabled = false; } } } } } -void func_80A4BF78(EnWizFire* this, PlayState* play) { +void EnWizFire_DrawEffects(EnWizFire* this, PlayState* play) { s16 i; - u8 flag; - EnWizFireStruct* ptr = &this->unk_254[0]; + u8 materialFlag; + EnWizFireEffect* effect = &this->effects[0]; GraphicsContext* gfxCtx = play->state.gfxCtx; OPEN_DISPS(gfxCtx); @@ -844,27 +876,27 @@ void func_80A4BF78(EnWizFire* this, PlayState* play) { func_8012C28C(play->state.gfxCtx); func_8012C2DC(play->state.gfxCtx); - flag = false; - for (i = 0; i < ARRAY_COUNT(this->unk_254); i++, ptr++) { - if (ptr->unk_00 != 0) { - if (!flag) { - gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_000E70); - flag++; + materialFlag = false; + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isEnabled) { + if (!materialFlag) { + gSPDisplayList(POLY_XLU_DISP++, gWizrobeIceSmokeMaterialDL); + materialFlag++; } - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, ptr->unk_06); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, effect->alpha); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(play->state.gfxCtx, 0, (ptr->unk_01 * 3) & 0x7F, (ptr->unk_01 * 0xF) & 0xFF, - 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, (effect->smokeScroll * 3) & 0x7F, + (effect->smokeScroll * 0xF) & 0xFF, 32, 64, 1, 0, 0, 32, 32)); - Matrix_Translate(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_ReplaceRotation(&play->billboardMtxF); - Matrix_Scale(ptr->unk_0C, ptr->unk_0C, 1.0f, MTXMODE_APPLY); + Matrix_Scale(effect->scale, effect->scale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetRenderMode(POLY_XLU_DISP++, G_RM_PASS, G_RM_AA_ZB_XLU_SURF2); gSPClearGeometryMode(POLY_XLU_DISP++, G_CULL_BACK | G_FOG); - gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_000FD8); + gSPDisplayList(POLY_XLU_DISP++, gWizrobeIceSmokeModelDL); } } diff --git a/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.h b/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.h index b628404bba..180192d4c5 100644 --- a/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.h +++ b/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.h @@ -3,52 +3,65 @@ #include "global.h" +typedef enum { + /* 0 */ EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE, + /* 1 */ EN_WIZ_FIRE_TYPE_ARCING_MAGIC_PROJECTILE, + /* 2 */ EN_WIZ_FIRE_TYPE_SMALL_FLAME, + /* 3 */ EN_WIZ_FIRE_TYPE_REFLECTED_MAGIC_PROJECTILE, + /* 4 */ EN_WIZ_FIRE_TYPE_ICE_MAGIC_PROJECTILE +} EnWizFireType; + +#define EN_WIZ_FIRE_GET_TYPE(thisx) ((thisx)->params) + struct EnWizFire; typedef void (*EnWizFireActionFunc)(struct EnWizFire*, PlayState*); typedef struct { - /* 0x00 */ u8 unk_00; - /* 0x01 */ u8 unk_01; + /* 0x00 */ u8 isEnabled; + /* 0x01 */ u8 smokeScroll; /* 0x02 */ UNK_TYPE1 unk02[0x4]; - /* 0x06 */ s16 unk_06; - /* 0x08 */ s16 unk_08; - /* 0x0A */ UNK_TYPE1 unk0A[0x2]; - /* 0x0C */ f32 unk_0C; - /* 0x10 */ Vec3f unk_10; - /* 0x1C */ Vec3f unk_1C; - /* 0x28 */ Vec3f unk_28; -} EnWizFireStruct; // size = 0x34 + /* 0x06 */ s16 alpha; + /* 0x08 */ s16 shouldDecreaseAlpha; + /* 0x0C */ f32 scale; + /* 0x10 */ Vec3f pos; + /* 0x1C */ Vec3f velocity; + /* 0x28 */ Vec3f accel; +} EnWizFireEffect; // size = 0x34 typedef struct EnWizFire { /* 0x0000 */ Actor actor; /* 0x0144 */ EnWizFireActionFunc actionFunc; - /* 0x0148 */ u8 unk_148; - /* 0x014C */ f32 unk_14C; - /* 0x0150 */ f32 unk_150; - /* 0x0154 */ f32 unk_154; - /* 0x0158 */ f32 unk_158; - /* 0x015C */ f32 unk_15C; - /* 0x0160 */ s16 unk_160; - /* 0x0162 */ s16 unk_162; - /* 0x0164 */ u8 unk_164; - /* 0x0166 */ s16 unk_166; - /* 0x0168 */ s16 unk_168; - /* 0x016A */ s16 unk_16A; - /* 0x016C */ s16 unk_16C; - /* 0x016E */ s16 unk_16E; - /* 0x0170 */ s16 unk_170; - /* 0x0172 */ s16 unk_172; - /* 0x0174 */ s8 unk_174; - /* 0x0178 */ Vec3f unk_178[10]; - /* 0x01F0 */ f32 unk_1F0; - /* 0x01F4 */ f32 unk_1F4; - /* 0x01F8 */ f32 unk_1F8; - /* 0x01FC */ f32 unk_1FC; - /* 0x0200 */ f32 unk_200; - /* 0x0204 */ f32 unk_204; + /* 0x0148 */ u8 hitByIceArrow; + /* 0x014C */ f32 scale; + /* 0x0150 */ f32 targetScale; + /* 0x0154 */ Vec3f scaleMod; + /* 0x0160 */ s16 action; + /* 0x0162 */ s16 type; + /* 0x0164 */ union { + u8 shouldPoolFadeOut; + u8 hasSpawnedSmallFlame; + }; + /* 0x0166 */ s16 isIceType; + /* 0x0168 */ s16 timer; + /* 0x016A */ union { + s16 poolTimer; + s16 increaseLowestUsedIndexTimer; + }; + /* 0x016C */ s16 steamSpawnTimer; + /* 0x016E */ s16 lowestUsedIndex; + /* 0x0170 */ s16 smallFlameScroll; + /* 0x0172 */ s16 wallCheckTimer; // The projectile won't check for impacts with walls until this is zero + /* 0x0174 */ s8 playerHitByIceProjectile; // Set, but never used + /* 0x0178 */ Vec3f magicProjectilePos[10]; + /* 0x01F0 */ f32 poolScale; + /* 0x01F4 */ f32 bigFlameScale; + /* 0x01F8 */ f32 fireSmokeScale; + /* 0x01FC */ f32 alpha; + /* 0x0200 */ f32 blendScale; + /* 0x0204 */ f32 blendScaleFrac; /* 0x0208 */ ColliderCylinder collider; - /* 0x0254 */ EnWizFireStruct unk_254[200]; + /* 0x0254 */ EnWizFireEffect effects[200]; } EnWizFire; // size = 0x2AF4 extern const ActorInit En_Wiz_Fire_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 519550a83b..ef47869a5d 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -10441,31 +10441,31 @@ 0x80A45164:("EnSekihi_Draw",), 0x80A45360:("EnWiz_Init",), 0x80A45568:("EnWiz_Destroy",), - 0x80A455C4:("func_80A455C4",), - 0x80A456A0:("func_80A456A0",), - 0x80A45CD8:("func_80A45CD8",), - 0x80A460A4:("func_80A460A4",), - 0x80A46280:("func_80A46280",), - 0x80A462F8:("func_80A462F8",), - 0x80A46414:("func_80A46414",), - 0x80A4668C:("func_80A4668C",), - 0x80A46764:("func_80A46764",), - 0x80A468CC:("func_80A468CC",), - 0x80A46990:("func_80A46990",), - 0x80A46C88:("func_80A46C88",), - 0x80A46CC4:("func_80A46CC4",), - 0x80A46DDC:("func_80A46DDC",), - 0x80A46E24:("func_80A46E24",), - 0x80A47000:("func_80A47000",), - 0x80A470D8:("func_80A470D8",), - 0x80A47298:("func_80A47298",), - 0x80A473B8:("func_80A473B8",), - 0x80A4767C:("func_80A4767C",), - 0x80A476C8:("func_80A476C8",), - 0x80A477E8:("func_80A477E8",), + 0x80A455C4:("EnWiz_ChangeAnim",), + 0x80A456A0:("EnWiz_HandleIntroCutscene",), + 0x80A45CD8:("EnWiz_SelectPlatform",), + 0x80A460A4:("EnWiz_MoveGhosts",), + 0x80A46280:("EnWiz_StartIntroCutscene",), + 0x80A462F8:("EnWiz_SetupAppear",), + 0x80A46414:("EnWiz_Appear",), + 0x80A4668C:("EnWiz_SetupDance",), + 0x80A46764:("EnWiz_Dance",), + 0x80A468CC:("EnWiz_SetupSecondPhaseCutscene",), + 0x80A46990:("EnWiz_SecondPhaseCutscene",), + 0x80A46C88:("EnWiz_SetupWindUp",), + 0x80A46CC4:("EnWiz_WindUp",), + 0x80A46DDC:("EnWiz_SetupAttack",), + 0x80A46E24:("EnWiz_Attack",), + 0x80A47000:("EnWiz_SetupDisappear",), + 0x80A470D8:("EnWiz_Disappear",), + 0x80A47298:("EnWiz_SetupDamaged",), + 0x80A473B8:("EnWiz_Damaged",), + 0x80A4767C:("EnWiz_SetupDead",), + 0x80A476C8:("EnWiz_Dead",), + 0x80A477E8:("EnWiz_UpdateDamage",), 0x80A47C6C:("EnWiz_Update",), - 0x80A47FCC:("func_80A47FCC",), - 0x80A48138:("func_80A48138",), + 0x80A47FCC:("EnWiz_PostLimbDrawOpa",), + 0x80A48138:("EnWiz_PostLimbDrawXlu",), 0x80A483B4:("EnWiz_Draw",), 0x80A48FE0:("EnWizBrock_Init",), 0x80A490B0:("EnWizBrock_Destroy",), @@ -10475,20 +10475,20 @@ 0x80A49308:("EnWizBrock_Draw",), 0x80A496A0:("EnWizFire_Init",), 0x80A497D4:("EnWizFire_Destroy",), - 0x80A4984C:("func_80A4984C",), - 0x80A49A44:("func_80A49A44",), - 0x80A49F38:("func_80A49F38",), - 0x80A49FD8:("func_80A49FD8",), - 0x80A4A11C:("func_80A4A11C",), - 0x80A4A608:("func_80A4A608",), + 0x80A4984C:("EnWiz_SetupMoveMagicProjectile",), + 0x80A49A44:("EnWiz_MoveMagicProjectile",), + 0x80A49F38:("EnWiz_SetupSmallFlame",), + 0x80A49FD8:("EnWiz_SmallFlame",), + 0x80A4A11C:("EnWiz_Pool",), + 0x80A4A608:("EnWiz_KillMagicProjectile",), 0x80A4A698:("EnWizFire_Update",), - 0x80A4B0C8:("func_80A4B0C8",), - 0x80A4B33C:("func_80A4B33C",), + 0x80A4B0C8:("EnWizFire_DrawIcePool",), + 0x80A4B33C:("EnWizFire_DrawFirePoolAndFlame",), 0x80A4B804:("EnWizFire_Draw",), - 0x80A4BAB4:("func_80A4BAB4",), - 0x80A4BC74:("func_80A4BC74",), - 0x80A4BDDC:("func_80A4BDDC",), - 0x80A4BF78:("func_80A4BF78",), + 0x80A4BAB4:("EnWizFire_DrawSmallFlame",), + 0x80A4BC74:("EnWizFire_InitializeEffect",), + 0x80A4BDDC:("EnWizFire_UpdateEffects",), + 0x80A4BF78:("EnWizFire_DrawEffects",), 0x80A4C490:("EffChange_Init",), 0x80A4C54C:("EffChange_Destroy",), 0x80A4C578:("EffChange_SetColors",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index eac44b02df..57d876acbb 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -11517,18 +11517,18 @@ 0x80A452A4:("D_80A452A4","UNK_TYPE1","",0x1), 0x80A452B0:("D_80A452B0","UNK_TYPE4","",0x4), 0x80A48B30:("En_Wiz_InitVars","UNK_TYPE1","",0x1), - 0x80A48B50:("D_80A48B50","UNK_TYPE1","",0x1), - 0x80A48CB8:("D_80A48CB8","UNK_PTR","",0x4), - 0x80A48CC8:("D_80A48CC8","UNK_TYPE1","",0x1), - 0x80A48CF4:("D_80A48CF4","UNK_TYPE1","",0x1), - 0x80A48D14:("D_80A48D14","UNK_TYPE1","",0x1), - 0x80A48D34:("D_80A48D34","UNK_TYPE1","",0x1), - 0x80A48D4C:("D_80A48D4C","UNK_TYPE1","",0x1), - 0x80A48D54:("D_80A48D54","UNK_TYPE4","",0x4), - 0x80A48D60:("D_80A48D60","UNK_TYPE1","",0x1), - 0x80A48D64:("D_80A48D64","UNK_TYPE1","",0x1), - 0x80A48D68:("D_80A48D68","UNK_TYPE4","",0x4), - 0x80A48D74:("D_80A48D74","UNK_TYPE4","",0x4), + 0x80A48B50:("sJntSphElementsInit","UNK_TYPE1","",0x1), + 0x80A48CB8:("sJntSphInit","UNK_PTR","",0x4), + 0x80A48CC8:("sCylinderInit","UNK_TYPE1","",0x1), + 0x80A48CF4:("sFireWizrobeDamageTable","UNK_TYPE1","",0x1), + 0x80A48D14:("sIceWizrobeDamageTable","UNK_TYPE1","",0x1), + 0x80A48D34:("sAnimations","UNK_TYPE1","",0x1), + 0x80A48D4C:("sAnimationModes","UNK_TYPE1","",0x1), + 0x80A48D54:("staffTargetFlameScale","UNK_TYPE4","",0x4), + 0x80A48D60:("sDustPrimColor","UNK_TYPE1","",0x1), + 0x80A48D64:("sDustEnvTimer","UNK_TYPE1","",0x1), + 0x80A48D68:("staffFlamePos","UNK_TYPE4","",0x4), + 0x80A48D74:("staffFlamePos","UNK_TYPE4","",0x4), 0x80A48D80:("jtbl_80A48D80","UNK_PTR","",0x4), 0x80A48D98:("D_80A48D98","f32","",0x4), 0x80A48D9C:("D_80A48D9C","f32","",0x4), @@ -11556,15 +11556,15 @@ 0x80A495F8:("D_80A495F8","f32","",0x4), 0x80A495FC:("D_80A495FC","f32","",0x4), 0x80A49600:("D_80A49600","f32","",0x4), - 0x80A4C1C0:("D_80A4C1C0","UNK_TYPE4","",0x4), + 0x80A4C1C0:("sPoolHitByIceArrow","UNK_TYPE4","",0x4), 0x80A4C1C4:("En_Wiz_Fire_InitVars","UNK_TYPE1","",0x1), 0x80A4C1E4:("D_80A4C1E4","UNK_TYPE1","",0x1), 0x80A4C210:("D_80A4C210","UNK_TYPE4","",0x4), 0x80A4C21C:("D_80A4C21C","UNK_TYPE4","",0x4), 0x80A4C228:("D_80A4C228","UNK_TYPE4","",0x4), - 0x80A4C234:("D_80A4C234","UNK_TYPE1","",0x1), - 0x80A4C24C:("D_80A4C24C","UNK_TYPE1","",0x1), - 0x80A4C250:("D_80A4C250","UNK_TYPE1","",0x1), + 0x80A4C234:("lightSettingsColors","UNK_TYPE1","",0x1), + 0x80A4C24C:("sSteamPrimColor","UNK_TYPE1","",0x1), + 0x80A4C250:("sSteamEnvColor","UNK_TYPE1","",0x1), 0x80A4C260:("jtbl_80A4C260","UNK_PTR","",0x4), 0x80A4C274:("D_80A4C274","f32","",0x4), 0x80A4C278:("D_80A4C278","f32","",0x4), diff --git a/undefined_syms.txt b/undefined_syms.txt index aae06790f4..073840341b 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1375,14 +1375,6 @@ D_060014C0 = 0x060014C0; D_060015B0 = 0x060015B0; D_06001E20 = 0x06001E20; -// ovl_En_Wiz - -D_06001860 = 0x06001860; -D_0600211C = 0x0600211C; -D_060025F0 = 0x060025F0; -D_060066C0 = 0x060066C0; -D_0600B320 = 0x0600B320; - // ovl_En_Zl4 D_06013328 = 0x06013328; From 82afae675b47fbbd90bad9bcd6e38325158082dc Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sat, 1 Oct 2022 09:08:47 -0700 Subject: [PATCH 11/25] Replace player animation names with original names derived from OoT3D/MM3D (#1103) --- assets/xml/misc/link_animetion.xml | 1350 ++++++++--------- assets/xml/objects/gameplay_keep.xml | 1350 ++++++++--------- .../actors/ovl_En_Minifrog/z_en_minifrog.c | 6 +- src/overlays/actors/ovl_En_Tab/z_en_tab.c | 2 +- src/overlays/actors/ovl_En_Yb/z_en_yb.c | 2 +- 5 files changed, 1355 insertions(+), 1355 deletions(-) diff --git a/assets/xml/misc/link_animetion.xml b/assets/xml/misc/link_animetion.xml index 788e0a49da..2bb5826dd1 100644 --- a/assets/xml/misc/link_animetion.xml +++ b/assets/xml/misc/link_animetion.xml @@ -1,699 +1,699 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + - - - - - + + + + + - + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 03ed9eef50..354c710bbf 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -71,701 +71,701 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + 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 1e92e1f777..399a8f6596 100644 --- a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c +++ b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c @@ -411,7 +411,7 @@ void EnMinifrog_NextFrogReturned(EnMinifrog* this, PlayState* play) { this->actionFunc = EnMinifrog_ContinueChoirCutscene; this->flags &= ~(0x2 << MINIFROG_YELLOW | 0x2 << MINIFROG_CYAN | 0x2 << MINIFROG_PINK | 0x2 << MINIFROG_BLUE | 0x2 << MINIFROG_WHITE); - play->setPlayerTalkAnim(play, &gameplay_keep_Linkanim_00DEA8, 0); + play->setPlayerTalkAnim(play, &gPlayerAnim_link_normal_talk_free_wait, 0); } } @@ -442,7 +442,7 @@ void EnMinifrog_SetupNextFrogChoir(EnMinifrog* this, PlayState* play) { this->flags &= ~0x100; this->flags &= ~(0x2 << MINIFROG_YELLOW | 0x2 << MINIFROG_CYAN | 0x2 << MINIFROG_PINK | 0x2 << MINIFROG_BLUE | 0x2 << MINIFROG_WHITE); - play->setPlayerTalkAnim(play, &gameplay_keep_Linkanim_00DEA8, 0); + play->setPlayerTalkAnim(play, &gPlayerAnim_link_normal_talk_free_wait, 0); } else if (this->timer <= 0) { this->actionFunc = EnMinifrog_NextFrogReturned; this->timer = 30; @@ -462,7 +462,7 @@ void EnMinifrog_BeginChoirCutscene(EnMinifrog* this, PlayState* play) { this->timer = 5; func_801A1F00(3, NA_BGM_FROG_SONG); this->flags |= 0x100; - play->setPlayerTalkAnim(play, &gameplay_keep_Linkanim_00E2A8, 0); + play->setPlayerTalkAnim(play, &gPlayerAnim_pn_gakkiplay, 0); } else { ActorCutscene_SetIntentToPlay(this->actor.cutscene); } diff --git a/src/overlays/actors/ovl_En_Tab/z_en_tab.c b/src/overlays/actors/ovl_En_Tab/z_en_tab.c index 860ad9d0c0..ffa5577467 100644 --- a/src/overlays/actors/ovl_En_Tab/z_en_tab.c +++ b/src/overlays/actors/ovl_En_Tab/z_en_tab.c @@ -323,7 +323,7 @@ s32 func_80BE0D60(EnTab* this, PlayState* play) { this->unk_320++; if (this->unk_320 == 1) { - play->setPlayerTalkAnim(play, &gameplay_keep_Linkanim_00D568, 2); + play->setPlayerTalkAnim(play, &gPlayerAnim_link_demo_bikkuri, 2); } else if (this->unk_320 > 20) { play->setPlayerTalkAnim(play, NULL, 0); this->unk_320 = 0; diff --git a/src/overlays/actors/ovl_En_Yb/z_en_yb.c b/src/overlays/actors/ovl_En_Yb/z_en_yb.c index d28a06fa0b..11474f01eb 100644 --- a/src/overlays/actors/ovl_En_Yb/z_en_yb.c +++ b/src/overlays/actors/ovl_En_Yb/z_en_yb.c @@ -68,7 +68,7 @@ static ColliderCylinderInit sCylinderInit = { // assumption: draw uses two different skeleton functions, might be incompatible static AnimationHeader* gYbUnusedAnimations[] = { &object_yb_Anim_000200 }; -static LinkAnimationHeader* gLinkAnimations[] = { &gameplay_keep_Linkanim_00DF28, &gameplay_keep_Linkanim_00CF98 }; +static LinkAnimationHeader* gLinkAnimations[] = { &gPlayerAnim_link_normal_wait_free, &gPlayerAnim_alink_dance_loop }; static Vec3f D_80BFB2E8 = { 0.0f, 0.5f, 0.0f }; From 84d77d5101f08433f14e15e1c5fd0e5e51b5f6c0 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sat, 1 Oct 2022 21:00:52 -0700 Subject: [PATCH 12/25] EnMThunder Ok with some docs (#1082) * Match EnMThunder_Init * Match func_808B53C0 * Match func_808B65BC * Match func_808B6310 * Match func_808B5EEC * Matched func_808B60D4 * Match func_808B5F68 * Match func_808B5984 * Matched func_808B58CC * Matched EnMThunder_Destroy * Matched EnMThunder_Update * Matched EnMThunder_Draw * Matched data * Doc WIP * Code docs * Assets * PR * Rename one more function from OoT WIP docs * Update src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * PR Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> --- assets/xml/objects/gameplay_keep.xml | 29 +- include/functions.h | 2 +- spec | 3 +- src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c | 4 +- src/overlays/actors/ovl_Eff_Dust/z_eff_dust.h | 2 +- .../actors/ovl_En_M_Thunder/z_en_m_thunder.c | 546 +++++++++++++++++- .../actors/ovl_En_M_Thunder/z_en_m_thunder.h | 27 +- src/overlays/actors/ovl_En_St/z_en_st.c | 4 +- tools/disasm/functions.txt | 16 +- 9 files changed, 583 insertions(+), 50 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 354c710bbf..ee2bed429a 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -915,18 +915,23 @@ - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/include/functions.h b/include/functions.h index 99e030cde6..41f3308ebb 100644 --- a/include/functions.h +++ b/include/functions.h @@ -3146,7 +3146,7 @@ void AudioSfx_LowerSfxSettingsReverb(Vec3f* pos, s8 isReverbLowered); // void func_8019F7D8(void); // void func_8019F830(void); void func_8019F88C(Vec3f* arg0, u16 sfxId, UNK_TYPE arg2); -// void func_8019F900(void); +void func_8019F900(Vec3f* pos, u8 chargeLevel); // void func_8019FA18(void); void func_8019FAD8(Vec3f* param_1, u16 sfxId, f32 param_3); void func_8019FB0C(Vec3f* arg0, u16 sfxId, f32 arg2, s32 arg3); diff --git a/spec b/spec index 9ad5e4cca9..e2ea0c1b33 100644 --- a/spec +++ b/spec @@ -984,8 +984,7 @@ beginseg name "ovl_En_M_Thunder" compress include "build/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.o" - include "build/data/ovl_En_M_Thunder/ovl_En_M_Thunder.data.o" - include "build/data/ovl_En_M_Thunder/ovl_En_M_Thunder.reloc.o" + include "build/src/overlays/actors/ovl_En_M_Thunder/ovl_En_M_Thunder_reloc.o" endseg beginseg 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 b2d896a14c..c517ad007a 100644 --- a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c +++ b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c @@ -71,7 +71,7 @@ void EffDust_Init(Actor* thisx, PlayState* play) { this->dz = 0.8f; this->scalingFactor = 0.5f; break; - case EFF_DUST_TYPE_2: + case EFF_DUST_TYPE_SPIN_ATTACK_CHARGE: case EFF_DUST_TYPE_3: this->actionFunc = func_80919230; this->actor.draw = func_809199FC; @@ -203,7 +203,7 @@ void func_80919230(EffDust* this, PlayState* play) { if (this->distanceTraveled[i] >= 1.0f) { theta = randPlusMinusPoint5Scaled(0x10000); switch (this->actor.params) { - case EFF_DUST_TYPE_2: + case EFF_DUST_TYPE_SPIN_ATTACK_CHARGE: this->initialPositions[i].x = (Rand_ZeroOne() * 4500.0f) + 700.0f; if (this->initialPositions[i].x > 3000.0f) { this->initialPositions[i].y = (3000.0f * Rand_ZeroOne()) * Math_SinS(theta); diff --git a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.h b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.h index ec864ea4d7..d73b5ce0ea 100644 --- a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.h +++ b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.h @@ -24,7 +24,7 @@ typedef struct EffDust { typedef enum { /* 0x0 */ EFF_DUST_TYPE_0, /* 0x1 */ EFF_DUST_TYPE_1, - /* 0x2 */ EFF_DUST_TYPE_2, + /* 0x2 */ EFF_DUST_TYPE_SPIN_ATTACK_CHARGE, /* 0x3 */ EFF_DUST_TYPE_3, /* 0x4 */ EFF_DUST_TYPE_4, /* 0x5 */ EFF_DUST_TYPE_5 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 b509cf7899..fbfb170408 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 @@ -6,6 +6,8 @@ #include "z_en_m_thunder.h" #include "z64rumble.h" +#include "overlays/actors/ovl_Eff_Dust/z_eff_dust.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10) @@ -16,7 +18,17 @@ void EnMThunder_Destroy(Actor* thisx, PlayState* play); void EnMThunder_Update(Actor* thisx, PlayState* play); void EnMThunder_Draw(Actor* thisx, PlayState* play); -#if 0 +void EnMThunder_UnkType_Update(Actor* thisx, PlayState* play); + +void EnMThunder_AdjustLights(PlayState* play, f32 arg1); + +void EnMThunder_Charge(EnMThunder* this, PlayState* play); +void EnMThunder_Spin_Attack(EnMThunder* this, PlayState* play); +void EnMThunder_SwordBeam_Attack(EnMThunder* this, PlayState* play); +void EnMThunder_UnkType_Attack(EnMThunder* this, PlayState* play); + +#define ENMTHUNDER_TYPE_MAX 4 + const ActorInit En_M_Thunder_InitVars = { ACTOR_EN_M_THUNDER, ACTORCAT_ITEMACTION, @@ -29,39 +41,533 @@ const ActorInit En_M_Thunder_InitVars = { (ActorFunc)EnMThunder_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808B7120 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_NONE, OC1_NONE, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK2, { 0x01000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_NONE, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK2, + { 0x01000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_ON, + OCELEM_ON, + }, { 200, 200, 0, { 0, 0, 0 } }, }; -#endif +static u8 sDamages[] = { + 1, 2, 3, 4, // Regular + 1, 2, 3, 4, // Great Spin +}; -extern ColliderCylinderInit D_808B7120; +static u16 sChargingSfxIds[] = { + NA_SE_IT_ROLLING_CUT_LV2, // ENMTHUNDER_SUBTYPE_SPIN_GREAT + NA_SE_IT_ROLLING_CUT_LV1, // ENMTHUNDER_SUBTYPE_SPIN_REGULAR + NA_SE_IT_ROLLING_CUT_LV2, // ENMTHUNDER_SUBTYPE_SWORDBEAM_GREAT + NA_SE_IT_ROLLING_CUT_LV1, // ENMTHUNDER_SUBTYPE_SWORDBEAM_REGULAR +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/func_808B53C0.s") +static f32 sScales[] = { 0.1f, 0.15f, 0.2f, 0.25f, 0.3f, 0.25f, 0.2f, 0.15f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/EnMThunder_Init.s") +typedef enum { + /* 0 */ ENMTHUNDER_SUBTYPE_SPIN_GREAT, + /* 1 */ ENMTHUNDER_SUBTYPE_SPIN_REGULAR, + /* 2 */ ENMTHUNDER_SUBTYPE_SWORDBEAM_GREAT, + /* 3 */ ENMTHUNDER_SUBTYPE_SWORDBEAM_REGULAR +} EnMThunderSubType; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/EnMThunder_Destroy.s") +void EnMThunder_UnkType_Setup(EnMThunder* this, PlayState* play) { + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/func_808B5890.s") + this->actor.update = EnMThunder_UnkType_Update; + this->isCharging = false; + this->subtype = ENMTHUNDER_SUBTYPE_SPIN_REGULAR; + this->scaleTarget = 2; + this->actionFunc = EnMThunder_UnkType_Attack; + this->timer = 8; + this->lightColorFrac = 1.0f; + AudioSfx_PlaySfx(NA_SE_IT_ROLLING_CUT_LV1, &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, + &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + this->actor.child = NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/func_808B58CC.s") +void EnMThunder_Init(Actor* thisx, PlayState* play) { + s32 pad; + EnMThunder* this = THIS; + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/func_808B5984.s") + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + this->type = ENMTHUNDER_GET_TYPE(&this->actor); + Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 255, 255, 255, 0); + this->lightNode = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfo); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/func_808B5EEC.s") + if (this->type == ENMTHUNDER_TYPE_UNK) { + EnMThunder_UnkType_Setup(this, play); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/func_808B5F68.s") + this->collider.dim.radius = 0; + this->collider.dim.height = 40; + this->collider.dim.yShift = -20; + this->timer = 8; + this->scroll = 0.0f; + this->actor.world.pos = player->bodyPartsPos[0]; + this->lightColorFrac = 0.0f; + this->adjustLightsArg1 = 0.0f; + this->actor.shape.rot.y = player->actor.shape.rot.y + 0x8000; + this->actor.shape.rot.x = -this->actor.world.rot.x; + this->actor.room = -1; + Actor_SetScale(&this->actor, 0.1f); + this->isCharging = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/func_808B60D4.s") + if (player->stateFlags2 & PLAYER_STATE2_20000) { + if (!gSaveContext.save.playerData.isMagicAcquired || (gSaveContext.magicState != MAGIC_STATE_IDLE) || + ((ENMTHUNDER_GET_MAGIC_COST(&this->actor) != 0) && + !Magic_Consume(play, ENMTHUNDER_GET_MAGIC_COST(&this->actor), MAGIC_CONSUME_NOW))) { + AudioSfx_PlaySfx(NA_SE_IT_ROLLING_CUT, &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, + &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + AudioSfx_PlaySfx(NA_SE_IT_SWORD_SWING_HARD, &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, + &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/func_808B6310.s") + player->stateFlags2 &= ~PLAYER_STATE2_20000; + this->isCharging = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/EnMThunder_Update.s") + if (gSaveContext.save.weekEventReg[23] & 2) { + player->unk_B08[0] = 1.0f; + this->collider.info.toucher.damage = sDamages[this->type + ENMTHUNDER_TYPE_MAX]; + this->subtype = ENMTHUNDER_SUBTYPE_SPIN_GREAT; + if (this->type == ENMTHUNDER_TYPE_GREAT_FAIRY_SWORD) { + this->scaleTarget = 6; + } else if (this->type == ENMTHUNDER_TYPE_GILDED_SWORD) { + this->scaleTarget = 4; + } else { + this->scaleTarget = 3; + } + } else { + player->unk_B08[0] = 0.5f; + this->collider.info.toucher.damage = sDamages[this->type]; + this->subtype = ENMTHUNDER_SUBTYPE_SPIN_REGULAR; + if (this->type == ENMTHUNDER_TYPE_GREAT_FAIRY_SWORD) { + this->scaleTarget = 4; + } else if (this->type == ENMTHUNDER_TYPE_GILDED_SWORD) { + this->scaleTarget = 3; + } else { + this->scaleTarget = 2; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/func_808B65BC.s") + if (player->meleeWeaponAnimation < PLAYER_MWA_SPIN_ATTACK_1H) { + this->subtype += ENMTHUNDER_SUBTYPE_SWORDBEAM_GREAT; + this->actionFunc = EnMThunder_SwordBeam_Attack; + this->timer = 1; + this->scaleTarget = 12; + this->collider.info.toucher.dmgFlags = DMG_SWORD_BEAM; + this->collider.info.toucher.damage = 3; + } else { + this->actionFunc = EnMThunder_Spin_Attack; + this->timer = 8; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/EnMThunder_Draw.s") + AudioSfx_PlaySfx(NA_SE_IT_ROLLING_CUT_LV1, &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, + &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + + this->lightColorFrac = 1.0f; + } else { + this->actionFunc = EnMThunder_Charge; + } + + this->actor.child = NULL; +} + +void EnMThunder_Destroy(Actor* thisx, PlayState* play) { + EnMThunder* this = THIS; + + if (this->isCharging) { + Magic_Reset(play); + } + + Collider_DestroyCylinder(play, &this->collider); + EnMThunder_AdjustLights(play, 0.0f); + LightContext_RemoveLight(play, &play->lightCtx, this->lightNode); +} + +void EnMThunder_AdjustLights(PlayState* play, f32 arg1) { + func_800FD2B4(play, arg1, 850.0f, 0.2f, 0.0f); +} + +void EnMThunder_Spin_AttackNoMagic(EnMThunder* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + if (player->stateFlags2 & PLAYER_STATE2_20000) { + if (player->meleeWeaponAnimation >= PLAYER_MWA_SPIN_ATTACK_1H) { + AudioSfx_PlaySfx(NA_SE_IT_ROLLING_CUT, &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, + &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + AudioSfx_PlaySfx(NA_SE_IT_SWORD_SWING_HARD, &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, + &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + } + Actor_MarkForDeath(&this->actor); + } else if (!(player->stateFlags1 & PLAYER_STATE1_1000)) { + Actor_MarkForDeath(&this->actor); + } +} + +void EnMThunder_Charge(EnMThunder* this, PlayState* play) { + Player* player = GET_PLAYER(play); + Actor* child = this->actor.child; + + this->unk1B0 = player->unk_B08[0]; + this->actor.world.pos = player->bodyPartsPos[0]; + this->actor.shape.rot.y = player->actor.shape.rot.y + 0x8000; + + if (!this->isCharging && (player->unk_B08[0] >= 0.1f)) { + if ((gSaveContext.magicState != MAGIC_STATE_IDLE) || + ((ENMTHUNDER_GET_MAGIC_COST(&this->actor) != 0) && + !Magic_Consume(play, ENMTHUNDER_GET_MAGIC_COST(&this->actor), MAGIC_CONSUME_WAIT_PREVIEW))) { + EnMThunder_Spin_AttackNoMagic(this, play); + this->actionFunc = EnMThunder_Spin_AttackNoMagic; + this->chargingAlpha = 0; + this->adjustLightsArg1 = 0.0f; + this->lightColorFrac = 0.0f; + return; + } + this->isCharging = true; + } + + if (player->unk_B08[0] >= 0.1f) { + Rumble_Request(0.0f, (s32)(player->unk_B08[0] * 150.0f), 2, (s32)(player->unk_B08[0] * 150.0f)); + } + + if (player->stateFlags2 & PLAYER_STATE2_20000) { + if ((child != NULL) && (child->update != NULL)) { + child->parent = NULL; + } + + if (player->unk_B08[0] <= 0.15f) { + if ((player->unk_B08[0] >= 0.1f) && (player->meleeWeaponAnimation >= PLAYER_MWA_SPIN_ATTACK_1H)) { + AudioSfx_PlaySfx(NA_SE_IT_ROLLING_CUT, &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, + &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + AudioSfx_PlaySfx(NA_SE_IT_SWORD_SWING_HARD, &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, + &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + } + Actor_MarkForDeath(&this->actor); + return; + } + + player->stateFlags2 &= ~PLAYER_STATE2_20000; + + if (ENMTHUNDER_GET_MAGIC_COST(&this->actor) != 0) { + gSaveContext.magicState = MAGIC_STATE_CONSUME_SETUP; + } + + if (player->unk_B08[0] < 0.85f) { + this->collider.info.toucher.damage = sDamages[this->type]; + this->subtype = ENMTHUNDER_SUBTYPE_SPIN_REGULAR; + if (this->type == ENMTHUNDER_TYPE_GREAT_FAIRY_SWORD) { + this->scaleTarget = 4; + } else if (this->type == ENMTHUNDER_TYPE_GILDED_SWORD) { + this->scaleTarget = 3; + } else { + this->scaleTarget = 2; + } + } else { + this->collider.info.toucher.damage = sDamages[this->type + ENMTHUNDER_TYPE_MAX]; + this->subtype = ENMTHUNDER_SUBTYPE_SPIN_GREAT; + if (this->type == ENMTHUNDER_TYPE_GREAT_FAIRY_SWORD) { + this->scaleTarget = 6; + } else if (this->type == ENMTHUNDER_TYPE_GILDED_SWORD) { + this->scaleTarget = 4; + } else { + this->scaleTarget = 3; + } + } + + if (player->meleeWeaponAnimation < PLAYER_MWA_SPIN_ATTACK_1H) { + this->subtype += ENMTHUNDER_SUBTYPE_SWORDBEAM_GREAT; + this->actionFunc = EnMThunder_SwordBeam_Attack; + this->timer = 1; + } else { + this->actionFunc = EnMThunder_Spin_Attack; + this->timer = 8; + } + + AudioSfx_PlaySfx(sChargingSfxIds[this->subtype], &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, + &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + + this->lightColorFrac = 1.0f; + + return; + } + + if (!(player->stateFlags1 & PLAYER_STATE1_1000)) { + if (this->actor.child != NULL) { + this->actor.child->parent = NULL; + } + Actor_MarkForDeath(&this->actor); + return; + } + + if (player->unk_B08[0] > 0.15f) { + this->chargingAlpha = 255; + if (this->actor.child == NULL) { + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EFF_DUST, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, + EFF_DUST_TYPE_SPIN_ATTACK_CHARGE); + } + this->adjustLightsArg1 += (((player->unk_B08[0] - 0.15f) * 1.5f) - this->adjustLightsArg1) * 0.5f; + } else if (player->unk_B08[0] > .1f) { + this->chargingAlpha = (s32)((player->unk_B08[0] - .1f) * 255.0f * 20.0f); + this->lightColorFrac = (player->unk_B08[0] - .1f) * 10.0f; + } else { + this->chargingAlpha = 0; + } + + if (player->unk_B08[0] > 0.85f) { + func_8019F900(&player->actor.projectedPos, 2); + } else if (player->unk_B08[0] > 0.15f) { + func_8019F900(&player->actor.projectedPos, 1); + } else if (player->unk_B08[0] > 0.1f) { + func_8019F900(&player->actor.projectedPos, 0); + } + + if (Play_InCsMode(play)) { + Actor_MarkForDeath(&this->actor); + } +} + +void func_808B5EEC(EnMThunder* this, PlayState* play) { + if (this->timer < 2) { + if (this->chargingAlpha < 40) { + this->chargingAlpha = 0; + } else { + this->chargingAlpha -= 40; + } + } + + this->scroll += 2.0f * this->alphaFrac; + + if (this->adjustLightsArg1 < this->lightColorFrac) { + this->adjustLightsArg1 = F32_LERPIMP(this->adjustLightsArg1, this->lightColorFrac, 0.1f); + } else { + this->adjustLightsArg1 = this->lightColorFrac; + } +} + +void EnMThunder_Spin_Attack(EnMThunder* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + if (Math_StepToF(&this->lightColorFrac, 0.0f, 0.0625f)) { + Actor_MarkForDeath(&this->actor); + } else { + Math_SmoothStepToF(&this->actor.scale.x, (s32)this->scaleTarget, 0.6f, 0.8f, 0.0f); + Actor_SetScale(&this->actor, this->actor.scale.x); + this->collider.dim.radius = this->actor.scale.x * 30.0f; + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); + } + + if (this->timer > 0) { + this->actor.world.pos.x = player->bodyPartsPos[0].x; + this->actor.world.pos.z = player->bodyPartsPos[0].z; + this->timer--; + } + + if (this->lightColorFrac > (6.0f / 10.0f)) { + this->alphaFrac = 1.0f; + } else { + this->alphaFrac = this->lightColorFrac * (10.0f / 6.0f); + } + + func_808B5EEC(this, play); + + if (Play_InCsMode(play)) { + Actor_MarkForDeath(&this->actor); + } +} + +void EnMThunder_SwordBeam_Attack(EnMThunder* this, PlayState* play) { + s32 pad[2]; + f32 sp2C; + + if (this->lightColorFrac > (9.0f / 10.0f)) { + this->alphaFrac = 1.0f; + } else { + this->alphaFrac = this->lightColorFrac * (10.0f / 9.0f); + } + + if (Math_StepToF(&this->lightColorFrac, 0.0f, 0.05f)) { + Actor_MarkForDeath(&this->actor); + } else { + sp2C = -80.0f * Math_CosS(this->actor.world.rot.x); + + this->actor.world.pos.x += sp2C * Math_SinS(this->actor.shape.rot.y); + this->actor.world.pos.z += sp2C * Math_CosS(this->actor.shape.rot.y); + this->actor.world.pos.y += -80.0f * Math_SinS(this->actor.world.rot.x); + + Math_SmoothStepToF(&this->actor.scale.x, this->scaleTarget, 0.6f, 2.0f, 0.0f); + Actor_SetScale(&this->actor, this->actor.scale.x); + + this->collider.dim.radius = this->actor.scale.x * 5.0f; + + this->collider.dim.pos.x = this->actor.world.pos.x; + this->collider.dim.pos.y = this->actor.world.pos.y; + this->collider.dim.pos.z = this->actor.world.pos.z; + + this->collider.dim.pos.x = + (Math_SinS(this->actor.shape.rot.y) * -5.0f * this->actor.scale.x) + this->actor.world.pos.x; + this->collider.dim.pos.y = this->actor.world.pos.y; + this->collider.dim.pos.z = + (Math_CosS(this->actor.shape.rot.y) * -5.0f * this->actor.scale.z) + this->actor.world.pos.z; + + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); + } + + if (this->timer > 0) { + this->timer--; + } + + func_808B5EEC(this, play); +} + +void EnMThunder_UnkType_Attack(EnMThunder* this, PlayState* play) { + if (Math_StepToF(&this->lightColorFrac, 0.0f, 0.0625f)) { + Actor_MarkForDeath(&this->actor); + } else { + Math_SmoothStepToF(&this->actor.scale.x, (s32)this->scaleTarget, 0.6f, 0.8f, 0.0f); + Actor_SetScale(&this->actor, this->actor.scale.x); + } + + if (this->lightColorFrac > (6.0f / 10.0f)) { + this->alphaFrac = 1.0f; + } else { + this->alphaFrac = this->lightColorFrac * (10.0f / 6.0f); + } + + func_808B5EEC(this, play); +} + +void EnMThunder_Update(Actor* thisx, PlayState* play) { + EnMThunder* this = THIS; + + this->actionFunc(this, play); + EnMThunder_AdjustLights(play, this->adjustLightsArg1); + Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, this->lightColorFrac * 255.0f, this->lightColorFrac * 255.0f, + this->lightColorFrac * 100.0f, this->lightColorFrac * 800.0f); +} + +void EnMThunder_UnkType_Update(Actor* thisx, PlayState* play) { + EnMThunder* this = THIS; + + this->actionFunc(this, play); + Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, this->lightColorFrac * 255.0f, this->lightColorFrac * 255.0f, + this->lightColorFrac * 100.0f, this->lightColorFrac * 800.0f); +} + +void EnMThunder_Draw(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EnMThunder* this = THIS; + Player* player = GET_PLAYER(play); + f32 scale; + s32 y2Scroll; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C2DC(play->state.gfxCtx); + Matrix_Scale(0.02f, 0.02f, 0.02f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + switch (this->subtype) { + case ENMTHUNDER_SUBTYPE_SPIN_GREAT: + case ENMTHUNDER_SUBTYPE_SPIN_REGULAR: + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0xFF - ((u16)(s32)(this->scroll * 30.0f) & 0xFF), 0, 64, + 32, 1, 0xFF - ((u16)(s32)(this->scroll * 20.0f) & 0xFF), 0, 8, 8)); + break; + + case ENMTHUNDER_SUBTYPE_SWORDBEAM_GREAT: + case ENMTHUNDER_SUBTYPE_SWORDBEAM_REGULAR: + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 16, 64, 1, 0, + 0x1FF - ((u16)(s32)(this->scroll * 10.0f) & 0x1FF), 32, 128)); + break; + + default: + break; + } + + switch (this->subtype) { + case ENMTHUNDER_SUBTYPE_SPIN_GREAT: + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 170, (u16)(this->alphaFrac * 255.0f)); + gSPDisplayList(POLY_XLU_DISP++, gGreatSpinAttackDiskDL); + gSPDisplayList(POLY_XLU_DISP++, gGreatSpinAttackCylinderDL); + break; + + case ENMTHUNDER_SUBTYPE_SPIN_REGULAR: + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 170, 255, 255, (u16)(this->alphaFrac * 255.0f)); + gSPDisplayList(POLY_XLU_DISP++, gSpinAttackDiskDL); + gSPDisplayList(POLY_XLU_DISP++, gSpinAttackCylinderDL); + break; + + case ENMTHUNDER_SUBTYPE_SWORDBEAM_REGULAR: + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 170, 255, 255, (u16)(this->alphaFrac * 255.0f)); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 100, 255, 128); + gSPDisplayList(POLY_XLU_DISP++, gSwordBeamDL); + break; + + case ENMTHUNDER_SUBTYPE_SWORDBEAM_GREAT: + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 0, 255, 255, (u16)(this->alphaFrac * 255.0f)); + gDPSetEnvColor(POLY_XLU_DISP++, 200, 200, 200, 128); + gSPDisplayList(POLY_XLU_DISP++, gSwordBeamDL); + break; + + default: + break; + } + + Matrix_Mult(&player->mf_CC4, MTXMODE_NEW); + + if (this->type == ENMTHUNDER_TYPE_GILDED_SWORD) { + Matrix_Translate(0.0f, 220.0f, 0.0f, MTXMODE_APPLY); + Matrix_Scale(-1.2f, -0.8f, -0.6f, MTXMODE_APPLY); + Matrix_RotateXS(0x4000, MTXMODE_APPLY); + } else { + Matrix_Translate(0.0f, 220.0f, 0.0f, MTXMODE_APPLY); + Matrix_Scale(-0.7f, -0.6f, -0.4f, MTXMODE_APPLY); + Matrix_RotateXS(0x4000, MTXMODE_APPLY); + } + + if (this->unk1B0 >= 0.85f) { + scale = (sScales[play->gameplayFrames & 7] * 6.0f) + 1.0f; + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 170, this->chargingAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 100, 0, 128); + y2Scroll = 40; + } else { + scale = (sScales[play->gameplayFrames & 7] * 2.0f) + 1.0f; + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 170, 255, 255, this->chargingAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 100, 255, 128); + y2Scroll = 20; + } + + Matrix_Scale(1.0f, scale, scale, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_XLU_DISP++, 0x09, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, (play->gameplayFrames * 5) & 0xFF, 0, 32, 32, 1, + (play->gameplayFrames * 20) & 0xFF, (play->gameplayFrames * y2Scroll) & 0xFF, 8, 8)); + gSPDisplayList(POLY_XLU_DISP++, gSpinAttackChargingDL); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.h b/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.h index 14d0227704..7ac851e920 100644 --- a/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.h +++ b/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.h @@ -5,13 +5,36 @@ struct EnMThunder; +#define ENMTHUNDER_GET_TYPE(thisx) ((thisx)->params & 0xFF) +#define ENMTHUNDER_GET_MAGIC_COST(thisx) (((thisx)->params & 0xFF00) >> 8) + +typedef enum { + /* 0x00 */ ENMTHUNDER_TYPE_KOKIRI_SWORD, + /* 0x01 */ ENMTHUNDER_TYPE_RAZOR_SWORD, + /* 0x02 */ ENMTHUNDER_TYPE_GILDED_SWORD, + /* 0x03 */ ENMTHUNDER_TYPE_GREAT_FAIRY_SWORD, + /* 0x80 */ ENMTHUNDER_TYPE_UNK = 0x80 +} EnMThunderType; + typedef void (*EnMThunderActionFunc)(struct EnMThunder*, PlayState*); typedef struct EnMThunder { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x74]; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ LightNode* lightNode; + /* 0x194 */ LightInfo lightInfo; + /* 0x1A4 */ f32 lightColorFrac; + /* 0x1A8 */ f32 alphaFrac; + /* 0x1AC */ f32 scroll; + /* 0x1B0 */ f32 unk1B0; + /* 0x1B4 */ f32 adjustLightsArg1; /* 0x1B8 */ EnMThunderActionFunc actionFunc; - /* 0x1BC */ char unk_1BC[0x8]; + /* 0x1BC */ u16 timer; + /* 0x1BE */ u8 subtype; + /* 0x1BF */ u8 type; + /* 0x1C0 */ u8 chargingAlpha; + /* 0x1C1 */ u8 scaleTarget; + /* 0x1C2 */ u8 isCharging; } EnMThunder; // size = 0x1C4 extern const ActorInit En_M_Thunder_InitVars; 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 7d0dcbf114..ecc2b85b22 100644 --- a/src/overlays/actors/ovl_En_St/z_en_st.c +++ b/src/overlays/actors/ovl_En_St/z_en_st.c @@ -260,8 +260,8 @@ void func_808A54B0(EnSt* this, PlayState* play) { } gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 170, 255, 255, (u8)(255 * temp_f0)); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_025850); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_025970); + gSPDisplayList(POLY_XLU_DISP++, gSpinAttackDiskDL); + gSPDisplayList(POLY_XLU_DISP++, gSpinAttackCylinderDL); CLOSE_DISPS(play->state.gfxCtx); } diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index ef47869a5d..a465f75992 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -5947,18 +5947,18 @@ 0x808B5230:("EnMFire1_Init",), 0x808B5294:("EnMFire1_Destroy",), 0x808B52C0:("EnMFire1_Update",), - 0x808B53C0:("func_808B53C0",), + 0x808B53C0:("EnMThunder_UnkType_Setup",), 0x808B545C:("EnMThunder_Init",), 0x808B5820:("EnMThunder_Destroy",), - 0x808B5890:("func_808B5890",), - 0x808B58CC:("func_808B58CC",), - 0x808B5984:("func_808B5984",), + 0x808B5890:("EnMThunder_AdjustLights",), + 0x808B58CC:("EnMThunder_Spin_AttackNoMagic",), + 0x808B5984:("EnMThunder_Charge",), 0x808B5EEC:("func_808B5EEC",), - 0x808B5F68:("func_808B5F68",), - 0x808B60D4:("func_808B60D4",), - 0x808B6310:("func_808B6310",), + 0x808B5F68:("EnMThunder_Spin_Attack",), + 0x808B60D4:("EnMThunder_SwordBeam_Attack",), + 0x808B6310:("EnMThunder_UnkType_Attack",), 0x808B63E8:("EnMThunder_Update",), - 0x808B65BC:("func_808B65BC",), + 0x808B65BC:("EnMThunder_UnkType_Update",), 0x808B677C:("EnMThunder_Draw",), 0x808B7360:("BgBreakwall_SetupAction",), 0x808B736C:("func_808B736C",), From 063d24f491e137778bdd6c65f0942d8ce74a2a91 Mon Sep 17 00:00:00 2001 From: chloe!! <47910150+chloebangbang@users.noreply.github.com> Date: Sun, 2 Oct 2022 00:07:07 -0500 Subject: [PATCH 13/25] ovl_En_Door_Etc OK (#994) * ovl_En_Door_Etc OK * review fixes * more review fixes * name yawDiff variables * various vixes * Update src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.c Co-authored-by: Chloe <> Co-authored-by: EllipticEllipsis --- spec | 3 +- .../actors/ovl_En_Door_Etc/z_en_door_etc.c | 222 ++++++++++++++++-- .../actors/ovl_En_Door_Etc/z_en_door_etc.h | 11 +- tools/disasm/functions.txt | 6 +- tools/disasm/variables.txt | 6 +- 5 files changed, 219 insertions(+), 29 deletions(-) diff --git a/spec b/spec index e2ea0c1b33..80141af9c4 100644 --- a/spec +++ b/spec @@ -3198,8 +3198,7 @@ beginseg name "ovl_En_Door_Etc" compress include "build/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.o" - include "build/data/ovl_En_Door_Etc/ovl_En_Door_Etc.data.o" - include "build/data/ovl_En_Door_Etc/ovl_En_Door_Etc.reloc.o" + include "build/src/overlays/actors/ovl_En_Door_Etc/ovl_En_Door_Etc_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.c b/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.c index 0d3612145f..98e9d2b8fa 100644 --- a/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.c +++ b/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.c @@ -5,6 +5,7 @@ */ #include "z_en_door_etc.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10) @@ -14,7 +15,11 @@ void EnDoorEtc_Init(Actor* thisx, PlayState* play); void EnDoorEtc_Destroy(Actor* thisx, PlayState* play); void EnDoorEtc_Update(Actor* thisx, PlayState* play); -#if 0 +void EnDoorEtc_WaitForObject(EnDoorEtc* this, PlayState* play); +void func_80AC21A0(EnDoorEtc* this, PlayState* play); +void func_80AC2354(EnDoorEtc* this, PlayState* play); +void EnDoorEtc_Draw(Actor* thisx, PlayState* play); + const ActorInit En_Door_Etc_InitVars = { ACTOR_EN_DOOR_ETC, ACTORCAT_DOOR, @@ -27,42 +32,219 @@ const ActorInit En_Door_Etc_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80AC25A0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 100, 40, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80AC2634[] = { +typedef struct { + /* 0x0 */ s16 sceneId; + /* 0x2 */ u8 dListIndex; + /* 0x4 */ s16 objectId; +} EnDoorEtcInfo; // size = 0x6 + +EnDoorEtcInfo sObjInfo[] = { + { SCENE_MITURIN, 1, OBJECT_NUMA_OBJ }, + { -1, 0, GAMEPLAY_KEEP }, + { -1, 13, GAMEPLAY_FIELD_KEEP }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_U8(targetMode, 0, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_U16(shape.rot.x, 0, ICHAIN_CONTINUE), ICHAIN_U16(shape.rot.z, 0, ICHAIN_STOP), }; -#endif +void EnDoorEtc_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + s32 objectIndex; + EnDoorEtcInfo* objectInfo = sObjInfo; + s32 i; + EnDoorEtc* this = THIS; -extern ColliderCylinderInit D_80AC25A0; -extern InitChainEntry D_80AC2634[]; + Actor_ProcessInitChain(&this->actor, sInitChain); + Actor_SetScale(&this->actor, 0.01f); + this->actor.shape.rot.x = -0x4000; + this->angle = 0; + for (i = 0; i < 15; i++, objectInfo++) { + if (play->sceneId == objectInfo->sceneId) { + break; + } + } + if ((i >= 15) && (Object_GetIndex(&play->objectCtx, GAMEPLAY_FIELD_KEEP) >= 0)) { + objectInfo++; + } + objectIndex = Object_GetIndex(&play->objectCtx, objectInfo->objectId); + if (objectIndex < 0) { + Actor_MarkForDeath(&this->actor); + } else { + this->objectIndex = objectIndex; + this->dListIndex = objectInfo->dListIndex; + if (this->actor.objBankIndex == this->objectIndex) { + EnDoorEtc_WaitForObject(this, play); + } else { + this->actionFunc = EnDoorEtc_WaitForObject; + } + } + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door_Etc/EnDoorEtc_Init.s") +void EnDoorEtc_Destroy(Actor* thisx, PlayState* play) { + EnDoorEtc* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door_Etc/EnDoorEtc_Destroy.s") + Collider_DestroyCylinder(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door_Etc/func_80AC2044.s") +/** + * Calculates if the distance between `a` and `b` is greater than distance `c` + */ +s32 EnDoorEtc_IsDistanceGreater(Vec3f* a, Vec3f* b, f32 c) { + f32 dx = b->x - a->x; + f32 dy = b->y - a->y; + f32 dz = b->z - a->z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door_Etc/func_80AC20A8.s") + return ((SQ(dx) + SQ(dy) + SQ(dz)) < SQ(c)); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door_Etc/func_80AC2118.s") +void EnDoorEtc_WaitForObject(EnDoorEtc* this, PlayState* play) { + if (Object_IsLoaded(&play->objectCtx, this->objectIndex)) { + this->actor.flags &= ~ACTOR_FLAG_10; + this->actor.objBankIndex = this->objectIndex; + this->actionFunc = func_80AC2354; + this->actor.draw = EnDoorEtc_Draw; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door_Etc/func_80AC2154.s") +void func_80AC2118(EnDoorEtc* this, PlayState* play) { + if (this->angle < 0) { + this->angle += 0x100; + } else { + this->angle = 0; + this->actionFunc = func_80AC21A0; + this->unk_1F4 &= ~1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door_Etc/func_80AC21A0.s") +void func_80AC2154(EnDoorEtc* this, PlayState* play) { + if (this->timer > 0) { + this->timer--; + } else if (this->angle > -0x4000) { + this->angle -= 0x800; + } else { + this->angle = -0x4000; + this->actionFunc = func_80AC2118; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door_Etc/func_80AC2354.s") +void func_80AC21A0(EnDoorEtc* this, PlayState* play) { + Player* player = GET_PLAYER(play); + Vec3f playerOffsetFromDoor; + s32 pad; + s16 yawDiff; + s32 yawDiffAbs; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door_Etc/EnDoorEtc_Update.s") + Actor_OffsetOfPointInActorCoords(&this->actor, &playerOffsetFromDoor, &player->actor.world.pos); + if (this->unk_1A1 == 0) { + if ((!Player_InCsMode(play)) && + ((fabsf(playerOffsetFromDoor.y) < 20.0f) && fabsf(playerOffsetFromDoor.x) < 20.0f) && + (fabsf(playerOffsetFromDoor.z) < 50.0f)) { + yawDiff = player->actor.shape.rot.y - this->actor.shape.rot.y; + if (playerOffsetFromDoor.z > 0.0f) { + yawDiff = 0x8000 - yawDiff; + } + yawDiffAbs = ABS_ALT(yawDiff); + if (yawDiffAbs < 0x3000) { + player->doorDirection = (playerOffsetFromDoor.z >= 0.0f) ? 1.0f : -1.0f; + player->doorActor = &this->actor; + player->doorType = -1; + } + } + } + if ((this->actor.textId == 0x239B) && Flags_GetSwitch(play, ENDOORETC_GET_SWITCHFLAG(&this->actor))) { + Flags_UnsetSwitch(play, ENDOORETC_GET_SWITCHFLAG(&this->actor)); + this->actionFunc = func_80AC2154; + this->actor.textId = 0x1800; // "It won't budge!" + this->unk_1F4 |= 1; + this->timer = 0x5A; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door_Etc/func_80AC24A8.s") +void func_80AC2354(EnDoorEtc* this, PlayState* play) { + Actor* door = play->actorCtx.actorLists[ACTORCAT_DOOR].first; + + while (door != NULL) { + if ((door->id != ACTOR_EN_DOOR) || + !EnDoorEtc_IsDistanceGreater(&door->world.pos, &this->actor.world.pos, 10.0f)) { + door = door->next; + } else { + this->actor.world.pos.x = door->world.pos.x; + this->actor.world.pos.y = door->world.pos.y; + this->actor.world.pos.z = door->world.pos.z; + this->actor.shape.rot.y = door->shape.rot.y; + this->actor.world.rot.y = door->world.rot.y; + Actor_MarkForDeath(door); + this->actionFunc = func_80AC21A0; + this->actor.textId = 0x239B; + Actor_SetFocus(&this->actor, 70.0f); + break; + } + } +} + +void EnDoorEtc_Update(Actor* thisx, PlayState* play) { + s32 pad; + EnDoorEtc* this = THIS; + + this->actionFunc(this, play); + if (this->unk_1F4 & 1) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + } +} + +void EnDoorEtc_Draw(Actor* thisx, PlayState* play) { + EnDoorEtc* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + Matrix_Translate(-2900.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateZS(this->angle, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gDoorLeftDL); + gSPDisplayList(POLY_OPA_DISP++, gDoorRightDL); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.h b/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.h index 18d525f44a..cbcdf2f54f 100644 --- a/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.h +++ b/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.h @@ -5,11 +5,20 @@ struct EnDoorEtc; +#define ENDOORETC_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) + typedef void (*EnDoorEtcActionFunc)(struct EnDoorEtc*, PlayState*); typedef struct EnDoorEtc { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0xB4]; + /* 0x144 */ char pad_144[0x5D]; + /* 0x1A1 */ u8 unk_1A1; + /* 0x1A2 */ s8 objectIndex; + /* 0x1A3 */ u8 dListIndex; // Never read, inferred from ovl_En_Door + /* 0x1A4 */ s16 angle; + /* 0x1A6 */ s16 timer; + /* 0x1A8 */ ColliderCylinder collider; + /* 0x1F4 */ u8 unk_1F4; /* 0x1F8 */ EnDoorEtcActionFunc actionFunc; } EnDoorEtc; // size = 0x1FC diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index a465f75992..594ce3427b 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -11902,14 +11902,14 @@ 0x80AC1D14:("EnPoFusen_Draw",), 0x80AC1ED0:("EnDoorEtc_Init",), 0x80AC2018:("EnDoorEtc_Destroy",), - 0x80AC2044:("func_80AC2044",), - 0x80AC20A8:("func_80AC20A8",), + 0x80AC2044:("EnDoorEtc_IsDistanceGreater",), + 0x80AC20A8:("EnDoorEtc_WaitForObject",), 0x80AC2118:("func_80AC2118",), 0x80AC2154:("func_80AC2154",), 0x80AC21A0:("func_80AC21A0",), 0x80AC2354:("func_80AC2354",), 0x80AC2430:("EnDoorEtc_Update",), - 0x80AC24A8:("func_80AC24A8",), + 0x80AC24A8:("EnDoorEtc_Draw",), 0x80AC26F0:("EnBigokuta_Init",), 0x80AC2874:("EnBigokuta_Destroy",), 0x80AC28B4:("EnBigokuta_SetupCutsceneCamera",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 57d876acbb..97cf77e76c 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -12869,9 +12869,9 @@ 0x80AC1E00:("D_80AC1E00","f32","",0x4), 0x80AC1E04:("D_80AC1E04","f32","",0x4), 0x80AC2580:("En_Door_Etc_InitVars","UNK_TYPE1","",0x1), - 0x80AC25A0:("D_80AC25A0","UNK_TYPE1","",0x1), - 0x80AC25CC:("D_80AC25CC","UNK_TYPE2","",0x2), - 0x80AC2634:("D_80AC2634","UNK_TYPE1","",0x1), + 0x80AC25A0:("sCylinderInit","UNK_TYPE1","",0x1), + 0x80AC25CC:("sObjInfo","UNK_TYPE2","",0x2), + 0x80AC2634:("sInitChain","UNK_TYPE1","",0x1), 0x80AC2650:("D_80AC2650","f32","",0x4), 0x80AC4510:("En_Bigokuta_InitVars","UNK_TYPE1","",0x1), 0x80AC4530:("D_80AC4530","UNK_TYPE1","",0x1), From 841da5f13818741c1a50cd16605ad4934b9de36e Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Sun, 2 Oct 2022 10:32:57 -0400 Subject: [PATCH 14/25] View & Shrink_Window Docs (#1049) * view and shrink_window docs * cleanup * move func declaration to header * move struct to local * PR Suggestions * g to s --- include/functions.h | 41 --- include/variables.h | 2 - include/z64.h | 7 - include/z64shrink_window.h | 23 ++ include/z64view.h | 41 ++- src/code/speed_meter.c | 1 + src/code/z_camera.c | 2 + src/code/z_demo.c | 9 +- src/code/z_eventmgr.c | 1 + src/code/z_game_over.c | 3 +- src/code/z_kaleido_scope_call.c | 3 +- src/code/z_kaleido_setup.c | 6 +- src/code/z_message.c | 4 +- src/code/z_parameter.c | 2 +- src/code/z_play.c | 2 + src/code/z_quake.c | 9 +- src/code/z_shrink_window.c | 93 ++++--- src/code/z_view.c | 247 ++++++++++-------- src/overlays/actors/ovl_Boss_01/z_boss_01.c | 1 + src/overlays/actors/ovl_Boss_02/z_boss_02.c | 5 +- src/overlays/actors/ovl_Boss_04/z_boss_04.c | 3 +- src/overlays/actors/ovl_Boss_06/z_boss_06.c | 3 +- src/overlays/actors/ovl_Boss_07/z_boss_07.c | 1 + src/overlays/actors/ovl_En_Bsb/z_en_bsb.c | 1 + .../actors/ovl_En_Fishing/z_en_fishing.c | 3 +- .../actors/ovl_En_Knight/z_en_knight.c | 1 + .../actors/ovl_player_actor/z_player.c | 1 + .../gamestates/ovl_daytelop/z_daytelop.c | 2 + .../ovl_file_choose/z_file_choose_NES.c | 2 + .../gamestates/ovl_opening/z_opening.c | 2 + src/overlays/gamestates/ovl_select/z_select.c | 4 +- src/overlays/gamestates/ovl_title/z_title.c | 8 +- .../ovl_kaleido_scope/z_kaleido_scope_NES.c | 1 + tools/disasm/functions.txt | 50 ++-- tools/disasm/variables.txt | 4 +- tools/sizes/code_functions.csv | 50 ++-- 36 files changed, 362 insertions(+), 276 deletions(-) create mode 100644 include/z64shrink_window.h diff --git a/include/functions.h b/include/functions.h index 41f3308ebb..c79fc333f5 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2261,35 +2261,6 @@ void SkinMatrix_SetYRotation(MtxF* mf, s16 a); void SkinMatrix_MulYRotation(MtxF* mf, s16 a); void SkinMatrix_SetZRotation(MtxF* mf, s16 a); -void View_ViewportToVp(Vp* dest, Viewport* src); -void View_Init(View* view, GraphicsContext* gfxCtx); -void View_SetViewOrientation(View* view, Vec3f* eye, Vec3f* at, Vec3f* up); -void func_8013F050(View* view, Vec3f* eye, Vec3f* at, Vec3f* up); -void View_SetScale(View* view, f32 scale); -void View_GetScale(View* view, f32* scale); -void func_8013F0D0(View* view, f32 fovy, f32 zNear, f32 zFar); -void func_8013F100(View* view, f32* fovy, f32* zNear, f32* zFar); -void func_8013F120(View* view, f32 fovy, f32 zNear, f32 zFar); -void func_8013F15C(View* view, f32* fovy, f32* zNear, f32* zFar); -void View_SetViewport(View* view, Viewport* viewport); -void View_GetViewport(View* view, Viewport* viewport); -void View_WriteScissor(Gfx** gfx, s32 ulx, s32 uly, s32 lrx, s32 lry); -void View_SyncAndWriteScissor(View* view, Gfx** gfx); -void View_SetScissorForLetterbox(View* view); -s32 View_SetDistortionDirRot(View* view, f32 dirRotX, f32 dirRotY, f32 dirRotZ); -s32 View_SetDistortionScale(View* view, f32 scaleX, f32 scaleY, f32 scaleZ); -s32 View_SetDistortionSpeed(View* view, f32 speed); -s32 View_InitDistortion(View* view); -s32 View_ClearDistortion(View* view); -s32 View_SetDistortion(View* view, Vec3f dirRot, Vec3f scale, f32 speed); -s32 View_StepDistortion(View* view, Mtx* projectionMtx); -void View_RenderView(View* view, s32 uParm2); -s32 View_RenderToPerspectiveMatrix(View* view); -s32 View_RenderToOrthographicMatrix(View* view); -s32 func_8013FBC8(View* view); -s32 func_8013FD74(View* view); -s32 func_80140024(View* view); -s32 func_801400CC(View* view, Gfx** gfxp); void func_80140260(OSViMode* vimode); // void func_8014026C(OSViMode* param_1, UNK_TYPE1 param_2, s32 param_3, s32 param_4, s32 param_5, s32 param_6, s32 param_7, s32 param_8, UNK_TYPE4 param_9, s32 param_10, s16 param_11, u32 param_12, UNK_TYPE4 param_13); // void func_80140730(void); @@ -2399,18 +2370,6 @@ void Message_FindCreditsMessage(PlayState* play, u16 textId); void func_8015E7EC(PlayState* play, UNK_PTR puParm2); // void func_8015F8A8(UNK_TYPE4 ctxt); -void ShrinkWindow_SetLetterboxTarget(s32 target); -s32 ShrinkWindow_GetLetterboxTarget(void); -void ShrinkWindow_SetLetterboxMagnitude(s32 magnitude); -s32 ShrinkWindow_GetLetterboxMagnitude(void); -void ShrinkWindow_SetPillarboxTarget(s32 target); -s32 ShrinkWindow_GetPillarboxTarget(void); -void ShrinkWindow_SetPillarboxMagnitude(s32 magnitude); -s32 ShrinkWindow_GetPillarboxMagnitude(void); -void ShrinkWindow_Init(void); -void ShrinkWindow_Destroy(void); -void ShrinkWindow_Update(s32 framerateDivisor); -void ShrinkWindow_Draw(GraphicsContext* gfxCtx); // void func_80161180(void); s32 func_8016119C(Camera* camera, DbCameraUnkStruct* arg1); // void func_8016122C(void); diff --git a/include/variables.h b/include/variables.h index c7ea263f2a..ae97a6c51e 100644 --- a/include/variables.h +++ b/include/variables.h @@ -3181,8 +3181,6 @@ extern s16 D_801F4E7A; // extern UNK_TYPE1 D_801F6B1E; // extern UNK_TYPE1 D_801F6B20; // extern UNK_TYPE1 D_801F6B22; -extern ShrinkWindowContext gShrinkWindowContext; -extern ShrinkWindowContext* gShrinkWindowContextPtr; // extern UNK_TYPE4 D_801F6B50; // extern UNK_TYPE1 D_801F6B58; extern void (*sKaleidoScopeUpdateFunc)(PlayState* play); diff --git a/include/z64.h b/include/z64.h index ceb91bfb80..d038790729 100644 --- a/include/z64.h +++ b/include/z64.h @@ -286,13 +286,6 @@ typedef struct { /* 0x10 */ OSTime resetTime; } NmiBuff; // size >= 0x18 -typedef struct { - /* 0x0 */ s8 letterboxTarget; - /* 0x1 */ s8 letterboxMagnitude; - /* 0x2 */ s8 pillarboxTarget; - /* 0x3 */ s8 pillarboxMagnitude; -} ShrinkWindowContext; // size = 0x4 - typedef void(*osCreateThread_func)(void*); typedef enum { diff --git a/include/z64shrink_window.h b/include/z64shrink_window.h new file mode 100644 index 0000000000..2742fb602e --- /dev/null +++ b/include/z64shrink_window.h @@ -0,0 +1,23 @@ +#ifndef Z64SHRINK_WINDOW_H +#define Z64SHRINK_WINDOW_H + +#include "PR/ultratypes.h" + +struct GraphicsContext; + +void ShrinkWindow_Letterbox_SetSizeTarget(s32 target); +s32 ShrinkWindow_Letterbox_GetSizeTarget(void); +void ShrinkWindow_Letterbox_SetSize(s32 size); +s32 ShrinkWindow_Letterbox_GetSize(void); + +void ShrinkWindow_Pillarbox_SetSizeTarget(s32 target); +s32 ShrinkWindow_Pillarbox_GetSizeTarget(void); +void ShrinkWindow_Pillarbox_SetSize(s32 size); +s32 ShrinkWindow_Pillarbox_GetSize(void); + +void ShrinkWindow_Init(void); +void ShrinkWindow_Destroy(void); +void ShrinkWindow_Update(s32 framerateDivisor); +void ShrinkWindow_Draw(GraphicsContext* gfxCtx); + +#endif diff --git a/include/z64view.h b/include/z64view.h index 98ca1ab19f..f0661d9471 100644 --- a/include/z64view.h +++ b/include/z64view.h @@ -33,16 +33,27 @@ typedef struct View { /* 0x0E0 */ Mtx unkE0; /* 0x120 */ Mtx* projectionPtr; /* 0x124 */ Mtx* viewingPtr; - /* 0x128 */ Vec3f distortionDirRot; + /* 0x128 */ Vec3f distortionOrientation; /* 0x134 */ Vec3f distortionScale; /* 0x140 */ f32 distortionSpeed; - /* 0x144 */ Vec3f curDistortionDirRot; + /* 0x144 */ Vec3f curDistortionOrientation; /* 0x150 */ Vec3f curDistortionScale; - /* 0x15C */ u16 normal; // used to normalize the projection matrix + /* 0x15C */ u16 perspNorm; // used to normalize the projection matrix /* 0x160 */ u32 flags; // bit 3: Render to an orthographic perspective /* 0x164 */ s32 unk164; } View; // size = 0x168 +#define VIEW_VIEWING (1 << 0) +#define VIEW_VIEWPORT (1 << 1) +#define VIEW_PROJECTION_PERSPECTIVE (1 << 2) +#define VIEW_PROJECTION_ORTHO (1 << 3) +#define VIEW_ALL (VIEW_VIEWING | VIEW_VIEWPORT | VIEW_PROJECTION_PERSPECTIVE | VIEW_PROJECTION_ORTHO) + +#define VIEW_FORCE_VIEWING (VIEW_VIEWING << 4) +#define VIEW_FORCE_VIEWPORT (VIEW_VIEWPORT << 4) +#define VIEW_FORCE_PROJECTION_PERSPECTIVE (VIEW_PROJECTION_PERSPECTIVE << 4) +#define VIEW_FORCE_PROJECTION_ORTHO (VIEW_PROJECTION_ORTHO << 4) + #define SET_FULLSCREEN_VIEWPORT(view) \ { \ Viewport viewport; \ @@ -54,4 +65,28 @@ typedef struct View { } \ (void)0 +void View_Init(View* view, struct GraphicsContext* gfxCtx); +void View_LookAt(View* view, Vec3f* eye, Vec3f* at, Vec3f* up); +void View_SetScale(View* view, f32 scale); +void View_GetScale(View* view, f32* scale); +void View_SetPerspective(View* view, f32 fovy, f32 zNear, f32 zFar); +void View_GetPerspective(View* view, f32* fovy, f32* zNear, f32* zFar); +void View_SetOrtho(View* view, f32 fovy, f32 zNear, f32 zFar); +void View_GetOrtho(View* view, f32* fovy, f32* zNear, f32* zFar); +void View_SetViewport(View* view, Viewport* viewport); +void View_GetViewport(View* view, Viewport* viewport); + +s32 View_SetDistortionOrientation(View* view, f32 rotX, f32 rotY, f32 rotZ); +s32 View_SetDistortionScale(View* view, f32 scaleX, f32 scaleY, f32 scaleZ); +s32 View_SetDistortionSpeed(View* view, f32 speed); +s32 View_InitDistortion(View* view); +s32 View_ClearDistortion(View* view); +s32 View_SetDistortion(View* view, Vec3f orientation, Vec3f scale, f32 speed); + +void View_Apply(View* view, s32 mask); +s32 View_ApplyOrthoToOverlay(View* view); +s32 View_ApplyPerspectiveToOverlay(View* view); +s32 View_UpdateViewingMatrix(View* view); +s32 View_ApplyTo(View* view, Gfx** gfxp); + #endif diff --git a/src/code/speed_meter.c b/src/code/speed_meter.c index 9f04de110c..5ad1cdbe0e 100644 --- a/src/code/speed_meter.c +++ b/src/code/speed_meter.c @@ -1,4 +1,5 @@ #include "global.h" +#include "z64view.h" #include "system_malloc.h" #pragma GLOBAL_ASM("asm/non_matchings/code/speed_meter/func_80177390.s") diff --git a/src/code/z_camera.c b/src/code/z_camera.c index c26947b218..da8a5f35aa 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -1,5 +1,7 @@ #include "global.h" #include "z64quake.h" +#include "z64shrink_window.h" +#include "z64view.h" /** * Returns the absolute value for floats diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 6c83e83915..1fa041be18 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -1,6 +1,7 @@ #include "global.h" #include "z64quake.h" #include "z64rumble.h" +#include "z64shrink_window.h" #include "overlays/gamestates/ovl_daytelop/z_daytelop.h" void Cutscene_DoNothing(PlayState* play, CutsceneContext* csCtx); @@ -107,7 +108,7 @@ s32 func_800EA220(PlayState* play, CutsceneContext* csCtx, f32 target) { void func_800EA258(PlayState* play, CutsceneContext* csCtx) { Interface_SetHudVisibility(HUD_VISIBILITY_NONE); - ShrinkWindow_SetLetterboxTarget(32); + ShrinkWindow_Letterbox_SetSizeTarget(32); if (func_800EA220(play, csCtx, 1.0f)) { Audio_SetCutsceneFlag(true); csCtx->state++; @@ -117,7 +118,7 @@ void func_800EA258(PlayState* play, CutsceneContext* csCtx) { void func_800EA2B8(PlayState* play, CutsceneContext* csCtx) { func_800ED980(play, csCtx); Interface_SetHudVisibility(HUD_VISIBILITY_NONE); - ShrinkWindow_SetLetterboxTarget(32); + ShrinkWindow_Letterbox_SetSizeTarget(32); if (func_800EA220(play, csCtx, 1.0f)) { Audio_SetCutsceneFlag(true); csCtx->state++; @@ -1449,8 +1450,8 @@ void func_800EDA84(PlayState* play, CutsceneContext* csCtx) { if (gSaveContext.cutsceneTrigger == 0) { Interface_SetHudVisibility(HUD_VISIBILITY_NONE); - ShrinkWindow_SetLetterboxTarget(32); - ShrinkWindow_SetLetterboxMagnitude(0x20); + ShrinkWindow_Letterbox_SetSizeTarget(32); + ShrinkWindow_Letterbox_SetSize(32); csCtx->state++; } diff --git a/src/code/z_eventmgr.c b/src/code/z_eventmgr.c index 7128368aca..5b8b8dce37 100644 --- a/src/code/z_eventmgr.c +++ b/src/code/z_eventmgr.c @@ -1,4 +1,5 @@ #include "global.h" +#include "z64shrink_window.h" #pragma GLOBAL_ASM("asm/non_matchings/code/z_eventmgr/func_800F1460.s") diff --git a/src/code/z_game_over.c b/src/code/z_game_over.c index 776dc75d76..857250eecf 100644 --- a/src/code/z_game_over.c +++ b/src/code/z_game_over.c @@ -1,5 +1,6 @@ #include "global.h" #include "z64rumble.h" +#include "z64shrink_window.h" void GameOver_Init(PlayState* play) { play->gameOverCtx.state = GAMEOVER_INACTIVE; @@ -86,7 +87,7 @@ void GameOver_Update(PlayState* play) { gameOverCtx->state++; sGameOverTimer = 0; Kankyo_InitGameOverLights(play); - ShrinkWindow_SetLetterboxTarget(32); + ShrinkWindow_Letterbox_SetSizeTarget(32); break; case GAMEOVER_REVIVE_RUMBLE: sGameOverTimer = 50; diff --git a/src/code/z_kaleido_scope_call.c b/src/code/z_kaleido_scope_call.c index d7905e4dd7..9cea42691e 100644 --- a/src/code/z_kaleido_scope_call.c +++ b/src/code/z_kaleido_scope_call.c @@ -1,5 +1,6 @@ #include "prevent_bss_reordering.h" #include "global.h" +#include "z64shrink_window.h" #include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" void (*sKaleidoScopeUpdateFunc)(PlayState* play); @@ -36,7 +37,7 @@ void KaleidoScopeCall_Update(PlayState* play) { if ((play->pauseCtx.state != 0) || (play->pauseCtx.debugEditor != DEBUG_EDITOR_NONE)) { if (pauseCtx->state == 1 || pauseCtx->state == 19) { - if (ShrinkWindow_GetLetterboxMagnitude() == 0) { + if (ShrinkWindow_Letterbox_GetSize() == 0) { R_PAUSE_MENU_MODE = 1; pauseCtx->unk_200 = 0; pauseCtx->unk_208 = 0; diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c index 1135f2de97..0109dc4ab6 100644 --- a/src/code/z_kaleido_setup.c +++ b/src/code/z_kaleido_setup.c @@ -1,5 +1,7 @@ #include "global.h" #include "z64rumble.h" +#include "z64shrink_window.h" +#include "z64view.h" #include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" s16 D_801BDB00[] = { PAUSE_MAP, PAUSE_QUEST, PAUSE_MASK, PAUSE_ITEM }; @@ -91,8 +93,8 @@ void KaleidoSetup_Update(PlayState* play) { if (pauseCtx->state == 1) { Game_SetFramerateDivisor(&play->state, 2); - if (ShrinkWindow_GetLetterboxTarget() != 0) { - ShrinkWindow_SetLetterboxTarget(0); + if (ShrinkWindow_Letterbox_GetSizeTarget() != 0) { + ShrinkWindow_Letterbox_SetSizeTarget(0); } func_801A3AEC(1); } diff --git a/src/code/z_message.c b/src/code/z_message.c index cb00d8cd2e..94f1e59925 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -1,4 +1,6 @@ #include "global.h" +#include "z64shrink_window.h" +#include "z64view.h" #include "message_data_static.h" #include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" @@ -489,7 +491,7 @@ u8 Message_GetState(MessageContext* msgCtx) { void func_80152C64(View* view) { SET_FULLSCREEN_VIEWPORT(view); - func_8013FBC8(view); + View_ApplyOrthoToOverlay(view); } #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80152CAC.s") diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index 3a2da402c7..4620dd8169 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -1,5 +1,5 @@ #include "global.h" - +#include "z64view.h" #include "interface/parameter_static/parameter_static.h" #include "interface/do_action_static/do_action_static.h" #include "misc/story_static/story_static.h" diff --git a/src/code/z_play.c b/src/code/z_play.c index 06ec9c21e9..47bb97a604 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -1,5 +1,7 @@ #include "global.h" #include "z64quake.h" +#include "z64shrink_window.h" +#include "z64view.h" #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80165460.s") diff --git a/src/code/z_quake.c b/src/code/z_quake.c index 2b66a39f8a..964935ea1f 100644 --- a/src/code/z_quake.c +++ b/src/code/z_quake.c @@ -1,5 +1,6 @@ #include "global.h" #include "z64quake.h" +#include "z64view.h" typedef struct { /* 0x00 */ s16 randIndex; @@ -823,10 +824,10 @@ void Distortion_Update(void) { depthPhase += CAM_DEG_TO_BINANG(depthPhaseStep); screenPlanePhase += CAM_DEG_TO_BINANG(screenPlanePhaseStep); - View_SetDistortionDirRot(&sDistortionRequest.play->view, - Math_CosS(depthPhase) * (DEGF_TO_RADF(rotX) * xyScaleFactor), - Math_SinS(depthPhase) * (DEGF_TO_RADF(rotY) * xyScaleFactor), - Math_SinS(screenPlanePhase) * (DEGF_TO_RADF(rotZ) * zScaleFactor)); + View_SetDistortionOrientation(&sDistortionRequest.play->view, + Math_CosS(depthPhase) * (DEGF_TO_RADF(rotX) * xyScaleFactor), + Math_SinS(depthPhase) * (DEGF_TO_RADF(rotY) * xyScaleFactor), + Math_SinS(screenPlanePhase) * (DEGF_TO_RADF(rotZ) * zScaleFactor)); View_SetDistortionScale(&sDistortionRequest.play->view, (Math_SinS(screenPlanePhase) * (xScale * xyScaleFactor)) + 1.0f, (Math_CosS(screenPlanePhase) * (yScale * xyScaleFactor)) + 1.0f, diff --git a/src/code/z_shrink_window.c b/src/code/z_shrink_window.c index 5bfca86d92..acbdb5c5bc 100644 --- a/src/code/z_shrink_window.c +++ b/src/code/z_shrink_window.c @@ -4,70 +4,78 @@ */ #include "prevent_bss_reordering.h" #include "global.h" +#include "z64shrink_window.h" -ShrinkWindowContext gShrinkWindowContext; -ShrinkWindowContext* gShrinkWindowContextPtr; +typedef struct { + /* 0x0 */ s8 letterboxTarget; + /* 0x1 */ s8 letterboxSize; + /* 0x2 */ s8 pillarboxTarget; + /* 0x3 */ s8 pillarboxSize; +} ShrinkWindow; // size = 0x4 -void ShrinkWindow_SetLetterboxTarget(s32 target) { - gShrinkWindowContextPtr->letterboxTarget = target; +ShrinkWindow sShrinkWindow; +ShrinkWindow* sShrinkWindowPtr; + +void ShrinkWindow_Letterbox_SetSizeTarget(s32 target) { + sShrinkWindowPtr->letterboxTarget = target; } -s32 ShrinkWindow_GetLetterboxTarget(void) { - return gShrinkWindowContextPtr->letterboxTarget; +s32 ShrinkWindow_Letterbox_GetSizeTarget(void) { + return sShrinkWindowPtr->letterboxTarget; } -void ShrinkWindow_SetLetterboxMagnitude(s32 magnitude) { - gShrinkWindowContextPtr->letterboxMagnitude = magnitude; +void ShrinkWindow_Letterbox_SetSize(s32 size) { + sShrinkWindowPtr->letterboxSize = size; } -s32 ShrinkWindow_GetLetterboxMagnitude(void) { - return gShrinkWindowContextPtr->letterboxMagnitude; +s32 ShrinkWindow_Letterbox_GetSize(void) { + return sShrinkWindowPtr->letterboxSize; } -void ShrinkWindow_SetPillarboxTarget(s32 target) { - gShrinkWindowContextPtr->pillarboxTarget = target; +void ShrinkWindow_Pillarbox_SetSizeTarget(s32 target) { + sShrinkWindowPtr->pillarboxTarget = target; } -s32 ShrinkWindow_GetPillarboxTarget(void) { - return gShrinkWindowContextPtr->pillarboxTarget; +s32 ShrinkWindow_Pillarbox_GetSizeTarget(void) { + return sShrinkWindowPtr->pillarboxTarget; } -void ShrinkWindow_SetPillarboxMagnitude(s32 magnitude) { - gShrinkWindowContextPtr->pillarboxMagnitude = magnitude; +void ShrinkWindow_Pillarbox_SetSize(s32 size) { + sShrinkWindowPtr->pillarboxSize = size; } -s32 ShrinkWindow_GetPillarboxMagnitude(void) { - return gShrinkWindowContextPtr->pillarboxMagnitude; +s32 ShrinkWindow_Pillarbox_GetSize(void) { + return sShrinkWindowPtr->pillarboxSize; } void ShrinkWindow_Init(void) { - gShrinkWindowContextPtr = &gShrinkWindowContext; - bzero(gShrinkWindowContextPtr, sizeof(gShrinkWindowContext)); + sShrinkWindowPtr = &sShrinkWindow; + bzero(sShrinkWindowPtr, sizeof(sShrinkWindow)); } void ShrinkWindow_Destroy(void) { - gShrinkWindowContextPtr = NULL; + sShrinkWindowPtr = NULL; } void ShrinkWindow_Update(s32 framerateDivisor) { - s32 step = ((framerateDivisor == 3) ? 10 : 30 / framerateDivisor); - s32 nextMagnitude; + s32 step = (framerateDivisor == 3) ? 10 : (30 / framerateDivisor); + s32 nextSize; - nextMagnitude = gShrinkWindowContextPtr->letterboxMagnitude; - Math_StepToIGet(&nextMagnitude, gShrinkWindowContextPtr->letterboxTarget, step); - gShrinkWindowContextPtr->letterboxMagnitude = nextMagnitude; + nextSize = sShrinkWindowPtr->letterboxSize; + Math_StepToIGet(&nextSize, sShrinkWindowPtr->letterboxTarget, step); + sShrinkWindowPtr->letterboxSize = nextSize; - nextMagnitude = gShrinkWindowContextPtr->pillarboxMagnitude; - Math_StepToIGet(&nextMagnitude, gShrinkWindowContextPtr->pillarboxTarget, step); - gShrinkWindowContextPtr->pillarboxMagnitude = nextMagnitude; + nextSize = sShrinkWindowPtr->pillarboxSize; + Math_StepToIGet(&nextSize, sShrinkWindowPtr->pillarboxTarget, step); + sShrinkWindowPtr->pillarboxSize = nextSize; } void ShrinkWindow_Draw(GraphicsContext* gfxCtx) { Gfx* gfx; - s8 letterboxMagnitude = gShrinkWindowContextPtr->letterboxMagnitude; - s8 pillarboxMagnitude = gShrinkWindowContextPtr->pillarboxMagnitude; + s8 letterboxSize = sShrinkWindowPtr->letterboxSize; + s8 pillarboxSize = sShrinkWindowPtr->pillarboxSize; - if (letterboxMagnitude > 0) { + if (letterboxSize > 0) { OPEN_DISPS(gfxCtx); gfx = OVERLAY_DISP; @@ -76,23 +84,23 @@ void ShrinkWindow_Draw(GraphicsContext* gfxCtx) { gDPSetCycleType(gfx++, G_CYC_FILL); gDPSetRenderMode(gfx++, G_RM_NOOP, G_RM_NOOP2); gDPSetFillColor(gfx++, (GPACK_RGBA5551(0, 0, 0, 1) << 16) | GPACK_RGBA5551(0, 0, 0, 1)); - gDPFillRectangle(gfx++, 0, 0, gScreenWidth - 1, letterboxMagnitude - 1); - gDPFillRectangle(gfx++, 0, gScreenHeight - letterboxMagnitude, gScreenWidth - 1, gScreenHeight - 1); + gDPFillRectangle(gfx++, 0, 0, gScreenWidth - 1, letterboxSize - 1); + gDPFillRectangle(gfx++, 0, gScreenHeight - letterboxSize, gScreenWidth - 1, gScreenHeight - 1); gDPPipeSync(gfx++); gDPSetCycleType(gfx++, G_CYC_1CYCLE); gDPSetRenderMode(gfx++, G_RM_XLU_SURF, G_RM_XLU_SURF2); gDPSetPrimColor(gfx++, 0, 0, 0, 0, 0, 0); - gDPFillRectangle(gfx++, 0, letterboxMagnitude, gScreenWidth, letterboxMagnitude + 1); - gDPFillRectangle(gfx++, 0, gScreenHeight - letterboxMagnitude - 1, gScreenWidth, - gScreenHeight - letterboxMagnitude); + gDPFillRectangle(gfx++, 0, letterboxSize, gScreenWidth, letterboxSize + 1); + gDPFillRectangle(gfx++, 0, gScreenHeight - letterboxSize - 1, gScreenWidth, gScreenHeight - letterboxSize); gDPPipeSync(gfx++); OVERLAY_DISP = gfx++; CLOSE_DISPS(gfxCtx); } - if (pillarboxMagnitude > 0) { + + if (pillarboxSize > 0) { OPEN_DISPS(gfxCtx); gfx = OVERLAY_DISP; @@ -102,17 +110,16 @@ void ShrinkWindow_Draw(GraphicsContext* gfxCtx) { gDPSetRenderMode(gfx++, G_RM_NOOP, G_RM_NOOP2); gDPSetFillColor(gfx++, (GPACK_RGBA5551(0, 0, 0, 1) << 16) | GPACK_RGBA5551(0, 0, 0, 1)); - gDPFillRectangle(gfx++, 0, 0, pillarboxMagnitude - 1, gScreenHeight - 1); - gDPFillRectangle(gfx++, gScreenWidth - pillarboxMagnitude, 0, gScreenWidth - 1, gScreenHeight - 1); + gDPFillRectangle(gfx++, 0, 0, pillarboxSize - 1, gScreenHeight - 1); + gDPFillRectangle(gfx++, gScreenWidth - pillarboxSize, 0, gScreenWidth - 1, gScreenHeight - 1); gDPPipeSync(gfx++); gDPSetCycleType(gfx++, G_CYC_1CYCLE); gDPSetRenderMode(gfx++, G_RM_XLU_SURF, G_RM_XLU_SURF2); gDPSetPrimColor(gfx++, 0, 0, 0, 0, 0, 0); - gDPFillRectangle(gfx++, pillarboxMagnitude, 0, pillarboxMagnitude + 2, gScreenHeight); - gDPFillRectangle(gfx++, gScreenWidth - pillarboxMagnitude - 2, 0, gScreenWidth - pillarboxMagnitude, - gScreenHeight); + gDPFillRectangle(gfx++, pillarboxSize, 0, pillarboxSize + 2, gScreenHeight); + gDPFillRectangle(gfx++, gScreenWidth - pillarboxSize - 2, 0, gScreenWidth - pillarboxSize, gScreenHeight); gDPPipeSync(gfx++); OVERLAY_DISP = gfx++; diff --git a/src/code/z_view.c b/src/code/z_view.c index 915c196b72..105e6643a9 100644 --- a/src/code/z_view.c +++ b/src/code/z_view.c @@ -1,4 +1,9 @@ #include "global.h" +#include "z64shrink_window.h" +#include "z64view.h" + +s32 View_ApplyPerspective(View* view); +s32 View_ApplyOrtho(View* view); void View_ViewportToVp(Vp* dest, Viewport* src) { s32 width = src->rightX - src->leftX; @@ -13,41 +18,45 @@ void View_ViewportToVp(Vp* dest, Viewport* src) { dest->vp.vtrans[2] = 0x01FF; dest->vp.vtrans[3] = 0; - if (src->leftX == 0 && src->rightX == 576 && src->topY == 0 && src->bottomY) {} + if ((src->leftX == 0) && (src->rightX == SCREEN_WIDTH_HIGH_RES) && (src->topY == 0) && + (src->bottomY == SCREEN_HEIGHT_HIGH_RES)) {} } void View_Init(View* view, GraphicsContext* gfxCtx) { view->gfxCtx = gfxCtx; + view->viewport.topY = 0; - view->viewport.bottomY = 240; + view->viewport.bottomY = SCREEN_HEIGHT; view->viewport.leftX = 0; - view->viewport.rightX = 320; + view->viewport.rightX = SCREEN_WIDTH; + view->magic = 0x56494557; // "VIEW" - view->unk164 = 0; - view->flags = 1 | 2 | 4; - - if (1) { - ; - } + if (1) {} view->scale = 1.0f; - view->up.y = 1.0f; view->fovy = 60.0f; - view->eye.x = 0.0f; - view->eye.y = 0.0f; - view->at.x = 0.0f; - view->up.x = 0.0f; - view->up.z = 0.0f; view->zNear = 10.0f; view->zFar = 12800.0f; + + view->eye.x = 0.0f; + view->eye.y = 0.0f; view->eye.z = -1.0f; + view->at.x = 0.0f; + + view->up.x = 0.0f; + view->up.y = 1.0f; + view->up.z = 0.0f; + + view->unk164 = 0; + view->flags = VIEW_VIEWING | VIEW_VIEWPORT | VIEW_PROJECTION_PERSPECTIVE; + View_InitDistortion(view); } -void View_SetViewOrientation(View* view, Vec3f* eye, Vec3f* at, Vec3f* up) { - if (eye->x == at->x && eye->z == at->z) { +void View_LookAt(View* view, Vec3f* eye, Vec3f* at, Vec3f* up) { + if ((eye->x == at->x) && (eye->z == at->z)) { eye->z += 0.1f; up->z = 0.0f; up->x = 0.0f; @@ -57,17 +66,21 @@ void View_SetViewOrientation(View* view, Vec3f* eye, Vec3f* at, Vec3f* up) { view->eye = *eye; view->at = *at; view->up = *up; - view->flags |= 1; + view->flags |= VIEW_VIEWING; } -void func_8013F050(View* view, Vec3f* eye, Vec3f* at, Vec3f* up) { +/* + * Unused. View_LookAt is always used instead. This version is similar but + * is missing the input sanitization and the update to the flags. + */ +void View_LookAtUnsafe(View* view, Vec3f* eye, Vec3f* at, Vec3f* up) { view->eye = *eye; view->at = *at; view->up = *up; } void View_SetScale(View* view, f32 scale) { - view->flags |= 4; + view->flags |= VIEW_PROJECTION_PERSPECTIVE; view->scale = scale; } @@ -75,28 +88,32 @@ void View_GetScale(View* view, f32* scale) { *scale = view->scale; } -void func_8013F0D0(View* view, f32 fovy, f32 zNear, f32 zFar) { +void View_SetPerspective(View* view, f32 fovy, f32 zNear, f32 zFar) { view->fovy = fovy; view->zNear = zNear; view->zFar = zFar; - view->flags |= 4; + view->flags |= VIEW_PROJECTION_PERSPECTIVE; } -void func_8013F100(View* view, f32* fovy, f32* zNear, f32* zFar) { +void View_GetPerspective(View* view, f32* fovy, f32* zNear, f32* zFar) { *fovy = view->fovy; *zNear = view->zNear; *zFar = view->zFar; } -void func_8013F120(View* view, f32 fovy, f32 zNear, f32 zFar) { +void View_SetOrtho(View* view, f32 fovy, f32 zNear, f32 zFar) { view->fovy = fovy; view->zNear = zNear; view->zFar = zFar; - view->flags |= 8; + view->flags |= VIEW_PROJECTION_ORTHO; view->scale = 1.0f; } -void func_8013F15C(View* view, f32* fovy, f32* zNear, f32* zFar) { +/* + * Identical to View_GetPerspective, and never called. + * Named as it seems to fit the "set, get" pattern. + */ +void View_GetOrtho(View* view, f32* fovy, f32* zNear, f32* zFar) { *fovy = view->fovy; *zNear = view->zNear; *zFar = view->zFar; @@ -104,14 +121,14 @@ void func_8013F15C(View* view, f32* fovy, f32* zNear, f32* zFar) { void View_SetViewport(View* view, Viewport* viewport) { view->viewport = *viewport; - view->flags |= 2; + view->flags |= VIEW_VIEWPORT; } void View_GetViewport(View* view, Viewport* viewport) { *viewport = view->viewport; } -void View_WriteScissor(Gfx** gfx, s32 ulx, s32 uly, s32 lrx, s32 lry) { +void View_SetScissor(Gfx** gfx, s32 ulx, s32 uly, s32 lrx, s32 lry) { Gfx* gfxp = *gfx; gDPSetScissor(gfxp++, G_SC_NON_INTERLACE, ulx, uly, lrx, lry); @@ -119,7 +136,7 @@ void View_WriteScissor(Gfx** gfx, s32 ulx, s32 uly, s32 lrx, s32 lry) { *gfx = gfxp; } -void View_SyncAndWriteScissor(View* view, Gfx** gfx) { +void View_ClearScissor(View* view, Gfx** gfx) { Gfx* gfxp = *gfx; s32 ulx = view->viewport.leftX; s32 uly = view->viewport.topY; @@ -127,12 +144,12 @@ void View_SyncAndWriteScissor(View* view, Gfx** gfx) { s32 lry = view->viewport.bottomY; gDPPipeSync(gfxp++); - View_WriteScissor(&gfxp, ulx, uly, lrx, lry); + View_SetScissor(&gfxp, ulx, uly, lrx, lry); *gfx = gfxp; } -void View_SetScissorForLetterbox(View* view) { +void View_ApplyLetterbox(View* view) { s32 letterboxY; s32 letterboxX; s32 pad1; @@ -143,20 +160,21 @@ void View_SetScissorForLetterbox(View* view) { OPEN_DISPS(view->gfxCtx); - letterboxY = ShrinkWindow_GetLetterboxMagnitude(); + letterboxY = ShrinkWindow_Letterbox_GetSize(); + letterboxX = -1; // The following is optimized to varX = 0 but affects codegen if (letterboxX < 0) { letterboxX = 0; } - if (letterboxX > 160) { - letterboxX = 160; + if (letterboxX > (SCREEN_WIDTH / 2)) { + letterboxX = SCREEN_WIDTH / 2; } if (letterboxY < 0) { letterboxY = 0; - } else if (letterboxY > 120) { - letterboxY = 120; + } else if (letterboxY > (SCREEN_HEIGHT / 2)) { + letterboxY = SCREEN_HEIGHT / 2; } ulx = view->viewport.leftX + letterboxX; @@ -166,31 +184,31 @@ void View_SetScissorForLetterbox(View* view) { gDPPipeSync(POLY_OPA_DISP++); { - s32 pad3; + s32 pad2; Gfx* polyOpa; polyOpa = POLY_OPA_DISP; - View_WriteScissor(&polyOpa, ulx, uly, lrx, lry); + View_SetScissor(&polyOpa, ulx, uly, lrx, lry); POLY_OPA_DISP = polyOpa; } gDPPipeSync(POLY_XLU_DISP++); { Gfx* polyXlu; - s32 pad4; + s32 pad3; polyXlu = POLY_XLU_DISP; - View_WriteScissor(&polyXlu, ulx, uly, lrx, lry); + View_SetScissor(&polyXlu, ulx, uly, lrx, lry); POLY_XLU_DISP = polyXlu; } CLOSE_DISPS(view->gfxCtx); } -s32 View_SetDistortionDirRot(View* view, f32 dirRotX, f32 dirRotY, f32 dirRotZ) { - view->distortionDirRot.x = dirRotX; - view->distortionDirRot.y = dirRotY; - view->distortionDirRot.z = dirRotZ; +s32 View_SetDistortionOrientation(View* view, f32 rotX, f32 rotY, f32 rotZ) { + view->distortionOrientation.x = rotX; + view->distortionOrientation.y = rotY; + view->distortionOrientation.z = rotZ; return 1; } @@ -207,22 +225,22 @@ s32 View_SetDistortionSpeed(View* view, f32 speed) { } s32 View_InitDistortion(View* view) { - view->distortionDirRot.x = 0.0f; - view->distortionDirRot.y = 0.0f; - view->distortionDirRot.z = 0.0f; + view->distortionOrientation.x = 0.0f; + view->distortionOrientation.y = 0.0f; + view->distortionOrientation.z = 0.0f; view->distortionScale.x = 1.0f; view->distortionScale.y = 1.0f; view->distortionScale.z = 1.0f; - view->curDistortionDirRot = view->distortionDirRot; + view->curDistortionOrientation = view->distortionOrientation; view->curDistortionScale = view->distortionScale; view->distortionSpeed = 0.0f; return 1; } s32 View_ClearDistortion(View* view) { - view->distortionDirRot.x = 0.0f; - view->distortionDirRot.y = 0.0f; - view->distortionDirRot.z = 0.0f; + view->distortionOrientation.x = 0.0f; + view->distortionOrientation.y = 0.0f; + view->distortionOrientation.z = 0.0f; view->distortionScale.x = 1.0f; view->distortionScale.y = 1.0f; view->distortionScale.z = 1.0f; @@ -230,8 +248,8 @@ s32 View_ClearDistortion(View* view) { return 1; } -s32 View_SetDistortion(View* view, Vec3f dirRot, Vec3f scale, f32 speed) { - view->distortionDirRot = dirRot; +s32 View_SetDistortion(View* view, Vec3f orientation, Vec3f scale, f32 speed) { + view->distortionOrientation = orientation; view->distortionScale = scale; view->distortionSpeed = speed; return 1; @@ -242,17 +260,19 @@ s32 View_StepDistortion(View* view, Mtx* projectionMtx) { if (view->distortionSpeed == 0.0f) { return false; - } else if (view->distortionSpeed == 1.0f) { - view->curDistortionDirRot = view->distortionDirRot; + } + + if (view->distortionSpeed == 1.0f) { + view->curDistortionOrientation = view->distortionOrientation; view->curDistortionScale = view->distortionScale; view->distortionSpeed = 0.0f; } else { - view->curDistortionDirRot.x = - F32_LERPIMP(view->curDistortionDirRot.x, view->distortionDirRot.x, view->distortionSpeed); - view->curDistortionDirRot.y = - F32_LERPIMP(view->curDistortionDirRot.y, view->distortionDirRot.y, view->distortionSpeed); - view->curDistortionDirRot.z = - F32_LERPIMP(view->curDistortionDirRot.z, view->distortionDirRot.z, view->distortionSpeed); + view->curDistortionOrientation.x = + F32_LERPIMP(view->curDistortionOrientation.x, view->distortionOrientation.x, view->distortionSpeed); + view->curDistortionOrientation.y = + F32_LERPIMP(view->curDistortionOrientation.y, view->distortionOrientation.y, view->distortionSpeed); + view->curDistortionOrientation.z = + F32_LERPIMP(view->curDistortionOrientation.z, view->distortionOrientation.z, view->distortionSpeed); view->curDistortionScale.x = F32_LERPIMP(view->curDistortionScale.x, view->distortionScale.x, view->distortionSpeed); @@ -264,29 +284,32 @@ s32 View_StepDistortion(View* view, Mtx* projectionMtx) { Matrix_MtxToMtxF(projectionMtx, &projectionMtxF); Matrix_Put(&projectionMtxF); - Matrix_RotateXFApply(view->curDistortionDirRot.x); - Matrix_RotateYF(view->curDistortionDirRot.y, MTXMODE_APPLY); - Matrix_RotateZF(view->curDistortionDirRot.z, MTXMODE_APPLY); + Matrix_RotateXFApply(view->curDistortionOrientation.x); + Matrix_RotateYF(view->curDistortionOrientation.y, MTXMODE_APPLY); + Matrix_RotateZF(view->curDistortionOrientation.z, MTXMODE_APPLY); Matrix_Scale(view->curDistortionScale.x, view->curDistortionScale.y, view->curDistortionScale.z, MTXMODE_APPLY); - Matrix_RotateZF(-view->curDistortionDirRot.z, MTXMODE_APPLY); - Matrix_RotateYF(-view->curDistortionDirRot.y, MTXMODE_APPLY); - Matrix_RotateXFApply(-view->curDistortionDirRot.x); + Matrix_RotateZF(-view->curDistortionOrientation.z, MTXMODE_APPLY); + Matrix_RotateYF(-view->curDistortionOrientation.y, MTXMODE_APPLY); + Matrix_RotateXFApply(-view->curDistortionOrientation.x); Matrix_ToMtx(projectionMtx); return true; } -void View_RenderView(View* view, s32 uParm2) { - uParm2 = (view->flags & uParm2) | uParm2 >> 4; +/** + * Apply view to POLY_OPA_DISP, POLY_XLU_DISP (and OVERLAY_DISP if ortho) + */ +void View_Apply(View* view, s32 mask) { + mask = (view->flags & mask) | (mask >> 4); - if (uParm2 & 8) { - View_RenderToOrthographicMatrix(view); + if (mask & VIEW_PROJECTION_ORTHO) { + View_ApplyOrtho(view); } else { - View_RenderToPerspectiveMatrix(view); + View_ApplyPerspective(view); } } -s32 View_RenderToPerspectiveMatrix(View* view) { +s32 View_ApplyPerspective(View* view) { f32 aspect; s32 width; s32 height; @@ -297,36 +320,39 @@ s32 View_RenderToPerspectiveMatrix(View* view) { OPEN_DISPS(gfxCtx); - vp = GRAPH_ALLOC(gfxCtx, sizeof(*vp)); + // Viewport + vp = GRAPH_ALLOC(gfxCtx, sizeof(Vp)); View_ViewportToVp(vp, &view->viewport); view->vp = *vp; - View_SetScissorForLetterbox(view); + View_ApplyLetterbox(view); gSPViewport(POLY_OPA_DISP++, vp); gSPViewport(POLY_XLU_DISP++, vp); - projection = GRAPH_ALLOC(gfxCtx, sizeof(*projection)); + // Perspective projection + projection = GRAPH_ALLOC(gfxCtx, sizeof(Mtx)); view->projectionPtr = projection; width = view->viewport.rightX - view->viewport.leftX; height = view->viewport.bottomY - view->viewport.topY; aspect = (f32)width / (f32)height; - guPerspective(projection, &view->normal, view->fovy, aspect, view->zNear, view->zFar, view->scale); + guPerspective(projection, &view->perspNorm, view->fovy, aspect, view->zNear, view->zFar, view->scale); view->projection = *projection; View_StepDistortion(view, projection); - gSPPerspNormalize(POLY_OPA_DISP++, view->normal); + gSPPerspNormalize(POLY_OPA_DISP++, view->perspNorm); gSPMatrix(POLY_OPA_DISP++, projection, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); - gSPPerspNormalize(POLY_XLU_DISP++, view->normal); + gSPPerspNormalize(POLY_XLU_DISP++, view->perspNorm); gSPMatrix(POLY_XLU_DISP++, projection, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); - viewing = GRAPH_ALLOC(gfxCtx, sizeof(*viewing)); + // View matrix (look-at) + viewing = GRAPH_ALLOC(gfxCtx, sizeof(Mtx)); view->viewingPtr = viewing; - if (view->eye.x == view->at.x && view->eye.y == view->at.y && view->eye.z == view->at.z) { + if ((view->eye.x == view->at.x) && (view->eye.y == view->at.y) && (view->eye.z == view->at.z)) { view->eye.z += 2.0f; } @@ -343,24 +369,24 @@ s32 View_RenderToPerspectiveMatrix(View* view) { return 1; } -s32 View_RenderToOrthographicMatrix(View* view) { +s32 View_ApplyOrtho(View* view) { Vp* vp; Mtx* projection; GraphicsContext* gfxCtx = view->gfxCtx; OPEN_DISPS(gfxCtx); - vp = GRAPH_ALLOC(gfxCtx, sizeof(*vp)); + vp = GRAPH_ALLOC(gfxCtx, sizeof(Vp)); View_ViewportToVp(vp, &view->viewport); view->vp = *vp; - View_SetScissorForLetterbox(view); + View_ApplyLetterbox(view); gSPViewport(POLY_OPA_DISP++, vp); gSPViewport(POLY_XLU_DISP++, vp); gSPViewport(OVERLAY_DISP++, vp); - projection = GRAPH_ALLOC(gfxCtx, sizeof(*projection)); + projection = GRAPH_ALLOC(gfxCtx, sizeof(Mtx)); view->projectionPtr = projection; guOrtho(projection, gScreenWidth * -0.5f, gScreenWidth * 0.5f, gScreenHeight * -0.5f, gScreenHeight * 0.5f, @@ -376,7 +402,10 @@ s32 View_RenderToOrthographicMatrix(View* view) { return 1; } -s32 func_8013FBC8(View* view) { +/** + * Apply scissor, viewport and projection (ortho) to OVERLAY_DISP. + */ +s32 View_ApplyOrthoToOverlay(View* view) { Vp* vp; Mtx* projection; GraphicsContext* gfxCtx; @@ -385,7 +414,7 @@ s32 func_8013FBC8(View* view) { OPEN_DISPS(gfxCtx); - vp = GRAPH_ALLOC(gfxCtx, sizeof(*vp)); + vp = GRAPH_ALLOC(gfxCtx, sizeof(Vp)); View_ViewportToVp(vp, &view->viewport); view->vp = *vp; @@ -395,26 +424,29 @@ s32 func_8013FBC8(View* view) { s32 pad; overlay = OVERLAY_DISP; - View_WriteScissor(&overlay, view->viewport.leftX, view->viewport.topY, view->viewport.rightX, - view->viewport.bottomY); + View_SetScissor(&overlay, view->viewport.leftX, view->viewport.topY, view->viewport.rightX, + view->viewport.bottomY); OVERLAY_DISP = overlay; } gSPViewport(OVERLAY_DISP++, vp); - projection = GRAPH_ALLOC(gfxCtx, sizeof(*projection)); + projection = GRAPH_ALLOC(gfxCtx, sizeof(Mtx)); view->projectionPtr = projection; guOrtho(projection, gScreenWidth * -0.5f, gScreenWidth * 0.5f, gScreenHeight * -0.5f, gScreenHeight * 0.5f, view->zNear, view->zFar, view->scale); view->projection = *projection; - gSPMatrix(OVERLAY_DISP++, projection, G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(OVERLAY_DISP++, projection, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); CLOSE_DISPS(gfxCtx); return 1; } -s32 func_8013FD74(View* view) { +/** + * Apply scissor, viewport, view and projection (perspective) to OVERLAY_DISP. + */ +s32 View_ApplyPerspectiveToOverlay(View* view) { f32 aspect; s32 width; s32 height; @@ -428,7 +460,7 @@ s32 func_8013FD74(View* view) { OPEN_DISPS(gfxCtx); - vp = GRAPH_ALLOC(gfxCtx, sizeof(*vp)); + vp = GRAPH_ALLOC(gfxCtx, sizeof(Vp)); View_ViewportToVp(vp, &view->viewport); view->vp = *vp; @@ -438,28 +470,30 @@ s32 func_8013FD74(View* view) { Gfx* overlay; overlay = OVERLAY_DISP; - View_WriteScissor(&overlay, view->viewport.leftX, view->viewport.topY, view->viewport.rightX, - view->viewport.bottomY); + View_SetScissor(&overlay, view->viewport.leftX, view->viewport.topY, view->viewport.rightX, + view->viewport.bottomY); OVERLAY_DISP = overlay; } gSPViewport(OVERLAY_DISP++, vp); - projection = GRAPH_ALLOC(gfxCtx, sizeof(*projection)); + projection = GRAPH_ALLOC(gfxCtx, sizeof(Mtx)); view->projectionPtr = projection; width = view->viewport.rightX - view->viewport.leftX; height = view->viewport.bottomY - view->viewport.topY; aspect = (f32)width / (f32)height; - guPerspective(projection, &view->normal, view->fovy, aspect, view->zNear, view->zFar, view->scale); + guPerspective(projection, &view->perspNorm, view->fovy, aspect, view->zNear, view->zFar, view->scale); + view->projection = *projection; - gSPPerspNormalize(OVERLAY_DISP++, view->normal); + gSPPerspNormalize(OVERLAY_DISP++, view->perspNorm); gSPMatrix(OVERLAY_DISP++, projection, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); - viewing = GRAPH_ALLOC(gfxCtx, sizeof(*viewing)); + viewing = GRAPH_ALLOC(gfxCtx, sizeof(Mtx)); view->viewingPtr = viewing; + // This check avoids a divide-by-zero in guLookAt if eye == at if (view->eye.x == view->at.x && view->eye.y == view->at.y && view->eye.z == view->at.z) { view->eye.z += 2.0f; } @@ -476,7 +510,10 @@ s32 func_8013FD74(View* view) { return 1; } -s32 func_80140024(View* view) { +/** + * Just updates view's view matrix from its eye/at/up vectors. + */ +s32 View_UpdateViewingMatrix(View* view) { guLookAt(view->viewingPtr, view->eye.x, view->eye.y, view->eye.z, view->at.x, view->at.y, view->at.z, view->up.x, view->up.y, view->up.z); @@ -486,22 +523,22 @@ s32 func_80140024(View* view) { return 1; } -s32 func_801400CC(View* view, Gfx** gfxp) { +s32 View_ApplyTo(View* view, Gfx** gfxp) { Gfx* gfx = *gfxp; GraphicsContext* gfxCtx = view->gfxCtx; Viewport* viewport = &view->viewport; Mtx* projection; Vp* vp; - vp = GRAPH_ALLOC(gfxCtx, sizeof(*vp)); + vp = GRAPH_ALLOC(gfxCtx, sizeof(Vp)); View_ViewportToVp(vp, viewport); view->vp = *vp; - View_SyncAndWriteScissor(view, &gfx); + View_ClearScissor(view, &gfx); gSPViewport(gfx++, vp); - projection = GRAPH_ALLOC(gfxCtx, sizeof(*projection)); + projection = GRAPH_ALLOC(gfxCtx, sizeof(Mtx)); view->projectionPtr = projection; guOrtho(projection, gScreenWidth * -0.5f, gScreenWidth * 0.5f, gScreenHeight * -0.5f, gScreenHeight * 0.5f, @@ -509,7 +546,7 @@ s32 func_801400CC(View* view, Gfx** gfxp) { view->projection = *projection; - gSPMatrix(gfx++, projection, G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(gfx++, projection, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); *gfxp = gfx; return 1; diff --git a/src/overlays/actors/ovl_Boss_01/z_boss_01.c b/src/overlays/actors/ovl_Boss_01/z_boss_01.c index 11790f3776..40800569fc 100644 --- a/src/overlays/actors/ovl_Boss_01/z_boss_01.c +++ b/src/overlays/actors/ovl_Boss_01/z_boss_01.c @@ -6,6 +6,7 @@ #include "z_boss_01.h" #include "z64rumble.h" +#include "z64shrink_window.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) 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 9808e68a40..b3ab79b201 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -6,6 +6,7 @@ #include "z_boss_02.h" #include "z64rumble.h" +#include "z64shrink_window.h" #include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" #include "overlays/actors/ovl_Item_B_Heart/z_item_b_heart.h" #include "objects/gameplay_keep/gameplay_keep.h" @@ -2033,7 +2034,7 @@ void func_809DD934(Boss02* this, PlayState* play) { Matrix_RotateZF(this->unk_1D54, MTXMODE_APPLY); Matrix_MultVecY(1.0f, &this->subCamUp); Play_SetCameraAtEyeUp(play, this->subCamId, &this->subCamAt, &this->subCamEye, &this->subCamUp); - ShrinkWindow_SetLetterboxTarget(27); + ShrinkWindow_Letterbox_SetSizeTarget(27); } } @@ -2241,6 +2242,6 @@ void func_809DEAC4(Boss02* this, PlayState* play) { Play_SetCameraAtEyeUp(play, this->subCamId, &this->subCamAt, &subCamEye, &this->subCamUp); this->subCamUp.z = this->subCamUp.x = 0.0f; this->subCamUp.y = 1.0f; - ShrinkWindow_SetLetterboxTarget(27); + ShrinkWindow_Letterbox_SetSizeTarget(27); } } diff --git a/src/overlays/actors/ovl_Boss_04/z_boss_04.c b/src/overlays/actors/ovl_Boss_04/z_boss_04.c index f26bc505f5..8eb73d84d2 100644 --- a/src/overlays/actors/ovl_Boss_04/z_boss_04.c +++ b/src/overlays/actors/ovl_Boss_04/z_boss_04.c @@ -5,6 +5,7 @@ */ #include "z_boss_04.h" +#include "z64shrink_window.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -399,7 +400,7 @@ void func_809EC568(Boss04* this, PlayState* play) { if (this->subCamId != SUB_CAM_ID_DONE) { Vec3f subCamAt; - ShrinkWindow_SetLetterboxTarget(27); + ShrinkWindow_Letterbox_SetSizeTarget(27); if (this->subCamAtOscillator != 0) { this->subCamAtOscillator--; } diff --git a/src/overlays/actors/ovl_Boss_06/z_boss_06.c b/src/overlays/actors/ovl_Boss_06/z_boss_06.c index 045a769953..3aadce42cb 100644 --- a/src/overlays/actors/ovl_Boss_06/z_boss_06.c +++ b/src/overlays/actors/ovl_Boss_06/z_boss_06.c @@ -6,6 +6,7 @@ #include "prevent_bss_reordering.h" #include "z_boss_06.h" +#include "z64shrink_window.h" #include "overlays/actors/ovl_En_Knight/z_en_knight.h" #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_knight/object_knight.h" @@ -339,7 +340,7 @@ void func_809F24C8(Boss06* this, PlayState* play) { } if (this->subCamId != SUB_CAM_ID_DONE) { - ShrinkWindow_SetLetterboxTarget(27); + ShrinkWindow_Letterbox_SetSizeTarget(27); Play_SetCameraAtEye(play, this->subCamId, &this->subCamAt, &this->subCamEye); } } diff --git a/src/overlays/actors/ovl_Boss_07/z_boss_07.c b/src/overlays/actors/ovl_Boss_07/z_boss_07.c index 9b988da18a..923c838fc9 100644 --- a/src/overlays/actors/ovl_Boss_07/z_boss_07.c +++ b/src/overlays/actors/ovl_Boss_07/z_boss_07.c @@ -5,6 +5,7 @@ */ #include "z_boss_07.h" +#include "z64shrink_window.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) 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 5a3ce9cf87..4ad558a0a0 100644 --- a/src/overlays/actors/ovl_En_Bsb/z_en_bsb.c +++ b/src/overlays/actors/ovl_En_Bsb/z_en_bsb.c @@ -6,6 +6,7 @@ #include "z_en_bsb.h" #include "z64rumble.h" +#include "z64shrink_window.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_2000000) diff --git a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c index 8bd1b7e0ec..baa65bfa3e 100644 --- a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c +++ b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c @@ -6,6 +6,7 @@ #include "z_en_fishing.h" #include "z64rumble.h" +#include "z64shrink_window.h" #include "objects/object_fish/object_fish.h" #include "overlays/actors/ovl_En_Kanban/z_en_kanban.h" @@ -5170,7 +5171,7 @@ void EnFishing_UpdateOwner(Actor* thisx, PlayState* play2) { sSubCamVelFactor = 0.0f; // fallthrough case 2: - ShrinkWindow_SetLetterboxTarget(27); + ShrinkWindow_Letterbox_SetSizeTarget(27); spFC.x = sLurePos.x - player->actor.world.pos.x; spFC.z = sLurePos.z - player->actor.world.pos.z; diff --git a/src/overlays/actors/ovl_En_Knight/z_en_knight.c b/src/overlays/actors/ovl_En_Knight/z_en_knight.c index 095ca5a98a..17d0e37526 100644 --- a/src/overlays/actors/ovl_En_Knight/z_en_knight.c +++ b/src/overlays/actors/ovl_En_Knight/z_en_knight.c @@ -5,6 +5,7 @@ */ #include "z_en_knight.h" +#include "z64shrink_window.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index 681438463a..1f92e8825e 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -7,6 +7,7 @@ #include "global.h" #include "z64quake.h" #include "z64rumble.h" +#include "z64shrink_window.h" #define THIS ((Player*)thisx) diff --git a/src/overlays/gamestates/ovl_daytelop/z_daytelop.c b/src/overlays/gamestates/ovl_daytelop/z_daytelop.c index ad5230253a..2010308627 100644 --- a/src/overlays/gamestates/ovl_daytelop/z_daytelop.c +++ b/src/overlays/gamestates/ovl_daytelop/z_daytelop.c @@ -5,6 +5,8 @@ */ #include "z_daytelop.h" +#include "z64shrink_window.h" +#include "z64view.h" #include "misc/daytelop_static/daytelop_static.h" #include "interface/icon_item_gameover_static/icon_item_gameover_static.h" diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c b/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c index 657a2530f0..da9144e7c6 100644 --- a/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c +++ b/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c @@ -6,6 +6,8 @@ #include "z_file_choose.h" #include "z64rumble.h" +#include "z64shrink_window.h" +#include "z64view.h" extern UNK_TYPE D_01002800; extern UNK_TYPE D_01007980; diff --git a/src/overlays/gamestates/ovl_opening/z_opening.c b/src/overlays/gamestates/ovl_opening/z_opening.c index 42336b9bca..fc5d05be24 100644 --- a/src/overlays/gamestates/ovl_opening/z_opening.c +++ b/src/overlays/gamestates/ovl_opening/z_opening.c @@ -5,6 +5,8 @@ */ #include "z_opening.h" +#include "z64shrink_window.h" +#include "z64view.h" void TitleSetup_SetupTitleScreen(TitleSetupState* this) { static s32 sOpeningEntrances[] = { ENTRANCE(CUTSCENE, 0), ENTRANCE(CUTSCENE, 1) }; diff --git a/src/overlays/gamestates/ovl_select/z_select.c b/src/overlays/gamestates/ovl_select/z_select.c index 6ae0f5b6c3..2e8bbb802b 100644 --- a/src/overlays/gamestates/ovl_select/z_select.c +++ b/src/overlays/gamestates/ovl_select/z_select.c @@ -5,6 +5,8 @@ */ #include "z_select.h" +#include "z64shrink_window.h" +#include "z64view.h" #include "libc/alloca.h" #include "overlays/gamestates/ovl_title/z_title.h" @@ -1026,7 +1028,7 @@ void MapSelect_Draw(MapSelectState* this) { func_8012CF0C(gfxCtx, true, true, 0, 0, 0); SET_FULLSCREEN_VIEWPORT(&this->view); - View_RenderView(&this->view, 0xF); + View_Apply(&this->view, VIEW_ALL); if (!this->state.running) { MapSelect_DrawLoadingScreen(this); } else { diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.c index 62d2a36d06..2b23bf565e 100644 --- a/src/overlays/gamestates/ovl_title/z_title.c +++ b/src/overlays/gamestates/ovl_title/z_title.c @@ -5,6 +5,8 @@ */ #include "z_title.h" +#include "z64shrink_window.h" +#include "z64view.h" #include "overlays/gamestates/ovl_opening/z_opening.h" #include "misc/nintendo_rogo_static/nintendo_rogo_static.h" @@ -44,9 +46,9 @@ void ConsoleLogo_RenderView(ConsoleLogoState* this, f32 x, f32 y, f32 z) { up.x = up.z = 0.0f; at.x = at.y = at.z = 0.0f; up.y = 1.0f; - func_8013F0D0(view, 30.0f, 10.0f, 12800.0f); - View_SetViewOrientation(view, &eye, &at, &up); - View_RenderView(view, 0xF); + View_SetPerspective(view, 30.0f, 10.0f, 12800.0f); + View_LookAt(view, &eye, &at, &up); + View_Apply(view, VIEW_ALL); } void ConsoleLogo_Draw(GameState* thisx) { diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c index c02ebcad28..3b3de5937a 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c @@ -5,6 +5,7 @@ */ #include "z_kaleido_scope.h" +#include "z64view.h" extern UNK_TYPE D_02001360; extern UNK_TYPE D_020044A0; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 594ce3427b..8a146996da 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2721,33 +2721,33 @@ 0x8013EE48:("Rumble_SetUpdateEnabled",), 0x8013EE60:("View_ViewportToVp",), 0x8013EEF4:("View_Init",), - 0x8013EF9C:("View_SetViewOrientation",), - 0x8013F050:("func_8013F050",), + 0x8013EF9C:("View_LookAt",), + 0x8013F050:("View_LookAtUnsafe",), 0x8013F0A0:("View_SetScale",), 0x8013F0C0:("View_GetScale",), - 0x8013F0D0:("func_8013F0D0",), - 0x8013F100:("func_8013F100",), - 0x8013F120:("func_8013F120",), - 0x8013F15C:("func_8013F15C",), + 0x8013F0D0:("View_SetPerspective",), + 0x8013F100:("View_GetPerspective",), + 0x8013F120:("View_SetOrtho",), + 0x8013F15C:("View_GetOrtho",), 0x8013F17C:("View_SetViewport",), 0x8013F1B0:("View_GetViewport",), - 0x8013F1D8:("View_WriteScissor",), - 0x8013F28C:("View_SyncAndWriteScissor",), - 0x8013F2F8:("View_SetScissorForLetterbox",), - 0x8013F3F8:("View_SetDistortionDirRot",), + 0x8013F1D8:("View_SetScissor",), + 0x8013F28C:("View_ClearScissor",), + 0x8013F2F8:("View_ApplyLetterbox",), + 0x8013F3F8:("View_SetDistortionOrientation",), 0x8013F420:("View_SetDistortionScale",), 0x8013F448:("View_SetDistortionSpeed",), 0x8013F45C:("View_InitDistortion",), 0x8013F4C0:("View_ClearDistortion",), 0x8013F4F4:("View_SetDistortion",), 0x8013F54C:("View_StepDistortion",), - 0x8013F6FC:("View_RenderView",), - 0x8013F748:("View_RenderToPerspectiveMatrix",), - 0x8013FA1C:("View_RenderToOrthographicMatrix",), - 0x8013FBC8:("func_8013FBC8",), - 0x8013FD74:("func_8013FD74",), - 0x80140024:("func_80140024",), - 0x801400CC:("func_801400CC",), + 0x8013F6FC:("View_Apply",), + 0x8013F748:("View_ApplyPerspective",), + 0x8013FA1C:("View_ApplyOrtho",), + 0x8013FBC8:("View_ApplyOrthoToOverlay",), + 0x8013FD74:("View_ApplyPerspectiveToOverlay",), + 0x80140024:("View_UpdateViewingMatrix",), + 0x801400CC:("View_ApplyTo",), 0x80140260:("func_80140260",), 0x8014026C:("func_8014026C",), 0x80140730:("func_80140730",), @@ -2892,14 +2892,14 @@ 0x80160B40:("PlayerCall_Destroy",), 0x80160B80:("PlayerCall_Update",), 0x80160BC0:("PlayerCall_Draw",), - 0x80160C00:("ShrinkWindow_SetLetterboxTarget",), - 0x80160C14:("ShrinkWindow_GetLetterboxTarget",), - 0x80160C28:("ShrinkWindow_SetLetterboxMagnitude",), - 0x80160C3C:("ShrinkWindow_GetLetterboxMagnitude",), - 0x80160C50:("ShrinkWindow_SetPillarboxTarget",), - 0x80160C64:("ShrinkWindow_GetPillarboxTarget",), - 0x80160C78:("ShrinkWindow_SetPillarboxMagnitude",), - 0x80160C8C:("ShrinkWindow_GetPillarboxMagnitude",), + 0x80160C00:("ShrinkWindow_Letterbox_SetSizeTarget",), + 0x80160C14:("ShrinkWindow_Letterbox_GetSizeTarget",), + 0x80160C28:("ShrinkWindow_Letterbox_SetSize",), + 0x80160C3C:("ShrinkWindow_Letterbox_GetSize",), + 0x80160C50:("ShrinkWindow_Pillarbox_SetSizeTarget",), + 0x80160C64:("ShrinkWindow_Pillarbox_GetSizeTarget",), + 0x80160C78:("ShrinkWindow_Pillarbox_SetSize",), + 0x80160C8C:("ShrinkWindow_Pillarbox_GetSize",), 0x80160CA0:("ShrinkWindow_Init",), 0x80160CD4:("ShrinkWindow_Destroy",), 0x80160CE4:("ShrinkWindow_Update",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 97cf77e76c..a0b3692644 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -4046,8 +4046,8 @@ 0x801F6B34:("sPlayerCallDestroyFunc","UNK_TYPE1","",0x1), 0x801F6B38:("sPlayerCallUpdateFunc","UNK_TYPE1","",0x1), 0x801F6B3C:("sPlayerCallDrawFunc","UNK_TYPE1","",0x1), - 0x801F6B40:("gShrinkWindowContext","ShrinkWindowContext","",0x4), - 0x801F6B44:("gShrinkWindowContextPtr","ShrinkWindowContext*","",0x4), + 0x801F6B40:("sShrinkWindow","ShrinkWindow","",0x4), + 0x801F6B44:("sShrinkWindowPtr","ShrinkWindow*","",0x4), 0x801F6B50:("D_801F6B50","UNK_TYPE4","",0x4), 0x801F6B58:("D_801F6B58","UNK_TYPE1","",0x1), 0x801F6BF0:("sKaleidoAreaFaultClient","FaultAddrConvClient","",0xC), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 33b82cef00..f64c45241e 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -2235,33 +2235,33 @@ asm/non_matchings/code/code_8013EC10/Rumble_StateWipeRequests.s,Rumble_StateWipe asm/non_matchings/code/code_8013EC10/Rumble_SetUpdateEnabled.s,Rumble_SetUpdateEnabled,0x8013EE48,0x6 asm/non_matchings/code/z_view/View_ViewportToVp.s,View_ViewportToVp,0x8013EE60,0x25 asm/non_matchings/code/z_view/View_Init.s,View_Init,0x8013EEF4,0x2A -asm/non_matchings/code/z_view/View_SetViewOrientation.s,View_SetViewOrientation,0x8013EF9C,0x2D -asm/non_matchings/code/z_view/func_8013F050.s,func_8013F050,0x8013F050,0x14 +asm/non_matchings/code/z_view/View_LookAt.s,View_LookAt,0x8013EF9C,0x2D +asm/non_matchings/code/z_view/View_LookAtUnsafe.s,View_LookAtUnsafe,0x8013F050,0x14 asm/non_matchings/code/z_view/View_SetScale.s,View_SetScale,0x8013F0A0,0x8 asm/non_matchings/code/z_view/View_GetScale.s,View_GetScale,0x8013F0C0,0x4 -asm/non_matchings/code/z_view/func_8013F0D0.s,func_8013F0D0,0x8013F0D0,0xC -asm/non_matchings/code/z_view/func_8013F100.s,func_8013F100,0x8013F100,0x8 -asm/non_matchings/code/z_view/func_8013F120.s,func_8013F120,0x8013F120,0xF -asm/non_matchings/code/z_view/func_8013F15C.s,func_8013F15C,0x8013F15C,0x8 +asm/non_matchings/code/z_view/View_SetPerspective.s,View_SetPerspective,0x8013F0D0,0xC +asm/non_matchings/code/z_view/View_GetPerspective.s,View_GetPerspective,0x8013F100,0x8 +asm/non_matchings/code/z_view/View_SetOrtho.s,View_SetOrtho,0x8013F120,0xF +asm/non_matchings/code/z_view/View_GetOrtho.s,View_GetOrtho,0x8013F15C,0x8 asm/non_matchings/code/z_view/View_SetViewport.s,View_SetViewport,0x8013F17C,0xD asm/non_matchings/code/z_view/View_GetViewport.s,View_GetViewport,0x8013F1B0,0xA -asm/non_matchings/code/z_view/View_WriteScissor.s,View_WriteScissor,0x8013F1D8,0x2D -asm/non_matchings/code/z_view/View_SyncAndWriteScissor.s,View_SyncAndWriteScissor,0x8013F28C,0x1B -asm/non_matchings/code/z_view/View_SetScissorForLetterbox.s,View_SetScissorForLetterbox,0x8013F2F8,0x40 -asm/non_matchings/code/z_view/View_SetDistortionDirRot.s,View_SetDistortionDirRot,0x8013F3F8,0xA +asm/non_matchings/code/z_view/View_SetScissor.s,View_SetScissor,0x8013F1D8,0x2D +asm/non_matchings/code/z_view/View_ClearScissor.s,View_ClearScissor,0x8013F28C,0x1B +asm/non_matchings/code/z_view/View_ApplyLetterbox.s,View_ApplyLetterbox,0x8013F2F8,0x40 +asm/non_matchings/code/z_view/View_SetDistortionOrientation.s,View_SetDistortionOrientation,0x8013F3F8,0xA asm/non_matchings/code/z_view/View_SetDistortionScale.s,View_SetDistortionScale,0x8013F420,0xA asm/non_matchings/code/z_view/View_SetDistortionSpeed.s,View_SetDistortionSpeed,0x8013F448,0x5 asm/non_matchings/code/z_view/View_InitDistortion.s,View_InitDistortion,0x8013F45C,0x19 asm/non_matchings/code/z_view/View_ClearDistortion.s,View_ClearDistortion,0x8013F4C0,0xD asm/non_matchings/code/z_view/View_SetDistortion.s,View_SetDistortion,0x8013F4F4,0x16 asm/non_matchings/code/z_view/View_StepDistortion.s,View_StepDistortion,0x8013F54C,0x6C -asm/non_matchings/code/z_view/View_RenderView.s,View_RenderView,0x8013F6FC,0x13 -asm/non_matchings/code/z_view/View_RenderToPerspectiveMatrix.s,View_RenderToPerspectiveMatrix,0x8013F748,0xB5 -asm/non_matchings/code/z_view/View_RenderToOrthographicMatrix.s,View_RenderToOrthographicMatrix,0x8013FA1C,0x6B -asm/non_matchings/code/z_view/func_8013FBC8.s,func_8013FBC8,0x8013FBC8,0x6B -asm/non_matchings/code/z_view/func_8013FD74.s,func_8013FD74,0x8013FD74,0xAC -asm/non_matchings/code/z_view/func_80140024.s,func_80140024,0x80140024,0x2A -asm/non_matchings/code/z_view/func_801400CC.s,func_801400CC,0x801400CC,0x65 +asm/non_matchings/code/z_view/View_Apply.s,View_Apply,0x8013F6FC,0x13 +asm/non_matchings/code/z_view/View_ApplyPerspective.s,View_ApplyPerspective,0x8013F748,0xB5 +asm/non_matchings/code/z_view/View_ApplyOrtho.s,View_ApplyOrtho,0x8013FA1C,0x6B +asm/non_matchings/code/z_view/View_ApplyOrthoToOverlay.s,View_ApplyOrthoToOverlay,0x8013FBC8,0x6B +asm/non_matchings/code/z_view/View_ApplyPerspectiveToOverlay.s,View_ApplyPerspectiveToOverlay,0x8013FD74,0xAC +asm/non_matchings/code/z_view/View_UpdateViewingMatrix.s,View_UpdateViewingMatrix,0x80140024,0x2A +asm/non_matchings/code/z_view/View_ApplyTo.s,View_ApplyTo,0x801400CC,0x65 asm/non_matchings/code/z_vimode/func_80140260.s,func_80140260,0x80140260,0x3 asm/non_matchings/code/z_vimode/func_8014026C.s,func_8014026C,0x8014026C,0x131 asm/non_matchings/code/z_vimode/func_80140730.s,func_80140730,0x80140730,0x38 @@ -2406,14 +2406,14 @@ asm/non_matchings/code/z_player_call/PlayerCall_Init.s,PlayerCall_Init,0x80160AF asm/non_matchings/code/z_player_call/PlayerCall_Destroy.s,PlayerCall_Destroy,0x80160B40,0x10 asm/non_matchings/code/z_player_call/PlayerCall_Update.s,PlayerCall_Update,0x80160B80,0x10 asm/non_matchings/code/z_player_call/PlayerCall_Draw.s,PlayerCall_Draw,0x80160BC0,0x10 -asm/non_matchings/code/z_shrink_window/ShrinkWindow_SetLetterboxTarget.s,ShrinkWindow_SetLetterboxTarget,0x80160C00,0x5 -asm/non_matchings/code/z_shrink_window/ShrinkWindow_GetLetterboxTarget.s,ShrinkWindow_GetLetterboxTarget,0x80160C14,0x5 -asm/non_matchings/code/z_shrink_window/ShrinkWindow_SetLetterboxMagnitude.s,ShrinkWindow_SetLetterboxMagnitude,0x80160C28,0x5 -asm/non_matchings/code/z_shrink_window/ShrinkWindow_GetLetterboxMagnitude.s,ShrinkWindow_GetLetterboxMagnitude,0x80160C3C,0x5 -asm/non_matchings/code/z_shrink_window/ShrinkWindow_SetPillarboxTarget.s,ShrinkWindow_SetPillarboxTarget,0x80160C50,0x5 -asm/non_matchings/code/z_shrink_window/ShrinkWindow_GetPillarboxTarget.s,ShrinkWindow_GetPillarboxTarget,0x80160C64,0x5 -asm/non_matchings/code/z_shrink_window/ShrinkWindow_SetPillarboxMagnitude.s,ShrinkWindow_SetPillarboxMagnitude,0x80160C78,0x5 -asm/non_matchings/code/z_shrink_window/ShrinkWindow_GetPillarboxMagnitude.s,ShrinkWindow_GetPillarboxMagnitude,0x80160C8C,0x5 +asm/non_matchings/code/z_shrink_window/ShrinkWindow_Letterbox_SetSizeTarget.s,ShrinkWindow_Letterbox_SetSizeTarget,0x80160C00,0x5 +asm/non_matchings/code/z_shrink_window/ShrinkWindow_Letterbox_GetSizeTarget.s,ShrinkWindow_Letterbox_GetSizeTarget,0x80160C14,0x5 +asm/non_matchings/code/z_shrink_window/ShrinkWindow_Letterbox_SetSize.s,ShrinkWindow_Letterbox_SetSize,0x80160C28,0x5 +asm/non_matchings/code/z_shrink_window/ShrinkWindow_Letterbox_GetSize.s,ShrinkWindow_Letterbox_GetSize,0x80160C3C,0x5 +asm/non_matchings/code/z_shrink_window/ShrinkWindow_Pillarbox_SetSizeTarget.s,ShrinkWindow_Pillarbox_SetSizeTarget,0x80160C50,0x5 +asm/non_matchings/code/z_shrink_window/ShrinkWindow_Pillarbox_GetSizeTarget.s,ShrinkWindow_Pillarbox_GetSizeTarget,0x80160C64,0x5 +asm/non_matchings/code/z_shrink_window/ShrinkWindow_Pillarbox_SetSize.s,ShrinkWindow_Pillarbox_SetSize,0x80160C78,0x5 +asm/non_matchings/code/z_shrink_window/ShrinkWindow_Pillarbox_GetSize.s,ShrinkWindow_Pillarbox_GetSize,0x80160C8C,0x5 asm/non_matchings/code/z_shrink_window/ShrinkWindow_Init.s,ShrinkWindow_Init,0x80160CA0,0xD asm/non_matchings/code/z_shrink_window/ShrinkWindow_Destroy.s,ShrinkWindow_Destroy,0x80160CD4,0x4 asm/non_matchings/code/z_shrink_window/ShrinkWindow_Update.s,ShrinkWindow_Update,0x80160CE4,0x2D From aa3f1be55e0409e032062cc6779a6d5710941b85 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sun, 2 Oct 2022 09:07:55 -0700 Subject: [PATCH 15/25] Object Tru Docs (Koume) (#1098) * Name everything in xml * Actor docs regarding assets * move header include * PR * Format * PR * MT animation enum * index () --- assets/xml/objects/object_trt.xml | 4 +- assets/xml/objects/object_tru.xml | 217 +++++++------- .../actors/ovl_En_Jc_Mato/z_en_jc_mato.c | 7 +- src/overlays/actors/ovl_En_Tru/z_en_tru.c | 266 ++++++++++-------- src/overlays/actors/ovl_En_Tru/z_en_tru.h | 13 +- .../actors/ovl_En_Tru_Mt/z_en_tru_mt.c | 113 ++++---- .../actors/ovl_En_Tru_Mt/z_en_tru_mt.h | 8 +- tools/disasm/functions.txt | 6 +- 8 files changed, 342 insertions(+), 292 deletions(-) diff --git a/assets/xml/objects/object_trt.xml b/assets/xml/objects/object_trt.xml index 826aa1ef07..9f024f9cb0 100644 --- a/assets/xml/objects/object_trt.xml +++ b/assets/xml/objects/object_trt.xml @@ -51,10 +51,10 @@ - + - + -> diff --git a/assets/xml/objects/object_tru.xml b/assets/xml/objects/object_tru.xml index 138723cebf..db35ec6044 100644 --- a/assets/xml/objects/object_tru.xml +++ b/assets/xml/objects/object_tru.xml @@ -1,108 +1,117 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c b/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c index 99c17772c2..ced184e682 100644 --- a/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c +++ b/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c @@ -145,15 +145,14 @@ void EnJcMato_Update(Actor* thisx, PlayState* play) { } } -static Vec3f movement = { 0.0f, -2500.0f, 0.0f }; - void EnJcMato_Draw(Actor* thisx, PlayState* play) { + static Vec3f sOffset = { 0.0f, -2500.0f, 0.0f }; EnJcMato* this = THIS; OPEN_DISPS(play->state.gfxCtx); func_8012C28C(play->state.gfxCtx); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_tru_DL_000390); - Matrix_MultVec3f(&movement, &this->pos); + gSPDisplayList(POLY_OPA_DISP++, gKoumeTargetDL); + Matrix_MultVec3f(&sOffset, &this->pos); CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Tru/z_en_tru.c b/src/overlays/actors/ovl_En_Tru/z_en_tru.c index 42cbdc22a1..c54d924dfe 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.c +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.c @@ -5,7 +5,7 @@ */ #include "z_en_tru.h" -#include "objects/object_tru/object_tru.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -24,6 +24,26 @@ s32 func_80A87DC0(Actor* thisx, PlayState* play); void func_80A87FD0(EnTru* this, PlayState* play); void func_80A881E0(EnTru* this, PlayState* play); +typedef enum { + /* 0x00 */ KOUME_ANIM_INJURED_LYING_DOWN, + /* 0x01 */ KOUME_ANIM_INJURED_LYING_DOWN_MORPH, + /* 0x02 */ KOUME_ANIM_TRY_GET_UP, + /* 0x03 */ KOUME_ANIM_INJURED_RAISE_HEAD, + /* 0x04 */ KOUME_ANIM_INJURED_TALK, + /* 0x05 */ KOUME_ANIM_INJURED_HEAD_UP, + /* 0x06 */ KOUME_ANIM_INJURED_HEAD_UP_MORPH, + /* 0x07 */ KOUME_ANIM_TAKE, + /* 0x08 */ KOUME_ANIM_SHAKE, // Unused + /* 0x09 */ KOUME_ANIM_DRINK, + /* 0x0A */ KOUME_ANIM_FINISHED_DRINKING, + /* 0x0B */ KOUME_ANIM_HEALED, + /* 0x0C */ KOUME_ANIM_HOVER1, + /* 0x0D */ KOUME_ANIM_TAKE_OFF, + /* 0x0E */ KOUME_ANIM_FLY, + /* 0x0F */ KOUME_ANIM_HOVER2, + /* 0x10 */ KOUME_ANIM_MAX +} KoumeAnimation; + static UNK_TYPE D_80A88910[] = { 0x0E08520C, 0x16100000, @@ -69,7 +89,6 @@ const ActorInit En_Tru_InitVars = { }; #include "overlays/ovl_En_Tru/ovl_En_Tru.c" -#include "objects/gameplay_keep/gameplay_keep.h" static Vec3f D_80A8B250 = { 0.0f, 0.02f, 0.0f }; @@ -107,22 +126,22 @@ static ColliderSphereInit sSphereInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 1, 20, 0, 0, MASS_IMMOVABLE }; static AnimationInfoS sAnimationInfo[] = { - { &object_tru_Anim_00F9A0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_tru_Anim_00F9A0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_tru_Anim_0108AC, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_tru_Anim_009348, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_tru_Anim_00EEDC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_tru_Anim_015CA0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_tru_Anim_015CA0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_tru_Anim_014728, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_tru_Anim_01B5C4, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_tru_Anim_007FA0, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_tru_Anim_016B4C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_tru_Anim_011F88, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_tru_Anim_00446C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_tru_Anim_003698, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_tru_Anim_002BD8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_tru_Anim_00446C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKoumeInjuredLyingDownAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKoumeInjuredLyingDownAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gKoumeTryGetUpAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gKoumeInjuredRaiseHeadAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKoumeInjuredTalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gKoumeInjuredHeadUpAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKoumeInjuredHeadUpAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gKoumeTakeAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKoumeShakeAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKoumeDrinkAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gKoumeFinishedDrinkingAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gKoumeHealedAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gKoumeHoverAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKoumeTakeOffAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gKoumeFlyAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKoumeHoverAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; static Vec3f D_80A8B3D8 = { 0.0f, 24.0f, 16.0f }; @@ -275,12 +294,12 @@ void func_80A85F84(EnTruUnkStruct* arg0, PlayState* play) { for (i = 0; i < 30; i++, arg0++) { f32 alpha; - s32 idx; + s32 index; if ((arg0->unk_00 == 3) || (arg0->unk_00 == 4) || (arg0->unk_00 == 5)) { if (!flag) { - POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, sizeof(Gfx) * 0); - gSPDisplayList(POLY_XLU_DISP++, object_tru_DL_01A820); + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); + gSPDisplayList(POLY_XLU_DISP++, gKoumeDustMaterialDL); flag = true; } @@ -306,9 +325,9 @@ void func_80A85F84(EnTruUnkStruct* arg0, PlayState* play) { Matrix_ReplaceRotation(&play->billboardMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - idx = ((f32)arg0->unk_02 / arg0->unk_01) * 8.0f; - gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sDustTextures[idx])); - gSPDisplayList(POLY_XLU_DISP++, object_tru_DL_01A830); + index = ((f32)arg0->unk_02 / arg0->unk_01) * 8.0f; + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sDustTextures[index])); + gSPDisplayList(POLY_XLU_DISP++, gKoumeDustModelDL); Matrix_Pop(); } @@ -414,21 +433,21 @@ s32 func_80A86770(EnTru* this) { return false; } -void func_80A868F8(EnTru* this) { - this->skelAnime.playSpeed = this->unk_358; +void EnTru_UpdateSkelAnime(EnTru* this) { + this->skelAnime.playSpeed = this->playSpeed; SkelAnime_Update(&this->skelAnime); } -s32 func_80A86924(EnTru* this, s32 arg1) { - s32 ret = false; +s32 EnTru_ChangeAnim(EnTru* this, s32 animIndex) { + s32 didChange = false; - if (arg1 != this->unk_37C) { - this->unk_37C = arg1; - ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, arg1); - this->unk_358 = this->skelAnime.playSpeed; + if (animIndex != this->animIndex) { + this->animIndex = animIndex; + didChange = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, animIndex); + this->playSpeed = this->skelAnime.playSpeed; } - return ret; + return didChange; } void func_80A8697C(EnTru* this, PlayState* play) { @@ -497,7 +516,7 @@ s32 func_80A86BAC(EnTru* this, PlayState* play) { Matrix_RotateXS(-0x4000, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_tru_DL_0020C8); + gSPDisplayList(POLY_OPA_DISP++, gKoumePotionDL); Matrix_Pop(); @@ -515,7 +534,7 @@ s32 func_80A86BAC(EnTru* this, PlayState* play) { Matrix_RotateXS(-0x4000, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_tru_DL_001F90); + gSPDisplayList(POLY_XLU_DISP++, gKoumeBottleDL); Matrix_Pop(); @@ -527,104 +546,105 @@ s32 func_80A86BAC(EnTru* this, PlayState* play) { s32 func_80A86DB8(EnTru* this) { if (this->unk_34E & 0x80) { - this->unk_36E = 2; + this->eyeTexIndex = 2; return false; } - switch (this->unk_37C) { - case 0: - case 1: - if (DECR(this->unk_36C) == 0) { + switch (this->animIndex) { + case KOUME_ANIM_INJURED_LYING_DOWN: + case KOUME_ANIM_INJURED_LYING_DOWN_MORPH: + if (DECR(this->blinkTimer) == 0) { s16 rand = Rand_S16Offset(40, 20); - if (this->unk_36E == 2) { - this->unk_36C = 8; + + if (this->eyeTexIndex == 2) { + this->blinkTimer = 8; } else { - this->unk_36C = rand; + this->blinkTimer = rand; } - if (this->unk_36E == 2) { - this->unk_36E = 1; + if (this->eyeTexIndex == 2) { + this->eyeTexIndex = 1; } else { - this->unk_36E = 2; + this->eyeTexIndex = 2; } } return false; - case 2: + case KOUME_ANIM_TRY_GET_UP: if (Animation_OnFrame(&this->skelAnime, 10.0f)) { - this->unk_36E = 1; + this->eyeTexIndex = 1; } else if ((this->skelAnime.curFrame >= 11.0f) && (this->skelAnime.curFrame <= 32.0f)) { - this->unk_36E = 0; + this->eyeTexIndex = 0; } else { - this->unk_36E = 2; + this->eyeTexIndex = 2; } return false; - case 3: + case KOUME_ANIM_INJURED_RAISE_HEAD: if (Animation_OnFrame(&this->skelAnime, 31.0f)) { - this->unk_36E = 1; + this->eyeTexIndex = 1; } else if (this->skelAnime.curFrame <= 32.0f) { - this->unk_36E = 2; + this->eyeTexIndex = 2; } else { - this->unk_36E = 0; + this->eyeTexIndex = 0; } return false; - case 9: + case KOUME_ANIM_DRINK: if (Animation_OnFrame(&this->skelAnime, 57.0f)) { - this->unk_36C = 0; - this->unk_36E = 0; + this->blinkTimer = 0; + this->eyeTexIndex = 0; } if (this->skelAnime.curFrame < 57.0f) { - if (DECR(this->unk_36C) == 0) { - this->unk_36C = Rand_S16Offset(8, 8); - this->unk_36E = 2; + if (DECR(this->blinkTimer) == 0) { + this->blinkTimer = Rand_S16Offset(8, 8); + this->eyeTexIndex = 2; } else { - this->unk_36E = 1; + this->eyeTexIndex = 1; } - } else if (DECR(this->unk_36C) == 0) { - this->unk_36E++; - if (this->unk_36E >= 4) { - this->unk_36C = Rand_S16Offset(20, 10); - this->unk_36E = 0; + } else if (DECR(this->blinkTimer) == 0) { + this->eyeTexIndex++; + if (this->eyeTexIndex >= 4) { + this->blinkTimer = Rand_S16Offset(20, 10); + this->eyeTexIndex = 0; } } return false; - case 10: - this->unk_36E = 0; + case KOUME_ANIM_FINISHED_DRINKING: + this->eyeTexIndex = 0; return false; - case 11: + case KOUME_ANIM_HEALED: if (Animation_OnFrame(&this->skelAnime, 19.0f) || Animation_OnFrame(&this->skelAnime, 45.0f)) { - this->unk_36E = 1; + this->eyeTexIndex = 1; } else if ((this->skelAnime.curFrame >= 19.0f) && (this->skelAnime.curFrame <= 45.0f)) { - this->unk_36E = 2; + this->eyeTexIndex = 2; } else { - this->unk_36E = 3; + this->eyeTexIndex = 3; } return false; - case 13: + case KOUME_ANIM_TAKE_OFF: if (Animation_OnFrame(&this->skelAnime, 19.0f)) { - this->unk_36E = 1; + this->eyeTexIndex = 1; } else if (this->skelAnime.curFrame >= 19.0f) { - this->unk_36E = 2; + this->eyeTexIndex = 2; } else { - this->unk_36E = 0; + this->eyeTexIndex = 0; } return false; default: - if (DECR(this->unk_36C) == 0) { - if ((this->unk_36E != 2) || !(this->unk_34E & 0x80)) { - this->unk_36E++; + if (DECR(this->blinkTimer) == 0) { + if ((this->eyeTexIndex != 2) || !(this->unk_34E & 0x80)) { + this->eyeTexIndex++; } - if (this->unk_36E >= 4) { - this->unk_36C = Rand_S16Offset(30, 30); - this->unk_36E = 0; + if (this->eyeTexIndex >= 4) { + this->blinkTimer = Rand_S16Offset(30, 30); + this->eyeTexIndex = 0; } } return false; @@ -772,11 +792,12 @@ s32 func_80A875AC(Actor* thisx, PlayState* play) { break; case 2: - if ((this->unk_37C != 5) && (this->unk_37C != 6)) { - func_80A86924(this, 3); + if ((this->animIndex != KOUME_ANIM_INJURED_HEAD_UP) && + (this->animIndex != KOUME_ANIM_INJURED_HEAD_UP_MORPH)) { + EnTru_ChangeAnim(this, KOUME_ANIM_INJURED_RAISE_HEAD); this->unk_364++; } else { - func_80A86924(this, 4); + EnTru_ChangeAnim(this, KOUME_ANIM_INJURED_TALK); ret = true; } break; @@ -784,7 +805,7 @@ s32 func_80A875AC(Actor* thisx, PlayState* play) { case 3: if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_364++; - func_80A86924(this, 4); + EnTru_ChangeAnim(this, KOUME_ANIM_INJURED_TALK); ret = true; } break; @@ -806,7 +827,7 @@ s32 func_80A875AC(Actor* thisx, PlayState* play) { s32 func_80A8777C(Actor* thisx, PlayState* play) { EnTru* this = THIS; s32 ret = 0; - s32 temp_v0; + s32 itemActionParam; switch (Message_GetState(&play->msgCtx)) { case TEXT_STATE_CHOICE: @@ -816,10 +837,10 @@ s32 func_80A8777C(Actor* thisx, PlayState* play) { } // Fallthrough case TEXT_STATE_16: - temp_v0 = func_80123810(play); - if ((temp_v0 == 35) || (temp_v0 == 36)) { + itemActionParam = func_80123810(play); + if ((itemActionParam == PLAYER_AP_BOTTLE_POTION_RED) || (itemActionParam == PLAYER_AP_BOTTLE_POTION_BLUE)) { this->unk_34E |= 8; - if (temp_v0 == 35) { + if (itemActionParam == PLAYER_AP_BOTTLE_POTION_RED) { this->unk_390 = 1; } else { this->unk_390 = 2; @@ -827,9 +848,9 @@ s32 func_80A8777C(Actor* thisx, PlayState* play) { this->unk_378 = func_80A87880; this->unk_364 = 0; ret = 1; - } else if (temp_v0 < 0) { + } else if (itemActionParam < PLAYER_AP_NONE) { ret = 3; - } else if (temp_v0 != 0) { + } else if (itemActionParam != PLAYER_AP_NONE) { ret = 2; } break; @@ -866,14 +887,14 @@ s32 func_80A87880(Actor* thisx, PlayState* play) { this->unk_34E &= ~0x8; this->actor.shape.rot.y = this->actor.yawTowardsPlayer; this->actor.world.rot.y = this->actor.yawTowardsPlayer; - func_80A86924(this, 7); + EnTru_ChangeAnim(this, KOUME_ANIM_TAKE); this->unk_364++; break; case 3: if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_364++; - func_80A86924(this, 9); + EnTru_ChangeAnim(this, KOUME_ANIM_DRINK); this->actor.world.rot.y += 0x4000; } else if (Animation_OnFrame(&this->skelAnime, 12.0f) && !(this->unk_34E & 0x800)) { this->unk_34E |= 0x400; @@ -885,7 +906,7 @@ s32 func_80A87880(Actor* thisx, PlayState* play) { case 4: if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_364++; - func_80A86924(this, 10); + EnTru_ChangeAnim(this, KOUME_ANIM_FINISHED_DRINKING); ret = true; } else if (Animation_OnFrame(&this->skelAnime, 18.0f) || Animation_OnFrame(&this->skelAnime, 32.0f) || Animation_OnFrame(&this->skelAnime, 52.0f)) { @@ -923,7 +944,7 @@ s32 func_80A87B48(Actor* thisx, PlayState* play) { switch (this->unk_364) { case 0: - func_80A86924(this, 11); + EnTru_ChangeAnim(this, KOUME_ANIM_HEALED); this->unk_364++; break; @@ -954,7 +975,7 @@ s32 func_80A87B48(Actor* thisx, PlayState* play) { if (player->exchangeItemId != 0) { player->exchangeItemId = 0; } - func_80A86924(this, 12); + EnTru_ChangeAnim(this, KOUME_ANIM_HOVER1); } } else { MREG(64) = 0; @@ -997,7 +1018,7 @@ s32 func_80A87DC0(Actor* thisx, PlayState* play) { AudioSfx_StopById(NA_SE_EN_KOUME_MAGIC); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOUME_AWAY); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOUME_LAUGH); - func_80A86924(this, 13); + EnTru_ChangeAnim(this, KOUME_ANIM_TAKE_OFF); this->skelAnime.baseTransl.y = 0; this->skelAnime.moveFlags = 2; this->unk_34E &= ~0x8; @@ -1010,7 +1031,7 @@ s32 func_80A87DC0(Actor* thisx, PlayState* play) { AnimationContext_SetMoveActor(play, &this->actor, &this->skelAnime, 1.0f); break; } else { - func_80A86924(this, 14); + EnTru_ChangeAnim(this, KOUME_ANIM_FLY); this->actor.shape.rot.y = this->actor.world.rot.y; this->unk_362 = 20; this->unk_364++; @@ -1049,13 +1070,14 @@ void func_80A87FD0(EnTru* this, PlayState* play) { SubS_UpdateFlags(&this->unk_34E, 0, 7); } - if ((this->unk_37C == 2) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + if ((this->animIndex == KOUME_ANIM_TRY_GET_UP) && + Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_362 = Rand_S16Offset(40, 20); - func_80A86924(this, 1); + EnTru_ChangeAnim(this, KOUME_ANIM_INJURED_LYING_DOWN_MORPH); func_80A86460(this); - } else if (this->unk_37C != 2) { + } else if (this->animIndex != KOUME_ANIM_TRY_GET_UP) { if (DECR(this->unk_362) == 0) { - func_80A86924(this, 2); + EnTru_ChangeAnim(this, KOUME_ANIM_TRY_GET_UP); } } } else if (!(gSaveContext.save.weekEventReg[16] & 0x10) && (fabsf(this->actor.playerHeightRel) < 10.0f) && @@ -1084,12 +1106,12 @@ void func_80A881E0(EnTru* this, PlayState* play) { } if (!(this->unk_34E & 0x40) && !(gSaveContext.save.weekEventReg[16] & 0x10)) { - func_80A86924(this, 0); + EnTru_ChangeAnim(this, KOUME_ANIM_INJURED_LYING_DOWN); } else if (this->unk_34E & 0x80) { - func_80A86924(this, 0); + EnTru_ChangeAnim(this, KOUME_ANIM_INJURED_LYING_DOWN); func_80A86460(this); } else if (gSaveContext.save.weekEventReg[16] & 0x10) { - func_80A86924(this, 6); + EnTru_ChangeAnim(this, KOUME_ANIM_INJURED_HEAD_UP_MORPH); } SubS_UpdateFlags(&this->unk_34E, 0, 7); @@ -1111,11 +1133,11 @@ void EnTru_Init(Actor* thisx, PlayState* play) { } ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); - SkelAnime_InitFlex(play, &this->skelAnime, &object_tru_Skel_01AA60, NULL, this->jointTable, this->morphTable, 27); + SkelAnime_InitFlex(play, &this->skelAnime, &gKoumeSkel, NULL, this->jointTable, this->morphTable, KOUME_LIMB_MAX); Collider_InitAndSetSphere(play, &this->collider, &this->actor, &sSphereInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); - this->unk_37C = -1; - func_80A86924(this, 0); + this->animIndex = -1; + EnTru_ChangeAnim(this, KOUME_ANIM_INJURED_LYING_DOWN); this->path = SubS_GetDayDependentPath(play, ENTRU_GET_PATH(&this->actor), 255, &this->unk_384); if (this->path != NULL) { this->unk_384 = 1; @@ -1126,7 +1148,7 @@ void EnTru_Init(Actor* thisx, PlayState* play) { this->unk_34E = 0; if (gSaveContext.save.weekEventReg[16] & 0x10) { - func_80A86924(this, 5); + EnTru_ChangeAnim(this, KOUME_ANIM_INJURED_HEAD_UP); } else { this->unk_388 = PLAYER_AP_NONE; } @@ -1149,7 +1171,7 @@ void EnTru_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); - func_80A868F8(this); + EnTru_UpdateSkelAnime(this); func_80A86B0C(this, play); func_80A86DB8(this); @@ -1165,7 +1187,7 @@ s32 EnTru_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* p s32 pad; EnTru* this = THIS; - if (limbIndex == 21) { + if (limbIndex == KOUME_LIMB_HEAD) { Matrix_MultZero(&this->actor.focus.pos); Math_Vec3f_ToVec3s(&this->collider.dim.worldSphere.center, &this->actor.focus.pos); this->actor.focus.pos.x = (this->actor.focus.pos.x / 10.0f) * 10.0f; @@ -1175,7 +1197,7 @@ s32 EnTru_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* p Matrix_MultVec3f(&D_80A8B3FC, &this->unk_1F8); } - if (!(this->unk_34E & 0x200) && (limbIndex == 14)) { + if (!(this->unk_34E & 0x200) && (limbIndex == KOUME_LIMB_BROOM)) { *dList = NULL; } @@ -1185,7 +1207,7 @@ s32 EnTru_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* p void EnTru_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnTru* this = THIS; - if (limbIndex == 19) { + if (limbIndex == KOUME_LIMB_RIGHT_HAND) { func_80A86BAC(this, play); } } @@ -1212,7 +1234,7 @@ void EnTru_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { overrideRot = false; } - if (limbIndex == 21) { + if (limbIndex == KOUME_LIMB_HEAD) { SubS_UpdateLimb(this->unk_366, this->unk_368 + this->actor.shape.rot.y, &this->unk_1EC, &this->unk_204, stepRot, overrideRot); Matrix_Pop(); @@ -1232,11 +1254,11 @@ void EnTru_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { } void EnTru_Draw(Actor* thisx, PlayState* play) { - static TexturePtr D_80A8B408[] = { - object_tru_Tex_018FA0, - object_tru_Tex_0197A0, - object_tru_Tex_019FA0, - object_tru_Tex_0197A0, + static TexturePtr sEyeTextures[] = { + gKoumeEyeOpenTex, + gKoumeEyeHalfTex, + gKoumeEyeClosedTex, + gKoumeEyeHalfTex, }; s32 pad; EnTru* this = THIS; @@ -1245,8 +1267,8 @@ void EnTru_Draw(Actor* thisx, PlayState* play) { func_8012C28C(play->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A8B408[this->unk_36E])); - gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80A8B408[this->unk_36E])); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTexIndex])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTexIndex])); SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnTru_OverrideLimbDraw, EnTru_PostLimbDraw, diff --git a/src/overlays/actors/ovl_En_Tru/z_en_tru.h b/src/overlays/actors/ovl_En_Tru/z_en_tru.h index 7e1c233806..711d5aeb61 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.h +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.h @@ -2,6 +2,7 @@ #define Z_EN_TRU_H #include "global.h" +#include "objects/object_tru/object_tru.h" struct EnTru; @@ -31,12 +32,12 @@ typedef struct EnTru { /* 0x1EC */ Vec3f unk_1EC; /* 0x1F8 */ Vec3f unk_1F8; /* 0x204 */ Vec3s unk_204; - /* 0x20A */ Vec3s jointTable[27]; - /* 0x2AC */ Vec3s morphTable[27]; + /* 0x20A */ Vec3s jointTable[KOUME_LIMB_MAX]; + /* 0x2AC */ Vec3s morphTable[KOUME_LIMB_MAX]; /* 0x34E */ u16 unk_34E; /* 0x350 */ UNK_TYPE1 unk350[0x4]; /* 0x354 */ s32* unk_354; - /* 0x358 */ f32 unk_358; + /* 0x358 */ f32 playSpeed; /* 0x35C */ f32 unk_35C; /* 0x360 */ s16 unk_360; /* 0x362 */ s16 unk_362; @@ -44,13 +45,13 @@ typedef struct EnTru { /* 0x366 */ s16 unk_366; /* 0x368 */ s16 unk_368; /* 0x36A */ s16 unk_36A; - /* 0x36C */ s16 unk_36C; - /* 0x36E */ s16 unk_36E; + /* 0x36C */ s16 blinkTimer; + /* 0x36E */ s16 eyeTexIndex; /* 0x370 */ s16 unk_370; /* 0x372 */ s16 unk_372; /* 0x374 */ s16 unk_374; /* 0x378 */ EnTruUnkFunc unk_378; - /* 0x37C */ s32 unk_37C; + /* 0x37C */ s32 animIndex; /* 0x380 */ UNK_TYPE1 unk380[0x4]; /* 0x384 */ s32 unk_384; /* 0x388 */ s32 unk_388; diff --git a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c index ac772a9404..69725414ad 100644 --- a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c +++ b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c @@ -20,6 +20,26 @@ void func_80B76A64(EnTruMt* this, PlayState* play); void func_80B76BB8(EnTruMt* this, PlayState* play); void func_80B76C38(EnTruMt* this, PlayState* play); +typedef enum { + /* 0x00 */ KOUME_MT_ANIM_INJURED_LYING_DOWN, + /* 0x01 */ KOUME_MT_ANIM_INJURED_LYING_DOWN_MORPH, + /* 0x02 */ KOUME_MT_ANIM_TRY_GET_UP, + /* 0x03 */ KOUME_MT_ANIM_INJURED_RAISE_HEAD, + /* 0x04 */ KOUME_MT_ANIM_INJURED_TALK, + /* 0x05 */ KOUME_MT_ANIM_INJURED_HEAD_UP, + /* 0x06 */ KOUME_MT_ANIM_INJURED_HEAD_UP_MORPH, + /* 0x07 */ KOUME_MT_ANIM_TAKE, + /* 0x08 */ KOUME_MT_ANIM_SHAKE, // Unused + /* 0x09 */ KOUME_MT_ANIM_DRINK, + /* 0x0A */ KOUME_MT_ANIM_FINISHED_DRINKING, + /* 0x0B */ KOUME_MT_ANIM_HEALED, + /* 0x0C */ KOUME_MT_ANIM_HOVER1, + /* 0x0D */ KOUME_MT_ANIM_TAKE_OFF, + /* 0x0E */ KOUME_MT_ANIM_FLY, + /* 0x0F */ KOUME_MT_ANIM_HOVER2, + /* 0x10 */ KOUME_MT_ANIM_MAX +} KoumeMtAnimation; + const ActorInit En_Tru_Mt_InitVars = { ACTOR_EN_TRU_MT, ACTORCAT_NPC, @@ -88,57 +108,57 @@ static DamageTable sDamageTable = { }; static AnimationInfoS sAnimationInfo[] = { - { &object_tru_Anim_00F9A0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_tru_Anim_00F9A0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_tru_Anim_0108AC, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_tru_Anim_009348, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_tru_Anim_00EEDC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_tru_Anim_015CA0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_tru_Anim_015CA0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_tru_Anim_014728, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_tru_Anim_01B5C4, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_tru_Anim_007FA0, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_tru_Anim_016B4C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_tru_Anim_011F88, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_tru_Anim_00446C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_tru_Anim_003698, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_tru_Anim_002BD8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_tru_Anim_00446C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKoumeInjuredLyingDownAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKoumeInjuredLyingDownAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gKoumeTryGetUpAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gKoumeInjuredRaiseHeadAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gKoumeInjuredTalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gKoumeInjuredHeadUpAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKoumeInjuredHeadUpAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gKoumeTakeAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKoumeShakeAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKoumeDrinkAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gKoumeFinishedDrinkingAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gKoumeHealedAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gKoumeHoverAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKoumeTakeOffAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gKoumeFlyAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKoumeHoverAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; Vec3f D_80B7765C = { 3000.0f, -800.0f, 0.0f }; Vec3f D_80B77668 = { 0.0f, 0.0f, -3000.0f }; -s32 func_80B76030(SkelAnime* skelAnime, s16 arg1) { +s32 EnTruMt_ChangeAnim(SkelAnime* skelAnime, s16 animIndex) { s16 endFrame; s16 startFrame; - s32 ret = false; + s32 didChange = false; - if ((arg1 >= 0) && (arg1 < ARRAY_COUNT(sAnimationInfo))) { - endFrame = sAnimationInfo[arg1].frameCount; + if ((animIndex >= KOUME_MT_ANIM_INJURED_LYING_DOWN) && (animIndex < KOUME_MT_ANIM_MAX)) { + endFrame = sAnimationInfo[animIndex].frameCount; if (endFrame < 0) { - endFrame = Animation_GetLastFrame(sAnimationInfo[arg1].animation); + endFrame = Animation_GetLastFrame(sAnimationInfo[animIndex].animation); } - startFrame = sAnimationInfo[arg1].startFrame; + startFrame = sAnimationInfo[animIndex].startFrame; if (startFrame < 0) { - startFrame = Animation_GetLastFrame(sAnimationInfo[arg1].animation); + startFrame = Animation_GetLastFrame(sAnimationInfo[animIndex].animation); } - Animation_Change(skelAnime, sAnimationInfo[arg1].animation, sAnimationInfo[arg1].playSpeed, startFrame, - endFrame, sAnimationInfo[arg1].mode, sAnimationInfo[arg1].morphFrames); - ret = true; + Animation_Change(skelAnime, sAnimationInfo[animIndex].animation, sAnimationInfo[animIndex].playSpeed, + startFrame, endFrame, sAnimationInfo[animIndex].mode, sAnimationInfo[animIndex].morphFrames); + didChange = true; } - return ret; + return didChange; } void func_80B76110(EnTruMt* this) { - if (DECR(this->unk_34E) == 0) { - this->unk_34C++; - if (this->unk_34C >= 3) { - this->unk_34E = Rand_S16Offset(30, 30); - this->unk_34C = 0; + if (DECR(this->blinkTimer) == 0) { + this->eyeTexIndex++; + if (this->eyeTexIndex >= 3) { + this->blinkTimer = Rand_S16Offset(30, 30); + this->eyeTexIndex = 0; } } } @@ -404,8 +424,7 @@ void EnTruMt_Init(Actor* thisx, PlayState* play) { } ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); - SkelAnime_InitFlex(play, &this->skelAnime, &object_tru_Skel_01AA60, NULL, this->jointTable, this->morphTable, - OBJECT_TRU_LIMB_MAX); + SkelAnime_InitFlex(play, &this->skelAnime, &gKoumeSkel, NULL, this->jointTable, this->morphTable, KOUME_LIMB_MAX); Collider_InitSphere(play, &this->collider); Collider_SetSphere(play, &this->collider, &this->actor, &sSphereInit); @@ -421,7 +440,7 @@ void EnTruMt_Init(Actor* thisx, PlayState* play) { this->unk_328 = 0; this->actor.room = -1; this->path = SubS_GetPathByIndex(play, ENTRUMT_GET_FC00(&this->actor), 0x3F); - func_80B76030(&this->skelAnime, 14); + EnTruMt_ChangeAnim(&this->skelAnime, KOUME_MT_ANIM_FLY); this->actionFunc = func_80B76A64; } @@ -477,11 +496,11 @@ void func_80B76ED4(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4) { s32 EnTruMt_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnTruMt* this = THIS; - if (limbIndex == OBJECT_TRU_LIMB_15) { + if (limbIndex == KOUME_LIMB_HEAD) { Matrix_MultVec3f(&gZeroVec3f, &this->unk_35C); } - if (limbIndex == OBJECT_TRU_LIMB_15) { + if (limbIndex == KOUME_LIMB_HEAD) { Matrix_MultVec3f(&D_80B7765C, &this->unk_350); } return false; @@ -493,7 +512,7 @@ void EnTruMt_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* ro MtxF* sp54; s32 phi_v0; - if (limbIndex == OBJECT_TRU_LIMB_15) { + if (limbIndex == KOUME_LIMB_HEAD) { if (this->unk_328 & 0x10) { phi_v0 = 1; } else { @@ -507,7 +526,7 @@ void EnTruMt_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* ro Matrix_RotateZS(this->unk_336.z, MTXMODE_APPLY); } - if (limbIndex == OBJECT_TRU_LIMB_0E) { + if (limbIndex == KOUME_LIMB_BROOM) { func_8012C28C(play->state.gfxCtx); OPEN_DISPS(play->state.gfxCtx); @@ -520,7 +539,7 @@ void EnTruMt_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* ro Matrix_Scale(0.008f, 0.008f, 0.008f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_tru_DL_0004C8); + gSPDisplayList(POLY_OPA_DISP++, gKoumeChainDL); CLOSE_DISPS(play->state.gfxCtx); @@ -545,7 +564,7 @@ void EnTruMt_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* ro void EnTruMt_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { EnTruMt* this = THIS; - if (limbIndex == OBJECT_TRU_LIMB_15) { + if (limbIndex == KOUME_LIMB_HEAD) { Matrix_Translate(this->unk_33C.x, this->unk_33C.y, this->unk_33C.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); Matrix_RotateYS(this->unk_336.y, MTXMODE_APPLY); @@ -556,18 +575,18 @@ void EnTruMt_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { void EnTruMt_Draw(Actor* thisx, PlayState* play) { EnTruMt* this = THIS; - TexturePtr sp48[] = { - object_tru_Tex_018FA0, - object_tru_Tex_0197A0, - object_tru_Tex_019FA0, + TexturePtr eyeTextures[] = { + gKoumeEyeOpenTex, + gKoumeEyeHalfTex, + gKoumeEyeClosedTex, }; OPEN_DISPS(play->state.gfxCtx); func_8012C28C(play->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sp48[this->unk_34C])); - gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sp48[this->unk_34C])); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(eyeTextures[this->eyeTexIndex])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(eyeTextures[this->eyeTexIndex])); SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnTruMt_OverrideLimbDraw, EnTruMt_PostLimbDraw, diff --git a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.h b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.h index 670d0d728a..54d58326e5 100644 --- a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.h +++ b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.h @@ -16,16 +16,16 @@ typedef struct EnTruMt { /* 0x144 */ EnTruMtActionFunc actionFunc; /* 0x148 */ SkelAnime skelAnime; /* 0x18C */ ColliderSphere collider; - /* 0x1E4 */ Vec3s jointTable[OBJECT_TRU_LIMB_MAX]; - /* 0x286 */ Vec3s morphTable[OBJECT_TRU_LIMB_MAX]; + /* 0x1E4 */ Vec3s jointTable[KOUME_LIMB_MAX]; + /* 0x286 */ Vec3s morphTable[KOUME_LIMB_MAX]; /* 0x328 */ u16 unk_328; /* 0x32A */ UNK_TYPE1 unk32A[0xC]; /* 0x336 */ Vec3s unk_336; /* 0x33C */ Vec3f unk_33C; /* 0x348 */ s16 unk_348; /* 0x34A */ s16 unk_34A; - /* 0x34C */ s16 unk_34C; - /* 0x34E */ s16 unk_34E; + /* 0x34C */ s16 eyeTexIndex; + /* 0x34E */ s16 blinkTimer; /* 0x350 */ Vec3f unk_350; /* 0x35C */ Vec3f unk_35C; /* 0x368 */ Path* path; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 8a146996da..057170442e 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -11226,8 +11226,8 @@ 0x80A86460:("func_80A86460",), 0x80A86674:("func_80A86674",), 0x80A86770:("func_80A86770",), - 0x80A868F8:("func_80A868F8",), - 0x80A86924:("func_80A86924",), + 0x80A868F8:("EnTru_UpdateSkelAnime",), + 0x80A86924:("EnTru_ChangeAnim",), 0x80A8697C:("func_80A8697C",), 0x80A869DC:("func_80A869DC",), 0x80A86B0C:("func_80A86B0C",), @@ -14437,7 +14437,7 @@ 0x80B75658:("EnJg_OverrideLimbDraw",), 0x80B75708:("EnJg_PostLimbDraw",), 0x80B757AC:("EnJg_Draw",), - 0x80B76030:("func_80B76030",), + 0x80B76030:("EnTruMt_ChangeAnim",), 0x80B76110:("func_80B76110",), 0x80B76188:("func_80B76188",), 0x80B761FC:("func_80B761FC",), From 3d5d39e74d8eca94be52657bacf017de4e9962c2 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sun, 2 Oct 2022 09:16:30 -0700 Subject: [PATCH 16/25] Document leftover pause joint tables (#1104) * Document leftover pause joint tables * Grab the other two joint tables * Document the deku stick thing * Add @bug to comment --- assets/xml/objects/gameplay_keep.xml | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index ee2bed429a..121dcfe5e5 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -39,7 +39,7 @@ - + @@ -69,8 +69,26 @@ - - + + + + + + + + + + + + + + + + + + + + @@ -766,6 +784,7 @@ + From fdfe2842d9daf023c8ccdc8621489a44de3c1786 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sun, 2 Oct 2022 10:10:31 -0700 Subject: [PATCH 17/25] Eff Srchball OK (#1092) * OK * Some docs and cleanup * flags -> params * Remove todo * Small cleanup * Description and dls * Format * bug tag * Update bug comment * Update src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.c Co-authored-by: EllipticEllipsis * Format Co-authored-by: EllipticEllipsis --- assets/xml/objects/gameplay_keep.xml | 4 +- include/functions.h | 2 +- include/z64effect.h | 1 - spec | 3 +- src/code/z_effect_soft_sprite_old_init.c | 10 +-- .../actors/ovl_Demo_Kankyo/z_demo_kankyo.c | 4 +- .../actors/ovl_En_Encount2/z_en_encount2.c | 4 +- .../actors/ovl_En_Hanabi/z_en_hanabi.c | 4 +- .../actors/ovl_En_Look_Nuts/z_en_look_nuts.c | 8 +- .../actors/ovl_En_Suttari/z_en_suttari.c | 19 +++-- .../actors/ovl_En_Suttari/z_en_suttari.h | 2 +- .../z_eff_ss_solder_srch_ball.c | 80 +++++++++++++++++-- .../z_eff_ss_solder_srch_ball.h | 9 ++- 13 files changed, 111 insertions(+), 39 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 121dcfe5e5..ca0aaeb3cc 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -1377,8 +1377,8 @@ - - + + diff --git a/include/functions.h b/include/functions.h index c79fc333f5..9d21eca01c 100644 --- a/include/functions.h +++ b/include/functions.h @@ -558,7 +558,7 @@ void EffectSsHitmark_SpawnFixedScale(PlayState* play, s32 type, Vec3f* pos); void EffectSsHitmark_SpawnCustomScale(PlayState* play, s32 type, s16 scale, Vec3f* pos); void EffectSsFhgFlash_SpawnShock(PlayState* play, Actor* actor, Vec3f* pos, s16 scale, u8 params); // void EffectSsKFire_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, UNK_TYPE2 param_5, UNK_TYPE1 param_6); -void EffectSsSolderSrchBall_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 unused, s16* linkDetected, s16 drawFlag); +void EffectSsSolderSrchBall_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16* playerDetected, s16 params); void EffectSsKakera_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* arg3, s16 gravity, s16 arg5, s16 arg6, s16 arg7, s16 arg8, s16 scale, s16 arg10, s16 arg11, s32 life, s16 colorIdx, s16 objId, Gfx* dList); // void EffectSsIcePiece_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, UNK_TYPE4 uParm3, Vec3f* pzParm4, Vec3f* param_5, UNK_TYPE4 param_6); // void EffectSsIcePiece_SpawnBurst(void); diff --git a/include/z64effect.h b/include/z64effect.h index dde996eb76..b4574592a0 100644 --- a/include/z64effect.h +++ b/include/z64effect.h @@ -257,7 +257,6 @@ typedef struct { /* 0x18 */ u8 unk18; // Always 1? } EffectSsOverlay; // size = 0x1C -//! TODO: Review reuse of vec/gfx/actor fields across all effects typedef struct EffectSs { /* 0x00 */ Vec3f pos; /* 0x0C */ Vec3f velocity; diff --git a/spec b/spec index 80141af9c4..2dce298d5b 100644 --- a/spec +++ b/spec @@ -1869,8 +1869,7 @@ beginseg name "ovl_Effect_Ss_Solder_Srch_Ball" compress include "build/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.o" - include "build/data/ovl_Effect_Ss_Solder_Srch_Ball/ovl_Effect_Ss_Solder_Srch_Ball.data.o" - include "build/data/ovl_Effect_Ss_Solder_Srch_Ball/ovl_Effect_Ss_Solder_Srch_Ball.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/ovl_Effect_Ss_Solder_Srch_Ball_reloc.o" endseg beginseg diff --git a/src/code/z_effect_soft_sprite_old_init.c b/src/code/z_effect_soft_sprite_old_init.c index 5fc51b0c33..bbdd528a4a 100644 --- a/src/code/z_effect_soft_sprite_old_init.c +++ b/src/code/z_effect_soft_sprite_old_init.c @@ -702,16 +702,16 @@ void EffectSsKFire_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* ac // EffectSsSolderSrchBall Spawn Functions -void EffectSsSolderSrchBall_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 unused, - s16* linkDetected, s16 drawFlag) { +void EffectSsSolderSrchBall_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, + s16* playerDetected, s16 flags) { EffectSsSolderSrchBallInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); Math_Vec3f_Copy(&initParams.velocity, velocity); Math_Vec3f_Copy(&initParams.accel, accel); - initParams.unused = unused; - initParams.linkDetected = linkDetected; - initParams.drawFlag = drawFlag; + initParams.scale = scale; + initParams.playerDetected = playerDetected; + initParams.flags = flags; EffectSs_Spawn(play, EFFECT_SS_SOLDER_SRCH_BALL, 128, &initParams); } diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c index 12da392887..10b72634a2 100644 --- a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c +++ b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c @@ -508,7 +508,7 @@ void DemoKakyo_DrawLostWoodsSparkle(Actor* thisx, PlayState* play2) { POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 20); gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gSun1Tex)); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_07AB10); + gSPDisplayList(POLY_XLU_DISP++, gSunSparkleMaterialDL); for (i = 0; i < play->envCtx.unk_F2[3]; i++) { worldPos.x = this->effects[i].posBase.x + this->effects[i].posOffset.x; @@ -575,7 +575,7 @@ void DemoKakyo_DrawLostWoodsSparkle(Actor* thisx, PlayState* play2) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_07AB58); + gSPDisplayList(POLY_XLU_DISP++, gSunSparkleModelDL); } } 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 d771f3511c..b7c698376a 100644 --- a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c +++ b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c @@ -279,14 +279,14 @@ void EnEncount2_DrawEffects(EnEncount2* this, PlayState* play) { Matrix_Scale(sPtr->scale, sPtr->scale, sPtr->scale, MTXMODE_APPLY); POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 20); gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gSun1Tex)); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_07AB10); + gSPDisplayList(POLY_XLU_DISP++, gSunSparkleMaterialDL); gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); gDPSetEnvColor(POLY_XLU_DISP++, 250, 180, 255, sPtr->alpha); Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); Matrix_RotateZF(DEGF_TO_RADF(play->state.frames * 20.0f), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_07AB58); + gSPDisplayList(POLY_XLU_DISP++, gSunSparkleModelDL); } } CLOSE_DISPS(gfxCtx); diff --git a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c index f9085e8253..0f016f3004 100644 --- a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c +++ b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c @@ -146,7 +146,7 @@ void func_80B22FA8(EnHanabiStruct* arg0, PlayState* play2) { POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 20); gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gSun1Tex)); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_07AB10); + gSPDisplayList(POLY_XLU_DISP++, gSunSparkleMaterialDL); sp53 = 0xFF; if (sp53) {} @@ -181,7 +181,7 @@ void func_80B22FA8(EnHanabiStruct* arg0, PlayState* play2) { D_80B23C2C[arg0->unk_02 + 2], 255); } - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_07AB58); + gSPDisplayList(POLY_XLU_DISP++, gSunSparkleModelDL); } } diff --git a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c index de053c46a8..6fd949febe 100644 --- a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c +++ b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c @@ -5,6 +5,7 @@ */ #include "z_en_look_nuts.h" +#include "overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.h" #define FLAGS (ACTOR_FLAG_80000000) @@ -340,13 +341,14 @@ void EnLookNuts_Update(Actor* thisx, PlayState* play) { Matrix_MultVec3f(&effectVelOffset, &effectVel); Matrix_Pop(); if (!this->isPlayerDetected) { - s16 drawFlag = 1; + s16 effectFlags = SOLDERSRCHBALL_INVISIBLE; + if (gSaveContext.save.isNight) { - drawFlag = 0; + effectFlags = 0; } if (Player_GetMask(play) != PLAYER_MASK_STONE) { EffectSsSolderSrchBall_Spawn(play, &effectPos, &effectVel, &gZeroVec3f, 50, &this->isPlayerDetected, - drawFlag); + effectFlags); } } 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 bbce2ee6ca..4f3882aa7f 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -7,6 +7,7 @@ #include "z_en_suttari.h" #include "overlays/actors/ovl_En_Elf/z_en_elf.h" #include "overlays/actors/ovl_En_Door/z_en_door.h" +#include "overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.h" #include "objects/object_boj/object_boj.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) @@ -444,12 +445,13 @@ void func_80BAAFDC(EnSuttari* this, PlayState* play) { effectVelOffset.z = 20.0f; Matrix_MultVec3f(&effectVelOffset, &effectVel); Matrix_Pop(); - if (this->unk3F0 == 0) { - EffectSsSolderSrchBall_Spawn(play, &effectPos, &effectVel, &gZeroVec3f, 50, &this->unk3F0, 1); + if (!this->playerDetected) { + EffectSsSolderSrchBall_Spawn(play, &effectPos, &effectVel, &gZeroVec3f, 50, &this->playerDetected, + SOLDERSRCHBALL_INVISIBLE); } - if (this->unk3F0 == 1) { + if (this->playerDetected == true) { play_sound(NA_SE_SY_FOUND); - this->unk3F0 = 0; + this->playerDetected = false; this->actor.speedXZ = 0.0f; if (this->unk1F4[0] != 0) { this->unk1F4[0]--; @@ -476,12 +478,13 @@ void func_80BAB1A0(EnSuttari* this, PlayState* play) { effectVelOffset.z = 20.0f; Matrix_MultVec3f(&effectVelOffset, &effectVel); Matrix_Pop(); - if (this->unk3F0 == 0) { - EffectSsSolderSrchBall_Spawn(play, &effectPos, &effectVel, &gZeroVec3f, 50, &this->unk3F0, 1); + if (!this->playerDetected) { + EffectSsSolderSrchBall_Spawn(play, &effectPos, &effectVel, &gZeroVec3f, 50, &this->playerDetected, + SOLDERSRCHBALL_INVISIBLE); } - if (this->unk3F0 == 1) { + if (this->playerDetected == true) { play_sound(NA_SE_SY_FOUND); - this->unk3F0 = 0; + this->playerDetected = false; this->actor.speedXZ = 0.0f; if (this->unk1F4[0] != 0) { this->unk1F4[0]--; 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 35a9b6e2e4..427f74988f 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h @@ -34,7 +34,7 @@ typedef struct EnSuttari { /* 0x2FA */ s16 unk2FA[16]; /* 0x31A */ s16 unk31A[16]; /* 0x33A */ UNK_TYPE1 unk_33A[0xB6]; - /* 0x3F0 */ s16 unk3F0; + /* 0x3F0 */ s16 playerDetected; /* 0x3F2 */ s16 unk3F2; /* 0x3F4 */ s16 unk3F4; /* 0x3F6 */ s16 unk3F6; diff --git a/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.c b/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.c index 04afcba3f5..01224dd329 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.c +++ b/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.c @@ -1,27 +1,93 @@ /* * File: z_eff_ss_solder_srch_ball.c * Overlay: ovl_Effect_Ss_Solder_Srch_Ball - * Description: + * Description: Vision sphere */ #include "z_eff_ss_solder_srch_ball.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rFlags regs[0] #define PARAMS ((EffectSsSolderSrchBallInitParams*)initParamsx) -s32 EffectSsSolderSrchBall_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsSolderSrchBall_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); void EffectSsSolderSrchBall_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsSolderSrchBall_Draw(PlayState* play, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Solder_Srch_Ball_InitVars = { EFFECT_SS_SOLDER_SRCH_BALL, EffectSsSolderSrchBall_Init, }; -#endif +u32 EffectSsSolderSrchBall_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { + EffectSsSolderSrchBallInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Solder_Srch_Ball/EffectSsSolderSrchBall_Init.s") + this->pos = initParams->pos; + this->velocity = initParams->velocity; + this->accel = initParams->accel; + this->update = EffectSsSolderSrchBall_Update; + if (!(initParams->flags & SOLDERSRCHBALL_INVISIBLE)) { + this->draw = EffectSsSolderSrchBall_Draw; + } + this->life = 10; + this->rgScale = initParams->scale; + this->rFlags = initParams->flags; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Solder_Srch_Ball/EffectSsSolderSrchBall_Draw.s") + //! @bug actor field used to store an s16* + // This bug is purely cosmetic. Nothing external will ever read this as an Actor, so there are no unintended + // side-effects. + this->actor = (Actor*)initParams->playerDetected; + return 1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Solder_Srch_Ball/EffectSsSolderSrchBall_Update.s") +void EffectSsSolderSrchBall_Draw(PlayState* play, u32 index, EffectSs* this) { + s32 pad; + GraphicsContext* gfxCtx = play->state.gfxCtx; + f32 scale = this->rgScale / 100.0f; + + func_8012C28C(gfxCtx); + func_8012C2DC(play->state.gfxCtx); + + OPEN_DISPS(gfxCtx); + + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 20); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gSun1Tex)); + gSPDisplayList(POLY_XLU_DISP++, gSunSparkleMaterialDL); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 250, 180, 255, 255); + Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZF(DEGF_TO_RADF(20.0f * play->state.frames), MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gSunSparkleModelDL); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsSolderSrchBall_Update(PlayState* play, u32 index, EffectSs* this) { + s32 pad; + f32 diffX; + f32 diffY; + f32 diffZ; + s16* playerDetected = (s16*)this->actor; + Player* player = GET_PLAYER(play); + + diffX = player->actor.world.pos.x - this->pos.x; + diffY = player->actor.world.pos.y - this->pos.y; + diffZ = player->actor.world.pos.z - this->pos.z; + + if (this->rFlags >= SOLDERSRCHBALL_SMALL_DETECT_RADIUS) { + if ((sqrtf(SQ(diffX) + SQ(diffZ)) < 10.0f) && (sqrtf(SQ(diffY)) < 10.0f)) { + *playerDetected = true; + } + } else if (!BgCheck_SphVsFirstWall(&play->colCtx, &this->pos, 30.0f)) { + if ((sqrtf(SQ(diffX) + SQ(diffZ)) < 40.0f) && (sqrtf(SQ(diffY)) < 80.0f)) { + *playerDetected = true; + } + } else if (this->life > 1) { + this->life = 1; + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.h b/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.h index 24b9f47fcc..fb4fb4159c 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.h +++ b/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.h @@ -3,13 +3,16 @@ #include "global.h" +#define SOLDERSRCHBALL_INVISIBLE (1 << 0) +#define SOLDERSRCHBALL_SMALL_DETECT_RADIUS (1 << 1) + typedef struct { /* 0x00 */ Vec3f pos; /* 0x0C */ Vec3f velocity; /* 0x18 */ Vec3f accel; - /* 0x24 */ s16 unused; - /* 0x28 */ s16* linkDetected; - /* 0x2C */ s16 drawFlag; + /* 0x24 */ s16 scale; + /* 0x28 */ s16* playerDetected; + /* 0x2C */ s16 flags; } EffectSsSolderSrchBallInitParams; // size = 0x30 extern const EffectSsInit Effect_Ss_Solder_Srch_Ball_InitVars; From 0e2de439dd2882bb4e3585d918e040ba18b55b41 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sun, 2 Oct 2022 19:31:55 +0100 Subject: [PATCH 18/25] Dm_Tag (#922) * Dm_Tag * PR * Fix * PR * PR --- spec | 3 +- src/overlays/actors/ovl_Dm_Tag/z_dm_tag.c | 235 ++++++++++++++++++++-- src/overlays/actors/ovl_Dm_Tag/z_dm_tag.h | 11 +- 3 files changed, 230 insertions(+), 19 deletions(-) diff --git a/spec b/spec index 2dce298d5b..4dec1f2289 100644 --- a/spec +++ b/spec @@ -5029,8 +5029,7 @@ beginseg name "ovl_Dm_Tag" compress include "build/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.o" - include "build/data/ovl_Dm_Tag/ovl_Dm_Tag.data.o" - include "build/data/ovl_Dm_Tag/ovl_Dm_Tag.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Tag/ovl_Dm_Tag_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.c b/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.c index b74c43940e..2c8bf046f5 100644 --- a/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.c +++ b/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.c @@ -18,7 +18,6 @@ void func_80C229AC(DmTag* this, PlayState* play); void func_80C229EC(DmTag* this, PlayState* play); void func_80C229FC(DmTag* this, PlayState* play); -#if 0 const ActorInit Dm_Tag_InitVars = { ACTOR_DM_TAG, ACTORCAT_ITEMACTION, @@ -31,30 +30,236 @@ const ActorInit Dm_Tag_InitVars = { (ActorFunc)NULL, }; -#endif +s32 D_80C22BF0[] = { + 0x0E28F00C, + 0x15090000, + 0x10000000, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/func_80C22350.s") +s32 D_80C22BFC[] = { + 0x0900000E, 0x28F10C09, 0x00000E28, 0xF20C0900, 0x000E28F3, 0x0C090000, 0x0E28F40C, + 0x0900000E, 0x28F50C09, 0x00000E28, 0xF60C1511, 0x55040900, 0x00100000, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/func_80C22400.s") +s32 D_80C22C30[] = { + 0x0E28EF0C, + 0x10000000, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/func_80C2247C.s") +Actor* func_80C22350(DmTag* this, PlayState* play, u8 actorCat, s16 actorId) { + Actor* foundActor = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/func_80C224D8.s") + while (true) { + foundActor = SubS_FindActor(play, foundActor, actorCat, actorId); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/func_80C227E8.s") + if ((foundActor == NULL) || (((this != (DmTag*)foundActor)) && (foundActor->update != NULL))) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/func_80C22880.s") + if (foundActor->next == NULL) { + foundActor = NULL; + break; + } + foundActor = foundActor->next; + } + return foundActor; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/func_80C2291C.s") +s32 func_80C22400(DmTag* this, s16 arg1) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/func_80C229AC.s") + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(arg1); + } else if (ActorCutscene_GetCanPlayNext(arg1)) { + ActorCutscene_StartAndSetUnkLinkFields(arg1, &this->actor); + ret = true; + } else { + ActorCutscene_SetIntentToPlay(arg1); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/func_80C229EC.s") +s16 func_80C2247C(DmTag* this, s32 arg1) { + s32 i; + s16 cs = this->actor.cutscene; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/func_80C229FC.s") + for (i = 0; i < arg1; i++) { + cs = ActorCutscene_GetAdditionalCutscene(cs); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/DmTag_Init.s") + return cs; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/DmTag_Destroy.s") +s32 func_80C224D8(DmTag* this, PlayState* play) { + s32 pad; + Actor* sp30; + Actor* sp2C; + s16 sp2A = this->actor.cutscene; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/DmTag_Update.s") + sp30 = func_80C22350(this, play, ACTORCAT_NPC, ACTOR_EN_AN); + sp2C = func_80C22350(this, play, ACTORCAT_NPC, ACTOR_EN_AH); + + switch (this->unk_1A4) { + case 0: + if (func_80C22400(this, sp2A)) { + if ((sp2C != NULL) && (sp2C->update != NULL)) { + Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp2A)), sp2C); + } + this->unk_1A4++; + ret = true; + } + break; + + case 1: + if ((sp30 != NULL) && (sp30->update != NULL)) { + Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(func_80C2247C(this, 0))), + sp30); + } + this->unk_1A4++; + ret = true; + break; + + case 2: + ActorCutscene_Stop(func_80C2247C(this, 0)); + if (func_80C22400(this, func_80C2247C(this, 1))) { + this->unk_1A4++; + ret = true; + } + break; + + case 3: + ActorCutscene_Stop(func_80C2247C(this, 1)); + if (func_80C22400(this, func_80C2247C(this, 2))) { + this->unk_1A4++; + ret = true; + } + break; + + case 4: + ActorCutscene_Stop(func_80C2247C(this, 2)); + if (func_80C22400(this, func_80C2247C(this, 3))) { + this->unk_1A4++; + ret = true; + } + break; + + case 5: + ActorCutscene_Stop(func_80C2247C(this, 3)); + if (func_80C22400(this, func_80C2247C(this, 4))) { + this->unk_1A4++; + ret = true; + } + break; + + case 6: + func_800B7298(play, &this->actor, 7); + play->nextEntrance = ENTRANCE(STOCK_POT_INN, 5); + gSaveContext.nextCutsceneIndex = 0; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_02; + gSaveContext.nextTransitionType = TRANS_TYPE_06; + this->unk_1A4++; + break; + } + return ret; +} + +s32 func_80C227E8(DmTag* this, PlayState* play) { + if (this->unk_1A4 == 0) { + func_800B7298(play, &this->actor, 7); + play->nextEntrance = ENTRANCE(STOCK_POT_INN, 4); + gSaveContext.nextCutsceneIndex = 0; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_02; + gSaveContext.nextTransitionType = TRANS_TYPE_06; + this->unk_1A4++; + } + return false; +} + +s32* func_80C22880(DmTag* this, PlayState* play) { + s32 time; + + switch (this->unk_18E) { + case 1: + time = gSaveContext.save.time - 0x3FFC; + if ((time >= 0xA54B) && (time < 0xB54A) && (gSaveContext.save.day == 2)) { + this->msgEventCallback = func_80C227E8; + return D_80C22BF0; + } + return D_80C22C30; + case 2: + this->msgEventCallback = func_80C224D8; + return D_80C22BFC; + } + return NULL; +} + +s32 func_80C2291C(DmTag* this, PlayState* play) { + s32 ret = false; + + if (this->unk_18C & 7) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + this->unk_18C |= 8; + SubS_UpdateFlags(&this->unk_18C, 0, 7); + this->msgEventScript = func_80C22880(this, play); + this->actionFunc = func_80C229FC; + ret = true; + } + } + return ret; +} + +void func_80C229AC(DmTag* this, PlayState* play) { + SubS_UpdateFlags(&this->unk_18C, 3, 7); + this->actor.flags |= ACTOR_FLAG_1; +} + +void func_80C229EC(DmTag* this, PlayState* play) { +} + +void func_80C229FC(DmTag* this, PlayState* play) { + if (func_8010BF58(&this->actor, play, this->msgEventScript, this->msgEventCallback, &this->msgEventArg4)) { + this->actionFunc = func_80C229AC; + } +} + +void DmTag_Init(Actor* thisx, PlayState* play) { + DmTag* this = (DmTag*)thisx; + Player* player = GET_PLAYER(play); + + if (gSaveContext.save.weekEventReg[85] & 4) { + Actor_MarkForDeath(&this->actor); + return; + } + + if ((play->sceneId == SCENE_YADOYA) && (play->curSpawn == 4)) { + player->stateFlags1 |= PLAYER_STATE1_20; + this->unk_18E = 2; + this->unk_18C = 0; + SubS_UpdateFlags(&this->unk_18C, 4, 7); + this->actor.flags &= ~ACTOR_FLAG_1; + this->actionFunc = func_80C229EC; + } else if (this->actor.room == 2) { + Actor_MarkForDeath(&this->actor); + } else { + this->actor.targetMode = 1; + this->unk_18E = 1; + this->unk_18C = 0; + this->actionFunc = func_80C229AC; + } +} + +void DmTag_Destroy(Actor* thisx, PlayState* play) { +} + +void DmTag_Update(Actor* thisx, PlayState* play) { + DmTag* this = THIS; + + func_80C2291C(this, play); + this->actionFunc(this, play); + func_8013C964(&this->actor, play, 40.0f, fabsf(this->actor.playerHeightRel) + 1.0f, 0, this->unk_18C & 7); + Actor_SetFocus(&this->actor, 0.0f); +} diff --git a/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.h b/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.h index fda9397c7b..d68cd38d44 100644 --- a/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.h +++ b/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.h @@ -6,12 +6,19 @@ struct DmTag; typedef void (*DmTagActionFunc)(struct DmTag*, PlayState*); +typedef s32 (*DmTagMsgEventFunc)(struct DmTag*, PlayState*); typedef struct DmTag { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x44]; + /* 0x144 */ UNK_TYPE1 pad144[0x44]; /* 0x188 */ DmTagActionFunc actionFunc; - /* 0x18C */ char unk_18C[0x20]; + /* 0x18C */ u16 unk_18C; + /* 0x18E */ u8 unk_18E; + /* 0x190 */ s32* msgEventScript; + /* 0x194 */ s32 msgEventArg4; + /* 0x198 */ UNK_TYPE1 pad198[0xC]; + /* 0x1A4 */ s16 unk_1A4; + /* 0x1A8 */ DmTagMsgEventFunc msgEventCallback; } DmTag; // size = 0x1AC extern const ActorInit Dm_Tag_InitVars; From 3e32379c2bbce332dae9675954e28387480128f0 Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Sun, 2 Oct 2022 15:24:10 -0400 Subject: [PATCH 19/25] audio_synthesis.c OK and Documented (#1090) * import synth docs * cleanup * small followup cleanup * PR Suggestions, small cleanup * fix bss * PR suggestion * fix enum * PR Suggestions --- include/PR/abi.h | 91 +- include/functions.h | 43 +- include/variables.h | 34 +- include/z64audio.h | 312 +-- spec | 1 - src/code/audio/audio_data.c | 93 +- src/code/audio/audio_heap.c | 264 +-- src/code/audio/audio_init_params.c | 182 +- src/code/audio/audio_load.c | 6 +- src/code/audio/audio_playback.c | 202 +- src/code/audio/audio_seqplayer.c | 49 +- src/code/audio/audio_synthesis.c | 1807 +++++++++++++++-- src/code/audio/code_8019AF00.c | 2 +- src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c | 1 - tools/disasm/files.txt | 1 + tools/disasm/functions.txt | 138 +- tools/disasm/variables.txt | 18 +- tools/sizes/code_functions.csv | 138 +- 18 files changed, 2612 insertions(+), 770 deletions(-) diff --git a/include/PR/abi.h b/include/PR/abi.h index 49d5397628..15ae5d9115 100644 --- a/include/PR/abi.h +++ b/include/PR/abi.h @@ -53,6 +53,7 @@ #define A_INIT 0x01 #define A_CONTINUE 0x00 #define A_LOOP 0x02 +#define A_ADPCM_SHORT 0x04 #define A_OUT 0x02 #define A_LEFT 0x02 #define A_RIGHT 0x00 @@ -331,13 +332,20 @@ typedef short ENVMIX_STATE[40]; _a->words.w1 = (unsigned int)(a2); \ } -#define aClearBuffer(pkt, d, c) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_CLEARBUFF, 24, 8) | _SHIFTL(d, 0, 24); \ - _a->words.w1 = (unsigned int)(c); \ -} +/* + * Clears DMEM by writing zeros. + * + * @param pkt pointer to an Acmd buffer + * @param dmem DMEM address to clear + * @param size number of bytes to clear (rounded up to the next multiple of 16) + */ +#define aClearBuffer(pkt, dmem, size) \ + { \ + Acmd* _a = (Acmd*)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_CLEARBUFF, 24, 8) | _SHIFTL(dmem, 0, 24); \ + _a->words.w1 = (uintptr_t)(size); \ + } #define aEnvMixer(pkt, dmemi, count, swapLR, x0, x1, x2, x3, m, bits) \ { \ @@ -368,14 +376,21 @@ typedef short ENVMIX_STATE[40]; _a->words.w1 = _SHIFTL(dmemi, 16, 16) | _SHIFTL(dmemo, 0, 16); \ } -#define aLoadBuffer(pkt, s, d, c) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_LOADBUFF, 24, 8) | \ - _SHIFTL((c) >> 4, 16, 8) | _SHIFTL(d, 0, 16); \ - _a->words.w1 = (unsigned int)(s); \ -} +/* + * Loads a buffer to DMEM from any physical source address, KSEG0, or KSEG1 + * + * @param pkt pointer to an Acmd buffer + * @param addrSrc Any physical source address, KSEG0, or KSEG1 + * @param dmemDest DMEM destination address + * @param size number of bytes to copy (rounded down to the next multiple of 16) + */ +#define aLoadBuffer(pkt, addrSrc, dmemDest, size) \ + { \ + Acmd* _a = (Acmd*)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_LOADBUFF, 24, 8) | _SHIFTL((size) >> 4, 16, 8) | _SHIFTL(dmemDest, 0, 16)); \ + _a->words.w1 = (uintptr_t)(addrSrc); \ + } #define aMix(pkt, f, g, i, o) \ { \ @@ -404,14 +419,21 @@ typedef short ENVMIX_STATE[40]; _a->words.w1 = (unsigned int)(s); \ } -#define aSaveBuffer(pkt, s, d, c) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_SAVEBUFF, 24, 8) | \ - _SHIFTL((c) >> 4, 16, 8) | _SHIFTL(s, 0, 16); \ - _a->words.w1 = (unsigned int)(d); \ -} +/* + * Stores a buffer from DMEM to any physical source address, KSEG0, or KSEG1 + * + * @param pkt pointer to an Acmd buffer + * @param dmemSrc DMEM source address + * @param addrDest Any physical source address, KSEG0, or KSEG1 + * @param size number of bytes to copy (rounded down to the next multiple of 16) + */ +#define aSaveBuffer(pkt, dmemSrc, addrDest, size) \ + { \ + Acmd* _a = (Acmd*)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_SAVEBUFF, 24, 8) | _SHIFTL((size) >> 4, 16, 8) | _SHIFTL(dmemSrc, 0, 16)); \ + _a->words.w1 = (uintptr_t)(addrDest); \ + } #define aSegment(pkt, s, b) \ { \ @@ -501,14 +523,21 @@ typedef short ENVMIX_STATE[40]; _a->words.w1 = (unsigned int)(addr); \ } -#define aDuplicate(pkt, count, dmemi, dmemo, a4) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_DUPLICATE, 24, 8) | \ - _SHIFTL(count, 16, 8) | _SHIFTL(dmemi, 0, 16)); \ - _a->words.w1 = _SHIFTL(dmemo, 16, 16) | _SHIFTL(a4, 0, 16); \ -} +/* + * Duplicates 128 bytes of data a specified number of times. + * + * @param pkt pointer to an Acmd buffer + * @param numCopies number of times to duplicate 128 bytes from src + * @param dmemSrc DMEM source address + * @param dmemDest DMEM destination address for the duplicates, size 128 * numCopies + */ +#define aDuplicate(pkt, numCopies, dmemSrc, dmemDest) \ + { \ + Acmd* _a = (Acmd*)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_DUPLICATE, 24, 8) | _SHIFTL(numCopies, 16, 8) | _SHIFTL(dmemSrc, 0, 16)); \ + _a->words.w1 = _SHIFTL(dmemDest, 16, 16) | _SHIFTL(0x80, 0, 16); \ + } #define aAddMixer(pkt, count, dmemi, dmemo, a4) \ { \ diff --git a/include/functions.h b/include/functions.h index 9d21eca01c..d42733a145 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2897,48 +2897,7 @@ s32 osFlashWriteBuffer(OSIoMesg* mb, s32 priority, void* dramAddr, OSMesgQueue* s32 osFlashWriteArray(u32 pageNum); s32 osFlashReadArray(OSIoMesg* mb, s32 priority, u32 pageNum, void* dramAddr, u32 pageCount, OSMesgQueue* mq); -// void func_801877D0(void); -// void func_80187B64(void); -// void func_80187BEC(void); -// void func_80187DE8(void); -// void func_80187E58(void); -// void func_80187F00(void); -// void func_80187FB0(void); -// void func_80187FE8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80188034(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80188078(void); -// void func_801880C4(void); -// void func_801880E8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80188124(void); -// void func_8018814C(void); -// void func_80188174(void); -// void func_801881A8(void); -// void func_801881C4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_801881F8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80188264(void); -// void func_80188288(void); -// void func_801882A0(void); -// void func_80188304(void); -// void func_801884A0(void); -// void func_80188698(void); -// void func_8018883C(void); -// void func_801888E4(void); -// void func_801889A4(void); -// void func_80188A50(void); -// void func_80188AFC(void); -// void func_80188C48(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80188CB4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80188D28(void); -// void func_80188D68(void); -// void func_80188DDC(void); -// void func_80188FBC(void); -// void func_80189064(void); -// void func_80189620(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -// void func_8018A4B4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -// void func_8018A768(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE4 param_6); -// void func_8018A808(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE4 param_6); -// void func_8018ACC4(void); -// void func_8018AE34(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); +Acmd* AudioSynth_Update(Acmd* cmdStart, s32* numAbiCmds, s16* aiStart, s32 aiBufLen); void AudioHeap_DiscardFont(s32 fontId); void* AudioHeap_WritebackDCache(void* addr, size_t size); diff --git a/include/variables.h b/include/variables.h index ae97a6c51e..a4914a4413 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1557,11 +1557,11 @@ extern f32 gPitchFrequencies[]; extern u8 gDefaultShortNoteVelocityTable[]; extern u8 gDefaultShortNoteGateTimeTable[]; extern EnvelopePoint gDefaultEnvelope[]; -extern NoteSubEu gZeroNoteSub; -extern NoteSubEu gDefaultNoteSub; -extern u16 gHeadsetPanQuantization[]; -extern u16 gHeadsetPanQuantization[]; -extern s16 D_801D58A8[]; +extern NoteSampleState gZeroedSampleState; +extern NoteSampleState gDefaultSampleState; +extern u16 gHaasEffectDelaySize[]; +extern u16 gHaasEffectDelaySize[]; +extern s16 gInvalidAdpcmCodeBook[]; extern f32 gHeadsetPanVolume[]; extern f32 gStereoPanVolume[]; extern f32 gDefaultPanVolume[]; @@ -1721,21 +1721,7 @@ extern s8 gSfxDefaultReverb; extern u8 gAudioSpecId; // extern UNK_TYPE1 D_801DB4D8; // extern UNK_TYPE4 D_801DB4DC; -// extern UNK_TYPE1 D_801DB4E0; -// extern UNK_TYPE1 D_801DB528; -// extern UNK_TYPE1 D_801DB570; -// extern UNK_TYPE1 D_801DB5B8; -// extern UNK_TYPE1 D_801DB600; -// extern UNK_TYPE1 D_801DB648; -// extern UNK_TYPE1 D_801DB690; -// extern UNK_TYPE1 D_801DB6D8; -// extern UNK_TYPE1 D_801DB720; -// extern UNK_TYPE1 D_801DB750; -// extern UNK_TYPE1 D_801DB798; -// extern UNK_TYPE1 D_801DB870; -// extern UNK_TYPE1 D_801DB8B8; -// extern UNK_TYPE1 D_801DB900; -extern UNK_PTR D_801DB930; +extern ReverbSettings* gReverbSettingsTable[]; extern AudioSpec gAudioSpecs[21]; // rodata @@ -3483,10 +3469,10 @@ extern ActiveSequence gActiveSeqs[]; // extern UNK_TYPE1 D_80200BCE; // extern UNK_TYPE1 D_80200BD0; extern AudioContext gAudioContext; // at 0x80200C70 -extern void (*D_80208E68)(void); -extern u32 (*D_80208E6C)(s8 value, SequenceChannel* channel); -extern s32 (*D_80208E70)(Sample*, s32, s8, s32); -extern Acmd* (*D_80208E74)(Acmd*, s32, s32); +extern void (*gCustomAudioUpdateFunction)(void); +extern u32 (*gCustomAudioSeqFunction)(s8 value, SequenceChannel* channel); +extern s32 (*gCustomAudioReverbFunction)(Sample*, s32, s8, s32); +extern Acmd* (*gCustomAudioSynthFunction)(Acmd*, s32, s32); // post-code buffers extern u8 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE]; diff --git a/include/z64audio.h b/include/z64audio.h index c5045e34ff..264e8d9e3b 100644 --- a/include/z64audio.h +++ b/include/z64audio.h @@ -1,7 +1,7 @@ #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 AUDIO_MK_CMD(b0,b1,b2,b3) ((((b0) & 0xFF) << 0x18) | (((b1) & 0xFF) << 0x10) | (((b2) & 0xFF) << 0x8) | (((b3) & 0xFF) << 0)) #define NO_LAYER ((SequenceLayer*)(-1)) @@ -32,13 +32,45 @@ typedef enum { #define ADSR_GOTO -2 #define ADSR_RESTART -3 -#define AIBUF_LEN 0x580 +// size of a single sample point +#define SAMPLE_SIZE sizeof(s16) + +// Samples are processed in groups of 16 called a "frame" +#define SAMPLES_PER_FRAME ADPCMFSIZE + +// The length of one left/right channel is 13 frames +#define DMEM_1CH_SIZE (13 * SAMPLES_PER_FRAME * SAMPLE_SIZE) +// Both left and right channels +#define DMEM_2CH_SIZE (2 * DMEM_1CH_SIZE) + +#define AIBUF_LEN (88 * SAMPLES_PER_FRAME) // number of samples +#define AIBUF_SIZE (AIBUF_LEN * SAMPLE_SIZE) // number of bytes + +// Filter sizes +#define FILTER_SIZE (8 * SAMPLE_SIZE) +#define FILTER_BUF_PART1 (8 * SAMPLE_SIZE) +#define FILTER_BUF_PART2 (8 * SAMPLE_SIZE) // Must be the same amount of samples as copied by aDuplicate() (audio microcode) #define WAVE_SAMPLE_COUNT 64 #define AUDIO_RELOCATED_ADDRESS_START K0BASE +#define REVERB_INDEX_NONE -1 + +typedef enum { + /* 0 */ REVERB_DATA_TYPE_SETTINGS, // Reverb Settings (Init) + /* 1 */ REVERB_DATA_TYPE_DELAY, // Reverb Delay (numSamples) + /* 2 */ REVERB_DATA_TYPE_DECAY, // Reverb Decay Ratio + /* 3 */ REVERB_DATA_TYPE_SUB_VOLUME, // Reverb Sub-Volume + /* 4 */ REVERB_DATA_TYPE_VOLUME, // Reverb Volume + /* 5 */ REVERB_DATA_TYPE_LEAK_RIGHT, // Reverb Leak Right Channel + /* 6 */ REVERB_DATA_TYPE_LEAK_LEFT, // Reverb Leak Left Channel + /* 7 */ REVERB_DATA_TYPE_FILTER_LEFT, // Reverb Left Filter + /* 8 */ REVERB_DATA_TYPE_FILTER_RIGHT, // Reverb Right Filter + /* 9 */ REVERB_DATA_TYPE_9 // Reverb Unk +} ReverbDataType; + typedef enum { /* 0x1 */ AUDIO_ERROR_NO_INST = 1, /* 0x3 */ AUDIO_ERROR_INVALID_INST_ID = 3, @@ -78,12 +110,14 @@ typedef enum { } SampleMedium; typedef enum { - /* 0 */ CODEC_ADPCM, - /* 1 */ CODEC_S8, + /* 0 */ CODEC_ADPCM, // 16 2-byte samples (32 bytes) compressed into 4-bit samples (8 bytes) + 1 header byte + /* 1 */ CODEC_S8, // 16 2-byte samples (32 bytes) compressed into 8-bit samples (16 bytes) /* 2 */ CODEC_S16_INMEMORY, - /* 3 */ CODEC_SMALL_ADPCM, + /* 3 */ CODEC_SMALL_ADPCM, // 16 2-byte samples (32 bytes) compressed into 2-bit samples (4 bytes) + 1 header byte /* 4 */ CODEC_REVERB, - /* 5 */ CODEC_S16 + /* 5 */ CODEC_S16, + /* 6 */ CODEC_UNK6, + /* 7 */ CODEC_UNK7 // processed as uncompressed samples } SampleCodec; typedef enum { @@ -165,24 +199,28 @@ typedef struct { typedef struct { /* 0x00 */ u32 start; - /* 0x04 */ u32 end; + /* 0x04 */ u32 loopEnd; // numSamples into the sample where the loop ends /* 0x08 */ u32 count; - /* 0x0C */ u32 unk_0C; - /* 0x10 */ s16 state[16]; // only exists if count != 0. 8-byte aligned + /* 0x0C */ u32 sampleEnd; // total number of s16-samples in the + /* 0x10 */ s16 predictorState[16]; // only exists if count != 0. 8-byte aligned } AdpcmLoop; // size = 0x30 (or 0x10) +/** + * The procedure used to design the codeBook is based on an adaptive clustering algorithm. + * The size of the codeBook is (8 * order * numPredictors) and is 8-byte aligned + */ typedef struct { /* 0x00 */ s32 order; - /* 0x04 */ s32 npredictors; - /* 0x08 */ s16 book[1]; // size 8 * order * npredictors. 8-byte aligned + /* 0x04 */ s32 numPredictors; + /* 0x08 */ s16 codeBook[1]; // a table of prediction coefficients that the coder selects from to optimize sound quality. } AdpcmBook; // size >= 0x8 typedef struct { /* 0x00 */ u32 unk_0 : 1; /* 0x00 */ u32 codec : 3; // The state of compression or decompression /* 0x00 */ u32 medium : 2; // Medium where sample is currently stored - /* 0x00 */ u32 unk_bit26 : 1; // Has the sample header been relocated (offsets to pointers) - /* 0x00 */ u32 isRelocated : 1; // Size of the sample + /* 0x00 */ u32 unk_bit26 : 1; + /* 0x00 */ u32 isRelocated : 1; // Has the sample header been relocated (offsets to pointers) /* 0x01 */ u32 size : 24; // Size of the sample /* 0x04 */ u8* sampleAddr; // Raw sample data. Offset from the start of the sample bank or absolute address to either rom or ram /* 0x08 */ AdpcmLoop* loop; // Adpcm loop parameters used by the sample. Offset from the start of the sound font / pointer to ram @@ -194,18 +232,23 @@ typedef struct { /* 0x04 */ f32 tuning; // frequency scale factor } TunedSample; // size = 0x8 +/** + * Stores an entry of decompressed samples in a reverb ring buffer. + * By storing the sample in a ring buffer, the time it takes to loop + * around back to the same sample acts as a delay, leading to an echo effect. + */ typedef struct { /* 0x00 */ s16 numSamplesAfterDownsampling; // never read - /* 0x02 */ s16 chunkLen; // never read + /* 0x02 */ s16 numSamples; // never read /* 0x04 */ s16* toDownsampleLeft; /* 0x08 */ s16* toDownsampleRight; // data pointed to by left and right are adjacent in memory /* 0x0C */ s32 startPos; // start pos in ring buffer - /* 0x10 */ s16 lengthA; // first length in ring buffer (from startPos, at most until end) - /* 0x12 */ s16 lengthB; // second length in ring buffer (from pos 0) - /* 0x14 */ u16 unk_14; - /* 0x16 */ u16 unk_16; - /* 0x18 */ u16 unk_18; -} ReverbRingBufferItem; // size = 0x1C + /* 0x10 */ s16 size; // first length in ring buffer (from startPos, at most until end) + /* 0x12 */ s16 wrappedSize; // second length in ring buffer (from pos 0) + /* 0x14 */ u16 loadResamplePitch; + /* 0x16 */ u16 saveResamplePitch; + /* 0x18 */ u16 saveResampleNumSamples; +} ReverbBufferEntry; // size = 0x1C typedef struct { /* 0x000 */ u8 resampleFlags; @@ -213,35 +256,35 @@ typedef struct { /* 0x002 */ u8 framesToIgnore; /* 0x003 */ u8 curFrame; /* 0x004 */ u8 downsampleRate; - /* 0x005 */ s8 unk_05; - /* 0x006 */ u16 windowSize; - /* 0x008 */ s16 unk_08; - /* 0x00A */ s16 unk_0A; - /* 0x00C */ u16 unk_0C; - /* 0x00E */ u16 unk_0E; + /* 0x005 */ s8 mixReverbIndex; // mix in reverb from this index. set to 0xFF to not mix any + /* 0x006 */ u16 delayNumSamples; // number of samples between echos + /* 0x008 */ s16 mixReverbStrength; // the gain/amount to mix in reverb from mixReverbIndex + /* 0x00A */ s16 volume; + /* 0x00C */ u16 decayRatio; // determines how fast reverb dissipate + /* 0x00E */ u16 downsamplePitch; /* 0x010 */ s16 leakRtl; /* 0x012 */ s16 leakLtr; - /* 0x014 */ u16 unk_14; - /* 0x016 */ s16 unk_16; - /* 0x018 */ u8 unk_18; - /* 0x019 */ s8 unk_19; - /* 0x01A */ u16 unk_1A; - /* 0x01C */ u16 unk_1C; - /* 0x01E */ u8 unk_1E; - /* 0x020 */ s32 nextRingBufPos; - /* 0x024 */ s32 unk_24; // May be bufSizePerChan - /* 0x028 */ s16* leftRingBuf; - /* 0x02C */ s16* rightRingBuf; - /* 0x030 */ void* unk_30; - /* 0x034 */ void* unk_34; - /* 0x038 */ void* unk_38; - /* 0x03C */ void* unk_3C; - /* 0x040 */ ReverbRingBufferItem items[2][5]; - /* 0x158 */ ReverbRingBufferItem items2[2][5]; + /* 0x014 */ u16 subDelay; // number of samples between sub echos + /* 0x016 */ s16 subVolume; // strength of the sub echos + /* 0x018 */ u8 resampleEffectOn; + /* 0x019 */ s8 resampleEffectExtraSamples; + /* 0x01A */ u16 resampleEffectLoadUnk; + /* 0x01C */ u16 resampleEffectSaveUnk; + /* 0x01E */ u8 delayNumSamplesAfterDownsampling; + /* 0x020 */ s32 nextReverbBufPos; + /* 0x024 */ s32 delayNumSamplesUnk; // May be bufSizePerChan + /* 0x028 */ s16* leftReverbBuf; + /* 0x02C */ s16* rightReverbBuf; + /* 0x030 */ s16* leftLoadResampleBuf; + /* 0x034 */ s16* rightLoadResampleBuf; + /* 0x038 */ s16* leftSaveResampleBuf; + /* 0x03C */ s16* rightSaveResampleBuf; + /* 0x040 */ ReverbBufferEntry bufEntry[2][5]; + /* 0x158 */ ReverbBufferEntry subBufEntry[2][5]; /* 0x270 */ s16* filterLeft; /* 0x274 */ s16* filterRight; - /* 0x278 */ s16* unk_278; - /* 0x27C */ s16* unk_27C; + /* 0x278 */ s16* filterLeftInit; + /* 0x27C */ s16* filterRightInit; /* 0x280 */ s16* filterLeftState; /* 0x284 */ s16* filterRightState; /* 0x288 */ TunedSample tunedSample; @@ -363,28 +406,26 @@ typedef struct { /* 0x1C */ EnvelopePoint* envelope; } AdsrState; // size = 0x20 -typedef struct { - /* 0x0 */ u8 unused : 2; - /* 0x0 */ u8 bit2 : 2; - /* 0x0 */ u8 strongRight : 1; - /* 0x0 */ u8 strongLeft : 1; - /* 0x0 */ u8 stereoHeadsetEffects : 1; - /* 0x0 */ u8 usesHeadsetPanEffects : 1; +typedef union { + struct { + /* 0x0 */ u8 unused : 2; + /* 0x0 */ u8 type : 2; + /* 0x0 */ u8 strongRight : 1; + /* 0x0 */ u8 strongLeft : 1; + /* 0x0 */ u8 strongReverbRight : 1; + /* 0x0 */ u8 strongReverbLeft : 1; + }; + /* 0x0 */ u8 asByte; } StereoData; // size = 0x1 -typedef union { - /* 0x0 */ StereoData s; - /* 0x0 */ u8 asByte; -} Stereo; // size = 0x1 - typedef struct { - /* 0x00 */ u8 reverb; + /* 0x00 */ u8 targetReverbVol; /* 0x01 */ u8 gain; // Increases volume by a multiplicative scaling factor. Represented as a UQ4.4 number /* 0x02 */ u8 pan; - /* 0x03 */ u8 unk_3; // Possibly part of stereo? - /* 0x04 */ Stereo stereo; - /* 0x05 */ u8 unk_4; - /* 0x06 */ u16 unk_6; + /* 0x03 */ u8 surroundEffectIndex; + /* 0x04 */ StereoData stereoData; + /* 0x05 */ u8 combFilterSize; + /* 0x06 */ u16 combFilterGain; /* 0x08 */ f32 freqScale; /* 0x0C */ f32 velocity; /* 0x10 */ s16* filter; @@ -421,7 +462,7 @@ typedef struct SequenceChannel { } changes; /* 0x02 */ u8 noteAllocPolicy; /* 0x03 */ u8 muteFlags; - /* 0x04 */ u8 reverb; // or dry/wet mix + /* 0x04 */ u8 targetReverbVol; // or dry/wet mix /* 0x05 */ u8 notePriority; // 0-3 /* 0x06 */ u8 someOtherPriority; /* 0x07 */ u8 fontId; @@ -432,12 +473,12 @@ typedef struct SequenceChannel { /* 0x0C */ u8 gain; // Increases volume by a multiplicative scaling factor. Represented as a UQ4.4 number /* 0x0D */ u8 velocityRandomVariance; /* 0x0E */ u8 gateTimeRandomVariance; - /* 0x0F */ u8 unk_0F; - /* 0x10 */ u8 unk_10; + /* 0x0F */ u8 combFilterSize; + /* 0x10 */ u8 surroundEffectIndex; /* 0x11 */ u8 unk_11; /* 0x12 */ VibratoSubStruct vibrato; /* 0x20 */ u16 delay; - /* 0x22 */ u16 unk_20; + /* 0x22 */ u16 combFilterGain; /* 0x24 */ u16 unk_22; // Used for indexing data /* 0x26 */ s16 instOrWave; // either 0 (none), instrument index + 1, or // 0x80..0x83 for sawtooth/triangle/sine/square waves. @@ -459,7 +500,7 @@ typedef struct SequenceChannel { /* 0xC8 */ s8 soundScriptIO[8]; // bridge between sound script and audio lib, "io ports" /* 0xD0 */ u8* sfxState; // SfxChannelState /* 0xD4 */ s16* filter; - /* 0xD8 */ Stereo stereo; + /* 0xD8 */ StereoData stereoData; /* 0xDC */ s32 startSamplePos; /* 0xE0 */ s32 unk_E0; } SequenceChannel; // size = 0xE4 @@ -474,15 +515,15 @@ typedef struct SequenceLayer { /* 0x00 */ u8 ignoreDrumPan : 1; /* 0x00 */ u8 bit1 : 1; // "has initialized continuous notes"? /* 0x00 */ u8 notePropertiesNeedInit : 1; - /* 0x01 */ Stereo stereo; + /* 0x01 */ StereoData stereoData; /* 0x02 */ u8 instOrWave; /* 0x03 */ u8 gateTime; /* 0x04 */ u8 semitone; /* 0x05 */ u8 portamentoTargetNote; /* 0x06 */ u8 pan; // 0..128 /* 0x07 */ u8 notePan; - /* 0x08 */ u8 unk_08; - /* 0x09 */ u8 unk_09; + /* 0x08 */ u8 surroundEffectIndex; + /* 0x09 */ u8 targetReverbVol; union { struct { /* 0x0A */ u16 bit_0 : 1; @@ -531,45 +572,37 @@ typedef struct SequenceLayer { } SequenceLayer; // size = 0x90 typedef struct { - /* 0x00 */ s16 adpcmdecState[0x10]; - /* 0x20 */ s16 finalResampleState[0x10]; - /* 0x40 */ s16 mixEnvelopeState[0x28]; - /* 0x90 */ s16 panResampleState[0x10]; - /* 0xB0 */ s16 panSamplesBuffer[0x20]; - /* 0xF0 */ s16 dummyResampleState[0x10]; -} NoteSynthesisBuffers; // size = 0x110 + /* 0x000 */ s16 adpcmState[16]; + /* 0x020 */ s16 finalResampleState[16]; + /* 0x040 */ s16 filterState[32]; + /* 0x080 */ s16 unusedState[16]; + /* 0x0A0 */ s16 haasEffectDelayState[32]; + /* 0x0E0 */ s16 combFilterState[128]; + /* 0x1E0 */ s16 surroundEffectState[128]; +} NoteSynthesisBuffers; // size = 0x2E0 typedef struct { - /* 0x00 */ u8 restart_bit0 : 1; - /* 0x00 */ u8 restart_bit1 : 1; - /* 0x00 */ u8 restart_bit2 : 1; - /* 0x00 */ u8 restart_bit3 : 1; - /* 0x00 */ u8 restart_bit4 : 1; - /* 0x00 */ u8 restart_bit5 : 1; - /* 0x00 */ u8 restart_bit6 : 1; - /* 0x00 */ u8 restart_bit7 : 1; + /* 0x00 */ u8 atLoopPoint : 1; + /* 0x00 */ u8 stopLoop : 1; /* 0x01 */ u8 sampleDmaIndex; - /* 0x02 */ u8 prevHeadsetPanRight; - /* 0x03 */ u8 prevHeadsetPanLeft; - /* 0x04 */ u8 reverbVol; + /* 0x02 */ u8 prevHaasEffectLeftDelaySize; + /* 0x03 */ u8 prevHaasEffectRightDelaySize; + /* 0x04 */ u8 curReverbVol; /* 0x05 */ u8 numParts; - /* 0x06 */ u16 samplePosFrac; - /* 0x08 */ u16 unk_08; - /* 0x0C */ s32 samplePosInt; + /* 0x06 */ u16 samplePosFrac; // Fractional part of the sample position + /* 0x08 */ u16 surroundEffectGain; + /* 0x0C */ s32 samplePosInt; // Integer part of the sample position /* 0x10 */ NoteSynthesisBuffers* synthesisBuffers; /* 0x14 */ s16 curVolLeft; /* 0x16 */ s16 curVolRight; - /* 0x18 */ u16 unk_14; - /* 0x1A */ u16 unk_16; - /* 0x1C */ u16 unk_18; - /* 0x1E */ u8 unk_1A; + /* 0x18 */ UNK_TYPE1 unk_14[0x6]; + /* 0x1E */ u8 combFilterNeedsInit; /* 0x1F */ u8 unk_1F; - /* 0x20 */ u16 unk_1C; - /* 0x22 */ u16 unk_1E; + /* 0x20 */ UNK_TYPE1 unk_20[0x4]; } NoteSynthesisState; // size = 0x24 typedef struct { - /* 0x00 */ struct VibratoSubStruct* vibSubStruct; // MM Something else? + /* 0x00 */ struct VibratoSubStruct* vibSubStruct; // Something else? /* 0x04 */ u32 time; /* 0x08 */ s16* curve; /* 0x0C */ f32 extent; @@ -603,67 +636,68 @@ typedef struct { /* 0x34 */ AdsrState adsr; /* 0x54 */ Portamento portamento; /* 0x60 */ VibratoState vibratoState; - /* 0x7C */ char unk_7C[0x8]; + /* 0x7C */ UNK_TYPE1 pad7C[0x4]; + /* 0x80 */ u8 unk_80; /* 0x84 */ u32 startSamplePos; -} NotePlaybackState; // size = 0x88 + /* 0x88 */ UNK_TYPE1 unk_BC[0x1C]; +} NotePlaybackState; // size = 0xA4 typedef struct { struct { /* 0x00 */ volatile u8 enabled : 1; /* 0x00 */ u8 needsInit : 1; - /* 0x00 */ u8 finished : 1; // ? + /* 0x00 */ u8 finished : 1; /* 0x00 */ u8 unused : 1; - /* 0x00 */ u8 stereoStrongRight : 1; - /* 0x00 */ u8 stereoStrongLeft : 1; - /* 0x00 */ u8 stereoHeadsetEffects : 1; - /* 0x00 */ u8 usesHeadsetPanEffects : 1; // ? + /* 0x00 */ u8 strongRight : 1; + /* 0x00 */ u8 strongLeft : 1; + /* 0x00 */ u8 strongReverbRight : 1; + /* 0x00 */ u8 strongReverbLeft : 1; } bitField0; struct { /* 0x01 */ u8 reverbIndex : 3; /* 0x01 */ u8 bookOffset : 2; /* 0x01 */ u8 isSyntheticWave : 1; /* 0x01 */ u8 hasTwoParts : 1; - /* 0x01 */ u8 usesHeadsetPanEffects2 : 1; + /* 0x01 */ u8 useHaasEffect : 1; } bitField1; /* 0x02 */ u8 gain; // Increases volume by a multiplicative scaling factor. Represented as a UQ4.4 number - /* 0x03 */ u8 headsetPanRight; - /* 0x04 */ u8 headsetPanLeft; - /* 0x05 */ u8 reverbVol; + /* 0x03 */ u8 haasEffectLeftDelaySize; + /* 0x04 */ u8 haasEffectRightDelaySize; + /* 0x05 */ u8 targetReverbVol; /* 0x06 */ u8 harmonicIndexCurAndPrev; // bits 3..2 store curHarmonicIndex, bits 1..0 store prevHarmonicIndex - /* 0x07 */ u8 unk_07; + /* 0x07 */ u8 combFilterSize; /* 0x08 */ u16 targetVolLeft; /* 0x0A */ u16 targetVolRight; - /* 0x0C */ u16 resamplingRateFixedPoint; - /* 0x0E */ u16 unk_0E; + /* 0x0C */ u16 frequencyFixedPoint; + /* 0x0E */ u16 combFilterGain; union { /* 0x10 */ TunedSample* tunedSample; /* 0x10 */ s16* waveSampleAddr; // used for synthetic waves }; /* 0x14 */ s16* filter; - /* 0x18 */ u8 unk_18; - /* 0x19 */ u8 unk_19; - /* 0x1A */ UNK_TYPE1 pad_1A[0x6]; -} NoteSubEu; // size = 0x20 + /* 0x18 */ UNK_TYPE1 unk_18; + /* 0x19 */ u8 surroundEffectIndex; + /* 0x1A */ UNK_TYPE1 unk_1A[0x6]; +} NoteSampleState; // size = 0x20 typedef struct Note { /* 0x00 */ AudioListItem listItem; /* 0x10 */ NoteSynthesisState synthesisState; /* 0x34 */ NotePlaybackState playbackState; - /* 0xBC */ char unk_BC[0x1C]; - /* 0xD8 */ NoteSubEu noteSubEu; + /* 0xD8 */ NoteSampleState sampleState; } Note; // size = 0xF8 typedef struct { /* 0x00 */ u8 downsampleRate; - /* 0x02 */ u16 windowSize; - /* 0x04 */ u16 unk_4; - /* 0x06 */ u16 unk_6; - /* 0x08 */ u16 unk_8; - /* 0x0A */ u16 unk_A; + /* 0x02 */ u16 delayNumSamples; + /* 0x04 */ u16 decayRatio; // determines how fast reverb dissipates + /* 0x06 */ u16 subDelay; + /* 0x08 */ u16 subVolume; + /* 0x0A */ u16 volume; /* 0x0C */ u16 leakRtl; /* 0x0E */ u16 leakLtr; - /* 0x10 */ s8 unk_10; - /* 0x12 */ u16 unk_12; + /* 0x10 */ s8 mixReverbIndex; + /* 0x12 */ u16 mixReverbStrength; /* 0x14 */ s16 lowPassFilterCutoffLeft; /* 0x16 */ s16 lowPassFilterCutoffRight; } ReverbSettings; // size = 0x18 @@ -704,13 +738,13 @@ typedef struct { /* 0x00 */ s16 specUnk4; /* 0x02 */ u16 samplingFreq; // Target sampling rate in Hz /* 0x04 */ u16 aiSamplingFreq; // True sampling rate set to the audio interface (AI) for the audio digital-analog converter (DAC) - /* 0x06 */ s16 samplesPerFrameTarget; - /* 0x08 */ s16 maxAiBufNumSamples; - /* 0x0A */ s16 minAiBufNumSamples; + /* 0x06 */ s16 numSamplesPerFrameTarget; + /* 0x08 */ s16 numSamplesPerFrameMax; + /* 0x0A */ s16 numSamplesPerFrameMin; /* 0x0C */ s16 updatesPerFrame; // for each frame of the audio thread (default 60 fps), number of updates to process audio - /* 0x0E */ s16 samplesPerUpdate; - /* 0x10 */ s16 samplesPerUpdateMax; - /* 0x12 */ s16 samplesPerUpdateMin; + /* 0x0E */ s16 numSamplesPerUpdate; + /* 0x10 */ s16 numSamplesPerUpdateMax; + /* 0x12 */ s16 numSamplesPerUpdateMin; /* 0x14 */ s16 numSequencePlayers; /* 0x18 */ f32 resampleRate; /* 0x1C */ f32 updatesPerFrameInv; // inverse (reciprocal) of updatesPerFrame @@ -899,8 +933,8 @@ typedef struct { /* 0x0002 */ u16 unk_2; // reads from audio spec unk_14, never used, always set to 0x7FFF /* 0x0004 */ u16 unk_4; /* 0x0006 */ char unk_0006[0xA]; - /* 0x0010 */ s16* curLoadedBook; - /* 0x0014 */ NoteSubEu* noteSubsEu; + /* 0x0010 */ s16* adpcmCodeBook; + /* 0x0014 */ NoteSampleState* sampleStateList; /* 0x0018 */ SynthesisReverb synthesisReverbs[4]; /* 0x0B58 */ char unk_0B58[0x30]; /* 0x0B88 */ Sample* usedSamples[128]; @@ -1002,7 +1036,7 @@ typedef struct { /* 0x4460 */ SequencePlayer seqPlayers[5]; /* 0x4B40 */ SequenceLayer sequenceLayers[80]; /* 0x7840 */ SequenceChannel sequenceChannelNone; - /* 0x7924 */ s32 noteSubEuOffset; + /* 0x7924 */ s32 sampleStateOffset; // Start of the list of sample states for this update. Resets after each audio frame. /* 0x7928 */ AudioListItem layerFreeList; /* 0x7938 */ NotePool noteFreeLists; /* 0x7978 */ u8 cmdWritePos; @@ -1023,17 +1057,17 @@ typedef struct { } AudioContext; // size = 0x81F8 typedef struct { - /* 0x00 */ u8 reverbVol; + /* 0x00 */ u8 targetReverbVol; /* 0x01 */ u8 gain; // Increases volume by a multiplicative scaling factor. Represented as a UQ4.4 number /* 0x02 */ u8 pan; - /* 0x03 */ u8 unk_3; - /* 0x04 */ Stereo stereo; + /* 0x03 */ u8 surroundEffectIndex; + /* 0x04 */ StereoData stereoData; /* 0x08 */ f32 frequency; /* 0x0C */ f32 velocity; /* 0x10 */ char unk_0C[0x4]; /* 0x14 */ s16* filter; - /* 0x18 */ u8 unk_14; - /* 0x1A */ u16 unk_16; + /* 0x18 */ u8 combFilterSize; + /* 0x1A */ u16 combFilterGain; } NoteSubAttributes; // size = 0x1A typedef struct { diff --git a/spec b/spec index 4dec1f2289..100e615cf1 100644 --- a/spec +++ b/spec @@ -608,7 +608,6 @@ beginseg pad_text include "build/src/code/audio/audio_data.o" include "build/src/code/audio/audio_synthesis.o" - include "build/data/code/audio_synthesis.data.o" include "build/src/code/audio/audio_heap.o" include "build/data/code/audio_heap.bss.o" include "build/src/code/audio/audio_load.o" diff --git a/src/code/audio/audio_data.c b/src/code/audio/audio_data.c index 7238a4bfa6..eb931262b0 100644 --- a/src/code/audio/audio_data.c +++ b/src/code/audio/audio_data.c @@ -857,22 +857,99 @@ EnvelopePoint gDefaultEnvelope[] = { { ADSR_DISABLE, 0 }, }; -NoteSubEu gZeroNoteSub = { 0 }; +NoteSampleState gZeroedSampleState = { 0 }; -NoteSubEu gDefaultNoteSub = { - { 1, 1, 0, 0, 0, 0, 0, 0 }, { 0 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +NoteSampleState gDefaultSampleState = { + { true, true, false, false, false, false, false, false }, + { 0 }, + 0, // gain + 0, // haasEffectLeftDelaySize + 0, // haasEffectRightDelaySize + 0, // targetReverbVol + 0, // harmonicIndexCurAndPrev + 0, // combFilterSize + 0, // targetVolLeft + 0, // targetVolRight + 0, // frequencyFixedPoint + 0, // combFilterGain + NULL, // tunedSample + NULL, // filter + 0, // unk_18 + 0, // surroundEffectIndex + 0, // unk_1A }; -u16 gHeadsetPanQuantization[64] = { - 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, - 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +u16 gHaasEffectDelaySize[64] = { + 30 * SAMPLE_SIZE, + 29 * SAMPLE_SIZE, + 28 * SAMPLE_SIZE, + 27 * SAMPLE_SIZE, + 26 * SAMPLE_SIZE, + 25 * SAMPLE_SIZE, + 24 * SAMPLE_SIZE, + 23 * SAMPLE_SIZE, + 22 * SAMPLE_SIZE, + 21 * SAMPLE_SIZE, + 20 * SAMPLE_SIZE, + 19 * SAMPLE_SIZE, + 18 * SAMPLE_SIZE, + 17 * SAMPLE_SIZE, + 16 * SAMPLE_SIZE, + 15 * SAMPLE_SIZE, + 14 * SAMPLE_SIZE, + 13 * SAMPLE_SIZE, + 12 * SAMPLE_SIZE, + 11 * SAMPLE_SIZE, + 10 * SAMPLE_SIZE, + 9 * SAMPLE_SIZE, + 8 * SAMPLE_SIZE, + 7 * SAMPLE_SIZE, + 6 * SAMPLE_SIZE, + 5 * SAMPLE_SIZE, + 4 * SAMPLE_SIZE, + 3 * SAMPLE_SIZE, + 2 * SAMPLE_SIZE, + 1 * SAMPLE_SIZE, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, }; s32 D_801D58A4 = 0; // clang-format off -s16 D_801D58A8[] = { +s16 gInvalidAdpcmCodeBook[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, diff --git a/src/code/audio/audio_heap.c b/src/code/audio/audio_heap.c index 667cd1c400..8412220a34 100644 --- a/src/code/audio/audio_heap.c +++ b/src/code/audio/audio_heap.c @@ -10,7 +10,7 @@ void AudioHeap_DiscardSampleCaches(void); void AudioHeap_DiscardSampleBank(s32 sampleBankId); void AudioHeap_ApplySampleBankCacheInternal(s32 apply, s32 sampleBankId); void AudioHeap_DiscardSampleBanks(void); -void AudioHeap_InitReverb(s32 reverbIndex, ReverbSettings* settings, s32 flags); +void AudioHeap_InitReverb(s32 reverbIndex, ReverbSettings* settings, s32 isFirstInit); #define gTatumsPerBeat (gAudioTatumInit[1]) @@ -421,7 +421,7 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) { if (loadStatusEntry0 == LOAD_STATUS_MAYBE_DISCARDABLE) { for (i = 0; i < gAudioContext.numNotes; i++) { if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[0].id) && - gAudioContext.notes[i].noteSubEu.bitField0.enabled) { + gAudioContext.notes[i].sampleState.bitField0.enabled) { break; } } @@ -435,7 +435,7 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) { if (loadStatusEntry1 == LOAD_STATUS_MAYBE_DISCARDABLE) { for (i = 0; i < gAudioContext.numNotes; i++) { if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[1].id) && - gAudioContext.notes[i].noteSubEu.bitField0.enabled) { + gAudioContext.notes[i].sampleState.bitField0.enabled) { break; } } @@ -491,7 +491,7 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) { if (loadStatusEntry0 == LOAD_STATUS_COMPLETE) { for (i = 0; i < gAudioContext.numNotes; i++) { if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[0].id) && - gAudioContext.notes[i].noteSubEu.bitField0.enabled) { + gAudioContext.notes[i].sampleState.bitField0.enabled) { break; } } @@ -504,7 +504,7 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) { if (loadStatusEntry1 == LOAD_STATUS_COMPLETE) { for (i = 0; i < gAudioContext.numNotes; i++) { if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[1].id) && - gAudioContext.notes[i].noteSubEu.bitField0.enabled) { + gAudioContext.notes[i].sampleState.bitField0.enabled) { break; } } @@ -814,7 +814,7 @@ void AudioHeap_UpdateReverb(SynthesisReverb* reverb) { void AudioHeap_UpdateReverbs(void) { s32 count; - s32 i; + s32 reverbIndex; s32 j; if (gAudioContext.audioBufferParameters.specUnk4 == 2) { @@ -823,9 +823,9 @@ void AudioHeap_UpdateReverbs(void) { count = 1; } - for (i = 0; i < gAudioContext.numSynthesisReverbs; i++) { + for (reverbIndex = 0; reverbIndex < gAudioContext.numSynthesisReverbs; reverbIndex++) { for (j = 0; j < count; j++) { - AudioHeap_UpdateReverb(&gAudioContext.synthesisReverbs[i]); + AudioHeap_UpdateReverb(&gAudioContext.synthesisReverbs[reverbIndex]); } } } @@ -837,7 +837,7 @@ void AudioHeap_ClearAiBuffers(void) { s32 curAiBufferIndex = gAudioContext.curAiBufferIndex; s32 i; - gAudioContext.aiBufNumSamples[curAiBufferIndex] = gAudioContext.audioBufferParameters.minAiBufNumSamples; + gAudioContext.aiBufNumSamples[curAiBufferIndex] = gAudioContext.audioBufferParameters.numSamplesPerFrameMin; for (i = 0; i < AIBUF_LEN; i++) { gAudioContext.aiBuffers[curAiBufferIndex][i] = 0; @@ -870,7 +870,7 @@ s32 AudioHeap_ResetStep(void) { AudioHeap_UpdateReverbs(); } else { for (i = 0; i < gAudioContext.numNotes; i++) { - if (gAudioContext.notes[i].noteSubEu.bitField0.enabled && + if (gAudioContext.notes[i].sampleState.bitField0.enabled && gAudioContext.notes[i].playbackState.adsr.action.s.state != ADSR_STATE_DISABLED) { gAudioContext.notes[i].playbackState.adsr.fadeOutVel = gAudioContext.audioBufferParameters.updatesPerFrameInv; @@ -907,7 +907,7 @@ s32 AudioHeap_ResetStep(void) { AudioHeap_Init(); gAudioContext.resetStatus = 0; for (i = 0; i < ARRAY_COUNT(gAudioContext.aiBufNumSamples); i++) { - gAudioContext.aiBufNumSamples[i] = gAudioContext.audioBufferParameters.maxAiBufNumSamples; + gAudioContext.aiBufNumSamples[i] = gAudioContext.audioBufferParameters.numSamplesPerFrameMax; for (j = 0; j < AIBUF_LEN; j++) { gAudioContext.aiBuffers[i][j] = 0; } @@ -930,8 +930,8 @@ void AudioHeap_Init(void) { size_t cachePoolSize; size_t miscPoolSize; u32 intMask; + s32 reverbIndex; s32 i; - s32 j; s32 pad2; AudioSpec* spec = &gAudioSpecs[gAudioContext.audioResetSpecIdToLoad]; // Audio Specifications @@ -942,19 +942,22 @@ void AudioHeap_Init(void) { gAudioContext.audioBufferParameters.aiSamplingFreq = osAiSetFrequency(gAudioContext.audioBufferParameters.samplingFreq); - gAudioContext.audioBufferParameters.samplesPerFrameTarget = + gAudioContext.audioBufferParameters.numSamplesPerFrameTarget = ALIGN16(gAudioContext.audioBufferParameters.samplingFreq / gAudioContext.refreshRate); - gAudioContext.audioBufferParameters.minAiBufNumSamples = - gAudioContext.audioBufferParameters.samplesPerFrameTarget - 0x10; - gAudioContext.audioBufferParameters.maxAiBufNumSamples = - gAudioContext.audioBufferParameters.samplesPerFrameTarget + 0x10; + gAudioContext.audioBufferParameters.numSamplesPerFrameMin = + gAudioContext.audioBufferParameters.numSamplesPerFrameTarget - 0x10; + gAudioContext.audioBufferParameters.numSamplesPerFrameMax = + gAudioContext.audioBufferParameters.numSamplesPerFrameTarget + 0x10; gAudioContext.audioBufferParameters.updatesPerFrame = - ((gAudioContext.audioBufferParameters.samplesPerFrameTarget + 0x10) / 0xD0) + 1; - gAudioContext.audioBufferParameters.samplesPerUpdate = (gAudioContext.audioBufferParameters.samplesPerFrameTarget / - gAudioContext.audioBufferParameters.updatesPerFrame) & - ~7; - gAudioContext.audioBufferParameters.samplesPerUpdateMax = gAudioContext.audioBufferParameters.samplesPerUpdate + 8; - gAudioContext.audioBufferParameters.samplesPerUpdateMin = gAudioContext.audioBufferParameters.samplesPerUpdate - 8; + ((gAudioContext.audioBufferParameters.numSamplesPerFrameTarget + 0x10) / 0xD0) + 1; + gAudioContext.audioBufferParameters.numSamplesPerUpdate = + (gAudioContext.audioBufferParameters.numSamplesPerFrameTarget / + gAudioContext.audioBufferParameters.updatesPerFrame) & + ~7; + gAudioContext.audioBufferParameters.numSamplesPerUpdateMax = + gAudioContext.audioBufferParameters.numSamplesPerUpdate + 8; + gAudioContext.audioBufferParameters.numSamplesPerUpdateMin = + gAudioContext.audioBufferParameters.numSamplesPerUpdate - 8; gAudioContext.audioBufferParameters.resampleRate = 32000.0f / (s32)gAudioContext.audioBufferParameters.samplingFreq; gAudioContext.audioBufferParameters.updatesPerFrameInvScaled = (1.0f / 256.0f) / gAudioContext.audioBufferParameters.updatesPerFrame; @@ -984,13 +987,13 @@ void AudioHeap_Init(void) { gAudioContext.unk_2870 /= gAudioContext.tempoInternalToExternal; gAudioContext.audioBufferParameters.specUnk4 = spec->unk_04; - gAudioContext.audioBufferParameters.samplesPerFrameTarget *= gAudioContext.audioBufferParameters.specUnk4; - gAudioContext.audioBufferParameters.maxAiBufNumSamples *= gAudioContext.audioBufferParameters.specUnk4; - gAudioContext.audioBufferParameters.minAiBufNumSamples *= gAudioContext.audioBufferParameters.specUnk4; + gAudioContext.audioBufferParameters.numSamplesPerFrameTarget *= gAudioContext.audioBufferParameters.specUnk4; + gAudioContext.audioBufferParameters.numSamplesPerFrameMax *= gAudioContext.audioBufferParameters.specUnk4; + gAudioContext.audioBufferParameters.numSamplesPerFrameMin *= gAudioContext.audioBufferParameters.specUnk4; gAudioContext.audioBufferParameters.updatesPerFrame *= gAudioContext.audioBufferParameters.specUnk4; if (gAudioContext.audioBufferParameters.specUnk4 >= 2) { - gAudioContext.audioBufferParameters.maxAiBufNumSamples -= 0x10; + gAudioContext.audioBufferParameters.numSamplesPerFrameMax -= 0x10; } // Determine the maximum allowable number of audio command list entries for the rsp microcode @@ -1037,13 +1040,13 @@ void AudioHeap_Init(void) { gAudioContext.notes = AudioHeap_AllocZeroed(&gAudioContext.miscPool, gAudioContext.numNotes * sizeof(Note)); AudioPlayback_NoteInitAll(); AudioPlayback_InitNoteFreeList(); - gAudioContext.noteSubsEu = + gAudioContext.sampleStateList = AudioHeap_AllocZeroed(&gAudioContext.miscPool, gAudioContext.audioBufferParameters.updatesPerFrame * - gAudioContext.numNotes * sizeof(NoteSubEu)); + gAudioContext.numNotes * sizeof(NoteSampleState)); // Initialize audio binary interface command list buffer - for (j = 0; j < ARRAY_COUNT(gAudioContext.abiCmdBufs); j++) { - gAudioContext.abiCmdBufs[j] = + for (i = 0; i < ARRAY_COUNT(gAudioContext.abiCmdBufs); i++) { + gAudioContext.abiCmdBufs[i] = AudioHeap_AllocDmaMemoryZeroed(&gAudioContext.miscPool, gAudioContext.maxAudioCmds * sizeof(Acmd)); } @@ -1052,20 +1055,20 @@ void AudioHeap_Init(void) { AudioHeap_InitAdsrDecayTable(); // Initialize reverbs - for (i = 0; i < ARRAY_COUNT(gAudioContext.synthesisReverbs); i++) { - gAudioContext.synthesisReverbs[i].useReverb = 0; + for (reverbIndex = 0; reverbIndex < ARRAY_COUNT(gAudioContext.synthesisReverbs); reverbIndex++) { + gAudioContext.synthesisReverbs[reverbIndex].useReverb = 0; } gAudioContext.numSynthesisReverbs = spec->numReverbs; - for (i = 0; i < gAudioContext.numSynthesisReverbs; i++) { - AudioHeap_InitReverb(i, &spec->reverbSettings[i], 1); + for (reverbIndex = 0; reverbIndex < gAudioContext.numSynthesisReverbs; reverbIndex++) { + AudioHeap_InitReverb(reverbIndex, &spec->reverbSettings[reverbIndex], true); } // Initialize sequence players AudioSeq_InitSequencePlayers(); - for (j = 0; j < gAudioContext.audioBufferParameters.numSequencePlayers; j++) { - AudioSeq_InitSequencePlayerChannels(j); - AudioSeq_ResetSequencePlayer(&gAudioContext.seqPlayers[j]); + for (i = 0; i < gAudioContext.audioBufferParameters.numSequencePlayers; i++) { + AudioSeq_InitSequencePlayerChannels(i); + AudioSeq_ResetSequencePlayer(&gAudioContext.seqPlayers[i]); } // Initialize two additional caches on the audio heap to store individual audio samples @@ -1529,149 +1532,165 @@ void AudioHeap_DiscardSampleBanks(void) { } } -void AudioHeap_SetReverbData(s32 reverbIndex, u32 dataType, s32 data, s32 flags) { - s32 windowSize; +void AudioHeap_SetReverbData(s32 reverbIndex, u32 dataType, s32 data, s32 isFirstInit) { + s32 delayNumSamples; SynthesisReverb* reverb = &gAudioContext.synthesisReverbs[reverbIndex]; switch (dataType) { - case 0: - AudioHeap_InitReverb(reverbIndex, (ReverbSettings*)data, 0); + case REVERB_DATA_TYPE_SETTINGS: + AudioHeap_InitReverb(reverbIndex, (ReverbSettings*)data, false); break; - case 1: + + case REVERB_DATA_TYPE_DELAY: if (data < 4) { data = 4; } - windowSize = data * 64; - if (windowSize < 0x100) { - windowSize = 0x100; + delayNumSamples = data * 64; + if (delayNumSamples < (16 * SAMPLES_PER_FRAME)) { + delayNumSamples = 16 * SAMPLES_PER_FRAME; } - windowSize /= reverb->downsampleRate; + delayNumSamples /= reverb->downsampleRate; - if (flags == 0) { - if (reverb->unk_1E >= (data / reverb->downsampleRate)) { - if ((reverb->nextRingBufPos >= windowSize) || (reverb->unk_24 >= windowSize)) { - reverb->nextRingBufPos = 0; - reverb->unk_24 = 0; - } - } else { + if (!isFirstInit) { + if (reverb->delayNumSamplesAfterDownsampling < (data / reverb->downsampleRate)) { break; } + if ((reverb->nextReverbBufPos >= delayNumSamples) || (reverb->delayNumSamplesUnk >= delayNumSamples)) { + reverb->nextReverbBufPos = 0; + reverb->delayNumSamplesUnk = 0; + } } - reverb->windowSize = windowSize; + reverb->delayNumSamples = delayNumSamples; - if ((reverb->downsampleRate != 1) || reverb->unk_18) { - reverb->unk_0E = 0x8000 / reverb->downsampleRate; - if (reverb->unk_30 == NULL) { - reverb->unk_30 = AudioHeap_AllocZeroed(&gAudioContext.miscPool, 0x20); - reverb->unk_34 = AudioHeap_AllocZeroed(&gAudioContext.miscPool, 0x20); - reverb->unk_38 = AudioHeap_AllocZeroed(&gAudioContext.miscPool, 0x20); - reverb->unk_3C = AudioHeap_AllocZeroed(&gAudioContext.miscPool, 0x20); - if (reverb->unk_3C == NULL) { + if ((reverb->downsampleRate != 1) || reverb->resampleEffectOn) { + reverb->downsamplePitch = 0x8000 / reverb->downsampleRate; + if (reverb->leftLoadResampleBuf == NULL) { + reverb->leftLoadResampleBuf = + AudioHeap_AllocZeroed(&gAudioContext.miscPool, sizeof(RESAMPLE_STATE)); + reverb->rightLoadResampleBuf = + AudioHeap_AllocZeroed(&gAudioContext.miscPool, sizeof(RESAMPLE_STATE)); + reverb->leftSaveResampleBuf = + AudioHeap_AllocZeroed(&gAudioContext.miscPool, sizeof(RESAMPLE_STATE)); + reverb->rightSaveResampleBuf = + AudioHeap_AllocZeroed(&gAudioContext.miscPool, sizeof(RESAMPLE_STATE)); + if (reverb->rightSaveResampleBuf == NULL) { reverb->downsampleRate = 1; } } } break; - case 2: - gAudioContext.synthesisReverbs[reverbIndex].unk_0C = data; + + case REVERB_DATA_TYPE_DECAY: + gAudioContext.synthesisReverbs[reverbIndex].decayRatio = data; break; - case 3: - gAudioContext.synthesisReverbs[reverbIndex].unk_16 = data; + + case REVERB_DATA_TYPE_SUB_VOLUME: + gAudioContext.synthesisReverbs[reverbIndex].subVolume = data; break; - case 4: - gAudioContext.synthesisReverbs[reverbIndex].unk_0A = data; + + case REVERB_DATA_TYPE_VOLUME: + gAudioContext.synthesisReverbs[reverbIndex].volume = data; break; - case 5: + + case REVERB_DATA_TYPE_LEAK_RIGHT: gAudioContext.synthesisReverbs[reverbIndex].leakRtl = data; break; - case 6: + + case REVERB_DATA_TYPE_LEAK_LEFT: gAudioContext.synthesisReverbs[reverbIndex].leakLtr = data; break; - case 7: + + case REVERB_DATA_TYPE_FILTER_LEFT: if (data != 0) { - if ((flags != 0) || (reverb->unk_278 == 0)) { - reverb->filterLeftState = AudioHeap_AllocDmaMemoryZeroed(&gAudioContext.miscPool, 0x40); - reverb->unk_278 = AudioHeap_AllocDmaMemory(&gAudioContext.miscPool, 0x10); + if (isFirstInit || (reverb->filterLeftInit == NULL)) { + reverb->filterLeftState = AudioHeap_AllocDmaMemoryZeroed(&gAudioContext.miscPool, + 2 * (FILTER_BUF_PART1 + FILTER_BUF_PART2)); + reverb->filterLeftInit = AudioHeap_AllocDmaMemory(&gAudioContext.miscPool, FILTER_SIZE); } - reverb->filterLeft = reverb->unk_278; - if (reverb->filterLeft != 0) { + reverb->filterLeft = reverb->filterLeftInit; + if (reverb->filterLeft != NULL) { AudioHeap_LoadLowPassFilter(reverb->filterLeft, data); } } else { - reverb->filterLeft = 0; + reverb->filterLeft = NULL; - if (flags != 0) { - reverb->unk_278 = 0; + if (isFirstInit) { + reverb->filterLeftInit = NULL; } } - break; - case 8: + + case REVERB_DATA_TYPE_FILTER_RIGHT: if (data != 0) { - if ((flags != 0) || (reverb->unk_27C == 0)) { - reverb->filterRightState = AudioHeap_AllocDmaMemoryZeroed(&gAudioContext.miscPool, 0x40); - reverb->unk_27C = AudioHeap_AllocDmaMemory(&gAudioContext.miscPool, 0x10); + if (isFirstInit || (reverb->filterRightInit == NULL)) { + reverb->filterRightState = AudioHeap_AllocDmaMemoryZeroed( + &gAudioContext.miscPool, 2 * (FILTER_BUF_PART1 + FILTER_BUF_PART2)); + reverb->filterRightInit = AudioHeap_AllocDmaMemory(&gAudioContext.miscPool, FILTER_SIZE); } - reverb->filterRight = reverb->unk_27C; - if (reverb->unk_27C != 0) { - AudioHeap_LoadLowPassFilter(reverb->unk_27C, data); + reverb->filterRight = reverb->filterRightInit; + if (reverb->filterRight != NULL) { + AudioHeap_LoadLowPassFilter(reverb->filterRight, data); } } else { - reverb->filterRight = 0; - if (flags != 0) { - reverb->unk_27C = 0; + reverb->filterRight = NULL; + if (isFirstInit) { + reverb->filterRightInit = NULL; } } break; - case 9: - reverb->unk_19 = data; + + case REVERB_DATA_TYPE_9: + reverb->resampleEffectExtraSamples = data; if (data == 0) { - reverb->unk_18 = false; + reverb->resampleEffectOn = false; } else { - reverb->unk_18 = true; + reverb->resampleEffectOn = true; } break; + default: break; } } -void AudioHeap_InitReverb(s32 reverbIndex, ReverbSettings* settings, s32 flags) { +void AudioHeap_InitReverb(s32 reverbIndex, ReverbSettings* settings, s32 isFirstInit) { SynthesisReverb* reverb = &gAudioContext.synthesisReverbs[reverbIndex]; - if (flags != 0) { - reverb->unk_1E = settings->windowSize / settings->downsampleRate; - reverb->unk_30 = 0; - } else if (reverb->unk_1E < (settings->windowSize / settings->downsampleRate)) { + if (isFirstInit) { + reverb->delayNumSamplesAfterDownsampling = settings->delayNumSamples / settings->downsampleRate; + reverb->leftLoadResampleBuf = NULL; + } else if (reverb->delayNumSamplesAfterDownsampling < (settings->delayNumSamples / settings->downsampleRate)) { return; } reverb->downsampleRate = settings->downsampleRate; - reverb->unk_18 = false; - reverb->unk_19 = 0; - reverb->unk_1A = 0; - reverb->unk_1C = 0; - AudioHeap_SetReverbData(reverbIndex, 1, settings->windowSize, flags); - reverb->unk_0C = settings->unk_4; - reverb->unk_0A = settings->unk_A; - reverb->unk_14 = settings->unk_6 << 6; - reverb->unk_16 = settings->unk_8; + reverb->resampleEffectOn = false; + reverb->resampleEffectExtraSamples = 0; + reverb->resampleEffectLoadUnk = 0; + reverb->resampleEffectSaveUnk = 0; + AudioHeap_SetReverbData(reverbIndex, REVERB_DATA_TYPE_DELAY, settings->delayNumSamples, isFirstInit); + reverb->decayRatio = settings->decayRatio; + reverb->volume = settings->volume; + reverb->subDelay = settings->subDelay * 64; + reverb->subVolume = settings->subVolume; reverb->leakRtl = settings->leakRtl; reverb->leakLtr = settings->leakLtr; - reverb->unk_05 = settings->unk_10; - reverb->unk_08 = settings->unk_12; - reverb->useReverb = 8; + reverb->mixReverbIndex = settings->mixReverbIndex; + reverb->mixReverbStrength = settings->mixReverbStrength; + reverb->useReverb = 8; // used as a boolean - if (flags != 0) { - reverb->leftRingBuf = AudioHeap_AllocZeroedAttemptExternal(&gAudioContext.miscPool, reverb->windowSize * 2); - reverb->rightRingBuf = AudioHeap_AllocZeroedAttemptExternal(&gAudioContext.miscPool, reverb->windowSize * 2); + if (isFirstInit) { + reverb->leftReverbBuf = + AudioHeap_AllocZeroedAttemptExternal(&gAudioContext.miscPool, reverb->delayNumSamples * 2); + reverb->rightReverbBuf = + AudioHeap_AllocZeroedAttemptExternal(&gAudioContext.miscPool, reverb->delayNumSamples * 2); reverb->resampleFlags = 1; - reverb->nextRingBufPos = 0; - reverb->unk_24 = 0; + reverb->nextReverbBufPos = 0; + reverb->delayNumSamplesUnk = 0; reverb->curFrame = 0; reverb->framesToIgnore = 2; } @@ -1681,12 +1700,13 @@ void AudioHeap_InitReverb(s32 reverbIndex, ReverbSettings* settings, s32 flags) reverb->tunedSample.tuning = 1.0f; reverb->sample.codec = CODEC_REVERB; reverb->sample.medium = MEDIUM_RAM; - reverb->sample.size = reverb->windowSize * 2; - reverb->sample.sampleAddr = (u8*)reverb->leftRingBuf; + reverb->sample.size = reverb->delayNumSamples * SAMPLE_SIZE; + reverb->sample.sampleAddr = (u8*)reverb->leftReverbBuf; reverb->loop.start = 0; reverb->loop.count = 1; - reverb->loop.end = reverb->windowSize; + reverb->loop.loopEnd = reverb->delayNumSamples; - AudioHeap_SetReverbData(reverbIndex, 7, settings->lowPassFilterCutoffLeft, flags); - AudioHeap_SetReverbData(reverbIndex, 8, settings->lowPassFilterCutoffRight, flags); + AudioHeap_SetReverbData(reverbIndex, REVERB_DATA_TYPE_FILTER_LEFT, settings->lowPassFilterCutoffLeft, isFirstInit); + AudioHeap_SetReverbData(reverbIndex, REVERB_DATA_TYPE_FILTER_RIGHT, settings->lowPassFilterCutoffRight, + isFirstInit); } diff --git a/src/code/audio/audio_init_params.c b/src/code/audio/audio_init_params.c index 81c49b30ca..59c6658ac3 100644 --- a/src/code/audio/audio_init_params.c +++ b/src/code/audio/audio_init_params.c @@ -1,12 +1,184 @@ #include "global.h" const s16 gAudioTatumInit[] = { - 0x1C00, // unused - 0x30, // gTatumsPerBeat + 0x1C00, // unused + TATUMS_PER_BEAT, // gTatumsPerBeat }; +// TODO: Extract from table? +#define NUM_SOUNDFONTS 41 +#define SFX_SEQ_SIZE 0xC6A0 +#define AMBIENCE_SEQ_SIZE 0xFC0 +#define SOUNDFONT_0_SIZE 0x81C0 +#define SOUNDFONT_1_SIZE 0x36D0 +#define SOUNDFONT_2_SIZE 0xCE0 + +// Sizes of everything on the init pool +#define AI_BUFFERS_SIZE (AIBUF_SIZE * ARRAY_COUNT(gAudioContext.aiBuffers)) +#define SOUNDFONT_LIST_SIZE (NUM_SOUNDFONTS * sizeof(SoundFont)) + +// 0x19BD0 +#define PERMANENT_POOL_SIZE \ + (SFX_SEQ_SIZE + AMBIENCE_SEQ_SIZE + SOUNDFONT_0_SIZE + SOUNDFONT_1_SIZE + SOUNDFONT_2_SIZE + 0x430) + const AudioHeapInitSizes gAudioHeapInitSizes = { - 0x137F00, // heapSize - 0x1C480, // initPoolSize - 0x1A000, // permanentPoolSize + ALIGN16(sizeof(gAudioHeap) - 0x100), // audio heap size + ALIGN16(PERMANENT_POOL_SIZE + AI_BUFFERS_SIZE + SOUNDFONT_LIST_SIZE + 0x40), // init pool size + ALIGN16(PERMANENT_POOL_SIZE), // permanent pool size +}; + +#define REVERB_INDEX_0_SETTINGS \ + { 1, 0x30, 0x3000, 0, 0, 0x7FFF, 0x0000, 0x0000, REVERB_INDEX_NONE, 0x3000, 0, 0 } + +ReverbSettings reverbSettings0[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x20, 0x0800, 0, 0, 0x7FFF, 0x0000, 0x0000, REVERB_INDEX_NONE, 0x0000, 0, 0 }, +}; + +ReverbSettings reverbSettings1[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x30, 0x1800, 0, 0, 0x7FFF, 0x0000, 0x0000, REVERB_INDEX_NONE, 0x0000, 11, 11 }, +}; + +ReverbSettings reverbSettings2[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x38, 0x2800, 0, 0, 0x7FFF, 0x0000, 0x0000, REVERB_INDEX_NONE, 0x0000, 7, 7 }, +}; + +ReverbSettings reverbSettings3[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x30, 0x6800, 0, 0, 0x7FFF, 0x1400, 0x1400, REVERB_INDEX_NONE, 0x3000, 6, 6 }, + { 2, 0x50, 0x6000, 0, 0, 0x7FFF, 0xD000, 0x3000, REVERB_INDEX_NONE, 0x3000, 0, 0 }, +}; + +ReverbSettings reverbSettings4[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x40, 0x5000, 0, 0, 0x7FFF, 0x1800, 0x1800, REVERB_INDEX_NONE, 0x3000, 7, 7 }, +}; + +ReverbSettings reverbSettings5[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x40, 0x5C00, 0, 0, 0x7FFF, 0x2000, 0x2000, REVERB_INDEX_NONE, 0x3000, 4, 4 }, +}; + +ReverbSettings reverbSettings6[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x30, 0x6000, 0, 0, 0x7FFF, 0x1000, 0x1000, REVERB_INDEX_NONE, 0x3000, 10, 10 }, +}; + +ReverbSettings reverbSettings7[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x30, 0x6800, 0, 0, 0x7FFF, 0x1400, 0x1400, REVERB_INDEX_NONE, 0x3000, 6, 6 }, +}; + +ReverbSettings reverbSettings8[2] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x50, 0x5000, 0, 0, 0x7FFF, 0xD000, 0x3000, REVERB_INDEX_NONE, 0x3000, 0, 0 }, +}; + +ReverbSettings reverbSettings9[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x20, 0x0000, 0, 0, 0x7FFF, 0x0000, 0x0000, REVERB_INDEX_NONE, 0x0000, 0, 0 }, +}; + +ReverbSettings reverbSettingsA[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x30, 0x1800, 0, 0, 0x7FFF, 0x0000, 0x0000, REVERB_INDEX_NONE, 0x0000, 11, 11 }, +}; + +ReverbSettings reverbSettingsB[3] = { + REVERB_INDEX_0_SETTINGS, +}; + +ReverbSettings reverbSettingsC[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x40, 0x5000, 0, 0, 0x7FFF, 0x0000, 0x0000, REVERB_INDEX_NONE, 0x3000, 0, 0 }, +}; + +ReverbSettings reverbSettingsD[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x30, 0x6800, 0, 0, 0x7FFF, 0x1400, 0x1400, REVERB_INDEX_NONE, 0x3000, 6, 6 }, + { 2, 0x50, 0x6000, 0, 0, 0x7FFF, 0xD000, 0x3000, REVERB_INDEX_NONE, 0x3000, 0, 0 }, +}; + +ReverbSettings reverbSettingsE[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x30, 0x1800, 0, 0, 0x7FFF, 0x0000, 0x0000, REVERB_INDEX_NONE, 0x0000, 11, 11 }, + { 1, 0x40, 0x5000, 0, 0, 0x7FFF, 0x1800, 0x1800, REVERB_INDEX_NONE, 0x3000, 7, 7 }, +}; + +ReverbSettings reverbSettingsF[2] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x50, 0x1800, 0, 0, 0x7FFF, 0x0000, 0x0000, REVERB_INDEX_NONE, 0x0000, 11, 11 }, +}; + +ReverbSettings* gReverbSettingsTable[] = { + reverbSettings0, reverbSettings1, reverbSettings2, reverbSettings4, reverbSettings5, + reverbSettings6, reverbSettings7, reverbSettings8, reverbSettings9, reverbSettings3, +}; + +AudioSpec gAudioSpecs[21] = { + /* 0x0 */ + { 32000, 1, 24, 5, 0, 0, 2, reverbSettingsF, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x1 */ + { 32000, 1, 24, 5, 0, 0, 2, reverbSettingsF, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x2 */ + { 32000, 1, 24, 5, 0, 0, 2, reverbSettingsF, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x3 */ + { 32000, 1, 24, 5, 0, 0, 2, reverbSettingsF, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x4 */ + { 32000, 1, 24, 5, 0, 0, 2, reverbSettingsF, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x5 */ + { 32000, 1, 24, 5, 0, 0, 2, reverbSettingsF, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x6 */ + { 32000, 1, 24, 5, 0, 0, 2, reverbSettingsF, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x7 */ + { 32000, 1, 24, 5, 0, 0, 2, reverbSettingsF, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x8 */ + { 32000, 1, 24, 5, 0, 0, 2, reverbSettingsF, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x9 */ + { 32000, 1, 24, 5, 0, 0, 2, reverbSettingsF, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0xA */ + { 32000, 1, 28, 3, 0, 0, 2, reverbSettingsA, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x2800, 0x2D00, 0, 0, + 0xDC800 }, + /* 0xB */ + { 32000, 1, 28, 3, 0, 0, 2, reverbSettingsA, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0xC */ + { 32000, 1, 28, 5, 0, 0, 2, reverbSettingsA, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xCC800 }, + /* 0xD */ + { 32000, 1, 24, 5, 0, 0, 3, reverbSettingsD, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0xE */ + { 32000, 1, 24, 5, 0, 0, 3, reverbSettingsE, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0xF */ + { 32000, 1, 24, 5, 0, 0, 2, reverbSettingsF, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4000, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x10 */ + { 32000, 1, 22, 5, 0, 0, 2, reverbSettings0, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x11 */ + { 32000, 1, 22, 5, 0, 0, 2, reverbSettings8, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x12 */ + { 32000, 1, 16, 5, 0, 0, 2, reverbSettings0, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x13 */ + { 22050, 1, 24, 5, 0, 0, 2, reverbSettings0, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x14 */ + { 32000, 1, 24, 5, 0, 0, 2, reverbSettings2, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x3600, 0x2600, 0, 0, + 0xDC800 }, }; diff --git a/src/code/audio/audio_load.c b/src/code/audio/audio_load.c index c8e5ac5d1b..ccdc7488d5 100644 --- a/src/code/audio/audio_load.c +++ b/src/code/audio/audio_load.c @@ -1218,9 +1218,9 @@ void AudioLoad_Init(void* heap, size_t heapSize) { s32 i; s32 j; - D_80208E68 = NULL; - D_80208E70 = NULL; - D_80208E74 = NULL; + gCustomAudioUpdateFunction = NULL; + gCustomAudioReverbFunction = NULL; + gCustomAudioSynthFunction = NULL; for (i = 0; i < ARRAY_COUNT(gAudioContext.unk_29A8); i++) { gAudioContext.unk_29A8[i] = NULL; diff --git a/src/code/audio/audio_playback.c b/src/code/audio/audio_playback.c index e1a42b1eda..a7cc9a5880 100644 --- a/src/code/audio/audio_playback.c +++ b/src/code/audio/audio_playback.c @@ -1,10 +1,10 @@ #include "global.h" -void AudioPlayback_NoteSetResamplingRate(NoteSubEu* noteSubEu, f32 resamplingRateInput); +void AudioPlayback_NoteSetResamplingRate(NoteSampleState* sampleState, f32 resamplingRateInput); void AudioPlayback_AudioListPushFront(AudioListItem* list, AudioListItem* item); void AudioPlayback_NoteInitForLayer(Note* note, SequenceLayer* layer); -void AudioPlayback_InitNoteSub(Note* note, NoteSubEu* noteSubEu, NoteSubAttributes* subAttrs) { +void AudioPlayback_InitSampleState(Note* note, NoteSampleState* sampleState, NoteSubAttributes* subAttrs) { f32 volLeft; f32 volRight; s32 halfPanIndex; @@ -13,45 +13,45 @@ void AudioPlayback_InitNoteSub(Note* note, NoteSubEu* noteSubEu, NoteSubAttribut u8 strongRight; f32 vel; u8 pan; - u8 reverbVol; + u8 targetReverbVol; StereoData stereoData; s32 stereoHeadsetEffects = note->playbackState.stereoHeadsetEffects; vel = subAttrs->velocity; pan = subAttrs->pan; - reverbVol = subAttrs->reverbVol; - stereoData = subAttrs->stereo.s; + targetReverbVol = subAttrs->targetReverbVol; + stereoData = subAttrs->stereoData; - noteSubEu->bitField0 = note->noteSubEu.bitField0; - noteSubEu->bitField1 = note->noteSubEu.bitField1; - noteSubEu->waveSampleAddr = note->noteSubEu.waveSampleAddr; - noteSubEu->harmonicIndexCurAndPrev = note->noteSubEu.harmonicIndexCurAndPrev; + sampleState->bitField0 = note->sampleState.bitField0; + sampleState->bitField1 = note->sampleState.bitField1; + sampleState->waveSampleAddr = note->sampleState.waveSampleAddr; + sampleState->harmonicIndexCurAndPrev = note->sampleState.harmonicIndexCurAndPrev; - AudioPlayback_NoteSetResamplingRate(noteSubEu, subAttrs->frequency); + AudioPlayback_NoteSetResamplingRate(sampleState, subAttrs->frequency); pan &= 0x7F; - noteSubEu->bitField0.stereoStrongRight = false; - noteSubEu->bitField0.stereoStrongLeft = false; - noteSubEu->bitField0.stereoHeadsetEffects = stereoData.stereoHeadsetEffects; - noteSubEu->bitField0.usesHeadsetPanEffects = stereoData.usesHeadsetPanEffects; + sampleState->bitField0.strongRight = false; + sampleState->bitField0.strongLeft = false; + sampleState->bitField0.strongReverbRight = stereoData.strongReverbRight; + sampleState->bitField0.strongReverbLeft = stereoData.strongReverbLeft; if (stereoHeadsetEffects && (gAudioContext.soundMode == SOUNDMODE_HEADSET)) { halfPanIndex = pan >> 1; if (halfPanIndex > 0x3F) { halfPanIndex = 0x3F; } - noteSubEu->headsetPanLeft = gHeadsetPanQuantization[halfPanIndex]; - noteSubEu->headsetPanRight = gHeadsetPanQuantization[0x3F - halfPanIndex]; - noteSubEu->bitField1.usesHeadsetPanEffects2 = true; + sampleState->haasEffectRightDelaySize = gHaasEffectDelaySize[halfPanIndex]; + sampleState->haasEffectLeftDelaySize = gHaasEffectDelaySize[0x3F - halfPanIndex]; + sampleState->bitField1.useHaasEffect = true; volLeft = gHeadsetPanVolume[pan]; volRight = gHeadsetPanVolume[0x7F - pan]; } else if (stereoHeadsetEffects && (gAudioContext.soundMode == SOUNDMODE_STEREO)) { strongLeft = strongRight = false; - noteSubEu->headsetPanRight = 0; - noteSubEu->headsetPanLeft = 0; - noteSubEu->bitField1.usesHeadsetPanEffects2 = false; + sampleState->haasEffectLeftDelaySize = 0; + sampleState->haasEffectRightDelaySize = 0; + sampleState->bitField1.useHaasEffect = false; volLeft = gStereoPanVolume[pan]; volRight = gStereoPanVolume[0x7F - pan]; @@ -62,37 +62,37 @@ void AudioPlayback_InitNoteSub(Note* note, NoteSubEu* noteSubEu, NoteSubAttribut } // case 0: - noteSubEu->bitField0.stereoStrongRight = strongRight; - noteSubEu->bitField0.stereoStrongLeft = strongLeft; + sampleState->bitField0.strongRight = strongRight; + sampleState->bitField0.strongLeft = strongLeft; - switch (stereoData.bit2) { + switch (stereoData.type) { case 0: break; case 1: - noteSubEu->bitField0.stereoStrongRight = stereoData.strongRight; - noteSubEu->bitField0.stereoStrongLeft = stereoData.strongLeft; + sampleState->bitField0.strongRight = stereoData.strongRight; + sampleState->bitField0.strongLeft = stereoData.strongLeft; break; case 2: - noteSubEu->bitField0.stereoStrongRight = stereoData.strongRight | strongRight; - noteSubEu->bitField0.stereoStrongLeft = stereoData.strongLeft | strongLeft; + sampleState->bitField0.strongRight = stereoData.strongRight | strongRight; + sampleState->bitField0.strongLeft = stereoData.strongLeft | strongLeft; break; case 3: - noteSubEu->bitField0.stereoStrongRight = stereoData.strongRight ^ strongRight; - noteSubEu->bitField0.stereoStrongLeft = stereoData.strongLeft ^ strongLeft; + sampleState->bitField0.strongRight = stereoData.strongRight ^ strongRight; + sampleState->bitField0.strongLeft = stereoData.strongLeft ^ strongLeft; break; } } else if (gAudioContext.soundMode == SOUNDMODE_MONO) { - noteSubEu->bitField0.stereoHeadsetEffects = false; - noteSubEu->bitField0.usesHeadsetPanEffects = false; + sampleState->bitField0.strongReverbRight = false; + sampleState->bitField0.strongReverbLeft = false; volLeft = 0.707f; // approx 1/sqrt(2) volRight = 0.707f; } else { - noteSubEu->bitField0.stereoStrongRight = stereoData.strongRight; - noteSubEu->bitField0.stereoStrongLeft = stereoData.strongLeft; + sampleState->bitField0.strongRight = stereoData.strongRight; + sampleState->bitField0.strongLeft = stereoData.strongLeft; volLeft = gDefaultPanVolume[pan]; volRight = gDefaultPanVolume[0x7F - pan]; } @@ -100,33 +100,33 @@ void AudioPlayback_InitNoteSub(Note* note, NoteSubEu* noteSubEu, NoteSubAttribut vel = 0.0f > vel ? 0.0f : vel; vel = 1.0f < vel ? 1.0f : vel; - noteSubEu->targetVolLeft = (s32)((vel * volLeft) * (0x1000 - 0.001f)); - noteSubEu->targetVolRight = (s32)((vel * volRight) * (0x1000 - 0.001f)); + sampleState->targetVolLeft = (s32)((vel * volLeft) * (0x1000 - 0.001f)); + sampleState->targetVolRight = (s32)((vel * volRight) * (0x1000 - 0.001f)); - noteSubEu->gain = subAttrs->gain; - noteSubEu->filter = subAttrs->filter; - noteSubEu->unk_07 = subAttrs->unk_14; - noteSubEu->unk_0E = subAttrs->unk_16; - noteSubEu->reverbVol = reverbVol; - noteSubEu->unk_19 = subAttrs->unk_3; + sampleState->gain = subAttrs->gain; + sampleState->filter = subAttrs->filter; + sampleState->combFilterSize = subAttrs->combFilterSize; + sampleState->combFilterGain = subAttrs->combFilterGain; + sampleState->targetReverbVol = targetReverbVol; + sampleState->surroundEffectIndex = subAttrs->surroundEffectIndex; } -void AudioPlayback_NoteSetResamplingRate(NoteSubEu* noteSubEu, f32 resamplingRateInput) { +void AudioPlayback_NoteSetResamplingRate(NoteSampleState* sampleState, f32 resamplingRateInput) { f32 resamplingRate = 0.0f; if (resamplingRateInput < 2.0f) { - noteSubEu->bitField1.hasTwoParts = false; + sampleState->bitField1.hasTwoParts = false; resamplingRate = CLAMP_MAX(resamplingRateInput, 1.99998f); } else { - noteSubEu->bitField1.hasTwoParts = true; + sampleState->bitField1.hasTwoParts = true; if (resamplingRateInput > 3.99996f) { resamplingRate = 1.99998f; } else { resamplingRate = resamplingRateInput * 0.5f; } } - noteSubEu->resamplingRateFixedPoint = (s32)(resamplingRate * 32768.0f); + sampleState->frequencyFixedPoint = (s32)(resamplingRate * 32768.0f); } void AudioPlayback_NoteInit(Note* note) { @@ -140,17 +140,17 @@ void AudioPlayback_NoteInit(Note* note) { note->playbackState.status = PLAYBACK_STATUS_0; note->playbackState.adsr.action.s.state = ADSR_STATE_INITIAL; - note->noteSubEu = gDefaultNoteSub; + note->sampleState = gDefaultSampleState; } void AudioPlayback_NoteDisable(Note* note) { - if (note->noteSubEu.bitField0.needsInit == true) { - note->noteSubEu.bitField0.needsInit = false; + if (note->sampleState.bitField0.needsInit == true) { + note->sampleState.bitField0.needsInit = false; } note->playbackState.priority = 0; - note->noteSubEu.bitField0.enabled = false; + note->sampleState.bitField0.enabled = false; note->playbackState.status = PLAYBACK_STATUS_0; - note->noteSubEu.bitField0.finished = false; + note->sampleState.bitField0.finished = false; note->playbackState.parentLayer = NO_LAYER; note->playbackState.prevParentLayer = NO_LAYER; note->playbackState.adsr.action.s.state = ADSR_STATE_DISABLED; @@ -161,8 +161,8 @@ void AudioPlayback_ProcessNotes(void) { s32 pad; s32 playbackStatus; NoteAttributes* attrs; - NoteSubEu* noteSubEu2; - NoteSubEu* noteSubEu; + NoteSampleState* sampleState; + NoteSampleState* noteSampleState; Note* note; NotePlaybackState* playbackState; NoteSubAttributes subAttrs; @@ -172,7 +172,7 @@ void AudioPlayback_ProcessNotes(void) { for (i = 0; i < gAudioContext.numNotes; i++) { note = &gAudioContext.notes[i]; - noteSubEu2 = &gAudioContext.noteSubsEu[gAudioContext.noteSubEuOffset + i]; + sampleState = &gAudioContext.sampleStateList[gAudioContext.sampleStateOffset + i]; playbackState = ¬e->playbackState; if (playbackState->parentLayer != NO_LAYER) { if ((u32)playbackState->parentLayer < 0x7FFFFFFF) { @@ -211,10 +211,12 @@ void AudioPlayback_ProcessNotes(void) { out: if (playbackState->priority != 0) { + //! FAKE: if (1) {} - noteSubEu = ¬e->noteSubEu; - if ((playbackState->status >= 1) || noteSubEu->bitField0.finished) { - if ((playbackState->adsr.action.s.state == ADSR_STATE_DISABLED) || noteSubEu->bitField0.finished) { + noteSampleState = ¬e->sampleState; + if ((playbackState->status >= 1) || noteSampleState->bitField0.finished) { + if ((playbackState->adsr.action.s.state == ADSR_STATE_DISABLED) || + noteSampleState->bitField0.finished) { if (playbackState->wantedParentLayer != NO_LAYER) { AudioPlayback_NoteDisable(note); if (playbackState->wantedParentLayer->channel != NULL) { @@ -260,14 +262,14 @@ void AudioPlayback_ProcessNotes(void) { subAttrs.frequency = attrs->freqScale; subAttrs.velocity = attrs->velocity; subAttrs.pan = attrs->pan; - subAttrs.reverbVol = attrs->reverb; - subAttrs.stereo = attrs->stereo; + subAttrs.targetReverbVol = attrs->targetReverbVol; + subAttrs.stereoData = attrs->stereoData; subAttrs.gain = attrs->gain; subAttrs.filter = attrs->filter; - subAttrs.unk_14 = attrs->unk_4; - subAttrs.unk_16 = attrs->unk_6; - subAttrs.unk_3 = attrs->unk_3; - bookOffset = noteSubEu->bitField1.bookOffset; + subAttrs.combFilterSize = attrs->combFilterSize; + subAttrs.combFilterGain = attrs->combFilterGain; + subAttrs.surroundEffectIndex = attrs->surroundEffectIndex; + bookOffset = noteSampleState->bitField1.bookOffset; } else { SequenceLayer* layer = playbackState->parentLayer; SequenceChannel* channel = playbackState->parentLayer->channel; @@ -276,34 +278,35 @@ void AudioPlayback_ProcessNotes(void) { subAttrs.velocity = layer->noteVelocity; subAttrs.pan = layer->notePan; - if (layer->unk_08 == 0x80) { - subAttrs.unk_3 = channel->unk_10; + if (layer->surroundEffectIndex == 0x80) { + subAttrs.surroundEffectIndex = channel->surroundEffectIndex; } else { - subAttrs.unk_3 = layer->unk_08; + subAttrs.surroundEffectIndex = layer->surroundEffectIndex; } - if (layer->stereo.s.bit2 == 0) { - subAttrs.stereo = channel->stereo; + if (layer->stereoData.type == 0) { + subAttrs.stereoData = channel->stereoData; } else { - subAttrs.stereo = layer->stereo; + subAttrs.stereoData = layer->stereoData; } if (layer->unk_0A.s.bit_2 == 1) { - subAttrs.reverbVol = channel->reverb; + subAttrs.targetReverbVol = channel->targetReverbVol; } else { - subAttrs.reverbVol = layer->unk_09; + subAttrs.targetReverbVol = layer->targetReverbVol; } if (layer->unk_0A.s.bit_9 == 1) { subAttrs.gain = channel->gain; } else { subAttrs.gain = 0; + //! FAKE: if (1) {} } subAttrs.filter = channel->filter; - subAttrs.unk_14 = channel->unk_0F; - subAttrs.unk_16 = channel->unk_20; + subAttrs.combFilterSize = channel->combFilterSize; + subAttrs.combFilterGain = channel->combFilterGain; bookOffset = channel->bookOffset & 0x7; if (channel->seqPlayer->muted && (channel->muteFlags & MUTE_FLAGS_3)) { @@ -315,8 +318,8 @@ void AudioPlayback_ProcessNotes(void) { subAttrs.frequency *= playbackState->vibratoFreqScale * playbackState->portamentoFreqScale; subAttrs.frequency *= gAudioContext.audioBufferParameters.resampleRate; subAttrs.velocity *= scale; - AudioPlayback_InitNoteSub(note, noteSubEu2, &subAttrs); - noteSubEu->bitField1.bookOffset = bookOffset; + AudioPlayback_InitSampleState(note, sampleState, &subAttrs); + noteSampleState->bitField1.bookOffset = bookOffset; skip:; } } @@ -500,15 +503,15 @@ void AudioPlayback_SeqLayerDecayRelease(SequenceLayer* layer, s32 target) { channel = layer->channel; if (layer->unk_0A.s.bit_2 == 1) { - attrs->reverb = channel->reverb; + attrs->targetReverbVol = channel->targetReverbVol; } else { - attrs->reverb = layer->unk_09; + attrs->targetReverbVol = layer->targetReverbVol; } - if (layer->unk_08 == 0x80) { - attrs->unk_3 = channel->unk_10; + if (layer->surroundEffectIndex == 0x80) { + attrs->surroundEffectIndex = channel->surroundEffectIndex; } else { - attrs->unk_3 = layer->unk_08; + attrs->surroundEffectIndex = layer->surroundEffectIndex; } if (layer->unk_0A.s.bit_9 == 1) { @@ -526,20 +529,20 @@ void AudioPlayback_SeqLayerDecayRelease(SequenceLayer* layer, s32 target) { attrs->filter = attrs->filterBuf; } - attrs->unk_6 = channel->unk_20; - attrs->unk_4 = channel->unk_0F; + attrs->combFilterGain = channel->combFilterGain; + attrs->combFilterSize = channel->combFilterSize; if (channel->seqPlayer->muted && (channel->muteFlags & MUTE_FLAGS_3)) { - note->noteSubEu.bitField0.finished = true; + note->sampleState.bitField0.finished = true; } - if (layer->stereo.asByte == 0) { - attrs->stereo = channel->stereo; + if (layer->stereoData.asByte == 0) { + attrs->stereoData = channel->stereoData; } else { - attrs->stereo = layer->stereo; + attrs->stereoData = layer->stereoData; } note->playbackState.priority = channel->someOtherPriority; } else { - attrs->stereo = layer->stereo; + attrs->stereoData = layer->stereoData; note->playbackState.priority = 1; } @@ -620,7 +623,7 @@ s32 AudioPlayback_BuildSyntheticWave(Note* note, SequenceLayer* layer, s32 waveI // Save the pointer to the synthethic wave // waveId index starts at 128, there are WAVE_SAMPLE_COUNT samples to read from - note->noteSubEu.waveSampleAddr = &gWaveSamples[waveId - 128][harmonicIndex * WAVE_SAMPLE_COUNT]; + note->sampleState.waveSampleAddr = &gWaveSamples[waveId - 128][harmonicIndex * WAVE_SAMPLE_COUNT]; return harmonicIndex; } @@ -638,7 +641,7 @@ void AudioPlayback_InitSyntheticWave(Note* note, SequenceLayer* layer) { curHarmonicIndex = AudioPlayback_BuildSyntheticWave(note, layer, waveId); if (curHarmonicIndex != prevHarmonicIndex) { - note->noteSubEu.harmonicIndexCurAndPrev = (curHarmonicIndex << 2) + prevHarmonicIndex; + note->sampleState.harmonicIndexCurAndPrev = (curHarmonicIndex << 2) + prevHarmonicIndex; } } @@ -808,7 +811,7 @@ void AudioPlayback_NoteInitForLayer(Note* note, SequenceLayer* layer) { s16 instId; SequenceChannel* channel = layer->channel; NotePlaybackState* playbackState = ¬e->playbackState; - NoteSubEu* noteSubEu = ¬e->noteSubEu; + NoteSampleState* noteSampleState = ¬e->sampleState; playbackState->prevParentLayer = NO_LAYER; playbackState->parentLayer = layer; @@ -825,28 +828,28 @@ void AudioPlayback_NoteInitForLayer(Note* note, SequenceLayer* layer) { if (instId == 0xFF) { instId = channel->instOrWave; } - noteSubEu->tunedSample = layer->tunedSample; + noteSampleState->tunedSample = layer->tunedSample; if (instId >= 0x80 && instId < 0xC0) { - noteSubEu->bitField1.isSyntheticWave = true; + noteSampleState->bitField1.isSyntheticWave = true; } else { - noteSubEu->bitField1.isSyntheticWave = false; + noteSampleState->bitField1.isSyntheticWave = false; } - if (noteSubEu->bitField1.isSyntheticWave) { + if (noteSampleState->bitField1.isSyntheticWave) { AudioPlayback_BuildSyntheticWave(note, layer, instId); } else if (channel->startSamplePos == 1) { - playbackState->startSamplePos = noteSubEu->tunedSample->sample->loop->start; + playbackState->startSamplePos = noteSampleState->tunedSample->sample->loop->start; } else { playbackState->startSamplePos = channel->startSamplePos; - if (playbackState->startSamplePos >= noteSubEu->tunedSample->sample->loop->end) { + if (playbackState->startSamplePos >= noteSampleState->tunedSample->sample->loop->loopEnd) { playbackState->startSamplePos = 0; } } playbackState->fontId = channel->fontId; playbackState->stereoHeadsetEffects = channel->stereoHeadsetEffects; - noteSubEu->bitField1.reverbIndex = channel->reverbIndex & 3; + noteSampleState->bitField1.reverbIndex = channel->reverbIndex & 3; } void func_801963E8(Note* note, SequenceLayer* layer) { @@ -987,7 +990,7 @@ void AudioPlayback_NoteInitAll(void) { for (i = 0; i < gAudioContext.numNotes; i++) { note = &gAudioContext.notes[i]; - note->noteSubEu = gZeroNoteSub; + note->sampleState = gZeroedSampleState; note->playbackState.priority = 0; note->playbackState.status = PLAYBACK_STATUS_0; note->playbackState.parentLayer = NO_LAYER; @@ -1002,7 +1005,8 @@ void AudioPlayback_NoteInitAll(void) { note->playbackState.portamento.speed = 0; note->playbackState.stereoHeadsetEffects = false; note->playbackState.startSamplePos = 0; - note->synthesisState.synthesisBuffers = AudioHeap_AllocDmaMemory(&gAudioContext.miscPool, 0x2E0); - note->playbackState.attributes.filterBuf = AudioHeap_AllocDmaMemory(&gAudioContext.miscPool, 0x10); + note->synthesisState.synthesisBuffers = + AudioHeap_AllocDmaMemory(&gAudioContext.miscPool, sizeof(NoteSynthesisBuffers)); + note->playbackState.attributes.filterBuf = AudioHeap_AllocDmaMemory(&gAudioContext.miscPool, FILTER_SIZE); } } diff --git a/src/code/audio/audio_seqplayer.c b/src/code/audio/audio_seqplayer.c index a8573e33d2..bc5115f8f6 100644 --- a/src/code/audio/audio_seqplayer.c +++ b/src/code/audio/audio_seqplayer.c @@ -282,17 +282,17 @@ void AudioSeq_InitSequenceChannel(SequenceChannel* channel) { channel->transposition = 0; channel->largeNotes = false; channel->bookOffset = 0; - channel->stereo.asByte = 0; + channel->stereoData.asByte = 0; channel->changes.asByte = 0xFF; channel->scriptState.depth = 0; channel->newPan = 0x40; channel->panChannelWeight = 0x80; - channel->unk_10 = 0xFF; + channel->surroundEffectIndex = 0xFF; channel->velocityRandomVariance = 0; channel->gateTimeRandomVariance = 0; channel->noteUnused = NULL; channel->reverbIndex = 0; - channel->reverb = 0; + channel->targetReverbVol = 0; channel->gain = 0; channel->notePriority = 3; channel->someOtherPriority = 1; @@ -308,8 +308,8 @@ void AudioSeq_InitSequenceChannel(SequenceChannel* channel) { channel->vibrato.vibratoExtentChangeDelay = 0; channel->vibrato.vibratoDelay = 0; channel->filter = NULL; - channel->unk_20 = 0; - channel->unk_0F = 0; + channel->combFilterGain = 0; + channel->combFilterSize = 0; channel->volume = 1.0f; channel->volumeScale = 1.0f; channel->freqScale = 1.0f; @@ -345,7 +345,7 @@ s32 AudioSeq_SeqChannelSetLayer(SequenceChannel* channel, s32 layerIndex) { layer->channel = channel; layer->adsr = channel->adsr; layer->adsr.decayIndex = 0; - layer->unk_09 = channel->reverb; + layer->targetReverbVol = channel->targetReverbVol; layer->enabled = true; layer->finished = false; layer->stopSomething = false; @@ -355,8 +355,8 @@ s32 AudioSeq_SeqChannelSetLayer(SequenceChannel* channel, s32 layerIndex) { layer->bit1 = false; layer->notePropertiesNeedInit = false; layer->gateTime = 0x80; - layer->unk_08 = 0x80; - layer->stereo.asByte = 0; + layer->surroundEffectIndex = 0x80; + layer->stereoData.asByte = 0; layer->portamento.mode = PORTAMENTO_MODE_OFF; layer->scriptState.depth = 0; layer->pan = 0x40; @@ -782,7 +782,7 @@ s32 AudioSeq_SeqLayerProcessScriptStep2(SequenceLayer* layer) { break; case 0xCD: // layer: stereo effects - layer->stereo.asByte = AudioSeq_ScriptReadU8(state); + layer->stereoData.asByte = AudioSeq_ScriptReadU8(state); break; case 0xCE: // layer: bend pitch @@ -796,7 +796,7 @@ s32 AudioSeq_SeqLayerProcessScriptStep2(SequenceLayer* layer) { break; case 0xF1: // layer: - layer->unk_08 = AudioSeq_ScriptReadU8(state); + layer->surroundEffectIndex = AudioSeq_ScriptReadU8(state); break; default: @@ -991,13 +991,14 @@ s32 AudioSeq_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd) { if (layer->delay == 0) { if (layer->tunedSample != NULL) { - time = layer->tunedSample->sample->loop->end; + time = layer->tunedSample->sample->loop->loopEnd; } else { time = 0.0f; } time *= seqPlayer->tempo; time *= gAudioContext.unk_2870; time /= layer->freqScale; + //! FAKE: if (1) {} if (time > 0x7FFE) { time = 0x7FFE; @@ -1416,9 +1417,9 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { channel->vibrato.vibratoDelay = cmd * 16; break; - case 0xD4: // channel: set reverb + case 0xD4: // channel: set reverb volume cmd = (u8)cmdArgs[0]; - channel->reverb = cmd; + channel->targetReverbVol = cmd; break; case 0xC6: // channel: set soundFont @@ -1491,7 +1492,7 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { } else { channel->stereoHeadsetEffects = false; } - channel->stereo.asByte = cmd & 0x7F; + channel->stereoData.asByte = cmd & 0x7F; break; case 0xD1: // channel: set note allocation policy @@ -1537,7 +1538,7 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { data += 4; channel->newPan = data[-3]; channel->panChannelWeight = data[-2]; - channel->reverb = data[-1]; + channel->targetReverbVol = data[-1]; channel->reverbIndex = data[0]; //! @bug: Not marking reverb state as changed channel->changes.s.pan = true; @@ -1551,7 +1552,7 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { channel->transposition = (s8)AudioSeq_ScriptReadU8(scriptState); channel->newPan = AudioSeq_ScriptReadU8(scriptState); channel->panChannelWeight = AudioSeq_ScriptReadU8(scriptState); - channel->reverb = AudioSeq_ScriptReadU8(scriptState); + channel->targetReverbVol = AudioSeq_ScriptReadU8(scriptState); channel->reverbIndex = AudioSeq_ScriptReadU8(scriptState); //! @bug: Not marking reverb state as changed channel->changes.s.pan = true; @@ -1569,8 +1570,8 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { channel->adsr.sustain = 0; channel->velocityRandomVariance = 0; channel->gateTimeRandomVariance = 0; - channel->unk_0F = 0; - channel->unk_20 = 0; + channel->combFilterSize = 0; + channel->combFilterGain = 0; channel->bookOffset = 0; channel->startSamplePos = 0; channel->unk_E0 = 0; @@ -1651,8 +1652,8 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { break; case 0xBB: // channel: - channel->unk_0F = cmdArgs[0]; - channel->unk_20 = cmdArgs[1]; + channel->combFilterSize = cmdArgs[0]; + channel->combFilterGain = cmdArgs[1]; break; case 0xBC: // channel: add large @@ -1667,8 +1668,8 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { if (cmdArgs[0] < 5) { if (1) {} if (gAudioContext.unk_29A8[cmdArgs[0]] != NULL) { - D_80208E6C = gAudioContext.unk_29A8[cmdArgs[0]]; - scriptState->value = D_80208E6C(scriptState->value, channel); + gCustomAudioSeqFunction = gAudioContext.unk_29A8[cmdArgs[0]]; + scriptState->value = gCustomAudioSeqFunction(scriptState->value, channel); } } break; @@ -1693,7 +1694,7 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { break; case 0xA4: // channel: - channel->unk_10 = cmdArgs[0]; + channel->surroundEffectIndex = cmdArgs[0]; break; case 0xA5: // channel: @@ -2197,7 +2198,7 @@ void AudioSeq_ProcessSequences(s32 arg0) { SequencePlayer* seqPlayer; u32 i; - gAudioContext.noteSubEuOffset = + gAudioContext.sampleStateOffset = (gAudioContext.audioBufferParameters.updatesPerFrame - arg0 - 1) * gAudioContext.numNotes; for (i = 0; i < (u32)gAudioContext.audioBufferParameters.numSequencePlayers; i++) { diff --git a/src/code/audio/audio_synthesis.c b/src/code/audio/audio_synthesis.c index 51842a33f7..17b3ff4bea 100644 --- a/src/code/audio/audio_synthesis.c +++ b/src/code/audio/audio_synthesis.c @@ -1,137 +1,1698 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801877D0.s") +// DMEM Addresses for the RSP +#define DMEM_TEMP 0x3B0 +#define DMEM_TEMP2 0x3C0 +#define DMEM_SURROUND_TEMP 0x4B0 +#define DMEM_UNCOMPRESSED_NOTE 0x570 +#define DMEM_HAAS_TEMP 0x5B0 +#define DMEM_COMB_TEMP 0x750 // = DMEM_TEMP + DMEM_2CH_SIZE + a bit more +#define DMEM_COMPRESSED_ADPCM_DATA 0x930 // = DMEM_LEFT_CH +#define DMEM_LEFT_CH 0x930 +#define DMEM_RIGHT_CH 0xAD0 +#define DMEM_WET_TEMP 0x3D0 +#define DMEM_WET_SCRATCH 0x710 // = DMEM_WET_TEMP + DMEM_2CH_SIZE +#define DMEM_WET_LEFT_CH 0xC70 +#define DMEM_WET_RIGHT_CH 0xE10 // = DMEM_WET_LEFT_CH + DMEM_1CH_SIZE + +typedef enum { + /* 0 */ HAAS_EFFECT_DELAY_NONE, + /* 1 */ HAAS_EFFECT_DELAY_LEFT, // Delay left channel so that right channel is heard first + /* 2 */ HAAS_EFFECT_DELAY_RIGHT // Delay right channel so that left channel is heard first +} HaasEffectDelaySide; + +Acmd* AudioSynth_SaveResampledReverbSamplesImpl(Acmd* cmd, u16 dmem, u16 arg2, uintptr_t arg3); +Acmd* AudioSynth_LoadReverbSamplesImpl(Acmd* cmd, u16 dmem, u16 startPos, s32 size, SynthesisReverb* reverb); +Acmd* AudioSynth_SaveReverbSamplesImpl(Acmd* cmd, u16 dmem, u16 startPos, s32 size, SynthesisReverb* reverb); +Acmd* AudioSynth_ProcessSamples(s16* aiBuf, s32 numSamplesPerUpdate, Acmd* cmd, s32 updateIndex); +Acmd* AudioSynth_ProcessSample(s32 noteIndex, NoteSampleState* sampleState, NoteSynthesisState* synthState, s16* aiBuf, + s32 numSamplesPerUpdate, Acmd* cmd, s32 updateIndex); +Acmd* AudioSynth_ApplySurroundEffect(Acmd* cmd, NoteSampleState* sampleState, NoteSynthesisState* synthState, s32 size, + s32 dmem, s32 flags); +Acmd* AudioSynth_FinalResample(Acmd* cmd, NoteSynthesisState* synthState, s32 size, u16 pitch, u16 inpDmem, + s32 resampleFlags); +Acmd* AudioSynth_ProcessEnvelope(Acmd* cmd, NoteSampleState* sampleState, NoteSynthesisState* synthState, + s32 numSamplesPerUpdate, u16 dmemSrc, s32 haasEffectDelaySide, s32 flags); +Acmd* AudioSynth_LoadWaveSamples(Acmd* cmd, NoteSampleState* sampleState, NoteSynthesisState* synthState, + s32 numSamplesToLoad); +Acmd* AudioSynth_ApplyHaasEffect(Acmd* cmd, NoteSampleState* sampleState, NoteSynthesisState* synthState, s32 size, + s32 flags, s32 haasEffectDelaySide); + +s32 D_801D5FB0 = 0; + +u32 sEnvMixerOp = _SHIFTL(A_ENVMIXER, 24, 8); + +// Store the left dry channel in a temp space to be delayed to produce the haas effect +u32 sEnvMixerLeftHaasDmemDests = + AUDIO_MK_CMD(DMEM_HAAS_TEMP >> 4, DMEM_RIGHT_CH >> 4, DMEM_WET_LEFT_CH >> 4, DMEM_WET_RIGHT_CH >> 4); + +// Store the right dry channel in a temp space to be delayed to produce the haas effect +u32 sEnvMixerRightHaasDmemDests = + AUDIO_MK_CMD(DMEM_LEFT_CH >> 4, DMEM_HAAS_TEMP >> 4, DMEM_WET_LEFT_CH >> 4, DMEM_WET_RIGHT_CH >> 4); + +u32 sEnvMixerDefaultDmemDests = + AUDIO_MK_CMD(DMEM_LEFT_CH >> 4, DMEM_RIGHT_CH >> 4, DMEM_WET_LEFT_CH >> 4, DMEM_WET_RIGHT_CH >> 4); + +// Unused Data +u16 D_801D5FC4[] = { + 0x7FFF, 0xD001, 0x3FFF, 0xF001, 0x5FFF, 0x9001, 0x7FFF, 0x8001, +}; + +u8 sNumSamplesPerWavePeriod[] = { + WAVE_SAMPLE_COUNT / 1, // 1st harmonic + WAVE_SAMPLE_COUNT / 2, // 2nd harmonic + WAVE_SAMPLE_COUNT / 4, // 4th harmonic + WAVE_SAMPLE_COUNT / 8, // 8th harmonic +}; + +/** + * Add a collection of s16-samples as a single entry to the reverb buffer + */ +void AudioSynth_AddReverbBufferEntry(s32 numSamples, s32 updateIndex, s32 reverbIndex) { + SynthesisReverb* reverb; + ReverbBufferEntry* entry; + s32 extraSamples; + s32 numSamplesAfterDownsampling; + s32 reverbBufPos; + s32 temp_t2; + s32 temp_t4; + s32 count1; + s32 count2; + s32 nextReverbSubBufPos; + + reverb = &gAudioContext.synthesisReverbs[reverbIndex]; + entry = &reverb->bufEntry[reverb->curFrame][updateIndex]; + + numSamplesAfterDownsampling = numSamples / gAudioContext.synthesisReverbs[reverbIndex].downsampleRate; + + // Apply resampling effect + if (gAudioContext.synthesisReverbs[reverbIndex].resampleEffectOn) { + if (reverb->downsampleRate == 1) { + count1 = 0; + count2 = 0; + + numSamplesAfterDownsampling += reverb->resampleEffectExtraSamples; + + entry->saveResampleNumSamples = numSamplesAfterDownsampling; + entry->loadResamplePitch = ((u16)numSamplesAfterDownsampling << 0xF) / numSamples; + entry->saveResamplePitch = (numSamples << 0xF) / (u16)numSamplesAfterDownsampling; + + while (true) { + temp_t2 = (entry->loadResamplePitch * numSamples * 2) + reverb->resampleEffectLoadUnk; + temp_t4 = temp_t2 >> 0x10; + + if ((temp_t4 != numSamplesAfterDownsampling) && (count1 == 0)) { + entry->loadResamplePitch = + ((numSamplesAfterDownsampling << 0x10) - reverb->resampleEffectLoadUnk) / (numSamples * 2); + count1++; + } else { + count1++; + if (temp_t4 > numSamplesAfterDownsampling) { + entry->loadResamplePitch--; + } else if (temp_t4 < numSamplesAfterDownsampling) { + entry->loadResamplePitch++; + } else { + break; + } + } + } + + reverb->resampleEffectLoadUnk = temp_t2 & 0xFFFF; + + while (true) { + temp_t2 = (entry->saveResamplePitch * numSamplesAfterDownsampling * 2) + reverb->resampleEffectSaveUnk; + temp_t4 = temp_t2 >> 0x10; + + if ((temp_t4 != numSamples) && (count2 == 0)) { + entry->saveResamplePitch = + ((numSamples << 0x10) - reverb->resampleEffectSaveUnk) / (numSamplesAfterDownsampling * 2); + count2++; + } else { + count2++; + if (temp_t4 > numSamples) { + entry->saveResamplePitch--; + } else if (temp_t4 < numSamples) { + entry->saveResamplePitch++; + } else { + break; + } + } + } + + reverb->resampleEffectSaveUnk = temp_t2 & 0xFFFF; + } + } + + extraSamples = (reverb->nextReverbBufPos + numSamplesAfterDownsampling) - reverb->delayNumSamples; + reverbBufPos = reverb->nextReverbBufPos; + + // Add a reverb entry + if (extraSamples < 0) { + entry->size = numSamplesAfterDownsampling * SAMPLE_SIZE; + entry->wrappedSize = 0; + entry->startPos = reverb->nextReverbBufPos; + reverb->nextReverbBufPos += numSamplesAfterDownsampling; + } else { + // End of the buffer is reached. Loop back around + entry->size = (numSamplesAfterDownsampling - extraSamples) * SAMPLE_SIZE; + entry->wrappedSize = extraSamples * SAMPLE_SIZE; + entry->startPos = reverb->nextReverbBufPos; + reverb->nextReverbBufPos = extraSamples; + } + + entry->numSamplesAfterDownsampling = numSamplesAfterDownsampling; + entry->numSamples = numSamples; + + // Add a sub-reverb entry + if (reverb->subDelay != 0) { + nextReverbSubBufPos = reverb->subDelay + reverbBufPos; + if (nextReverbSubBufPos >= reverb->delayNumSamples) { + nextReverbSubBufPos -= reverb->delayNumSamples; + } + + entry = &reverb->subBufEntry[reverb->curFrame][updateIndex]; + numSamplesAfterDownsampling = numSamples / reverb->downsampleRate; + extraSamples = (nextReverbSubBufPos + numSamplesAfterDownsampling) - reverb->delayNumSamples; + + if (extraSamples < 0) { + entry->size = numSamplesAfterDownsampling * SAMPLE_SIZE; + entry->wrappedSize = 0; + entry->startPos = nextReverbSubBufPos; + } else { + // End of the buffer is reached. Loop back around + entry->size = (numSamplesAfterDownsampling - extraSamples) * SAMPLE_SIZE; + entry->wrappedSize = extraSamples * SAMPLE_SIZE; + entry->startPos = nextReverbSubBufPos; + } + + entry->numSamplesAfterDownsampling = numSamplesAfterDownsampling; + entry->numSamples = numSamples; + } +} + +/** + * Sync the sample states between the notes and the list + */ +void AudioSynth_SyncSampleStates(s32 updateIndex) { + NoteSampleState* noteSampleState; + NoteSampleState* sampleState; + s32 sampleStateBaseIndex; + s32 i; + + sampleStateBaseIndex = gAudioContext.numNotes * updateIndex; + for (i = 0; i < gAudioContext.numNotes; i++) { + noteSampleState = &gAudioContext.notes[i].sampleState; + sampleState = &gAudioContext.sampleStateList[sampleStateBaseIndex + i]; + if (noteSampleState->bitField0.enabled) { + noteSampleState->bitField0.needsInit = false; + } else { + sampleState->bitField0.enabled = false; + } + + noteSampleState->harmonicIndexCurAndPrev = 0; + } +} + +Acmd* AudioSynth_Update(Acmd* abiCmdStart, s32* numAbiCmds, s16* aiBufStart, s32 numSamplesPerFrame) { + s32 numSamplesPerUpdate; + s16* curAiBufPos; + Acmd* curCmd = abiCmdStart; + s32 reverseUpdateIndex; + s32 reverbIndex; + SynthesisReverb* reverb; + + for (reverseUpdateIndex = gAudioContext.audioBufferParameters.updatesPerFrame; reverseUpdateIndex > 0; + reverseUpdateIndex--) { + AudioSeq_ProcessSequences(reverseUpdateIndex - 1); + AudioSynth_SyncSampleStates(gAudioContext.audioBufferParameters.updatesPerFrame - reverseUpdateIndex); + } + + curAiBufPos = aiBufStart; + gAudioContext.adpcmCodeBook = NULL; + + // Process/Update all samples multiple times in a single frame + for (reverseUpdateIndex = gAudioContext.audioBufferParameters.updatesPerFrame; reverseUpdateIndex > 0; + reverseUpdateIndex--) { + if (reverseUpdateIndex == 1) { + // Final Update + numSamplesPerUpdate = numSamplesPerFrame; + } else if ((numSamplesPerFrame / reverseUpdateIndex) >= + gAudioContext.audioBufferParameters.numSamplesPerUpdateMax) { + numSamplesPerUpdate = gAudioContext.audioBufferParameters.numSamplesPerUpdateMax; + } else if ((numSamplesPerFrame / reverseUpdateIndex) <= + gAudioContext.audioBufferParameters.numSamplesPerUpdateMin) { + numSamplesPerUpdate = gAudioContext.audioBufferParameters.numSamplesPerUpdateMin; + } else { + numSamplesPerUpdate = gAudioContext.audioBufferParameters.numSamplesPerUpdate; + } + + for (reverbIndex = 0; reverbIndex < gAudioContext.numSynthesisReverbs; reverbIndex++) { + if (gAudioContext.synthesisReverbs[reverbIndex].useReverb) { + AudioSynth_AddReverbBufferEntry( + numSamplesPerUpdate, gAudioContext.audioBufferParameters.updatesPerFrame - reverseUpdateIndex, + reverbIndex); + } + } + + curCmd = AudioSynth_ProcessSamples(curAiBufPos, numSamplesPerUpdate, curCmd, + gAudioContext.audioBufferParameters.updatesPerFrame - reverseUpdateIndex); + numSamplesPerFrame -= numSamplesPerUpdate; + curAiBufPos += numSamplesPerUpdate * SAMPLE_SIZE; + } + + // Update reverb frame info + for (reverbIndex = 0; reverbIndex < gAudioContext.numSynthesisReverbs; reverbIndex++) { + if (gAudioContext.synthesisReverbs[reverbIndex].framesToIgnore != 0) { + gAudioContext.synthesisReverbs[reverbIndex].framesToIgnore--; + } + gAudioContext.synthesisReverbs[reverbIndex].curFrame ^= 1; + } + + *numAbiCmds = curCmd - abiCmdStart; + return curCmd; +} + +void AudioSynth_DisableSampleStates(s32 updateIndex, s32 noteIndex) { + NoteSampleState* sampleState; + s32 i; + + for (i = updateIndex + 1; i < gAudioContext.audioBufferParameters.updatesPerFrame; i++) { + sampleState = &gAudioContext.sampleStateList[(gAudioContext.numNotes * i) + noteIndex]; + if (sampleState->bitField0.needsInit) { + break; + } + sampleState->bitField0.enabled = false; + } +} + +/** + * Load reverb samples from a different reverb index + */ +Acmd* AudioSynth_LoadMixedReverbSamples(Acmd* cmd, SynthesisReverb* reverb, s16 updateIndex) { + ReverbBufferEntry* entry = &reverb->bufEntry[reverb->curFrame][updateIndex]; + + cmd = AudioSynth_LoadReverbSamplesImpl(cmd, DMEM_WET_TEMP, entry->startPos, entry->size, reverb); + if (entry->wrappedSize != 0) { + // Ring buffer wrapped + cmd = AudioSynth_LoadReverbSamplesImpl(cmd, DMEM_WET_TEMP + entry->size, 0, entry->wrappedSize, reverb); + } + return cmd; +} + +/** + * Save reverb samples from a different reverb index + */ +Acmd* AudioSynth_SaveMixedReverbSamples(Acmd* cmd, SynthesisReverb* reverb, s16 updateIndex) { + ReverbBufferEntry* entry = &reverb->bufEntry[reverb->curFrame][updateIndex]; + + cmd = AudioSynth_SaveReverbSamplesImpl(cmd, DMEM_WET_TEMP, entry->startPos, entry->size, reverb); + if (entry->wrappedSize != 0) { + // Ring buffer wrapped + cmd = AudioSynth_SaveReverbSamplesImpl(cmd, DMEM_WET_TEMP + entry->size, 0, entry->wrappedSize, reverb); + } + return cmd; +} + +void AudioSynth_Noop1(void) { +} + +void AudioSynth_ClearBuffer(Acmd* cmd, s32 dmem, s32 size) { + aClearBuffer(cmd, dmem, size); +} + +void AudioSynth_Noop2(void) { +} + +void AudioSynth_Noop3(void) { +} + +void AudioSynth_Noop4(void) { +} + +void AudioSynth_Mix(Acmd* cmd, size_t size, s32 gain, s32 dmemIn, s32 dmemOut) { + aMix(cmd, size, gain, dmemIn, dmemOut); +} + +void AudioSynth_Noop5(void) { +} + +void AudioSynth_Noop6(void) { +} + +void AudioSynth_Noop7(void) { +} + +void AudioSynth_SetBuffer(Acmd* cmd, s32 flags, s32 dmemIn, s32 dmemOut, size_t size) { + aSetBuffer(cmd, flags, dmemIn, dmemOut, size); +} + +void AudioSynth_Noop8(void) { +} + +void AudioSynth_Noop9(void) { +} + +void AudioSynth_DMemMove(Acmd* cmd, s32 dmemIn, s32 dmemOut, size_t size) { + // aDMEMMove(cmd, dmemIn, dmemOut, size); + cmd->words.w0 = _SHIFTL(A_DMEMMOVE, 24, 8) | _SHIFTL(dmemIn, 0, 24); + cmd->words.w1 = _SHIFTL(dmemOut, 16, 16) | _SHIFTL(size, 0, 16); +} + +void AudioSynth_Noop10(void) { +} + +void AudioSynth_Noop11(void) { +} + +void AudioSynth_Noop12(void) { +} + +void AudioSynth_Noop13(void) { +} + +void AudioSynth_InterL(Acmd* cmd, s32 dmemIn, s32 dmemOut, s32 numSamples) { + // aInterl(cmd, dmemIn, dmemOut, numSamples); + cmd->words.w0 = _SHIFTL(A_INTERL, 24, 8) | _SHIFTL(numSamples, 0, 16); + cmd->words.w1 = _SHIFTL(dmemIn, 16, 16) | _SHIFTL(dmemOut, 0, 16); +} + +void AudioSynth_EnvSetup1(Acmd* cmd, s32 reverbVol, s32 rampReverb, s32 rampLeft, s32 rampRight) { + aEnvSetup1(cmd, reverbVol, rampReverb, rampLeft, rampRight); +} + +void AudioSynth_Noop14(void) { +} + +void AudioSynth_LoadBuffer(Acmd* cmd, s32 dmemDest, s32 size, void* addrSrc) { + aLoadBuffer(cmd, addrSrc, dmemDest, size); +} + +void AudioSynth_SaveBuffer(Acmd* cmd, s32 dmemSrc, s32 size, void* addrDest) { + aSaveBuffer(cmd, dmemSrc, addrDest, size); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80187B64.s") +void AudioSynth_EnvSetup2(Acmd* cmd, s32 volLeft, s32 volRight) { + // aEnvSetup2(cmd, volLeft, volRight); + cmd->words.w0 = _SHIFTL(A_ENVSETUP2, 24, 8); + cmd->words.w1 = _SHIFTL(volLeft, 16, 16) | _SHIFTL(volRight, 0, 16); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80187BEC.s") +void AudioSynth_Noop15(void) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80187DE8.s") +void AudioSynth_Noop16(void) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80187E58.s") +void AudioSynth_Noop17(void) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80187F00.s") +void AudioSynth_S8Dec(Acmd* cmd, s32 flags, s16* state) { + aS8Dec(cmd, flags, state); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80187FA8.s") +void AudioSynth_HiLoGain(Acmd* cmd, s32 gain, s32 dmemIn, s32 dmemOut, s32 size) { + // aHiLoGain(cmd, gain, size, dmemIn, dmemOut); + cmd->words.w0 = _SHIFTL(A_HILOGAIN, 24, 8) | _SHIFTL(gain, 16, 8) | _SHIFTL(size, 0, 16); + cmd->words.w1 = _SHIFTL(dmemIn, 16, 16) | _SHIFTL(dmemOut, 0, 16); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80187FB0.s") +// Remnant of OoT +void AudioSynth_UnkCmd19(Acmd* cmd, s32 dmem1, s32 dmem2, s32 size, s32 arg4) { + cmd->words.w0 = _SHIFTL(A_SPNOOP, 24, 8) | _SHIFTL(arg4, 16, 8) | _SHIFTL(size, 0, 16); + cmd->words.w1 = _SHIFTL(dmem1, 16, 16) | _SHIFTL(dmem2, 0, 16); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80187FD0.s") +void AudioSynth_Noop18(void) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80187FD8.s") +void AudioSynth_Noop19(void) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80187FE0.s") +void AudioSynth_Noop20(void) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80187FE8.s") +void AudioSynth_Noop21(void) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018801C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188024.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018802C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188034.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188068.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188070.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188078.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801880A4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801880AC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801880B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801880BC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801880C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801880E8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018811C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188124.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018814C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188174.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188190.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188198.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801881A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801881A8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801881C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801881F8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188224.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018822C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188234.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018823C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188244.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018824C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188254.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018825C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188264.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188288.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801882A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188304.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801884A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188698.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018883C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801888E4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801889A4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188A50.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188AFC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188C48.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188CB4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188D20.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188D28.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188D68.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188DDC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188FBC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80189064.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80189620.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018A4B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018A768.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018A808.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018ACC4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018AE34.s") +void AudioSynth_Noop22(void) { +} + +void AudioSynth_Noop23(void) { +} + +void AudioSynth_Noop24(void) { +} + +void AudioSynth_Noop25(void) { +} + +void AudioSynth_LoadFilterBuffer(Acmd* cmd, s32 flags, s32 buf, s16* addr) { + aFilter(cmd, flags, buf, addr); +} + +void AudioSynth_LoadFilterSize(Acmd* cmd, size_t size, s16* addr) { + aFilter(cmd, 2, size, addr); +} + +/** + * Leak some audio from the left reverb channel into the right reverb channel and vice versa (pan) + */ +Acmd* AudioSynth_LeakReverb(Acmd* cmd, SynthesisReverb* reverb) { + aDMEMMove(cmd++, DMEM_WET_LEFT_CH, DMEM_WET_SCRATCH, DMEM_1CH_SIZE); + aMix(cmd++, DMEM_1CH_SIZE >> 4, reverb->leakRtl, DMEM_WET_RIGHT_CH, DMEM_WET_LEFT_CH); + aMix(cmd++, DMEM_1CH_SIZE >> 4, reverb->leakLtr, DMEM_WET_SCRATCH, DMEM_WET_RIGHT_CH); + + return cmd; +} + +Acmd* AudioSynth_LoadDownsampledReverbSamples(Acmd* cmd, s32 numSamplesPerUpdate, SynthesisReverb* reverb, + s16 updateIndex) { + ReverbBufferEntry* entry = &reverb->bufEntry[reverb->curFrame][updateIndex]; + s16 offsetSize = (entry->startPos & 7) * SAMPLE_SIZE; + s16 wrappedOffsetSize = ALIGN16(offsetSize + entry->size); + + cmd = AudioSynth_LoadReverbSamplesImpl(cmd, DMEM_WET_TEMP, entry->startPos - (offsetSize / (s32)SAMPLE_SIZE), + DMEM_1CH_SIZE, reverb); + + if (entry->wrappedSize != 0) { + // Ring buffer wrapped + cmd = AudioSynth_LoadReverbSamplesImpl(cmd, DMEM_WET_TEMP + wrappedOffsetSize, 0, + DMEM_1CH_SIZE - wrappedOffsetSize, reverb); + } + + aSetBuffer(cmd++, 0, DMEM_WET_TEMP + offsetSize, DMEM_WET_LEFT_CH, numSamplesPerUpdate * SAMPLE_SIZE); + aResample(cmd++, reverb->resampleFlags, reverb->downsamplePitch, reverb->leftLoadResampleBuf); + aSetBuffer(cmd++, 0, DMEM_WET_TEMP + DMEM_1CH_SIZE + offsetSize, DMEM_WET_RIGHT_CH, + numSamplesPerUpdate * SAMPLE_SIZE); + aResample(cmd++, reverb->resampleFlags, reverb->downsamplePitch, reverb->rightLoadResampleBuf); + + return cmd; +} + +Acmd* AudioSynth_SaveResampledReverbSamples(Acmd* cmd, SynthesisReverb* reverb, s16 updateIndex) { + ReverbBufferEntry* entry = &reverb->bufEntry[reverb->curFrame][updateIndex]; + s16 numSamples = entry->numSamples; + u32 size = numSamples * SAMPLE_SIZE; + + // Left Resample + aDMEMMove(cmd++, DMEM_WET_LEFT_CH, DMEM_WET_TEMP, size); + aSetBuffer(cmd++, 0, DMEM_WET_TEMP, DMEM_WET_SCRATCH, entry->saveResampleNumSamples * SAMPLE_SIZE); + aResample(cmd++, reverb->resampleFlags, entry->saveResamplePitch, reverb->leftSaveResampleBuf); + + cmd = AudioSynth_SaveResampledReverbSamplesImpl(cmd, DMEM_WET_SCRATCH, entry->size, + &reverb->leftReverbBuf[entry->startPos]); + + if (entry->wrappedSize != 0) { + // Ring buffer wrapped + cmd = AudioSynth_SaveResampledReverbSamplesImpl(cmd, entry->size + DMEM_WET_SCRATCH, entry->wrappedSize, + reverb->leftReverbBuf); + } + + // Right Resample + aDMEMMove(cmd++, DMEM_WET_RIGHT_CH, DMEM_WET_TEMP, size); + aSetBuffer(cmd++, 0, DMEM_WET_TEMP, DMEM_WET_SCRATCH, entry->saveResampleNumSamples * SAMPLE_SIZE); + aResample(cmd++, reverb->resampleFlags, entry->saveResamplePitch, reverb->rightSaveResampleBuf); + + cmd = AudioSynth_SaveResampledReverbSamplesImpl(cmd, DMEM_WET_SCRATCH, entry->size, + &reverb->rightReverbBuf[entry->startPos]); + + if (entry->wrappedSize != 0) { + // Ring buffer wrapped + cmd = AudioSynth_SaveResampledReverbSamplesImpl(cmd, entry->size + DMEM_WET_SCRATCH, entry->wrappedSize, + reverb->rightReverbBuf); + } + + return cmd; +} + +Acmd* AudioSynth_LoadResampledReverbSamples(Acmd* cmd, s32 numSamplesPerUpdate, SynthesisReverb* reverb, + s16 updateIndex) { + ReverbBufferEntry* entry = &reverb->bufEntry[reverb->curFrame][updateIndex]; + s16 offsetSize = (entry->startPos & 7) * SAMPLE_SIZE; + s16 wrappedOffsetSize = ALIGN16(offsetSize + entry->size); + + cmd = AudioSynth_LoadReverbSamplesImpl(cmd, DMEM_WET_TEMP, entry->startPos - (offsetSize / (s32)SAMPLE_SIZE), + DMEM_1CH_SIZE, reverb); + + if (entry->wrappedSize != 0) { + // Ring buffer wrapped + cmd = AudioSynth_LoadReverbSamplesImpl(cmd, wrappedOffsetSize + DMEM_WET_TEMP, 0, + DMEM_1CH_SIZE - wrappedOffsetSize, reverb); + } + + aSetBuffer(cmd++, 0, DMEM_WET_TEMP + offsetSize, DMEM_WET_LEFT_CH, numSamplesPerUpdate * SAMPLE_SIZE); + aResample(cmd++, reverb->resampleFlags, entry->loadResamplePitch, reverb->leftLoadResampleBuf); + aSetBuffer(cmd++, 0, DMEM_WET_TEMP + DMEM_1CH_SIZE + offsetSize, DMEM_WET_RIGHT_CH, + numSamplesPerUpdate * SAMPLE_SIZE); + aResample(cmd++, reverb->resampleFlags, entry->loadResamplePitch, reverb->rightLoadResampleBuf); + + return cmd; +} + +/** + * Apply a filter (convolution) to each reverb channel. + */ +Acmd* AudioSynth_FilterReverb(Acmd* cmd, s32 size, SynthesisReverb* reverb) { + if (reverb->filterLeft != NULL) { + aFilter(cmd++, 2, size, reverb->filterLeft); + aFilter(cmd++, reverb->resampleFlags, DMEM_WET_LEFT_CH, reverb->filterLeftState); + } + + if (reverb->filterRight != NULL) { + aFilter(cmd++, 2, size, reverb->filterRight); + aFilter(cmd++, reverb->resampleFlags, DMEM_WET_RIGHT_CH, reverb->filterRightState); + } + + return cmd; +} + +/** + * Mix in reverb from a different reverb index + */ +Acmd* AudioSynth_MixOtherReverbIndex(Acmd* cmd, SynthesisReverb* reverb, s32 updateIndex) { + SynthesisReverb* mixReverb; + + if (reverb->mixReverbIndex >= gAudioContext.numSynthesisReverbs) { + return cmd; + } + + mixReverb = &gAudioContext.synthesisReverbs[reverb->mixReverbIndex]; + if (mixReverb->downsampleRate == 1) { + cmd = AudioSynth_LoadMixedReverbSamples(cmd, mixReverb, updateIndex); + aMix(cmd++, DMEM_2CH_SIZE >> 4, reverb->mixReverbStrength, DMEM_WET_LEFT_CH, DMEM_WET_TEMP); + cmd = AudioSynth_SaveMixedReverbSamples(cmd, mixReverb, updateIndex); + } + + return cmd; +} + +Acmd* AudioSynth_LoadDefaultReverbSamples(Acmd* cmd, s32 numSamplesPerUpdate, SynthesisReverb* reverb, + s16 updateIndex) { + ReverbBufferEntry* entry = &reverb->bufEntry[reverb->curFrame][updateIndex]; + + cmd = AudioSynth_LoadReverbSamplesImpl(cmd, DMEM_WET_LEFT_CH, entry->startPos, entry->size, reverb); + if (entry->wrappedSize != 0) { + // Ring buffer wrapped + cmd = AudioSynth_LoadReverbSamplesImpl(cmd, DMEM_WET_LEFT_CH + entry->size, 0, entry->wrappedSize, reverb); + } + + return cmd; +} + +Acmd* AudioSynth_LoadSubReverbSamples(Acmd* cmd, s32 numSamplesPerUpdate, SynthesisReverb* reverb, s16 updateIndex) { + ReverbBufferEntry* subEntry = &reverb->subBufEntry[reverb->curFrame][updateIndex]; + + cmd = AudioSynth_LoadReverbSamplesImpl(cmd, DMEM_WET_LEFT_CH, subEntry->startPos, subEntry->size, reverb); + if (subEntry->wrappedSize != 0) { + // Ring buffer wrapped + cmd = + AudioSynth_LoadReverbSamplesImpl(cmd, DMEM_WET_LEFT_CH + subEntry->size, 0, subEntry->wrappedSize, reverb); + } + + return cmd; +} + +Acmd* AudioSynth_SaveResampledReverbSamplesImpl(Acmd* cmd, u16 dmem, u16 size, uintptr_t startAddr) { + s32 startAddrAlignDropped; + u32 endAddr; + s32 endAddrAlignDropped; + + endAddr = startAddr + size; + + endAddrAlignDropped = endAddr & 0xF; + if (endAddrAlignDropped != 0) { + aLoadBuffer(cmd++, (endAddr - endAddrAlignDropped), DMEM_TEMP, 0x10); + aDMEMMove(cmd++, dmem, DMEM_TEMP2, size); + aDMEMMove(cmd++, DMEM_TEMP + endAddrAlignDropped, size + DMEM_TEMP2, 0x10 - endAddrAlignDropped); + + size += (0x10 - endAddrAlignDropped); + dmem = DMEM_TEMP2; + } + + startAddrAlignDropped = startAddr & 0xF; + if (startAddrAlignDropped != 0) { + aLoadBuffer(cmd++, startAddr - startAddrAlignDropped, DMEM_TEMP, 0x10); + aDMEMMove(cmd++, dmem, startAddrAlignDropped + DMEM_TEMP, size); + + size += startAddrAlignDropped; + dmem = DMEM_TEMP; + } + + aSaveBuffer(cmd++, dmem, startAddr - startAddrAlignDropped, size); + + return cmd; +} + +Acmd* AudioSynth_LoadReverbSamplesImpl(Acmd* cmd, u16 dmem, u16 startPos, s32 size, SynthesisReverb* reverb) { + aLoadBuffer(cmd++, &reverb->leftReverbBuf[startPos], dmem, size); + aLoadBuffer(cmd++, &reverb->rightReverbBuf[startPos], dmem + DMEM_1CH_SIZE, size); + + return cmd; +} + +Acmd* AudioSynth_SaveReverbSamplesImpl(Acmd* cmd, u16 dmem, u16 startPos, s32 size, SynthesisReverb* reverb) { + aSaveBuffer(cmd++, dmem, &reverb->leftReverbBuf[startPos], size); + aSaveBuffer(cmd++, dmem + DMEM_1CH_SIZE, &reverb->rightReverbBuf[startPos], size); + + return cmd; +} + +void AudioSynth_Noop26(void) { +} + +Acmd* AudioSynth_LoadSubReverbSamplesWithoutDownsample(Acmd* cmd, s32 numSamplesPerUpdate, SynthesisReverb* reverb, + s16 updateIndex) { + if (reverb->downsampleRate == 1) { + cmd = AudioSynth_LoadSubReverbSamples(cmd, numSamplesPerUpdate, reverb, updateIndex); + } + + return cmd; +} + +Acmd* AudioSynth_LoadReverbSamples(Acmd* cmd, s32 numSamplesPerUpdate, SynthesisReverb* reverb, s16 updateIndex) { + if (reverb->downsampleRate == 1) { + if (reverb->resampleEffectOn) { + cmd = AudioSynth_LoadResampledReverbSamples(cmd, numSamplesPerUpdate, reverb, updateIndex); + } else { + cmd = AudioSynth_LoadDefaultReverbSamples(cmd, numSamplesPerUpdate, reverb, updateIndex); + } + } else { + cmd = AudioSynth_LoadDownsampledReverbSamples(cmd, numSamplesPerUpdate, reverb, updateIndex); + } + + return cmd; +} + +Acmd* AudioSynth_SaveReverbSamples(Acmd* cmd, SynthesisReverb* reverb, s16 updateIndex) { + ReverbBufferEntry* entry = &reverb->bufEntry[reverb->curFrame][updateIndex]; + s32 downsampleRate; + s32 numSamples; + + if (reverb->downsampleRate == 1) { + if (reverb->resampleEffectOn) { + cmd = AudioSynth_SaveResampledReverbSamples(cmd, reverb, updateIndex); + } else { + // Put the oldest samples in the ring buffer into the wet channels + cmd = AudioSynth_SaveReverbSamplesImpl(cmd, DMEM_WET_LEFT_CH, entry->startPos, entry->size, reverb); + if (entry->wrappedSize != 0) { + // Ring buffer wrapped + cmd = AudioSynth_SaveReverbSamplesImpl(cmd, DMEM_WET_LEFT_CH + entry->size, 0, entry->wrappedSize, + reverb); + } + } + } else { + //! FAKE: + if (1) {} + + downsampleRate = reverb->downsampleRate; + numSamples = 13 * SAMPLES_PER_FRAME; + + while (downsampleRate >= 2) { + aInterl(cmd++, DMEM_WET_LEFT_CH, DMEM_WET_LEFT_CH, numSamples); + aInterl(cmd++, DMEM_WET_RIGHT_CH, DMEM_WET_RIGHT_CH, numSamples); + downsampleRate >>= 1; + numSamples >>= 1; + } + + if (entry->size != 0) { + cmd = AudioSynth_SaveResampledReverbSamplesImpl(cmd, DMEM_WET_LEFT_CH, entry->size, + &reverb->leftReverbBuf[entry->startPos]); + cmd = AudioSynth_SaveResampledReverbSamplesImpl(cmd, DMEM_WET_RIGHT_CH, entry->size, + &reverb->rightReverbBuf[entry->startPos]); + } + + if (entry->wrappedSize != 0) { + cmd = AudioSynth_SaveResampledReverbSamplesImpl(cmd, entry->size + DMEM_WET_LEFT_CH, entry->wrappedSize, + reverb->leftReverbBuf); + cmd = AudioSynth_SaveResampledReverbSamplesImpl(cmd, entry->size + DMEM_WET_RIGHT_CH, entry->wrappedSize, + reverb->rightReverbBuf); + } + } + + reverb->resampleFlags = 0; + + return cmd; +} + +Acmd* AudioSynth_SaveSubReverbSamples(Acmd* cmd, SynthesisReverb* reverb, s16 updateIndex) { + ReverbBufferEntry* subEntry = &reverb->subBufEntry[reverb->curFrame][updateIndex]; + + cmd = AudioSynth_SaveReverbSamplesImpl(cmd, DMEM_WET_LEFT_CH, subEntry->startPos, subEntry->size, reverb); + if (subEntry->wrappedSize != 0) { + // Ring buffer wrapped + cmd = + AudioSynth_SaveReverbSamplesImpl(cmd, DMEM_WET_LEFT_CH + subEntry->size, 0, subEntry->wrappedSize, reverb); + } + + return cmd; +} + +/** + * Process all samples embedded in a note. Every sample has numSamplesPerUpdate processed, + * and each of those are mixed together into both DMEM_LEFT_CH and DMEM_RIGHT_CH + */ +Acmd* AudioSynth_ProcessSamples(s16* aiBuf, s32 numSamplesPerUpdate, Acmd* cmd, s32 updateIndex) { + s32 size; + u8 noteIndices[0x58]; + s16 noteCount = 0; + s16 reverbIndex; + SynthesisReverb* reverb; + s32 useReverb; + s32 sampleStateOffset = gAudioContext.numNotes * updateIndex; + s32 i; + + if (gAudioContext.numSynthesisReverbs == 0) { + for (i = 0; i < gAudioContext.numNotes; i++) { + if (gAudioContext.sampleStateList[sampleStateOffset + i].bitField0.enabled) { + noteIndices[noteCount++] = i; + } + } + } else { + NoteSampleState* sampleState; + + for (reverbIndex = 0; reverbIndex < gAudioContext.numSynthesisReverbs; reverbIndex++) { + for (i = 0; i < gAudioContext.numNotes; i++) { + sampleState = &gAudioContext.sampleStateList[sampleStateOffset + i]; + if (sampleState->bitField0.enabled && (sampleState->bitField1.reverbIndex == reverbIndex)) { + noteIndices[noteCount++] = i; + } + } + } + + for (i = 0; i < gAudioContext.numNotes; i++) { + sampleState = &gAudioContext.sampleStateList[sampleStateOffset + i]; + if (sampleState->bitField0.enabled && + (sampleState->bitField1.reverbIndex >= gAudioContext.numSynthesisReverbs)) { + noteIndices[noteCount++] = i; + } + } + } + + aClearBuffer(cmd++, DMEM_LEFT_CH, DMEM_2CH_SIZE); + + i = 0; + for (reverbIndex = 0; reverbIndex < gAudioContext.numSynthesisReverbs; reverbIndex++) { + s32 subDelay; + NoteSampleState* sampleState; + + reverb = &gAudioContext.synthesisReverbs[reverbIndex]; + useReverb = reverb->useReverb; + if (useReverb) { + + // Loads reverb samples from DRAM (ringBuffer) into DMEM (DMEM_WET_LEFT_CH) + cmd = AudioSynth_LoadReverbSamples(cmd, numSamplesPerUpdate, reverb, updateIndex); + + // Mixes reverb sample into the main dry channel + // reverb->volume is always set to 0x7FFF (audio spec), and DMEM_LEFT_CH is cleared before reverbs. + // So this is essentially a DMEMmove from DMEM_WET_LEFT_CH to DMEM_LEFT_CH + aMix(cmd++, DMEM_2CH_SIZE >> 4, reverb->volume, DMEM_WET_LEFT_CH, DMEM_LEFT_CH); + + subDelay = reverb->subDelay; + if (subDelay != 0) { + aDMEMMove(cmd++, DMEM_WET_LEFT_CH, DMEM_WET_TEMP, DMEM_2CH_SIZE); + } + + // Decays reverb over time. The (+ 0x8000) here is -100% + aMix(cmd++, DMEM_2CH_SIZE >> 4, reverb->decayRatio + 0x8000, DMEM_WET_LEFT_CH, DMEM_WET_LEFT_CH); + + if (((reverb->leakRtl != 0) || (reverb->leakLtr != 0)) && (gAudioContext.soundMode != SOUNDMODE_MONO)) { + cmd = AudioSynth_LeakReverb(cmd, reverb); + } + + if (subDelay != 0) { + if (reverb->mixReverbIndex != REVERB_INDEX_NONE) { + cmd = AudioSynth_MixOtherReverbIndex(cmd, reverb, updateIndex); + } + cmd = AudioSynth_SaveReverbSamples(cmd, reverb, updateIndex); + cmd = AudioSynth_LoadSubReverbSamplesWithoutDownsample(cmd, numSamplesPerUpdate, reverb, updateIndex); + aMix(cmd++, DMEM_2CH_SIZE >> 4, reverb->subVolume, DMEM_WET_TEMP, DMEM_WET_LEFT_CH); + } + } + + while (i < noteCount) { + sampleState = &gAudioContext.sampleStateList[sampleStateOffset + noteIndices[i]]; + if (sampleState->bitField1.reverbIndex != reverbIndex) { + break; + } + cmd = AudioSynth_ProcessSample(noteIndices[i], sampleState, + &gAudioContext.notes[noteIndices[i]].synthesisState, aiBuf, + numSamplesPerUpdate, cmd, updateIndex); + i++; + } + + if (useReverb) { + if ((reverb->filterLeft != NULL) || (reverb->filterRight != NULL)) { + cmd = AudioSynth_FilterReverb(cmd, numSamplesPerUpdate * SAMPLE_SIZE, reverb); + } + + // Saves the wet channel sample from DMEM (DMEM_WET_LEFT_CH) into (ringBuffer) DRAM for future use + if (subDelay != 0) { + cmd = AudioSynth_SaveSubReverbSamples(cmd, reverb, updateIndex); + } else { + if (reverb->mixReverbIndex != REVERB_INDEX_NONE) { + cmd = AudioSynth_MixOtherReverbIndex(cmd, reverb, updateIndex); + } + cmd = AudioSynth_SaveReverbSamples(cmd, reverb, updateIndex); + } + } + } + + while (i < noteCount) { + cmd = AudioSynth_ProcessSample( + noteIndices[i], &gAudioContext.sampleStateList[sampleStateOffset + noteIndices[i]], + &gAudioContext.notes[noteIndices[i]].synthesisState, aiBuf, numSamplesPerUpdate, cmd, updateIndex); + i++; + } + + size = numSamplesPerUpdate * SAMPLE_SIZE; + aInterleave(cmd++, DMEM_TEMP, DMEM_LEFT_CH, DMEM_RIGHT_CH, size); + + if (gCustomAudioSynthFunction != NULL) { + cmd = gCustomAudioSynthFunction(cmd, 2 * size, updateIndex); + } + aSaveBuffer(cmd++, DMEM_TEMP, aiBuf, 2 * size); + + return cmd; +} + +Acmd* AudioSynth_ProcessSample(s32 noteIndex, NoteSampleState* sampleState, NoteSynthesisState* synthState, s16* aiBuf, + s32 numSamplesPerUpdate, Acmd* cmd, s32 updateIndex) { + s32 pad1[2]; + void* reverbAddrSrc; + Sample* sample; + AdpcmLoop* loopInfo; + s32 numSamplesUntilEnd; + s32 numSamplesInThisIteration; + s32 sampleFinished; + s32 loopToPoint; + s32 flags; + u16 frequencyFixedPoint; + s32 gain; + s32 frameIndex; + s32 skipBytes; + void* combFilterState; + s32 numSamplesToDecode; + s32 numFirstFrameSamplesToIgnore; + u8* sampleAddr; + u32 numSamplesToLoadFixedPoint; + s32 numSamplesToLoadAdj; + s32 numSamplesProcessed; + s32 sampleEndPos; + s32 numSamplesToProcess; + s32 dmemUncompressedAddrOffset2; + s32 pad2[3]; + s32 numSamplesInFirstFrame; + s32 numTrailingSamplesToIgnore; + s32 pad3[3]; + s32 frameSize; + s32 numFramesToDecode; + s32 skipInitialSamples; + s32 zeroOffset; + u8* samplesToLoadAddr; + s32 numParts; + s32 curPart; + s32 sampleDataChunkAlignPad; + s32 haasEffectDelaySide; + s32 numSamplesToLoadFirstPart; + u16 sampleDmemBeforeResampling; + s32 sampleAddrOffset; + s32 combFilterDmem; + s32 dmemUncompressedAddrOffset1; + Note* note; + u32 numSamplesToLoad; + u16 combFilterSize; + u16 combFilterGain; + s16* filter; + s32 bookOffset = sampleState->bitField1.bookOffset; + s32 finished = sampleState->bitField0.finished; + s32 sampleDataChunkSize; + s16 sampleDataDmemAddr; + + note = &gAudioContext.notes[noteIndex]; + flags = A_CONTINUE; + + // Initialize the synthesis state + if (sampleState->bitField0.needsInit == true) { + flags = A_INIT; + synthState->atLoopPoint = false; + synthState->stopLoop = false; + synthState->samplePosInt = note->playbackState.startSamplePos; + synthState->samplePosFrac = 0; + synthState->curVolLeft = 0; + synthState->curVolRight = 0; + synthState->prevHaasEffectLeftDelaySize = 0; + synthState->prevHaasEffectRightDelaySize = 0; + synthState->curReverbVol = sampleState->targetReverbVol; + synthState->numParts = 0; + synthState->combFilterNeedsInit = true; + note->sampleState.bitField0.finished = false; + synthState->unk_1F = note->playbackState.unk_80; // Never set, never used + finished = false; + } + + // Process the sample in either one or two parts + numParts = sampleState->bitField1.hasTwoParts + 1; + + // Determine number of samples to load based on numSamplesPerUpdate and relative frequency + frequencyFixedPoint = sampleState->frequencyFixedPoint; + numSamplesToLoadFixedPoint = (frequencyFixedPoint * numSamplesPerUpdate * 2) + synthState->samplePosFrac; + numSamplesToLoad = numSamplesToLoadFixedPoint >> 16; + + if (numSamplesToLoad == 0) { + skipBytes = false; + } + + synthState->samplePosFrac = numSamplesToLoadFixedPoint & 0xFFFF; + + // Partially-optimized out no-op ifs required for matching. SM64 decomp + // makes it clear that this is how it should look. + if ((synthState->numParts == 1) && (numParts == 2)) { + } else if ((synthState->numParts == 2) && (numParts == 1)) { + } else { + } + + synthState->numParts = numParts; + + if (sampleState->bitField1.isSyntheticWave) { + cmd = AudioSynth_LoadWaveSamples(cmd, sampleState, synthState, numSamplesToLoad); + sampleDmemBeforeResampling = DMEM_UNCOMPRESSED_NOTE + (synthState->samplePosInt * 2); + synthState->samplePosInt += numSamplesToLoad; + } else { + sample = sampleState->tunedSample->sample; + loopInfo = sample->loop; + + if (note->playbackState.status != PLAYBACK_STATUS_0) { + synthState->stopLoop = true; + } + + if ((loopInfo->count == 2) && synthState->stopLoop) { + sampleEndPos = loopInfo->sampleEnd; + } else { + sampleEndPos = loopInfo->loopEnd; + } + + sampleAddr = sample->sampleAddr; + numSamplesToLoadFirstPart = 0; + + // If the frequency requested is more than double that of the raw sample, + // then the sample processing is split into two parts. + for (curPart = 0; curPart < numParts; curPart++) { + numSamplesProcessed = 0; + dmemUncompressedAddrOffset1 = 0; + + // Adjust the number of samples to load only if there are two parts and an odd number of samples + if (numParts == 1) { + numSamplesToLoadAdj = numSamplesToLoad; + } else if (numSamplesToLoad & 1) { + // round down for the first part + // round up for the second part + numSamplesToLoadAdj = (numSamplesToLoad & ~1) + (curPart * 2); + } else { + numSamplesToLoadAdj = numSamplesToLoad; + } + + // Load the ADPCM codeBook + if ((sample->codec == CODEC_ADPCM) || (sample->codec == CODEC_SMALL_ADPCM)) { + if (gAudioContext.adpcmCodeBook != sample->book->codeBook) { + u32 numEntries; + + switch (bookOffset) { + case 1: + gAudioContext.adpcmCodeBook = &gInvalidAdpcmCodeBook[1]; + break; + + case 2: + case 3: + default: + gAudioContext.adpcmCodeBook = sample->book->codeBook; + break; + } + + numEntries = SAMPLES_PER_FRAME * sample->book->order * sample->book->numPredictors; + aLoadADPCM(cmd++, numEntries, gAudioContext.adpcmCodeBook); + } + } + + // Continue processing samples until the number of samples needed to load is reached + while (numSamplesProcessed != numSamplesToLoadAdj) { + sampleFinished = false; + loopToPoint = false; + dmemUncompressedAddrOffset2 = 0; + + numFirstFrameSamplesToIgnore = synthState->samplePosInt & 0xF; + numSamplesUntilEnd = sampleEndPos - synthState->samplePosInt; + + // Calculate number of samples to process this loop + numSamplesToProcess = numSamplesToLoadAdj - numSamplesProcessed; + + if ((numFirstFrameSamplesToIgnore == 0) && !synthState->atLoopPoint) { + numFirstFrameSamplesToIgnore = SAMPLES_PER_FRAME; + } + numSamplesInFirstFrame = SAMPLES_PER_FRAME - numFirstFrameSamplesToIgnore; + + // Determine the number of samples to decode based on whether the end will be reached or not. + if (numSamplesToProcess < numSamplesUntilEnd) { + // The end will not be reached. + numFramesToDecode = + (s32)(numSamplesToProcess - numSamplesInFirstFrame + SAMPLES_PER_FRAME - 1) / SAMPLES_PER_FRAME; + numSamplesToDecode = numFramesToDecode * SAMPLES_PER_FRAME; + numTrailingSamplesToIgnore = numSamplesInFirstFrame + numSamplesToDecode - numSamplesToProcess; + } else { + // The end will be reached. + numSamplesToDecode = numSamplesUntilEnd - numSamplesInFirstFrame; + numTrailingSamplesToIgnore = 0; + if (numSamplesToDecode <= 0) { + numSamplesToDecode = 0; + numSamplesInFirstFrame = numSamplesUntilEnd; + } + numFramesToDecode = (numSamplesToDecode + SAMPLES_PER_FRAME - 1) / SAMPLES_PER_FRAME; + if (loopInfo->count != 0) { + if ((loopInfo->count == 2) && synthState->stopLoop) { + sampleFinished = true; + } else { + // Loop around and restart + loopToPoint = true; + } + } else { + sampleFinished = true; + } + } + + // Set parameters based on compression type + switch (sample->codec) { + case CODEC_ADPCM: + // 16 2-byte samples (32 bytes) compressed into 4-bit samples (8 bytes) + 1 header byte + frameSize = 9; + skipInitialSamples = SAMPLES_PER_FRAME; + zeroOffset = 0; + break; + + case CODEC_SMALL_ADPCM: + // 16 2-byte samples (32 bytes) compressed into 2-bit samples (4 bytes) + 1 header byte + frameSize = 5; + skipInitialSamples = SAMPLES_PER_FRAME; + zeroOffset = 0; + break; + + case CODEC_UNK7: + // 2 2-byte samples (4 bytes) processed without decompression + frameSize = 4; + skipInitialSamples = SAMPLES_PER_FRAME; + zeroOffset = 0; + break; + + case CODEC_S8: + // 16 2-byte samples (32 bytes) compressed into 8-bit samples (16 bytes) + frameSize = 16; + skipInitialSamples = SAMPLES_PER_FRAME; + zeroOffset = 0; + break; + + case CODEC_REVERB: + reverbAddrSrc = (void*)0xFFFFFFFF; + if (gCustomAudioReverbFunction != NULL) { + reverbAddrSrc = gCustomAudioReverbFunction(sample, numSamplesToLoadAdj, flags, noteIndex); + } + + if (reverbAddrSrc == (void*)0xFFFFFFFF) { + sampleFinished = true; + } else if (reverbAddrSrc == NULL) { + return cmd; + } else { + AudioSynth_LoadBuffer(cmd++, DMEM_UNCOMPRESSED_NOTE, + (numSamplesToLoadAdj + SAMPLES_PER_FRAME) * SAMPLE_SIZE, + reverbAddrSrc); + flags = A_CONTINUE; + skipBytes = 0; + numSamplesProcessed = numSamplesToLoadAdj; + dmemUncompressedAddrOffset1 = numSamplesToLoadAdj; + } + goto skip; + + case CODEC_S16_INMEMORY: + case CODEC_UNK6: + AudioSynth_ClearBuffer(cmd++, DMEM_UNCOMPRESSED_NOTE, + (numSamplesToLoadAdj + SAMPLES_PER_FRAME) * SAMPLE_SIZE); + flags = A_CONTINUE; + skipBytes = 0; + numSamplesProcessed = numSamplesToLoadAdj; + dmemUncompressedAddrOffset1 = numSamplesToLoadAdj; + goto skip; + + case CODEC_S16: + AudioSynth_ClearBuffer(cmd++, DMEM_UNCOMPRESSED_NOTE, + (numSamplesToLoadAdj + SAMPLES_PER_FRAME) * SAMPLE_SIZE); + flags = A_CONTINUE; + skipBytes = 0; + numSamplesProcessed = numSamplesToLoadAdj; + dmemUncompressedAddrOffset1 = numSamplesToLoadAdj; + goto skip; + + default: + break; + } + + // Move the compressed raw sample data from ram into the rsp (DMEM) + if (numFramesToDecode != 0) { + // Get the offset from the start of the sample to where the sample is currently playing from + frameIndex = (synthState->samplePosInt + skipInitialSamples - numFirstFrameSamplesToIgnore) / + SAMPLES_PER_FRAME; + sampleAddrOffset = frameIndex * frameSize; + + // Get the ram address of the requested sample chunk + if (sample->medium == MEDIUM_RAM) { + // Sample is already loaded into ram + samplesToLoadAddr = sampleAddr + (zeroOffset + sampleAddrOffset); + } else if (gAudioContext.unk_29B8) { // always false + return cmd; + } else if (sample->medium == MEDIUM_UNK) { + // This medium is unsupported so terminate processing this note + return cmd; + } else { + // This medium is not in ram, so dma the requested sample into ram + samplesToLoadAddr = + AudioLoad_DmaSampleData(sampleAddr + (zeroOffset + sampleAddrOffset), + ALIGN16((numFramesToDecode * frameSize) + SAMPLES_PER_FRAME), flags, + &synthState->sampleDmaIndex, sample->medium); + } + + if (samplesToLoadAddr == NULL) { + // The ram address was unsuccessfully allocated + return cmd; + } + + // Move the raw sample chunk from ram to the rsp + // DMEM at the addresses before DMEM_COMPRESSED_ADPCM_DATA + sampleDataChunkAlignPad = (u32)samplesToLoadAddr & 0xF; + sampleDataChunkSize = ALIGN16((numFramesToDecode * frameSize) + SAMPLES_PER_FRAME); + sampleDataDmemAddr = DMEM_COMPRESSED_ADPCM_DATA - sampleDataChunkSize; + aLoadBuffer(cmd++, samplesToLoadAddr - sampleDataChunkAlignPad, sampleDataDmemAddr, + sampleDataChunkSize); + } else { + numSamplesToDecode = 0; + sampleDataChunkAlignPad = 0; + } + + if (synthState->atLoopPoint) { + aSetLoop(cmd++, sample->loop->predictorState); + flags = A_LOOP; + synthState->atLoopPoint = false; + } + + numSamplesInThisIteration = numSamplesToDecode + numSamplesInFirstFrame - numTrailingSamplesToIgnore; + + if (numSamplesProcessed == 0) { + //! FAKE: + if (1) {} + skipBytes = numFirstFrameSamplesToIgnore * SAMPLE_SIZE; + } else { + dmemUncompressedAddrOffset2 = ALIGN16(dmemUncompressedAddrOffset1 + 8 * SAMPLE_SIZE); + } + + // Decompress the raw sample chunks in the rsp + // Goes from adpcm (compressed) sample data to pcm (uncompressed) sample data + switch (sample->codec) { + case CODEC_ADPCM: + sampleDataChunkSize = ALIGN16((numFramesToDecode * frameSize) + SAMPLES_PER_FRAME); + sampleDataDmemAddr = DMEM_COMPRESSED_ADPCM_DATA - sampleDataChunkSize; + aSetBuffer(cmd++, 0, sampleDataDmemAddr + sampleDataChunkAlignPad, + DMEM_UNCOMPRESSED_NOTE + dmemUncompressedAddrOffset2, + numSamplesToDecode * SAMPLE_SIZE); + aADPCMdec(cmd++, flags, synthState->synthesisBuffers->adpcmState); + break; + + case CODEC_SMALL_ADPCM: + sampleDataChunkSize = ALIGN16((numFramesToDecode * frameSize) + SAMPLES_PER_FRAME); + sampleDataDmemAddr = DMEM_COMPRESSED_ADPCM_DATA - sampleDataChunkSize; + aSetBuffer(cmd++, 0, sampleDataDmemAddr + sampleDataChunkAlignPad, + DMEM_UNCOMPRESSED_NOTE + dmemUncompressedAddrOffset2, + numSamplesToDecode * SAMPLE_SIZE); + aADPCMdec(cmd++, flags | A_ADPCM_SHORT, synthState->synthesisBuffers->adpcmState); + break; + + case CODEC_S8: + sampleDataChunkSize = ALIGN16((numFramesToDecode * frameSize) + SAMPLES_PER_FRAME); + sampleDataDmemAddr = DMEM_COMPRESSED_ADPCM_DATA - sampleDataChunkSize; + AudioSynth_SetBuffer(cmd++, 0, sampleDataDmemAddr + sampleDataChunkAlignPad, + DMEM_UNCOMPRESSED_NOTE + dmemUncompressedAddrOffset2, + numSamplesToDecode * SAMPLE_SIZE); + AudioSynth_S8Dec(cmd++, flags, synthState->synthesisBuffers->adpcmState); + break; + + case CODEC_UNK7: + default: + // No decompression + break; + } + + if (numSamplesProcessed != 0) { + aDMEMMove(cmd++, + DMEM_UNCOMPRESSED_NOTE + dmemUncompressedAddrOffset2 + + (numFirstFrameSamplesToIgnore * SAMPLE_SIZE), + DMEM_UNCOMPRESSED_NOTE + dmemUncompressedAddrOffset1, + numSamplesInThisIteration * SAMPLE_SIZE); + } + + numSamplesProcessed += numSamplesInThisIteration; + + switch (flags) { + case A_INIT: + skipBytes = SAMPLES_PER_FRAME * SAMPLE_SIZE; + dmemUncompressedAddrOffset1 = (numSamplesToDecode + SAMPLES_PER_FRAME) * SAMPLE_SIZE; + break; + + case A_LOOP: + dmemUncompressedAddrOffset1 = + numSamplesInThisIteration * SAMPLE_SIZE + dmemUncompressedAddrOffset1; + break; + + default: + if (dmemUncompressedAddrOffset1 != 0) { + dmemUncompressedAddrOffset1 = + numSamplesInThisIteration * SAMPLE_SIZE + dmemUncompressedAddrOffset1; + } else { + dmemUncompressedAddrOffset1 = + (numFirstFrameSamplesToIgnore + numSamplesInThisIteration) * SAMPLE_SIZE; + } + break; + } + + flags = A_CONTINUE; + + skip: + + // Update what to do with the samples next + if (sampleFinished) { + if ((numSamplesToLoadAdj - numSamplesProcessed) != 0) { + AudioSynth_ClearBuffer(cmd++, DMEM_UNCOMPRESSED_NOTE + dmemUncompressedAddrOffset1, + (numSamplesToLoadAdj - numSamplesProcessed) * SAMPLE_SIZE); + } + finished = true; + note->sampleState.bitField0.finished = true; + AudioSynth_DisableSampleStates(updateIndex, noteIndex); + break; // break out of the for-loop + } else if (loopToPoint) { + synthState->atLoopPoint = true; + synthState->samplePosInt = loopInfo->start; + } else { + synthState->samplePosInt += numSamplesToProcess; + } + } + + switch (numParts) { + case 1: + sampleDmemBeforeResampling = DMEM_UNCOMPRESSED_NOTE + skipBytes; + break; + + case 2: + switch (curPart) { + case 0: + AudioSynth_InterL(cmd++, DMEM_UNCOMPRESSED_NOTE + skipBytes, + DMEM_TEMP + (SAMPLES_PER_FRAME * SAMPLE_SIZE), + ALIGN8(numSamplesToLoadAdj / 2)); + numSamplesToLoadFirstPart = numSamplesToLoadAdj; + sampleDmemBeforeResampling = DMEM_TEMP + (SAMPLES_PER_FRAME * SAMPLE_SIZE); + if (finished) { + AudioSynth_ClearBuffer(cmd++, sampleDmemBeforeResampling + numSamplesToLoadFirstPart, + numSamplesToLoadAdj + SAMPLES_PER_FRAME); + } + break; + + case 1: + AudioSynth_InterL(cmd++, DMEM_UNCOMPRESSED_NOTE + skipBytes, + DMEM_TEMP + (SAMPLES_PER_FRAME * SAMPLE_SIZE) + numSamplesToLoadFirstPart, + ALIGN8(numSamplesToLoadAdj / 2)); + break; + + default: + break; + } + break; + + default: + break; + } + if (finished) { + break; + } + } + } + + // Update the flags for the signal processing below + flags = A_CONTINUE; + if (sampleState->bitField0.needsInit == true) { + sampleState->bitField0.needsInit = false; + flags = A_INIT; + } + + // Resample the decompressed mono-signal to the correct pitch + cmd = AudioSynth_FinalResample(cmd, synthState, numSamplesPerUpdate * SAMPLE_SIZE, frequencyFixedPoint, + sampleDmemBeforeResampling, flags); + + // UnkCmd19 was removed from the audio microcode + // This block performs no operation + if (bookOffset == 3) { + AudioSynth_UnkCmd19(cmd++, DMEM_TEMP, DMEM_TEMP, numSamplesPerUpdate * (s32)SAMPLE_SIZE, 0); + } + + // Apply the gain to the mono-signal to adjust the volume + gain = sampleState->gain; + if (gain != 0) { + // A gain of 0x10 (a UQ4.4 number) is equivalent to 1.0 and represents no volume change + if (gain < 0x10) { + gain = 0x10; + } + AudioSynth_HiLoGain(cmd++, gain, DMEM_TEMP, 0, (numSamplesPerUpdate + SAMPLES_PER_FRAME) * SAMPLE_SIZE); + } + + // Apply the filter to the mono-signal + filter = sampleState->filter; + if (filter != 0) { + AudioSynth_LoadFilterSize(cmd++, numSamplesPerUpdate * SAMPLE_SIZE, filter); + AudioSynth_LoadFilterBuffer(cmd++, flags, DMEM_TEMP, synthState->synthesisBuffers->filterState); + } + + // Apply the comb filter to the mono-signal by taking the signal with a small temporal offset, + // and adding it back to itself + combFilterSize = sampleState->combFilterSize; + combFilterGain = sampleState->combFilterGain; + combFilterState = synthState->synthesisBuffers->combFilterState; + if ((combFilterSize != 0) && (sampleState->combFilterGain != 0)) { + AudioSynth_DMemMove(cmd++, DMEM_TEMP, DMEM_COMB_TEMP, numSamplesPerUpdate * SAMPLE_SIZE); + combFilterDmem = DMEM_COMB_TEMP - combFilterSize; + if (synthState->combFilterNeedsInit) { + AudioSynth_ClearBuffer(cmd++, combFilterDmem, combFilterSize); + synthState->combFilterNeedsInit = false; + } else { + AudioSynth_LoadBuffer(cmd++, combFilterDmem, combFilterSize, combFilterState); + } + AudioSynth_SaveBuffer(cmd++, DMEM_TEMP + (numSamplesPerUpdate * SAMPLE_SIZE) - combFilterSize, combFilterSize, + combFilterState); + AudioSynth_Mix(cmd++, (numSamplesPerUpdate * (s32)SAMPLE_SIZE) >> 4, combFilterGain, DMEM_COMB_TEMP, + combFilterDmem); + AudioSynth_DMemMove(cmd++, combFilterDmem, DMEM_TEMP, numSamplesPerUpdate * SAMPLE_SIZE); + } else { + synthState->combFilterNeedsInit = true; + } + + // Determine the behavior of the audio processing that leads to the haas effect + if ((sampleState->haasEffectLeftDelaySize != 0) || (synthState->prevHaasEffectLeftDelaySize != 0)) { + haasEffectDelaySide = HAAS_EFFECT_DELAY_LEFT; + } else if ((sampleState->haasEffectRightDelaySize != 0) || (synthState->prevHaasEffectRightDelaySize != 0)) { + haasEffectDelaySide = HAAS_EFFECT_DELAY_RIGHT; + } else { + haasEffectDelaySide = HAAS_EFFECT_DELAY_NONE; + } + + // Apply an unknown effect based on the surround sound-mode + if (gAudioContext.soundMode == SOUNDMODE_SURROUND) { + sampleState->targetVolLeft = sampleState->targetVolLeft >> 1; + sampleState->targetVolRight = sampleState->targetVolRight >> 1; + if (sampleState->surroundEffectIndex != 0xFF) { + cmd = AudioSynth_ApplySurroundEffect(cmd, sampleState, synthState, numSamplesPerUpdate, DMEM_TEMP, flags); + } + } + + // Split the mono-signal into left and right channels: + // Both for dry signal (to go to the speakers now) + // and for wet signal (to go to a reverb buffer to be stored, and brought back later to produce an echo) + cmd = AudioSynth_ProcessEnvelope(cmd, sampleState, synthState, numSamplesPerUpdate, DMEM_TEMP, haasEffectDelaySide, + flags); + + // Apply the haas effect by delaying either the left or the right channel by a small amount + if (sampleState->bitField1.useHaasEffect) { + if (!(flags & A_INIT)) { + flags = A_CONTINUE; + } + cmd = AudioSynth_ApplyHaasEffect(cmd, sampleState, synthState, numSamplesPerUpdate * (s32)SAMPLE_SIZE, flags, + haasEffectDelaySide); + } + + return cmd; +} + +Acmd* AudioSynth_ApplySurroundEffect(Acmd* cmd, NoteSampleState* sampleState, NoteSynthesisState* synthState, + s32 numSamplesPerUpdate, s32 haasDmem, s32 flags) { + s32 wetGain; + u16 dryGain; + s64 dmem = DMEM_SURROUND_TEMP; + f32 decayGain; + + AudioSynth_DMemMove(cmd++, haasDmem, DMEM_HAAS_TEMP, numSamplesPerUpdate * SAMPLE_SIZE); + dryGain = synthState->surroundEffectGain; + + if (flags == A_INIT) { + aClearBuffer(cmd++, dmem, sizeof(synthState->synthesisBuffers->surroundEffectState)); + synthState->surroundEffectGain = 0; + } else { + aLoadBuffer(cmd++, synthState->synthesisBuffers->surroundEffectState, dmem, + sizeof(synthState->synthesisBuffers->surroundEffectState)); + aMix(cmd++, (numSamplesPerUpdate * (s32)SAMPLE_SIZE) >> 4, dryGain, dmem, DMEM_LEFT_CH); + aMix(cmd++, (numSamplesPerUpdate * (s32)SAMPLE_SIZE) >> 4, (dryGain ^ 0xFFFF), dmem, DMEM_RIGHT_CH); + + wetGain = (dryGain * synthState->curReverbVol) >> 7; + + aMix(cmd++, (numSamplesPerUpdate * (s32)SAMPLE_SIZE) >> 4, wetGain, dmem, DMEM_WET_LEFT_CH); + aMix(cmd++, (numSamplesPerUpdate * (s32)SAMPLE_SIZE) >> 4, (wetGain ^ 0xFFFF), dmem, DMEM_WET_RIGHT_CH); + } + + aSaveBuffer(cmd++, DMEM_SURROUND_TEMP + (numSamplesPerUpdate * SAMPLE_SIZE), + synthState->synthesisBuffers->surroundEffectState, + sizeof(synthState->synthesisBuffers->surroundEffectState)); + + decayGain = (sampleState->targetVolLeft + sampleState->targetVolRight) * (1.0f / 0x2000); + + if (decayGain > 1.0f) { + decayGain = 1.0f; + } + + decayGain = decayGain * gDefaultPanVolume[127 - sampleState->surroundEffectIndex]; + synthState->surroundEffectGain = ((decayGain * 0x7FFF) + synthState->surroundEffectGain) / 2; + + AudioSynth_DMemMove(cmd++, DMEM_HAAS_TEMP, haasDmem, numSamplesPerUpdate * SAMPLE_SIZE); + + return cmd; +} + +Acmd* AudioSynth_FinalResample(Acmd* cmd, NoteSynthesisState* synthState, s32 size, u16 pitch, u16 inpDmem, + s32 resampleFlags) { + if (pitch == 0) { + AudioSynth_ClearBuffer(cmd++, DMEM_TEMP, size); + } else { + aSetBuffer(cmd++, 0, inpDmem, DMEM_TEMP, size); + aResample(cmd++, resampleFlags, pitch, synthState->synthesisBuffers->finalResampleState); + } + + return cmd; +} + +Acmd* AudioSynth_ProcessEnvelope(Acmd* cmd, NoteSampleState* sampleState, NoteSynthesisState* synthState, + s32 numSamplesPerUpdate, u16 dmemSrc, s32 haasEffectDelaySide, s32 flags) { + u32 dmemDests; + u16 curVolLeft; + u16 targetVolLeft; + s32 curReverbVol; + u16 curVolRight; + s16 targetReverbVol; + s16 rampLeft; + s16 rampRight; + s16 rampReverb; + s16 curReverbVolAndFlags; + u16 targetVolRight; + f32 defaultPanVolume; + s32 pad; + + targetReverbVol = sampleState->targetReverbVol; + + curVolLeft = synthState->curVolLeft; + curVolRight = synthState->curVolRight; + + targetVolLeft = sampleState->targetVolLeft; + targetVolLeft <<= 4; + targetVolRight = sampleState->targetVolRight; + targetVolRight <<= 4; + + if ((gAudioContext.soundMode == SOUNDMODE_SURROUND) && (sampleState->surroundEffectIndex != 0xFF)) { + defaultPanVolume = gDefaultPanVolume[sampleState->surroundEffectIndex]; + targetVolLeft *= defaultPanVolume; + targetVolRight *= defaultPanVolume; + } + + if (targetVolLeft != curVolLeft) { + rampLeft = (targetVolLeft - curVolLeft) / (numSamplesPerUpdate >> 3); + } else { + rampLeft = 0; + } + + if (targetVolRight != curVolRight) { + rampRight = (targetVolRight - curVolRight) / (numSamplesPerUpdate >> 3); + } else { + rampRight = 0; + } + + curReverbVolAndFlags = synthState->curReverbVol; + curReverbVol = curReverbVolAndFlags & 0x7F; + + if (curReverbVolAndFlags != targetReverbVol) { + rampReverb = (((targetReverbVol & 0x7F) - curReverbVol) << 9) / (numSamplesPerUpdate >> 3); + synthState->curReverbVol = targetReverbVol; + } else { + rampReverb = 0; + } + + synthState->curVolLeft = curVolLeft + (rampLeft * (numSamplesPerUpdate >> 3)); + synthState->curVolRight = curVolRight + (rampRight * (numSamplesPerUpdate >> 3)); + + if (sampleState->bitField1.useHaasEffect) { + AudioSynth_ClearBuffer(cmd++, DMEM_HAAS_TEMP, DMEM_1CH_SIZE); + AudioSynth_EnvSetup1(cmd++, curReverbVol * 2, rampReverb, rampLeft, rampRight); + AudioSynth_EnvSetup2(cmd++, curVolLeft, curVolRight); + + switch (haasEffectDelaySide) { + case HAAS_EFFECT_DELAY_LEFT: + // Store the left dry channel in a temp space to be delayed to produce the haas effect + dmemDests = sEnvMixerLeftHaasDmemDests; + break; + + case HAAS_EFFECT_DELAY_RIGHT: + // Store the right dry channel in a temp space to be delayed to produce the haas effect + dmemDests = sEnvMixerRightHaasDmemDests; + break; + + default: // HAAS_EFFECT_DELAY_NONE + dmemDests = sEnvMixerDefaultDmemDests; + break; + } + } else { + aEnvSetup1(cmd++, curReverbVol * 2, rampReverb, rampLeft, rampRight); + aEnvSetup2(cmd++, curVolLeft, curVolRight); + dmemDests = sEnvMixerDefaultDmemDests; + } + + aEnvMixer(cmd++, dmemSrc, numSamplesPerUpdate, (curReverbVolAndFlags & 0x80) >> 7, + sampleState->bitField0.strongReverbRight, sampleState->bitField0.strongReverbLeft, + sampleState->bitField0.strongRight, sampleState->bitField0.strongLeft, dmemDests, sEnvMixerOp); + + return cmd; +} + +Acmd* AudioSynth_LoadWaveSamples(Acmd* cmd, NoteSampleState* sampleState, NoteSynthesisState* synthState, + s32 numSamplesToLoad) { + s32 numSamplesAvailable; + s32 harmonicIndexCurAndPrev = sampleState->harmonicIndexCurAndPrev; + s32 samplePosInt = synthState->samplePosInt; + s32 numDuplicates; + + if (sampleState->bitField1.bookOffset != 0) { + // Move the noise wave (that reads compiled assembly as samples) from ram to dmem + AudioSynth_LoadBuffer(cmd++, DMEM_UNCOMPRESSED_NOTE, ALIGN16(numSamplesToLoad * SAMPLE_SIZE), gWaveSamples[8]); + // Offset the address for the samples read by gWaveSamples[8] to the next set of samples + gWaveSamples[8] += numSamplesToLoad * SAMPLE_SIZE; + + return cmd; + } else { + // Move the synthetic wave from ram to dmem + aLoadBuffer(cmd++, sampleState->waveSampleAddr, DMEM_UNCOMPRESSED_NOTE, WAVE_SAMPLE_COUNT * SAMPLE_SIZE); + + // If the harmonic changes, map the offset in the wave from one harmonic to another for continuity + if (harmonicIndexCurAndPrev != 0) { + samplePosInt = (samplePosInt * sNumSamplesPerWavePeriod[harmonicIndexCurAndPrev >> 2]) / + sNumSamplesPerWavePeriod[harmonicIndexCurAndPrev & 3]; + } + + // Offset in the WAVE_SAMPLE_COUNT samples of gWaveSamples to start processing the wave for continuity + samplePosInt = (u32)samplePosInt % WAVE_SAMPLE_COUNT; + // Number of samples in the initial WAVE_SAMPLE_COUNT samples available to be used to process + numSamplesAvailable = WAVE_SAMPLE_COUNT - samplePosInt; + + // Require duplicates if there are more samples to load than available + if (numSamplesToLoad > numSamplesAvailable) { + // Duplicate (copy) the WAVE_SAMPLE_COUNT samples as many times as needed to reach numSamplesToLoad. + // (numSamplesToLoad - numSamplesAvailable) is the number of samples missing. + // Divide by WAVE_SAMPLE_COUNT, rounding up, to get the amount of duplicates + numDuplicates = ((numSamplesToLoad - numSamplesAvailable + WAVE_SAMPLE_COUNT - 1) / WAVE_SAMPLE_COUNT); + if (numDuplicates != 0) { + aDuplicate(cmd++, numDuplicates, DMEM_UNCOMPRESSED_NOTE, + DMEM_UNCOMPRESSED_NOTE + (WAVE_SAMPLE_COUNT * SAMPLE_SIZE)); + } + } + synthState->samplePosInt = samplePosInt; + } + + return cmd; +} + +/** + * The Haas Effect gives directionality to sound by applying a small (< 35ms) delay to either the left or right channel. + * The delay is small enough that the sound is still perceived as one sound, but the channel that is not delayed will + * reach our ear first and give a sense of directionality. The sound is directed towards the opposite side of the delay. + */ +Acmd* AudioSynth_ApplyHaasEffect(Acmd* cmd, NoteSampleState* sampleState, NoteSynthesisState* synthState, s32 size, + s32 flags, s32 haasEffectDelaySide) { + u16 dmemDest; + u16 pitch; + u8 prevHaasEffectDelaySize; + u8 haasEffectDelaySize; + + switch (haasEffectDelaySide) { + case HAAS_EFFECT_DELAY_LEFT: + // Delay the sample on the left channel + // This allows the right channel to be heard first + dmemDest = DMEM_LEFT_CH; + haasEffectDelaySize = sampleState->haasEffectLeftDelaySize; + prevHaasEffectDelaySize = synthState->prevHaasEffectLeftDelaySize; + synthState->prevHaasEffectRightDelaySize = 0; + synthState->prevHaasEffectLeftDelaySize = haasEffectDelaySize; + break; + + case HAAS_EFFECT_DELAY_RIGHT: + // Delay the sample on the right channel + // This allows the left channel to be heard first + dmemDest = DMEM_RIGHT_CH; + haasEffectDelaySize = sampleState->haasEffectRightDelaySize; + prevHaasEffectDelaySize = synthState->prevHaasEffectRightDelaySize; + synthState->prevHaasEffectRightDelaySize = haasEffectDelaySize; + synthState->prevHaasEffectLeftDelaySize = 0; + break; + + default: // HAAS_EFFECT_DELAY_NONE + return cmd; + } + + if (flags != A_INIT) { + // Slightly adjust the sample rate in order to fit a change in sample delay + if (haasEffectDelaySize != prevHaasEffectDelaySize) { + pitch = (((size << 0xF) / 2) - 1) / ((size + haasEffectDelaySize - prevHaasEffectDelaySize - 2) / 2); + aSetBuffer(cmd++, 0, DMEM_HAAS_TEMP, DMEM_TEMP, size + haasEffectDelaySize - prevHaasEffectDelaySize); + aResampleZoh(cmd++, pitch, 0); + } else { + aDMEMMove(cmd++, DMEM_HAAS_TEMP, DMEM_TEMP, size); + } + + if (prevHaasEffectDelaySize != 0) { + aLoadBuffer(cmd++, synthState->synthesisBuffers->haasEffectDelayState, DMEM_HAAS_TEMP, + ALIGN16(prevHaasEffectDelaySize)); + aDMEMMove(cmd++, DMEM_TEMP, DMEM_HAAS_TEMP + prevHaasEffectDelaySize, + size + haasEffectDelaySize - prevHaasEffectDelaySize); + } else { + aDMEMMove(cmd++, DMEM_TEMP, DMEM_HAAS_TEMP, size + haasEffectDelaySize); + } + } else { + // Just apply a delay directly + aDMEMMove(cmd++, DMEM_HAAS_TEMP, DMEM_TEMP, size); + if (haasEffectDelaySize) { // != 0 + aClearBuffer(cmd++, DMEM_HAAS_TEMP, haasEffectDelaySize); + } + aDMEMMove(cmd++, DMEM_TEMP, DMEM_HAAS_TEMP + haasEffectDelaySize, size); + } + + if (haasEffectDelaySize) { // != 0 + // Save excessive samples for next iteration + aSaveBuffer(cmd++, DMEM_HAAS_TEMP + size, synthState->synthesisBuffers->haasEffectDelayState, + ALIGN16(haasEffectDelaySize)); + } + + aAddMixer(cmd++, ALIGN64(size), DMEM_HAAS_TEMP, dmemDest, 0x7FFF); + + return cmd; +} diff --git a/src/code/audio/code_8019AF00.c b/src/code/audio/code_8019AF00.c index 007d7ca856..98be413977 100644 --- a/src/code/audio/code_8019AF00.c +++ b/src/code/audio/code_8019AF00.c @@ -4078,7 +4078,7 @@ void AudioSfx_SetProperties(u8 bankId, u8 entryIndex, u8 channelIndex) { } u32 AudioSfx_SetFreqAndStereoBits(u8 seqScriptValIn, SequenceChannel* channel) { - channel->stereo.asByte = sSfxChannelState[seqScriptValIn].stereoBits; + channel->stereoData.asByte = sSfxChannelState[seqScriptValIn].stereoBits; channel->freqScale = sSfxChannelState[seqScriptValIn].freqScale; channel->changes.s.freqScale = true; 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 4ed5b82a04..fdf3cc9ac5 100644 --- a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c +++ b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c @@ -4,7 +4,6 @@ * Description: Keaton grass */ -#include "prevent_bss_reordering.h" #include "z_en_kusa2.h" #include "objects/gameplay_field_keep/gameplay_field_keep.h" #include "objects/gameplay_keep/gameplay_keep.h" diff --git a/tools/disasm/files.txt b/tools/disasm/files.txt index ffa305cddd..c546c1f69b 100644 --- a/tools/disasm/files.txt +++ b/tools/disasm/files.txt @@ -597,6 +597,7 @@ 0x801D9090 : "audio_sound_params", 0x801DB470 : "code_801A5BD0", 0x801DB4C0 : "code_801A7B10", + 0x801DB4E0 : "audio_init_params", # .rodata section 0x801DBDF0 : "z_en_item00", diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 057170442e..20fa0265c2 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -3478,74 +3478,74 @@ 0x801872FC:("osFlashWriteBuffer",), 0x801873BC:("osFlashWriteArray",), 0x8018752C:("osFlashReadArray",), - 0x801877D0:("func_801877D0",), - 0x80187B64:("func_80187B64",), - 0x80187BEC:("func_80187BEC",), - 0x80187DE8:("func_80187DE8",), - 0x80187E58:("func_80187E58",), - 0x80187F00:("func_80187F00",), - 0x80187FA8:("func_80187FA8",), - 0x80187FB0:("func_80187FB0",), - 0x80187FD0:("func_80187FD0",), - 0x80187FD8:("func_80187FD8",), - 0x80187FE0:("func_80187FE0",), - 0x80187FE8:("func_80187FE8",), - 0x8018801C:("func_8018801C",), - 0x80188024:("func_80188024",), - 0x8018802C:("func_8018802C",), - 0x80188034:("func_80188034",), - 0x80188068:("func_80188068",), - 0x80188070:("func_80188070",), - 0x80188078:("func_80188078",), - 0x801880A4:("func_801880A4",), - 0x801880AC:("func_801880AC",), - 0x801880B4:("func_801880B4",), - 0x801880BC:("func_801880BC",), - 0x801880C4:("func_801880C4",), - 0x801880E8:("func_801880E8",), - 0x8018811C:("func_8018811C",), - 0x80188124:("func_80188124",), - 0x8018814C:("func_8018814C",), - 0x80188174:("func_80188174",), - 0x80188190:("func_80188190",), - 0x80188198:("func_80188198",), - 0x801881A0:("func_801881A0",), - 0x801881A8:("func_801881A8",), - 0x801881C4:("func_801881C4",), - 0x801881F8:("func_801881F8",), - 0x80188224:("func_80188224",), - 0x8018822C:("func_8018822C",), - 0x80188234:("func_80188234",), - 0x8018823C:("func_8018823C",), - 0x80188244:("func_80188244",), - 0x8018824C:("func_8018824C",), - 0x80188254:("func_80188254",), - 0x8018825C:("func_8018825C",), - 0x80188264:("func_80188264",), - 0x80188288:("func_80188288",), - 0x801882A0:("func_801882A0",), - 0x80188304:("func_80188304",), - 0x801884A0:("func_801884A0",), - 0x80188698:("func_80188698",), - 0x8018883C:("func_8018883C",), - 0x801888E4:("func_801888E4",), - 0x801889A4:("func_801889A4",), - 0x80188A50:("func_80188A50",), - 0x80188AFC:("func_80188AFC",), - 0x80188C48:("func_80188C48",), - 0x80188CB4:("func_80188CB4",), - 0x80188D20:("func_80188D20",), - 0x80188D28:("func_80188D28",), - 0x80188D68:("func_80188D68",), - 0x80188DDC:("func_80188DDC",), - 0x80188FBC:("func_80188FBC",), - 0x80189064:("func_80189064",), - 0x80189620:("func_80189620",), - 0x8018A4B4:("func_8018A4B4",), - 0x8018A768:("func_8018A768",), - 0x8018A808:("func_8018A808",), - 0x8018ACC4:("func_8018ACC4",), - 0x8018AE34:("func_8018AE34",), + 0x801877D0:("AudioSynth_AddReverbBufferEntry",), + 0x80187B64:("AudioSynth_SyncSampleStates",), + 0x80187BEC:("AudioSynth_Update",), + 0x80187DE8:("AudioSynth_DisableSampleStates",), + 0x80187E58:("AudioSynth_LoadMixedReverbSamples",), + 0x80187F00:("AudioSynth_SaveMixedReverbSamples",), + 0x80187FA8:("AudioSynth_Noop1",), + 0x80187FB0:("AudioSynth_ClearBuffer",), + 0x80187FD0:("AudioSynth_Noop2",), + 0x80187FD8:("AudioSynth_Noop3",), + 0x80187FE0:("AudioSynth_Noop4",), + 0x80187FE8:("AudioSynth_Mix",), + 0x8018801C:("AudioSynth_Noop5",), + 0x80188024:("AudioSynth_Noop6",), + 0x8018802C:("AudioSynth_Noop7",), + 0x80188034:("AudioSynth_SetBuffer",), + 0x80188068:("AudioSynth_Noop8",), + 0x80188070:("AudioSynth_Noop9",), + 0x80188078:("AudioSynth_DMemMove",), + 0x801880A4:("AudioSynth_Noop10",), + 0x801880AC:("AudioSynth_Noop11",), + 0x801880B4:("AudioSynth_Noop12",), + 0x801880BC:("AudioSynth_Noop13",), + 0x801880C4:("AudioSynth_InterL",), + 0x801880E8:("AudioSynth_EnvSetup1",), + 0x8018811C:("AudioSynth_Noop14",), + 0x80188124:("AudioSynth_LoadBuffer",), + 0x8018814C:("AudioSynth_SaveBuffer",), + 0x80188174:("AudioSynth_EnvSetup2",), + 0x80188190:("AudioSynth_Noop15",), + 0x80188198:("AudioSynth_Noop16",), + 0x801881A0:("AudioSynth_Noop17",), + 0x801881A8:("AudioSynth_S8Dec",), + 0x801881C4:("AudioSynth_HiLoGain",), + 0x801881F8:("AudioSynth_UnkCmd19",), + 0x80188224:("AudioSynth_Noop18",), + 0x8018822C:("AudioSynth_Noop19",), + 0x80188234:("AudioSynth_Noop20",), + 0x8018823C:("AudioSynth_Noop21",), + 0x80188244:("AudioSynth_Noop22",), + 0x8018824C:("AudioSynth_Noop23",), + 0x80188254:("AudioSynth_Noop24",), + 0x8018825C:("AudioSynth_Noop25",), + 0x80188264:("AudioSynth_LoadFilterBuffer",), + 0x80188288:("AudioSynth_LoadFilterSize",), + 0x801882A0:("AudioSynth_LeakReverb",), + 0x80188304:("AudioSynth_LoadDownsampledReverbSamples",), + 0x801884A0:("AudioSynth_SaveResampledReverbSamples",), + 0x80188698:("AudioSynth_LoadResampledReverbSamples",), + 0x8018883C:("AudioSynth_FilterReverb",), + 0x801888E4:("AudioSynth_MixOtherReverbIndex",), + 0x801889A4:("AudioSynth_LoadDefaultReverbSamples",), + 0x80188A50:("AudioSynth_LoadSubReverbSamples",), + 0x80188AFC:("AudioSynth_SaveResampledReverbSamplesImpl",), + 0x80188C48:("AudioSynth_LoadReverbSamplesImpl",), + 0x80188CB4:("AudioSynth_SaveReverbSamplesImpl",), + 0x80188D20:("AudioSynth_Noop26",), + 0x80188D28:("AudioSynth_LoadSubReverbSamplesWithoutDownsample",), + 0x80188D68:("AudioSynth_LoadReverbSamples",), + 0x80188DDC:("AudioSynth_SaveReverbSamples",), + 0x80188FBC:("AudioSynth_SaveSubReverbSamples",), + 0x80189064:("AudioSynth_ProcessSamples",), + 0x80189620:("AudioSynth_ProcessSample",), + 0x8018A4B4:("AudioSynth_ApplySurroundEffect",), + 0x8018A768:("AudioSynth_FinalResample",), + 0x8018A808:("AudioSynth_ProcessEnvelope",), + 0x8018ACC4:("AudioSynth_LoadWaveSamples",), + 0x8018AE34:("AudioSynth_ApplyHaasEffect",), 0x8018B0F0:("AudioHeap_CalculateAdsrDecay",), 0x8018B10C:("AudioHeap_InitAdsrDecayTable",), 0x8018B250:("AudioHeap_ResetLoadStatus",), @@ -3726,7 +3726,7 @@ 0x80194804:("func_80194804",), 0x80194840:("func_80194840",), 0x801948B0:("func_801948B0",), - 0x80194930:("AudioPlayback_InitNoteSub",), + 0x80194930:("AudioPlayback_InitSampleState",), 0x80194DB0:("AudioPlayback_NoteSetResamplingRate",), 0x80194E60:("AudioPlayback_NoteInit",), 0x80194F20:("AudioPlayback_NoteDisable",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index a0b3692644..5c8147eefb 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -2220,11 +2220,11 @@ 0x801D57B4:("gDefaultShortNoteVelocityTable","UNK_TYPE1","",0x1), 0x801D57C4:("gDefaultShortNoteGateTimeTable","UNK_TYPE1","",0x1), 0x801D57D4:("gDefaultEnvelope","UNK_TYPE1","",0x1), - 0x801D57E4:("gZeroNoteSub","UNK_TYPE4","",0x4), - 0x801D5804:("gDefaultNoteSub","UNK_TYPE4","",0x4), - 0x801D5824:("gHeadsetPanQuantization","u16","[64]",0x80), + 0x801D57E4:("gZeroedSampleState","UNK_TYPE4","",0x4), + 0x801D5804:("gDefaultSampleState","UNK_TYPE4","",0x4), + 0x801D5824:("gHaasEffectDelaySize","u16","[64]",0x80), 0x801D58A4:("D_801D58A4","s32","",0x4), - 0x801D58A8:("D_801D58A8","s16","[64]",0x80), + 0x801D58A8:("gInvalidAdpcmCodeBook","s16","[64]",0x80), 0x801D5928:("gHeadsetPanVolume","f32","[128]",0x200), 0x801D5B28:("gStereoPanVolume","f32","[128]",0x200), 0x801D5D28:("gDefaultPanVolume","f32","[128]",0x200), @@ -2411,7 +2411,7 @@ 0x801DB870:("D_801DB870","UNK_TYPE1","",0x1), 0x801DB8B8:("D_801DB8B8","UNK_TYPE1","",0x1), 0x801DB900:("D_801DB900","UNK_TYPE1","",0x1), - 0x801DB930:("D_801DB930","UNK_PTR","",0x4), + 0x801DB930:("gReverbSettingsTable","UNK_PTR","",0x4), 0x801DB958:("gAudioSpecs","AudioSpec","[21]",0x498), 0x801DBDF0:("D_801DBDF0","f32","",0x4), 0x801DBDF4:("jtbl_801DBDF4","UNK_PTR","",0x4), @@ -4354,10 +4354,10 @@ 0x80200BCE:("D_80200BCE","UNK_TYPE1","",0x1), 0x80200BD0:("D_80200BD0","UNK_TYPE1","",0x1), 0x80200C70:("gAudioContext","AudioContext","",0x81F8), - 0x80208E68:("D_80208E68","UNK_TYPE4","",0x4), - 0x80208E6C:("D_80208E6C","UNK_TYPE4","",0x4), - 0x80208E70:("D_80208E70","UNK_TYPE4","",0x4), - 0x80208E74:("D_80208E74","UNK_TYPE4","",0x4), + 0x80208E68:("gCustomAudioUpdateFunction","UNK_TYPE4","",0x4), + 0x80208E6C:("gCustomAudioSeqFunction","UNK_TYPE4","",0x4), + 0x80208E70:("gCustomAudioReverbFunction","UNK_TYPE4","",0x4), + 0x80208E74:("gCustomAudioSynthFunction","UNK_TYPE4","",0x4), 0x80208E90:("sJpegBitStreamPtr","UNK_TYPE1","",0x1), 0x80208E94:("sJpegBitStreamByteIdx","UNK_TYPE1","",0x1), 0x80208E98:("sJpegBitStreamBitIdx","UNK_TYPE1","",0x1), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index f64c45241e..9db0c0308e 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -2996,74 +2996,74 @@ asm/non_matchings/code/osFlash/func_80187284.s,func_80187284,0x80187284,0x1E asm/non_matchings/code/osFlash/func_801872FC.s,func_801872FC,0x801872FC,0x30 asm/non_matchings/code/osFlash/func_801873BC.s,func_801873BC,0x801873BC,0x5C asm/non_matchings/code/osFlash/func_8018752C.s,func_8018752C,0x8018752C,0x9D -asm/non_matchings/code/audio_synthesis/func_801877D0.s,func_801877D0,0x801877D0,0xE5 -asm/non_matchings/code/audio_synthesis/func_80187B64.s,func_80187B64,0x80187B64,0x22 -asm/non_matchings/code/audio_synthesis/func_80187BEC.s,func_80187BEC,0x80187BEC,0x7F -asm/non_matchings/code/audio_synthesis/func_80187DE8.s,func_80187DE8,0x80187DE8,0x1C -asm/non_matchings/code/audio_synthesis/func_80187E58.s,func_80187E58,0x80187E58,0x2A -asm/non_matchings/code/audio_synthesis/func_80187F00.s,func_80187F00,0x80187F00,0x2A -asm/non_matchings/code/audio_synthesis/func_80187FA8.s,func_80187FA8,0x80187FA8,0x2 -asm/non_matchings/code/audio_synthesis/func_80187FB0.s,func_80187FB0,0x80187FB0,0x8 -asm/non_matchings/code/audio_synthesis/func_80187FD0.s,func_80187FD0,0x80187FD0,0x2 -asm/non_matchings/code/audio_synthesis/func_80187FD8.s,func_80187FD8,0x80187FD8,0x2 -asm/non_matchings/code/audio_synthesis/func_80187FE0.s,func_80187FE0,0x80187FE0,0x2 -asm/non_matchings/code/audio_synthesis/func_80187FE8.s,func_80187FE8,0x80187FE8,0xD -asm/non_matchings/code/audio_synthesis/func_8018801C.s,func_8018801C,0x8018801C,0x2 -asm/non_matchings/code/audio_synthesis/func_80188024.s,func_80188024,0x80188024,0x2 -asm/non_matchings/code/audio_synthesis/func_8018802C.s,func_8018802C,0x8018802C,0x2 -asm/non_matchings/code/audio_synthesis/func_80188034.s,func_80188034,0x80188034,0xD -asm/non_matchings/code/audio_synthesis/func_80188068.s,func_80188068,0x80188068,0x2 -asm/non_matchings/code/audio_synthesis/func_80188070.s,func_80188070,0x80188070,0x2 -asm/non_matchings/code/audio_synthesis/func_80188078.s,func_80188078,0x80188078,0xB -asm/non_matchings/code/audio_synthesis/func_801880A4.s,func_801880A4,0x801880A4,0x2 -asm/non_matchings/code/audio_synthesis/func_801880AC.s,func_801880AC,0x801880AC,0x2 -asm/non_matchings/code/audio_synthesis/func_801880B4.s,func_801880B4,0x801880B4,0x2 -asm/non_matchings/code/audio_synthesis/func_801880BC.s,func_801880BC,0x801880BC,0x2 -asm/non_matchings/code/audio_synthesis/func_801880C4.s,func_801880C4,0x801880C4,0x9 -asm/non_matchings/code/audio_synthesis/func_801880E8.s,func_801880E8,0x801880E8,0xD -asm/non_matchings/code/audio_synthesis/func_8018811C.s,func_8018811C,0x8018811C,0x2 -asm/non_matchings/code/audio_synthesis/func_80188124.s,func_80188124,0x80188124,0xA -asm/non_matchings/code/audio_synthesis/func_8018814C.s,func_8018814C,0x8018814C,0xA -asm/non_matchings/code/audio_synthesis/func_80188174.s,func_80188174,0x80188174,0x7 -asm/non_matchings/code/audio_synthesis/func_80188190.s,func_80188190,0x80188190,0x2 -asm/non_matchings/code/audio_synthesis/func_80188198.s,func_80188198,0x80188198,0x2 -asm/non_matchings/code/audio_synthesis/func_801881A0.s,func_801881A0,0x801881A0,0x2 -asm/non_matchings/code/audio_synthesis/func_801881A8.s,func_801881A8,0x801881A8,0x7 -asm/non_matchings/code/audio_synthesis/func_801881C4.s,func_801881C4,0x801881C4,0xD -asm/non_matchings/code/audio_synthesis/func_801881F8.s,func_801881F8,0x801881F8,0xB -asm/non_matchings/code/audio_synthesis/func_80188224.s,func_80188224,0x80188224,0x2 -asm/non_matchings/code/audio_synthesis/func_8018822C.s,func_8018822C,0x8018822C,0x2 -asm/non_matchings/code/audio_synthesis/func_80188234.s,func_80188234,0x80188234,0x2 -asm/non_matchings/code/audio_synthesis/func_8018823C.s,func_8018823C,0x8018823C,0x2 -asm/non_matchings/code/audio_synthesis/func_80188244.s,func_80188244,0x80188244,0x2 -asm/non_matchings/code/audio_synthesis/func_8018824C.s,func_8018824C,0x8018824C,0x2 -asm/non_matchings/code/audio_synthesis/func_80188254.s,func_80188254,0x80188254,0x2 -asm/non_matchings/code/audio_synthesis/func_8018825C.s,func_8018825C,0x8018825C,0x2 -asm/non_matchings/code/audio_synthesis/func_80188264.s,func_80188264,0x80188264,0x9 -asm/non_matchings/code/audio_synthesis/func_80188288.s,func_80188288,0x80188288,0x6 -asm/non_matchings/code/audio_synthesis/func_801882A0.s,func_801882A0,0x801882A0,0x19 -asm/non_matchings/code/audio_synthesis/func_80188304.s,func_80188304,0x80188304,0x67 -asm/non_matchings/code/audio_synthesis/func_801884A0.s,func_801884A0,0x801884A0,0x7E -asm/non_matchings/code/audio_synthesis/func_80188698.s,func_80188698,0x80188698,0x69 -asm/non_matchings/code/audio_synthesis/func_8018883C.s,func_8018883C,0x8018883C,0x2A -asm/non_matchings/code/audio_synthesis/func_801888E4.s,func_801888E4,0x801888E4,0x30 -asm/non_matchings/code/audio_synthesis/func_801889A4.s,func_801889A4,0x801889A4,0x2B -asm/non_matchings/code/audio_synthesis/func_80188A50.s,func_80188A50,0x80188A50,0x2B -asm/non_matchings/code/audio_synthesis/func_80188AFC.s,func_80188AFC,0x80188AFC,0x53 -asm/non_matchings/code/audio_synthesis/func_80188C48.s,func_80188C48,0x80188C48,0x1B -asm/non_matchings/code/audio_synthesis/func_80188CB4.s,func_80188CB4,0x80188CB4,0x1B -asm/non_matchings/code/audio_synthesis/func_80188D20.s,func_80188D20,0x80188D20,0x2 -asm/non_matchings/code/audio_synthesis/func_80188D28.s,func_80188D28,0x80188D28,0x10 -asm/non_matchings/code/audio_synthesis/func_80188D68.s,func_80188D68,0x80188D68,0x1D -asm/non_matchings/code/audio_synthesis/func_80188DDC.s,func_80188DDC,0x80188DDC,0x78 -asm/non_matchings/code/audio_synthesis/func_80188FBC.s,func_80188FBC,0x80188FBC,0x2A -asm/non_matchings/code/audio_synthesis/func_80189064.s,func_80189064,0x80189064,0x16F -asm/non_matchings/code/audio_synthesis/func_80189620.s,func_80189620,0x80189620,0x3A5 -asm/non_matchings/code/audio_synthesis/func_8018A4B4.s,func_8018A4B4,0x8018A4B4,0xAD -asm/non_matchings/code/audio_synthesis/func_8018A768.s,func_8018A768,0x8018A768,0x28 -asm/non_matchings/code/audio_synthesis/func_8018A808.s,func_8018A808,0x8018A808,0x12F -asm/non_matchings/code/audio_synthesis/func_8018ACC4.s,func_8018ACC4,0x8018ACC4,0x5C -asm/non_matchings/code/audio_synthesis/func_8018AE34.s,func_8018AE34,0x8018AE34,0xAF +asm/non_matchings/code/audio_synthesis/AudioSynth_AddReverbBufferEntry.s,AudioSynth_AddReverbBufferEntry,0x801877D0,0xE5 +asm/non_matchings/code/audio_synthesis/AudioSynth_SyncSampleStates.s,AudioSynth_SyncSampleStates,0x80187B64,0x22 +asm/non_matchings/code/audio_synthesis/AudioSynth_Update.s,AudioSynth_Update,0x80187BEC,0x7F +asm/non_matchings/code/audio_synthesis/AudioSynth_DisableSampleStates.s,AudioSynth_DisableSampleStates,0x80187DE8,0x1C +asm/non_matchings/code/audio_synthesis/AudioSynth_LoadMixedReverbSamples.s,AudioSynth_LoadMixedReverbSamples,0x80187E58,0x2A +asm/non_matchings/code/audio_synthesis/AudioSynth_SaveMixedReverbSamples.s,AudioSynth_SaveMixedReverbSamples,0x80187F00,0x2A +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop1.s,AudioSynth_Noop1,0x80187FA8,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_ClearBuffer.s,AudioSynth_ClearBuffer,0x80187FB0,0x8 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop2.s,AudioSynth_Noop2,0x80187FD0,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop3.s,AudioSynth_Noop3,0x80187FD8,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop4.s,AudioSynth_Noop4,0x80187FE0,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Mix.s,AudioSynth_Mix,0x80187FE8,0xD +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop5.s,AudioSynth_Noop5,0x8018801C,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop6.s,AudioSynth_Noop6,0x80188024,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop7.s,AudioSynth_Noop7,0x8018802C,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_SetBuffer.s,AudioSynth_SetBuffer,0x80188034,0xD +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop8.s,AudioSynth_Noop8,0x80188068,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop9.s,AudioSynth_Noop9,0x80188070,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_DMemMove.s,AudioSynth_DMemMove,0x80188078,0xB +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop10.s,AudioSynth_Noop10,0x801880A4,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop11.s,AudioSynth_Noop11,0x801880AC,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop12.s,AudioSynth_Noop12,0x801880B4,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop13.s,AudioSynth_Noop13,0x801880BC,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_InterL.s,AudioSynth_InterL,0x801880C4,0x9 +asm/non_matchings/code/audio_synthesis/AudioSynth_EnvSetup1.s,AudioSynth_EnvSetup1,0x801880E8,0xD +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop14.s,AudioSynth_Noop14,0x8018811C,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_LoadBuffer.s,AudioSynth_LoadBuffer,0x80188124,0xA +asm/non_matchings/code/audio_synthesis/AudioSynth_SaveBuffer.s,AudioSynth_SaveBuffer,0x8018814C,0xA +asm/non_matchings/code/audio_synthesis/AudioSynth_EnvSetup2.s,AudioSynth_EnvSetup2,0x80188174,0x7 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop15.s,AudioSynth_Noop15,0x80188190,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop16.s,AudioSynth_Noop16,0x80188198,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop17.s,AudioSynth_Noop17,0x801881A0,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_S8Dec.s,AudioSynth_S8Dec,0x801881A8,0x7 +asm/non_matchings/code/audio_synthesis/AudioSynth_HiLoGain.s,AudioSynth_HiLoGain,0x801881C4,0xD +asm/non_matchings/code/audio_synthesis/AudioSynth_UnkCmd19.s,AudioSynth_UnkCmd19,0x801881F8,0xB +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop18.s,AudioSynth_Noop18,0x80188224,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop19.s,AudioSynth_Noop19,0x8018822C,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop20.s,AudioSynth_Noop20,0x80188234,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop21.s,AudioSynth_Noop21,0x8018823C,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop22.s,AudioSynth_Noop22,0x80188244,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop23.s,AudioSynth_Noop23,0x8018824C,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop24.s,AudioSynth_Noop24,0x80188254,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop25.s,AudioSynth_Noop25,0x8018825C,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_LoadFilterBuffer.s,AudioSynth_LoadFilterBuffer,0x80188264,0x9 +asm/non_matchings/code/audio_synthesis/AudioSynth_LoadFilterSize.s,AudioSynth_LoadFilterSize,0x80188288,0x6 +asm/non_matchings/code/audio_synthesis/AudioSynth_LeakReverb.s,AudioSynth_LeakReverb,0x801882A0,0x19 +asm/non_matchings/code/audio_synthesis/AudioSynth_LoadDownsampledReverbSamples.s,AudioSynth_LoadDownsampledReverbSamples,0x80188304,0x67 +asm/non_matchings/code/audio_synthesis/AudioSynth_SaveResampledReverbSamples.s,AudioSynth_SaveResampledReverbSamples,0x801884A0,0x7E +asm/non_matchings/code/audio_synthesis/AudioSynth_LoadResampledReverbSamples.s,AudioSynth_LoadResampledReverbSamples,0x80188698,0x69 +asm/non_matchings/code/audio_synthesis/AudioSynth_FilterReverb.s,AudioSynth_FilterReverb,0x8018883C,0x2A +asm/non_matchings/code/audio_synthesis/AudioSynth_MixOtherReverbIndex.s,AudioSynth_MixOtherReverbIndex,0x801888E4,0x30 +asm/non_matchings/code/audio_synthesis/AudioSynth_LoadDefaultReverbSamples.s,AudioSynth_LoadDefaultReverbSamples,0x801889A4,0x2B +asm/non_matchings/code/audio_synthesis/AudioSynth_LoadSubReverbSamples.s,AudioSynth_LoadSubReverbSamples,0x80188A50,0x2B +asm/non_matchings/code/audio_synthesis/AudioSynth_SaveResampledReverbSamplesImpl.s,AudioSynth_SaveResampledReverbSamplesImpl,0x80188AFC,0x53 +asm/non_matchings/code/audio_synthesis/AudioSynth_LoadReverbSamplesImpl.s,AudioSynth_LoadReverbSamplesImpl,0x80188C48,0x1B +asm/non_matchings/code/audio_synthesis/AudioSynth_SaveReverbSamplesImpl.s,AudioSynth_SaveReverbSamplesImpl,0x80188CB4,0x1B +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop26.s,AudioSynth_Noop26,0x80188D20,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_LoadSubReverbSamplesWithoutDownsample.s,AudioSynth_LoadSubReverbSamplesWithoutDownsample,0x80188D28,0x10 +asm/non_matchings/code/audio_synthesis/AudioSynth_LoadReverbSamples.s,AudioSynth_LoadReverbSamples,0x80188D68,0x1D +asm/non_matchings/code/audio_synthesis/AudioSynth_SaveReverbSamples.s,AudioSynth_SaveReverbSamples,0x80188DDC,0x78 +asm/non_matchings/code/audio_synthesis/AudioSynth_SaveSubReverbSamples.s,AudioSynth_SaveSubReverbSamples,0x80188FBC,0x2A +asm/non_matchings/code/audio_synthesis/AudioSynth_ProcessSamples.s,AudioSynth_ProcessSamples,0x80189064,0x16F +asm/non_matchings/code/audio_synthesis/AudioSynth_ProcessSample.s,AudioSynth_ProcessSample,0x80189620,0x3A5 +asm/non_matchings/code/audio_synthesis/AudioSynth_ApplySurroundEffect.s,AudioSynth_ApplySurroundEffect,0x8018A4B4,0xAD +asm/non_matchings/code/audio_synthesis/AudioSynth_FinalResample.s,AudioSynth_FinalResample,0x8018A768,0x28 +asm/non_matchings/code/audio_synthesis/AudioSynth_ProcessEnvelope.s,AudioSynth_ProcessEnvelope,0x8018A808,0x12F +asm/non_matchings/code/audio_synthesis/AudioSynth_LoadWaveSamples.s,AudioSynth_LoadWaveSamples,0x8018ACC4,0x5C +asm/non_matchings/code/audio_synthesis/AudioSynth_ApplyHaasEffect.s,AudioSynth_ApplyHaasEffect,0x8018AE34,0xAF asm/non_matchings/code/audio_heap/AudioHeap_ResetLoadStatus.s,AudioHeap_ResetLoadStatus,0x8018B250,0x32 asm/non_matchings/code/audio_heap/AudioHeap_DiscardFont.s,AudioHeap_DiscardFont,0x8018B318,0x39 asm/non_matchings/code/audio_heap/AudioHeap_ReleaseNotesForFont.s,AudioHeap_ReleaseNotesForFont,0x8018B3FC,0x1E @@ -3242,7 +3242,7 @@ asm/non_matchings/code/code_80194710/osAiSetNextBuffer.s,osAiSetNextBuffer,0x801 asm/non_matchings/code/code_80194710/func_80194804.s,func_80194804,0x80194804,0xF asm/non_matchings/code/code_80194710/func_80194840.s,func_80194840,0x80194840,0x1C asm/non_matchings/code/code_80194710/func_801948B0.s,func_801948B0,0x801948B0,0x20 -asm/non_matchings/code/audio_playback/AudioPlayback_InitNoteSub.s,AudioPlayback_InitNoteSub,0x80194930,0x120 +asm/non_matchings/code/audio_playback/AudioPlayback_InitSampleState.s,AudioPlayback_InitSampleState,0x80194930,0x120 asm/non_matchings/code/audio_playback/AudioPlayback_NoteSetResamplingRate.s,AudioPlayback_NoteSetResamplingRate,0x80194DB0,0x2C asm/non_matchings/code/audio_playback/AudioPlayback_NoteInit.s,AudioPlayback_NoteInit,0x80194E60,0x30 asm/non_matchings/code/audio_playback/AudioPlayback_NoteDisable.s,AudioPlayback_NoteDisable,0x80194F20,0x19 From 26207594f2b7e41e9522930fd171142a8810214e Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Mon, 3 Oct 2022 20:06:04 -0700 Subject: [PATCH 20/25] Format Script Update (#904) * Bring over format.sh and .clang-tidy and run it * Little fixes * Adjustments * Jenkins kick * Jenkins kick 2 * format * small fixes * Bring over new formatter by Roman Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com> * Force use of clang-11 * check_format * Update error messages * Fix from Tharo for python3.6 Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com> * Just use nproc to determine num jobs for check format * Update error message * AnimatedMat_DrawStepOpa texture arg -> matAnim * Fix enTwig draw prototype * Tidying up * Bring over fixes in OoT #1387 Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com> * Fix * Update doc tools * PR Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com> Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com> --- .clang-tidy | 6 +- docs/tools.md | 28 +- format.py | 176 +++++++++++ format.sh | 46 --- include/functions.h | 297 +++++++++--------- include/gfxprint.h | 28 +- include/os_malloc.h | 2 +- include/sys_matrix.h | 2 +- include/z64quake.h | 2 +- include/z64save.h | 6 +- include/z64subs.h | 6 +- include/z_en_hy_code.h | 2 +- include/z_title_setup.h | 2 +- src/boot_O2_g3/irqmgr.c | 12 +- src/code/audio/audio_load.c | 2 +- src/code/audio/audio_synthesis.c | 6 +- src/code/audio/code_8019AF00.c | 2 +- src/code/z_en_item00.c | 4 +- src/code/z_scene_proc.c | 4 +- src/code/z_skelanime.c | 4 +- src/libultra/flash/osFlash.c | 6 +- .../ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c | 2 +- .../ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c | 2 +- .../ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.c | 2 +- .../actors/ovl_Bg_Ingate/z_bg_ingate.c | 2 +- .../ovl_Bg_Last_Bwall/z_bg_last_bwall.c | 2 +- .../actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c | 2 +- .../ovl_Bg_Open_Shutter/z_bg_open_shutter.c | 2 +- src/overlays/actors/ovl_Boss_02/z_boss_02.c | 2 +- src/overlays/actors/ovl_Boss_03/z_boss_03.c | 4 +- src/overlays/actors/ovl_Boss_04/z_boss_04.c | 4 +- src/overlays/actors/ovl_Boss_06/z_boss_06.c | 2 +- src/overlays/actors/ovl_Dm_An/z_dm_an.c | 2 +- .../actors/ovl_Dm_Char00/z_dm_char00.c | 2 +- .../actors/ovl_Dm_Char01/z_dm_char01.c | 2 +- .../actors/ovl_Door_Shutter/z_door_shutter.c | 2 +- src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c | 4 +- src/overlays/actors/ovl_En_Am/z_en_am.c | 2 +- src/overlays/actors/ovl_En_Az/z_en_az.c | 10 +- .../actors/ovl_En_Bbfall/z_en_bbfall.c | 2 +- src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c | 4 +- .../actors/ovl_En_Bigslime/z_en_bigslime.c | 2 +- src/overlays/actors/ovl_En_Bombf/z_en_bombf.c | 2 +- .../actors/ovl_En_Bomjimb/z_en_bomjimb.c | 2 +- src/overlays/actors/ovl_En_Cha/z_en_cha.c | 2 +- src/overlays/actors/ovl_En_Cow/z_en_cow.c | 6 +- .../actors/ovl_En_Dinofos/z_en_dinofos.c | 2 +- src/overlays/actors/ovl_En_Dnb/z_en_dnb.c | 2 +- .../actors/ovl_En_Dodongo/z_en_dodongo.c | 2 +- src/overlays/actors/ovl_En_Door/z_en_door.c | 2 +- .../actors/ovl_En_Door_Etc/z_en_door_etc.c | 2 +- src/overlays/actors/ovl_En_Elf/z_en_elf.c | 6 +- .../actors/ovl_En_Elfbub/z_en_elfbub.c | 2 +- .../actors/ovl_En_Firefly/z_en_firefly.c | 2 +- src/overlays/actors/ovl_En_Fish/z_en_fish.c | 2 +- src/overlays/actors/ovl_En_Fish2/z_en_fish2.c | 2 +- .../actors/ovl_En_Fishing/z_en_fishing.c | 8 +- .../actors/ovl_En_Floormas/z_en_floormas.c | 2 +- src/overlays/actors/ovl_En_Ge1/z_en_ge1.c | 4 +- src/overlays/actors/ovl_En_Gg2/z_en_gg2.c | 2 +- .../actors/ovl_En_Hanabi/z_en_hanabi.c | 4 +- src/overlays/actors/ovl_En_Horse/z_en_horse.c | 4 +- src/overlays/actors/ovl_En_Ik/z_en_ik.c | 2 +- .../actors/ovl_En_Invadepoh/z_en_invadepoh.c | 2 +- src/overlays/actors/ovl_En_Ishi/z_en_ishi.c | 2 +- .../actors/ovl_En_Karebaba/z_en_karebaba.c | 2 +- src/overlays/actors/ovl_En_Kusa/z_en_kusa.c | 2 +- .../actors/ovl_En_M_Thunder/z_en_m_thunder.c | 2 +- src/overlays/actors/ovl_En_Muto/z_en_muto.c | 2 +- .../actors/ovl_En_Nutsball/z_en_nutsball.c | 2 +- .../actors/ovl_En_Peehat/z_en_peehat.c | 2 +- src/overlays/actors/ovl_En_Poh/z_en_poh.c | 2 +- src/overlays/actors/ovl_En_Pr/z_en_pr.c | 2 +- .../actors/ovl_En_Racedog/z_en_racedog.c | 2 +- .../actors/ovl_En_Railgibud/z_en_railgibud.c | 3 +- src/overlays/actors/ovl_En_Rr/z_en_rr.c | 2 +- .../actors/ovl_En_Ruppecrow/z_en_ruppecrow.c | 2 +- .../ovl_En_Syateki_Crow/z_en_syateki_crow.c | 2 +- .../z_en_syateki_dekunuts.c | 2 +- .../ovl_En_Syateki_Wf/z_en_syateki_wf.c | 2 +- .../actors/ovl_En_Tanron2/z_en_tanron2.c | 2 +- .../actors/ovl_En_Tanron4/z_en_tanron4.c | 2 +- .../actors/ovl_En_Tanron5/z_en_tanron5.c | 4 +- src/overlays/actors/ovl_En_Test/z_en_test.c | 2 +- src/overlays/actors/ovl_En_Test5/z_en_test5.c | 4 +- src/overlays/actors/ovl_En_Test6/z_en_test6.c | 4 +- src/overlays/actors/ovl_En_Test7/z_en_test7.c | 2 +- .../actors/ovl_En_Thiefbird/z_en_thiefbird.c | 2 +- .../actors/ovl_En_Torch2/z_en_torch2.c | 2 +- src/overlays/actors/ovl_En_Twig/z_en_twig.c | 10 +- .../ovl_En_Water_Effect/z_en_water_effect.c | 4 +- .../actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c | 4 +- .../actors/ovl_En_Wood02/z_en_wood02.c | 2 +- src/overlays/actors/ovl_En_Zos/z_en_zos.c | 2 +- src/overlays/actors/ovl_En_Zot/z_en_zot.c | 2 +- .../actors/ovl_Obj_Armos/z_obj_armos.c | 2 +- src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c | 2 +- src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c | 2 +- .../actors/ovl_Obj_Dhouse/z_obj_dhouse.c | 2 +- .../ovl_Obj_Flowerpot/z_obj_flowerpot.c | 4 +- .../ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c | 2 +- .../actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c | 2 +- .../actors/ovl_Obj_Kibako/z_obj_kibako.c | 4 +- .../actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c | 2 +- .../actors/ovl_Obj_Raillift/z_obj_raillift.c | 6 +- .../ovl_Obj_Spinyroll/z_obj_spinyroll.c | 2 +- .../actors/ovl_Obj_Syokudai/z_obj_syokudai.c | 2 +- src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c | 2 +- .../actors/ovl_Obj_Tsubo/z_obj_tsubo.c | 4 +- src/overlays/actors/ovl_Obj_Um/z_obj_um.c | 2 +- .../ovl_Obj_Vspinyroll/z_obj_vspinyroll.c | 2 +- .../ovl_Obj_Warpstone/z_obj_warpstone.c | 2 +- src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c | 2 +- .../ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c | 2 +- tools/check_format.sh | 4 +- 115 files changed, 526 insertions(+), 372 deletions(-) create mode 100755 format.py delete mode 100755 format.sh diff --git a/.clang-tidy b/.clang-tidy index 4022a3f68a..caf62ab7f8 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,5 +1,9 @@ -Checks: '-*,readability-braces-around-statements' +Checks: '-*,readability-braces-around-statements,readability-inconsistent-declaration-parameter-name' WarningsAsErrors: '' HeaderFilterRegex: '(src|include)\/.*\.h$' FormatStyle: 'file' CheckOptions: + # Require argument names to match exactly (instead of allowing a name to be a prefix/suffix of another) + # Note: 'true' is expected by clang-tidy 12+ but '1' is used for compatibility with older versions + - key: readability-inconsistent-declaration-parameter-name.Strict + value: 1 diff --git a/docs/tools.md b/docs/tools.md index 149fba9ae6..0aba4fa475 100644 --- a/docs/tools.md +++ b/docs/tools.md @@ -23,7 +23,7 @@ - [`tools/warnings_count/check_new_warnings.sh`](#toolswarnings_countcheck_new_warningssh) - [`tools/warnings_count/update_current_warnings.sh`](#toolswarnings_countupdate_current_warningssh) - [`fixle.sh`](#fixlesh) - - [`format.sh`](#formatsh) + - [`format.py`](#formatpy) - [External tools](#external-tools) - [mips_to_c](#mips_to_c) - [Permuter](#permuter) @@ -196,9 +196,31 @@ If you have to add new warnings, **and have permission from the leads**, run thi Fixes line endings in the repo to Linux style (LF), which is required for the build process to work. (You may be better off creating a new clone directly in Linux/WSL, though) -### `format.sh` +### `format.py` -Formats all C files in the repo using `clang-format-11` (instructions on how to install this version are pinned in Discord if you can't get it from your package manager in the usual way). This will touch all files in the repo, so the next `make` will take longer. +Formats all C files in the repo using `clang-format-11`, `clang-tidy`, and `clang-apply-replacements` (when multiprocessing). This will touch all files in the repo, so the next `make` will take longer. + +You can specify how many threads you would like this to run with by adding the `-jN` flag. Where N is the number of threads. By default this will run using 1 thread (i.e. `-j1`). + +`clang-11` is available in many native package managers, but if not try: + +Linux: +Download llvm's setup script, run it, than install normally +```bash +wget https://apt.llvm.org/llvm.sh +chmod +x llvm.sh +sudo ./llvm.sh 11 +rm llvm.sh +sudo apt install clang-format-11 clang-tidy-11 clang-apply-replacements-11 +``` + +Mac: +Install with brew, than create symlinks for `clang-tidy` and `clang-apply-replacements` to use properly +```bash +brew install llvm clang-format-11 +ln -s "$(brew --prefix llvm)/bin/clang-tidy" "/usr/local/bin/clang-tidy" +ln -s "$(brew --prefix llvm)/bin/clang-apply-replacements" "/usr/local/bin/clang-apply-replacements" +``` ## External tools diff --git a/format.py b/format.py new file mode 100755 index 0000000000..5b3cd31580 --- /dev/null +++ b/format.py @@ -0,0 +1,176 @@ +#!/usr/bin/env python3 + +import argparse +import glob +import multiprocessing +import os +import re +import shutil +import subprocess +import sys +import tempfile +from functools import partial +from typing import List + + +# clang-format, clang-tidy and clang-apply-replacements default version +# Version 11 is used when available for more consistency between contributors +CLANG_VER = 11 + +# Clang-Format options (see .clang-format for rules applied) +FORMAT_OPTS = "-i -style=file" + +# Clang-Tidy options (see .clang-tidy for checks enabled) +TIDY_OPTS = "-p ." +TIDY_FIX_OPTS = "--fix --fix-errors" + +# Clang-Apply-Replacements options (used for multiprocessing) +APPLY_OPTS = "" + +# Compiler options used with Clang-Tidy +# Normal warnings are disabled with -Wno-everything to focus only on tidying +INCLUDES = "-Iinclude -Isrc -Ibuild -I." +DEFINES = "-D_LANGUAGE_C -DNON_MATCHING" +COMPILER_OPTS = f"-fno-builtin -std=gnu90 -m32 -Wno-everything {INCLUDES} {DEFINES}" + + +def get_clang_executable(allowed_executables: List[str]): + for executable in allowed_executables: + try: + subprocess.check_call([executable, "--version"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + return executable + except FileNotFoundError or subprocess.CalledProcessError: + pass + return None + + +def get_tidy_version(tidy_executable: str): + tidy_version_run = subprocess.run([tidy_executable, "--version"], stdout=subprocess.PIPE, universal_newlines=True) + match = re.search(r"LLVM version ([0-9]+)", tidy_version_run.stdout) + return int(match.group(1)) + + +CLANG_FORMAT = get_clang_executable([f"clang-format-{CLANG_VER}"]) +if CLANG_FORMAT is None: + sys.exit(f"Error: clang-format-{CLANG_VER} found") + +CLANG_TIDY = get_clang_executable([f"clang-tidy-{CLANG_VER}", "clang-tidy"]) +if CLANG_TIDY is None: + sys.exit(f"Error: neither clang-tidy-{CLANG_VER} nor clang-tidy found") + +CLANG_APPLY_REPLACEMENTS = get_clang_executable([f"clang-apply-replacements-{CLANG_VER}", "clang-apply-replacements"]) + +# Try to detect the clang-tidy version and add --fix-notes for version 13+ +# This is used to ensure all fixes are applied properly in recent versions +if get_tidy_version(CLANG_TIDY) >= 13: + TIDY_FIX_OPTS += " --fix-notes" + + +def list_chunks(list: List, chunk_length: int): + for i in range(0, len(list), chunk_length): + yield list[i : i + chunk_length] + + +def run_clang_format(files: List[str]): + exec_str = f"{CLANG_FORMAT} {FORMAT_OPTS} {' '.join(files)}" + subprocess.run(exec_str, shell=True) + + +def run_clang_tidy(files: List[str]): + exec_str = f"{CLANG_TIDY} {TIDY_OPTS} {TIDY_FIX_OPTS} {' '.join(files)} -- {COMPILER_OPTS}" + subprocess.run(exec_str, shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + + +def run_clang_tidy_with_export(tmp_dir: str, files: List[str]): + (handle, tmp_file) = tempfile.mkstemp(suffix=".yaml", dir=tmp_dir) + os.close(handle) + + exec_str = f"{CLANG_TIDY} {TIDY_OPTS} --export-fixes={tmp_file} {' '.join(files)} -- {COMPILER_OPTS}" + subprocess.run(exec_str, shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + + +def run_clang_apply_replacements(tmp_dir: str): + exec_str = f"{CLANG_APPLY_REPLACEMENTS} {APPLY_OPTS} {tmp_dir}" + subprocess.run(exec_str, shell=True) + + +def add_final_new_line(file: str): + # https://backreference.org/2010/05/23/sanitizing-files-with-no-trailing-newline/index.html + # "gets the last character of the file pipes it into read, which will exit with a nonzero exit + # code if it encounters EOF before newline (so, if the last character of the file isn't a newline). + # If read exits nonzero, then append a newline onto the file using echo (if read exits 0, + # that satisfies the ||, so the echo command isn't run)." (https://stackoverflow.com/a/34865616) + exec_str = f"tail -c1 {file} | read -r _ || echo >> {file}" + subprocess.run(exec_str, shell=True) + + +def format_files(src_files: List[str], extra_files: List[str], nb_jobs: int): + if nb_jobs != 1: + print(f"Formatting files with {nb_jobs} jobs") + else: + print(f"Formatting files with a single job (consider using -j to make this faster)") + + # Format files in chunks to improve performance while still utilizing jobs + file_chunks = list(list_chunks(src_files, (len(src_files) // nb_jobs) + 1)) + + print("Running clang-format...") + # clang-format only applies changes in the given files, so it's safe to run in parallel + with multiprocessing.get_context("fork").Pool(nb_jobs) as pool: + pool.map(run_clang_format, file_chunks) + + print("Running clang-tidy...") + if nb_jobs > 1: + # clang-tidy may apply changes in #included files, so when running it in parallel we use --export-fixes + # then we call clang-apply-replacements to apply all suggested fixes at the end + tmp_dir = tempfile.mkdtemp() + + try: + with multiprocessing.get_context("fork").Pool(nb_jobs) as pool: + pool.map(partial(run_clang_tidy_with_export, tmp_dir), file_chunks) + + run_clang_apply_replacements(tmp_dir) + finally: + shutil.rmtree(tmp_dir) + else: + run_clang_tidy(src_files) + + print("Adding missing final new lines...") + # Adding final new lines is safe to do in parallel and can be applied to all types of files + with multiprocessing.get_context("fork").Pool(nb_jobs) as pool: + pool.map(add_final_new_line, src_files + extra_files) + + print("Done formatting files.") + + +def main(): + parser = argparse.ArgumentParser(description="Format files in the codebase to enforce most style rules") + parser.add_argument("files", metavar="file", nargs="*") + parser.add_argument( + "-j", + dest="jobs", + type=int, + nargs="?", + default=1, + help="number of jobs to run (default: 1 without -j, number of cpus with -j)", + ) + args = parser.parse_args() + + nb_jobs = args.jobs or multiprocessing.cpu_count() + if nb_jobs > 1: + if CLANG_APPLY_REPLACEMENTS is None: + sys.exit( + f"Error: neither clang-apply-replacements-{CLANG_VER} nor clang-apply-replacements found (required to use -j)" + ) + + if args.files: + files = args.files + extra_files = [] + else: + files = glob.glob("src/**/*.c", recursive=True) + extra_files = glob.glob("assets/**/*.xml", recursive=True) + + format_files(files, extra_files, nb_jobs) + + +if __name__ == "__main__": + main() diff --git a/format.sh b/format.sh deleted file mode 100755 index 1c9389a9ac..0000000000 --- a/format.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env bash - -FORMAT_VER="11" -FORMAT_OPTS="-i -style=file" -TIDY_OPTS="-p . --fix --fix-errors" -COMPILER_OPTS="-fno-builtin -std=gnu90 -Iinclude -Isrc -D_LANGUAGE_C -DNON_MATCHING" - -# https://backreference.org/2010/05/23/sanitizing-files-with-no-trailing-newline/index.html -# "gets the last character of the file pipes it into read, which will exit with a nonzero exit code if it encounters EOF before newline (so, if the last character of the file isn't a newline). If read exits nonzero, then append a newline onto the file using echo (if read exits 0, that satisfies the ||, so the echo command isn't run)." (https://stackoverflow.com/a/34865616) -function add_final_newline () { - for file in "$@" - do - tail -c1 $file | read -r _ || echo >> $file - done -} -export -f add_final_newline - -shopt -s globstar - -if [ -z `command -v clang-format-${FORMAT_VER}` ] -then - echo "clang-format-${FORMAT_VER} not found. Exiting." - exit 1 -fi - -if (( $# > 0 )); then - echo "Formatting file(s) $*" - echo "Running clang-format..." - clang-format-${FORMAT_VER} ${FORMAT_OPTS} "$@" - echo "Running clang-tidy..." - clang-tidy ${TIDY_OPTS} "$@" -- ${COMPILER_OPTS} &> /dev/null - echo "Adding missing final new lines..." - add_final_newline "$@" - echo "Done formatting file(s) $*" - exit -fi - -echo "Formatting C files. This will take a bit" -echo "Running clang-format..." -clang-format-${FORMAT_VER} ${FORMAT_OPTS} src/**/*.c -echo "Running clang-tidy..." -clang-tidy ${TIDY_OPTS} src/**/*.c -- ${COMPILER_OPTS} &> /dev/null -echo "Adding missing final new lines..." -find src/ -type f -name "*.c" -exec bash -c 'add_final_newline "$@"' bash {} + -find assets/xml/ -type f -name "*.xml" -exec bash -c 'add_final_newline "$@"' bash {} + -echo "Done formatting all files." diff --git a/include/functions.h b/include/functions.h index d42733a145..34384ab3f9 100644 --- a/include/functions.h +++ b/include/functions.h @@ -5,25 +5,25 @@ void bootproc(void); void Idle_ThreadEntry(void* arg); -void ViConfig_UpdateVi(u32 arg0); +void ViConfig_UpdateVi(u32 mode); void ViConfig_UpdateBlack(void); -s32 DmaMgr_DmaRomToRam(u32 src, void* dst, size_t size); -s32 DmaMgr_DmaHandler(OSPiHandle* piHandle, OSIoMesg* mb, s32 direction); -DmaEntry* DmaMgr_FindDmaEntry(u32 vromAddr); -u32 DmaMgr_TranslateVromToRom(u32 vromAddr); -s32 DmaMgr_FindDmaIndex(u32 vromAddr); +s32 DmaMgr_DmaRomToRam(u32 rom, void* ram, size_t size); +s32 DmaMgr_DmaHandler(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction); +DmaEntry* DmaMgr_FindDmaEntry(u32 vrom); +u32 DmaMgr_TranslateVromToRom(u32 vrom); +s32 DmaMgr_FindDmaIndex(u32 vrom); const char* func_800809F4(u32 param_1); void DmaMgr_ProcessMsg(DmaRequest* req); void DmaMgr_ThreadEntry(void* arg); -s32 DmaMgr_SendRequestImpl(DmaRequest* request, void* vramStart, uintptr_t vromStart, size_t size, UNK_TYPE4 unused, OSMesgQueue* callback, void* callbackMesg); +s32 DmaMgr_SendRequestImpl(DmaRequest* request, void* vramStart, uintptr_t vromStart, size_t size, UNK_TYPE4 unused, OSMesgQueue* queue, void* msg); s32 DmaMgr_SendRequest0(void* vramStart, uintptr_t vromStart, size_t size); void DmaMgr_Start(void); void DmaMgr_Stop(void); void* Yaz0_FirstDMA(void); void* Yaz0_NextDMA(void* curSrcPos); -s32 Yaz0_DecompressImpl(u8* hdr, u8* dst); +s32 Yaz0_DecompressImpl(u8* src, u8* dst); void Yaz0_Decompress(u32 romStart, void* dst, size_t size); -void IrqMgr_AddClient(IrqMgr* irqmgr, IrqMgrClient* add, OSMesgQueue* msgQ); +void IrqMgr_AddClient(IrqMgr* irqmgr, IrqMgrClient* client, OSMesgQueue* msgQueue); void IrqMgr_RemoveClient(IrqMgr* irqmgr, IrqMgrClient* remove); void IrqMgr_SendMesgForClient(IrqMgr* irqmgr, OSMesg msg); void IrqMgr_JamMesgForClient(IrqMgr* irqmgr, OSMesg msg); @@ -85,7 +85,7 @@ void Fault_HangupFaultClient(const char* arg0, char* arg1); void Fault_AddHungupAndCrashImpl(const char* arg0, char* arg1); void Fault_AddHungupAndCrash(const char* filename, u32 line); void FaultDrawer_SetOsSyncPrintfEnabled(u32 enabled); -void FaultDrawer_DrawRecImpl(s32 xstart, s32 ystart, s32 xend, s32 yend, u16 color); +void FaultDrawer_DrawRecImpl(s32 xStart, s32 yStart, s32 xEnd, s32 yEnd, u16 color); void FaultDrawer_DrawChar(char c); s32 FaultDrawer_ColorToPrintColor(u16 color); void FaultDrawer_UpdatePrintColor(void); @@ -128,8 +128,8 @@ StackStatus StackCheck_GetState(StackEntry* entry); u32 StackCheck_CheckAll(void); u32 StackCheck_Check(StackEntry* entry); -void MtxConv_F2L(Mtx* m1, MtxF* m2); -void MtxConv_L2F(MtxF* m1, Mtx* m2); +void MtxConv_F2L(Mtx* mtx, MtxF* mf); +void MtxConv_L2F(MtxF* mtx, Mtx* mf); void __assert(const char* file, u32 lineNum); // void func_800862B4(void); @@ -150,7 +150,7 @@ f32 func_80086814(f32 x); // void func_80086AF0(void); f32 func_80086B30(f32 y, f32 x); // void func_80086C18(void); -f32 func_80086C48(f32 param_1); +f32 func_80086C48(f32 x); // void func_80086C70(void); f64 func_80086C7C(f64 param_1); s32 func_80086C88(f32 param_1); @@ -177,13 +177,13 @@ void Rand_Seed(u32 seed); f32 Rand_ZeroOne(void); f32 Rand_Centered(void); void Rand_Seed_Variable(u32* rndNum, u32 seed); -u32 Rand_Next_Variable(u32* param_1); -f32 Rand_ZeroOne_Variable(u32* param_1); -f32 Rand_Centered_Variable(u32* param_1); +u32 Rand_Next_Variable(u32* rndNum); +f32 Rand_ZeroOne_Variable(u32* rndNum); +f32 Rand_Centered_Variable(u32* rndNum); -void* proutSprintf(void* s, const char* buf, size_t n); +void* proutSprintf(void* dst, const char* fmt, size_t size); s32 vsprintf(char* dst, char* fmt, va_list args); -s32 sprintf(char* s, char* fmt, ...); +s32 sprintf(char* dst, char* fmt, ...); s32 PrintUtils_VPrintf(PrintCallback* pfn, const char* fmt, va_list args); s32 PrintUtils_Printf(PrintCallback* pfn, const char* fmt, ...); void Sleep_Cycles(OSTime time); @@ -194,7 +194,7 @@ void Sleep_Sec(u32 sec); // void __osSetCause(void); s32 osSendMesg(OSMesgQueue* mq, OSMesg msg, s32 flags); s32 osPfsFreeBlocks(OSPfs* pfs, s32* leftoverBytes); -void osViExtendVStart(u32 param_1); +void osViExtendVStart(u32 a0); void osStopThread(OSThread* t); s32 osRecvMesg(OSMesgQueue* mq, OSMesg* msg, s32 flags); OSIntMask osSetIntMask(OSIntMask im); @@ -226,8 +226,8 @@ OSThread* __osPopThread(OSThread** param_1); // void __osNop(void); void __osDispatchThread(void); void __osCleanupThread(void); -void __osDequeueThread(OSThread** param_1, OSThread* param_2); -void osDestroyThread(OSThread* puParm1); +void __osDequeueThread(OSThread** queue, OSThread* t); +void osDestroyThread(OSThread* t); // void __osVoiceCheckResult(void); void bzero(void* begin, s32 length); @@ -236,13 +236,13 @@ void __osSiGetAccess(void); void __osSiRelAccess(void); s32 osContInit(OSMesgQueue* mq, u8* bitpattern, OSContStatus* data); void __osContGetInitData(u8* pattern, OSContStatus* data); -void __osPackRequestData(u8 cmd); +void __osPackRequestData(u8 poll); void osCreateThread(OSThread* t, OSId id, void* entry, void* arg, void* sp, OSPri p); s32 osContStartReadData(OSMesgQueue* mq); void osContGetReadData(OSContPad* data); void __osPackReadData(void); // void osVoiceGetReadData(void); -uintptr_t osVirtualToPhysical(void* vaddr); +uintptr_t osVirtualToPhysical(void* virtualAddress); u32 __osGetSR(void); void __osSetSR(u32 value); void osWritebackDCache(void* vaddr, s32 nbytes); @@ -292,12 +292,12 @@ void guMtxL2F(MtxF* m1, Mtx* m2); u32 osGetMemSize(void); s32 osPfsFindFile(OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u8* extName, s32* fileNo); void osSetEventMesg(OSEvent e, OSMesgQueue* mq, OSMesg m); -f32 sqrtf(f32 __x); +f32 sqrtf(f32 f); s32 osAfterPreNMI(void); s32 osContStartQuery(OSMesgQueue* mq); void osContGetQuery(OSContStatus* data); -void guLookAtHiliteF(float mf[4][4], LookAt* l, Hilite* h, f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp, f32 xl1, f32 yl1, f32 zl1, f32 xl2, f32 yl2, f32 zl2, s32 twidth, s32 theight); -void guLookAtHilite(Mtx* m, LookAt* l, Hilite* h, f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp, f32 xl1, f32 yl1, f32 zl1, f32 xl2, f32 yl2, f32 zl2, s32 twidth, s32 theight); +void guLookAtHiliteF(float mf[4][4], LookAt* l, Hilite* h, f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp, f32 xl1, f32 yl1, f32 zl1, f32 xl2, f32 yl2, f32 zl2, s32 hiliteWidth, s32 hiliteHeight); +void guLookAtHilite(Mtx* m, LookAt* l, Hilite* h, f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp, f32 xl1, f32 yl1, f32 zl1, f32 xl2, f32 yl2, f32 zl2, s32 hiliteWidth, s32 hiliteHeight); s32 _Printf(PrintCallback pfn, void* arg, const char* fmt, va_list ap); void _Putfld(_Pft* px, va_list* pap, u8 code, u8* ac); // void osVoiceClearDictionary(void); @@ -305,9 +305,9 @@ void osUnmapTLBAll(void); s32 osEPiStartDma(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction); // void __osVoiceContRead2(void); u8 __osVoiceContDataCrc(u8* data, size_t numBytes); -const char* strchr(const char* __s, s32 __c); -size_t strlen(const char* __s); -void* memcpy(void* __dest, const void* __src, size_t __n); +const char* strchr(const char* s, s32 c); +size_t strlen(const char* s); +void* memcpy(void* s1, const void* s2, size_t n); void osCreateMesgQueue(OSMesgQueue* mq, OSMesg* msq, s32 count); void osInvalICache(void* vaddr, size_t nbytes); void osInvalDCache(void* vaddr, size_t nbytes); @@ -320,24 +320,24 @@ s32 __osSpDeviceBusy(void); s32 __osSiDeviceBusy(void); // void guMtxIdent(void); s32 osJamMesg(OSMesgQueue* mq, OSMesg msg, s32 flag); -void osSetThreadPri(OSThread* t, OSPri pri); +void osSetThreadPri(OSThread* t, OSPri p); OSPri osGetThreadPri(OSThread* t); s32 __osEPiRawReadIo(OSPiHandle* handle, u32 devAddr, u32* data); void osViSwapBuffer(void* frameBufPtr); -void guPositionF(float mf[4][4], f32 r, f32 p, f32 h, f32 s, f32 x, f32 y, f32 z); -void guPosition(Mtx* m, f32 r, f32 p, f32 h, f32 s, f32 x, f32 y, f32 z); +void guPositionF(float mf[4][4], f32 rot, f32 pitch, f32 yaw, f32 scale, f32 x, f32 y, f32 z); +void guPosition(Mtx* m, f32 rot, f32 pitch, f32 yaw, f32 scale, f32 x, f32 y, f32 z); s32 __osEPiRawStartDma(OSPiHandle* handle, s32 direction, u32 cartAddr, void* dramAddr, size_t size); OSYieldResult osSpTaskYielded(OSTask* task); s32 bcmp(void* __s1, void* __s2, size_t __n); OSTime osGetTime(void); -void guRotateF(float mf[4][4], f32 a, f32 x, f32 y, f32 z); +void guRotateF(float m[4][4], f32 a, f32 x, f32 y, f32 z); void guRotate(Mtx* m, f32 a, f32 x, f32 y, f32 z); void __osSetGlobalIntMask(u32 mask); // void osVoiceInit(void); s32 __osContChannelReset(OSMesgQueue* mq, s32 channel); // void __osVoiceSetADConverter(void); s32 osAiSetFrequency(u32 frequency); -s32 __osContRamRead(OSMesgQueue* mq, s32 channel, u16 address, u8* buffer); +s32 __osContRamRead(OSMesgQueue* ctrlrqueue, s32 channel, u16 addr, u8* buffer); // void __osVoiceContWrite20(void); u8 __osContAddressCrc(u16 addr); u8 __osContDataCrc(u8* data); @@ -351,7 +351,7 @@ void bcopy(void* __src, void* __dest, size_t __n); void __osResetGlobalIntMask(u32 mask); // void osPfsDeleteFile(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void __osPfsReleasePages(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -void guOrthoF(float mf[4][4], f32 l, f32 r, f32 b, f32 t, f32 n, f32 f, f32 scale); +void guOrthoF(float m[4][4], f32 l, f32 r, f32 b, f32 t, f32 n, f32 f, f32 scale); void guOrtho(Mtx* m, f32 l, f32 r, f32 b, f32 t, f32 n, f32 f, f32 scale); OSIntMask __osDisableInt(void); void __osRestoreInt(OSIntMask im); @@ -359,13 +359,13 @@ void __osViInit(void); void __osViSwapContext(void); OSMesgQueue* osPiGetCmdQueue(void); f32 cosf(f32 __x); -s32 osEPiReadIo(OSPiHandle* pihandle, u32 devAddr, u32* data); +s32 osEPiReadIo(OSPiHandle* handle, u32 devAddr, u32* data); void osViSetSpecialFeatures(u32 func); s16 coss(u16 x); void osSetTime(OSTime ticks); // void osVoiceStopReadData(void); void osViSetEvent(OSMesgQueue* mq, OSMesg m, u32 retraceCount); -s32 osPfsIsPlug(OSMesgQueue* queue, u8* pattern); +s32 osPfsIsPlug(OSMesgQueue* mq, u8* pattern); // void __osPfsRequestData(void); // void __osPfsGetInitData(void); s32 __osVoiceGetStatus(OSMesgQueue* mq, s32 port, u8* status); @@ -380,7 +380,7 @@ u32 __osGetFpcCsr(void); // void __osPfsCheckRamArea(void); // void osPfsChecker(void); u32 osAiGetLength(void); -s32 osEPiWriteIo(OSPiHandle* pihandle, u32 devAddr, u32 data); +s32 osEPiWriteIo(OSPiHandle* handle, u32 devAddr, u32 data); void osMapTLBRdb(void); void osYieldThread(void); void guTranslate(Mtx* mtx, f32 x, f32 y, f32 z); @@ -388,15 +388,15 @@ u32 __osGetCause(void); s32 __osContRamWrite(OSMesgQueue* mq, s32 channel, u16 address, u8* buffer, s32 force); s32 __osEPiRawWriteIo(OSPiHandle* handle, u32 devAddr, u32 data); s32 osSetTimer(OSTimer* t, OSTime value, OSTime interval, OSMesgQueue* mq, OSMesg msg); -void _Ldtob(_Pft* px, u8 code); +void _Ldtob(_Pft* args, u8 type); // void _Ldunscale(void); void _Genld(_Pft* px, u8 code, u8* p, s16 nsig, s16 xexp); ldiv_t ldiv(long numer, long denom); lldiv_t lldiv(long long numer, long long denom); -void _Litob(_Pft* px, u8 code); +void _Litob(_Pft* args, u8 type); s32 __osSiRawWriteIo(u32 devAddr, u32 data); u32 __osSpGetStatus(void); -void __osSpSetStatus(u32 value); +void __osSpSetStatus(u32 data); void osCreateViManager(OSPri pri); // void viMgrMain(OSDevMgr* iParm1); __OSViContext* __osViGetCurrentContext(void); @@ -404,17 +404,17 @@ void osWritebackDCacheAll(void); OSThread* __osGetCurrFaultedThread(void); // void osVoiceMaskDictionary(void); void guMtxF2L(float mf[4][4], Mtx* m); -void osStartThread(OSThread* param_1); +void osStartThread(OSThread* t); void osViSetYScale(f32 value); void osViSetXScale(f32 value); long long __d_to_ll(double d); long long __f_to_ll(float f); unsigned long long __d_to_ull(double d); unsigned long long __f_to_ull(float f); -double __ll_to_d(long long l); -float __ll_to_f(long long l); -double __ull_to_d(unsigned long long l); -float __ull_to_f(unsigned long long l); +double __ll_to_d(long long s); +float __ll_to_f(long long s); +double __ull_to_d(unsigned long long u); +float __ull_to_f(unsigned long long u); // void osVoiceCheckWord(void); // void osVoiceControlGain(void); // void osVoiceStartReadData(void); @@ -473,7 +473,7 @@ void func_800AE5A0(PlayState* play); void func_800AE5E4(PlayState* play, Color_RGBA8* color, s16 arg2, s16 arg3); void func_800AE778(PlayState* play, Color_RGBA8* color, s16 arg2, s16 arg3); void func_800AE8EC(PlayState* play); -void func_800AE930(CollisionContext* colCtx, EffectTireMark* this, Vec3f* pos, f32 arg3, s16 angle, CollisionPoly* colPoly, s32 arg6); +void func_800AE930(CollisionContext* colCtx, EffectTireMark* this, Vec3f* pos, f32 arg3, s16 arg4, CollisionPoly* colPoly, s32 arg6); void func_800AEF44(EffectTireMark* this); void EffectTireMark_Init(void* thisx, void* initParamsx); void EffectTireMark_Destroy(void* thisx); @@ -490,18 +490,18 @@ void Effect_DestroyAll(PlayState* play); void EffectSS_Init(PlayState* play, s32 numEntries); void EffectSS_Clear(PlayState* play); EffectSs* EffectSS_GetTable(void); -void EffectSS_Delete(EffectSs* param_1); +void EffectSS_Delete(EffectSs* effectSs); void EffectSS_ResetEntry(EffectSs* particle); s32 EffectSS_FindFreeSpace(s32 priority, s32* tableEntry); -void EffectSS_Copy(PlayState* play, EffectSs* particle); -void EffectSs_Spawn(PlayState* play, s32 type, s32 priority, void* initParams); +void EffectSS_Copy(PlayState* play, EffectSs* effectsSs); +void EffectSs_Spawn(PlayState* play, s32 type, s32 priority, void* initData); void EffectSS_UpdateParticle(PlayState* play, s32 index); void EffectSS_UpdateAllParticles(PlayState* play); void EffectSS_DrawParticle(PlayState* play, s32 index); void EffectSS_DrawAllParticles(PlayState* play); -s16 func_800B096C(s16 param_1, s16 param_2, s32 param_3); -s16 func_800B09D0(s16 a0, s16 a1, f32 a2); -u8 func_800B0A24(u8 a0, u8 a1, f32 a2); +s16 func_800B096C(s16 arg0, s16 arg1, s32 arg2); +s16 func_800B09D0(s16 arg0, s16 arg1, f32 arg2); +u8 func_800B0A24(u8 arg0, u8 arg1, f32 arg2); void EffectSs_DrawGEffect(PlayState* play, EffectSs* this, void* texture); void EffectSsDust_Spawn(PlayState* play, u16 drawFlags, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life, u8 updateMode); void func_800B0DE0(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep); @@ -530,10 +530,9 @@ void EffectSsKirakira_SpawnDispersed(PlayState* play, Vec3f* pos, Vec3f* velocit // void EffectSsBomb2_SpawnFade(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4); void EffectSsBomb2_SpawnLayered(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep); // void EffectSsBlast_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, Color_RGBA8* param_5, Color_RGBA8* param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10); -void EffectSsBlast_SpawnWhiteCustomScale(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, - s16 scaleStep, s16 life); +void EffectSsBlast_SpawnWhiteCustomScale(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 life); // void EffectSsBlast_SpawnShockwave(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE2 param_7); -void EffectSsBlast_SpawnWhiteShockwave(PlayState* play, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3); +void EffectSsBlast_SpawnWhiteShockwave(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel); // void EffectSsGSpk_SpawnAccel(UNK_TYPE4 uParm1, UNK_TYPE4 uParm2, Vec3f* pzParm3, Vec3f* pzParm4, Vec3f* param_5, Color_RGBA8* param_6, Color_RGBA8* param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9); // void EffectSsGSpk_SpawnNoAccel(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9); void EffectSsGSpk_SpawnFuse(PlayState* play, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel); @@ -558,11 +557,11 @@ void EffectSsHitmark_SpawnFixedScale(PlayState* play, s32 type, Vec3f* pos); void EffectSsHitmark_SpawnCustomScale(PlayState* play, s32 type, s16 scale, Vec3f* pos); void EffectSsFhgFlash_SpawnShock(PlayState* play, Actor* actor, Vec3f* pos, s16 scale, u8 params); // void EffectSsKFire_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, UNK_TYPE2 param_5, UNK_TYPE1 param_6); -void EffectSsSolderSrchBall_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16* playerDetected, s16 params); +void EffectSsSolderSrchBall_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16* playerDetected, s16 flags); void EffectSsKakera_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* arg3, s16 gravity, s16 arg5, s16 arg6, s16 arg7, s16 arg8, s16 scale, s16 arg10, s16 arg11, s32 life, s16 colorIdx, s16 objId, Gfx* dList); // void EffectSsIcePiece_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, UNK_TYPE4 uParm3, Vec3f* pzParm4, Vec3f* param_5, UNK_TYPE4 param_6); // void EffectSsIcePiece_SpawnBurst(void); -void func_800B2B44(PlayState* play, Actor* actor, Vec3f* arg2, f32 arg3); +void func_800B2B44(PlayState* play, Actor* actor, Vec3f* pos, f32 scale); // void func_800B2B7C(void); void EffectSsEnIce_Spawn(PlayState* play, Vec3f* pos, f32 scale, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s32 life); // void EffectSsFireTail_Spawn(UNK_TYPE4 uParm1, UNK_TYPE4 uParm2, Vec3f* pzParm3, UNK_TYPE4 uParm4, Vec3f* param_5, UNK_TYPE2 param_6, Color_RGBA8* param_7, Color_RGBA8* param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10, UNK_TYPE4 param_11); @@ -571,7 +570,7 @@ void EffectSsEnIce_Spawn(PlayState* play, Vec3f* pos, f32 scale, Vec3f* velocity void EffectSsEnFire_SpawnVec3f(PlayState* play, Actor* actor, Vec3f* pos, s16 scale, s16 params, s16 flags, s16 bodyPart); // void EffectSsEnFire_SpawnVec3s(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7); void EffectSsExtra_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scoreIdx); -void EffectSsDeadDb_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* prim, Color_RGBA8* env, s16 scale, s16 scaleStep, s32 unk); +void EffectSsDeadDb_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* prim, Color_RGBA8* env, s16 scale, s16 scaleStep, s32 life); void func_800B3030(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s32 colorIndex); void EffectSsDeadDd_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* prim, Color_RGBA8* env, s16 scale, s16 scaleStep, s16 alphaStep, s32 life); // void EffectSsDeadDs_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7, UNK_TYPE4 param_8); @@ -580,8 +579,8 @@ void EffectSsIceSmoke_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* void EffectSsIceBlock_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale); void FlagSet_Update(GameState* gameState); void FlagSet_Draw(GameState* gameState); -void Overlay_LoadGameState(GameStateOverlay* gameState); -void Overlay_FreeGameState(GameStateOverlay* gameState); +void Overlay_LoadGameState(GameStateOverlay* overlayEntry); +void Overlay_FreeGameState(GameStateOverlay* overlayEntry); void ActorShape_Init(ActorShape* actorShape, f32 yOffset, ActorShadowFunc shadowDraw, f32 shadowScale); void ActorShadow_DrawCircle(Actor* actor, Lights* lights, PlayState* play); @@ -648,7 +647,7 @@ f32 Actor_XZDistanceBetweenActors(Actor* actor1, Actor* actor2); f32 Actor_XZDistanceToPoint(Actor* actor, Vec3f* point); void Actor_OffsetOfPointInActorCoords(Actor* actor, Vec3f* offset, Vec3f* point); f32 Actor_HeightDiff(Actor* actor1, Actor* actor2); -void func_800B6F20(PlayState* play, Input* input, f32 arg2, s16 arg3); +void func_800B6F20(PlayState* play, Input* input, f32 magnitude, s16 baseYaw); f32 Player_GetHeight(Player* player); f32 Player_GetRunSpeedLimit(Player* player); s32 func_800B7118(Player* player); @@ -717,7 +716,7 @@ void func_800B9010(Actor* actor, u16 sfxId); void func_800B9038(Actor* actor, s32 timer); void func_800B9084(Actor* actor); void func_800B9098(Actor* actor); -s32 func_800B90AC(PlayState* play, Actor* actor, CollisionPoly* polygon, s32 index, s32 arg4); +s32 func_800B90AC(PlayState* play, Actor* actor, CollisionPoly* polygon, s32 bgId, s32 arg4); void Actor_DeactivateLens(PlayState* play); void func_800B9120(ActorContext* actorCtx); void Actor_InitContext(PlayState* play, ActorContext* actorCtx, ActorEntry* actorEntry); @@ -783,15 +782,15 @@ void ActorOverlayTable_Init(void); void ActorOverlayTable_Cleanup(void); void SSNode_SetValue(SSNode* node, s16* polyIndex, u16 next); -void SSList_SetNull(SSList* head); +void SSList_SetNull(SSList* ssList); void SSNodeList_SetSSListHead(SSNodeList* list, SSList* ssList, s16* polyIndex); void DynaSSNodeList_SetSSListHead(DynaSSNodeList* list, SSList* ssList, s16* polyIndex); void DynaSSNodeList_Init(PlayState* play, DynaSSNodeList* list); void DynaSSNodeList_Alloc(PlayState* play, DynaSSNodeList* list, u32 numNodes); void DynaSSNodeList_ResetCount(DynaSSNodeList* list); u16 DynaSSNodeList_GetNextNodeIdx(DynaSSNodeList* list); -void BgCheck_Vec3sToVec3f(Vec3s* vertex, Vec3f* vector); -void BgCheck_Vec3fToVec3s(Vec3s* vertex, Vec3f* vector); +void BgCheck_Vec3sToVec3f(Vec3s* src, Vec3f* dest); +void BgCheck_Vec3fToVec3s(Vec3s* dest, Vec3f* src); f32 func_800BFD84(CollisionPoly *poly, f32 arg1, f32 arg2); s32 func_800BFDEC(CollisionPoly* polyA, CollisionPoly* polyB, u32* outVtxId0, u32* outVtxId1); s16 CollisionPoly_GetMinY(CollisionPoly* poly, Vec3s* vertices); @@ -815,7 +814,7 @@ void BgCheck_Allocate(CollisionContext* colCtx, PlayState* play, CollisionHeader void BgCheck_SetContextFlags(CollisionContext* colCtx, u32 flags); void BgCheck_UnsetContextFlags(CollisionContext* colCtx, u32 flags); CollisionHeader* BgCheck_GetCollisionHeader(CollisionContext* colCtx, s32 bgId); -f32 BgCheck_RaycastFloorImpl(PlayState* play, CollisionContext* colCtx, u16 xpFlags, CollisionPoly** outPoly, s32* outBgId, Vec3f* pos, Actor* actor, u32 arg7, f32 chkDist, s32 arg9); +f32 BgCheck_RaycastFloorImpl(PlayState* play, CollisionContext* colCtx, u16 xpFlags, CollisionPoly** outPoly, s32* outBgId, Vec3f* pos, Actor* actor, u32 arg7, f32 checkDist, s32 arg9); f32 BgCheck_CameraRaycastFloor1(CollisionContext* colCtx, CollisionPoly** outPoly, Vec3f* pos); f32 BgCheck_EntityRaycastFloor1(CollisionContext* colCtx, CollisionPoly** outPoly, Vec3f* pos); f32 BgCheck_EntityRaycastFloor2(PlayState* play, CollisionContext* colCtx, CollisionPoly** outPoly, Vec3f* pos); @@ -824,7 +823,7 @@ f32 BgCheck_EntityRaycastFloor3(CollisionContext* colCtx, CollisionPoly** outPol f32 BgCheck_EntityRaycastFloor5(CollisionContext* colCtx, CollisionPoly** outPoly, s32* outBgId, Actor* actor, Vec3f* pos); f32 BgCheck_EntityRaycastFloor5_2(PlayState* play, CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos); f32 BgCheck_EntityRaycastFloor5_3(PlayState* play, CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos); -f32 BgCheck_EntityRaycastFloor6(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos, f32 chkDist); +f32 BgCheck_EntityRaycastFloor6(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos, f32 checkDist); f32 BgCheck_EntityRaycastFloor7(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos); f32 BgCheck_AnyRaycastFloor1(CollisionContext* colCtx, CollisionPoly* outPoly, Vec3f* pos); f32 BgCheck_AnyRaycastFloor2(CollisionContext* colCtx, CollisionPoly* outPoly, s32* bgId, Vec3f* pos); @@ -839,15 +838,15 @@ s32 BgCheck_EntitySphVsWall4(CollisionContext* colCtx, Vec3f* posResult, Vec3f* s32 BgCheck_CheckCeilingImpl(CollisionContext* colCtx, u16 xpFlags, f32* outY, Vec3f* pos, f32 checkHeight, CollisionPoly** outPoly, s32* outBgId, Actor* actor); s32 BgCheck_AnyCheckCeiling(CollisionContext* colCtx, f32* outY, Vec3f* pos, f32 checkHeight); s32 BgCheck_EntityCheckCeiling(CollisionContext* colCtx, f32* outY, Vec3f* pos, f32 checkHeight, CollisionPoly** outPoly, s32* outBgId, Actor* actor); -s32 BgCheck_CameraLineTest1(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId); -s32 BgCheck_CameraLineTest2(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId); -s32 BgCheck_EntityLineTest1(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId); -s32 BgCheck_EntityLineTest2(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId, Actor* actor); -s32 BgCheck_EntityLineTest3(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId, Actor* actor, f32 chkDist); -s32 BgCheck_ProjectileLineTest(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId); -s32 BgCheck_AnyLineTest1(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 chkOneFace); -s32 BgCheck_AnyLineTest2(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace); -s32 BgCheck_AnyLineTest3(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId); +s32 BgCheck_CameraLineTest1(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 checkWall, s32 checkFloor, s32 checkCeil, s32 checkOneFace, s32* bgId); +s32 BgCheck_CameraLineTest2(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 checkWall, s32 checkFloor, s32 checkCeil, s32 checkOneFace, s32* bgId); +s32 BgCheck_EntityLineTest1(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 checkWall, s32 checkFloor, s32 checkCeil, s32 checkOneFace, s32* bgId); +s32 BgCheck_EntityLineTest2(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 checkWall, s32 checkFloor, s32 checkCeil, s32 checkOneFace, s32* bgId, Actor* actor); +s32 BgCheck_EntityLineTest3(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 checkWall, s32 checkFloor, s32 checkCeil, s32 checkOneFace, s32* bgId, Actor* actor, f32 checkDist); +s32 BgCheck_ProjectileLineTest(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 checkWall, s32 checkFloor, s32 checkCeil, s32 checkOneFace, s32* bgId); +s32 BgCheck_AnyLineTest1(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 checkOneFace); +s32 BgCheck_AnyLineTest2(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 checkWall, s32 checkFloor, s32 checkCeil, s32 checkOneFace); +s32 BgCheck_AnyLineTest3(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 checkWall, s32 checkFloor, s32 checkCeil, s32 checkOneFace, s32* bgId); s32 BgCheck_SphVsFirstPolyImpl(CollisionContext* colCtx, u16 xpFlags, CollisionPoly** outPoly, s32* outBgId, Vec3f* center, f32 radius, Actor* actor, u16 bciFlags); s32 BgCheck_SphVsFirstPoly(CollisionContext* colCtx, Vec3f* center, f32 radius); s32 BgCheck_SphVsFirstWall(CollisionContext* colCtx, Vec3f* center, f32 radius); @@ -890,8 +889,8 @@ void BgCheck_ResetFlagsIfLoadedActor(PlayState* play, DynaCollisionContext* dyna void DynaPoly_Setup(PlayState* play, DynaCollisionContext* dyna); void func_800C756C(DynaCollisionContext* dyna, s32* numPolygons, s32* numVertices, s32* numWaterBoxes); void DynaPoly_UpdateBgActorTransforms(PlayState* play, DynaCollisionContext* dyna); -void CollisionHeader_SegmentedToVirtual(CollisionHeader* header); -void CollisionHeader_GetVirtual(CollisionHeader* meshSegPtr, CollisionHeader** param_2); +void CollisionHeader_SegmentedToVirtual(CollisionHeader* colHeader); +void CollisionHeader_GetVirtual(CollisionHeader* colHeader, CollisionHeader** dest); void BgCheck_InitCollisionHeaders(CollisionContext* colCtx, PlayState* play); u32 SurfaceType_GetBgCamIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); @@ -931,7 +930,7 @@ u32 SurfaceType_IsWallDamage(CollisionContext* colCtx, CollisionPoly* poly, s32 s32 WaterBox_GetSurfaceImpl(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox, s32* bgId); s32 WaterBox_GetSurface1(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox); s32 WaterBox_GetSurface1_2(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox); -s32 WaterBox_GetSurface2(PlayState* play, CollisionContext* colCtx, Vec3f* pos, f32 surfaceChkDist, WaterBox** outWaterBox, s32* bgId); +s32 WaterBox_GetSurface2(PlayState* play, CollisionContext* colCtx, Vec3f* pos, f32 surfaceCheckDist, WaterBox** outWaterBox, s32* bgId); f32 func_800CA568(CollisionContext* colCtx, s32 waterBoxId, s32 bgId); u16 WaterBox_GetBgCamSetting(CollisionContext* colCtx, WaterBox* waterBox, s32 bgId); void WaterBox_GetSceneBgCamSetting(CollisionContext* colCtx, WaterBox* waterBox); @@ -939,18 +938,18 @@ u32 WaterBox_GetLightSettingIndex(CollisionContext* colCtx, WaterBox* waterBox); s32 func_800CA6F0(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox, s32* bgId); s32 func_800CA9D0(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox); s32 func_800CAA14(CollisionPoly* polyA, CollisionPoly* polyB, Vec3f* pointA, Vec3f* pointB, Vec3f* closestPoint); -void BgCheck2_UpdateActorPosition(CollisionContext* colCtx, s32 index, Actor* actor); -void BgCheck2_UpdateActorYRotation(CollisionContext* colCtx, s32 index, Actor* actor); -void BgCheck2_AttachToMesh(CollisionContext* colCtx, Actor* actor, s32 index); -u32 BgCheck2_UpdateActorAttachedToMesh(CollisionContext* colCtx, s32 index, Actor* actor); +void BgCheck2_UpdateActorPosition(CollisionContext* colCtx, s32 bgId, Actor* actor); +void BgCheck2_UpdateActorYRotation(CollisionContext* colCtx, s32 bgId, Actor* actor); +void BgCheck2_AttachToMesh(CollisionContext* colCtx, Actor* actor, s32 bgId); +u32 BgCheck2_UpdateActorAttachedToMesh(CollisionContext* colCtx, s32 bgId, Actor* actor); void DynaPolyActor_Init(DynaPolyActor* dynaActor, s32 flags); void DynaPolyActor_LoadMesh(PlayState* play, DynaPolyActor* dynaActor, CollisionHeader* meshHeader); void DynaPolyActor_ResetState(DynaPolyActor* dynaActor); void DynaPolyActor_SetRidingFallingState(DynaPolyActor* dynaActor); void DynaPolyActor_SetRidingMovingState(DynaPolyActor* dynaActor); -void DynaPolyActor_SetRidingMovingStateByIndex(CollisionContext* colCtx, s32 index); +void DynaPolyActor_SetRidingMovingStateByIndex(CollisionContext* colCtx, s32 bgId); void DynaPolyActor_SetRidingRotatingState(DynaPolyActor* dynaActor); -void DynaPolyActor_SetRidingRotatingStateByIndex(CollisionContext* colCtx, s32 index); +void DynaPolyActor_SetRidingRotatingStateByIndex(CollisionContext* colCtx, s32 bgId); void DynaPolyActor_SetSwitchPressedState(DynaPolyActor* dynaActor); void DynaPolyActor_SetHeavySwitchPressedState(DynaPolyActor* dynaActor); s32 DynaPolyActor_IsInRidingFallingState(DynaPolyActor* dynaActor); @@ -1331,7 +1330,7 @@ s32 Flags_GetInfTable(s32 flag); void Flags_SetInfTable(s32 flag); s32 Actor_TrackNone(Vec3s* headRot, Vec3s* torsoRot); s32 Actor_TrackPoint(Actor* actor, Vec3f* target, Vec3s* headRot, Vec3s* torsoRot); -s32 Actor_TrackPlayerSetFocusHeight(PlayState* play, Actor* actor, Vec3s* headRot, Vec3s* torsoRot, f32 focusPosYAdj); +s32 Actor_TrackPlayerSetFocusHeight(PlayState* play, Actor* actor, Vec3s* headRot, Vec3s* torsoRot, f32 focusHeight); s32 Actor_TrackPlayer(PlayState* play, Actor* actor, Vec3s* headRot, Vec3s* torsoRot, Vec3f focusPos); void SaveContext_Init(void); void GameInfo_Init(void); @@ -1616,10 +1615,10 @@ void Lights_GlowCheck(PlayState* play); void Lights_DrawGlow(PlayState* play); void* ZeldaArena_Malloc(size_t size); void* ZeldaArena_MallocR(size_t size); -void* ZeldaArena_Realloc(void* oldPtr, size_t newSize); -void ZeldaArena_Free(void* param_1); +void* ZeldaArena_Realloc(void* ptr, size_t newSize); +void ZeldaArena_Free(void* ptr); void* ZeldaArena_Calloc(u32 num, size_t size); -void ZeldaArena_GetSizes(size_t* maxFreeBlock, size_t* bytesFree, size_t* bytesAllocated); +void ZeldaArena_GetSizes(size_t* outMaxFree, size_t* outFree, size_t* outAlloc); s32 ZeldaArena_Check(); void ZeldaArena_Init(void* start, size_t size); void ZeldaArena_Cleanup(); @@ -1898,7 +1897,7 @@ void func_80122F28(Player* player); s32 func_80122F9C(PlayState* play); s32 func_80122FCC(PlayState* play); void func_8012300C(PlayState* play, s32 arg1); -void func_8012301C(Player* player, PlayState* play); +void func_8012301C(Player* player, PlayState* play2); void func_80123140(PlayState* play, Player* player); s32 Player_InBlockingCsMode(PlayState* play, Player* player); s32 Player_InCsMode(PlayState* play); @@ -1912,10 +1911,10 @@ s32 func_8012364C(PlayState* play, Player* player, s32 arg2); s32 func_80123810(PlayState* play); s32 Player_ActionToModelGroup(Player* player, s32 actionParam); void func_801239AC(Player* player); -void Player_SetModels(Player* player, s32 arg1); +void Player_SetModels(Player* player, s32 modelGroup); void Player_SetModelGroup(Player* player, s32 modelGroup); void func_80123C58(Player* player); -void Player_SetEquipmentData(PlayState* play, Player* this); +void Player_SetEquipmentData(PlayState* play, Player* player); void func_80123D50(PlayState* play, Player* player, s32 itemId, s32 actionParam); void func_80123DA4(Player* player); void func_80123DC0(Player* player); @@ -1938,7 +1937,7 @@ s32 Player_ActionToBottle(Player* player, s32 actionParam); s32 Player_GetBottleHeld(Player* Player); s32 Player_ActionToExplosive(Player* player, s32 actionParam); s32 Player_GetExplosiveHeld(Player* player); -s32 func_80124278(Actor* actor, s32 arg1); +s32 func_80124278(Actor* actor, s32 actionParam); s32 func_801242B4(Player* player); s32 Player_GetEnvTimerType(PlayState* play); void func_80124420(Player* player); @@ -1953,7 +1952,7 @@ s32 func_801263FC(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s s32 func_80126440(PlayState* play, ColliderQuad* collider, WeaponInfo* weaponInfo, Vec3f* arg3, Vec3f* arg4); void Player_DrawGetItem(PlayState* play, Player* player); void func_80126B8C(PlayState* play, Player* player); -s32 func_80127438(PlayState* play, Player* player, s32 maskId); +s32 func_80127438(PlayState* play, Player* player, s32 currentMask); s32 func_80128640(PlayState* play, Player* player, Gfx* dlist); void func_80128B74(PlayState* play, Player* player, s32 limbIndex); void func_80128BD0(PlayState* play, s32 limbIndex, Gfx** dList1, Gfx** dList2, Vec3s* rot, Actor* actor); @@ -2065,7 +2064,7 @@ void Inventory_SaveLotteryCodeGuess(PlayState* play); s32 Object_Spawn(ObjectContext* objectCtx, s16 id); void Object_InitBank(GameState* gameState, ObjectContext* objectCtx); void Object_UpdateBank(ObjectContext* objectCtx); -s32 Object_GetIndex(ObjectContext* objectCtx, s16 id); +s32 Object_GetIndex(ObjectContext* objectCtx, s16 objectId); s32 Object_IsLoaded(ObjectContext* objectCtx, s32 index); void Object_LoadAll(ObjectContext* objectCtx); void* func_8012F73C(ObjectContext* objectCtx, s32 iParm2, s16 id); @@ -2111,7 +2110,7 @@ Gfx* AnimatedMat_TexScroll(PlayState* play, AnimatedMatTexScrollParams* params); void AnimatedMat_DrawTexScroll(PlayState* play, s32 segment, void* params); Gfx* AnimatedMat_TwoLayerTexScroll(PlayState* play, AnimatedMatTexScrollParams* params); void AnimatedMat_DrawTwoTexScroll(PlayState* play, s32 segment, void* params); -void AnimatedMat_SetColor(PlayState* play, s32 segment, F3DPrimColor* primColor, F3DEnvColor* envColor); +void AnimatedMat_SetColor(PlayState* play, s32 segment, F3DPrimColor* primColorResult, F3DEnvColor* envColor); void AnimatedMat_DrawColor(PlayState* play, s32 segment, void* params); s32 AnimatedMat_Lerp(s32 min, s32 max, f32 norm); void AnimatedMat_DrawColorLerp(PlayState* play, s32 segment, void* params); @@ -2157,7 +2156,7 @@ void SkelAnime_DrawFlexLimbOpa(PlayState* play, s32 limbIndex, void** skeleton, void SkelAnime_DrawFlexOpa(PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor); void SkelAnime_DrawTransformFlexLimbOpa(PlayState* play, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, TransformLimbDrawOpa transformLimbDraw, Actor* actor, Mtx** mtx); void SkelAnime_DrawTransformFlexOpa(PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, TransformLimbDrawOpa transformLimbDraw, Actor* actor); -void SkelAnime_GetFrameData(AnimationHeader* animation, s32 currentFrame, s32 limbCount, Vec3s* dst); +void SkelAnime_GetFrameData(AnimationHeader* animation, s32 frame, s32 limbCount, Vec3s* frameTable); s16 Animation_GetLength(void* animation); s16 Animation_GetLastFrame(void* animation); Gfx* SkelAnime_DrawLimb(PlayState* play, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, Gfx* gfx); @@ -2176,8 +2175,8 @@ AnimationEntry* AnimationContext_AddEntry(AnimationContext* animationCtx, Animat void AnimationContext_SetLoadFrame(PlayState* play, LinkAnimationHeader* animation, s32 frame, s32 limbCount, Vec3s* frameTable); void AnimationContext_SetCopyAll(PlayState* play, s32 vecCount, Vec3s* dst, Vec3s* src); void AnimationContext_SetInterp(PlayState* play, s32 vecCount, Vec3s* base, Vec3s* mod, f32 weight); -void AnimationContext_SetCopyTrue(PlayState* play, s32 vecCount, Vec3s* dst, Vec3s* src, u8* index); -void AnimationContext_SetCopyFalse(PlayState* play, s32 vecCount, Vec3s* dst, Vec3s* src, u8* index); +void AnimationContext_SetCopyTrue(PlayState* play, s32 vecCount, Vec3s* dst, Vec3s* src, u8* copyFlag); +void AnimationContext_SetCopyFalse(PlayState* play, s32 vecCount, Vec3s* dst, Vec3s* src, u8* copyFlag); void AnimationContext_SetMoveActor(PlayState* play, Actor* actor, SkelAnime* skelAnime, f32 arg3); void AnimationContext_LoadFrame(PlayState* play, AnimationEntryData* data); void AnimationContext_CopyAll(PlayState* play, AnimationEntryData* data); @@ -2203,7 +2202,7 @@ void LinkAnimation_CopyJointToMorph(PlayState* play, SkelAnime* skelAnime); void LinkAnimation_CopyMorphToJoint(PlayState* play, SkelAnime* skelAnime); void LinkAnimation_LoadToMorph(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 frame); void LinkAnimation_LoadToJoint(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 frame); -void LinkAnimation_InterpJointMorph(PlayState* play, SkelAnime* skelAnime, f32 frame); +void LinkAnimation_InterpJointMorph(PlayState* play, SkelAnime* skelAnime, f32 weight); void LinkAnimation_BlendToJoint(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation1, f32 frame1, LinkAnimationHeader* animation2, f32 frame2, f32 blendWeight, Vec3s* blendTable); void LinkAnimation_BlendToMorph(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation1, f32 frame1, LinkAnimationHeader* animation2, f32 frame2, f32 blendWeight, Vec3s* blendTable); void LinkAnimation_EndLoop(SkelAnime* skelAnime); @@ -2211,7 +2210,7 @@ s32 Animation_OnFrameImpl(SkelAnime* skelAnime, f32 frame, f32 updateRate); s32 LinkAnimation_OnFrame(SkelAnime* skelAnime, f32 frame); void SkelAnime_Init(PlayState* play, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount); void SkelAnime_InitFlex(PlayState* play, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount); -void SkelAnime_InitSkin(GameState* gameState, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animationSeg); +void SkelAnime_InitSkin(GameState* gameState, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation); void SkelAnime_SetUpdate(SkelAnime* skelAnime); s32 SkelAnime_Update(SkelAnime* skelAnime); s32 SkelAnime_Morph(SkelAnime* skelAnime); @@ -2232,15 +2231,15 @@ void Animation_EndLoop(SkelAnime* skelAnime); void Animation_Reverse(SkelAnime* skelAnime); void SkelAnime_CopyFrameTableTrue(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src, u8* copyFlag); void SkelAnime_CopyFrameTableFalse(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src, u8* copyFlag); -void SkelAnime_UpdateTranslation(SkelAnime* skelAnime, Vec3f* pos, s16 angle); +void SkelAnime_UpdateTranslation(SkelAnime* skelAnime, Vec3f* diff, s16 angle); s32 Animation_OnFrame(SkelAnime* skelAnime, f32 frame); void SkelAnime_Free(SkelAnime* skelAnime, PlayState* play); void SkelAnime_CopyFrameTable(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src); void SkinMatrix_Vec3fMtxFMultXYZW(MtxF* mf, Vec3f* src, Vec3f* xyzDest, f32* wDest); void SkinMatrix_Vec3fMtxFMultXYZ(MtxF* mf, Vec3f* src, Vec3f* dest); void SkinMatrix_MtxFMtxFMult(MtxF* mfB, MtxF* mfA, MtxF* dest); -void SkinMatrix_GetClear(MtxF** puParm1); -void SkinMatrix_GetClear(MtxF** mf); +void SkinMatrix_GetClear(MtxF** mfp); +void SkinMatrix_GetClear(MtxF** mfp); void SkinMatrix_MtxFCopy(MtxF* src, MtxF* dest); s32 SkinMatrix_Invert(MtxF* src, MtxF* dest); void SkinMatrix_SetScale(MtxF* mf, f32 x, f32 y, f32 z); @@ -2309,7 +2308,7 @@ void func_801477B4(PlayState* play); void func_80147818(PlayState* play, UNK_PTR puParm2, UNK_TYPE4 uParm3, UNK_TYPE4 uParm4); // void func_80147F18(PlayState* play, UNK_PTR puParm2, UNK_TYPE4 uParm3, UNK_TYPE4 uParm4); // void func_80148558(PlayState* play, UNK_PTR puParm2, UNK_TYPE4 uParm3, UNK_TYPE4 uParm4); -void func_80148B98(PlayState* play, u8 bParm2); +void func_80148B98(PlayState* play, u8 arg1); // void func_80148CBC(void); // void func_80148D64(void); // void func_80149048(void); @@ -2323,7 +2322,7 @@ void func_80149F74(PlayState* play, u32** ppuParm2); // void func_8014AAD0(void); void func_8014ADBC(PlayState* play, UNK_PTR puParm2); // void func_8014C70C(void); -void Message_LoadChar(PlayState* play, u16 codePointIndex, s32* offset, f32* arg3, s16 arg4); +void Message_LoadChar(PlayState* play, u16 codePointIndex, s32* offset, f32* arg3, s16 decodedBufPos); // void func_8014CCB4(void); // void func_8014CDF0(void); // void func_8014CFDC(void); @@ -2336,7 +2335,7 @@ void func_801514B0(PlayState* play, u16 arg1, u8 arg2); void Message_StartTextbox(PlayState* play, u16 textId, Actor* Actor); void func_80151938(PlayState* play, u16 textId); void func_80151A68(PlayState* play, u16 textId); -void func_80151BB4(PlayState* play, u8 uParm2); +void func_80151BB4(PlayState* play, u8 arg1); // void func_80151C9C(void); void func_80151DA4(PlayState* play, u16 arg2); void func_80152434(PlayState* play, u16 arg2); @@ -2462,42 +2461,42 @@ void func_80167DE4(PlayState* play); void Play_Draw(PlayState* play); void func_80168DAC(PlayState* play); void Play_Main(PlayState* play); -s32 Play_InCsMode(PlayState* play); +s32 Play_InCsMode(PlayState* this); f32 func_80169100(PlayState* play, MtxF* mtx, CollisionPoly** arg2, s32* arg3, Vec3f* feetPosPtr); void func_801691F0(PlayState* play, MtxF* mtx, Vec3f* arg2); void* Play_LoadScene(PlayState* play, RomFile* entry); void func_8016927C(PlayState* play, s16 sParm2); // void func_801692C4(PlayState* play, UNK_TYPE1 uParm2); // void Play_SceneInit(PlayState* play, s32 sceneIndex, UNK_TYPE1 param_3); -void Play_GetScreenPos(PlayState* play, Vec3f* worldPos, Vec3f* screenPos); -s16 Play_CreateSubCamera(PlayState* play); -s16 Play_GetActiveCamId(PlayState* play); -s32 Play_ChangeCameraStatus(PlayState* play, s16 camId, s16 status); -void Play_ClearCamera(PlayState* play, s16 camId); -Camera* Play_GetCamera(PlayState* play, s16 camId); -s32 Play_SetCameraAtEye(PlayState* play, s16 camId, Vec3f* at, Vec3f* eye); -s32 Play_SetCameraAtEyeUp(PlayState* play, s16 camId, Vec3f* at, Vec3f* eye, Vec3f* up); -s32 Play_SetCameraFov(PlayState* play, s16 camId, f32 fov); -s32 Play_SetCameraRoll(PlayState* play, s16 camId, s16 roll); -void Play_CopyCamera(PlayState* play, s16 dstCamId, s16 srcCamId); -s32 func_80169A50(PlayState* play, s16 camId, Player* player, s16 setting); -s32 Play_ChangeCameraSetting(PlayState* play, s16 camId, s16 setting); -void func_80169AFC(PlayState* play, s16 camId, s16 arg2); -u16 Play_GetActorCsCamSetting(PlayState* play, s32 csCamDataIndex); -Vec3s* Play_GetActorCsCamFuncData(PlayState* play, s32 csCamDataIndex); +void Play_GetScreenPos(PlayState* this, Vec3f* worldPos, Vec3f* screenPos); +s16 Play_CreateSubCamera(PlayState* this); +s16 Play_GetActiveCamId(PlayState* this); +s32 Play_ChangeCameraStatus(PlayState* this, s16 camId, s16 status); +void Play_ClearCamera(PlayState* this, s16 camId); +Camera* Play_GetCamera(PlayState* this, s16 camId); +s32 Play_SetCameraAtEye(PlayState* this, s16 camId, Vec3f* at, Vec3f* eye); +s32 Play_SetCameraAtEyeUp(PlayState* this, s16 camId, Vec3f* at, Vec3f* eye, Vec3f* up); +s32 Play_SetCameraFov(PlayState* this, s16 camId, f32 fov); +s32 Play_SetCameraRoll(PlayState* this, s16 camId, s16 roll); +void Play_CopyCamera(PlayState* this, s16 destCamId, s16 srcCamId); +s32 func_80169A50(PlayState* this, s16 camId, Player* player, s16 setting); +s32 Play_ChangeCameraSetting(PlayState* this, s16 camId, s16 setting); +void func_80169AFC(PlayState* this, s16 camId, s16 timer); +u16 Play_GetActorCsCamSetting(PlayState* this, s32 csCamDataIndex); +Vec3s* Play_GetActorCsCamFuncData(PlayState* this, s32 csCamDataIndex); s16 Play_GetOriginalSceneId(s16 sceneId); -void Play_SaveCycleSceneFlags(GameState* gameState); -void Play_SetRespawnData(GameState* gameState, s32 respawnNumber, u16 sceneSetup, s32 roomIndex, s32 playerParams, Vec3f* pos, s16 yaw); -void Play_SetupRespawnPoint(GameState* gameState, s32 respawnNumber, s32 playerParams); -void func_80169EFC(GameState* gameState); -void func_80169F78(GameState* gameState); -void func_80169FDC(GameState* gameState); -s32 func_80169FFC(GameState* gameState); -s32 FrameAdvance_IsEnabled(GameState* gameState); -s32 func_8016A02C(GameState* gameState, Actor* actor, s16* yaw); -s32 Play_IsUnderwater(PlayState* play, Vec3f* pos); +void Play_SaveCycleSceneFlags(GameState* thisx); +void Play_SetRespawnData(GameState* thisx, s32 respawnMode, u16 entrance, s32 roomIndex, s32 playerParams, Vec3f* pos, s16 yaw); +void Play_SetupRespawnPoint(GameState* thisx, s32 respawnMode, s32 playerParams); +void func_80169EFC(GameState* thisx); +void func_80169F78(GameState* thisx); +void func_80169FDC(GameState* thisx); +s32 func_80169FFC(GameState* thisx); +s32 FrameAdvance_IsEnabled(GameState* thisx); +s32 func_8016A02C(GameState* thisx, Actor* actor, s16* yaw); +s32 Play_IsUnderwater(PlayState* this, Vec3f* pos); s32 Play_IsDebugCamEnabled(void); -void Play_AssignPlayerActorCsIdsFromScene(GameState* gameState, s32 cutscene); +void Play_AssignPlayerActorCsIdsFromScene(GameState* thisx, s32 startActorCsId); void func_8016A268(GameState* gameState, s16 arg1, u8 arg2, u8 arg3, u8 arg4, u8 arg5); void Play_Init(GameState* gameState); // void func_8016AC10(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10); @@ -2589,7 +2588,7 @@ void Game_Update(GameState* gameState); void Game_IncrementFrameCount(GameState* gameState); void GameState_InitArena(GameState* gameState, size_t size); void GameState_Realloc(GameState* gameState, size_t size); -void GameState_Init(GameState* gameState, GameStateFunc gameStateInit, GraphicsContext* gfxCtx); +void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* gfxCtx); void GameState_Destroy(GameState* gameState); GameStateFunc GameState_GetInit(GameState* gameState); size_t GameState_GetSize(GameState* gameState); @@ -2806,9 +2805,9 @@ s32 Math3D_YZInSphere(Sphere16* sphere, f32 y, f32 z); // void func_8017FB1C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11); // void func_8017FD44(void); -u16 Math_GetAtan2Tbl(f32 opposite, f32 adjacent); -s16 Math_Atan2S(f32 opposite, f32 adjacent); -f32 Math_Atan2F(f32 opposite, f32 adjacent); +u16 Math_GetAtan2Tbl(f32 y, f32 x); +s16 Math_Atan2S(f32 y, f32 x); +f32 Math_Atan2F(f32 y, f32 x); s16 Math_FAtan2F(f32 adjacent, f32 opposite); f32 Math_Acot2F(f32 adjacent, f32 opposite); @@ -2843,9 +2842,7 @@ void func_801835EC(UNK_PTR arg0, UNK_PTR arg1); // void func_80183B68(void); s32 func_80183DE0(SkeletonInfo* skeletonInfo); // void func_8018410C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -void func_8018450C(PlayState* play, SkeletonInfo* skeleton, Mtx* mtx, - OverrideKeyframeDrawScaled overrideKeyframeDraw, PostKeyframeDrawScaled postKeyframeDraw, - Actor* actor); +void func_8018450C(PlayState* play, SkeletonInfo* skeleton, Mtx* mtx, OverrideKeyframeDrawScaled overrideKeyframeDraw, PostKeyframeDrawScaled postKeyframeDraw, Actor* actor); // void func_801845A4(void); // void func_801845C8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_80184638(void); @@ -2897,7 +2894,7 @@ s32 osFlashWriteBuffer(OSIoMesg* mb, s32 priority, void* dramAddr, OSMesgQueue* s32 osFlashWriteArray(u32 pageNum); s32 osFlashReadArray(OSIoMesg* mb, s32 priority, u32 pageNum, void* dramAddr, u32 pageCount, OSMesgQueue* mq); -Acmd* AudioSynth_Update(Acmd* cmdStart, s32* numAbiCmds, s16* aiStart, s32 aiBufLen); +Acmd* AudioSynth_Update(Acmd* abiCmdStart, s32* numAbiCmds, s16* aiBufStart, s32 numSamplesPerFrame); void AudioHeap_DiscardFont(s32 fontId); void* AudioHeap_WritebackDCache(void* addr, size_t size); @@ -2917,15 +2914,15 @@ void* AudioHeap_SearchPermanentCache(s32 tableType, s32 id); void* AudioHeap_AllocPermanent(s32 tableType, s32 id, size_t size); void* AudioHeap_AllocSampleCache(size_t size, s32 sampleBankId, void* sampleAddr, s8 medium, s32 cache); void AudioHeap_ApplySampleBankCache(s32 sampleBankId); -void AudioHeap_SetReverbData(s32 reverbIndex, u32 dataType, s32 data, s32 flags); +void AudioHeap_SetReverbData(s32 reverbIndex, u32 dataType, s32 data, s32 isFirstInit); void AudioLoad_DecreaseSampleDmaTtls(void); void* AudioLoad_DmaSampleData(uintptr_t devAddr, size_t size, s32 arg2, u8* dmaIndexRef, s32 medium); void AudioLoad_InitSampleDmaBuffers(s32 numNotes); s32 AudioLoad_IsFontLoadComplete(s32 fontId); s32 AudioLoad_IsSeqLoadComplete(s32 seqId); -void AudioLoad_SetFontLoadStatus(s32 fontId, s32 status); -void AudioLoad_SetSeqLoadStatus(s32 seqId, s32 status); +void AudioLoad_SetFontLoadStatus(s32 fontId, s32 loadStatus); +void AudioLoad_SetSeqLoadStatus(s32 seqId, s32 loadStatus); void AudioLoad_SyncLoadSeqParts(s32 seqId, s32 arg1, s32 arg2, OSMesgQueue* arg3); s32 AudioLoad_SyncLoadInstrument(s32 fontId, s32 instId, s32 drumId); void AudioLoad_AsyncLoadSeq(s32 seqId, s32 arg1, s32 retData, OSMesgQueue* retQueue); @@ -2933,7 +2930,7 @@ void AudioLoad_AsyncLoadSampleBank(s32 sampleBankId, s32 arg1, s32 retData, OSMe void AudioLoad_AsyncLoadFont(s32 fontId, s32 arg1, s32 retData, OSMesgQueue* retQueue); u8* AudioLoad_GetFontsForSequence(s32 seqId, u32* outNumFonts); void AudioLoad_DiscardSeqFonts(s32 seqId); -void func_8018FA60(u32 tableType, u32 id, s32 arg2, s32 arg3); +void func_8018FA60(u32 tableType, u32 id, s32 type, s32 data); s32 AudioLoad_SyncInitSeqPlayer(s32 playerIndex, s32 seqId, s32 arg2); s32 AudioLoad_SyncInitSeqPlayerSkipTicks(s32 playerIndex, s32 seqId, s32 skipTicks); void AudioLoad_ProcessLoads(s32 resetStatus); @@ -3035,7 +3032,7 @@ void AudioOcarina_StartWithSongNoteLengths(u32 ocarinaFlags); void AudioOcarina_StartDefault(u32 ocarinaFlags); u8 func_8019B5AC(void); void AudioOcarina_ResetAndReadInput(void); -void AudioOcarina_SetOcarinaDisableTimer(u8 resetUnused, u8 resetDelay); +void AudioOcarina_SetOcarinaDisableTimer(u8 unused, u8 timer); u32 AudioOcarina_SetInstrument(u8 ocarinaInstrumentId); void AudioOcarina_SetPlaybackSong(s8 songIndexPlusOne, u8 playbackState); void AudioOcarina_SetRecordingState(u8 recordingState); @@ -3129,7 +3126,7 @@ void Audio_RestorePrevBgm(void); void Audio_PlayFanfare(u16 seqId); // void func_801A312C(void); void func_801A31EC(u16 seqId, s8 arg1, u8 arg2); -void Audio_PlaySequenceWithSeqPlayerIO(s8 playerIndex, u16 seqId, u8 fadeTimer, s8 ioPort, u8 ioData); +void Audio_PlaySequenceWithSeqPlayerIO(s8 playerIndex, u16 seqId, u8 fadeInDuration, s8 ioPort, u8 ioData); void Audio_SetSequenceMode(u8 seqMode); void Audio_UpdateEnemyBgmVolume(f32 dist); u8 func_801A3950(s32 playerIndex, s32 isChannelIOSet); diff --git a/include/gfxprint.h b/include/gfxprint.h index e643b05048..b652cc1322 100644 --- a/include/gfxprint.h +++ b/include/gfxprint.h @@ -29,21 +29,21 @@ typedef struct GfxPrint { /* 0x14 */ UNK_TYPE1 unk_14[0x1C]; // unused } GfxPrint; // size = 0x30 -void GfxPrint_Setup(GfxPrint* printer); -void GfxPrint_SetColor(GfxPrint* printer, u32 r, u32 g, u32 b, u32 a); -void GfxPrint_SetPosPx(GfxPrint* printer, s32 x, s32 y); -void GfxPrint_SetPos(GfxPrint* printer, s32 x, s32 y); -void GfxPrint_SetBasePosPx(GfxPrint* printer, s32 x, s32 y); -void GfxPrint_PrintCharImpl(GfxPrint* printer, u8 c); -void GfxPrint_PrintChar(GfxPrint* printer, u8 c); -void GfxPrint_PrintStringWithSize(GfxPrint* printer, const void* buffer, size_t charSize, size_t charCount); -void GfxPrint_PrintString(GfxPrint* printer, const char* str); +void GfxPrint_Setup(GfxPrint* this); +void GfxPrint_SetColor(GfxPrint* this, u32 r, u32 g, u32 b, u32 a); +void GfxPrint_SetPosPx(GfxPrint* this, s32 x, s32 y); +void GfxPrint_SetPos(GfxPrint* this, s32 x, s32 y); +void GfxPrint_SetBasePosPx(GfxPrint* this, s32 x, s32 y); +void GfxPrint_PrintCharImpl(GfxPrint* this, u8 c); +void GfxPrint_PrintChar(GfxPrint* this, u8 c); +void GfxPrint_PrintStringWithSize(GfxPrint* this, const void* buffer, size_t charSize, size_t charCount); +void GfxPrint_PrintString(GfxPrint* this, const char* str); void* GfxPrint_Callback(void* arg, const char* str, size_t size); -void GfxPrint_Init(GfxPrint* printer); +void GfxPrint_Init(GfxPrint* this); void GfxPrint_Destroy(GfxPrint* printer); -void GfxPrint_Open(GfxPrint* printer, Gfx* dList); -Gfx* GfxPrint_Close(GfxPrint* printer); -s32 GfxPrint_VPrintf(GfxPrint* printer, const char* fmt, va_list args); -s32 GfxPrint_Printf(GfxPrint* printer, const char* fmt, ...); +void GfxPrint_Open(GfxPrint* this, Gfx* dList); +Gfx* GfxPrint_Close(GfxPrint* this); +s32 GfxPrint_VPrintf(GfxPrint* this, const char* fmt, va_list args); +s32 GfxPrint_Printf(GfxPrint* this, const char* fmt, ...); #endif diff --git a/include/os_malloc.h b/include/os_malloc.h index 6b1cceab5a..6f6bbf900a 100644 --- a/include/os_malloc.h +++ b/include/os_malloc.h @@ -29,7 +29,7 @@ void* __osMalloc(Arena* arena, size_t size); void* __osMallocR(Arena* arena, size_t size); void __osFree(Arena* arena, void* ptr); void* __osRealloc(Arena* arena, void* ptr, size_t newSize); -void __osGetSizes(Arena* arena, size_t* maxFreeBlock, size_t* bytesFree, size_t* bytesAllocated); +void __osGetSizes(Arena* arena, size_t* outMaxFree, size_t* outFree, size_t* outAlloc); s32 __osCheckArena(Arena* arena); #endif diff --git a/include/sys_matrix.h b/include/sys_matrix.h index 536322624c..a471e4dde3 100644 --- a/include/sys_matrix.h +++ b/include/sys_matrix.h @@ -29,7 +29,7 @@ MtxF* Matrix_GetCurrent(void); /* Basic operations */ -void Matrix_Mult(MtxF* matrix, MatrixMode mode); +void Matrix_Mult(MtxF* mf, MatrixMode mode); void Matrix_Translate(f32 x, f32 y, f32 z, MatrixMode mode); void Matrix_Scale(f32 x, f32 y, f32 z, MatrixMode mode); void Matrix_RotateXS(s16 x, MatrixMode mode); diff --git a/include/z64quake.h b/include/z64quake.h index 468f56793d..a1272941d9 100644 --- a/include/z64quake.h +++ b/include/z64quake.h @@ -42,7 +42,7 @@ u32 Quake_SetQuakeValues(s16 quakeIndex, s16 verticalMag, s16 horizontalMag, s16 u32 Quake_SetQuakeValues2(s16 quakeIndex, s16 isShakePerpendicular, Vec3s shakePlaneOffset); s16 Quake_Add(Camera* camera, u32 type); s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData); -u32 Quake_Remove(s16 quakeIndex); +u32 Quake_Remove(s16 index); s32 Quake_NumActiveQuakes(void); void Quake_Init(void); diff --git a/include/z64save.h b/include/z64save.h index c357479722..436e410e65 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -480,9 +480,9 @@ void func_80144A94(SramContext* sramCtx); void Sram_OpenSave(struct FileSelectState* fileSelect, SramContext* sramCtx); void func_8014546C(SramContext* sramCtx); void func_801457CC(struct FileSelectState* fileSelect, SramContext* sramCtx); -void func_80146580(struct FileSelectState* fileSelect, SramContext* sramCtx, s32 fileNum); -void func_80146628(struct FileSelectState* fileSelect, SramContext* sramCtx); -void Sram_InitSave(struct FileSelectState* fileSelect, SramContext* sramCtx); +void func_80146580(struct FileSelectState* fileSelect2, SramContext* sramCtx, s32 fileNum); +void func_80146628(struct FileSelectState* fileSelect2, SramContext* sramCtx); +void Sram_InitSave(struct FileSelectState* fileSelect2, SramContext* sramCtx); void func_80146DF8(SramContext* sramCtx); void Sram_InitSram(struct GameState* gameState, SramContext* sramCtx); void Sram_Alloc(struct GameState* gameState, SramContext* sramCtx); diff --git a/include/z64subs.h b/include/z64subs.h index 9f0b5fea3b..ca90cb232a 100644 --- a/include/z64subs.h +++ b/include/z64subs.h @@ -100,7 +100,7 @@ void SubS_TimePathing_ComputeTargetPosXZ(f32* x, f32* z, f32 progress, s32 order s32 SubS_TimePathing_Update(Path* path, f32* progress, s32* elapsedTime, s32 waypointTime, s32 totalTime, s32* waypoint, f32 knots[], Vec3f* targetPos, s32 timeSpeed); void SubS_TimePathing_ComputeInitialY(struct PlayState* play, Path* path, s32 waypoint, Vec3f* targetPos); -Path* SubS_GetAdditionalPath(struct PlayState* play, u8 pathIndex, s32 max); +Path* SubS_GetAdditionalPath(struct PlayState* play, u8 pathIndex, s32 limit); Actor* SubS_FindNearestActor(Actor* actor, struct PlayState* play, u8 actorCategory, s16 actorId); @@ -122,7 +122,7 @@ void SubS_GenShadowTex(Vec3f bodyPartsPos[], Vec3f* worldPos, u8* tex, f32 tween void SubS_DrawShadowTex(Actor* actor, struct GameState* gameState, u8* tex); s16 SubS_ComputeTrackPointRot(s16* rot, s16 rotMax, s16 target, f32 slowness, f32 stepMin, f32 stepMax); -s32 SubS_TrackPoint(Vec3f* point, Vec3f* focusPos, Vec3s* shapeRot, Vec3s* trackTarget, Vec3s* headRot, Vec3s* torsoRot, TrackOptionsSet* options); +s32 SubS_TrackPoint(Vec3f* target, Vec3f* focusPos, Vec3s* shapeRot, Vec3s* trackTarget, Vec3s* headRot, Vec3s* torsoRot, TrackOptionsSet* options); s32 SubS_AngleDiffLessEqual(s16 angleA, s16 threshold, s16 angleB); @@ -130,7 +130,7 @@ Path* SubS_GetPathByIndex(struct PlayState* play, s16 pathIndex, s16 max); s32 SubS_CopyPointFromPath(Path* path, s32 pointIndex, Vec3f* dst); s16 SubS_GetDistSqAndOrientPoints(Vec3f* vecA, Vec3f* vecB, f32* distSq); s32 SubS_MoveActorToPoint(Actor* actor, Vec3f* point, s16 rotStep); -s16 SubS_GetDistSqAndOrientPath(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq); +s16 SubS_GetDistSqAndOrientPath(Path* path, s32 pointIndex, Vec3f* pos, f32* distSq); s8 SubS_IsObjectLoaded(s8 index, struct PlayState* play); s8 SubS_GetObjectIndex(s16 id, struct PlayState* play); diff --git a/include/z_en_hy_code.h b/include/z_en_hy_code.h index d272522c91..0620d35a04 100644 --- a/include/z_en_hy_code.h +++ b/include/z_en_hy_code.h @@ -79,7 +79,7 @@ s32 EnHy_ChangeAnim(SkelAnime* skelAnime, s16 animIndex); EnDoor* EnHy_FindNearestDoor(Actor* actor, PlayState* play); void EnHy_ChangeObjectAndAnim(EnHy* enHy, PlayState* play, s16 animIndex); s32 EnHy_UpdateSkelAnime(EnHy* enHy, PlayState* play); -void EnHy_Blink(EnHy* enHy, s32 arg1); +void EnHy_Blink(EnHy* enHy, s32 eyeTexMaxIndex); s32 EnHy_Init(EnHy* enHy, PlayState* play, FlexSkeletonHeader* skeletonHeaderSeg, s16 animIndex); void func_800F0BB4(EnHy* enHy, PlayState* play, EnDoor* door, s16 arg3, s16 arg4); s32 func_800F0CE4(EnHy* enHy, PlayState* play, ActorFunc draw, s16 arg3, s16 arg4, f32 arg5); diff --git a/include/z_title_setup.h b/include/z_title_setup.h index 685b87c799..41e3f52f84 100644 --- a/include/z_title_setup.h +++ b/include/z_title_setup.h @@ -4,7 +4,7 @@ #include "global.h" void Setup_Destroy(GameState* gameState); -void Setup_Init(GameState* gameState); +void Setup_Init(GameState* thisx); typedef struct { /* 0x00 */ GameState state; diff --git a/src/boot_O2_g3/irqmgr.c b/src/boot_O2_g3/irqmgr.c index f605dc3270..b100f209d5 100644 --- a/src/boot_O2_g3/irqmgr.c +++ b/src/boot_O2_g3/irqmgr.c @@ -5,22 +5,22 @@ volatile OSTime sIrqMgrResetTime = 0; volatile OSTime sIrqMgrRetraceTime = 0; s32 sIrqMgrRetraceCount = 0; -void IrqMgr_AddClient(IrqMgr* irqmgr, IrqMgrClient* param_2, OSMesgQueue* param_3) { +void IrqMgr_AddClient(IrqMgr* irqmgr, IrqMgrClient* client, OSMesgQueue* msgQueue) { u32 saveMask; saveMask = osSetIntMask(1); - param_2->queue = param_3; - param_2->next = irqmgr->callbacks; - irqmgr->callbacks = param_2; + client->queue = msgQueue; + client->next = irqmgr->callbacks; + irqmgr->callbacks = client; osSetIntMask(saveMask); if (irqmgr->prenmiStage > 0) { - osSendMesg(param_2->queue, &irqmgr->prenmiMsg.type, OS_MESG_NOBLOCK); + osSendMesg(client->queue, &irqmgr->prenmiMsg.type, OS_MESG_NOBLOCK); } if (irqmgr->prenmiStage > 1) { - osSendMesg(param_2->queue, &irqmgr->nmiMsg.type, OS_MESG_NOBLOCK); + osSendMesg(client->queue, &irqmgr->nmiMsg.type, OS_MESG_NOBLOCK); } } diff --git a/src/code/audio/audio_load.c b/src/code/audio/audio_load.c index ccdc7488d5..c9b5ad30bf 100644 --- a/src/code/audio/audio_load.c +++ b/src/code/audio/audio_load.c @@ -37,7 +37,7 @@ void* AudioLoad_SyncLoad(s32 tableType, u32 id, s32* didAllocate); u32 AudioLoad_GetRealTableIndex(s32 tableType, u32 id); void* AudioLoad_SearchCaches(s32 tableType, s32 id); AudioTable* AudioLoad_GetLoadTable(s32 tableType); -void AudioLoad_SyncDma(uintptr_t devAddr, u8* addr, size_t size, s32 medium); +void AudioLoad_SyncDma(uintptr_t devAddr, u8* ramAddr, size_t size, s32 medium); void AudioLoad_SyncDmaUnkMedium(uintptr_t devAddr, u8* addr, size_t size, s32 unkMediumParam); s32 AudioLoad_Dma(OSIoMesg* mesg, u32 priority, s32 direction, uintptr_t devAddr, void* ramAddr, size_t size, OSMesgQueue* reqQueue, s32 medium, const char* dmaFuncType); diff --git a/src/code/audio/audio_synthesis.c b/src/code/audio/audio_synthesis.c index 17b3ff4bea..d3b25f4461 100644 --- a/src/code/audio/audio_synthesis.c +++ b/src/code/audio/audio_synthesis.c @@ -21,14 +21,14 @@ typedef enum { /* 2 */ HAAS_EFFECT_DELAY_RIGHT // Delay right channel so that left channel is heard first } HaasEffectDelaySide; -Acmd* AudioSynth_SaveResampledReverbSamplesImpl(Acmd* cmd, u16 dmem, u16 arg2, uintptr_t arg3); +Acmd* AudioSynth_SaveResampledReverbSamplesImpl(Acmd* cmd, u16 dmem, u16 size, uintptr_t startAddr); Acmd* AudioSynth_LoadReverbSamplesImpl(Acmd* cmd, u16 dmem, u16 startPos, s32 size, SynthesisReverb* reverb); Acmd* AudioSynth_SaveReverbSamplesImpl(Acmd* cmd, u16 dmem, u16 startPos, s32 size, SynthesisReverb* reverb); Acmd* AudioSynth_ProcessSamples(s16* aiBuf, s32 numSamplesPerUpdate, Acmd* cmd, s32 updateIndex); Acmd* AudioSynth_ProcessSample(s32 noteIndex, NoteSampleState* sampleState, NoteSynthesisState* synthState, s16* aiBuf, s32 numSamplesPerUpdate, Acmd* cmd, s32 updateIndex); -Acmd* AudioSynth_ApplySurroundEffect(Acmd* cmd, NoteSampleState* sampleState, NoteSynthesisState* synthState, s32 size, - s32 dmem, s32 flags); +Acmd* AudioSynth_ApplySurroundEffect(Acmd* cmd, NoteSampleState* sampleState, NoteSynthesisState* synthState, + s32 numSamplesPerUpdate, s32 haasDmem, s32 flags); Acmd* AudioSynth_FinalResample(Acmd* cmd, NoteSynthesisState* synthState, s32 size, u16 pitch, u16 inpDmem, s32 resampleFlags); Acmd* AudioSynth_ProcessEnvelope(Acmd* cmd, NoteSampleState* sampleState, NoteSynthesisState* synthState, diff --git a/src/code/audio/code_8019AF00.c b/src/code/audio/code_8019AF00.c index 98be413977..6d1468d82f 100644 --- a/src/code/audio/code_8019AF00.c +++ b/src/code/audio/code_8019AF00.c @@ -70,7 +70,7 @@ s32 Audio_SetGanonsTowerBgmVolume(u8 targetVolume); void Audio_StartMorningSceneSequence(u16 seqId); void Audio_StartSceneSequence(u16 seqId); -void Audio_PlaySequenceWithSeqPlayerIO(s8 playerIndex, u16 seqId, u8 fadeTimer, s8 arg3, u8 arg4); +void Audio_PlaySequenceWithSeqPlayerIO(s8 playerIndex, u16 seqId, u8 fadeInDuration, s8 ioPort, u8 ioData); void func_801A4428(u8 reverbIndex); void func_801A3038(void); void Audio_PlayAmbience(u8 ambienceId); diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index 437728f0ea..d6ab737c7b 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -843,10 +843,10 @@ void EnItem00_DrawSprite(EnItem00* this, PlayState* play) { CLOSE_DISPS(play->state.gfxCtx); } -void EnItem00_DrawHeartContainer(EnItem00* actor, PlayState* play) { +void EnItem00_DrawHeartContainer(EnItem00* this, PlayState* play) { s32 pad[2]; - if (Object_GetIndex(&play->objectCtx, OBJECT_GI_HEARTS) == actor->actor.objBankIndex) { + if (Object_GetIndex(&play->objectCtx, OBJECT_GI_HEARTS) == this->actor.objBankIndex) { OPEN_DISPS(play->state.gfxCtx); func_8012C2DC(play->state.gfxCtx); diff --git a/src/code/z_scene_proc.c b/src/code/z_scene_proc.c index 8ddde8a825..4de83bcaad 100644 --- a/src/code/z_scene_proc.c +++ b/src/code/z_scene_proc.c @@ -459,8 +459,8 @@ void AnimatedMat_DrawStep(PlayState* play, AnimatedMaterial* matAnim, u32 step) /** * Draws an animated material with a step to only the OPA buffer. */ -void AnimatedMat_DrawStepOpa(PlayState* play, AnimatedMaterial* textures, u32 step) { - AnimatedMat_DrawMain(play, textures, 1, step, 1); +void AnimatedMat_DrawStepOpa(PlayState* play, AnimatedMaterial* matAnim, u32 step) { + AnimatedMat_DrawMain(play, matAnim, 1, step, 1); } /** diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index 8321a309ee..088f1469f1 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -8,9 +8,9 @@ s32 SkelAnime_LoopFull(SkelAnime* skelAnime); s32 SkelAnime_LoopPartial(SkelAnime* skelAnime); s32 SkelAnime_Once(SkelAnime* skelAnime); void Animation_PlayLoop(SkelAnime* skelAnime, AnimationHeader* animation); -void SkelAnime_UpdateTranslation(SkelAnime* skelAnime, Vec3f* pos, s16 angle); +void SkelAnime_UpdateTranslation(SkelAnime* skelAnime, Vec3f* diff, s16 angle); void LinkAnimation_Change(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 playSpeed, - f32 frame, f32 frameCount, u8 animationMode, f32 morphFrames); + f32 startFrame, f32 endFrame, u8 mode, f32 morphFrames); void SkelAnime_CopyFrameTable(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src); static AnimationEntryCallback sAnimationLoadDone[] = { diff --git a/src/libultra/flash/osFlash.c b/src/libultra/flash/osFlash.c index edba06fc22..cd4420c4af 100644 --- a/src/libultra/flash/osFlash.c +++ b/src/libultra/flash/osFlash.c @@ -32,9 +32,9 @@ OSPiHandle* osFlashReInit(u8 latency, u8 pulse, u8 pageSize, u8 relDuration, u32 return &__osFlashHandler; } -void osFlashChange(u32 flash_num) { - __osFlashHandler.baseAddress = RDRAM_UNCACHED | (FRAM_STATUS_REGISTER + (flash_num << 17)); - __osFlashHandler.type = 8 + flash_num; +void osFlashChange(u32 flashNum) { + __osFlashHandler.baseAddress = RDRAM_UNCACHED | (FRAM_STATUS_REGISTER + (flashNum << 17)); + __osFlashHandler.type = 8 + flashNum; return; } diff --git a/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c b/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c index 8e0c025e28..44e38f0da5 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c @@ -16,7 +16,7 @@ void BgDblueMovebg_Init(Actor* thisx, PlayState* play); void BgDblueMovebg_Destroy(Actor* thisx, PlayState* play); void BgDblueMovebg_Update(Actor* thisx, PlayState* play); -void BgDblueMovebg_Draw(Actor* thisx, PlayState* play); +void BgDblueMovebg_Draw(Actor* thisx, PlayState* play2); void func_80A2A1E0(BgDblueMovebg* this, PlayState* play); void func_80A2A32C(BgDblueMovebg* this, PlayState* play); 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 4f1434dc22..6c5e85e73c 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 @@ -12,7 +12,7 @@ #define THIS ((BgIkanaDharma*)thisx) -void BgIkanaDharma_Init(Actor* thisx, PlayState* play); +void BgIkanaDharma_Init(Actor* thisx, PlayState* play2); void BgIkanaDharma_Destroy(Actor* thisx, PlayState* play); void BgIkanaDharma_Update(Actor* thisx, PlayState* play); void BgIkanaDharma_Draw(Actor* thisx, PlayState* play); diff --git a/src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.c b/src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.c index cfa67eb1de..11734b2843 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.c @@ -16,7 +16,7 @@ #define THIS ((BgIkanaMirror*)thisx) -void BgIkanaMirror_Init(Actor* thisx, PlayState* play); +void BgIkanaMirror_Init(Actor* thisx, PlayState* play2); void BgIkanaMirror_Destroy(Actor* thisx, PlayState* play); void BgIkanaMirror_Update(Actor* thisx, PlayState* play); void BgIkanaMirror_Draw(Actor* thisx, PlayState* play); diff --git a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c index 9091948ae3..95ca8936e7 100644 --- a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c +++ b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c @@ -11,7 +11,7 @@ #define THIS ((BgIngate*)thisx) -void BgIngate_Init(Actor* thisx, PlayState* play); +void BgIngate_Init(Actor* thisx, PlayState* play2); void BgIngate_Destroy(Actor* thisx, PlayState* play); void BgIngate_Update(Actor* thisx, PlayState* play); void BgIngate_Draw(Actor* thisx, PlayState* play); diff --git a/src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.c b/src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.c index 2b4c24381c..85272fa51f 100644 --- a/src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.c +++ b/src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.c @@ -25,7 +25,7 @@ typedef struct { void BgLastBwall_Init(Actor* thisx, PlayState* play); void BgLastBwall_Destroy(Actor* thisx, PlayState* play); void BgLastBwall_Update(Actor* thisx, PlayState* play); -void BgLastBwall_Draw(Actor* thisx, PlayState* play); +void BgLastBwall_Draw(Actor* thisx, PlayState* play2); void BgLastBwall_InitCollider(ColliderTrisInit* init, Vec3f* pos, Vec3s* rot, ColliderTris* collider, BgLastBwallInitColliderStruct* arg4); diff --git a/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c b/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c index 4c0c109ea9..8554e2b5a3 100644 --- a/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c +++ b/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c @@ -15,7 +15,7 @@ void BgNumaHana_Init(Actor* thisx, PlayState* play); void BgNumaHana_Destroy(Actor* thisx, PlayState* play); void BgNumaHana_Update(Actor* thisx, PlayState* play); -void BgNumaHana_Draw(Actor* thisx, PlayState* play); +void BgNumaHana_Draw(Actor* thisx, PlayState* play2); void BgNumaHana_SetupDoNothing(BgNumaHana* this); void BgNumaHana_DoNothing(BgNumaHana* this, PlayState* play); 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 22cf4968f1..6504ec00e2 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 @@ -15,7 +15,7 @@ void BgOpenShutter_Init(Actor* thisx, PlayState* play); void BgOpenShutter_Destroy(Actor* thisx, PlayState* play); -void BgOpenShutter_Update(Actor* thisx, PlayState* play); +void BgOpenShutter_Update(Actor* thisx, PlayState* play2); void BgOpenShutter_Draw(Actor* thisx, PlayState* play); void func_80ACAD88(BgOpenShutter* this, PlayState* play); 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 b3ab79b201..0d0e55e62a 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -18,7 +18,7 @@ void Boss02_Init(Actor* thisx, PlayState* play); void Boss02_Destroy(Actor* thisx, PlayState* play); void Boss02_Twinmold_Update(Actor* thisx, PlayState* play); -void Boss02_Twinmold_Draw(Actor* thisx, PlayState* play); +void Boss02_Twinmold_Draw(Actor* thisx, PlayState* play2); void func_809DAA74(Boss02* this, PlayState* play); void func_809DAA98(Boss02* this, PlayState* play); diff --git a/src/overlays/actors/ovl_Boss_03/z_boss_03.c b/src/overlays/actors/ovl_Boss_03/z_boss_03.c index 1c14d63bb1..870bc53a1d 100644 --- a/src/overlays/actors/ovl_Boss_03/z_boss_03.c +++ b/src/overlays/actors/ovl_Boss_03/z_boss_03.c @@ -78,9 +78,9 @@ #define PLATFORM_HEIGHT 440.0f #define WATER_HEIGHT 430.0f -void Boss03_Init(Actor* thisx, PlayState* play); +void Boss03_Init(Actor* thisx, PlayState* play2); void Boss03_Destroy(Actor* thisx, PlayState* play); -void Boss03_Update(Actor* thisx, PlayState* play); +void Boss03_Update(Actor* thisx, PlayState* play2); void Boss03_Draw(Actor* thisx, PlayState* play); void func_809E344C(Boss03* this, PlayState* play); diff --git a/src/overlays/actors/ovl_Boss_04/z_boss_04.c b/src/overlays/actors/ovl_Boss_04/z_boss_04.c index 8eb73d84d2..9a7371c97d 100644 --- a/src/overlays/actors/ovl_Boss_04/z_boss_04.c +++ b/src/overlays/actors/ovl_Boss_04/z_boss_04.c @@ -11,9 +11,9 @@ #define THIS ((Boss04*)thisx) -void Boss04_Init(Actor* thisx, PlayState* play); +void Boss04_Init(Actor* thisx, PlayState* play2); void Boss04_Destroy(Actor* thisx, PlayState* play); -void Boss04_Update(Actor* thisx, PlayState* play); +void Boss04_Update(Actor* thisx, PlayState* play2); void Boss04_Draw(Actor* thisx, PlayState* play); void func_809EC544(Boss04* this); diff --git a/src/overlays/actors/ovl_Boss_06/z_boss_06.c b/src/overlays/actors/ovl_Boss_06/z_boss_06.c index 3aadce42cb..1b8b6fef65 100644 --- a/src/overlays/actors/ovl_Boss_06/z_boss_06.c +++ b/src/overlays/actors/ovl_Boss_06/z_boss_06.c @@ -18,7 +18,7 @@ void Boss06_Init(Actor* thisx, PlayState* play); void Boss06_Destroy(Actor* thisx, PlayState* play); void Boss06_Update(Actor* thisx, PlayState* play); -void Boss06_Draw(Actor* thisx, PlayState* play); +void Boss06_Draw(Actor* thisx, PlayState* play2); void func_809F24A8(Boss06* this); void func_809F24C8(Boss06* this, PlayState* play); diff --git a/src/overlays/actors/ovl_Dm_An/z_dm_an.c b/src/overlays/actors/ovl_Dm_An/z_dm_an.c index 5e03eb74c1..592800e9d9 100644 --- a/src/overlays/actors/ovl_Dm_An/z_dm_an.c +++ b/src/overlays/actors/ovl_Dm_An/z_dm_an.c @@ -19,7 +19,7 @@ void DmAn_Update(Actor* thisx, PlayState* play); void func_80C1C958(DmAn* this, PlayState* play); void func_80C1CAB0(DmAn* this, PlayState* play); void func_80C1CC80(DmAn* this, PlayState* play); -void func_80C1D0B0(Actor* this, PlayState* play); +void func_80C1D0B0(Actor* thisx, PlayState* play); const ActorInit Dm_An_InitVars = { ACTOR_DM_AN, 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 82e5157f61..a40bd1bc38 100644 --- a/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c +++ b/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c @@ -15,7 +15,7 @@ void DmChar00_Init(Actor* thisx, PlayState* play); void DmChar00_Destroy(Actor* thisx, PlayState* play); void DmChar00_Update(Actor* thisx, PlayState* play); -void DmChar00_Draw(Actor* thisx, PlayState* play); +void DmChar00_Draw(Actor* thisx, PlayState* play2); void func_80AA67F8(DmChar00* this, PlayState* play); void func_80AA695C(DmChar00* this, PlayState* play); 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 2f715afed4..6d3b18c2da 100644 --- a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c +++ b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c @@ -14,7 +14,7 @@ void DmChar01_Init(Actor* thisx, PlayState* play); void DmChar01_Destroy(Actor* thisx, PlayState* play); -void DmChar01_Update(Actor* thisx, PlayState* play); +void DmChar01_Update(Actor* thisx, PlayState* play2); void DmChar01_Draw(Actor* thisx, PlayState* play); void func_80AA8698(DmChar01* this, PlayState* play); diff --git a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c index b2ffe1dcb3..d7e9424e5e 100644 --- a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c +++ b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c @@ -24,7 +24,7 @@ #define THIS ((DoorShutter*)thisx) -void DoorShutter_Init(Actor* thisx, PlayState* play); +void DoorShutter_Init(Actor* thisx, PlayState* play2); void DoorShutter_Destroy(Actor* thisx, PlayState* play); void DoorShutter_Update(Actor* thisx, PlayState* play); 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 c517ad007a..e23ed12043 100644 --- a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c +++ b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c @@ -21,8 +21,8 @@ void func_80918D64(EffDust* this, PlayState* play); void func_80918FE4(EffDust* this, PlayState* play); void func_80919230(EffDust* this, PlayState* play); -void func_80919768(Actor* thisx, PlayState* play); -void func_809199FC(Actor* thisx, PlayState* play); +void func_80919768(Actor* thisx, PlayState* play2); +void func_809199FC(Actor* thisx, PlayState* play2); const ActorInit Eff_Dust_InitVars = { ACTOR_EFF_DUST, 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 eda01c2545..858d125c08 100644 --- a/src/overlays/actors/ovl_En_Am/z_en_am.c +++ b/src/overlays/actors/ovl_En_Am/z_en_am.c @@ -35,7 +35,7 @@ void func_808B07A8(EnAm* this, PlayState* play); void func_808B0820(EnAm* this); void func_808B0894(EnAm* this, PlayState* play); void func_808B0B4C(EnAm* this, PlayState* play); -void EnAm_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* actor); +void EnAm_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx); const ActorInit En_Am_InitVars = { ACTOR_EN_AM, 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 3f35a5e353..08333482e3 100644 --- a/src/overlays/actors/ovl_En_Az/z_en_az.c +++ b/src/overlays/actors/ovl_En_Az/z_en_az.c @@ -18,16 +18,16 @@ typedef struct { /* 0x4 */ f32 unk_4; } struct_80A98F94; // size = 0x8 -void EnAz_Init(Actor* thisx, PlayState* play); -void EnAz_Destroy(Actor* thisx, PlayState* play); -void EnAz_Update(Actor* thisx, PlayState* play); -void EnAz_Draw(Actor* thisx, PlayState* play); +void EnAz_Init(Actor* thisx, PlayState* play2); +void EnAz_Destroy(Actor* thisx, PlayState* play2); +void EnAz_Update(Actor* thisx, PlayState* play2); +void EnAz_Draw(Actor* thisx, PlayState* play2); void func_80A982E0(PlayState* play, ActorPathing* actorPathing); void func_80A98414(EnAz* this, PlayState* play); s32 func_80A98DA4(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx); void func_80A98E48(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx); -void func_80A98EFC(EnAz* this, PlayState* play, u16 textId, s32 arg3, s32 arg4); +void func_80A98EFC(EnAz* this, PlayState* play, u16 textId, s32 animIndex, s32 brotherAnimIndex); void func_80A98F94(struct_80A98F94* yData, f32 frame, f32* yInterp); void func_80A95C5C(EnAz* this, PlayState* play); 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 b1e4db445a..875a5a0799 100644 --- a/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c +++ b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c @@ -14,7 +14,7 @@ void EnBbfall_Init(Actor* thisx, PlayState* play); void EnBbfall_Destroy(Actor* thisx, PlayState* play); void EnBbfall_Update(Actor* thisx, PlayState* play); -void EnBbfall_Draw(Actor* thisx, PlayState* play); +void EnBbfall_Draw(Actor* thisx, PlayState* play2); void EnBbfall_SetupWaitForPlayer(EnBbfall* this); void EnBbfall_WaitForPlayer(EnBbfall* this, PlayState* play); 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 62e1df422a..57dae03687 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c @@ -12,8 +12,8 @@ #define THIS ((EnBigpo*)thisx) -void EnBigpo_Init(Actor* thisx, PlayState* play); -void EnBigpo_Destroy(Actor* thisx, PlayState* play); +void EnBigpo_Init(Actor* thisx, PlayState* play2); +void EnBigpo_Destroy(Actor* thisx, PlayState* play2); void EnBigpo_Update(Actor* thisx, PlayState* play); void EnBigpo_UpdateFire(Actor* thisx, PlayState* play); 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 e569970519..f65172093e 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c @@ -15,7 +15,7 @@ #define THIS ((EnBigslime*)thisx) -void EnBigslime_Init(Actor* thisx, PlayState* play); +void EnBigslime_Init(Actor* thisx, PlayState* play2); void EnBigslime_Destroy(Actor* thisx, PlayState* play); void EnBigslime_UpdateGekko(Actor* thisx, PlayState* play); void EnBigslime_DrawGekko(Actor* thisx, PlayState* play); 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 4a7ac1bafa..4eb0ea4567 100644 --- a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c +++ b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c @@ -12,7 +12,7 @@ #define THIS ((EnBombf*)thisx) -void EnBombf_Init(Actor* thisx, PlayState* play); +void EnBombf_Init(Actor* thisx, PlayState* play2); void EnBombf_Destroy(Actor* thisx, PlayState* play); void EnBombf_Update(Actor* thisx, PlayState* play); void EnBombf_Draw(Actor* thisx, PlayState* play); 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 25f5de3e1d..300d839582 100644 --- a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c +++ b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c @@ -14,7 +14,7 @@ void EnBomjimb_Init(Actor* thisx, PlayState* play); void EnBomjimb_Destroy(Actor* thisx, PlayState* play); -void EnBomjimb_Update(Actor* thisx, PlayState* play); +void EnBomjimb_Update(Actor* thisx, PlayState* play2); void EnBomjimb_Draw(Actor* thisx, PlayState* play); void func_80C01494(EnBomjimb* this); diff --git a/src/overlays/actors/ovl_En_Cha/z_en_cha.c b/src/overlays/actors/ovl_En_Cha/z_en_cha.c index b53f5f6208..0fb85a7562 100644 --- a/src/overlays/actors/ovl_En_Cha/z_en_cha.c +++ b/src/overlays/actors/ovl_En_Cha/z_en_cha.c @@ -13,7 +13,7 @@ void EnCha_Init(Actor* thisx, PlayState* play); void EnCha_Destroy(Actor* thisx, PlayState* play); -void EnCha_Update(Actor* thisx, PlayState* play); +void EnCha_Update(Actor* thisx, PlayState* play2); void EnCha_Draw(Actor* thisx, PlayState* play); void EnCha_Idle(EnCha* this, PlayState* play); 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 902f01931b..df60936905 100644 --- a/src/overlays/actors/ovl_En_Cow/z_en_cow.c +++ b/src/overlays/actors/ovl_En_Cow/z_en_cow.c @@ -12,7 +12,7 @@ void EnCow_Init(Actor* thisx, PlayState* play); void EnCow_Destroy(Actor* thisx, PlayState* play); -void EnCow_Update(Actor* thisx, PlayState* play); +void EnCow_Update(Actor* thisx, PlayState* play2); void EnCow_Draw(Actor* thisx, PlayState* play); void EnCow_TalkEnd(EnCow* this, PlayState* play); @@ -24,8 +24,8 @@ void EnCow_Talk(EnCow* this, PlayState* play); void EnCow_Idle(EnCow* this, PlayState* play); void EnCow_DoTail(EnCow* this, PlayState* play); -void EnCow_UpdateTail(Actor* this, PlayState* play); -void EnCow_DrawTail(Actor* this, PlayState* play); +void EnCow_UpdateTail(Actor* thisx, PlayState* play); +void EnCow_DrawTail(Actor* thisx, PlayState* play); const ActorInit En_Cow_InitVars = { ACTOR_EN_COW, 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 bf2f5e7ce1..506e5eb475 100644 --- a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c +++ b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c @@ -13,7 +13,7 @@ void EnDinofos_Init(Actor* thisx, PlayState* play); void EnDinofos_Destroy(Actor* thisx, PlayState* play); -void EnDinofos_Update(Actor* thisx, PlayState* play); +void EnDinofos_Update(Actor* thisx, PlayState* play2); void EnDinofos_Draw(Actor* thisx, PlayState* play); void func_8089B834(EnDinofos* this, PlayState* play); 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 d663bcf740..b9bc34d99b 100644 --- a/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c +++ b/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c @@ -19,7 +19,7 @@ void EnDnb_Draw(Actor* thisx, PlayState* play); s32 func_80A507C0(EnDnbUnkStruct* arg0, Vec3f arg1, Vec3f arg2, u8 arg3, f32 arg4, f32 arg5); s32 func_80A5086C(EnDnbUnkStruct* arg0); -s32 func_80A50950(EnDnbUnkStruct* arg0, PlayState* play); +s32 func_80A50950(EnDnbUnkStruct* arg0, PlayState* play2); const ActorInit En_Dnb_InitVars = { ACTOR_EN_DNB, 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 65e5417f33..cd3710a3b7 100644 --- a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c +++ b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c @@ -15,7 +15,7 @@ void EnDodongo_Init(Actor* thisx, PlayState* play); void EnDodongo_Destroy(Actor* thisx, PlayState* play); -void EnDodongo_Update(Actor* thisx, PlayState* play); +void EnDodongo_Update(Actor* thisx, PlayState* play2); void EnDodongo_Draw(Actor* thisx, PlayState* play); void func_808773C4(EnDodongo* this); diff --git a/src/overlays/actors/ovl_En_Door/z_en_door.c b/src/overlays/actors/ovl_En_Door/z_en_door.c index 892eab09c7..5d2822d787 100644 --- a/src/overlays/actors/ovl_En_Door/z_en_door.c +++ b/src/overlays/actors/ovl_En_Door/z_en_door.c @@ -24,7 +24,7 @@ #define THIS ((EnDoor*)thisx) -void EnDoor_Init(Actor* thisx, PlayState* play); +void EnDoor_Init(Actor* thisx, PlayState* play2); void EnDoor_Destroy(Actor* thisx, PlayState* play); void EnDoor_Update(Actor* thisx, PlayState* play); void EnDoor_Draw(Actor* thisx, PlayState* play); diff --git a/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.c b/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.c index 98e9d2b8fa..a17ce6193d 100644 --- a/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.c +++ b/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.c @@ -11,7 +11,7 @@ #define THIS ((EnDoorEtc*)thisx) -void EnDoorEtc_Init(Actor* thisx, PlayState* play); +void EnDoorEtc_Init(Actor* thisx, PlayState* play2); void EnDoorEtc_Destroy(Actor* thisx, PlayState* play); void EnDoorEtc_Update(Actor* thisx, PlayState* play); diff --git a/src/overlays/actors/ovl_En_Elf/z_en_elf.c b/src/overlays/actors/ovl_En_Elf/z_en_elf.c index c9b3939804..aa4768a764 100644 --- a/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ b/src/overlays/actors/ovl_En_Elf/z_en_elf.c @@ -11,7 +11,7 @@ #define THIS ((EnElf*)thisx) -void EnElf_Init(Actor* thisx, PlayState* play); +void EnElf_Init(Actor* thisx, PlayState* play2); void EnElf_Destroy(Actor* thisx, PlayState* play); void EnElf_Update(Actor* thisx, PlayState* play); void EnElf_Draw(Actor* thisx, PlayState* play); @@ -29,9 +29,9 @@ void func_8088E484(EnElf* this, PlayState* play); void func_8088E850(EnElf* this, PlayState* play); void func_8088EFA4(EnElf* this, PlayState* play); void func_8088F214(EnElf* this, PlayState* play); -void func_8088F5F4(EnElf* this, PlayState* play, s32 arg2); +void func_8088F5F4(EnElf* this, PlayState* play, s32 sparkleLife); void func_8089010C(Actor* thisx, PlayState* play); -void func_808908D0(Vec3f* arg0, PlayState* play, u32 arg2); +void func_808908D0(Vec3f* vec, PlayState* play, u32 action); const ActorInit En_Elf_InitVars = { ACTOR_EN_ELF, diff --git a/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c b/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c index e50fc13cd7..42a4a06d88 100644 --- a/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c +++ b/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c @@ -15,7 +15,7 @@ void EnElfbub_Init(Actor* thisx, PlayState* play); void EnElfbub_Destroy(Actor* thisx, PlayState* play); void EnElfbub_Update(Actor* thisx, PlayState* play); -void EnElfbub_Draw(Actor* thisx, PlayState* play); +void EnElfbub_Draw(Actor* thisx, PlayState* play2); void EnElfbub_Pop(EnElfbub* this, PlayState* play); void EnElfbub_Idle(EnElfbub* this, PlayState* play); diff --git a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c index 3ac02d9c94..ba43ec2a4b 100644 --- a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c +++ b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c @@ -14,7 +14,7 @@ void EnFirefly_Init(Actor* thisx, PlayState* play); void EnFirefly_Destroy(Actor* thisx, PlayState* play); -void EnFirefly_Update(Actor* thisx, PlayState* play); +void EnFirefly_Update(Actor* thisx, PlayState* play2); void EnFirefly_Draw(Actor* thisx, PlayState* play); void EnFirefly_FlyIdle(EnFirefly* this, PlayState* play); diff --git a/src/overlays/actors/ovl_En_Fish/z_en_fish.c b/src/overlays/actors/ovl_En_Fish/z_en_fish.c index d5dc5469ae..0479ba261c 100644 --- a/src/overlays/actors/ovl_En_Fish/z_en_fish.c +++ b/src/overlays/actors/ovl_En_Fish/z_en_fish.c @@ -12,7 +12,7 @@ #define THIS ((EnFish*)thisx) void EnFish_Init(Actor* thisx, PlayState* play); -void EnFish_Destroy(Actor* thisx, PlayState* play); +void EnFish_Destroy(Actor* thisx, PlayState* play2); void EnFish_Update(Actor* thisx, PlayState* play); void EnFish_Draw(Actor* thisx, PlayState* play); 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 6b8ae91aa8..a0575eb9ad 100644 --- a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c +++ b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c @@ -16,7 +16,7 @@ void EnFish2_Init(Actor* thisx, PlayState* play); void EnFish2_Destroy(Actor* thisx, PlayState* play); -void EnFish2_Update(Actor* thisx, PlayState* play); +void EnFish2_Update(Actor* thisx, PlayState* play2); void EnFish2_Draw(Actor* thisx, PlayState* play); void func_80B28B5C(EnFish2* this); diff --git a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c index baa65bfa3e..d940a09599 100644 --- a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c +++ b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c @@ -16,12 +16,12 @@ #define WATER_SURFACE_Y(play) play->colCtx.colHeader->waterBoxes->minPos.y -void EnFishing_Init(Actor* thisx, PlayState* play); -void EnFishing_Destroy(Actor* thisx, PlayState* play); -void EnFishing_UpdateFish(Actor* thisx, PlayState* play); +void EnFishing_Init(Actor* thisx, PlayState* play2); +void EnFishing_Destroy(Actor* thisx, PlayState* play2); +void EnFishing_UpdateFish(Actor* thisx, PlayState* play2); void EnFishing_DrawFish(Actor* thisx, PlayState* play); -void EnFishing_UpdateOwner(Actor* thisx, PlayState* play); +void EnFishing_UpdateOwner(Actor* thisx, PlayState* play2); void EnFishing_DrawOwner(Actor* thisx, PlayState* play); typedef struct { diff --git a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c index 411d837121..92330d25a3 100644 --- a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c +++ b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c @@ -10,7 +10,7 @@ #define THIS ((EnFloormas*)thisx) -void EnFloormas_Init(Actor* thisx, PlayState* play); +void EnFloormas_Init(Actor* thisx, PlayState* play2); void EnFloormas_Destroy(Actor* thisx, PlayState* play); void EnFloormas_Update(Actor* thisx, PlayState* play); void EnFloormas_Draw(Actor* thisx, PlayState* play); 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 ad0d3de241..c8e85a3aca 100644 --- a/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c +++ b/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c @@ -73,10 +73,10 @@ typedef enum { } GerudoWhiteAnimations; void EnGe1_ChangeAnim(EnGe1* this, s16 animIndex, u8 mode, f32 morphFrames); -void EnGe1_ShadowDraw(Actor* actor, Lights* lights, PlayState* play); +void EnGe1_ShadowDraw(Actor* thisx, Lights* lights, PlayState* play); void EnGe1_Wait(EnGe1* this, PlayState* play); void EnGe1_PerformCutsceneActions(EnGe1* this, PlayState* play); -s32 EnGe1_ValidatePictograph(PlayState* play, Actor* this); +s32 EnGe1_ValidatePictograph(PlayState* play, Actor* thisx); void EnGe1_Init(Actor* thisx, PlayState* play) { EnGe1* this = THIS; diff --git a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c index a9aaedaa18..47eac30512 100644 --- a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c +++ b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c @@ -11,7 +11,7 @@ #define THIS ((EnGg2*)thisx) -void EnGg2_Init(Actor* thisx, PlayState* play); +void EnGg2_Init(Actor* thisx, PlayState* play2); void EnGg2_Destroy(Actor* thisx, PlayState* play); void EnGg2_Update(Actor* thisx, PlayState* play); void EnGg2_Draw(Actor* thisx, PlayState* play); diff --git a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c index 0f016f3004..6b354dd94c 100644 --- a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c +++ b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c @@ -11,8 +11,8 @@ #define THIS ((EnHanabi*)thisx) -void EnHanabi_Init(Actor* thisx, PlayState* play); -void EnHanabi_Destroy(Actor* thisx, PlayState* play); +void EnHanabi_Init(Actor* thisx, PlayState* play2); +void EnHanabi_Destroy(Actor* thisx, PlayState* play2); void EnHanabi_Update(Actor* thisx, PlayState* play); void func_80B23894(EnHanabi* this, PlayState* play); diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.c b/src/overlays/actors/ovl_En_Horse/z_en_horse.c index a9b233aa53..d822ba6748 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -15,9 +15,9 @@ #define THIS ((EnHorse*)thisx) -void EnHorse_Init(Actor* thisx, PlayState* play); +void EnHorse_Init(Actor* thisx, PlayState* play2); void EnHorse_Destroy(Actor* thisx, PlayState* play); -void EnHorse_Update(Actor* thisx, PlayState* play); +void EnHorse_Update(Actor* thisx, PlayState* play2); void EnHorse_Draw(Actor* thisx, PlayState* play); void func_8087D540(Actor* thisx, PlayState* play); diff --git a/src/overlays/actors/ovl_En_Ik/z_en_ik.c b/src/overlays/actors/ovl_En_Ik/z_en_ik.c index ffd45eaf96..92f73dac51 100644 --- a/src/overlays/actors/ovl_En_Ik/z_en_ik.c +++ b/src/overlays/actors/ovl_En_Ik/z_en_ik.c @@ -13,7 +13,7 @@ void EnIk_Init(Actor* thisx, PlayState* play); void EnIk_Destroy(Actor* thisx, PlayState* play); -void EnIk_Update(Actor* thisx, PlayState* play); +void EnIk_Update(Actor* thisx, PlayState* play2); void EnIk_Draw(Actor* thisx, PlayState* play); void EnIk_Thaw(EnIk* this, PlayState* play); 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 2050c7316e..a0dbf7ca28 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -170,7 +170,7 @@ void func_80B4BA30(Actor* thisx, PlayState* play); void func_80B4C568(Actor* thisx, PlayState* play); void func_80B4CFFC(Actor* thisx, PlayState* play); void func_80B46184(unkStruct80B50350* unkStruct); -s32 func_80B450C0(f32* arg0, f32* arg1, f32 arg2, f32 arg3, f32 arg4); +s32 func_80B450C0(f32* x1, f32* z1, f32 x2, f32 z2, f32 speed); s32 func_80B4516C(EnInvadepoh* this); void func_80B45A4C(EnInvadePohStruct* s, unkstructInvadepoh4** u); void func_80B45A94(EnInvadePohStruct* s, unkstructInvadepoh4** u); 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 57c18ad7b3..5ebc15a029 100644 --- a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c +++ b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c @@ -16,7 +16,7 @@ #define THIS ((EnIshi*)thisx) void EnIshi_Init(Actor* thisx, PlayState* play); -void EnIshi_Destroy(Actor* thisx, PlayState* play); +void EnIshi_Destroy(Actor* thisx, PlayState* play2); void EnIshi_Update(Actor* thisx, PlayState* play); void func_8095D804(Actor* thisx, PlayState* play); diff --git a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c index 46a1adfd5d..61c1c5b3c4 100644 --- a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c +++ b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c @@ -15,7 +15,7 @@ void EnKarebaba_Init(Actor* thisx, PlayState* play); void EnKarebaba_Destroy(Actor* thisx, PlayState* play); -void EnKarebaba_Update(Actor* thisx, PlayState* play); +void EnKarebaba_Update(Actor* thisx, PlayState* play2); void EnKarebaba_Draw(Actor* thisx, PlayState* play); void func_808F155C(EnKarebaba* this); diff --git a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c index 9d0c412953..2ab13422a8 100644 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c @@ -15,7 +15,7 @@ void EnKusa_Init(Actor* thisx, PlayState* play); void EnKusa_Destroy(Actor* thisx, PlayState* play); -void EnKusa_Update(Actor* thisx, PlayState* play); +void EnKusa_Update(Actor* thisx, PlayState* play2); s32 EnKusa_SnapToFloor(EnKusa* this, PlayState* play, f32 yOffset); void EnKusa_DropCollectible(EnKusa* this, PlayState* play); 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 fbfb170408..1fa4589b56 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 @@ -16,7 +16,7 @@ void EnMThunder_Init(Actor* thisx, PlayState* play); void EnMThunder_Destroy(Actor* thisx, PlayState* play); void EnMThunder_Update(Actor* thisx, PlayState* play); -void EnMThunder_Draw(Actor* thisx, PlayState* play); +void EnMThunder_Draw(Actor* thisx, PlayState* play2); void EnMThunder_UnkType_Update(Actor* thisx, PlayState* play); diff --git a/src/overlays/actors/ovl_En_Muto/z_en_muto.c b/src/overlays/actors/ovl_En_Muto/z_en_muto.c index 69861434b2..8a657ad2ae 100644 --- a/src/overlays/actors/ovl_En_Muto/z_en_muto.c +++ b/src/overlays/actors/ovl_En_Muto/z_en_muto.c @@ -13,7 +13,7 @@ void EnMuto_Init(Actor* thisx, PlayState* play); void EnMuto_Destroy(Actor* thisx, PlayState* play); -void EnMuto_Update(Actor* thisx, PlayState* play); +void EnMuto_Update(Actor* thisx, PlayState* play2); void EnMuto_Draw(Actor* thisx, PlayState* play); void EnMuto_ChangeAnim(EnMuto* this, s32 animIndex); 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 36fea369b0..c93e531bea 100644 --- a/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c +++ b/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c @@ -14,7 +14,7 @@ void EnNutsball_Init(Actor* thisx, PlayState* play); void EnNutsball_Destroy(Actor* thisx, PlayState* play); -void EnNutsball_Update(Actor* thisx, PlayState* play); +void EnNutsball_Update(Actor* thisx, PlayState* play2); void EnNutsball_Draw(Actor* thisx, PlayState* play); void EnNutsball_InitColliderParams(EnNutsball* this); diff --git a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c index 02e660f147..cf3cd935f5 100644 --- a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c +++ b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c @@ -15,7 +15,7 @@ void EnPeehat_Init(Actor* thisx, PlayState* play); void EnPeehat_Destroy(Actor* thisx, PlayState* play); -void EnPeehat_Update(Actor* thisx, PlayState* play); +void EnPeehat_Update(Actor* thisx, PlayState* play2); void EnPeehat_Draw(Actor* thisx, PlayState* play); void func_80897498(EnPeehat* this); diff --git a/src/overlays/actors/ovl_En_Poh/z_en_poh.c b/src/overlays/actors/ovl_En_Poh/z_en_poh.c index dde6236b52..a3718497c8 100644 --- a/src/overlays/actors/ovl_En_Poh/z_en_poh.c +++ b/src/overlays/actors/ovl_En_Poh/z_en_poh.c @@ -13,7 +13,7 @@ void EnPoh_Init(Actor* thisx, PlayState* play); void EnPoh_Destroy(Actor* thisx, PlayState* play); -void EnPoh_Update(Actor* thisx, PlayState* play); +void EnPoh_Update(Actor* thisx, PlayState* play2); void EnPoh_Draw(Actor* thisx, PlayState* play); void func_80B2CAA4(EnPoh* this, PlayState* play); diff --git a/src/overlays/actors/ovl_En_Pr/z_en_pr.c b/src/overlays/actors/ovl_En_Pr/z_en_pr.c index 724b2c19fe..ec8ab91de1 100644 --- a/src/overlays/actors/ovl_En_Pr/z_en_pr.c +++ b/src/overlays/actors/ovl_En_Pr/z_en_pr.c @@ -12,7 +12,7 @@ #define THIS ((EnPr*)thisx) -void EnPr_Init(Actor* thisx, PlayState* play); +void EnPr_Init(Actor* thisx, PlayState* play2); void EnPr_Destroy(Actor* thisx, PlayState* play); void EnPr_Update(Actor* thisx, PlayState* play); void EnPr_Draw(Actor* thisx, PlayState* play); diff --git a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c index 66b2a0a1ed..3190e3e36b 100644 --- a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c +++ b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c @@ -28,7 +28,7 @@ void EnRacedog_CalculateFinalStretchTargetSpeed(EnRacedog* this); void EnRacedog_UpdateRaceVariables(EnRacedog* this); void EnRacedog_CheckForFinish(EnRacedog* this); void EnRacedog_UpdateRunAnimationPlaySpeed(EnRacedog* this); -s32 EnRacedog_IsOverFinishLine(EnRacedog* this, Vec2f* arg1); +s32 EnRacedog_IsOverFinishLine(EnRacedog* this, Vec2f* finishLineCoordinates); void EnRacedog_SpawnFloorDustRing(EnRacedog* this, PlayState* play); void EnRacedog_PlaySfxWalk(EnRacedog* this); diff --git a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c index 58ab51cf83..50df4d01cd 100644 --- a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c +++ b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c @@ -35,7 +35,8 @@ void EnRailgibud_Damage(EnRailgibud* this, PlayState* play); void EnRailgibud_Stunned(EnRailgibud* this, PlayState* play); void EnRailgibud_SetupDead(EnRailgibud* this); void EnRailgibud_Dead(EnRailgibud* this, PlayState* play); -void EnRailgibud_SpawnDust(PlayState* play, Vec3f* vec, f32 arg2, s32 arg3, s16 arg4, s16 arg5); +void EnRailgibud_SpawnDust(PlayState* play, Vec3f* basePos, f32 randomnessScale, s32 dustCount, s16 dustScale, + s16 scaleStep); void EnRailgibud_TurnTowardsPlayer(EnRailgibud* this, PlayState* play); s32 EnRailgibud_PlayerInRangeWithCorrectState(EnRailgibud* this, PlayState* play); s32 EnRailgibud_PlayerOutOfRange(EnRailgibud* this, PlayState* play); 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 4a61e62b9c..daf11baa66 100644 --- a/src/overlays/actors/ovl_En_Rr/z_en_rr.c +++ b/src/overlays/actors/ovl_En_Rr/z_en_rr.c @@ -15,7 +15,7 @@ void EnRr_Init(Actor* thisx, PlayState* play); void EnRr_Destroy(Actor* thisx, PlayState* play); void EnRr_Update(Actor* thisx, PlayState* play); -void EnRr_Draw(Actor* thisx, PlayState* play); +void EnRr_Draw(Actor* thisx, PlayState* play2); void func_808FAF94(EnRr* this, PlayState* play); void func_808FB088(EnRr* this, PlayState* play); diff --git a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c index 66db63c652..98f7b0a117 100644 --- a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c +++ b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c @@ -17,7 +17,7 @@ enum { ENRUPPECROW_EFFECT_LIGHT = 20, }; -void EnRuppecrow_Init(Actor* thisx, PlayState* play); +void EnRuppecrow_Init(Actor* thisx, PlayState* play2); void EnRuppecrow_Destroy(Actor* thisx, PlayState* play); void EnRuppecrow_Update(Actor* thisx, PlayState* play); void EnRuppecrow_Draw(Actor* thisx, PlayState* play); diff --git a/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c b/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c index f3bce9c4f6..0b76c77151 100644 --- a/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c +++ b/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c @@ -11,7 +11,7 @@ #define THIS ((EnSyatekiCrow*)thisx) -void EnSyatekiCrow_Init(Actor* thisx, PlayState* play); +void EnSyatekiCrow_Init(Actor* thisx, PlayState* play2); void EnSyatekiCrow_Destroy(Actor* thisx, PlayState* play); void EnSyatekiCrow_Update(Actor* thisx, PlayState* play); void EnSyatekiCrow_Draw(Actor* thisx, PlayState* play); diff --git a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c index 5e6f5925a9..b7e79fdfd1 100644 --- a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c +++ b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c @@ -12,7 +12,7 @@ #define THIS ((EnSyatekiDekunuts*)thisx) -void EnSyatekiDekunuts_Init(Actor* thisx, PlayState* play); +void EnSyatekiDekunuts_Init(Actor* thisx, PlayState* play2); void EnSyatekiDekunuts_Destroy(Actor* thisx, PlayState* play); void EnSyatekiDekunuts_Update(Actor* thisx, PlayState* play); void EnSyatekiDekunuts_Draw(Actor* thisx, PlayState* play); diff --git a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c index c9caedf014..ad9aa824fb 100644 --- a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c +++ b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c @@ -13,7 +13,7 @@ void EnSyatekiWf_Init(Actor* thisx, PlayState* play); void EnSyatekiWf_Destroy(Actor* thisx, PlayState* play); -void EnSyatekiWf_Update(Actor* thisx, PlayState* play); +void EnSyatekiWf_Update(Actor* thisx, PlayState* play2); void EnSyatekiWf_Draw(Actor* thisx, PlayState* play); void func_80A201CC(EnSyatekiWf* this); diff --git a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c index 542a564f52..9737c9f813 100644 --- a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c +++ b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c @@ -16,7 +16,7 @@ void EnTanron2_Init(Actor* thisx, PlayState* play); void EnTanron2_Destroy(Actor* thisx, PlayState* play); void EnTanron2_Update(Actor* thisx, PlayState* play); -void EnTanron2_Draw(Actor* thisx, PlayState* play); +void EnTanron2_Draw(Actor* thisx, PlayState* play2); void func_80BB69C0(EnTanron2* this); void func_80BB69FC(EnTanron2* this, PlayState* play); diff --git a/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c b/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c index e68ca1b3a9..c67b36940d 100644 --- a/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c +++ b/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c @@ -10,7 +10,7 @@ #define THIS ((EnTanron4*)thisx) -void EnTanron4_Init(Actor* thisx, PlayState* play); +void EnTanron4_Init(Actor* thisx, PlayState* play2); void EnTanron4_Destroy(Actor* thisx, PlayState* play); void EnTanron4_Update(Actor* thisx, PlayState* play); void EnTanron4_Draw(Actor* thisx, PlayState* play); diff --git a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c index 45f88ffb72..f45afbb013 100644 --- a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c +++ b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c @@ -15,10 +15,10 @@ void EnTanron5_Init(Actor* thisx, PlayState* play); void EnTanron5_Destroy(Actor* thisx, PlayState* play); -void EnTanron5_Update(Actor* thisx, PlayState* play); +void EnTanron5_Update(Actor* thisx, PlayState* play2); void EnTanron5_Draw(Actor* thisx, PlayState* play); -void func_80BE5818(Actor* thisx, PlayState* play); +void func_80BE5818(Actor* thisx, PlayState* play2); void func_80BE5C10(Actor* thisx, PlayState* play); s32 D_80BE5D80 = 0; 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 af2824c698..348290ccf1 100644 --- a/src/overlays/actors/ovl_En_Test/z_en_test.c +++ b/src/overlays/actors/ovl_En_Test/z_en_test.c @@ -11,7 +11,7 @@ #define THIS ((EnTest*)thisx) -void EnTest_Init(Actor* thisx, PlayState* play); +void EnTest_Init(Actor* thisx, PlayState* play2); void EnTest_Destroy(Actor* thisx, PlayState* play); void EnTest_Update(Actor* thisx, PlayState* play); void EnTest_Draw(Actor* thisx, PlayState* play); diff --git a/src/overlays/actors/ovl_En_Test5/z_en_test5.c b/src/overlays/actors/ovl_En_Test5/z_en_test5.c index 57db36ea6b..13cb04b028 100644 --- a/src/overlays/actors/ovl_En_Test5/z_en_test5.c +++ b/src/overlays/actors/ovl_En_Test5/z_en_test5.c @@ -10,9 +10,9 @@ #define THIS ((EnTest5*)thisx) -void EnTest5_Init(Actor* thisx, PlayState* play); +void EnTest5_Init(Actor* thisx, PlayState* play2); void EnTest5_Destroy(Actor* thisx, PlayState* play); -void EnTest5_Update(Actor* thisx, PlayState* play); +void EnTest5_Update(Actor* thisx, PlayState* play2); void EnTest5_HandleBottleAction(EnTest5* this, PlayState* play); void EnTest5_SetupAction(EnTest5* this, EnTest5ActionFunc actionFunc); 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 23dccca0fb..ea50336d91 100644 --- a/src/overlays/actors/ovl_En_Test6/z_en_test6.c +++ b/src/overlays/actors/ovl_En_Test6/z_en_test6.c @@ -12,8 +12,8 @@ #define THIS ((EnTest6*)thisx) -void EnTest6_Init(Actor* thisx, PlayState* play); -void EnTest6_Destroy(Actor* thisx, PlayState* play); +void EnTest6_Init(Actor* thisx, PlayState* play2); +void EnTest6_Destroy(Actor* thisx, PlayState* play2); void EnTest6_Update(Actor* thisx, PlayState* play); void EnTest6_Draw(Actor* thisx, PlayState* play); 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 e1223cddb4..5f153e5a98 100644 --- a/src/overlays/actors/ovl_En_Test7/z_en_test7.c +++ b/src/overlays/actors/ovl_En_Test7/z_en_test7.c @@ -11,7 +11,7 @@ #define THIS ((EnTest7*)thisx) -void EnTest7_Init(Actor* thisx, PlayState* play); +void EnTest7_Init(Actor* thisx, PlayState* play2); void EnTest7_Destroy(Actor* thisx, PlayState* play); void EnTest7_Update(Actor* thisx, PlayState* play); void EnTest7_Draw(Actor* thisx, PlayState* play); diff --git a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c index dd4890d537..fc82ed2620 100644 --- a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c +++ b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c @@ -12,7 +12,7 @@ void EnThiefbird_Init(Actor* thisx, PlayState* play); void EnThiefbird_Destroy(Actor* thisx, PlayState* play); -void EnThiefbird_Update(Actor* thisx, PlayState* play); +void EnThiefbird_Update(Actor* thisx, PlayState* play2); void EnThiefbird_Draw(Actor* thisx, PlayState* play); void func_80C11538(EnThiefbird* this); diff --git a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c index 2cb3cb1938..0486f7c5c9 100644 --- a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c +++ b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c @@ -14,7 +14,7 @@ void EnTorch2_Init(Actor* thisx, PlayState* play); void EnTorch2_Destroy(Actor* thisx, PlayState* play); void EnTorch2_Update(Actor* thisx, PlayState* play); -void EnTorch2_Draw(Actor* thisx, PlayState* play); +void EnTorch2_Draw(Actor* thisx, PlayState* play2); void EnTorch2_UpdateIdle(Actor* thisx, PlayState* play); void EnTorch2_UpdateDeath(Actor* thisx, PlayState* play); diff --git a/src/overlays/actors/ovl_En_Twig/z_en_twig.c b/src/overlays/actors/ovl_En_Twig/z_en_twig.c index 5df9cee3c5..1f26288c4d 100644 --- a/src/overlays/actors/ovl_En_Twig/z_en_twig.c +++ b/src/overlays/actors/ovl_En_Twig/z_en_twig.c @@ -11,10 +11,10 @@ #define THIS ((EnTwig*)thisx) -void EnTwig_Init(Actor* thisx, PlayState* play); -void EnTwig_Destroy(Actor* thisx, PlayState* play); -void EnTwig_Update(Actor* this, PlayState* play); -void EnTwig_Draw(EnTwig* this, PlayState* play); +void EnTwig_Init(Actor* thisx, PlayState* play2); +void EnTwig_Destroy(Actor* thisx, PlayState* play2); +void EnTwig_Update(Actor* thisx, PlayState* play2); +void EnTwig_Draw(Actor* thisx, PlayState* play); void func_80AC0A54(EnTwig* this, PlayState* play); void func_80AC0A6C(EnTwig* this, PlayState* play); @@ -227,7 +227,7 @@ void EnTwig_Update(Actor* thisx, PlayState* play2) { this->actionFunc(this, play); } -void EnTwig_Draw(EnTwig* thisx, PlayState* play) { +void EnTwig_Draw(Actor* thisx, PlayState* play) { EnTwig* this = THIS; switch (this->unk_160) { diff --git a/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c b/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c index fc1ad7279b..aa36b69472 100644 --- a/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c +++ b/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c @@ -22,8 +22,8 @@ void EnWaterEffect_Init(Actor* thisx, PlayState* play); void EnWaterEffect_Destroy(Actor* thisx, PlayState* play); -void EnWaterEffect_Update(Actor* thisx, PlayState* play); -void EnWaterEffect_Draw(Actor* thisx, PlayState* play); +void EnWaterEffect_Update(Actor* thisx, PlayState* play2); +void EnWaterEffect_Draw(Actor* thisx, PlayState* play2); void func_80A59C04(Actor* thisx, PlayState* play2); void func_80A5A184(Actor* thisx, PlayState* play2); diff --git a/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c b/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c index eea112f894..ca3fde7451 100644 --- a/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c +++ b/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c @@ -14,8 +14,8 @@ void EnWizFire_Init(Actor* thisx, PlayState* play); void EnWizFire_Destroy(Actor* thisx, PlayState* play); -void EnWizFire_Update(Actor* thisx, PlayState* play); -void EnWizFire_Draw(Actor* thisx, PlayState* play); +void EnWizFire_Update(Actor* thisx, PlayState* play2); +void EnWizFire_Draw(Actor* thisx, PlayState* play2); void EnWiz_SetupMoveMagicProjectile(EnWizFire* this, PlayState* play); void EnWiz_MoveMagicProjectile(EnWizFire* this, PlayState* play); diff --git a/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c b/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c index 67faa1f3c3..08295ad1e7 100644 --- a/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c +++ b/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c @@ -13,7 +13,7 @@ void EnWood02_Init(Actor* thisx, PlayState* play); void EnWood02_Destroy(Actor* thisx, PlayState* play); -void EnWood02_Update(Actor* thisx, PlayState* play); +void EnWood02_Update(Actor* thisx, PlayState* play2); void EnWood02_Draw(Actor* thisx, PlayState* play); /** diff --git a/src/overlays/actors/ovl_En_Zos/z_en_zos.c b/src/overlays/actors/ovl_En_Zos/z_en_zos.c index 1b7be4e0b1..11fcc25953 100644 --- a/src/overlays/actors/ovl_En_Zos/z_en_zos.c +++ b/src/overlays/actors/ovl_En_Zos/z_en_zos.c @@ -15,7 +15,7 @@ void EnZos_Destroy(Actor* thisx, PlayState* play); void EnZos_Update(Actor* thisx, PlayState* play); void EnZos_Draw(Actor* thisx, PlayState* play); -void EnZos_ChangeAnim(EnZos* this, s16 arg1, u8 arg2); +void EnZos_ChangeAnim(EnZos* this, s16 animIndex, u8 animMode); void func_80BBB2C4(EnZos* this, PlayState* play); void func_80BBB354(EnZos* this, PlayState* play); void func_80BBB4CC(EnZos* this, PlayState* play); diff --git a/src/overlays/actors/ovl_En_Zot/z_en_zot.c b/src/overlays/actors/ovl_En_Zot/z_en_zot.c index bced0c6f30..1519a37745 100644 --- a/src/overlays/actors/ovl_En_Zot/z_en_zot.c +++ b/src/overlays/actors/ovl_En_Zot/z_en_zot.c @@ -12,7 +12,7 @@ #define THIS ((EnZot*)thisx) -void EnZot_Init(Actor* thisx, PlayState* play); +void EnZot_Init(Actor* thisx, PlayState* play2); void EnZot_Destroy(Actor* thisx, PlayState* play); void EnZot_Update(Actor* thisx, PlayState* play); void EnZot_Draw(Actor* thisx, PlayState* play); diff --git a/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c b/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c index 9b31c22ca6..b9310b27e8 100644 --- a/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c +++ b/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c @@ -13,7 +13,7 @@ void ObjArmos_Init(Actor* thisx, PlayState* play); void ObjArmos_Destroy(Actor* thisx, PlayState* play); -void ObjArmos_Update(Actor* thisx, PlayState* play); +void ObjArmos_Update(Actor* thisx, PlayState* play2); void ObjArmos_Draw(Actor* thisx, PlayState* play); void func_809A54B4(ObjArmos* this); diff --git a/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c b/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c index 0380b338d3..1fca2a0018 100644 --- a/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c +++ b/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c @@ -16,7 +16,7 @@ void ObjBoat_Destroy(Actor* thisx, PlayState* play); void ObjBoat_Update(Actor* thisx, PlayState* play); void ObjBoat_Draw(Actor* thisx, PlayState* play); -void func_80B9B428(Actor* thisx, PlayState* play); +void func_80B9B428(Actor* thisx, PlayState* play2); const ActorInit Obj_Boat_InitVars = { ACTOR_OBJ_BOAT, diff --git a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c index 8e555a19f2..d387436be3 100644 --- a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c +++ b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c @@ -25,7 +25,7 @@ void ObjChan_Destroy(Actor* thisx, PlayState* play); void ObjChan_Update(Actor* thisx, PlayState* play); void ObjChan_Draw(Actor* thisx, PlayState* play); -void ObjChan_ChandelierAction(ObjChan* this, PlayState* play); +void ObjChan_ChandelierAction(ObjChan* this2, PlayState* play); void ObjChan_PotAction(ObjChan* this, PlayState* play); const ActorInit Obj_Chan_InitVars = { diff --git a/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c b/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c index 77b704a6c7..fa92bd2e33 100644 --- a/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c +++ b/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c @@ -22,7 +22,7 @@ void func_80B13170(ObjDhouse* this, PlayState* play, ObjDhouseStruct1* ptr, ObjD void func_80B13908(ObjDhouse* this); void func_80B1391C(ObjDhouse* this, PlayState* play); void func_80B1392C(ObjDhouse* this); -void func_80B13940(ObjDhouse* this, PlayState* play); +void func_80B13940(ObjDhouse* this, PlayState* play2); void func_80B139D8(ObjDhouse* this); void func_80B139F4(ObjDhouse* this, PlayState* play); void func_80B13C08(Actor* thisx, PlayState* play); diff --git a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c index 79961ad82b..c4ebe8063f 100644 --- a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c +++ b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c @@ -12,8 +12,8 @@ #define THIS ((ObjFlowerpot*)thisx) void ObjFlowerpot_Init(Actor* thisx, PlayState* play); -void ObjFlowerpot_Destroy(Actor* thisx, PlayState* play); -void ObjFlowerpot_Update(Actor* thisx, PlayState* play); +void ObjFlowerpot_Destroy(Actor* thisx, PlayState* play2); +void ObjFlowerpot_Update(Actor* thisx, PlayState* play2); void ObjFlowerpot_Draw(Actor* thisx, PlayState* play); void func_80A1C818(ObjFlowerpot* this); 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 38f3164e38..3ad2cf5e82 100644 --- a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c +++ b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c @@ -14,7 +14,7 @@ #define THIS ((ObjHugebombiwa*)thisx) void ObjHugebombiwa_Init(Actor* thisx, PlayState* play); -void ObjHugebombiwa_Destroy(Actor* thisx, PlayState* play); +void ObjHugebombiwa_Destroy(Actor* thisx, PlayState* play2); void ObjHugebombiwa_Update(Actor* thisx, PlayState* play); void ObjHugebombiwa_Draw(Actor* thisx, PlayState* play); diff --git a/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c b/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c index 33de741002..57e0f4b2e5 100644 --- a/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c +++ b/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c @@ -11,7 +11,7 @@ #define THIS ((ObjJgGakki*)thisx) -void ObjJgGakki_Init(Actor* thisx, PlayState* play); +void ObjJgGakki_Init(Actor* thisx, PlayState* play2); void ObjJgGakki_Destroy(Actor* thisx, PlayState* play); void ObjJgGakki_Update(Actor* thisx, PlayState* play); void ObjJgGakki_Draw(Actor* thisx, PlayState* play); 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 e2a71db925..9bd2e0442f 100644 --- a/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c +++ b/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c @@ -12,8 +12,8 @@ #define THIS ((ObjKibako*)thisx) -void ObjKibako_Init(Actor* thisx, PlayState* play); -void ObjKibako_Destroy(Actor* thisx, PlayState* play); +void ObjKibako_Init(Actor* thisx, PlayState* play2); +void ObjKibako_Destroy(Actor* thisx, PlayState* play2); void ObjKibako_Update(Actor* thisx, PlayState* play); void ObjKibako_Draw(Actor* thisx, PlayState* play); diff --git a/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c b/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c index 99745be7cb..e1b1bc1b97 100644 --- a/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c +++ b/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c @@ -13,7 +13,7 @@ void ObjMilkBin_Init(Actor* thisx, PlayState* play); void ObjMilkBin_Destroy(Actor* thisx, PlayState* play); -void ObjMilkBin_Update(Actor* thisx, PlayState* play); +void ObjMilkBin_Update(Actor* thisx, PlayState* play2); void ObjMilkBin_Draw(Actor* thisx, PlayState* play); const ActorInit Obj_Milk_Bin_InitVars = { 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 23ca0872d1..01cfdd8329 100644 --- a/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c +++ b/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c @@ -22,7 +22,7 @@ void ObjRaillift_DrawDekuFlowerPlatform(Actor* thisx, PlayState* play); void ObjRaillift_DoNothing(ObjRaillift* this, PlayState* play); void ObjRaillift_Idle(ObjRaillift* this, PlayState* play); -void ObjRaillift_UpdatePosition(ObjRaillift* this, s32 arg1); +void ObjRaillift_UpdatePosition(ObjRaillift* this, s32 index); void ObjRaillift_StartCutscene(ObjRaillift* this, PlayState* play); void ObjRaillift_Teleport(ObjRaillift* this, PlayState* play); void ObjRaillift_Wait(ObjRaillift* this, PlayState* play); @@ -49,8 +49,8 @@ static InitChainEntry sInitChain[] = { static CollisionHeader* sColHeaders[] = { &object_raillift_Colheader_004FF8, &object_raillift_Colheader_0048D0 }; -void ObjRaillift_UpdatePosition(ObjRaillift* this, s32 idx) { - Math_Vec3s_ToVec3f(&this->dyna.actor.world.pos, &this->points[idx]); +void ObjRaillift_UpdatePosition(ObjRaillift* this, s32 index) { + Math_Vec3s_ToVec3f(&this->dyna.actor.world.pos, &this->points[index]); } void ObjRaillift_Init(Actor* thisx, PlayState* play) { 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 0db945c96c..c57db1111e 100644 --- a/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c +++ b/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c @@ -13,7 +13,7 @@ void ObjSpinyroll_Init(Actor* thisx, PlayState* play); void ObjSpinyroll_Destroy(Actor* thisx, PlayState* play); -void ObjSpinyroll_Update(Actor* thisx, PlayState* play); +void ObjSpinyroll_Update(Actor* thisx, PlayState* play2); void ObjSpinyroll_Draw(Actor* thisx, PlayState* play); void func_80A1E9C4(ObjSpinyroll* this); 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 7625b403f8..02a7d59e14 100644 --- a/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c +++ b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c @@ -15,7 +15,7 @@ void ObjSyokudai_Init(Actor* thisx, PlayState* play); void ObjSyokudai_Destroy(Actor* thisx, PlayState* play); -void ObjSyokudai_Update(Actor* thisx, PlayState* play); +void ObjSyokudai_Update(Actor* thisx, PlayState* play2); void ObjSyokudai_Draw(Actor* thisx, PlayState* play); const ActorInit Obj_Syokudai_InitVars = { diff --git a/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c b/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c index bd5c164131..a37f64b849 100644 --- a/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c +++ b/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c @@ -12,7 +12,7 @@ #define THIS ((ObjToge*)thisx) void ObjToge_Init(Actor* thisx, PlayState* play); -void ObjToge_Destroy(Actor* thisx, PlayState* play); +void ObjToge_Destroy(Actor* thisx, PlayState* play2); void ObjToge_Update(Actor* thisx, PlayState* play); void ObjToge_Draw(Actor* thisx, PlayState* play); diff --git a/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c b/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c index 9d635d7eb1..eccc9c2c3c 100644 --- a/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c +++ b/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c @@ -15,9 +15,9 @@ #define THIS ((ObjTsubo*)thisx) void ObjTsubo_Init(Actor* thisx, PlayState* play); -void ObjTsubo_Destroy(Actor* thisx, PlayState* play); +void ObjTsubo_Destroy(Actor* thisx, PlayState* play2); void ObjTsubo_Update(Actor* thisx, PlayState* play); -void ObjTsubo_Draw(Actor* thisx, PlayState* play); +void ObjTsubo_Draw(Actor* thisx, PlayState* play2); void ObjTsubo_PotBreak1(ObjTsubo* this, PlayState* play); void ObjTsubo_RacePotBreak1(ObjTsubo* this, PlayState* play); diff --git a/src/overlays/actors/ovl_Obj_Um/z_obj_um.c b/src/overlays/actors/ovl_Obj_Um/z_obj_um.c index 7cb4f310f7..63fe325012 100644 --- a/src/overlays/actors/ovl_Obj_Um/z_obj_um.c +++ b/src/overlays/actors/ovl_Obj_Um/z_obj_um.c @@ -58,7 +58,7 @@ void ObjUm_Update(Actor* thisx, PlayState* play); void ObjUm_Draw(Actor* thisx, PlayState* play); void ObjUm_DefaultAnim(ObjUm* this, PlayState* play); -void ObjUm_ChangeAnim(ObjUm* this, PlayState* play, ObjUmAnimation index); +void ObjUm_ChangeAnim(ObjUm* this, PlayState* play, ObjUmAnimation animIndex); void ObjUm_SetupAction(ObjUm* this, ObjUmActionFunc actionFunc); const ActorInit Obj_Um_InitVars = { 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 6740cc684e..be692069f3 100644 --- a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c +++ b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c @@ -13,7 +13,7 @@ void ObjVspinyroll_Init(Actor* thisx, PlayState* play); void ObjVspinyroll_Destroy(Actor* thisx, PlayState* play); -void ObjVspinyroll_Update(Actor* thisx, PlayState* play); +void ObjVspinyroll_Update(Actor* thisx, PlayState* play2); void ObjVspinyroll_Draw(Actor* thisx, PlayState* play); void func_80A3CEC4(ObjVspinyroll* this); diff --git a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c index ea9b35f5c2..4e0fb508d6 100644 --- a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c +++ b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c @@ -15,7 +15,7 @@ void ObjWarpstone_Init(Actor* thisx, PlayState* play); void ObjWarpstone_Destroy(Actor* thisx, PlayState* play); void ObjWarpstone_Update(Actor* thisx, PlayState* play); -void ObjWarpstone_Draw(Actor* thisx, PlayState* play); +void ObjWarpstone_Draw(Actor* thisx, PlayState* play2); void ObjWarpstone_SetupAction(ObjWarpstone* this, ObjWarpstoneActionFunc actionFunc); s32 ObjWarpstone_ClosedIdle(ObjWarpstone* this, PlayState* play); s32 ObjWarpstone_BeginOpeningCutscene(ObjWarpstone* this, PlayState* play); diff --git a/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c b/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c index 0932613449..1aa2e545e9 100644 --- a/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c +++ b/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c @@ -17,7 +17,7 @@ void ShotSun_Destroy(Actor* thisx, PlayState* play); void ShotSun_Update(Actor* thisx, PlayState* play); void ShotSun_UpdateForOcarina(ShotSun* this, PlayState* play); -void ShotSun_UpdateHyliaSun(ShotSun* this, PlayState* play2); +void ShotSun_UpdateHyliaSun(ShotSun* this, PlayState* play); const ActorInit Shot_Sun_InitVars = { ACTOR_SHOT_SUN, diff --git a/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c b/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c index bd8a40ed8f..3298b2ab3c 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c +++ b/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c @@ -14,7 +14,7 @@ #define PARAMS ((EffectSsBubbleInitParams*)initParamsx) u32 EffectSsBubble_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); -void EffectSsBubble_Update(PlayState* play, u32 index, EffectSs* this); +void EffectSsBubble_Update(PlayState* play2, u32 index, EffectSs* this); void EffectSsBubble_Draw(PlayState* play, u32 index, EffectSs* this); const EffectSsInit Effect_Ss_Bubble_InitVars = { diff --git a/tools/check_format.sh b/tools/check_format.sh index d8119e7434..1195a9c593 100755 --- a/tools/check_format.sh +++ b/tools/check_format.sh @@ -1,7 +1,7 @@ #!/bin/bash STATUSOLD=`git status --porcelain` -./format.sh +./format.py -j if [ $? -ne 0 ] then echo "Formatter failed. Exiting." @@ -12,7 +12,7 @@ STATUSNEW=`git status --porcelain` if [ "${STATUSOLD}" != "${STATUSNEW}" ]; then echo "" - echo "Misformatted files found. Run ./format.sh and verify codegen is not impacted." + echo "Misformatted files found. Run ./format.py and verify codegen is not impacted." echo "" diff --unified=0 --label "Old git status" <(echo "${STATUSOLD}") --label "New git status" <(echo "${STATUSNEW}") echo "" From 362a73a017fe353e09feb9a8592a05f07f7cdb91 Mon Sep 17 00:00:00 2001 From: SonicDcer <96613413+sonicdcer@users.noreply.github.com> Date: Tue, 4 Oct 2022 00:36:12 -0300 Subject: [PATCH 21/25] ovl_En_Bombal OK (#1051) * ovl_En_Bombal OK * alpha * decimal values for weekEventReg * pr review * cutscenes * merge fix * pr review --- assets/xml/objects/object_fusen.xml | 4 +- spec | 3 +- .../actors/ovl_En_Bombal/z_en_bombal.c | 246 ++++++++++++++++-- .../actors/ovl_En_Bombal/z_en_bombal.h | 28 +- .../actors/ovl_En_Bomjima/z_en_bomjima.c | 150 ++++++----- .../actors/ovl_En_Bomjima/z_en_bomjima.h | 16 +- .../actors/ovl_En_Encount2/z_en_encount2.c | 6 +- tools/disasm/functions.txt | 6 +- 8 files changed, 346 insertions(+), 113 deletions(-) diff --git a/assets/xml/objects/object_fusen.xml b/assets/xml/objects/object_fusen.xml index 0ff9e9f6c1..2e115b2b73 100644 --- a/assets/xml/objects/object_fusen.xml +++ b/assets/xml/objects/object_fusen.xml @@ -1,7 +1,7 @@  - - + + diff --git a/spec b/spec index 100e615cf1..42bbff1820 100644 --- a/spec +++ b/spec @@ -4769,8 +4769,7 @@ beginseg name "ovl_En_Bombal" compress include "build/src/overlays/actors/ovl_En_Bombal/z_en_bombal.o" - include "build/data/ovl_En_Bombal/ovl_En_Bombal.data.o" - include "build/data/ovl_En_Bombal/ovl_En_Bombal.reloc.o" + include "build/src/overlays/actors/ovl_En_Bombal/ovl_En_Bombal_reloc.o" endseg beginseg 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 b4ebb73e6d..a4fc5d484f 100644 --- a/src/overlays/actors/ovl_En_Bombal/z_en_bombal.c +++ b/src/overlays/actors/ovl_En_Bombal/z_en_bombal.c @@ -5,6 +5,8 @@ */ #include "z_en_bombal.h" +#include "assets/objects/object_fusen/object_fusen.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10) @@ -18,8 +20,11 @@ void EnBombal_Draw(Actor* thisx, PlayState* play); void func_80C05B3C(EnBombal* this, PlayState* play); void func_80C05C44(EnBombal* this, PlayState* play); void func_80C05DE8(EnBombal* this, PlayState* play); +void func_80C05B24(EnBombal* this); +void EnBombal_InitEffects(EnBombal* this, Vec3f* pos, s16 fadeDelay); +void EnBombal_UpdateEffects(EnBombal* this, PlayState* play); +void EnBombal_DrawEffects(EnBombal*, PlayState*); -#if 0 const ActorInit En_Bombal_InitVars = { ACTOR_EN_BOMBAL, ACTORCAT_PROP, @@ -32,37 +37,240 @@ const ActorInit En_Bombal_InitVars = { (ActorFunc)EnBombal_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80C06460 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x004138B0, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x004138B0, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 60, 90, -50, { 0, 0, 0 } }, }; -#endif +void EnBombal_Init(Actor* thisx, PlayState* play) { + EnBombal* this = THIS; -extern ColliderCylinderInit D_80C06460; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); + this->actor.colChkInfo.mass = 0; + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + this->actor.targetMode = 6; + this->actor.colChkInfo.health = 1; + this->scale = 0.1f; + this->cutscene = this->actor.cutscene; + func_80C05B24(this); +} -extern UNK_TYPE D_06000A00; +void EnBombal_Destroy(Actor* thisx, PlayState* play) { + EnBombal* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombal/EnBombal_Init.s") + Collider_DestroyCylinder(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombal/EnBombal_Destroy.s") +void func_80C05B24(EnBombal* this) { + this->isPopped = false; + this->actionFunc = func_80C05B3C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombal/func_80C05B24.s") +void func_80C05B3C(EnBombal* this, PlayState* play) { + Player* player; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombal/func_80C05B3C.s") + this->oscillationAngle += 1500.0f; + this->actor.velocity.y = Math_SinS(this->oscillationAngle); + Math_ApproachF(&this->scale, 0.1f, 0.3f, 0.01f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombal/func_80C05C44.s") + if (play->msgCtx.msgLength == 0) { + if (this->collider.base.acFlags & AC_HIT) { + player = GET_PLAYER(play); + this->collider.base.acFlags &= ~AC_HIT; + if (!(gSaveContext.save.weekEventReg[75] & 0x40) && !(gSaveContext.save.weekEventReg[73] & 0x10) && + !(gSaveContext.save.weekEventReg[85] & 2)) { + player->stateFlags1 |= ACTOR_FLAG_20; + this->actor.flags |= ACTOR_FLAG_100000; + } + this->actionFunc = func_80C05C44; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombal/func_80C05DE8.s") +void func_80C05C44(EnBombal* this, PlayState* play) { + s32 phi_s0 = false; + s32 i; + Vec3f pos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombal/EnBombal_Update.s") + if (!(gSaveContext.save.weekEventReg[75] & 0x40) && !(gSaveContext.save.weekEventReg[73] & 0x10) && + !(gSaveContext.save.weekEventReg[85] & 2)) { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->cutscene); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombal/EnBombal_Draw.s") + if (!ActorCutscene_GetCanPlayNext(this->cutscene)) { + ActorCutscene_SetIntentToPlay(this->cutscene); + } else { + ActorCutscene_StartAndSetUnkLinkFields(this->cutscene, &this->actor); + phi_s0 = true; + } + } else { + phi_s0 = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombal/func_80C05F90.s") + if (phi_s0) { + Math_Vec3f_Copy(&pos, &this->actor.world.pos); + pos.y += 60.0f; + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, pos.x, pos.y, pos.z, 255, 255, 200, + CLEAR_TAG_LARGE_EXPLOSION); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombal/func_80C060B8.s") + for (i = 0; i < 100; i++) { + EnBombal_InitEffects(this, &pos, 10); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombal/func_80C06208.s") + gSaveContext.save.weekEventReg[83] |= 4; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MUJURA_BALLOON_BROKEN); + this->timer = 30; + this->isPopped = true; + this->actionFunc = func_80C05DE8; + } +} + +void func_80C05DE8(EnBombal* this, PlayState* play) { + if (this->timer == 0) { + if (!(gSaveContext.save.weekEventReg[75] & 0x40) && !(gSaveContext.save.weekEventReg[73] & 0x10) && + !(gSaveContext.save.weekEventReg[85] & 2)) { + ActorCutscene_Stop(this->cutscene); + } + Actor_MarkForDeath(&this->actor); + } else if (this->timer < 10) { + this->actor.colChkInfo.health = 0; + } +} + +void EnBombal_Update(Actor* thisx, PlayState* play) { + s32 pad; + EnBombal* this = THIS; + + if (this->timer != 0) { + this->timer--; + } + + this->actor.shape.rot.y = this->actor.world.rot.y; + + Actor_SetFocus(&this->actor, 30.0f); + Actor_SetScale(&this->actor, this->scale); + + this->actionFunc(this, play); + + Actor_MoveWithGravity(&this->actor); + EnBombal_UpdateEffects(this, play); + + if (!this->isPopped) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + } +} + +void EnBombal_Draw(Actor* thisx, PlayState* play) { + EnBombal* this = THIS; + + if (this->isPopped != true) { + Gfx_DrawDListOpa(play, gMajoraBalloonDL); + Gfx_DrawDListOpa(play, gMajoraBalloonKnotDL); + } + EnBombal_DrawEffects(this, play); +} + +void EnBombal_InitEffects(EnBombal* this, Vec3f* pos, s16 fadeDelay) { + s16 i; + EnBombalEffect* sPtr = this->effects; + + for (i = 0; i < ARRAY_COUNT(this->effects); i++, sPtr++) { + if (!sPtr->isEnabled) { + sPtr->isEnabled = true; + sPtr->pos = *pos; + sPtr->alphaFadeDelay = fadeDelay; + sPtr->alpha = 255; + + sPtr->accel.x = (Rand_ZeroOne() - 0.5f) * 10.0f; + sPtr->accel.y = (Rand_ZeroOne() - 0.5f) * 10.0f; + sPtr->accel.z = (Rand_ZeroOne() - 0.5f) * 10.0f; + + sPtr->velocity.x = Rand_ZeroOne() - 0.5f; + sPtr->velocity.y = Rand_ZeroOne() - 0.5f; + sPtr->velocity.z = Rand_ZeroOne() - 0.5f; + + sPtr->scale = (Rand_ZeroFloat(1.0f) * 0.5f) + 2.0f; + return; + } + } +} + +void EnBombal_UpdateEffects(EnBombal* this, PlayState* play) { + s32 i; + EnBombalEffect* sPtr = this->effects; + + for (i = 0; i < ARRAY_COUNT(this->effects); i++, sPtr++) { + if (sPtr->isEnabled) { + sPtr->pos.x += sPtr->velocity.x; + sPtr->pos.y += sPtr->velocity.y; + sPtr->pos.z += sPtr->velocity.z; + sPtr->velocity.x += sPtr->accel.x; + sPtr->velocity.y += sPtr->accel.y; + sPtr->velocity.z += sPtr->accel.z; + + if (sPtr->alphaFadeDelay != 0) { + sPtr->alphaFadeDelay--; + } else { + sPtr->alpha -= 10; + if (sPtr->alpha < 10) { + sPtr->isEnabled = 0; + } + } + } + } +} + +void EnBombal_DrawEffects(EnBombal* this, PlayState* play) { + s16 i; + GraphicsContext* gfxCtx = play->state.gfxCtx; + EnBombalEffect* sPtr = this->effects; + + OPEN_DISPS(gfxCtx); + + func_8012C28C(gfxCtx); + func_8012C2DC(play->state.gfxCtx); + + for (i = 0; i < ARRAY_COUNT(this->effects); i++, sPtr++) { + if (sPtr->isEnabled != 0) { + Matrix_Translate(sPtr->pos.x, sPtr->pos.y, sPtr->pos.z, MTXMODE_NEW); + Matrix_Scale(sPtr->scale, sPtr->scale, sPtr->scale, MTXMODE_APPLY); + + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x14); + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(&gSun1Tex)); + + gSPDisplayList(POLY_XLU_DISP++, &gSunSparkleMaterialDL); + + gDPPipeSync(POLY_XLU_DISP++); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 250, 180, 255, sPtr->alpha); + + Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZF(DEGF_TO_RADF(play->state.frames * 20.0f), MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, &gSunSparkleModelDL); + } + } + CLOSE_DISPS(gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Bombal/z_en_bombal.h b/src/overlays/actors/ovl_En_Bombal/z_en_bombal.h index 5731208a40..a678fe1d8c 100644 --- a/src/overlays/actors/ovl_En_Bombal/z_en_bombal.h +++ b/src/overlays/actors/ovl_En_Bombal/z_en_bombal.h @@ -7,15 +7,27 @@ struct EnBombal; typedef void (*EnBombalActionFunc)(struct EnBombal*, PlayState*); +typedef struct EnBombalEffect { + /* 0x00 */ u8 isEnabled; + /* 0x04 */ Vec3f pos; + /* 0x10 */ UNK_TYPE4 unk10; + /* 0x14 */ s16 alpha; + /* 0x16 */ s16 alphaFadeDelay; + /* 0x18 */ Vec3f velocity; + /* 0x24 */ Vec3f accel; + /* 0x30 */ f32 scale; +} EnBombalEffect; + typedef struct EnBombal { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnBombalActionFunc actionFunc; - /* 0x0148 */ char unk148[0x4]; - /* 0x014C */ s16 unk_14C; - /* 0x0150 */ f32 unk_150; - /* 0x0154 */ char unk154[0x150]; - /* 0x02A4 */ Vec3f unk_2A4; - /* 0x02B0 */ char unk2B0[0x2794]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnBombalActionFunc actionFunc; + /* 0x148 */ s16 timer; + /* 0x14A */ s16 isPopped; + /* 0x14C */ s16 cutscene; + /* 0x150 */ f32 scale; + /* 0x154 */ f32 oscillationAngle; + /* 0x158 */ ColliderCylinder collider; + /* 0x1A4 */ EnBombalEffect effects[200]; } EnBombal; // size = 0x2A44 extern const ActorInit En_Bombal_InitVars; 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 6c5a6f235f..48b953ffed 100644 --- a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c +++ b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c @@ -39,6 +39,17 @@ void func_80C00168(EnBomjima* this, PlayState* play); void func_80C00234(EnBomjima* this); void func_80C00284(EnBomjima* this, PlayState* play); +typedef enum EN_BOMJIMA_ACTION { + /* 0 */ EN_BOMJIMA_ACTION_0, + /* 1 */ EN_BOMJIMA_ACTION_1, + /* 2 */ EN_BOMJIMA_ACTION_2, + /* 3 */ EN_BOMJIMA_ACTION_3, + /* 4 */ EN_BOMJIMA_ACTION_4, + /* 5 */ EN_BOMJIMA_ACTION_5, + /* 6 */ EN_BOMJIMA_ACTION_6, + /* 7 */ EN_BOMJIMA_ACTION_7, +} EN_BOMJIMA_ACTION; + static s32 D_80C009F0 = 0; static s32 D_80C009F4 = 0; @@ -129,7 +140,7 @@ void EnBomjima_Init(Actor* thisx, PlayState* play) { while (cs != -1) { // clang-format off - this->unk_2D4[i] = cs; cs = ActorCutscene_GetAdditionalCutscene(cs); + this->cutscenes[i] = cs; cs = ActorCutscene_GetAdditionalCutscene(cs); // clang-format on i++; } @@ -197,31 +208,31 @@ void func_80BFE32C(EnBomjima* this, PlayState* play, s32 arg2) { } } -void func_80BFE494(EnBomjima* this, s32 arg1, f32 arg2) { - this->unk_2EC = arg1; - this->unk_2CC = Animation_GetLastFrame(sAnimations[arg1]); - Animation_Change(&this->skelAnime, sAnimations[this->unk_2EC], arg2, 0.0f, this->unk_2CC, D_80C00AE4[this->unk_2EC], - -4.0f); +void func_80BFE494(EnBomjima* this, s32 animIndex, f32 playSpeed) { + this->animIndex = animIndex; + this->animLastFrame = Animation_GetLastFrame(sAnimations[animIndex]); + Animation_Change(&this->skelAnime, sAnimations[this->animIndex], playSpeed, 0.0f, this->animLastFrame, + D_80C00AE4[this->animIndex], -4.0f); } void func_80BFE524(EnBomjima* this) { - if ((this->unk_2EC == 5) && + if ((this->animIndex == 5) && (Animation_OnFrame(&this->skelAnime, 9.0f) || Animation_OnFrame(&this->skelAnime, 10.0f) || Animation_OnFrame(&this->skelAnime, 17.0f) || Animation_OnFrame(&this->skelAnime, 18.0f))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_WALK); } - if ((this->unk_2EC == 18) && + if ((this->animIndex == 18) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 2.0f) || Animation_OnFrame(&this->skelAnime, 4.0f) || Animation_OnFrame(&this->skelAnime, 6.0f))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_WALK); } - if ((this->unk_2EC == 15) && Animation_OnFrame(&this->skelAnime, 15.0f)) { + if ((this->animIndex == 15) && Animation_OnFrame(&this->skelAnime, 15.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_LAND); } - if ((this->unk_2EC == 6) && Animation_OnFrame(&this->skelAnime, 8.0f)) { + if ((this->animIndex == 6) && Animation_OnFrame(&this->skelAnime, 8.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_LAND); } } @@ -326,10 +337,11 @@ void func_80BFEA94(EnBomjima* this, PlayState* play) { continue; } - this->unk_2F0 = (EnBombal*)actor; + this->bombal = (EnBombal*)actor; Math_Vec3f_Copy(&this->unk_2B0, &actor->world.pos); - if (this->unk_2F4 == 0) { - this->unk_2F4 = this->unk_2F0->actor.cutscene; + + if (this->bombalCutscene == 0) { + this->bombalCutscene = this->bombal->actor.cutscene; } func_80BFEB1C(this); break; @@ -339,7 +351,7 @@ void func_80BFEA94(EnBomjima* this, PlayState* play) { void func_80BFEB1C(EnBomjima* this) { func_80BFE494(this, 1, 1.0f); func_80BFE65C(this); - this->unk_2A0 = 0; + this->action = EN_BOMJIMA_ACTION_0; this->actionFunc = func_80BFEB64; } @@ -381,7 +393,7 @@ void func_80BFEB64(EnBomjima* this, PlayState* play) { func_800B8614(&this->actor, play, 70.0f); } - if ((this->unk_2F0->actor.update == NULL) || (this->unk_2F0->actor.colChkInfo.health == 0)) { + if ((this->bombal->actor.update == NULL) || (this->bombal->actor.colChkInfo.health == 0)) { func_80BFEFF0(this); return; } @@ -394,14 +406,14 @@ void func_80BFEB64(EnBomjima* this, PlayState* play) { break; case 1: - this->unk_2DC = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_2F0->actor.world.pos); + this->unk_2DC = Math_Vec3f_Yaw(&this->actor.world.pos, &this->bombal->actor.world.pos); if (Animation_OnFrame(&this->skelAnime, 19.0f)) { this->unk_2C0 = 5; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_SHOT_BREATH); } if (this->unk_2C0 == 1) { - s16 sp3E = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_2F0->actor.world.pos); + s16 sp3E = Math_Vec3f_Yaw(&this->actor.world.pos, &this->bombal->actor.world.pos); if (Rand_ZeroOne() < 0.5f) { sp3E += 0x4000; @@ -409,9 +421,9 @@ void func_80BFEB64(EnBomjima* this, PlayState* play) { sp3E += 0xC000; } - sp40.x = (Math_SinS(sp3E) * (Rand_ZeroFloat(20.0f) + 40.0f)) + this->unk_2F0->actor.world.pos.x; - sp40.y = this->unk_2F0->actor.world.pos.y - randPlusMinusPoint5Scaled(40.0f); - sp40.z = (Math_CosS(sp3E) * (Rand_ZeroFloat(20.0f) + 40.0f)) + this->unk_2F0->actor.world.pos.z; + sp40.x = (Math_SinS(sp3E) * (Rand_ZeroFloat(20.0f) + 40.0f)) + this->bombal->actor.world.pos.x; + sp40.y = this->bombal->actor.world.pos.y - randPlusMinusPoint5Scaled(40.0f); + sp40.z = (Math_CosS(sp3E) * (Rand_ZeroFloat(20.0f) + 40.0f)) + this->bombal->actor.world.pos.z; SoundSource_PlaySfxAtFixedWorldPos(play, &sp40, 50, NA_SE_EV_BOMBERS_SHOT_EXPLOSUIN); EffectSsHitmark_SpawnFixedScale(play, 0, &sp40); @@ -443,10 +455,10 @@ void func_80BFEB64(EnBomjima* this, PlayState* play) { } void func_80BFEFF0(EnBomjima* this) { - this->unk_2F0 = NULL; + this->bombal = NULL; func_80BFE494(this, 19, 1.0f); func_80BFE65C(this); - this->unk_2A0 = 1; + this->action = EN_BOMJIMA_ACTION_1; this->actionFunc = func_80BFF03C; } @@ -455,25 +467,25 @@ void func_80BFF03C(EnBomjima* this, PlayState* play) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->unk_2D4[0]); - } else if (!ActorCutscene_GetCanPlayNext(this->unk_2D4[0])) { - ActorCutscene_SetIntentToPlay(this->unk_2D4[0]); + ActorCutscene_SetIntentToPlay(this->cutscenes[0]); + } else if (!ActorCutscene_GetCanPlayNext(this->cutscenes[0])) { + ActorCutscene_SetIntentToPlay(this->cutscenes[0]); } else { player->stateFlags1 &= ~0x20; gSaveContext.save.weekEventReg[83] &= (u8)~4; this->actor.world.rot.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)); this->unk_2DC = Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)); - ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D4[0], &this->actor); + ActorCutscene_StartAndSetUnkLinkFields(this->cutscenes[0], &this->actor); func_80BFF120(this); } } void func_80BFF120(EnBomjima* this) { func_80BFE65C(this); - this->unk_2C4 = 30; + this->cutsceneTimer = 30; func_80BFE494(this, 6, 1.0f); - this->unk_2DE = 0; - this->unk_2A0 = 2; + this->cutsceneEnded = false; + this->action = EN_BOMJIMA_ACTION_2; this->actionFunc = func_80BFF174; } @@ -481,9 +493,9 @@ void func_80BFF174(EnBomjima* this, PlayState* play) { f32 sp2C = this->skelAnime.curFrame; Player* player = GET_PLAYER(play); - if (this->unk_2C4 == 1) { - ActorCutscene_Stop(this->unk_2D4[0]); - this->unk_2DE = 1; + if (this->cutsceneTimer == 1) { + ActorCutscene_Stop(this->cutscenes[0]); + this->cutsceneEnded = true; } if (Text_GetFaceReaction(play, 0x11) != 0) { @@ -498,9 +510,9 @@ void func_80BFF174(EnBomjima* this, PlayState* play) { Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2DC, 1, 5000, 0); - if ((this->unk_2CC <= sp2C) && (this->unk_2BC < 5)) { + if ((this->animLastFrame <= sp2C) && (this->unk_2BC < 5)) { this->unk_2BC++; - if (this->unk_2EC != 19) { + if (this->animIndex != 19) { func_80BFE494(this, 19, 1.0f); } } @@ -541,7 +553,7 @@ void func_80BFF174(EnBomjima* this, PlayState* play) { func_80BFE32C(this, play, 1); } - if (this->unk_2DE != 0) { + if (this->cutsceneEnded != false) { if (this->unk_2BC >= 5) { func_80BFE67C(this, play); } @@ -551,20 +563,20 @@ void func_80BFF174(EnBomjima* this, PlayState* play) { void func_80BFF3F0(EnBomjima* this) { func_80BFE494(this, 15, 1.0f); - this->unk_2A0 = 3; + this->action = EN_BOMJIMA_ACTION_3; this->actionFunc = func_80BFF430; } void func_80BFF430(EnBomjima* this, PlayState* play) { f32 curFrame = this->skelAnime.curFrame; - if (this->unk_2CC <= curFrame) { + if (this->animLastFrame <= curFrame) { EnBombal* bombal = (EnBombal*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOMBAL, this->unk_2B0.x, this->unk_2B0.y, this->unk_2B0.z, 0, 0, 0, 0); if (bombal != NULL) { - bombal->unk_150 = 0.0f; - bombal->unk_14C = this->unk_2F4; + bombal->scale = 0.0f; + bombal->cutscene = this->bombalCutscene; Actor_ChangeFocus(&this->actor, play, &bombal->actor); gSaveContext.save.weekEventReg[83] &= (u8)~4; func_80BFE65C(this); @@ -576,7 +588,7 @@ void func_80BFF430(EnBomjima* this, PlayState* play) { void func_80BFF4F4(EnBomjima* this) { func_80BFE65C(this); - this->unk_2A0 = 4; + this->action = EN_BOMJIMA_ACTION_4; this->actionFunc = func_80BFF52C; } @@ -599,7 +611,7 @@ void func_80BFF52C(EnBomjima* this, PlayState* play) { func_80151938(play, this->actor.textId); play_sound(NA_SE_SY_FOUND); func_80BFE494(this, 15, 1.0f); - this->unk_2A0 = 5; + this->action = EN_BOMJIMA_ACTION_5; this->actionFunc = func_80BFF6CC; } else { Player* player = GET_PLAYER(play); @@ -623,7 +635,7 @@ void func_80BFF52C(EnBomjima* this, PlayState* play) { void func_80BFF6CC(EnBomjima* this, PlayState* play) { f32 curFrame = this->skelAnime.curFrame; - if (this->unk_2CC <= curFrame) { + if (this->animLastFrame <= curFrame) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { func_801477B4(play); func_80BFE494(this, 1, 1.0f); @@ -635,7 +647,7 @@ void func_80BFF6CC(EnBomjima* this, PlayState* play) { void func_80BFF754(EnBomjima* this, PlayState* play) { Player* player = GET_PLAYER(play); Vec3f spA0; - EnBombal* temp_s3; + EnBomjima* bomjima; s32 i; f32 x; f32 y; @@ -643,12 +655,12 @@ void func_80BFF754(EnBomjima* this, PlayState* play) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->unk_2D4[1]); + ActorCutscene_SetIntentToPlay(this->cutscenes[1]); return; } - if (!ActorCutscene_GetCanPlayNext(this->unk_2D4[1])) { - ActorCutscene_SetIntentToPlay(this->unk_2D4[1]); + if (!ActorCutscene_GetCanPlayNext(this->cutscenes[1])) { + ActorCutscene_SetIntentToPlay(this->cutscenes[1]); return; } @@ -663,9 +675,9 @@ void func_80BFF754(EnBomjima* this, PlayState* play) { spA0.y += y * (2.0f + (i * 0.2f)); spA0.z += z * (2.0f + (i * 0.2f)); - temp_s3 = (EnBombal*)Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_BOMJIMA, spA0.x, spA0.y, - spA0.z, 0, 0, 0, i + 32); - if (temp_s3 != NULL) { + bomjima = (EnBomjima*)Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_BOMJIMA, spA0.x, spA0.y, + spA0.z, 0, 0, 0, i + 32); + if (bomjima != NULL) { s32 index = (i * 2) - 2; Math_Vec3f_Copy(&spA0, &this->actor.world.pos); @@ -673,12 +685,12 @@ void func_80BFF754(EnBomjima* this, PlayState* play) { spA0.x += Math_SinS(D_80C00AF8[(i * 2) - 2] + this->actor.world.rot.y) * D_80C00AF8[index + 1]; spA0.z += Math_CosS(D_80C00AF8[index] + this->actor.world.rot.y) * D_80C00AF8[index + 1]; - Math_Vec3f_Copy(&temp_s3->unk_2A4, &spA0); + Math_Vec3f_Copy(&bomjima->unk_2A4, &spA0); } } D_80C009F0 = 0; - ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D4[1], &this->actor); + ActorCutscene_StartAndSetUnkLinkFields(this->cutscenes[1], &this->actor); this->actionFunc = func_80BFF9B0; } @@ -741,7 +753,7 @@ void func_80BFFB40(EnBomjima* this, PlayState* play) { void func_80BFFBC4(EnBomjima* this, PlayState* play) { f32 curFrame = this->skelAnime.curFrame; - if ((this->unk_2EC != 1) && (this->unk_2CC <= curFrame)) { + if ((this->animIndex != 1) && (this->animLastFrame <= curFrame)) { func_80BFE494(this, 1, 1.0f); } @@ -762,14 +774,14 @@ void func_80BFFBC4(EnBomjima* this, PlayState* play) { play->transitionTrigger = TRANS_TRIGGER_START; play->transitionType = TRANS_TYPE_86; gSaveContext.nextTransitionType = TRANS_TYPE_03; - ActorCutscene_Stop(this->unk_2D4[1]); + ActorCutscene_Stop(this->cutscenes[1]); } } void func_80BFFCFC(EnBomjima* this) { func_80BFE65C(this); func_80BFE494(this, 18, 1.0f); - this->unk_2A0 = 6; + this->action = EN_BOMJIMA_ACTION_6; this->actionFunc = func_80BFFD48; } @@ -825,22 +837,22 @@ void func_80BFFF54(EnBomjima* this, PlayState* play) { } if (this->unk_2E4 != 4) { - if ((this->unk_2EC != 0) && (this->unk_2CC <= curFrame)) { + if ((this->animIndex != 0) && (this->animLastFrame <= curFrame)) { D_80C009F0++; func_80BFE494(this, 0, 1.0f); } - } else if ((this->unk_2EC != 8) && (this->unk_2CC <= curFrame)) { + } else if ((this->animIndex != 8) && (this->animLastFrame <= curFrame)) { func_80BFE494(this, 8, 1.0f); D_80C009F4 = 1; } - if (this->unk_2EC == 8) { + if (this->animIndex == 8) { if ((D_80C009F4 == 1) && Animation_OnFrame(&this->skelAnime, 7.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HUMAN_BOUND); D_80C009F4 = 2; } - if ((this->unk_2CC <= curFrame) && (this->unk_2C0 == 0)) { + if ((this->animLastFrame <= curFrame) && (this->unk_2C0 == 0)) { this->unk_2C0 = 10; } @@ -853,7 +865,7 @@ void func_80BFFF54(EnBomjima* this, PlayState* play) { void func_80C0011C(EnBomjima* this) { func_80BFE65C(this); func_80BFE494(this, 0, 1.0f); - this->unk_2A0 = 7; + this->action = EN_BOMJIMA_ACTION_7; this->actionFunc = func_80C00168; } @@ -894,8 +906,9 @@ void func_80C00284(EnBomjima* this, PlayState* play) { f32 sp28 = this->skelAnime.curFrame; Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2DC, 1, 5000, 0); - if (((this->unk_2A0 == 0) || (this->unk_2C8 == 10) || (this->unk_2C8 == 11) || (this->unk_2CA == 1)) && - (this->unk_2CC <= sp28)) { + if (((this->action == EN_BOMJIMA_ACTION_0) || (this->unk_2C8 == 10) || (this->unk_2C8 == 11) || + (this->unk_2CA == 1)) && + (this->animLastFrame <= sp28)) { if (!(this->unk_2BC & 1)) { func_80BFE494(this, 3, 1.0f); } else { @@ -919,14 +932,15 @@ void func_80C00284(EnBomjima* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { this->collider.dim.radius = 10; this->collider.dim.height = 30; - if ((this->unk_2A0 == 4) || (this->unk_2CA == 1) || ((this->unk_2CA == 3) && (this->unk_2C8 >= 2))) { + if ((this->action == EN_BOMJIMA_ACTION_4) || (this->unk_2CA == 1) || + ((this->unk_2CA == 3) && (this->unk_2C8 >= 2))) { this->unk_28E = 0; if (player->stateFlags1 & 0x20) { player->stateFlags1 &= ~0x20; } - if ((this->unk_2F0 == 0) || (this->unk_2F0->actor.update == NULL) || - (this->unk_2F0->actor.colChkInfo.health <= 0)) { + if ((this->bombal == 0) || (this->bombal->actor.update == NULL) || + (this->bombal->actor.colChkInfo.health <= 0)) { func_80BFF3F0(this); } else { func_80BFE65C(this); @@ -941,7 +955,7 @@ void func_80C00284(EnBomjima* this, PlayState* play) { switch (this->unk_2CA) { case 0: this->unk_28E = 0; - if (this->unk_2A0 == 7) { + if (this->action == EN_BOMJIMA_ACTION_7) { func_80C0011C(this); } else { func_80BFEB1C(this); @@ -953,7 +967,7 @@ void func_80C00284(EnBomjima* this, PlayState* play) { func_80BFE65C(this); this->unk_28E = 0; func_80BFE494(this, 1, 1.0f); - this->unk_2A0 = 2; + this->action = EN_BOMJIMA_ACTION_2; this->actionFunc = func_80BFF174; return; } @@ -1008,8 +1022,8 @@ void EnBomjima_Update(Actor* thisx, PlayState* play) { this->unk_2C6--; } - if (this->unk_2C4 != 0) { - this->unk_2C4--; + if (this->cutsceneTimer != 0) { + this->cutsceneTimer--; } SkelAnime_Update(&this->skelAnime); diff --git a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.h b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.h index b247e03ea0..046e8813c8 100644 --- a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.h +++ b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.h @@ -26,7 +26,7 @@ typedef struct EnBomjima { /* 0x296 */ UNK_TYPE1 unk296[4]; /* 0x29A */ s16 unk_29A; /* 0x29C */ UNK_TYPE1 unk29C[4]; - /* 0x2A0 */ s16 unk_2A0; + /* 0x2A0 */ s16 action; /* 0x2A2 */ s16 unk_2A2; /* 0x2A4 */ Vec3f unk_2A4; /* 0x2B0 */ Vec3f unk_2B0; @@ -34,25 +34,25 @@ typedef struct EnBomjima { /* 0x2BE */ s16 unk_2BE; /* 0x2C0 */ s16 unk_2C0; /* 0x2C2 */ s16 unk_2C2; - /* 0x2C4 */ s16 unk_2C4; + /* 0x2C4 */ s16 cutsceneTimer; /* 0x2C6 */ s16 unk_2C6; /* 0x2C8 */ s16 unk_2C8; /* 0x2CA */ s16 unk_2CA; - /* 0x2CC */ f32 unk_2CC; + /* 0x2CC */ f32 animLastFrame; /* 0x2D0 */ f32 unk_2D0; - /* 0x2D4 */ s16 unk_2D4[2]; + /* 0x2D4 */ s16 cutscenes[2]; /* 0x2D8 */ UNK_TYPE1 unk2D8[4]; // maybe a part of the above? /* 0x2DC */ s16 unk_2DC; - /* 0x2DE */ s16 unk_2DE; + /* 0x2DE */ s16 cutsceneEnded; /* 0x2E0 */ s16 unk_2E0; /* 0x2E2 */ s16 unk_2E2; /* 0x2E4 */ s16 unk_2E4; /* 0x2E6 */ s16 unk_2E6; /* 0x2E8 */ s16 unk_2E8; /* 0x2EA */ s16 unk_2EA; - /* 0x2EC */ s32 unk_2EC; - /* 0x2F0 */ EnBombal* unk_2F0; - /* 0x2F4 */ s16 unk_2F4; + /* 0x2EC */ s32 animIndex; + /* 0x2F0 */ EnBombal* bombal; + /* 0x2F4 */ s16 bombalCutscene; /* 0x2F8 */ ColliderCylinder collider; } EnBomjima; // size = 0x344 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 b7c698376a..506f147903 100644 --- a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c +++ b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c @@ -208,8 +208,8 @@ void EnEncount2_Update(Actor* thisx, PlayState* play) { void EnEncount2_Draw(Actor* thisx, PlayState* play) { EnEncount2* this = THIS; if (this->isPopped != true) { - Gfx_DrawDListOpa(play, object_fusen_DL_000A00); - Gfx_DrawDListOpa(play, object_fusen_DL_000D78); + Gfx_DrawDListOpa(play, gMajoraBalloonDL); + Gfx_DrawDListOpa(play, gMajoraBalloonKnotDL); } EnEncount2_DrawEffects(this, play); } @@ -223,7 +223,7 @@ void EnEncount2_InitEffects(EnEncount2* this, Vec3f* pos, s16 fadeDelay) { sPtr->isEnabled = true; sPtr->pos = *pos; sPtr->alphaFadeDelay = fadeDelay; - sPtr->alpha = 0xFF; + sPtr->alpha = 255; sPtr->accel.x = (Rand_ZeroOne() - 0.5f) * 10.0f; sPtr->accel.y = (Rand_ZeroOne() - 0.5f) * 10.0f; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 20fa0265c2..3431e755a9 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -16552,9 +16552,9 @@ 0x80C05DE8:("func_80C05DE8",), 0x80C05E7C:("EnBombal_Update",), 0x80C05F30:("EnBombal_Draw",), - 0x80C05F90:("func_80C05F90",), - 0x80C060B8:("func_80C060B8",), - 0x80C06208:("func_80C06208",), + 0x80C05F90:("EnBombal_InitEffects",), + 0x80C060B8:("EnBombal_UpdateEffects",), + 0x80C06208:("EnBombal_DrawEffects",), 0x80C06510:("ObjMoonStone_Init",), 0x80C0661C:("ObjMoonStone_Destroy",), 0x80C0662C:("func_80C0662C",), From 4833c08364014ac93727c907f0f149d5426fad30 Mon Sep 17 00:00:00 2001 From: SonicDcer <96613413+sonicdcer@users.noreply.github.com> Date: Tue, 4 Oct 2022 01:03:53 -0300 Subject: [PATCH 22/25] ovl_Oceff_Storm OK (#1010) * all functions matching * all functions matching * all functions matching (for real this time) * data extracted and imported * ovl_Oceff_Storm OK * reloc * pr review * texture name * renamings * renamings * Magic_Reset * pr review * gSPTextureRectangle * pr review --- assets/xml/overlays/ovl_Oceff_Storm.xml | 12 ++ spec | 3 +- .../actors/ovl_Oceff_Storm/z_oceff_storm.c | 198 ++++++++++++++++-- .../actors/ovl_Oceff_Storm/z_oceff_storm.h | 10 +- tools/disasm/functions.txt | 4 +- 5 files changed, 208 insertions(+), 19 deletions(-) create mode 100644 assets/xml/overlays/ovl_Oceff_Storm.xml diff --git a/assets/xml/overlays/ovl_Oceff_Storm.xml b/assets/xml/overlays/ovl_Oceff_Storm.xml new file mode 100644 index 0000000000..6b8dc02289 --- /dev/null +++ b/assets/xml/overlays/ovl_Oceff_Storm.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/spec b/spec index 42bbff1820..207b70da12 100644 --- a/spec +++ b/spec @@ -1938,8 +1938,7 @@ beginseg name "ovl_Oceff_Storm" compress include "build/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.o" - include "build/data/ovl_Oceff_Storm/ovl_Oceff_Storm.data.o" - include "build/data/ovl_Oceff_Storm/ovl_Oceff_Storm.reloc.o" + include "build/src/overlays/actors/ovl_Oceff_Storm/ovl_Oceff_Storm_reloc.o" endseg beginseg 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 68ee9d27f2..3a4faceea2 100644 --- a/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c +++ b/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c @@ -15,12 +15,10 @@ void OceffStorm_Destroy(Actor* thisx, PlayState* play); void OceffStorm_Update(Actor* thisx, PlayState* play); void OceffStorm_Draw(Actor* thisx, PlayState* play); -void func_80981928(OceffStorm* this, PlayState* play); +void OceffStorm_DefaultAction(OceffStorm* this, PlayState* play); void func_80981B48(OceffStorm* this, PlayState* play); +void OceffStorm_Draw2(Actor* thisx, PlayState* play); -void OceffStorm_SetupAction(OceffStorm* this, OceffStormActionFunc actionFunc); - -#if 0 const ActorInit Oceff_Storm_InitVars = { ACTOR_OCEFF_STORM, ACTORCAT_ITEMACTION, @@ -33,22 +31,194 @@ const ActorInit Oceff_Storm_InitVars = { (ActorFunc)OceffStorm_Draw, }; -#endif +void OceffStorm_SetupAction(OceffStorm* this, OceffStormActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Storm/OceffStorm_SetupAction.s") +s32 func_8098176C(PlayState* play) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Storm/func_8098176C.s") + switch (play->sceneId) { + case SCENE_13HUBUKINOMITI: + case SCENE_11GORONNOSATO: + case SCENE_10YUKIYAMANOMURA: + case SCENE_14YUKIDAMANOMITI: + case SCENE_12HAKUGINMAE: + case SCENE_17SETUGEN: + case SCENE_GORONRACE: + if (gSaveContext.sceneLayer == 0) { + ret = true; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Storm/OceffStorm_Init.s") + case SCENE_10YUKIYAMANOMURA2: + if (gSaveContext.sceneLayer == 1) { + ret = true; + } + break; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Storm/OceffStorm_Destroy.s") +void OceffStorm_Init(Actor* thisx, PlayState* play) { + s32 pad[2]; + Player* player = GET_PLAYER(play); + OceffStorm* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Storm/func_80981928.s") + OceffStorm_SetupAction(this, OceffStorm_DefaultAction); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Storm/func_80981B48.s") + this->posYOffAdd = 0; + this->counter = 0; + this->primColorAlpha = 0; + this->vtxAlpha = 0; + this->actor.scale.y = 0.0f; + this->actor.scale.z = 0.0f; + this->actor.scale.x = 0.0f; + this->posYOff = this->posYOffAdd; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Storm/OceffStorm_Update.s") + if (this->actor.params == OCEFF_STORM_ACTION_PARAM_1) { + OceffStorm_SetupAction(this, func_80981B48); + this->actor.draw = OceffStorm_Draw2; + } else { + this->actor.world.pos.y = player->actor.world.pos.y; + this->actor.world.pos.x = player->bodyPartsPos[0].x; + this->actor.world.pos.z = player->bodyPartsPos[0].z; + gSaveContext.jinxTimer = 0; + if ((play->interfaceCtx.restrictions.songOfStorms == 0) && !func_8098176C(play)) { + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_OKARINA_EFFECT, this->actor.world.pos.x, + this->actor.world.pos.y - 30.0f, this->actor.world.pos.z, 0, 0, 0, 1); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Storm/func_80981BB8.s") +void OceffStorm_Destroy(Actor* thisx, PlayState* play) { + OceffStorm* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Storm/OceffStorm_Draw.s") + Magic_Reset(play); +} + +void OceffStorm_DefaultAction(OceffStorm* this, PlayState* play) { + f32 cylinderScale; + + switch (gSaveContext.save.playerForm) { + default: + cylinderScale = 1.0f; + break; + + case PLAYER_FORM_DEKU: + cylinderScale = 1.3f; + break; + + case PLAYER_FORM_ZORA: + cylinderScale = 1.2f; + break; + + case PLAYER_FORM_GORON: + cylinderScale = 2.0f; + break; + } + + if (this->counter < 10) { + this->primColorAlpha = (s8)(this->counter * 10.0f); + } else if (this->counter > 60) { + this->primColorAlpha = (s8)((70 - this->counter) * 10.0f); + } else { + this->primColorAlpha = 100; + } + + if ((this->counter < 10) || (this->counter >= 60)) { + this->vtxAlpha = 0; + } else if (this->counter <= 40) { + if (this->vtxAlpha <= 200) { + this->vtxAlpha += 10; + } + this->actor.scale.x = this->actor.scale.z = 0.4f * cylinderScale; + this->actor.scale.y = 0.3f; + } else if (this->counter > 40) { + this->vtxAlpha = (60 - this->counter) * 10; + } else { + this->actor.scale.x = this->actor.scale.z = 0.4f * cylinderScale; + this->vtxAlpha = -1; + } + + if (this->counter > 40) { + this->actor.world.pos.y += this->posYOff * 0.01f; + this->posYOff += this->posYOffAdd; + this->posYOffAdd += 10; + } + + if (this->counter < 70) { + this->counter++; + } else { + Actor_MarkForDeath(&this->actor); + } +} + +void func_80981B48(OceffStorm* this, PlayState* play) { + if (this->primColorAlpha < 100) { + this->primColorAlpha += 5; + } + //! @bug Actor_Kill is never called so the actor will stay alive forever +} + +void OceffStorm_Update(Actor* thisx, PlayState* play) { + OceffStorm* this = THIS; + + this->actor.shape.rot.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)); + this->actionFunc(this, play); +} + +#include "assets/overlays/ovl_Oceff_Storm/ovl_Oceff_Storm.c" + +void OceffStorm_Draw2(Actor* thisx, PlayState* play) { + s32 scroll = play->state.frames & 0xFFF; + OceffStorm* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + gDPPipeSync(POLY_XLU_DISP++); + + POLY_XLU_DISP = func_8012C3A4(POLY_XLU_DISP); + + gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_NOISE); + gDPSetColorDither(POLY_XLU_DISP++, G_CD_NOISE); + + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 200, 200, 150, this->primColorAlpha); + + gSPDisplayList(POLY_XLU_DISP++, &sSongOfStormsMaterialDL); + gSPDisplayList(POLY_XLU_DISP++, Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, scroll * 8, scroll * 4, 64, + 64, 1, scroll * 4, scroll * 4, 64, 64)); + gSPTextureRectangle(POLY_XLU_DISP++, 0, 0, SCREEN_WIDTH << 2, SCREEN_HEIGHT << 2, G_TX_RENDERTILE, 0, 0, + (s32)(0.13671875 * (1 << 10)), (s32)(-0.13671875 * (1 << 10))); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void OceffStorm_Draw(Actor* thisx, PlayState* play) { + u32 scroll = play->state.frames & 0xFFF; + OceffStorm* this = (OceffStorm*)thisx; + Vtx* vtxPtr = sSongOfStormsCylinderVtx; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C2DC(play->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 200, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 150, 150, 0, 128); + gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_NOISE); + gDPSetColorDither(POLY_XLU_DISP++, G_CD_NOISE); + + vtxPtr[0].v.cn[3] = vtxPtr[6].v.cn[3] = vtxPtr[16].v.cn[3] = vtxPtr[25].v.cn[3] = this->vtxAlpha >> 1; + vtxPtr[10].v.cn[3] = vtxPtr[22].v.cn[3] = this->vtxAlpha; + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, &sSongOfStormsCylinderMaterialDL); + gSPDisplayList(POLY_XLU_DISP++, Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, scroll * 4, (0 - scroll) * 8, + 32, 32, 1, scroll * 8, (0 - scroll) * 12, 32, 32)); + gSPDisplayList(POLY_XLU_DISP++, &sSongOfStormsCylinderModelDL); + + CLOSE_DISPS(play->state.gfxCtx); + + OceffStorm_Draw2(&this->actor, play); +} diff --git a/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.h b/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.h index 460ede8447..20dd1ffcb3 100644 --- a/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.h +++ b/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.h @@ -9,10 +9,18 @@ typedef void (*OceffStormActionFunc)(struct OceffStorm*, PlayState*); typedef struct OceffStorm { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x8]; + /* 0x144 */ u16 counter; + /* 0x146 */ u8 primColorAlpha; + /* 0x147 */ u8 vtxAlpha; + /* 0x148 */ s16 posYOff; + /* 0x14A */ s16 posYOffAdd; /* 0x14C */ OceffStormActionFunc actionFunc; } OceffStorm; // size = 0x150 extern const ActorInit Oceff_Storm_InitVars; +typedef enum { + /* 1 */ OCEFF_STORM_ACTION_PARAM_1 = 1 +} OceffStormActionParams; + #endif // Z_OCEFF_STORM_H diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 3431e755a9..62e5b7bdc3 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -8245,10 +8245,10 @@ 0x8098176C:("func_8098176C",), 0x809817E4:("OceffStorm_Init",), 0x80981904:("OceffStorm_Destroy",), - 0x80981928:("func_80981928",), + 0x80981928:("OceffStorm_DefaultAction",), 0x80981B48:("func_80981B48",), 0x80981B68:("OceffStorm_Update",), - 0x80981BB8:("func_80981BB8",), + 0x80981BB8:("OceffStorm_Draw2",), 0x80981D68:("OceffStorm_Draw",), 0x80983520:("ObjDemo_Init",), 0x80983634:("func_80983634",), From 6c414889c9561837c5103c7d27c868f2b90cd142 Mon Sep 17 00:00:00 2001 From: Parker Burnett Date: Tue, 4 Oct 2022 05:55:20 -0700 Subject: [PATCH 23/25] Fbdemo_circle OK (#1024) * some progress, nasty draw func only thing to do * pushing for engineer * matching with no warnings * fixes * minor names * PR feedback * fixes for PR * docs * PR comments * fixing format and found bit shift --- include/functions.h | 19 ++--- include/variables.h | 4 +- include/z64transition.h | 25 ++++++- spec | 1 - src/code/z_actor.c | 3 +- src/code/z_fbdemo_circle.c | 143 ++++++++++++++++++++++++++++++++++--- 6 files changed, 172 insertions(+), 23 deletions(-) diff --git a/include/functions.h b/include/functions.h index 34384ab3f9..93b15c2c56 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2420,15 +2420,16 @@ void* TransitionFade_Init(void* param_1); // void TransitionFade_IsDone(void); // void TransitionFade_SetColor(void); // void TransitionFade_SetType(void); -// void TransitionCircle_Start(void); -// void TransitionCircle_Init(void); -// void TransitionCircle_Destroy(void); -// void TransitionCircle_Update(void); -// void TransitionCircle_SetColor(void); -// void TransitionCircle_SetType(void); -void func_80164C14(Gfx** arg0, TexturePtr* arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, f32 arg6); -// void TransitionCircle_Draw(void); -// void TransitionCircle_IsDone(void); +void TransitionCircle_Start(void* thisx); +void* TransitionCircle_Init(void* thisx); +void TransitionCircle_Destroy(void* thisx); +void TransitionCircle_Update(void* thisx); +void TransitionCircle_SetColor(void* thisx, u32 color); +void TransitionCircle_SetType(void* thisx, s32 type); +void TransitionCircle_LoadAndSetTexture(Gfx** gfxp, TexturePtr texture, s32 fmt, s32 arg3, s32 masks, s32 maskt, + f32 arg6); +void TransitionCircle_Draw(void* thisx, Gfx** gfxp); +s32 TransitionCircle_IsDone(void* thisx); // void func_801651B0(void); // void func_80165224(void); // void func_80165288(void); diff --git a/include/variables.h b/include/variables.h index a4914a4413..dfe8ae715b 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1472,7 +1472,7 @@ extern KaleidoMgrOverlay* gKaleidoMgrCurOvl; // extern UNK_TYPE1 D_801D0C80; // extern UNK_TYPE1 D_801D0CB0; extern const TransitionInit TransitionFade_InitVars; -// extern UNK_TYPE1 D_801D0D00; +extern Gfx D_801D0D00[]; extern const TransitionInit TransitionCircle_InitVars; extern s32 gDbgCamEnabled; // extern UNK_TYPE1 D_801D0D54; @@ -2703,7 +2703,7 @@ extern f32 D_801DE860; extern f32 D_801DE864; extern f32 D_801DE868; extern f32 D_801DE884; -extern TexturePtr gCircleTex; +extern TexturePtr gCircleTex[]; extern f32 D_801DF090; extern f32 D_801DF094; extern f32 D_801DF0A0; diff --git a/include/z64transition.h b/include/z64transition.h index 9630b4a3ff..3742291a61 100644 --- a/include/z64transition.h +++ b/include/z64transition.h @@ -3,6 +3,8 @@ #include "ultra64.h" +#define TC_SET_PARAMS (1 << 7) + typedef struct { /* 0x00 */ void* (*init)(void* transition); /* 0x04 */ void (*destroy)(void* transition); @@ -21,8 +23,29 @@ typedef struct { extern const TransitionInit TransitionFade_InitVars; + +typedef enum { + /* 0 */ TRANSITION_CIRCLE_IN, + /* 1 */ TRANSITION_CIRCLE_OUT, +} TransitionCircleDirection; + +#define FBDEMO_CIRCLE_GET_MASK_TYPE(type) (type & 1) + typedef struct { - /* 0x00 */ char unk_0[0x20]; + /* 0x00 */ Color_RGBA8_u32 color; + /* 0x04 */ f32 referenceRadius; // Reference for where to transition to + /* 0x08 */ f32 stepValue; // How fast the Transition is + /* 0x0C */ f32 startingRadius; // Radius value where transition will begin + /* 0x10 */ f32 targetRadius; // Final radius of transition circle + /* 0x14 */ u8 direction; // Direction the circle is transitioning ( In / Out ) + /* 0x15 */ u8 maskType; // Positive / Negative mask type. Value of 0 will create a black circle + /* 0x16 */ u8 isDone; // Signals when Transition is done updating + /* 0x17 */ UNK_TYPE1 pad_17; // struct padding + /* 0x18 */ TexturePtr texture; + /* 0x1C */ u8 masks; + /* 0x1D */ u8 maskt; + /* 0x1E */ s8 unk_1E; // Set to 4 and never used + /* 0x1F */ s8 unk_1F; // Set to 0 and never used } TransitionCircle; // size = 0x20 extern const TransitionInit TransitionCircle_InitVars; diff --git a/spec b/spec index 207b70da12..bcbcf66976 100644 --- a/spec +++ b/spec @@ -554,7 +554,6 @@ beginseg include "build/data/code/z_fbdemo.data.o" include "build/src/code/z_fbdemo_fade.o" include "build/src/code/z_fbdemo_circle.o" - include "build/data/code/z_fbdemo_circle.data.o" include "build/src/code/z_overlay.o" include "build/src/code/z_play.o" include "build/data/code/z_play.data.o" diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 389f7a0516..88ec6c07bf 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -2609,7 +2609,8 @@ s32 Actor_RecordUndrawnActor(PlayState* play, Actor* actor) { } void Actor_DrawLensOverlay(Gfx** gfxP, s32 lensMaskSize) { - func_80164C14(gfxP, &gCircleTex, 4, 0, 6, 6, ((LENS_MASK_ACTIVE_SIZE - lensMaskSize) * 0.003f) + 1.0f); + TransitionCircle_LoadAndSetTexture(gfxP, gCircleTex, 4, 0, 6, 6, + ((LENS_MASK_ACTIVE_SIZE - lensMaskSize) * 0.003f) + 1.0f); } #ifdef NON_EQUIVALENT diff --git a/src/code/z_fbdemo_circle.c b/src/code/z_fbdemo_circle.c index a822262ee0..9cbc308be1 100644 --- a/src/code/z_fbdemo_circle.c +++ b/src/code/z_fbdemo_circle.c @@ -1,19 +1,144 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_circle/TransitionCircle_Start.s") +Gfx D_801D0D00[] = { + gsDPPipeSync(), + gsDPSetOtherMode(G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE | + G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, + G_AC_THRESHOLD | G_ZS_PRIM | AA_EN | IM_RD | CVG_DST_FULL | ZMODE_OPA | CVG_X_ALPHA | FORCE_BL | + GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) | + GBL_c2(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1)), + gsDPSetPrimColor(0, 255, 0, 0, 0, 1), + gsDPSetBlendColor(0, 0, 0, 1), + gsSPEndDisplayList(), +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_circle/TransitionCircle_Init.s") +//! @bug: TransitionCircle_Update should take an additional argument `s32 updateRate` +const TransitionInit TransitionCircle_InitVars = { + TransitionCircle_Init, TransitionCircle_Destroy, (void*)TransitionCircle_Update, TransitionCircle_Draw, + TransitionCircle_Start, TransitionCircle_SetType, TransitionCircle_SetColor, NULL, + TransitionCircle_IsDone, +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_circle/TransitionCircle_Destroy.s") +void TransitionCircle_Start(void* thisx) { + TransitionCircle* this = (TransitionCircle*)thisx; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_circle/TransitionCircle_Update.s") + this->stepValue = 0.1f; + if (this->direction == TRANSITION_CIRCLE_IN) { + this->targetRadius = 0.0f; + this->startingRadius = 1.0f; + } else { + this->startingRadius = 0.0f; + this->targetRadius = 1.0f; + } + this->referenceRadius = this->startingRadius; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_circle/TransitionCircle_SetColor.s") +void* TransitionCircle_Init(void* thisx) { + TransitionCircle* this = (TransitionCircle*)thisx; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_circle/TransitionCircle_SetType.s") + bzero(this, sizeof(TransitionCircle)); + this->maskType = 1; + this->texture = gCircleTex; + this->masks = 6; + this->maskt = 6; + this->unk_1E = 4; + this->unk_1F = 0; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_circle/func_80164C14.s") + return this; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_circle/TransitionCircle_Draw.s") +void TransitionCircle_Destroy(void* thisx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_circle/TransitionCircle_IsDone.s") +void TransitionCircle_Update(void* thisx) { + TransitionCircle* this = (TransitionCircle*)thisx; + + this->isDone = Math_StepToF(&this->referenceRadius, this->targetRadius, this->stepValue); +} + +void TransitionCircle_SetColor(void* thisx, u32 color) { + TransitionCircle* this = (TransitionCircle*)thisx; + + this->color.rgba = color; +} + +void TransitionCircle_SetType(void* thisx, s32 type) { + TransitionCircle* this = (TransitionCircle*)thisx; + + if (type & TC_SET_PARAMS) { + this->maskType = FBDEMO_CIRCLE_GET_MASK_TYPE(type); + } else if (type == 1) { + this->direction = TRANSITION_CIRCLE_OUT; + } else { + this->direction = TRANSITION_CIRCLE_IN; + } +} + +void TransitionCircle_LoadAndSetTexture(Gfx** gfxp, TexturePtr texture, s32 fmt, s32 arg3, s32 masks, s32 maskt, + f32 arg6) { + Gfx* gfx = *gfxp; + s32 xh = D_801FBBCC; + s32 yh = D_801FBBCE; + s32 width = 1 << masks; + s32 height = 1 << maskt; + f32 s; + f32 t; + s32 dtdy; + s32 dsdx; + + gDPLoadTextureBlock_4b(gfx++, texture, fmt, width, height, 0, G_TX_MIRROR | G_TX_CLAMP, G_TX_MIRROR | G_TX_CLAMP, + masks, maskt, G_TX_NOLOD, G_TX_NOLOD); + gDPSetTileSize(gfx++, G_TX_RENDERTILE, ((SCREEN_WIDTH / 2) - width) << 2, ((SCREEN_HEIGHT / 2) - height) << 2, + ((SCREEN_WIDTH / 2) + (width - 1)) << 2, ((SCREEN_HEIGHT / 2) + (height - 1)) << 2); + + s = ((1.0f - (1.0f / arg6)) * (SCREEN_WIDTH / 2)) + 70.0f; + t = ((1.0f - (1.0f / arg6)) * (SCREEN_HEIGHT / 2)) + 50.0f; + + if (s < -1023.0f) { + s = -1023.0f; + } + if (t < -1023.0f) { + t = -1023.0f; + } + + if ((s <= -1023.0f) || (t <= -1023.0f)) { + dsdx = 0; + dtdy = 0; + } else { + dsdx = ((SCREEN_WIDTH - (2.0f * s)) / gScreenWidth) * (1 << 10); + dtdy = ((SCREEN_HEIGHT - (2.0f * t)) / gScreenHeight) * (1 << 10); + } + + gSPTextureRectangle(gfx++, 0, 0, xh << 2, yh << 2, G_TX_RENDERTILE, (s32)(s * (1 << 5)), (s32)(t * (1 << 5)), dsdx, + dtdy); + gDPPipeSync(gfx++); + + *gfxp = gfx; +} + +void TransitionCircle_Draw(void* thisx, Gfx** gfxp) { + Gfx* gfx = *gfxp; + TransitionCircle* this = (TransitionCircle*)thisx; + + gDPPipeSync(gfx++); + gSPDisplayList(gfx++, &D_801D0D00); + gDPSetPrimColor(gfx++, 0, this->color.a, this->color.r, this->color.g, this->color.b, 1); + if (this->maskType == 0) { + gDPSetCombineLERP(gfx++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIM_LOD_FRAC, PRIMITIVE, 0, 0, 0, PRIMITIVE, TEXEL0, 0, + PRIM_LOD_FRAC, PRIMITIVE); + } else { + gDPSetCombineLERP(gfx++, 0, 0, 0, PRIMITIVE, 1, TEXEL0, PRIM_LOD_FRAC, PRIMITIVE, 0, 0, 0, PRIMITIVE, 1, TEXEL0, + PRIM_LOD_FRAC, PRIMITIVE); + } + TransitionCircle_LoadAndSetTexture(&gfx, this->texture, G_IM_FMT_I, 0, this->masks, this->maskt, + this->referenceRadius); + gDPPipeSync(gfx++); + + *gfxp = gfx; +} + +s32 TransitionCircle_IsDone(void* thisx) { + TransitionCircle* this = (TransitionCircle*)thisx; + + return this->isDone; +} From 8cd48db087ed7527d376195736eb9d4714bdf862 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Tue, 4 Oct 2022 12:23:13 -0700 Subject: [PATCH 24/25] Better match for BgKin2Fence_CheckHitMask (#1105) Co-authored-by: EllipticEllipsis Co-authored-by: EllipticEllipsis --- .../actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) 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 628ade7f1f..09f71c4ff2 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 @@ -120,19 +120,12 @@ static InitChainEntry sInitChain[] = { }; s32 BgKin2Fence_CheckHitMask(BgKin2Fence* this) { - ColliderJntSphElement* elements = this->collider.elements; + s32 i; - if (elements[0].info.bumperFlags & BUMP_HIT) { - return 0; - } - if (elements[1].info.bumperFlags & BUMP_HIT) { - return 1; - } - if (elements[2].info.bumperFlags & BUMP_HIT) { - return 2; - } - if (elements[3].info.bumperFlags & BUMP_HIT) { - return 3; + for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { + if (this->collider.elements[i].info.bumperFlags & BUMP_HIT) { + return i; + } } return -1; } From 2006a65ba62e7e848823cd1de009c9e16d6421eb Mon Sep 17 00:00:00 2001 From: petrie911 <69443847+petrie911@users.noreply.github.com> Date: Tue, 4 Oct 2022 15:46:32 -0500 Subject: [PATCH 25/25] z_overlay and z_fbdemo_dlftbls (Transition overlay handling), clean up a lot of u32s used to store pointers (#1073) * overlay matches * prototypes * fbdemo too * virtual to physical * names, cleanup, etc * bss reordering * uintptr stuff * fixed now? * one fix * headers and such * fixes'n'stuff * XXX action * docs of a sort * useless error codes * n * format * header? I barely know her! Co-authored-by: petrie911 --- include/functions.h | 44 ++++---- include/initvars.h | 8 ++ include/os.h | 10 +- include/os_internal.h | 4 +- include/variables.h | 2 - include/z64actor.h | 4 +- include/z64dma.h | 22 ++-- include/z64effect.h | 4 +- include/z64transition.h | 38 +++++-- spec | 1 - src/boot_O2_g3/yaz0.c | 4 +- src/boot_O2_g3/z_std_dma.c | 6 +- src/code/z_actor.c | 2 +- src/code/z_effect_soft_sprite_old_init.c | 2 +- src/code/z_en_hy_code.c | 6 +- src/code/z_fbdemo_circle.c | 2 +- src/code/z_fbdemo_dlftbls.c | 53 ++++++++- src/code/z_lib.c | 30 ++++-- src/code/z_overlay.c | 101 ++++++++++++++++-- src/code/z_player_lib.c | 4 +- src/code/z_room.c | 4 +- src/code/z_scene.c | 10 +- src/libultra/io/epirawdma.c | 2 +- src/libultra/io/sirawread.c | 2 +- src/libultra/io/sirawwrite.c | 2 +- src/overlays/actors/ovl_Boss_03/z_boss_03.c | 3 +- src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c | 8 +- .../actors/ovl_En_Bba_01/z_en_bba_01.c | 6 +- .../actors/ovl_En_Cne_01/z_en_cne_01.c | 6 +- src/overlays/actors/ovl_En_Dnk/z_en_dnk.c | 2 +- src/overlays/actors/ovl_En_Nwc/z_en_nwc.c | 4 +- .../actors/ovl_En_S_Goro/z_en_s_goro.c | 6 +- src/overlays/actors/ovl_En_Sob1/z_en_sob1.c | 6 +- .../ovl_Effect_Ss_Extra/z_eff_ss_extra.c | 4 +- .../ovl_fbdemo_triforce/z_fbdemo_triforce.c | 2 +- .../ovl_fbdemo_triforce/z_fbdemo_triforce.h | 2 - .../fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.c | 2 +- .../fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.h | 2 - .../fbdemos/ovl_fbdemo_wipe3/z_fbdemo_wipe3.c | 2 +- .../fbdemos/ovl_fbdemo_wipe3/z_fbdemo_wipe3.h | 2 - .../fbdemos/ovl_fbdemo_wipe4/z_fbdemo_wipe4.c | 2 +- .../fbdemos/ovl_fbdemo_wipe4/z_fbdemo_wipe4.h | 2 - .../fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.c | 2 +- .../fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.h | 2 - tools/disasm/functions.txt | 20 ++-- tools/sizes/code_functions.csv | 20 ++-- 46 files changed, 321 insertions(+), 151 deletions(-) diff --git a/include/functions.h b/include/functions.h index 93b15c2c56..dbbcc07dfc 100644 --- a/include/functions.h +++ b/include/functions.h @@ -7,12 +7,12 @@ void bootproc(void); void Idle_ThreadEntry(void* arg); void ViConfig_UpdateVi(u32 mode); void ViConfig_UpdateBlack(void); -s32 DmaMgr_DmaRomToRam(u32 rom, void* ram, size_t size); +s32 DmaMgr_DmaRomToRam(uintptr_t rom, void* ram, size_t size); s32 DmaMgr_DmaHandler(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction); -DmaEntry* DmaMgr_FindDmaEntry(u32 vrom); -u32 DmaMgr_TranslateVromToRom(u32 vrom); -s32 DmaMgr_FindDmaIndex(u32 vrom); -const char* func_800809F4(u32 param_1); +DmaEntry* DmaMgr_FindDmaEntry(uintptr_t vrom); +u32 DmaMgr_TranslateVromToRom(uintptr_t vrom); +s32 DmaMgr_FindDmaIndex(uintptr_t vrom); +const char* func_800809F4(uintptr_t param_1); void DmaMgr_ProcessMsg(DmaRequest* req); void DmaMgr_ThreadEntry(void* arg); s32 DmaMgr_SendRequestImpl(DmaRequest* request, void* vramStart, uintptr_t vromStart, size_t size, UNK_TYPE4 unused, OSMesgQueue* queue, void* msg); @@ -22,7 +22,7 @@ void DmaMgr_Stop(void); void* Yaz0_FirstDMA(void); void* Yaz0_NextDMA(void* curSrcPos); s32 Yaz0_DecompressImpl(u8* src, u8* dst); -void Yaz0_Decompress(u32 romStart, void* dst, size_t size); +void Yaz0_Decompress(uintptr_t romStart, void* dst, size_t size); void IrqMgr_AddClient(IrqMgr* irqmgr, IrqMgrClient* client, OSMesgQueue* msgQueue); void IrqMgr_RemoveClient(IrqMgr* irqmgr, IrqMgrClient* remove); void IrqMgr_SendMesgForClient(IrqMgr* irqmgr, OSMesg msg); @@ -256,7 +256,7 @@ s32 __osSpRawStartDma(s32 direction, void* devAddr, void* dramAddr, size_t size) s32 __osSiRawStartDma(s32 direction, void* dramAddr); s32 osEPiLinkHandle(OSPiHandle* handle); void osViBlack(u8 active); -s32 __osSiRawReadIo(u32 devAddr, u32* data); +s32 __osSiRawReadIo(uintptr_t devAddr, u32* data); OSId osGetThreadId(OSThread* t); void osSpTaskYield(void); s32 __osPfsGetNextPage(OSPfs* pfs, u8* bank, __OSInode* inode, __OSInodeUnit* page); @@ -280,7 +280,7 @@ void __osPiGetAccess(void); void __osPiRelAccess(void); void __osDevMgrMain(void* arg); // void func_8008C640(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5, UNK_TYPE1 param_6, UNK_TYPE1 param_7, UNK_TYPE1 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11, UNK_TYPE4 param_12, UNK_TYPE4 param_13, UNK_TYPE4 param_14, UNK_TYPE4 param_15, UNK_TYPE4 param_16, UNK_TYPE4 param_17, UNK_TYPE4 param_18); -s32 __osPiRawStartDma(s32 direction, u32 devAddr, void* dramAddr, size_t size); +s32 __osPiRawStartDma(s32 direction, uintptr_t devAddr, void* dramAddr, size_t size); u16 __osSumcalc(u8* ptr, s32 length); s32 __osIdCheckSum(u16* ptr, u16* checkSum, u16* idSum); s32 __osRepairPackId(OSPfs* pfs, __OSPackId* badid, __OSPackId* newid); @@ -322,11 +322,11 @@ s32 __osSiDeviceBusy(void); s32 osJamMesg(OSMesgQueue* mq, OSMesg msg, s32 flag); void osSetThreadPri(OSThread* t, OSPri p); OSPri osGetThreadPri(OSThread* t); -s32 __osEPiRawReadIo(OSPiHandle* handle, u32 devAddr, u32* data); +s32 __osEPiRawReadIo(OSPiHandle* handle, uintptr_t devAddr, u32* data); void osViSwapBuffer(void* frameBufPtr); void guPositionF(float mf[4][4], f32 rot, f32 pitch, f32 yaw, f32 scale, f32 x, f32 y, f32 z); void guPosition(Mtx* m, f32 rot, f32 pitch, f32 yaw, f32 scale, f32 x, f32 y, f32 z); -s32 __osEPiRawStartDma(OSPiHandle* handle, s32 direction, u32 cartAddr, void* dramAddr, size_t size); +s32 __osEPiRawStartDma(OSPiHandle* handle, s32 direction, uintptr_t cartAddr, void* dramAddr, size_t size); OSYieldResult osSpTaskYielded(OSTask* task); s32 bcmp(void* __s1, void* __s2, size_t __n); OSTime osGetTime(void); @@ -359,7 +359,7 @@ void __osViInit(void); void __osViSwapContext(void); OSMesgQueue* osPiGetCmdQueue(void); f32 cosf(f32 __x); -s32 osEPiReadIo(OSPiHandle* handle, u32 devAddr, u32* data); +s32 osEPiReadIo(OSPiHandle* handle, uintptr_t devAddr, u32* data); void osViSetSpecialFeatures(u32 func); s16 coss(u16 x); void osSetTime(OSTime ticks); @@ -380,13 +380,13 @@ u32 __osGetFpcCsr(void); // void __osPfsCheckRamArea(void); // void osPfsChecker(void); u32 osAiGetLength(void); -s32 osEPiWriteIo(OSPiHandle* handle, u32 devAddr, u32 data); +s32 osEPiWriteIo(OSPiHandle* handle, uintptr_t devAddr, u32 data); void osMapTLBRdb(void); void osYieldThread(void); void guTranslate(Mtx* mtx, f32 x, f32 y, f32 z); u32 __osGetCause(void); s32 __osContRamWrite(OSMesgQueue* mq, s32 channel, u16 address, u8* buffer, s32 force); -s32 __osEPiRawWriteIo(OSPiHandle* handle, u32 devAddr, u32 data); +s32 __osEPiRawWriteIo(OSPiHandle* handle, uintptr_t devAddr, u32 data); s32 osSetTimer(OSTimer* t, OSTime value, OSTime interval, OSMesgQueue* mq, OSMesg msg); void _Ldtob(_Pft* args, u8 type); // void _Ldunscale(void); @@ -394,7 +394,7 @@ void _Genld(_Pft* px, u8 code, u8* p, s16 nsig, s16 xexp); ldiv_t ldiv(long numer, long denom); lldiv_t lldiv(long long numer, long long denom); void _Litob(_Pft* args, u8 type); -s32 __osSiRawWriteIo(u32 devAddr, u32 data); +s32 __osSiRawWriteIo(uintptr_t devAddr, u32 data); u32 __osSpGetStatus(void); void __osSpSetStatus(u32 data); void osCreateViManager(OSPri pri); @@ -1576,8 +1576,8 @@ f32 Math_Vec3f_StepTo(Vec3f* start, Vec3f* target, f32 speed); void Lib_Nop801004FC(void); void* Lib_SegmentedToVirtual(void* ptr); void* Lib_SegmentedToVirtualNull(void* ptr); +void* Lib_VirtualToPhysical(void* ptr); void* Lib_PhysicalToVirtual(void* ptr); -void* Lib_PhysicalToVirtualNull(void* ptr); void LifeMeter_Init(PlayState* play); void LifeMeter_UpdateColors(PlayState* play); s32 LifeMeter_SaveInterfaceHealth(PlayState* play); @@ -2401,8 +2401,8 @@ void KaleidoScopeCall_Init(PlayState* play); void KaleidoScopeCall_Destroy(PlayState* play); void KaleidoScopeCall_Update(PlayState* play); void KaleidoScopeCall_Draw(PlayState* play); -// void func_80163C90(void); -// void func_80163D80(void); +void Transition_Init(TransitionContext* transitionCtx); +void Transition_Destroy(TransitionContext* transitionCtx); // void func_80163DC0(void); // void func_8016418C(void); // void func_8016424C(void); @@ -2420,6 +2420,8 @@ void* TransitionFade_Init(void* param_1); // void TransitionFade_IsDone(void); // void TransitionFade_SetColor(void); // void TransitionFade_SetType(void); +void TransitionOverlay_ClearLoadInfo(TransitionOverlay *overlayEntry); +void TransitionOverlay_SetSegment(TransitionOverlay *overlayEntry, void* vramStart, void* vramEnd, uintptr_t vromStart, uintptr_t vromEnd); void TransitionCircle_Start(void* thisx); void* TransitionCircle_Init(void* thisx); void TransitionCircle_Destroy(void* thisx); @@ -2430,10 +2432,10 @@ void TransitionCircle_LoadAndSetTexture(Gfx** gfxp, TexturePtr texture, s32 fmt, f32 arg6); void TransitionCircle_Draw(void* thisx, Gfx** gfxp); s32 TransitionCircle_IsDone(void* thisx); -// void func_801651B0(void); -// void func_80165224(void); -// void func_80165288(void); -// void func_8016537C(void); +void* TransitionOverlay_VramToRam(TransitionOverlay *overlayEntry, void* vramAddr); +void TransitionOverlay_VramToRamArray(TransitionOverlay *overlayEntry, void** vramAddrs, s32 count); +s32 TransitionOverlay_Load(TransitionOverlay *overlayEntry); +s32 TransitionOverlay_Free(TransitionOverlay *overlayEntry); void func_80165438(UNK_PTR param_1); // void func_80165444(s32 param_1, UNK_TYPE4 param_2, UNK_TYPE4 param_3, UNK_TYPE4 param_4, UNK_TYPE4 param_5); // void func_80165460(void); diff --git a/include/initvars.h b/include/initvars.h index 11a6719e9c..4de39757cc 100644 --- a/include/initvars.h +++ b/include/initvars.h @@ -610,4 +610,12 @@ extern ActorInit Oceff_Wipe7_InitVars; extern ActorInit Shot_Sun_InitVars; extern ActorInit TG_Sw_InitVars; +extern TransitionInit TransitionFade_InitVars; +extern TransitionInit TransitionTriforce_InitVars; +extern TransitionInit TransitionWipe1_InitVars; +extern TransitionInit TransitionWipe3_InitVars; +extern TransitionInit TransitionWipe4_InitVars; +extern TransitionInit TransitionCircle_InitVars; +extern TransitionInit TransitionWipe5_InitVars; + #endif diff --git a/include/os.h b/include/os.h index 838d8234ac..6e34bd4283 100644 --- a/include/os.h +++ b/include/os.h @@ -47,7 +47,7 @@ typedef struct { /* 0x04 */ u16 transferMode; /* 0x06 */ u16 blockNum; /* 0x08 */ s32 sectorNum; - /* 0x0C */ u32 devAddr; + /* 0x0C */ uintptr_t devAddr; /* 0x10 */ u32 bmCtlShadow; /* 0x14 */ u32 seqCtlShadow; /* 0x18 */ __OSBlockInfo block[2]; @@ -62,7 +62,7 @@ typedef struct OSPiHandle { /* 0x07 */ u8 relDuration; /* 0x08 */ u8 pulse; /* 0x09 */ u8 domain; - /* 0x0C */ u32 baseAddress; + /* 0x0C */ uintptr_t baseAddress; /* 0x10 */ u32 speed; /* 0x14 */ __OSTranxInfo transferInfo; } OSPiHandle; // size = 0x74 @@ -70,7 +70,7 @@ typedef struct OSPiHandle { typedef struct { /* 0x0 */ u8 type; - /* 0x4 */ u32 address; + /* 0x4 */ uintptr_t address; } OSPiInfo; // size = 0x8 @@ -97,8 +97,8 @@ typedef struct { /* 0x08 */ OSMesgQueue* cmdQueue; /* 0x0C */ OSMesgQueue* evtQueue; /* 0x10 */ OSMesgQueue* acsQueue; - /* 0x14 */ s32 (*piDmaCallback)(s32, u32, void*, size_t); - /* 0x18 */ s32 (*epiDmaCallback)(OSPiHandle*, s32, u32, void*, size_t); + /* 0x14 */ s32 (*piDmaCallback)(s32, uintptr_t, void*, size_t); + /* 0x18 */ s32 (*epiDmaCallback)(OSPiHandle*, s32, uintptr_t, void*, size_t); } OSDevMgr; // size = 0x1C typedef u64 OSTime; diff --git a/include/os_internal.h b/include/os_internal.h index b4f98bffad..2d82b41a9b 100644 --- a/include/os_internal.h +++ b/include/os_internal.h @@ -12,8 +12,8 @@ typedef struct { /* 0x08 */ OSMesgQueue* cmdQueue; /* 0x0C */ OSMesgQueue* eventQueue; /* 0x10 */ OSMesgQueue* accessQueue; - /* 0x14 */ s32 (*piDmaCallback)(s32, u32, void*, size_t); - /* 0x18 */ s32 (*epiDmaCallback)(OSPiHandle*, s32, u32, void*, size_t); + /* 0x14 */ s32 (*piDmaCallback)(s32, uintptr_t, void*, size_t); + /* 0x18 */ s32 (*epiDmaCallback)(OSPiHandle*, s32, uintptr_t, void*, size_t); } OSMgrArgs; // size = 0x1C #endif diff --git a/include/variables.h b/include/variables.h index dfe8ae715b..e865f890ef 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1471,9 +1471,7 @@ extern KaleidoMgrOverlay* gKaleidoMgrCurOvl; // extern UNK_TYPE4 D_801D0BB0; // extern UNK_TYPE1 D_801D0C80; // extern UNK_TYPE1 D_801D0CB0; -extern const TransitionInit TransitionFade_InitVars; extern Gfx D_801D0D00[]; -extern const TransitionInit TransitionCircle_InitVars; extern s32 gDbgCamEnabled; // extern UNK_TYPE1 D_801D0D54; // extern UNK_TYPE2 D_801D0D58; diff --git a/include/z64actor.h b/include/z64actor.h index b110783160..f1c33783a7 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -105,8 +105,8 @@ typedef enum { } AllocType; typedef struct { - /* 0x00 */ u32 vromStart; - /* 0x04 */ u32 vromEnd; + /* 0x00 */ uintptr_t vromStart; + /* 0x04 */ uintptr_t vromEnd; /* 0x08 */ void* vramStart; /* 0x0C */ void* vramEnd; /* 0x10 */ void* loadedRamAddr; // original name: "allocp" diff --git a/include/z64dma.h b/include/z64dma.h index 3b17d04d03..92c0227f3d 100644 --- a/include/z64dma.h +++ b/include/z64dma.h @@ -4,21 +4,21 @@ #include "ultra64.h" typedef struct { - /* 0x00 */ u32 vromAddr; // VROM address (source) - /* 0x04 */ void* dramAddr; // DRAM address (destination) - /* 0x08 */ u32 size; // File Transfer size - /* 0x0C */ char* filename; // Filename for debugging - /* 0x10 */ s32 line; // Line for debugging - /* 0x14 */ s32 unk14; + /* 0x00 */ uintptr_t vromAddr; // VROM address (source) + /* 0x04 */ void* dramAddr; // DRAM address (destination) + /* 0x08 */ u32 size; // File Transfer size + /* 0x0C */ char* filename; // Filename for debugging + /* 0x10 */ s32 line; // Line for debugging + /* 0x14 */ s32 unk14; /* 0x18 */ OSMesgQueue* notifyQueue; // Message queue for the notification message - /* 0x1C */ OSMesg notifyMsg; // Completion notification message + /* 0x1C */ OSMesg notifyMsg; // Completion notification message } DmaRequest; // size = 0x20 typedef struct { - /* 0x0 */ u32 vromStart; - /* 0x4 */ u32 vromEnd; - /* 0x8 */ u32 romStart; - /* 0xC */ u32 romEnd; + /* 0x0 */ uintptr_t vromStart; + /* 0x4 */ uintptr_t vromEnd; + /* 0x8 */ uintptr_t romStart; + /* 0xC */ uintptr_t romEnd; } DmaEntry; // size = 0x10 #endif diff --git a/include/z64effect.h b/include/z64effect.h index b4574592a0..727bf04d2a 100644 --- a/include/z64effect.h +++ b/include/z64effect.h @@ -248,8 +248,8 @@ typedef struct { } EffectSsInit; // size = 0x8 typedef struct { - /* 0x00 */ u32 vromStart; - /* 0x04 */ u32 vromEnd; + /* 0x00 */ uintptr_t vromStart; + /* 0x04 */ uintptr_t vromEnd; /* 0x08 */ void* vramStart; /* 0x0C */ void* vramEnd; /* 0x10 */ void* loadedRamAddr; diff --git a/include/z64transition.h b/include/z64transition.h index 3742291a61..45178ba8ec 100644 --- a/include/z64transition.h +++ b/include/z64transition.h @@ -17,13 +17,42 @@ typedef struct { /* 0x20 */ s32 (*isDone)(void* transition); } TransitionInit; // size = 0x24 +typedef struct { + union { + struct { + /* 0x00 */ u32 count : 8; + /* 0x00 */ uintptr_t addr : 24; + }; + /* 0x00 */ u32 word; + } loadInfo; + /* 0x04 */ void* vramStart; + /* 0x08 */ void* vramEnd; + /* 0x0C */ uintptr_t vromStart; + /* 0x10 */ uintptr_t vromEnd; + /* 0x14 */ TransitionInit* initInfo; + /* 0x18 */ size_t size; +} TransitionOverlay; + +typedef struct { + /* 0x000 */ s16 transitionType; + /* 0x002 */ s8 fbdemoType; + /* 0x003 */ char unk_003[0x22B]; + /* 0x230 */ void* (*init)(void* transition); + /* 0x234 */ void (*destroy)(void* transition); + /* 0x238 */ void (*update)(void* transition, s32 updateRate); + /* 0x23C */ void (*draw)(void* transition, Gfx** gfxP); + /* 0x240 */ void (*start)(void* transition); + /* 0x244 */ void (*setType)(void* transition, s32 type); + /* 0x248 */ void (*setColor)(void* transition, u32 color); + /* 0x24C */ void (*setEnvColor)(void* transition, u32 color); + /* 0x250 */ s32 (*isDone)(void* transition); + /* 0x254 */ char unk_254[0x4]; +} TransitionContext; // size = 0x258 + typedef struct { /* 0x0 */ char unk_0[0xC]; } TransitionFade; // size = 0xC -extern const TransitionInit TransitionFade_InitVars; - - typedef enum { /* 0 */ TRANSITION_CIRCLE_IN, /* 1 */ TRANSITION_CIRCLE_OUT, @@ -40,7 +69,6 @@ typedef struct { /* 0x14 */ u8 direction; // Direction the circle is transitioning ( In / Out ) /* 0x15 */ u8 maskType; // Positive / Negative mask type. Value of 0 will create a black circle /* 0x16 */ u8 isDone; // Signals when Transition is done updating - /* 0x17 */ UNK_TYPE1 pad_17; // struct padding /* 0x18 */ TexturePtr texture; /* 0x1C */ u8 masks; /* 0x1D */ u8 maskt; @@ -48,6 +76,4 @@ typedef struct { /* 0x1F */ s8 unk_1F; // Set to 0 and never used } TransitionCircle; // size = 0x20 -extern const TransitionInit TransitionCircle_InitVars; - #endif diff --git a/spec b/spec index bcbcf66976..33f635b8f2 100644 --- a/spec +++ b/spec @@ -549,7 +549,6 @@ beginseg include "build/src/code/z_kaleido_manager.o" include "build/src/code/z_kaleido_scope_call.o" include "build/src/code/z_fbdemo_dlftbls.o" - include "build/data/code/code_801D0BB0.data.o" include "build/src/code/z_fbdemo.o" include "build/data/code/z_fbdemo.data.o" include "build/src/code/z_fbdemo_fade.o" diff --git a/src/boot_O2_g3/yaz0.c b/src/boot_O2_g3/yaz0.c index 5f8e5a0edc..63260e8853 100644 --- a/src/boot_O2_g3/yaz0.c +++ b/src/boot_O2_g3/yaz0.c @@ -3,7 +3,7 @@ u8 sYaz0DataBuffer[0x400]; u8* sYaz0CurDataEnd; -u32 sYaz0CurRomStart; +uintptr_t sYaz0CurRomStart; u32 sYaz0CurSize; u8* sYaz0MaxPtr; u8* D_8009BE20; @@ -123,7 +123,7 @@ s32 Yaz0_DecompressImpl(u8* src, u8* dst) { return 0; } -void Yaz0_Decompress(u32 romStart, void* dst, size_t size) { +void Yaz0_Decompress(uintptr_t romStart, void* dst, size_t size) { s32 status; u32 pad; char sp80[0x50]; diff --git a/src/boot_O2_g3/z_std_dma.c b/src/boot_O2_g3/z_std_dma.c index 10d84dcb03..8e9d838729 100644 --- a/src/boot_O2_g3/z_std_dma.c +++ b/src/boot_O2_g3/z_std_dma.c @@ -60,7 +60,7 @@ s32 DmaMgr_DmaHandler(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction) { return osEPiStartDma(pihandle, mb, direction); } -DmaEntry* DmaMgr_FindDmaEntry(u32 vrom) { +DmaEntry* DmaMgr_FindDmaEntry(uintptr_t vrom) { DmaEntry* curr; for (curr = dmadata; curr->vromEnd != 0; curr++) { @@ -77,7 +77,7 @@ DmaEntry* DmaMgr_FindDmaEntry(u32 vrom) { return NULL; } -u32 DmaMgr_TranslateVromToRom(u32 vrom) { +u32 DmaMgr_TranslateVromToRom(uintptr_t vrom) { DmaEntry* entry = DmaMgr_FindDmaEntry(vrom); if (entry != NULL) { @@ -95,7 +95,7 @@ u32 DmaMgr_TranslateVromToRom(u32 vrom) { return -1; } -s32 DmaMgr_FindDmaIndex(u32 vrom) { +s32 DmaMgr_FindDmaIndex(uintptr_t vrom) { DmaEntry* entry = DmaMgr_FindDmaEntry(vrom); if (entry != NULL) { diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 88ec6c07bf..84616f083b 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -1060,7 +1060,7 @@ void Actor_SetScale(Actor* actor, f32 scale) { } void Actor_SetObjectDependency(PlayState* play, Actor* actor) { - gSegments[0x06] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[actor->objBankIndex].segment); + gSegments[0x06] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[actor->objBankIndex].segment); } void Actor_Init(Actor* actor, PlayState* play) { diff --git a/src/code/z_effect_soft_sprite_old_init.c b/src/code/z_effect_soft_sprite_old_init.c index bbdd528a4a..4f24651d13 100644 --- a/src/code/z_effect_soft_sprite_old_init.c +++ b/src/code/z_effect_soft_sprite_old_init.c @@ -50,7 +50,7 @@ void EffectSs_DrawGEffect(PlayState* play, EffectSs* this, TexturePtr texture) { SkinMatrix_SetScale(&mfScale, scale, scale, scale); SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTrans11DA0); SkinMatrix_MtxFMtxFMult(&mfTrans11DA0, &mfScale, &mfResult); - gSegments[0x06] = PHYSICAL_TO_VIRTUAL(object); + gSegments[0x06] = VIRTUAL_TO_PHYSICAL(object); gSPSegment(POLY_XLU_DISP++, 0x06, object); mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult); diff --git a/src/code/z_en_hy_code.c b/src/code/z_en_hy_code.c index 5e32e5c950..19a52c1b40 100644 --- a/src/code/z_en_hy_code.c +++ b/src/code/z_en_hy_code.c @@ -84,7 +84,7 @@ EnDoor* EnHy_FindNearestDoor(Actor* actor, PlayState* play) { } void EnHy_ChangeObjectAndAnim(EnHy* enHy, PlayState* play, s16 animIndex) { - gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[enHy->animObjIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[enHy->animObjIndex].segment); EnHy_ChangeAnim(&enHy->skelAnime, animIndex); } @@ -92,7 +92,7 @@ s32 EnHy_UpdateSkelAnime(EnHy* enHy, PlayState* play) { s32 isUpdated = false; if (enHy->actor.draw != NULL) { - gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[enHy->animObjIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[enHy->animObjIndex].segment); SkelAnime_Update(&enHy->skelAnime); isUpdated = true; } @@ -119,7 +119,7 @@ s32 EnHy_Init(EnHy* enHy, PlayState* play, FlexSkeletonHeader* skeletonHeaderSeg enHy->actor.objBankIndex = enHy->skelLowerObjIndex; isInitialized = true; ActorShape_Init(&enHy->actor.shape, 0.0f, NULL, 0.0f); - gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[enHy->actor.objBankIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[enHy->actor.objBankIndex].segment); SkelAnime_InitFlex(play, &enHy->skelAnime, skeletonHeaderSeg, NULL, enHy->jointTable, enHy->morphTable, ENHY_LIMB_MAX); EnHy_ChangeObjectAndAnim(enHy, play, animIndex); diff --git a/src/code/z_fbdemo_circle.c b/src/code/z_fbdemo_circle.c index 9cbc308be1..2a8144ea43 100644 --- a/src/code/z_fbdemo_circle.c +++ b/src/code/z_fbdemo_circle.c @@ -13,7 +13,7 @@ Gfx D_801D0D00[] = { }; //! @bug: TransitionCircle_Update should take an additional argument `s32 updateRate` -const TransitionInit TransitionCircle_InitVars = { +TransitionInit TransitionCircle_InitVars = { TransitionCircle_Init, TransitionCircle_Destroy, (void*)TransitionCircle_Update, TransitionCircle_Draw, TransitionCircle_Start, TransitionCircle_SetType, TransitionCircle_SetColor, NULL, TransitionCircle_IsDone, diff --git a/src/code/z_fbdemo_dlftbls.c b/src/code/z_fbdemo_dlftbls.c index 7ebce9e69e..9d3685a454 100644 --- a/src/code/z_fbdemo_dlftbls.c +++ b/src/code/z_fbdemo_dlftbls.c @@ -1,5 +1,54 @@ #include "global.h" +#include "initvars.h" +#include "overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.h" +#include "overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.h" +#include "overlays/fbdemos/ovl_fbdemo_wipe3/z_fbdemo_wipe3.h" +#include "overlays/fbdemos/ovl_fbdemo_wipe4/z_fbdemo_wipe4.h" +#include "overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_dlftbls/func_80163C90.s") +#define TRANSITION_OVERLAY(name, filename) \ + { \ + { 0, 0 }, SEGMENT_START(ovl_##filename), SEGMENT_END(ovl_##filename), SEGMENT_ROM_START(ovl_##filename), \ + SEGMENT_ROM_END(ovl_##filename), &name##_InitVars, sizeof(name) \ + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_dlftbls/func_80163D80.s") +#define TRANSITION_OVERLAY_INTERNAL(name) \ + { { 0, 0 }, NULL, NULL, 0, 0, &name##_InitVars, sizeof(name) } + +#define TRANSITION_OVERLAY_UNSET \ + { 0 } + +TransitionOverlay gTransitionOverlayTable[] = { + TRANSITION_OVERLAY_INTERNAL(TransitionFade), TRANSITION_OVERLAY(TransitionTriforce, fbdemo_triforce), + TRANSITION_OVERLAY(TransitionWipe1, fbdemo_wipe1), TRANSITION_OVERLAY(TransitionWipe3, fbdemo_wipe3), + TRANSITION_OVERLAY(TransitionWipe4, fbdemo_wipe4), TRANSITION_OVERLAY_INTERNAL(TransitionCircle), + TRANSITION_OVERLAY(TransitionWipe5, fbdemo_wipe5), +}; + +void Transition_Init(TransitionContext* transitionCtx) { + TransitionOverlay* overlayEntry; + ptrdiff_t relocOffset; + TransitionInit* initInfo[1]; + + overlayEntry = &gTransitionOverlayTable[transitionCtx->fbdemoType]; + TransitionOverlay_Load(overlayEntry); + + relocOffset = (uintptr_t)Lib_PhysicalToVirtual(overlayEntry->loadInfo.addr) - (uintptr_t)overlayEntry->vramStart; + initInfo[0] = NULL; + initInfo[0] = (overlayEntry->initInfo != NULL) ? (TransitionInit*)((uintptr_t)overlayEntry->initInfo + relocOffset) + : initInfo[0]; + + transitionCtx->init = initInfo[0]->init; + transitionCtx->destroy = initInfo[0]->destroy; + transitionCtx->start = initInfo[0]->start; + transitionCtx->isDone = initInfo[0]->isDone; + transitionCtx->draw = initInfo[0]->draw; + transitionCtx->update = initInfo[0]->update; + transitionCtx->setType = initInfo[0]->setType; + transitionCtx->setColor = initInfo[0]->setColor; + transitionCtx->setEnvColor = initInfo[0]->setEnvColor; +} + +void Transition_Destroy(TransitionContext* transitionCtx) { + TransitionOverlay_Free(&gTransitionOverlayTable[transitionCtx->fbdemoType]); +} diff --git a/src/code/z_lib.c b/src/code/z_lib.c index 03e6c395c0..6466b337c3 100644 --- a/src/code/z_lib.c +++ b/src/code/z_lib.c @@ -704,11 +704,29 @@ void* Lib_SegmentedToVirtual(void* ptr) { void* Lib_SegmentedToVirtualNull(void* ptr) { if (((uintptr_t)ptr >> 28) == 0) { return ptr; + } else { + return SEGMENTED_TO_VIRTUAL(ptr); } - - return SEGMENTED_TO_VIRTUAL(ptr); } +/* + * Converts a 32-bit virtual address (0x80XXXXXX) to a 24-bit physical address (0xXXXXXX). The NULL case accounts for + * the NULL virtual address being 0x00000000 and not 0x80000000. Used by transition overlays, which store their + * addresses in 24-bit fields. + */ +void* Lib_VirtualToPhysical(void* ptr) { + if (ptr == NULL) { + return NULL; + } else { + return (void*)VIRTUAL_TO_PHYSICAL(ptr); + } +} + +/* + * Converts a 24-bit physical address (0xXXXXXX) to a 32-bit virtual address (0x80XXXXXX). The NULL case accounts for + * the NULL virtual address being 0x00000000 and not 0x80000000. Used by transition overlays, which store their + * addresses in 24-bit fields. + */ void* Lib_PhysicalToVirtual(void* ptr) { if (ptr == NULL) { return NULL; @@ -716,11 +734,3 @@ void* Lib_PhysicalToVirtual(void* ptr) { return (void*)PHYSICAL_TO_VIRTUAL(ptr); } } - -void* Lib_PhysicalToVirtualNull(void* ptr) { - if (ptr == NULL) { - return NULL; - } else { - return (void*)PHYSICAL_TO_VIRTUAL(ptr); - } -} diff --git a/src/code/z_overlay.c b/src/code/z_overlay.c index a358cefe61..2c8c8d6d79 100644 --- a/src/code/z_overlay.c +++ b/src/code/z_overlay.c @@ -1,14 +1,103 @@ +/** + * @file z_overlay.c + * + * Functions for handling transition overlays in memory + * + * Status codes returned from TransitionOverlay_Load and TransitionOverlay_Free: + * + * -1 : failed allocation or null reference + * 0 : successfully loaded/freed overlay + * 1 : successfully added/removed instance + * 2 : overlay is loaded but has no instances (?) TODO: Figure out why this exists + * 3 : internal overlay, so always loaded + */ + #include "global.h" #include "z64load.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_overlay/func_801651B0.s") +void* TransitionOverlay_VramToRam(TransitionOverlay* overlayEntry, void* vramAddr) { + void* loadedRamAddr = Lib_PhysicalToVirtual(overlayEntry->loadInfo.addr); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_overlay/func_80165224.s") + if ((loadedRamAddr != NULL) && (vramAddr >= overlayEntry->vramStart) && (vramAddr < overlayEntry->vramEnd)) { + return ((uintptr_t)loadedRamAddr - (uintptr_t)overlayEntry->vramStart) + (uintptr_t)vramAddr; + } + return vramAddr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_overlay/func_80165288.s") +void TransitionOverlay_VramToRamArray(TransitionOverlay* overlayEntry, void** vramAddrs, s32 count) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_overlay/func_8016537C.s") + for (i = 0; i < count; i++) { + vramAddrs[i] = TransitionOverlay_VramToRam(overlayEntry, vramAddrs[i]); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_overlay/func_80165438.s") +s32 TransitionOverlay_Load(TransitionOverlay* overlayEntry) { + s32 count; + void* loadedRamAddr; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_overlay/func_80165444.s") + if (overlayEntry->vromStart == 0) { + return 3; + } + if (Lib_PhysicalToVirtual(overlayEntry->loadInfo.addr) == NULL) { + loadedRamAddr = ZeldaArena_Malloc(VRAM_PTR_SIZE(overlayEntry)); + + if (loadedRamAddr == NULL) { + return -1; + } + Load2_LoadOverlay(overlayEntry->vromStart, overlayEntry->vromEnd, overlayEntry->vramStart, + overlayEntry->vramEnd, loadedRamAddr); + overlayEntry->loadInfo.addr = Lib_VirtualToPhysical(loadedRamAddr); + overlayEntry->loadInfo.count = 1; + return 0; + } else { + count = overlayEntry->loadInfo.count; + if (count != 0) { + count++; + overlayEntry->loadInfo.count = count; + if (count == 0) { + return 2; + } else { + return 1; + } + } + return 2; + } +} + +s32 TransitionOverlay_Free(TransitionOverlay* overlayEntry) { + s32 count; + void* loadedRamAddr; + + if (overlayEntry->vromStart == 0) { + return 3; + } + loadedRamAddr = Lib_PhysicalToVirtual(overlayEntry->loadInfo.addr); + if (loadedRamAddr != NULL) { + count = overlayEntry->loadInfo.count; + if (count != 0) { + count--; + overlayEntry->loadInfo.count = count; + if (count == 0) { + ZeldaArena_Free(loadedRamAddr); + overlayEntry->loadInfo.addr = Lib_VirtualToPhysical(NULL); + return 0; + } + return 1; + } + return 2; + } + return -1; +} + +void TransitionOverlay_ClearLoadInfo(TransitionOverlay* overlayEntry) { + overlayEntry->loadInfo.word = 0; // Equivalent to overlayEntry->loadInfo.count = 0, overlayEntry->loadInfo.addr = 0; +} + +void TransitionOverlay_SetSegment(TransitionOverlay* overlayEntry, void* vramStart, void* vramEnd, uintptr_t vromStart, + uintptr_t vromEnd) { + overlayEntry->vramStart = vramStart; + overlayEntry->vramEnd = vramEnd; + overlayEntry->vromStart = vromStart; + overlayEntry->vromEnd = vromEnd; +} diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index 0888be7c53..6f4198fc79 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -1107,7 +1107,7 @@ void Player_DrawGetItemImpl(PlayState* play, Player* player, Vec3f* refPos, s32 OPEN_DISPS(play->state.gfxCtx); - gSegments[6] = PHYSICAL_TO_VIRTUAL(player->giObjectSegment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(player->giObjectSegment); gSPSegment(POLY_OPA_DISP++, 0x06, player->giObjectSegment); gSPSegment(POLY_XLU_DISP++, 0x06, player->giObjectSegment); @@ -1187,7 +1187,7 @@ void func_80127488(PlayState* play, Player* player, u8 alpha) { } void Player_DrawCouplesMask(PlayState* play, Player* player) { - gSegments[0xA] = PHYSICAL_TO_VIRTUAL(player->maskObjectSegment); + gSegments[0xA] = VIRTUAL_TO_PHYSICAL(player->maskObjectSegment); AnimatedMat_DrawOpa(play, Lib_SegmentedToVirtual(&object_mask_meoto_Matanimheader_001CD8)); } diff --git a/src/code/z_room.c b/src/code/z_room.c index e198e95ed3..eb615c4093 100644 --- a/src/code/z_room.c +++ b/src/code/z_room.c @@ -105,7 +105,7 @@ s32 Room_HandleLoadCallbacks(PlayState* play, RoomContext* roomCtx) { roomCtx->unk31 = 0; roomCtx->curRoom.segment = roomCtx->activeRoomVram; // TODO: Segment number enum - gSegments[0x03] = PHYSICAL_TO_VIRTUAL(roomCtx->activeRoomVram); + gSegments[0x03] = VIRTUAL_TO_PHYSICAL(roomCtx->activeRoomVram); Scene_ProcessHeader(play, (SceneCmd*)roomCtx->curRoom.segment); func_80123140(play, GET_PLAYER(play)); @@ -130,7 +130,7 @@ s32 Room_HandleLoadCallbacks(PlayState* play, RoomContext* roomCtx) { void Room_Draw(PlayState* play, Room* room, u32 flags) { if (room->segment != NULL) { // TODO: Segment number enum - gSegments[0x03] = PHYSICAL_TO_VIRTUAL(room->segment); + gSegments[0x03] = VIRTUAL_TO_PHYSICAL(room->segment); roomDrawFuncs[room->mesh->type0.type](play, room, flags); } return; diff --git a/src/code/z_scene.c b/src/code/z_scene.c index 7b88d4520f..c32a2271df 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -52,7 +52,7 @@ void Object_InitBank(GameState* gameState, ObjectContext* objectCtx) { objectCtx->spaceEnd = (void*)((u32)objectCtx->spaceStart + spaceSize); objectCtx->mainKeepIndex = Object_Spawn(objectCtx, GAMEPLAY_KEEP); - gSegments[0x04] = PHYSICAL_TO_VIRTUAL(objectCtx->status[objectCtx->mainKeepIndex].segment); + gSegments[0x04] = VIRTUAL_TO_PHYSICAL(objectCtx->status[objectCtx->mainKeepIndex].segment); } void Object_UpdateBank(ObjectContext* objectCtx) { @@ -108,7 +108,7 @@ s32 Object_IsLoaded(ObjectContext* objectCtx, s32 index) { void Object_LoadAll(ObjectContext* objectCtx) { s32 i; s32 id; - u32 vromSize; + uintptr_t vromSize; for (i = 0; i < objectCtx->num; i++) { id = objectCtx->status[i].id; @@ -124,7 +124,7 @@ void Object_LoadAll(ObjectContext* objectCtx) { void* func_8012F73C(ObjectContext* objectCtx, s32 iParm2, s16 id) { u32 addr; - u32 vromSize; + uintptr_t vromSize; RomFile* fileTableEntry; objectCtx->status[iParm2].id = -id; @@ -224,7 +224,7 @@ void Scene_HeaderCmdSpecialFiles(PlayState* play, SceneCmd* cmd) { if (cmd->specialFiles.subKeepIndex != 0) { play->objectCtx.subKeepIndex = Object_Spawn(&play->objectCtx, cmd->specialFiles.subKeepIndex); // TODO: Segment number enum? - gSegments[0x05] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[play->objectCtx.subKeepIndex].segment); + gSegments[0x05] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[play->objectCtx.subKeepIndex].segment); } if (cmd->specialFiles.cUpElfMsgNum != 0) { @@ -350,7 +350,7 @@ void Scene_LoadAreaTextures(PlayState* play, s32 fileIndex) { { SEGMENT_ROM_START(scene_texture_07), SEGMENT_ROM_END(scene_texture_07) }, { SEGMENT_ROM_START(scene_texture_08), SEGMENT_ROM_END(scene_texture_08) }, }; - u32 vromStart = sceneTextureFiles[fileIndex].vromStart; + uintptr_t vromStart = sceneTextureFiles[fileIndex].vromStart; size_t size = sceneTextureFiles[fileIndex].vromEnd - vromStart; if (size != 0) { diff --git a/src/libultra/io/epirawdma.c b/src/libultra/io/epirawdma.c index fd7573151d..aadd8ad5bd 100644 --- a/src/libultra/io/epirawdma.c +++ b/src/libultra/io/epirawdma.c @@ -1,6 +1,6 @@ #include "global.h" -s32 __osEPiRawStartDma(OSPiHandle* handle, s32 direction, u32 cartAddr, void* dramAddr, size_t size) { +s32 __osEPiRawStartDma(OSPiHandle* handle, s32 direction, uintptr_t cartAddr, void* dramAddr, size_t size) { s32 status; OSPiHandle* curHandle; diff --git a/src/libultra/io/sirawread.c b/src/libultra/io/sirawread.c index 19327db496..7e3537603c 100644 --- a/src/libultra/io/sirawread.c +++ b/src/libultra/io/sirawread.c @@ -1,6 +1,6 @@ #include "global.h" -s32 __osSiRawReadIo(u32 devAddr, u32* data) { +s32 __osSiRawReadIo(uintptr_t devAddr, u32* data) { if (__osSiDeviceBusy()) { return -1; } diff --git a/src/libultra/io/sirawwrite.c b/src/libultra/io/sirawwrite.c index 040fdee0da..0f98b08c52 100644 --- a/src/libultra/io/sirawwrite.c +++ b/src/libultra/io/sirawwrite.c @@ -1,6 +1,6 @@ #include "global.h" -s32 __osSiRawWriteIo(u32 devAddr, u32 data) { +s32 __osSiRawWriteIo(uintptr_t devAddr, u32 data) { if (__osSiDeviceBusy() != 0) { return -1; } diff --git a/src/overlays/actors/ovl_Boss_03/z_boss_03.c b/src/overlays/actors/ovl_Boss_03/z_boss_03.c index 870bc53a1d..a0f3a208b8 100644 --- a/src/overlays/actors/ovl_Boss_03/z_boss_03.c +++ b/src/overlays/actors/ovl_Boss_03/z_boss_03.c @@ -52,7 +52,6 @@ * - Effect Update/Draw * - Seaweed */ - #include "prevent_bss_reordering.h" #include "z_boss_03.h" #include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" @@ -2156,7 +2155,7 @@ void Boss03_SetObject(PlayState* play, s16 objectId) { OPEN_DISPS(play->state.gfxCtx); - gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[objectIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[objectIndex].segment); gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[objectIndex].segment); gSPSegment(POLY_XLU_DISP++, 0x06, play->objectCtx.status[objectIndex].segment); 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 2be56dda3c..90ccb1382f 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c @@ -311,7 +311,7 @@ void DmStk_LoadObjectForAnimation(DmStk* this, PlayState* play) { } if (objectIndex >= 0) { - gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[objectIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[objectIndex].segment); } } @@ -1909,13 +1909,13 @@ void DmStk_PostLimbDraw2(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot (this->objectStk2ObjectIndex >= 0)) { Matrix_Push(); Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); - gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[this->objectStk2ObjectIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->objectStk2ObjectIndex].segment); gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[this->objectStk2ObjectIndex].segment); AnimatedMat_Draw(play, Lib_SegmentedToVirtual(gSkullKidMajorasMaskCurseOverlayTexAnim)); Gfx_DrawDListOpa(play, gSkullKidMajorasMaskCurseOverlayDL); - gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[this->objectStkObjectIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->objectStkObjectIndex].segment); gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[this->objectStkObjectIndex].segment); @@ -2027,7 +2027,7 @@ void DmStk_Draw(Actor* thisx, PlayState* play) { return; } - gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[this->objectStkObjectIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->objectStkObjectIndex].segment); OPEN_DISPS(play->state.gfxCtx); 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 d141c6514c..8398a69edf 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 @@ -262,8 +262,8 @@ s32 EnBba01_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* if (limbIndex == BBA_LIMB_RIGHT_LOWER_ARM_ROOT) { OPEN_DISPS(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[this->enHy.headObjIndex].segment); - gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[this->enHy.headObjIndex].segment); - gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[this->enHy.skelLowerObjIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->enHy.headObjIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->enHy.skelLowerObjIndex].segment); CLOSE_DISPS(play->state.gfxCtx); } if (limbIndex == BBA_LIMB_RIGHT_LOWER_ARM_ROOT) { @@ -298,7 +298,7 @@ void EnBba01_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* ro if (limbIndex == BBA_LIMB_HEAD) { OPEN_DISPS(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[this->enHy.skelUpperObjIndex].segment); - gSegments[0x06] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[this->enHy.skelUpperObjIndex].segment); + gSegments[0x06] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->enHy.skelUpperObjIndex].segment); CLOSE_DISPS(play->state.gfxCtx); } 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 889055ee82..993076ba8c 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 @@ -252,9 +252,9 @@ s32 EnCne01_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* if (limbIndex == CNE_LIMB_HEAD) { OPEN_DISPS(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[this->enHy.headObjIndex].segment); - gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[this->enHy.headObjIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->enHy.headObjIndex].segment); *dList = gCneHeadBrownHairDL; - gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[this->enHy.skelLowerObjIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->enHy.skelLowerObjIndex].segment); CLOSE_DISPS(play->state.gfxCtx); } if (limbIndex == CNE_LIMB_HEAD) { @@ -290,7 +290,7 @@ void EnCne01_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* ro if (limbIndex == CNE_LIMB_RIGHT_FOOT) { OPEN_DISPS(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[this->enHy.skelUpperObjIndex].segment); - gSegments[0x06] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[this->enHy.skelUpperObjIndex].segment); + gSegments[0x06] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->enHy.skelUpperObjIndex].segment); CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c index 50a027efa3..346246f860 100644 --- a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c +++ b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c @@ -171,7 +171,7 @@ s32 func_80A515C4(EnDnk* this) { void func_80A51648(EnDnk* this, PlayState* play) { if (SubS_IsObjectLoaded(this->unk_28E, play) == true) { - gSegments[0x06] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[this->unk_28E].segment); + gSegments[0x06] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->unk_28E].segment); this->actor.draw = func_80A52018; this->actor.objBankIndex = this->unk_28E; ActorShape_Init(&this->actor.shape, 0.0f, NULL, 18.0f); diff --git a/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c b/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c index 2f842c8aed..3f66f7f70a 100644 --- a/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c +++ b/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c @@ -242,14 +242,14 @@ void EnNwc_CheckFound(EnNwc* this, PlayState* play) { void EnNwc_LoadNiwSkeleton(EnNwc* this, PlayState* play) { if (Object_IsLoaded(&play->objectCtx, this->niwObjectIndex)) { - gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[this->niwObjectIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->niwObjectIndex].segment); SkelAnime_InitFlex(play, &this->niwSkeleton, &gNiwSkeleton, &gNiwIdleAnim, this->jointTable, this->morphTable, NIW_LIMB_MAX); Animation_Change(&this->niwSkeleton, &gNiwIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gNiwIdleAnim), ANIMMODE_LOOP, 0.0f); - gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[this->nwcObjectIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->nwcObjectIndex].segment); this->state = NWC_STATE_NIW_LOADED; EnNwc_ToggleState(this); } diff --git a/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.c b/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.c index ccc11a002d..fbfe32252b 100644 --- a/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.c +++ b/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.c @@ -788,7 +788,7 @@ s32 EnSGoro_UpdateCheerAnimation(EnSGoro* this, PlayState* play) { if (((EnJg*)this->otherGoron)->flags & 1) { this->loadedObjIndex = Object_GetIndex(&play->objectCtx, OBJECT_TAISOU); if (this->loadedObjIndex >= 0) { - gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[this->loadedObjIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->loadedObjIndex].segment); this->animInfoIndex = EN_S_GORO_ANIM_TAISOU_CHEER; SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animInfoIndex); return true; @@ -797,7 +797,7 @@ s32 EnSGoro_UpdateCheerAnimation(EnSGoro* this, PlayState* play) { } else if ((this->animInfoIndex == EN_S_GORO_ANIM_TAISOU_CHEER) && !(((EnJg*)this->otherGoron)->flags & 1)) { this->loadedObjIndex = Object_GetIndex(&play->objectCtx, OBJECT_OF1D_MAP); if (this->loadedObjIndex >= 0) { - gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[this->loadedObjIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->loadedObjIndex].segment); this->animInfoIndex = EN_S_GORO_ANIM_IDLE_STAND; SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animInfoIndex); this->skelAnime.curFrame = this->skelAnime.endFrame; @@ -1329,7 +1329,7 @@ void EnSGoro_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 5); - gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[this->loadedObjIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->loadedObjIndex].segment); SkelAnime_Update(&this->skelAnime); if (this->animInfoIndex != EN_S_GORO_ANIM_SLEEPY) { EnSGoro_UpdateAttentionTarget(this, play); diff --git a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c index b698777588..ebbdcf5425 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c @@ -1305,7 +1305,7 @@ void EnSob1_Blink(EnSob1* this) { } void EnSob1_ChangeObject(EnSob1* this, PlayState* play) { - gSegments[0x06] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[this->shopkeeperAnimObjIndex].segment); + gSegments[0x06] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->shopkeeperAnimObjIndex].segment); } s32 EnSob1_AreObjectsLoaded(EnSob1* this, PlayState* play) { @@ -1323,7 +1323,7 @@ s32 EnSob1_AreObjectsLoaded(EnSob1* this, PlayState* play) { void EnSob1_ZoraShopkeeper_Init(EnSob1* this, PlayState* play) { SkelAnime_InitFlex(play, &this->skelAnime, &gZoraSkel, NULL, this->jointTable, this->morphTable, ZORA_LIMB_MAX); - gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[this->shopkeeperAnimObjIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->shopkeeperAnimObjIndex].segment); Animation_Change(&this->skelAnime, &gZoraShopkeeperAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gZoraShopkeeperAnim), ANIMMODE_LOOP, 0.0f); this->actor.draw = EnSob1_ZoraShopkeeper_Draw; @@ -1332,7 +1332,7 @@ void EnSob1_ZoraShopkeeper_Init(EnSob1* this, PlayState* play) { void EnSob1_GoronShopkeeper_Init(EnSob1* this, PlayState* play) { SkelAnime_InitFlex(play, &this->skelAnime, &gGoronSkel, NULL, this->jointTable, this->morphTable, GORON_LIMB_MAX); - gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[this->shopkeeperAnimObjIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->shopkeeperAnimObjIndex].segment); Animation_Change(&this->skelAnime, &gGoronShopkeeperAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gGoronShopkeeperAnim), ANIMMODE_LOOP, 0.0f); this->actor.draw = EnSob1_GoronShopkeeper_Draw; diff --git a/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c b/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c index e33b486f4a..1ec1ab41d5 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c +++ b/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c @@ -37,7 +37,7 @@ u32 EffectSsExtra_Init(PlayState* play, u32 index, EffectSs* this, void* initPar if ((objIndex >= 0) && (Object_IsLoaded(&play->objectCtx, objIndex))) { void* segBackup = gSegments[6]; - gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[objIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[objIndex].segment); this->pos = params->pos; this->velocity = params->velocity; @@ -66,7 +66,7 @@ void EffectSsExtra_Draw(PlayState* play, u32 index, EffectSs* this) { OPEN_DISPS(play->state.gfxCtx); - gSegments[6] = PHYSICAL_TO_VIRTUAL(storedSegment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(storedSegment); gSPSegment(POLY_XLU_DISP++, 0x06, storedSegment); diff --git a/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.c b/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.c index 4584cfab24..00e7cfabda 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.c +++ b/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.c @@ -16,7 +16,7 @@ void TransitionTriforce_SetType(void* thisx, s32 type); void TransitionTriforce_SetColor(void* thisx, u32 color); s32 TransitionTriforce_IsDone(void* thisx); -const TransitionInit TransitionTriforce_InitVars = { +TransitionInit TransitionTriforce_InitVars = { TransitionTriforce_Init, TransitionTriforce_Destroy, TransitionTriforce_Update, TransitionTriforce_Draw, TransitionTriforce_Start, TransitionTriforce_SetType, TransitionTriforce_SetColor, NULL, TransitionTriforce_IsDone, diff --git a/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.h b/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.h index 2637b32cfe..06d807a08e 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.h +++ b/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.h @@ -28,6 +28,4 @@ typedef struct { /* 0x060 */ Mtx modelView[2][3]; } TransitionTriforce; // size = 0x1E0 -extern const TransitionInit TransitionTriforce_InitVars; - #endif diff --git a/src/overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.c b/src/overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.c index 560d341f20..ed12d400ed 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.c +++ b/src/overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.c @@ -17,7 +17,7 @@ void TransitionWipe1_SetEnvColor(void* thisx, u32 color); s32 TransitionWipe1_IsDone(void* thisx); #if 0 -const TransitionInit TransitionWipe1_InitVars = { +TransitionInit TransitionWipe1_InitVars = { TransitionWipe1_Init, TransitionWipe1_Destroy, TransitionWipe1_Update, diff --git a/src/overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.h b/src/overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.h index fe70e724b4..971940bb2c 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.h +++ b/src/overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.h @@ -7,6 +7,4 @@ typedef struct { /* 0x0000 */ char unk_0[0x218]; } TransitionWipe1; // size = 0x218 -extern const TransitionInit TransitionWipe1_InitVars; - #endif diff --git a/src/overlays/fbdemos/ovl_fbdemo_wipe3/z_fbdemo_wipe3.c b/src/overlays/fbdemos/ovl_fbdemo_wipe3/z_fbdemo_wipe3.c index bbd488642f..c33f3c8c78 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_wipe3/z_fbdemo_wipe3.c +++ b/src/overlays/fbdemos/ovl_fbdemo_wipe3/z_fbdemo_wipe3.c @@ -17,7 +17,7 @@ void TransitionWipe3_SetEnvColor(void* thisx, u32 color); s32 TransitionWipe3_IsDone(void* thisx); #if 0 -const TransitionInit TransitionWipe3_InitVars = { +TransitionInit TransitionWipe3_InitVars = { TransitionWipe3_Init, TransitionWipe3_Destroy, TransitionWipe3_Update, diff --git a/src/overlays/fbdemos/ovl_fbdemo_wipe3/z_fbdemo_wipe3.h b/src/overlays/fbdemos/ovl_fbdemo_wipe3/z_fbdemo_wipe3.h index f74f86a613..8fed0dcfe9 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_wipe3/z_fbdemo_wipe3.h +++ b/src/overlays/fbdemos/ovl_fbdemo_wipe3/z_fbdemo_wipe3.h @@ -7,6 +7,4 @@ typedef struct { /* 0x0000 */ char unk_0[0x120]; } TransitionWipe3; // size = 0x120 -extern const TransitionInit TransitionWipe3_InitVars; - #endif diff --git a/src/overlays/fbdemos/ovl_fbdemo_wipe4/z_fbdemo_wipe4.c b/src/overlays/fbdemos/ovl_fbdemo_wipe4/z_fbdemo_wipe4.c index 49dd027c85..e91d8ab5e0 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_wipe4/z_fbdemo_wipe4.c +++ b/src/overlays/fbdemos/ovl_fbdemo_wipe4/z_fbdemo_wipe4.c @@ -17,7 +17,7 @@ void TransitionWipe4_SetEnvColor(void* thisx, u32 color); s32 TransitionWipe4_IsDone(void* thisx); #if 0 -const TransitionInit TransitionWipe4_InitVars = { +TransitionInit TransitionWipe4_InitVars = { TransitionWipe4_Init, TransitionWipe4_Destroy, TransitionWipe4_Update, diff --git a/src/overlays/fbdemos/ovl_fbdemo_wipe4/z_fbdemo_wipe4.h b/src/overlays/fbdemos/ovl_fbdemo_wipe4/z_fbdemo_wipe4.h index 60296230ed..8a677c2a4b 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_wipe4/z_fbdemo_wipe4.h +++ b/src/overlays/fbdemos/ovl_fbdemo_wipe4/z_fbdemo_wipe4.h @@ -7,6 +7,4 @@ typedef struct { /* 0x0000 */ char unk_0[0x28]; } TransitionWipe4; // size = 0x28 -extern const TransitionInit TransitionWipe4_InitVars; - #endif diff --git a/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.c b/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.c index 87f5638ac5..0ed80c066d 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.c +++ b/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.c @@ -17,7 +17,7 @@ void TransitionWipe5_SetEnvColor(void* thisx, u32 color); s32 TransitionWipe5_IsDone(void* thisx); #if 0 -const TransitionInit TransitionWipe5_InitVars = { +TransitionInit TransitionWipe5_InitVars = { TransitionWipe5_Init, TransitionWipe5_Destroy, TransitionWipe5_Update, diff --git a/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.h b/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.h index d8ffe06164..d5f882dec4 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.h +++ b/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.h @@ -7,6 +7,4 @@ typedef struct { /* 0x0000 */ char unk_0[0x14]; } TransitionWipe5; // size = 0x14 -extern const TransitionInit TransitionWipe5_InitVars; - #endif diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 62e5b7bdc3..dbe3430c40 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -1854,8 +1854,8 @@ 0x801004FC:("Lib_Nop801004FC",), 0x80100504:("Lib_SegmentedToVirtual",), 0x8010053C:("Lib_SegmentedToVirtualNull",), - 0x80100584:("Lib_PhysicalToVirtual",), - 0x801005A0:("Lib_PhysicalToVirtualNull",), + 0x80100584:("Lib_VirtualToPhysical",), + 0x801005A0:("Lib_PhysicalToVirtual",), 0x801005C0:("LifeMeter_Init",), 0x8010069C:("LifeMeter_UpdateColors",), 0x80100A80:("func_80100A80",), @@ -2936,8 +2936,8 @@ 0x80163A38:("KaleidoScopeCall_Destroy",), 0x80163A58:("KaleidoScopeCall_Update",), 0x80163C0C:("KaleidoScopeCall_Draw",), - 0x80163C90:("func_80163C90",), - 0x80163D80:("func_80163D80",), + 0x80163C90:("Transition_Init",), + 0x80163D80:("Transition_Destroy",), 0x80163DC0:("func_80163DC0",), 0x8016418C:("func_8016418C",), 0x8016424C:("func_8016424C",), @@ -2964,12 +2964,12 @@ 0x80164C14:("func_80164C14",), 0x80165044:("TransitionCircle_Draw",), 0x80165198:("TransitionCircle_IsDone",), - 0x801651B0:("func_801651B0",), - 0x80165224:("func_80165224",), - 0x80165288:("func_80165288",), - 0x8016537C:("func_8016537C",), - 0x80165438:("func_80165438",), - 0x80165444:("func_80165444",), + 0x801651B0:("TransitionOverlay_VramToRam",), + 0x80165224:("TransitionOverlay_VramToRamArray",), + 0x80165288:("TransitionOverlay_Load",), + 0x8016537C:("TransitionOverlay_Free",), + 0x80165438:("TransitionOverlay_ClearLoadInfo",), + 0x80165444:("TransitionOverlay_SetSegment",), 0x80165460:("func_80165460",), 0x80165608:("func_80165608",), 0x80165630:("func_80165630",), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 9db0c0308e..acec92239c 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -1368,8 +1368,8 @@ asm/non_matchings/code/z_lib/Math_Vec3f_StepTo.s,Math_Vec3f_StepTo,0x80100448,0x asm/non_matchings/code/z_lib/Lib_Nop801004FC.s,Lib_Nop801004FC,0x801004FC,0x2 asm/non_matchings/code/z_lib/Lib_SegmentedToVirtual.s,Lib_SegmentedToVirtual,0x80100504,0xE asm/non_matchings/code/z_lib/Lib_SegmentedToVirtualNull.s,Lib_SegmentedToVirtualNull,0x8010053C,0x12 -asm/non_matchings/code/z_lib/Lib_PhysicalToVirtual.s,Lib_PhysicalToVirtual,0x80100584,0x7 -asm/non_matchings/code/z_lib/Lib_PhysicalToVirtualNull.s,Lib_PhysicalToVirtualNull,0x801005A0,0x8 +asm/non_matchings/code/z_lib/Lib_VirtualToPhysical.s,Lib_VirtualToPhysical,0x80100584,0x7 +asm/non_matchings/code/z_lib/Lib_PhysicalToVirtual.s,Lib_PhysicalToVirtual,0x801005A0,0x8 asm/non_matchings/code/z_lifemeter/LifeMeter_Init.s,LifeMeter_Init,0x801005C0,0x37 asm/non_matchings/code/z_lifemeter/LifeMeter_UpdateColors.s,LifeMeter_UpdateColors,0x8010069C,0xF9 asm/non_matchings/code/z_lifemeter/func_80100A80.s,func_80100A80,0x80100A80,0x8 @@ -2450,8 +2450,8 @@ asm/non_matchings/code/z_kaleido_scope_call/func_801639EC.s,func_801639EC,0x8016 asm/non_matchings/code/z_kaleido_scope_call/func_80163A38.s,func_80163A38,0x80163A38,0x8 asm/non_matchings/code/z_kaleido_scope_call/func_80163A58.s,func_80163A58,0x80163A58,0x6D asm/non_matchings/code/z_kaleido_scope_call/func_80163C0C.s,func_80163C0C,0x80163C0C,0x21 -asm/non_matchings/code/z_fbdemo_dlftbls/func_80163C90.s,func_80163C90,0x80163C90,0x3C -asm/non_matchings/code/z_fbdemo_dlftbls/func_80163D80.s,func_80163D80,0x80163D80,0x10 +asm/non_matchings/code/z_fbdemo_dlftbls/Transition_Init.s,Transition_Init,0x80163C90,0x3C +asm/non_matchings/code/z_fbdemo_dlftbls/Transition_Destroy.s,Transition_Destroy,0x80163D80,0x10 asm/non_matchings/code/z_fbdemo/func_80163DC0.s,func_80163DC0,0x80163DC0,0xF3 asm/non_matchings/code/z_fbdemo/func_8016418C.s,func_8016418C,0x8016418C,0x30 asm/non_matchings/code/z_fbdemo/func_8016424C.s,func_8016424C,0x8016424C,0x23 @@ -2478,12 +2478,12 @@ asm/non_matchings/code/z_fbdemo_circle/TransitionCircle_SetType.s,TransitionCirc asm/non_matchings/code/z_fbdemo_circle/func_80164C14.s,func_80164C14,0x80164C14,0x10C asm/non_matchings/code/z_fbdemo_circle/TransitionCircle_Draw.s,TransitionCircle_Draw,0x80165044,0x55 asm/non_matchings/code/z_fbdemo_circle/TransitionCircle_IsDone.s,TransitionCircle_IsDone,0x80165198,0x6 -asm/non_matchings/code/z_overlay/func_801651B0.s,func_801651B0,0x801651B0,0x1D -asm/non_matchings/code/z_overlay/func_80165224.s,func_80165224,0x80165224,0x19 -asm/non_matchings/code/z_overlay/func_80165288.s,func_80165288,0x80165288,0x3D -asm/non_matchings/code/z_overlay/func_8016537C.s,func_8016537C,0x8016537C,0x2F -asm/non_matchings/code/z_overlay/func_80165438.s,func_80165438,0x80165438,0x3 -asm/non_matchings/code/z_overlay/func_80165444.s,func_80165444,0x80165444,0x7 +asm/non_matchings/code/z_overlay/TransitionOverlay_VramToRam.s,TransitionOverlay_VramToRam,0x801651B0,0x1D +asm/non_matchings/code/z_overlay/TransitionOverlay_VramToRamArray.s,TransitionOverlay_VramToRamArray,0x80165224,0x19 +asm/non_matchings/code/z_overlay/TransitionOverlay_Load.s,TransitionOverlay_Load,0x80165288,0x3D +asm/non_matchings/code/z_overlay/TransitionOverlay_Free.s,TransitionOverlay_Free,0x8016537C,0x2F +asm/non_matchings/code/z_overlay/TransitionOverlay_ClearLoadInfo.s,TransitionOverlay_ClearLoadInfo,0x80165438,0x3 +asm/non_matchings/code/z_overlay/TransitionOverlay_SetSegment.s,TransitionOverlay_SetSegment,0x80165444,0x7 asm/non_matchings/code/z_play/func_80165460.s,func_80165460,0x80165460,0x6A asm/non_matchings/code/z_play/func_80165608.s,func_80165608,0x80165608,0xA asm/non_matchings/code/z_play/func_80165630.s,func_80165630,0x80165630,0xA