mirror of
https://github.com/vsariola/sointu.git
synced 2025-12-02 07:23:24 -05:00
Implement player speed modulation opcode for triplets and such.
This commit is contained in:
@ -49,6 +49,33 @@ EXPORT MANGLE_FUNC(su_op_advance,0) ; Stack: addr voice wrkptr valptr comptr
|
||||
|
||||
%endif
|
||||
|
||||
;-------------------------------------------------------------------------------
|
||||
; SPEED tick
|
||||
;-------------------------------------------------------------------------------
|
||||
%if SPEED_ID > -1
|
||||
|
||||
SECT_TEXT(suspeed)
|
||||
|
||||
EXPORT MANGLE_FUNC(su_op_speed,0)
|
||||
fsub dword [c_0_5] ; s-.5
|
||||
fadd st0, st0 ; 2*s-1
|
||||
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
|
||||
fadd dword [WRK+su_speed_wrk.remainder] ; t+2^p-1, t is the remainder from previous rounds as ticks have to be rounded to 1
|
||||
push eax
|
||||
fist dword [esp] ; Main stack: k=int(t+2^p-1)
|
||||
fisub dword [esp] ; t+2^p-1-k, the remainder
|
||||
pop eax
|
||||
add dword [esp+24], 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
|
||||
ret
|
||||
|
||||
SECT_DATA(suconst)
|
||||
c_bpmscale dd 2.666666666666 ; 64/24, 24 values will be double speed, so you can go from ~ 1/2.5 speed to 2.5x speed
|
||||
|
||||
%endif
|
||||
|
||||
;-------------------------------------------------------------------------------
|
||||
; Constants
|
||||
|
||||
@ -0,0 +1,21 @@
|
||||
;-------------------------------------------------------------------------------
|
||||
; SPEED related defines
|
||||
;-------------------------------------------------------------------------------
|
||||
%assign SPEED_ID -1
|
||||
%macro USE_SPEED 0
|
||||
%if SPEED_ID == -1
|
||||
%assign SPEED_ID CUR_ID
|
||||
%assign CUR_ID CUR_ID + 2
|
||||
%xdefine OPCODES OPCODES MANGLE_FUNC(su_op_speed,0),
|
||||
%xdefine NUMPARAMS NUMPARAMS 0,
|
||||
%endif
|
||||
%endmacro
|
||||
|
||||
%macro SU_SPEED 0
|
||||
USE_SPEED
|
||||
%xdefine CMDS CMDS SPEED_ID, ; there is no stereo variant I can think of
|
||||
%endmacro
|
||||
|
||||
struc su_speed_wrk
|
||||
.remainder resd 1
|
||||
endstruc
|
||||
@ -127,6 +127,7 @@
|
||||
%define MONO 0
|
||||
%define STEREO 1
|
||||
|
||||
%include "opcodes/flowcontrol.inc"
|
||||
%include "opcodes/arithmetic.inc"
|
||||
%include "opcodes/effects.inc"
|
||||
%include "opcodes/sources.inc"
|
||||
|
||||
Reference in New Issue
Block a user