Get rid of transformed values and use the header of the voice for that; saves _CX completely for the opcode.

This commit is contained in:
Veikko Sariola
2020-05-23 17:30:52 +03:00
parent 79b384a0d6
commit da52c10f7f
7 changed files with 18 additions and 18 deletions

View File

@ -78,7 +78,7 @@ EXPORT MANGLE_FUNC(su_op_loadnote,0)
call su_op_loadnote_mono call su_op_loadnote_mono
su_op_loadnote_mono: su_op_loadnote_mono:
%endif %endif
fild dword [_CX+su_unit.size-su_voice.workspace+su_voice.note] fild dword [INP-su_voice.inputs+su_voice.note]
apply fmul dword, c_i128 apply fmul dword, c_i128
ret ret

View File

@ -370,7 +370,7 @@ su_op_delay_loop:
%ifdef INCLUDE_DELAY_NOTETRACKING %ifdef INCLUDE_DELAY_NOTETRACKING
test ah, 1 ; note syncing is the least significant bit of ah, 0 = ON, 1 = OFF test ah, 1 ; note syncing is the least significant bit of ah, 0 = ON, 1 = OFF
jne su_op_delay_skipnotesync jne su_op_delay_skipnotesync
fild dword [_CX+su_unit.size-su_voice.workspace+su_voice.note] fild dword [INP-su_voice.inputs+su_voice.note]
apply fmul dword, c_i12 apply fmul dword, c_i12
call MANGLE_FUNC(su_power,0) call MANGLE_FUNC(su_power,0)
fdivp st1, st0 ; use 10787 for delaytime to have neutral transpose fdivp st1, st0 ; use 10787 for delaytime to have neutral transpose

View File

