Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions code/include/z3D/z3D.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "z3Dmath.h"
#include "z3Dbgcheck.h"
#include "z3Deffect.h"
#include "z3Daudio.h"

#include "hid.h"

Expand Down Expand Up @@ -671,9 +672,6 @@ extern DrawItemTableEntry gDrawItemTable[];
extern RestrictionFlags gRestrictionFlags[];
extern MainClass gMainClass;
extern s32 gIsBottomScreenDimmed;
extern s32 sPrevMainBgmSeqId;
extern f32 gSfxDefaultFreqAndVolScale;
extern s8 gSfxDefaultReverb;

#define PLAYER ((Player*)gGlobalContext->actorCtx.actorList[ACTORTYPE_PLAYER].first)
#define GearSlot(X) (X - ITEM_SWORD_KOKIRI)
Expand All @@ -695,14 +693,6 @@ void EventSet(u32 flag);
void Rupees_ChangeBy(s16 rupeeChange);
void LinkDamage(GlobalContext* globalCtx, Player* player, s32 arg2, f32 arg3, f32 arg4, s16 arg5, s32 arg6);
u32 Inventory_HasEmptyBottle(void);
// This function plays sound effects and music tracks, overlaid on top of the current BGM
void Audio_PlayFanfare(u32);
u32 Audio_GetActiveSeqId(u8 seqPlayerIndex);
// Restores the original sequence to the main BGM player after a mini-boss battle or a minigame.
void Audio_RestoreBGM(void);
// Unknown params. Passing (0, 0) stops the BGM.
void Audio_SetBGM(u32, u32);
#define Audio_StopBGM() Audio_SetBGM(0, 0)
Actor* Actor_Spawn(ActorContext* actorCtx, GlobalContext* globalCtx, s16 actorId, float posX, float posY, float posZ,
s16 rotX, s16 rotY, s16 rotZ, s16 params, s32 initImmediately) __attribute__((pcs("aapcs-vfp")));
Actor* Actor_Find(ActorContext* actorCtx, s16 actorId, u8 actorType);
Expand All @@ -715,7 +705,6 @@ void Actor_OfferGetItem(Actor* actor, GlobalContext* globalCtx, s32 getItemId, f
void Message_CloseTextbox(GlobalContext* globalCtx);
void SetupItemInWater(Player* player, GlobalContext* globalCtx);
void Health_ChangeBy(GlobalContext* arg1, u32 arg2);
void Audio_PlaySfxGeneral(u32 sfxId, Vec3f* pos, u32 token, f32* freqScale, f32* a4, s8* reverbAdd);
void Flags_SetSwitch(GlobalContext* globalCtx, u32 flag);
void Flags_UnsetSwitch(GlobalContext* globalCtx, u32 flag);
u32 Flags_GetSwitch(GlobalContext* globalCtx, u32 flag);
Expand All @@ -725,7 +714,7 @@ u32 Flags_GetClear(GlobalContext* globalCtx, u32 flag);
u32 Flags_SetClear(GlobalContext* globalCtx, u32 flag);
void Player_SetEquipmentData(GlobalContext* globalCtx, Player* player);
s32 BossChallenge_IsActive(void);
s32 Audio_PlayActorSfx2(Actor* actor, s32 sfxID);
s32 Actor_PlaySfx(Actor* actor, s32 sfxID);
s32 Model_GetMeshGroupCount(SkeletonAnimationModel* skelAnimeModel);
s32 Model_IsMeshGroupUsed(SkeletonAnimationModel* skelAnimeModel, s32 param);
void Model_EnableMeshGroupByIndex(SkeletonAnimationModel* skel, u32 index);
Expand All @@ -745,6 +734,5 @@ void EffectSsDeadDb_Spawn(GlobalContext* globalCtx, Vec3f* position, Vec3f* velo
s16 env_b, s16 unused, s32 frame_duration, s16 play_sound);
void SaveGame(GlobalContext* globalCtx, u8 isSaveFileCreation);
s32 Message_GetState(void);
void SetEventBGM(u32 seqPlayerIndex, u32 seqId);

#endif //_Z3D_H_
38 changes: 38 additions & 0 deletions code/include/z3D/z3Daudio.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#ifndef _Z3DAUDIO_H_
#define _Z3DAUDIO_H_

#include "s_types.h"
#include "s_seq_id.h"

typedef enum SequencePlayerId {
/* 0 */ SEQ_PLAYER_BGM_MAIN,
/* 1 */ SEQ_PLAYER_FANFARE,
/* 2 */ SEQ_PLAYER_SFX,
/* 3 */ SEQ_PLAYER_BGM_SUB,
/* 4 */ SEQ_PLAYER_MAX,
} SequencePlayerId;

typedef struct UnkSequencePlayerData {
/* 0x00 */ void* vTable;
/* 0x04 */ char unk_04[0x2C];
/* 0x30 */ f32 volume;
/* 0x34 */ f32 freq;
// ...
} UnkSequencePlayerData;

extern UnkSequencePlayerData* gUnkSequencePlayerData[SEQ_PLAYER_MAX];

extern f32 gSfxDefaultFreqAndVolScale;
extern s8 gSfxDefaultReverb;
extern s32 sPrevMainBgmSeqId;

void Audio_PlaySfxGeneral(u32 sfxId, Vec3f* pos, u32 token, f32* freqScale, f32* a4, s8* reverbAdd);
// This function plays sound effects and music tracks, overlaid on top of the current BGM
void Audio_PlayFanfare(u32);
u32 Audio_GetActiveSeqId(SequencePlayerId seqPlayerIndex);
// Restores the original sequence to the main BGM player after a mini-boss battle or a minigame.
void Audio_RestoreBGM(void);
void Audio_PlaySequence(SequencePlayerId seqPlayerIndex, u32 seqId);
void Audio_StopSequence(SequencePlayerId seqPlayerId, u32 fadeOutDuration);

#endif //_Z3DAUDIO_H_
14 changes: 7 additions & 7 deletions code/oot.ld
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,7 @@ SECTIONS
EnPeehat_StateAttackRecoil = 0x2B2CC0 + _LD_OFF;
.patch_RainbowSwordTrail 0x2B9AD0 + _LD_OFF : { *(.patch_RainbowSwordTrail) }
Model_GetMeshGroupCount = 0x2BB71C + _LD_OFF;
.patch_OverrideTextID 0x2BC1C4 + _LD_OFF : { *(.patch_OverrideTextID) }
.patch_OverrideItemID 0x2BC1D0 + _LD_OFF : { *(.patch_OverrideItemID) }
.patch_OverrideItemAndTextID 0x2BC1C8 + _LD_OFF : { *(.patch_OverrideItemAndTextID) }
.patch_NoSilverGauntletsCutsceneWarp 0x2BC2A0 + _LD_OFF : { *(.patch_NoSilverGauntletsCutsceneWarp) }
.patch_RunAnimationSpeed 0x2BE70C + _LD_OFF : { *(.patch_RunAnimationSpeed) }
.patch_FishingIgnoreTempBOne 0x2C3A10 + _LD_OFF : { *(.patch_FishingIgnoreTempBOne) }
Expand Down Expand Up @@ -499,7 +498,7 @@ SECTIONS
.patch_ExtendObjectGetSlot 0x363CB4 + _LD_OFF : { *(.patch_ExtendObjectGetSlot) }
Flags_GetCollectible = 0x36405C + _LD_OFF;
EffectSsDeadDb_Spawn = 0x3642F4 + _LD_OFF;
Audio_SetBGM = 0x3655D0 + _LD_OFF;
Audio_StopSequence = 0x3655D0 + _LD_OFF;
.patch_StalchildDespawn_366338 0x366338 + _LD_OFF : { *(.patch_StalchildDespawn_366338) }
Audio_GetActiveSeqId = 0x366684 + _LD_OFF;
Flags_SetEnv = 0x366704 + _LD_OFF;
Expand All @@ -522,8 +521,8 @@ SECTIONS
Math_SmoothStepToF = 0x36E168 + _LD_OFF;
Flags_GetSwitch = 0x36E864 + _LD_OFF;
Flags_SetClear = 0x36EC14 + _LD_OFF;
.patch_SetBGMEvent 0x36EC40 + _LD_OFF : { *(.patch_SetBGMEvent) }
SetEventBGM = 0x36EC40 + _LD_OFF;
.patch_Audio_PlaySequence 0x36EC40 + _LD_OFF : { *(.patch_Audio_PlaySequence) }
Audio_PlaySequence = 0x36EC40 + _LD_OFF;
Player_GetMask = 0x36EF98 + _LD_OFF;
SetNextEntrance = 0x3716F0 + _LD_OFF;
Actor_HasParent = 0x371E40 + _LD_OFF;
Expand All @@ -548,11 +547,11 @@ SECTIONS
EnWonderTalk_Update = 0x3731F4 + _LD_OFF;
Actor_Spawn = 0x3738D0 + _LD_OFF;
.patch_ConvertBombDropTwo 0x3747A4 + _LD_OFF : { *(.patch_ConvertBombDropTwo) }
.patch_SetSFX 0x37547C + _LD_OFF : { *(.patch_SetSFX) }
.patch_Audio_PlaySfxGeneral 0x37547C + _LD_OFF : { *(.patch_Audio_PlaySfxGeneral) }
Audio_PlaySfxGeneral = 0x37547C + _LD_OFF;
Math_SmoothStepToS = 0x375A18 + _LD_OFF;
Enemy_StartFinishingBlow = 0x375B70 + _LD_OFF;
Audio_PlayActorSfx2 = 0x375BCC + _LD_OFF;
Actor_PlaySfx = 0x375BCC + _LD_OFF;
Animation_Change = 0x375C08 + _LD_OFF;
Flags_SetSwitch = 0x375C10 + _LD_OFF;
CollisionCheck_SetAC = 0x376168 + _LD_OFF;
Expand Down Expand Up @@ -882,6 +881,7 @@ SECTIONS
gSaveContext = 0x587958 + _LD_OFF;
gEffectContext = 0x58B2E0 + _LD_OFF;
gEffectSsInfo = 0x598530 + _LD_OFF;
gUnkSequencePlayerData = 0x5AF450 + _LD_OFF;
gMainClass = 0x5BE5B8 + _LD_OFF;

/* 0x005C6607: End of vanilla .bss section */
Expand Down
2 changes: 1 addition & 1 deletion code/src/actors/chest.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void EnBox_rUpdate(Actor* thisx, GlobalContext* globalCtx) {
if (gSaveContext.doubleDefense) {
healthDecrement /= 2;
}
Audio_PlayFanfare(0x100035C); // Poe laugh SFX
Audio_PlayFanfare(NA_SE_EN_PO_LAUGH);
sFairy = 0;
}

Expand Down
12 changes: 6 additions & 6 deletions code/src/actors/door.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ void EnDoor_Unlock(EnDoor* this) {
return;
}
this->action_fn = &EnDoor_Unlocking;
Audio_PlaySfxGeneral(0x10001D3, &this->base.world.pos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultReverb); // NA_SE_EV_CHAIN_KEY_UNLOCK
Audio_PlaySfxGeneral(NA_SE_EV_CHAIN_KEY_UNLOCK, &this->base.world.pos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
}

void EnDoor_Unlocking(EnDoor* this, GlobalContext* globalCtx) {
Expand Down Expand Up @@ -110,8 +110,8 @@ void DoorShutter_Unlock(DoorShutter* this) {
return;
}
this->action_fn = &DoorShutter_Unlocking;
// NA_SE_EV_CHAIN_KEY_UNLOCK : NA_SE_EV_CHAIN_KEY_UNLOCK_B
u32 sfx_id = this->door_type_maybe != 5 ? 0x10001D3 : 0x1000200;

u32 sfx_id = this->door_type_maybe != 5 ? NA_SE_EV_CHAIN_KEY_UNLOCK : NA_SE_EV_CHAIN_KEY_UNLOCK_B;
Audio_PlaySfxGeneral(sfx_id, &this->base.world.pos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultReverb);
}
Expand Down Expand Up @@ -151,6 +151,6 @@ void DoorGerudo_Unlock(DoorGerudo* this) {
return;
}
this->action_fn = DoorGerudo_Unlocking;
Audio_PlaySfxGeneral(0x10001D3, &this->base.world.pos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultReverb); // NA_SE_EV_CHAIN_KEY_UNLOCK
Audio_PlaySfxGeneral(NA_SE_EV_CHAIN_KEY_UNLOCK, &this->base.world.pos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
}
6 changes: 3 additions & 3 deletions code/src/actors/flare_dancer.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void EnFd_rUpdate(Actor* thisx, GlobalContext* globalCtx) {
EnFd* this = (EnFd*)thisx;

Actor* prevEnemiesHead = globalCtx->actorCtx.actorList[ACTORTYPE_ENEMY].first;
u32 prevBgm = Audio_GetActiveSeqId(0);
u32 prevBgm = Audio_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN);

EnFd_Update(thisx, globalCtx);

Expand Down Expand Up @@ -68,11 +68,11 @@ void EnFd_rUpdate(Actor* thisx, GlobalContext* globalCtx) {
}

// If Flare Dancer started the Mini-Boss battle theme, disable it immediately
if (prevBgm != BGM_MINI_BOSS && Audio_GetActiveSeqId(0) == BGM_MINI_BOSS) {
if (prevBgm != NA_BGM_MIDDLE_BOSS && Audio_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) == NA_BGM_MIDDLE_BOSS) {
if (sPrevMainBgmSeqId != -1) {
Audio_RestoreBGM();
} else {
Audio_StopBGM();
Audio_StopSequence(SEQ_PLAYER_BGM_MAIN, 0);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions code/src/actors/graveyard_objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ void BgSpot02Objects_rUpdate(Actor* thisx, GlobalContext* globalCtx) {
}

void BgSpot02Objects_ExplodeGrave(BgSpot02Objects* this) {
Audio_PlaySfxGeneral(0x1000219, &this->base.world.pos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultReverb); // NA_SE_EV_GRAVE_EXPLOSION
Audio_PlaySfxGeneral(NA_SE_EV_GRAVE_EXPLOSION, &this->base.world.pos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
this->timer = 38;
this->action_fn = BgSpot02Objects_Explode;
}
4 changes: 2 additions & 2 deletions code/src/actors/lake_hylia_objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void BgSpot06Objects_rUpdate(Actor* thisx, GlobalContext* globalCtx) {
if (globalCtx->actorCtx.flags.tempSwch & (0x40 << 24)) { // switch pressed
if (thisx->params == 0x0002 && gSaveContext.eventChkInf[6] & 0x0200) { // if water is raised, lower it
waterMovement = -1;
Audio_PlayFanfare(0x100025B);
Audio_PlayFanfare(NA_SE_EV_WATER_LEVEL_DOWN_STOP);
gSaveContext.eventChkInf[6] &= ~0x0200;
// TODO: remove this warp when the water will properly move
globalCtx->nextEntranceIndex = 0x0604;
Expand All @@ -67,7 +67,7 @@ void BgSpot06Objects_rUpdate(Actor* thisx, GlobalContext* globalCtx) {
} else {
if (thisx->params == 0x0002 && !(gSaveContext.eventChkInf[6] & 0x0200)) {
waterMovement = 1;
Audio_PlayFanfare(0x100025B);
Audio_PlayFanfare(NA_SE_EV_WATER_LEVEL_DOWN_STOP);
gSaveContext.eventChkInf[6] |= 0x0200;
// TODO: remove this warp when the water will properly move
globalCtx->nextEntranceIndex = 0x0604;
Expand Down
11 changes: 4 additions & 7 deletions code/src/actors/red_ice.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,25 @@
#include "settings.h"
#include "red_ice.h"

#define ACTOR_BG_ICE_SHELTER 0xEF // Red Ice
#define ACTOR_EN_ARROW 0x16
#define ARROW_ICE 4

void BgIceShelter_Melt(BgIceShelter* this, GlobalContext* globalCtx);
#define NA_SE_EV_ICE_MELT 0x10001F9

void RedIce_CheckIceArrow(Collider* at, Collider* ac) {
if (gSettingsContext.extraArrowEffects && at->actor != 0 && at->actor->id == ACTOR_EN_ARROW &&
at->actor->params == ARROW_ICE && ac->actor != 0 && ac->actor->id == ACTOR_BG_ICE_SHELTER) {
if (gSettingsContext.extraArrowEffects && at->actor != NULL && at->actor->id == ACTOR_ARROW &&
at->actor->params == ARROW_ICE && ac->actor != NULL && ac->actor->id == ACTOR_RED_ICE) {

BgIceShelter* ice = (BgIceShelter*)ac->actor;
s16 type = (ice->dyna.actor.params >> 8) & 7;

if (type == RED_ICE_KING_ZORA) {
if (ice->dyna.actor.parent != 0) {
if (ice->dyna.actor.parent != NULL) {
ice->dyna.actor.parent->freezeTimer = 50;
}
}

ice->actionFunc = BgIceShelter_Melt;
ice->alpha = 0xFF;
Audio_PlayActorSfx2(&ice->dyna.actor, NA_SE_EV_ICE_MELT);
Actor_PlaySfx(&ice->dyna.actor, NA_SE_EV_ICE_MELT);
}
}
4 changes: 1 addition & 3 deletions code/src/actors/twinrova.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ void Boss_Tw_Update(Actor* thisx, GlobalContext* globalCtx);
void Boss_Tw_Draw(Actor* thisx, GlobalContext* globalCtx);
void Boss_Tw_Destroy(Actor* thisx, GlobalContext* globalCtx);

#define BOSS_BATTLE_BGM 0x1000589

static u8 fightStarted = 0;
static u8 appeared = 0;

Expand All @@ -27,7 +25,7 @@ void Boss_Tw_rUpdate(Actor* thisx, GlobalContext* globalCtx) {

if (!fightStarted && pos.x > -100 && pos.x < 100 && pos.y > 200 && pos.z > -100 && pos.z < 100) {
fightStarted = 1;
SetEventBGM(0, BOSS_BATTLE_BGM);
Audio_PlaySequence(SEQ_PLAYER_BGM_MAIN, NA_BGM_BOSS00);
}

if (fightStarted) {
Expand Down
43 changes: 14 additions & 29 deletions code/src/asm/hooks.s
Original file line number Diff line number Diff line change
Expand Up @@ -72,33 +72,16 @@ HOOK SaveFile_Init
strb r1,[r0,#0x35]
bx lr

.global rActiveItemRow
.rActiveItemRow_addr:
.word rActiveItemRow

HOOK OverrideTextID
ldr r1,.rActiveItemRow_addr
ldr r1,[r1]
cmp r1,#0x0
beq noOverrideTextID
b 0x2BC1D0
noOverrideTextID:
ldrb r1,[r6,#0x4]
b 0x2BC1C8

HOOK OverrideItemID
ldr r1,.rActiveItemRow_addr
ldr r1,[r1]
cmp r1,#0x0
beq noOverrideItemID
HOOK OverrideItemAndTextID
cpy r0,r7 @ globalCtx
push {r0-r12, lr}
cpy r0,r2
bl ItemOverride_GetItemTextAndItemID
cpy r1,r4 @ player
bl ItemOverride_GetOverheadItem
cmp r0,#0x0
pop {r0-r12, lr}
b 0x2BC1DC
noOverrideItemID:
ldrb r1,[r6,#0x0]
b 0x2BC1D4
bxlt lr @ resume vanilla code
beq 0x2BC1DC @ skip text and item
b 0x2BC354 @ skip text, item and fanfare

HOOK OverrideDrawItemOne
push {r1-r12, lr}
Expand Down Expand Up @@ -168,9 +151,11 @@ HOOK DaruniaStrengthCheck

HOOK GetToken
push {r0-r12, lr}
cpy r0,r4
cpy r0,r4 @ token actor
bl ItemOverride_GetSkulltulaToken
cmp r0,#0x0
pop {r0-r12, lr}
addne lr,lr,#0x20 @ skip playing fanfare
bx lr

HOOK PoeCollectorCheckPoints
Expand Down Expand Up @@ -776,7 +761,7 @@ HOOK GearMenuEmptySlot

HOOK Audio_PlayFanfare
push {r1-r12, lr}
bl SetBGM
bl Bgm_OverrideFanfare
pop {r1-r12, lr}
push {r3-r7, lr}
b 0x35C52C
Expand All @@ -795,7 +780,7 @@ HOOK SetBGMDayNight
push {r4-r6, lr}
b ret_SetBGMDayNight

HOOK SetBGMEvent
HOOK Audio_PlaySequence
push {r0, r2-r12, lr}
cpy r0,r1
bl SetBGM
Expand All @@ -804,7 +789,7 @@ HOOK SetBGMEvent
push {r4-r11, lr}
b 0x36EC44

HOOK SetSFX
HOOK Audio_PlaySfxGeneral
push {r1-r12, lr}
bl SetSFX
pop {r1-r12, lr}
Expand Down
Loading