0
0
Fork 0
mirror of https://git.sr.ht/~rabbits/uxn synced 2024-11-22 05:45:10 +00:00

Merge branch 'main' into aarch64

This commit is contained in:
Sigrid Solveig Haflínudóttir 2022-01-16 00:49:00 +01:00
commit 766e217c8e
29 changed files with 2073 additions and 1623 deletions

View file

@ -10,6 +10,7 @@ environment:
SSH_HOST_KEYS: |
[w1.uxn-build.ald.nu]:2222 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP+IYCB4JrKklFjWSMRkPBTqUjBqUuhlDQy6/X3l8xj5
[m1.uxn-build.ald.nu]:2223 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDvWVqlHh3XQ5ziEbT55K896/mW2BVDdkU6hWgIfU9md
[p1.uxn-build.ald.nu]:2224 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAgduGa60Tx3PsnEaJDyUzmPmpzGYmDeLFtLcVoU5tJs
secrets:
- 138ad607-a4ec-4d74-88a1-8f3be2ba2d03
sources:
@ -21,7 +22,7 @@ tasks:
umask 077
mkdir -p ~/.ssh
printf '%s\n' "${SSH_HOST_KEYS}" > ~/.ssh/known_hosts
printf 'User build\nStrictHostKeyChecking yes\nCheckHostIP no\nHost win\nHostName w1.uxn-build.ald.nu\nPort 2222\nHost mac\nHostName m1.uxn-build.ald.nu\nPort 2223\n' > ~/.ssh/config
printf 'User build\nStrictHostKeyChecking yes\nCheckHostIP no\nHost win\nHostName w1.uxn-build.ald.nu\nPort 2222\nHost mac\nHostName m1.uxn-build.ald.nu\nPort 2223\nHost 9front\nHostName p1.uxn-build.ald.nu\nPort 2224\n' > ~/.ssh/config
- build-linux: |
cd uxn
./build.sh --no-run
@ -46,3 +47,5 @@ tasks:
}
acurl -f "https://pages.sr.ht/publish/${SITE}" -Fcontent=@out.tar.gz
acurl -f "https://pages.sr.ht/publish/${SITE}" -Fcontent=@out.tar.gz -Fprotocol=GEMINI
- build-9front: |
ssh 9front "$(cd uxn && git rev-parse HEAD)"

View file

