Added --install flag to build script

This commit is contained in:
neauoire 2022-02-03 19:52:12 -08:00
parent 7c46d9ce8e
commit 7511f4c2ac
8 changed files with 81 additions and 65 deletions

View File

@ -25,6 +25,7 @@ Build the assembler and emulator by running the `build.sh` script. The assembler
./build.sh ./build.sh
--debug # Add debug flags to compiler --debug # Add debug flags to compiler
--format # Format source code --format # Format source code
--install # Copy to ~/bin
``` ```
If you wish to build the emulator without graphics mode: If you wish to build the emulator without graphics mode:

View File

@ -2,6 +2,7 @@
format=0 format=0
console=0 console=0
install=0
debug=0 debug=0
norun=0 norun=0
@ -17,6 +18,11 @@ while [ $# -gt 0 ]; do
shift shift
;; ;;
--install)
install=1
shift
;;
--debug) --debug)
debug=1 debug=1
shift 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/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 ${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 then
echo "Installing in $HOME/bin" echo "Installing in $HOME/bin"
cp bin/uxnemu bin/uxnasm bin/uxncli $HOME/bin/ cp bin/uxnemu bin/uxnasm bin/uxncli $HOME/bin/

View File

@ -19,7 +19,7 @@
%LTS2 { #8000 ++ SWP2 #8000 ++ GTH2 } %LTS2 { #8000 ++ SWP2 #8000 ++ GTH2 }
%GTS2 { #8000 ++ SWP2 #8000 ++ LTH2 } %GTS2 { #8000 ++ SWP2 #8000 ++ LTH2 }
%RADIUS { #0040 } %RADIUS { #0040 }
%SCALEX { 2// .center/x LDZ2 ++ RADIUS -- } %SCALEX { 2// .center/x LDZ2 ++ RADIUS -- }
%SCALEY { 2// .center/y LDZ2 ++ RADIUS -- } %SCALEY { 2// .center/y LDZ2 ++ RADIUS -- }
%12HOURS { #0c MOD } %12HOURS { #0c MOD }
@ -144,7 +144,8 @@ BRK
OVR2 OVR2 OVR2 OVR2
.needles/hx LDZ2 .needles/hy LDZ2 #01 STHr * ;draw-line JSR2 .needles/hx LDZ2 .needles/hy LDZ2 #01 STHr * ;draw-line JSR2
( middle ) ( middle )
#0001 -- .Screen/y DEO2 #0001 -- .Screen/x DEO2 #0001 -- .Screen/y DEO2
#0001 -- .Screen/x DEO2
;middle-icn .Screen/addr DEO2 ;middle-icn .Screen/addr DEO2
#0a .Screen/sprite DEO #0a .Screen/sprite DEO
@ -153,6 +154,7 @@ RTN
@draw-text ( addr* -- ) @draw-text ( addr* -- )
( auto addr ) #06 .Screen/auto DEO ( auto addr ) #06 .Screen/auto DEO
.Screen/y DEI2 ,&anchor-y STR2
&while &while
LDAk LDAk
DUP IS-LC ,&lc JCN DUP IS-LC ,&lc JCN
@ -163,13 +165,13 @@ RTN
POP ;font/blank POP ;font/blank
&end &end
.Screen/addr DEO2 .Screen/addr DEO2
#0303 .Screen/sprite DEO .Screen/sprite DEO #03 .Screen/sprite DEOk DEO
.Screen/y DEI2 #0010 -- .Screen/y DEO2 [ LIT2 &anchor-y $2 ] .Screen/y DEO2
.Screen/x DEI2 #0008 ++ .Screen/x DEO2 .Screen/x DEI2k #0008 ++ ROT DEO2
INC2 LDAk ,&while JCN INC2 LDAk ,&while JCN
POP2 POP2
( auto none ) #00 .Screen/auto DEO ( auto none ) #00 .Screen/auto DEO
.Screen/x DEI2 #0008 ++ .Screen/x DEO2 .Screen/x DEI2k #0008 ++ ROT DEO2
RTN RTN
&lc #61 - TOS 10** ;font/lc ++ ,&end JMP &lc #61 - TOS 10** ;font/lc ++ ,&end JMP
@ -211,12 +213,12 @@ RTN
#3c00 #3c00
&loop &loop
( dots ) ( dots )
DUP TOS 2** ;table ++ LDA2 #00 OVR 2** ;table ++ LDA2
#0018 ;circle JSR2 #0018 ;circle JSR2
.Screen/x DEO2 .Screen/y DEO2 #01 .Screen/pixel DEO .Screen/x DEO2 .Screen/y DEO2 #01 .Screen/pixel DEO
( markers ) ( markers )
DUP #05 MOD ,&no-marker JCN DUP #05 MOD ,&no-marker JCN
DUP TOS 2** ;table ++ LDA2 #00 OVR 2** ;table ++ LDA2
STH2k #0018 ;circle JSR2 SWP2 STH2k #0018 ;circle JSR2 SWP2
STH2r #001c ;circle JSR2 SWP2 STH2r #001c ;circle JSR2 SWP2
#01 ;draw-line JSR2 #01 ;draw-line JSR2
@ -243,9 +245,9 @@ RTN
@circle ( cx cy radius* -- y* x* ) @circle ( cx cy radius* -- y* x* )
STH2 SWP STH2 SWP
TOS 10** STH2kr // .center/x LDZ2 ++ #0080 10** STH2kr // -- TOS 10** STH2kr // .center/x LDZ2 ++ #0800 STH2kr // --
STH2 SWP2r STH2 SWP2r
TOS 10** STH2kr // .center/y LDZ2 ++ #0080 10** STH2kr // -- TOS 10** STH2kr // .center/y LDZ2 ++ #0800 STH2kr // --
POP2r STH2r POP2r STH2r
RTN RTN

View File

@ -30,11 +30,14 @@
%GET-ITERATORS { SWP2k POP NIP } %GET-ITERATORS { SWP2k POP NIP }
%GET-ITER { OVR2 NIP OVR SWP } %GET-ITER { OVR2 NIP OVR SWP }
%AUTO-NONE { #00 .Screen/auto DEO }
%AUTO-X { #01 .Screen/auto DEO }
( devices ) ( devices )
|00 @System [ &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 ] |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 ] |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 ] |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 ] |80 @Controller [ &vector $2 &button $1 &key $1 ]
|90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &wheel $1 ] |90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &wheel $1 ]
@ -201,14 +204,16 @@ BRK
( draw cell count ) ( draw cell count )
.anchor/x LDZ2 .Screen/x DEO2 .anchor/x LDZ2 .Screen/x DEO2
.anchor/y LDZ2 HEIGHT DUP ADD TOS ++ .Screen/y DEO2 .anchor/y LDZ2 HEIGHT DUP ADD TOS ++ .Screen/y DEO2
AUTO-X
.world/count LDZ2 #03 ;draw-short JSR2 .world/count LDZ2 #03 ;draw-short JSR2
AUTO-NONE
HEIGHT #00 HEIGHT #00
&ver &ver
DUP TOS 2** .anchor/y LDZ2 ++ .Screen/y DEO2 #00 OVR 2** .anchor/y LDZ2 ++ .Screen/y DEO2
WIDTH #00 WIDTH #00
&hor &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 GET-ITER ,get-cell JSR INC .Screen/pixel DEO
INC GTHk ,&hor JCN INC GTHk ,&hor JCN
POP2 POP2
@ -267,18 +272,18 @@ RTN
@draw-short ( short* color -- ) @draw-short ( short* color -- )
STH SWP ;draw-char/color STA
DUP #04 SFT TOS 8** ;font-hex ++ .Screen/addr DEO2 SWP ,draw-byte JSR
( draw ) STHkr .Screen/sprite DEO
#0f AND TOS 8** ;font-hex ++ .Screen/addr DEO2 @draw-byte ( byte -- )
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
( draw ) STHkr .Screen/sprite DEO DUP #04 SFT ,draw-char JSR
DUP #04 SFT TOS 8** ;font-hex ++ .Screen/addr DEO2 #0f AND
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
( draw ) STHkr .Screen/sprite DEO @draw-char ( char -- )
#0f AND TOS 8** ;font-hex ++ .Screen/addr DEO2
.Screen/x DEI2 #0008 ++ .Screen/x DEO2 TOS 8** ;font-hex ++ .Screen/addr DEO2
( draw ) STHr .Screen/sprite DEO [ LIT &color $1 ] .Screen/sprite DEO
RTN RTN

View File

@ -365,7 +365,7 @@ RTN
.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
DUP TOS .Audio0/addr DEI2 ++ LDA #00 OVR .Audio0/addr DEI2 ++ LDA
2/ 2/
TOS 4// .wave-view/y1 LDZ2 ++ .Screen/y DEO2 TOS 4// .wave-view/y1 LDZ2 ++ .Screen/y DEO2
.Screen/x DEI2 INC2 .Screen/x DEO2 .Screen/x DEI2 INC2 .Screen/x DEO2

View File

@ -1,13 +1,14 @@
( wireworld )
( (
#00 empty - black wireworld
#01 conductor - yellow
#02 electron tail - red A - conductor
#03 electron head - blue B - tail
Sel - head
RULES Start - clear
mouse1 - paint
mouse2 - erase
RULES:
- electron head(3), becomes electron tail(2) - electron head(3), becomes electron tail(2)
- electron tail(2), becomes conductor(1) - electron tail(2), becomes conductor(1)
- conductor(1), becomes electron head(3) - conductor(1), becomes electron head(3)
@ -18,6 +19,8 @@
%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 } %++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 } %<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
%!~ { NEQk NIP }
%2* { #10 SFT } %2/ { #01 SFT } %2** { #10 SFT2 } %2// { #01 SFT2 } %2* { #10 SFT } %2/ { #01 SFT } %2** { #10 SFT2 } %2// { #01 SFT2 }
%4* { #20 SFT } %4/ { #02 SFT } %4** { #20 SFT2 } %4// { #02 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 } %8* { #30 SFT } %8/ { #03 SFT } %8** { #30 SFT2 } %8// { #03 SFT2 }
@ -77,33 +80,11 @@ BRK
.timer/frame LDZk .timer/frame LDZk
#03 AND ,&no-run JCN #03 AND ,&no-run JCN
;run JSR2 ;run JSR2
( Swap worlds )
;get-addr/current LDA2k ;run/future LDA2 STH2k
++ SWP2 STA2 #0000 STH2r -- ;run/future STA2
;redraw JSR2
&no-run &no-run
LDZk INC SWP STZ LDZk INC SWP STZ
BRK 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 ( -> ) @on-mouse ( -> )
;pointer-icn .Screen/addr DEO2 ;pointer-icn .Screen/addr DEO2
@ -125,16 +106,33 @@ BRK
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 ( -- ) @redraw ( -- )
;cell-icn .Screen/addr DEO2 ;cell-icn .Screen/addr DEO2
HEIGHT #00 HEIGHT #00
&ver &ver
DUP TOS 4** .Screen/y DEO2 #00 OVR 4** .Screen/y DEO2
STHk STHk
WIDTH #00 WIDTH #00
&hor &hor
DUP TOS 4** .Screen/x DEO2 #00 OVR 4** .Screen/x DEO2
DUP STHkr ,get-addr JSR LDA .Screen/sprite DEO DUP STHkr ,get-addr JSR LDA .Screen/sprite DEO
INC GTHk ,&hor JCN INC GTHk ,&hor JCN
POP2 POP2
@ -159,6 +157,10 @@ RTN
POPr POPr
INC GTHk ,&ver JCN INC GTHk ,&ver JCN
POP2 POP2
( Swap worlds )
;get-addr/current LDA2k ;run/future LDA2 STH2k ++ SWP2 STA2
#0000 STH2r -- ;run/future STA2
,redraw JSR
RTN RTN

View File

@ -232,7 +232,7 @@ BRK
@push-input ( key -- ) @push-input ( key -- )
DUP #50 + .Audio0/pitch DEO DUP #50 + .Audio0/pitch DEO
DUP TOS ;keypad/series ++ LDA ;draw-keypad JSR2 #00 OVR ;keypad/series ++ LDA ;draw-keypad JSR2
( hex/dec ) ( hex/dec )
TOS .input/value LDZ2 #00 [ #0a #10 .input/mode LDZ JMP SWP POP ] ** TOS .input/value LDZ2 #00 [ #0a #10 .input/mode LDZ JMP SWP POP ] **
++ .input/value STZ2 ++ .input/value STZ2
@ -454,7 +454,7 @@ RTN
#08 #00 #08 #00
&loop &loop
.input-frame/x LDZ2 #0018 ++ .Screen/x DEO2 .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 ( color ) DUP #08 .stack/length LDZ - #01 - > STH
( value ) DUP 2* .stack/items + [ #10 .stack/length LDZ 2* - - ] LDZ2 ( value ) DUP 2* .stack/items + [ #10 .stack/length LDZ 2* - - ] LDZ2
STHr ;draw-number JSR2 STHr ;draw-number JSR2
@ -493,9 +493,9 @@ RTN
STH STH
#10 #00 #10 #00
&loop &loop
( color ) DUP TOS ;keypad/color ++ LDA STH ( color ) #00 OVR ;keypad/color ++ LDA STH
( state ) DUP OVRr STHr = 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 ( layout addr ) TOS 8** ;font-hex ++ STH2
( x ) DUP 4MOD TOS 10** STH2 ( x ) DUP 4MOD TOS 10** STH2
( y ) DUP 4/ TOS 10** ( y ) DUP 4/ TOS 10**
@ -514,7 +514,7 @@ RTN
#08 #00 #08 #00
&loop &loop
( state ) DUP STHkr = STH ( 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 ( y ) DUP 4/ TOS 10** .modpad-frame/y LDZ2 ++ STH2
( x ) DUP 4MOD TOS 10** .modpad-frame/x LDZ2 ++ STH2 ( x ) DUP 4MOD TOS 10** .modpad-frame/x LDZ2 ++ STH2
STH2r STH2r STH2r STHr #03 ;draw-key JSR2 STH2r STH2r STH2r STHr #03 ;draw-key JSR2

View File

@ -309,7 +309,7 @@ RTN
DUP INC .browser/lines LDZ > ,&end JCN DUP INC .browser/lines LDZ > ,&end JCN
( has file ) ( has file )
.browser/x LDZ2 .Screen/x DEO2 .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 DUP .browser/scroll LDZ + ;get-entry JSR2
DUP2 ;get-type JSR2 ;draw-type JSR2 DUP2 ;get-type JSR2 ;draw-type JSR2
#01 STHkr * ;draw-str JSR2 #01 STHkr * ;draw-str JSR2