uxn-notebook/one_line_gen.tal

85 lines
1.7 KiB
Tal

|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
|a0 @File/vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
(
Portable BitMap
https://en.wikipedia.org/wiki/Netpbm#File_formats
P4
# This is an example binary format of the letter "J" with each byte in decimal notation
6 10
8 8 8 8 8 8 136 112 0 0
88x31 pixel image
row of 88px -> 11 bytes 8 bits per byte
31 rows -> 341 bytes
)
|00
@img-pt $2
@img $20
|0100
@on-reset
( set img-pt to start of img )
;img ;img-pt STA2
LIT2 00 "P write-to-image
LIT2 00 "4 write-to-image
#000a write-to-image
#0008 write-to-image
#0008 write-to-image
#0020 write-to-image
#0008 write-to-image
#000a write-to-image
#00e7 write-to-image
#00e7 write-to-image
#00e7 write-to-image
#00e7 write-to-image
#00e7 write-to-image
#00e7 write-to-image
#00e7 write-to-image
#00e7 write-to-image
save-file
BRK
@write-to-image ( val* )
;img-pt LDA2 ( val* pt* )
STA2 ( )
;img-pt LDA2 ( pt* )
#0002 ADD2 ( pt*+2 )
;img-pt STA2
JMP2r
@save-file
;/filename .File/name DEO2
#0020 .File/length DEO2
;img .File/write DEO2
JMP2r
&filename "one_line.pbm $1
(
@gen-image
( set image-pt to start of image )
;image ;image-pt STA2
LIT2 00 "P write-to-image
LIT2 00 "4 write-to-image
#000a write-to-image
#0008 write-to-image
#0020 write-to-image
#0008 write-to-image
#00ff write-to-image
JMP2r
@image-pt $2
( todo include space for header )
@image $155
( @drawing $1550 ( 5456 ) )
)