@ -30,7 +30,7 @@ Build the assembler and emulator by running the `build.sh` script. The assembler
If you wish to build the emulator without graphics mode:
```sh
cc src/devices/file.c src/uxn.c -DNDEBUG -Os -g0 -s src/uxncli.c -o bin/uxncli
cc src/devices/datetime.c src/devices/system.c src/devices/file.c src/uxn.c -DNDEBUG -Os -g0 -s src/uxncli.c -o bin/uxncli
```
### Plan 9
@ -94,7 +94,7 @@ uxnemu orca.rom | shim
- `F1` toggle zoom
- `F2` toggle debug
- `F3` capture screen
- `F4` load boot.rom
- `F4` load launcher.rom
### Buttons
@ -105,7 +105,14 @@ uxnemu orca.rom | shim
## Need a hand?
Find us in [`#uxn` on irc.esper.net](ircs://irc.esper.net:6697/#uxn).
The following resources are a good place to start:
* [XXIIVV — uxntal](https://wiki.xxiivv.com/site/uxntal.html)
* [XXIIVV — uxntal cheatsheet](https://wiki.xxiivv.com/site/uxntal_cheatsheet.html)
* [XXIIVV — uxntal reference](https://wiki.xxiivv.com/site/uxntal_reference.html)
* [compudanzas — uxn tutorial](https://compudanzas.net/uxn_tutorial.html)
You can also find us in [`#uxn` on irc.esper.net](ircs://irc.esper.net:6697/#uxn).
## Contributing

View file

@ -36,8 +36,7 @@ echo "Cleaning.."
rm -f ./bin/uxnasm
rm -f ./bin/uxnemu
rm -f ./bin/uxncli
rm -f ./bin/supervisor.rom
rm -f ./bin/boot.rom
rm -f ./bin/launcher.rom
rm -f ./bin/asma.rom
# When clang-format is present
@ -108,10 +107,8 @@ then
cp bin/uxnemu bin/uxnasm bin/uxncli $HOME/bin/
fi
echo "Assembling(supervisor).."
./bin/uxnasm projects/software/supervisor.tal bin/supervisor.rom
echo "Assembling(boot).."
./bin/uxnasm projects/software/boot.tal bin/boot.rom
echo "Assembling(launcher).."
./bin/uxnasm projects/software/launcher.tal bin/launcher.rom
echo "Assembling(asma).."
./bin/uxnasm projects/software/asma.tal bin/asma.rom

View file

@ -1,194 +0,0 @@
( uxnasm projects/examples/demos/font.tal bin/font.rom && uxnemu bin/font.rom )
%+ { ADD } %- { SUB } %* { MUL } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
%RTN { JMP2r }
%TOS { #00 SWP }
%GET-WIDTH { TOS ;font-data ++ LDA }
%GET-GLYPH { TOS #50 SFT2 ;font-data/glyphs ++ }
%AUTO-NONE { #00 .Screen/auto DEO }
%AUTO-X { #01 .Screen/auto DEO }
%AUTO-Y { #02 .Screen/auto DEO }
%AUTO-ADDR { #04 .Screen/auto DEO }
%AUTO-X-ADDR { #05 .Screen/auto DEO }
%AUTO-Y-ADDR { #06 .Screen/auto DEO }
( devices )
|00 @System &vector $2 &pad $6 &r $2 &g $2 &b $2
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
|a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
( variables )
|0000
( init )
|0100 ( -> )
( theme )
#0fa7 .System/r DEO2
#0fa7 .System/g DEO2
#0fa7 .System/b DEO2
( load font )
#4900 .File/length DEO2
;font-path-large .File/name DEO2
;font-data .File/read DEO2
( draw label )
#0020 #0020 ;title #01 ;draw-uf3 JSR2
( load font )
#2100 .File/length DEO2
;font-path-medium .File/name DEO2
;font-data .File/read DEO2
( draw label )
#0020 #0048 ;body #02 ;draw-uf2 JSR2
( load font )
#0900 .File/length DEO2
;font-path-small .File/name DEO2
;font-data .File/read DEO2
( draw label )
#0030 #00b8 ;footer #03 ;draw-uf1 JSR2
BRK
@draw-uf1 ( x* y* text* color -- )
STH
SWP2 .Screen/y DEO2
SWP2 DUP2 .Screen/x DEO2 SWP2
&loop
LDAk
DUP #0a ! ,&no-linebreak JCN
( move down ) STH OVR2 .Screen/x DEO2 STHr
( incr y ) .Screen/y DEI2 #0010 ++ .Screen/y DEO2
POP ,&continue JMP &no-linebreak
( get addr ) STHk TOS #30 SFT2 ;font-data #0100 ++ ++ .Screen/addr DEO2
( get width ) STHr TOS ;font-data ++ LDA TOS
( draw ) STHkr .Screen/sprite DEO
( use width ) .Screen/x DEI2 ++ .Screen/x DEO2
&continue
( incr addr ) INC2
LDAk ,&loop JCN
POP2 POP2 POPr
RTN
@draw-uf2 ( x* y* text* color -- )
STH
SWP2 .Screen/y DEO2
SWP2 .Screen/x DEO2
AUTO-Y-ADDR
&while
LDAk #0a ! ,&no-linebreak JCN
( reset ) #0020 .Screen/x DEO2
( down ) .Screen/y DEI2k #0010 ++ ROT DEO2
,&continue JMP &no-linebreak
LDAk STHkr ,&sprite JSR
&continue
INC2 LDAk ,&while JCN
POP2 POPr
AUTO-NONE
RTN
&sprite ( char color -- )
.Screen/x DEI2 STH2
.Screen/y DEI2 STH2
( glyph ) OVR GET-GLYPH .Screen/addr DEO2
DUP .Screen/sprite DEOk DEO
STH2kr .Screen/y DEO2
SWP GET-WIDTH
DUP #09 < ,&narrow JCN
.Screen/x DEI2k #0008 ++ ROT DEO2
OVR .Screen/sprite DEOk DEO
STH2kr .Screen/y DEO2
&narrow
POP2r
( width ) TOS STH2r ++ .Screen/x DEO2
POP
RTN
RTN
@draw-uf3 ( x* y* text* color -- )
STH
SWP2 .Screen/y DEO2
SWP2 DUP2 .Screen/x DEO2 SWP2
&loop
LDAk
DUP #0a ! ,&no-linebreak JCN
( move down ) OVR2 .Screen/x DEO2
( incr y ) .Screen/y DEI2 #0010 ++ .Screen/y DEO2
POP ,&continue JMP &no-linebreak
STHkr ,&sprite JSR
&continue
( incr addr ) INC2
LDAk ,&loop JCN
POP2 POP2 POPr
RTN
&sprite ( char color -- )
STH
( get addr ) DUP TOS #30 SFT2 #30 SFT2k ROT POP ADD2 ;font-data #0100 ++ ++ .Screen/addr DEO2
( get width ) TOS ;font-data ++ LDA TOS
#0300
&ver
#0300
&hor
STHkr .Screen/sprite DEO
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
.Screen/addr DEI2 #0008 ++ .Screen/addr DEO2
INC GTHk ,&hor JCN
POP2
.Screen/y DEI2 #0008 ++ .Screen/y DEO2
.Screen/x DEI2 #0018 -- .Screen/x DEO2
INC GTHk ,&ver JCN
POP2
.Screen/y DEI2 #0018 -- .Screen/y DEO2
( use width ) .Screen/x DEI2 ++ .Screen/x DEO2
POPr
RTN
RTN
@title
5468 6520 466f 6720 486f 726e $1
@body
4927 6c6c 206d 616b 6520 6120 736f 756e
6420 7468 6174 2773 2073 6f20 616c 6f6e
6520 0a74 6861 7420 6e6f 206f 6e65 2063
616e 206d 6973 7320 6974 2c20 7468 6174
2077 686f 6576 6572 200a 6865 6172 7320
6974 2077 696c 6c20 7765 6570 2069 6e20
7468 6569 7220 736f 756c 732c 200a 616e
6420 6865 6172 7468 7320 7769 6c6c 2073
6565 6d20 7761 726d 6572 2c20 0a61 6e64
2062 6569 6e67 2069 6e73 6964 6520 7769
6c6c 2073 6565 6d20 6265 7474 6572 200a
746f 2061 6c6c 2077 686f 2068 6561 7220
6974 2069 6e20 7468 6520 6469 7374 616e
7420 746f 776e 732e 20 $1
@footer
2d20 4279 2052 6179 2042 7261 6462 7572
79 $1
@font-path-large
"projects/fonts/geneva24.uf3 $1
@font-path-medium
"projects/fonts/venice14.uf2 $1
@font-path-small
"projects/fonts/atari8.uf1 $1
@font-data $100 &glyphs

View file

@ -6,7 +6,7 @@
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
%!~ { NEQk NIP }
%HALT { #01 #0f DEO }
%HALT { #010f DEO }
%RTN { JMP2r }
%TOS { #00 SWP }

View file

@ -1,15 +1,18 @@
( GUI Animation )
%2// { #01 SFT2 }
%AUTO-XADDR { #05 .Screen/auto DEO }
( devices )
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 ]
|00 @System &vector $2 &wst $1 &rst $1 &eaddr $2 &ecode $1 &pad $1 &r $2 &g $2 &b $2 &debug $1 &halt $1
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
|0000
@dvd [ &x $2 &y $2 &dx $1 &dy $1 ]
@dvd
&x $2 &y $2
&dx $1 &dy $1
( program )
@ -27,52 +30,54 @@
.Screen/width DEI2 2// .dvd/x STZ2
.Screen/height DEI2 2// .dvd/y STZ2
AUTO-XADDR
#01 ;draw-dvd JSR2
BRK
@on-frame ( -> )
( clear ) #00 ;draw-dvd JSR2
#00 ;draw-dvd JSR2
( case: hit-right ) .dvd/x LDZ2 .Screen/width DEI2 #0020 SUB2 EQU2
( case: hit-left ) .dvd/x LDZ2 #0000 EQU2
#0000 EQU2 ,&no-flipx JCN
.dvd/dx LDZ #00 EQU .dvd/dx STZ &no-flipx
.dvd/dx LDZk #00 EQU SWP STZ &no-flipx
( case: hit-bottom ) .dvd/y LDZ2 .Screen/height DEI2 #0010 SUB2 EQU2
( case: hit-top ) .dvd/y LDZ2 #0000 EQU2
#0000 EQU2 ,&no-flipy JCN
.dvd/dy LDZ #00 EQU .dvd/dy STZ &no-flipy
.dvd/dy LDZk #00 EQU SWP STZ &no-flipy
( incr ) .dvd/x LDZ2 #0001 #00 .dvd/dx LDZ #00 EQU DUP2 ADD2 SUB2 ADD2 .dvd/x STZ2
( incr ) .dvd/y LDZ2 #0001 #00 .dvd/dy LDZ #00 EQU DUP2 ADD2 SUB2 ADD2 .dvd/y STZ2
( draw ) #01 ;draw-dvd JSR2
#01 ;draw-dvd JSR2
BRK
@draw-dvd ( color -- )
( stash ) STH
STH
;dvd_icn .Screen/addr DEO2
[ .dvd/y LDZ2 #0010 ADD2 ] .dvd/y LDZ2
&ver
DUP2 .Screen/y DEO2
[ .dvd/x LDZ2 #0020 ADD2 ] .dvd/x LDZ2
&hor
DUP2 .Screen/x DEO2
( draw ) STHkr .Screen/sprite DEO
( next ) .Screen/addr DEI2 #0008 ADD2 .Screen/addr DEO2
( incr ) #0008 ADD2
GTH2k ,&hor JCN
POP2 POP2
( incr ) #0008 ADD2
GTH2k ,&ver JCN
POP2 POP2
( destroy ) POPr
.dvd/x LDZ2 .Screen/x DEO2
.dvd/y LDZ2 .Screen/y DEO2
#0800
&loop
DUP #04 NEQ ,&no-lb JCN
.Screen/x DEI2k #0020 SUB2 ROT DEO2
.Screen/y DEI2k #0008 ADD2 ROT DEO2
&no-lb
STHkr .Screen/sprite DEO
INC GTHk ,&loop JCN
POP2
POPr
JMP2r
@dvd_icn [
@dvd_icn ( 4 x 2 )
001f 3f38 3838 787f 00fe fe7e 7777 e3c3
000f 1f3b 7b77 e7c7 00fc fe8f 8707 0efc
7f00 000f ff7f 0700 0301 00ff f0f8 ff00
8700 00ff 7f7f ff00 f000 00e0 fcfc 8000
]

View file

@ -1,13 +1,37 @@
( GUI Labels )
%+ { ADD } %- { SUB } %* { MUL } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
%=~ { EQUk NIP } %!~ { NEQk NIP }
%<~ { LTHk NIP } %>~ { GTHk 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 }
%10* { #40 SFT } %10/ { #04 SFT } %10** { #40 SFT2 } %10// { #04 SFT2 }
%20* { #50 SFT } %20/ { #05 SFT } %20** { #50 SFT2 } %20// { #05 SFT2 }
%IS-VALID { DUP #1f > SWP #7f < AND }
%RTN { JMP2r }
%2// { #01 SFT2 }
%8** { #30 SFT2 }
%TOS { #00 SWP }
%AUTO-NONE { #00 .Screen/auto DEO }
%AUTO-Y { #02 .Screen/auto DEO }
%AUTO-YADDR { #06 .Screen/auto DEO }
%HALT { #010f DEO }
%EMIT { #18 DEO }
%PRINT { ;print-str JSR2 #0a EMIT }
%DEBUG { ;print-hex/byte JSR2 #0a EMIT }
%DEBUG2 { ;print-hex JSR2 #0a EMIT }
( devices )
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|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
( variables )
@ -21,118 +45,596 @@
|0100
( theme )
#0f0f .System/r DEO2
#0fff .System/g DEO2
#0ff0 .System/b DEO2
#f0d7 .System/r DEO2
#f0de .System/g DEO2
#f0dc .System/b DEO2
( find screen center )
.Screen/width DEI2 2// .center/x STZ2
.Screen/height DEI2 2// .center/y STZ2
( draw ver line )
.center/x LDZ2 .Screen/x DEO2 #0000 .Screen/y DEO2
&draw-ver
( draw ) #02 .Screen/pixel DEO
( incr ) .Screen/y DEI2 #0002 ADD2 .Screen/y DEO2
.Screen/y DEI2 .Screen/height DEI2 LTH2 ,&draw-ver JCN
( ver )
AUTO-Y
#0000 .Screen/y DEO2
.center/x LDZ2 .Screen/x DEO2
.Screen/height DEI2 #0000
&ver
#43 .Screen/pixel DEO
.Screen/y DEI2k INC2 ROT DEO2
INC2 GTH2k ,&ver JCN
POP2 POP2
.center/x LDZ2 .center/y LDZ2 #0010 SUB2 #0c ;text1 ;draw-label-left JSR2
.center/x LDZ2 .center/y LDZ2 #0c ;text2 ;draw-label-middle JSR2
.center/x LDZ2 .center/y LDZ2 #0010 ADD2 #0c ;text3 ;draw-label-right JSR2
.center/x LDZ2 .center/y LDZ2 #0020 ADD2 #0c ;text4 ;draw-label-middle JSR2
.center/x LDZ2 .center/y LDZ2 #0030 ADD2 #0c ;text5 ;draw-label-middle JSR2
.center/x LDZ2 .Screen/x DEO2
.center/y LDZ2 #0020 -- .Screen/y DEO2
;left-txt #09 ;draw-uf2 JSR2
.center/x LDZ2 .Screen/x DEO2
.center/y LDZ2 .Screen/y DEO2
;center-txt #09 ;draw-uf2-center JSR2
.center/x LDZ2 .Screen/x DEO2
.center/y LDZ2 #0020 ++ .Screen/y DEO2
;right-txt #09 ;draw-uf2-right JSR2
BRK
@draw-uf2-center ( text* color -- )
STH
DUP2 ,get-width JSR 2// .Screen/x DEI2 SWP2 -- .Screen/x DEO2
STHr ,draw-uf2 JSR
RTN
@draw-label-left ( x y color addr -- )
( load ) .label/addr STZ2 .label/color STZ .Screen/y DEO2 .Screen/x DEO2
.label/addr LDZ2
&loop
( draw ) LDAk #00 SWP 8** ;font ADD2 .Screen/addr DEO2 .label/color LDZ .Screen/sprite DEO
( incr ) INC2
( incr ) .Screen/x DEI2 #0008 ADD2 .Screen/x DEO2
LDAk ,&loop JCN
@draw-uf2-right ( text* color -- )
STH
DUP2 ,get-width JSR .Screen/x DEI2 SWP2 -- .Screen/x DEO2
STHr ,draw-uf2 JSR
RTN
@get-width ( text* -- width* )
LIT2r 0000
&while
LDAk TOS ;font ++ LDA TOS STH2 ADD2r
INC2 LDAk ,&while JCN
POP2
STH2r
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 8** 2// SUB2 .Screen/x DEO2
.label/addr LDZ2
&loop
( draw ) LDAk #00 SWP 8** ;font ADD2 .Screen/addr DEO2 .label/color LDZ .Screen/sprite DEO
( incr ) INC2
( incr ) .Screen/x DEI2 #0008 ADD2 .Screen/x DEO2
LDAk ,&loop JCN
POP2
@draw-uf2 ( text* color -- )
STH
AUTO-YADDR
&while
LDAk STHkr ,draw-glyph JSR
INC2 LDAk ,&while JCN
POP2 POPr
AUTO-NONE
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 8** SUB2 .Screen/x DEO2
.label/addr LDZ2
&loop
( draw ) LDAk #00 SWP 8** ;font ADD2 .Screen/addr DEO2 .label/color LDZ .Screen/sprite DEO
( incr ) INC2
( incr ) .Screen/x DEI2 #0008 ADD2 .Screen/x DEO2
LDAk ,&loop JCN
POP2
@draw-glyph ( char color -- )
.Screen/x DEI2 STH2
.Screen/y DEI2 STH2
( glyph ) OVR ,get-glyph JSR .Screen/addr DEO2
DUP .Screen/sprite DEOk DEO
STH2kr .Screen/y DEO2
( get width ) SWP TOS ;font ++ LDA
DUP #09 < ,&narrow JCN
.Screen/x DEI2k #0008 ++ ROT DEO2
OVR .Screen/sprite DEOk DEO
STH2kr .Screen/y DEO2
&narrow
POP2r
( width ) TOS STH2r ++ .Screen/x DEO2
POP
RTN
@get-text-length ( label* -- length )
#0000 ( counter )
&loop
( incr ) INC2 OVR2 OVR2 ADD2
LDA ,&loop JCN
NIP2
@get-glyph ( char -- addr* )
#09 =~ ,&tab JCN ( tab )
#0a =~ ,&linebreak JCN ( linebreak )
#0d =~ ,&linebreak JCN ( linebreak )
DUP IS-VALID ,&valid JCN
POP ;unknown-icn RTN
&linebreak
POP ;linebreak-icn RTN
&tab
POP ;tab-icn RTN
&valid
TOS 20** ;font
#0100 ++ ++
RTN
@font ( spectrum-zx font )
[
0000 0000 0000 0000 0000 2400 7e3c 0000 0000 2400 3c42 0000 0000 6c7c 7c38 1000
0010 387c 7c38 1000 0038 387c 6c10 3800 0010 387c 7c10 3800 0000 0018 1800 0000
007e 4242 4242 7e00 0000 1824 2418 0000 0018 2442 4224 1800 001e 063a 4a48 3000
0038 446c 107c 1000 000c 0808 0838 3800 003e 2222 2266 6600 0000 0822 0022 0800
0000 1018 1c18 1000 0000 0818 3818 0800 0008 1c00 001c 0800 0028 2828 2800 2800
003e 4a4a 3a0a 0a00 000c 3046 620c 3000 0000 0000 0000 ffff 0010 3800 3810 0038
0008 1c2a 0808 0800 0008 0808 2a1c 0800 0000 0804 7e04 0800 0000 1020 7e20 1000
0000 4040 7e00 0000 0000 0024 6624 0000 0000 1038 7c00 0000 0000 007c 3810 0000
0000 0000 0000 0000 0008 0808 0800 0800 0014 1400 0000 0000 0024 7e24 247e 2400
0008 1e28 1c0a 3c08 0042 0408 1020 4200 0030 4832 4c44 3a00 0008 1000 0000 0000
0004 0808 0808 0400 0010 0808 0808 1000 0000 1408 3e08 1400 0000 0808 3e08 0800
0000 0000 0008 0810 0000 0000 3c00 0000 0000 0000 0000 0800 0000 0204 0810 2000
003c 464a 5262 3c00 0018 2808 0808 3e00 003c 4202 3c40 7e00 003c 421c 0242 3c00
0008 1828 487e 0800 007e 407c 0242 3c00 003c 407c 4242 3c00 007e 0204 0810 1000
003c 423c 4242 3c00 003c 4242 3e02 3c00 0000 0008 0000 0800 0000 0800 0008 0810
0000 0810 2010 0800 0000 003e 003e 0000 0000 1008 0408 1000 003c 4202 0c00 0800
003c 425a 5442 3c00 0018 2442 7e42 4200 007c 427c 4242 7c00 003c 4240 4042 3c00
0078 4442 4244 7800 007e 407c 4040 7e00 003e 4040 7c40 4000 003c 4240 4e42 3c00
0042 427e 4242 4200 003e 0808 0808 3e00 0002 0202 4242 3c00 0044 4870 4844 4200
0040 4040 4040 7e00 0042 665a 4242 4200 0042 6252 4a46 4200 003c 4242 4242 3c00
007c 4242 7c40 4000 003c 4242 524a 3c00 007c 4242 7c44 4200 003c 403c 0242 3c00
00fe 1010 1010 1000 0042 4242 4242 3c00 0042 4242 4224 1800 0042 4242 5a66 4200
0042 2418 1824 4200 0082 4428 1010 1000 007e 0408 1020 7e00 000c 0808 0808 0c00
0040 2010 0804 0200 0018 0808 0808 1800 0008 1422 0000 0000 0000 0000 0000 7e00
0008 0400 0000 0000 0000 1c02 1e22 1e00 0020 203c 2222 3c00 0000 1e20 2020 1e00
0002 021e 2222 1e00 0000 1c22 3c20 1e00 000c 101c 1010 1000 0000 1c22 221e 021c
0020 202c 3222 2200 0008 0018 0808 0400 0008 0008 0808 4830 0020 2428 3028 2400
0010 1010 1010 0c00 0000 6854 5454 5400 0000 5864 4444 4400 0000 3844 4444 3800
0000 7844 4478 4040 0000 3c44 443c 0406 0000 2c30 2020 2000 0000 3840 3804 7800
0010 103c 1010 0c00 0000 4444 4444 3800 0000 4444 2828 1000 0000 4454 5454 2800
0000 4428 1028 4400 0000 4444 443c 0438 0000 7c08 1020 7c00 000c 0810 1008 0c00
0008 0808 0808 0800 0030 1008 0810 3000 0000 0032 4c00 0000 3c42 99a1 a199 423c
]
@print-hex ( value* -- )
@text1 [ "Left 20 "Aligned 00 ]
@text2 [ "Middle 20 "Aligned 00 ]
@text3 [ "Right 20 "Aligned 00 ]
@text4 [ "even 00 ]
@text5 [ "odd 00 ]
SWP ,&byte JSR
&byte ( byte -- )
STHk #04 SFT ,&parse JSR #18 DEO
STHr #0f AND ,&parse JSR #18 DEO
JMP2r
&parse ( byte -- char ) DUP #09 GTH ,&above JCN #30 ADD JMP2r
&above #57 ADD JMP2r
JMP2r
@left-txt "Left 20 "Aligned 20 "Label $1
@center-txt "Center 20 "Aligned 20 "Label $1
@right-txt "Right 20 "Aligned 20 "Label $1
@unknown-icn
aa55 aa55 aa55 aa55
aa55 aa55 aa55 aa55
aa55 aa55 aa55 aa55
aa55 aa55 aa55 aa55
@tab-icn
0000 0000 0000 1008
1000 0000 0000 0000
0000 0000 0000 0000
0000 0000 0000 0000
@linebreak-icn
0000 0000 0000 1028
1000 0000 0000 0000
0000 0000 0000 0000
0000 0000 0000 0000
@font ( venice14 )
0000 0000 0000 0000 0009 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0505 0809 080c 0d05 0707 0a09 0609 0608
0808 0808 0908 0808 0808 0505 0708 0709
000d 0a08 0b0a 090a 0c08 070c 090e 0c09
0a09 0c08 090b 0a0d 0d0a 0906 0806 0809
0509 0807 0a07 0708 0906 0609 050f 0a08
0908 0707 060a 090e 0a09 0807 0507 0800
0d0d 080a 0c09 0b09 0909 0909 0907 0707
0707 0606 0606 0a08 0808 0808 0a0a 0a0a
0000 0000 0000 000a 0000 0005 0000 1009
0000 0000 0000 0000 0000 0000 0000 0c08
0905 0000 0000 000a 0a00 080d 0d09 0e0c
090c 0808 0505 0000 0907 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 3030 3030 3030 3000 3030 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 2424 2400 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 1212 7f24 24fe 4848 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 1038 5450 7038 1c14 5438 1000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 3748 494b 360d 1a32 6241 0000 0000
0000 c0c0 8000 0080 4040 4080 0000 0000
0000 1c22 261c 1835 6343 463c 0000 0000
0000 0000 0000 e090 1020 8060 0000 0000
0000 2020 2000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0008 1030 2060 6060 6020 3010 0800 0000
0000 0000 0000 0000 0000 0000 0000 0000
0020 1018 080c 0c0c 0c08 1810 2000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0012 0c3f 0c12 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0008 0808 7f08 0808 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 3030 1020 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 7f00 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 3030 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0206 040c 0818 1030 2060 4000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 3c66 6666 6666 6666 663c 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0818 3818 1818 1818 183c 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 3c46 8606 0c18 3060 c2fc 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 7e8c 1830 7c06 4686 8c78 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 040c 1c2c 4c8d fe0c 0c1e 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 7c62 6078 0c06 0606 4c38 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 1c22 606c 7666 6666 663c 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 7e86 060c 0c18 1830 3030 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 3c66 6666 3c66 6666 663c 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 3c66 6666 666e 3606 4438 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0030 3000 0000 3030 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0030 3000 0000 3030 1020 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0c18 3060 3018 0c00 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 7e00 7e00 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 6030 180c 1830 6000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 3c46 0606 0c18 1000 1010 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0001 0200 0001 0306 7f98 30e0 0000 0000
00c0 6060 e0e0 6060 e060 6038 0000 0000
0010 7eb3 b333 3e31 3131 31ff 0000 0000
0000 0000 0000 0080 8080 8000 0000 0000
0000 7cc2 c2c4 c0c0 c0c2 c478 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0010 7fb1 b030 3030 3030 30ff 0000 0000
0000 0080 c0c0 c0c0 c0c0 8000 0000 0000
0010 7fb0 b030 3e30 3030 30ff 0000 0000
0000 8080 0000 0000 0040 8000 0000 0000
0010 7fb0 b030 3e30 3030 30e0 0000 0000
0000 8080 0000 0000 0000 0000 0000 0000
0000 3f61 c2c0 cfc3 c3c7 cb73 0000 0000
0000 0000 0000 0000 0040 8000 0000 0000
0000 71b1 b131 7fb1 3131 31e1 0000 0000
00e0 8080 8080 8080 8090 a0c0 0000 0000
0000 7898 9818 1818 1819 1a1c 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 7898 9818 1818 1818 1818 1810 20c0
0000 0000 0000 0000 0000 0000 0000 0000
0000 70b1 b336 3c38 3c36 33e1 0000 0000
0000 c080 0000 0000 0010 20c0 0000 0000
0000 3860 6060 6060 6060 61fe 0000 0000
0000 0000 0000 0000 0080 0000 0000 0000
0000 70b8 bd2e 2420 2020 20c0 0000 0000
0000 70e0 6060 6060 6064 6870 0000 0000
0000 70b8 bc2e 2723 2120 20c0 0000 0000
0000 6040 4040 40c0 c0c0 4040 0000 0000
0000 3c46 c3c3 c3c3 c3c2 4438 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 7fb1 b131 313f 3030 30e0 0000 0000
0000 0080 8080 8000 0000 0000 0000 0000
0000 3c46 c3c3 c3c3 c3d3 4a3c 0402 0000
0000 0000 0000 0000 0000 0000 0000 0000
0010 7fb1 b131 313f 3633 31e0 0000 0000
0000 0080 8080 8000 0000 90e0 0000 0000
0000 7cc2 e470 381c 4e86 c67c 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 7f8c 8c0c 0c0c 0c0c 0c38 0000 0000
0000 8000 0000 0000 0000 0000 0000 0000
0000 61e1 6161 6161 6365 6931 0000 0000
0000 8080 8080 8080 80a0 c080 0000 0000
0000 61e3 6161 6163 666c 7870 0000 0000
0000 0080 8080 8000 0000 0000 0000 0000
0000 60e0 6060 6266 6e76 6747 0000 0000
0000 2070 3030 3030 60c0 8000 0000 0000
0000 60b0 980d 0707 0d18 3060 0000 0000
0000 3060 c080 0000 80c8 6830 0000 0000
0000 61e1 6161 6161 6163 6539 0101 021c
0000 8080 8080 8080 8080 8080 8000 0000
0000 7f83 860c 1830 60c0 c1fe 0000 0000
0000 0000 0000 0000 0080 0000 0000 0000
0078 6060 6060 6060 6060 6060 7800 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 4060 2030 1018 080c 0406 0200 0000
0000 0000 0000 0000 0000 0000 0000 0000
0078 1818 1818 1818 1818 1818 7800 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0010 2844 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 00ff 0000 0000
0000 0000 0000 0000 0000 0080 0000 0000
0040 2010 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 007e c6c6 c6ce d766 0000 0000
0000 0000 0000 0000 0080 0000 0000 0000
0070 c0c0 c0dc e6c6 c6c6 ccf8 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 007c c4c0 c0c4 c870 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0003 0606 067e c6c6 c6ce d667 0000 0000
0080 0000 0000 0000 0040 8000 0000 0000
0000 0000 007c c4c8 d0e2 c478 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
001c 3030 3078 3030 3030 3030 3030 20c0
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 007e c6c6 c6ce d666 0604 0830
0000 0000 0000 0000 0000 0000 0000 0000
0070 c0c0 c0ce d6e6 c6c6 c7c6 0000 0000
0000 0000 0000 0000 0080 0000 0000 0000
0000 2040 0060 e060 6064 6870 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 1020 0030 70b0 3030 3030 3020 4080
0000 0000 0000 0000 0000 0000 0000 0000
0070 c0c0 c0d8 e4c4 f8d8 cdc6 0000 0000
0000 0000 0000 0000 0080 0000 0000 0000
0070 c0c0 c0c0 c0c0 c0c8 d0e0 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0067 eb73 6363 6363 0000 0000
0000 0000 0038 5898 181a 1c18 0000 0000
0000 0000 0067 eb73 6363 6363 0000 0000
0000 0000 0000 0000 0040 8000 0000 0000
0000 0000 007c c6c6 c6c6 cc78 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 006e f363 6363 667c 6060 60c0
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 007e c6c6 c6ce d666 0606 0706
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 006c f060 6060 7060 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0078 c4c0 780c 8c78 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0020 60f8 6060 6064 6870 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0063 e363 6367 6b33 0000 0000
0000 0000 0000 0000 0040 8000 0000 0000
0000 0000 0042 e763 6264 6870 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0042 e763 676b 7363 0000 0000
0000 0000 0010 3818 1020 4080 0000 0000
0000 0000 0061 b21c 0c16 2341 0000 0000
0000 0000 0000 0000 0000 4080 0000 0000
0000 0000 0063 e363 6367 6b33 0302 0438
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 007e 860c 1830 61fe 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 1830 3030 3060 3030 3030 3018 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 2020 2020 2020 2020 2020 2020 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 3018 1818 180c 1818 1818 1830 0000
0000 0000 0000 0000 0000 0000 0000 0000
4c00 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0001 0200 0001 0306 7f98 30e0 0000 0000
00c0 6060 e0e0 6060 e060 6038 0000 0000
0001 0200 0001 0306 7f98 30e0 0000 0000
c0c0 6060 e0e0 6060 e060 6038 0000 0000
0000 7cc2 c2c4 c0c0 c0c2 c478 1010 2000
0000 0000 0000 0000 0000 0000 0000 0000
0010 7fb0 b030 3e30 3030 30ff 0000 0000
0000 8080 0000 0000 0040 8000 0000 0000
1300 70b8 bc2e 2723 2120 20c0 0000 0000
0000 6040 4040 40c0 c0c0 4040 0000 0000
0000 3c46 c3c3 c3c3 c3c2 4438 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 61e1 6161 6161 6365 6931 0000 0000
0000 8080 8080 8080 80a0 c080 0000 0000
0008 1000 007e c6c6 c6ce d766 0000 0000
0000 0000 0000 0000 0080 0000 0000 0000
0010 0800 007e c6c6 c6ce d766 0000 0000
0000 0000 0000 0000 0080 0000 0000 0000
1028 4400 007e c6c6 c6ce d766 0000 0000
0000 0000 0000 0000 0080 0000 0000 0000
0000 2400 007e c6c6 c6ce d766 0000 0000
0000 0000 0000 0000 0080 0000 0000 0000
0032 4c00 007e c6c6 c6ce d766 0000 0000
0000 0000 0000 0000 0080 0000 0000 0000
1824 2418 007e c6c6 c6ce d766 0000 0000
0000 0000 0000 0000 0080 0000 0000 0000
0000 0000 007c c4c0 c0c4 c870 1010 2000
0000 0000 0000 0000 0000 0000 0000 0000
0008 1000 007c c4c8 d0e2 c478 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0020 1000 007c c4c8 d0e2 c478 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
1028 4400 007c c4c8 d0e2 c478 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 4800 007c c4c8 d0e2 c478 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0020 4000 0060 e060 6064 6870 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0040 2000 0060 e060 6064 6870 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
2050 8800 0060 e060 6064 6870 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 9000 0060 e060 6064 6870 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0019 2600 0067 eb73 6363 6363 0000 0000
0000 0000 0000 0000 0040 8000 0000 0000
0008 1000 007c c6c6 c6c6 cc78 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0020 1000 007c c6c6 c6c6 cc78 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
1028 4400 007c c6c6 c6c6 cc78 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 2400 007c c6c6 c6c6 cc78 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0032 4c00 007c c6c6 c6c6 cc78 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0008 1000 0063 e363 6367 6b33 0000 0000
0000 0000 0000 0000 0040 8000 0000 0000
0010 0800 0063 e363 6367 6b33 0000 0000
0000 0000 0000 0000 0040 8000 0000 0000
0814 2200 0063 e363 6367 6b33 0000 0000
0000 0000 0000 0000 0040 8000 0000 0000
0000 2400 0063 e363 6367 6b33 0000 0000
0000 0000 0000 0000 0040 8000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 1e33 3333 3631 3131 33e6 0000 0000
0000 0000 0000 0000 8080 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0010 2040 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0001 0200 0001 0306 7f98 30e1 0000 0000
00c0 7f61 e0e0 7c60 e060 61fe 0000 0000
0000 3d42 c7cb cbd3 d3e2 44b8 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 007d c6c6 c6cf d663 0000 0000
0000 0000 00e0 2040 8010 20c0 0000 0000
0000 0000 007c c6ce d6e6 cc78 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0808 0008 1830 6060 623c 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 6060 0060 6060 6060 6060 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0009 1224 4824 1209 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0024 1209 0409 1224 0000 0000
0000 0000 0000 0000 8000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0001 0200 0001 0306 7f98 30e0 0000 0000
00c0 6060 e0e0 6060 e060 6038 0000 0000
0001 0200 0001 0306 7f98 30e0 0000 0000
00c0 6060 e0e0 6060 e060 6038 0000 0000
4c00 3c46 c3c3 c3c3 c3c2 4438 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 3f47 c3c3 c3c3 c3c3 473b 0000 0000
0000 f808 0000 e000 0004 08f0 0000 0000
0000 0000 007d c6c6 c6c7 ce79 0000 0000
0000 0000 00e0 2040 8010 20c0 0000 0000
0000 0000 0000 7f00 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 7f00 0000 0000 0000 0000
0000 0000 0000 e000 0000 0000 0000 0000
0000 2448 6c6c 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 3636 1224 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 2040 6060 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 3030 1020 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 2400 0063 e363 6367 6b33 0302 0438
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0070 98ce 6438 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000

View file

@ -0,0 +1,155 @@
( Draw a 8x8 font )
%+ { ADD } %- { SUB } %* { MUL } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
%AUTO-X { #01 .Screen/auto DEO }
( devices )
|00 @System &vector $2 &wst $1 &rst $1 &eaddr $2 &ecode $1 &pad $1 &r $2 &g $2 &b $2 &debug $1 &halt $1
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
( variables )
|0000
( program )
|0100
( theme )
#f05d .System/r DEO2
#f0cd .System/g DEO2
#f0ad .System/b DEO2
( draw hello world )
#0010 .Screen/x DEO2
#0010 .Screen/y DEO2
;hello-txt #01 ;draw-uf1 JSR2
( draw long text )
#0010 .Screen/x DEO2
#0030 .Screen/y DEO2
;long-txt #02 ;draw-uf1-linebreaks JSR2
BRK
@draw-uf1 ( string* color -- )
AUTO-X
STH
&while
( get sprite ) LDAk #20 - #00 SWP #30 SFT2 ;font ++ .Screen/addr DEO2
( draw ) STHkr .Screen/sprite DEO
INC2 LDAk ,&while JCN
POPr
JMP2r
@draw-uf1-linebreaks ( string* color -- )
.Screen/x DEI2 ,&anchor STR2
AUTO-X
STH
&while
LDAk #0a ! ,&no-lb JCN
( rewind ) LIT2 &anchor $2 .Screen/x DEO2
( skip line ) .Screen/y DEI2k #0008 ++ ROT DEO2
,&end JMP
&no-lb
( get sprite ) LDAk #20 - #00 SWP #30 SFT2 ;font ++ .Screen/addr DEO2
( draw ) STHkr .Screen/sprite DEO
&end
INC2 LDAk ,&while JCN
POPr
JMP2r
@hello-txt "Hello 20 "Uxn! $1
@long-txt
5275 7374 6963 2043 6f6d 7075 7469 6e67
2072 6566 6572 7320 746f 2074 6865 2063
6f6e 7374 7275 6374 696f 6e20 0a6f 6620
6361 6c63 756c 6174 696f 6e20 6d61 6368
696e 6573 2075 7369 6e67 2070 7265 2d69
6e64 7573 7472 6961 6c20 0a6f 7220 6576
656e 2070 7265 2d68 6973 746f 7269 6320
7465 6368 6e6f 6c6f 6779 2e20 0a0a 4974
2072 6576 6561 6c73 2061 2068 6973 746f
7279 206f 6620 636f 6d70 7574 696e 6720
6173 2074 6865 200a 7061 7374 696d 6520
6f66 2064 696c 6574 7461 6e74 6573 2c20
616d 6174 6575 7220 7363 6965 6e74 6973
7473 0a61 6e64 2074 6162 756c 6174 6f72
7320 7768 6f20 636f 6e73 7472 7563 7420
6d61 6368 696e 6573 2074 6f20 0a6d 616e
6970 756c 6174 6520 6162 7374 7261 6374
2073 796d 626f 6c73 2077 6974 6820 6e6f
2070 7261 6374 6963 616c 200a 6170 706c
6963 6174 696f 6e2e 2041 7320 7468 6573
6520 6d61 6368 696e 6573 2061 7265 2067
656e 6572 616c 6c79 200a 6c65 7373 2065
6666 6963 6965 6e74 2074 6861 6e20 636f
6e76 656e 7469 6f6e 616c 2070 656e 6369
6c20 616e 6420 0a70 6170 6572 2063 6f6d
7075 7461 7469 6f6e 2c20 7468 6579 2061
6c6c 7564 6520 746f 2061 206d 6f72 6520
0a65 7069 6375 7265 616e 2070 7261 6374
6963 6520 6f66 2063 6f6d 7075 7469 6e67
2066 6f72 2070 6c65 6173 7572 6520 0a72
6174 6865 7220 7468 616e 2070 726f 6475
6374 696f 6e2e
@font ( bbcmicro )
0000 0000 0000 0000 1818 1818 1800 1800
6c6c 6c00 0000 0000 3636 7f36 7f36 3600
0c3f 683e 0b7e 1800 6066 0c18 3066 0600
386c 6c38 6d66 3b00 0c18 3000 0000 0000
0c18 3030 3018 0c00 3018 0c0c 0c18 3000
0018 7e3c 7e18 0000 0018 187e 1818 0000
0000 0000 0018 1830 0000 007e 0000 0000
0000 0000 0018 1800 0006 0c18 3060 0000
3c66 6e7e 7666 3c00 1838 1818 1818 7e00
3c66 060c 1830 7e00 3c66 061c 0666 3c00
0c1c 3c6c 7e0c 0c00 7e60 7c06 0666 3c00
1c30 607c 6666 3c00 7e06 0c18 3030 3000
3c66 663c 6666 3c00 3c66 663e 060c 3800
0000 1818 0018 1800 0000 1818 0018 1830
0c18 3060 3018 0c00 0000 7e00 7e00 0000
3018 0c06 0c18 3000 3c66 0c18 1800 1800
3c66 6e6a 6e60 3c00 3c66 667e 6666 6600
7c66 667c 6666 7c00 3c66 6060 6066 3c00
786c 6666 666c 7800 7e60 607c 6060 7e00
7e60 607c 6060 6000 3c66 606e 6666 3c00
6666 667e 6666 6600 7e18 1818 1818 7e00
3e0c 0c0c 0c6c 3800 666c 7870 786c 6600
6060 6060 6060 7e00 6377 7f6b 6b63 6300
6666 767e 6e66 6600 3c66 6666 6666 3c00
7c66 667c 6060 6000 3c66 6666 6a6c 3600
7c66 667c 6c66 6600 3c66 603c 0666 3c00
7e18 1818 1818 1800 6666 6666 6666 3c00
6666 6666 663c 1800 6363 6b6b 7f77 6300
6666 3c18 3c66 6600 6666 663c 1818 1800
7e06 0c18 3060 7e00 7c60 6060 6060 7c00
0060 3018 0c06 0000 3e06 0606 0606 3e00
183c 6642 0000 0000 0000 0000 0000 00ff
1c36 307c 3030 7e00 0000 3c06 3e66 3e00
6060 7c66 6666 7c00 0000 3c66 6066 3c00
0606 3e66 6666 3e00 0000 3c66 7e60 3c00
1c30 307c 3030 3000 0000 3e66 663e 063c
6060 7c66 6666 6600 1800 3818 1818 3c00
1800 3818 1818 1870 6060 666c 786c 6600
3818 1818 1818 3c00 0000 367f 6b6b 6300
0000 7c66 6666 6600 0000 3c66 6666 3c00
0000 7c66 667c 6060 0000 3e66 663e 0607
0000 6c76 6060 6000 0000 3e60 3c06 7c00
3030 7c30 3030 1c00 0000 6666 6666 3e00
0000 6666 663c 1800 0000 636b 6b7f 3600
0000 663c 183c 6600 0000 6666 663e 063c
0000 7e0c 1830 7e00 0c18 1870 1818 0c00
1818 1800 1818 1800 3018 180e 1818 3000
316b 4600 0000 0000 ffff ffff ffff ffff

View file

@ -0,0 +1,313 @@
( GUI Picture )
%+ { ADD } %- { SUB } %* { MUL } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
%AUTO-NONE { #00 .Screen/auto DEO }
%AUTO-XADDR { #05 .Screen/auto DEO }
( devices )
|00 @System &vector $2 &wst $1 &rst $1 &eaddr $2 &ecode $1 &pad $1 &r $2 &g $2 &b $2 &debug $1 &halt $1
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
( variables )
|0000
( program )
|0100
( theme )
#f0d7 .System/r DEO2
#f0de .System/g DEO2
#f0dc .System/b DEO2
#0030 .Screen/x DEO2
#0030 .Screen/y DEO2
;picture-icn #20 #10 #01 ;draw-icn JSR2
BRK
@draw-icn ( addr* width height color -- )
AUTO-XADDR
STH
( set bounds ) ,&height STR ,&width STR .Screen/addr DEO2
( set origin ) .Screen/x DEI2 ,&x STR2
LIT &height $1 #00
&ver
LIT2 &x $2 .Screen/x DEO2
LIT &width $1 #00
&hor
STHkr .Screen/sprite DEO
INC GTHk ,&hor JCN
POP2
.Screen/y DEI2k #0008 ++ ROT DEO2
INC GTHk ,&ver JCN
POP2
POPr
AUTO-NONE
JMP2r
@picture-icn ( akane2010.bit 20 x 10 )
0000 0000 0000 0000 2b41 2341 2b41 2341
8881 8081 8880 8080 0a00 2000 8800 2000
8004 2004 8804 2a04 0000 0000 8000 0000
0307 0f0f 0f1f 1f5f ffff ffff ffff ffff
ffff ffff ffff ffff ffff ffff ffff ffff
ffff ffff ffff ffff ffff ffff ffff ffff
ffff ffff ffff ffff ffff ffff ffff ffff
ffff ffff ffff ffff ffff fff7 ffff efdf
fbf7 efd7 efdf af5f fffd fbfd fbf5 ebd7
eaf5 ead5 ead5 aa55 ab55 ab55 ab57 ab57
fbf7 ebd7 ebd7 ab57 ffff ffff ffff fbf7
ffff ffff ffff ffff ffff ffff ffff ffff
ffff ffff ffff ffff ffff ffff ffff fefc
80c0 8000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 2a54 2a54 2a54 2a54
8800 2200 8800 2200 8800 2200 8800 2200
0000 0000 0000 0000 2b41 2341 2b41 2341
8880 8080 8880 a080 8800 2000 8800 2000
8a05 2a05 8f0f 2a15 aa55 aafd ffff aa45
bf7f ff7f ffff ffff ffff ffff ffff ffff
ffff ffff ffff ffff ffff ffff ffff ffff
ffff ffff ffff ffff ffff ffff ffff ffff
ffff ffff ffff fefd ffff ffff ffff be7c
ffff ffff 8a00 0200 befd fafd fe1f 2307
bf5f bf7d bad5 eaf5 ead5 aa55 aa55 aa55
aa55 aa55 aa55 aa55 aa55 aa55 aa55 ab57
af57 af7f ffc5 a307 fbf7 ff9f 1f1f 8f9f
ffff ffff ffff ffff ffff ffff ffff ffff
ffff ffff ffff ffff fefd faf5 eaff ff5f
0055 aa55 aaff ffff 0055 aa55 aaff ffff
0055 aadf aaff ffff aa55 aad5 aaff ffff
8840 aa77 aaff ffff 8800 aaff aaff ffff
0000 0000 0000 0000 2b41 2341 2b41 2241
8800 a000 8800 a004 8804 2004 8000 2240
8810 0810 a010 2010 0200 0000 0000 0000
bf3f 3f1f 0f07 0303 ffff ffff ffff ffff
ffff ffff ffff ffff ffff ffff ffff ffff
ffff ffff ffff ffff ffff ffff ffd7 ab55
faf5 faf5 eaf5 eaf5 f870 e240 8840 8240
8800 2200 8841 233f 8f1f 3f7f ffff ffff
fadd eac1 e2c1 c2c1 aa55 aa55 aa55 aa55
aa55 aa55 aa54 a040 ae54 a854 a855 2f07
8f1f 1f3f bfff ffff 8f87 8f85 8205 2a05
ffdf af5f bf7f bf77 ffff ffff ffff ffff
fefd f8c0 80c0 80c0 aa55 2a15 0a15 0a15
ab55 8000 8000 8000 fe55 0200 0800 2200
aa55 2200 8800 2200 eb77 2a54 2a54 2a54
ff55 2000 8800 2000 ff55 0000 0000 2000
0000 0000 0000 0000 2a41 2241 2b41 2341
8804 a004 8004 a004 0840 aa40 8850 8210
a010 2040 a040 2040 0000 0000 0000 0000
0301 0000 0000 0000 ffff ff7f 7f3f 3b07
ffff ffff ffff ffff ffff ffff ffff ffff
feff fefd fefd fefd aa55 aa55 aa55 aa55
eaf5 fafd fafd fefd 8840 a250 a854 aa54
bf1f 2f07 8800 8055 ffff fefc e800 0a54
8201 2000 8000 8010 aa54 2800 0000 0000
0000 0000 0000 0000 0301 0000 0000 0200
fefc fa70 8801 aa50 8a05 0a05 0201 0303
ef57 af5f af5f bf7f ffff ffff ffff ffff
c0c0 a2c0 8880 a280 0a15 0a15 8a15 0a15
0000 0000 8000 2000 0800 0200 0800 2000
0800 2200 8800 0000 2a54 2a55 2a55 2a57
8800 2000 a0ff ffff 8000 2000 a8ff ffff
0000 0000 0000 0001 ab41 a341 ab5f ffff
8004 a804 8eff ffff 8010 a200 a0c0 e2c1
8040 80c0 80c0 8000 0000 0000 0000 0000
0000 0000 0000 0000 0301 0101 0000 0000
ffff ffff ff7f 1f0f ffff ffff ffff ffff
fefd feff feff ffff aa55 aa55 aa55 aad5
feff feff fe7f fe7f aa54 aa55 aa55 aa54
0000 0000 0000 0000 0000 0000 0000 0000
0800 0000 0000 0000 0000 0000 0000 0000
0000 0001 0205 0a05 8040 2040 e070 e040
0000 0000 0000 0000 0307 0307 0707 0f07
ffff ffff ffff ffff ffff fefc fefc fcfc
8207 3f7f 7f7f 7f7f 8aff ffff ffff ffff
08c0 faf8 fcfc feff 8800 2000 8800 2000
0000 2000 0000 0000 2b57 2f57 2b55 2a54
ffff ffff ffff ffff ffff ffff ffff ffff
0b03 0307 0707 0f1f ffff ffff ffff ffff
ffff ffff ffff ffff e0f1 f9f1 faf3 faf7
8000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0707 0301 0000 0000 ffff ffff ff7f 3f1f
ffff ffff ffff ffff eaf5 fafd feff ffff
fe7d be7f be7d ffff aa54 aa54 aa54 aad5
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0201 0000 0000 0001 e040 0000 0000 0040
0000 0000 0000 0000 0f07 0f07 0f0f 0f1f
ffff ffff fffe fcfc f8f0 c280 0800 2200
be7f 3e15 8a01 2205 ff5f af55 ab55 ab55
feff ffff ffff bf7f 8000 2000 8800 a201
8800 2000 0000 00f7 2854 2854 2854 28f4
ff7f bf57 af5f 2f57 ffff ffff ffff ffff
0f1f 0f07 0707 0707 ffff ffff ffff ffff
ffff ffff fefd faf5 e2c4 8604 8844 a854
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0f03 0100 0000 0000
ffff ff7f 0f07 0a05 ffff ffff ffff ff7f
ffff ffff ffff ffff eaf5 fafd feff ffff
8000 8040 a0d0 e8d4 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0200 0000 0000 0000 8000 0000 0000 0000
0000 0000 0001 0305 0f1f 3f7c f8f0 8201
e8c4 2a11 a840 a200 8800 2200 2005 2000
8215 2e57 2a55 aa55 aa55 aa55 aa55 3a15
fe7c f8f0 e840 a250 0307 2f1f 8f1f 2f0f
ffff ffff ffff ffff f8fc fefc feff fef0
ab57 2b15 0a55 0a01 ffff feff ea55 8040
0301 0005 aa10 0805 ffff ff5f aa05 2000
eaf5 ead5 aa55 aa41 8810 b810 2070 2040
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0204 0a10
0000 0000 a805 2200 0000 0000 0040 2805
0a05 0a10 2a41 a200 af57 a840 8844 0a10
ffff ff7f 8f01 2004 ffff ffff ffff ff7f
aed5 aad5 aad5 aad5 80c0 a85d ab55 aa55
0000 0000 a054 aa55 0000 0000 0000 a055
0000 0000 0000 0045 0000 0071 fa7c faf0
0810 a240 0800 2001 0a04 0254 a850 8200
0800 2200 8800 2200 8800 2200 8804 2a00
8a05 2201 8a01 2001 a8d0 a0c4 8a54 a040
2801 2000 8800 0250 8f01 8240 a011 2211
af55 a040 8051 a815 e0c0 c240 8800 a200
0840 2200 aa10 2214 2a05 2000 8800 2200
8a00 2000 8000 2200 2a00 2200 8800 2200
a214 2301 8000 2210 e040 80c0 6070 2010
0000 0000 0000 0000 0000 0000 0000 0000
0000 0001 0204 0814 2840 a200 8800 2200
8800 2200 8800 2200 8b10 2240 0800 a200
a855 2200 8800 2200 2040 a240 a810 2a04
8810 2200 0845 a800 bf7f 3a11 3805 2301
aa55 aa55 aa55 aa55 aa55 aa55 aa55 aa55
aa55 aa55 aa55 aa55 aa55 aa55 aa75 fa7f
ef75 bb5d bb5f bb5f f8f8 fafc f8fc fcfc
8800 2201 8801 2201 0800 2200 0801 2204
8800 2200 0850 2800 8010 0240 a810 2210
8a01 2000 8800 2200 0800 a200 8800 2240
a840 2200 a800 2200 8801 2a04 8805 2204
8add aa45 8a14 2015 8800 a200 8800 a280
8804 2804 8004 2204 8800 2200 8800 2200
8800 0200 8840 0240 8800 2200 8800 2001
8800 0240 8800 2200 b010 1810 b810 1810
0000 0000 0000 0000 0000 0000 0000 0001
0810 2240 8800 a200 8800 2200 8800 2201
8801 2241 8a00 a204 8800 2200 8800 2200
8800 2200 8800 2200 8a00 2201 8800 2200
8a01 2200 0800 a200 0a05 aa75 aa05 2201
aa55 aa55 aa55 aa55 aa55 aa55 aa55 aa55
aa55 aa55 aa55 aa55 bf7f bf5f af47 8301
bbd7 fbf1 f8fd feff fefc fefc fefe fefe
8801 2241 2a05 2200 0040 8200 8800 0200
0000 a204 a840 2200 0a50 8200 8800 2200
a010 2200 8801 2200 8800 2200 2800 a240
a800 2205 8205 2205 8a04 2254 a855 ab55
3e15 2a75 ead5 aa55 82d5 ea75 aa75 aa75
a85c aa50 a850 aa50 8800 2200 8800 2200
0800 a200 8800 a200 8a01 2000 8801 2001
0800 2200 8800 2200 8810 2810 8814 2804
0000 0000 0000 0000 0204 0004 0810 0210
8800 2200 8800 2200 8801 2001 8801 2200
0804 2a00 0810 a200 8800 2200 8800 2200
8800 2200 8800 2200 8800 2200 8801 2200
0840 0240 a800 a210 8800 2200 8800 2200
2a14 2200 8800 2200 aa00 8040 a804 2200
a800 0000 0000 8050 0000 0000 0000 0001
ff7f 3f1f 3f71 8200 feff feff ffff ff7f
8800 2200 88f0 fafc a804 2200 aa11 0210
8800 2200 0800 a200 8800 2200 8800 2200
8800 2200 8800 2200 0840 2240 a800 221f
8a01 2205 8205 befd a850 a854 a855 a955
ff7f ffdd badd ba5d eaf5 ea75 ea75 ead5
a850 aa50 a850 a250 8800 2a04 8a00 2200
0800 0250 0800 0254 8011 2200 8800 2201
0800 2055 aa55 aad5 8810 2040 a040 a040
0000 0000 0000 0200 2800 2240 0840 0240
8800 2200 8800 2200 8800 2200 8800 2200
8800 2200 8800 2200 8800 2200 8800 2200
8800 2200 8800 2200 8800 2200 8800 2200
0850 2210 881c 2804 8800 2200 8800 2200
8800 2200 8800 2200 8800 2200 8800 2200
8a05 2200 8004 0f1f 0244 a818 9810 b2f0
8800 2200 8800 2200 bf1f 2f1f 8f0f 2f07
feff ffff ffff ffff 0090 e2f0 e0f0 f8fc
8840 2200 a800 2210 8800 2200 8800 2200
8800 2200 8800 2200 9f1f 2f0f 8f07 2305
fefd fefd fefd fefd ab51 aa57 aa57 ae55
ba5d ba55 aa55 aa55 ead5 ead5 aad5 aad5
a857 bf7f ff7f ffff afff ffff ffff ffff
80f5 ffff ffff ffff 8855 faf0 f8f8 f8fd
aad5 aa55 2a55 2a55 a075 aa40 a040 a055
0850 aa01 0201 0055 0840 8240 2800 2270
8800 2200 8800 2200 8800 2200 8800 2200
8800 2200 8800 2200 8800 2200 8800 2200
8800 2200 8800 2200 8800 2200 8800 2200
8a01 2001 8800 2200 8800 a2c0 a850 2834
8800 2200 8800 2200 8800 2200 8800 2200
bf7f ff7f ff7f 7f7f e8f0 e2f0 f0f0 fafc
8800 2200 8800 2200 8f0f 2f1f 9f1f 3f7f
ffff ffff fffd fefd fcfd fef5 aa55 ab57
0050 e0f1 fafd eed5 0874 ae57 af5f be5d
8800 22c0 b85c aa5c 8a04 2200 8800 2200
fe7d 3e3d be1d 2e05 ae55 ae55 ae7d ee5d
ab55 ab55 ab57 aa57 aa55 ab55 ab57 ab57
ffff ffff ffff ffff ffff ffff ffff ffff
ffff ffff ffff ffff ffff ffff ffff fefc
ead5 eaf5 eaf5 aa15 bf5f bf5f bf5d aa51
feff ffff ff75 aa40 e8f0 eae4 e064 a210
8800 2200 8800 2200 8800 2200 8800 2200
8800 2200 8800 2200 8800 2200 8800 2201
8800 2005 8810 2200 8800 8200 8800 2200
8800 2200 8800 2200 ba14 2a05 8607 2301
0800 2210 0804 a200 8800 2201 8a04 2850
7f7f ff7f 3f1f 3f1f fcfe ffff ffff f8fc
8801 8fff ffff fe7d ffff ffff ebd7 af57
feff ead7 abd5 aa55 ab55 aa55 ab75 faf5
aed7 aa57 fa50 a0c1 be5f fa50 0000 0255
b878 f87c 2f17 aa40 8800 2200 8840 2010
8a05 2a05 0a1d 0a1d ae5d ae5d ae5d ee5d
aa55 ae55 aa5d ba55 af5f ab5f bb77 ab77
ffff ffff ffff ffff ffff ffff ffff ffff
ffff ffff ffff ffff fefc fefc fefc feff
0a15 0a05 0a05 0255 a850 a850 a850 a854
8040 0000 0800 0814 2211 2010 2010 2210
8800 2200 0800 2200 8800 2200 8800 2200
8800 2200 8800 2200 8a04 2a10 a840 0200
0800 2200 8800 2015 8800 2200 8800 a800
8800 2200 8800 2240 8801 2201 8801 2001
88c0 aad5 aad5 aa55 2000 ba55 aa55 aa57
8f1f af5f afff bf7f fafd fcfc faf5 faff
3a55 0e07 0301 80c0 aa55 eaf5 fbff ff7f
aa55 ab7f ffff ffff fb75 f8f0 e0c0 80c0
8a14 0800 0000 0000 aa00 0000 0000 0000
0004 0201 0001 0001 2010 2040 8880 a001
3e15 2040 e0f4 feff ef55 0000 0000 80d0
fa55 0a15 0a15 0a15 bf77 a347 a347 83c7
ffff ffff ffff ffff ffff ffff ffff ffff
ffff ffff ffff ffff ffff ffff ffff ffff
feff feff ffff aad5 af57 af57 ab57 ab55
ffff ffff ffff aa55 e8f0 e2e0 e8e0 a240
8800 2200 8800 2200 8800 2200 8800 2200
8801 2204 8000 2810 0800 2204 8810 2240
2040 2200 8800 2200 8800 2200 8800 2200
8000 2a04 8a00 2211 8a07 2e0d 8a1d 3a7d
aa55 aa55 aa55 aa55 ae55 af57 ab55 abff
ffff ffff ffff ffff ffff ffff ffff ffff
e0c0 e0f0 f8f0 f8f0 3f1f 0f07 0301 0001
ffff ffff fefe fefc 8000 8000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0001 0001 0000 0000 8303 8343 8343 8343
ffff ffff ffff ffff faff ffff ffff fbf7
bafd ffff bfdf ff5f ef7f ffff af5f af5f
ffff ffff ffff ffff ffff ffff ffff ffff

View file

@ -1,121 +0,0 @@
( GUI Proportional font )
( devices )
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 ]
( variables )
|0000
( program )
|0100
( theme ) #0f9f .System/r DEO2 #0f3f .System/g DEO2 #0f30 .System/b DEO2
#0000 ;draw JSR2
#0001 ;draw JSR2
#0002 ;draw JSR2
BRK
@draw ( extra-spacing* -- )
STH2
;text
&loop
LDAk
DUP #00 EQU ,&end JCN
DUP #0a EQU ,&linefeed JCN
#0005 SFT2 ;font ADD2
DUP2 .Screen/addr DEO2
#09 .Screen/sprite DEO
,get-x-advance JSR .Screen/x DEI2 ADD2 STH2kr ADD2 .Screen/x DEO2
&next
INC2
,&loop JMP
&linefeed
POP
#0000 .Screen/x DEO2
#0008 .Screen/y DEI2 ADD2 STH2kr ADD2 .Screen/y DEO2
,&next JMP
&end
POP POP2 POP2r
JMP2r
@get-x-advance ( font-char-addr* -- advance* )
( Save two 00 bytes for later use )
#0000 SWP2
( First, load the eight bytes that make up the character )
LDA2k SWP2 #0002 ADD2
LDA2k SWP2 #0002 ADD2
LDA2k SWP2 #0002 ADD2
LDA2
( OR all the bytes together, so we know which columns contain filled pixels )
ORA2 ORA2 ORA2 ORA
( Find the lowest set bit (using one of the 00 bytes at the top, but not consuming it) )
SUBk AND
( Convert the nine possible values (00-80) into an offset into the magic table (00-08). )
( They get jumbled up with these two operations, but each possible value remains unique )
#a3 MUL #16 DIV
( Load the byte from the magic table, return a short (consuming/returning the 00 bytes at the top) )
;&magic ADD2 LDA
JMP2r
( The magic table performs the last bit of arithmetic we want:
* the advance in x should be one more than the number of columns with filled pixels,
* with a maximum of 8, and
* a minimum of 3. )
&magic
03 ( lowest set bit is 00, 0 columns wide )
06 ( lowest set bit is 08, 5 columns wide )
05 ( lowest set bit is 10, 4 columns wide )
08 ( lowest set bit is 02, 7 columns wide )
04 ( lowest set bit is 20, 3 columns wide )
03 ( lowest set bit is 80, 1 column wide )
07 ( lowest set bit is 04, 6 columns wide )
08 ( lowest set bit is 01, 8 columns wide )
03 ( lowest set bit is 40, 2 columns wide )
@font ( spectrum-zx font, with each character moved to be flush left in its cell )
[
0000 0000 0000 0000 0000 4800 fc78 0000 0000 4800 7884 0000 0000 d8f8 f870 2000
0020 70f8 f870 2000 0070 70f8 d820 7000 0020 70f8 f820 7000 0000 00c0 c000 0000
00fc 8484 8484 fc00 0000 6090 9060 0000 0030 4884 8448 3000 003c 0c74 9490 6000
0070 88d8 20f8 2000 0030 2020 20e0 e000 007c 4444 44cc cc00 0000 2088 0088 2000
0000 80c0 e0c0 8000 0000 2060 e060 2000 0040 e000 00e0 4000 00a0 a0a0 a000 a000
007c 9494 7414 1400 0018 608c c418 6000 0000 0000 0000 ffff 0040 e000 e040 00e0
0020 70a8 2020 2000 0020 2020 a870 2000 0000 1008 fc08 1000 0000 2040 fc40 2000
0000 8080 fc00 0000 0000 0048 cc48 0000 0000 2070 f800 0000 0000 00f8 7020 0000
0000 0000 0000 0000 0080 8080 8000 8000 00a0 a000 0000 0000 0048 fc48 48fc 4800
0020 78a0 7028 f020 0084 0810 2040 8400 0060 9064 9888 7400 0040 8000 0000 0000
0040 8080 8080 4000 0080 4040 4040 8000 0000 5020 f820 5000 0000 2020 f820 2000
0000 0000 0040 4080 0000 0000 f000 0000 0000 0000 0000 8000 0000 0810 2040 8000
0078 8c94 a4c4 7800 0060 a020 2020 f800 0078 8404 7880 fc00 0078 8438 0484 7800
0010 3050 90fc 1000 00fc 80f8 0484 7800 0078 80f8 8484 7800 00fc 0408 1020 2000
0078 8478 8484 7800 0078 8484 7c04 7800 0000 0080 0000 8000 0000 4000 0040 4080
0000 2040 8040 2000 0000 00f8 00f8 0000 0000 8040 2040 8000 0078 8404 1800 1000
0078 84b4 a884 7800 0030 4884 fc84 8400 00f8 84f8 8484 f800 0078 8480 8084 7800
00f0 8884 8488 f000 00fc 80f8 8080 fc00 007c 8080 f880 8000 0078 8480 9c84 7800
0084 84fc 8484 8400 00f8 2020 2020 f800 0004 0404 8484 7800 0088 90e0 9088 8400
0080 8080 8080 fc00 0084 ccb4 8484 8400 0084 c4a4 948c 8400 0078 8484 8484 7800
00f8 8484 f880 8000 0078 8484 a494 7800 00f8 8484 f888 8400 0078 8078 0484 7800
00fe 1010 1010 1000 0084 8484 8484 7800 0084 8484 8448 3000 0084 8484 b4cc 8400
0084 4830 3048 8400 0082 4428 1010 1000 00fc 0810 2040 fc00 00c0 8080 8080 c000
0080 4020 1008 0400 00c0 4040 4040 c000 0020 5088 0000 0000 0000 0000 0000 fc00
0080 4000 0000 0000 0000 7008 7888 7800 0080 80f0 8888 f000 0000 7880 8080 7800
0008 0878 8888 7800 0000 7088 f080 7800 0060 80e0 8080 8000 0000 7088 8878 0870
0080 80b0 c888 8800 0040 00c0 4040 2000 0010 0010 1010 9060 0080 90a0 c0a0 9000
0080 8080 8080 6000 0000 d0a8 a8a8 a800 0000 b0c8 8888 8800 0000 7088 8888 7000
0000 f088 88f0 8080 0000 7888 8878 080c 0000 b0c0 8080 8000 0000 7080 7008 f000
0040 40f0 4040 3000 0000 8888 8888 7000 0000 8888 5050 2000 0000 88a8 a8a8 5000
0000 8850 2050 8800 0000 8888 8878 0870 0000 f810 2040 f800 0060 4080 8040 6000
0080 8080 8080 8000 00c0 4020 2040 c000 0000 0064 9800 0000 3c42 99a1 a199 423c
]
@text "Are 20 "proportional 20 "fonts 20 "a 20 "good 20 "idea? 0a 0a
"The 20 "jury 20 "is 20 "still 20 "out, 20 "but 20 "one 20 "thing 20 "is 20 "certain: 0a
"it 20 "is 20 "possible 20 "to 20 "print 20 "with 20 "these 20 "fonts 20 "in 20 "Uxn. 0a 0a 0a 00

View file

@ -22,7 +22,7 @@ The debugger will catch stack errors that arise after that point.
@debug ( pc* -- )
#0001 SUB2 .System/eaddr DEO2
.System/ecode DEIk #f8 AND #06 EOR SWP DEO
.System/ecode DEIk #07 EOR SWP DEO
,debug-vector/main JMP
@debug-vector ( -> )
@ -126,18 +126,19 @@ The debugger will catch stack errors that arise after that point.
:&rst-msg :&overflow-msg
:&wst-msg :&divzero-msg
:&rst-msg :&divzero-msg
:&emulator-msg :&interrupt-msg
:&userdef-msg :&breakpoint-msg
:&userdef-msg :&custom-msg
&halted-msg "Halted: 2000 ( #0002, at 0x0100 )
&wst-msg "Working-stack 2000
&rst-msg "Return-stack 2000
&emulator-msg "Emulator 2000
&userdef-msg "User-defined 2000
&underflow-msg "underflow 00
&overflow-msg "overflow 00
&divzero-msg "division 20 "by 20 "zero 00
&interrupt-msg "interrupt 00
&breakpoint-msg "breakpoint 00
&custom-msg "custom 20 "error 00
&executing-msg 20 "executing 2000
&at-msg 20 "at 20 "0x 00
&contents-msg "contents: 00

Binary file not shown.

BIN
projects/pictures/uxn16.chr Normal file

Binary file not shown.

BIN
projects/pictures/uxn32.chr Normal file

Binary file not shown.

View file

@ -1,464 +0,0 @@
( launcher )
%+ { ADD } %- { SUB } %* { MUL } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
%8// { #03 SFT2 }
%10** { #40 SFT2 } %10// { #04 SFT2 }
%MIN2 { LTH2k JMP SWP2 POP2 }
%MOD { DIVk MUL SUB }
%DEC { #01 - }
%RTN { JMP2r }
%TOS { #00 SWP }
%SWP? { #01 JCN SWP } %SWP2? { #01 JCN SWP2 }
%BRK? { #01 JCN BRK }
%RTN? { #01 JCN RTN }
%DEBUG { ;print-hex/byte JSR2 #0a .Console/write DEO }
%DEBUG2 { ;print-hex/short JSR2 #0a .Console/write DEO }
%SEL-ENTRY { ;dir/entries #00 .browser/sel LDZ DUP2 ADD2 ADD2 }
( devices )
|00 @System &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1
|10 @Console &vector $2 &read $1 &pad $5 &write $1 &error $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
|a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
|b0 @DateTime &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1
( variables )
|0000
@pointer
&x $2 &y $2
@browser
&x $2 &y $2
&sel $1 &last $1
( init )
|0100 ( -> )
( theme )
#f077 .System/r DEO2
#f00c .System/g DEO2
#f02a .System/b DEO2
( vectors )
;on-frame .Screen/vector DEO2
;on-button .Controller/vector DEO2
;on-mouse .Mouse/vector DEO2
( setup synth )
#0102 .Audio0/adsr DEO2
;sin-pcm .Audio0/addr DEO2
#0100 .Audio0/length DEO2
#dd .Audio0/volume DEO ( TODO: turn ON )
( determine max visible file length )
.Screen/width DEI2 8// #00ff MIN2 NIP
;draw-browser/clear-length STA
( place )
#0088 .browser/x STZ2
#0010 .browser/y STZ2
( draw mascot )
#0010 #0010 #0060 #0060 ;mascot-icn #01 ;draw-icn JSR2
;read-dir JSR2
( theme support )
;load-theme JSR2
( force selection )
#ff .browser/last STZ
#00 ;select-file JSR2
BRK
@on-frame ( -> )
( unused )
BRK
@on-mouse ( -> )
;pointer-icn .Screen/addr DEO2
( clear last cursor )
.pointer/x LDZ2 .Screen/x DEO2
.pointer/y LDZ2 .Screen/y DEO2
#40 .Screen/sprite DEO
( draw new cursor )
.Mouse/x DEI2 DUP2 .pointer/x STZ2 .Screen/x DEO2
.Mouse/y DEI2 DUP2 .pointer/y STZ2 .Screen/y DEO2
#41 .Mouse/state DEI #01 = + .Screen/sprite DEO
( select choice )
.Mouse/y DEI2 .browser/y LDZ2 --
10// NIP ;select-file JSR2
.Mouse/state DEI #00 = ,&no-click JCN
.browser/sel LDZ ;run-file JSR2
&no-click
BRK
@on-button ( -> )
.Controller/button DEI
DUP #10 ! ,&no-up JCN
.browser/sel LDZ DEC ;select-file JSR2
POP BRK
&no-up
DUP #20 ! ,&no-down JCN
.browser/sel LDZ INC ;select-file JSR2
POP BRK
&no-down
DUP #01 ! ,&no-a JCN
.browser/sel LDZ ;run-file JSR2
POP BRK
&no-a
POP
.Controller/key DEI
DUP #0d ! ,&no-enter JCN
.browser/sel LDZ ;run-file JSR2
POP
&no-enter
POP
BRK
@read-dir ( -- )
;dir/path .File/name DEO2
#1000 .File/length DEO2
;dir/data .File/read DEO2
( separate into lines )
#00 ;dir/data STH2k
&while
LDAk #0a ! ,&no-lb JCN
STAk
STH2r ;add-entry JSR2
INC2 STH2k ,&while JMP
&no-lb INC2 LDAk ,&while JCN
POP2r POP2 POP
RTN
@add-entry ( line* -- )
DUP2 ;filter-entry JSR2 ,&ignored JCN
( just add entry to end for now, FIXME sort entries )
;dir/entries
#00 ;dir/lines LDA DUP2 ADD2
ADD2
STA2
;dir/lines LDAk INC ROT ROT STA
#0000
&ignored
POP2
RTN
@filter-entry ( line* -- ignore-flag )
POP2 #00
RTN
@select-file ( id -- )
( clamp id to useful values )
DUP #fc LTH ,&not-negative JCN
DUP EOR
&not-negative
;dir/lines LDA DEC LTHk SWP? POP
DUP .browser/last LDZ ! ,&has-changed JCN
POP RTN
&has-changed
DUP ;scroll-browser JSR2
.browser/x LDZ2 #0018 -- .browser/y LDZ2 [ .browser/sel LDZ TOS 10** ++ ]
#0010 #0010
;hand-icn #00 ;draw-icn JSR2
DUP
.browser/sel STZ
DUP
.browser/last STZ
#30 + .Audio0/pitch DEO
;draw-browser JSR2
.browser/x LDZ2 #0018 -- .browser/y LDZ2 [ .browser/sel LDZ TOS 10** ++ ]
#0010 #0010
;hand-icn #02 ;draw-icn JSR2
#0010 #0010 #0060 #0060
;mascot-icn [ .browser/sel LDZ #03 AND TOS #0480 ** ++ ] #01
;draw-icn JSR2
RTN
( Scroll the browser to accomodate off-screen line items )
@scroll-browser ( id -- )
( Check whether the selection moved up or down )
.browser/last LDZ OVR SWP SUB #80 AND ,&negative JCN
&positive ( The selection moved down )
( Calculate the id currently at the bottom of the screen )
.Screen/height DEI2 .browser/y LDZ2 #0010 ++ -- 10// NIP
GTH ,&scroll-up JCN [ RTN ]
&scroll-up
.browser/y LDZ2k #0010 -- ROT STZ2
RTN
&negative ( The selection moved up )
( Calculate the id currently at the top of the screen )
( TODO make a macro constant for y initial pos )
#0010 .browser/y LDZ2 -- 10// NIP
LTH ,&scroll-down JCN [ RTN ]
&scroll-down
.browser/y LDZ2k #0010 ++ ROT STZ2 ( Decrement y by 0x10 )
RTN
@run-file ( id -- )
SEL-ENTRY LDA2
#0005 ++ DUP2 ;print-string JSR2
#0a .Console/write DEO
DUP2 ;check-rom JSR2 ,&valid JCN
POP2 RTN
&valid
;load-rom JSR2
RTN
@print-string ( addr* -- )
&loop
LDAk .Console/write DEO
INC2 LDAk ,&loop JCN
POP2
RTN
@redraw ( -- )
( unused )
RTN
@draw-browser ( -- )
.browser/x LDZ2 .Screen/x DEO2
.browser/y LDZ2 .Screen/y DEO2
SEL-ENTRY ;dir/entries
&outer ( selected-entry* this-entry* )
.Screen/y DEI2 #0010 LTH2 ,&inc JCN ( Don't draw anything in the first row )
EQU2k #0c * #01 + STH
LDA2k ORAk #00 = ,&end JCN
,&clear JSR
STHr ,&draw-one JSR
.browser/x LDZ2 .Screen/x DEO2
&inc .Screen/y DEI2 #0010 ++ .Screen/y DEO2
INC2 INC2 ,&outer JMP
&end
POP2 POP2 POP2 POPr
RTN
&draw-one ( line* color -- )
STH
&loop
( top-addr ) LDAk #20 - TOS #0010 MUL2 ;font ++ .Screen/addr DEO2
( top-draw ) STHkr .Screen/sprite DEO
( bottom-addr ) .Screen/addr DEI2 #0008 ++ .Screen/addr DEO2
( next-y ) .Screen/y DEI2 #0008 ++ .Screen/y DEO2
( bottom-draw ) STHkr .Screen/sprite DEO
( prev-y ) .Screen/y DEI2 #0008 -- .Screen/y DEO2
( move ) .Screen/x DEI2 #0008 ++ .Screen/x DEO2
&skip
INC2 LDAk ,&loop JCN
POP2 POPr
RTN
&clear ( -- )
.Screen/x DEI2k ( Stash the current x pos )
( Clear the screen )
( Clear length gets set in init )
LIT2 &clear-length 00 00
&clear-loop
#00 .Screen/sprite DEO
.Screen/y DEI2k #0008 ++ ROT DEO2
#00 .Screen/sprite DEO
.Screen/y DEI2k #0008 -- ROT DEO2
.Screen/x DEI2k #0008 ++ ROT DEO2
INC NEQk ,&clear-loop JCN
POP2
ROT DEO2
RTN
@draw-time ( -- )
.DateTime/day DEI
DUP #0f AND ;hex-char JSR2 ;&date-str #0009 ++ STA
#04 SFT ;hex-char JSR2 ;&date-str #0008 ++ STA
.DateTime/month DEI
DUP #0f AND ;hex-char JSR2 ;&date-str #0006 ++ STA
#04 SFT ;hex-char JSR2 ;&date-str #0005 ++ STA
.DateTime/year DEI2
DUP #0f AND ;hex-char JSR2 ;&date-str #0003 ++ STA
#04 SFT ;hex-char JSR2 ;&date-str #0002 ++ STA
DUP #0f AND ;hex-char JSR2 ;&date-str INC2 STA
#04 SFT ;hex-char JSR2 ;&date-str STA
.DateTime/second DEI
DUP #0f AND ;hex-char JSR2 ;&time-str #0007 ++ STA
#04 SFT ;hex-char JSR2 ;&time-str #0006 ++ STA
.DateTime/minute DEI
DUP #0f AND ;hex-char JSR2 ;&time-str #0004 ++ STA
#04 SFT ;hex-char JSR2 ;&time-str #0003 ++ STA
.DateTime/hour DEI
DUP #0f AND ;hex-char JSR2 ;&time-str INC2 STA
#04 SFT ;hex-char JSR2 ;&time-str STA
#0020 #0080 ;&date-str #01 ;draw-label JSR2
#0080 #0080 ;&time-str #02 ;draw-label JSR2
RTN
&date-str "0000-00-00 $1
&time-str "00:00:00 $1
@hex-char ( hex -- char )
DUP #09 GTH #04 JCN #30 + RTN #57 +
RTN
@draw-icn ( x* y* width* height* addr* color -- )
( load ) STH .Screen/addr DEO2 ,&height STR2 ,&width STR2 ,&y STR2 ,&x STR2
,&height LDR2 #0000
&ver
( save ) DUP2 ,&y LDR2 ADD2 .Screen/y DEO2
,&width LDR2 #0000
&hor
( save ) DUP2 ,&x LDR2 ADD2 .Screen/x DEO2
( draw ) STHkr .Screen/sprite DEO
( incr ) .Screen/addr DEI2 #0008 ADD2 .Screen/addr DEO2
#0008 ADD2 GTH2k ,&hor JCN
POP2 POP2
#0008 ADD2 GTH2k ,&ver JCN
POP2 POP2
POPr
RTN
&x $2 &y $2 &width $2 &height $2
@draw-label ( x* y* addr* color -- )
STH STH2
.Screen/y DEO2
.Screen/x DEO2
STH2r
&loop
( top-addr ) LDAk #20 - TOS #0010 MUL2 ;font ++ .Screen/addr DEO2
( top-draw ) STHkr .Screen/sprite DEO
( bottom-addr ) .Screen/addr DEI2 #0008 ++ .Screen/addr DEO2
( next-y ) .Screen/y DEI2 #0008 ++ .Screen/y DEO2
( bottom-draw ) STHkr .Screen/sprite DEO
( prev-y ) .Screen/y DEI2 #0008 -- .Screen/y DEO2
( move ) .Screen/x DEI2 #0008 ++ .Screen/x DEO2
INC2 LDAk ,&loop JCN
POP2 POPr
RTN
( theme )
@theme-txt ".theme $1
@load-theme ( -- )
;theme-txt .File/name DEO2
#0006 .File/length DEO2
#fffa .File/read DEO2
.File/success DEI2 #0006 !! ,&ignore JCN
#fffa LDA2 .System/r DEO2
#fffc LDA2 .System/g DEO2
#fffe LDA2 .System/b DEO2
&ignore
;redraw JSR2
RTN
( helpers )
@print-hex ( value* -- )
&short ( value* -- )
SWP ,&echo JSR
&byte ( value -- )
,&echo JSR
RTN
&echo ( value -- )
STHk #04 SFT ,&parse JSR .Console/write DEO
STHr #0f AND ,&parse JSR .Console/write DEO
RTN
&parse ( value -- char )
DUP #09 GTH ,&above JCN #30 + RTN &above #09 - #60 + RTN
RTN
@pointer-icn
80c0 e0f0 f8e0 1000
@hand-icn
000c 0a0a 1224 4780
0000 0000 0000 fc02
8180 8080 8040 3f00
fc20 c020 c020 c000
@sin-pcm
8083 8689 8c8f 9295 989b 9ea1 a4a7 aaad
b0b3 b6b9 bbbe c1c3 c6c9 cbce d0d2 d5d7
d9db dee0 e2e4 e6e7 e9eb ecee f0f1 f2f4
f5f6 f7f8 f9fa fbfb fcfd fdfe fefe fefe
fffe fefe fefe fdfd fcfb fbfa f9f8 f7f6
f5f4 f2f1 f0ee eceb e9e7 e6e4 e2e0 dedb
d9d7 d5d2 d0ce cbc9 c6c3 c1be bbb9 b6b3
b0ad aaa7 a4a1 9e9b 9895 928f 8c89 8683
807d 7a77 7471 6e6b 6865 625f 5c59 5653
504d 4a47 4542 3f3d 3a37 3532 302e 2b29
2725 2220 1e1c 1a19 1715 1412 100f 0e0c
0b0a 0908 0706 0505 0403 0302 0202 0202
0102 0202 0202 0303 0405 0506 0708 090a
0b0c 0e0f 1012 1415 1719 1a1c 1e20 2225
2729 2b2e 3032 3537 3a3d 3f42 4547 4a4d
5053 5659 5c5f 6265 686b 6e71 7477 7a7d
~projects/library/check-rom.tal
~projects/library/load-rom.tal
~projects/assets/mascot0cx0c.tal
~projects/assets/msx01x02.tal
@dir
&path ". $1
&lines $1
&entries $100
&data

View file

@ -2,33 +2,35 @@
a simple calculator
uxnasm projects/software/calc.tal bin/calc.rom && uxnemu bin/calc.rom )
%+ { ADD } %- { SUB } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %// { DIV2 }
%+ { ADD } %- { SUB } %* { MUL } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
%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 }
%10* { #40 SFT } %10/ { #04 SFT } %10** { #40 SFT2 } %10// { #04 SFT2 }
%20* { #50 SFT } %20/ { #05 SFT } %20** { #50 SFT2 } %20// { #05 SFT2 }
%2MOD { #01 AND } %2MOD2 { #0001 AND2 }
%4MOD { #03 AND } %4MOD2 { #0003 AND2 }
%8MOD { #07 AND } %8MOD2 { #0007 AND2 }
%10MOD { #0f AND } %10MOD2 { #000f AND2 }
%!~ { NEQk NIP }
%2* { #10 SFT }
%4* { #20 SFT } %4/ { #02 SFT }
%8* { #30 SFT } %8/ { #03 SFT }
%2** { #10 SFT2 } %2// { #01 SFT2 }
%4** { #20 SFT2 }
%8** { #30 SFT2 } %8// { #03 SFT2 }
%10** { #40 SFT2 } %10// { #04 SFT2 }
%20** { #50 SFT2 }
%2MOD2 { #0001 AND2 }
%4MOD { #03 AND } %4MOD2 { #0003 AND2 }
%8MOD { #07 AND }
%DEBUG { ;print-hex/byte JSR2 #0a .Console/write DEO }
%DEBUG2 { ;print-hex/short JSR2 #0a .Console/write DEO }
%AUTO-NONE { #00 .Screen/auto DEO }
%AUTO-X { #01 .Screen/auto DEO }
%AUTO-XADDR { #05 .Screen/auto DEO }
%AUTO-YADDR { #06 .Screen/auto DEO }
%RELEASE-MOUSE { #0096 DEO }
%RTN { JMP2r }
%BRK? { #01 JCN BRK }
%RTN? { #01 JCN RTN }
%TOS { #00 SWP }
@ -47,7 +49,8 @@
|0000
@input
&length $1 &value $2
&value $2
&mode $1
@stack
&length $1
&items $10
@ -82,7 +85,7 @@
;on-button .Controller/vector DEO2
( setup synth )
#0110 .Audio0/adsr DEO2
#0010 .Audio0/adsr DEO2
;sin-pcm .Audio0/addr DEO2
#0100 .Audio0/length DEO2
#dd .Audio0/volume DEO
@ -120,13 +123,11 @@ BRK
.Controller/key DEI
( generics )
#00 !~ ,&no-release JCN ;redraw JSR2 POP BRK &no-release
#00 !~ ,&no-empty JCN ;redraw JSR2 POP BRK &no-empty
#09 !~ ,&no-tab JCN ;toggle-mode JSR2 POP BRK &no-tab
#0d !~ ,&no-enter JCN ;do-push JSR2 POP BRK &no-enter
#1b !~ ,&no-esc JCN ;do-pop JSR2 POP BRK &no-esc
#08 !~ ,&no-backspace JCN
.input/value LDZ2 #04 SFT2 .input/value STZ2
#ff ;draw-input JSR2 POP BRK
&no-backspace
#08 !~ ,&no-backspace JCN ;do-erase JSR2 POP BRK &no-backspace
( arithmetic )
LIT '+ !~ ,&no-add JCN ;do-add JSR2 POP BRK &no-add
LIT '- !~ ,&no-sub JCN ;do-sub JSR2 POP BRK &no-sub
@ -156,50 +157,59 @@ BRK
.Mouse/y DEI2 DUP2 .pointer/y STZ2 .Screen/y DEO2
#41 .Mouse/state DEI #01 = + .Screen/sprite DEO
( handle events )
.Mouse/state DEI .pointer/last LDZ
( down )
DUP2 #0100 !! ,&no-down JCN
.Mouse/state DEI .pointer/last STZ
POP2
.Mouse/x DEI2 .Mouse/y DEI2
OVR2 OVR2 .keypad-frame ;within-rect JSR2 ;click-keypad JCN2
OVR2 OVR2 .input-frame ;within-rect JSR2 ;click-input JCN2
OVR2 OVR2 .modpad-frame ;within-rect JSR2 ;click-modpad JCN2
OVR2 OVR2 .bitpad-frame ;within-rect JSR2 ;click-bitpad JCN2
POP2 POP2
BRK
&no-down
( up )
DUP2 #0001 !! ,&no-up JCN
.Mouse/state DEI .pointer/last STZ
POP2 ;redraw JSR2 BRK
;redraw JSR2
&no-up
POP2
( record )
.Mouse/state DEI .pointer/last STZ
BRK
@click-keypad ( x* y* -> )
@click-keypad ( state* x* y* -> )
( y ) .keypad-frame/y LDZ2 -- #24 SFT2
( x ) SWP2 .keypad-frame/x LDZ2 -- 10// 4MOD2
( value ) ++ ;keypad/layout ++ LDA
;push-input JSR2
RELEASE-MOUSE
( value ) ++ ;keypad/layout ++ LDA ;push-input JSR2
RELEASE-MOUSE POP2
BRK
@click-modpad ( x* y* -> )
@click-modpad ( state* x* y* -> )
( y ) .modpad-frame/y LDZ2 -- #24 SFT2 NIP STH
( x ) .modpad-frame/x LDZ2 -- 10//
( lookup ) STHr + 2** ;keypad/ops ++ LDA2 JSR2
;draw-bitpad JSR2
RELEASE-MOUSE
RELEASE-MOUSE POP2
BRK
@click-bitpad ( x* y* -> )
@click-input ( state* x* y* -> )
POP2
.input-frame/x LDZ2 -- 8// NIP
DUP #00 ! ,&no-push JCN
;do-push JSR2 &no-push
DUP #01 ! ,&no-pop JCN
;do-pop JSR2 &no-pop
POP
RELEASE-MOUSE POP2
BRK
@click-bitpad ( state* x* y* -> )
( y ) .bitpad-frame/y LDZ2 -- 8// NIP 8* STH
( x ) .bitpad-frame/x LDZ2 -- 8// NIP
@ -213,22 +223,8 @@ BRK
.input/value STZ2
;draw-bitpad JSR2
RELEASE-MOUSE
BRK
@click-input ( x* y* -> )
POP2
.input-frame/x LDZ2 -- 8// NIP
DUP #00 ! ,&no-push JCN
;do-push JSR2
&no-push
DUP #01 ! ,&no-pop JCN
;do-pop JSR2
&no-pop
POP
RELEASE-MOUSE
#ff ;draw-input JSR2
RELEASE-MOUSE POP2
BRK
@ -236,8 +232,9 @@ BRK
DUP #50 + .Audio0/pitch DEO
DUP TOS ;keypad/series ++ LDA ;draw-keypad JSR2
TOS .input/value LDZ2 10** ++ .input/value STZ2
( INCZ ) .input/length LDZk INC SWP STZ
( hex/dec )
TOS .input/value LDZ2 #00 [ #0a #10 .input/mode LDZ JMP SWP POP ] **
++ .input/value STZ2
#ff ;draw-input JSR2
;draw-bitpad JSR2
@ -263,13 +260,20 @@ RTN
RTN
@toggle-mode ( -- )
.input/mode LDZk #00 = SWP STZ
;redraw JSR2
RTN
@do-push ( -- )
.input/value LDZ2 ADD #00 > JMP RTN
.stack/length LDZ #07 < JMP RTN
#40 .Audio0/pitch DEO
.input/value LDZ2 ;push JSR2
;draw-bitpad JSR2
RTN
@ -282,6 +286,7 @@ RTN
;draw-stack JSR2
&continue
#01 ;draw-input JSR2
;draw-bitpad JSR2
RTN
@ -397,17 +402,22 @@ RTN
RTN
@do-erase ( -- )
.input/value LDZ2 #04 SFT2 .input/value STZ2
#ff ;draw-input JSR2
;draw-bitpad JSR2
RTN
@key-value ( key -- value )
DUP #2f > OVR #3a < #0101 !! ,&no-num JCN
#30 - RTN
&no-num
DUP #60 > OVR #67 < #0101 !! ,&no-lc JCN
#57 - RTN ( #61 - #0a + )
&no-lc
DUP #40 > OVR #47 < #0101 !! ,&no-uc JCN
#37 - RTN ( #41 - #0a + )
&no-uc
DUP #2f > OVR #3a < #0101 !! ,&no-num JCN
#30 - RTN &no-num
DUP #60 > OVR #67 < #0101 !! ,&no-lc JCN
#57 - RTN ( #61 - #0a + ) &no-lc
DUP #40 > OVR #47 < #0101 !! ,&no-uc JCN
#37 - RTN ( #41 - #0a + ) &no-uc
POP #00
RTN
@ -418,7 +428,22 @@ RTN
#ff ;draw-modpad JSR2
#ff ;draw-input JSR2
;draw-bitpad JSR2
,draw-stack JSR
;draw-mode JSR2
;draw-stack JSR2
#0010 .Screen/x DEO2
#0010 .Screen/y DEO2
RTN
@draw-mode ( -- )
AUTO-XADDR
.input-frame/x LDZ2 .Screen/x DEO2
.input-frame/y LDZ2 #0014 -- .Screen/y DEO2
;modes #00 .input/mode LDZ #0018 MUL2 ++ .Screen/addr DEO2
#02 .input/mode LDZ + .Screen/sprite DEOk DEOk DEO
AUTO-NONE
RTN
@ -426,99 +451,39 @@ RTN
#08 #00
&loop
.input-frame/x LDZ2 #0018 ++ .Screen/x DEO2
DUP TOS 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 STH2
( y ) DUP TOS 8** .input-frame/y LDZ2 ++ #004c -- STH2
( x ) .input-frame/x LDZ2 #0020 ++ STH2r STH2r STHr ,draw-short JSR
( value ) DUP 2* .stack/items + [ #10 .stack/length LDZ 2* - - ] LDZ2
STHr ;draw-number JSR2
INC GTHk ,&loop JCN
POP2
RTN
@draw-short ( x* y* value* color -- )
STH STH2
.Screen/y DEO2
#0020 ++ .Screen/x DEO2
#0400
&loop
.Screen/x DEI2 #0008 -- .Screen/x DEO2
( value ) DUP STH2kr ROT 4* SFT2 #000f AND2
( value glyph ) 8** ;font-hex ++ .Screen/addr DEO2
( get color ) ROTr STHkr
( place stack ) ROTr ROTr
( no leading zeros )
OVR STH2kr ,get-length JSR < ,&visible JCN
POP #00
&visible
( draw ) .Screen/sprite DEO
INC GTHk ,&loop JCN
POP2
POP2r POPr
RTN
@get-length ( short* -- length )
DUP2 #1000 << ,&no4 JCN POP2 #04 RTN &no4
DUP2 #0100 << ,&no3 JCN POP2 #03 RTN &no3
DUP2 #0010 << ,&no2 JCN POP2 #02 RTN &no2
#0000 !!
RTN
@draw-decimal ( -- )
.bitpad-frame/y2 LDZ2 #0008 ++ .Screen/y DEO2
.center/x LDZ2 #0014 -- .Screen/x DEO2
#01 .Screen/auto DEO
.input/value LDZ2
( 10,000 ) #2710 DIV2k DUP2 NIP ,&digit JSR [ MUL2 SUB2 ]
( 1,000 ) #03e8 DIV2k DUP2 NIP ,&digit JSR [ MUL2 SUB2 ]
( 100 ) #0064 DIV2k DUP2 NIP ,&digit JSR [ MUL2 SUB2 NIP ]
( 10 ) #0a DIVk DUP ,&digit JSR [ MUL SUB ]
( 1 ) ,&digit JSR
#00 .Screen/auto DEO
RTN
&digit ( num -- )
8* TOS ;font-hex ++ .Screen/addr DEO2
#03 .Screen/sprite DEO
RTN
@draw-input ( key -- )
STH
( draw value )
.input-frame/x LDZ2 #0020 ++
.input-frame/y LDZ2 #0003 ++
.input/value LDZ2
#02
;draw-short JSR2
.input-frame/x LDZ2 #0018 ++ .Screen/x DEO2
.input-frame/y LDZ2 #0003 ++ .Screen/y DEO2
.input/value LDZ2 #02 ;draw-number JSR2
( controls )
.input-frame/x LDZ2
.input-frame/y LDZ2
;stack-icns/push [ STHkr #00 = ] #02
;draw-key-thin JSR2
.input-frame/x LDZ2 #0008 ++
.input-frame/y LDZ2
;stack-icns/pop [ STHkr #01 = ] #03
;draw-key-thin JSR2
( line )
.input-frame/x LDZ2
.input-frame/x2 LDZ2
.input-frame/y LDZ2 #0004 -- #02
;line-hor-dotted JSR2
POPr
;draw-decimal JSR2
RTN
@draw-keypad ( key -- )
@ -559,7 +524,7 @@ RTN
@draw-bitpad ( -- )
#10 #00
#1000
&loop
( y ) DUP 8/ TOS 8** .bitpad-frame/y LDZ2 ++ .Screen/y DEO2
( x ) DUP 8MOD TOS 8** .bitpad-frame/x LDZ2 ++ .Screen/x DEO2
@ -573,7 +538,7 @@ RTN
@draw-key ( x* y* glyph* state color -- )
( auto x addr ) #05 .Screen/auto DEO
( auto x addr ) AUTO-XADDR
( color ) ,&color STR
( state ) ,&state STR
( glyph ) ,&glyph STR2
@ -591,30 +556,57 @@ RTN
.Screen/x DEI2 #000c -- .Screen/x DEO2
.Screen/y DEI2 #0005 -- .Screen/y DEO2
,&color LDR [ ,&state LDR #09 MUL + ] .Screen/sprite DEO
( auto none ) #00 .Screen/auto DEO
( auto none ) AUTO-NONE
RTN
&color $1 &state $1 &glyph $2
@draw-key-thin ( x* y* glyph* state color -- )
( auto y addr ) #06 .Screen/auto DEO
( color ) ,&color STR
( state ) ,&state STR
( glyph ) ,&glyph STR2
( state ) ;button-thin-icns [ #00 ,&state LDR 10** ++ ] .Screen/addr DEO2
( y ) .Screen/y DEO2
( x ) .Screen/x DEO2
( draw background )
,&color LDR .Screen/sprite DEOk DEO
AUTO-YADDR
,&color STR ,&state STR ,&glyph STR2
( frame )
;button-thin-icns #00 [ LIT &state $1 ] 10** ++ .Screen/addr DEO2
.Screen/y DEO2 .Screen/x DEO2
[ LIT &color $1 ] .Screen/sprite DEOk DEO
( glyph )
,&glyph LDR2 .Screen/addr DEO2
[ LIT2 &glyph $2 ] .Screen/addr DEO2
.Screen/y DEI2 #000c -- .Screen/y DEO2
#05 .Screen/sprite DEO
( auto none ) #00 .Screen/auto DEO
AUTO-NONE
RTN
@draw-number ( number* color -- )
,&color STR
.input/mode LDZ ,&decimal JCN
( hexadecimal )
AUTO-X
,&color LDR #00 ,&color STR
#00 ,&digit JSR ,&color STR
SWP
STHk #04 SFT ,&digit JSR
STHr #0f AND ,&digit JSR
STHk #04 SFT ,&digit JSR
STHr #0f AND ,&digit JSR
AUTO-NONE
RTN
&decimal
AUTO-X
#2710 DIV2k DUP2 NIP ,&digit JSR MUL2 SUB2
#03e8 DIV2k DUP2 NIP ,&digit JSR MUL2 SUB2
#0064 DIV2k DUP2 NIP ,&digit JSR MUL2 SUB2 NIP
#0a DIVk DUP ,&digit JSR MUL SUB
,&digit JSR
AUTO-NONE
RTN
&digit
8* TOS ;font-hex ++ .Screen/addr DEO2
LIT &color $1 .Screen/sprite DEO
RTN
RTN
&color $1 &state $1 &glyph $2
( theme )
@ -645,12 +637,8 @@ RTN
( x > rect.x2 ) DUP2 STHkr #04 ADD LDZ2 GTH2 ,&skip JCN
POP2 POP2 POPr
#01
RTN
&skip
POP2 POP2 POPr
#00
RTN
RTN
&skip POP2 POP2 POPr #00 RTN
@line-hor-dotted ( x0* x1* y* color -- )
@ -665,38 +653,24 @@ RTN
RTN
@print-hex ( value* -- )
&short ( value* -- )
SWP ,&echo JSR
&byte ( value -- )
,&echo JSR
RTN
&echo ( value -- )
STHk #04 SFT ,&parse JSR .Console/write DEO
STHr #0f AND ,&parse JSR .Console/write DEO
RTN
&parse ( value -- char )
DUP #09 GTH ,&above JCN #30 + RTN &above #09 - #60 + RTN
SWP ,&byte JSR
&byte ( byte -- )
STHk #04 SFT ,&parse JSR #18 DEO
STHr #0f AND ,&parse JSR #18 DEO
JMP2r
&parse ( byte -- char ) DUP #09 GTH ,&above JCN #30 ADD JMP2r
&above #57 ADD JMP2r
RTN
JMP2r
@keypad
&layout
0708 090f
0405 060e
0102 030d
000a 0b0c
0708 090f 0405 060e 0102 030d 000a 0b0c
&series
0c08 090a
0405 0600
0102 0d0e
0f0b 0703
0c08 090a 0405 0600 0102 0d0e 0f0b 0703
&color
0101 0102
0101 0102
0101 0102
0102 0202
0101 0102 0101 0102 0101 0102 0102 0202
&ops
:do-add :do-sub :do-mul :do-div
:do-and :do-ora :do-eor :do-not
@ -727,7 +701,17 @@ RTN
007c 8282 7c82 827c 007c 8282 7e02 827c
007c 8202 7e82 827e 00fc 8282 fc82 82fc
007c 8280 8080 827c 00fc 8282 8282 82fc
007c 8280 f080 827c 007c 8280 f080 8080
007e 8080 fe80 807e 007c 8280 f080 8080
@modes
( hex )
0082 8282 fe82 8282
007e 8080 fe80 807e
0082 4428 1028 4482
( dec )
00fc 8282 8282 82fc
007e 8080 fe80 807e
007c 8280 8080 827c
@mod-icns
0010 1010 fe10 1010
@ -742,35 +726,35 @@ RTN
@button-icns
( outline )
3f40 8080 8080 8080
f804 0202 0202 0202
8080 8080 8040 3f00
0202 0202 0204 f800
3f40 8080 8080 8080
f804 0202 0202 0202
8080 8080 8040 3f00
0202 0202 0204 f800
( full )
3f7f ffff ffff ffff
f8fc fefe fefe fefe
ffff ffff ff7f 3f00
fefe fefe fefc f800
3f7f ffff ffff ffff
f8fc fefe fefe fefe
ffff ffff ff7f 3f00
fefe fefe fefc f800
@button-thin-icns
( outline )
3844 8282 8282 8282
8282 8282 8244 3800
3844 8282 8282 8282
8282 8282 8244 3800
( full )
387c fefe fefe fefe
fefe fefe fe7c 3800
387c fefe fefe fefe
fefe fefe fe7c 3800
@bit-icns
( outline )
3844 8282 8244 3800
3844 8282 8244 3800
( full )
387c fefe fe7c 3800
387c fefe fe7c 3800
@stack-icns
&push
0000 1028 1000 0000
0000 1028 1000 0000
&pop
0000 2810 2800 0000
0000 2810 2800 0000
@pointer-icn
80c0 e0f0 f8e0 1000

View file

@ -0,0 +1,575 @@
( launcher )
%+ { ADD } %- { SUB } %* { MUL } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
%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 }
%10* { #40 SFT } %10/ { #04 SFT } %10** { #40 SFT2 } %10// { #04 SFT2 }
%20* { #50 SFT } %20/ { #05 SFT } %20** { #50 SFT2 } %20// { #05 SFT2 }
%40** { #60 SFT2 }
%RTN { JMP2r }
%TOS { #00 SWP }
%AUTO-NONE { #00 .Screen/auto DEO }
%AUTO-XADDR { #05 .Screen/auto DEO }
%AUTO-YADDR { #06 .Screen/auto DEO }
%HALT { #010f DEO }
%EMIT { #18 DEO }
%PRINT { ;print-str JSR2 #0a EMIT }
%DEBUG { ;print-hex/byte JSR2 #0a EMIT }
%DEBUG2 { ;print-hex JSR2 #0a EMIT }
%LINES-COUNT { .browser/y2 LDZ2 .browser/y LDZ2 -- 10// NIP }
( devices )
|00 @System &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1
|10 @Console &vector $2 &read $1 &pad $5 &write $1 &error $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 &pad $3 &scrollx $2 &scrolly $2
|a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
|b0 @DateTime &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1
( variables )
|0000
@pointer
&x $2 &y $2
@browser
&x $2 &y $2 &x2 $2 &y2 $2
&sel $1 &last $1 &scroll $1
( init )
|0100 ( -> )
( theme )
#f079 .System/r DEO2
#f0c2 .System/g DEO2
#f0a4 .System/b DEO2
( vectors )
;on-frame .Screen/vector DEO2
;on-button .Controller/vector DEO2
;on-mouse .Mouse/vector DEO2
( asma debugger )
#0d ;asma/log-level STA
;asma-heap ;heap STA2
( setup synth )
#0102 .Audio0/adsr DEO2
;sin-pcm .Audio0/addr DEO2
#0100 .Audio0/length DEO2
#dd .Audio0/volume DEO ( TODO: turn ON )
( place )
#0088 .browser/x STZ2
#0010 .browser/y STZ2
.Screen/height DEI2 #33 SFT2 #0011 -- .browser/y2 STZ2
( draw mascot )
#0010 #0010 #0060 #0060 ;mascot-icn #01 ;draw-icn JSR2
;load-dir JSR2
( theme support )
;load-theme JSR2
( force selection )
#ff .browser/last STZ
#00 ;select-file JSR2
BRK
@on-frame ( -> )
( unused )
BRK
@on-mouse ( -> )
;pointer-icn .Screen/addr DEO2
( clear last cursor )
.pointer/x LDZ2 .Screen/x DEO2
.pointer/y LDZ2 .Screen/y DEO2
#40 .Screen/sprite DEO
( draw new cursor )
.Mouse/x DEI2 DUP2 .pointer/x STZ2 .Screen/x DEO2
.Mouse/y DEI2 DUP2 .pointer/y STZ2 .Screen/y DEO2
#41 .Mouse/state DEI #01 = + .Screen/sprite DEO
( wheel )
.Mouse/scrolly INC DEI
DUP #ff ! ,&no-up JCN
.browser/scroll LDZ #00 = ,&no-up JCN
DUP .browser/scroll LDZ + ;scroll-to JSR2
&no-up
DUP #01 ! ,&no-down JCN
.browser/scroll LDZ ;dir/lines LDA = ,&no-down JCN
DUP .browser/scroll LDZ + ;scroll-to JSR2
&no-down
POP
( within browser )
.Mouse/y DEI2 .browser/y LDZ2 << ,&outside JCN
.Mouse/y DEI2 .browser/y2 LDZ2 #0010 -- >> ,&outside JCN
( select choice )
.Mouse/y DEI2 .browser/y LDZ2 --
10// NIP .browser/scroll LDZ + ;select-file JSR2
( run choice )
.Mouse/state DEI #00 = ,&no-click JCN
.browser/sel LDZ ;run-file JSR2
&no-click
&outside
BRK
@on-button ( -> )
( controller )
.Controller/button DEI
DUP #10 ! ,&no-up JCN
.browser/sel LDZ #00 = ,&no-up JCN
.browser/sel LDZ #01 - ;select-file JSR2
;follow-selection JSR2
POP BRK
&no-up
DUP #20 ! ,&no-down JCN
.browser/sel LDZ INC ;dir/lines LDA = ,&no-down JCN
.browser/sel LDZ INC ;select-file JSR2
;follow-selection JSR2
POP BRK
&no-down
DUP #01 ! ,&no-a JCN
.browser/sel LDZ ;run-file JSR2
POP BRK
&no-a
POP
( keyboard )
.Controller/key DEI
DUP #0d ! ,&no-enter JCN
.browser/sel LDZ ;run-file JSR2
POP BRK
&no-enter
POP
BRK
@load-dir ( -- )
;dir/path .File/name DEO2
#1000 .File/length DEO2
;dir/data .File/read DEO2
.File/success DEI2 ;dir/length STA2
( split with null-char )
;dir/data
&while
LDAk #1f > ,&no-lb JCN
( split ) STH2k #00 STH2r STA
( count lines ) ;dir/lines LDA INC ;dir/lines STA
&no-lb
INC2 LDAk ,&while JCN
POP2
RTN
@select-file ( id -- )
( has changed )
DUP .browser/last LDZ ! ,&has-changed JCN
POP RTN
&has-changed
( beyond )
DUP ;dir/lines LDA < ,&valid JCN
POP RTN
&valid
#00 ;draw-browser JSR2
DUP .browser/sel STZ
DUP .browser/last STZ
#30 + .Audio0/pitch DEO
#01 ;draw-browser JSR2
( draw mascot )
#0010 #0010 #0060 #0060
;mascot-icn [ .browser/sel LDZ #03 AND TOS #0480 ** ++ ] #01
;draw-icn JSR2
( draw position )
AUTO-YADDR
#0010 .Screen/x DEO2
#0080 .Screen/y DEO2
.browser/sel LDZ #02 ;draw-byte JSR2
LIT '/ #02 ;draw-char JSR2
;dir/lines LDA #01 - #02 ;draw-byte JSR2
AUTO-NONE
RTN
@follow-selection ( -- )
LINES-COUNT .browser/sel LDZ .browser/scroll LDZ -
DUP2 > ,&no-down JCN
.browser/scroll LDZ INC ,scroll-to JSR
&no-down
DUP2 SWP < ,&no-up JCN
.browser/sel LDZ ,scroll-to JSR
&no-up
POP2
RTN
@scroll-to ( line -- )
STH
( more lines than visible )
;dir/lines LDA LINES-COUNT
DUP2 > ,&can-scroll JCN
POPr POP2 RTN
&can-scroll
( less than max scroll )
- INC STHkr > ,&valid-scroll JCN
POPr RTN
&valid-scroll
#00 ;draw-browser JSR2
STHr .browser/scroll STZ
#01 ;draw-browser JSR2
RTN
@run-file ( id -- )
;get-entry JSR2 #0005 ++
DUP2 ;check-rom JSR2 ,&valid JCN
( check if tal file )
DUP2 ;scap JSR2 #0004 -- ;&tal-ext ;scmp JSR2 #01 ! ,&no-tal JCN
DUP2 ;&output-path ;scpy JSR2
;&rom-ext ;&output-path ;scat JSR2
;&output-path ;asma-assemble-file JSR2
;load-dir JSR2
;redraw JSR2
RTN
&no-tal
POP2 RTN
&valid
;load-rom JSR2
RTN
&tal-ext ".tal $1
&rom-ext ".rom $1
&output-path $20
@redraw ( -- )
( force selection )
#ff .browser/last STZ
#00 ;select-file JSR2
RTN
@draw-browser ( mask -- )
( when empty )
;dir/lines LDA #01 = ;draw-browser-empty JCN2
STH
( draw hand )
.browser/x LDZ2 #0018 -- .browser/y LDZ2
.browser/sel LDZ .browser/scroll LDZ - TOS 10** ++
#0010 #0010
;hand-icn STHkr #02 * ;draw-icn JSR2
( draw files )
LINES-COUNT #00
&loop
( reached end )
DUP INC ;dir/lines LDA > ,&end JCN
( has file )
.browser/x LDZ2 .Screen/x DEO2
DUP TOS 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
INC GTHk ,&loop JCN
&end
POP2
POPr
RTN
@draw-browser-empty ( mask -- )
POP
.browser/x LDZ2 .Screen/x DEO2
.browser/y LDZ2 .Screen/y DEO2
;&empty-txt #01 ;draw-str JSR2
RTN
&empty-txt "Empty 20 "Folder $1
@get-type ( line* -- type )
;scap JSR2 #0004 -- ;&rom-ext ;scmp JSR2
RTN
&rom-ext ".rom $1
@get-entry ( id -- addr* )
( limit ) STH
( counter ) LITr 00
;dir/length LDA2 #0000
&loop
EQUkr STHr #00 = ,&no-reached JCN
POP2r NIP2 ;dir/data ++ RTN
&no-reached
DUP2 ;dir/data ++ LDA #00 ! ,&no-lb JCN
INCr
&no-lb
INC2 GTH2k ,&loop JCN
POP2 POP2
POP2r
;dir/data
RTN
@draw-type ( type -- )
STHk TOS 20** ;file-icns ++ .Screen/addr DEO2
AUTO-XADDR
#02 STHkr - .Screen/sprite DEOk DEO
.Screen/x DEI2k #0010 -- ROT DEO2
.Screen/y DEI2k #0008 ++ ROT DEO2
#02 STHr - .Screen/sprite DEOk DEO
.Screen/x DEI2k #0008 ++ ROT DEO2
.Screen/y DEI2k #0008 -- ROT DEO2
AUTO-NONE
RTN
@draw-icn ( x* y* width* height* addr* color -- )
AUTO-XADDR
( load ) STH .Screen/addr DEO2 ,&height STR2 ,&width STR2 ,&y STR2 ,&x STR2
,&height LDR2 #0000
&ver
( save ) DUP2 ,&y LDR2 ADD2 .Screen/y DEO2
,&x LDR2 .Screen/x DEO2
,&width LDR2 #0000
&hor
( draw ) STHkr .Screen/sprite DEO
#0008 ADD2 GTH2k ,&hor JCN
POP2 POP2
#0008 ADD2 GTH2k ,&ver JCN
POP2 POP2
POPr
AUTO-NONE
RTN
&x $2 &y $2 &width $2 &height $2
@draw-str ( text* color -- )
AUTO-YADDR
STH
&while
LDAk STHkr ,draw-char JSR
INC2 LDAk ,&while JCN
POP2
POPr
RTN
@draw-short ( short* color -- )
STH SWP STHkr ,draw-byte JSR
STHr ,draw-byte JSR
RTN
@draw-byte ( byte color -- )
STH
DUP #04 SFT ,&parse JSR STHkr ,draw-char JSR
#0f AND ,&parse JSR STHr ,draw-char JSR
RTN
&parse ( byte -- char ) DUP #09 GTH ,&above JCN #30 ADD JMP2r
&above #57 ADD JMP2r
@draw-char ( char color -- )
SWP
[ #20 - #00 SWP #40 SFT2 ;font ++ ] .Screen/addr DEO2
.Screen/sprite DEOk DEO
.Screen/x DEI2k #0008 ++ ROT DEO2
.Screen/y DEI2k #0010 -- ROT DEO2
JMP2r
( theme )
@theme-txt ".theme $1
@load-theme ( -- )
;theme-txt .File/name DEO2
#0006 .File/length DEO2
#fffa .File/read DEO2
.File/success DEI2 #0006 !! ,&ignore JCN
#fffa LDA2 .System/r DEO2
#fffc LDA2 .System/g DEO2
#fffe LDA2 .System/b DEO2
&ignore
;redraw JSR2
RTN
( helpers )
@print-str ( string* -- )
#0001 SUB2
&while
INC2 LDAk DUP #18 DEO ,&while JCN
POP2
JMP2r
@print-hex ( value* -- )
SWP ,&byte JSR
&byte ( byte -- )
STHk #04 SFT ,&parse JSR #18 DEO
STHr #0f AND ,&parse JSR #18 DEO
JMP2r
&parse ( byte -- char ) DUP #09 GTH ,&above JCN #30 ADD JMP2r
&above #57 ADD JMP2r
JMP2r
@scat ( src* dst* -- )
DUP2 ,slen JSR ++ ,scpy JSR
JMP2r
@scmp ( a* b* -- flag )
STH2
&loop
LDAk LDAkr STHr = ,&not-diff JCN
POP2 POP2r #00 RTN
&not-diff
LDAk LDAkr STHr #0000 !! ,&not-end JCN
POP2 POP2r #01 RTN
&not-end
INC2 INC2r
,&loop JMP
POP2 POP2r #00
RTN
@scpy ( src* dst* -- )
STH2
&while
LDAk STH2kr STA INC2r
INC2 LDAk ,&while JCN
POP2
#00 STH2r STA
JMP2r
@scap ( str* -- str-end* )
( clamp ) LDAk #00 ! JMP RTN
&while INC2 LDAk ,&while JCN
RTN
@slen ( str* -- len* )
DUP2 ,scap JSR SWP2 --
JMP2r
@pointer-icn
80c0 e0f0 f8e0 1000
@hand-icn
000c 0a0a 1224 4780
0000 0000 0000 fc02
8180 8080 8040 3f00
fc20 c020 c020 c000
@file-icns
003f 3f30 3f30 3f30
00fc fc0c fc0c fc0c
3f33 3f3f 3f3f 3f00
fcfc fcc4 c8d0 e000
003f 3f30 3132 3231
00fc fc0c 8c4c 4c8c
303f 3f3f 3f3f 3f00
0cfc fcc4 c8d0 e000
@sin-pcm
8083 8689 8c8f 9295 989b 9ea1 a4a7 aaad
b0b3 b6b9 bbbe c1c3 c6c9 cbce d0d2 d5d7
d9db dee0 e2e4 e6e7 e9eb ecee f0f1 f2f4
f5f6 f7f8 f9fa fbfb fcfd fdfe fefe fefe
fffe fefe fefe fdfd fcfb fbfa f9f8 f7f6
f5f4 f2f1 f0ee eceb e9e7 e6e4 e2e0 dedb
d9d7 d5d2 d0ce cbc9 c6c3 c1be bbb9 b6b3
b0ad aaa7 a4a1 9e9b 9895 928f 8c89 8683
807d 7a77 7471 6e6b 6865 625f 5c59 5653
504d 4a47 4542 3f3d 3a37 3532 302e 2b29
2725 2220 1e1c 1a19 1715 1412 100f 0e0c
0b0a 0908 0706 0505 0403 0302 0202 0202
0102 0202 0202 0303 0405 0506 0708 090a
0b0c 0e0f 1012 1415 1719 1a1c 1e20 2225
2729 2b2e 3032 3537 3a3d 3f42 4547 4a4d
5053 5659 5c5f 6265 686b 6e71 7477 7a7d
~projects/library/check-rom.tal
~projects/library/load-rom.tal
~projects/assets/mascot0cx0c.tal
~projects/assets/msx01x02.tal
@dir
&path ". $1
&lines $1
&length $2
&data $1000
( assembler memory )
~projects/library/asma.tal
@asma-heap
|e000 &end @asma-read-buffer
|f800 &end @asma-write-buffer
|ffff &end

View file

@ -1,270 +0,0 @@
( launcher )
%+ { ADD } %- { SUB } %* { MUL } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
%AUTO-X { #01 .Screen/auto DEO }
%AUTO-Y { #02 .Screen/auto DEO }
%AUTO-YADDR { #06 .Screen/auto DEO }
%HALT { #010f DEO }
%EMIT { #18 DEO }
%PRINT { ;print-str JSR2 #0a EMIT }
%DEBUG { ;print-hex/byte JSR2 #0a EMIT }
%DEBUG2 { ;print-hex JSR2 #0a EMIT }
%MODALW { #0024 }
%MODALH { #0009 }
%RTN { JMP2r }
%2// { #01 SFT2 }
%8** { #30 SFT2 }
%EADDR { #fd04 }
%ECODE { #fd06 }
( devices )
|00 @System &vector $2 &wst $1 &rst $1 &eaddr $2 &ecode $1 &pad $1 &r $2 &g $2 &b $2 &debug $1 &halt $1
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
|80 @Controller &vector $2 &button $1 &key $1 &func $1
( variables )
|0000
@center
&x $2 &y $2
@modal
&x $2 &y $2
( init )
|0100 ( -> )
.Screen/width DEI2 2//
DUP2 .center/x STZ2
MODALW #31 SFT2 -- .modal/x STZ2
.Screen/height DEI2 2//
DUP2 .center/y STZ2
MODALH #31 SFT2 -- .modal/y STZ2
( vectors )
;on-error .System/vector DEO2
;on-frame .Screen/vector DEO2
;on-button .Controller/vector DEO2
BRK
@on-frame ( -> )
;draw-cross JSR2
;draw-stacks JSR2
BRK
@on-button ( -> )
.Controller/func DEI
DUP #02 ! ,&no-f2 JCN
;toggle-debugger JSR2
&no-f2
DUP #08 ! ,&no-f4 JCN
;reboot JSR2
&no-f4
POP
BRK
@on-error ( -> )
( background )
#00 .Screen/auto DEO
;bg-icn .Screen/addr DEO2
MODALH #0000
&ver
DUP2 8** .modal/y LDZ2 ++ .Screen/y DEO2
MODALW #0000
&hor
DUP2 8** .modal/x LDZ2 ++ .Screen/x DEO2
#42 .Screen/sprite DEO
INC2 GTH2k ,&hor JCN
POP2 POP2
INC2 GTH2k ,&ver JCN
POP2 POP2
( corners )
;corner-icn .Screen/addr DEO2
.modal/x LDZ2 .Screen/x DEO2
.modal/y LDZ2 .Screen/y DEO2
#42 .Screen/sprite DEO
.modal/x LDZ2 MODALW #0001 -- 8** ++ .Screen/x DEO2
#52 .Screen/sprite DEO
.modal/y LDZ2 MODALH #0001 -- 8** ++ .Screen/y DEO2
#72 .Screen/sprite DEO
.modal/x LDZ2 .Screen/x DEO2
#62 .Screen/sprite DEO
( text )
.modal/x LDZ2 #0010 ++ .Screen/x DEO2
.modal/y LDZ2 #0010 ++ .Screen/y DEO2
;error-txts/0 #4f ;draw-str JSR2
;at-txt #4f ;draw-str JSR2
EADDR LDA2 #47 ;draw-short JSR2
#0000 EADDR STA2
BRK
@toggle-debugger ( -- )
( toggle debug ) #fd0e STH2k LDA #00 = STH2r STA
RTN
@reboot ( -- )
( clear devices/stacks )
#fd00 #0300 ;mclr JSR2
RTN
&boot-path "boot.rom $1
@draw-stacks ( -- )
AUTO-YADDR
#0010 #0000
&wst
( working stack )
#0010 .Screen/y DEO2
DUP2 #0018 ** #0010 ++ .Screen/x DEO2
DUP #fe00 LDA ( ptr ) EQU #41 + STH
DUP2 #fe01 ++ LDA STHr ;draw-byte JSR2
( return stack )
#0028 .Screen/y DEO2
DUP2 #0018 ** #0010 ++ .Screen/x DEO2
DUP #ff00 LDA ( ptr ) EQU #41 + STH
DUP2 #ff01 ++ LDA STHr ;draw-byte JSR2
INC2 GTH2k ,&wst JCN
POP2 POP2
RTN
@draw-cross ( -- )
( ver )
AUTO-Y
#0000 .Screen/y DEO2
.center/x LDZ2 .Screen/x DEO2
.Screen/height DEI2 #0000
&ver
#43 .Screen/pixel DEO
.Screen/y DEI2k INC2 ROT DEO2
INC2 GTH2k ,&ver JCN
POP2 POP2
( hor )
AUTO-X
#0000 .Screen/x DEO2
.center/y LDZ2 .Screen/y DEO2
.Screen/width DEI2 #0000
&hor
#43 .Screen/pixel DEO
.Screen/x DEI2k INC2 ROT DEO2
INC2 GTH2k ,&hor JCN
POP2 POP2
RTN
@draw-str ( text* color -- )
AUTO-YADDR
STH
&while
LDAk STHkr ,draw-char JSR
INC2 LDAk ,&while JCN
POP2
POPr
RTN
@draw-short ( short* color -- )
STH SWP STHkr ,draw-byte JSR
STHr ,draw-byte JSR
RTN
@draw-byte ( byte color -- )
STH
DUP #04 SFT ,&parse JSR STHkr ,draw-char JSR
#0f AND ,&parse JSR STHr ,draw-char JSR
RTN
&parse ( byte -- char ) DUP #09 GTH ,&above JCN #30 ADD JMP2r
&above #57 ADD JMP2r
@draw-char ( char color -- )
SWP
[ #20 - #00 SWP #40 SFT2 ;font ++ ] .Screen/addr DEO2
.Screen/sprite DEOk DEO
.Screen/x DEI2k #0008 ++ ROT DEO2
.Screen/y DEI2k #0010 -- ROT DEO2
JMP2r
@mclr ( addr* len* -- )
OVR2 ++ SWP2
&loop
STH2k #00 STH2r STA
INC2 GTH2k ,&loop JCN
POP2 POP2
JMP2r
@print-hex ( value* -- )
SWP ,&byte JSR
&byte ( byte -- )
STHk #04 SFT ,&parse JSR #18 DEO
STHr #0f AND ,&parse JSR #18 DEO
JMP2r
&parse ( byte -- char ) DUP #09 GTH ,&above JCN #30 ADD JMP2r
&above #57 ADD JMP2r
JMP2r
@print-str ( string* -- )
#0001 SUB2
&while
INC2 LDAk DUP #18 DEO ,&while JCN
POP2
JMP2r
@error-txts
&0 "Working-stack 20 "underflow $1
&1 "Return-stack 20 "underflow $1
&2 "Working-stack 20 "overflow $1
&3 "Return-stack 20 "overflow $1
&4 "Working-stack 20 "division 20 "by 20 "zero $1
&5 "Return-stack 20 "division 20 "by 20 "zero $1
@at-txt
', 20 "at 20 $1
@bg-icn
ffff ffff ffff ffff
@corner-icn
1f7f 7fff ffff ffff
~projects/assets/msx01x02.tal

View file

@ -18,7 +18,7 @@ controller_down(Device *d, Uint8 mask)
{
if(mask) {
d->dat[2] |= mask;
uxn_eval(d->u, d->vector);
uxn_eval(d->u, GETVECTOR(d));
}
}
@ -27,7 +27,7 @@ controller_up(Device *d, Uint8 mask)
{
if(mask) {
d->dat[2] &= (~mask);
uxn_eval(d->u, d->vector);
uxn_eval(d->u, GETVECTOR(d));
}
}
@ -36,7 +36,7 @@ controller_key(Device *d, Uint8 key)
{
if(key) {
d->dat[3] = key;
uxn_eval(d->u, d->vector);
uxn_eval(d->u, GETVECTOR(d));
d->dat[3] = 0x00;
}
}
@ -46,7 +46,7 @@ controller_special(Device *d, Uint8 key)
{
if(key) {
d->dat[4] = key;
uxn_eval(d->u, d->vector);
uxn_eval(d->u, GETVECTOR(d));
d->dat[4] = 0x00;
}
}

View file

@ -13,8 +13,6 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE.
*/
#define _POSIX_C_SOURCE 200809L
#include <stdio.h>
#include <dirent.h>
#include <string.h>
@ -53,13 +51,13 @@ get_entry(char *p, Uint16 len, const char *pathname, const char *basename, int f
if(len < strlen(basename) + 7)
return 0;
if(stat(pathname, &st))
return fail_nonzero ? snprintf(p, len, "!!!! %s\n", basename) : 0;
return fail_nonzero ? sprintf(p, "!!!! %s\n", basename) : 0;
else if(S_ISDIR(st.st_mode))
return snprintf(p, len, "---- %s\n", basename);
return sprintf(p, "---- %s\n", basename);
else if(st.st_size < 0x10000)
return snprintf(p, len, "%04x %s\n", (Uint16)st.st_size, basename);
return sprintf(p, "%04x %s\n", (unsigned int)st.st_size, basename);
else
return snprintf(p, len, "???? %s\n", basename);
return sprintf(p, "???? %s\n", basename);
}
static Uint16
@ -72,7 +70,10 @@ file_read_dir(char *dest, Uint16 len)
Uint16 n;
if(de->d_name[0] == '.' && de->d_name[1] == '\0')
continue;
snprintf(pathname, sizeof(pathname), "%s/%s", current_filename, de->d_name);
if(strlen(current_filename) + 1 + strlen(de->d_name) < sizeof(pathname))
sprintf(pathname, "%s/%s", current_filename, de->d_name);
else
pathname[0] = '\0';
n = get_entry(p, len, pathname, de->d_name, 1);
if(!n) break;
p += n;
@ -146,13 +147,10 @@ file_deo(Device *d, Uint8 port)
{
Uint16 a, b, res;
switch(port) {
case 0x1:
DEVPEEK16(d->vector, 0x0);
break;
case 0x5:
DEVPEEK16(a, 0x4);
DEVPEEK16(b, 0xa);
res = file_stat(&d->mem[a], b);
res = file_stat(&d->u->ram[a], b);
DEVPOKE16(0x2, res);
break;
case 0x6:
@ -161,19 +159,19 @@ file_deo(Device *d, Uint8 port)
break;
case 0x9:
DEVPEEK16(a, 0x8);
res = file_init(&d->mem[a]);
res = file_init(&d->u->ram[a]);
DEVPOKE16(0x2, res);
break;
case 0xd:
DEVPEEK16(a, 0xc);
DEVPEEK16(b, 0xa);
res = file_read(&d->mem[a], b);
res = file_read(&d->u->ram[a], b);
DEVPOKE16(0x2, res);
break;
case 0xf:
DEVPEEK16(a, 0xe);
DEVPEEK16(b, 0xa);
res = file_write(&d->mem[a], b, d->dat[0x7]);
res = file_write(&d->u->ram[a], b, d->dat[0x7]);
DEVPOKE16(0x2, res);
break;
}

View file

@ -17,14 +17,14 @@ void
mouse_down(Device *d, Uint8 mask)
{
d->dat[6] |= mask;
uxn_eval(d->u, d->vector);
uxn_eval(d->u, GETVECTOR(d));
}
void
mouse_up(Device *d, Uint8 mask)
{
d->dat[6] &= (~mask);
uxn_eval(d->u, d->vector);
uxn_eval(d->u, GETVECTOR(d));
}
void
@ -32,7 +32,7 @@ mouse_pos(Device *d, Uint16 x, Uint16 y)
{
DEVPOKE16(0x2, x);
DEVPOKE16(0x4, y);
uxn_eval(d->u, d->vector);
uxn_eval(d->u, GETVECTOR(d));
}
void
@ -40,7 +40,7 @@ mouse_scroll(Device *d, Uint16 x, Uint16 y)
{
DEVPOKE16(0xa, x);
DEVPOKE16(0xc, -y);
uxn_eval(d->u, d->vector);
uxn_eval(d->u, GETVECTOR(d));
DEVPOKE16(0xa, 0);
DEVPOKE16(0xc, 0);
}

View file

@ -1,3 +1,5 @@
#include <stdlib.h>
#include "../uxn.h"
#include "screen.h"
@ -81,7 +83,6 @@ screen_resize(UxnScreen *p, Uint16 width, Uint16 height)
if(bg && fg && pixels) {
p->width = width;
p->height = height;
p->pixels = pixels;
screen_clear(p, &p->bg);
screen_clear(p, &p->fg);
}
@ -118,8 +119,6 @@ screen_dei(Device *d, Uint8 port)
case 0x3: return uxn_screen.width;
case 0x4: return uxn_screen.height >> 8;
case 0x5: return uxn_screen.height;
case 0x6:
default: return d->dat[port];
}
}
@ -128,7 +127,6 @@ void
screen_deo(Device *d, Uint8 port)
{
switch(port) {
case 0x1: DEVPEEK16(d->vector, 0x0); break;
case 0x5:
if(!FIXED_SIZE) {
Uint16 w, h;
@ -154,7 +152,7 @@ screen_deo(Device *d, Uint8 port)
DEVPEEK16(x, 0x8);
DEVPEEK16(y, 0xa);
DEVPEEK16(addr, 0xc);
screen_blit(&uxn_screen, layer, x, y, &d->mem[addr], d->dat[0xf] & 0xf, d->dat[0xf] & 0x10, d->dat[0xf] & 0x20, twobpp);
screen_blit(&uxn_screen, layer, x, y, &d->u->ram[addr], d->dat[0xf] & 0xf, d->dat[0xf] & 0x10, d->dat[0xf] & 0x20, twobpp);
if(d->dat[0x6] & 0x04) DEVPOKE16(0xc, addr + 8 + twobpp * 8); /* auto addr+length */
if(d->dat[0x6] & 0x01) DEVPOKE16(0x8, x + 8); /* auto x+8 */
if(d->dat[0x6] & 0x02) DEVPOKE16(0xa, y + 8); /* auto y+8 */

View file

@ -1,5 +1,3 @@
#include <stdlib.h>
/*
Copyright (c) 2021 Devine Lu Linvega
Copyright (c) 2021 Andrew Alderwick
@ -15,8 +13,7 @@ WITH REGARD TO THIS SOFTWARE.
#define FIXED_SIZE 0
typedef struct Layer {
Uint8 *pixels;
Uint8 changed;
Uint8 *pixels, changed;
} Layer;
typedef struct UxnScreen {

View file

@ -14,8 +14,6 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE.
*/
Uxn supervisor;
static const char *errors[] = {
"Working-stack underflow",
"Return-stack underflow",
@ -24,20 +22,41 @@ static const char *errors[] = {
"Working-stack division by zero",
"Return-stack division by zero"};
static void
system_print(Stack *s, char *name)
{
Uint8 i;
fprintf(stderr, "<%s>", name);
for(i = 0; i < s->ptr; i++)
fprintf(stderr, " %02x", s->dat[i]);
if(!i)
fprintf(stderr, " empty");
fprintf(stderr, "\n");
}
void
system_inspect(Uxn *u)
{
system_print(&u->wst, "wst");
system_print(&u->rst, "rst");
}
int
uxn_halt(Uxn *u, Uint8 error, Uint16 addr)
{
Device *d = &u->dev[0];
Uint16 vec = d->vector;
Uint16 vec = GETVECTOR(d);
DEVPOKE16(0x4, addr);
d->dat[0x6] = error;
uxn_eval(&supervisor, supervisor.dev[0].vector);
if(vec) {
d->vector = 0; /* need to rearm to run System/vector again */
/* need to rearm to run System/vector again */
d->dat[0] = 0;
d->dat[1] = 0;
if(error != 2) /* working stack overflow has special treatment */
vec += 0x0004;
return uxn_eval(u, vec);
}
system_inspect(u);
fprintf(stderr, "Halted: %s#%04x, at 0x%04x\n", errors[error], u->ram[addr], addr);
return 0;
}
@ -48,8 +67,8 @@ Uint8
system_dei(Device *d, Uint8 port)
{
switch(port) {
case 0x2: return d->u->wst->ptr;
case 0x3: return d->u->rst->ptr;
case 0x2: return d->u->wst.ptr;
case 0x3: return d->u->rst.ptr;
default: return d->dat[port];
}
}
@ -58,9 +77,9 @@ void
system_deo(Device *d, Uint8 port)
{
switch(port) {
case 0x1: DEVPEEK16(d->vector, 0x0); break;
case 0x2: d->u->wst->ptr = d->dat[port]; break;
case 0x3: d->u->rst->ptr = d->dat[port]; break;
case 0x2: d->u->wst.ptr = d->dat[port]; break;
case 0x3: d->u->rst.ptr = d->dat[port]; break;
case 0xe: system_inspect(d->u); break;
default: system_deo_special(d, port);
}
}

View file

@ -9,8 +9,13 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE.
*/
typedef struct SystemDevice {
Device device;
struct UxnScreen *screen;
} SystemDevice;
void system_inspect(Uxn *u);
Uint8 system_dei(Device *d, Uint8 port);
void system_deo(Device *d, Uint8 port);
void system_deo_special(Device *d, Uint8 port);
extern Uxn supervisor;

View file

@ -29,23 +29,23 @@ WITH REGARD TO THIS SOFTWARE.
#define DEVR(o, d, x) { dev = (d); o = dev->dei(dev, (x) & 0x0f); if(bs) { o = (o << 8) + dev->dei(dev, ((x) + 1) & 0x0f); } }
#define DEVW8(x, y) { dev->dat[(x) & 0xf] = y; dev->deo(dev, (x) & 0x0f); }
#define DEVW(d, x, y) { dev = (d); if(bs) { DEVW8((x), (y) >> 8); DEVW8((x) + 1, (y)); } else { DEVW8((x), (y)) } }
#define WARP(x) { if(bs) pc = (x); else pc += (Sint8)(x); }
int
uxn_eval(Uxn *u, Uint16 pc)
{
unsigned int a, b, c, j, k, bs, instr, errcode;
Uint16 warp_count = 0;
Uint8 kptr, *sp;
Stack *src, *dst;
Device *dev;
if(!pc || u->dev[0].dat[0xf]) return 0;
if(u->wst->ptr > 0xf8) u->wst->ptr = 0xf8;
if(u->wst.ptr > 0xf8) u->wst.ptr = 0xf8;
while((instr = u->ram[pc++])) {
/* Return Mode */
if(instr & 0x40) {
src = u->rst; dst = u->wst;
src = &u->rst; dst = &u->wst;
} else {
src = u->wst; dst = u->rst;
src = &u->wst; dst = &u->rst;
}
/* Keep Mode */
if(instr & 0x80) {
@ -59,42 +59,46 @@ uxn_eval(Uxn *u, Uint16 pc)
switch(instr & 0x1f) {
/* Stack */
case 0x00: /* LIT */ if(bs) { PEEK16(a, pc) PUSH16(src, a) pc += 2; }
else { a = u->ram[pc]; PUSH8(src, a) pc++; } break;
case 0x01: /* INC */ POP(a) PUSH(src, a + 1) break;
case 0x02: /* POP */ POP(a) break;
case 0x03: /* DUP */ POP(a) PUSH(src, a) PUSH(src, a) break;
case 0x04: /* NIP */ POP(a) POP(b) PUSH(src, a) break;
case 0x05: /* SWP */ POP(a) POP(b) PUSH(src, a) PUSH(src, b) break;
case 0x06: /* OVR */ POP(a) POP(b) PUSH(src, b) PUSH(src, a) PUSH(src, b) break;
case 0x07: /* ROT */ POP(a) POP(b) POP(c) PUSH(src, b) PUSH(src, a) PUSH(src, c) break;
else { a = u->ram[pc]; PUSH8(src, a) pc++; } continue;
case 0x01: /* INC */ POP(a) PUSH(src, a + 1) continue;
case 0x02: /* POP */ POP(a) continue;
case 0x03: /* DUP */ POP(a) PUSH(src, a) PUSH(src, a) continue;
case 0x04: /* NIP */ POP(a) POP(b) PUSH(src, a) continue;
case 0x05: /* SWP */ POP(a) POP(b) PUSH(src, a) PUSH(src, b) continue;
case 0x06: /* OVR */ POP(a) POP(b) PUSH(src, b) PUSH(src, a) PUSH(src, b) continue;
case 0x07: /* ROT */ POP(a) POP(b) POP(c) PUSH(src, b) PUSH(src, a) PUSH(src, c) continue;
/* Logic */
case 0x08: /* EQU */ POP(a) POP(b) PUSH8(src, b == a) break;
case 0x09: /* NEQ */ POP(a) POP(b) PUSH8(src, b != a) break;
case 0x0a: /* GTH */ POP(a) POP(b) PUSH8(src, b > a) break;
case 0x0b: /* LTH */ POP(a) POP(b) PUSH8(src, b < a) break;
case 0x0c: /* JMP */ POP(a) WARP(a) break;
case 0x0d: /* JCN */ POP(a) POP8(b) if(b) WARP(a) break;
case 0x0e: /* JSR */ POP(a) PUSH16(dst, pc) WARP(a) break;
case 0x0f: /* STH */ POP(a) PUSH(dst, a) break;
case 0x08: /* EQU */ POP(a) POP(b) PUSH8(src, b == a) continue;
case 0x09: /* NEQ */ POP(a) POP(b) PUSH8(src, b != a) continue;
case 0x0a: /* GTH */ POP(a) POP(b) PUSH8(src, b > a) continue;
case 0x0b: /* LTH */ POP(a) POP(b) PUSH8(src, b < a) continue;
case 0x0c: /* JMP */ POP(a) break;
case 0x0d: /* JCN */ POP(a) POP8(b) if(b) break; continue;
case 0x0e: /* JSR */ POP(a) PUSH16(dst, pc) break;
case 0x0f: /* STH */ POP(a) PUSH(dst, a) continue;
/* Memory */
case 0x10: /* LDZ */ POP8(a) PEEK(b, a) PUSH(src, b) break;
case 0x11: /* STZ */ POP8(a) POP(b) POKE(a, b) break;
case 0x12: /* LDR */ POP8(a) PEEK(b, pc + (Sint8)a) PUSH(src, b) break;
case 0x13: /* STR */ POP8(a) POP(b) c = pc + (Sint8)a; POKE(c, b) break;
case 0x14: /* LDA */ POP16(a) PEEK(b, a) PUSH(src, b) break;
case 0x15: /* STA */ POP16(a) POP(b) POKE(a, b) break;
case 0x16: /* DEI */ POP8(a) DEVR(b, &u->dev[a >> 4], a) PUSH(src, b) break;
case 0x17: /* DEO */ POP8(a) POP(b) DEVW(&u->dev[a >> 4], a, b) break;
case 0x10: /* LDZ */ POP8(a) PEEK(b, a) PUSH(src, b) continue;
case 0x11: /* STZ */ POP8(a) POP(b) POKE(a, b) continue;
case 0x12: /* LDR */ POP8(a) PEEK(b, pc + (Sint8)a) PUSH(src, b) continue;
case 0x13: /* STR */ POP8(a) POP(b) c = pc + (Sint8)a; POKE(c, b) continue;
case 0x14: /* LDA */ POP16(a) PEEK(b, a) PUSH(src, b) continue;
case 0x15: /* STA */ POP16(a) POP(b) POKE(a, b) continue;
case 0x16: /* DEI */ POP8(a) DEVR(b, &u->dev[a >> 4], a) PUSH(src, b) continue;
case 0x17: /* DEO */ POP8(a) POP(b) DEVW(&u->dev[a >> 4], a, b) continue;
/* Arithmetic */
case 0x18: /* ADD */ POP(a) POP(b) PUSH(src, b + a) break;
case 0x19: /* SUB */ POP(a) POP(b) PUSH(src, b - a) break;
case 0x1a: /* MUL */ POP(a) POP(b) PUSH(src, (Uint32)b * a) break;
case 0x1b: /* DIV */ POP(a) POP(b) if(a == 0) { errcode = 4; goto err; } PUSH(src, b / a) break;
case 0x1c: /* AND */ POP(a) POP(b) PUSH(src, b & a) break;
case 0x1d: /* ORA */ POP(a) POP(b) PUSH(src, b | a) break;
case 0x1e: /* EOR */ POP(a) POP(b) PUSH(src, b ^ a) break;
case 0x1f: /* SFT */ POP8(a) POP(b) c = b >> (a & 0x0f) << ((a & 0xf0) >> 4); PUSH(src, c) break;
case 0x18: /* ADD */ POP(a) POP(b) PUSH(src, b + a) continue;
case 0x19: /* SUB */ POP(a) POP(b) PUSH(src, b - a) continue;
case 0x1a: /* MUL */ POP(a) POP(b) PUSH(src, (Uint32)b * a) continue;
case 0x1b: /* DIV */ POP(a) POP(b) if(a == 0) { errcode = 4; goto err; } PUSH(src, b / a) continue;
case 0x1c: /* AND */ POP(a) POP(b) PUSH(src, b & a) continue;
case 0x1d: /* ORA */ POP(a) POP(b) PUSH(src, b | a) continue;
case 0x1e: /* EOR */ POP(a) POP(b) PUSH(src, b ^ a) continue;
case 0x1f: /* SFT */ POP8(a) POP(b) c = b >> (a & 0x0f) << ((a & 0xf0) >> 4); PUSH(src, c) continue;
}
/* Jump to a */
if(bs) pc = a; else pc += (Sint8)(a);
if(!++warp_count && uxn_interrupt(u)) return uxn_halt(u, 6, pc - 1);
}
return 1;
@ -108,16 +112,13 @@ err:
/* clang-format on */
int
uxn_boot(Uxn *u, Uint8 *ram, Uint8 *devpage, Stack *wst, Stack *rst)
uxn_boot(Uxn *u, Uint8 *ram)
{
Uint32 i;
char *cptr = (char *)u;
for(i = 0; i < sizeof(*u); i++)
cptr[i] = 0x00;
u->ram = ram;
u->devpage = devpage;
u->wst = wst;
u->rst = rst;
return 1;
}
@ -126,9 +127,7 @@ uxn_port(Uxn *u, Uint8 id, Uint8 (*deifn)(Device *d, Uint8 port), void (*deofn)(
{
Device *d = &u->dev[id];
d->u = u;
d->mem = u->ram;
d->dei = deifn;
d->deo = deofn;
d->dat = u->devpage + id * 0x10;
return d;
}

View file

@ -27,6 +27,7 @@ typedef unsigned int Uint32;
#define DEVPEEK16(o, x) { (o) = (d->dat[(x)] << 8) + d->dat[(x) + 1]; }
#define DEVPOKE16(x, y) { d->dat[(x)] = (y) >> 8; d->dat[(x) + 1] = (y); }
#define GETVECTOR(d) ((d)->dat[0] << 8 | (d)->dat[1])
/* clang-format on */
@ -36,19 +37,19 @@ typedef struct {
typedef struct Device {
struct Uxn *u;
Uint8 *dat, *mem;
Uint16 vector;
Uint8 dat[16];
Uint8 (*dei)(struct Device *d, Uint8);
void (*deo)(struct Device *d, Uint8);
} Device;
typedef struct Uxn {
Uint8 *ram, *devpage;
Stack *wst, *rst;
Uint8 *ram;
Stack wst, rst;
Device dev[16];
} Uxn;
int uxn_boot(Uxn *u, Uint8 *ram, Uint8 *devpage, Stack *wst, Stack *rst);
int uxn_boot(Uxn *u, Uint8 *ram);
int uxn_eval(Uxn *u, Uint16 pc);
int uxn_halt(Uxn *u, Uint8 error, Uint16 addr);
int uxn_interrupt(Uxn *u);
Device *uxn_port(Uxn *u, Uint8 id, Uint8 (*deifn)(Device *, Uint8), void (*deofn)(Device *, Uint8));

View file

@ -1,7 +1,5 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include "uxn.h"
#include "devices/system.h"
@ -19,9 +17,12 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE.
*/
#pragma mark - Core
static Device *devsystem, *devconsole;
int
uxn_interrupt(Uxn *u)
{
(void)u;
return 0;
}
static int
error(char *msg, const char *err)
@ -30,40 +31,20 @@ error(char *msg, const char *err)
return 0;
}
static void
inspect(Stack *s, char *name)
{
Uint8 x, y;
fprintf(stderr, "\n%s\n", name);
for(y = 0; y < 0x04; y++) {
for(x = 0; x < 0x08; x++) {
Uint8 p = y * 0x08 + x;
fprintf(stderr,
p == s->ptr ? "[%02x]" : " %02x ",
s->dat[p]);
}
fprintf(stderr, "\n");
}
}
#pragma mark - Devices
void
system_deo_special(Device *d, Uint8 port)
{
if(port == 0xe) {
inspect(d->u->wst, "Working-stack");
inspect(d->u->rst, "Return-stack");
}
}
static void
console_deo(Device *d, Uint8 port)
{
if(port == 0x1)
DEVPEEK16(d->vector, 0x0);
if(port > 0x7)
write(port - 0x7, (char *)&d->dat[port], 1);
FILE *fd = port == 0x8 ? stdout : port == 0x9 ? stderr
: 0;
if(fd) {
fputc(d->dat[port], fd);
fflush(fd);
}
}
static Uint8
@ -75,26 +56,26 @@ nil_dei(Device *d, Uint8 port)
static void
nil_deo(Device *d, Uint8 port)
{
if(port == 0x1) DEVPEEK16(d->vector, 0x0);
(void)d;
(void)port;
}
#pragma mark - Generics
static int
console_input(Uxn *u, char c)
{
devconsole->dat[0x2] = c;
return uxn_eval(u, devconsole->vector);
Device *d = &u->dev[1];
d->dat[0x2] = c;
return uxn_eval(u, GETVECTOR(d));
}
static void
run(Uxn *u)
{
Uint16 vec;
Device *d = devconsole;
while((!u->dev[0].dat[0xf]) && (read(0, &devconsole->dat[0x2], 1) > 0)) {
DEVPEEK16(vec, 0);
uxn_eval(u, vec);
Device *d = &u->dev[0];
while(!d->dat[0xf]) {
int c = fgetc(stdin);
if(c != EOF)
console_input(u, (Uint8)c);
}
}
@ -104,59 +85,55 @@ load(Uxn *u, char *filepath)
FILE *f;
int r;
if(!(f = fopen(filepath, "rb"))) return 0;
r = fread(u->ram + PAGE_PROGRAM, 1, 0xffff - PAGE_PROGRAM, f);
r = fread(u->ram + PAGE_PROGRAM, 1, 0x10000 - PAGE_PROGRAM, f);
fclose(f);
if(r < 1) return 0;
fprintf(stderr, "Loaded %s\n", filepath);
return 1;
}
static Uint8 *shadow, *memory;
static int
start(Uxn *u)
{
if(!uxn_boot(u, (Uint8 *)calloc(0x10000, sizeof(Uint8))))
return error("Boot", "Failed");
/* system */ uxn_port(u, 0x0, system_dei, system_deo);
/* console */ uxn_port(u, 0x1, nil_dei, console_deo);
/* empty */ uxn_port(u, 0x2, nil_dei, nil_deo);
/* empty */ uxn_port(u, 0x3, nil_dei, nil_deo);
/* empty */ uxn_port(u, 0x4, nil_dei, nil_deo);
/* empty */ uxn_port(u, 0x5, nil_dei, nil_deo);
/* empty */ uxn_port(u, 0x6, nil_dei, nil_deo);
/* empty */ uxn_port(u, 0x7, nil_dei, nil_deo);
/* empty */ uxn_port(u, 0x8, nil_dei, nil_deo);
/* empty */ uxn_port(u, 0x9, nil_dei, nil_deo);
/* file */ uxn_port(u, 0xa, nil_dei, file_deo);
/* datetime */ uxn_port(u, 0xb, datetime_dei, nil_deo);
/* empty */ uxn_port(u, 0xc, nil_dei, nil_deo);
/* empty */ uxn_port(u, 0xd, nil_dei, nil_deo);
/* empty */ uxn_port(u, 0xe, nil_dei, nil_deo);
/* empty */ uxn_port(u, 0xf, nil_dei, nil_deo);
return 1;
}
int
main(int argc, char **argv)
{
Uxn u;
int i, loaded = 0;
shadow = (Uint8 *)calloc(0xffff, sizeof(Uint8));
memory = (Uint8 *)calloc(0xffff, sizeof(Uint8));
if(!uxn_boot(&u, memory, shadow + PAGE_DEV, (Stack *)(shadow + PAGE_WST), (Stack *)(shadow + PAGE_RST)))
return error("Boot", "Failed");
/* system */ devsystem = uxn_port(&u, 0x0, system_dei, system_deo);
/* console */ devconsole = uxn_port(&u, 0x1, nil_dei, console_deo);
/* empty */ uxn_port(&u, 0x2, nil_dei, nil_deo);
/* empty */ uxn_port(&u, 0x3, nil_dei, nil_deo);
/* empty */ uxn_port(&u, 0x4, nil_dei, nil_deo);
/* empty */ uxn_port(&u, 0x5, nil_dei, nil_deo);
/* empty */ uxn_port(&u, 0x6, nil_dei, nil_deo);
/* empty */ uxn_port(&u, 0x7, nil_dei, nil_deo);
/* empty */ uxn_port(&u, 0x8, nil_dei, nil_deo);
/* empty */ uxn_port(&u, 0x9, nil_dei, nil_deo);
/* file */ uxn_port(&u, 0xa, nil_dei, file_deo);
/* datetime */ uxn_port(&u, 0xb, datetime_dei, nil_deo);
/* empty */ uxn_port(&u, 0xc, nil_dei, nil_deo);
/* empty */ uxn_port(&u, 0xd, nil_dei, nil_deo);
/* empty */ uxn_port(&u, 0xe, nil_dei, nil_deo);
/* empty */ uxn_port(&u, 0xf, nil_dei, nil_deo);
for(i = 1; i < argc; i++) {
if(!loaded++) {
if(!load(&u, argv[i]))
return error("Load", "Failed");
if(!uxn_eval(&u, PAGE_PROGRAM))
return error("Init", "Failed");
} else {
char *p = argv[i];
while(*p) console_input(&u, *p++);
console_input(&u, '\n');
}
int i;
if(argc < 2)
return error("Usage", "uxncli game.rom args");
if(!start(&u))
return error("Start", "Failed");
if(!load(&u, argv[1]))
return error("Load", "Failed");
if(!uxn_eval(&u, PAGE_PROGRAM))
return error("Init", "Failed");
for(i = 2; i < argc; i++) {
char *p = argv[i];
while(*p) console_input(&u, *p++);
console_input(&u, '\n');
}
if(!loaded)
return error("Input", "Missing");
run(&u);
return 0;
}

View file

@ -1,6 +1,6 @@
#include <stdio.h>
#include <unistd.h>
#include <time.h>
#include "uxn.h"
#pragma GCC diagnostic push
@ -42,7 +42,7 @@ static SDL_Rect gRect;
/* devices */
static Device *devsystem, *devscreen, *devmouse, *devctrl, *devaudio0, *devconsole;
static Device *devscreen, *devmouse, *devctrl, *devaudio0;
static Uint8 zoom = 1;
static Uint32 stdin_event, audio0_event;
@ -82,12 +82,19 @@ audio_finished_handler(UxnAudio *c)
SDL_PushEvent(&event);
}
int
uxn_interrupt(Uxn *u)
{
(void)u;
return 0;
}
static int
stdin_handler(void *p)
{
SDL_Event event;
event.type = stdin_event;
while(read(0, &event.cbutton.button, 1) > 0)
while(fread(&event.cbutton.button, 1, 1, stdin) > 0)
SDL_PushEvent(&event);
return 0;
(void)p;
@ -180,10 +187,12 @@ system_deo_special(Device *d, Uint8 port)
static void
console_deo(Device *d, Uint8 port)
{
if(port == 0x1)
DEVPEEK16(d->vector, 0x0);
if(port > 0x7)
write(port - 0x7, (char *)&d->dat[port], 1);
FILE *fd = port == 0x8 ? stdout : port == 0x9 ? stderr
: 0;
if(fd) {
fputc(d->dat[port], fd);
fflush(fd);
}
}
static Uint8
@ -209,7 +218,7 @@ audio_deo(Device *d, Uint8 port)
DEVPEEK16(adsr, 0x8);
DEVPEEK16(c->len, 0xa);
DEVPEEK16(addr, 0xc);
c->addr = &d->mem[addr];
c->addr = &d->u->ram[addr];
c->volume[0] = d->dat[0xe] >> 4;
c->volume[1] = d->dat[0xe] & 0xf;
c->repeat = !(d->dat[0xf] & 0x80);
@ -228,7 +237,8 @@ nil_dei(Device *d, Uint8 port)
static void
nil_deo(Device *d, Uint8 port)
{
if(port == 0x1) DEVPEEK16(d->vector, 0x0);
(void)d;
(void)port;
}
/* Boot */
@ -239,7 +249,7 @@ load(Uxn *u, char *rom)
SDL_RWops *f;
int r;
if(!(f = SDL_RWFromFile(rom, "rb"))) return 0;
r = f->read(f, u->ram + PAGE_PROGRAM, 1, 0xffff - PAGE_PROGRAM);
r = f->read(f, u->ram + PAGE_PROGRAM, 1, 0x10000 - PAGE_PROGRAM);
f->close(f);
if(r < 1) return 0;
fprintf(stderr, "Loaded %s\n", rom);
@ -247,25 +257,15 @@ load(Uxn *u, char *rom)
return 1;
}
static Uint8 *shadow, *memory;
static int
start(Uxn *u, char *rom)
{
memory = (Uint8 *)calloc(0xffff, sizeof(Uint8));
shadow = (Uint8 *)calloc(0xffff, sizeof(Uint8));
if(!uxn_boot(&supervisor, shadow, shadow + VISOR_DEV, (Stack *)(shadow + VISOR_WST), (Stack *)(shadow + VISOR_RST)))
if(!uxn_boot(u, (Uint8 *)calloc(0x10000, sizeof(Uint8))))
return error("Boot", "Failed to start uxn.");
if(!uxn_boot(u, memory, shadow + PAGE_DEV, (Stack *)(shadow + PAGE_WST), (Stack *)(shadow + PAGE_RST)))
return error("Boot", "Failed to start uxn.");
if(!load(&supervisor, "supervisor.rom"))
error("Supervisor", "No debugger found.");
if(!load(u, rom))
return error("Boot", "Failed to load rom.");
/* system */ devsystem = uxn_port(u, 0x0, system_dei, system_deo);
/* console */ devconsole = uxn_port(u, 0x1, nil_dei, console_deo);
/* system */ uxn_port(u, 0x0, system_dei, system_deo);
/* console */ uxn_port(u, 0x1, nil_dei, console_deo);
/* screen */ devscreen = uxn_port(u, 0x2, screen_dei, screen_deo);
/* audio0 */ devaudio0 = uxn_port(u, 0x3, audio_dei, audio_deo);
/* audio1 */ uxn_port(u, 0x4, audio_dei, audio_deo);
@ -280,18 +280,8 @@ start(Uxn *u, char *rom)
/* unused */ uxn_port(u, 0xd, nil_dei, nil_deo);
/* unused */ uxn_port(u, 0xe, nil_dei, nil_deo);
/* unused */ uxn_port(u, 0xf, nil_dei, nil_deo);
/* Supervisor */
uxn_port(&supervisor, 0x0, system_dei, system_deo);
uxn_port(&supervisor, 0x1, nil_dei, console_deo);
uxn_port(&supervisor, 0x2, screen_dei, screen_deo);
uxn_port(&supervisor, 0x8, nil_dei, nil_deo);
uxn_eval(&supervisor, PAGE_PROGRAM);
if(!uxn_eval(u, PAGE_PROGRAM))
return error("Boot", "Failed to start rom.");
return 1;
}
@ -302,13 +292,6 @@ set_zoom(Uint8 scale)
set_window_size(gWindow, (uxn_screen.width + PAD * 2) * zoom, (uxn_screen.height + PAD * 2) * zoom);
}
static void
toggle_debugger(void)
{
devsystem->dat[0xe] = !devsystem->dat[0xe];
screen_clear(&uxn_screen, &uxn_screen.fg);
}
static void
capture_screen(void)
{
@ -330,7 +313,7 @@ static void
restart(Uxn *u)
{
set_size(WIDTH, HEIGHT, 1);
start(u, "boot.rom");
start(u, "launcher.rom");
}
static Uint8
@ -349,22 +332,6 @@ get_button(SDL_Event *event)
return 0x00;
}
static Uint8
get_fkey(SDL_Event *event)
{
switch(event->key.keysym.sym) {
case SDLK_F1: return 0x01;
case SDLK_F2: return 0x02;
case SDLK_F3: return 0x04;
case SDLK_F4: return 0x08;
case SDLK_F5: return 0x10;
case SDLK_F6: return 0x20;
case SDLK_F7: return 0x40;
case SDLK_F8: return 0x80;
}
return 0x00;
}
static Uint8
get_button_joystick(SDL_Event *event)
{
@ -398,7 +365,7 @@ do_shortcut(Uxn *u, SDL_Event *event)
if(event->key.keysym.sym == SDLK_F1)
set_zoom(zoom > 2 ? 1 : zoom + 1);
else if(event->key.keysym.sym == SDLK_F2)
toggle_debugger();
system_inspect(u);
else if(event->key.keysym.sym == SDLK_F3)
capture_screen();
else if(event->key.keysym.sym == SDLK_F4)
@ -408,15 +375,17 @@ do_shortcut(Uxn *u, SDL_Event *event)
static int
console_input(Uxn *u, char c)
{
devconsole->dat[0x2] = c;
return uxn_eval(u, devconsole->vector);
Device *d = &u->dev[1];
d->dat[0x2] = c;
return uxn_eval(u, GETVECTOR(d));
}
static int
run(Uxn *u)
{
Device *devsys = &u->dev[0];
redraw();
while(!devsystem->dat[0xf]) {
while(!devsys->dat[0xf]) {
SDL_Event event;
double elapsed, begin;
if(!BENCH)
@ -435,9 +404,7 @@ run(Uxn *u)
/* Audio */
else if(event.type >= audio0_event && event.type < audio0_event + POLYPHONY) {
Device *d = devaudio0 + (event.type - audio0_event);
Uint16 res;
DEVPEEK16(res, 0x00);
uxn_eval(u, res);
uxn_eval(u, GETVECTOR(d));
}
/* Mouse */
else if(event.type == SDL_MOUSEMOTION)
@ -459,8 +426,6 @@ run(Uxn *u)
controller_key(devctrl, get_key(&event));
else if(get_button(&event))
controller_down(devctrl, get_button(&event));
/* else if(get_fkey(&event))
controller_special(&supervisor.dev[0x8], get_fkey(&event)); */
else
do_shortcut(u, &event);
ksym = event.key.keysym.sym;
@ -482,10 +447,8 @@ run(Uxn *u)
else if(event.type == stdin_event)
console_input(u, event.cbutton.button);
}
if(devsystem->dat[0xe])
uxn_eval(&supervisor, supervisor.dev[2].vector);
uxn_eval(u, devscreen->vector);
if(uxn_screen.fg.changed || uxn_screen.bg.changed || devsystem->dat[0xe])
uxn_eval(u, GETVECTOR(devscreen));
if(uxn_screen.fg.changed || uxn_screen.bg.changed)
redraw();
if(!BENCH) {
elapsed = (SDL_GetPerformanceCounter() - begin) / (double)SDL_GetPerformanceFrequency() * 1000.0f;
@ -526,7 +489,7 @@ main(int argc, char **argv)
console_input(&u, '\n');
}
}
if(!loaded && !start(&u, "boot.rom"))
if(!loaded && !start(&u, "launcher.rom"))
return error("usage", "uxnemu [-s scale] file.rom");
run(&u);
SDL_Quit();