diff --git a/config/MarioClub_us/dol_slices.yml b/config/MarioClub_us/dol_slices.yml index 61d5814..f36b023 100644 --- a/config/MarioClub_us/dol_slices.yml +++ b/config/MarioClub_us/dol_slices.yml @@ -919,6 +919,13 @@ src/Bando/EngineSound.cpp: .text: [0x80118cac, 0x80118d1c] .data: [0x80393760, 0x803937b8] +src/Inagaki/GameAudioCommon.cpp: + .text: [0x8011af3c, 0x8011b264] + .ctors: [0x80316190, 0x80316194] + .bss: [0x803c9368, 0x803c93a8] + .sbss: [0x80416210, 0x80416218] + .sdata2: [0x80418940, 0x80418960] + src/Inagaki/GameAudioHostIO.cpp: .text: [0x8011b264, 0x8011b478] .ctors: [0x80316194, 0x80316198] diff --git a/config/Release_eu/dol_slices.yml b/config/Release_eu/dol_slices.yml index 2ef3366..6cf22ec 100644 --- a/config/Release_eu/dol_slices.yml +++ b/config/Release_eu/dol_slices.yml @@ -896,6 +896,13 @@ src/Bando/EngineSound.cpp: .text: [0x8011226c, 0x801122dc] .data: [0x80353590, 0x803535e8] +src/Inagaki/GameAudioCommon.cpp: + .text: [0x80113900, 0x80113c28] + .ctors: [0x802d8594, 0x802d8598] + .bss: [0x80388ea8, 0x80388ee8] + .sbss: [0x803d5490, 0x803d5498] + .sdata2: [0x803d7638, 0x803d7658] + src/Inagaki/GameAudioHostIO.cpp: .text: [0x80113c28, 0x80113ddc] .ctors: [0x802d8598, 0x802d859c] diff --git a/config/Release_eu/symbols.yml b/config/Release_eu/symbols.yml index d591278..a68e66b 100644 --- a/config/Release_eu/symbols.yml +++ b/config/Release_eu/symbols.yml @@ -1089,6 +1089,9 @@ global: 0x803d4c81: __init__memPool___26JASPoolAllocObject<5JAISe> # JAISeq.cpp 0x8008c978: __dt__27JASMemPool<13JAISoundChild>Fv + # JAIStreamDataMgr.cpp + 0x8034b6a8: __vt__16JAIStreamAramMgr + 0x8034b6bc: __vt__16JAIStreamDataMgr # JASReport.cpp 0x80091270: JASReport__FPCce # JASTaskThread.cpp @@ -1136,6 +1139,8 @@ global: 0x800a318c: __ct__Q29JGeometry8TVec3Fv # JAUSectionHeap.cpp 0x800a7578: newCopy__10JAUSectionFPCvUll + # JAUSoundInfo.cpp + 0x8034f280: __vt__12JAUSoundInfo # Dolphin # these have been ported by hand, there might be some errors in here # all local symbols are filtered out. @@ -2378,7 +2383,12 @@ global: # Inagaki # GameAudioCommon.cpp + 0x80113900: panDeform__Q29GameAudio6CommonFff + 0x80113944: setMultiPlayModePan__Q29GameAudio6CommonFUc + 0x80113970: changeRandomId__Q29GameAudio6CommonFUlUl 0x80113a08: setSeed__Q29GameAudio6RandomFUl + 0x80113a14: getRandomU32__Q29GameAudio6RandomFv + 0x80113a70: getSignalEngineRandomU32__Q29GameAudio6RandomFv # GameAudioHostIO.cpp 0x803d7658: GA_MULTI_CAMERA_VOL_DOWN_DISTANCE__9GameAudio 0x803d765c: GA_MULTI_CAMERA_VOL_DOWN_RATE__9GameAudio @@ -2401,6 +2411,27 @@ global: # GameAudioParam.cpp 0x80119294: setDemoMode__Q29GameAudio10ParametersFUc 0x801195c0: getDemoMode__Q29GameAudio10ParametersFv + # GameSoundTable.cpp + 0x8011fb74: getBgmSeqResourceID__Q29GameAudio16CustomSoundTableCF10JAISoundID + 0x8011fbf0: getSoundType__Q29GameAudio16CustomSoundTableCF10JAISoundID + 0x8011fc38: getCategory__Q29GameAudio16CustomSoundTableCF10JAISoundID + 0x8011fc8c: getAudibleSw__Q29GameAudio16CustomSoundTableCF10JAISoundID + 0x8011fd08: getPTrack__Q29GameAudio16CustomSoundTableCF10JAISoundID + 0x8011fd80: getSwBit__Q29GameAudio16CustomSoundTableCF10JAISoundID + 0x8011fe0c: getLevelFlag__Q29GameAudio16CustomSoundTableCF10JAISoundID + 0x8011fe90: getPriority__Q29GameAudio16CustomSoundTableCF10JAISoundID + 0x8011ff3c: getSeInfo__Q29GameAudio16CustomSoundTableCF10JAISoundIDP5JAISe + 0x8011ff74: getSeqInfo__Q29GameAudio16CustomSoundTableCF10JAISoundIDP6JAISeq + 0x8011ffa0: getStreamInfo__Q29GameAudio16CustomSoundTableCF10JAISoundIDP9JAIStream + 0x801200a4: getSoundInfo___Q29GameAudio16CustomSoundTableCF10JAISoundIDP8JAISound + 0x801201c8: getStreamFileEntry__Q29GameAudio16CustomSoundTableF10JAISoundID + 0x801201fc: initAudibleSw__Q29GameAudio16CustomSoundTableFv + 0x80120318: __dt__Q29GameAudio16CustomSoundTableFv + #0x80120578: @4@getBgmSeqResourceID__Q29GameAudio16CustomSoundTableCF10JAISoundID + #0x80120580: @4@getAudibleSw__Q29GameAudio16CustomSoundTableCF10JAISoundID + #0x80120588: @8@__dt__Q29GameAudio16CustomSoundTableFv + #0x80120590: @8@getStreamFileEntry__Q29GameAudio16CustomSoundTableF10JAISoundID + 0x80353c00: __vt__Q29GameAudio16CustomSoundTable # GameAudioFxConfig.cpp 0x80122d7c: __ct__Q29GameAudio12FxLineConfigFP7JKRHeap 0x80122e5c: set__Q29GameAudio12FxLineConfigFUc diff --git a/include/Inagaki/GameAudioCommon.h b/include/Inagaki/GameAudioCommon.h new file mode 100644 index 0000000..8bad138 --- /dev/null +++ b/include/Inagaki/GameAudioCommon.h @@ -0,0 +1,31 @@ +#ifndef GAMEAUDIOCOMMON_H +#define GAMEAUDIOCOMMON_H + +#include + +namespace GameAudio +{ + class Common + { + public: + static f32 panDeform(f32, f32); + static f32 setMultiPlayModePan(u8); // this is a getter, not a setter + static u32 changeRandomId(u32, u32); + }; + + class Random + { + public: + static void setSeed(u32 seed); + static u32 getRandomU32(); + static u32 getSignalEngineRandomU32(); + + static void *getMgr(); // Unused, however i assume it returned sRandom? + + private: + static JMath::TRandom_ sRandom; + static JMath::TRandom_ sSignalEngineRandom; + }; +} + +#endif \ No newline at end of file diff --git a/include/Inagaki/GameAudioMain.h b/include/Inagaki/GameAudioMain.h index 9c9f876..016dca4 100644 --- a/include/Inagaki/GameAudioMain.h +++ b/include/Inagaki/GameAudioMain.h @@ -5,6 +5,7 @@ #include #include "Inagaki/GameAudioFxConfig.h" +#include "Inagaki/GameSoundTable.h" #include "types.h" namespace GameAudio @@ -45,6 +46,7 @@ namespace GameAudio f32 getTHPOptionVolume() { return getMasterVolumeValue() / 2; }; JAUSectionHeap *getSectionHeap() { return mSectionHeap; } + CustomSoundTable *getSoundTable() { return mTable; } static Main *getAudio() { return msBasic; }; @@ -52,7 +54,9 @@ namespace GameAudio private: CustomMgr *mMgr; // 00 - u8 _04[0x14 - 0x4]; // + u8 _04[0xC - 0x4]; // + CustomSoundTable *mTable; // 0C + u8 _10[4]; // JAUSectionHeap *mSectionHeap; // 14 u8 _18[0x44 - 0x18]; // FxLineConfig *mConfig; // 44 diff --git a/include/Inagaki/GameSoundTable.h b/include/Inagaki/GameSoundTable.h new file mode 100644 index 0000000..9830970 --- /dev/null +++ b/include/Inagaki/GameSoundTable.h @@ -0,0 +1,31 @@ +#ifndef GAMESOUNDTABLE_H +#define GAMESOUNDTABLE_H + +#include +#include +#include + +namespace GameAudio +{ + class CustomSoundTable : public JAISoundInfo, public JAUSoundInfo, public JAIStreamDataMgr, public JASGlobalInstance + { + public: + virtual u32 getSoundType(JAISoundID) const; + virtual int getCategory(JAISoundID) const; + virtual u32 getPriority(JAISoundID) const; + virtual void getSeInfo(JAISoundID, JAISe *) const; + virtual void getSeqInfo(JAISoundID, JAISeq *) const ; + virtual void getStreamInfo(JAISoundID, JAIStream *) const; + + virtual ~CustomSoundTable(); + virtual void getAudibleSw(JAISoundID) const; + virtual u16 getBgmSeqResourceID(JAISoundID) const; + + virtual u8 getPTrack(JAISoundID) const; + virtual u32 getSwBit(JAISoundID) const; + virtual u8 getLevelFlag(JAISoundID) const; + virtual s32 getStreamFileEntry(JAISoundID); + }; +} + +#endif \ No newline at end of file diff --git a/include/Inagaki/SoundMgr.h b/include/Inagaki/SoundMgr.h index 1741e85..0f58e47 100644 --- a/include/Inagaki/SoundMgr.h +++ b/include/Inagaki/SoundMgr.h @@ -6,6 +6,8 @@ #include "JSystem/JKernel/JKRHeap.h" #include "JSystem/JMath/JMath.h" +#include "Inagaki/GameAudioCommon.h" // Temporary(so permanent) fix for that one file that actually uses this + namespace GameAudio { template @@ -17,18 +19,6 @@ namespace GameAudio virtual void setSe(u32 id); virtual void loop(u32); }; - - - namespace Random - { - void setSeed(u32); - u32 getRandomU32(); - u32 getSignalEngineRandomU32(); - - extern JMath::TRandom_fast_ sRandom; - extern JMath::TRandom_fast_ sSignalEngineRandom; - } - } #endif \ No newline at end of file diff --git a/include/JSystem/JAudio/Interface/JAISound.h b/include/JSystem/JAudio/Interface/JAISound.h index 066cf19..65a17b1 100644 --- a/include/JSystem/JAudio/Interface/JAISound.h +++ b/include/JSystem/JAudio/Interface/JAISound.h @@ -40,24 +40,35 @@ private: class JAISoundID { public: + operator u32() const { return this->mId.mFullId; } + void operator=(JAISoundID const &other) { mId.mFullId = other.mId.mFullId; }; + + JAISoundID(u32 pId) { mId.mFullId = pId; }; + + JAISoundID(JAISoundID const &other) { mId = other.mId; }; + JAISoundID() {} - JAISoundID(u32 id) - { - mID = id; - } - void setAnonymous() - { - mID = 0xffffffff; - } + bool isAnonymous() { return mId.mFullId == 0xffffffff; } + void setAnonymous() { mId.mFullId = -1; } - bool isAnonymous() const + union { - return mID != 0xffffffff; - } - -private: - u32 mID; + u32 mFullId; + struct + { + u8 b0; + u8 b1; + u8 b2; + u8 b3; + } mBytes; + struct + { + u16 mSoundType; + u16 mShortId; + } mAdvancedId; // Debug doesn't have an inline for referencing the short ID so I assume + // it's similar to this + } mId; }; struct JAISoundStatus_ { diff --git a/include/JSystem/JAudio/Interface/JAISoundInfo.h b/include/JSystem/JAudio/Interface/JAISoundInfo.h new file mode 100644 index 0000000..0e2de96 --- /dev/null +++ b/include/JSystem/JAudio/Interface/JAISoundInfo.h @@ -0,0 +1,19 @@ +#ifndef JAUDIO_JAISOUNDINFO_H +#define JAUDIO_JAISOUNDINFO_H + +#include "JSystem/JAudio/Interface/JAISound.h" +#include "JSystem/JAudio/System/JASGadget.h" + +struct JAISoundInfo : public JASGlobalInstance +{ + JAISoundInfo(bool); + virtual u32 getSoundType(JAISoundID) const = 0; + virtual int getCategory(JAISoundID) const = 0; + virtual u32 getPriority(JAISoundID) const = 0; + virtual void getSeInfo(JAISoundID, JAISe *) const = 0; + virtual void getSeqInfo(JAISoundID, JAISeq *) const = 0; + virtual void getStreamInfo(JAISoundID, JAIStream *) const = 0; + virtual ~JAISoundInfo(); +}; + +#endif /* JAUDIO_JAISOUNDINFO_H */ \ No newline at end of file diff --git a/include/JSystem/JAudio/Interface/JAIStreamDataMgr.h b/include/JSystem/JAudio/Interface/JAIStreamDataMgr.h new file mode 100644 index 0000000..80c9fea --- /dev/null +++ b/include/JSystem/JAudio/Interface/JAIStreamDataMgr.h @@ -0,0 +1,19 @@ +#ifndef JAUDIO_JAISTREAMDATAMGR_H +#define JAUDIO_JAISTREAMDATAMGR_H + +#include "JSystem/JAudio/Interface/JAISound.h" + +struct JAIStreamDataMgr +{ + virtual s32 getStreamFileEntry(JAISoundID) = 0; + virtual ~JAIStreamDataMgr(); +}; + +struct JAIStreamAramMgr +{ + virtual void *newStreamAram(u32 *) = 0; + virtual void deleteStreamAram(u32) = 0; + virtual ~JAIStreamAramMgr(); +}; + +#endif /* JAUDIO_JAISTREAMDATAMGR_H */ \ No newline at end of file diff --git a/include/JSystem/JAudio/JASFakeMatch4.h b/include/JSystem/JAudio/JASFakeMatch4.h new file mode 100644 index 0000000..41d3791 --- /dev/null +++ b/include/JSystem/JAudio/JASFakeMatch4.h @@ -0,0 +1,16 @@ +#ifndef JAUDIO_JASFAKEMATCH4_H +#define JAUDIO_JASFAKEMATCH4_H + +#ifdef MATCHING +#include "JSystem/JAudio/System/JASMemPool.h" +#include "JSystem/JAudio/System/JASTrack.h" +class JAISe; +class JAISeq; + +#include "JSystem/JAudio/JASFakeMatch.h" +JASMemPool JASPoolAllocObject::memPool_; +JASMemPool JASPoolAllocObject::memPool_; + +#endif + +#endif \ No newline at end of file diff --git a/include/JSystem/JAudio/JAUSoundInfo.h b/include/JSystem/JAudio/JAUSoundInfo.h new file mode 100644 index 0000000..3432dbf --- /dev/null +++ b/include/JSystem/JAudio/JAUSoundInfo.h @@ -0,0 +1,15 @@ +#ifndef JAUDIO_JAUSOUNDINFO_H +#define JAUDIO_JAUSOUNDINFO_H + +#include "JSystem/JAudio/Interface/JAISound.h" +#include "JSystem/JAudio/System/JASGadget.h" + +class JAUSoundInfo : public JASGlobalInstance +{ +public: + JAUSoundInfo(bool param_0) : JASGlobalInstance(param_0) {} + virtual void getAudibleSw(JAISoundID) const = 0; + virtual u16 getBgmSeqResourceID(JAISoundID) const = 0; +}; + +#endif /* JAUDIO_JAUSOUNDINFO_H */ \ No newline at end of file diff --git a/src/Inagaki/GameAudioCommon.cpp b/src/Inagaki/GameAudioCommon.cpp new file mode 100644 index 0000000..af235eb --- /dev/null +++ b/src/Inagaki/GameAudioCommon.cpp @@ -0,0 +1,54 @@ +#include "Inagaki/GameAudioCommon.h" +#include "Inagaki/GameAudioMain.h" + +namespace GameAudio +{ + JMath::TRandom_ Random::sRandom(0); + JMath::TRandom_ Random::sSignalEngineRandom(0); + + f32 Common::panDeform(f32 x, f32 y) + { + if(x > 0.5f) { + f32 ret = 0.5f + (x - 0.5f) * y; + if(ret > 1.0f) + ret = 1.0f; + return ret; + } + else { + f32 ret = 0.5f - (0.5f - x) * y; + if (ret < 0.0f) + ret = 0.0f; + return ret; + } + } + + f32 Common::setMultiPlayModePan(u8 p1) { return (p1 & 1); } + + u32 Common::changeRandomId(u32 id1, u32 id2) + { + u32 swBit = GetGameAudioMain()->getSoundTable()->getSwBit(id1); + + if (swBit & 0x70000000) { + swBit = ((swBit & 0x70000000) >> 0x1c) + 1; + u32 rnd = Random::getRandomU32(); + u32 randId = id1 + ((rnd >> 0xc) % swBit); + if (randId == id2 && (++randId == id1 + swBit)) + { + randId = id1; + } + return randId; + } + return id1; + } + + void Random::setSeed(u32 seed) + { + sRandom.setSeed(seed); + sSignalEngineRandom.setSeed(seed); + } + + u32 Random::getRandomU32() { return 4294967295.0f * sRandom.get_ufloat_1(); } + u32 Random::getSignalEngineRandomU32() { return 4294967295.0f * sSignalEngineRandom.get_ufloat_1(); } +} + +#include \ No newline at end of file diff --git a/src/Inagaki/not matched/GameAudioCommon.cpp b/src/Inagaki/not matched/GameAudioCommon.cpp deleted file mode 100644 index e69de29..0000000