@ -35,6 +35,7 @@ SECT_TEXT(susend)
EXPORT MANGLE_FUNC(su_op_send,0) EXPORT MANGLE_FUNC(su_op_send,0)
lodsw lodsw
mov _CX, [_SP + su_stack.wrk]
%ifdef INCLUDE_STEREO_SEND %ifdef INCLUDE_STEREO_SEND
jnc su_op_send_mono jnc su_op_send_mono
mov _DI, _AX mov _DI, _AX
@ -50,7 +51,7 @@ su_op_send_mono:
%ifdef INCLUDE_GLOBAL_SEND %ifdef INCLUDE_GLOBAL_SEND
test _AX, SEND_GLOBAL test _AX, SEND_GLOBAL
jz su_op_send_skipglobal jz su_op_send_skipglobal
mov _CX, PTRWORD su_synth_obj - su_unit.size mov _CX, PTRWORD su_synth_obj
su_op_send_skipglobal: su_op_send_skipglobal:
%endif %endif
test _AX, SEND_POP ; if the SEND_POP bit is not set test _AX, SEND_POP ; if the SEND_POP bit is not set
@ -62,8 +63,8 @@ su_op_send_skippush: ; there is signal s, but maybe also another: s (
fadd st0 ; g=2*a-1 l (l) fadd st0 ; g=2*a-1 l (l)
and _AX, 0x0000ffff - SEND_POP - SEND_GLOBAL ; eax = send address and _AX, 0x0000ffff - SEND_POP - SEND_GLOBAL ; eax = send address
fmulp st1, st0 ; g*l (l) fmulp st1, st0 ; g*l (l)
fadd dword [_CX+su_unit.size+_AX*4] ; g*l+L (l),where L is the current value fadd dword [_CX + _AX*4] ; g*l+L (l),where L is the current value
fstp dword [_CX+su_unit.size+_AX*4] ; (l) fstp dword [_CX + _AX*4] ; (l)
ret ret
%endif ; SU_USE_SEND > -1 %endif ; SU_USE_SEND > -1

View File

@ -54,7 +54,7 @@ endstruc
%endmacro %endmacro
%define AMOUNT(val) val %define AMOUNT(val) val
%define PORT(unit,unittype,port) (unit*su_unit.size + su_ %+ unittype %+ _ports. %+ port + su_unit.ports)/4 %define PORT(unit,unittype,port) ((unit+1)*su_unit.size + su_ %+ unittype %+ _ports. %+ port + su_unit.ports)/4
%define GLOBALPORT(voice,unit,unittype,port) SEND_GLOBAL + (su_synth.voices+voice*su_voice.size+su_voice.workspace+unit*su_unit.size + su_ %+ unittype %+ _ports. %+ port + su_unit.ports)/4 %define GLOBALPORT(voice,unit,unittype,port) SEND_GLOBAL + (su_synth.voices+voice*su_voice.size+su_voice.workspace+unit*su_unit.size + su_ %+ unittype %+ _ports. %+ port + su_unit.ports)/4
%define OUTPORT 0 %define OUTPORT 0
%define SEND_POP 0x8000 %define SEND_POP 0x8000

View File

@ -17,7 +17,7 @@ EXPORT MANGLE_FUNC(su_op_envelope,0)
su_op_envelope_mono: su_op_envelope_mono:
%endif %endif
kmENV_func_do: kmENV_func_do:
mov eax, dword [_CX+su_unit.size-su_voice.workspace+su_voice.release] ; eax = su_instrument.release mov eax, dword [INP-su_voice.inputs+su_voice.release] ; eax = su_instrument.release
test eax, eax ; if (eax == 0) test eax, eax ; if (eax == 0)
je kmENV_func_process ; goto process je kmENV_func_process ; goto process
mov dword [WRK+su_env_work.state], ENV_STATE_RELEASE ; [state]=RELEASE mov dword [WRK+su_env_work.state], ENV_STATE_RELEASE ; [state]=RELEASE
@ -145,7 +145,7 @@ su_op_oscillat_single:
faddp st1 faddp st1
test al, byte LFO test al, byte LFO
jnz su_op_oscillat_skipnote jnz su_op_oscillat_skipnote
fiadd dword [_CX+su_unit.size-su_voice.workspace+su_voice.note] ; // st0 is note, st1 is t+d offset fiadd dword [INP-su_voice.inputs+su_voice.note] ; // st0 is note, st1 is t+d offset
su_op_oscillat_skipnote: su_op_oscillat_skipnote:
apply fmul dword,c_i12 apply fmul dword,c_i12
call MANGLE_FUNC(su_power,0) call MANGLE_FUNC(su_power,0)

View File

@ -118,7 +118,6 @@ endstruc
SECT_BSS(susynth) SECT_BSS(susynth)
su_synth_obj resb su_synth.size su_synth_obj resb su_synth.size
su_transformed_values resd 16
;=============================================================================== ;===============================================================================
; The opcode table jump table. This is constructed to only include the opcodes ; The opcode table jump table. This is constructed to only include the opcodes
@ -176,8 +175,7 @@ EXPORT MANGLE_FUNC(su_run_vm,0)
%endif %endif
mov COM, PTRWORD MANGLE_DATA(su_commands) ; COM points to vm code mov COM, PTRWORD MANGLE_DATA(su_commands) ; COM points to vm code
mov VAL, PTRWORD MANGLE_DATA(su_params) ; VAL points to unit params mov VAL, PTRWORD MANGLE_DATA(su_params) ; VAL points to unit params
; su_unit.size will be added back before WRK is used mov WRK, PTRWORD su_synth_obj + su_synth.voices ; WRK points to the first voice
mov WRK, PTRWORD su_synth_obj + su_synth.voices + su_voice.workspace - su_unit.size
push COM ; Stack: COM push COM ; Stack: COM
push VAL ; Stack: VAL COM push VAL ; Stack: VAL COM
push WRK ; Stack: WRK VAL COM push WRK ; Stack: WRK VAL COM
@ -192,7 +190,6 @@ su_run_vm_loop: ; loop until all voices done
apply {mov al,byte},su_opcode_numparams,_AX,{} apply {mov al,byte},su_opcode_numparams,_AX,{}
push _AX push _AX
call su_transform_values call su_transform_values
mov _CX, PTRWORD [_SP+su_stack.wrk]
pop _AX pop _AX
shr eax,1 shr eax,1
apply call,su_synth_commands,_AX*PTRSIZE,{} ; call the function corresponding to the instruction apply call,su_synth_commands,_AX*PTRSIZE,{} ; call the function corresponding to the instruction
@ -230,13 +227,13 @@ EXPORT MANGLE_FUNC(FloatRandomNumber,0)
SECT_TEXT(sutransf) SECT_TEXT(sutransf)
su_transform_values: su_transform_values:
push _CX
xor ecx, ecx xor ecx, ecx
xor eax, eax xor eax, eax
mov INP, PTRWORD su_transformed_values mov INP, [_SP+su_stack.wrk+2*PTRSIZE]
add INP, su_voice.inputs
su_transform_values_loop: su_transform_values_loop:
cmp ecx, dword [_SP+2*PTRSIZE] cmp ecx, dword [_SP+PTRSIZE]
jge su_transform_values_out jnb su_transform_values_out
lodsb lodsb
push _AX push _AX
fild dword [_SP] fild dword [_SP]
@ -248,7 +245,6 @@ su_transform_values_loop:
inc ecx inc ecx
jmp su_transform_values_loop jmp su_transform_values_loop
su_transform_values_out: su_transform_values_out:
pop _CX
ret PTRSIZE ret PTRSIZE
;------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------

View File

@ -236,7 +236,8 @@ endstruc
struc su_voice struc su_voice
.note resd 1 .note resd 1
.release resd 1 .release resd 1
.reserved resb (su_unit.size - 8) ; this is done to so the whole voice is 2^n long, see polyphonic player .inputs resd 8
.reserved resd 6 ; this is done to so the whole voice is 2^n long, see polyphonic player
.workspace resb MAX_UNITS * su_unit.size .workspace resb MAX_UNITS * su_unit.size
.size .size
endstruc endstruc
@ -245,8 +246,10 @@ endstruc
; synth struct ; synth struct
;------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------
struc su_synth struc su_synth
.reserved resd 8 ; this is so that left/right/aux ports are aligned to the input ports of units
.left resd 1 .left resd 1
.right resd 1 .right resd 1
.aux resd 6 ; 3 auxiliary signals
.voices resb ABSOLUTE_MAX_VOICES * su_voice.size .voices resb ABSOLUTE_MAX_VOICES * su_voice.size
.size .size
endstruc endstruc