mirror of https://git.sr.ht/~rabbits/uxn
Optimized Piano
This commit is contained in:
parent
7d8600c679
commit
9b4aa10f07
4
build.sh
4
build.sh
|
@ -54,9 +54,9 @@ then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Assembling.."
|
echo "Assembling.."
|
||||||
./bin/uxnasm projects/examples/demos/life.tal bin/life.rom
|
./bin/uxnasm projects/examples/demos/piano.tal bin/piano.rom
|
||||||
|
|
||||||
echo "Running.."
|
echo "Running.."
|
||||||
./bin/uxnemu bin/life.rom
|
./bin/uxnemu bin/piano.rom
|
||||||
|
|
||||||
echo "Done."
|
echo "Done."
|
||||||
|
|
|
@ -10,14 +10,11 @@
|
||||||
%MOD { DUP2 / * - }
|
%MOD { DUP2 / * - }
|
||||||
%LTS2 { #8000 ++ SWP2 #8000 ++ >> }
|
%LTS2 { #8000 ++ SWP2 #8000 ++ >> }
|
||||||
%GTS2 { #8000 ++ SWP2 #8000 ++ << }
|
%GTS2 { #8000 ++ SWP2 #8000 ++ << }
|
||||||
%INCR { SWP #01 + SWP }
|
|
||||||
%2// { #01 SFT2 }
|
%2// { #01 SFT2 }
|
||||||
%4// { #02 SFT2 }
|
%4// { #02 SFT2 }
|
||||||
%8// { #03 SFT2 }
|
%8// { #03 SFT2 }
|
||||||
%8** { #30 SFT2 }
|
%8** { #30 SFT2 }
|
||||||
|
|
||||||
%BREAKPOINT { #0101 #0e DEO2 }
|
|
||||||
|
|
||||||
( devices )
|
( devices )
|
||||||
|
|
||||||
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|
||||||
|
@ -97,15 +94,14 @@ BRK
|
||||||
|
|
||||||
.adsr-view/y2 LDZ2 #0020 -- .Screen/y DEO2
|
.adsr-view/y2 LDZ2 #0020 -- .Screen/y DEO2
|
||||||
|
|
||||||
#00 #10
|
#10 #00
|
||||||
&loop
|
&loop
|
||||||
.adsr-view/x2 LDZ2 #003a -- .Screen/x DEO2
|
.adsr-view/x2 LDZ2 #003a -- .Screen/x DEO2
|
||||||
OVR #10 SWP - .Audio0/output DEI #0f AND < .Screen/pixel DEO
|
DUP #10 SWP - .Audio0/output DEI #0f AND < .Screen/pixel DEO
|
||||||
.adsr-view/x2 LDZ2 #003a -- #0002 ++ .Screen/x DEO2
|
.adsr-view/x2 LDZ2 #003a -- #0002 ++ .Screen/x DEO2
|
||||||
OVR #10 SWP - .Audio0/output DEI #04 SFT < .Screen/pixel DEO
|
DUP #10 SWP - .Audio0/output DEI #04 SFT < .Screen/pixel DEO
|
||||||
.Screen/y DEI2 #0002 ++ .Screen/y DEO2
|
.Screen/y DEI2 #0002 ++ .Screen/y DEO2
|
||||||
( incr ) INCR
|
#01 + GTHk ,&loop JCN
|
||||||
LTHk ,&loop JCN
|
|
||||||
POP2
|
POP2
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
@ -134,9 +130,6 @@ BRK
|
||||||
#3b .octave LDZ #0c * + ;play JSR2 &no-b
|
#3b .octave LDZ #0c * + ;play JSR2 &no-b
|
||||||
DUP #6b ! ,&no-c2 JCN
|
DUP #6b ! ,&no-c2 JCN
|
||||||
#3c .octave LDZ #0c * + ;play JSR2 &no-c2
|
#3c .octave LDZ #0c * + ;play JSR2 &no-c2
|
||||||
DUP #1b ! ,&no-esc JCN
|
|
||||||
BREAKPOINT
|
|
||||||
&no-esc
|
|
||||||
POP
|
POP
|
||||||
|
|
||||||
( release )
|
( release )
|
||||||
|
@ -302,13 +295,12 @@ RTN
|
||||||
STH
|
STH
|
||||||
.Screen/addr DEO2
|
.Screen/addr DEO2
|
||||||
SWP2 .Screen/x DEO2
|
SWP2 .Screen/x DEO2
|
||||||
DUP2 #0018 ++
|
DUP2 #0018 ++ SWP2
|
||||||
&loop
|
&loop
|
||||||
( move ) OVR2 .Screen/y DEO2
|
( move ) DUP2 .Screen/y DEO2
|
||||||
( draw ) STHkr .Screen/sprite DEO
|
( draw ) STHkr .Screen/sprite DEO
|
||||||
( incr ) .Screen/addr DEI2 #0008 ++ .Screen/addr DEO2
|
( incr ) .Screen/addr DEI2 #0008 ++ .Screen/addr DEO2
|
||||||
( incr ) SWP2 #0008 ++ SWP2
|
#0008 ++ GTH2k ,&loop JCN
|
||||||
LTH2k ,&loop JCN
|
|
||||||
POP2 POP2
|
POP2 POP2
|
||||||
POPr
|
POPr
|
||||||
|
|
||||||
|
@ -353,22 +345,21 @@ RTN
|
||||||
.wave-view/x1 LDZ2 .Screen/x DEO2
|
.wave-view/x1 LDZ2 .Screen/x DEO2
|
||||||
|
|
||||||
( waveform )
|
( waveform )
|
||||||
#00 #ff
|
#ff #00
|
||||||
&loop
|
&loop
|
||||||
( dotted line )
|
( dotted line )
|
||||||
OVR #01 AND ,&no-dot JCN
|
DUP #01 AND ,&no-dot JCN
|
||||||
.wave-view/y1 LDZ2 #0010 ++ .Screen/y DEO2
|
.wave-view/y1 LDZ2 #0010 ++ .Screen/y DEO2
|
||||||
#03 .Screen/pixel DEO
|
#03 .Screen/pixel DEO
|
||||||
&no-dot
|
&no-dot
|
||||||
OVR TOS .Audio0/addr DEI2 ++ LDA
|
DUP TOS .Audio0/addr DEI2 ++ LDA
|
||||||
#02 /
|
#02 /
|
||||||
TOS 4// .wave-view/y1 LDZ2 ++ .Screen/y DEO2
|
TOS 4// .wave-view/y1 LDZ2 ++ .Screen/y DEO2
|
||||||
.Screen/x DEI2 #0001 ++ .Screen/x DEO2
|
.Screen/x DEI2 #0001 ++ .Screen/x DEO2
|
||||||
( draw ) OVR
|
( draw ) DUP
|
||||||
.Audio0/length DEI2 TOB >
|
.Audio0/length DEI2 TOB >
|
||||||
.Audio0/length DEI2 #0100 !! #0101 == #02 * #01 + .Screen/pixel DEO
|
.Audio0/length DEI2 #0100 !! #0101 == #02 * #01 + .Screen/pixel DEO
|
||||||
( incr ) INCR
|
#01 + GTHk ,&loop JCN
|
||||||
LTHk ,&loop JCN
|
|
||||||
POP2
|
POP2
|
||||||
|
|
||||||
( range )
|
( range )
|
||||||
|
@ -384,12 +375,11 @@ RTN
|
||||||
|
|
||||||
STH
|
STH
|
||||||
.wave-view/x1 LDZ2 .Audio0/length DEI2 ++ .Screen/x DEO2
|
.wave-view/x1 LDZ2 .Audio0/length DEI2 ++ .Screen/x DEO2
|
||||||
.wave-view/y1 LDZ2 DUP2 #0020 ++
|
.wave-view/y1 LDZ2 DUP2 #0020 ++ SWP2
|
||||||
&loop
|
&loop
|
||||||
OVR2 .Screen/y DEO2
|
DUP2 .Screen/y DEO2
|
||||||
( draw ) STHkr .Screen/pixel DEO
|
( draw ) STHkr .Screen/pixel DEO
|
||||||
( incr ) SWP2 #0001 ++ SWP2
|
#0001 ++ GTH2k ,&loop JCN
|
||||||
LTH2k ,&loop JCN
|
|
||||||
POP2 POP2
|
POP2 POP2
|
||||||
POPr
|
POPr
|
||||||
|
|
||||||
|
@ -399,24 +389,24 @@ RTN
|
||||||
|
|
||||||
( load ) STH .Screen/y DEO2 .Screen/x DEO2
|
( load ) STH .Screen/y DEO2 .Screen/x DEO2
|
||||||
;knob-icns .Screen/addr DEO2
|
;knob-icns .Screen/addr DEO2
|
||||||
( draw ) #01 .Screen/sprite DEO
|
( draw ) #01 .Screen/sprite DEO
|
||||||
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
|
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
|
||||||
;knob-icns #0008 ++ .Screen/addr DEO2
|
;knob-icns #0008 ++ .Screen/addr DEO2
|
||||||
( draw ) #01 .Screen/sprite DEO
|
( draw ) #01 .Screen/sprite DEO
|
||||||
.Screen/y DEI2 #0008 ++ .Screen/y DEO2
|
.Screen/y DEI2 #0008 ++ .Screen/y DEO2
|
||||||
;knob-icns #0018 ++ .Screen/addr DEO2
|
;knob-icns #0018 ++ .Screen/addr DEO2
|
||||||
( draw ) #01 .Screen/sprite DEO
|
( draw ) #01 .Screen/sprite DEO
|
||||||
.Screen/x DEI2 #0008 -- .Screen/x DEO2
|
.Screen/x DEI2 #0008 -- .Screen/x DEO2
|
||||||
;knob-icns #0010 ++ .Screen/addr DEO2
|
;knob-icns #0010 ++ .Screen/addr DEO2
|
||||||
( draw ) #01 .Screen/sprite DEO
|
( draw ) #01 .Screen/sprite DEO
|
||||||
.Screen/x DEI2 #0004 ++ .Screen/x DEO2
|
.Screen/x DEI2 #0004 ++ .Screen/x DEO2
|
||||||
.Screen/y DEI2 #0008 ++ .Screen/y DEO2
|
.Screen/y DEI2 #0008 ++ .Screen/y DEO2
|
||||||
;font-hex #00 STHkr #08 * ++ .Screen/addr DEO2
|
;font-hex #00 STHkr #08 * ++ .Screen/addr DEO2
|
||||||
( draw ) #01 .Screen/sprite DEO
|
( draw ) #01 .Screen/sprite DEO
|
||||||
.Screen/x DEI2 #0004 -- #00 #00 STHkr ;knob-offsetx ++ LDA ++ .Screen/x DEO2
|
.Screen/x DEI2 #0004 -- #00 #00 STHkr ;knob-offsetx ++ LDA ++ .Screen/x DEO2
|
||||||
.Screen/y DEI2 #0010 -- #00 #00 STHr ;knob-offsety ++ LDA ++ .Screen/y DEO2
|
.Screen/y DEI2 #0010 -- #00 #00 STHr ;knob-offsety ++ LDA ++ .Screen/y DEO2
|
||||||
;knob-icns #0020 ++ .Screen/addr DEO2
|
;knob-icns #0020 ++ .Screen/addr DEO2
|
||||||
( draw ) #05 .Screen/sprite DEO
|
( draw ) #05 .Screen/sprite DEO
|
||||||
|
|
||||||
RTN
|
RTN
|
||||||
|
|
||||||
|
@ -424,37 +414,38 @@ RTN
|
||||||
|
|
||||||
STH SWP
|
STH SWP
|
||||||
DUP #04 SFT TOS 8** ;font-hex ++ .Screen/addr DEO2
|
DUP #04 SFT TOS 8** ;font-hex ++ .Screen/addr DEO2
|
||||||
( draw ) STHkr .Screen/sprite DEO
|
( draw ) STHkr .Screen/sprite DEO
|
||||||
#0f AND TOS 8** ;font-hex ++ .Screen/addr DEO2
|
#0f AND TOS 8** ;font-hex ++ .Screen/addr DEO2
|
||||||
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
|
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
|
||||||
( draw ) STHkr .Screen/sprite DEO
|
( draw ) STHkr .Screen/sprite DEO
|
||||||
DUP #04 SFT TOS 8** ;font-hex ++ .Screen/addr DEO2
|
DUP #04 SFT TOS 8** ;font-hex ++ .Screen/addr DEO2
|
||||||
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
|
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
|
||||||
( draw ) STHkr .Screen/sprite DEO
|
( draw ) STHkr .Screen/sprite DEO
|
||||||
#0f AND TOS 8** ;font-hex ++ .Screen/addr DEO2
|
#0f AND TOS 8** ;font-hex ++ .Screen/addr DEO2
|
||||||
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
|
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
|
||||||
( draw ) STHr .Screen/sprite DEO
|
( draw ) STHr .Screen/sprite DEO
|
||||||
|
|
||||||
RTN
|
RTN
|
||||||
|
|
||||||
@fill-rect ( x1* y1* x2* y2* color -- )
|
@fill-rect ( x1* y1* x2* y2* color -- )
|
||||||
|
|
||||||
.color STZ
|
,&color STR
|
||||||
( x1 x2 y1 y2 ) ROT2 SWP2
|
( x1 x2 y1 y2 ) ROT2
|
||||||
&ver
|
&ver
|
||||||
( save ) OVR2 .Screen/y DEO2
|
( save ) DUP2 .Screen/y DEO2
|
||||||
STH2 STH2 OVR2 OVR2
|
STH2 STH2 OVR2 OVR2 SWP2
|
||||||
&hor
|
&hor
|
||||||
( save ) OVR2 .Screen/x DEO2
|
( save ) DUP2 .Screen/x DEO2
|
||||||
( draw ) .color LDZ .Screen/pixel DEO
|
( draw ) ,&color LDR .Screen/pixel DEO
|
||||||
( incr ) SWP2 #0001 ++ SWP2
|
( incr ) #0001 ++
|
||||||
OVR2 OVR2 LTS2 ,&hor JCN
|
OVR2 OVR2 GTS2 ,&hor JCN
|
||||||
POP2 POP2 STH2r STH2r
|
POP2 POP2 STH2r STH2r
|
||||||
( incr ) SWP2 #0001 ++ SWP2
|
( incr ) #0001 ++
|
||||||
OVR2 OVR2 LTS2 ,&ver JCN
|
OVR2 OVR2 GTS2 ,&ver JCN
|
||||||
POP2 POP2 POP2 POP2
|
POP2 POP2 POP2 POP2
|
||||||
|
|
||||||
RTN
|
RTN
|
||||||
|
&color $1
|
||||||
|
|
||||||
@within-rect ( x* y* rect -- flag )
|
@within-rect ( x* y* rect -- flag )
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue