From f96f1ddbea6a21330a0e53145e8829b28a5896a1 Mon Sep 17 00:00:00 2001 From: Joachim Divet Date: Sat, 22 Aug 2026 00:10:08 +0200 Subject: [PATCH 01/22] 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 f8ee249e..70a18c50 100644 --- a/include/Inagaki/GameSoundMgr.h +++ b/include/Inagaki/GameSoundMgr.h @@ -240,9 +240,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 { @@ -345,6 +356,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 af035cb4db61e8a56557d8870145ded9f592870c Mon Sep 17 00:00:00 2001 From: Joachim Divet Date: Sat, 22 Aug 2026 12:29:41 +0200 Subject: [PATCH 02/22] 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 70a18c50..097569f3 100644 --- a/include/Inagaki/GameSoundMgr.h +++ b/include/Inagaki/GameSoundMgr.h @@ -225,6 +225,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 b049c2ccba692dd6f31082ececedd63597b0fffd Mon Sep 17 00:00:00 2001 From: Joachim Divet Date: Sat, 22 Aug 2026 12:57:44 +0200 Subject: [PATCH 03/22] 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 c98753f313d30c0f6b6253b311b0d7eaabac6106 Mon Sep 17 00:00:00 2001 From: Joachim Divet Date: Sat, 22 Aug 2026 15:26:48 +0200 Subject: [PATCH 04/22] 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 1e297abe013cef571da70497c20e50bbd3189b38 Mon Sep 17 00:00:00 2001 From: Joachim Divet Date: Sat, 22 Aug 2026 15:30:45 +0200 Subject: [PATCH 05/22] 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 af62eef6f3d03f71a1501c7bc6e28a355eb1de4c Mon Sep 17 00:00:00 2001 From: Joachim Divet Date: Sun, 23 Aug 2026 16:07:39 +0200 Subject: [PATCH 06/22] 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 097569f3..86e19672 100644 --- a/include/Inagaki/GameSoundMgr.h +++ b/include/Inagaki/GameSoundMgr.h @@ -240,26 +240,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 f565e3c07bfe4b1a881fd54b1c6e58d25fae4b75 Mon Sep 17 00:00:00 2001 From: Joachim Divet Date: Sun, 23 Aug 2026 17:17:00 +0200 Subject: [PATCH 07/22] 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 86e19672..bebef4d1 100644 --- a/include/Inagaki/GameSoundMgr.h +++ b/include/Inagaki/GameSoundMgr.h @@ -186,7 +186,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() {} From 1e90df3612063992c4785505d20895d4dfc3322d Mon Sep 17 00:00:00 2001 From: Joachim Divet Date: Tue, 25 Aug 2026 17:39:24 +0200 Subject: [PATCH 08/22] Add checkAfterGoalVolume method --- include/Inagaki/GameSoundMgr.h | 6 +- src/Inagaki/KartSoundMgr.cpp | 100 +++++++++++++++++++++++++++++++-- 2 files changed, 97 insertions(+), 9 deletions(-) diff --git a/include/Inagaki/GameSoundMgr.h b/include/Inagaki/GameSoundMgr.h index bebef4d1..05398dd3 100644 --- a/include/Inagaki/GameSoundMgr.h +++ b/include/Inagaki/GameSoundMgr.h @@ -295,10 +295,10 @@ class KartSoundMgr : public SoundMgr f32 _114; u8 _118[0x11c - 0x118]; u32 _11c; - f32 _120; + f32 mGoalVolume; f32 mCameraVolume; // 124 - u8 _128[0x12c - 0x128]; - u32 _12c; + f32 mDeltaVolume; // 128 + u32 mGoalVolumeCounter; // 12c CrsArea* _130; }; diff --git a/src/Inagaki/KartSoundMgr.cpp b/src/Inagaki/KartSoundMgr.cpp index 02e73266..09a44ab0 100644 --- a/src/Inagaki/KartSoundMgr.cpp +++ b/src/Inagaki/KartSoundMgr.cpp @@ -12,6 +12,11 @@ #include "Kaneshige/Course/CrsArea.h" #include "JSystem/JAudio/JASFakeMatch2.h" +static bool float_equal(f32 f1, f32 f2) { + return f1 == f2; +} + // } FABRICATED) + namespace GameAudio { // TODO @@ -60,13 +65,14 @@ u8 KartSoundMgr::smGoalKartCount; u8 KartSoundMgr::smKartRankClassMem[7] = {}; -KartSoundMgr::KartSoundMgr(Vec *pos, JKRHeap *heap, u8 p3, u8 p4) : SoundMgr(pos, heap, 12) { +KartSoundMgr::KartSoundMgr(Vec *pos, JKRHeap *heap, u8 p3, u8 p4) + : SoundMgr(pos, heap, 12) { _114 = 1.f; _110 = 1.f; _11c = 0; mCameraVolume = 1.f; - _120 = 1.f; - _12c = 0; + mGoalVolume = 1.f; + mGoalVolumeCounter = 0; _C = 0xff; _61 = p3; @@ -247,8 +253,8 @@ void KartSoundMgr::init() { _110 = 0.f; _11c = 0; mCameraVolume = 1.f; - _120 = 1.f; - _12c = 0.f; + mGoalVolume = 1.f; + mGoalVolumeCounter = 0.f; _78 = 0; _5e = 0; _74 = 0; @@ -339,7 +345,89 @@ void KartSoundMgr::frameWork(u8 p1) { checkAfterGoalVolume(); } -void KartSoundMgr::checkAfterGoalVolume() {} +void KartSoundMgr::checkAfterGoalVolume() { + if(_66 != 0) { + return; + } + + if(_5e != 1) + { + return; + } + + const f32 goalVolumeOn = 0.35f; + const f32 goalVolumeOff = 0.0f; + if(_78 == 0) { + JAISoundHandle& handle = (*this)[3]; + if(handle.isSoundAttached()) + { + handle->stop(); + } + + Main* main = Main::getAudio(); + CameraMgr* camera = main->getCamera(); + + if(camera->getSceneMax() == 2) { + u8 mode = Parameters::getRaceMode(); + if(mode == 1) { + _7c = 0xc; + _80 = 0x78; + } + } + } + else if (_78 == 0x3c) { + if(mGoalVolumeCounter != 0 || !float_equal(mCameraVolume, goalVolumeOn)) + { + if(mGoalVolumeCounter == 0 || !float_equal(mGoalVolume,goalVolumeOn)) { + mGoalVolume = goalVolumeOn; + mDeltaVolume = (mCameraVolume - mGoalVolume) / 61.f; + mGoalVolumeCounter = 0x3d; + } + } + } + else if (_78 == 0x168) { + if(mGoalVolumeCounter != 0 || !float_equal(mCameraVolume, goalVolumeOff)) + { + if(mGoalVolumeCounter == 0 || !float_equal(mGoalVolume, goalVolumeOff)) + { + mGoalVolume = goalVolumeOff; + mDeltaVolume = (mCameraVolume - mGoalVolume) / 301.f; + mGoalVolumeCounter = 0x12d; + } + } + } + _78++; + + u8 camera; + if(mGoalVolumeCounter == 0) + { + camera = 0; + } + else { + if(--mGoalVolumeCounter){ + camera = 1; + mCameraVolume -= mDeltaVolume; + } + else { + camera = 1; + mCameraVolume = mGoalVolume; + } + } + + if(camera == 0) + { + return; + } + + s32 kartCount = mKartCount; + f32 cameraVolume = mCameraVolume; + + if(kartCount >= 4){ + return; + } + + CustomAudience<4>::smCameraVolume[kartCount] = cameraVolume; +} void KartSoundMgr::setHandleVolume(JAISoundHandle&, f32) {} // UNUSED From e0f3ab6a6239d0dd608adc914ec39b4b9e830e88 Mon Sep 17 00:00:00 2001 From: Joachim Divet Date: Tue, 25 Aug 2026 17:55:35 +0200 Subject: [PATCH 09/22] Add setWaterDepth --- include/Inagaki/GameSoundMgr.h | 2 +- src/Inagaki/KartSoundMgr.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/Inagaki/GameSoundMgr.h b/include/Inagaki/GameSoundMgr.h index 05398dd3..990dff53 100644 --- a/include/Inagaki/GameSoundMgr.h +++ b/include/Inagaki/GameSoundMgr.h @@ -275,7 +275,7 @@ class KartSoundMgr : public SoundMgr f32 _a4[4]; f32 _b4[4]; f32 _c4[4]; - f32 _d4[4]; + f32 mWaterDepths[4]; u8 _e4[4]; u8 _e8[4]; f32 _ec; diff --git a/src/Inagaki/KartSoundMgr.cpp b/src/Inagaki/KartSoundMgr.cpp index 09a44ab0..a6aa6dc0 100644 --- a/src/Inagaki/KartSoundMgr.cpp +++ b/src/Inagaki/KartSoundMgr.cpp @@ -233,7 +233,7 @@ void KartSoundMgr::init() { _b4[index] = 0.f; _c4[index] = 0.f; _e4[index] = 0; - _d4[index] = 0.f; + mWaterDepths[index] = 0.f; _e8[index] = 0; } @@ -433,7 +433,9 @@ void KartSoundMgr::setHandleVolume(JAISoundHandle&, f32) {} // UNUSED void KartSoundMgr::setWaterDepth(f32) {} // UNUSED -void KartSoundMgr::setWaterDepth(u8, f32) {} +void KartSoundMgr::setWaterDepth(u8 index, f32 depth) { + mWaterDepths[index] = depth; +} void KartSoundMgr::setSlip(u8, u8, u8, f32) {} From ca916d02bdc6d0b105f2621352489dd5a33c8c9c Mon Sep 17 00:00:00 2001 From: Joachim Divet Date: Sat, 29 Aug 2026 10:03:36 +0200 Subject: [PATCH 10/22] Add methods --- include/Inagaki/GameAudioMain.h | 7 +- include/Kaneshige/Course/CrsGround.h | 13 ++++ src/Inagaki/KartSoundMgr.cpp | 104 +++++++++++++++++++++++++-- 3 files changed, 117 insertions(+), 7 deletions(-) diff --git a/include/Inagaki/GameAudioMain.h b/include/Inagaki/GameAudioMain.h index fdcacd8e..ebc9ede7 100644 --- a/include/Inagaki/GameAudioMain.h +++ b/include/Inagaki/GameAudioMain.h @@ -111,6 +111,10 @@ class Main } CustomMgr *getCustomMgr() { return mMgr; } + + u32 get_80() const { + return _80; + } // } FABRICATED CameraMgr *getCamera() { @@ -145,7 +149,8 @@ class Main JAISoundHandle _68; // JAISoundHandle _6c; // JAISoundHandle _70; // - u8 _74[0xa8 - 0x74]; // + u8 _74[0x80 - 0x74]; // + u32 _80; // JAISoundHandle _84[4]; // u8 _94[0xa8 - 0x94]; // diff --git a/include/Kaneshige/Course/CrsGround.h b/include/Kaneshige/Course/CrsGround.h index 60478082..31ff63b8 100644 --- a/include/Kaneshige/Course/CrsGround.h +++ b/include/Kaneshige/Course/CrsGround.h @@ -45,6 +45,19 @@ class CrsGround { // TODO Mat_1 = 1, + Mat_5 = 5, + Mat_6 = 6, + Mat_7 = 7, + Mat_8 = 8, + Mat_9 = 9, + Mat_10 = 10, + Mat_15 = 15, + Mat_16 = 16, + Mat_17 = 17, + Mat_18 = 18, + Mat_19 = 19, + Mat_25 = 25, + Mat_27 = 27, Mat_255 = 0xff, }; diff --git a/src/Inagaki/KartSoundMgr.cpp b/src/Inagaki/KartSoundMgr.cpp index a6aa6dc0..867613a1 100644 --- a/src/Inagaki/KartSoundMgr.cpp +++ b/src/Inagaki/KartSoundMgr.cpp @@ -11,6 +11,7 @@ #include "JSystem/JGeometry/Vec.h" #include "Kaneshige/Course/CrsArea.h" #include "JSystem/JAudio/JASFakeMatch2.h" +#include "Kaneshige/Course/CrsGround.h" static bool float_equal(f32 f1, f32 f2) { return f1 == f2; @@ -20,7 +21,7 @@ static bool float_equal(f32 f1, f32 f2) { namespace GameAudio { // TODO -static const u8 cKartRankClassTable0[7] = {0, 0, 1, 1, 2, 2, 2}; +static const u8 cKartRankClassTable0[7] = {0, 0, 1, 1, 1, 2, 2}; static const u8 cKartRankClassTable1[7] = {0, 0, 1, 1, 2, 2, 2}; u32 BoundSe[0x19]; @@ -441,11 +442,26 @@ void KartSoundMgr::setSlip(u8, u8, u8, f32) {} void KartSoundMgr::setConductStatus(f32, f32, bool, bool, bool, u8, CrsArea *) {} -void KartSoundMgr::setWaterCutoffPort(u16) {} +void KartSoundMgr::setWaterCutoffPort(u16 port) { + JAISoundHandle &handle = (*this)[3]; + if (handle.isSoundAttached()) { + handle->getTrack()->writePort(0xa, port); + } +} void KartSoundMgr::getEngineIDOffsetAtt() {} // UNUSED -void KartSoundMgr::countGoalKart() {} +void KartSoundMgr::countGoalKart() { + if(_5e != 0){ + return; + } + + if(_63 == _8d) + { + return; + } + smGoalKartCount++; +} void KartSoundMgr::setConductLocomotiveAccel() {} @@ -461,11 +477,87 @@ void KartSoundMgr::setConductTrouble(f32, u8) {} void KartSoundMgr::setConductRace(bool) {} -void KartSoundMgr::setConductAfterGoal(bool) {} +void KartSoundMgr::setConductAfterGoal(bool enable) { + setConductRace(enable); +} + +void KartSoundMgr::setCrushSe(CrsGround::EMat mat, f32 f1) { + switch (mat) { + case CrsGround::Mat_5: + case CrsGround::Mat_17: + setCrushSe(0x1001DU, f1); + return; + case CrsGround::Mat_8: + setCrushSe(0x10015U, f1); + return; + case CrsGround::Mat_7: + case CrsGround::Mat_15: + setCrushSe(0x10021U, f1); + return; + case CrsGround::Mat_16: + setCrushSe(0x10023U, f1); + return; + case CrsGround::Mat_18: + setCrushSe(0x10053U, f1); + return; + case CrsGround::Mat_19: + setCrushSe(0x10056U, f1); + return; + case CrsGround::Mat_9: + setCrushSe(0x10019U, f1); + return; + case CrsGround::Mat_25: + setCrushSe(0x10067U, f1); + return; + case CrsGround::Mat_27: + setCrushSe(0x1007DU, f1); + return; + case CrsGround::Mat_255: + break; + default: + setCrushSe(0x10015U, f1); + return; + } +} -void KartSoundMgr::setCrushSe(CrsGround::EMat, f32) {} +void KartSoundMgr::setCrushSe(u32 r4, f32 f1) { + const u32 randomId = Common::changeRandomId(r4, 0); + const u32 randomId2 = Random::getRandomU32(); -void KartSoundMgr::setCrushSe(u32, f32) {} + if(mKillSw || _66 == 2) { + return; + } + + if(_66 != 0) { + return; + } + + Main* main = Main::getAudio(); + + if(main->get_80() - _74 < 0x3c) { + return; + } + + _74 = main->get_80(); + + if(_9c != 0) { + return; + } + + startSoundHandleNumber(0, randomId, 0); + + JAISoundHandle& handle = (*this)[0]; + const f32 f30 = f1 + 0.6f; + if(handle.isSoundAttached()) { + const f32 volume = f30 * 0.8f; + handle->getAuxiliary().moveVolume(volume, 0); + _a0 = f30; + } + + u8 r3 = (randomId2 & 0x7); + + _9c = r3 + 4; +} void KartSoundMgr::setBrakeSe(u32) {} From 892cd45738da5851483a8133d5af220a1d989288 Mon Sep 17 00:00:00 2001 From: Joachim Divet Date: Tue, 1 Sep 2026 18:58:32 +0200 Subject: [PATCH 11/22] Add setSlip draft impl --- include/Inagaki/GameSoundMgr.h | 10 +- src/Inagaki/KartSoundMgr.cpp | 371 +++++++++++++++++++++++++++++++-- 2 files changed, 368 insertions(+), 13 deletions(-) diff --git a/include/Inagaki/GameSoundMgr.h b/include/Inagaki/GameSoundMgr.h index 990dff53..e7e82b9e 100644 --- a/include/Inagaki/GameSoundMgr.h +++ b/include/Inagaki/GameSoundMgr.h @@ -240,6 +240,14 @@ class KartSoundMgr : public SoundMgr static u8 smKartRankClassMem[7]; + bool isGoalVolumeEqual(f32 volume) const { + return mGoalVolume == volume; + } + + bool isCameraVolumeEqual(f32 volume) const { + return mCameraVolume == volume; + } + u8 _5c; u8 _5d; u8 _5e; @@ -275,7 +283,7 @@ class KartSoundMgr : public SoundMgr f32 _a4[4]; f32 _b4[4]; f32 _c4[4]; - f32 mWaterDepths[4]; + f32 mWaterDepths[4]; // d4 u8 _e4[4]; u8 _e8[4]; f32 _ec; diff --git a/src/Inagaki/KartSoundMgr.cpp b/src/Inagaki/KartSoundMgr.cpp index 867613a1..2a132ed5 100644 --- a/src/Inagaki/KartSoundMgr.cpp +++ b/src/Inagaki/KartSoundMgr.cpp @@ -9,15 +9,11 @@ #include "JSystem/JAudio/JAUSoundObject.h" #include "JSystem/JAudio/System/JASGadget.h" #include "JSystem/JGeometry/Vec.h" +#include "JSystem/JUtility/JUTAssert.h" #include "Kaneshige/Course/CrsArea.h" #include "JSystem/JAudio/JASFakeMatch2.h" #include "Kaneshige/Course/CrsGround.h" -static bool float_equal(f32 f1, f32 f2) { - return f1 == f2; -} - // } FABRICATED) - namespace GameAudio { // TODO @@ -356,8 +352,6 @@ void KartSoundMgr::checkAfterGoalVolume() { return; } - const f32 goalVolumeOn = 0.35f; - const f32 goalVolumeOff = 0.0f; if(_78 == 0) { JAISoundHandle& handle = (*this)[3]; if(handle.isSoundAttached()) @@ -377,9 +371,10 @@ void KartSoundMgr::checkAfterGoalVolume() { } } else if (_78 == 0x3c) { - if(mGoalVolumeCounter != 0 || !float_equal(mCameraVolume, goalVolumeOn)) + const f32 goalVolumeOn = 0.35f; + if(mGoalVolumeCounter != 0 || !isCameraVolumeEqual(goalVolumeOn)) { - if(mGoalVolumeCounter == 0 || !float_equal(mGoalVolume,goalVolumeOn)) { + if(mGoalVolumeCounter == 0 || !isGoalVolumeEqual(goalVolumeOn)) { mGoalVolume = goalVolumeOn; mDeltaVolume = (mCameraVolume - mGoalVolume) / 61.f; mGoalVolumeCounter = 0x3d; @@ -387,9 +382,10 @@ void KartSoundMgr::checkAfterGoalVolume() { } } else if (_78 == 0x168) { - if(mGoalVolumeCounter != 0 || !float_equal(mCameraVolume, goalVolumeOff)) + const f32 goalVolumeOff = 0.0f; + if(mGoalVolumeCounter != 0 || !isCameraVolumeEqual(goalVolumeOff)) { - if(mGoalVolumeCounter == 0 || !float_equal(mGoalVolume, goalVolumeOff)) + if(mGoalVolumeCounter == 0 || !isGoalVolumeEqual(goalVolumeOff)) { mGoalVolume = goalVolumeOff; mDeltaVolume = (mCameraVolume - mGoalVolume) / 301.f; @@ -438,7 +434,358 @@ void KartSoundMgr::setWaterDepth(u8 index, f32 depth) { mWaterDepths[index] = depth; } -void KartSoundMgr::setSlip(u8, u8, u8, f32) {} +void KartSoundMgr::setSlip(u8 wheel, u8 r5, u8 r6, f32 slip) { + #line 907 + JUT_ASSERT_MSG(wheel < 4, "KartSoundMgr::setSlip wheel ERROR!!!\n"); + + _e8[wheel] = r5; + if(mKillSw || _66 == 2) + { + return; + } + + if(_66 != 0) + { + return; + } + + f32 f29; + f32 f28 = slip; + u32 r27 = r5; + f32 f30 = 0.f; + f32 f31 = 1.f; + u8 r6_2; + switch(r5) { + case 0x11: + { + if(mWaterDepths[wheel] <= f30) + { + switch(r6) { + case 0xa: + f29 = 0.1f; + r6_2 = 0x14; + break; + case 0x1c: + f29 = 0.1f; + r6_2 = 0x15; + break; + default: + f29 = 0.f; + r6_2 = 0xff; + } + } + else { + f29 = 0.f; + r6_2 = 0xa; + } + } + break; + default: + { + switch(r6) + { + case 1: + if(r27 == 1) + { + f29 = 0.1f; + } + else { + f29 = -0.1f; + } + r6_2 = 0; + break; + case 0: + f29 = 0.1f; + u8 type = Parameters::getCharacterType(_61); + if(type == 1){ + r6_2 = 9; + } + else { + r6_2 = 1; + } + break; + case 7: + if(r27 == 1) + { + f29 = -0.06f; + } + else { + f29 = -0.1f; + } + r6_2 = 2; + break; + case 6: + if(r27 == 1) + { + f29 = f30; + } + else { + f29 = 0.1f; + } + r6_2 = 3; + break; + case 2: + f29 = 0.1f; + r6_2 = 4; + break; + case 8: + f29 = 0.1f; + r6_2 = 0x13; + break; + case 3: + f29 = -0.1f; + r6_2 = 5; + break; + case 5: + f29 = -0.1f; + r6_2 = 6; + break; + case 14: + f29 = 0.1f; + r6_2 = 0xd; + break; + case 20: + f29 = 0.1f; + r6_2 = 0xf; + break; + case 22: + f29 = -0.06f; + r6_2 = 0xc; + break; + case 13: + f29 = -0.06f; + r6_2 = 0xe; + break; + case 10: + f29 = 0.1f; + r6_2 = 0x14; + break; + case 28: + f29 = 0.1f; + r6_2 = 0x15; + break; + case 12: + f29 = 0.1f; + r6_2 = 0xb; + break; + case 21: + f29 = 0.1f; + r6_2 = 0x10; + break; + case 11: + f29 = 0.1f; + r6_2 = 0x11; + break; + case 23: + f29 = 0.1f; + r6_2 = 0x16; + break; + case 24: + f29 = 0.1f; + r6_2 = 0x17; + break; + case 4: + case 9: + case 15: + case 16: + case 17: + case 18: + case 19: + case 25: + case 26: + case 27: + default: + f29 = 0.f; + r6_2 = 0xff; + break; + } + // 294 + } + } + + _105 = r6_2; + + if(r6_2 != 0xff && _8d != 0) + { + f32 f4 = _84; + f32 f0 = 5.f; + if(f4 < f0) + { + return; + } + f0 = 0.0026666666; + f32 f1 = 0.7; + f32 f2; + f32 f5; + f32 f3; + u32 r0; + + switch(r5) + { + case 0: + case 1: + case 0x0c: + switch(r6) + { + default: + case 3: + f1 = 0.0026666666f; + f0 = 0.7f; + f31 = (f1 * f4) + f0; + case 11: + case 12: + case 20: + case 28: + f0 = f28 - f29; + f1 = 0.2f; + f30 = f1 + f0; + break; + case 0: + case 1: + case 4: + case 6: + case 7: + case 8: + case 9: + case 15: + case 16: + case 17: + case 18: + case 19: + case 21: + case 23: + case 24: + case 25: + case 26: + case 27: + f1 = 0.0026666666f; + f0 = 0.7f; + f31 = (f1 * f4) + f0; + case 2: + case 5: + case 10: + case 13: + case 14: + case 22: + f1 = 70.f; + f0 = 1.f; + f2 = f4 / f1; + if(f2 > f0) + { + f2 = f0; + } + f0 = f28 - f29; + f1 = 0.4f; + f0 += f1; + f30 = f2 * f0; + break; + } + break; + + break; + case 0x11: + switch(r6_2) + { + case 0x14: + case 0x15: + f0 = f28 - f29; + f1 = 0.2f; + f3 = 0.0026666666f; + f2 = 0.7f; + f30 = f1 + f0; + f31 = (f3 * f4) + f2; + break; + case 0xa: + f0 = 40.f; + f1 = mWaterDepths[wheel]; + if(f1 > f0) + { + f1 = f0; + } + f2 = 40.f; + f0 = 10.f; + f1 = f2 - f1; + f5 = f1 / f2; + if(f4 < f0) + { + f30 = 0.f; + } + else { + f1 = 70.f; + f0 = 1.f; + f4 /= f1; + if(f4 > f0) + { + f4 = f0; + } + f0 = 0.53f; + f3 = 1.2f; + f1 = f0 * f4; + f2 = 0.2f; + f0 = 0.79f; + f30 = (f3 * f4) + f2; + f31 = (f5 * f1) + f0; + } + break; + } + break; + + default: + f1 = 70.f; + f0 = 1.f; + f2 = f4 / f1; + if(f0 > f2) + { + f2 = f0; + } + f0 = f28 - f29; + f1 = 0.4f; + f0 = f1 + f0; + f30 = f2 * f0; + break; + } // 438 ? + f0 = 0.1f; + if(f30 <= f0){ + return; + } + f0 = 1.5f; + if(f30 > f0){ + f30 = f0; + } + _e4[wheel] = 1; + + _b4[wheel] = f30; + + bool isRightWheel = wheel & 1; + if(isRightWheel) + { + f0 = 0.47f; + _a4[wheel] = f0; + } + else { + f0 = 0.53f; + _a4[wheel] = f0; + } + _c4[wheel] = f31; + + switch(wheel) + { + case 0: + _104 = r6_2; + break; + case 1: + case 2: + case 3: + r0 = _104; + if(r0 != 6 && r0 != 5 && r0 != 10) + { + _104 = r6_2; + } + break; + } + } + //4d8 +} void KartSoundMgr::setConductStatus(f32, f32, bool, bool, bool, u8, CrsArea *) {} From 1595432ec57497f8f1fed204cde2c061ced0b514 Mon Sep 17 00:00:00 2001 From: Joachim Divet Date: Tue, 1 Sep 2026 20:00:35 +0200 Subject: [PATCH 12/22] 100% setSlip --- src/Inagaki/KartSoundMgr.cpp | 38 +++++++++++++----------------------- 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/src/Inagaki/KartSoundMgr.cpp b/src/Inagaki/KartSoundMgr.cpp index 2a132ed5..ad20f1eb 100644 --- a/src/Inagaki/KartSoundMgr.cpp +++ b/src/Inagaki/KartSoundMgr.cpp @@ -449,11 +449,13 @@ void KartSoundMgr::setSlip(u8 wheel, u8 r5, u8 r6, f32 slip) { return; } - f32 f29; f32 f28 = slip; u32 r27 = r5; + f32 f30 = 0.f; f32 f31 = 1.f; + f32 f29; + u8 r6_2; switch(r5) { case 0x11: @@ -609,11 +611,11 @@ void KartSoundMgr::setSlip(u8 wheel, u8 r5, u8 r6, f32 slip) { { f32 f4 = _84; f32 f0 = 5.f; + if(f4 < f0) { return; } - f0 = 0.0026666666; f32 f1 = 0.7; f32 f2; f32 f5; @@ -670,14 +672,11 @@ void KartSoundMgr::setSlip(u8 wheel, u8 r5, u8 r6, f32 slip) { f1 = 70.f; f0 = 1.f; f2 = f4 / f1; - if(f2 > f0) + if(f2 > 1.f) { f2 = f0; } - f0 = f28 - f29; - f1 = 0.4f; - f0 += f1; - f30 = f2 * f0; + f30 = f2 * (f28 - f29 + 0.4f); break; } break; @@ -688,25 +687,19 @@ void KartSoundMgr::setSlip(u8 wheel, u8 r5, u8 r6, f32 slip) { { case 0x14: case 0x15: - f0 = f28 - f29; - f1 = 0.2f; - f3 = 0.0026666666f; - f2 = 0.7f; - f30 = f1 + f0; - f31 = (f3 * f4) + f2; + f31 = (f4 * 0.0026666666f) + 0.7f; + f30 = (f28 - f29) + 0.2f; break; case 0xa: f0 = 40.f; f1 = mWaterDepths[wheel]; - if(f1 > f0) + if(f1 > 40.f) { f1 = f0; } - f2 = 40.f; - f0 = 10.f; - f1 = f2 - f1; - f5 = f1 / f2; - if(f4 < f0) + + f5 = (40.f - f1) / 40.f; + if(f4 < 10.f) { f30 = 0.f; } @@ -734,14 +727,11 @@ void KartSoundMgr::setSlip(u8 wheel, u8 r5, u8 r6, f32 slip) { f1 = 70.f; f0 = 1.f; f2 = f4 / f1; - if(f0 > f2) + if(f2 > f0) { f2 = f0; } - f0 = f28 - f29; - f1 = 0.4f; - f0 = f1 + f0; - f30 = f2 * f0; + f30 = f2 * (f28 - f29 + 0.4f); break; } // 438 ? f0 = 0.1f; From 6f0ae17f92cc29d4686a7750753fb0a69511e1b9 Mon Sep 17 00:00:00 2001 From: Joachim Divet Date: Tue, 1 Sep 2026 20:20:09 +0200 Subject: [PATCH 13/22] setCrushSe 100% --- src/Inagaki/KartSoundMgr.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Inagaki/KartSoundMgr.cpp b/src/Inagaki/KartSoundMgr.cpp index ad20f1eb..f174cd48 100644 --- a/src/Inagaki/KartSoundMgr.cpp +++ b/src/Inagaki/KartSoundMgr.cpp @@ -858,7 +858,7 @@ void KartSoundMgr::setCrushSe(CrsGround::EMat mat, f32 f1) { } void KartSoundMgr::setCrushSe(u32 r4, f32 f1) { - const u32 randomId = Common::changeRandomId(r4, 0); + r4 = Common::changeRandomId(r4, 0); const u32 randomId2 = Random::getRandomU32(); if(mKillSw || _66 == 2) { @@ -881,12 +881,13 @@ void KartSoundMgr::setCrushSe(u32 r4, f32 f1) { return; } - startSoundHandleNumber(0, randomId, 0); + startSoundHandleNumber(0, r4, 0); JAISoundHandle& handle = (*this)[0]; + f32 volume; const f32 f30 = f1 + 0.6f; if(handle.isSoundAttached()) { - const f32 volume = f30 * 0.8f; + volume = 0.8f * f30; handle->getAuxiliary().moveVolume(volume, 0); _a0 = f30; } From f3774530bc7efb02fffb46919133f7c9cac26f11 Mon Sep 17 00:00:00 2001 From: Joachim Divet Date: Tue, 1 Sep 2026 20:32:50 +0200 Subject: [PATCH 14/22] 100% constructor --- src/Inagaki/KartSoundMgr.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Inagaki/KartSoundMgr.cpp b/src/Inagaki/KartSoundMgr.cpp index f174cd48..aec321ca 100644 --- a/src/Inagaki/KartSoundMgr.cpp +++ b/src/Inagaki/KartSoundMgr.cpp @@ -74,15 +74,14 @@ KartSoundMgr::KartSoundMgr(Vec *pos, JKRHeap *heap, u8 p3, u8 p4) _61 = p3; - if(p3 == 0) { - smKartCount++; - mKartCount = smKartCount; + if(p4 == 0) { + mKartCount = smKartCount++; } else { mKartCount = 4; } - if(p3 != 2) { + if(p4 != 2) { smEntryKartCount++; } @@ -99,9 +98,9 @@ KartSoundMgr::KartSoundMgr(Vec *pos, JKRHeap *heap, u8 p3, u8 p4) while(smKartRankClassMem[rankClassIndex] == 1 && index < 7) { - rankClassIndex = rankClassIndex + 1; index++; - if(rankClassIndex == 7) + + if(++rankClassIndex == 7) { rankClassIndex = 0; } From b8de13e3c999bcb57abdb6803dd0350fb1b64964 Mon Sep 17 00:00:00 2001 From: Joachim Divet Date: Wed, 2 Sep 2026 20:04:11 +0200 Subject: [PATCH 15/22] Add setConductStatus implementation --- include/Inagaki/GameSoundMgr.h | 2 + src/Inagaki/KartSoundMgr.cpp | 196 ++++++++++++++++++++++++++++++++- 2 files changed, 196 insertions(+), 2 deletions(-) diff --git a/include/Inagaki/GameSoundMgr.h b/include/Inagaki/GameSoundMgr.h index e7e82b9e..cf1eca36 100644 --- a/include/Inagaki/GameSoundMgr.h +++ b/include/Inagaki/GameSoundMgr.h @@ -240,6 +240,7 @@ class KartSoundMgr : public SoundMgr static u8 smKartRankClassMem[7]; + // FABRICATED { bool isGoalVolumeEqual(f32 volume) const { return mGoalVolume == volume; } @@ -247,6 +248,7 @@ class KartSoundMgr : public SoundMgr bool isCameraVolumeEqual(f32 volume) const { return mCameraVolume == volume; } + // } FABRICATED u8 _5c; u8 _5d; diff --git a/src/Inagaki/KartSoundMgr.cpp b/src/Inagaki/KartSoundMgr.cpp index aec321ca..dd66ae81 100644 --- a/src/Inagaki/KartSoundMgr.cpp +++ b/src/Inagaki/KartSoundMgr.cpp @@ -5,14 +5,17 @@ #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" #include "JSystem/JGeometry/Vec.h" #include "JSystem/JUtility/JUTAssert.h" -#include "Kaneshige/Course/CrsArea.h" #include "JSystem/JAudio/JASFakeMatch2.h" + +#include "Kaneshige/Course/CrsArea.h" #include "Kaneshige/Course/CrsGround.h" +#include "kartEnums.h" namespace GameAudio { @@ -776,7 +779,196 @@ void KartSoundMgr::setSlip(u8 wheel, u8 r5, u8 r6, f32 slip) { //4d8 } -void KartSoundMgr::setConductStatus(f32, f32, bool, bool, bool, u8, CrsArea *) {} +void KartSoundMgr::setConductStatus(f32 f1, f32 f2, bool r4, bool r5, bool r6, u8 r7, CrsArea *r8) { + if(r8 != NULL && _5c == 0) + { + f32 rate = r8->getRate(); + f32 zeroValue = 0.f; + if(rate != zeroValue) + { + _6c = 0.8f * r8->getEchoRate(); + if(_6c > 0.8f) + { + _6c = 0.8f; + } + } + else { + _6c = zeroValue; + } + } + + if(mKillSw || _66 == 2) + { + return; + } + + _88 = f1; + _84 = f2; + + if(r6) + { + if(f2 < 1.0f) + { + r6 = 0; + } + } + + if(r6) + { + _8c = r5; + } + else { + _8c = r4; + } + _8d = r7; + + u8 characterType = Parameters::getCharacterType(_61); + + if(characterType != 9) + { + ECourseID id; + switch(_8d) + { + case 0: + setConductSignal(); + setWaterCutoffPort(0); + break; + case 1: + setConductOutOfCourse(r7); + setWaterCutoffPort(0); + if(_66 != 0) + { + break; + } + if(_63 == r7) + { + break; + } + id = Parameters::getRaceCourse(); + if(id != 0x2f) + { + break; + } + startSoundHandleNumber(7, 0x40074, 0); + break; + case 2: + setConductTrouble(f1, r7); + setWaterCutoffPort(0); + + if(_66 != 0) + { + break; + } + if(_63 == r7) + { + break; + } + + id = Parameters::getRaceCourse(); + if(id == 0x2a) + { + startSoundHandleNumber(7, 0x40057, 0); + break; + } + id = Parameters::getRaceCourse(); + if(id != 0x2f) + { + break; + } + startSoundHandleNumber(7, 0x40074, 0); + break; + case 3: + countGoalKart(); + _8c = 1; + setConductAfterGoal(r6); + _5e = 1; + break; + case 4: + setConductRace(r6); + // _66 + break; + case 5: + if(_66 == 0 && _63 != r7 && Parameters::getRaceCourse() == 0x2f) + { + startSoundHandleNumber(7, 0x40074, 0); + } + setConductPressed(); + break; + case 6: + default: + break; + } + } + else { + ECourseID id; + switch(_8d) + { + case 0: + case 2: + case 4: + if(_63 != r7) + { + _8e = 0; + _92 = 0; + } + setConductLocomotiveAccel(); + if(_66 != 0) + { + break; + } + if(_63 == r7) + { + break; + } + id = Parameters::getRaceCourse(); + if(id == 0x2a) + { + startSoundHandleNumber(7, 0x40057, 0); + break; + } + id = Parameters::getRaceCourse(); + if(id == 0x2f) + { + startSoundHandleNumber(7, 0x40074, 0); + } + break; + + case 3: + countGoalKart(); + _8c = 1; + _5e = 1; + + case 1: + if(_63 != r7) + { + _8e = 0; + _92 = 0; + } + + setConductLocomotiveSpeed(r6); + break; + case 5: + if(_66 == 0 && _63 != r7) + { + id = Parameters::getRaceCourse(); + if(id == 0x2f) + { + startSoundHandleNumber(7, 0x40074, 0); + } + } + + setConductPressed(); + break; + case 6: + default: + break; + } + } + + _68 = f1; + _63 = r7; + _98 = _84; +} void KartSoundMgr::setWaterCutoffPort(u16 port) { JAISoundHandle &handle = (*this)[3]; From 4de1dc74ab242957f1463a5a2e8e58548e6ad78a Mon Sep 17 00:00:00 2001 From: Joachim Divet Date: Sat, 5 Sep 2026 19:47:43 +0200 Subject: [PATCH 16/22] Add setConductLocomotiveAccel --- include/Inagaki/GameSoundMgr.h | 2 +- src/Inagaki/KartSoundMgr.cpp | 93 +++++++++++++++++++++++++++++++++- 2 files changed, 93 insertions(+), 2 deletions(-) diff --git a/include/Inagaki/GameSoundMgr.h b/include/Inagaki/GameSoundMgr.h index cf1eca36..801802c4 100644 --- a/include/Inagaki/GameSoundMgr.h +++ b/include/Inagaki/GameSoundMgr.h @@ -277,7 +277,7 @@ class KartSoundMgr : public SoundMgr u16 _90; u16 _92; u16 _94; - u16 _96; + s16 _96; f32 _98; u8 _9c; u8 _9d[3]; // padding diff --git a/src/Inagaki/KartSoundMgr.cpp b/src/Inagaki/KartSoundMgr.cpp index dd66ae81..829c5dbd 100644 --- a/src/Inagaki/KartSoundMgr.cpp +++ b/src/Inagaki/KartSoundMgr.cpp @@ -6,6 +6,7 @@ #include "Inagaki/GameAudioMain.h" #include "Inagaki/GameSoundTable.h" +#include "JSystem/JAudio/Interface/JAIAudible.h" #include "JSystem/JAudio/Interface/JAISound.h" #include "JSystem/JAudio/JAUSoundObject.h" #include "JSystem/JAudio/System/JASGadget.h" @@ -991,7 +992,97 @@ void KartSoundMgr::countGoalKart() { smGoalKartCount++; } -void KartSoundMgr::setConductLocomotiveAccel() {} +void KartSoundMgr::setConductLocomotiveAccel() { + u32 r6; + JAISound* sound; + f32 r4; + JAISoundStarter* soundStarter; + f32 f31; + + bool changed = false; + u32 soundID; + + if(_8c != 0) + { + if(_8e == 0) + { + if(_92 == 0) + { + _92 = 9; + } + else if(_92 > 4) { + _92--; + } + changed = true; + f31 = 0.6f; + _8e = _92; + } + } + else if(_8e == 0) + { + if(_92 == 0) + { + _92 = 9; + } + if(_92 < 9){ + _92++; + _8e = _92; + } + else { + _8e = _92; + } + changed = true; + f31 = 0.4f; + } + + if(changed) + { + soundID = ((_96++ & 1) ? 0x11 : 0x12); + + soundStarter = JASGlobalInstance::getInstance(); + + JAISoundHandle& handle = (*this)[3]; + + soundStarter->startSound( + soundID + (_66 != 0 ? 0x14 : 0), + &handle, + NULL); + + if(handle.isSoundAttached()) + { + JAIAudible* audible = handle->getAudible(); + if(audible == 0) + { + r6 = _7c; + + sound = handle.operator->(); + JGeometry::TVec3f vec(*mSoundPos); + + sound->newAudible(vec, &_18, r6, NULL); + if(_80 != 0){ + + handle->fader_.fadeInFromOut2(_80); + _80 = 0; + } + } + setEcho(&handle, _6c); + } + JAISoundHandle& handle_2 = (*this)[3]; + if(!handle_2.isSoundAttached()) + { + return; + } + handle_2->getAuxiliary().moveVolume(f31, 0); + r4 = 0.6f + ((0.4f * (9 - _92)) / 5.f); + handle_2->getAuxiliary().movePitch(r4, 0); + } + else { + if(_8e != 0) + { + _8e--; + } + } +} void KartSoundMgr::setConductLocomotiveSpeed(bool) {} From 7c9c4b6556ec45d485a47482e754b394298d2c5e Mon Sep 17 00:00:00 2001 From: Joachim Divet Date: Sat, 5 Sep 2026 23:28:04 +0200 Subject: [PATCH 17/22] Add setConductLocomotiveSpeed --- src/Inagaki/KartSoundMgr.cpp | 74 +++++++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-) diff --git a/src/Inagaki/KartSoundMgr.cpp b/src/Inagaki/KartSoundMgr.cpp index 829c5dbd..5948beb7 100644 --- a/src/Inagaki/KartSoundMgr.cpp +++ b/src/Inagaki/KartSoundMgr.cpp @@ -1084,7 +1084,79 @@ void KartSoundMgr::setConductLocomotiveAccel() { } } -void KartSoundMgr::setConductLocomotiveSpeed(bool) {} +void KartSoundMgr::setConductLocomotiveSpeed(bool) { + u32 r6; + JAISound* sound; + f32 r4; + f32 f31; + u32 soundID; + + f31 = _84; + if(_8e == 0) + { + if(f31 < 1.f) + { + f31 = 1.f; + } + if(f31 > 130.f) + { + f31 = 130.f; + } + _8e = (u16) (3.f + ((130.f - f31) / 20.f)); + + soundID = 0x12 + -(_96++ & 1); + + JAISoundStarter *const soundStarter = JASGlobalInstance::getInstance(); + + JAISoundHandle* handle = &(*this)[3]; + + soundStarter->startSound( + soundID + (_66 != 0 ? 0x14 : 0), + handle, + NULL); + + if(handle->isSoundAttached()) + { + JAIAudible* audible = (*handle)->getAudible(); + if(audible == 0) + { + r6 = _7c; + + sound = (*handle).operator->(); + JGeometry::TVec3f vec(*mSoundPos); + + sound->newAudible(vec, &_18, r6, NULL); + if(_80 != 0){ + + (*handle)->fader_.fadeInFromOut2(_80); + _80 = 0; + } + } + setEcho(handle, _6c); + } + handle = &(*this)[3]; + if(!handle->isSoundAttached()) + { + return; + } + JAISound* sound = handle->operator->(); + sound->getAuxiliary().moveVolume((0.7f * (f31 / 130.f)) + 0.5f, 0); + f32 pitch = 1.f; + if(f31 < 100.f) { + pitch = f31 / 100.f; + } + if(_5d != 0) + { + f32 chibiPitch = Parameters::getChibiPitch(soundID); + pitch *= chibiPitch; + } + r4 = 0.6f + ((0.4f * (9 - _92)) / 5.f); + (*handle)->getAuxiliary().movePitch((0.4f * pitch) + 0.6f, 0); + } + else { + _8e--; + } +} void KartSoundMgr::setConductPressed() {} From 17c2f6ed629e8082d9468b445ffd3a92db355483 Mon Sep 17 00:00:00 2001 From: Joachim Divet Date: Sun, 6 Sep 2026 00:22:46 +0200 Subject: [PATCH 18/22] Add setConductPressed --- include/Inagaki/GameSoundMgr.h | 36 ++++++++++++++++ src/Inagaki/KartSoundMgr.cpp | 77 ++++++++++------------------------ 2 files changed, 57 insertions(+), 56 deletions(-) diff --git a/include/Inagaki/GameSoundMgr.h b/include/Inagaki/GameSoundMgr.h index 801802c4..82f47cb0 100644 --- a/include/Inagaki/GameSoundMgr.h +++ b/include/Inagaki/GameSoundMgr.h @@ -248,6 +248,42 @@ class KartSoundMgr : public SoundMgr bool isCameraVolumeEqual(f32 volume) const { return mCameraVolume == volume; } + + void startSoundFromID(u32 id) { + u32 r6; + JAISound* sound; + + JAISoundStarter* soundStarter = JASGlobalInstance::getInstance(); + + JAISoundHandle& handle = (*this)[3]; + + id += (_66 != 0 ? 0x14 : 0); + + soundStarter->startSound( + id, + &handle, + NULL); + + if(handle.isSoundAttached()) + { + JAIAudible* audible = handle->getAudible(); + if(audible == 0) + { + r6 = _7c; + + sound = handle.operator->(); + JGeometry::TVec3f vec(*mSoundPos); + + sound->newAudible(vec, &_18, r6, NULL); + if(_80 != 0){ + + handle->fader_.fadeInFromOut2(_80); + _80 = 0; + } + } + setEcho(&handle, _6c); + } + } // } FABRICATED u8 _5c; diff --git a/src/Inagaki/KartSoundMgr.cpp b/src/Inagaki/KartSoundMgr.cpp index 5948beb7..60b66c83 100644 --- a/src/Inagaki/KartSoundMgr.cpp +++ b/src/Inagaki/KartSoundMgr.cpp @@ -1039,34 +1039,7 @@ void KartSoundMgr::setConductLocomotiveAccel() { { soundID = ((_96++ & 1) ? 0x11 : 0x12); - soundStarter = JASGlobalInstance::getInstance(); - - JAISoundHandle& handle = (*this)[3]; - - soundStarter->startSound( - soundID + (_66 != 0 ? 0x14 : 0), - &handle, - NULL); - - if(handle.isSoundAttached()) - { - JAIAudible* audible = handle->getAudible(); - if(audible == 0) - { - r6 = _7c; - - sound = handle.operator->(); - JGeometry::TVec3f vec(*mSoundPos); - - sound->newAudible(vec, &_18, r6, NULL); - if(_80 != 0){ - - handle->fader_.fadeInFromOut2(_80); - _80 = 0; - } - } - setEcho(&handle, _6c); - } + startSoundFromID(soundID); JAISoundHandle& handle_2 = (*this)[3]; if(!handle_2.isSoundAttached()) { @@ -1106,35 +1079,9 @@ void KartSoundMgr::setConductLocomotiveSpeed(bool) { soundID = 0x12 + -(_96++ & 1); - JAISoundStarter *const soundStarter = JASGlobalInstance::getInstance(); + startSoundFromID(soundID); JAISoundHandle* handle = &(*this)[3]; - - soundStarter->startSound( - soundID + (_66 != 0 ? 0x14 : 0), - handle, - NULL); - - if(handle->isSoundAttached()) - { - JAIAudible* audible = (*handle)->getAudible(); - if(audible == 0) - { - r6 = _7c; - - sound = (*handle).operator->(); - JGeometry::TVec3f vec(*mSoundPos); - - sound->newAudible(vec, &_18, r6, NULL); - if(_80 != 0){ - - (*handle)->fader_.fadeInFromOut2(_80); - _80 = 0; - } - } - setEcho(handle, _6c); - } - handle = &(*this)[3]; if(!handle->isSoundAttached()) { return; @@ -1158,7 +1105,25 @@ void KartSoundMgr::setConductLocomotiveSpeed(bool) { } } -void KartSoundMgr::setConductPressed() {} +void KartSoundMgr::setConductPressed() { + startSoundFromID(0x13); + + f32 pitch = _84; + if(pitch > 100.f) + { + pitch = 100.f; + } + + pitch = 1.f + (pitch / 100.f); + + JAISoundHandle& handle = (*this)[3]; + if(!handle.isSoundAttached()) + { + return; + } + + handle->getAuxiliary().movePitch(pitch, 0); +} void KartSoundMgr::setConductSignal() {} From ec05ad5be43159d38caef60bb14650d23534187b Mon Sep 17 00:00:00 2001 From: Joachim Divet Date: Sun, 6 Sep 2026 00:55:03 +0200 Subject: [PATCH 19/22] Fix build --- include/Inagaki/GameSoundMgr.h | 41 ++++------------------------------ src/Inagaki/KartSoundMgr.cpp | 41 ++++++++++++++++++++++++++++++++-- 2 files changed, 43 insertions(+), 39 deletions(-) diff --git a/include/Inagaki/GameSoundMgr.h b/include/Inagaki/GameSoundMgr.h index 82f47cb0..4ff73a2f 100644 --- a/include/Inagaki/GameSoundMgr.h +++ b/include/Inagaki/GameSoundMgr.h @@ -240,6 +240,7 @@ class KartSoundMgr : public SoundMgr static u8 smKartRankClassMem[7]; +private: // FABRICATED { bool isGoalVolumeEqual(f32 volume) const { return mGoalVolume == volume; @@ -249,43 +250,9 @@ class KartSoundMgr : public SoundMgr return mCameraVolume == volume; } - void startSoundFromID(u32 id) { - u32 r6; - JAISound* sound; - - JAISoundStarter* soundStarter = JASGlobalInstance::getInstance(); - - JAISoundHandle& handle = (*this)[3]; - - id += (_66 != 0 ? 0x14 : 0); - - soundStarter->startSound( - id, - &handle, - NULL); - - if(handle.isSoundAttached()) - { - JAIAudible* audible = handle->getAudible(); - if(audible == 0) - { - r6 = _7c; - - sound = handle.operator->(); - JGeometry::TVec3f vec(*mSoundPos); - - sound->newAudible(vec, &_18, r6, NULL); - if(_80 != 0){ - - handle->fader_.fadeInFromOut2(_80); - _80 = 0; - } - } - setEcho(&handle, _6c); - } - } - // } FABRICATED - + void startSoundFromID(u32 id); +// } FABRICATED +public: u8 _5c; u8 _5d; u8 _5e; diff --git a/src/Inagaki/KartSoundMgr.cpp b/src/Inagaki/KartSoundMgr.cpp index 60b66c83..b8f8fd02 100644 --- a/src/Inagaki/KartSoundMgr.cpp +++ b/src/Inagaki/KartSoundMgr.cpp @@ -992,6 +992,43 @@ void KartSoundMgr::countGoalKart() { smGoalKartCount++; } +void KartSoundMgr::startSoundFromID(u32 id) +{ + u32 r6; + JAISound* sound; + + JAISoundStarter* soundStarter = JASGlobalInstance::getInstance(); + + JAISoundHandle& handle = (*this)[3]; + + id += (_66 != 0 ? 0x14 : 0); + + soundStarter->startSound( + id, + &handle, + NULL); + + if(handle.isSoundAttached()) + { + JAIAudible* audible = handle->getAudible(); + if(audible == 0) + { + r6 = _7c; + + sound = handle.operator->(); + JGeometry::TVec3f vec(*mSoundPos); + + sound->newAudible(vec, &_18, r6, NULL); + if(_80 != 0){ + + handle->fader_.fadeInFromOut2(_80); + _80 = 0; + } + } + setEcho(&handle, _6c); + } +} + void KartSoundMgr::setConductLocomotiveAccel() { u32 r6; JAISound* sound; @@ -1000,7 +1037,6 @@ void KartSoundMgr::setConductLocomotiveAccel() { f32 f31; bool changed = false; - u32 soundID; if(_8c != 0) { @@ -1037,7 +1073,7 @@ void KartSoundMgr::setConductLocomotiveAccel() { if(changed) { - soundID = ((_96++ & 1) ? 0x11 : 0x12); + const u32 soundID = ((_96++ & 1) ? 0x11 : 0x12); startSoundFromID(soundID); JAISoundHandle& handle_2 = (*this)[3]; @@ -1057,6 +1093,7 @@ void KartSoundMgr::setConductLocomotiveAccel() { } } + void KartSoundMgr::setConductLocomotiveSpeed(bool) { u32 r6; JAISound* sound; From 72b81568052c1ac9c4b36d9ac956293a77c4b2a8 Mon Sep 17 00:00:00 2001 From: Joachim Divet Date: Mon, 7 Sep 2026 19:50:51 +0200 Subject: [PATCH 20/22] Add setConductSignal implementation --- include/Inagaki/GameSoundMgr.h | 2 +- src/Inagaki/KartSoundMgr.cpp | 190 ++++++++++++++++++++++++++++++++- 2 files changed, 190 insertions(+), 2 deletions(-) diff --git a/include/Inagaki/GameSoundMgr.h b/include/Inagaki/GameSoundMgr.h index 4ff73a2f..a3759578 100644 --- a/include/Inagaki/GameSoundMgr.h +++ b/include/Inagaki/GameSoundMgr.h @@ -306,7 +306,7 @@ class KartSoundMgr : public SoundMgr u8 _106[0x110 - 0x106]; f32 _110; f32 _114; - u8 _118[0x11c - 0x118]; + f32 _118; u32 _11c; f32 mGoalVolume; f32 mCameraVolume; // 124 diff --git a/src/Inagaki/KartSoundMgr.cpp b/src/Inagaki/KartSoundMgr.cpp index b8f8fd02..3f3e8ceb 100644 --- a/src/Inagaki/KartSoundMgr.cpp +++ b/src/Inagaki/KartSoundMgr.cpp @@ -20,6 +20,13 @@ namespace GameAudio { +const s16 SignalUpPitchWidth[3] = { 0x0064, 0x0082, 0x0078 }; +const s16 SignalUpPitchBase[3] = { 0x0032, 0x0046, 0x0050 }; +const s16 SignalUpIntervalWidth[3] = { 0x0046, 0x001E, 0x000A }; +const s16 SignalUpIntervalBase[3] = { 0x0014, 0x000A, 0x0005 }; +const s16 SignalDownIntervalWidth[3] = { 0x0050, 0x0032, 0x0014 }; +const s16 SignalDownIntervalBase[3] = { 0x0014, 0x000A, 0x0005 }; + // TODO static const u8 cKartRankClassTable0[7] = {0, 0, 1, 1, 1, 2, 2}; static const u8 cKartRankClassTable1[7] = {0, 0, 1, 1, 2, 2, 2}; @@ -30,6 +37,8 @@ u32 SpinSe[0x19]; 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, @@ -992,6 +1001,7 @@ void KartSoundMgr::countGoalKart() { smGoalKartCount++; } +// FABRICATED { void KartSoundMgr::startSoundFromID(u32 id) { u32 r6; @@ -1028,6 +1038,7 @@ void KartSoundMgr::startSoundFromID(u32 id) setEcho(&handle, _6c); } } +// } FABRICATED void KartSoundMgr::setConductLocomotiveAccel() { u32 r6; @@ -1162,7 +1173,184 @@ void KartSoundMgr::setConductPressed() { handle->getAuxiliary().movePitch(pitch, 0); } -void KartSoundMgr::setConductSignal() {} +static const f32 EngineKarabukashiLength[] = { + 90.f, 40.f, 90.f, 30.f, + 40.f, 35.f, 30.f, 95.f, + 90.f +}; + +static const f32 EnginePitchKeisuuSignal[] = { + 0.02f, 0.05f, 0.02f, 0.09f, + 0.05f, 0.06f, 0.06f, 0.02f, + 0.05f +}; + +static const f32 EnginePitchDownSignal[] = { + 0.9f, 0.9f, 0.6f, 0.9f, + 0.9f, 0.7f, 0.7f, 0.6f, + 0.8f +}; + +static const f32 EnginePitchKeisuuOutOfCourse[] = { + 0.01f, 0.01f, 0.01f, 0.01f, + 0.01f, 0.01f, 0.01f, 0.01f, + 0.01f +}; + +static const f32 EnginePitchKeisuuTrouble[] = { + 0.025f, 0.025f, 0.025f, 0.025f, + 0.025f, 0.025f, 0.025f, 0.025f, + 0.025f +}; + +static const f32 EngineAddKeisuuRaceUp[] = { + 0.0006f, 0.0006f, 0.0006f, 0.0005f, + 0.0012f, 0.0012f, 0.0012f, 0.0012f, + 0.0012f +}; + +static const f32 UpEngineLoopStart[] = { + 100639.f, 133568.f, 121677.f, 89762.f, + 0.f, 0.f, 0.f, 0.f, + 0.f +}; + +static const f32 UpEngineLoopEnd[] = { + 113023.f, 167266.f, 138431.f, 100738.f, + 0.f, 0.f, 0.f, 0.f, + 0.f +}; + +static const f32 EngineAddKeisuuRaceDown[] = { + 0.00015f, 0.00015f, 0.00015f, 0.00015f, + 0.0006f, 0.0006f, 0.0006f, 0.0006f, + 0.0006f +}; + +static const f32 DownEngineLoopStart[] = { + 42032.f, 57452.f, 54457.f, 33775.f, + 0.f, 0.f, 0.f, 0.f, + 0.f +}; + +static const f32 DownEngineLoopEnd[] = { + 93600.f, 104350.f, 79743.f, 63943.f, + 0.f, 0.f, 0.f, 0.f, + 0.f +}; + +void KartSoundMgr::setConductSignal() { + if(_63 != _8d) + { + _fc = 0.f; + } + + f32 pitch; + f32 volume; + if(_66 == 0 || Parameters::getNetworkCubes() != 1) + { + if(_8c == 1) + { + volume = 1.4f; + f32 length = EngineKarabukashiLength[(u8)Parameters::getEngineType(_61)]; + if(_fc < length) + { + _fc = _fc + 1.f; + } + + f32 signal = EnginePitchKeisuuSignal[(u8)Parameters::getEngineType(_61)]; + pitch = (_fc * signal) + 0.7f; + } + else { + volume = 0.7f; + if(_fc > 0.f){ + f32 signal = EnginePitchDownSignal[(u8)Parameters::getEngineType(_61)]; + _fc -= signal; + } + else { + _fc = 0.f; + } + f32 signal = EnginePitchKeisuuSignal[(u8)Parameters::getEngineType(_61)]; + pitch = (_fc * signal) + 0.7f; + } + if(_fc < 20.f) + { + volume = ((-0.015000001f * _fc) + volume) + 0.3f; + } + } + else { + if(_11c == 0) + { + _5f ^= 1; + if(_5f != 0) + { + u32 interval = SignalUpIntervalBase[_64] + (Random::getSignalEngineRandomU32() % SignalUpIntervalWidth[_64]); + u32 pitchInt = SignalUpPitchBase[_64] + (Random::getSignalEngineRandomU32() % SignalUpPitchWidth[_64]); + f32 currentPitch = f32(pitchInt) / 100.f; + if((_11c != 0 || _114 != currentPitch) && (_11c == 0 || _110 != currentPitch)) + { + _110 = currentPitch; + if(interval == 0) + { + _114 = currentPitch; + } + else { + _118 = (_114 - _110) / (f32)(interval + 1); + _11c = interval + 1; + } + } + } + else { + u32 interval = SignalDownIntervalBase[_64] + (Random::getSignalEngineRandomU32() % SignalDownIntervalWidth[_64]); + f32 volumeC = 0.7f; + if ((_11c != 0 || _114 != volumeC) && (_11c == 0 || _110 != volumeC)) + { + _110 = 0.7f; + if (interval == 0) + { + _114 = 0.7f; + } + else + { + u32 ticks = interval + 1; + _118 = (_114 - _110) / (f32)ticks; + _11c = ticks; + } + } + } + } + + if(_11c != 0) + { + if(--_11c != 0){ + _114 -= _118; + } + else { + _114 = _110; + } + } + if(_5f != 0) + { + volume = 1.4f; + } + else { + volume = 0.7f; + } + + pitch = _114; + volume = volume * GA_ENEMY_VOLUME_DOWN_VALUE; + } + + u8 engineType = Parameters::getEngineType(_61); + startSoundFromID(engineType + 8); + + JAISoundHandle& handle = (*this)[3]; + if(handle.isSoundAttached()) + { + handle->getAuxiliary().moveVolume(volume, 0); + handle->getAuxiliary().movePitch(pitch, 0); + } +} void KartSoundMgr::setConductOutOfCourse(u8) {} From 75b965d3aad2a9d40aec5e2c4f6555369c982c50 Mon Sep 17 00:00:00 2001 From: Joachim Divet Date: Mon, 7 Sep 2026 20:26:32 +0200 Subject: [PATCH 21/22] Add setConductOutOfCourse --- src/Inagaki/KartSoundMgr.cpp | 51 +++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/src/Inagaki/KartSoundMgr.cpp b/src/Inagaki/KartSoundMgr.cpp index 3f3e8ceb..278fa9bc 100644 --- a/src/Inagaki/KartSoundMgr.cpp +++ b/src/Inagaki/KartSoundMgr.cpp @@ -1352,7 +1352,56 @@ void KartSoundMgr::setConductSignal() { } } -void KartSoundMgr::setConductOutOfCourse(u8) {} +void KartSoundMgr::setConductOutOfCourse(u8 r4) { + JAISound* sound; + f32 volume; + u32 soundID; + + if(_63 != r4) + { + _94 = 0; + } + if(_8c == 1) + { + if(_94 < 0x64) + { + _94++; + _94++; + } + volume = 1.2f; + } + else { + if(_94 != 0) + { + _94--; + } + volume = 0.55f; + } + + f32 pitch = (EnginePitchKeisuuOutOfCourse[(u8)Parameters::getEngineType(_61)] * _94) + 0.6f; + + if(_66 != 0){ + volume *= GA_ENEMY_VOLUME_DOWN_VALUE; + } + + u8 engineType = Parameters::getEngineType(_61); + startSoundFromID(engineType + 8); + + JAISoundHandle* handle = &(*this)[3]; + if(!handle->isSoundAttached()) + { + return; + } + + if(_5d != 0) + { + f32 chibiPitch = Parameters::getChibiPitch((*handle)->getID()); + pitch *= chibiPitch; + volume *= 0.65f; + } + (*handle)->getAuxiliary().moveVolume(volume, 0); + (*handle)->getAuxiliary().movePitch(pitch, 0); +} void KartSoundMgr::setConductTrouble(f32, u8) {} From 9b888d0140c1f0cf06dcef0d37b28b01e1b0159e Mon Sep 17 00:00:00 2001 From: Joachim Divet Date: Mon, 7 Sep 2026 20:30:15 +0200 Subject: [PATCH 22/22] Add setConductTrouble --- src/Inagaki/KartSoundMgr.cpp | 51 +++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/src/Inagaki/KartSoundMgr.cpp b/src/Inagaki/KartSoundMgr.cpp index 278fa9bc..bacdacde 100644 --- a/src/Inagaki/KartSoundMgr.cpp +++ b/src/Inagaki/KartSoundMgr.cpp @@ -1403,7 +1403,56 @@ void KartSoundMgr::setConductOutOfCourse(u8 r4) { (*handle)->getAuxiliary().movePitch(pitch, 0); } -void KartSoundMgr::setConductTrouble(f32, u8) {} +void KartSoundMgr::setConductTrouble(f32 f1, u8 r4) { + JAISound* sound; + f32 volume; + u32 soundID; + + if(_63 != r4) + { + _92 = (u16)(38.f * f1); + } + if(_8c == 1) + { + if(_92 < 0x26) + { + _92++; + _92++; + } + volume = 1.2f; + } + else { + if(_92 != 0) + { + _92--; + } + volume = 0.55f; + } + + f32 pitch = (EnginePitchKeisuuTrouble[(u8)Parameters::getEngineType(_61)] * _92) + 0.6f; + + if(_66 != 0){ + volume *= GA_ENEMY_VOLUME_DOWN_VALUE; + } + + u8 engineType = Parameters::getEngineType(_61); + startSoundFromID(engineType + 8); + + JAISoundHandle* handle = &(*this)[3]; + if(!handle->isSoundAttached()) + { + return; + } + + if(_5d != 0) + { + f32 chibiPitch = Parameters::getChibiPitch((*handle)->getID()); + pitch *= chibiPitch; + volume *= 0.65f; + } + (*handle)->getAuxiliary().moveVolume(volume, 0); + (*handle)->getAuxiliary().movePitch(pitch, 0); +} void KartSoundMgr::setConductRace(bool) {}