uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit 9b4aa10f079488bfd174b8cacc8c82b126492bfb
parent 7d8600c6793c91bbb0d5e903891614186b12fc11
Author: neauoire <aliceffekt@gmail.com>
Date:   Mon,  9 Aug 2021 11:12:11 -0700

Optimized Piano

Diffstat:
Mbuild.sh | 4++--
Mprojects/examples/demos/piano.tal | 81+++++++++++++++++++++++++++++++++++--------------------------------------------
2 files changed, 38 insertions(+), 47 deletions(-)

diff --git a/build.sh b/build.sh @@ -54,9 +54,9 @@ then fi echo "Assembling.." -./bin/uxnasm projects/examples/demos/life.tal bin/life.rom +./bin/uxnasm projects/examples/demos/piano.tal bin/piano.rom echo "Running.." -./bin/uxnemu bin/life.rom +./bin/uxnemu bin/piano.rom echo "Done." diff --git a/projects/examples/demos/piano.tal b/projects/examples/demos/piano.tal @@ -10,14 +10,11 @@ %MOD { DUP2 / * - } %LTS2 { #8000 ++ SWP2 #8000 ++ >> } %GTS2 { #8000 ++ SWP2 #8000 ++ << } -%INCR { SWP #01 + SWP } %2// { #01 SFT2 } %4// { #02 SFT2 } %8// { #03 SFT2 } %8** { #30 SFT2 } -%BREAKPOINT { #0101 #0e DEO2 } - ( devices ) |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 - #00 #10 + #10 #00 &loop .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 - 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 - ( incr ) INCR - LTHk ,&loop JCN + #01 + GTHk ,&loop JCN POP2 BRK @@ -134,9 +130,6 @@ BRK #3b .octave LDZ #0c * + ;play JSR2 &no-b DUP #6b ! ,&no-c2 JCN #3c .octave LDZ #0c * + ;play JSR2 &no-c2 - DUP #1b ! ,&no-esc JCN - BREAKPOINT - &no-esc POP ( release ) @@ -302,13 +295,12 @@ RTN STH .Screen/addr DEO2 SWP2 .Screen/x DEO2 - DUP2 #0018 ++ + DUP2 #0018 ++ SWP2 &loop - ( move ) OVR2 .Screen/y DEO2 + ( move ) DUP2 .Screen/y DEO2 ( draw ) STHkr .Screen/sprite DEO ( incr ) .Screen/addr DEI2 #0008 ++ .Screen/addr DEO2 - ( incr ) SWP2 #0008 ++ SWP2 - LTH2k ,&loop JCN + #0008 ++ GTH2k ,&loop JCN POP2 POP2 POPr @@ -353,22 +345,21 @@ RTN .wave-view/x1 LDZ2 .Screen/x DEO2 ( waveform ) - #00 #ff + #ff #00 &loop ( dotted line ) - OVR #01 AND ,&no-dot JCN + DUP #01 AND ,&no-dot JCN .wave-view/y1 LDZ2 #0010 ++ .Screen/y DEO2 #03 .Screen/pixel DEO &no-dot - OVR TOS .Audio0/addr DEI2 ++ LDA + DUP TOS .Audio0/addr DEI2 ++ LDA #02 / TOS 4// .wave-view/y1 LDZ2 ++ .Screen/y DEO2 .Screen/x DEI2 #0001 ++ .Screen/x DEO2 - ( draw ) OVR + ( draw ) DUP .Audio0/length DEI2 TOB > .Audio0/length DEI2 #0100 !! #0101 == #02 * #01 + .Screen/pixel DEO - ( incr ) INCR - LTHk ,&loop JCN + #01 + GTHk ,&loop JCN POP2 ( range ) @@ -384,12 +375,11 @@ RTN STH .wave-view/x1 LDZ2 .Audio0/length DEI2 ++ .Screen/x DEO2 - .wave-view/y1 LDZ2 DUP2 #0020 ++ + .wave-view/y1 LDZ2 DUP2 #0020 ++ SWP2 &loop - OVR2 .Screen/y DEO2 + DUP2 .Screen/y DEO2 ( draw ) STHkr .Screen/pixel DEO - ( incr ) SWP2 #0001 ++ SWP2 - LTH2k ,&loop JCN + #0001 ++ GTH2k ,&loop JCN POP2 POP2 POPr @@ -399,24 +389,24 @@ RTN ( load ) STH .Screen/y DEO2 .Screen/x DEO2 ;knob-icns .Screen/addr DEO2 - ( draw ) #01 .Screen/sprite DEO + ( draw ) #01 .Screen/sprite DEO .Screen/x DEI2 #0008 ++ .Screen/x DEO2 ;knob-icns #0008 ++ .Screen/addr DEO2 - ( draw ) #01 .Screen/sprite DEO + ( draw ) #01 .Screen/sprite DEO .Screen/y DEI2 #0008 ++ .Screen/y DEO2 ;knob-icns #0018 ++ .Screen/addr DEO2 - ( draw ) #01 .Screen/sprite DEO + ( draw ) #01 .Screen/sprite DEO .Screen/x DEI2 #0008 -- .Screen/x 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/y DEI2 #0008 ++ .Screen/y 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/y DEI2 #0010 -- #00 #00 STHr ;knob-offsety ++ LDA ++ .Screen/y DEO2 ;knob-icns #0020 ++ .Screen/addr DEO2 - ( draw ) #05 .Screen/sprite DEO + ( draw ) #05 .Screen/sprite DEO RTN @@ -424,37 +414,38 @@ RTN STH SWP 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 .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 .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 .Screen/x DEI2 #0008 ++ .Screen/x DEO2 - ( draw ) STHr .Screen/sprite DEO + ( draw ) STHr .Screen/sprite DEO RTN @fill-rect ( x1* y1* x2* y2* color -- ) - .color STZ - ( x1 x2 y1 y2 ) ROT2 SWP2 + ,&color STR + ( x1 x2 y1 y2 ) ROT2 &ver - ( save ) OVR2 .Screen/y DEO2 - STH2 STH2 OVR2 OVR2 + ( save ) DUP2 .Screen/y DEO2 + STH2 STH2 OVR2 OVR2 SWP2 &hor - ( save ) OVR2 .Screen/x DEO2 - ( draw ) .color LDZ .Screen/pixel DEO - ( incr ) SWP2 #0001 ++ SWP2 - OVR2 OVR2 LTS2 ,&hor JCN + ( save ) DUP2 .Screen/x DEO2 + ( draw ) ,&color LDR .Screen/pixel DEO + ( incr ) #0001 ++ + OVR2 OVR2 GTS2 ,&hor JCN POP2 POP2 STH2r STH2r - ( incr ) SWP2 #0001 ++ SWP2 - OVR2 OVR2 LTS2 ,&ver JCN + ( incr ) #0001 ++ + OVR2 OVR2 GTS2 ,&ver JCN POP2 POP2 POP2 POP2 RTN + &color $1 @within-rect ( x* y* rect -- flag )