Change apply to "do" and add brackets.

This commit is contained in:
Veikko Sariola 2020-05-24 01:11:17 +03:00
parent 2c6f4f44d5
commit 7de7b49e24
7 changed files with 59 additions and 60 deletions

View File

@ -79,7 +79,7 @@ EXPORT MANGLE_FUNC(su_op_loadnote,0)
su_op_loadnote_mono:
%endif
fild dword [INP-su_voice.inputs+su_voice.note]
apply fmul dword, c_i128
do fmul dword [,c_i128,]
ret
%endif

View File

@ -24,7 +24,7 @@ su_waveshaper:
call su_clip
fxch ; a x' (from now on just called x)
fld st0 ; a a x
apply fsub dword,c_0_5 ; a-.5 a x
do fsub dword [,c_0_5,] ; a-.5 a x
fadd st0 ; 2*a-1 a x
fld st2 ; x 2*a-1 a x
fabs ; abs(x) 2*a-1 a x
@ -317,7 +317,7 @@ EXPORT MANGLE_FUNC(su_op_delay,0)
lodsw ; al = delay index, ah = delay count
push_registers VAL, COM ; these are non-volatile according to our convention
movzx ebx, al
apply {lea _BX,},MANGLE_DATA(su_delay_times),_BX*2,{} ; _BP now points to the right position within delay time table
do{lea _BX,[},MANGLE_DATA(su_delay_times),_BX*2,] ; _BP now points to the right position within delay time table
movzx esi, word [_SP + su_stack.tick + PUSH_REG_SIZE(2)] ; notice that we load word, so we wrap at 65536
mov _CX, PTRWORD [_SP + su_stack.delaywrk + PUSH_REG_SIZE(2)] ; WRK is now the separate delay workspace, as they require a lot more space
%ifdef INCLUDE_STEREO_DELAY
@ -367,14 +367,14 @@ su_op_delay_loop:
test ah, 1 ; note syncing is the least significant bit of ah, 0 = ON, 1 = OFF
jne su_op_delay_skipnotesync
fild dword [INP-su_voice.inputs+su_voice.note]
apply fmul dword, c_i12
do fmul dword [,c_i12,]
call MANGLE_FUNC(su_power,0)
fdivp st1, st0 ; use 10787 for delaytime to have neutral transpose
su_op_delay_skipnotesync:
%endif
%ifdef INCLUDE_DELAY_MODULATION
fld dword [WRK+su_unit.ports+su_delay_ports.delaymod]
apply fmul dword, c_32767 ; scale it up, as the modulations would be too small otherwise
do fmul dword [,c_32767,] ; scale it up, as the modulations would be too small otherwise
faddp st1, st0
%endif
fistp dword [_SP-4] ; dr*y p*p*x, dword [_SP-4] = integer amount of delay (samples)
@ -403,13 +403,13 @@ su_op_delay_loop:
fstp st1 ; dr*y+s1+s2+s3+...
; DC-filtering
fld dword [_CX+su_delayline_wrk.dcout] ; o s
apply fmul dword, c_dc_const ; c*o s
do fmul dword [,c_dc_const,] ; c*o s
fsub dword [_CX+su_delayline_wrk.dcin] ; c*o-i s
fxch ; s c*o-i
fst dword [_CX+su_delayline_wrk.dcin] ; i'=s, s c*o-i
faddp st1 ; s+c*o-i
apply fadd dword, c_0_5 ; add and sub small offset to prevent denormalization
apply fsub dword, c_0_5
do fadd dword [,c_0_5,] ; add and sub small offset to prevent denormalization
do fsub dword [,c_0_5,]
fst dword [_CX+su_delayline_wrk.dcout] ; o'=s+c*o-i
ret
@ -480,7 +480,7 @@ su_op_compressor_releasing:
su_op_compressor_compress: ; l' x
fdivrp st1, st0 ; t*t/l' x
fld dword [INP+su_compres_ports.ratio] ; r t*t/l' x
apply fmul dword, c_0_5 ; p=r/2 t*t/l' x
do fmul dword [,c_0_5,] ; p=r/2 t*t/l' x
fxch ; t*t/l' p x
fyl2x ; p*log2(t*t/l') x
jmp MANGLE_FUNC(su_power,0) ; 2^(p*log2(t*t/l')) x

View File

@ -50,9 +50,9 @@ su_op_advance_finish:
SECT_TEXT(suspeed)
EXPORT MANGLE_FUNC(su_op_speed,0)
apply fsub dword, c_0_5 ; s-.5
do fsub dword [,c_0_5,] ; s-.5
fadd st0, st0 ; 2*s-1
apply fmul dword, c_bpmscale ; (2*s-1)*64/24, let's call this p from now on
do fmul dword [,c_bpmscale,] ; (2*s-1)*64/24, let's call this p from now on
call MANGLE_FUNC(su_power,0) ; 2^p, this is how many ticks we should be taking
fld1 ; 1 2^p
fsubp st1, st0 ; 2^p-1, the player is advancing 1 tick by its own

View File

@ -59,7 +59,7 @@ su_op_send_skipglobal:
fld st0 ; duplicate the signal on stack: s s
su_op_send_skippush: ; there is signal s, but maybe also another: s (s)
fld dword [INP+su_send_ports.amount] ; a l (l)
apply fsub dword, c_0_5 ; a-.5 l (l)
do fsub dword [,c_0_5,] ; a-.5 l (l)
fadd st0 ; g=2*a-1 l (l)
and _AX, 0x0000ffff - SEND_POP - SEND_GLOBAL ; eax = send address
fmulp st1, st0 ; g*l (l)

View File

@ -84,7 +84,7 @@ su_op_noise_mono:
imul eax, [_CX + su_stack.randseed],16007
mov [_CX + su_stack.randseed],eax
fild dword [_CX + su_stack.randseed]
apply fidiv dword,c_RandDiv
do fidiv dword [,c_RandDiv,]
fld dword [INP+su_noise_ports.shape]
call su_waveshaper
fld dword [INP+su_noise_ports.gain]
@ -108,7 +108,7 @@ SECT_TEXT(suoscill)
EXPORT MANGLE_FUNC(su_op_oscillat,0)
lodsb ; load the flags
fld dword [INP+su_osc_ports.detune] ; e, where e is the detune [0,1]
apply fsub dword,c_0_5 ; e-.5
do fsub dword [,c_0_5,] ; e-.5
fadd st0, st0 ; d=2*e-.5, where d is the detune [-1,1]
%ifdef INCLUDE_STEREO_OSCILLAT
jnc su_op_oscillat_mono
@ -131,10 +131,10 @@ su_op_oscillat_unison_loop:
je su_op_oscillat_unison_out
add WRK, 8
fld dword [INP+su_osc_ports.phaseofs] ; p s
apply fadd dword, c_i12 ; p s, add some little phase offset to unison oscillators so they don't start in sync
do fadd dword [,c_i12,] ; p s, add some little phase offset to unison oscillators so they don't start in sync
fstp dword [INP+su_osc_ports.phaseofs] ; s note that this changes the phase for second, possible stereo run. That's probably ok
fld dword [_SP] ; d s
apply fmul dword, c_0_5 ; .5*d s // negate and halve the detune of each oscillator
do fmul dword [,c_0_5,] ; .5*d s // negate and halve the detune of each oscillator
fchs ; -.5*d s // negate and halve the detune of each oscillator
dec eax
jmp short su_op_oscillat_unison_loop
@ -144,21 +144,21 @@ su_op_oscillat_unison_out:
su_op_oscillat_single:
%endif
fld dword [INP+su_osc_ports.transpose]
apply fsub dword,c_0_5
apply fdiv dword,c_i128
do fsub dword [,c_0_5,]
do fdiv dword [,c_i128,]
faddp st1
test al, byte LFO
jnz su_op_oscillat_skipnote
fiadd dword [INP-su_voice.inputs+su_voice.note] ; // st0 is note, st1 is t+d offset
su_op_oscillat_skipnote:
apply fmul dword,c_i12
do fmul dword [,c_i12,]
call MANGLE_FUNC(su_power,0)
test al, byte LFO
jz short su_op_oscillat_normalize_note
apply fmul dword,c_lfo_normalize ; // st0 is now frequency for lfo
do fmul dword [,c_lfo_normalize,] ; // st0 is now frequency for lfo
jmp short su_op_oscillat_normalized
su_op_oscillat_normalize_note:
apply fmul dword,c_freq_normalize ; // st0 is now frequency
do fmul dword [,c_freq_normalize,] ; // st0 is now frequency
su_op_oscillat_normalized:
fadd dword [WRK+su_osc_wrk.phase]
fst dword [WRK+su_osc_wrk.phase]
@ -286,7 +286,7 @@ SECT_TEXT(sugate)
su_oscillat_gate:
fxch ; p c
fstp st1 ; p
apply fmul dword, c_16 ; 16*p
do fmul dword [,c_16,] ; 16*p
push _AX
push _AX
fistp dword [_SP] ; s=int(16*p), stack empty
@ -299,9 +299,9 @@ su_oscillat_gate:
go4kVCO_gate_bit: ; stack: 0/1, let's call it x
fld dword [WRK+su_osc_wrk.gatestate] ; g x, g is gatestate, x is the input to this filter 0/1
fsub st1 ; g-x x
apply fmul dword,c_dc_const ; c(g-x) x
do fmul dword [,c_dc_const,] ; c(g-x) x
faddp st1, st0 ; x+c(g-x)
fst dword [WRK+su_osc_wrk.gatestate] ; g'=x+c(g-x)
fst dword [WRK+su_osc_wrk.gatestate]; g'=x+c(g-x)
pop _AX ; Another way to see this (c~0.996)
ret ; g'=cg+(1-c)x
; This is a low-pass to smooth the gate transitions
@ -329,8 +329,8 @@ su_oscillat_sample: ; p
push_registers _AX,_DX,_CX,_BX ; edx must be saved, eax & ecx if this is stereo osc
push _AX
mov al, byte [VAL-4] ; reuse "color" as the sample number
apply {lea _DI,}, MANGLE_DATA(su_sample_offsets), _AX*8,{} ; edi points now to the sample table entry
apply fmul dword, c_samplefreq_scaling ; p*r
do{lea _DI, [}, MANGLE_DATA(su_sample_offsets), _AX*8,]; edi points now to the sample table entry
do fmul dword [,c_samplefreq_scaling,] ; p*r
fistp dword [_SP]
pop _DX ; edx is now the sample number
movzx ebx, word [_DI + su_sample_offset.loopstart] ; ecx = loopstart
@ -343,8 +343,8 @@ su_oscillat_sample: ; p
su_oscillat_sample_not_looping:
add edx, ebx ; sampleno += loopstart
add edx, dword [_DI + su_sample_offset.start]
apply fild word, MANGLE_DATA(su_sample_table), _DX*2,{}
apply fdiv dword, c_32767
do fild word [,MANGLE_DATA(su_sample_table),_DX*2,]
do fdiv dword [,c_32767,]
pop_registers _AX,_DX,_CX,_BX
ret
@ -373,7 +373,7 @@ EXPORT MANGLE_FUNC(su_op_loadval,0)
su_op_loadval_mono:
%endif
fld dword [INP+su_load_val_ports.value] ; v
apply fsub dword, c_0_5
do fsub dword [,c_0_5,]
fadd st0 ; 2*v-1
ret

View File

@ -89,10 +89,10 @@ SECT_DATA(suconst)
xor _CX,_CX
xor eax,eax
%%loop: ; loop over two channels, left & right
apply fld dword,su_synth_obj+su_synth.left,_CX*4,{}
do fld dword [,su_synth_obj+su_synth.left,_CX*4,]
call su_clip
fstp dword [_SI]
apply mov dword,su_synth_obj+su_synth.left,_CX*4,{,eax} ; clear the sample so the VM is ready to write it
do mov dword [,su_synth_obj+su_synth.left,_CX*4,{],eax} ; clear the sample so the VM is ready to write it
add _SI,4
cmp ecx,2
jl %%loop
@ -105,7 +105,7 @@ SECT_DATA(suconst)
%%loop: ; loop over two channels, left & right
fld dword [_DI]
call su_clip
apply fmul dword, c_32767
do fmul dword [,c_32767,]
push _AX
fistp dword [_SP]
pop _AX
@ -186,14 +186,14 @@ su_update_voices: ; Stack: retaddr row
xor edx, edx
mov ebx, PATTERN_SIZE ; we could do xor ebx,ebx; mov bl,PATTERN_SIZE, but that would limit patternsize to 256...
div ebx ; eax = current pattern, edx = current row in pattern
apply {lea _SI,},MANGLE_DATA(su_tracks),_AX,{} ; esi points to the pattern data for current track
do{lea _SI, [},MANGLE_DATA(su_tracks),_AX,] ; esi points to the pattern data for current track
xor eax, eax ; eax is the first voice of next track
xor ebx, ebx ; ebx is the first voice of current track
mov _BP, PTRWORD su_synth_obj ; ebp points to the current_voiceno array
su_update_voices_trackloop:
movzx eax, byte [_SI] ; eax = current pattern
imul eax, PATTERN_SIZE ; eax = offset to current pattern data
apply {movzx eax,byte},MANGLE_DATA(su_patterns),_AX,_DX,{} ; eax = note
do{movzx eax,byte [},MANGLE_DATA(su_patterns),_AX,_DX,] ; eax = note
push _DX ; Stack: ptrnrow
xor edx, edx ; edx=0
mov ecx, ebx ; ecx=first voice of the track to be done
@ -209,7 +209,7 @@ su_calculate_voices_loop: ; do {
mov edi, ecx
add edi, ebx
shl edi, MAX_UNITS_SHIFT + 6 ; each unit = 64 bytes and there are 1<<MAX_UNITS_SHIFT units + small header
apply inc dword, su_synth_obj+su_synth.voices+su_voice.release,_DI,{} ; set the voice currently active to release; notice that it could increment any number of times
do inc dword [,su_synth_obj+su_synth.voices+su_voice.release,_DI,] ; set the voice currently active to release; notice that it could increment any number of times
cmp al, HLD ; if cl < HLD (no new note triggered)
jl su_update_voices_nexttrack ; goto nexttrack
inc ecx ; curvoice++
@ -220,7 +220,7 @@ su_update_voices_skipreset:
mov byte [_BP],cl
add ecx, ebx
shl ecx, MAX_UNITS_SHIFT + 6 ; each unit = 64 bytes and there are 1<<MAX_UNITS_SHIFT units + small header
apply {lea _DI,},su_synth_obj+su_synth.voices,_CX,{}
do{lea _DI,[},su_synth_obj+su_synth.voices,_CX,]
stosd ; save note
mov ecx, (su_voice.size - su_voice.release)/4
xor eax, eax
@ -230,8 +230,7 @@ su_update_voices_nexttrack:
pop _DX ; edx=patrnrow
add _SI, MAX_PATTERNS
inc _BP
apply {lea _AX,},su_synth_obj,MAX_TRACKS,{}
cmp _BP,_AX
do{cmp _BP,},su_synth_obj+MAX_TRACKS
jl su_update_voices_trackloop
ret
@ -243,13 +242,13 @@ su_update_voices: ; Stack: retaddr row
xor ebx, ebx
mov bl, PATTERN_SIZE
div ebx ; eax = current pattern, edx = current row in pattern
apply {lea _SI,},MANGLE_DATA(su_tracks),_AX,{}; esi points to the pattern data for current track
do{lea _SI, [},MANGLE_DATA(su_tracks),_AX,]; esi points to the pattern data for current track
mov _DI, PTRWORD su_synth_obj+su_synth.voices
mov bl, MAX_TRACKS ; MAX_TRACKS is always <= 32 so this is ok
su_update_voices_trackloop:
movzx eax, byte [_SI] ; eax = current pattern
imul eax, PATTERN_SIZE ; eax = offset to current pattern data
apply {movzx eax, byte}, MANGLE_DATA(su_patterns), _AX, _DX, {} ; ecx = note
do{movzx eax, byte [}, MANGLE_DATA(su_patterns),_AX,_DX,] ; ecx = note
cmp al, HLD ; anything but hold causes action
je short su_update_voices_nexttrack
inc dword [_DI+su_voice.release] ; set the voice currently active to release; notice that it could increment any number of times

View File

@ -16,25 +16,25 @@
%define RESPTR resq
%define DPTR dq
%macro apply 2
%macro do 2
mov r9, qword %2
%1 [r9]
%1 r9
%endmacro
%macro apply 3
%macro do 3
mov r9, qword %2
%1 [r9] %3
%1 r9 %3
%endmacro
%macro apply 4
%macro do 4
mov r9, qword %2
%1 [r9+%3] %4
%1 r9+%3 %4
%endmacro
%macro apply 5
%macro do 5
mov r9, qword %2
lea r9, [r9+%3]
%1 [r9+%4] %5
%1 r9+%4 %5
%endmacro
%macro push_registers 1-*
@ -70,20 +70,20 @@
%define RESPTR resd
%define DPTR dd
%macro apply 2
%1 [%2]
%macro do 2
%1 %2
%endmacro
%macro apply 3
%1 [%2] %3
%macro do 3
%1 %2 %3
%endmacro
%macro apply 4
%1 [%2+%3] %4
%macro do 4
%1 %2+%3 %4
%endmacro
%macro apply 5
%1 [%2+%3+%4] %5
%macro do 5
%1 %2+%3+%4 %5
%endmacro
%macro push_registers 1-*
@ -174,12 +174,12 @@ su_run_vm_loop: ; loop until all voices done
add WRK, su_unit.size ; move WRK to next unit
push _AX
shr eax,1
apply {mov al,byte},su_opcode_numparams,_AX,{}
do {mov al, byte [},su_opcode_numparams,_AX,]
push _AX
call su_transform_values
pop _AX
shr eax,1
apply call,su_synth_commands,_AX*PTRSIZE,{} ; call the function corresponding to the instruction
do call [,su_synth_commands,_AX*PTRSIZE,] ; call the function corresponding to the instruction
cmp dword [_SP+su_stack.voiceno-PTRSIZE],MAX_VOICES ; if (voice < MAX_VOICES)
jl su_run_vm_loop ; goto vm_loop
add _SP, su_stack.retaddrvm-PTRSIZE ; Stack cleared
@ -208,7 +208,7 @@ su_transform_values_loop:
lodsb
push _AX
fild dword [_SP]
apply fmul dword, c_i128
do fmul dword [,c_i128,]
fadd dword [WRK+su_unit.ports+_CX*4]
fstp dword [INP+_CX*4]
mov dword [WRK+su_unit.ports+_CX*4], 0
@ -230,7 +230,7 @@ SECT_TEXT(supower)
%if ENVELOPE_ID > -1 ; TODO: compressor also uses this, so should be compiled if either
su_env_map:
fld dword [INP+_AX*4] ; x, where x is the parameter in the range 0-1
apply fimul dword,c_24 ; 24*x
do fimul dword [,c_24,] ; 24*x
fchs ; -24*x
; flow into Power function, which outputs 2^(-24*x)
%endif