Optimized speed/shuffle code.
This commit is contained in:
parent
627b388615
commit
7bac794dd8
@ -109,6 +109,7 @@ solve this problem.
|
|||||||
- Bake in this strange vibrato speed multiplication to precalculated vibrato value (where possible)
|
- Bake in this strange vibrato speed multiplication to precalculated vibrato value (where possible)
|
||||||
- Various small optimizations
|
- Various small optimizations
|
||||||
- Store instrument number * 4 on loading to avoid using two adds every frame
|
- Store instrument number * 4 on loading to avoid using two adds every frame
|
||||||
|
- Optimized speed/shuffle code. Idea of using xor turned out to make things too complicated for pattern breaks/jumps.
|
||||||
|
|
||||||
### V1.0 (26-Dec-22)
|
### V1.0 (26-Dec-22)
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
;--------------------------------------------------------------------
|
;--------------------------------------------------------------------
|
||||||
; Raspberry Casket Player V1.0+ (27-Dec-2022)
|
; Raspberry Casket Player V1.1beta (28-Dec-2022)
|
||||||
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
;
|
;
|
||||||
; Provided by Chris 'platon42' Hodges <chrisly@platon42.de>
|
; Provided by Chris 'platon42' Hodges <chrisly@platon42.de>
|
||||||
;
|
;
|
||||||
@ -415,6 +415,7 @@ uii_SIZEOF rs.b 0
|
|||||||
rsreset
|
rsreset
|
||||||
sv_waveinfo_table rs.l MAX_WAVES ; 24 pointers to wave infos to avoid mulu
|
sv_waveinfo_table rs.l MAX_WAVES ; 24 pointers to wave infos to avoid mulu
|
||||||
sv_inst_patterns_table rs.l MAX_INSTRUMENTS ; 32 pointers to pattern data
|
sv_inst_patterns_table rs.l MAX_INSTRUMENTS ; 32 pointers to pattern data
|
||||||
|
; --- 127 byte displacement limit ---
|
||||||
sv_wavelength_table rs.l MAX_WAVES ; 24 longwords to sample lengths (standard octave) (NEW)
|
sv_wavelength_table rs.l MAX_WAVES ; 24 longwords to sample lengths (standard octave) (NEW)
|
||||||
sv_wavetotal_table rs.l MAX_WAVES ; 24 longwords to sample lengths for all octaves (NEW)
|
sv_wavetotal_table rs.l MAX_WAVES ; 24 longwords to sample lengths for all octaves (NEW)
|
||||||
sv_wavegen_order_table rs.b MAX_WAVES ; 24 bytes
|
sv_wavegen_order_table rs.b MAX_WAVES ; 24 bytes
|
||||||
@ -544,13 +545,16 @@ owb_SIZEOF rs.b 0
|
|||||||
pv_pat_curr_row_b rs.b 1 ; current step
|
pv_pat_curr_row_b rs.b 1 ; current step
|
||||||
pv_next_pat_row_b rs.b 1
|
pv_next_pat_row_b rs.b 1
|
||||||
pv_next_pat_pos_b rs.b 1
|
pv_next_pat_pos_b rs.b 1
|
||||||
pv_pat_speed_b rs.b 1 ; speed byte (unfiltered)
|
pv_pat_speed_even_b rs.b 1 ; even shuffle speed
|
||||||
|
|
||||||
|
pv_pat_speed_odd_b rs.b 1 ; odd shuffle speed
|
||||||
|
pv_pat_line_ticks_b rs.b 1
|
||||||
|
pv_pat_stopped_b rs.b 1 ; 0 = stop, $ff = run
|
||||||
|
pv_songend_detected_b rs.b 1
|
||||||
; DO NOT CHANGE ORDER -- OPTIMIZED INIT END
|
; DO NOT CHANGE ORDER -- OPTIMIZED INIT END
|
||||||
|
|
||||||
pv_pat_stopped_b rs.b 1 ; 0 = stop, 1 = run
|
|
||||||
pv_pat_line_ticks_b rs.b 1
|
|
||||||
pv_loop_pattern_b rs.b 1 ; repeat current pattern, do not advance
|
pv_loop_pattern_b rs.b 1 ; repeat current pattern, do not advance
|
||||||
pv_songend_detected_b rs.b 1
|
rs.b 1 ; padding
|
||||||
|
|
||||||
pv_trigger_mask_w rs.w 1
|
pv_trigger_mask_w rs.w 1
|
||||||
|
|
||||||
@ -559,7 +563,9 @@ pv_sample_buffer_ptr rs.l 1 ; pointer to start of sample buffer
|
|||||||
pv_copperlist_ptr rs.l 1
|
pv_copperlist_ptr rs.l 1
|
||||||
pv_wave_sample_table rs.l MAX_WAVES ; 24 pointers to sample starts
|
pv_wave_sample_table rs.l MAX_WAVES ; 24 pointers to sample starts
|
||||||
pv_period_table rs.w 16*NOTES_IN_OCTAVE*3
|
pv_period_table rs.w 16*NOTES_IN_OCTAVE*3
|
||||||
|
; --- 127 byte displacement limit ---
|
||||||
pv_channeldata rs.b NUM_CHANNELS*pcd_SIZEOF
|
pv_channeldata rs.b NUM_CHANNELS*pcd_SIZEOF
|
||||||
|
|
||||||
IFNE PRETRACKER_VOLUME_TABLE
|
IFNE PRETRACKER_VOLUME_TABLE
|
||||||
pv_osc_buffers rs.b 0 ; reuse space of volume_table, which is bigger than NOTES_IN_OCTAVE*owb_SIZEOF
|
pv_osc_buffers rs.b 0 ; reuse space of volume_table, which is bigger than NOTES_IN_OCTAVE*owb_SIZEOF
|
||||||
pv_volume_table rs.b (MAX_VOLUME+1)*MAX_VOLUME*2
|
pv_volume_table rs.b (MAX_VOLUME+1)*MAX_VOLUME*2
|
||||||
@ -1003,10 +1009,8 @@ pre_PlayerInit:
|
|||||||
|
|
||||||
; ----------------------------------------
|
; ----------------------------------------
|
||||||
|
|
||||||
move.l #$00ffff06,pv_pat_curr_row_b(a4) ; pattern frame = 0, line = $ff, pattern pos = $ff, speed = 6
|
move.l #$00ffff06,pv_pat_curr_row_b(a4) ; pattern frame = 0, line = $ff, pattern pos = $ff, speed_even = 0
|
||||||
move.b #1,pv_pat_stopped_b(a4) ; start pattern processing
|
move.l #$06060100,pv_pat_speed_odd_b(a4) ; and pv_pat_line_ticks_b, pv_pat_stopped_b, pv_songend_detected_b
|
||||||
|
|
||||||
bsr pre_update_pat_line_counter
|
|
||||||
|
|
||||||
move.l sv_waveinfo_ptr(a6),a1
|
move.l sv_waveinfo_ptr(a6),a1
|
||||||
lea pv_channeldata(a4),a0
|
lea pv_channeldata(a4),a0
|
||||||
@ -2515,7 +2519,7 @@ pre_PlayerTick:
|
|||||||
bne.s .pat_is_not_ed_cmd
|
bne.s .pat_is_not_ed_cmd
|
||||||
; note delay in x sub steps
|
; note delay in x sub steps
|
||||||
IFNE PRETRACKER_PARANOIA_MODE ; who does this kind of stuff?
|
IFNE PRETRACKER_PARANOIA_MODE ; who does this kind of stuff?
|
||||||
tst.b pv_pat_speed_b(a4)
|
tst.b pv_pat_speed_even_b(a4)
|
||||||
beq.s .pat_exy_cmd_cont
|
beq.s .pat_exy_cmd_cont
|
||||||
ENDC
|
ENDC
|
||||||
move.b d1,pcd_note_delay_b(a5)
|
move.b d1,pcd_note_delay_b(a5)
|
||||||
@ -2858,17 +2862,28 @@ pre_PlayerTick:
|
|||||||
|
|
||||||
; ----------------------------------------
|
; ----------------------------------------
|
||||||
.pat_set_speed
|
.pat_set_speed
|
||||||
move.b d5,pv_pat_speed_b(a4)
|
lea pv_pat_speed_even_b(a4),a1
|
||||||
sne d2
|
cmpi.b #MAX_SPEED,d5
|
||||||
neg.b d2
|
bhs.s .pat_set_speed_shuffle
|
||||||
move.b d2,pv_pat_stopped_b(a4)
|
move.b d5,(a1)+ ; pv_pat_speed_even_b
|
||||||
|
move.b d5,(a1)+ ; pv_pat_speed_odd_b
|
||||||
|
move.b d5,(a1)+ ; pv_pat_line_ticks_b
|
||||||
|
sne (a1)+ ; pv_pat_stopped_b
|
||||||
IFNE PRETRACKER_SONG_END_DETECTION
|
IFNE PRETRACKER_SONG_END_DETECTION
|
||||||
bne.s .pat_no_songend
|
seq (a1)+ ; pv_songend_detected_b
|
||||||
st pv_songend_detected_b(a4)
|
|
||||||
.pat_no_songend
|
|
||||||
ENDC
|
ENDC
|
||||||
|
bra.s .pat_play_cont
|
||||||
bsr pre_update_pat_line_counter
|
.pat_set_speed_shuffle
|
||||||
|
moveq.l #15,d2
|
||||||
|
and.w d5,d2 ; odd speed
|
||||||
|
lsr.w #4,d5 ; even speed
|
||||||
|
move.b d5,(a1)+ ; pv_pat_speed_even_b
|
||||||
|
move.b d2,(a1)+ ; pv_pat_speed_odd_b
|
||||||
|
btst #0,pv_pat_curr_row_b(a4)
|
||||||
|
beq.s .pat_shuffle_on_even
|
||||||
|
move.b d2,d5 ; toggle speed to odd row
|
||||||
|
.pat_shuffle_on_even
|
||||||
|
move.b d5,(a1)+ ; pv_pat_line_ticks_b
|
||||||
|
|
||||||
; ----------------------------------------
|
; ----------------------------------------
|
||||||
|
|
||||||
@ -2894,8 +2909,9 @@ pre_PlayerTick:
|
|||||||
; pattern advancing FIXME try to figure out all the cases
|
; pattern advancing FIXME try to figure out all the cases
|
||||||
.pattern_advancing
|
.pattern_advancing
|
||||||
subq.b #1,pv_pat_line_ticks_b(a4)
|
subq.b #1,pv_pat_line_ticks_b(a4)
|
||||||
bne .inst_pattern_processing
|
bne .no_pattern_advance
|
||||||
|
|
||||||
|
; clear note delay info
|
||||||
moveq.l #0,d1
|
moveq.l #0,d1
|
||||||
REPT NUM_CHANNELS
|
REPT NUM_CHANNELS
|
||||||
move.b d1,pv_channeldata+pcd_note_delay_b+REPTN*pcd_SIZEOF(a4)
|
move.b d1,pv_channeldata+pcd_note_delay_b+REPTN*pcd_SIZEOF(a4)
|
||||||
@ -2996,7 +3012,13 @@ pre_PlayerTick:
|
|||||||
.set_song_pos
|
.set_song_pos
|
||||||
move.w d0,sv_curr_pat_pos_w(a6)
|
move.w d0,sv_curr_pat_pos_w(a6)
|
||||||
.done_pat_advance
|
.done_pat_advance
|
||||||
bsr pre_update_pat_line_counter
|
move.b pv_pat_speed_even_b(a4),d0
|
||||||
|
btst #0,pv_pat_curr_row_b(a4)
|
||||||
|
beq.s .set_speed_even
|
||||||
|
move.b pv_pat_speed_odd_b(a4),d0
|
||||||
|
.set_speed_even
|
||||||
|
move.b d0,pv_pat_line_ticks_b(a4)
|
||||||
|
.no_pattern_advance
|
||||||
|
|
||||||
; ----------------------------------------
|
; ----------------------------------------
|
||||||
; processes the instrument pattern for each running instrument
|
; processes the instrument pattern for each running instrument
|
||||||
@ -3875,8 +3897,8 @@ pre_PlayerTick:
|
|||||||
move.l pcd_out_base+8(a5),(a3)+ ; ocd_period/ocd_volume/ocd_trigger
|
move.l pcd_out_base+8(a5),(a3)+ ; ocd_period/ocd_volume/ocd_trigger
|
||||||
;move.l pcd_out_base+12(a5),(a3)+ ; this is never used
|
;move.l pcd_out_base+12(a5),(a3)+ ; this is never used
|
||||||
|
|
||||||
move.b pcd_SIZEOF+pcd_channel_mask_b(a5),d2
|
move.b -(a3),d2
|
||||||
tst.b -(a3)
|
add.b d2,d2 ; increment channel
|
||||||
bne.s .copy_trigger_for_delayed_channel
|
bne.s .copy_trigger_for_delayed_channel
|
||||||
tst.b pcd_SIZEOF+pcd_track_delay_steps_b(a5)
|
tst.b pcd_SIZEOF+pcd_track_delay_steps_b(a5)
|
||||||
bne.s .dont_trigger_track_delay_first_note
|
bne.s .dont_trigger_track_delay_first_note
|
||||||
@ -4035,7 +4057,7 @@ pre_PlayerTick:
|
|||||||
|
|
||||||
; turn channels off and remember raster position
|
; turn channels off and remember raster position
|
||||||
move.w d2,dmacon(a5) ; turn dma channels off
|
move.w d2,dmacon(a5) ; turn dma channels off
|
||||||
move.w vhposr(a5),d5
|
move.w vhposr(a5),d5 ; I know this only works for the lower 256 rasterlines...
|
||||||
add.w #4<<8,d5 ; target rasterpos
|
add.w #4<<8,d5 ; target rasterpos
|
||||||
|
|
||||||
; in the meanwhile we can update both channels that
|
; in the meanwhile we can update both channels that
|
||||||
@ -4077,11 +4099,11 @@ pre_PlayerTick:
|
|||||||
tst.w d2
|
tst.w d2
|
||||||
beq.s .skiprasterwait ; if no channel needed triggering, we are done!
|
beq.s .skiprasterwait ; if no channel needed triggering, we are done!
|
||||||
|
|
||||||
|
or.w #DMAF_SETCLR,d2
|
||||||
.rasterwait1
|
.rasterwait1
|
||||||
cmp.w vhposr(a5),d5
|
cmp.w vhposr(a5),d5
|
||||||
bgt.s .rasterwait1
|
bgt.s .rasterwait1
|
||||||
|
|
||||||
or.w #DMAF_SETCLR,d2
|
|
||||||
move.w d2,dmacon(a5) ; enable triggered channels
|
move.w d2,dmacon(a5) ; enable triggered channels
|
||||||
add.w #4<<8,d5 ; target rasterpos
|
add.w #4<<8,d5 ; target rasterpos
|
||||||
|
|
||||||
@ -4119,22 +4141,6 @@ pre_PlayerTick:
|
|||||||
ENDC
|
ENDC
|
||||||
rts
|
rts
|
||||||
|
|
||||||
; ----------------------------------------
|
|
||||||
|
|
||||||
pre_update_pat_line_counter
|
|
||||||
move.b pv_pat_speed_b(a4),d1
|
|
||||||
cmpi.b #MAX_SPEED,d1
|
|
||||||
bls.s .pat_set_speed_no_shuffle
|
|
||||||
btst #0,pv_pat_curr_row_b(a4)
|
|
||||||
beq.s .pat_set_even_speed
|
|
||||||
andi.b #15,d1
|
|
||||||
bra.s .pat_set_speed_no_shuffle
|
|
||||||
.pat_set_even_speed
|
|
||||||
lsr.b #4,d1
|
|
||||||
.pat_set_speed_no_shuffle
|
|
||||||
move.b d1,pv_pat_line_ticks_b(a4)
|
|
||||||
rts
|
|
||||||
|
|
||||||
;--------------------------------------------------------------------
|
;--------------------------------------------------------------------
|
||||||
; table data currently about 594 bytes
|
; table data currently about 594 bytes
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user