summaryrefslogtreecommitdiff
path: root/include/d
diff options
context:
space:
mode:
authorrobojumper <robojumper@gmail.com>2025-07-20 21:36:03 +0200
committerrobojumper <robojumper@gmail.com>2025-09-13 11:10:28 +0200
commitac846aea3e813fb9f03b3d491ccd15ac4646ac7d (patch)
tree57d9af5d3ab8928ed7842b2b16b00123e19edba3 /include/d
parent339ee576b58abf191ea7d834dc6e1b06c3dea52b (diff)
I can't believe this function matches
Diffstat (limited to 'include/d')
-rw-r--r--include/d/snd/d_snd_bgm_harp_data.h44
-rw-r--r--include/d/snd/d_snd_bgm_sound.h2
-rw-r--r--include/d/snd/d_snd_bgm_sound_harp_mgr.h2
-rw-r--r--include/d/snd/d_snd_rng_mgr.h3
-rw-r--r--include/d/snd/d_snd_small_effect_mgr.h8
-rw-r--r--include/d/snd/d_snd_types.h2
6 files changed, 53 insertions, 8 deletions
diff --git a/include/d/snd/d_snd_bgm_harp_data.h b/include/d/snd/d_snd_bgm_harp_data.h
index fc62f9ab..3c4cee7f 100644
--- a/include/d/snd/d_snd_bgm_harp_data.h
+++ b/include/d/snd/d_snd_bgm_harp_data.h
@@ -2,6 +2,7 @@
#define D_SND_BGM_HARP_DATA_H
#include "common.h"
+#include "d/snd/d_snd_rng_mgr.h"
/**
* This file deals with the pitch of the Goddess' Harp when Link
@@ -37,6 +38,10 @@ struct dSndBgmDataHarpVar_c {
field_0x00 |= 1;
}
+ bool checkFlag() const {
+ return field_0x00 & 1;
+ }
+
/* 0x00 */ u8 field_0x00; // flags
/* 0x01 */ s8 field_0x01; // var
};
@@ -61,7 +66,7 @@ public:
mPosition = position;
}
- s32 getCount() const {
+ s32 getCount() {
return mCount;
}
@@ -69,6 +74,16 @@ public:
return mMax;
}
+ s32 getNumBitsSet() {
+ s32 numBits = 0;
+ for (int i = 0; i < getCount(); i++) {
+ if (mpVars[i].checkFlag()) {
+ numBits++;
+ }
+ }
+ return numBits;
+ }
+
dSndBgmDataHarpVar_c *getVar(s32 idx) {
if (idx >= getCount()) {
return nullptr;
@@ -76,6 +91,33 @@ public:
return &mpVars[idx];
}
+ s32 getRandomIdx() {
+ return dSndRngMgr_c::GetInstance()->rndIntRange(0, getCount());
+ }
+
+ s32 getRandomIdxWithBitSet() {
+ s32 numBitsSet = getNumBitsSet();
+ s32 idx;
+ if (numBitsSet <= 0) {
+ return 0;
+ } else {
+ idx = dSndRngMgr_c::GetInstance()->rndIntRange(0, getCount());
+ while (true) {
+ if (mpVars[idx].checkFlag()) {
+ return idx;
+ }
+ idx = dSndRngMgr_c::GetInstance()->rndIntRange(0, getCount());
+ }
+ }
+ }
+
+ s32 getVal(s32 idx) {
+ if (idx >= getCount()) {
+ return 0;
+ }
+ return mpVars[idx].field_0x01;
+ }
+
dSndBgmDataHarpVar_c *getUnusedVar() {
if (mCount >= mMax) {
return nullptr;
diff --git a/include/d/snd/d_snd_bgm_sound.h b/include/d/snd/d_snd_bgm_sound.h
index 09403fb7..3d4ccd7b 100644
--- a/include/d/snd/d_snd_bgm_sound.h
+++ b/include/d/snd/d_snd_bgm_sound.h
@@ -55,7 +55,7 @@ public:
void onBecomeActive();
bool isBgmBattle() const;
- const dSndBgmDataHarpVarSetBase_c *getCurrentHarpVarSet();
+ dSndBgmDataHarpVarSetBase_c *getCurrentHarpVarSet();
u32 getStrmPlaySamplePosition();
u32 getWavePlaySamplePosition();
diff --git a/include/d/snd/d_snd_bgm_sound_harp_mgr.h b/include/d/snd/d_snd_bgm_sound_harp_mgr.h
index 16bcdc40..34ed6df2 100644
--- a/include/d/snd/d_snd_bgm_sound_harp_mgr.h
+++ b/include/d/snd/d_snd_bgm_sound_harp_mgr.h
@@ -15,7 +15,7 @@ public:
void setPlaySamplePosition(s32 position);
- const dSndBgmDataHarpVarSetBase_c *getCurrentVarSet();
+ dSndBgmDataHarpVarSetBase_c *getCurrentVarSet();
bool isLoaded() const {
return mIsLoaded;
diff --git a/include/d/snd/d_snd_rng_mgr.h b/include/d/snd/d_snd_rng_mgr.h
index 9ef8adab..64596883 100644
--- a/include/d/snd/d_snd_rng_mgr.h
+++ b/include/d/snd/d_snd_rng_mgr.h
@@ -10,10 +10,9 @@ class dSndRngMgr_c : public dSndRng_c {
public:
SND_DISPOSER_MEMBERS(dSndRngMgr_c)
- u32 rndIntRange(s32 min, s32 max);
-
public:
dSndRngMgr_c() {}
+ u32 rndIntRange(s32 min, s32 max);
};
#endif
diff --git a/include/d/snd/d_snd_small_effect_mgr.h b/include/d/snd/d_snd_small_effect_mgr.h
index 7c6ad9d0..3e55b06a 100644
--- a/include/d/snd/d_snd_small_effect_mgr.h
+++ b/include/d/snd/d_snd_small_effect_mgr.h
@@ -82,6 +82,8 @@ private:
bool isPlayingSound(u32 playerIdx, u32 soundId);
bool isPlayingSound(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,
@@ -100,9 +102,9 @@ private:
/* 0x30 */ s32 mDelayedSoundTimers[NUM_DELAYED_SOUNDS];
/* 0x38 */ u32 mTextboxAdvanceSound;
/* 0x3C */ nw4r::snd::SoundHandle mBattleTuttiHandle;
- /* 0x40 */ u16 field_0x40;
- /* 0x42 */ u16 field_0x42;
- /* 0x44 */ s32 field_0x44;
+ /* 0x40 */ s16 field_0x40;
+ /* 0x42 */ s16 field_0x42;
+ /* 0x44 */ u32 field_0x44;
};
#endif
diff --git a/include/d/snd/d_snd_types.h b/include/d/snd/d_snd_types.h
index c156c7c1..4c835232 100644
--- a/include/d/snd/d_snd_types.h
+++ b/include/d/snd/d_snd_types.h
@@ -28,6 +28,8 @@ class dSndBgmSoundHarpMgr_c;
class dSndBgmSeqConfig;
class dSndBgmBattleConfig;
+class dSndBgmDataHarpVarSetBase_c;
+
class dSndHarpSongData_c;
class dSndTagData;