uxn

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

commit 7f158c9d66b611f80e6ab65680c853d63703984d
parent 00df90c47e0778d9cb3129ec2e2376af2a935d7e
Author: Andrew Alderwick <andrew@alderwick.co.uk>
Date:   Mon, 24 May 2021 22:52:11 +0100

Optimised MUL2 by powers of 2 to SFT2

Diffstat:
Mprojects/demos/bifurcan.usm | 7++++---
Mprojects/demos/drum-rack.usm | 32++++++++++++++++++--------------
Mprojects/demos/life.usm | 13+++++++------
Mprojects/demos/musictracker.usm | 4++--
Mprojects/demos/piano.usm | 11++++++-----
Mprojects/demos/theme.usm | 26++++++++++++++------------
Mprojects/examples/devices/audio.usm | 15+++++++++++----
Mprojects/examples/devices/datetime.usm | 15++++++++-------
Mprojects/examples/devices/mouse.usm | 7++++---
Mprojects/examples/gui/label.usm | 11++++++-----
Mprojects/examples/gui/shapes.usm | 20+++++++++++---------
Mprojects/software/asma.usm | 2+-
Mprojects/software/neralie.usm | 7++++---
Mprojects/software/orca.usm | 42+++++++++++++++++++++---------------------
14 files changed, 117 insertions(+), 95 deletions(-)

