uxn/projects/demos/piano.usm

520 lines
14 KiB
Plaintext
Raw Normal View History

2021-04-25 16:47:32 -04:00
( piano )
2021-05-04 13:57:57 -04:00
%+ { ADD } %- { SUB } %* { MUL } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
2021-05-12 14:44:18 -04:00
%RTN { JMP2r }
%TOS { #00 SWP }
%MOD { DUP2 / * - }
%LTS2 { #8000 ++ SWP2 #8000 ++ >> }
%GTS2 { #8000 ++ SWP2 #8000 ++ << }
%INCR { SWP #01 + SWP }
2021-04-25 16:47:32 -04:00
2021-04-28 14:54:19 -04:00
%WAVEFORM { #1000 }
2021-04-25 16:47:32 -04:00
( devices )
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
2021-04-25 22:50:45 -04:00
|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 ]
2021-04-26 23:55:51 -04:00
|70 @Midi [ &vector $2 &channel $1 &note $1 &velocity $1 ]
2021-04-26 13:52:46 -04:00
|80 @Controller [ &vector $2 &button $1 &key $1 ]
|90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &chord $1 ]
2021-04-28 14:54:19 -04:00
|a0 @File [ &vector $2 &success $2 &offset $2 &pad $2 &name $2 &length $2 &load $2 &save $2 ]
2021-04-25 16:47:32 -04:00
( variables )
|0000
2021-04-30 15:08:24 -04:00
@last-note $1
@octave $1
@color $1
2021-04-25 17:03:17 -04:00
@pointer [ &x $2 &y $2 ]
@center [ &x $2 &y $2 ]
@adsr-view [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
@wave-view [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
2021-04-25 16:47:32 -04:00
@octave-view [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
( program )
|0100 ( -> )
( theme )
#0fe5 .System/r DEO2
#0fc5 .System/g DEO2
#0f25 .System/b DEO2
( vectors )
2021-05-11 14:42:12 -04:00
;on-frame .Screen/vector DEO2
2021-04-25 16:47:32 -04:00
;on-control .Controller/vector DEO2
2021-05-04 13:57:57 -04:00
;on-mouse .Mouse/vector DEO2
;on-midi .Midi/vector DEO2
2021-04-25 16:47:32 -04:00
2021-04-28 14:54:19 -04:00
( load waveform )
2021-05-04 14:54:01 -04:00
;piano-path .File/name DEO2 #0100 .File/length DEO2 WAVEFORM .File/load DEO2
;violin-path .File/name DEO2 #0100 .File/length DEO2 WAVEFORM #0100 ++ .File/load DEO2
;sin-path .File/name DEO2 #0100 .File/length DEO2 WAVEFORM #0200 ++ .File/load DEO2
;tri-path .File/name DEO2 #0100 .File/length DEO2 WAVEFORM #0300 ++ .File/load DEO2
;sqr-path .File/name DEO2 #0100 .File/length DEO2 WAVEFORM #0400 ++ .File/load DEO2
;saw-path .File/name DEO2 #0100 .File/length DEO2 WAVEFORM #0500 ++ .File/load DEO2
2021-04-28 14:54:19 -04:00
2021-04-25 16:47:32 -04:00
( find center )
2021-05-11 14:14:52 -04:00
.Screen/width DEI2 #0002 // .center/x STZ2
.Screen/height DEI2 #0002 // .center/y STZ2
2021-04-25 16:47:32 -04:00
( place octave )
2021-05-11 14:14:52 -04:00
.center/x LDZ2 #0080 -- .octave-view/x1 STZ2
.center/y LDZ2 #0008 ++ .octave-view/y1 STZ2
.octave-view/x1 LDZ2 #0050 ++ .octave-view/x2 STZ2
.octave-view/y1 LDZ2 #0018 ++ .octave-view/y2 STZ2
2021-04-25 16:47:32 -04:00
( place adsr )
2021-05-11 14:14:52 -04:00
.center/x LDZ2 #0020 -- .adsr-view/x1 STZ2
.center/y LDZ2 #0008 ++ .adsr-view/y1 STZ2
.adsr-view/x1 LDZ2 #00a0 ++ .adsr-view/x2 STZ2
.adsr-view/y1 LDZ2 #0018 ++ .adsr-view/y2 STZ2
2021-04-25 16:47:32 -04:00
( place waveform )
2021-05-11 14:14:52 -04:00
.center/x LDZ2 #0080 -- .wave-view/x1 STZ2
.center/y LDZ2 #0020 -- .wave-view/y1 STZ2
.wave-view/x1 LDZ2 #0100 ++ .wave-view/x2 STZ2
.wave-view/y1 LDZ2 #0020 ++ .wave-view/y2 STZ2
2021-04-25 16:47:32 -04:00
( default settings )
2021-05-11 14:14:52 -04:00
#ff .last-note STZ
2021-05-04 14:54:01 -04:00
#041c .Audio0/adsr DEO2
2021-04-26 23:55:51 -04:00
#88 .Audio0/volume DEO
2021-04-28 14:54:19 -04:00
WAVEFORM .Audio0/addr DEO2
#0100 .Audio0/length DEO2
2021-04-25 17:00:35 -04:00
( inital drawing )
;draw-octave JSR2
;draw-adsr JSR2
;draw-wave JSR2
2021-04-25 16:47:32 -04:00
BRK
2021-04-25 22:50:45 -04:00
@on-frame ( -> )
2021-05-11 14:14:52 -04:00
.adsr-view/y2 LDZ2 #0020 -- .Screen/y DEO2
2021-04-28 15:11:05 -04:00
#00 #10
&loop
2021-05-11 14:14:52 -04:00
.adsr-view/x2 LDZ2 #003a -- .Screen/x DEO2
2021-05-04 13:57:57 -04:00
OVR #10 SWP - .Audio0/output DEI #0f AND < .Screen/color DEO
2021-05-11 14:14:52 -04:00
.adsr-view/x2 LDZ2 #003a -- #0002 ++ .Screen/x DEO2
2021-05-04 13:57:57 -04:00
OVR #10 SWP - .Audio0/output DEI #04 SFT < .Screen/color DEO
.Screen/y DEI2 #0002 ++ .Screen/y DEO2
2021-05-12 14:44:18 -04:00
( incr ) INCR
2021-05-12 13:42:24 -04:00
LTHk ,&loop JCN
2021-04-28 15:11:05 -04:00
POP2
2021-04-25 22:50:45 -04:00
BRK
2021-05-11 14:42:12 -04:00
@on-control ( -> )
( clear last cursor )
.pointer/x LDZ2 .Screen/x DEO2
.pointer/y LDZ2 .Screen/y DEO2
#30 .Screen/color DEO
.Controller/key DEI
DUP #61 ! ,&no-c JCN
#00 .last-note STZ ;notes LDA ;play JSR2 &no-c
DUP #73 ! ,&no-d JCN
#01 .last-note STZ ;notes #0001 ++ LDA ;play JSR2 &no-d
DUP #64 ! ,&no-e JCN
#02 .last-note STZ ;notes #0002 ++ LDA ;play JSR2 &no-e
DUP #66 ! ,&no-f JCN
#03 .last-note STZ ;notes #0003 ++ LDA ;play JSR2 &no-f
DUP #67 ! ,&no-g JCN
#04 .last-note STZ ;notes #0004 ++ LDA ;play JSR2 &no-g
DUP #68 ! ,&no-a JCN
#05 .last-note STZ ;notes #0005 ++ LDA ;play JSR2 &no-a
DUP #6a ! ,&no-b JCN
#06 .last-note STZ ;notes #0006 ++ LDA ;play JSR2 &no-b
DUP #6b ! ,&no-c2 JCN
#07 .last-note STZ ;notes #0007 ++ LDA ;play JSR2 &no-c2
POP
( release )
#00 .Controller/key DEO
.Controller/button DEI #f0 AND
DUP #04 SFT #01 AND #01 ! ,&no-up JCN
( move ) .Audio0/addr DEI2 #0001 -- .Audio0/addr DEO2 &no-up
DUP #05 SFT #01 AND #01 ! ,&no-down JCN
( move ) .Audio0/addr DEI2 #0001 ++ .Audio0/addr DEO2 &no-down
DUP #06 SFT #01 AND #01 ! ,&no-left JCN
( move ) .Audio0/addr DEI2 #0010 -- .Audio0/addr DEO2 &no-left
DUP #07 SFT #01 AND #01 ! ,&no-right JCN
( move ) .Audio0/addr DEI2 #0010 ++ .Audio0/addr DEO2 &no-right
POP
;draw-octave JSR2
;draw-wave JSR2
BRK
2021-04-25 22:50:45 -04:00
@on-midi ( -> )
2021-05-11 14:12:07 -04:00
.Midi/note DEI #00 ! #01 JCN [ BRK ]
2021-05-04 13:57:57 -04:00
.Midi/note DEI .Audio0/pitch .Midi/channel DEI #04 MOD #10 * + DEO
2021-04-25 22:50:45 -04:00
BRK
2021-04-25 16:47:32 -04:00
@on-mouse ( -> )
;draw-cursor JSR2
2021-05-11 14:12:07 -04:00
.Mouse/state DEI #00 ! #01 JCN [ BRK ]
2021-04-25 16:47:32 -04:00
( wave-view )
2021-05-11 14:14:52 -04:00
.Mouse/x DEI2 DUP2 .wave-view/x1 LDZ2 >> ROT ROT .wave-view/x2 LDZ2 #0001 ++ << #0101 ==
.Mouse/y DEI2 DUP2 .wave-view/y1 LDZ2 >> ROT ROT .wave-view/y2 LDZ2 << #0101 ==
2021-05-11 14:12:07 -04:00
#0101 == ;on-touch-wave-view JCN2
2021-04-25 16:47:32 -04:00
( adsr-view )
2021-05-11 14:14:52 -04:00
.Mouse/x DEI2 DUP2 .adsr-view/x1 LDZ2 >> ROT ROT .adsr-view/x2 LDZ2 << #0101 ==
.Mouse/y DEI2 DUP2 .adsr-view/y1 LDZ2 >> ROT ROT .adsr-view/y2 LDZ2 << #0101 ==
2021-05-11 14:12:07 -04:00
#0101 == ;on-touch-adsr-view JCN2
2021-04-25 16:47:32 -04:00
( octave-view )
2021-05-11 14:14:52 -04:00
.Mouse/x DEI2 DUP2 .octave-view/x1 LDZ2 >> ROT ROT .octave-view/x2 LDZ2 << #0101 ==
.Mouse/y DEI2 DUP2 .octave-view/y1 LDZ2 >> ROT ROT .octave-view/y2 LDZ2 << #0101 ==
2021-05-11 14:12:07 -04:00
#0101 == ;on-touch-octave-view JCN2
2021-04-25 16:47:32 -04:00
BRK
@on-touch-wave-view ( -> )
2021-05-11 14:14:52 -04:00
.Mouse/x DEI2 .wave-view/x1 LDZ2 -- .Audio0/length DEO2
2021-04-25 16:47:32 -04:00
;draw-wave JSR2
;draw-cursor JSR2
BRK
@on-touch-octave-view ( -> )
2021-05-11 14:14:52 -04:00
.Mouse/x DEI2 .octave-view/x1 LDZ2 -- #0008 // SWP POP #09 ! ,&no-mod JCN
.Mouse/y DEI2 .octave-view/y1 LDZ2 -- #0008 // SWP POP
2021-05-11 14:12:07 -04:00
DUP #00 ! ,&no-incr JCN
2021-05-11 14:14:52 -04:00
.octave LDZ #01 + .octave STZ &no-incr
2021-05-11 14:12:07 -04:00
DUP #02 ! ,&no-decr JCN
2021-05-11 14:14:52 -04:00
.octave LDZ #01 - .octave STZ &no-decr
2021-04-25 16:47:32 -04:00
POP
( release ) #00 .Mouse/state DEO
;draw-octave JSR2
BRK
&no-mod
2021-05-11 14:14:52 -04:00
.Mouse/x DEI2 .octave-view/x1 LDZ2 -- #0008 // SWP POP #06 > ,&no-key JCN
.Mouse/x DEI2 .octave-view/x1 LDZ2 -- #0008 // DUP2 SWP POP .last-note STZ ;notes ++ LDA ;play JSR2
2021-04-28 14:54:19 -04:00
( release ) #00 .Mouse/state DEO
;draw-octave JSR2
&no-key
2021-04-25 16:47:32 -04:00
BRK
@on-touch-adsr-view ( -> )
2021-05-11 14:14:52 -04:00
.Mouse/x DEI2 .adsr-view/x1 LDZ2 -- #0008 // SWP POP #03 /
2021-05-11 14:12:07 -04:00
DUP #00 ! ,&no-a JCN
2021-04-26 23:55:51 -04:00
.Audio0/adsr DEI
2021-05-04 13:57:57 -04:00
#10 .Mouse/state DEI #10 = #e0 * + +
2021-04-26 23:55:51 -04:00
.Audio0/adsr DEO &no-a
2021-05-11 14:12:07 -04:00
DUP #01 ! ,&no-d JCN
2021-04-26 23:55:51 -04:00
.Audio0/adsr DEI
2021-05-04 13:57:57 -04:00
DUP #f0 AND STH #01 .Mouse/state DEI #10 = #0e * + + #0f AND STHr +
2021-04-26 23:55:51 -04:00
.Audio0/adsr DEO &no-d
2021-05-11 14:12:07 -04:00
DUP #02 ! ,&no-s JCN
2021-05-04 13:57:57 -04:00
.Audio0/adsr #01 + DEI
#10 .Mouse/state DEI #10 = #e0 * + +
.Audio0/adsr #01 + DEO &no-s
2021-05-11 14:12:07 -04:00
DUP #03 ! ,&no-r JCN
2021-05-04 13:57:57 -04:00
.Audio0/adsr #01 + DEI
DUP #f0 AND STH #01 .Mouse/state DEI #10 = #0e * + + #0f AND STHr +
.Audio0/adsr #01 + DEO &no-r
2021-05-11 14:12:07 -04:00
DUP #05 ! ,&no-left JCN
2021-04-28 14:54:19 -04:00
.Audio0/volume DEI
2021-05-04 13:57:57 -04:00
#10 .Mouse/state DEI #10 = #e0 * + +
2021-04-28 14:54:19 -04:00
.Audio0/volume DEO &no-left
2021-05-11 14:12:07 -04:00
DUP #06 ! ,&no-right JCN
2021-04-28 14:54:19 -04:00
.Audio0/volume DEI
2021-05-04 13:57:57 -04:00
DUP #f0 AND STH #01 .Mouse/state DEI #10 = #0e * + + #0f AND STHr +
2021-04-28 14:54:19 -04:00
.Audio0/volume DEO &no-right
2021-04-25 16:47:32 -04:00
POP
2021-04-25 17:00:35 -04:00
2021-04-25 16:47:32 -04:00
( release ) #00 .Mouse/state DEO
;draw-adsr JSR2
;draw-cursor JSR2
BRK
@play ( pitch -- )
2021-05-12 14:44:18 -04:00
.octave LDZ #0c * + .Audio0/pitch DEO
2021-04-25 16:47:32 -04:00
RTN
@draw-cursor ( -- )
( clear last cursor )
2021-05-06 13:38:38 -04:00
;cursor .Screen/addr DEO2
2021-05-11 14:14:52 -04:00
.pointer/x LDZ2 .Screen/x DEO2
.pointer/y LDZ2 .Screen/y DEO2
2021-04-25 16:47:32 -04:00
#30 .Screen/color DEO
( record pointer positions )
2021-05-11 14:14:52 -04:00
.Mouse/x DEI2 .pointer/x STZ2
.Mouse/y DEI2 .pointer/y STZ2
2021-04-25 16:47:32 -04:00
( draw new cursor )
2021-05-11 14:14:52 -04:00
.pointer/x LDZ2 .Screen/x DEO2
.pointer/y LDZ2 .Screen/y DEO2
2021-04-25 16:47:32 -04:00
( colorize on state )
2021-05-04 13:57:57 -04:00
#31 [ .Mouse/state DEI #00 ! ] + .Screen/color DEO
2021-04-25 16:47:32 -04:00
RTN
@draw-octave ( -- )
2021-05-11 14:14:52 -04:00
.octave-view/x1 LDZ2 .octave-view/y1 LDZ2
2021-04-25 16:47:32 -04:00
2021-05-11 14:14:52 -04:00
OVR2 OVR2 ;keys-left-icns #21 .last-note LDZ #00 = + ;draw-key JSR2
OVR2 #0008 ++ OVR2 ;keys-middle-icns #21 .last-note LDZ #01 = + ;draw-key JSR2
OVR2 #0010 ++ OVR2 ;keys-right-icns #21 .last-note LDZ #02 = + ;draw-key JSR2
OVR2 #0018 ++ OVR2 ;keys-left-icns #21 .last-note LDZ #03 = + ;draw-key JSR2
OVR2 #0020 ++ OVR2 ;keys-middle-icns #21 .last-note LDZ #04 = + ;draw-key JSR2
OVR2 #0028 ++ OVR2 ;keys-middle-icns #21 .last-note LDZ #05 = + ;draw-key JSR2
SWP2 #0030 ++ SWP2 ;keys-right-icns #21 .last-note LDZ #06 = + ;draw-key JSR2
2021-04-25 16:47:32 -04:00
2021-05-11 14:14:52 -04:00
.octave-view/x1 LDZ2 #0048 ++ .Screen/x DEO2
2021-04-28 14:54:19 -04:00
2021-04-25 16:47:32 -04:00
;arrow-icns .Screen/addr DEO2
2021-05-11 14:14:52 -04:00
.octave-view/y1 LDZ2 .Screen/y DEO2
2021-04-25 16:47:32 -04:00
#21 .Screen/color DEO
2021-05-04 13:57:57 -04:00
;arrow-icns #0008 ++ .Screen/addr DEO2
2021-05-11 14:14:52 -04:00
.octave-view/y1 LDZ2 #0010 ++ .Screen/y DEO2
2021-04-25 16:47:32 -04:00
#21 .Screen/color DEO
2021-05-11 14:14:52 -04:00
;font-hex .octave LDZ #03 + #00 SWP #0008 ** ++ .Screen/addr DEO2
.octave-view/y1 LDZ2 #0008 ++ .Screen/y DEO2
2021-04-25 16:47:32 -04:00
#23 .Screen/color DEO
RTN
@draw-key ( x* y* addr* color -- )
STH
.Screen/addr DEO2
SWP2 .Screen/x DEO2
2021-05-04 13:57:57 -04:00
DUP2 #0018 ++
2021-04-25 16:47:32 -04:00
&loop
( move ) OVR2 .Screen/y DEO2
2021-05-12 13:42:24 -04:00
( draw ) STHrk .Screen/color DEO
2021-05-04 13:57:57 -04:00
( incr ) .Screen/addr DEI2 #0008 ++ .Screen/addr DEO2
( incr ) SWP2 #0008 ++ SWP2
2021-05-12 14:44:18 -04:00
LTH2k ,&loop JCN
2021-04-25 16:47:32 -04:00
POP2 POP2
POPr
RTN
@draw-adsr ( -- )
2021-05-04 13:57:57 -04:00
( adsr )
2021-05-11 14:14:52 -04:00
.adsr-view/x1 LDZ2 .adsr-view/y1 LDZ2
2021-04-26 23:55:51 -04:00
.Audio0/adsr DEI #04 SFT
2021-04-25 16:47:32 -04:00
;draw-knob JSR2
2021-05-11 14:14:52 -04:00
.adsr-view/x1 LDZ2 #0018 ++ .adsr-view/y1 LDZ2
2021-04-26 23:55:51 -04:00
.Audio0/adsr DEI #0f AND
2021-04-25 16:47:32 -04:00
;draw-knob JSR2
2021-05-11 14:14:52 -04:00
.adsr-view/x1 LDZ2 #0030 ++ .adsr-view/y1 LDZ2
2021-05-04 13:57:57 -04:00
.Audio0/adsr #01 + DEI #04 SFT
2021-04-25 16:47:32 -04:00
;draw-knob JSR2
2021-05-11 14:14:52 -04:00
.adsr-view/x1 LDZ2 #0048 ++ .adsr-view/y1 LDZ2
2021-05-04 13:57:57 -04:00
.Audio0/adsr #01 + DEI #0f AND
2021-04-25 16:47:32 -04:00
;draw-knob JSR2
2021-04-28 14:54:19 -04:00
( volume )
2021-05-11 14:14:52 -04:00
.adsr-view/x2 LDZ2 #0028 -- .adsr-view/y1 LDZ2
2021-04-28 14:54:19 -04:00
.Audio0/volume DEI #04 SFT
;draw-knob JSR2
2021-05-11 14:14:52 -04:00
.adsr-view/x2 LDZ2 #0010 -- .adsr-view/y1 LDZ2
2021-04-28 14:54:19 -04:00
.Audio0/volume DEI #0f AND
;draw-knob JSR2
2021-04-25 16:47:32 -04:00
RTN
@draw-wave ( -- )
2021-05-04 13:57:57 -04:00
( clear )
2021-05-11 14:14:52 -04:00
.wave-view/x1 LDZ2
.wave-view/y1 LDZ2
.wave-view/x2 LDZ2 #0001 ++
.wave-view/y2 LDZ2
2021-04-25 16:47:32 -04:00
#00 ;fill-rect JSR2
#01 ;draw-wave-length JSR2
2021-05-11 14:14:52 -04:00
.wave-view/x1 LDZ2 .Screen/x DEO2
2021-04-25 16:47:32 -04:00
( waveform )
2021-04-28 14:54:19 -04:00
#00 #ff
2021-04-25 16:47:32 -04:00
&loop
( dotted line )
2021-05-11 14:12:07 -04:00
OVR #01 AND ,&no-dot JCN
2021-05-11 14:14:52 -04:00
.wave-view/y1 LDZ2 #0010 ++ .Screen/y DEO2
2021-04-25 16:47:32 -04:00
#03 .Screen/color DEO
&no-dot
2021-05-04 13:57:57 -04:00
OVR TOS .Audio0/addr DEI2 ++ LDA
#02 /
2021-05-11 14:14:52 -04:00
TOS #0004 // .wave-view/y1 LDZ2 ++ .Screen/y DEO2
2021-05-04 13:57:57 -04:00
.Screen/x DEI2 #0001 ++ .Screen/x DEO2
( draw ) OVR .Audio0/length DEI2 SWP POP > #02 * #01 + .Screen/color DEO
2021-05-12 14:44:18 -04:00
( incr ) INCR
2021-05-12 13:42:24 -04:00
LTHk ,&loop JCN
2021-04-25 16:47:32 -04:00
POP2
( range )
2021-05-11 14:14:52 -04:00
.wave-view/x1 LDZ2 .Screen/x DEO2
.wave-view/y1 LDZ2 #0010 -- .Screen/y DEO2
2021-04-27 23:53:39 -04:00
.Audio0/addr DEI2 #22 ;draw-short JSR2
2021-05-11 14:14:52 -04:00
.wave-view/x2 LDZ2 #0020 -- .Screen/x DEO2
2021-04-27 23:53:39 -04:00
.Audio0/length DEI2 #22 ;draw-short JSR2
2021-04-25 16:47:32 -04:00
RTN
@draw-wave-length ( color -- )
STH
2021-05-11 14:14:52 -04:00
.wave-view/x1 LDZ2 .Audio0/length DEI2 ++ .Screen/x DEO2
.wave-view/y1 LDZ2 DUP2 #0020 ++
2021-04-25 16:47:32 -04:00
&loop
OVR2 .Screen/y DEO2
2021-05-12 13:42:24 -04:00
( draw ) STHrk .Screen/color DEO
2021-05-04 13:57:57 -04:00
( incr ) SWP2 #0001 ++ SWP2
2021-05-12 14:44:18 -04:00
LTH2k ,&loop JCN
2021-04-25 16:47:32 -04:00
POP2 POP2
POPr
RTN
@draw-knob ( x* y* value -- )
2021-05-04 13:57:57 -04:00
( 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-12 13:42:24 -04:00
;font-hex #00 STHrk #08 * ++ .Screen/addr DEO2
2021-05-04 13:57:57 -04:00
( draw ) #21 .Screen/color DEO
2021-05-12 13:42:24 -04:00
.Screen/x DEI2 #0004 -- #00 #00 STHrk ;knob-offsetx ++ LDA ++ .Screen/x DEO2
2021-05-04 13:57:57 -04: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
2021-04-25 16:47:32 -04:00
RTN
2021-04-27 23:53:39 -04:00
@draw-short ( short* color -- )
2021-04-25 16:47:32 -04:00
2021-04-27 23:53:39 -04:00
STH SWP
2021-05-04 13:57:57 -04:00
DUP #04 SFT TOS #0008 ** ;font-hex ++ .Screen/addr DEO2
2021-05-12 13:42:24 -04:00
( draw ) STHrk .Screen/color DEO
2021-05-04 13:57:57 -04:00
#0f AND TOS #0008 ** ;font-hex ++ .Screen/addr DEO2
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
2021-05-12 13:42:24 -04:00
( draw ) STHrk .Screen/color DEO
2021-05-04 13:57:57 -04:00
DUP #04 SFT TOS #0008 ** ;font-hex ++ .Screen/addr DEO2
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
2021-05-12 13:42:24 -04:00
( draw ) STHrk .Screen/color DEO
2021-05-04 13:57:57 -04:00
#0f AND TOS #0008 ** ;font-hex ++ .Screen/addr DEO2
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
2021-04-27 23:53:39 -04:00
( draw ) STHr .Screen/color DEO
2021-04-25 16:47:32 -04:00
RTN
2021-04-27 23:53:39 -04:00
@fill-rect ( x1* y1* x2* y2* color -- )
2021-04-25 16:47:32 -04:00
2021-05-11 14:14:52 -04:00
.color STZ
2021-04-25 16:47:32 -04: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 14:14:52 -04:00
( draw ) .color LDZ .Screen/color DEO
2021-05-04 13:57:57 -04:00
( incr ) SWP2 #0001 ++ SWP2
2021-05-11 14:12:07 -04:00
OVR2 OVR2 LTS2 ,&hor JCN
2021-04-25 16:47:32 -04:00
POP2 POP2 STH2r STH2r
2021-05-04 13:57:57 -04:00
( incr ) SWP2 #0001 ++ SWP2
2021-05-11 14:12:07 -04:00
OVR2 OVR2 LTS2 ,&ver JCN
2021-04-25 16:47:32 -04:00
POP2 POP2 POP2 POP2
RTN
@cursor [
80c0 e0f0 f8e0 1000 ]
@arrow-icns [
0010 387c fe10 1000
0010 1010 fe7c 3810 ]
@notes [
3c 3e 40 41 43 45 47
48 4a 4c 4d 4f 51 53 ]
@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 ]
2021-05-04 13:57:57 -04:00
@knob-icns [
2021-04-25 16:47:32 -04: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 ]
@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-04 14:54:01 -04:00
@piano-path "projects/sounds/piano.pcm $1
@violin-path "projects/sounds/violin.pcm $1
2021-04-28 14:54:19 -04:00
@sin-path "projects/sounds/sin.pcm $1
@tri-path "projects/sounds/tri.pcm $1
2021-05-04 14:54:01 -04:00
@sqr-path "projects/sounds/sqr.pcm $1
@saw-path "projects/sounds/saw.pcm $1