mirror of https://github.com/zeldaret/botw.git
ksys/snd: Add MusicDefinition
This commit is contained in:
parent
754523a246
commit
1322b57b55
|
@ -86097,16 +86097,16 @@
|
|||
0x0000007101014450,sub_7101014450,24,
|
||||
0x0000007101014468,sub_7101014468,52,
|
||||
0x000000710101449c,registerBmscdefEntryFactory,392,
|
||||
0x0000007101014624,ResourceBmscdef::doCreate,1716,
|
||||
0x0000007101014cd8,sub_7101014CD8,324,
|
||||
0x0000007101014e1c,sub_7101014E1C,364,
|
||||
0x0000007101014f88,sub_7101014F88,316,
|
||||
0x00000071010150c4,sub_71010150C4,288,
|
||||
0x00000071010151e4,sub_71010151E4,92,
|
||||
0x0000007101015240,sub_7101015240,44,
|
||||
0x000000710101526c,sub_710101526C,76,
|
||||
0x00000071010152b8,sub_71010152B8,52,
|
||||
0x00000071010152ec,sub_71010152EC,80,
|
||||
0x0000007101014624,ResourceBmscdef::doCreate,1716,_ZN4ksys3snd15MusicDefinition9doCreate_EPhjPN4sead4HeapE!
|
||||
0x0000007101014cd8,sub_7101014CD8,324,_ZNK4ksys3snd15MusicDefinition19getMusicIndexByNameERKN4sead14SafeStringBaseIcEE
|
||||
0x0000007101014e1c,sub_7101014E1C,364,_ZNK4ksys3snd15MusicDefinition22getMusicCategoryByNameERKN4sead14SafeStringBaseIcEE
|
||||
0x0000007101014f88,sub_7101014F88,316,_ZNK4ksys3snd15MusicDefinition30getPriorityValueByCategoryNameERKN4sead14SafeStringBaseIcEE
|
||||
0x00000071010150c4,sub_71010150C4,288,_ZNK4ksys3snd15MusicDefinition27checkDerivedRuntimeTypeInfoEPKN4sead15RuntimeTypeInfo9InterfaceE
|
||||
0x00000071010151e4,sub_71010151E4,92,_ZNK4ksys3snd15MusicDefinition18getRuntimeTypeInfoEv
|
||||
0x0000007101015240,sub_7101015240,44,_ZN4ksys3snd15MusicDefinitionD2Ev
|
||||
0x000000710101526c,sub_710101526C,76,_ZN4ksys3snd15MusicDefinitionD0Ev
|
||||
0x00000071010152b8,sub_71010152B8,52,_ZThn32_N4ksys3snd15MusicDefinitionD1Ev
|
||||
0x00000071010152ec,sub_71010152EC,80,_ZThn32_N4ksys3snd15MusicDefinitionD0Ev
|
||||
0x000000710101533c,sub_710101533C,108,
|
||||
0x00000071010153a8,sub_71010153A8,116,
|
||||
0x000000710101541c,sub_710101541C,132,
|
||||
|
|
Can't render this file because it is too large.
|
|
@ -1,6 +1,8 @@
|
|||
target_sources(uking PRIVATE
|
||||
sndInfoData.cpp
|
||||
sndInfoData.h
|
||||
sndMusicDefinition.cpp
|
||||
sndMusicDefinition.h
|
||||
sndResource.cpp
|
||||
sndResource.h
|
||||
)
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
#include "KingSystem/Sound/sndMusicDefinition.h"
|
||||
|
||||
namespace ksys::snd {
|
||||
|
||||
static sead::SafeString str_EventBgm = "EventBgm";
|
||||
|
||||
// NON_MATCHING: two bigger diffs cause a different regalloc
|
||||
// 1. During `SafeString` generation of line
|
||||
// `auto categoryDefines_list = agl::utl::getResParameterList(root_list, "CategoryDefines");`
|
||||
// 2. Mis-ordered operations around
|
||||
// `addList(&mCategoryList, "CategoryDefines");`
|
||||
void MusicDefinition::doCreate_(u8* data, u32 file_size, sead::Heap* heap) {
|
||||
auto archive = agl::utl::ResParameterArchive(data);
|
||||
auto root_list = archive.getRootList();
|
||||
|
||||
auto musicDefines_list = agl::utl::getResParameterList(root_list, "MusicDefines");
|
||||
if (musicDefines_list) {
|
||||
s32 musicDefines_list_length = musicDefines_list.getResParameterObjNum();
|
||||
if (musicDefines_list_length == 0) {
|
||||
return;
|
||||
}
|
||||
mMusicDefines.allocBufferAssert(musicDefines_list_length, heap);
|
||||
|
||||
for (auto it = mMusicDefines.begin(), end = mMusicDefines.end(); it != end; ++it) {
|
||||
auto param_obj = &it->param_obj;
|
||||
it->name.init("", "Name", param_obj);
|
||||
it->category.init("", "Category", param_obj);
|
||||
it->volume.init(1, "Volume", param_obj);
|
||||
it->is_enable_weather_filter.init(false, "IsEnableWeatherFilter", param_obj);
|
||||
it->is_indoor_ducking.init(false, "IsIndoorDucking", param_obj);
|
||||
|
||||
mMusicList.addObj(param_obj,
|
||||
sead::FormatFixedSafeString<32>("MusicDefine_%d", it.getIndex()));
|
||||
}
|
||||
|
||||
addList(&mMusicList, "MusicDefines");
|
||||
}
|
||||
|
||||
auto categoryDefines_list = agl::utl::getResParameterList(root_list, "CategoryDefines");
|
||||
if (categoryDefines_list) {
|
||||
s32 categoryDefines_list_length = categoryDefines_list.getResParameterObjNum();
|
||||
if (categoryDefines_list_length == 0)
|
||||
return;
|
||||
mCategoryDefines.allocBufferAssert(categoryDefines_list_length, heap);
|
||||
|
||||
for (auto it = mCategoryDefines.begin(), end = mCategoryDefines.end(); it != end; ++it) {
|
||||
it->name.init("", "Name", &it->param_obj);
|
||||
it->priority_value.init(0, "PriorityValue", &it->param_obj);
|
||||
|
||||
mCategoryList.addObj(&it->param_obj, sead::FormatFixedSafeString<32>(
|
||||
"CategoryDefine_%d", it.getIndex()));
|
||||
}
|
||||
|
||||
addList(&mCategoryList, "CategoryDefines");
|
||||
}
|
||||
|
||||
if (data)
|
||||
applyResParameterArchive(agl::utl::ResParameterArchive(data));
|
||||
|
||||
for (auto& music : mMusicDefines) {
|
||||
if (music.category.ref() == str_EventBgm) {
|
||||
music.is_event_bgm = true;
|
||||
mEventBgmCount++;
|
||||
} else {
|
||||
music.is_event_bgm = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int MusicDefinition::getMusicIndexByName(const sead::SafeString& name) const {
|
||||
for (int i = 0; i < mMusicDefines.size(); i++) {
|
||||
if (mMusicDefines.get(i)->name.ref() == name) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
const sead::SafeString&
|
||||
MusicDefinition::getMusicCategoryByName(const sead::SafeString& name) const {
|
||||
for (int i = 0; i < mMusicDefines.size(); i++) {
|
||||
if (mMusicDefines.get(i)->name.ref() == name) {
|
||||
return mMusicDefines.get(i)->category.ref();
|
||||
}
|
||||
}
|
||||
return sead::SafeString::cEmptyString;
|
||||
}
|
||||
|
||||
int MusicDefinition::getPriorityValueByCategoryName(const sead::SafeString& name) const {
|
||||
for (int i = 0; i < mCategoryDefines.size(); i++) {
|
||||
auto element = mCategoryDefines.get(i);
|
||||
if (element->name.ref() == name) {
|
||||
return element->priority_value.ref();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace ksys::snd
|
|
@ -0,0 +1,46 @@
|
|||
#pragma once
|
||||
|
||||
#include <agl/Utils/aglParameter.h>
|
||||
#include <agl/Utils/aglParameterIO.h>
|
||||
#include <agl/Utils/aglParameterList.h>
|
||||
#include <agl/Utils/aglParameterObj.h>
|
||||
#include <container/seadBuffer.h>
|
||||
#include <resource/seadResource.h>
|
||||
#include "KingSystem/Utils/Types.h"
|
||||
|
||||
namespace ksys::snd {
|
||||
|
||||
class MusicDefinition : public sead::DirectResource, public agl::utl::IParameterIO {
|
||||
SEAD_RTTI_OVERRIDE(MusicDefinition, sead::DirectResource)
|
||||
|
||||
public:
|
||||
struct MusicDefine {
|
||||
agl::utl::Parameter<sead::SafeString> name;
|
||||
agl::utl::Parameter<sead::SafeString> category;
|
||||
agl::utl::Parameter<float> volume;
|
||||
agl::utl::Parameter<bool> is_enable_weather_filter;
|
||||
agl::utl::Parameter<bool> is_indoor_ducking;
|
||||
bool is_event_bgm;
|
||||
agl::utl::ParameterObj param_obj;
|
||||
};
|
||||
struct CategoryDefine {
|
||||
agl::utl::Parameter<sead::SafeString> name;
|
||||
agl::utl::Parameter<u32> priority_value;
|
||||
agl::utl::ParameterObj param_obj;
|
||||
};
|
||||
|
||||
void doCreate_(u8* data, u32 file_size, sead::Heap* heap) override;
|
||||
int getMusicIndexByName(const sead::SafeString& name) const;
|
||||
const sead::SafeString& getMusicCategoryByName(const sead::SafeString& name) const;
|
||||
int getPriorityValueByCategoryName(const sead::SafeString& name) const;
|
||||
|
||||
private:
|
||||
sead::Buffer<MusicDefine> mMusicDefines;
|
||||
agl::utl::ParameterList mMusicList;
|
||||
int mEventBgmCount = 0;
|
||||
sead::Buffer<CategoryDefine> mCategoryDefines;
|
||||
agl::utl::ParameterList mCategoryList;
|
||||
};
|
||||
KSYS_CHECK_SIZE_NX150(MusicDefinition, 0x2A8);
|
||||
|
||||
} // namespace ksys::snd
|
Loading…
Reference in New Issue