Replaced the period table by byte-deltas, saved 36 bytes and compression is even better!

This commit is contained in:
Chris Hodges 2023-08-10 20:27:30 +02:00
parent 40822e295c
commit dd8c224199
4 changed files with 32 additions and 28 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 (26-Jul-2023) ## Raspberry Casket Player V2.x (10-Aug-2023)
Provided by Chris 'platon42' Hodges <chrisly@platon42.de> Provided by Chris 'platon42' Hodges <chrisly@platon42.de>
@ -90,7 +90,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
5992 bytes and goes down to ~4238 bytes (in isolation). 5942 bytes and goes down to ~4202 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".
@ -144,8 +144,9 @@ solve this problem.
- Split wave generation out of main file, reorganised content into header files. - Split wave generation out of main file, reorganised content into header files.
- Optimized some more code paths for Raspberry Casket replayer. - Optimized some more code paths for Raspberry Casket replayer.
- In the wave generator optimized away a table (32 words), replacement code is even smaller! - In the wave generator optimized away a table (32 words), replacement code is even smaller!
- Replaced the period table by byte-deltas, saved 36 bytes and compression is even better!
- Added Presto player draft. - Added Presto player draft.
- Drop-in replacement code size: 5992 bytes. - Drop-in replacement code size: 5942 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 (26-Jul-2023) ; Raspberry Casket Player V2.x (10-Aug-2023)
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; ;
; Provided by Chris 'platon42' Hodges <chrisly@platon42.de> ; Provided by Chris 'platon42' Hodges <chrisly@platon42.de>
@ -87,7 +87,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
; 5992 bytes and goes down to ~4238 bytes (in isolation). ; 5942 bytes and goes down to ~4202 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".
; ;
@ -162,7 +162,11 @@ PRETRACKER_PARANOIA_MODE = 0
; I guess this might add some phasing to the sound (which would be ; I guess this might add some phasing to the sound (which would be
; only audible in a mono mix, I would think), but it comes with an ; only audible in a mono mix, I would think), but it comes with an
; extra multiplication per channel. ; extra multiplication per channel.
; If you really want that, enable this switch. ; Moreover, I traced down that this may reduce the Amiga period
; value lower than the minimum allowed value of 124. This may cause
; distortions (like playing a note in Protracker with pitch B-3)
; on the delayed track.
; If you really want (to risk) that, enable this switch.
IFND PRETRACKER_DUBIOUS_PITCH_SHIFT_FOR_DELAYED_TRACK IFND PRETRACKER_DUBIOUS_PITCH_SHIFT_FOR_DELAYED_TRACK
PRETRACKER_DUBIOUS_PITCH_SHIFT_FOR_DELAYED_TRACK = 0 PRETRACKER_DUBIOUS_PITCH_SHIFT_FOR_DELAYED_TRACK = 0
ENDC ENDC
@ -590,28 +594,28 @@ pre_PlayerInit:
; ---------------------------------------- ; ----------------------------------------
lea pre_period_table(pc),a0 lea pre_delta_period_table(pc),a0
lea pv_period_table(a4),a1 lea pv_period_table(a4),a1
.calcperiodtable .calcperiodtable
; fill the missing entries in the period table by interpolating ; fill the missing entries in the period table by interpolating
move.w (a0)+,d2
moveq.l #3*NOTES_IN_OCTAVE-1,d7 moveq.l #3*NOTES_IN_OCTAVE-1,d7
.periodtableloop .periodtableloop
move.w (a0)+,d0 moveq.l #0,d0
move.w (a0),d1 moveq.l #0,d1
sub.w d0,d1 move.b (a0)+,d1
swap d0 move.w d2,d0
clr.w d0 sub.w d1,d2
swap d1 swap d1
clr.w d1 lsr.l #4,d1
asr.l #4,d1
moveq.l #16-1,d6 moveq.l #16-1,d6
.perfineipolloop .perfineipolloop
swap d0
move.w d0,(a1)+ move.w d0,(a1)+
swap d0 swap d0
add.l d1,d0 sub.l d1,d0
swap d0
dbra d6,.perfineipolloop dbra d6,.perfineipolloop
dbra d7,.periodtableloop dbra d7,.periodtableloop
@ -791,7 +795,7 @@ pre_PlayerTick:
move.l d1,(a1)+ ; pcd_pat_vol_ramp_speed_b, pcd_pat_2nd_inst_num4_b, pcd_pat_2nd_inst_delay_b, pcd_wave_offset_b move.l d1,(a1)+ ; pcd_pat_vol_ramp_speed_b, pcd_pat_2nd_inst_num4_b, pcd_pat_2nd_inst_delay_b, pcd_wave_offset_b
move.l d1,(a1)+ ; pcd_inst_pitch_slide_w and pcd_inst_sel_arp_note_w move.l d1,(a1)+ ; pcd_inst_pitch_slide_w and pcd_inst_sel_arp_note_w
move.w d1,(a1)+ ; pcd_inst_note_pitch_w move.w d1,(a1)+ ; pcd_inst_note_pitch_w
addq.w #2,a1 addq.l #2,a1
move.l d1,(a1)+ ; pcd_inst_line_ticks_b, pcd_inst_pitch_pinned_b, pcd_inst_vol_slide_b, pcd_inst_step_pos_b move.l d1,(a1)+ ; pcd_inst_line_ticks_b, pcd_inst_pitch_pinned_b, pcd_inst_vol_slide_b, pcd_inst_step_pos_b
@ -2024,14 +2028,14 @@ pre_PlayerTick:
bra.s .loop_handling_done bra.s .loop_handling_done
.wave_has_no_subloop .wave_has_no_subloop
moveq.l #0,d1
move.b pcd_wave_offset_b(a5),d1 move.b pcd_wave_offset_b(a5),d1
beq.s .loop_handling_done beq.s .loop_handling_done
tst.b wi_allow_9xx_b(a3) tst.b wi_allow_9xx_b(a3)
beq.s .loop_handling_done beq.s .loop_handling_done
; apply offset from pattern for sample without subloop ; apply offset from pattern for sample without subloop
lsl.w #8,d1 ; clear upper byte lsl.w #7,d1
lsr.w #1,d1
clr.b pcd_wave_offset_b(a5) clr.b pcd_wave_offset_b(a5)
@ -2491,7 +2495,7 @@ pre_PlayerTick:
rts rts
;-------------------------------------------------------------------- ;--------------------------------------------------------------------
; table data currently about 594 bytes ; table data currently about 496 bytes
; Tables used by WaveGen ; Tables used by WaveGen
pre_roll_off_table: ; used by WaveGen pre_roll_off_table: ; used by WaveGen
dc.w $400,$200,$180,$140,$100,$C0,$A0,$80,$78,$74,$6E dc.w $400,$200,$180,$140,$100,$C0,$A0,$80,$78,$74,$6E
@ -2510,7 +2514,7 @@ pre_log12_table:
pre_modulator_ramp_8: ; used by WaveGen pre_modulator_ramp_8: ; used by WaveGen
;dc.w 77,293,539,1079,1337,1877,2431,3031 ; the 1079 value is strange (938 better?) ;dc.w 77,293,539,1079,1337,1877,2431,3031 ; the 1079 value is strange (938 better?)
dc.w $4D,$125,$21B,$437,$539,$755,$96D,$BD7 dc.w $4D,$125,$21B,$437,$539,$755,$96D,$BD7
; linear then steep quadratic slope ; linear then steep quadratic slope
pre_vib_speed_table: pre_vib_speed_table:
@ -2566,11 +2570,11 @@ pre_octave_select_table:
IFNE PRETRACKER_DUBIOUS_PITCH_SHIFT_FOR_DELAYED_TRACK IFNE PRETRACKER_DUBIOUS_PITCH_SHIFT_FOR_DELAYED_TRACK
; -4,-3,-1,1,2,3,4,0 ; -4,-3,-1,1,2,3,4,0
pre_minus4plus4_table: pre_minus4plus4_table:
dc.b $FC,$FB,$FF,1,2,3,4,0 dc.b $FC,$FB,$FF,1,2,3,4,0
ENDC ENDC
pre_period_table: pre_delta_period_table:
dc.w $350,$320,$2F2,$2C8,$2A0,$279,$256,$236,$216,$1F8,$1DC,$1C0 dc.w $350
dc.w $1A8,$190,$179,$164,$151,$13E,$12C,$11B,$10B,$FC,$EE,$E0 dc.b $30,$2e,$2a,$28,$27,$23,$20,$20,$1e,$1c,$1c,$18,$18,$17,$15,$13
dc.w $D4,$C8,$BD,$B2,$A8,$9F,$96,$8D,$86,$7E,$78,$71 dc.b $13,$12,$11,$10,$0f,$0e,$0e,$0c,$0c,$0b,$0b,$0a,$09,$09,$09,$07
dc.w $71 dc.b $08,$06,$07,$00

View File

@ -61,7 +61,6 @@
; - 6 Bits : Pitch ($01 is C-0) ; - 6 Bits : Pitch ($01 is C-0)
; - 4 Bits : unused? ; - 4 Bits : unused?
; - 12 Bits: Effect ; - 12 Bits: Effect
; - Patterns x steps x 3 bytes
; ;
; Wave definitions (WAVE): ; Wave definitions (WAVE):
; - 24 (!) x Null terminated string (or 23 chars max) ; - 24 (!) x Null terminated string (or 23 chars max)