diff --git a/configure.py b/configure.py index 05d98548..0a4ce20f 100755 --- a/configure.py +++ b/configure.py @@ -1065,7 +1065,7 @@ def MatchingFor(*versions): Object(Matching, "Inagaki/NpcCarSoundMgr.cpp"), Object(Matching, "Inagaki/ObjectSoundMgr.cpp"), Object(Matching, "Inagaki/RockSoundMgr.cpp"), - Object(NonMatching, "Inagaki/GameSoundTable.cpp"), + Object(Matching, "Inagaki/GameSoundTable.cpp"), Object(NonMatching, "Inagaki/ShoreSoundMgr.cpp"), Object(NonMatching, "Inagaki/CircleSoundMgr.cpp"), Object(Matching, "Inagaki/CoasterSoundMgr.cpp"), diff --git a/include/Inagaki/GameSoundTable.h b/include/Inagaki/GameSoundTable.h index 776f698e..16e72102 100644 --- a/include/Inagaki/GameSoundTable.h +++ b/include/Inagaki/GameSoundTable.h @@ -7,28 +7,33 @@ namespace GameAudio { - class CustomSoundTable : public JAISoundInfo, public JAUSoundInfo, public JAIStreamDataMgr, public JASGlobalInstance + class CustomSoundTable : public JAISoundInfo, public JAUSoundInfo, public JAIStreamDataMgr { public: virtual u32 getSoundType(JAISoundID soundID) const; virtual int getCategory(JAISoundID soundID) const; + virtual u32 getPriority(JAISoundID soundID) const; virtual void getSeInfo(JAISoundID soundID, JAISe *se) const; - virtual void getSeqInfo(JAISoundID soundID, JAISeq *seq) const ; + virtual void getSeqInfo(JAISoundID soundID, JAISeq *seq) const; virtual void getStreamInfo(JAISoundID soundID, JAIStream *stream) const; - virtual ~CustomSoundTable(); - virtual void getAudibleSw(JAISoundID soundID) const; + virtual ~CustomSoundTable(){}; + virtual u16 getAudibleSw(JAISoundID soundID) const; virtual u16 getBgmSeqResourceID(JAISoundID soundID) const; - + virtual u8 getPTrack(JAISoundID soundID) const; virtual u32 getSwBit(JAISoundID soundID) const; virtual u8 getLevelFlag(JAISoundID soundID) const; virtual s32 getStreamFileEntry(JAISoundID soundID); void initAudibleSw(); + + // UNUSED + void getStreamFilePath(JAISoundID soundID); + private: - JAISoundInfo *getSoundInfo_(JAISoundID soundID, JAISound *sound) const; + void getSoundInfo_(JAISoundID soundID, JAISound *sound) const; }; } diff --git a/include/JSystem/JAudio/Interface/JAISound.h b/include/JSystem/JAudio/Interface/JAISound.h index 5288cdf1..b4f9ccfe 100644 --- a/include/JSystem/JAudio/Interface/JAISound.h +++ b/include/JSystem/JAudio/Interface/JAISound.h @@ -392,17 +392,17 @@ class JAISound JAISoundParamsMove &getAuxiliary() { return params_.mMove; } // private: - JAISoundHandle *handle_; - JAIAudible *audible_; - JAIAudience *audience_; - u32 lifeTime_; - s32 prepareCount_; - JAISoundID soundID_; - JAISoundStatus_ status_; - JAISoundFader fader_; - u32 priority_; - s32 count_; - JAISoundParams params_; + JAISoundHandle *handle_; // 04 + JAIAudible *audible_; // 08 + JAIAudience *audience_; // 0c + u32 lifeTime_; // 10 + s32 prepareCount_; // 14 + JAISoundID soundID_; // 18 + JAISoundStatus_ status_; // 1c + JAISoundFader fader_; // 24 + u32 priority_; // 34 + s32 count_; // 38 + JAISoundParams params_; // 3a }; // Size: 0x98 #endif diff --git a/include/JSystem/JAudio/JAUSoundInfo.h b/include/JSystem/JAudio/JAUSoundInfo.h index 4b9531fa..3be62992 100644 --- a/include/JSystem/JAudio/JAUSoundInfo.h +++ b/include/JSystem/JAudio/JAUSoundInfo.h @@ -8,7 +8,7 @@ class JAUSoundInfo : public JASGlobalInstance { public: JAUSoundInfo(bool param_1) : JASGlobalInstance(param_1) {} - virtual void getAudibleSw(JAISoundID) const = 0; + virtual u16 getAudibleSw(JAISoundID) const = 0; virtual u16 getBgmSeqResourceID(JAISoundID) const = 0; }; diff --git a/include/JSystem/JAudio/JAUSoundTable.h b/include/JSystem/JAudio/JAUSoundTable.h index e10c79c9..69c6a5e5 100644 --- a/include/JSystem/JAudio/JAUSoundTable.h +++ b/include/JSystem/JAudio/JAUSoundTable.h @@ -6,11 +6,15 @@ struct JAUSoundTableItem { - u8 mPriority; - u8 _1; - u16 mResourceId; - u32 _4; - f32 _8; + u8 mPriority; // 00 + u8 _1; // (Other type of priority?) 01 + u16 mResourceId; // 02 + u32 mSwBit; // 04 + u8 _8; // 08 + u8 mPTrack; // 09 + u16 mSeqResourceID; // 0a + u32 _c; // 0c + u16 mAudibleSw; // 10 }; template diff --git a/src/Inagaki/GameSoundTable.cpp b/src/Inagaki/GameSoundTable.cpp index 059f2506..575fd961 100644 --- a/src/Inagaki/GameSoundTable.cpp +++ b/src/Inagaki/GameSoundTable.cpp @@ -1,36 +1,270 @@ #include "Inagaki/GameSoundTable.h" #include "JSystem/JAudio/Interface/JAISound.h" +#include "JSystem/JAudio/JAUSoundTable.h" #include "JSystem/JAudio/JASFakeMatch11.h" +#include "JSystem/JAudio/Interface/JAISe.h" +#include "JSystem/JAudio/Interface/JAISeq.h" +#include "JSystem/JAudio/Interface/JAIStream.h" +#include "JSystem/JAudio/System/JASDriver.h" +#include "JSystem/JAudio/System/JASGadget.h" +#include "JSystem/JUtility/JUTAssert.h" namespace GameAudio { -u16 CustomSoundTable::getBgmSeqResourceID(JAISoundID soundID) const {} +static inline bool isValid() { + bool resourceNotNull = false; + if(JASGlobalInstance::sInstance != NULL + && JASGlobalInstance::sInstance->getResource() != NULL) + { + resourceNotNull = true; + } + return resourceNotNull; +} + +u16 CustomSoundTable::getBgmSeqResourceID(JAISoundID soundID) const { + #line 27 + JUT_ASSERT(isValid()); + + JAUSoundTableItem* tableItem = JASGlobalInstance::sInstance->getData(soundID); + const u8 typeID = JASGlobalInstance::sInstance->getTypeID(soundID); + + if(tableItem != NULL) { + switch(typeID) case 0x20: + return tableItem->mSeqResourceID; + } + return -1; +} + +u32 CustomSoundTable::getSoundType(JAISoundID soundID) const { + switch(soundID.mId.mBytes.mSectionId) + { + case 0: return 0; + case 1: return 1; + case 2: return 2; + default: return -1; + } +} + +int CustomSoundTable::getCategory(JAISoundID soundID) const { + if(soundID.mId.mBytes.mSectionId == 1) { + return getPTrack(soundID.mId.mFullId) - 1; + } + + return soundID.mId.mBytes.mGroupId; +} + +u16 CustomSoundTable::getAudibleSw(JAISoundID soundID) const { + #line 76 + JUT_ASSERT(isValid()); + + JAUSoundTableItem* tableItem = JASGlobalInstance::sInstance->getData(soundID); + const u8 typeID = JASGlobalInstance::sInstance->getTypeID(soundID); + + if(tableItem != NULL) { + switch(typeID) case 0x10: + return tableItem->mAudibleSw; + } + return -1; +} + +u8 CustomSoundTable::getPTrack(JAISoundID soundID) const { + #line 109 + JUT_ASSERT(isValid()); + + JAUSoundTableItem* tableItem = JASGlobalInstance::sInstance->getData(soundID); + const u8 typeID = JASGlobalInstance::sInstance->getTypeID(soundID); + + if(tableItem != NULL) { + switch(typeID) case 0x20: + return tableItem->mPTrack; + } + return -1; +} + +u32 CustomSoundTable::getSwBit(JAISoundID soundID) const { + #line 128 + JUT_ASSERT(isValid()); + + JAUSoundTableItem* tableItem = JASGlobalInstance::sInstance->getData(soundID); + const u8 typeID = JASGlobalInstance::sInstance->getTypeID(soundID); + + if(tableItem != NULL) { + switch(typeID){ + case 0x20: + return tableItem->mSwBit; + case 0x10: + return tableItem->mSwBit; + } + } + return -1; +} + +u8 CustomSoundTable::getLevelFlag(JAISoundID soundID) const { + #line 152 + JUT_ASSERT(isValid()); + + JAUSoundTableItem* tableItem = JASGlobalInstance::sInstance->getData(soundID); + const u8 typeID = JASGlobalInstance::sInstance->getTypeID(soundID); + + if(tableItem != NULL) { + switch(typeID){ + case 0x10: + return tableItem->mPriority != 0; + } + } + return 0; +} -u32 CustomSoundTable::getSoundType(JAISoundID soundID) const {} +u32 CustomSoundTable::getPriority(JAISoundID soundID) const { + #line 171 + JUT_ASSERT(isValid()); -int CustomSoundTable::getCategory(JAISoundID soundID) const {} + JAUSoundTableItem* tableItem = JASGlobalInstance::sInstance->getData(soundID); + const u8 typeID = JASGlobalInstance::sInstance->getTypeID(soundID); -void CustomSoundTable::getAudibleSw(JAISoundID soundID) const {} + if(tableItem != NULL) { + switch(typeID){ + case 0x10: + return 0xFF - tableItem->_1; + case 0x20: + return 0xFF - tableItem->mPriority; + case 0x30: + return 0xFF - tableItem->mPriority; + } + } + return 0; +} -u8 CustomSoundTable::getPTrack(JAISoundID soundID) const {} +void CustomSoundTable::getSeInfo(JAISoundID soundID, JAISe *se) const { + getSoundInfo_(soundID, se); +} -u32 CustomSoundTable::getSwBit(JAISoundID soundID) const {} +void CustomSoundTable::getSeqInfo(JAISoundID soundID, JAISeq *seg) const { + getSoundInfo_(soundID, seg); +} -u8 CustomSoundTable::getLevelFlag(JAISoundID soundID) const {} +void CustomSoundTable::getStreamInfo(JAISoundID soundID, JAIStream *stream) const { + getSoundInfo_(soundID, stream); -u32 CustomSoundTable::getPriority(JAISoundID soundID) const {} + #line 209 + JUT_ASSERT(isValid()); -void CustomSoundTable::getSeInfo(JAISoundID soundID, JAISe *se) const {} + const u8 typeID = JASGlobalInstance::sInstance->getTypeID(soundID); -void CustomSoundTable::getSeqInfo(JAISoundID soundID, JAISeq *seg) const {} + switch(typeID) { + case 0x30: + JAUSoundTableItem* data = JASGlobalInstance::sInstance->getData(soundID); -void CustomSoundTable::getStreamInfo(JAISoundID soundID, JAIStream *stream) const {} + #line 216 + JUT_ASSERT(data); -JAISoundInfo *CustomSoundTable::getSoundInfo_(JAISoundID soundID, JAISound *sound) const {} + s32 numChild = stream->getNumChild(); -s32 CustomSoundTable::getStreamFileEntry(JAISoundID soundID) {} + const f32 leftPan = 0.f; + const f32 rightPan = 1.f; + + for(s32 childIndex = 0; childIndex < numChild; childIndex++) + { + JAISoundChild* child = stream->getChild(childIndex); + if(child == NULL) + { + continue; + } + + if(childIndex == 0) + { + child->mMove.mPan = leftPan; + } + else if(childIndex == 1) + { + child->mMove.mPan = rightPan; + } + } + } +} + +void CustomSoundTable::getSoundInfo_(JAISoundID soundID, JAISound *sound) const { + #line 257 + JUT_ASSERT(isValid()); + + JAUSoundTable* soundTable = JASGlobalInstance::sInstance; + JAUSoundTableItem* tableItem = soundTable->getData(soundID); + const u8 typeID = JASGlobalInstance::sInstance->getTypeID(soundID); + + if(tableItem != NULL) { + switch(typeID){ + case 0x10: + sound->params_.mProperty._0 = tableItem->_8 / 255.f; + break; + + case 0x20: + sound->params_.mProperty._0 = tableItem->_8 / 255.f; + break; + + case 0x30: + sound->params_.mProperty._0 = tableItem->_8 / 255.f; + if(JASDriver::getOutputMode() == 0) + { + sound->params_.mProperty._0 *= 0.75f; + } + break; + } + } +} -void CustomSoundTable::initAudibleSw() {} +// UNUSED +void CustomSoundTable::getStreamFilePath(JAISoundID soundID){} + +s32 CustomSoundTable::getStreamFileEntry(JAISoundID soundID) { + const u32 ID = soundID.mId.mFullId; + #line 297 + JUT_ASSERT(isValid()); + + JASGlobalInstance::sInstance->getTypeID(ID); + + return -1; +} + +void CustomSoundTable::initAudibleSw() { + JAISoundID id; + id.mId.mFullId = 0; + + for (u8 group_id = 0; + (s32)group_id < (s32)JASGlobalInstance::sInstance->getNumGroups_inSection(0); + group_id++) + { + for (u16 item = 0; + (s32)item < (s32)JASGlobalInstance::sInstance->getNumItems_inGroup(0, group_id); + item++) + { + JAUSoundTableItem* data = JASGlobalInstance::sInstance->getData(id); + + u16 acc = data->mAudibleSw & 0xC1; + u32 swBit = getSwBit(id); + + acc += (u16)(((swBit >> 8) & 0x3) << 14); + + if ((swBit & 0x1) == 0) + { + acc += 0x800; + } + if ((swBit & 0x2) == 0) + { + acc += 0x400; + } + if ( swBit & 0x20) + { + acc += 0x100; + } + + data->mAudibleSw = acc; + + id.mId.mAdvancedId.mShortId++; + } + id.mId.mAdvancedId.mShortId = 0; + id.mId.mBytes.mGroupId++; + } +} }