diff options
author | Nadia Holmquist Pedersen <nadia@nhp.sh> | 2021-08-16 23:47:54 +0200 |
---|---|---|
committer | Nadia Holmquist Pedersen <nadia@nhp.sh> | 2021-08-17 01:01:15 +0200 |
commit | 418b35198680643be760dab4f4b2b8df2696041f (patch) | |
tree | 29f72afaa5bcd25283859e69e1b339af339084de /src/SPU.cpp | |
parent | d5a20ad3c85ca09679fdc83feb3814785d1187cf (diff) |
SPU: Emulate SOUNDBIAS and 10-bit degrade
Diffstat (limited to 'src/SPU.cpp')
-rw-r--r-- | src/SPU.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/SPU.cpp b/src/SPU.cpp index e42bff8..d1c2d84 100644 --- a/src/SPU.cpp +++ b/src/SPU.cpp @@ -81,6 +81,8 @@ Platform::Mutex* AudioLock; u16 Cnt; u8 MasterVolume; u16 Bias; +bool ApplyBias; +bool Degrade10Bit; Channel* Channels[16]; CaptureUnit* Capture[2]; @@ -190,6 +192,14 @@ void SetBias(u16 bias) Bias = bias; } +void SetApplyBias(bool enable) { + ApplyBias = enable; +} + +void SetDegrade10Bit(bool enable) { + Degrade10Bit = enable; +} + Channel::Channel(u32 num) { @@ -795,6 +805,21 @@ void Mix(u32 dummy) if (rightoutput < -0x8000) rightoutput = -0x8000; else if (rightoutput > 0x7FFF) rightoutput = 0x7FFF; + // The original DS and DS lite degrade the output from 16 to 10 bit before output + if (Degrade10Bit) + { + leftoutput &= 0xFFFFFFC0; + rightoutput &= 0xFFFFFFC0; + } + + // Add SOUNDBIAS value + // The value used by all commercial games is 0x200, so we subtract that so it won't offset the final sound output. + if (ApplyBias == true) + { + leftoutput += (Bias << 6) - 0x8000; + rightoutput += (Bias << 6) - 0x8000; + } + // OutputBufferFrame can never get full because it's // transfered to OutputBuffer at the end of the frame OutputBackbuffer[OutputBackbufferWritePosition ] = leftoutput >> 1; |