uxn

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

commit 73deb679f3dd45436d33289ab48ea37c2b3467f3
parent 69dca52737865e2b30076a4a4ce240cd0cbb4d80
Author: neauoire <aliceffekt@gmail.com>
Date:   Tue,  4 May 2021 10:57:57 -0700

Optimized piano example

Diffstat:
Mbuild.sh | 2+-
Mprojects/demos/drum-rack.usm | 48+++++++++---------------------------------------
Mprojects/demos/piano.usm | 339++++++++++++++++++++++++++++++++++++++++---------------------------------------
Msrc/assembler.c | 2+-
4 files changed, 182 insertions(+), 209 deletions(-)

diff --git a/build.sh b/build.sh @@ -34,7 +34,7 @@ else fi echo "Assembling.." -./bin/assembler projects/demos/drum-rack.usm bin/boot.rom +./bin/assembler projects/demos/piano.usm bin/boot.rom echo "Running.." if [ "${2}" = '--cli' ]; diff --git a/projects/demos/drum-rack.usm b/projects/demos/drum-rack.usm @@ -30,7 +30,6 @@ |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 ] -|b0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ] ( variables ) @@ -40,13 +39,12 @@ @pointer [ &x $2 &y $2 ] @piano [ &last $1 &octave $1 ] @pads [ &last $1 ] +@frame [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ] @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 ] -@frame [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ] - ( TODO: remove ) @color $1 @rect [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ] @@ -132,32 +130,21 @@ .wav-view/y2 PEK2 #0002 ++ #01 ;line-rect JSR2 - ( load samples ) - #00 #10 - &load-samples - ( name ) OVR TOS #0019 ** ;pad-path ++ .File/name DEO2 - ( length ) OVR #04 / #10 * .Audio0/length + DEI2 .File/length DEO2 - ( load ) OVR TOS #0002 ** ;pad-addr ++ LDA2 .File/load DEO2 - ( incr ) SWP #01 + SWP - DUP2 < ,&load-samples JNZ - POP2 - ( initial draw ) - #00 #10 &draw-pads + ( load sample ) + OVR TOS #0019 ** ;pad-path ++ .File/name DEO2 + OVR #04 / #10 * .Audio0/length + DEI2 .File/length DEO2 + OVR TOS #0002 ** ;pad-addr ++ LDA2 .File/load DEO2 + ( draw pad ) OVR #01 ;draw-pad JSR2 - SWP #01 + SWP + ( draw mixer ) + OVR #04 / ;draw-mixer JSR2 + ( incr ) SWP #01 + SWP DUP2 < ,&draw-pads JNZ POP2 - #00 #04 - &draw-mixers - OVR ;draw-mixer JSR2 - SWP #01 + SWP - DUP2 < ,&draw-mixers JNZ - POP2 - ;draw-octave JSR2 BRK @@ -576,23 +563,6 @@ RTN RTN -@draw-short ( addr* color -- ) - - STH SWP - DUP #04 SFT TOS #0008 ** ;font-hex ++ .Screen/addr DEO2 - ( draw ) DUPr STHr .Screen/color DEO - #0f AND TOS #0008 ** ;font-hex ++ .Screen/addr DEO2 - .Screen/x DEI2 #0008 ++ .Screen/x DEO2 - ( draw ) DUPr STHr .Screen/color DEO - DUP #04 SFT TOS #0008 ** ;font-hex ++ .Screen/addr DEO2 - .Screen/x DEI2 #0008 ++ .Screen/x DEO2 - ( draw ) DUPr STHr .Screen/color DEO - #0f AND TOS #0008 ** ;font-hex ++ .Screen/addr DEO2 - .Screen/x DEI2 #0008 ++ .Screen/x DEO2 - ( draw ) STHr .Screen/color DEO - -RTN - @line-rect ( x1* y1* x2* y2* color -- ) ( load ) .color POK DUP2 STH2 .rect/y2 POK2 .rect/x2 POK2 DUP2 STH2 .rect/y1 POK2 .rect/x1 POK2 diff --git a/projects/demos/piano.usm b/projects/demos/piano.usm @@ -1,14 +1,15 @@ ( piano ) +%+ { ADD } %- { SUB } %* { MUL } %/ { DIV } +%< { LTH } %> { GTH } %= { EQU } %! { NEQ } +%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 } +%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 } + %RTN { JMP2r } -%8+ { #0008 ADD2 } -%8/ { #0008 DIV2 } -%2/ { #0002 DIV2 } -%++ { #0001 ADD2 } %TOS { #00 SWP } -%MOD { DUP2 DIV MUL SUB } -%LTS2 { #8000 ADD2 SWP2 #8000 ADD2 GTH2 } -%GTS2 { #8000 ADD2 SWP2 #8000 ADD2 LTH2 } +%MOD { DUP2 / * - } +%LTS2 { #8000 ++ SWP2 #8000 ++ >> } +%GTS2 { #8000 ++ SWP2 #8000 ++ << } %WAVEFORM { #1000 } @@ -32,7 +33,6 @@ @color $1 @pointer [ &x $2 &y $2 ] @center [ &x $2 &y $2 ] -@knob [ &x $2 &y $2 &value $1 ] @adsr-view [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ] @wave-view [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ] @octave-view [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ] @@ -48,36 +48,36 @@ ( vectors ) ;on-control .Controller/vector DEO2 - ;on-mouse .Mouse/vector DEO2 - ;on-midi .Midi/vector DEO2 - ;on-frame .Screen/vector DEO2 + ;on-mouse .Mouse/vector DEO2 + ;on-midi .Midi/vector DEO2 + ;on-frame .Screen/vector DEO2 ( load waveform ) ;sin-path .File/name DEO2 #0100 .File/length DEO2 WAVEFORM .File/load DEO2 - ;tri-path .File/name DEO2 #0100 .File/length DEO2 WAVEFORM #0100 ADD2 .File/load DEO2 - ;sqr-path .File/name DEO2 #0100 .File/length DEO2 WAVEFORM #0200 ADD2 .File/load DEO2 + ;tri-path .File/name DEO2 #0100 .File/length DEO2 WAVEFORM #0100 ++ .File/load DEO2 + ;sqr-path .File/name DEO2 #0100 .File/length DEO2 WAVEFORM #0200 ++ .File/load DEO2 ( find center ) - .Screen/width DEI2 2/ .center/x POK2 - .Screen/height DEI2 2/ .center/y POK2 + .Screen/width DEI2 #0002 // .center/x POK2 + .Screen/height DEI2 #0002 // .center/y POK2 ( place octave ) - .center/x PEK2 #0080 SUB2 .octave-view/x1 POK2 - .center/y PEK2 8+ .octave-view/y1 POK2 - .octave-view/x1 PEK2 #0050 ADD2 .octave-view/x2 POK2 - .octave-view/y1 PEK2 #0018 ADD2 .octave-view/y2 POK2 + .center/x PEK2 #0080 -- .octave-view/x1 POK2 + .center/y PEK2 #0008 ++ .octave-view/y1 POK2 + .octave-view/x1 PEK2 #0050 ++ .octave-view/x2 POK2 + .octave-view/y1 PEK2 #0018 ++ .octave-view/y2 POK2 ( place adsr ) - .center/x PEK2 #0020 SUB2 .adsr-view/x1 POK2 - .center/y PEK2 8+ .adsr-view/y1 POK2 - .adsr-view/x1 PEK2 #00a0 ADD2 .adsr-view/x2 POK2 - .adsr-view/y1 PEK2 #0018 ADD2 .adsr-view/y2 POK2 + .center/x PEK2 #0020 -- .adsr-view/x1 POK2 + .center/y PEK2 #0008 ++ .adsr-view/y1 POK2 + .adsr-view/x1 PEK2 #00a0 ++ .adsr-view/x2 POK2 + .adsr-view/y1 PEK2 #0018 ++ .adsr-view/y2 POK2 ( place waveform ) - .center/x PEK2 #0080 SUB2 .wave-view/x1 POK2 - .center/y PEK2 #0020 SUB2 .wave-view/y1 POK2 - .wave-view/x1 PEK2 #0100 ADD2 .wave-view/x2 POK2 - .wave-view/y1 PEK2 #0020 ADD2 .wave-view/y2 POK2 + .center/x PEK2 #0080 -- .wave-view/x1 POK2 + .center/y PEK2 #0020 -- .wave-view/y1 POK2 + .wave-view/x1 PEK2 #0100 ++ .wave-view/x2 POK2 + .wave-view/y1 PEK2 #0020 ++ .wave-view/y2 POK2 ( default settings ) #ff .last-note POK @@ -95,50 +95,50 @@ BRK @on-frame ( -> ) - .adsr-view/y2 PEK2 #0020 SUB2 .Screen/y DEO2 + .adsr-view/y2 PEK2 #0020 -- .Screen/y DEO2 #00 #10 &loop - .adsr-view/x2 PEK2 #003a SUB2 .Screen/x DEO2 - OVR #10 SWP SUB .Audio0/output DEI #0f AND LTH .Screen/color DEO - .adsr-view/x2 PEK2 #003a SUB2 #0002 ADD2 .Screen/x DEO2 - OVR #10 SWP SUB .Audio0/output DEI #04 SFT LTH .Screen/color DEO - .Screen/y DEI2 #0002 ADD2 .Screen/y DEO2 - ( incr ) SWP #01 ADD SWP - DUP2 LTH ,&loop JNZ + .adsr-view/x2 PEK2 #003a -- .Screen/x DEO2 + OVR #10 SWP - .Audio0/output DEI #0f AND < .Screen/color DEO + .adsr-view/x2 PEK2 #003a -- #0002 ++ .Screen/x DEO2 + OVR #10 SWP - .Audio0/output DEI #04 SFT < .Screen/color DEO + .Screen/y DEI2 #0002 ++ .Screen/y DEO2 + ( incr ) SWP #01 + SWP + DUP2 < ,&loop JNZ POP2 BRK @on-midi ( -> ) - .Midi/note DEI #00 NEQ ,&note-on JNZ BRK &note-on - .Midi/note DEI .Audio0/pitch .Midi/channel DEI #04 MOD #10 MUL ADD DEO + .Midi/note DEI #00 ! #01 JNZ [ BRK ] + .Midi/note DEI .Audio0/pitch .Midi/channel DEI #04 MOD #10 * + DEO BRK @on-mouse ( -> ) ;draw-cursor JSR2 - .Mouse/state DEI #00 NEQ ,&no-touch JNZ BRK &no-touch + .Mouse/state DEI #00 ! #01 JNZ [ BRK ] ( wave-view ) - .Mouse/x DEI2 DUP2 .wave-view/x1 PEK2 GTH2 ROT ROT .wave-view/x2 PEK2 #0001 ADD2 LTH2 #0101 EQU2 - .Mouse/y DEI2 DUP2 .wave-view/y1 PEK2 GTH2 ROT ROT .wave-view/y2 PEK2 LTH2 #0101 EQU2 - #0101 EQU2 ;on-touch-wave-view JNZ2 + .Mouse/x DEI2 DUP2 .wave-view/x1 PEK2 >> ROT ROT .wave-view/x2 PEK2 #0001 ++ << #0101 == + .Mouse/y DEI2 DUP2 .wave-view/y1 PEK2 >> ROT ROT .wave-view/y2 PEK2 << #0101 == + #0101 == ;on-touch-wave-view JNZ2 ( adsr-view ) - .Mouse/x DEI2 DUP2 .adsr-view/x1 PEK2 GTH2 ROT ROT .adsr-view/x2 PEK2 LTH2 #0101 EQU2 - .Mouse/y DEI2 DUP2 .adsr-view/y1 PEK2 GTH2 ROT ROT .adsr-view/y2 PEK2 LTH2 #0101 EQU2 - #0101 EQU2 ;on-touch-adsr-view JNZ2 + .Mouse/x DEI2 DUP2 .adsr-view/x1 PEK2 >> ROT ROT .adsr-view/x2 PEK2 << #0101 == + .Mouse/y DEI2 DUP2 .adsr-view/y1 PEK2 >> ROT ROT .adsr-view/y2 PEK2 << #0101 == + #0101 == ;on-touch-adsr-view JNZ2 ( octave-view ) - .Mouse/x DEI2 DUP2 .octave-view/x1 PEK2 GTH2 ROT ROT .octave-view/x2 PEK2 LTH2 #0101 EQU2 - .Mouse/y DEI2 DUP2 .octave-view/y1 PEK2 GTH2 ROT ROT .octave-view/y2 PEK2 LTH2 #0101 EQU2 - #0101 EQU2 ;on-touch-octave-view JNZ2 + .Mouse/x DEI2 DUP2 .octave-view/x1 PEK2 >> ROT ROT .octave-view/x2 PEK2 << #0101 == + .Mouse/y DEI2 DUP2 .octave-view/y1 PEK2 >> ROT ROT .octave-view/y2 PEK2 << #0101 == + #0101 == ;on-touch-octave-view JNZ2 BRK @on-touch-wave-view ( -> ) - .Mouse/x DEI2 .wave-view/x1 PEK2 SUB2 .Audio0/length DEO2 + .Mouse/x DEI2 .wave-view/x1 PEK2 -- .Audio0/length DEO2 ;draw-wave JSR2 ;draw-cursor JSR2 @@ -146,20 +146,20 @@ BRK @on-touch-octave-view ( -> ) - .Mouse/x DEI2 .octave-view/x1 PEK2 SUB2 8/ SWP POP #09 NEQ ,&no-mod JNZ - .Mouse/y DEI2 .octave-view/y1 PEK2 SUB2 8/ SWP POP - DUP #00 NEQ ,&no-incr JNZ - .octave PEK #01 ADD .octave POK &no-incr - DUP #02 NEQ ,&no-decr JNZ - .octave PEK #01 SUB .octave POK &no-decr + .Mouse/x DEI2 .octave-view/x1 PEK2 -- #0008 // SWP POP #09 ! ,&no-mod JNZ + .Mouse/y DEI2 .octave-view/y1 PEK2 -- #0008 // SWP POP + DUP #00 ! ,&no-incr JNZ + .octave PEK #01 + .octave POK &no-incr + DUP #02 ! ,&no-decr JNZ + .octave PEK #01 - .octave POK &no-decr POP ( release ) #00 .Mouse/state DEO ;draw-octave JSR2 BRK &no-mod - .Mouse/x DEI2 .octave-view/x1 PEK2 SUB2 8/ SWP POP #06 GTH ,&no-key JNZ - .Mouse/x DEI2 .octave-view/x1 PEK2 SUB2 8/ DUP2 SWP POP .last-note POK ;notes ADD2 LDA ;play JSR2 + .Mouse/x DEI2 .octave-view/x1 PEK2 -- #0008 // SWP POP #06 > ,&no-key JNZ + .Mouse/x DEI2 .octave-view/x1 PEK2 -- #0008 // DUP2 SWP POP .last-note POK ;notes ++ LDA ;play JSR2 ( release ) #00 .Mouse/state DEO ;draw-octave JSR2 &no-key @@ -168,30 +168,30 @@ BRK @on-touch-adsr-view ( -> ) - .Mouse/x DEI2 .adsr-view/x1 PEK2 SUB2 8/ SWP POP #03 DIV - DUP #00 NEQ ,&no-a JNZ + .Mouse/x DEI2 .adsr-view/x1 PEK2 -- #0008 // SWP POP #03 / + DUP #00 ! ,&no-a JNZ .Audio0/adsr DEI - #10 .Mouse/state DEI #10 EQU #e0 MUL ADD ADD + #10 .Mouse/state DEI #10 = #e0 * + + .Audio0/adsr DEO &no-a - DUP #01 NEQ ,&no-d JNZ + DUP #01 ! ,&no-d JNZ .Audio0/adsr DEI - DUP #f0 AND STH #01 .Mouse/state DEI #10 EQU #0e MUL ADD ADD #0f AND STHr ADD + DUP #f0 AND STH #01 .Mouse/state DEI #10 = #0e * + + #0f AND STHr + .Audio0/adsr DEO &no-d - DUP #02 NEQ ,&no-s JNZ - .Audio0/adsr #01 ADD DEI - #10 .Mouse/state DEI #10 EQU #e0 MUL ADD ADD - .Audio0/adsr #01 ADD DEO &no-s - DUP #03 NEQ ,&no-r JNZ - .Audio0/adsr #01 ADD DEI - DUP #f0 AND STH #01 .Mouse/state DEI #10 EQU #0e MUL ADD ADD #0f AND STHr ADD - .Audio0/adsr #01 ADD DEO &no-r - DUP #05 NEQ ,&no-left JNZ + DUP #02 ! ,&no-s JNZ + .Audio0/adsr #01 + DEI + #10 .Mouse/state DEI #10 = #e0 * + + + .Audio0/adsr #01 + DEO &no-s + DUP #03 ! ,&no-r JNZ + .Audio0/adsr #01 + DEI + DUP #f0 AND STH #01 .Mouse/state DEI #10 = #0e * + + #0f AND STHr + + .Audio0/adsr #01 + DEO &no-r + DUP #05 ! ,&no-left JNZ .Audio0/volume DEI - #10 .Mouse/state DEI #10 EQU #e0 MUL ADD ADD + #10 .Mouse/state DEI #10 = #e0 * + + .Audio0/volume DEO &no-left - DUP #06 NEQ ,&no-right JNZ + DUP #06 ! ,&no-right JNZ .Audio0/volume DEI - DUP #f0 AND STH #01 .Mouse/state DEI #10 EQU #0e MUL ADD ADD #0f AND STHr ADD + DUP #f0 AND STH #01 .Mouse/state DEI #10 = #0e * + + #0f AND STHr + .Audio0/volume DEO &no-right POP @@ -204,39 +204,39 @@ BRK @on-control ( -> ) ( clear last cursor ) - ;clear .Screen/addr DEO2 + #fff8 .Screen/addr DEO2 .pointer/x PEK2 .Screen/x DEO2 .pointer/y PEK2 .Screen/y DEO2 #30 .Screen/color DEO .Controller/key DEI - DUP #61 NEQ ,&no-c JNZ + DUP #61 ! ,&no-c JNZ #00 .last-note POK ;notes LDA ;play JSR2 &no-c - DUP #73 NEQ ,&no-d JNZ - #01 .last-note POK ;notes ++ LDA ;play JSR2 &no-d - DUP #64 NEQ ,&no-e JNZ - #02 .last-note POK ;notes #0002 ADD2 LDA ;play JSR2 &no-e - DUP #66 NEQ ,&no-f JNZ - #03 .last-note POK ;notes #0003 ADD2 LDA ;play JSR2 &no-f - DUP #67 NEQ ,&no-g JNZ - #04 .last-note POK ;notes #0004 ADD2 LDA ;play JSR2 &no-g - DUP #68 NEQ ,&no-a JNZ - #05 .last-note POK ;notes #0005 ADD2 LDA ;play JSR2 &no-a - DUP #6a NEQ ,&no-b JNZ - #06 .last-note POK ;notes #0006 ADD2 LDA ;play JSR2 &no-b - DUP #6b NEQ ,&no-c2 JNZ - #07 .last-note POK ;notes #0007 ADD2 LDA ;play JSR2 &no-c2 + DUP #73 ! ,&no-d JNZ + #01 .last-note POK ;notes #0001 ++ LDA ;play JSR2 &no-d + DUP #64 ! ,&no-e JNZ + #02 .last-note POK ;notes #0002 ++ LDA ;play JSR2 &no-e + DUP #66 ! ,&no-f JNZ + #03 .last-note POK ;notes #0003 ++ LDA ;play JSR2 &no-f + DUP #67 ! ,&no-g JNZ + #04 .last-note POK ;notes #0004 ++ LDA ;play JSR2 &no-g + DUP #68 ! ,&no-a JNZ + #05 .last-note POK ;notes #0005 ++ LDA ;play JSR2 &no-a + DUP #6a ! ,&no-b JNZ + #06 .last-note POK ;notes #0006 ++ LDA ;play JSR2 &no-b + DUP #6b ! ,&no-c2 JNZ + #07 .last-note POK ;notes #0007 ++ LDA ;play JSR2 &no-c2 POP .Controller/button DEI #f0 AND - DUP #04 SFT #01 AND #01 NEQ ,&no-up JNZ - ( move ) .Audio0/addr DEI2 #0001 SUB2 .Audio0/addr DEO2 &no-up - DUP #05 SFT #01 AND #01 NEQ ,&no-down JNZ - ( move ) .Audio0/addr DEI2 #0001 ADD2 .Audio0/addr DEO2 &no-down - DUP #06 SFT #01 AND #01 NEQ ,&no-left JNZ - ( move ) .Audio0/addr DEI2 #0010 SUB2 .Audio0/addr DEO2 &no-left - DUP #07 SFT #01 AND #01 NEQ ,&no-right JNZ - ( move ) .Audio0/addr DEI2 #0010 ADD2 .Audio0/addr DEO2 &no-right + DUP #04 SFT #01 AND #01 ! ,&no-up JNZ + ( move ) .Audio0/addr DEI2 #0001 -- .Audio0/addr DEO2 &no-up + DUP #05 SFT #01 AND #01 ! ,&no-down JNZ + ( move ) .Audio0/addr DEI2 #0001 ++ .Audio0/addr DEO2 &no-down + DUP #06 SFT #01 AND #01 ! ,&no-left JNZ + ( move ) .Audio0/addr DEI2 #0010 -- .Audio0/addr DEO2 &no-left + DUP #07 SFT #01 AND #01 ! ,&no-right JNZ + ( move ) .Audio0/addr DEI2 #0010 ++ .Audio0/addr DEO2 &no-right POP ;draw-octave JSR2 @@ -246,14 +246,14 @@ BRK @play ( pitch -- ) - DUP .octave PEK #0c MUL ADD .Audio0/pitch DEO + DUP .octave PEK #0c * + .Audio0/pitch DEO RTN @draw-cursor ( -- ) ( clear last cursor ) - ;clear .Screen/addr DEO2 + #fff8 .Screen/addr DEO2 .pointer/x PEK2 .Screen/x DEO2 .pointer/y PEK2 .Screen/y DEO2 #30 .Screen/color DEO @@ -265,7 +265,7 @@ RTN .pointer/x PEK2 .Screen/x DEO2 .pointer/y PEK2 .Screen/y DEO2 ( colorize on state ) - #31 [ .Mouse/state DEI #00 NEQ ] ADD .Screen/color DEO + #31 [ .Mouse/state DEI #00 ! ] + .Screen/color DEO RTN @@ -273,26 +273,26 @@ RTN .octave-view/x1 PEK2 .octave-view/y1 PEK2 - OVR2 OVR2 ;keys-left-icns #21 .last-note PEK #00 EQU ADD ;draw-key JSR2 - OVR2 8+ OVR2 ;keys-middle-icns #21 .last-note PEK #01 EQU ADD ;draw-key JSR2 - OVR2 #0010 ADD2 OVR2 ;keys-right-icns #21 .last-note PEK #02 EQU ADD ;draw-key JSR2 - OVR2 #0018 ADD2 OVR2 ;keys-left-icns #21 .last-note PEK #03 EQU ADD ;draw-key JSR2 - OVR2 #0020 ADD2 OVR2 ;keys-middle-icns #21 .last-note PEK #04 EQU ADD ;draw-key JSR2 - OVR2 #0028 ADD2 OVR2 ;keys-middle-icns #21 .last-note PEK #05 EQU ADD ;draw-key JSR2 - SWP2 #0030 ADD2 SWP2 ;keys-right-icns #21 .last-note PEK #06 EQU ADD ;draw-key JSR2 + OVR2 OVR2 ;keys-left-icns #21 .last-note PEK #00 = + ;draw-key JSR2 + OVR2 #0008 ++ OVR2 ;keys-middle-icns #21 .last-note PEK #01 = + ;draw-key JSR2 + OVR2 #0010 ++ OVR2 ;keys-right-icns #21 .last-note PEK #02 = + ;draw-key JSR2 + OVR2 #0018 ++ OVR2 ;keys-left-icns #21 .last-note PEK #03 = + ;draw-key JSR2 + OVR2 #0020 ++ OVR2 ;keys-middle-icns #21 .last-note PEK #04 = + ;draw-key JSR2 + OVR2 #0028 ++ OVR2 ;keys-middle-icns #21 .last-note PEK #05 = + ;draw-key JSR2 + SWP2 #0030 ++ SWP2 ;keys-right-icns #21 .last-note PEK #06 = + ;draw-key JSR2 - .octave-view/x1 PEK2 #0048 ADD2 .Screen/x DEO2 + .octave-view/x1 PEK2 #0048 ++ .Screen/x DEO2 ;arrow-icns .Screen/addr DEO2 .octave-view/y1 PEK2 .Screen/y DEO2 #21 .Screen/color DEO - ;arrow-icns 8+ .Screen/addr DEO2 - .octave-view/y1 PEK2 #0010 ADD2 .Screen/y DEO2 + ;arrow-icns #0008 ++ .Screen/addr DEO2 + .octave-view/y1 PEK2 #0010 ++ .Screen/y DEO2 #21 .Screen/color DEO - ;font-hex .octave PEK #03 ADD #00 SWP #0008 MUL2 ADD2 .Screen/addr DEO2 - .octave-view/y1 PEK2 8+ .Screen/y DEO2 + ;font-hex .octave PEK #03 + #00 SWP #0008 ** ++ .Screen/addr DEO2 + .octave-view/y1 PEK2 #0008 ++ .Screen/y DEO2 #23 .Screen/color DEO RTN @@ -302,38 +302,38 @@ RTN STH .Screen/addr DEO2 SWP2 .Screen/x DEO2 - DUP2 #0018 ADD2 + DUP2 #0018 ++ &loop ( move ) OVR2 .Screen/y DEO2 ( draw ) DUPr STHr .Screen/color DEO - ( incr ) .Screen/addr DEI2 8+ .Screen/addr DEO2 - ( incr ) SWP2 8+ SWP2 - OVR2 OVR2 LTH2 ,&loop JNZ + ( incr ) .Screen/addr DEI2 #0008 ++ .Screen/addr DEO2 + ( incr ) SWP2 #0008 ++ SWP2 + OVR2 OVR2 << ,&loop JNZ POP2 POP2 POPr RTN @draw-adsr ( -- ) - + + ( adsr ) .adsr-view/x1 PEK2 .adsr-view/y1 PEK2 .Audio0/adsr DEI #04 SFT ;draw-knob JSR2 - .adsr-view/x1 PEK2 #0018 ADD2 .adsr-view/y1 PEK2 + .adsr-view/x1 PEK2 #0018 ++ .adsr-view/y1 PEK2 .Audio0/adsr DEI #0f AND ;draw-knob JSR2 - .adsr-view/x1 PEK2 #0030 ADD2 .adsr-view/y1 PEK2 - .Audio0/adsr #01 ADD DEI #04 SFT + .adsr-view/x1 PEK2 #0030 ++ .adsr-view/y1 PEK2 + .Audio0/adsr #01 + DEI #04 SFT ;draw-knob JSR2 - .adsr-view/x1 PEK2 #0048 ADD2 .adsr-view/y1 PEK2 - .Audio0/adsr #01 ADD DEI #0f AND + .adsr-view/x1 PEK2 #0048 ++ .adsr-view/y1 PEK2 + .Audio0/adsr #01 + DEI #0f AND ;draw-knob JSR2 - ( volume ) - .adsr-view/x2 PEK2 #0028 SUB2 .adsr-view/y1 PEK2 + .adsr-view/x2 PEK2 #0028 -- .adsr-view/y1 PEK2 .Audio0/volume DEI #04 SFT ;draw-knob JSR2 - .adsr-view/x2 PEK2 #0010 SUB2 .adsr-view/y1 PEK2 + .adsr-view/x2 PEK2 #0010 -- .adsr-view/y1 PEK2 .Audio0/volume DEI #0f AND ;draw-knob JSR2 @@ -341,9 +341,10 @@ RTN @draw-wave ( -- ) + ( clear ) .wave-view/x1 PEK2 .wave-view/y1 PEK2 - .wave-view/x2 PEK2 ++ + .wave-view/x2 PEK2 #0001 ++ .wave-view/y2 PEK2 #00 ;fill-rect JSR2 @@ -356,23 +357,23 @@ RTN &loop ( dotted line ) OVR #01 AND ,&no-dot JNZ - .wave-view/y1 PEK2 #0010 ADD2 .Screen/y DEO2 + .wave-view/y1 PEK2 #0010 ++ .Screen/y DEO2 #03 .Screen/color DEO &no-dot - OVR TOS .Audio0/addr DEI2 ADD2 LDA - #02 DIV - TOS #0004 DIV2 .wave-view/y1 PEK2 ADD2 .Screen/y DEO2 - .Screen/x DEI2 ++ .Screen/x DEO2 - ( draw ) OVR .Audio0/length DEI2 SWP POP GTH #02 MUL #01 ADD .Screen/color DEO - ( incr ) SWP #01 ADD SWP - DUP2 LTH ,&loop JNZ + OVR TOS .Audio0/addr DEI2 ++ LDA + #02 / + TOS #0004 // .wave-view/y1 PEK2 ++ .Screen/y DEO2 + .Screen/x DEI2 #0001 ++ .Screen/x DEO2 + ( draw ) OVR .Audio0/length DEI2 SWP POP > #02 * #01 + .Screen/color DEO + ( incr ) SWP #01 + SWP + DUP2 < ,&loop JNZ POP2 ( range ) .wave-view/x1 PEK2 .Screen/x DEO2 - .wave-view/y1 PEK2 #0010 SUB2 .Screen/y DEO2 + .wave-view/y1 PEK2 #0010 -- .Screen/y DEO2 .Audio0/addr DEI2 #22 ;draw-short JSR2 - .wave-view/x2 PEK2 #0020 SUB2 .Screen/x DEO2 + .wave-view/x2 PEK2 #0020 -- .Screen/x DEO2 .Audio0/length DEI2 #22 ;draw-short JSR2 RTN @@ -380,13 +381,13 @@ RTN @draw-wave-length ( color -- ) STH - .wave-view/x1 PEK2 .Audio0/length DEI2 ADD2 .Screen/x DEO2 - .wave-view/y1 PEK2 DUP2 #0020 ADD2 + .wave-view/x1 PEK2 .Audio0/length DEI2 ++ .Screen/x DEO2 + .wave-view/y1 PEK2 DUP2 #0020 ++ &loop OVR2 .Screen/y DEO2 ( draw ) DUPr STHr .Screen/color DEO - ( incr ) SWP2 ++ SWP2 - OVR2 OVR2 LTH2 ,&loop JNZ + ( incr ) SWP2 #0001 ++ SWP2 + OVR2 OVR2 << ,&loop JNZ POP2 POP2 POPr @@ -394,37 +395,42 @@ RTN @draw-knob ( x* y* value -- ) - ( load ) .knob/value POK .knob/y POK2 .knob/x POK2 - - .knob/x PEK2 .Screen/x DEO2 - .knob/y PEK2 .Screen/y DEO2 ;knob_icns .Screen/addr DEO2 #21 .Screen/color DEO - .knob/x PEK2 8+ .Screen/x DEO2 ;knob_icns 8+ .Screen/addr DEO2 #21 .Screen/color DEO - .knob/y PEK2 8+ .Screen/y DEO2 ;knob_icns #0018 ADD2 .Screen/addr DEO2 #21 .Screen/color DEO - .knob/x PEK2 .Screen/x DEO2 ;knob_icns #0010 ADD2 .Screen/addr DEO2 #21 .Screen/color DEO - .knob/x PEK2 #00 #00 .knob/value PEK ;knob-offsetx ADD2 LDA ADD2 .Screen/x DEO2 - .knob/y PEK2 #00 #00 .knob/value PEK ;knob-offsety ADD2 LDA ADD2 .Screen/y DEO2 - ;knob_icns #0020 ADD2 .Screen/addr DEO2 - #25 .Screen/color DEO - .knob/x PEK2 #0004 ADD2 .Screen/x DEO2 - .knob/y PEK2 #0010 ADD2 .Screen/y DEO2 - ;font-hex #00 .knob/value PEK #08 MUL ADD2 .Screen/addr DEO2 - #21 .Screen/color DEO + ( 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 + ;font-hex #00 DUPr STHr #08 * ++ .Screen/addr DEO2 + ( draw ) #21 .Screen/color DEO + .Screen/x DEI2 #0004 -- #00 #00 DUPr STHr ;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 ) #25 .Screen/color DEO RTN @draw-short ( short* color -- ) STH SWP - DUP #04 SFT TOS #0008 MUL2 ;font-hex ADD2 .Screen/addr DEO2 + DUP #04 SFT TOS #0008 ** ;font-hex ++ .Screen/addr DEO2 ( draw ) DUPr STHr .Screen/color DEO - #0f AND TOS #0008 MUL2 ;font-hex ADD2 .Screen/addr DEO2 - .Screen/x DEI2 8+ .Screen/x DEO2 + #0f AND TOS #0008 ** ;font-hex ++ .Screen/addr DEO2 + .Screen/x DEI2 #0008 ++ .Screen/x DEO2 ( draw ) DUPr STHr .Screen/color DEO - DUP #04 SFT TOS #0008 MUL2 ;font-hex ADD2 .Screen/addr DEO2 - .Screen/x DEI2 8+ .Screen/x DEO2 + DUP #04 SFT TOS #0008 ** ;font-hex ++ .Screen/addr DEO2 + .Screen/x DEI2 #0008 ++ .Screen/x DEO2 ( draw ) DUPr STHr .Screen/color DEO - #0f AND TOS #0008 MUL2 ;font-hex ADD2 .Screen/addr DEO2 - .Screen/x DEI2 8+ .Screen/x DEO2 + #0f AND TOS #0008 ** ;font-hex ++ .Screen/addr DEO2 + .Screen/x DEI2 #0008 ++ .Screen/x DEO2 ( draw ) STHr .Screen/color DEO RTN @@ -439,18 +445,15 @@ RTN &hor ( save ) OVR2 .Screen/x DEO2 ( draw ) .color PEK .Screen/color DEO - ( incr ) SWP2 ++ SWP2 + ( incr ) SWP2 #0001 ++ SWP2 OVR2 OVR2 LTS2 ,&hor JNZ POP2 POP2 STH2r STH2r - ( incr ) SWP2 ++ SWP2 + ( incr ) SWP2 #0001 ++ SWP2 OVR2 OVR2 LTS2 ,&ver JNZ POP2 POP2 POP2 POP2 RTN -@clear [ - 0000 0000 0000 0000 ] - @cursor [ 80c0 e0f0 f8e0 1000 ] @@ -477,7 +480,7 @@ RTN 1f1f 1f1f 1f1f 3f7f 7f7f 7f7f 7f7f 3e00 ] -@knob_icns [ +@knob-icns [ 0003 0c10 2020 4040 00c0 3008 0404 0202 4040 2020 100c 0300 diff --git a/src/assembler.c b/src/assembler.c @@ -356,7 +356,7 @@ cleanup(char *filename) for(i = 0; i < p.llen; ++i) if(p.labels[i].name[0] >= 'A' && p.labels[i].name[0] <= 'Z') continue; /* Ignore capitalized labels(devices) */ - else if(!p.labels[i].refs && scin(p.labels[i].name, '/') > 0) + else if(!p.labels[i].refs) printf("--- Unused label: %s\n", p.labels[i].name); for(i = 0; i < p.mlen; ++i) if(!p.macros[i].refs)