refactor(asm&go4k): Remove FLAGS from all units; they were the source of difficulty in parsing and fragile.

All units now take parameters according to flags. Only non-numeric parameter anymore is oscillator type.
This commit is contained in:
Veikko Sariola
2020-11-10 00:18:56 +02:00
parent e36aea59a5
commit ae334a5dfe
57 changed files with 207 additions and 250 deletions

View File

@ -177,31 +177,31 @@ EXPORT MANGLE_FUNC(su_op_filter,0)
fstp dword [WRK+su_filter_wrk.band] ; b'=f2*h'+b
fldz ; 0
%ifdef INCLUDE_LOWPASS
test al, byte LOWPASS
test al, byte LOWPASSFLAG
jz short su_op_filter_skiplowpass
fadd dword [WRK+su_filter_wrk.low]
su_op_filter_skiplowpass:
%endif
%ifdef INCLUDE_BANDPASS
test al, byte BANDPASS
test al, byte BANDPASSFLAG
jz short su_op_filter_skipbandpass
fadd dword [WRK+su_filter_wrk.band]
su_op_filter_skipbandpass:
%endif
%ifdef INCLUDE_HIGHPASS
test al, byte HIGHPASS
test al, byte HIGHPASSFLAG
jz short su_op_filter_skiphighpass
fadd dword [WRK+su_filter_wrk.high]
su_op_filter_skiphighpass:
%endif
%ifdef INCLUDE_NEGBANDPASS
test al, byte NEGBANDPASS
test al, byte NEGBANDPASSFLAG
jz short su_op_filter_skipnegbandpass
fsub dword [WRK+su_filter_wrk.band]
su_op_filter_skipnegbandpass:
%endif
%ifdef INCLUDE_NEGHIGHPASS
test al, byte NEGHIGHPASS
test al, byte NEGHIGHPASSFLAG
jz short su_op_filter_skipneghighpass
fsub dword [WRK+su_filter_wrk.high]
su_op_filter_skipneghighpass:

View File

@ -12,41 +12,46 @@
%endif
%endmacro
%define LOWPASS 0x40
%define BANDPASS 0x20
%define HIGHPASS 0x10
%define NEGBANDPASS 0x08
%define NEGHIGHPASS 0x04
%define LOWPASSFLAG 0x40
%define BANDPASSFLAG 0x20
%define HIGHPASSFLAG 0x10
%define NEGBANDPASSFLAG 0x08
%define NEGHIGHPASSFLAG 0x04
%macro SU_FILTER 4
%macro SU_FILTER 8
db %2
db %3
db %4
db (%4*LOWPASSFLAG)+(%5*BANDPASSFLAG)+(%6*HIGHPASSFLAG)+(%7*NEGBANDPASSFLAG)+(%8*NEGHIGHPASSFLAG)
USE_FILTER
%xdefine CMDS CMDS FILTER_ID + %1,
%if %1 == STEREO
%define INCLUDE_STEREO_FILTER
%endif
%if (%4) & LOWPASS == LOWPASS
%if %4 > 0
%define INCLUDE_LOWPASS
%endif
%if (%4) & BANDPASS == BANDPASS
%if %5 > 0
%define INCLUDE_BANDPASS
%endif
%if (%4) & HIGHPASS == HIGHPASS
%if %6 > 0
%define INCLUDE_HIGHPASS
%endif
%if (%4) & NEGBANDPASS == NEGBANDPASS
%if %7 > 0
%define INCLUDE_NEGBANDPASS
%endif
%if (%4) & NEGHIGHPASS == NEGHIGHPASS
%if %8 > 0
%define INCLUDE_NEGHIGHPASS
%endif
%endmacro
%define FREQUENCY(val) val
%define RESONANCE(val) val
%define FLAGS(val) val
%define FREQUENCY(val) val
%define RESONANCE(val) val
%define FLAGS(val) val
%define LOWPASS(val) val
%define BANDPASS(val) val
%define HIGHPASS(val) val
%define NEGBANDPASS(val) val
%define NEGHIGHPASS(val) val
struc su_filter_ports
.freq resd 1
@ -289,7 +294,7 @@ endstruc
%if %1 == STEREO
%define INCLUDE_STEREO_DELAY
%endif
%if (%8) & NOTETRACKING == 1
%if %8 > 0
%define INCLUDE_DELAY_NOTETRACKING
%define INCLUDE_DELAY_FLOAT_TIME
%endif
@ -311,14 +316,14 @@ endstruc
%endmacro
%define PREGAIN(val) val
%define DRY(val) val
%define FEEDBACK(val) val
%define DEPTH(val) val
%define DAMP(val) val
%define DELAY(val) val
%define COUNT(val) val
%define NOTETRACKING 1
%define PREGAIN(val) val
%define DRY(val) val
%define FEEDBACK(val) val
%define DEPTH(val) val
%define DAMP(val) val
%define DELAY(val) val
%define COUNT(val) val
%define NOTETRACKING(val) val
struc su_delay_ports
.pregain resd 1

View File

