3 ms·
Awesome! As an aside, the only code I know that uses Paula's attached mode (where one channel can modulate the volume or pitch of another) is the sound effect
by amiga386 5mo ago
Awesome!
As an aside, the only code I know that uses Paula's attached mode (where one channel can modulate the volume or pitch of another) is the sound effect used in X-Copy.
It sounds like this: https://youtu.be/2OG2tPx5gnU?t=22 https://youtu.be/2OG2tPx5gnU?t=22
and the code that generates that sound is this:
PLAY_SAMPLE ; a6=_custom, d0=zero for high-pitch sound, nonzero for low-pitch sound
move.w #$F00,d1 ; high pitch: period=$d00-$f00 if d0 == 0
tst.b d0
beq.s .high
move.w #$7700,d1 ; low pitch: period=$7500-$7700 if d0 != 0
.high lea MODULO,a0
move.w #$200-1,d0
.down move.w d1,(a0)+
subq.w #1,d1
dbra d0,.down
move.w #$200-1,d0
.up addq.w #1,d1
move.w d1,(a0)+
dbra d0,.up
; set up channel 2; whatever words this plays will
; be written to the period register of channel 3
move.w adkconr(a6),-(sp) ; save ADKCON state for later
move.w #ADKF_SETCLR!ADKF_USE2P3,adkcon(a6)
move.l #MODULO,aud2+ac_ptr(a6)
move.w #$400,aud2+ac_len(a6)
move.w #0,aud2+ac_vol(a6) ; no volume (no actual sound wanted!)
move.w #$90,aud2+ac_per(a6) ; change period every $90 ticks
lea SAMPLE,a0 ; set up channel 3 to play a simple square wave
move.l #$7f7f8080,(a0) ; square wave: 127 127 -128 -128 ...
move.l a0,aud3+ac_ptr(a6)
move.w #2,aud3+ac_len(a6)
move.w #DMAF_SETCLR!DMAF_AUD2|DMAF_AUD3,dmacon(a6) ; turn on sound DMA
moveq #$40,d2 ; start with volume = 64
.vol move.w d2,aud3+ac_vol(a6) ; write channel 3 volume
move.w #$600-1,d1 ; wait a bit
1$ move.b vhposr(a6),d0
2$ cmp.b vhposr(a6),d0
beq.s 2$
dbra d1,1$
subq #8,d2 ; repeat to fade
bpl.s .vol
moveq #0,d0 ; stop sound
move.w d0,aud2+ac_len(a6)
move.w d0,aud3+ac_vol(a6)
move.w d0,aud3+ac_len(a6)
move.w #DMAF_AUD2!DMAF_AUD3,dmacon(a6)
move.w (sp)+,d0 ; restore ADKCON
btst #ADKB_USE2P3,d0
bne.s .keepon
move.w #ADKF_USE2P3,adkcon(a6)
.keepon rts
section 2,bss,chip
SAMPLE ds.w 2
MODULO ds.w $400