mirror of
https://github.com/vsariola/sointu.git
synced 2025-06-03 17:18:20 -04:00
Reverse the voiceno counter: now it starts from MAX_VOICES and decrements until 0. This way, the VM needs not know anything about MAX_VOICES.
This commit is contained in:
parent
a193b8b1ef
commit
55d9ca0ffc
@ -17,6 +17,7 @@ EXPORT MANGLE_FUNC(su_op_advance,0) ; Stack: addr voice wrkptr valptr comptr
|
|||||||
add WRK, su_voice.size ; move to next voice
|
add WRK, su_voice.size ; move to next voice
|
||||||
mov [_SP+su_stack.wrk], WRK ; update stack
|
mov [_SP+su_stack.wrk], WRK ; update stack
|
||||||
mov ecx, [_SP+su_stack.voiceno] ; ecx = voice
|
mov ecx, [_SP+su_stack.voiceno] ; ecx = voice
|
||||||
|
dec ecx ; decrement number of voices to process
|
||||||
bt dword [_SP+su_stack.polyphony], ecx ; if voice bit of su_polyphonism not set
|
bt dword [_SP+su_stack.polyphony], ecx ; if voice bit of su_polyphonism not set
|
||||||
jnc su_op_advance_next_instrument ; goto next_instrument
|
jnc su_op_advance_next_instrument ; goto next_instrument
|
||||||
mov VAL, PTRWORD [_SP+su_stack.val] ; rollback to where we were earlier
|
mov VAL, PTRWORD [_SP+su_stack.val] ; rollback to where we were earlier
|
||||||
@ -26,7 +27,7 @@ su_op_advance_next_instrument:
|
|||||||
mov PTRWORD [_SP+su_stack.val], VAL ; save current VAL as a checkpoint
|
mov PTRWORD [_SP+su_stack.val], VAL ; save current VAL as a checkpoint
|
||||||
mov PTRWORD [_SP+su_stack.com], COM ; save current COM as a checkpoint
|
mov PTRWORD [_SP+su_stack.com], COM ; save current COM as a checkpoint
|
||||||
su_op_advance_finish:
|
su_op_advance_finish:
|
||||||
inc PTRWORD [_SP+su_stack.voiceno]
|
mov [_SP+su_stack.voiceno], ecx
|
||||||
ret
|
ret
|
||||||
|
|
||||||
%else
|
%else
|
||||||
@ -34,7 +35,7 @@ su_op_advance_finish:
|
|||||||
mov WRK, PTRWORD [_SP+su_stack.wrk] ; WRK = wrkptr
|
mov WRK, PTRWORD [_SP+su_stack.wrk] ; WRK = wrkptr
|
||||||
add WRK, su_voice.size ; move to next voice
|
add WRK, su_voice.size ; move to next voice
|
||||||
mov PTRWORD [_SP+su_stack.wrk], WRK ; update stack
|
mov PTRWORD [_SP+su_stack.wrk], WRK ; update stack
|
||||||
inc PTRWORD [_SP+su_stack.voiceno] ; voice++
|
dec PTRWORD [_SP+su_stack.voiceno] ; voices--
|
||||||
ret
|
ret
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
|
@ -123,6 +123,7 @@ su_render_sampleloop: ; loop through every sample in the row
|
|||||||
%ifdef INCLUDE_POLYPHONY
|
%ifdef INCLUDE_POLYPHONY
|
||||||
push POLYPHONY_BITMASK ; does the next voice reuse the current opcodes?
|
push POLYPHONY_BITMASK ; does the next voice reuse the current opcodes?
|
||||||
%endif
|
%endif
|
||||||
|
push MAX_VOICES
|
||||||
mov _DX, PTRWORD su_synth_obj ; _DX points to the synth object
|
mov _DX, PTRWORD su_synth_obj ; _DX points to the synth object
|
||||||
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
|
||||||
@ -130,13 +131,13 @@ su_render_sampleloop: ; loop through every sample in the row
|
|||||||
lea _CX, [_DX + su_synth.size - su_delayline_wrk.filtstate]
|
lea _CX, [_DX + su_synth.size - su_delayline_wrk.filtstate]
|
||||||
%endif
|
%endif
|
||||||
lea WRK, [_DX + su_synth.voices] ; WRK points to the first voice
|
lea WRK, [_DX + su_synth.voices] ; WRK points to the first voice
|
||||||
xor edi, edi ; voice = 0
|
|
||||||
call MANGLE_FUNC(su_run_vm,0) ; run through the VM code
|
call MANGLE_FUNC(su_run_vm,0) ; run through the VM code
|
||||||
|
pop _AX
|
||||||
%ifdef INCLUDE_POLYPHONY
|
%ifdef INCLUDE_POLYPHONY
|
||||||
pop _AX
|
pop _AX
|
||||||
%endif
|
%endif
|
||||||
output_sound ; *ptr++ = left, *ptr++ = right
|
output_sound ; *ptr++ = left, *ptr++ = right
|
||||||
pop _AX ; Stack: row pushad ptr
|
pop _AX
|
||||||
inc dword [_SP + PTRSIZE] ; increment global time, used by delays
|
inc dword [_SP + PTRSIZE] ; increment global time, used by delays
|
||||||
inc eax
|
inc eax
|
||||||
cmp eax, SAMPLES_PER_ROW
|
cmp eax, SAMPLES_PER_ROW
|
||||||
|
@ -99,7 +99,9 @@
|
|||||||
|
|
||||||
struc su_stack ; the structure of stack _as the units see it_
|
struc su_stack ; the structure of stack _as the units see it_
|
||||||
.retaddr RESPTR 1
|
.retaddr RESPTR 1
|
||||||
.voiceno RESPTR 1
|
%if BITS == 32 ; we dump everything with pushad, so this is unused in 32-bit
|
||||||
|
RESPTR 1
|
||||||
|
%endif
|
||||||
.val RESPTR 1
|
.val RESPTR 1
|
||||||
.wrk RESPTR 1
|
.wrk RESPTR 1
|
||||||
%if BITS == 32 ; we dump everything with pushad, so this is unused in 32-bit
|
%if BITS == 32 ; we dump everything with pushad, so this is unused in 32-bit
|
||||||
@ -112,6 +114,7 @@ struc su_stack ; the structure of stack _as the units see it_
|
|||||||
RESPTR 1
|
RESPTR 1
|
||||||
%endif
|
%endif
|
||||||
.retaddrvm RESPTR 1
|
.retaddrvm RESPTR 1
|
||||||
|
.voiceno RESPTR 1
|
||||||
%ifdef INCLUDE_POLYPHONY
|
%ifdef INCLUDE_POLYPHONY
|
||||||
.polyphony RESPTR 1
|
.polyphony RESPTR 1
|
||||||
%endif
|
%endif
|
||||||
@ -175,7 +178,7 @@ EXPORT MANGLE_DATA(LFO_NORMALIZE)
|
|||||||
; COM : Pointer to command stream
|
; COM : Pointer to command stream
|
||||||
; VAL : Pointer to value stream
|
; VAL : Pointer to value stream
|
||||||
; WRK : Pointer to the last workspace processed
|
; WRK : Pointer to the last workspace processed
|
||||||
; _DI : Voice number (0 = starting from first voice)
|
; _DI : Number of voices to process
|
||||||
; Output: su_synth_obj.left : left sample
|
; Output: su_synth_obj.left : left sample
|
||||||
; su_synth_obj.right : right sample
|
; su_synth_obj.right : right sample
|
||||||
; Dirty: everything
|
; Dirty: everything
|
||||||
@ -183,7 +186,7 @@ EXPORT MANGLE_DATA(LFO_NORMALIZE)
|
|||||||
SECT_TEXT(surunvm)
|
SECT_TEXT(surunvm)
|
||||||
|
|
||||||
EXPORT MANGLE_FUNC(su_run_vm,0)
|
EXPORT MANGLE_FUNC(su_run_vm,0)
|
||||||
push_registers _CX, _DX, COM, WRK, VAL, _DI ; save everything to stack
|
push_registers _CX, _DX, COM, WRK, VAL ; save everything to stack
|
||||||
su_run_vm_loop: ; loop until all voices done
|
su_run_vm_loop: ; loop until all voices done
|
||||||
movzx edi, byte [COM] ; edi = command byte
|
movzx edi, byte [COM] ; edi = command byte
|
||||||
inc COM ; move to next instruction
|
inc COM ; move to next instruction
|
||||||
@ -210,9 +213,9 @@ su_transform_values_loop:
|
|||||||
su_transform_values_out:
|
su_transform_values_out:
|
||||||
bt dword [COM-1],0 ; LSB of COM = stereo bit => carry
|
bt dword [COM-1],0 ; LSB of COM = stereo bit => carry
|
||||||
do call [,su_synth_commands,_DI*PTRSIZE,] ; call the function corresponding to the instruction
|
do call [,su_synth_commands,_DI*PTRSIZE,] ; call the function corresponding to the instruction
|
||||||
cmp dword [_SP+su_stack.voiceno-PTRSIZE],MAX_VOICES ; if (voice < MAX_VOICES)
|
cmp dword [_SP+su_stack.voiceno-PTRSIZE],0 ; do we have more voices to process?
|
||||||
jl su_run_vm_loop ; goto vm_loop
|
jne su_run_vm_loop ; if there's more voices to process, goto vm_loop
|
||||||
pop_registers _CX, _DX, COM, WRK, VAL, _DI ; pop everything from stack
|
pop_registers _CX, _DX, COM, WRK, VAL ; pop everything from stack
|
||||||
ret
|
ret
|
||||||
|
|
||||||
;-------------------------------------------------------------------------------
|
;-------------------------------------------------------------------------------
|
||||||
|
@ -128,10 +128,11 @@
|
|||||||
; increment MAX_VOICES equal to %1 and construct the POLYPHONY_BITMASK so that
|
; increment MAX_VOICES equal to %1 and construct the POLYPHONY_BITMASK so that
|
||||||
; for every except the last, the bit is on
|
; for every except the last, the bit is on
|
||||||
%rep %1-1
|
%rep %1-1
|
||||||
%assign POLYPHONY_BITMASK POLYPHONY_BITMASK + (1 << MAX_VOICES)
|
%assign POLYPHONY_BITMASK (POLYPHONY_BITMASK << 1) + 1
|
||||||
%assign MAX_VOICES MAX_VOICES + 1
|
%assign MAX_VOICES MAX_VOICES + 1
|
||||||
%endrep
|
%endrep
|
||||||
%assign MAX_VOICES MAX_VOICES + 1 ; the last voice increment, without adding bit mask
|
%assign POLYPHONY_BITMASK (POLYPHONY_BITMASK << 1)
|
||||||
|
%assign MAX_VOICES MAX_VOICES + 1 ; the last voice increment, without adding one bit to the mask
|
||||||
%if MAX_VOICES > 32
|
%if MAX_VOICES > 32
|
||||||
%error Error: cannot have more than 32 voices!
|
%error Error: cannot have more than 32 voices!
|
||||||
%endif
|
%endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user