Noise wave generation code optimized.

This commit is contained in:
Chris Hodges 2023-08-22 22:32:51 +02:00
parent 4461c72eaa
commit b805349bf0
4 changed files with 38 additions and 38 deletions

View File

@ -1,7 +1,7 @@
# Raspberry Casket # Raspberry Casket
A fast and small open source Pretracker replayer A fast and small open source Pretracker replayer
## Raspberry Casket Player V2.x (10-Aug-2023) ## Raspberry Casket Player V2.x (22-Aug-2023)
Provided by Chris 'platon42' Hodges <chrisly@platon42.de> Provided by Chris 'platon42' Hodges <chrisly@platon42.de>
@ -101,7 +101,7 @@ The original code compressed with *Blueberry's* Shrinkler goes from
18052 bytes down to 9023 bytes. 18052 bytes down to 9023 bytes.
Raspberry Casket, depending on the features compiled in, is about Raspberry Casket, depending on the features compiled in, is about
5784 bytes and shrinkles down to ~4118 bytes (in isolation). 5732 bytes and shrinkles down to ~4084 bytes (in isolation).
So this means that the optimization is not just "on the outside". So this means that the optimization is not just "on the outside".
@ -168,8 +168,9 @@ solve this problem.
- Bugfix: Songend detection for back-jumps was broken since at least V1.1. - Bugfix: Songend detection for back-jumps was broken since at least V1.1.
- Optimized some more wave selection code. - Optimized some more wave selection code.
- Nosync/sync wave selection optimized. - Nosync/sync wave selection optimized.
- Optimized wave generation a bit more (noise generator).
- Added Presto player draft. - Added Presto player draft.
- Drop-in replacement code size: 5784 bytes. - Drop-in replacement code size: 5732 bytes.
### V1.x (unreleased) ### V1.x (unreleased)
- Fixed a bug regarding the copper output mode with looping waves having a loop-offset. - Fixed a bug regarding the copper output mode with looping waves having a loop-offset.

Binary file not shown.

View File

@ -1,5 +1,5 @@
;-------------------------------------------------------------------- ;--------------------------------------------------------------------
; Raspberry Casket Player V2.x (20-Aug-2023) ; Raspberry Casket Player V2.x (22-Aug-2023)
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; ;
; Provided by Chris 'platon42' Hodges <chrisly@platon42.de> ; Provided by Chris 'platon42' Hodges <chrisly@platon42.de>
@ -96,7 +96,7 @@
; 18052 bytes down to 9023 bytes. ; 18052 bytes down to 9023 bytes.
; ;
; Raspberry Casket, depending on the features compiled in, is about ; Raspberry Casket, depending on the features compiled in, is about
; 5784 bytes and shrinkles down to ~4118 bytes (in isolation). ; 5732 bytes and shrinkles down to ~4084 bytes (in isolation).
; ;
; So this means that the optimization is not just "on the outside". ; So this means that the optimization is not just "on the outside".
; ;

View File

