2021-04-21 19:44:57 +00:00
|
|
|
( dev/audio )
|
|
|
|
|
|
|
|
%MOD { DUP2 DIV MUL SUB }
|
|
|
|
|
2021-04-23 02:57:47 +00:00
|
|
|
@timer $1
|
2021-04-21 19:46:40 +00:00
|
|
|
@progress $1
|
2021-04-21 19:44:57 +00:00
|
|
|
|
|
|
|
( devices )
|
|
|
|
|
|
|
|
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|
|
|
|
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
|
|
|
|
|30 @Audio [ &wave $2 &env $2 &pad $4 &vol $1 &pitch $1 &play $1 &value $2 &delay $2 &finish $1 ]
|
|
|
|
|
|
|
|
|0100 ( -> )
|
|
|
|
|
|
|
|
( set color pallete )
|
2021-04-23 03:44:38 +00:00
|
|
|
#00ff .System/r DEO2
|
|
|
|
#0f0f .System/g DEO2
|
|
|
|
#0ff0 .System/b DEO2
|
2021-04-21 19:44:57 +00:00
|
|
|
|
2021-04-23 03:44:38 +00:00
|
|
|
;on-frame .Screen/vector DEO2 ( run on-frame every 1/60th of a second )
|
|
|
|
#ff .Audio/vol DEO ( set volume to max )
|
|
|
|
;saw .Audio/wave DEO2 ( set waveform to saw for audio engine )
|
|
|
|
;env .Audio/env DEO2 ( set envelope for audio engine )
|
2021-04-21 19:44:57 +00:00
|
|
|
|
|
|
|
BRK
|
|
|
|
|
|
|
|
@on-frame ( -> )
|
|
|
|
|
2021-04-23 03:44:38 +00:00
|
|
|
( incr ) .timer PEK #01 ADD .timer POK
|
|
|
|
( skip ) .timer PEK #10 EQU ,&play-note JNZ BRK &play-note
|
2021-04-21 19:44:57 +00:00
|
|
|
|
|
|
|
( get note )
|
2021-04-23 03:44:38 +00:00
|
|
|
;melody #00 .progress PEK ADD2 GET
|
2021-04-21 19:44:57 +00:00
|
|
|
|
|
|
|
( play note )
|
2021-04-23 03:44:38 +00:00
|
|
|
DUP #80 ORA .Audio/pitch DEO
|
|
|
|
#01 .Audio/play DEO
|
2021-04-21 19:44:57 +00:00
|
|
|
|
|
|
|
( erase last note )
|
2021-04-23 03:44:38 +00:00
|
|
|
#20 .Screen/color DEO
|
2021-04-21 19:44:57 +00:00
|
|
|
|
|
|
|
( draw note )
|
2021-04-23 03:44:38 +00:00
|
|
|
#00 SWP #0004 MUL2 #0100 SUB2 .Screen/y DEO2
|
|
|
|
#00 .progress PEK #0008 MUL2 .Screen/x DEO2
|
|
|
|
;dot .Screen/addr DEO2
|
|
|
|
#21 .Screen/color DEO
|
2021-04-21 19:44:57 +00:00
|
|
|
|
2021-04-23 03:44:38 +00:00
|
|
|
( incr ) .progress PEK #01 ADD #20 MOD .progress POK
|
2021-04-21 19:44:57 +00:00
|
|
|
|
2021-04-23 03:44:38 +00:00
|
|
|
#00 .timer POK
|
2021-04-21 19:44:57 +00:00
|
|
|
|
|
|
|
BRK
|
|
|
|
|
|
|
|
@silence ( -> )
|
|
|
|
|
|
|
|
BRK
|
|
|
|
|
|
|
|
( defines a sawtooth wave. )
|
|
|
|
|
|
|
|
@saw ( -> )
|
|
|
|
|
2021-04-23 03:44:38 +00:00
|
|
|
#6000 .Audio/value DEO2
|
|
|
|
#0000 .Audio/delay DEO2 ( move to volume #600 after 0 delay )
|
|
|
|
#0000 .Audio/value DEO2
|
|
|
|
#ffff .Audio/delay DEO2 ( reach volume 0 after the whole note. Interpolated linearly )
|
2021-04-21 19:44:57 +00:00
|
|
|
|
|
|
|
BRK
|
|
|
|
|
|
|
|
( defines an envelope )
|
|
|
|
|
|
|
|
@env ( -> )
|
|
|
|
|
2021-04-23 03:44:38 +00:00
|
|
|
#ffff .Audio/value DEO2
|
|
|
|
#1000 .Audio/delay DEO2 ( move pretty quickly to volume #ffff (maximum) )
|
|
|
|
#0000 .Audio/value DEO2
|
|
|
|
#4000 .Audio/delay DEO2 ( interpolating linearly, move to #0000 after a delay of #4000 where #8000 is half a second )
|
|
|
|
#00 .Audio/finish DEO ( end the envelope )
|
2021-04-21 19:44:57 +00:00
|
|
|
|
|
|
|
BRK
|
|
|
|
|
2021-04-21 19:46:40 +00:00
|
|
|
( song data, #ff is used for a rest )
|
2021-04-21 19:44:57 +00:00
|
|
|
|
|
|
|
@melody [
|
|
|
|
54 52 54 4f 4b 4f 48 ff
|
|
|
|
54 52 54 4f 4b 4f 48 ff
|
|
|
|
54 56 57 56 57 54 56 54
|
|
|
|
56 52 54 52 54 50 54 ff
|
|
|
|
]
|
|
|
|
|
2021-04-21 19:46:40 +00:00
|
|
|
( dot sprite )
|
2021-04-21 19:44:57 +00:00
|
|
|
|
|
|
|
@dot [ 003c 7eff 7e3c 0000 ]
|