Wave generation code path for noise restructured.

This commit is contained in:
Chris Hodges 2023-08-22 21:06:02 +02:00
parent 1580f0a174
commit 4461c72eaa
4 changed files with 84 additions and 87 deletions

Binary file not shown.

View File

@ -1588,6 +1588,7 @@ pre_PlayerTick:
sub.w wi_subloop_step_w(a3),d1
move.w d1,pcd_inst_loop_offset_w(a5)
ENDC
.inst_set_wave_rts
rts
.inst_set_wave_has_no_subloop
@ -1632,7 +1633,6 @@ pre_PlayerTick:
move.b wi_subloop_wait_b(a3),d5
addq.w #1,d5
move.w d5,pcd_inst_subloop_wait_w(a5)
.inst_set_wave_rts
rts
; ----------------------------------------

View File

@ -108,7 +108,7 @@ ii_SIZEOF = 8
wi_loop_start_w = $00
wi_loop_end_w = $02
wi_subloop_len_w = $04
wi_allow_9xx_b = $06
wi_allow_9xx_b = $06 ; 0x00 / 0x01
wi_subloop_wait_b = $07
wi_subloop_step_w = $08
wi_chipram_w = $0a

View File

@ -208,7 +208,7 @@ pre_WaveGen:
swap d1
move.w d1,d0 ; note within octave
swap d1
sub.w d2,d1 ; restore octave
sub.w d2,d1 ; restore octave, result may be negative
mulu #owb_SIZEOF,d0
lea (a4,d0.w),a1
@ -226,108 +226,36 @@ pre_WaveGen:
suba.l a6,a6 ; noise selected
.osc_selected
move.l #$8000,d6
move.w d1,d0 ; check octave shift
bgt.s .shiftleft
beq.s .contshift
;.shiftright
move.w d0,d3
neg.w d3
asr.l d3,d6
bra.s .contshift
.shiftleft
lsl.l d0,d6
.contshift
; ----------------------------------------
; pitch ramp
move.b wi_pitch_ramp_b(a3),d3
ext.w d3
ext.l d3
move.b wi_pitch_ramp_b(a3),d2
ext.w d2
ext.l d2
btst #4,wi_flags_b(a3) ; pitch linear flag
beq.s .pitch_not_linear
tst.b d3
tst.b d2
bgt.s .pitch_ramp_positive
lsl.l d0,d3
add.l d3,d3
lsl.l d1,d2
add.l d2,d2
bra.s .pitch_ramp_cont
.pitch_not_linear
tst.b d3
tst.b d2
ble.s .pitch_ramp_cont
.pitch_ramp_positive
muls d3,d3
muls d2,d2
.pitch_ramp_cont
move.l d3,d2
lsl.l #8,d2
lsl.l #2,d2
moveq.l #0,d7
move.b pv_osc_buffers+owb_wave_length(a1),d7 ; get period
moveq.l #15,d5
lsl.l d5,d7
sub.w d0,d5 ; 15-octave
lsl.w #3,d5
moveq.l #0,d3
move.b wi_osc_phase_min_b(a3),d3
mulu d5,d3
lsl.l #6,d3
moveq.l #0,d0
move.b wi_osc_phase_max_b(a3),d0
mulu d5,d0
lsl.l #6,d0
move.l d0,a5
moveq.l #0,d5
move.b wi_osc_phase_spd_b(a3),d5
lsl.l #8,d5
lsl.l #3,d5
cmp.l d3,d0
bge.s .osc_with_positive_phase_speed
neg.l d5
movea.l d3,a5
bra.s .osc_continue
.osc_with_positive_phase_speed
move.l d3,d0
.osc_continue
move.l d0,pv_wg_osc_speed_l(a4)
; d0 = d6 * chord_shift * chordnum + d6 * phase_min = d6 * (chord_shift * chordnum + phase_min)
moveq.l #0,d4
move.b wi_chord_shift_b(a3),d4
move.w pv_wg_chord_flag_w(a4),d0
add.b pv_wg_chord_note_num_b(a4),d0
mulu d0,d4
moveq.l #0,d0
move.b wi_osc_phase_min_b(a3),d0
add.w d0,d4
move.l d6,d0
lsr.l #4,d0
lsl.l #4,d4
mulu d4,d0
cmp.l d7,d0
ble.s .lbC002516
.lbC002510
sub.l d7,d0
cmp.l d7,d0
bgt.s .lbC002510
.lbC002516
; check whether we have a noise oscillator or something else
move.l a6,d4
bne .no_noise
; ----------------------------------------
; d1 = octave
; d2 = pitch ramping value
; d5 = osc phase speed
; a2 = base note
.gen_noise
IFNE PRETRACKER_PARANOIA_MODE
@ -335,7 +263,8 @@ pre_WaveGen:
beq .wave_gen_tone_done
ENDC
move.l #$8000,d5
moveq.l #1,d5
ror.w #1,d5 ; $00008000
move.l d5,a5
tst.w d1
bge.s .gen_noise_positive_octave
@ -454,16 +383,84 @@ pre_WaveGen:
ble.s .gen_noise_innerloop
bra .gen_noise_outerloop
; ----------------------------------------
; d1 = octave
; d2 = pitch ramping value
; d5 = osc phase speed
; a2 = base note
.no_noise
moveq.l #0,d7
move.b pv_osc_buffers+owb_wave_length(a1),d7 ; get period
moveq.l #15,d5
lsl.l d5,d7
sub.w d1,d5 ; 15-octave
lsl.w #3,d5
moveq.l #0,d3
move.b wi_osc_phase_min_b(a3),d3
mulu d5,d3
lsl.l #6,d3
moveq.l #0,d0
move.b wi_osc_phase_max_b(a3),d0
mulu d5,d0
lsl.l #6,d0
move.l d0,a5
moveq.l #0,d5
move.b wi_osc_phase_spd_b(a3),d5
lsl.l #8,d5
lsl.l #3,d5
cmp.l d3,d0
bge.s .osc_with_positive_phase_speed
neg.l d5
movea.l d3,a5
bra.s .osc_continue
.osc_with_positive_phase_speed
move.l d3,d0
.osc_continue
move.l d0,pv_wg_osc_speed_l(a4)
; I think this calculates the base oscillator speed for higher and lower octaves
moveq.l #1,d6
moveq.l #15,d0
add.w d1,d0
lsl.l d0,d6
; d0 = d6 * chord_shift * chordnum + d6 * phase_min = d6 * (chord_shift * chordnum + phase_min)
moveq.l #0,d4
move.b wi_chord_shift_b(a3),d4
move.w pv_wg_chord_flag_w(a4),d0
add.b pv_wg_chord_note_num_b(a4),d0
mulu d0,d4
moveq.l #0,d0
move.b wi_osc_phase_min_b(a3),d0
add.w d0,d4
move.l d6,d0
lsr.l #4,d0
lsl.l #4,d4
mulu d4,d0
.osc_loop_until_in_range
sub.l d7,d0
bgt.s .osc_loop_until_in_range
add.l d7,d0
move.l d6,d1
tst.b pv_wg_unisono_run_b(a4)
beq.s .is_not_in_unisono
moveq.l #3<<3,d1
and.b wi_mod_density_b(a3),d1
lsr.b #3,d1
lsr.w #3,d1
moveq.l #9,d4
sub.b d1,d4
sub.w d1,d4
move.l d6,d1
asr.l d4,d1