@ -98,7 +98,7 @@ EXPORT MANGLE_FUNC(su_op_send,0)
fxch ; r l
call su_op_send_mono ; (r) l
mov _AX, _DI ; move back to original address
test _AX, SEND_POP ; if r was not popped and is still in the stack
test _AX, SENDPOPFLAG ; if r was not popped and is still in the stack
jnz su_op_send_mono
fxch ; swap them back: l r
su_op_send_mono:
@ -109,14 +109,14 @@ su_op_send_mono:
mov _CX, [_SP + su_stack.synth]
su_op_send_skipglobal:
%endif
test _AX, SEND_POP ; if the SEND_POP bit is not set
test _AX, SENDPOPFLAG ; if the SEND_POP bit is not set
jnz su_op_send_skippush
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)
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
and _AX, 0x0000ffff - SENDPOPFLAG - SEND_GLOBAL ; eax = send address
fmulp st1, st0 ; g*l (l)
fadd dword [_CX + _AX*4] ; g*l+L (l),where L is the current value
fstp dword [_CX + _AX*4] ; (l)

View File

@ -101,7 +101,7 @@ endstruc
%macro SU_SEND 5 ; local send (params: STEREO, AMOUNT, UNIT, PORT, FLAGS)
db %2
dw ((%3+1)*su_unit.size + su_unit.ports)/4 + %4 + %5
dw ((%3+1)*su_unit.size + su_unit.ports)/4 + %4 + (SENDPOPFLAG * %5)
USE_SEND
%xdefine CMDS CMDS SEND_ID + %1,
%if %1 == STEREO
@ -109,9 +109,9 @@ endstruc
%endif
%endmacro
%macro SU_SEND 6 ; global send (params: STEREO, AMOUNT, VOICE, UNIT, PORT, FLAGS)
%macro SU_SEND 6 ; global send (params: STEREO, AMOUNT, VOICE, UNIT, PORT, SENDPOP)
db %2
dw SEND_GLOBAL + (su_synthworkspace.voices+%3*su_voice.size+su_voice.workspace+%4*su_unit.size + su_unit.ports)/4 + %5 + %6
dw SEND_GLOBAL + (su_synthworkspace.voices+%3*su_voice.size+su_voice.workspace+%4*su_unit.size + su_unit.ports)/4 + %5 + (SENDPOPFLAG * %6)
USE_SEND
%xdefine CMDS CMDS SEND_ID + %1,
%if %1 == STEREO
@ -125,8 +125,8 @@ endstruc
%define PORT(val) val
%define AMOUNT(val) val
%define OUTPORT 0
%define NONE 0
%define SEND_POP 0x8000
%define SENDPOP(val) val
%define SENDPOPFLAG 0x8000
%define SEND_GLOBAL 0x4000
struc su_send_ports

View File

@ -131,7 +131,7 @@ su_op_oscillat_unison_loop:
fst dword [_SP] ; save the current detune, d. We could keep it in fpu stack but it was getting big.
call su_op_oscillat_single ; s a
faddp st1, st0 ; a+=s
test al, UNISON4
test al, UNISONBITS
je su_op_oscillat_unison_out
add WRK, 8
fld dword [INP+su_osc_ports.phaseofs] ; p s
@ -151,13 +151,13 @@ su_op_oscillat_single:
do fsub dword [,c_0_5,]
do fdiv dword [,c_i128,]
faddp st1
test al, byte LFO
test al, byte LFOFLAG
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:
do fmul dword [,c_i12,]
call MANGLE_FUNC(su_power,0)
test al, byte LFO
test al, byte LFOFLAG
jz short su_op_oscillat_normalize_note
do fmul dword [,c_lfo_normalize,] ; // st0 is now frequency for lfo
jmp short su_op_oscillat_normalized

View File

@ -66,20 +66,18 @@ endstruc
%define SINE 0x40
%define TRISAW 0x20
%define PULSE 0x10
%define LFO 0x08
%define LFOFLAG 0x08
%define GATE 0x04
%define UNISON2 0x01
%define UNISON3 0x02 ; Warning, UNISON3 and UNISON4 do not work with gate at the moment, as they use the same state variable
%define UNISON4 0x03
%define UNISONBITS 0x03
%macro SU_OSCILLAT 8
%macro SU_OSCILLAT 10
db %2
db %3
db %4
db %5
db %6
db %7
db %8
db %8 + (LFOFLAG * %9) + %10 ; TYPE + LFO + UNISON
USE_OSCILLAT
%xdefine CMDS CMDS OSCILLAT_ID + %1,
%if %1 == STEREO
@ -100,7 +98,7 @@ endstruc
%if (%8) & SAMPLE == SAMPLE
%define INCLUDE_SAMPLES
%endif
%if (%8) & UNISON4 > 0
%if (%10) > 0
%define INCLUDE_UNISONS
%endif
%endmacro
@ -124,6 +122,9 @@ endstruc
%define PHASE(val) val
%define COLOR(val) val
%define SHAPE(val) val
%define TYPE(val) val
%define LFO(val) val
%define UNISON(val) val
%define FLAGS(val) val
;-------------------------------------------------------------------------------