summaryrefslogtreecommitdiff
path: root/include/d/snd/d_snd_small_effect_mgr.h
blob: 08b524cd934a5eccc8ad645cfd538c0f4cf34e1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#ifndef D_SND_SMALL_EFFECT_MGR_H
#define D_SND_SMALL_EFFECT_MGR_H

#include "d/snd/d_snd_source.h"
#include "d/snd/d_snd_util.h"
#include "d/snd/d_snd_wzsound.h" // IWYU pragma: export
#include "nw4r/math/math_types.h"
#include "nw4r/snd/snd_SoundHandle.h"

SND_DISPOSER_FORWARD_DECL(dSndSmallEffectMgr_c);

/**
 * An interface for playing the SE_S ("sound effect, small"?) sounds.
 */
class dSndSmallEffectMgr_c {
    SND_DISPOSER_MEMBERS(dSndSmallEffectMgr_c)

    static const s32 NUM_DELAYED_SOUNDS = 2;
    static const s32 NUM_HOLD_SOUNDS = 3;

public:
    enum BattleHitSound_e {
        BATTLE_TUTTI_NORMAL = 0,
        BATTLE_TUTTI_TURN = 1,
        BATTLE_TUTTI_JUMP = 2,
        BATTLE_TUTTI_FINISH = 3,
        BATTLE_TUTTI_GUARDJUST = 5,
    };

    dSndSmallEffectMgr_c();

    void initialize();
    void calc();
    void calcTimer();

    void stopAllSound(s32 fadeFrames);
    void stopAllSoundDemoRelated(s32 fadeFrames); // TODO: better name
    void stopAllSoundExceptEvent(s32 fadeFrames);
    void stopAllSoundExceptEffectOrLink(s32 fadeFrames);

    bool playSound(u32 soundId);
    // used for clawshots cursor, pan depends on where on the screen
    // your cursor is when it activates
    bool playSoundWithPan(u32 soundId, f32 pan);
    bool holdSound(u32 soundId);
    bool holdSoundWithPitch(u32 soundId, f32 pitch);

    // These two do the exact same thing
    bool playSoundAtPosition(u32 soundId, const nw4r::math::VEC3 *position);
    bool playSoundAtPosition2(u32 soundId, const nw4r::math::VEC3 *position);

    bool holdBowChargeSound(f32 remainingChargeAmount);
    bool holdFinisherPromptSound(const nw4r::math::VEC3 *position);

    bool playDowsingPingSound(f32 volume, f32 pitch);
    bool holdDowsingNearestSound();

    bool playSirenCountdownSound(s32 timer);
    bool playMinigameCountdownSound(s32 timer); ///< timer is unused
    bool playMinigameTimeUpSound(s32 timer);
    bool playMinigameStartSound();
    bool playMinigameFinishSound();
    bool playMinigameFinishWhistleSound();
    bool playMinigameScoreUpSound(s32 param);
    bool playMinigameScoreDownSound(s32 score);
    bool playMinigameMusasabiSound(s32 count);

    bool playSkbSound(u32 soundId);
    bool playDemoSound(u32 soundId, nw4r::snd::SoundHandle *pHandle);

    bool playButtonPressSoundWhenAdvancingTextBoxes(f32);
    void resetButtonPressSound();
    void setButtonPressSound(dSoundSource_c *source);
    bool playBattleHitSound(BattleHitSound_e type, dSoundSource_c *source);

    bool playSoundInternalChecked(u32 soundId, nw4r::snd::SoundHandle *handle);

private:
    bool playSoundInternal(u32 soundId, nw4r::snd::SoundHandle *handle);
    bool playSoundInternal(u32 soundId);
    void stopSounds(u32 playerIdx, u32 soundId, s32 fadeFrames);
    void stopSounds(u32 soundId, s32 fadeFrames);
    bool isPlayingSound(u32 playerIdx, u32 soundId);
    bool isPlayingSound(u32 soundId);

    bool doSideEffects(u32 soundId);

    void setBitsIfAdjacent(dSndBgmDataHarpVarSetBase_c *set, s32 count, s32 target, u32 *pMask);

    /**
     * Finds a sound handle currently playing the given sound,
     * or an idle sound handle,
     * or stops a lower-priority sound if needed and possible.
     */
    nw4r::snd::SoundHandle *getHoldSoundHandle(u32 soundId);
    bool holdSound(u32 soundId, nw4r::snd::SoundHandle *handle);

    /* 0x10 */ s32 field_0x10;
    // used for most sounds
    /* 0x14 */ nw4r::snd::SoundHandle mNormalSound;
    /* 0x18 */ nw4r::snd::SoundHandle mDowsingSoundHandle;
    /* 0x1C */ nw4r::snd::SoundHandle mHoldSoundHandles[NUM_HOLD_SOUNDS];

    /* 0x28 */ u32 mDelayedSoundIds[NUM_DELAYED_SOUNDS];
    /* 0x30 */ s32 mDelayedSoundTimers[NUM_DELAYED_SOUNDS];
    /* 0x38 */ u32 mTextboxAdvanceSound;
    /* 0x3C */ nw4r::snd::SoundHandle mBattleTuttiHandle;
    /* 0x40 */ s16 field_0x40;
    /* 0x42 */ s16 field_0x42;
    /* 0x44 */ u32 field_0x44;
};

#endif