mirror of
https://github.com/zeldaret/ss
synced 2026-08-27 16:36:49 -04:00
d_snd_bgm_seq_data_mgr, d_snd_bgm_seq_config OK
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
#include "d/snd/d_snd_bgm_battle_data_mgr.h"
|
||||
#include "d/snd/d_snd_bgm_sound_harp_mgr.h"
|
||||
|
||||
#include "d/snd/d_snd_util.h"
|
||||
|
||||
SND_DISPOSER_DEFINE(dSndBgmBattleDataMgr_c)
|
||||
|
||||
dSndBgmBattleDataMgr_c::dSndBgmBattleDataMgr_c() : field_0x14(0) {
|
||||
mpMgrs = new dSndBgmSoundHarpMgr_c[2];
|
||||
}
|
||||
|
||||
const char *dSndBgmBattleDataMgr_c::getDataPrefix() {
|
||||
return "DATA_";
|
||||
}
|
||||
|
||||
u32 dSndBgmBattleDataMgr_c::getDataPrefixLength() {
|
||||
return std::strlen(getDataPrefix());
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "common.h"
|
||||
#include "d/snd/d_snd_mgr.h"
|
||||
#include "d/snd/d_snd_bgm_sound_harp_mgr.h"
|
||||
#include "d/snd/d_snd_bgm_battle_data_mgr.h"
|
||||
#include "d/snd/d_snd_bgm_seq_data_mgr.h"
|
||||
#include "d/snd/d_snd_player_mgr.h"
|
||||
#include "nw4r/snd/snd_SoundArchive.h"
|
||||
#include "sized_string.h"
|
||||
@@ -21,7 +21,7 @@ bool dSndBgmMmlParserHarp_c::parseData(const char *soundLabel, u32 baseSoundId,
|
||||
bool ok = false;
|
||||
field_0x294->reset();
|
||||
SizedString<64> dataLabel;
|
||||
dataLabel.sprintf("%s%s", dSndBgmBattleDataMgr_c::getDataPrefix(), soundLabel);
|
||||
dataLabel.sprintf("%s%s", dSndBgmSeqDataMgr_c::getDataPrefix(), soundLabel);
|
||||
u32 dataId = dSndPlayerMgr_c::GetInstance()->convertLabelStringToSoundId(dataLabel);
|
||||
if (dataId != -1 && dSndMgr_c::GetInstance()->getArchive()->GetSoundType(dataId) == nw4r::snd::SoundArchive::SOUND_TYPE_SEQ) {
|
||||
ok = loadAndParse(dataId, trackMask, true);
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
#include "d/snd/d_snd_bgm_seq_config.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "d/snd/d_snd_wzsound.h"
|
||||
|
||||
static const dSndBgmBattleConfig sBattleConfigs[] = {
|
||||
{ BGM_BATTLE2, {{(1 << 7) | (1 << 4) | (1 << 3), 0}, {(1 << 9) | (1 << 6), 0}, {0, 0}}},
|
||||
{BGM_BATTLE_ROOM_MAIN, {{(1 << 7) | (1 << 4), 0}, {(1 << 9), 0}, {0, 0}}},
|
||||
{ BGM_MIDDLE_BOSS, {{(1 << 1), 0}, {(1 << 2), 0}, {0, 0}}}
|
||||
};
|
||||
|
||||
const dSndBgmBattleConfig *dSndBgmBattleConfig::getConfig(u32 soundId) {
|
||||
for (int i = 0; i < ARRAY_LENGTH(sBattleConfigs); i++) {
|
||||
if (soundId == sBattleConfigs[i].soundId) {
|
||||
return &sBattleConfigs[i];
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool dSndBgmBattleConfig::hasConfig(u32 soundId) {
|
||||
if (soundId == -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < ARRAY_LENGTH(sBattleConfigs); i++) {
|
||||
if (soundId == sBattleConfigs[i].soundId) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static const dSndBgmSeqConfig sBgmConfigs[] = {
|
||||
{ BGM_BATTLE2, 0, 0x180, 1, 4},
|
||||
{ BGM_BATTLE2, 1, 0x180, 5, 0x2F},
|
||||
{BGM_BATTLE_ROOM_MAIN, 1, 0x180, 5, 0x2C},
|
||||
{ BGM_MUTE, 1, 0x120, 0, 0x1F},
|
||||
};
|
||||
|
||||
const dSndBgmSeqConfig *dSndBgmSeqConfig::getConfig(u32 soundId, s32 unkParam) {
|
||||
if (soundId == -1) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
for (const dSndBgmSeqConfig *def = sBgmConfigs; def < sBgmConfigs + ARRAY_LENGTH(sBgmConfigs); def++) {
|
||||
if (soundId == def->soundId && def->field_0x04 == unkParam) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
#include "d/snd/d_snd_bgm_seq_data_mgr.h"
|
||||
#include "common.h"
|
||||
#include "d/snd/d_snd_bgm_mgr.h"
|
||||
#include "d/snd/d_snd_bgm_mml_parsers.h"
|
||||
#include "d/snd/d_snd_bgm_sound_harp_mgr.h"
|
||||
|
||||
#include "d/snd/d_snd_mgr.h"
|
||||
#include "d/snd/d_snd_player_mgr.h"
|
||||
#include "d/snd/d_snd_util.h"
|
||||
#include "d/snd/d_snd_wzsound.h"
|
||||
|
||||
SND_DISPOSER_DEFINE(dSndBgmSeqDataMgr_c)
|
||||
|
||||
dSndBgmSeqDataMgr_c::dSndBgmSeqDataMgr_c() : mInitialized(false) {
|
||||
mpMgrs = new dSndBgmSoundHarpMgr_c[NUM_SOUNDS];
|
||||
}
|
||||
|
||||
const char *dSndBgmSeqDataMgr_c::getDataPrefix() {
|
||||
return "DATA_";
|
||||
}
|
||||
|
||||
u32 dSndBgmSeqDataMgr_c::getDataPrefixLength() {
|
||||
return std::strlen(getDataPrefix());
|
||||
}
|
||||
|
||||
void dSndBgmSeqDataMgr_c::initialize() {
|
||||
// no-op
|
||||
}
|
||||
|
||||
void dSndBgmSeqDataMgr_c::setupState0() {
|
||||
if (mInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
// DATA_BGM_BATTLE2, DATA_BGM_BATTLE2_OUTRO
|
||||
for (int i = 0; i < NUM_SOUNDS; i++) {
|
||||
u32 dataId = DATA_BGM_BATTLE2 + i;
|
||||
const char *baseLabel = dSndMgr_c::getSoundLabelString(dataId) + getDataPrefixLength();
|
||||
u32 baseSoundId = dSndPlayerMgr_c::GetInstance()->convertLabelStringToSoundId(baseLabel);
|
||||
dSndBgmMmlParserHarp_c parser(&mpMgrs[i]);
|
||||
(void)dSndBgmMgr_c::isSoundPlayedByBgmBattlePlayer(dataId);
|
||||
parser.parseData(baseSoundId, (1 << 15) | (1 << 0));
|
||||
}
|
||||
|
||||
mInitialized = true;
|
||||
}
|
||||
|
||||
dSndBgmSoundHarpMgr_c *dSndBgmSeqDataMgr_c::getHarpMgrForSoundId(u32 soundId) {
|
||||
if (soundId == -1) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
for (dSndBgmSoundHarpMgr_c *it = &mpMgrs[0]; it < &mpMgrs[NUM_SOUNDS]; it++) {
|
||||
if (it->getSoundId() == soundId) {
|
||||
return it;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
#include "d/snd/d_snd_bgm_sound.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "d/snd/d_snd_bgm_battle_data_mgr.h"
|
||||
#include "d/snd/d_snd_bgm_mgr.h"
|
||||
#include "d/snd/d_snd_bgm_mml_parsers.h"
|
||||
#include "d/snd/d_snd_bgm_seq_config.h"
|
||||
#include "d/snd/d_snd_bgm_seq_data_mgr.h"
|
||||
#include "d/snd/d_snd_mgr.h"
|
||||
#include "d/snd/d_snd_player_mgr.h"
|
||||
#include "d/snd/d_snd_sound.h"
|
||||
@@ -17,6 +18,7 @@
|
||||
#include "nw4r/snd/snd_WaveSoundHandle.h"
|
||||
#include "toBeSorted/music_mgrs.h"
|
||||
|
||||
|
||||
dSndBgmSoundHarpMgr_c *dSndBgmSound_c::spGlobalHarpMgr;
|
||||
|
||||
dSndBgmSound_c::dSndBgmSound_c()
|
||||
@@ -153,7 +155,8 @@ nw4r::snd::SoundStartable::StartResult dSndBgmSound_c::startBgmSound(u32 soundId
|
||||
mSeqTempo = mpHarpMgr->getTempo();
|
||||
}
|
||||
|
||||
if (mSeqTempo > 0 && dSndMgr_c::GetInstance()->getArchive()->GetSoundType(soundId) == nw4r::snd::SoundArchive::SOUND_TYPE_SEQ) {
|
||||
if (mSeqTempo > 0 && dSndMgr_c::GetInstance()->getArchive()->GetSoundType(soundId) ==
|
||||
nw4r::snd::SoundArchive::SOUND_TYPE_SEQ) {
|
||||
mSeqPlaySamplePosition = (mSeqTempo * startOffset * 0xC0);
|
||||
mSeqPlaySamplePosition /= 120000;
|
||||
info.startOffsetType = nw4r::snd::SoundStartable::StartInfo::START_OFFSET_TYPE_TICK;
|
||||
@@ -232,6 +235,15 @@ void dSndBgmSound_c::fadeIn(u32 id, s32 fadeFrames) {
|
||||
}
|
||||
}
|
||||
|
||||
void dSndBgmSound_c::loadSeqConfig(u32 soundId) {
|
||||
if (dSndMgr_c::GetInstance()->getArchive()->GetSoundType(soundId) == nw4r::snd::SoundArchive::SOUND_TYPE_SEQ) {
|
||||
mpSeqConfig = dSndBgmSeqConfig::getConfig(soundId, 1);
|
||||
if (mpSeqConfig != nullptr) {
|
||||
field_0x118 = mpSeqConfig->field_0x08;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Largely a copy of dSndSound_c::prepareSound, with changes to support different startable
|
||||
nw4r::snd::SoundStartable::StartResult dSndBgmSound_c::prepareSound(u32 soundId, u32 startOffset) {
|
||||
if (soundId == -1) {
|
||||
@@ -454,7 +466,7 @@ void dSndBgmSound_c::getHarpData(u32 soundId) {
|
||||
return;
|
||||
}
|
||||
|
||||
dSndBgmSoundHarpMgr_c *mgr = dSndBgmBattleDataMgr_c::GetInstance()->getHarpMgrForSoundId(soundId);
|
||||
dSndBgmSoundHarpMgr_c *mgr = dSndBgmSeqDataMgr_c::GetInstance()->getHarpMgrForSoundId(soundId);
|
||||
if (mgr != nullptr) {
|
||||
mpHarpMgr = mgr;
|
||||
} else {
|
||||
|
||||
@@ -41,7 +41,7 @@ dSndStateMgr_c::dSndStateMgr_c()
|
||||
field_0x088(0),
|
||||
mSoundEventId(SND_EVENT_0x89),
|
||||
field_0x090(0),
|
||||
field_0x094(0),
|
||||
mEventFlags(0),
|
||||
field_0x118(nullptr),
|
||||
field_0x11C(0),
|
||||
field_0x120(0),
|
||||
@@ -210,7 +210,7 @@ void dSndStateMgr_c::initializeEventCallbacks(const char *name) {
|
||||
sEventExecuteCallback = nullptr;
|
||||
resetOverrides();
|
||||
|
||||
if (checkEventFlag(EVENT_0x2)) {
|
||||
if (checkEventFlag(EVENT_DEMO)) {
|
||||
handleDemoEvent(name);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user