commit 7511f4c2ac8ce4125c726dfe8d27e1e2efa05e0e
parent 7c46d9ce8e7345f4b5efea1f4ad3a685bc2a0837
Author: neauoire <aliceffekt@gmail.com>
Date: Thu, 3 Feb 2022 19:52:12 -0800
Added --install flag to build script
Diffstat:
8 files changed, 82 insertions(+), 66 deletions(-)
diff --git a/README.md b/README.md
@@ -25,6 +25,7 @@ Build the assembler and emulator by running the `build.sh` script. The assembler
./build.sh
--debug # Add debug flags to compiler
--format # Format source code
+ --install # Copy to ~/bin
```
If you wish to build the emulator without graphics mode:
diff --git a/build.sh b/build.sh
@@ -2,6 +2,7 @@
format=0
console=0
+install=0
debug=0
norun=0
@@ -17,6 +18,11 @@ while [ $# -gt 0 ]; do
shift
;;
+ --install)
+ install=1
+ shift
+ ;;
+
--debug)
debug=1
shift
@@ -101,7 +107,7 @@ ${CC} ${CFLAGS} src/uxnasm.c -o bin/uxnasm
${CC} ${CFLAGS} ${CORE} src/devices/system.c src/devices/file.c src/devices/datetime.c src/devices/mouse.c src/devices/controller.c src/devices/screen.c src/devices/audio.c src/uxnemu.c ${UXNEMU_LDFLAGS} -o bin/uxnemu
${CC} ${CFLAGS} ${CORE} src/devices/system.c src/devices/file.c src/devices/datetime.c src/uxncli.c -o bin/uxncli
-if [ -d "$HOME/bin" ]
+if [ $install = 1 ]
then
echo "Installing in $HOME/bin"
cp bin/uxnemu bin/uxnasm bin/uxncli $HOME/bin/
diff --git a/projects/examples/demos/clock.tal b/projects/examples/demos/clock.tal
@@ -19,7 +19,7 @@
%LTS2 { #8000 ++ SWP2 #8000 ++ GTH2 }
%GTS2 { #8000 ++ SWP2 #8000 ++ LTH2 }
-%RADIUS { #0040 }
+%RADIUS { #0040 }
%SCALEX { 2// .center/x LDZ2 ++ RADIUS -- }
%SCALEY { 2// .center/y LDZ2 ++ RADIUS -- }
%12HOURS { #0c MOD }
@@ -144,7 +144,8 @@ BRK
OVR2 OVR2
.needles/hx LDZ2 .needles/hy LDZ2 #01 STHr * ;draw-line JSR2
( middle )
- #0001 -- .Screen/y DEO2 #0001 -- .Screen/x DEO2
+ #0001 -- .Screen/y DEO2
+ #0001 -- .Screen/x DEO2
;middle-icn .Screen/addr DEO2
#0a .Screen/sprite DEO
@@ -153,6 +154,7 @@ RTN
@draw-text ( addr* -- )
( auto addr ) #06 .Screen/auto DEO
+ .Screen/y DEI2 ,&anchor-y STR2
&while
LDAk
DUP IS-LC ,&lc JCN
@@ -163,13 +165,13 @@ RTN
POP ;font/blank
&end
.Screen/addr DEO2
- #0303 .Screen/sprite DEO .Screen/sprite DEO
- .Screen/y DEI2 #0010 -- .Screen/y DEO2
- .Screen/x DEI2 #0008 ++ .Screen/x DEO2
+ #03 .Screen/sprite DEOk DEO
+ [ LIT2 &anchor-y $2 ] .Screen/y DEO2
+ .Screen/x DEI2k #0008 ++ ROT DEO2
INC2 LDAk ,&while JCN
POP2
( auto none ) #00 .Screen/auto DEO
- .Screen/x DEI2 #0008 ++ .Screen/x DEO2
+ .Screen/x DEI2k #0008 ++ ROT DEO2
RTN
&lc #61 - TOS 10** ;font/lc ++ ,&end JMP
@@ -211,12 +213,12 @@ RTN
#3c00
&loop
( dots )
- DUP TOS 2** ;table ++ LDA2
+ #00 OVR 2** ;table ++ LDA2
#0018 ;circle JSR2
.Screen/x DEO2 .Screen/y DEO2 #01 .Screen/pixel DEO
( markers )
DUP #05 MOD ,&no-marker JCN
- DUP TOS 2** ;table ++ LDA2
+ #00 OVR 2** ;table ++ LDA2
STH2k #0018 ;circle JSR2 SWP2
STH2r #001c ;circle JSR2 SWP2
#01 ;draw-line JSR2
@@ -243,9 +245,9 @@ RTN
@circle ( cx cy radius* -- y* x* )
STH2 SWP
- TOS 10** STH2kr // .center/x LDZ2 ++ #0080 10** STH2kr // --
+ TOS 10** STH2kr // .center/x LDZ2 ++ #0800 STH2kr // --
STH2 SWP2r
- TOS 10** STH2kr // .center/y LDZ2 ++ #0080 10** STH2kr // --
+ TOS 10** STH2kr // .center/y LDZ2 ++ #0800 STH2kr // --
POP2r STH2r
RTN
diff --git a/projects/examples/demos/life.tal b/projects/examples/demos/life.tal
@@ -30,11 +30,14 @@
%GET-ITERATORS { SWP2k POP NIP }
%GET-ITER { OVR2 NIP OVR SWP }
+%AUTO-NONE { #00 .Screen/auto DEO }
+%AUTO-X { #01 .Screen/auto DEO }
+
( devices )
|00 @System [ &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 ]
|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 &error $1 ]
-|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 ]
+|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
|30 @Audio0 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
|80 @Controller [ &vector $2 &button $1 &key $1 ]
|90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &wheel $1 ]
@@ -201,14 +204,16 @@ BRK
( draw cell count )
.anchor/x LDZ2 .Screen/x DEO2
.anchor/y LDZ2 HEIGHT DUP ADD TOS ++ .Screen/y DEO2
+ AUTO-X
.world/count LDZ2 #03 ;draw-short JSR2
+ AUTO-NONE
HEIGHT #00
&ver
- DUP TOS 2** .anchor/y LDZ2 ++ .Screen/y DEO2
+ #00 OVR 2** .anchor/y LDZ2 ++ .Screen/y DEO2
WIDTH #00
&hor
- DUP TOS 2** .anchor/x LDZ2 ++ .Screen/x DEO2
+ #00 OVR 2** .anchor/x LDZ2 ++ .Screen/x DEO2
GET-ITER ,get-cell JSR INC .Screen/pixel DEO
INC GTHk ,&hor JCN
POP2
@@ -267,18 +272,18 @@ RTN
@draw-short ( short* color -- )
- STH SWP
- DUP #04 SFT TOS 8** ;font-hex ++ .Screen/addr DEO2
- ( 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
- DUP #04 SFT TOS 8** ;font-hex ++ .Screen/addr DEO2
- .Screen/x DEI2 #0008 ++ .Screen/x DEO2
- ( 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-char/color STA
+ SWP ,draw-byte JSR
+
+@draw-byte ( byte -- )
+
+ DUP #04 SFT ,draw-char JSR
+ #0f AND
+
+@draw-char ( char -- )
+
+ TOS 8** ;font-hex ++ .Screen/addr DEO2
+ [ LIT &color $1 ] .Screen/sprite DEO
RTN
diff --git a/projects/examples/demos/piano.tal b/projects/examples/demos/piano.tal
@@ -365,7 +365,7 @@ RTN
.wave-view/y1 LDZ2 #0010 ++ .Screen/y DEO2
#03 .Screen/pixel DEO
&no-dot
- DUP TOS .Audio0/addr DEI2 ++ LDA
+ #00 OVR .Audio0/addr DEI2 ++ LDA
2/
TOS 4// .wave-view/y1 LDZ2 ++ .Screen/y DEO2
.Screen/x DEI2 INC2 .Screen/x DEO2
diff --git a/projects/examples/demos/wireworld.tal b/projects/examples/demos/wireworld.tal
@@ -1,13 +1,14 @@
-( wireworld )
-
(
- #00 empty - black
- #01 conductor - yellow
- #02 electron tail - red
- #03 electron head - blue
-
- RULES
-
+ wireworld
+
+ A - conductor
+ B - tail
+ Sel - head
+ Start - clear
+ mouse1 - paint
+ mouse2 - erase
+
+ RULES:
- electron head(3), becomes electron tail(2)
- electron tail(2), becomes conductor(1)
- conductor(1), becomes electron head(3)
@@ -18,6 +19,8 @@
%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
+%!~ { NEQk NIP }
+
%2* { #10 SFT } %2/ { #01 SFT } %2** { #10 SFT2 } %2// { #01 SFT2 }
%4* { #20 SFT } %4/ { #02 SFT } %4** { #20 SFT2 } %4// { #02 SFT2 }
%8* { #30 SFT } %8/ { #03 SFT } %8** { #30 SFT2 } %8// { #03 SFT2 }
@@ -77,33 +80,11 @@ BRK
.timer/frame LDZk
#03 AND ,&no-run JCN
;run JSR2
- ( Swap worlds )
- ;get-addr/current LDA2k ;run/future LDA2 STH2k
- ++ SWP2 STA2 #0000 STH2r -- ;run/future STA2
- ;redraw JSR2
&no-run
LDZk INC SWP STZ
BRK
-@on-button ( -> )
-
- .Controller/button DEI
- DUP #01 ! ,&no-a JCN #01 .color STZ &no-a
- DUP #02 ! ,&no-b JCN #02 .color STZ &no-b
- DUP #04 ! ,&no-select JCN #03 .color STZ &no-select
- DUP #08 ! ,&no-start JCN #00 .color STZ &no-start
- DUP #0c ! ,&no-both JCN
- ;world LENGTH 2** ;mclr JSR2
- ;redraw JSR2
- &no-both
- POP
- ( space )
- .Controller/key DEI #20 ! ,&no-space JCN
- .timer/play LDZk #00 = SWP STZ &no-space
-
-BRK
-
@on-mouse ( -> )
;pointer-icn .Screen/addr DEO2
@@ -125,16 +106,33 @@ BRK
BRK
+@on-button ( -> )
+
+ .Controller/button DEI
+ [ #01 ] !~ ,&no-a JCN #01 .color STZ &no-a
+ [ #02 ] !~ ,&no-b JCN #02 .color STZ &no-b
+ [ #04 ] !~ ,&no-select JCN #03 .color STZ &no-select
+ [ #08 ] !~ ,&no-start JCN
+ ;world LENGTH 2** ;mclr JSR2
+ ,redraw JSR
+ &no-start
+ POP
+ ( space )
+ .Controller/key DEI #20 ! ,&no-space JCN
+ .timer/play LDZk #00 = SWP STZ &no-space
+
+BRK
+
@redraw ( -- )
;cell-icn .Screen/addr DEO2
HEIGHT #00
&ver
- DUP TOS 4** .Screen/y DEO2
+ #00 OVR 4** .Screen/y DEO2
STHk
WIDTH #00
&hor
- DUP TOS 4** .Screen/x DEO2
+ #00 OVR 4** .Screen/x DEO2
DUP STHkr ,get-addr JSR LDA .Screen/sprite DEO
INC GTHk ,&hor JCN
POP2
@@ -159,6 +157,10 @@ RTN
POPr
INC GTHk ,&ver JCN
POP2
+ ( Swap worlds )
+ ;get-addr/current LDA2k ;run/future LDA2 STH2k ++ SWP2 STA2
+ #0000 STH2r -- ;run/future STA2
+ ,redraw JSR
RTN
diff --git a/projects/software/calc.tal b/projects/software/calc.tal
@@ -232,7 +232,7 @@ BRK
@push-input ( key -- )
DUP #50 + .Audio0/pitch DEO
- DUP TOS ;keypad/series ++ LDA ;draw-keypad JSR2
+ #00 OVR ;keypad/series ++ LDA ;draw-keypad JSR2
( hex/dec )
TOS .input/value LDZ2 #00 [ #0a #10 .input/mode LDZ JMP SWP POP ] **
++ .input/value STZ2
@@ -454,7 +454,7 @@ RTN
#08 #00
&loop
.input-frame/x LDZ2 #0018 ++ .Screen/x DEO2
- DUP TOS 8** .input-frame/y LDZ2 ++ #004c -- .Screen/y DEO2
+ #00 OVR 8** .input-frame/y LDZ2 ++ #004c -- .Screen/y DEO2
( color ) DUP #08 .stack/length LDZ - #01 - > STH
( value ) DUP 2* .stack/items + [ #10 .stack/length LDZ 2* - - ] LDZ2
STHr ;draw-number JSR2
@@ -493,9 +493,9 @@ RTN
STH
#10 #00
&loop
- ( color ) DUP TOS ;keypad/color ++ LDA STH
+ ( color ) #00 OVR ;keypad/color ++ LDA STH
( state ) DUP OVRr STHr = STH
- ( layout ) DUP TOS ;keypad/layout ++ LDA
+ ( layout ) #00 OVR ;keypad/layout ++ LDA
( layout addr ) TOS 8** ;font-hex ++ STH2
( x ) DUP 4MOD TOS 10** STH2
( y ) DUP 4/ TOS 10**
@@ -514,7 +514,7 @@ RTN
#08 #00
&loop
( state ) DUP STHkr = STH
- ( glyph ) DUP TOS 8** ;mod-icns ++ STH2
+ ( glyph ) #00 OVR 8** ;mod-icns ++ STH2
( y ) DUP 4/ TOS 10** .modpad-frame/y LDZ2 ++ STH2
( x ) DUP 4MOD TOS 10** .modpad-frame/x LDZ2 ++ STH2
STH2r STH2r STH2r STHr #03 ;draw-key JSR2
diff --git a/projects/software/launcher.tal b/projects/software/launcher.tal
@@ -309,7 +309,7 @@ RTN
DUP INC .browser/lines LDZ > ,&end JCN
( has file )
.browser/x LDZ2 .Screen/x DEO2
- DUP TOS 10** .browser/y LDZ2 ++ .Screen/y DEO2
+ #00 OVR 10** .browser/y LDZ2 ++ .Screen/y DEO2
DUP .browser/scroll LDZ + ;get-entry JSR2
DUP2 ;get-type JSR2 ;draw-type JSR2
#01 STHkr * ;draw-str JSR2