uxn-utils/gui/sixels/sixels.tal

91 lines
1.9 KiB
Tal
Raw Normal View History

2023-10-19 15:36:00 -04:00
|00 @System &vector $2 &expansion $2 &wst $1 &rst $1 &metadata $2 &r $2 &g $2 &b $2 &debug $1 &state $1
2023-10-29 13:04:43 -04:00
|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
2023-10-19 15:36:00 -04:00
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
2023-10-29 13:04:43 -04:00
|a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
2024-06-12 13:29:37 -04:00
|000
2023-10-29 13:04:43 -04:00
@src $40
2023-03-21 00:07:28 -04:00
2024-06-12 13:29:37 -04:00
|100
2023-10-19 15:36:00 -04:00
@on-reset ( -> )
2023-10-29 13:04:43 -04:00
#f0ef .System/r DEO2
#f0e6 .System/g DEO2
#f0e2 .System/b DEO2
2023-10-29 15:21:40 -04:00
#00a0 .Screen/width DEO2
#00b0 .Screen/height DEO2
2023-10-19 15:45:58 -04:00
( | begin )
2024-06-12 13:29:37 -04:00
#0010 DUP2 .Screen/x DEO2
.Screen/y DEO2
2023-10-29 13:04:43 -04:00
;on-console .Console/vector DEO2
BRK
@on-console ( -> )
2024-06-12 13:29:37 -04:00
.Console/read DEI DUP #20 GTH ?{
POP ;src .File/name DEO2
#8000 .File/length DEO2
;img .File/read DEO2
;img <draw-sixels>
;sample <draw-sixels>
2023-10-29 13:04:43 -04:00
BRK }
2024-06-12 13:29:37 -04:00
[ LIT &ptr -src ] INCk ,&ptr STR
STZ
2023-10-19 15:36:00 -04:00
BRK
2023-10-19 15:45:58 -04:00
@<draw-sixels> ( data* -- )
2023-10-19 15:36:00 -04:00
[ LIT2 02 -Screen/auto ] DEO
.Screen/x DEI2 ,&anchor STR2
2024-06-12 13:29:37 -04:00
&>w ( -- )
2023-10-28 18:47:42 -04:00
LDAk [ LIT "$ ] EQU ?&op-over
LDAk [ LIT "- ] EQU ?&op-line
LDAk [ LIT "! ] EQU ?&op-rle
2023-10-29 15:40:54 -04:00
LDAk <draw-sixels>/op-col
2024-06-12 13:29:37 -04:00
& INC2 LDAk ?&>w
2023-10-28 18:47:42 -04:00
POP2 JMP2r
&op-line ( -- )
2024-06-12 13:29:37 -04:00
.Screen/y DEI2k #0006 ADD2 ROT DEO2
2023-10-28 18:47:42 -04:00
&op-over ( -- )
2024-06-12 13:29:37 -04:00
[ LIT2 &anchor $2 ] .Screen/x DEO2
!&
2023-10-28 18:47:42 -04:00
@<draw-sixels>/op-rle ( addr* -- addr* )
2024-06-12 13:29:37 -04:00
INC2 sdec OVR2 LDA ,&trle STR
2023-10-28 18:47:42 -04:00
#0000
2024-06-12 13:29:37 -04:00
&>lrle ( -- )
[ LIT &trle $1 ] <draw-sixels>/op-col
INC2 GTH2k ?&>lrle
2023-10-29 15:21:40 -04:00
POP2 POP2 !<draw-sixels>/
2023-10-28 18:47:42 -04:00
2023-10-29 15:40:54 -04:00
@<draw-sixels>/op-col ( char -- )
[ LIT "? ] SUB ,&t STR
2023-10-28 18:47:42 -04:00
#0600
2024-06-12 13:29:37 -04:00
&>l ( -- )
2023-10-29 15:40:54 -04:00
[ LIT &t $1 ] OVR SFT #01 AND .Screen/pixel DEO
2024-06-12 13:29:37 -04:00
INC GTHk ?&>l
2023-10-19 15:36:00 -04:00
POP2
( | advance )
.Screen/x DEI2k INC2 ROT DEO2
.Screen/y DEI2k #0006 SUB2 ROT DEO2
2023-10-28 18:47:42 -04:00
JMP2r
2023-10-29 13:04:43 -04:00
(
@|stdlib )
2023-10-28 18:47:42 -04:00
@sdec ( str* -- str* val* )
[ LIT2r 0000 ]
2024-06-12 13:29:37 -04:00
&>w ( -- )
( validate ) LDAk [ LIT "0 ] SUB #09 GTH ?{
( accumulate ) [ LIT2r 000a ] MUL2r
( combine ) LDAk [ LIT "0 ] SUB [ LITr 00 ] STH
ADD2r
( continue ) INC2 LDAk ?&>w }
STH2r JMP2r
2023-10-29 13:04:43 -04:00
(
@|memory )
2023-10-19 15:36:00 -04:00
@sample [ "???owYn||~ywo??-?IRJaVNn^NVbJRI $1 ]
2023-03-21 00:07:28 -04:00
2024-06-12 13:29:37 -04:00
@img
2023-10-28 18:47:42 -04:00