From 4461c72eaa0e1aced0505e482bbf2d104bfa4034 Mon Sep 17 00:00:00 2001 From: chrisly42 Date: Tue, 22 Aug 2023 21:06:02 +0200 Subject: [PATCH] Wave generation code path for noise restructured. --- binaries/raspberry_casket.bin | Bin 5784 -> 5760 bytes src/raspberry_casket.asm | 2 +- src/raspberry_casket.i | 2 +- src/raspberry_casket_wavegen.asm | 167 +++++++++++++++---------------- 4 files changed, 84 insertions(+), 87 deletions(-) diff --git a/binaries/raspberry_casket.bin b/binaries/raspberry_casket.bin index 65ea3ccd5acc4d9b15ad13386ad52c6e48a96b86..3ad90c0cc7b757856f9cf5792103a5e2e230e79d 100644 GIT binary patch delta 384 zcmbQC+n~$Cz`y{+j8zN_TtO3gv>ACOT2wP;Ox$vnao6N7Moq>QleaLgW^9<8z%-T7 zZ}K;$P{xSKKFl_HBH9d!9!(yHIJ6m97(~*!yqNO19wqUs?!6>%tPyPS=LkSH3bLtr6GzGY-_+PJ|9qmMMjIw z3pk`18TBUb;Z$W**!+mIkeTt^<`7w+a}n9T+&I9T&X?y6ysNC~**ddqcJE--xD YHv8~fGBPG@ZWEAZX1uU@k?=Pr0Dr!A#sB~S delta 358 zcmXw!KS%;`7>2*^PUY?}6%9KOM5QoODWsx5CPGOf4N?Trbc3jaoz)OwQIdmjQ}QE{ zTEiis4o)JRLWdR!mmDMlha7Boh@d2hmuGmUhd1jjdbI#B05bqwvY>UNqcC@b*+S(N zn?ynvK9LHRu}B2!0%N34ZK6olXn)w_2gt${id=%5g_Y%QNuWA+W;fWwxp19vg9?Td zT!a?6PPvs6G!Z&YJ=aI+j`Sg&fYoK-GWyT^t01{i`N+GpKsN8-Ark+)q~3<6^bg3;gwlk5d&4DgXub*nS$7zG(@ xDEtq42xuLc2e-l*3~Yp|$H2z`&f1}NsJb)wd!S6~=Me=(G+1bSQ6y8J`UN=QYjFSo diff --git a/src/raspberry_casket.asm b/src/raspberry_casket.asm index ec54cba..01ddbee 100755 --- a/src/raspberry_casket.asm +++ b/src/raspberry_casket.asm @@ -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 ; ---------------------------------------- diff --git a/src/raspberry_casket.i b/src/raspberry_casket.i index 727ba9d..9fad806 100644 --- a/src/raspberry_casket.i +++ b/src/raspberry_casket.i @@ -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 diff --git a/src/raspberry_casket_wavegen.asm b/src/raspberry_casket_wavegen.asm index 9ec7a8f..747fe26 100644 --- a/src/raspberry_casket_wavegen.asm +++ b/src/raspberry_casket_wavegen.asm @@ -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