diff --git a/projects/demos/bifurcan.usm b/projects/demos/bifurcan.usm @@ -7,6 +7,7 @@ %MOD { DUP2 DIV MUL SUB } %TOS { #00 SWP } %2// { #01 SFT2 } +%8** { #30 SFT2 } ( devices ) @@ -105,11 +106,11 @@ RTN ( save pos ) .anchor/y STZ2 .anchor/x STZ2 #00 #0f &loop - ( save-x ) OVR #03 MOD TOS #0008 MUL2 .anchor/x LDZ2 ADD2 .Screen/x DEO2 - ( save-y ) OVR #03 DIV TOS #0008 MUL2 .anchor/y LDZ2 ADD2 .Screen/y DEO2 + ( save-x ) OVR #03 MOD TOS 8** .anchor/x LDZ2 ADD2 .Screen/x DEO2 + ( save-y ) OVR #03 DIV TOS 8** .anchor/y LDZ2 ADD2 .Screen/y DEO2 ( get digit* ) OVR STHkr #02 MUL TOS ;digits ADD2 LDA2 ( get bit ) ROT #0e SWP SUB SFT2 #0001 AND2 - ( set tile ) #0008 MUL2 ;tiles ADD2 + ( set tile ) 8** ;tiles ADD2 ( set style ) .style LDZ #10 MUL TOS ADD2 .Screen/addr DEO2 ( draw ) #21 .Screen/color DEO diff --git a/projects/demos/drum-rack.usm b/projects/demos/drum-rack.usm @@ -9,6 +9,10 @@ %++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 } %<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 } +%2** { #10 SFT2 } %2// { #01 SFT2 } +%4** { #20 SFT2 } %4// { #02 SFT2 } +%8** { #30 SFT2 } %8// { #03 SFT2 } + %TOB { SWP POP } %TOS { #00 SWP } %RTN { JMP2r } %MOD { DUP2 / * - } @@ -85,14 +89,14 @@ #01 .piano/octave STZ ( find center ) - .Screen/width DEI2 #0002 // .center/x STZ2 - .Screen/height DEI2 #0002 // .center/y STZ2 + .Screen/width DEI2 2// .center/x STZ2 + .Screen/height DEI2 2// .center/y STZ2 ( place frame ) .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 - .frame/y1 LDZ2 PAD-HEIGHT #0004 ** ++ #0028 ++ .frame/y2 STZ2 + .frame/y1 LDZ2 PAD-HEIGHT 4** ++ #0028 ++ .frame/y2 STZ2 ( place pad-view ) .frame/x1 LDZ2 .pad-view/x1 STZ2 @@ -136,7 +140,7 @@ ( 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 + OVR TOS 2** ;pad-addr ++ LDA2 .File/load DEO2 ( draw pad ) OVR #01 ;draw-pad JSR2 ( draw mixer ) @@ -287,8 +291,8 @@ BRK @on-touch-oct ( -> ) - .Mouse/x DEI2 .oct-view/x1 LDZ2 -- #0008 // TOB #08 ! ,&no-mod JCN - .Mouse/y DEI2 .oct-view/y1 LDZ2 -- #0008 // TOB + .Mouse/x DEI2 .oct-view/x1 LDZ2 -- 8// TOB #08 ! ,&no-mod JCN + .Mouse/y DEI2 .oct-view/y1 LDZ2 -- 8// TOB DUP #00 ! ,&no-incr JCN .piano/octave LDZ #01 + .piano/octave STZ &no-incr DUP #02 ! ,&no-decr JCN @@ -299,8 +303,8 @@ BRK BRK &no-mod - .Mouse/x DEI2 .oct-view/x1 LDZ2 -- #0008 // TOB #06 GTH ,&no-key JCN - .Mouse/x DEI2 .oct-view/x1 LDZ2 -- #0008 // + .Mouse/x DEI2 .oct-view/x1 LDZ2 -- 8// TOB #06 GTH ,&no-key JCN + .Mouse/x DEI2 .oct-view/x1 LDZ2 -- 8// ( set pitch of pad ) DUP2 ;notes ++ LDA .pads/last LDZ SWP .piano/octave LDZ #02 - #0c * + ( save ) SWP TOS ;pad-pitch ++ STA @@ -321,7 +325,7 @@ BRK ( highlight ) DUP #02 ;draw-pad JSR2 ( addr ) - DUP TOS #0002 ** ;pad-addr ++ LDA2 STH2 + DUP TOS 2** ;pad-addr ++ LDA2 STH2 DUP #04 / #10 * .Audio0/addr + STH2r ROT DEO2 ( pitch ) DUP TOS ;pad-pitch ++ LDA STH @@ -355,7 +359,7 @@ RTN &no-dot OVR TOS #0010 ** [ DUP2r STH2r ] ++ LDA #02 / - TOS #0004 // .wav-view/y1 LDZ2 ++ .Screen/y DEO2 + TOS 4// .wav-view/y1 LDZ2 ++ .Screen/y DEO2 .Screen/x DEI2 #0001 ++ .Screen/x DEO2 ( draw ) #02 .Screen/color DEO ( incr ) SWP #01 + SWP @@ -417,14 +421,14 @@ RTN OVR2 #0003 ++ .Screen/x DEO2 DUP2 #0014 ++ .Screen/y DEO2 ( get pitch ) STHkr TOS ;pad-pitch ++ LDA - #0c / TOS #0008 ** ;font-hex ++ .Screen/addr DEO2 + #0c / TOS 8** ;font-hex ++ .Screen/addr DEO2 #21 .Screen/color DEO ( draw octave ) OVR2 #000b ++ .Screen/x DEO2 DUP2 #0014 ++ .Screen/y DEO2 ( get pitch ) STHkr TOS ;pad-pitch ++ LDA - #0c MOD TOS #0008 ** ;font-notes ++ .Screen/addr DEO2 + #0c MOD TOS 8** ;font-notes ++ .Screen/addr DEO2 #21 .Screen/color DEO POP2 POP2 @@ -455,7 +459,7 @@ RTN .oct-view/y1 LDZ2 #0010 ++ .Screen/y DEO2 #21 .Screen/color DEO - ;font-hex .piano/octave LDZ #03 + #00 SWP #0008 ** ++ .Screen/addr DEO2 + ;font-hex .piano/octave LDZ #03 + #00 SWP 8** ++ .Screen/addr DEO2 .oct-view/y1 LDZ2 #0008 ++ .Screen/y DEO2 #23 .Screen/color DEO @@ -589,7 +593,7 @@ RTN ( load ) STH STH2 .Screen/y DEO2 .Screen/x DEO2 STH2r &loop - DUP2 LDA #00 SWP #0030 -- #0008 ** ;font-num-uc ++ .Screen/addr DEO2 + DUP2 LDA #00 SWP #0030 -- 8** ;font-num-uc ++ .Screen/addr DEO2 ( draw ) STHkr .Screen/color DEO ( incr ) #0001 ++ ( incr ) .Screen/x DEI2 #0008 ++ .Screen/x DEO2 diff --git a/projects/demos/life.usm b/projects/demos/life.usm @@ -16,6 +16,7 @@ %MOD8 { #07 AND } %MOD2 { #01 AND } %SFL { #40 SFT SFT } %2// { #01 SFT2 } %8// { #03 SFT2 } +%2** { #10 SFT2 } %8** { #30 SFT2 } %WIDTH { #40 } %HEIGHT { #40 } %BANK1 { #8000 } %BANK2 { #a000 } @@ -151,10 +152,10 @@ BRK #00 HEIGHT &ver - OVR TOS #0002 ** .anchor/y LDZ2 ++ .Screen/y DEO2 + OVR TOS 2** .anchor/y LDZ2 ++ .Screen/y DEO2 #00 WIDTH &hor - OVR TOS #0002 ** .anchor/x LDZ2 ++ .Screen/x DEO2 + OVR TOS 2** .anchor/x LDZ2 ++ .Screen/x DEO2 GET-ITERATORS ,get-cell JSR #01 + .Screen/color DEO INCR NEQk ,&hor JCN @@ -256,15 +257,15 @@ RTN @draw-short ( short* color -- ) STH SWP - DUP #04 SFT TOS #0008 ** ;font-hex ++ .Screen/addr DEO2 + DUP #04 SFT TOS 8** ;font-hex ++ .Screen/addr DEO2 ( draw ) STHkr .Screen/color DEO - #0f AND TOS #0008 ** ;font-hex ++ .Screen/addr DEO2 + #0f AND TOS 8** ;font-hex ++ .Screen/addr DEO2 .Screen/x DEI2 #0008 ++ .Screen/x DEO2 ( draw ) STHkr .Screen/color DEO - DUP #04 SFT TOS #0008 ** ;font-hex ++ .Screen/addr DEO2 + DUP #04 SFT TOS 8** ;font-hex ++ .Screen/addr DEO2 .Screen/x DEI2 #0008 ++ .Screen/x DEO2 ( draw ) STHkr .Screen/color DEO - #0f AND TOS #0008 ** ;font-hex ++ .Screen/addr DEO2 + #0f AND TOS 8** ;font-hex ++ .Screen/addr DEO2 .Screen/x DEI2 #0008 ++ .Screen/x DEO2 ( draw ) STHr .Screen/color DEO diff --git a/projects/demos/musictracker.usm b/projects/demos/musictracker.usm @@ -2,10 +2,10 @@ %RTN { JMP2r } %8++ { #0008 ADD2 } %8-- { #0008 SUB2 } -%8** { #0008 MUL2 } %8// { #03 SFT2 } +%8** { #30 SFT2 } %8// { #03 SFT2 } %++ { #0001 ADD2 } %2// { #01 SFT2 } %MOD8 { #07 AND } -%TRACK { ;track/ch1 #00 .track/active LDZ #0020 MUL2 ADD2 } +%TRACK { ;track/ch1 #00 .track/active LDZ #50 SFT2 ADD2 } ( variables ) diff --git a/projects/demos/piano.usm b/projects/demos/piano.usm @@ -14,6 +14,7 @@ %2// { #01 SFT2 } %4// { #02 SFT2 } %8// { #03 SFT2 } +%8** { #30 SFT2 } %WAVEFORM { #1000 } @@ -295,7 +296,7 @@ RTN .octave-view/y1 LDZ2 #0010 ++ .Screen/y DEO2 #21 .Screen/color DEO - ;font-hex .octave LDZ #03 + #00 SWP #0008 ** ++ .Screen/addr DEO2 + ;font-hex .octave LDZ #03 + #00 SWP 8** ++ .Screen/addr DEO2 .octave-view/y1 LDZ2 #0008 ++ .Screen/y DEO2 #23 .Screen/color DEO @@ -425,15 +426,15 @@ RTN @draw-short ( short* color -- ) STH SWP - DUP #04 SFT TOS #0008 ** ;font-hex ++ .Screen/addr DEO2 + DUP #04 SFT TOS 8** ;font-hex ++ .Screen/addr DEO2 ( draw ) STHkr .Screen/color DEO - #0f AND TOS #0008 ** ;font-hex ++ .Screen/addr DEO2 + #0f AND TOS 8** ;font-hex ++ .Screen/addr DEO2 .Screen/x DEI2 #0008 ++ .Screen/x DEO2 ( draw ) STHkr .Screen/color DEO - DUP #04 SFT TOS #0008 ** ;font-hex ++ .Screen/addr DEO2 + DUP #04 SFT TOS 8** ;font-hex ++ .Screen/addr DEO2 .Screen/x DEI2 #0008 ++ .Screen/x DEO2 ( draw ) STHkr .Screen/color DEO - #0f AND TOS #0008 ** ;font-hex ++ .Screen/addr DEO2 + #0f AND TOS 8** ;font-hex ++ .Screen/addr DEO2 .Screen/x DEI2 #0008 ++ .Screen/x DEO2 ( draw ) STHr .Screen/color DEO diff --git a/projects/demos/theme.usm b/projects/demos/theme.usm @@ -4,6 +4,8 @@ %++ { #0001 ADD2 } %2// { #01 SFT2 } %4// { #02 SFT2 } +%4** { #20 SFT2 } +%8** { #30 SFT2 } %8+ { #0008 ADD2 } %STEP8 { #33 SFT2 } @@ -213,28 +215,28 @@ RTN .window/x1 LDZ2 #0038 ADD2 .Screen/x DEO2 .System/b DEI2 #28 ;draw-short JSR2 - .window/x1 LDZ2 #0060 ADD2 .window/y1 LDZ2 #0010 ADD2 .window/x1 LDZ2 #0090 ADD2 #00 ;theme/r1 .selection LDZ ADD LDA #0004 MUL2 #01 ;draw-slider JSR2 - .window/x1 LDZ2 #0060 ADD2 .window/y1 LDZ2 #0020 ADD2 .window/x1 LDZ2 #0090 ADD2 #00 ;theme/g1 .selection LDZ ADD LDA #0004 MUL2 #01 ;draw-slider JSR2 - .window/x1 LDZ2 #0060 ADD2 .window/y1 LDZ2 #0030 ADD2 .window/x1 LDZ2 #0090 ADD2 #00 ;theme/b1 .selection LDZ ADD LDA #0004 MUL2 #01 ;draw-slider JSR2 + .window/x1 LDZ2 #0060 ADD2 .window/y1 LDZ2 #0010 ADD2 .window/x1 LDZ2 #0090 ADD2 #00 ;theme/r1 .selection LDZ ADD LDA 4** #01 ;draw-slider JSR2 + .window/x1 LDZ2 #0060 ADD2 .window/y1 LDZ2 #0020 ADD2 .window/x1 LDZ2 #0090 ADD2 #00 ;theme/g1 .selection LDZ ADD LDA 4** #01 ;draw-slider JSR2 + .window/x1 LDZ2 #0060 ADD2 .window/y1 LDZ2 #0030 ADD2 .window/x1 LDZ2 #0090 ADD2 #00 ;theme/b1 .selection LDZ ADD LDA 4** #01 ;draw-slider JSR2 .window/x1 LDZ2 #0050 ADD2 .Screen/x DEO2 .window/y1 LDZ2 #0040 ADD2 .Screen/y DEO2 - ;radio_icns #00 .selection LDZ #00 EQU #0008 MUL2 ADD2 .Screen/addr DEO2 + ;radio_icns #00 .selection LDZ #00 EQU 8** ADD2 .Screen/addr DEO2 #25 .Screen/color DEO .window/x1 LDZ2 #0060 ADD2 .Screen/x DEO2 .window/y1 LDZ2 #0040 ADD2 .Screen/y DEO2 - ;radio_icns #00 .selection LDZ #01 EQU #0008 MUL2 ADD2 .Screen/addr DEO2 + ;radio_icns #00 .selection LDZ #01 EQU 8** ADD2 .Screen/addr DEO2 #25 .Screen/color DEO .window/x1 LDZ2 #0070 ADD2 .Screen/x DEO2 .window/y1 LDZ2 #0040 ADD2 .Screen/y DEO2 - ;radio_icns #00 .selection LDZ #02 EQU #0008 MUL2 ADD2 .Screen/addr DEO2 + ;radio_icns #00 .selection LDZ #02 EQU 8** ADD2 .Screen/addr DEO2 #25 .Screen/color DEO .window/x1 LDZ2 #0080 ADD2 .Screen/x DEO2 .window/y1 LDZ2 #0040 ADD2 .Screen/y DEO2 - ;radio_icns #00 .selection LDZ #03 EQU #0008 MUL2 ADD2 .Screen/addr DEO2 + ;radio_icns #00 .selection LDZ #03 EQU 8** ADD2 .Screen/addr DEO2 #25 .Screen/color DEO RTN @@ -328,7 +330,7 @@ RTN .Screen/x DEO2 STH2r &loop - DUP2 LDA #00 SWP #0008 MUL2 + DUP2 LDA #00 SWP 8** ;font ADD2 .Screen/addr DEO2 ( draw ) STHkr .Screen/color DEO ( incr ) ++ @@ -341,15 +343,15 @@ RTN @draw-short ( short* color -- ) STH SWP - DUP #04 SFT #00 SWP #0008 MUL2 ;font-hex ADD2 .Screen/addr DEO2 + DUP #04 SFT #00 SWP 8** ;font-hex ADD2 .Screen/addr DEO2 ( draw ) STHkr .Screen/color DEO - #0f AND #00 SWP #0008 MUL2 ;font-hex ADD2 .Screen/addr DEO2 + #0f AND #00 SWP 8** ;font-hex ADD2 .Screen/addr DEO2 .Screen/x DEI2 8+ .Screen/x DEO2 ( draw ) STHkr .Screen/color DEO - DUP #04 SFT #00 SWP #0008 MUL2 ;font-hex ADD2 .Screen/addr DEO2 + DUP #04 SFT #00 SWP 8** ;font-hex ADD2 .Screen/addr DEO2 .Screen/x DEI2 8+ .Screen/x DEO2 ( draw ) STHkr .Screen/color DEO - #0f AND #00 SWP #0008 MUL2 ;font-hex ADD2 .Screen/addr DEO2 + #0f AND #00 SWP 8** ;font-hex ADD2 .Screen/addr DEO2 .Screen/x DEI2 8+ .Screen/x DEO2 ( draw ) STHr .Screen/color DEO diff --git a/projects/examples/devices/audio.usm b/projects/examples/devices/audio.usm @@ -1,7 +1,7 @@ ( dev/audio ) -@timer $1 -@progress $1 +%4** { #20 SFT2 } +%8** { #30 SFT2 } ( devices ) @@ -9,6 +9,13 @@ |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 ] +( variables ) + +|0000 + +@timer $1 +@progress $1 + |0100 ( -> ) ( theme ) @@ -42,8 +49,8 @@ BRK #20 .Screen/color DEO ( draw note ) - #00 SWP #0004 MUL2 #0100 SUB2 .Screen/y DEO2 - #00 .progress LDZ #0008 MUL2 .Screen/x DEO2 + #00 SWP 4** #0100 SUB2 .Screen/y DEO2 + #00 .progress LDZ 8** .Screen/x DEO2 ;dot .Screen/addr DEO2 #21 .Screen/color DEO diff --git a/projects/examples/devices/datetime.usm b/projects/examples/devices/datetime.usm @@ -2,6 +2,7 @@ %2// { #01 SFT2 } %4// { #02 SFT2 } +%2** { #10 SFT2 } %RTN { JMP2r } %MOD { DUP2 DIV MUL SUB } @@ -54,13 +55,13 @@ BRK #0080 SCALEX #0080 SCALEY .needles/hx LDZ2 .needles/hy LDZ2 #00 ;draw-line JSR2 ( place ) - #00 .DateTime/second DEI #0002 MUL2 ;table ADD2 LDA2 + #00 .DateTime/second DEI 2** ;table ADD2 LDA2 #00 SWP SCALEY .needles/sy STZ2 #00 SWP SCALEX .needles/sx STZ2 - #00 .DateTime/minute DEI #0002 MUL2 ;table ADD2 LDA2 + #00 .DateTime/minute DEI 2** ;table ADD2 LDA2 #00 SWP 4// #0003 MUL2 #0020 ADD2 SCALEY .needles/my STZ2 #00 SWP 4// #0003 MUL2 #0020 ADD2 SCALEX .needles/mx STZ2 - #00 .DateTime/hour DEI 12HOURS #05 MUL #0002 MUL2 ;table ADD2 LDA2 + #00 .DateTime/hour DEI 12HOURS #05 MUL 2** ;table ADD2 LDA2 #00 SWP 2// #0040 ADD2 SCALEY .needles/hy STZ2 #00 SWP 2// #0040 ADD2 SCALEX .needles/hx STZ2 @@ -72,7 +73,7 @@ BRK ( circle ) #00 #3c &loop - ( load ) OVR #00 SWP #0002 MUL2 ;table ADD2 LDA2 + ( load ) OVR #00 SWP 2** ;table ADD2 LDA2 #00 SWP SCALEY .Screen/y DEO2 #00 SWP SCALEX .Screen/x DEO2 OVR #0f MOD #00 EQU #01 ADD .Screen/color DEO @@ -115,8 +116,8 @@ RTN ( load ) .color STZ .line/y0 STZ2 .line/x0 STZ2 .line/y STZ2 .line/x STZ2 .line/x0 LDZ2 .line/x LDZ2 SUB2 ABS2 .line/dx STZ2 .line/y0 LDZ2 .line/y LDZ2 SUB2 ABS2 #0000 SWP2 SUB2 .line/dy STZ2 - #ffff #00 .line/x LDZ2 .line/x0 LDZ2 LTS2 #0002 MUL2 ADD2 .line/sx STZ2 - #ffff #00 .line/y LDZ2 .line/y0 LDZ2 LTS2 #0002 MUL2 ADD2 .line/sy STZ2 + #ffff #00 .line/x LDZ2 .line/x0 LDZ2 LTS2 2** ADD2 .line/sx STZ2 + #ffff #00 .line/y LDZ2 .line/y0 LDZ2 LTS2 2** ADD2 .line/sy STZ2 .line/dx LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2 &loop .line/x LDZ2 .Screen/x DEO2 @@ -124,7 +125,7 @@ RTN .color LDZ .Screen/color DEO [ .line/x LDZ2 .line/x0 LDZ2 EQU2 ] [ .line/y LDZ2 .line/y0 LDZ2 EQU2 ] #0101 EQU2 ,&end JCN - .line/e1 LDZ2 #0002 MUL2 .line/e2 STZ2 + .line/e1 LDZ2 2** .line/e2 STZ2 .line/e2 LDZ2 .line/dy LDZ2 LTS2 ,&skipy JCN .line/e1 LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2 .line/x LDZ2 .line/sx LDZ2 ADD2 .line/x STZ2 diff --git a/projects/examples/devices/mouse.usm b/projects/examples/devices/mouse.usm @@ -4,6 +4,7 @@ %ABS2 { DUP2 #0f SFT2 EQU #04 JCN #ffff MUL2 } %LTS2 { #8000 ADD2 SWP2 #8000 ADD2 GTH2 } %GTS2 { #8000 ADD2 SWP2 #8000 ADD2 LTH2 } +%2** { #10 SFT2 } ( devices ) @@ -94,8 +95,8 @@ RTN ( load ) .color STZ .line/y0 STZ2 .line/x0 STZ2 .line/y STZ2 .line/x STZ2 .line/x0 LDZ2 .line/x LDZ2 SUB2 ABS2 .line/dx STZ2 .line/y0 LDZ2 .line/y LDZ2 SUB2 ABS2 #0000 SWP2 SUB2 .line/dy STZ2 - #ffff #00 .line/x LDZ2 .line/x0 LDZ2 LTS2 #0002 MUL2 ADD2 .line/sx STZ2 - #ffff #00 .line/y LDZ2 .line/y0 LDZ2 LTS2 #0002 MUL2 ADD2 .line/sy STZ2 + #ffff #00 .line/x LDZ2 .line/x0 LDZ2 LTS2 2** ADD2 .line/sx STZ2 + #ffff #00 .line/y LDZ2 .line/y0 LDZ2 LTS2 2** ADD2 .line/sy STZ2 .line/dx LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2 &loop .line/x LDZ2 .Screen/x DEO2 @@ -103,7 +104,7 @@ RTN .color LDZ .Screen/color DEO [ .line/x LDZ2 .line/x0 LDZ2 EQU2 ] [ .line/y LDZ2 .line/y0 LDZ2 EQU2 ] #0101 EQU2 ,&end JCN - .line/e1 LDZ2 #0002 MUL2 .line/e2 STZ2 + .line/e1 LDZ2 2** .line/e2 STZ2 .line/e2 LDZ2 .line/dy LDZ2 LTS2 ,&skipy JCN .line/e1 LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2 .line/x LDZ2 .line/sx LDZ2 ADD2 .line/x STZ2 diff --git a/projects/examples/gui/label.usm b/projects/examples/gui/label.usm @@ -2,6 +2,7 @@ %RTN { JMP2r } %2// { #01 SFT2 } +%8** { #30 SFT2 } ( devices ) @@ -51,7 +52,7 @@ RTN ( load ) .label/addr STZ2 .label/color STZ .Screen/y DEO2 .Screen/x DEO2 .label/addr LDZ2 &loop - ( draw ) DUP2 LDA #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2 .label/color LDZ .Screen/color DEO + ( draw ) DUP2 LDA #00 SWP 8** ;font ADD2 .Screen/addr DEO2 .label/color LDZ .Screen/color DEO ( incr ) #0001 ADD2 ( incr ) .Screen/x DEI2 #0008 ADD2 .Screen/x DEO2 DUP2 LDA ,&loop JCN @@ -62,10 +63,10 @@ RTN @draw-label-middle ( x y color addr -- ) ( load ) .label/addr STZ2 .label/color STZ .Screen/y DEO2 - ( align ) .label/addr LDZ2 ;get-text-length JSR2 #0008 MUL2 2// SUB2 .Screen/x DEO2 + ( align ) .label/addr LDZ2 ;get-text-length JSR2 8** 2// SUB2 .Screen/x DEO2 .label/addr LDZ2 &loop - ( draw ) DUP2 LDA #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2 .label/color LDZ .Screen/color DEO + ( draw ) DUP2 LDA #00 SWP 8** ;font ADD2 .Screen/addr DEO2 .label/color LDZ .Screen/color DEO ( incr ) #0001 ADD2 ( incr ) .Screen/x DEI2 #0008 ADD2 .Screen/x DEO2 DUP2 LDA ,&loop JCN @@ -76,10 +77,10 @@ RTN @draw-label-right ( x y color addr -- ) ( load ) .label/addr STZ2 .label/color STZ .Screen/y DEO2 - ( align ) .label/addr LDZ2 ;get-text-length JSR2 #0008 MUL2 SUB2 .Screen/x DEO2 + ( align ) .label/addr LDZ2 ;get-text-length JSR2 8** SUB2 .Screen/x DEO2 .label/addr LDZ2 &loop - ( draw ) DUP2 LDA #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2 .label/color LDZ .Screen/color DEO + ( draw ) DUP2 LDA #00 SWP 8** ;font ADD2 .Screen/addr DEO2 .label/color LDZ .Screen/color DEO ( incr ) #0001 ADD2 ( incr ) .Screen/x DEI2 #0008 ADD2 .Screen/x DEO2 DUP2 LDA ,&loop JCN diff --git a/projects/examples/gui/shapes.usm b/projects/examples/gui/shapes.usm @@ -3,7 +3,9 @@ %RTN { JMP2r } %++ { #0001 ADD2 } %-- { #0001 SUB2 } -%8+ { #0008 ADD2 } +%8++ { #0008 ADD2 } +%2** { #10 SFT2 } +%4** { #20 SFT2 } %ABS2 { DUP2 #0f SFT2 EQU #04 JCN #ffff MUL2 } %LTS2 { #8000 ADD2 SWP2 #8000 ADD2 GTH2 } %GTS2 { #8000 ADD2 SWP2 #8000 ADD2 LTH2 } @@ -49,13 +51,13 @@ BRK ( load ) .color STZ -- .line/y0 STZ2 -- .line/x0 STZ2 .line/y STZ2 .line/x STZ2 .line/x0 LDZ2 .line/x LDZ2 SUB2 ABS2 .line/dx STZ2 .line/y0 LDZ2 .line/y LDZ2 SUB2 ABS2 #0000 SWP2 SUB2 .line/dy STZ2 - #ffff #00 .line/x LDZ2 .line/x0 LDZ2 LTS2 #0002 MUL2 ADD2 .line/sx STZ2 - #ffff #00 .line/y LDZ2 .line/y0 LDZ2 LTS2 #0002 MUL2 ADD2 .line/sy STZ2 + #ffff #00 .line/x LDZ2 .line/x0 LDZ2 LTS2 2** ADD2 .line/sx STZ2 + #ffff #00 .line/y LDZ2 .line/y0 LDZ2 LTS2 2** ADD2 .line/sy STZ2 .line/dx LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2 &loop .line/x LDZ2 .Screen/x DEO2 .line/y LDZ2 .Screen/y DEO2 .color LDZ .Screen/color DEO .line/x LDZ2 .line/x0 LDZ2 EQU2 .line/y LDZ2 .line/y0 LDZ2 EQU2 #0101 EQU2 ,&end JCN - .line/e1 LDZ2 #0002 MUL2 .line/e2 STZ2 + .line/e1 LDZ2 2** .line/e2 STZ2 .line/e2 LDZ2 .line/dy LDZ2 LTS2 ,&skipy JCN .line/e1 LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2 .line/x LDZ2 .line/sx LDZ2 ADD2 .line/x STZ2 @@ -115,16 +117,16 @@ RTN ( load ) .color STZ .circle/r STZ2 .circle/yc STZ2 .circle/xc STZ2 #0000 .circle/x STZ2 .circle/r LDZ2 .circle/y STZ2 - .circle/r LDZ2 #0002 MUL2 .circle/d STZ2 + .circle/r LDZ2 2** .circle/d STZ2 ( draw ) ;&seg JSR2 &loop ( incr ) .circle/x LDZ2 ++ .circle/x STZ2 .circle/d LDZ2 #0001 LTS2 ,&else JCN ( decr ) .circle/y LDZ2 -- .circle/y STZ2 - .circle/x LDZ2 .circle/y LDZ2 SUB2 #0004 MUL2 .circle/d LDZ2 ADD2 .circle/d STZ2 + .circle/x LDZ2 .circle/y LDZ2 SUB2 4** .circle/d LDZ2 ADD2 .circle/d STZ2 ;&end JMP2 &else - .circle/x LDZ2 #0004 MUL2 .circle/d LDZ2 ADD2 .circle/d STZ2 + .circle/x LDZ2 4** .circle/d LDZ2 ADD2 .circle/d STZ2 &end ( draw ) ;&seg JSR2 .circle/y LDZ2 .circle/x LDZ2 -- GTS2 ,&loop JCN @@ -151,10 +153,10 @@ RTN &hor ( save ) OVR2 .Screen/x DEO2 ( draw ) .color LDZ .Screen/color DEO - ( incr ) SWP2 8+ SWP2 + ( incr ) SWP2 8++ SWP2 OVR2 OVR2 LTH2 ,&hor JCN POP2 POP2 - ( incr ) SWP2 8+ SWP2 + ( incr ) SWP2 8++ SWP2 OVR2 OVR2 LTH2 ,&ver JCN POP2 POP2 diff --git a/projects/software/asma.usm b/projects/software/asma.usm @@ -388,7 +388,7 @@ &not-end ,asma-parse-hex-digit JSR DUP #f0 AND ,&fail JCN - LIT2r 0010 MUL2r + LITr 40 SFT2r #00 STH STH ADD2r #0001 ADD2 ,&loop JMP diff --git a/projects/software/neralie.usm b/projects/software/neralie.usm @@ -8,6 +8,7 @@ %h { .DateTime/hour DEI } %m { .DateTime/minute DEI } %s { .DateTime/second DEI } +%8** { #30 SFT2 } ( devices ) @@ -68,7 +69,7 @@ #0120 #00 h MUL2 #00c0 #00 m MUL2 ADD2 #00f8 #00 s MUL2 ADD2 - #0271 #00 .fps/next LDZ MUL2 #00 .fps/current LDZ DIV2 #0008 MUL2 ADD2 + #0271 #00 .fps/next LDZ MUL2 #00 .fps/current LDZ DIV2 8** ADD2 #01b0 ;modf JSR2 SWP2 #0017 MUL2 #03e8 DIV2 .neralie/n6 STZ POP ( add up units and tens of pulses, store in n5 and n4 ) @@ -109,11 +110,11 @@ JMP2r @letter ( index* -- ) - #0008 MUL2 ;font-letters ADD2 .Screen/addr DEO2 + 8** ;font-letters ADD2 .Screen/addr DEO2 ,digit/middle JMP @digit ( index* -- ) - #0008 MUL2 ;font-numbers ADD2 .Screen/addr DEO2 + 8** ;font-numbers ADD2 .Screen/addr DEO2 &middle .neralie/color LDZ #20 ADD .Screen/color DEO .Screen/x DEI2 #0008 ADD2 .Screen/x DEO2 diff --git a/projects/software/orca.usm b/projects/software/orca.usm @@ -13,8 +13,8 @@ %RTN { JMP2r } %++ { #01 ADD } %-- { #01 SUB } -%8+ { #0008 ADD2 } -%8* { #0008 MUL2 } %8/ { #03 SFT2 } +%8++ { #0008 ADD2 } +%8** { #30 SFT2 } %8// { #03 SFT2 } %MOD { DUP2 DIV MUL SUB } %MOD8 { #07 AND } %MOD2 { #01 AND } @@ -61,8 +61,8 @@ ( vectors ) ;on-frame .Screen/vector DEO2 ( find size ) - .Screen/width DEI2 8/ SWP POP .grid/width STZ - .Screen/height DEI2 8/ SWP POP #02 SUB .grid/height STZ + .Screen/width DEI2 8// SWP POP .grid/width STZ + .Screen/height DEI2 8// SWP POP #02 SUB .grid/height STZ ( fill grid with dots ) @@ -123,8 +123,8 @@ BRK @on-mouse .Mouse/state DEI #00 EQU ,&no-touch JCN - .Mouse/x DEI2 8/ SWP POP .selection/x1 STZ - .Mouse/y DEI2 8/ SWP POP .selection/y1 STZ + .Mouse/x DEI2 8// SWP POP .selection/x1 STZ + .Mouse/y DEI2 8// SWP POP .selection/y1 STZ ;redraw JSR2 &no-touch @@ -202,7 +202,7 @@ RTN POP2 ;font RTN &no-bar STH POP2 STHr - #20 SUB #00 SWP #0008 MUL2 ;font ADD2 + #20 SUB #00 SWP 8** ;font ADD2 RTN @@ -489,19 +489,19 @@ RTN ( Positionx ) #0000 .Screen/x DEO2 .selection/x1 LDZ - DUP #04 SFT LDA-CHAR #20 SUB #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2 + DUP #04 SFT LDA-CHAR #20 SUB #00 SWP 8** ;font ADD2 .Screen/addr DEO2 #22 .Screen/color DEO #0008 .Screen/x DEO2 - #0f AND LDA-CHAR #20 SUB #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2 + #0f AND LDA-CHAR #20 SUB #00 SWP 8** ;font ADD2 .Screen/addr DEO2 #22 .Screen/color DEO ( Positiony ) #0010 .Screen/x DEO2 .selection/y1 LDZ - DUP #04 SFT LDA-CHAR #20 SUB #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2 + DUP #04 SFT LDA-CHAR #20 SUB #00 SWP 8** ;font ADD2 .Screen/addr DEO2 #22 .Screen/color DEO #0018 .Screen/x DEO2 - #0f AND LDA-CHAR #20 SUB #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2 + #0f AND LDA-CHAR #20 SUB #00 SWP 8** ;font ADD2 .Screen/addr DEO2 #22 .Screen/color DEO #0020 .Screen/x DEO2 @@ -511,10 +511,10 @@ RTN ( Frame ) #0030 .Screen/x DEO2 .timer/frame LDZ - DUP #04 SFT LDA-CHAR #20 SUB #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2 + DUP #04 SFT LDA-CHAR #20 SUB #00 SWP 8** ;font ADD2 .Screen/addr DEO2 #22 .Screen/color DEO #0038 .Screen/x DEO2 - #0f AND LDA-CHAR #20 SUB #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2 + #0f AND LDA-CHAR #20 SUB #00 SWP 8** ;font ADD2 .Screen/addr DEO2 #22 .Screen/color DEO #0040 .Screen/x DEO2 @@ -524,20 +524,20 @@ RTN ( Speed ) #0050 .Screen/x DEO2 .timer/speed LDZ - DUP #04 SFT LDA-CHAR #20 SUB #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2 + DUP #04 SFT LDA-CHAR #20 SUB #00 SWP 8** ;font ADD2 .Screen/addr DEO2 #22 .Screen/color DEO #0058 .Screen/x DEO2 - #0f AND LDA-CHAR #20 SUB #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2 + #0f AND LDA-CHAR #20 SUB #00 SWP 8** ;font ADD2 .Screen/addr DEO2 #22 .Screen/color DEO ( TODO: Signal VU ) ( File ) .Screen/width DEI2 #0028 SUB2 .Screen/x DEO2 - .Screen/x DEI2 8+ .Screen/x DEO2 ;eye_icns .Screen/addr DEO2 #21 .Screen/color DEO - .Screen/x DEI2 8+ .Screen/x DEO2 ;filestate_icn .Screen/addr DEO2 #21 .Screen/color DEO - .Screen/x DEI2 8+ .Screen/x DEO2 ;load_icn .Screen/addr DEO2 #21 .Screen/color DEO - .Screen/x DEI2 8+ .Screen/x DEO2 ;save_icn .Screen/addr DEO2 #21 .Screen/color DEO + .Screen/x DEI2 8++ .Screen/x DEO2 ;eye_icns .Screen/addr DEO2 #21 .Screen/color DEO + .Screen/x DEI2 8++ .Screen/x DEO2 ;filestate_icn .Screen/addr DEO2 #21 .Screen/color DEO + .Screen/x DEI2 8++ .Screen/x DEO2 ;load_icn .Screen/addr DEO2 #21 .Screen/color DEO + .Screen/x DEI2 8++ .Screen/x DEO2 ;save_icn .Screen/addr DEO2 #21 .Screen/color DEO RTN @@ -545,10 +545,10 @@ RTN #00 .grid/height LDZ &ver - ( pos-y ) OVR #00 SWP #0008 MUL2 .Screen/y DEO2 + ( pos-y ) OVR #00 SWP 8** .Screen/y DEO2 #00 .grid/width LDZ &hor - ( pos-x ) OVR #00 SWP #0008 MUL2 .Screen/x DEO2 + ( pos-x ) OVR #00 SWP 8** .Screen/x DEO2 ( get x,y ) SWP2 OVR STH SWP2 OVR STHr ( sprite ) DUP2 ;get-cell-sprite JSR2 .Screen/addr DEO2 ( draw ) ;is-selected JSR2 #0d MUL #21 ADD .Screen/color DEO