uxn-utils/gui/biticn/biticn.tal

98 lines
1.9 KiB
Tal
Raw Permalink Normal View History

2024-02-06 14:42:07 -05:00
( cat in.txt | uxnemu shavian.rom > out.icn )
2024-02-06 12:51:14 -05:00
|00 @System &vector $2 &expansion $2 &wst $1 &rst $1 &metadata $2 &r $2 &g $2 &b $2 &debug $1 &state $1
|10 @Console &vector $2 &read $1 &pad $4 &type $1 &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
2024-02-06 13:10:38 -05:00
|0000
@id $2
@buf $40
2024-02-06 12:51:14 -05:00
|0100
@on-reset ( -> )
2024-02-08 19:25:16 -05:00
#f0ef .System/r DEO2
#f0e6 .System/g DEO2
#f0e2 .System/b DEO2
2024-02-06 13:27:10 -05:00
#0000 DUP2 .Screen/x DEO2
.Screen/y DEO2
2024-02-08 19:25:16 -05:00
#0047 .Screen/width DEO2
#0065 .Screen/height DEO2
2024-02-06 12:51:14 -05:00
;on-console .Console/vector DEO2
2024-02-06 14:18:41 -05:00
[ LIT2 15 -Screen/auto ] DEO
#ffff .id STZ2
2024-02-06 12:51:14 -05:00
BRK
@on-console ( -> )
2024-02-06 13:10:38 -05:00
.Console/read DEI
( linebreak ) DUP #0a NEQ ?{ POP parse-line BRK }
( append ) #00 ;buf scap/ STA2
2024-02-06 14:42:07 -05:00
BRK
2024-02-06 12:51:14 -05:00
2024-02-06 13:10:38 -05:00
@parse-line ( -- )
2024-02-06 14:18:41 -05:00
;buf LDA DUP [ LIT "0 ] EQU SWP [ LIT "1 ] EQU ORA ?new-pixels
2024-02-06 13:10:38 -05:00
( >> )
@new-glyph ( -- )
2024-02-08 19:25:16 -05:00
;buf LDA [ LIT "- ] NEQ ?{ <output> }
2024-02-06 13:10:38 -05:00
( clean ) #0000 ;buf STA2
2024-02-06 14:18:41 -05:00
.id LDZ2 <draw-glyph>
2024-02-06 13:10:38 -05:00
.id LDZ2 INC2 .id STZ2
2024-02-06 14:42:07 -05:00
#0003 ;new-pixels/row STA2
2024-02-06 13:10:38 -05:00
JMP2r
@new-pixels ( -- )
2024-02-06 14:42:07 -05:00
;buf parse-pixels
2024-02-08 19:25:16 -05:00
( store ) .id LDZ2 #40 SFT2 ;glyphs ADD2 [ LIT2 &row 0003 ] INC2k ,&row STR2
2024-02-06 13:27:10 -05:00
ADD2 STA
2024-02-06 13:10:38 -05:00
( clean ) #0000 ;buf STA2
JMP2r
2024-02-08 19:25:16 -05:00
@<output> ( -- )
;glyphs/end ;glyphs
&l ( -- )
LDAk #18 DEO
INC2 GTH2k ?&l
POP2 POP2 JMP2r
2024-02-06 13:34:00 -05:00
@parse-pixels ( line* -- icn )
[ LITr 00 ] DUP2
&w ( -- )
LDAk [ LIT "0 ] EQU ?{
[ LITr 01 ] ORAr }
[ LITr 10 ] SFTr INC2 LDAk ?&w
POP2 STHr JMP2r
2024-02-06 13:27:10 -05:00
@<draw-glyph> ( id* -- )
2024-02-06 13:34:00 -05:00
DUP2 #ffff NEQ2 ?{ POP2 JMP2r }
2024-02-08 19:25:16 -05:00
DUP2 #0007 AND2 #0009 MUL2 .Screen/x DEO2
DUP2 #03 SFT2 #0011 MUL2 .Screen/y DEO2
2024-02-06 13:27:10 -05:00
#40 SFT2 ;glyphs ADD2 .Screen/addr DEO2
2024-02-08 19:25:16 -05:00
[ LIT2 09 -Screen/sprite ] DEO
2024-02-06 13:27:10 -05:00
JMP2r
2024-02-06 13:10:38 -05:00
(
@|stdlib )
@scap ( str* -- end* )
INC2 & LDAk ?scap
JMP2r
@<pstr> ( str* -- )
LDAk #18 DEO
INC2 & LDAk ?<pstr>
POP2 JMP2r
@<phex> ( short* -- )
SWP <phex>/b
&b ( -- )
DUP #04 SFT <phex>/c
&c ( -- )
#0f AND DUP #09 GTH #27 MUL ADD [ LIT "0 ] ADD #18 DEO
JMP2r
2024-02-08 19:25:16 -05:00
@glyphs $300
&end
2024-02-06 13:10:38 -05:00