nxu/drums.tal

100 lines
3.4 KiB
Tal

( drums.tal )
( )
( very very simple drum machine )
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 ]
|30 @Audio0 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
|40 @Audio1 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
|50 @Audio2 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
|60 @Audio3 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
|0000
@timer $2
|0100
( bass )
;noise .Audio0/addr DEO2 ( sample )
#0100 .Audio0/length DEO2 ( length )
#0100 .Audio0/adsr DEO2 ( envelope )
#99 .Audio0/volume DEO ( volume )
( snare )
;noise .Audio1/addr DEO2 ( sample )
#0100 .Audio1/length DEO2 ( length )
#0102 .Audio1/adsr DEO2 ( envelope )
#df .Audio1/volume DEO ( volume )
( hi-hat )
;noise .Audio2/addr DEO2 ( sample )
#0100 .Audio2/length DEO2 ( length )
#0001 .Audio2/adsr DEO2 ( envelope )
#fb .Audio2/volume DEO ( volume )
( cymbal )
;noise .Audio3/addr DEO2 ( sample )
#0100 .Audio3/length DEO2 ( length )
#0035 .Audio3/adsr DEO2 ( envelope )
#af .Audio3/volume DEO ( volume )
( set up clock timer, each tick is 1/60 second )
#0000 .timer STZ2
( this callback updates tick 60x a second )
;tick .Screen/vector DEO2
BRK
@tick
( this mask/shift defines the tempo )
( each sixteenth note is 8/60 seconds, i.e. 133ms )
( this makes the tempo 128 bpm )
.timer LDZ2 DUP2 INC2 .timer STZ2 ( t += 1 )
DUP #07 AND ,&done JCN ( done if t&7!=0 )
#03 SFT2 #000f AND2 ( beat=(t>>3)&f )
STH2k ;bass ;play-beat JSR2
STH2kr ;snare ;play-beat JSR2
STH2kr ;hi-hat ;play-beat JSR2
STH2r ;cymbal ;play-beat JSR2
&done BRK
@play-beat ( beat* addr* -- )
STH2k ADD2 LDA ,&on JCN POP2r JMP2r
&on STH2r #0010 ADD2 LDA2 DEO JMP2r
( each track has 16 notes )
( followed by 2 bytes describing pitch/channel to use )
@bass
01 00 00 01 00 00 00 00 00 00 01 00 00 00 00 00
00 3f ( #00 Audio0/pitch DEO )
@snare
00 00 00 00 01 00 00 00 00 00 00 00 01 01 00 01
0c 4f ( #0c Audio1/pitch DEO )
@hi-hat
01 00 01 00 01 00 01 01 01 01 01 00 01 00 01 00
3c 5f ( #3c Audio2/pitch DEO )
@cymbal
01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
48 6f ( #4a Audio3/pitch DEO )
( 256 random bytes to create noise )
@noise
c1 be 88 3c e5 55 c0 a1 3a b8 8c e7 a3 40 b4 b7
fa 20 52 fd 39 88 ef 3d d0 d2 37 12 81 56 40 1e
f1 de 86 9d 2a cd ba 2c 8c b2 a3 e5 17 2a bf a3
33 e9 ab f3 3d 7c ac 00 a3 77 a7 a9 d8 10 2f af
b1 ba 68 0f 12 d3 7b e0 62 68 ef 0f 8a ea 7f b5
ad 5c 43 c6 f0 f6 29 33 9b c6 2f 24 34 41 d2 3d
16 53 27 ae b7 ba f4 53 0e 78 bf b9 16 7d 18 56
4e 95 8a e4 10 08 6c 9d bc 99 f7 ad d4 5b db f4
17 ea e3 c8 e6 67 8f 66 29 48 13 1c 9c ed 6f 26
1a 55 77 6d ee 8a d1 63 f2 88 92 17 7c fc d8 55
11 20 a8 6b 9e 48 d2 97 a2 6c dc 73 3a 82 13 f7
03 9c 25 5f 01 62 c1 f0 6e 71 aa 41 2f a7 a0 e1
78 07 c9 e5 0b 31 0c 23 00 0a c9 86 fe 2d 60 97
8b df 01 dd fe 68 5b 7e e6 28 a5 a2 5f 96 57 36
0a b4 b5 fd 21 4e ff 50 fb 00 c8 ae 25 ca 02 c9
5f b4 4b 5b f7 59 0b 08 98 52 29 81 97 85 1c 6d