From d224532af60774afcde5a4d1f7c402dea983c409 Mon Sep 17 00:00:00 2001 From: shibbo Date: Thu, 8 Feb 2024 13:39:58 -0500 Subject: [PATCH] SpkSpeakerCtrl::connect match I forgot to commit a while ago --- csv/Speaker.csv | 2 +- data/Game.json | 2 +- data/json/Speaker.json | 2 +- docs/PROGRESS.md | 2 +- docs/lib/Speaker.md | 2 +- docs/lib/Speaker/SpkSpeakerCtrl.md | 4 +- include/Game/Speaker/SpkMixingBuffer.hpp | 2 +- include/Game/Speaker/SpkSpeakerCtrl.hpp | 13 +++---- libs/RVL_SDK/include/revolution/wenc.h | 2 + libs/RVL_SDK/include/revolution/wpad.h | 2 + source/Game/Speaker/SpkSpeakerCtrl.cpp | 47 +++++++++++++++++++++++- 11 files changed, 63 insertions(+), 17 deletions(-) diff --git a/csv/Speaker.csv b/csv/Speaker.csv index 9bf78c72..7a2137d8 100644 --- a/csv/Speaker.csv +++ b/csv/Speaker.csv @@ -14,7 +14,7 @@ framework__14SpkSpeakerCtrlFv,SpkSpeakerCtrl.o,Speaker.a,true reconnectProcess__14SpkSpeakerCtrlFl,SpkSpeakerCtrl.o,Speaker.a,true initReconnect__14SpkSpeakerCtrlFl,SpkSpeakerCtrl.o,Speaker.a,true continuousUsingProcess__14SpkSpeakerCtrlFl,SpkSpeakerCtrl.o,Speaker.a,true -updateSpeaker__14SpkSpeakerCtrlFP7OSAlarmP9OSContext,SpkSpeakerCtrl.o,Speaker.a,false +updateSpeaker__14SpkSpeakerCtrlFP7OSAlarmP9OSContext,SpkSpeakerCtrl.o,Speaker.a,true isEnable__14SpkSpeakerCtrlFl,SpkSpeakerCtrl.o,Speaker.a,true extensionProcess__14SpkSpeakerCtrlFll,SpkSpeakerCtrl.o,Speaker.a,true getDeviceVolume__14SpkSpeakerCtrlFl,SpkSpeakerCtrl.o,Speaker.a,true diff --git a/data/Game.json b/data/Game.json index 3da33022..b63d63cc 100644 --- a/data/Game.json +++ b/data/Game.json @@ -1,6 +1,6 @@ { "schemaVersion": 1, "label": "Game", - "message": "11.949%", + "message": "11.956%", "color": "blue" } \ No newline at end of file diff --git a/data/json/Speaker.json b/data/json/Speaker.json index af73344a..169f2cde 100644 --- a/data/json/Speaker.json +++ b/data/json/Speaker.json @@ -1,6 +1,6 @@ { "schemaVersion": 1, "label": "Speaker", - "message": "50.654%", + "message": "54.752%", "color": "daa520" } \ No newline at end of file diff --git a/docs/PROGRESS.md b/docs/PROGRESS.md index 4246fa03..e8adc081 100644 --- a/docs/PROGRESS.md +++ b/docs/PROGRESS.md @@ -21,6 +21,6 @@ | [Ride](https://github.com/shibbo/Petari/blob/master/docs/lib/Ride.md) | 0.0% | | [Scene](https://github.com/shibbo/Petari/blob/master/docs/lib/Scene.md) | 13.849590469099033% | | [Screen](https://github.com/shibbo/Petari/blob/master/docs/lib/Screen.md) | 6.315748206421598% | -| [Speaker](https://github.com/shibbo/Petari/blob/master/docs/lib/Speaker.md) | 50.65452475811042% | +| [Speaker](https://github.com/shibbo/Petari/blob/master/docs/lib/Speaker.md) | 54.75241889584519% | | [System](https://github.com/shibbo/Petari/blob/master/docs/lib/System.md) | 14.681379713534055% | | [Util](https://github.com/shibbo/Petari/blob/master/docs/lib/Util.md) | 10.090099514848767% | diff --git a/docs/lib/Speaker.md b/docs/lib/Speaker.md index 70548950..24fc7dd7 100644 --- a/docs/lib/Speaker.md +++ b/docs/lib/Speaker.md @@ -8,7 +8,7 @@ | Object | Percentage (of Bytes) | Functions Done / Total Functions | Percentage (Functions) | Status | ------------- | ------------- | ------------- | ------------- | ------------- -| [SpkSpeakerCtrl.o](https://github.com/shibbo/Petari/blob/master/docs/lib/Speaker/SpkSpeakerCtrl.md) | 58.289703315881326% | 16 / 21 | 76.19047619047619% | :eight_pointed_black_star: +| [SpkSpeakerCtrl.o](https://github.com/shibbo/Petari/blob/master/docs/lib/Speaker/SpkSpeakerCtrl.md) | 70.85514834205934% | 17 / 21 | 80.95238095238095% | :eight_pointed_black_star: | [SpkSystem.o](https://github.com/shibbo/Petari/blob/master/docs/lib/Speaker/SpkSystem.md) | 70.3125% | 11 / 14 | 78.57142857142857% | :eight_pointed_black_star: | [SpkMixingBuffer.o](https://github.com/shibbo/Petari/blob/master/docs/lib/Speaker/SpkMixingBuffer.md) | 55.952380952380956% | 3 / 4 | 75.0% | :eight_pointed_black_star: | [SpkWave.o](https://github.com/shibbo/Petari/blob/master/docs/lib/Speaker/SpkWave.md) | 100.0% | 7 / 7 | 100.0% | :white_check_mark: diff --git a/docs/lib/Speaker/SpkSpeakerCtrl.md b/docs/lib/Speaker/SpkSpeakerCtrl.md index 5482ddb4..81084b45 100644 --- a/docs/lib/Speaker/SpkSpeakerCtrl.md +++ b/docs/lib/Speaker/SpkSpeakerCtrl.md @@ -5,7 +5,7 @@ | :white_check_mark: | Function is completed. -# 16 / 21 Completed -- (76.19047619047619%) +# 17 / 21 Completed -- (80.95238095238095%) # SpkSpeakerCtrl.o | Symbol | Decompiled? | | ------------- | ------------- | @@ -24,7 +24,7 @@ | `reconnectProcess__14SpkSpeakerCtrlFl` | :white_check_mark: | | `initReconnect__14SpkSpeakerCtrlFl` | :white_check_mark: | | `continuousUsingProcess__14SpkSpeakerCtrlFl` | :white_check_mark: | -| `updateSpeaker__14SpkSpeakerCtrlFP7OSAlarmP9OSContext` | :x: | +| `updateSpeaker__14SpkSpeakerCtrlFP7OSAlarmP9OSContext` | :white_check_mark: | | `isEnable__14SpkSpeakerCtrlFl` | :white_check_mark: | | `extensionProcess__14SpkSpeakerCtrlFll` | :white_check_mark: | | `getDeviceVolume__14SpkSpeakerCtrlFl` | :white_check_mark: | diff --git a/include/Game/Speaker/SpkMixingBuffer.hpp b/include/Game/Speaker/SpkMixingBuffer.hpp index 7111b222..014322cd 100644 --- a/include/Game/Speaker/SpkMixingBuffer.hpp +++ b/include/Game/Speaker/SpkMixingBuffer.hpp @@ -9,7 +9,7 @@ public: void mix(s32, s16 *, s32, f32, s32); const s16* getSamples(s32) const; - void update(s32); + bool update(s32); const s16* mSamples[4]; }; \ No newline at end of file diff --git a/include/Game/Speaker/SpkSpeakerCtrl.hpp b/include/Game/Speaker/SpkSpeakerCtrl.hpp index 7f995661..a4c3d76d 100644 --- a/include/Game/Speaker/SpkSpeakerCtrl.hpp +++ b/include/Game/Speaker/SpkSpeakerCtrl.hpp @@ -38,18 +38,17 @@ public: static void reconnectProcess(s32); static void initReconnect(s32); static void continuousUsingProcess(s32); - static void updateSpekaer(OSAlarm *, OSContext *); + static void updateSpeaker(OSAlarm *, OSContext *); static bool isEnable(s32); static void extensionProcess(s32, s32); static f32 getDeviceVolume(s32); static void initInfoDefaults(s32 idx) { - sSpeakerInfo[idx]._0 = 1; - sSpeakerInfo[idx]._1 = 0; - sSpeakerInfo[idx]._24 = 0; - SpkSpeakerCtrl::initReconnect(idx); - sSpeakerInfo[idx]._30 = -1; - SpkSpeakerCtrl::setSpeakerOn(idx); + + } + + static inline SpeakerInfo& getSpeakerInfo(s32 idx) { + return sSpeakerInfo[idx]; } static SpeakerInfo sSpeakerInfo[4]; diff --git a/libs/RVL_SDK/include/revolution/wenc.h b/libs/RVL_SDK/include/revolution/wenc.h index da98a3fc..82022e60 100644 --- a/libs/RVL_SDK/include/revolution/wenc.h +++ b/libs/RVL_SDK/include/revolution/wenc.h @@ -11,6 +11,8 @@ typedef struct { u8 data[32]; } WENCInfo; +s32 WENCGetEncodeData(WENCInfo *, u32, const s16 *, s32, u8 *); + #ifdef __cplusplus } #endif diff --git a/libs/RVL_SDK/include/revolution/wpad.h b/libs/RVL_SDK/include/revolution/wpad.h index 8d22da12..271938b6 100644 --- a/libs/RVL_SDK/include/revolution/wpad.h +++ b/libs/RVL_SDK/include/revolution/wpad.h @@ -38,6 +38,8 @@ void WPADDisconnect(s32); s32 WPADGetInfoAsync(s32, WPADInfo *, WPADCallback); void WPADSetAutoSleepTime(u8); +BOOL WPADCanSendStreamData(s32); +s32 WPADSendStreamData(s32, void *, u16); #ifdef __cplusplus } diff --git a/source/Game/Speaker/SpkSpeakerCtrl.cpp b/source/Game/Speaker/SpkSpeakerCtrl.cpp index 5c13806d..884c26dd 100644 --- a/source/Game/Speaker/SpkSpeakerCtrl.cpp +++ b/source/Game/Speaker/SpkSpeakerCtrl.cpp @@ -14,7 +14,12 @@ void SpkSpeakerCtrl::setMixingBuffer(SpkMixingBuffer *pMixingBuffer) { void SpkSpeakerCtrl::connect(s32 idx) { BOOL state = OSDisableInterrupts(); - initInfoDefaults(idx); + sSpeakerInfo[idx]._0 = 1; + sSpeakerInfo[idx]._1 = 0; + sSpeakerInfo[idx]._24 = 0; + SpkSpeakerCtrl::initReconnect(idx); + sSpeakerInfo[idx]._30 = -1; + SpkSpeakerCtrl::setSpeakerOn(idx); OSRestoreInterrupts(state); } @@ -159,7 +164,45 @@ void SpkSpeakerCtrl::continuousUsingProcess(s32 idx) { } } -// SpkSpeakerCtrl::updateSpeaker +void SpkSpeakerCtrl::updateSpeaker(OSAlarm *, OSContext *) { + for (s32 i = 0; i < 4; i++) { + if (sMixingBuffer != nullptr) { + SpeakerInfo& inf = getSpeakerInfo(i); + + if (inf._1) { + if (!inf._23) { + if (sMixingBuffer->update(i)) { + bool v5 = true; + + if (inf._1 && sMixingBuffer != nullptr) { + BOOL en = OSDisableInterrupts(); + + if (!WPADCanSendStreamData(i)) { + + OSRestoreInterrupts(en); + } + else { + if (inf._22) { + v5 = false; + inf._22 = 0; + } + + const s16* samples = sMixingBuffer->getSamples(i); + u8 data[16]; + WENCGetEncodeData(&inf._2, v5, samples, 40, data); + WPADSendStreamData(i, data, 0x14); + OSRestoreInterrupts(en); + } + } + } + else { + inf._22 = 1; + } + } + } + } + } +} bool SpkSpeakerCtrl::isEnable(s32 idx) { bool ret = false;