ADSR envelope overflow bugfix.

This commit is contained in:
Bobbi Webber-Manners 2022-11-24 16:21:36 -05:00
parent 37fce59283
commit 943cce4f70
1 changed files with 6 additions and 1 deletions

View File

@ -1,7 +1,10 @@
* MAINMEM.AUDIO.S
* (c) Bobbi 2022 GPLv3
*
* Applecorn audio code
* Applecorn audio code.
* This is the implementation of the audio-engine. The code is
* device-independent, using the Ensoniq driver in MAINMEM.ENSQ.S
* or the Mockingboard driver in MAINMEM.MOCK.S.
*
SYSCLOCK DB $00 ; Centisecond counter (5 bytes)
@ -729,6 +732,7 @@ ADSRPHASE STX OSCNUM
:S1 TYA ; Change/step -> A
CLC
ADC CURRAMP,X ; Add change to current amp
BCS :CLAMP ; If overflow, clamp to target
CMP :TARGET ; Compare with target
BCS :CLAMP ; If target < sum, clamp to target
BRA :UPDATE
@ -739,6 +743,7 @@ ADSRPHASE STX OSCNUM
:S2 TYA ; Change/step -> A
CLC
ADC CURRAMP,X ; Add change to current amp
BCS :CLAMP ; If overflow, clamp to target
CMP :TARGET ; Compare with target
BCC :CLAMP ; If target >= sum, clamp to target
BRA :UPDATE