mirror of
https://github.com/vsariola/sointu.git
synced 2025-06-04 01:28:45 -04:00
Optimize size.
This commit is contained in:
parent
3b33b4e4d2
commit
f06810d956
@ -118,12 +118,12 @@ SECT_TEXT(suupdvce)
|
|||||||
|
|
||||||
su_update_voices: ; Stack: retaddr row
|
su_update_voices: ; Stack: retaddr row
|
||||||
xor edx, edx
|
xor edx, edx
|
||||||
mov ebx, PATTERN_SIZE
|
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
|
div ebx ; eax = current pattern, edx = current row in pattern
|
||||||
lea esi, [MANGLE_DATA(su_tracks)+eax] ; esi points to the pattern data for current track
|
lea esi, [MANGLE_DATA(su_tracks)+eax] ; esi points to the pattern data for current track
|
||||||
xor eax, eax ; eax is the first voice of next track
|
xor eax, eax ; eax is the first voice of next track
|
||||||
xor ebx, ebx ; ebx is the first voice of current track
|
xor ebx, ebx ; ebx is the first voice of current track
|
||||||
xor ebp, ebp ; ebp is the current track being processed
|
mov ebp, su_current_voiceno ; ebp points to the current_voiceno array
|
||||||
su_update_voices_trackloop:
|
su_update_voices_trackloop:
|
||||||
movzx eax, byte [esi] ; eax = current pattern
|
movzx eax, byte [esi] ; eax = current pattern
|
||||||
imul eax, PATTERN_SIZE ; eax = offset to current pattern data
|
imul eax, PATTERN_SIZE ; eax = offset to current pattern data
|
||||||
@ -139,11 +139,11 @@ su_calculate_voices_loop: ; do {
|
|||||||
push ecx ; Stack: next_instr ptrnrow
|
push ecx ; Stack: next_instr ptrnrow
|
||||||
cmp al, HLD ; anything but hold causes action
|
cmp al, HLD ; anything but hold causes action
|
||||||
je short su_update_voices_nexttrack
|
je short su_update_voices_nexttrack
|
||||||
mov ecx, dword [su_current_voiceno+ebp*4]
|
mov ecx, dword [ebp]
|
||||||
mov edi, ecx
|
mov edi, ecx
|
||||||
add edi, ebx
|
add edi, ebx
|
||||||
imul edi, edi, su_voice.size
|
shl edi, MAX_UNITS_SHIFT + 6 ; each unit = 64 bytes and there are 1<<MAX_UNITS_SHIFT units + small header
|
||||||
mov dword [su_synth_obj+su_synth.voices+edi+su_voice.release],1 ; set the voice currently active to release
|
inc dword [su_synth_obj+su_synth.voices+edi+su_voice.release] ; set the voice currently active to release; notice that it could increment any number of times
|
||||||
cmp al, HLD ; if cl < HLD (no new note triggered)
|
cmp al, HLD ; if cl < HLD (no new note triggered)
|
||||||
jl su_update_voices_nexttrack ; goto nexttrack
|
jl su_update_voices_nexttrack ; goto nexttrack
|
||||||
inc ecx ; curvoice++
|
inc ecx ; curvoice++
|
||||||
@ -151,9 +151,9 @@ su_calculate_voices_loop: ; do {
|
|||||||
jl su_update_voices_skipreset
|
jl su_update_voices_skipreset
|
||||||
xor ecx,ecx ; curvoice = 0
|
xor ecx,ecx ; curvoice = 0
|
||||||
su_update_voices_skipreset:
|
su_update_voices_skipreset:
|
||||||
mov dword [su_current_voiceno+ebp*4],ecx
|
mov dword [ebp],ecx
|
||||||
add ecx, ebx
|
add ecx, ebx
|
||||||
imul ecx, ecx, su_voice.size
|
shl ecx, MAX_UNITS_SHIFT + 6 ; each unit = 64 bytes and there are 1<<MAX_UNITS_SHIFT units + small header
|
||||||
lea edi, [su_synth_obj+su_synth.voices+ecx]
|
lea edi, [su_synth_obj+su_synth.voices+ecx]
|
||||||
stosd ; save note
|
stosd ; save note
|
||||||
mov ecx, (su_voice.size - su_voice.release)/4
|
mov ecx, (su_voice.size - su_voice.release)/4
|
||||||
@ -163,8 +163,8 @@ su_update_voices_nexttrack:
|
|||||||
pop ebx ; ebx=first voice of next instrument, Stack: ptrnrow
|
pop ebx ; ebx=first voice of next instrument, Stack: ptrnrow
|
||||||
pop edx ; edx=patrnrow
|
pop edx ; edx=patrnrow
|
||||||
add esi, MAX_PATTERNS
|
add esi, MAX_PATTERNS
|
||||||
inc ebp
|
add ebp, 4
|
||||||
cmp ebp, MAX_TRACKS
|
cmp ebp, su_current_voiceno+MAX_TRACKS*4
|
||||||
jl short su_update_voices_trackloop
|
jl short su_update_voices_trackloop
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -172,22 +172,24 @@ su_update_voices_nexttrack:
|
|||||||
|
|
||||||
su_update_voices: ; Stack: retaddr row
|
su_update_voices: ; Stack: retaddr row
|
||||||
xor edx, edx
|
xor edx, edx
|
||||||
mov ebx, PATTERN_SIZE
|
xor ebx, ebx
|
||||||
|
mov bl, PATTERN_SIZE
|
||||||
div ebx ; eax = current pattern, edx = current row in pattern
|
div ebx ; eax = current pattern, edx = current row in pattern
|
||||||
lea esi, [MANGLE_DATA(su_tracks)+eax] ; esi points to the pattern data for current track
|
lea esi, [MANGLE_DATA(su_tracks)+eax] ; esi points to the pattern data for current track
|
||||||
lea edi, [su_synth_obj+su_synth.voices]
|
lea edi, [su_synth_obj+su_synth.voices]
|
||||||
mov ebp, MAX_TRACKS
|
mov bl, MAX_TRACKS ; MAX_TRACKS is always <= 32 so this is ok
|
||||||
su_update_voices_trackloop:
|
su_update_voices_trackloop:
|
||||||
movzx eax, byte [esi] ; eax = current pattern
|
movzx eax, byte [esi] ; eax = current pattern
|
||||||
imul eax, PATTERN_SIZE ; eax = offset to current pattern data
|
imul eax, PATTERN_SIZE ; eax = offset to current pattern data
|
||||||
movzx eax, byte [MANGLE_DATA(su_patterns)+eax+edx] ; ecx = note
|
movzx eax, byte [MANGLE_DATA(su_patterns)+eax+edx] ; ecx = note
|
||||||
cmp al, HLD ; anything but hold causes action
|
cmp al, HLD ; anything but hold causes action
|
||||||
je short su_update_voices_nexttrack
|
je short su_update_voices_nexttrack
|
||||||
mov dword [edi+su_voice.release],1 ; set the voice currently active to release
|
inc dword [edi+su_voice.release] ; set the voice currently active to release; notice that it could increment any number of times
|
||||||
|
cmp al, HLD
|
||||||
jl su_update_voices_nexttrack ; if cl < HLD (no new note triggered) goto nexttrack
|
jl su_update_voices_nexttrack ; if cl < HLD (no new note triggered) goto nexttrack
|
||||||
su_update_voices_retrigger:
|
su_update_voices_retrigger:
|
||||||
stosd ; save note
|
stosd ; save note
|
||||||
mov ecx, (su_voice.size - su_voice.release)/4
|
mov ecx, (su_voice.size - su_voice.release)/4 ; could be xor ecx, ecx; mov ch,...>>8, but will it actually be smaller after compression?
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
rep stosd ; clear the workspace of the new voice, retriggering oscillators
|
rep stosd ; clear the workspace of the new voice, retriggering oscillators
|
||||||
jmp short su_update_voices_skipadd
|
jmp short su_update_voices_skipadd
|
||||||
@ -195,7 +197,7 @@ su_update_voices_nexttrack:
|
|||||||
add edi, su_voice.size
|
add edi, su_voice.size
|
||||||
su_update_voices_skipadd:
|
su_update_voices_skipadd:
|
||||||
add esi, MAX_PATTERNS
|
add esi, MAX_PATTERNS
|
||||||
dec ebp
|
dec ebx
|
||||||
jnz short su_update_voices_trackloop
|
jnz short su_update_voices_trackloop
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
@ -66,8 +66,7 @@ EXPORT MANGLE_FUNC(su_run_vm,0)
|
|||||||
push VAL ; Stack: VAL COM
|
push VAL ; Stack: VAL COM
|
||||||
push WRK ; Stack: WRK VAL COM
|
push WRK ; Stack: WRK VAL COM
|
||||||
%if DELAY_ID > -1
|
%if DELAY_ID > -1
|
||||||
mov ecx, MANGLE_DATA(su_delay_buffer) ; reset delaywrk to first delayline
|
mov dword [MANGLE_DATA(su_delay_buffer_ofs)], MANGLE_DATA(su_delay_buffer) ; reset delaywrk to first delayline
|
||||||
mov dword [MANGLE_DATA(su_delay_buffer_ofs)], ecx
|
|
||||||
%endif
|
%endif
|
||||||
xor ecx, ecx ; voice = 0
|
xor ecx, ecx ; voice = 0
|
||||||
push ecx ; Stack: voice WRK VAL COM
|
push ecx ; Stack: voice WRK VAL COM
|
||||||
|
@ -137,7 +137,8 @@
|
|||||||
; //----------------------------------------------------------------------------------------
|
; //----------------------------------------------------------------------------------------
|
||||||
|
|
||||||
%define MAX_DELAY 65536
|
%define MAX_DELAY 65536
|
||||||
%define MAX_UNITS 64
|
%assign MAX_UNITS_SHIFT 6
|
||||||
|
%assign MAX_UNITS ((1 << MAX_UNITS_SHIFT)-1) ; this is carefully chosen to align su_unit to 2^n boundary
|
||||||
%define ABSOLUTE_MAX_VOICES 32
|
%define ABSOLUTE_MAX_VOICES 32
|
||||||
|
|
||||||
%ifndef SAMPLE_RATE
|
%ifndef SAMPLE_RATE
|
||||||
@ -209,6 +210,9 @@
|
|||||||
db %1
|
db %1
|
||||||
%rotate 1
|
%rotate 1
|
||||||
%endrep
|
%endrep
|
||||||
|
%if %0 >= 256
|
||||||
|
%error 'Pattern size should be < 256'
|
||||||
|
%endif
|
||||||
%if PATTERN_SIZE == -1
|
%if PATTERN_SIZE == -1
|
||||||
%assign PATTERN_SIZE %0
|
%assign PATTERN_SIZE %0
|
||||||
%else
|
%else
|
||||||
@ -279,7 +283,7 @@ endstruc
|
|||||||
struc su_voice
|
struc su_voice
|
||||||
.note resd 1
|
.note resd 1
|
||||||
.release resd 1
|
.release resd 1
|
||||||
.track resd 1
|
.reserved resb (su_unit.size - 8) ; this is done to so the whole voice is 2^n long, see polyphonic player
|
||||||
.workspace resb MAX_UNITS * su_unit.size
|
.workspace resb MAX_UNITS * su_unit.size
|
||||||
.size
|
.size
|
||||||
endstruc
|
endstruc
|
||||||
|
Loading…
x
Reference in New Issue
Block a user