From c60601c56c55d6249b412622b2ccdbb3a630441e Mon Sep 17 00:00:00 2001 From: Joachim Divet Date: Sat, 22 Aug 2026 00:10:08 +0200 Subject: [PATCH 1/7] Add GameAudio::KartSoundMgr implementation --- include/Inagaki/GameSoundMgr.h | 19 ++++++++- src/Inagaki/KartSoundMgr.cpp | 71 +++++++++++++++++++++++++++++++++- 2 files changed, 87 insertions(+), 3 deletions(-) diff --git a/include/Inagaki/GameSoundMgr.h b/include/Inagaki/GameSoundMgr.h index 430d10f3..543508aa 100644 --- a/include/Inagaki/GameSoundMgr.h +++ b/include/Inagaki/GameSoundMgr.h @@ -241,9 +241,20 @@ class KartSoundMgr : public SoundMgr u8 _66; u8 _67[0x6c - 0x67]; f32 _6c; - u8 _70[0x8d - 0x70]; + u8 _70[0x7c - 0x70]; + u32 _7c; + u8 _80[0x8d - 0x80]; u8 _8d; - u8 _8e[0x134 - 0x8e]; + u8 _8e[0x110 - 0x8e]; + f32 _110; + f32 _114; + u8 _118[0x11c - 0x118]; + u32 _11c; + f32 _120; + f32 _124; + u8 _128[0x12c - 0x128]; + u32 _12c; + CrsArea* _130; }; class CharacterSoundMgr : public SoundMgr { @@ -346,6 +357,10 @@ class ShoreSoundMgr : public SoundMgr { private: static CustomAudience<4> *smAudience; // 0x80416278 + JGeometry::TVec3f& getPlayPos(s32 index) { // fabricated + return _64[index]; + } + u8 _5c; u8 _5d; u8 _5e[0x60 - 0x5e]; // padding? diff --git a/src/Inagaki/KartSoundMgr.cpp b/src/Inagaki/KartSoundMgr.cpp index ef2ff92d..3f942dba 100644 --- a/src/Inagaki/KartSoundMgr.cpp +++ b/src/Inagaki/KartSoundMgr.cpp @@ -1,8 +1,14 @@ +#include "Inagaki/GameAudioCommon.h" +#include "Inagaki/GameAudioCamera.h" +#include "Inagaki/GameAudioMain.h" #include "Inagaki/GameSoundMgr.h" +#include "Kaneshige/Course/CrsArea.h" namespace GameAudio { // TODO +static const u8 cKartRankClassTable0[7] = {0, 0, 1, 1, 2, 2, 2}; +static const u8 cKartRankClassTable1[7] = {0, 0, 1, 1, 2, 2, 2}; u32 BoundSe[0x19]; u32 WheelSpinSe[0x19]; @@ -29,7 +35,70 @@ u8 KartSoundMgr::smGoalKartCount; u8 KartSoundMgr::smKartRankClassMem[7] = {}; KartSoundMgr::KartSoundMgr(Vec *pos, JKRHeap *heap, u8 p3, u8 p4) : SoundMgr(pos, heap, 12) { - + _114 = 1.f; + _110 = 1.f; + _11c = 0; + _124 = 1.f; + _120 = 1.f; + _12c = 0; + _C = 0xff; + + _61 = p3; + + if(p3 == 0) { + smKartCount++; + mKartCount = smKartCount; + } + else { + mKartCount = 4; + } + + if(p3 != 2) { + smEntryKartCount++; + } + + _66 = p4; + _130 = new CrsArea(); + u8 index = 0; + + if(_66 == 0) { + _64 = 3; + } + else { + u32 randomValue = GameAudio::Random::getSignalEngineRandomU32(); + u8 rankClassIndex = randomValue % 7; + + while(smKartRankClassMem[rankClassIndex] == 1 && index < 7) + { + rankClassIndex = rankClassIndex + 1; + index++; + if(rankClassIndex == 7) + { + rankClassIndex = 0; + } + } + + smKartRankClassMem[rankClassIndex] = 1; + u8 playerMode = Parameters::getPlayerMode(); + if(playerMode != 1) + { + _64 = cKartRankClassTable0[rankClassIndex]; + } + else { + _64 = cKartRankClassTable1[rankClassIndex]; + } + } + + init(); + + _7c = 0; + + const u32 sceneMax = Main::getAudio()->getCamera()->getSceneMax(); + + if(sceneMax > 1 && sceneMax > mKartCount) + { + _7c = (1 << mKartCount) ^ 0xf; + } } KartSoundMgr::~KartSoundMgr() {} From f7b5a52604b6419adc77386405f1786d405dba07 Mon Sep 17 00:00:00 2001 From: Joachim Divet Date: Sat, 22 Aug 2026 12:29:41 +0200 Subject: [PATCH 2/7] Add unused symbols --- include/Inagaki/GameSoundMgr.h | 9 +++++++++ src/Inagaki/KartSoundMgr.cpp | 17 ++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/include/Inagaki/GameSoundMgr.h b/include/Inagaki/GameSoundMgr.h index 543508aa..4dcf41dd 100644 --- a/include/Inagaki/GameSoundMgr.h +++ b/include/Inagaki/GameSoundMgr.h @@ -226,6 +226,15 @@ class KartSoundMgr : public SoundMgr void clearInvincibleBgm(u8); // 0x80128c30 void setChibiFlag(bool, bool); // 0x80128e98 + // UNUSED { + void startSoundEngine(u8, u32); + void changeAttribute(u8); + void checkCourseSound(u8); + void setHandleVolume(JAISoundHandle&, f32); + void setWaterDepth(f32); + void getEngineIDOffsetAtt(); + // } UNUSED + static u8 smKartCount; static u8 smEntryKartCount; static u8 smGoalKartCount; diff --git a/src/Inagaki/KartSoundMgr.cpp b/src/Inagaki/KartSoundMgr.cpp index 3f942dba..bbeeb266 100644 --- a/src/Inagaki/KartSoundMgr.cpp +++ b/src/Inagaki/KartSoundMgr.cpp @@ -3,6 +3,7 @@ #include "Inagaki/GameAudioMain.h" #include "Inagaki/GameSoundMgr.h" #include "Kaneshige/Course/CrsArea.h" +#include "JSystem/JAudio/JASFakeMatch2.h" namespace GameAudio { @@ -103,18 +104,30 @@ KartSoundMgr::KartSoundMgr(Vec *pos, JKRHeap *heap, u8 p3, u8 p4) : SoundMgr(pos KartSoundMgr::~KartSoundMgr() {} -void KartSoundMgr::startSoundHandleNumber(u8, u32, u32) {} +void KartSoundMgr::startSoundHandleNumber(u8, u32, u32) { + setEcho(NULL, 0); +} void KartSoundMgr::dispose() {} +void KartSoundMgr::startSoundEngine(u8, u32) {} // UNUSED + void KartSoundMgr::init() {} +void KartSoundMgr::changeAttribute(u8) {} // UNUSED + void KartSoundMgr::changeDriver(bool) {} +void KartSoundMgr::checkCourseSound(u8) {} // UNUSED + void KartSoundMgr::frameWork(u8) {} void KartSoundMgr::checkAfterGoalVolume() {} +void KartSoundMgr::setHandleVolume(JAISoundHandle&, f32) {} // UNUSED + +void KartSoundMgr::setWaterDepth(f32) {} // UNUSED + void KartSoundMgr::setWaterDepth(u8, f32) {} void KartSoundMgr::setSlip(u8, u8, u8, f32) {} @@ -123,6 +136,8 @@ void KartSoundMgr::setConductStatus(f32, f32, bool, bool, bool, u8, CrsArea *) { void KartSoundMgr::setWaterCutoffPort(u16) {} +void KartSoundMgr::getEngineIDOffsetAtt() {} // UNUSED + void KartSoundMgr::countGoalKart() {} void KartSoundMgr::setConductLocomotiveAccel() {} From cfc36de55d2ba7bf16d911dcfa2c3a5246153a4c Mon Sep 17 00:00:00 2001 From: Joachim Divet Date: Sat, 22 Aug 2026 12:57:44 +0200 Subject: [PATCH 3/7] Add KartSoundMgr destructor --- src/Inagaki/KartSoundMgr.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/Inagaki/KartSoundMgr.cpp b/src/Inagaki/KartSoundMgr.cpp index bbeeb266..3045915f 100644 --- a/src/Inagaki/KartSoundMgr.cpp +++ b/src/Inagaki/KartSoundMgr.cpp @@ -1,7 +1,9 @@ +#include "Inagaki/GameSoundMgr.h" + +#include "Inagaki/GameAudioAudience.h" #include "Inagaki/GameAudioCommon.h" #include "Inagaki/GameAudioCamera.h" #include "Inagaki/GameAudioMain.h" -#include "Inagaki/GameSoundMgr.h" #include "Kaneshige/Course/CrsArea.h" #include "JSystem/JAudio/JASFakeMatch2.h" @@ -102,7 +104,26 @@ KartSoundMgr::KartSoundMgr(Vec *pos, JKRHeap *heap, u8 p3, u8 p4) : SoundMgr(pos } } -KartSoundMgr::~KartSoundMgr() {} +KartSoundMgr::~KartSoundMgr() { + setChibiFlag(false, false); + for(u8 index = 0; index < 7; index++) + { + smKartRankClassMem[index] = 0; + } + + if(_66 == 0) + { + const s32 kartCount = mKartCount; + if(kartCount < 4) + { + CustomAudience<4>::smCameraVolume[kartCount] = 1.f; + } + } + + smKartCount = 0; + smEntryKartCount = 0; + smGoalKartCount = 0; +} void KartSoundMgr::startSoundHandleNumber(u8, u32, u32) { setEcho(NULL, 0); From 8f6ebe39702ac9805949eb374949626ca482f5f3 Mon Sep 17 00:00:00 2001 From: Joachim Divet Date: Sat, 22 Aug 2026 15:26:48 +0200 Subject: [PATCH 4/7] Add startSoundHandleNumber --- include/JSystem/JAudio/Interface/JAISound.h | 14 ++++ src/Inagaki/KartSoundMgr.cpp | 72 +++++++++++++++++++-- 2 files changed, 80 insertions(+), 6 deletions(-) diff --git a/include/JSystem/JAudio/Interface/JAISound.h b/include/JSystem/JAudio/Interface/JAISound.h index b4f9ccfe..0e9e85db 100644 --- a/include/JSystem/JAudio/Interface/JAISound.h +++ b/include/JSystem/JAudio/Interface/JAISound.h @@ -230,6 +230,20 @@ struct JAISoundFader mIntensity = 0.0f; fadeIn(fadeCount); } + + // Same as fadeInFromOut but branching order is inversed + // Needed by KartSoundMgr... + void fadeInFromOut2(u32 fadeCount) + { + mIntensity = 0.f; + if (fadeCount != 0) { + mTransition.set(1.0f, mIntensity, fadeCount); + } + else + { + forceIn(); + } + } bool isOut() { return (mTransition.mCount == 0 && mIntensity < 0.01f); } void calc() { mIntensity = mTransition.apply(mIntensity); } f32 getIntensity() { return mIntensity; } diff --git a/src/Inagaki/KartSoundMgr.cpp b/src/Inagaki/KartSoundMgr.cpp index 3045915f..f9c56fe3 100644 --- a/src/Inagaki/KartSoundMgr.cpp +++ b/src/Inagaki/KartSoundMgr.cpp @@ -4,6 +4,9 @@ #include "Inagaki/GameAudioCommon.h" #include "Inagaki/GameAudioCamera.h" #include "Inagaki/GameAudioMain.h" +#include "JSystem/JAudio/Interface/JAISound.h" +#include "JSystem/JAudio/System/JASGadget.h" +#include "JSystem/JGeometry/Vec.h" #include "Kaneshige/Course/CrsArea.h" #include "JSystem/JAudio/JASFakeMatch2.h" @@ -20,17 +23,35 @@ u32 SpinTurnSe[0x19]; f32 GA_ENEMY_VOLUME_DOWN_VALUE = 0.85f; const f32 EngineKeisuuRaceUp[] = { - 0.006f, 0.006f, 0.005f, 0.003f, - 0.015f, 0.015f, 0.013f, 0.011f, + 0.006f, 0.006f, 0.005f, 0.003f, + 0.015f, 0.015f, 0.013f, 0.011f, 0.02f, }; const f32 EngineKeisuuRaceDown[] = { - 0.005f, 0.003f, 0.005f, 0.002f, - 0.012f, 0.012f, 0.012f, 0.009f, + 0.005f, 0.003f, 0.005f, 0.002f, + 0.012f, 0.012f, 0.012f, 0.009f, 0.019f, }; +const f32 DashEngineAdjustInitialValue[] = { + 0.3f, 0.3f, 0.3f, 0.3f, + 0.3f, 0.3f, 0.3f, 0.3f, + 0.3f +}; + +const f32 DashEngineIncPerFrame[] = { + 0.025f, 0.025f, 0.025f, 0.095f, + 0.025f, 0.025f, 0.025f, 0.025f, + 0.025f +}; + +const f32 DashEngineDecPerFrame[] = { + 0.005f, 0.005f, 0.005f, 0.005f, + 0.005f, 0.005f, 0.005f, 0.005f, + 0.005f +}; + u8 KartSoundMgr::smKartCount; u8 KartSoundMgr::smEntryKartCount; u8 KartSoundMgr::smGoalKartCount; @@ -125,8 +146,47 @@ KartSoundMgr::~KartSoundMgr() { smGoalKartCount = 0; } -void KartSoundMgr::startSoundHandleNumber(u8, u32, u32) { - setEcho(NULL, 0); +void KartSoundMgr::startSoundHandleNumber(u8 handleIndex, u32 soundID, u32 fadeCount) { + if(mKillSw || _66 == 2) + { + return; + } + + JAISoundStarter* soundStarter = JASGlobalInstance::getInstance(); + + JAISoundHandle& handle = (*this)[handleIndex]; + + soundStarter->startSound(soundID, &handle, NULL); + + JAISound* sound; + + if(!handle.isSoundAttached()) + { + return; + } + + if(handle->audible_ == NULL) + { + Main* main = Main::getAudio(); + u32 scene = 0; + CameraMgr* camera = main->getCamera(); + u32 sceneMax = camera->getSceneMax(); + + if(sceneMax > 1 && sceneMax > mKartCount) + { + scene = (1 << mKartCount) ^ 0xf; + } + + sound = handle.operator->(); + + JGeometry::TVec3f vec(*mSoundPos); + sound->newAudible(vec, &_18, scene, NULL); + } + sound = handle.operator->(); + + sound->fader_.fadeInFromOut2(fadeCount); + + setEcho(&handle, _6c); } void KartSoundMgr::dispose() {} From b389c0106e7dc62898c3aaa3fd115798d350bfba Mon Sep 17 00:00:00 2001 From: Joachim Divet Date: Sat, 22 Aug 2026 15:30:45 +0200 Subject: [PATCH 5/7] Add dispose --- src/Inagaki/KartSoundMgr.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Inagaki/KartSoundMgr.cpp b/src/Inagaki/KartSoundMgr.cpp index f9c56fe3..5e23727d 100644 --- a/src/Inagaki/KartSoundMgr.cpp +++ b/src/Inagaki/KartSoundMgr.cpp @@ -5,6 +5,7 @@ #include "Inagaki/GameAudioCamera.h" #include "Inagaki/GameAudioMain.h" #include "JSystem/JAudio/Interface/JAISound.h" +#include "JSystem/JAudio/JAUSoundObject.h" #include "JSystem/JAudio/System/JASGadget.h" #include "JSystem/JGeometry/Vec.h" #include "Kaneshige/Course/CrsArea.h" @@ -189,7 +190,11 @@ void KartSoundMgr::startSoundHandleNumber(u8 handleIndex, u32 soundID, u32 fadeC setEcho(&handle, _6c); } -void KartSoundMgr::dispose() {} +void KartSoundMgr::dispose() { + JAUSoundObject::dispose(); + + clearInvincibleBgm(3); +} void KartSoundMgr::startSoundEngine(u8, u32) {} // UNUSED From ba533a6b0aad396904ed033b1ae6949d52ac9d56 Mon Sep 17 00:00:00 2001 From: Joachim Divet Date: Sun, 23 Aug 2026 16:07:39 +0200 Subject: [PATCH 6/7] Add init method --- include/Inagaki/GameSoundMgr.h | 49 +++++++++++++++--- src/Inagaki/KartSoundMgr.cpp | 90 +++++++++++++++++++++++++++++++++- 2 files changed, 131 insertions(+), 8 deletions(-) diff --git a/include/Inagaki/GameSoundMgr.h b/include/Inagaki/GameSoundMgr.h index 4dcf41dd..76378869 100644 --- a/include/Inagaki/GameSoundMgr.h +++ b/include/Inagaki/GameSoundMgr.h @@ -241,26 +241,63 @@ class KartSoundMgr : public SoundMgr static u8 smKartRankClassMem[7]; - u8 _5c[0x61 - 0x5c]; + u8 _5c; + u8 _5d; + u8 _5e; + u8 _5f; + u8 _60; u8 _61; u8 mKartCount; // 62 u8 _63; u8 _64; u8 _65; u8 _66; - u8 _67[0x6c - 0x67]; + u8 _67; + f32 _68; f32 _6c; - u8 _70[0x7c - 0x70]; + f32 _70; + u32 _74; + u32 _78; u32 _7c; - u8 _80[0x8d - 0x80]; + u32 _80; + f32 _84; + f32 _88; + u8 _8c; u8 _8d; - u8 _8e[0x110 - 0x8e]; + u16 _8e; + u16 _90; + u16 _92; + u16 _94; + u16 _96; + f32 _98; + u8 _9c; + u8 _9d[3]; // padding + f32 _a0; + f32 _a4[4]; + f32 _b4[4]; + f32 _c4[4]; + f32 _d4[4]; + u8 _e4[4]; + u8 _e8[4]; + f32 _ec; + f32 _f0; + u32 _f4; + u16 _f8; + u8 _fa[2]; // padding + f32 _fc; + u8 _100; + u8 _101; + u8 _102; + u8 _103; + u8 _104; + u8 _105; + u8 _106[0x110 - 0x106]; f32 _110; f32 _114; u8 _118[0x11c - 0x118]; u32 _11c; f32 _120; - f32 _124; + f32 mCameraVolume; // 124 u8 _128[0x12c - 0x128]; u32 _12c; CrsArea* _130; diff --git a/src/Inagaki/KartSoundMgr.cpp b/src/Inagaki/KartSoundMgr.cpp index 5e23727d..d72d959b 100644 --- a/src/Inagaki/KartSoundMgr.cpp +++ b/src/Inagaki/KartSoundMgr.cpp @@ -4,6 +4,7 @@ #include "Inagaki/GameAudioCommon.h" #include "Inagaki/GameAudioCamera.h" #include "Inagaki/GameAudioMain.h" +#include "Inagaki/GameSoundTable.h" #include "JSystem/JAudio/Interface/JAISound.h" #include "JSystem/JAudio/JAUSoundObject.h" #include "JSystem/JAudio/System/JASGadget.h" @@ -63,7 +64,7 @@ KartSoundMgr::KartSoundMgr(Vec *pos, JKRHeap *heap, u8 p3, u8 p4) : SoundMgr(pos _114 = 1.f; _110 = 1.f; _11c = 0; - _124 = 1.f; + mCameraVolume = 1.f; _120 = 1.f; _12c = 0; _C = 0xff; @@ -198,7 +199,92 @@ void KartSoundMgr::dispose() { void KartSoundMgr::startSoundEngine(u8, u32) {} // UNUSED -void KartSoundMgr::init() {} +void KartSoundMgr::init() { + _60 = 0; + _5d = 0; + _68 = 0.f; + _63 = 0; + _5c = 0; + _6c = 0.f; + _70 = 0.f; + _80 = 0; + _84 = 0.f; + _88 = 0.f; + _8c = 0; + _8d = 0; + _8e = 0; + _90 = 0; + _92 = 0; + _94 = 0; + _96 = 0; + _98 = 0.f; + _9c = 0; + _a0 = 0.f; + + for(u8 index = 0; index < 4; index++) + { + _a4[index] = 0.f; + _b4[index] = 0.f; + _c4[index] = 0.f; + _e4[index] = 0; + _d4[index] = 0.f; + _e8[index] = 0; + } + + _ec = 0.f; + _f0 = 0.f; + _f4 = 0; + _f8 = 0; + _100 = 0; + _101 = 0; + _102 = 0; + _103 = 0; + _104 = 0; + _105 = 1; + _fc = 0.f; + _5f = 0; + _114 = 0.f; + _110 = 0.f; + _11c = 0; + mCameraVolume = 1.f; + _120 = 1.f; + _12c = 0.f; + _78 = 0; + _5e = 0; + _74 = 0; + _65 = 0xff; + + if(_66 == 0) + { + const s32 kartCount = mKartCount; + const f32 volume = mCameraVolume; + if(kartCount < 4) + { + CustomAudience<4>::smCameraVolume[kartCount] = volume; + } + } + + Main* main = Main::getAudio(); + CustomSoundTable* soundTable = main->getSoundTable(); + for(s32 index = 0; index < _10; index++) + { + if(!(*this)[index].isSoundAttached()) + { + continue; + } + JAISound* sound = (*this)[index].operator->(); + u32 swBit = soundTable->getSwBit(sound->getID().mId.mFullId); + if(!(swBit & 0x00800000)) + { + continue; + } + (*this)[index]->stop(); + } + + setChibiFlag(false, false); + clearInvincibleBgm(3); + smGoalKartCount = 0; +} void KartSoundMgr::changeAttribute(u8) {} // UNUSED From 6a974f499cc0196fdd6a62a3418ef85c8634201f Mon Sep 17 00:00:00 2001 From: Joachim Divet Date: Sun, 23 Aug 2026 17:17:00 +0200 Subject: [PATCH 7/7] Add framework method --- include/Inagaki/GameSoundMgr.h | 2 +- src/Inagaki/KartSoundMgr.cpp | 47 +++++++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/include/Inagaki/GameSoundMgr.h b/include/Inagaki/GameSoundMgr.h index 76378869..459ded4b 100644 --- a/include/Inagaki/GameSoundMgr.h +++ b/include/Inagaki/GameSoundMgr.h @@ -187,7 +187,7 @@ class KartSoundMgr : public SoundMgr public: KartSoundMgr(Vec *, JKRHeap *, u8, u8); // 0x80123118 ~KartSoundMgr(); // 0x80123328 - void startSoundHandleNumber(u8, u32, u32); // 0x801233fc + virtual void startSoundHandleNumber(u8, u32, u32); // 0x801233fc virtual void dispose(); // 0x801236d0 virtual void init(); // 0x80123708 void changeDriver(bool); // 0x80123ad4 diff --git a/src/Inagaki/KartSoundMgr.cpp b/src/Inagaki/KartSoundMgr.cpp index d72d959b..02e73266 100644 --- a/src/Inagaki/KartSoundMgr.cpp +++ b/src/Inagaki/KartSoundMgr.cpp @@ -292,7 +292,52 @@ void KartSoundMgr::changeDriver(bool) {} void KartSoundMgr::checkCourseSound(u8) {} // UNUSED -void KartSoundMgr::frameWork(u8) {} +void KartSoundMgr::frameWork(u8 p1) { + if(_66 == 0) { + _130->search(6, *mSoundPos); + Course::Area* area = _130->getArea(); + if(area != NULL) { + ECourseID courseID = Parameters::getRaceCourse(); + switch(courseID) { + case 0x2a: + if(p1 <= 3) + { + JAISoundHandle& handle = (*this)[7]; + if(!handle.isSoundAttached()) + { + startSoundHandleNumber(7, 0x40024, 0); + } + } + break; + + case 0x29: + _5c = 1; + _6c = 0.5f; + break; + } + } + else { + ECourseID courseID = Parameters::getRaceCourse(); + switch(courseID) { + case 0x29: + _5c = 0; + break; + } + } + } + checkEcho(); + + if(mKillSw || _66 == 2) { + return; + } + + crushRenzokuTaisaku(); + slipParamSet(); + if(_63 != 3) { + _65 = p1; + } + checkAfterGoalVolume(); +} void KartSoundMgr::checkAfterGoalVolume() {}