@ -1,25 +1,25 @@
CLIPTO8BIT MACRO CLIPTO8BIT MACRO
cmpi.w #-$80,\1 cmp.w #-$80,\1
bge.s .nominclip\@ bge.s .nominclip\@
moveq.l #-$80,\1 moveq.l #-$80,\1
.nominclip\@ .nominclip\@
cmpi.w #$7F,\1 cmp.w #$7f,\1
ble.s .nomaxclip\@ ble.s .nomaxclip\@
moveq.l #$7F,\1 moveq.l #$7f,\1
.nomaxclip\@ .nomaxclip\@
ENDM ENDM
CLIPORTRUNC8BIT MACRO CLIPORTRUNC8BIT MACRO
beq.s .unboosted\@ beq.s .unboosted\@
asr.l #6,\1 asr.l #6,\1
cmpi.w #-$80,\1 cmp.w #-$80,\1
bge.s .nominclip\@ bge.s .nominclip\@
moveq.l #-$80,\1 moveq.l #-$80,\1
.nominclip\@ .nominclip\@
cmpi.w #$7F,\1 cmp.w #$7f,\1
ble.s .nomaxclip\@ ble.s .nomaxclip\@
moveq.l #$7F,\1 moveq.l #$7f,\1
bra.s .nomaxclip\@ bra.s .nomaxclip\@
.unboosted\@ .unboosted\@
asr.l #8,\1 asr.l #8,\1
@ -254,8 +254,10 @@ pre_WaveGen:
bne .no_noise bne .no_noise
; ---------------------------------------- ; ----------------------------------------
; d0 = scratch
; d1 = octave ; d1 = octave
; d2 = pitch ramping value ; d2 = pitch ramping value
; d4 = scratch
; a2 = base note ; a2 = base note
.gen_noise .gen_noise
IFNE PRETRACKER_PARANOIA_MODE IFNE PRETRACKER_PARANOIA_MODE
@ -307,6 +309,8 @@ pre_WaveGen:
move.b wi_chord_shift_b(a3),d1 move.b wi_chord_shift_b(a3),d1
add.w d1,d0 add.w d1,d0
addq.w #1,d0 addq.w #1,d0
; sum of phase min and shift are used as root for noise
movea.l d5,a1 movea.l d5,a1
movea.l pv_wg_curr_sample_ptr(a4),a0 movea.l pv_wg_curr_sample_ptr(a4),a0
@ -330,30 +334,26 @@ pre_WaveGen:
lsl.w #7,d1 lsl.w #7,d1
eor.w d1,d0 eor.w d1,d0
cmpa.l #$8000,a5 ; if symmetrical move.b d0,d1 ; take the random seed
beq.s .gen_noise_centered
; FIXME what does this do? d4 = (a5 - $8000) d1 = (a5 + $7fff)&$ffff8000 -> d4 - d1 == ((a5 - $8000) - ((a5 + $7fff)&$ffff8000)
move.l a5,d4
addi.l #$FFFF8000,d4
move.l a5,d1
addi.l #$FFFF7FFF,d1
andi.w #$8000,d1
movea.l d4,a5
suba.l d1,a5
.gen_noise_centered
move.b d0,d1
ext.w d1 ext.w d1
move.w d3,d4 muls d3,d1 ; multiply by gain
muls d1,d4 asr.w #7,d1
move.l d4,d1
asr.l #7,d1
CLIPTO8BIT d1 CLIPTO8BIT d1
add.b (a0),d1 add.b (a0),d1
move.w a5,d4
subq.w #1,d4
and.w #$7fff,d4
move.w d4,a5
addq.w #1,a5
.gen_noise_innerloop .gen_noise_innerloop
move.b d1,(a0)+ move.b d1,(a0)+
cmpa.l pv_wg_curr_samend_ptr(a4),a0
beq .wave_gen_tone_done
adda.l a1,a5 adda.l a1,a5
tst.l d2 tst.l d2
beq.s .gen_noise_no_pitch_ramping beq.s .gen_noise_no_pitch_ramping
add.l d2,d6 add.l d2,d6
@ -365,22 +365,21 @@ pre_WaveGen:
btst #4,wi_flags_b(a3) ; pitch linear flag btst #4,wi_flags_b(a3) ; pitch linear flag
beq.s .noise_nonlinear_pitch beq.s .noise_nonlinear_pitch
move.l d2,d4 move.l d2,d4 ; filter pitch speed
asr.l #7,d4 asr.l #7,d4
sub.l d4,d2 sub.l d4,d2
.noise_nonlinear_pitch .noise_nonlinear_pitch
cmpa.w #$1FF,a1 cmpa.w #$1ff,a1
bgt.s .gen_noise_no_pitch_ramping bgt.s .gen_noise_no_end_of_pitch_ramp
moveq.l #0,d2 moveq.l #0,d2 ; stop pitch ramping
move.l d2,a5 move.l d2,a5
;suba.l a5,a5
movea.w #$200,a1 movea.w #$200,a1
.gen_noise_no_end_of_pitch_ramp
.gen_noise_no_pitch_ramping .gen_noise_no_pitch_ramping
cmpa.l pv_wg_curr_samend_ptr(a4),a0 cmpa.w a5,a5
beq .wave_gen_tone_done beq.s .gen_noise_innerloop
cmpa.w #$7FFF,a5
ble.s .gen_noise_innerloop
bra .gen_noise_outerloop bra .gen_noise_outerloop
; ---------------------------------------- ; ----------------------------------------