diff --git a/src/opcodes/arithmetic.asm b/src/opcodes/arithmetic.asm index 5572be4..f3ba6de 100644 --- a/src/opcodes/arithmetic.asm +++ b/src/opcodes/arithmetic.asm @@ -78,7 +78,7 @@ EXPORT MANGLE_FUNC(su_op_loadnote,0) call su_op_loadnote_mono su_op_loadnote_mono: %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 ret diff --git a/src/opcodes/effects.asm b/src/opcodes/effects.asm index bde3984..3c1013a 100644 --- a/src/opcodes/effects.asm +++ b/src/opcodes/effects.asm @@ -370,7 +370,7 @@ su_op_delay_loop: %ifdef INCLUDE_DELAY_NOTETRACKING test ah, 1 ; note syncing is the least significant bit of ah, 0 = ON, 1 = OFF 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 call MANGLE_FUNC(su_power,0) fdivp st1, st0 ; use 10787 for delaytime to have neutral transpose diff --git a/src/opcodes/sinks.asm b/src/opcodes/sinks.asm index e56890b..4ca75e5 100644 --- a/src/opcodes/sinks.asm +++ b/src/opcodes/sinks.asm @@ -35,6 +35,7 @@ SECT_TEXT(susend) EXPORT MANGLE_FUNC(su_op_send,0) lodsw + mov _CX, [_SP + su_stack.wrk] %ifdef INCLUDE_STEREO_SEND jnc su_op_send_mono mov _DI, _AX @@ -50,7 +51,7 @@ su_op_send_mono: %ifdef INCLUDE_GLOBAL_SEND test _AX, SEND_GLOBAL jz su_op_send_skipglobal - mov _CX, PTRWORD su_synth_obj - su_unit.size + mov _CX, PTRWORD su_synth_obj su_op_send_skipglobal: %endif 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) and _AX, 0x0000ffff - SEND_POP - SEND_GLOBAL ; eax = send address fmulp st1, st0 ; g*l (l) - fadd dword [_CX+su_unit.size+_AX*4] ; g*l+L (l),where L is the current value - fstp dword [_CX+su_unit.size+_AX*4] ; (l) + fadd dword [_CX + _AX*4] ; g*l+L (l),where L is the current value + fstp dword [_CX + _AX*4] ; (l) ret %endif ; SU_USE_SEND > -1 diff --git a/src/opcodes/sinks.inc b/src/opcodes/sinks.inc index 7e5551e..4d2bbea 100644 --- a/src/opcodes/sinks.inc +++ b/src/opcodes/sinks.inc @@ -54,7 +54,7 @@ endstruc %endmacro %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 OUTPORT 0 %define SEND_POP 0x8000 diff --git a/src/opcodes/sources.asm b/src/opcodes/sources.asm index fdd40b1..410497f 100644 --- a/src/opcodes/sources.asm +++ b/src/opcodes/sources.asm @@ -17,7 +17,7 @@ EXPORT MANGLE_FUNC(su_op_envelope,0) su_op_envelope_mono: %endif 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) je kmENV_func_process ; goto process mov dword [WRK+su_env_work.state], ENV_STATE_RELEASE ; [state]=RELEASE @@ -145,7 +145,7 @@ su_op_oscillat_single: faddp st1 test al, byte LFO 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: apply fmul dword,c_i12 call MANGLE_FUNC(su_power,0) diff --git a/src/sointu.asm b/src/sointu.asm index 2570c86..5a58ad1 100644 --- a/src/sointu.asm +++ b/src/sointu.asm @@ -118,7 +118,6 @@ endstruc SECT_BSS(susynth) 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 @@ -176,8 +175,7 @@ EXPORT MANGLE_FUNC(su_run_vm,0) %endif mov COM, PTRWORD MANGLE_DATA(su_commands) ; COM points to vm code 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 + su_voice.workspace - su_unit.size + mov WRK, PTRWORD su_synth_obj + su_synth.voices ; WRK points to the first voice push COM ; Stack: COM push VAL ; Stack: 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,{} push _AX call su_transform_values - mov _CX, PTRWORD [_SP+su_stack.wrk] pop _AX shr eax,1 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) su_transform_values: - push _CX xor ecx, ecx 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: - cmp ecx, dword [_SP+2*PTRSIZE] - jge su_transform_values_out + cmp ecx, dword [_SP+PTRSIZE] + jnb su_transform_values_out lodsb push _AX fild dword [_SP] @@ -248,7 +245,6 @@ su_transform_values_loop: inc ecx jmp su_transform_values_loop su_transform_values_out: - pop _CX ret PTRSIZE ;------------------------------------------------------------------------------- diff --git a/src/sointu.inc b/src/sointu.inc index 556aea0..456463a 100644 --- a/src/sointu.inc +++ b/src/sointu.inc @@ -236,7 +236,8 @@ endstruc struc su_voice .note 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 .size endstruc @@ -245,8 +246,10 @@ endstruc ; synth struct ;------------------------------------------------------------------------------- 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 .right resd 1 + .aux resd 6 ; 3 auxiliary signals .voices resb ABSOLUTE_MAX_VOICES * su_voice.size .size endstruc