mirror of
https://github.com/vsariola/sointu.git
synced 2025-06-04 01:28:45 -04:00
Use strucs for stack locations, instead of hard-coding them everywhere.
This commit is contained in:
parent
654e5868bc
commit
afbff66e36
@ -21,28 +21,28 @@ SECT_TEXT(suopadvn)
|
|||||||
%ifdef INCLUDE_POLYPHONY
|
%ifdef INCLUDE_POLYPHONY
|
||||||
|
|
||||||
EXPORT MANGLE_FUNC(su_op_advance,0) ; Stack: addr voice wrkptr valptr comptr
|
EXPORT MANGLE_FUNC(su_op_advance,0) ; Stack: addr voice wrkptr valptr comptr
|
||||||
mov WRK, [_SP+PTRSIZE*2] ; WRK = wrkptr
|
mov WRK, [_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 [_SP+PTRSIZE*2], WRK ; update stack
|
mov [_SP+su_stack.wrk], WRK ; update stack
|
||||||
mov ecx, [_SP+PTRSIZE] ; ecx = voice
|
mov ecx, [_SP+su_stack.voiceno] ; ecx = voice
|
||||||
apply bt dword,su_polyphony_bitmask,{,ecx} ; if voice bit of su_polyphonism not set
|
apply bt dword,su_polyphony_bitmask,{,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+PTRSIZE*3] ; rollback to where we were earlier
|
mov VAL, PTRWORD [_SP+su_stack.val] ; rollback to where we were earlier
|
||||||
mov COM, PTRWORD [_SP+PTRSIZE*4]
|
mov COM, PTRWORD [_SP+su_stack.com]
|
||||||
jmp short su_op_advance_finish
|
jmp short su_op_advance_finish
|
||||||
su_op_advance_next_instrument:
|
su_op_advance_next_instrument:
|
||||||
mov PTRWORD [_SP+PTRSIZE*3], VAL ; save current VAL as a checkpoint
|
mov PTRWORD [_SP+su_stack.val], VAL ; save current VAL as a checkpoint
|
||||||
mov PTRWORD [_SP+PTRSIZE*4], 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+PTRSIZE]
|
inc PTRWORD [_SP+su_stack.voiceno]
|
||||||
ret
|
ret
|
||||||
|
|
||||||
%else
|
%else
|
||||||
EXPORT MANGLE_FUNC(su_op_advance,0) ; Stack: addr voice wrkptr valptr comptr
|
EXPORT MANGLE_FUNC(su_op_advance,0) ; Stack: addr voice wrkptr valptr comptr
|
||||||
mov WRK, PTRWORD [_SP+PTRSIZE*2] ; 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+PTRSIZE*2], WRK ; update stack
|
mov PTRWORD [_SP+su_stack.wrk], WRK ; update stack
|
||||||
inc PTRWORD [_SP+PTRSIZE] ; voice++
|
inc PTRWORD [_SP+su_stack.voiceno] ; voice++
|
||||||
ret
|
ret
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ EXPORT MANGLE_FUNC(su_op_speed,0)
|
|||||||
fist dword [_SP] ; Main stack: k=int(t+2^p-1)
|
fist dword [_SP] ; Main stack: k=int(t+2^p-1)
|
||||||
fisub dword [_SP] ; t+2^p-1-k, the remainder
|
fisub dword [_SP] ; t+2^p-1-k, the remainder
|
||||||
pop _AX
|
pop _AX
|
||||||
add dword [_SP+6*PTRSIZE], eax ; add the whole ticks to song tick count, [esp+24] is the current tick in the row
|
add dword [_SP+su_stack.curtick], eax ; add the whole ticks to song tick count, [esp+24] is the current tick in the row
|
||||||
fstp dword [WRK+su_speed_wrk.remainder] ; save the remainder for future
|
fstp dword [WRK+su_speed_wrk.remainder] ; save the remainder for future
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
@ -93,6 +93,16 @@
|
|||||||
%endmacro
|
%endmacro
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
|
struc su_stack ; the structure of stack _as the units see it_
|
||||||
|
.retaddr RESPTR 1
|
||||||
|
.voiceno RESPTR 1
|
||||||
|
.wrk RESPTR 1
|
||||||
|
.val RESPTR 1
|
||||||
|
.com RESPTR 1
|
||||||
|
.retaddrvm RESPTR 1
|
||||||
|
.curtick RESPTR 1
|
||||||
|
endstruc
|
||||||
|
|
||||||
;===============================================================================
|
;===============================================================================
|
||||||
; Uninitialized data: The one and only synth object
|
; Uninitialized data: The one and only synth object
|
||||||
;===============================================================================
|
;===============================================================================
|
||||||
@ -174,13 +184,13 @@ 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+2*PTRSIZE]
|
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
|
||||||
cmp dword [_SP],MAX_VOICES ; if (voice < MAX_VOICES)
|
cmp dword [_SP+su_stack.voiceno-PTRSIZE],MAX_VOICES ; if (voice < MAX_VOICES)
|
||||||
jl su_run_vm_loop ; goto vm_loop
|
jl su_run_vm_loop ; goto vm_loop
|
||||||
add _SP, 4*PTRSIZE ; Stack cleared
|
add _SP, su_stack.retaddrvm-PTRSIZE ; Stack cleared
|
||||||
ret
|
ret
|
||||||
|
|
||||||
;-------------------------------------------------------------------------------
|
;-------------------------------------------------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user