From dd8c22419932140927c077e6d3e29e65edb18e2e Mon Sep 17 00:00:00 2001 From: chrisly42 Date: Thu, 10 Aug 2023 20:27:30 +0200 Subject: [PATCH] Replaced the period table by byte-deltas, saved 36 bytes and compression is even better! --- README.md | 7 +++-- binaries/raspberry_casket.bin | Bin 6002 -> 5942 bytes src/raspberry_casket.asm | 52 ++++++++++++++++++---------------- src/raspberry_casket.i | 1 - 4 files changed, 32 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index ab96fc5..899b46d 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Raspberry Casket 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 @@ -90,7 +90,7 @@ The original code compressed with *Blueberry's* Shrinkler goes from 18052 bytes down to 9023 bytes. 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". @@ -144,8 +144,9 @@ solve this problem. - Split wave generation out of main file, reorganised content into header files. - Optimized some more code paths for Raspberry Casket replayer. - 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. -- Drop-in replacement code size: 5992 bytes. +- Drop-in replacement code size: 5942 bytes. ### V1.x (unreleased) - Fixed a bug regarding the copper output mode with looping waves having a loop-offset. diff --git a/binaries/raspberry_casket.bin b/binaries/raspberry_casket.bin index 04f66cd0b3bc31e0afcb03021407d887340908fa..07155086939fde822628fc2d88732064c6da1bdc 100644 GIT binary patch delta 175 zcmV;g08sz(F19W>0000C0004Y000VvNasI1Z~#ow0D2Sw5&*KiP*PL?W&iQzI*^6ZvuWGv4AuIBz_|> z7%~u&KuADBKuAGCLFj>e4@f{Vz(_#QflcXE5PO;-1fHUbs__yODjzyYWMkO6rCWC2kDJ^?HN m8vzRd`~dC%-~iMB$N;?nvH++6p8%EsjR1xKegJp?aR71o!$y+; diff --git a/src/raspberry_casket.asm b/src/raspberry_casket.asm index 963afe1..bab1e73 100755 --- a/src/raspberry_casket.asm +++ b/src/raspberry_casket.asm @@ -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 @@ -87,7 +87,7 @@ ; 18052 bytes down to 9023 bytes. ; ; 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". ; @@ -162,7 +162,11 @@ PRETRACKER_PARANOIA_MODE = 0 ; 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 ; 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 PRETRACKER_DUBIOUS_PITCH_SHIFT_FOR_DELAYED_TRACK = 0 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 .calcperiodtable ; fill the missing entries in the period table by interpolating + move.w (a0)+,d2 moveq.l #3*NOTES_IN_OCTAVE-1,d7 .periodtableloop - move.w (a0)+,d0 - move.w (a0),d1 - sub.w d0,d1 - swap d0 - clr.w d0 + moveq.l #0,d0 + moveq.l #0,d1 + move.b (a0)+,d1 + move.w d2,d0 + sub.w d1,d2 swap d1 - clr.w d1 - asr.l #4,d1 + lsr.l #4,d1 moveq.l #16-1,d6 .perfineipolloop - swap d0 move.w d0,(a1)+ swap d0 - add.l d1,d0 + sub.l d1,d0 + swap d0 dbra d6,.perfineipolloop 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_inst_pitch_slide_w and pcd_inst_sel_arp_note_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 @@ -2024,14 +2028,14 @@ pre_PlayerTick: bra.s .loop_handling_done .wave_has_no_subloop + moveq.l #0,d1 move.b pcd_wave_offset_b(a5),d1 beq.s .loop_handling_done tst.b wi_allow_9xx_b(a3) beq.s .loop_handling_done ; apply offset from pattern for sample without subloop - lsl.w #8,d1 ; clear upper byte - lsr.w #1,d1 + lsl.w #7,d1 clr.b pcd_wave_offset_b(a5) @@ -2491,7 +2495,7 @@ pre_PlayerTick: rts ;-------------------------------------------------------------------- -; table data currently about 594 bytes +; table data currently about 496 bytes ; Tables used by WaveGen pre_roll_off_table: ; used by WaveGen 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 ;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 pre_vib_speed_table: @@ -2566,11 +2570,11 @@ pre_octave_select_table: IFNE PRETRACKER_DUBIOUS_PITCH_SHIFT_FOR_DELAYED_TRACK ; -4,-3,-1,1,2,3,4,0 pre_minus4plus4_table: - dc.b $FC,$FB,$FF,1,2,3,4,0 + dc.b $FC,$FB,$FF,1,2,3,4,0 ENDC -pre_period_table: - dc.w $350,$320,$2F2,$2C8,$2A0,$279,$256,$236,$216,$1F8,$1DC,$1C0 - dc.w $1A8,$190,$179,$164,$151,$13E,$12C,$11B,$10B,$FC,$EE,$E0 - dc.w $D4,$C8,$BD,$B2,$A8,$9F,$96,$8D,$86,$7E,$78,$71 - dc.w $71 +pre_delta_period_table: + dc.w $350 + dc.b $30,$2e,$2a,$28,$27,$23,$20,$20,$1e,$1c,$1c,$18,$18,$17,$15,$13 + dc.b $13,$12,$11,$10,$0f,$0e,$0e,$0c,$0c,$0b,$0b,$0a,$09,$09,$09,$07 + dc.b $08,$06,$07,$00 diff --git a/src/raspberry_casket.i b/src/raspberry_casket.i index 09fc2c6..b0e35b1 100644 --- a/src/raspberry_casket.i +++ b/src/raspberry_casket.i @@ -61,7 +61,6 @@ ; - 6 Bits : Pitch ($01 is C-0) ; - 4 Bits : unused? ; - 12 Bits: Effect -; - Patterns x steps x 3 bytes ; ; Wave definitions (WAVE): ; - 24 (!) x Null terminated string (or 23 chars max)