fix(amd64-386): crash with sample-based oscillator in 32-bit library

This commit is contained in:
5684185+vsariola@users.noreply.github.com 2024-09-22 09:30:42 +03:00
parent 0e10cd2ae8
commit ce673578fd
2 changed files with 8 additions and 0 deletions

View File

@ -10,6 +10,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
the command line tools.
### Fixed
- Crashes with sample-based oscillators in the 32-bit library, as the pointer to
sample-table (edi) got accidentally overwritten by detune
- Sample-based oscillators could hard crash if a x87 stack overflow happened
when calculating the current position in the sample ([#149][i149])
- Numeric updown widget calculated dp-to-px conversion incorrectly, resulting in

View File

@ -127,6 +127,9 @@ su_op_oscillat_mono:
{{- end}}
{{- if .SupportsParamValueOtherThan "oscillator" "unison" 0}}
{{.PushRegs .AX "" .WRK "OscWRK" .AX "OscFlags"}}
{{- if and (not .Amd64) .Library}}
push {{.AX}} ; pushregs is pushad in 32-bit, and pushes edi last, so decrease SP because library needs to save edi and we can store detune there
{{- end}}
fldz ; 0 d
fxch ; d a=0, "accumulated signal"
su_op_oscillat_unison_loop:
@ -147,6 +150,9 @@ su_op_oscillat_unison_loop:
dec eax
jmp short su_op_oscillat_unison_loop
su_op_oscillat_unison_out:
{{- if and (not .Amd64) .Library}}
pop {{.AX}} ; pushregs is pushad in 32-bit, and pushes edi last, so we inscrease SP to avoid destroying edi
{{- end}}
{{.PopRegs .AX .WRK .AX}}
ret
su_op_oscillat_single: