From 9f19d681de34d3cd0119d0d320a18f47008c1491 Mon Sep 17 00:00:00 2001 From: Ingo Saitz Date: Wed, 17 Nov 2021 15:56:27 +0100 Subject: [PATCH] [Linux] OpenAL: fix mic data The data returned by Mic_ReadSample() must be transfered in 2 parts. This must be done by every microphone driver. I did test with Lunar: Dragon Song which values are considered loud, since you can run away by screaming/blowing into the microphone. Values from 33-223 don't trigger the escape, values from 0-32 and from 224-255 trigger an escape attempt. Thus 128 would be considered silence. --- desmume/src/frontend/posix/shared/mic_openal.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/desmume/src/frontend/posix/shared/mic_openal.cpp b/desmume/src/frontend/posix/shared/mic_openal.cpp index 264cb672e..fc848cd08 100644 --- a/desmume/src/frontend/posix/shared/mic_openal.cpp +++ b/desmume/src/frontend/posix/shared/mic_openal.cpp @@ -149,7 +149,17 @@ u8 Mic_ReadSample() stats_max = ret; if (ret < stats_min) stats_min = ret; - Mic_BufPos += 2; + + // convert to 2 bytes to transfer over SPI + if (Mic_BufPos & 0x1) + { + ret = ((ret & 0x01) << 7); + } + else + { + ret = ((ret & 0xFE) >> 1); + } + Mic_BufPos += 1; return ret; }