Optimized ping pong some more.

This commit is contained in:
Chris Hodges 2023-09-05 21:17:11 +02:00
parent ef1c519a6c
commit f97f406272
2 changed files with 30 additions and 39 deletions

Binary file not shown.

View File

@ -1623,8 +1623,8 @@ pre_PlayerTick:
move.w d5,pcd_out_len_w(a5)
moveq.l #-1,d3
.inst_set_wave_has_subloop
move.w d3,pcd_out_lof_w(a5)
.inst_set_wave_has_subloop
move.l a1,pcd_out_ptr_l(a5)
move.w d1,pcd_inst_loop_offset_w(a5)
@ -1930,15 +1930,19 @@ pre_PlayerTick:
; ----------------------------------------
; wave loop pos advancing and pattern wave offset command handling
moveq.l #0,d1
tst.b wi_allow_9xx_b(a3)
sne d1
and.b pcd_wave_offset_b(a5),d1
move.w wi_subloop_len_w(a3),d3
beq .wave_has_no_subloop
move.w d3,pcd_out_len_w(a5) ; FIXME can we move this to wave loading?
move.w pcd_inst_subloop_wait_w(a5),d5
move.b pcd_inst_ping_pong_dir_b(a5),d4
move.w wi_subloop_step_w(a3),d2
moveq.l #0,d1
move.b pcd_wave_offset_b(a5),d1
beq.s .wave_with_subloop_but_no_wave_offset
tst.b wi_allow_9xx_b(a3)
tst.w d1
beq.s .wave_with_subloop_but_no_wave_offset
; update loop offset from pattern
@ -1947,7 +1951,7 @@ pre_PlayerTick:
clr.b pcd_wave_offset_b(a5)
; keep current direction of ping-pong unchanged
move.b pcd_inst_ping_pong_dir_b(a5),d4
tst.b d4
bpl.s .wave_move_one_step_ahead
sub.w d2,d1 ; go in reverse direction one step?
bra.s .wave_submove_cont
@ -1957,23 +1961,29 @@ pre_PlayerTick:
.wave_with_subloop_but_no_wave_offset
move.w pcd_inst_loop_offset_w(a5),d1
subq.w #1,pcd_inst_subloop_wait_w(a5)
subq.w #1,d5
bgt.s .wave_subloop_wait
; subloop moves!
move.b pcd_inst_ping_pong_dir_b(a5),d4
.wave_submove_cont
; reset subloop wait
moveq.l #0,d5
move.b wi_subloop_wait_b(a3),d5 ; FIXME why is this not increased by one here?
move.w d5,pcd_inst_subloop_wait_w(a5)
tst.b d4
bpl.s .loop_is_moving_backwards
bmi.s .loop_is_moving_forwards
sub.w d2,d1 ; decrement offset in backward direction one step
move.w wi_loop_start_w(a3),d2
sub.w d1,d2 ; calc how many bytes we are past front
bmi.s .wave_new_loop_pos_fits
bra.s .wave_loop_dir_changed
.loop_is_moving_forwards
add.w d2,d1 ; increment offset in forward direction one step
move.w d1,d4
add.w d3,d4 ; calculate next start of loop (curr start)
add.w d3,d4 ; calculate new end position of loop sample
move.w wi_loop_end_w(a3),d2
cmp.w d1,d2
@ -1983,46 +1993,28 @@ pre_PlayerTick:
sub.w d4,d2 ; space left = (max(loop end, sample end) - curr start)
bhi.s .wave_new_loop_pos_fits ; max(loop end, sample end) > curr start?
add.w d2,d1 ; place offset at last possible place (loop_end - loop size)
clr.b pcd_inst_ping_pong_dir_b(a5) ; mark going backwards
bra.s .wave_loop_dir_changed
.loop_is_moving_backwards
sub.w d2,d1 ; decrement offset in backward direction one step
move.w wi_loop_start_w(a3),d4
move.w d4,d2
sub.w d1,d2 ; calc how many bytes we are past front
bmi.s .wave_new_loop_pos_fits
.wave_hit_front_of_loop
move.w d4,d1
st pcd_inst_ping_pong_dir_b(a5)
.wave_loop_dir_changed
add.w d2,d1 ; fix front of looip
not.b pcd_inst_ping_pong_dir_b(a5)
IFEQ PRETRACKER_FASTER_CODE ; this extra code doesn't seem to be justified
tst.w d2
bne.s .wave_new_loop_pos_fits ; perfect fit for last loop
; partial fit only
subq.w #1,pcd_inst_subloop_wait_w(a5) ; why, oh why?
subq.w #1,d5 ; why, oh why?
ENDC
.wave_new_loop_pos_fits
move.w d1,pcd_inst_loop_offset_w(a5)
.wave_subloop_wait
move.w d5,pcd_inst_subloop_wait_w(a5)
move.w d1,pcd_out_lof_w(a5)
moveq.l #0,d1
bra.s .wave_load_sample_offset
.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
tst.w d1
beq.s .wave_loop_handling_done
; apply offset from pattern for sample without subloop
lsl.w #7,d1
@ -2049,8 +2041,7 @@ pre_PlayerTick:
add.l pv_wave_sample_table(a4,d2.w),d1
move.l d1,pcd_out_ptr_l(a5)
;move.w #$FFFF,pcd_out_lof_w(a5) ; this is already set to -1, no need to set it again
.loop_handling_done
.wave_loop_handling_done
; ----------------------------------------
; pitch handling