uxn/projects/examples/demos/drum-rack.tal

744 lines
19 KiB
Tal
Raw Normal View History

2021-05-03 22:13:12 +00:00
( drum rack
TODO
- When selecting a pad, should highlight note in octave
)
2021-05-24 21:36:15 +00:00
%+ { ADD } %- { SUB } %* { MUL } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
2021-05-04 16:10:54 +00:00
2021-05-24 21:52:11 +00:00
%2** { #10 SFT2 } %2// { #01 SFT2 }
%4** { #20 SFT2 } %4// { #02 SFT2 }
%8** { #30 SFT2 } %8// { #03 SFT2 }
2021-05-04 16:10:54 +00:00
%TOB { SWP POP } %TOS { #00 SWP }
2021-04-28 03:53:39 +00:00
%RTN { JMP2r }
2021-05-04 16:10:54 +00:00
%MOD { DUP2 / * - }
2021-05-04 17:24:00 +00:00
%LTS2 { #8000 ++ SWP2 #8000 ++ >> } %GTS2 { #8000 ++ SWP2 #8000 ++ << }
2021-04-28 03:53:39 +00:00
%PAD-WIDTH { #0030 }
%PAD-HEIGHT { #0020 }
( devices )
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|10 @Console [ &pad $8 &char $1 &byte $1 &short $2 &string $2 ]
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $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 ]
|70 @Midi [ &vector $2 &channel $1 &note $1 &velocity $1 ]
|80 @Controller [ &vector $2 &button $1 &key $1 ]
|90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &chord $1 ]
|a0 @File [ &vector $2 &success $2 &offset $2 &pad $2 &name $2 &length $2 &load $2 &save $2 ]
( variables )
|0000
2021-05-04 17:24:00 +00:00
@center [ &x $2 &y $2 ]
@pointer [ &x $2 &y $2 ]
@piano [ &last $1 &octave $1 ]
@pads [ &last $1 ]
2021-05-04 17:57:57 +00:00
@frame [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
2021-05-04 17:24:00 +00:00
@pad-view [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
@mix-view [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
@oct-view [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
@wav-view [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
( TODO: remove )
2021-04-28 03:53:39 +00:00
@color $1
2021-05-02 17:40:24 +00:00
@rect [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
2021-04-28 03:53:39 +00:00
2021-05-03 22:13:12 +00:00
@modes [ $1 $1 $1 $1 ] ( single/repeat )
2021-04-28 03:53:39 +00:00
( program )
|0100 ( -> )
( theme )
2021-05-12 18:58:31 +00:00
#0fe5 .System/r DEO2
#0fc5 .System/g DEO2
#0f25 .System/b DEO2
2021-04-28 03:53:39 +00:00
( vectors )
;on-control .Controller/vector DEO2
2021-05-04 16:10:54 +00:00
;on-mouse .Mouse/vector DEO2
;on-frame .Screen/vector DEO2
;on-midi .Midi/vector DEO2
2021-05-03 22:13:12 +00:00
2021-05-04 16:10:54 +00:00
( channel defaults )
#dd .Audio0/volume DEO
2021-05-05 03:26:39 +00:00
#0118 .Audio0/adsr DEO2
2021-05-04 18:54:01 +00:00
#0200 .Audio0/length DEO2
2021-05-04 16:10:54 +00:00
#ce .Audio1/volume DEO
2021-05-05 03:26:39 +00:00
#0334 .Audio1/adsr DEO2
2021-05-03 22:13:12 +00:00
#0800 .Audio1/length DEO2
2021-05-04 16:10:54 +00:00
#ec .Audio2/volume DEO
#0414 .Audio2/adsr DEO2
2021-05-03 22:13:12 +00:00
#0800 .Audio2/length DEO2
2021-05-04 16:10:54 +00:00
#ee .Audio3/volume DEO
#022c .Audio3/adsr DEO2
2021-05-03 22:13:12 +00:00
#1000 .Audio3/length DEO2
2021-05-04 16:10:54 +00:00
( defaults )
2021-05-11 18:14:52 +00:00
#01 .modes STZ
#01 .piano/octave STZ
2021-04-28 03:53:39 +00:00
( find center )
2021-05-24 21:52:11 +00:00
.Screen/width DEI2 2// .center/x STZ2
.Screen/height DEI2 2// .center/y STZ2
2021-04-28 03:53:39 +00:00
2021-05-03 16:57:39 +00:00
( place frame )
2021-05-11 18:14:52 +00:00
.center/x LDZ2 PAD-WIDTH #0003 ** -- #0010 -- .frame/x1 STZ2
.center/y LDZ2 #0050 -- .frame/y1 STZ2
.center/x LDZ2 PAD-WIDTH #0003 ** ++ #0010 ++ .frame/x2 STZ2
2021-05-24 21:52:11 +00:00
.frame/y1 LDZ2 PAD-HEIGHT 4** ++ #0028 ++ .frame/y2 STZ2
2021-05-03 22:13:12 +00:00
( place pad-view )
2021-05-11 18:14:52 +00:00
.frame/x1 LDZ2 .pad-view/x1 STZ2
.frame/y1 LDZ2 .pad-view/y1 STZ2
.pad-view/x1 LDZ2 #0004 PAD-WIDTH ** ++ .pad-view/x2 STZ2
.pad-view/y1 LDZ2 #0004 PAD-HEIGHT ** ++ .pad-view/y2 STZ2
2021-05-03 22:13:12 +00:00
( place mix-view )
2021-05-11 18:14:52 +00:00
.pad-view/x2 LDZ2 #0006 ++ .mix-view/x1 STZ2
.pad-view/y1 LDZ2 .mix-view/y1 STZ2
.mix-view/x1 LDZ2 #007a ++ .mix-view/x2 STZ2
.pad-view/y2 LDZ2 .mix-view/y2 STZ2
2021-05-03 22:13:12 +00:00
( place oct-view )
2021-05-11 18:14:52 +00:00
.frame/x1 LDZ2 .oct-view/x1 STZ2
.mix-view/y2 LDZ2 #0004 ++ .oct-view/y1 STZ2
.oct-view/x1 LDZ2 #0050 ++ .oct-view/x2 STZ2
.oct-view/y1 LDZ2 #0018 ++ .oct-view/y2 STZ2
2021-05-03 22:13:12 +00:00
( place wav-view )
2021-05-11 18:14:52 +00:00
.oct-view/x2 LDZ2 .wav-view/x1 STZ2
.mix-view/y2 LDZ2 #0004 ++ .wav-view/y1 STZ2
.frame/x2 LDZ2 .wav-view/x2 STZ2
.wav-view/y1 LDZ2 #0020 ++ .wav-view/y2 STZ2
2021-05-04 16:10:54 +00:00
( draw outlines )
2021-05-11 18:14:52 +00:00
.mix-view/x1 LDZ2 #0004 --
.mix-view/y1 LDZ2 #0000 --
.mix-view/x2 LDZ2 #0002 --
.mix-view/y2 LDZ2 #0002 --
2021-05-04 16:10:54 +00:00
#01 ;line-rect JSR2
2021-05-11 18:14:52 +00:00
.wav-view/x1 LDZ2 #0000 --
.wav-view/y1 LDZ2 #0002 --
.wav-view/x2 LDZ2 #0002 --
.wav-view/y2 LDZ2 #0002 ++
2021-05-04 16:10:54 +00:00
#01 ;line-rect JSR2
( initial draw )
#00 #10
&draw-pads
2021-05-04 17:57:57 +00:00
( load sample )
OVR TOS #0019 ** ;pad-path ++ .File/name DEO2
OVR #04 / #10 * .Audio0/length + DEI2 .File/length DEO2
2021-05-24 21:52:11 +00:00
OVR TOS 2** ;pad-addr ++ LDA2 .File/load DEO2
2021-05-04 17:57:57 +00:00
( draw pad )
2021-05-04 16:10:54 +00:00
OVR #01 ;draw-pad JSR2
2021-05-04 17:57:57 +00:00
( draw mixer )
OVR #04 / ;draw-mixer JSR2
( incr ) SWP #01 + SWP
2021-05-12 18:58:31 +00:00
LTHk ,&draw-pads JCN
2021-05-04 16:10:54 +00:00
POP2
2021-05-02 17:40:24 +00:00
2021-05-04 16:10:54 +00:00
;draw-octave JSR2
2021-04-28 03:53:39 +00:00
BRK
@on-frame ( -> )
2021-05-03 23:26:41 +00:00
( update VU monitors )
#00 #04
&loop
OVR STH
2021-05-11 18:14:52 +00:00
( x ) .mix-view/x1 LDZ2 #0074 ++
2021-05-13 01:28:45 +00:00
( y ) .mix-view/y1 LDZ2 PAD-HEIGHT STHkr TOS ** ++ #0002 ++
2021-05-04 16:10:54 +00:00
( output ) .Audio0/output STHr #10 * + DEI
2021-05-03 23:26:41 +00:00
;draw-monitor JSR2
2021-05-04 16:10:54 +00:00
( incr ) SWP #01 + SWP
2021-05-12 18:58:31 +00:00
LTHk ,&loop JCN
2021-05-03 23:26:41 +00:00
POP2
2021-04-28 03:53:39 +00:00
BRK
@on-mouse ( -> )
;draw-cursor JSR2
2021-05-11 18:12:07 +00:00
.Mouse/state DEI #00 ! #01 JCN [ BRK ]
2021-04-28 03:53:39 +00:00
2021-05-11 18:14:52 +00:00
.Mouse/x DEI2 DUP2 .pad-view/x1 LDZ2 >> ROT ROT .pad-view/x2 LDZ2 #0001 ++ << #0101 ==
.Mouse/y DEI2 DUP2 .pad-view/y1 LDZ2 >> ROT ROT .pad-view/y2 LDZ2 << #0101 ==
2021-05-11 18:12:07 +00:00
#0101 == ;on-touch-pad JCN2
2021-04-28 03:53:39 +00:00
2021-05-11 18:14:52 +00:00
.Mouse/x DEI2 DUP2 .mix-view/x1 LDZ2 >> ROT ROT .mix-view/x2 LDZ2 #0001 ++ << #0101 ==
.Mouse/y DEI2 DUP2 .mix-view/y1 LDZ2 >> ROT ROT .mix-view/y2 LDZ2 << #0101 ==
2021-05-11 18:12:07 +00:00
#0101 == ;on-touch-mix JCN2
2021-05-03 22:13:12 +00:00
2021-05-11 18:14:52 +00:00
.Mouse/x DEI2 DUP2 .oct-view/x1 LDZ2 >> ROT ROT .oct-view/x2 LDZ2 #0001 ++ << #0101 ==
.Mouse/y DEI2 DUP2 .oct-view/y1 LDZ2 >> ROT ROT .oct-view/y2 LDZ2 << #0101 ==
2021-05-11 18:12:07 +00:00
#0101 == ;on-touch-oct JCN2
2021-05-03 22:13:12 +00:00
2021-04-28 03:53:39 +00:00
BRK
@on-midi ( -> )
2021-05-11 18:12:07 +00:00
.Midi/note DEI #00 ! #01 JCN [ BRK ]
2021-04-28 03:53:39 +00:00
2021-05-04 16:10:54 +00:00
( drums )
2021-05-11 18:12:07 +00:00
.Midi/channel DEI #90 ! ,&no-drum JCN
2021-05-04 16:10:54 +00:00
.Midi/note DEI #10 MOD ;play-pad JSR2
2021-04-28 03:53:39 +00:00
BRK
&no-drum
2021-05-04 16:10:54 +00:00
( TODO: synths )
;pad-addr #0008 ++ LDA2 .Audio0/addr DEO2
2021-04-28 03:53:39 +00:00
#0008 .Audio0/length DEO2
.Midi/note DEI .Audio0/pitch DEO
BRK
@on-control ( -> )
2021-05-11 18:12:07 +00:00
.Controller/key DEI #00 ! #01 JCN [ BRK ]
2021-04-28 03:53:39 +00:00
.Controller/key DEI
2021-05-11 18:12:07 +00:00
DUP #31 ! ,&no-0 JCN #00 ;play-pad JSR2 &no-0
DUP #32 ! ,&no-1 JCN #01 ;play-pad JSR2 &no-1
DUP #33 ! ,&no-2 JCN #02 ;play-pad JSR2 &no-2
DUP #34 ! ,&no-3 JCN #03 ;play-pad JSR2 &no-3
DUP #71 ! ,&no-4 JCN #04 ;play-pad JSR2 &no-4
DUP #77 ! ,&no-5 JCN #05 ;play-pad JSR2 &no-5
DUP #65 ! ,&no-6 JCN #06 ;play-pad JSR2 &no-6
DUP #72 ! ,&no-7 JCN #07 ;play-pad JSR2 &no-7
DUP #61 ! ,&no-8 JCN #08 ;play-pad JSR2 &no-8
DUP #73 ! ,&no-9 JCN #09 ;play-pad JSR2 &no-9
DUP #64 ! ,&no-a JCN #0a ;play-pad JSR2 &no-a
DUP #66 ! ,&no-b JCN #0b ;play-pad JSR2 &no-b
DUP #7a ! ,&no-c JCN #0c ;play-pad JSR2 &no-c
DUP #78 ! ,&no-d JCN #0d ;play-pad JSR2 &no-d
DUP #63 ! ,&no-e JCN #0e ;play-pad JSR2 &no-e
DUP #76 ! ,&no-f JCN #0f ;play-pad JSR2 &no-f
2021-04-28 03:53:39 +00:00
POP
BRK
2021-05-02 17:40:24 +00:00
@on-touch-pad ( -> )
2021-05-11 18:14:52 +00:00
( x ) .Mouse/x DEI2 .pad-view/x1 LDZ2 -- PAD-WIDTH // TOB
( y ) .Mouse/y DEI2 .pad-view/y1 LDZ2 -- PAD-HEIGHT // TOB #04 * +
2021-05-03 16:57:39 +00:00
2021-05-03 22:13:12 +00:00
DUP SWP ;play-pad JSR2
2021-05-02 17:40:24 +00:00
2021-05-03 22:13:12 +00:00
;draw-waveform JSR2
( release ) #00 .Mouse/state DEO
2021-05-02 17:40:24 +00:00
2021-05-03 22:13:12 +00:00
BRK
@on-touch-mix ( -> )
2021-05-11 18:14:52 +00:00
( channel ) .Mouse/y DEI2 .mix-view/y1 LDZ2 -- PAD-HEIGHT // TOB STH
( knob ) .Mouse/x DEI2 .mix-view/x1 LDZ2 -- #0010 // TOB
2021-05-04 17:24:00 +00:00
( adsr )
2021-05-11 18:12:07 +00:00
DUP #00 ! ,&no-a JCN
2021-05-13 01:28:45 +00:00
.Audio0/adsr [ STHkr #10 * + ] DEI
2021-05-04 16:10:54 +00:00
#10 .Mouse/state DEI #10 = #e0 * + +
2021-05-13 01:28:45 +00:00
.Audio0/adsr [ STHkr #10 * + ] DEO &no-a
2021-05-11 18:12:07 +00:00
DUP #01 ! ,&no-d JCN
2021-05-13 01:28:45 +00:00
.Audio0/adsr [ STHkr #10 * + ] DEI
2021-05-04 16:10:54 +00:00
DUP #f0 AND STH #01 .Mouse/state DEI #10 = #0e * + + #0f AND STHr +
2021-05-13 01:28:45 +00:00
.Audio0/adsr [ STHkr #10 * + ] DEO &no-d
2021-05-11 18:12:07 +00:00
DUP #02 ! ,&no-s JCN
2021-05-13 01:28:45 +00:00
.Audio0/adsr [ STHkr #10 * + ] #01 + DEI
2021-05-04 16:10:54 +00:00
#10 .Mouse/state DEI #10 = #e0 * + +
2021-05-13 01:28:45 +00:00
.Audio0/adsr [ STHkr #10 * + ] #01 + DEO &no-s
2021-05-11 18:12:07 +00:00
DUP #03 ! ,&no-r JCN
2021-05-13 01:28:45 +00:00
.Audio0/adsr [ STHkr #10 * + ] #01 + DEI
2021-05-04 16:10:54 +00:00
DUP #f0 AND STH #01 .Mouse/state DEI #10 = #0e * + + #0f AND STHr +
2021-05-13 01:28:45 +00:00
.Audio0/adsr [ STHkr #10 * + ] #01 + DEO &no-r
2021-05-04 17:24:00 +00:00
( modes )
2021-05-11 18:12:07 +00:00
DUP #04 ! ,&no-repeat JCN
2021-05-13 01:28:45 +00:00
.modes [ STHkr + ] LDZ
2021-05-04 16:10:54 +00:00
#00 =
2021-05-13 01:28:45 +00:00
.modes [ STHkr + ] STZ &no-repeat
2021-05-04 17:24:00 +00:00
( volume )
2021-05-11 18:12:07 +00:00
DUP #05 ! ,&no-left JCN
2021-05-13 01:28:45 +00:00
.Audio0/volume [ STHkr #10 * + ] DEI
2021-05-04 16:10:54 +00:00
#10 .Mouse/state DEI #10 = #e0 * + +
2021-05-13 01:28:45 +00:00
.Audio0/volume [ STHkr #10 * + ] DEO &no-left
2021-05-11 18:12:07 +00:00
DUP #06 ! ,&no-right JCN
2021-05-13 01:28:45 +00:00
.Audio0/volume [ STHkr #10 * + ] DEI
2021-05-04 16:10:54 +00:00
DUP #f0 AND STH #01 .Mouse/state DEI #10 = #0e * + + #0f AND STHr +
2021-05-13 01:28:45 +00:00
.Audio0/volume [ STHkr #10 * + ] DEO &no-right
2021-05-03 16:57:39 +00:00
POP
2021-05-03 22:13:12 +00:00
2021-05-02 17:40:24 +00:00
( release ) #00 .Mouse/state DEO
2021-05-13 01:28:45 +00:00
STHkr ;draw-mixer JSR2
2021-05-03 22:13:12 +00:00
POPr
BRK
@on-touch-oct ( -> )
2021-05-24 21:52:11 +00:00
.Mouse/x DEI2 .oct-view/x1 LDZ2 -- 8// TOB #08 ! ,&no-mod JCN
.Mouse/y DEI2 .oct-view/y1 LDZ2 -- 8// TOB
2021-05-11 18:12:07 +00:00
DUP #00 ! ,&no-incr JCN
2021-05-11 18:14:52 +00:00
.piano/octave LDZ #01 + .piano/octave STZ &no-incr
2021-05-11 18:12:07 +00:00
DUP #02 ! ,&no-decr JCN
2021-05-11 18:14:52 +00:00
.piano/octave LDZ #01 - .piano/octave STZ &no-decr
2021-05-03 22:13:12 +00:00
POP
( release ) #00 .Mouse/state DEO
;draw-octave JSR2
BRK
&no-mod
2021-05-24 21:52:11 +00:00
.Mouse/x DEI2 .oct-view/x1 LDZ2 -- 8// TOB #06 GTH ,&no-key JCN
.Mouse/x DEI2 .oct-view/x1 LDZ2 -- 8//
2021-05-03 22:13:12 +00:00
( set pitch of pad )
2021-05-11 18:14:52 +00:00
DUP2 ;notes ++ LDA .pads/last LDZ SWP .piano/octave LDZ #02 - #0c * +
2021-05-04 17:24:00 +00:00
( save ) SWP TOS ;pad-pitch ++ STA
2021-05-03 22:13:12 +00:00
( record last note )
2021-05-11 18:14:52 +00:00
TOB .piano/last STZ
.pads/last LDZ ;play-pad JSR2
2021-05-03 22:13:12 +00:00
( release ) #00 .Mouse/state DEO
;draw-octave JSR2
&no-key
2021-05-02 17:40:24 +00:00
BRK
2021-04-28 03:53:39 +00:00
@play-pad ( note pad -- )
2021-05-03 22:13:12 +00:00
( unselect last )
2021-05-11 18:14:52 +00:00
.pads/last LDZ #01 ;draw-pad JSR2
DUP .pads/last STZ
2021-04-28 03:53:39 +00:00
( highlight )
2021-05-03 22:13:12 +00:00
DUP #02 ;draw-pad JSR2
2021-04-28 03:53:39 +00:00
( addr )
2021-05-24 21:52:11 +00:00
DUP TOS 2** ;pad-addr ++ LDA2 STH2
2021-05-04 16:10:54 +00:00
DUP #04 / #10 * .Audio0/addr + STH2r ROT DEO2
2021-04-28 03:53:39 +00:00
( pitch )
2021-05-04 16:10:54 +00:00
DUP TOS ;pad-pitch ++ LDA STH
2021-05-11 18:14:52 +00:00
DUP #04 / .modes + LDZ #00 = #80 * STH ADDr
2021-05-04 16:10:54 +00:00
DUP #04 / #10 * .Audio0/pitch + STHr SWP DEO
#04 / ;draw-mixer JSR2
2021-04-28 03:53:39 +00:00
RTN
2021-05-03 16:57:39 +00:00
@draw-waveform ( pad -- )
2021-05-04 17:24:00 +00:00
( stash address )
2021-05-04 16:10:54 +00:00
#02 * #00 SWP ;pad-addr ++ LDA2 STH2
2021-05-03 16:57:39 +00:00
2021-05-04 17:24:00 +00:00
( clear )
2021-05-11 18:14:52 +00:00
.wav-view/x1 LDZ2 #0002 ++
.wav-view/y1 LDZ2
.wav-view/x2 LDZ2 #0002 --
.wav-view/y2 LDZ2
2021-05-03 16:57:39 +00:00
#00 ;fill-rect JSR2
2021-05-11 18:14:52 +00:00
.wav-view/x1 LDZ2 #0002 ++ .Screen/x DEO2
2021-05-03 16:57:39 +00:00
( waveform )
2021-05-03 23:26:41 +00:00
#00 #e8
2021-05-03 16:57:39 +00:00
&loop
( dotted line )
2021-05-11 18:12:07 +00:00
OVR #01 AND ,&no-dot JCN
2021-05-11 18:14:52 +00:00
.wav-view/y1 LDZ2 #0010 ++ .Screen/y DEO2
2021-05-03 22:13:12 +00:00
#01 .Screen/color DEO
2021-05-03 16:57:39 +00:00
&no-dot
2021-05-04 16:10:54 +00:00
OVR TOS #0010 ** [ DUP2r STH2r ] ++ LDA
#02 /
2021-05-24 21:52:11 +00:00
TOS 4// .wav-view/y1 LDZ2 ++ .Screen/y DEO2
2021-05-04 16:10:54 +00:00
.Screen/x DEI2 #0001 ++ .Screen/x DEO2
2021-05-03 22:13:12 +00:00
( draw ) #02 .Screen/color DEO
2021-05-04 16:10:54 +00:00
( incr ) SWP #01 + SWP
2021-05-12 18:58:31 +00:00
LTHk ,&loop JCN
2021-05-03 16:57:39 +00:00
POP2
POP2r
RTN
2021-04-28 03:53:39 +00:00
@draw-mixer ( mixer -- )
2021-05-11 18:14:52 +00:00
DUP STH #00 SWP PAD-HEIGHT ** .mix-view/y1 LDZ2 ++ #0003 ++
2021-05-02 17:40:24 +00:00
( adsr )
2021-05-11 18:14:52 +00:00
DUP2 .mix-view/x1 LDZ2 SWP2
2021-05-13 01:28:45 +00:00
.Audio0/adsr [ STHkr #10 * + ] DEI #04 SFT ;draw-knob JSR2
2021-05-11 18:14:52 +00:00
DUP2 .mix-view/x1 LDZ2 #0010 ++ SWP2
2021-05-13 01:28:45 +00:00
.Audio0/adsr [ STHkr #10 * + ] DEI #0f AND ;draw-knob JSR2
2021-05-11 18:14:52 +00:00
DUP2 .mix-view/x1 LDZ2 #0020 ++ SWP2
2021-05-13 01:28:45 +00:00
.Audio0/adsr [ STHkr #10 * + ] #01 + DEI #04 SFT ;draw-knob JSR2
2021-05-11 18:14:52 +00:00
DUP2 .mix-view/x1 LDZ2 #0030 ++ SWP2
2021-05-13 01:28:45 +00:00
.Audio0/adsr [ STHkr #10 * + ] #01 + DEI #0f AND ;draw-knob JSR2
2021-05-03 22:13:12 +00:00
( once/repeat )
2021-05-11 18:14:52 +00:00
DUP2 .mix-view/x1 LDZ2 #0040 ++ SWP2
2021-05-13 01:28:45 +00:00
.modes [ STHkr + ] LDZ ;draw-switch JSR2
2021-05-02 17:40:24 +00:00
( volume )
2021-05-11 18:14:52 +00:00
DUP2 .mix-view/x1 LDZ2 #0050 ++ SWP2
2021-05-13 01:28:45 +00:00
.Audio0/volume [ STHkr #10 * + ] DEI #04 SFT ;draw-knob JSR2
2021-05-11 18:14:52 +00:00
DUP2 .mix-view/x1 LDZ2 #0060 ++ SWP2
2021-05-13 01:28:45 +00:00
.Audio0/volume [ STHkr #10 * + ] DEI #0f AND ;draw-knob JSR2
2021-05-03 22:13:12 +00:00
POP2
POPr
2021-05-02 17:40:24 +00:00
RTN
2021-04-28 03:53:39 +00:00
@draw-pad ( pad color -- )
STH STH
2021-05-13 01:28:45 +00:00
STHkr
2021-04-28 03:53:39 +00:00
2021-05-11 18:14:52 +00:00
DUP #04 / SWP #04 MOD TOS PAD-WIDTH ** ( center ) .pad-view/x1 LDZ2 ++
ROT TOS PAD-HEIGHT ** ( center ) .pad-view/y1 LDZ2 ++
2021-04-28 03:53:39 +00:00
( draw outline )
OVR2 OVR2
2021-05-04 16:10:54 +00:00
OVR2 PAD-WIDTH #0002 -- ++
OVR2 PAD-HEIGHT #0002 -- ++
2021-04-28 03:53:39 +00:00
OVRr STHr ;line-rect JSR2
( draw name )
2021-05-04 16:10:54 +00:00
OVR2 #0002 ++
OVR2 #0002 ++
2021-05-13 01:28:45 +00:00
;pad-name STHkr TOS #0005 ** ++
2021-05-04 17:24:00 +00:00
#20 OVRr STHr +
;draw-label JSR2
2021-04-28 03:53:39 +00:00
2021-05-03 22:13:12 +00:00
( draw note )
2021-05-04 16:10:54 +00:00
OVR2 #0003 ++ .Screen/x DEO2
DUP2 #0014 ++ .Screen/y DEO2
2021-05-13 01:28:45 +00:00
( get pitch ) STHkr TOS ;pad-pitch ++ LDA
2021-05-24 21:52:11 +00:00
#0c / TOS 8** ;font-hex ++ .Screen/addr DEO2
2021-05-03 22:13:12 +00:00
#21 .Screen/color DEO
( draw octave )
2021-05-04 16:10:54 +00:00
OVR2 #000b ++ .Screen/x DEO2
DUP2 #0014 ++ .Screen/y DEO2
2021-05-13 01:28:45 +00:00
( get pitch ) STHkr TOS ;pad-pitch ++ LDA
2021-05-24 21:52:11 +00:00
#0c MOD TOS 8** ;font-notes ++ .Screen/addr DEO2
2021-05-03 22:13:12 +00:00
#21 .Screen/color DEO
2021-04-28 03:53:39 +00:00
POP2 POP2
POPr POPr
RTN
2021-05-03 22:13:12 +00:00
@draw-octave ( -- )
2021-05-11 18:14:52 +00:00
.oct-view/x1 LDZ2 .oct-view/y1 LDZ2
2021-05-03 22:13:12 +00:00
2021-05-11 18:14:52 +00:00
OVR2 OVR2 ;keys-left-icns #21 .piano/last LDZ #00 = + ;draw-key JSR2
OVR2 #0008 ++ OVR2 ;keys-middle-icns #21 .piano/last LDZ #01 = + ;draw-key JSR2
OVR2 #0010 ++ OVR2 ;keys-right-icns #21 .piano/last LDZ #02 = + ;draw-key JSR2
OVR2 #0018 ++ OVR2 ;keys-left-icns #21 .piano/last LDZ #03 = + ;draw-key JSR2
OVR2 #0020 ++ OVR2 ;keys-middle-icns #21 .piano/last LDZ #04 = + ;draw-key JSR2
OVR2 #0028 ++ OVR2 ;keys-middle-icns #21 .piano/last LDZ #05 = + ;draw-key JSR2
SWP2 #0030 ++ SWP2 ;keys-right-icns #21 .piano/last LDZ #06 = + ;draw-key JSR2
2021-05-03 22:13:12 +00:00
2021-05-11 18:14:52 +00:00
.oct-view/x1 LDZ2 #0040 ++ .Screen/x DEO2
2021-05-03 22:13:12 +00:00
;arrow-icns .Screen/addr DEO2
2021-05-11 18:14:52 +00:00
.oct-view/y1 LDZ2 .Screen/y DEO2
2021-05-03 22:13:12 +00:00
#21 .Screen/color DEO
2021-05-04 16:10:54 +00:00
;arrow-icns #0008 ++ .Screen/addr DEO2
2021-05-11 18:14:52 +00:00
.oct-view/y1 LDZ2 #0010 ++ .Screen/y DEO2
2021-05-03 22:13:12 +00:00
#21 .Screen/color DEO
2021-05-24 21:52:11 +00:00
;font-hex .piano/octave LDZ #03 + #00 SWP 8** ++ .Screen/addr DEO2
2021-05-11 18:14:52 +00:00
.oct-view/y1 LDZ2 #0008 ++ .Screen/y DEO2
2021-05-03 22:13:12 +00:00
#23 .Screen/color DEO
RTN
2021-05-03 23:26:41 +00:00
@draw-monitor ( x* y* stereo -- )
STH
.Screen/y DEO2
.Screen/x DEO2
#00 #0f
&loop
2021-05-13 01:28:45 +00:00
OVR #10 SWP - STHkr #0f AND < #01 + .Screen/color DEO
2021-05-04 16:10:54 +00:00
.Screen/x DEI2 #0002 ++ .Screen/x DEO2
2021-05-13 01:28:45 +00:00
OVR #10 SWP - STHkr #04 SFT < #01 + .Screen/color DEO
2021-05-04 16:10:54 +00:00
.Screen/x DEI2 #0002 -- .Screen/x DEO2
.Screen/y DEI2 #0002 ++ .Screen/y DEO2
( incr ) SWP #01 + SWP
2021-05-12 18:58:31 +00:00
LTHk ,&loop JCN
2021-05-03 23:26:41 +00:00
POP2
POPr
RTN
2021-05-03 22:13:12 +00:00
@draw-key ( x* y* addr* color -- )
STH
.Screen/addr DEO2
SWP2 .Screen/x DEO2
2021-05-04 16:10:54 +00:00
DUP2 #0018 ++
2021-05-03 22:13:12 +00:00
&loop
( move ) OVR2 .Screen/y DEO2
2021-05-13 01:28:45 +00:00
( draw ) STHkr .Screen/color DEO
2021-05-04 16:10:54 +00:00
( incr ) .Screen/addr DEI2 #0008 ++ .Screen/addr DEO2
( incr ) SWP2 #0008 ++ SWP2
2021-05-12 18:58:31 +00:00
LTH2k ,&loop JCN
2021-05-03 22:13:12 +00:00
POP2 POP2
POPr
RTN
2021-04-28 03:53:39 +00:00
@draw-cursor ( -- )
( clear last cursor )
2021-05-06 17:38:38 +00:00
;cursor-icn .Screen/addr DEO2
2021-05-11 18:14:52 +00:00
.pointer/x LDZ2 .Screen/x DEO2
.pointer/y LDZ2 .Screen/y DEO2
2021-04-28 03:53:39 +00:00
#30 .Screen/color DEO
( record pointer positions )
2021-05-11 18:14:52 +00:00
.Mouse/x DEI2 .pointer/x STZ2
.Mouse/y DEI2 .pointer/y STZ2
2021-04-28 03:53:39 +00:00
( draw new cursor )
2021-05-11 18:14:52 +00:00
.pointer/x LDZ2 .Screen/x DEO2
.pointer/y LDZ2 .Screen/y DEO2
2021-04-28 03:53:39 +00:00
( colorize on state )
2021-05-04 16:10:54 +00:00
#33 [ .Mouse/state DEI #00 ! ] - .Screen/color DEO
2021-04-28 03:53:39 +00:00
RTN
2021-05-04 17:24:00 +00:00
@draw-knob ( x* y* value -- )
( load ) STH .Screen/y DEO2 .Screen/x DEO2
;knob-icns .Screen/addr DEO2
( draw ) #21 .Screen/color DEO
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
;knob-icns #0008 ++ .Screen/addr DEO2
( draw ) #21 .Screen/color DEO
.Screen/y DEI2 #0008 ++ .Screen/y DEO2
;knob-icns #0018 ++ .Screen/addr DEO2
( draw ) #21 .Screen/color DEO
.Screen/x DEI2 #0008 -- .Screen/x DEO2
;knob-icns #0010 ++ .Screen/addr DEO2
( draw ) #21 .Screen/color DEO
.Screen/x DEI2 #0004 ++ .Screen/x DEO2
.Screen/y DEI2 #0008 ++ .Screen/y DEO2
2021-05-13 01:28:45 +00:00
;font-hex #00 STHkr #08 * ++ .Screen/addr DEO2
2021-05-04 17:24:00 +00:00
( draw ) #21 .Screen/color DEO
2021-05-13 01:28:45 +00:00
.Screen/x DEI2 #0004 -- #00 #00 STHkr ;knob-offsetx ++ LDA ++ .Screen/x DEO2
2021-05-04 17:24:00 +00:00
.Screen/y DEI2 #0010 -- #00 #00 STHr ;knob-offsety ++ LDA ++ .Screen/y DEO2
;knob-icns #0020 ++ .Screen/addr DEO2
( draw ) #25 .Screen/color DEO
RTN
@draw-switch ( x* y* value -- )
STH .Screen/y DEO2 .Screen/x DEO2
2021-05-13 01:28:45 +00:00
STHkr #20 * #00 SWP ;switch-icns ++
2021-05-04 17:24:00 +00:00
DUP2 .Screen/addr DEO2
2021-05-13 01:28:45 +00:00
( draw ) #21 STHkr + .Screen/color DEO
2021-05-04 17:24:00 +00:00
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
DUP2 #0008 ++ .Screen/addr DEO2
2021-05-13 01:28:45 +00:00
( draw ) #21 STHkr + .Screen/color DEO
2021-05-04 17:24:00 +00:00
.Screen/y DEI2 #0008 ++ .Screen/y DEO2
.Screen/x DEI2 #0008 -- .Screen/x DEO2
DUP2 #0010 ++ .Screen/addr DEO2
2021-05-13 01:28:45 +00:00
( draw ) #21 STHkr + .Screen/color DEO
2021-05-04 17:24:00 +00:00
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
#0018 ++ .Screen/addr DEO2
( draw ) #21 STHr + .Screen/color DEO
RTN
@line-rect ( x1* y1* x2* y2* color -- )
2021-04-28 03:53:39 +00:00
2021-05-11 18:14:52 +00:00
( load ) .color STZ DUP2 STH2 .rect/y2 STZ2 .rect/x2 STZ2 DUP2 STH2 .rect/y1 STZ2 .rect/x1 STZ2
2021-05-04 16:10:54 +00:00
STH2r #0001 ++ STH2r
2021-04-28 03:53:39 +00:00
&ver
( save ) OVR2 .Screen/y DEO2
2021-05-11 18:14:52 +00:00
( draw ) .rect/x1 LDZ2 .Screen/x DEO2 .color LDZ DUP .Screen/color DEO
( draw ) .rect/x2 LDZ2 .Screen/x DEO2 .Screen/color DEO
2021-05-04 16:10:54 +00:00
( incr ) SWP2 #0001 ++ SWP2
2021-05-11 18:12:07 +00:00
OVR2 OVR2 LTS2 ,&ver JCN
2021-04-28 03:53:39 +00:00
POP2 POP2
2021-05-11 18:14:52 +00:00
.rect/x1 LDZ2 #0001 ++ .rect/x2 LDZ2 #0001 --
2021-04-28 03:53:39 +00:00
&hor
( save ) OVR2 .Screen/x DEO2
2021-05-11 18:14:52 +00:00
( draw ) .rect/y1 LDZ2 .Screen/y DEO2 .color LDZ DUP .Screen/color DEO
( draw ) .rect/y2 LDZ2 .Screen/y DEO2 .Screen/color DEO
2021-05-04 16:10:54 +00:00
( incr ) SWP2 #0001 ++ SWP2
2021-05-11 18:12:07 +00:00
OVR2 OVR2 #0001 ++ LTS2 ,&hor JCN
2021-04-28 03:53:39 +00:00
POP2 POP2
RTN
2021-05-04 17:24:00 +00:00
@draw-label ( x* y* addr* color -- )
2021-04-28 03:53:39 +00:00
2021-05-04 17:24:00 +00:00
( load ) STH STH2 .Screen/y DEO2 .Screen/x DEO2
STH2r
2021-04-28 03:53:39 +00:00
&loop
2021-05-24 21:52:11 +00:00
DUP2 LDA #00 SWP #0030 -- 8** ;font-num-uc ++ .Screen/addr DEO2
2021-05-13 01:28:45 +00:00
( draw ) STHkr .Screen/color DEO
2021-05-04 16:10:54 +00:00
( incr ) #0001 ++
( incr ) .Screen/x DEI2 #0008 ++ .Screen/x DEO2
2021-05-11 18:12:07 +00:00
DUP2 LDA #00 ! ,&loop JCN
2021-04-28 03:53:39 +00:00
POP2
2021-05-04 17:24:00 +00:00
POPr
2021-04-28 03:53:39 +00:00
RTN
2021-05-03 16:57:39 +00:00
@fill-rect ( x1* y1* x2* y2* color -- )
2021-05-11 18:14:52 +00:00
.color STZ
2021-05-03 16:57:39 +00:00
( x1 x2 y1 y2 ) ROT2 SWP2
&ver
( save ) OVR2 .Screen/y DEO2
STH2 STH2 OVR2 OVR2
&hor
( save ) OVR2 .Screen/x DEO2
2021-05-11 18:14:52 +00:00
( draw ) .color LDZ .Screen/color DEO
2021-05-04 16:10:54 +00:00
( incr ) SWP2 #0001 ++ SWP2
2021-05-11 18:12:07 +00:00
OVR2 OVR2 LTS2 ,&hor JCN
2021-05-03 16:57:39 +00:00
POP2 POP2 STH2r STH2r
2021-05-04 16:10:54 +00:00
( incr ) SWP2 #0001 ++ SWP2
2021-05-11 18:12:07 +00:00
OVR2 OVR2 LTS2 ,&ver JCN
2021-05-03 16:57:39 +00:00
POP2 POP2 POP2 POP2
RTN
2021-04-28 03:53:39 +00:00
@pad-name [
"PAD1 $1 "SYN1 $1 "SYN2 $1 "CYM1 $1 ( short )
"HHAT $1 "OHAT $1 "CHAT $1 "RIDE $1
"SID1 $1 "SNR1 $1 "SNR2 $1 "SID2 $1 ( long )
2021-05-03 22:13:12 +00:00
"BDR1 $1 "KCK1 $1 "KCK2 $1 "SUB1 $1 ]
2021-04-28 03:53:39 +00:00
@pad-addr [
2021-05-04 18:54:01 +00:00
6000 6400 6800 6c00
2021-04-28 03:53:39 +00:00
7000 7800 8000 8800
2021-05-04 18:54:01 +00:00
9000 9800 a000 a800
b000 c000 d000 e000 $2 ]
2021-04-28 03:53:39 +00:00
2021-05-03 22:13:12 +00:00
@pad-pitch [
30 30 30 30
30 30 30 30
30 30 30 30
30 30 30 30 ]
2021-04-28 03:53:39 +00:00
@pad-path [
2021-05-05 03:26:39 +00:00
"projects/sounds/pad1.pcm $1 "projects/sounds/syn1.pcm $1 "projects/sounds/syn2.pcm $1 "projects/sounds/pad2.pcm $1
"projects/sounds/hhat.pcm $1 "projects/sounds/ohat.pcm $1 "projects/sounds/chat.pcm $1 "projects/sounds/ride.pcm $1
"projects/sounds/sid1.pcm $1 "projects/sounds/snr1.pcm $1 "projects/sounds/snr2.pcm $1 "projects/sounds/sid2.pcm $1
"projects/sounds/bdr1.pcm $1 "projects/sounds/kck1.pcm $1 "projects/sounds/kck2.pcm $1 "projects/sounds/sub1.pcm $1 ]
2021-05-03 22:13:12 +00:00
@notes [
3c 3e 40 41 43 45 47
48 4a 4c 4d 4f 51 53 ]
@cursor-icn [
80c0 e0f0 f8e0 1000 ]
@keys-left-icns [
7c7c 7c7c 7c7c 7c7c
7c7c 7c7c 7c7c 7e7f
7f7f 7f7f 7f7f 3e00 ]
@keys-middle-icns [
1c1c 1c1c 1c1c 1c1c
1c1c 1c1c 1c1c 3e7f
7f7f 7f7f 7f7f 3e00 ]
@keys-right-icns [
1f1f 1f1f 1f1f 1f1f
1f1f 1f1f 1f1f 3f7f
7f7f 7f7f 7f7f 3e00 ]
@arrow-icns [
0010 387c fe10 1000
0010 1010 fe7c 3810 ]
@switch-icns [
001f 2040 4040 4040
00f8 0402 0202 0202
404f 5f5f 4f20 1f00
02f2 fafa f204 f800
001f 204f 5f5f 4f40
00f8 04f2 fafa f202
4040 4040 4020 1f00
2021-05-04 17:24:00 +00:00
0202 0202 0204 f800 ]
2021-05-03 22:13:12 +00:00
@knob-icns [
2021-05-02 17:40:24 +00:00
0003 0c10 2020 4040
00c0 3008 0404 0202
4040 2020 100c 0300
0202 0404 0830 c000
0000 183c 3c18 0000 ]
@knob-offsetx [
01 00 00 00 00 01 02 03
05 06 07 08 08 08 08 07 ]
@knob-offsety [
07 06 05 03 02 01 00 00
00 00 01 02 03 05 06 07 ]
2021-05-03 22:43:57 +00:00
@font-notes [
2021-05-04 17:24:00 +00:00
003e 4140 4040 413e 40ae 4100 4040 413e
007e 4141 4141 417e 40ae 4101 4141 417e
003e 4140 7c40 413e 003f 4040 7e40 4040
40af 4000 7e40 4040 003e 4140 5f41 413e
40ae 4100 5f41 413e 003e 4141 7f41 4141
40ae 4101 7f41 4141 007e 4141 7e41 417e
2021-05-03 22:43:57 +00:00
]
2021-04-28 03:53:39 +00:00
@font-hex ( 0-F )
[
007c 8282 8282 827c 0030 1010 1010 1010
007c 8202 7c80 80fe 007c 8202 1c02 827c
000c 1424 4484 fe04 00fe 8080 7c02 827c
007c 8280 fc82 827c 007c 8202 1e02 0202
007c 8282 7c82 827c 007c 8282 7e02 827c
007c 8202 7e82 827e 00fc 8282 fc82 82fc
007c 8280 8080 827c 00fc 8282 8282 82fc
007c 8280 f080 827c 007c 8280 f080 8080
]
2021-05-03 16:57:39 +00:00
@font-num-uc [
003e 4141 4141 413e 0018 0808 0808 081c
003e 4101 3e40 407f 003e 4101 1f01 413e
0011 2141 7f01 0101 007f 4040 7e01 413e
003e 4140 7e41 413e 003e 4101 0102 0408
003e 4141 3e41 413e 003e 4141 3f01 0102
0000 0800 0000 0800 0000 0800 0000 0800
0000 0800 0000 0810 0000 0408 1008 0400
0000 001c 001c 0000 0000 1008 0408 1000
0000 0000 0000 0000 003e 4101 3f41 413f
007e 4141 7e41 417e 003e 4140 4040 413e
007e 4141 4141 417e 007f 4040 7e40 407f
007f 4040 7e40 4040 003e 4140 5e41 413e
0041 4141 7f41 4141 0008 0808 0808 0808
007f 0101 0101 413e 0041 4244 7844 4241
0040 4040 4040 403f 0076 4949 4949 4949
005e 6141 4141 4141 003e 4141 4141 413e
007e 4141 7e40 4040 003e 4141 4145 423d
007e 4141 7e41 4141 003e 4140 3e01 413e
007f 0808 0808 0808 0041 4141 4141 433d
0041 4141 4122 1408 0049 4949 4949 4976
0041 2214 0814 2241 0041 4141 3f01 413e
007f 0101 3e40 407f ]