diff --git a/src/player.asm b/src/player.asm index 5c8893d..0b5d1f8 100644 --- a/src/player.asm +++ b/src/player.asm @@ -118,12 +118,12 @@ SECT_TEXT(suupdvce) su_update_voices: ; Stack: retaddr row 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 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 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: movzx eax, byte [esi] ; eax = current pattern 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 cmp al, HLD ; anything but hold causes action je short su_update_voices_nexttrack - mov ecx, dword [su_current_voiceno+ebp*4] + mov ecx, dword [ebp] mov edi, ecx add edi, ebx - imul edi, edi, su_voice.size - mov dword [su_synth_obj+su_synth.voices+edi+su_voice.release],1 ; set the voice currently active to release + shl edi, MAX_UNITS_SHIFT + 6 ; each unit = 64 bytes and there are 1<>8, but will it actually be smaller after compression? xor eax, eax rep stosd ; clear the workspace of the new voice, retriggering oscillators jmp short su_update_voices_skipadd @@ -195,7 +197,7 @@ su_update_voices_nexttrack: add edi, su_voice.size su_update_voices_skipadd: add esi, MAX_PATTERNS - dec ebp + dec ebx jnz short su_update_voices_trackloop ret diff --git a/src/sointu.asm b/src/sointu.asm index ec660a5..c501547 100644 --- a/src/sointu.asm +++ b/src/sointu.asm @@ -65,9 +65,8 @@ EXPORT MANGLE_FUNC(su_run_vm,0) push COM ; Stack: COM push VAL ; Stack: VAL COM push WRK ; Stack: WRK VAL COM -%if DELAY_ID > -1 - mov ecx, MANGLE_DATA(su_delay_buffer) ; reset delaywrk to first delayline - mov dword [MANGLE_DATA(su_delay_buffer_ofs)], ecx +%if DELAY_ID > -1 + mov dword [MANGLE_DATA(su_delay_buffer_ofs)], MANGLE_DATA(su_delay_buffer) ; reset delaywrk to first delayline %endif xor ecx, ecx ; voice = 0 push ecx ; Stack: voice WRK VAL COM diff --git a/src/sointu.inc b/src/sointu.inc index bbd5eca..2b58425 100644 --- a/src/sointu.inc +++ b/src/sointu.inc @@ -137,7 +137,8 @@ ; //---------------------------------------------------------------------------------------- %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 %ifndef SAMPLE_RATE @@ -209,12 +210,15 @@ db %1 %rotate 1 %endrep + %if %0 >= 256 + %error 'Pattern size should be < 256' + %endif %if PATTERN_SIZE == -1 %assign PATTERN_SIZE %0 %else %if %0 != PATTERN_SIZE %error 'All patterns should have the same length!' - %endif + %endif %endif %endmacro @@ -279,8 +283,8 @@ endstruc struc su_voice .note resd 1 .release resd 1 - .track resd 1 - .workspace resb MAX_UNITS * su_unit.size + .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 .size endstruc ; //----------------------------------------------------------------------------------------