diff --git a/src/opcodes/arithmetic.asm b/src/opcodes/arithmetic.asm index f3ba6de..ef629c0 100644 --- a/src/opcodes/arithmetic.asm +++ b/src/opcodes/arithmetic.asm @@ -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 diff --git a/src/opcodes/effects.asm b/src/opcodes/effects.asm index 3a13050..61e29f3 100644 --- a/src/opcodes/effects.asm +++ b/src/opcodes/effects.asm @@ -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 diff --git a/src/opcodes/flowcontrol.asm b/src/opcodes/flowcontrol.asm index 5a8c2a1..84a51c7 100644 --- a/src/opcodes/flowcontrol.asm +++ b/src/opcodes/flowcontrol.asm @@ -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 diff --git a/src/opcodes/sinks.asm b/src/opcodes/sinks.asm index 4e883ec..7b4d780 100644 --- a/src/opcodes/sinks.asm +++ b/src/opcodes/sinks.asm @@ -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) diff --git a/src/opcodes/sources.asm b/src/opcodes/sources.asm index bb27bb1..e4411d8 100644 --- a/src/opcodes/sources.asm +++ b/src/opcodes/sources.asm @@ -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 diff --git a/src/player.asm b/src/player.asm index 8886eb0..39800d2 100644 --- a/src/player.asm +++ b/src/player.asm @@ -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< -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