(sixels) Encoding/Decoding works

This commit is contained in:
neauoire 2023-10-29 10:04:43 -07:00
parent 0960ab486b
commit 611d65e08d
3 changed files with 48 additions and 44 deletions

View File

@ -1 +1 @@
????????????????????????????????????????????@@@BBBFBFFFFFFFFFFBFBBB@@@??????????????????????????????????????????????????????????-????????????????????????????????@@BFFNN^^~}}}|||zz~r~svvvvvvvv~vzvzzzzz|\\\MMMFFFFBFBB@@@@??????????????????????????????????????-?????????????????????????B@FF^^}{|zzvvnn^^~~~~~~~~~~~?|~~~~~~~~~~~~~~~~~~~~~~~^^^~n~nn~nv~v~^NNB????????????????????????????????-?????????????????@BFNN^}|zrvnN^~~~~~~~~~~~~~~~~~~~~~~J_~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~s????????????????????????????????-??????????CBFFFVnnnNn^^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~@|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|_?????????????????????????????????-???????????}~~~~~~~~~~~~~~~~~~~~~~~}~}|||zzzvzvvnvnnn}Nwkm~^n~^~n^~n^~nnnnnn~fvvv~z~z~~~~~~}o???????????????????????????????????-????????????_w}~~~~~~~~~~}}|z~rnvN^^~~~~~~~~~~~~~~~~~^FNNV~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~A????????????????????????????????????-???????????????_ow}~zzfn^~~~~~~~~~}}|}||zzzrzvvvtco`_``b@b@jJZ^\z\~Z^~Z~X~^L~nNn~f~vv~~w~|}j????????????????????????????????????-???????????????????_~~~}~|zzvnvN^^~~~~~~~~~~~~~~}~y__????yuz~{~~~~~~~~~~~~~~~~~~~~~~}|qv^~^z????????????????????????????????????-???????????????????]lb|Bv~~~~~~~~~~~~~~~~}~}~}~}i}?A@AAACAFAz~~z~zv~u~~~}}}|}|{uyrnphOGgn~xA?AA@????????????????????????????????-???????????????????G_qPw{~~zyxX{x[w|y[x[ywywywYoyoy`X@PORObscakaKO]Kw?P@bBbBBBB@B@@A????Qa???TG?????????????????????????????????-????????????????????O?W_QKs~d??_O_wfO?Ewcggk_gkoLAo_Sj_?E????????@HKWsasGssgwGgoo???????n?OCJ???????????????????????????????????-??????????????????????__GQ`?tA?????zABgUAB?fAFcBUk??FXE@A?B?H@@?@??_???????????????????jOEg?????????????????????????????????????-????????????????????????????axI@EHsGo?_OO?o?O?_O?_?__???__?_?O?oG_gOgG_W_WOGcOCW?OGSOSX?????????????????????????????????????????-?????????????????????????????BxxgA???????????????????????????????@??????????????????@Nf@E?A@@@??????????????????????????????????-??????????????????C?@@@FAEHVnNZ?m~^NB????????????????????`PbPRHRbBb@@????????????@F]p{~~~~~^NNnfFvRRPHOGGCCCCCAAA@A@@?@??????@??-????????@A@E?LBZF^f][xbN~~~~~On~Fx~~~~^NFB@C???????????|Zzhl{imkixir~w??????O?@fN{b^~D~~~~~~~~~~~~~~}{pBN~~^^NKWHRFFFfNfffVfVRJH-ACGGPP`_@N^^~~~~~s?N^~~~~~~~}?~~~^~v}~~~~~~~^NNBB@P??????oowwgkgXWp_@????@@FN~}|b^~~~^~~~~~~~~~~~~{pF^~~~~}wbF^~~~~~~~~~~~~~~}{w-N^~~~~~~B{~~~~~~~d?}~~~~~~~~|A~~~~~~~~n~z~}~}~~~~~~~^^NNFFFBBBB^_Z_wMBFN^~~~~~^}~}~~~~~~~~~~~~~{`J^~~~~~wb^~~~~~~~~~~~~~~{wo??@B-~~~~~~~~~No}~~~~~^?i~~~~~~~~nO~~~~~~~~~~~~~~^~nvvzz{}{{wwooo_o_pOnwKAsfBbFBFFFF^N^^~~~~~~~~~~wRN~~~~~~|ON~~~~~~~~~~~~{w_?@FN^~~~-{}~~~~~~~~~Fw~~~~~Hd~~~~~~~~~Bw~~~}}{}{w{wwooo___???????????GoUaBc^@_SJ{}}}}}~}~}~~~~~~~~~~~~N~~~~~~~~CR~~~~~~~~~{w_?@FN~~~~~~~~-o??_oooooooo?oooooO?oooooooooO___???????????????????????????????O??o???o?????????????Ooooooooooooooooo?ooooooooo???Oooooooooooo_-
?????????????????????????????????????????___ooowww{w{{{{{{{{{{w{wwwooo__????????????????????????????????????????????????????????-???????????????????????????????_oow{{}}~^^nnnvvvzz~x~D||||||||~|z|zzzzzvvvvmmm[[[{w{wwoooo__????????????????????????????????????-???????????????????????__wo{{^^nfvzz||}}~~~~~~~~~~~~~?v~~~~~~~~~~~~~~~~~~~~~~~~~~~}~}}~}|~|~~}}w????????????????????????????????-????????????????_ow[}]^nvzx|}}~~~~~~~~~~~~~~~~~~~~~~~y?~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~D????????????????????????????????-??????????Cw{{{|}}}}}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Ov~~~^~~^~~^~~^~~~~~~~~~~~~~~~~~~~~~~~~V??????????????????????????????????-???????????N~~~~~~~~~~~~~~~~~~~~~^^N~nvvvzzz|z||}|}}}N]BEM~~}~~~}~~}~~}}}}}}~{|||~z~z~~~~~~N@???????????????????????????????????-?????????????BN~~~~~~~~~^nnvz~x}|}~~~~~~~~~~~~~~~~~~~~{}]|^~^^^^~^~^^~^~^~^^~~^~~~~~~~~~~~~g????????????????????????????????????-????????????????@BN~zz{}~~~~~~~^^^nnvnvvzzzxz|||tc`o_OOWOwoyyz~vzv~z~~z~r~~u~}}}~{~||~~b^vNy????????????????????????????????????-????????????????????~~~N~vzz|}|}~~~~~~~~~~~~~~~~n~J??????JLZ~f~~~~~~~~~~~~~~~~~~~~~~nVH|~~~Z????????????????????????????????????-???????????????????NuwVw|~~~~~^~~^~~~^~^~n~n~n^nin_gOGGGCG{gz~~z^Z\^l^^^nNnVNVFLJX]PQ@AA]~RG?GGO????????????????????????????????-???????????????????A?HPbF^~zjRRfRfbvJFRfjbjbjbj`J@joRop@X@WDCGEGE@NEB_poWwwwwWwowOOG????hG???TA?????????????????????????????????-????????????????????@?b_HEd^s???@?B{@?kBCAAe?Ae@Ug@?DY??K????????OQeBDGDADDABAA@@??????_]?`CY???????????????????????????????????-????????????????????????AHO?tg????_ZgWaLGW_[G[cWLe?_{RKOg_W_QOO_O__?_?_?_???_??????????Y@KA?????????????????????????????????????-????????????????????????????GRiokQDA@??@@?@?@??@?????????????@?@A?A@AA?B?B@AC@CB?@AD@Dr?????????????????????????????????????????-????????????????????????????_WRRag???????????????????????_?_????_O_?????????????????o}{ok_gOOO__?_??????????????????????????????-??????????????????c?Ooo[gkq|}]z_M~~}w_?????????????????_?opwpxqxwwwoo_?????????_?o{NpF~~~~~~}}}{{|xxpq`AAccCCCGGGOGOO_O___?_?O??-??????__OGOK_uwz{~[NFrw}~~~~~@}~{R~~~~~}{woc???????????VZzqufimeIRix^B??????@_o{}Fw~~S~~~~~~~~~~~~~~NFpw}~~~~]Ebqx{{{{}{{{|{|xyq-GCaappo_O}~~~~~~~d?}~~~~~~~~n?~~~~~|n~~~~~~~~}}wwop_?????@@BBAEArBp_O????oo{}~Nvw~~~~~~~~~~~~~~~~^Fp{~~~~~Nbw{~~~~~~~~~~~~~~^NFB-}~~~~~~~wF~~~~~~~S?n~~~~~~~~vG~~~~~~~~}~z~n~N~~~~~~~~~}}{{{wwww~?z_BMw{]~^^^^^^N^N^~~~~~~~~~~~^Foy~~~~~^Bw~~~~~~~~~~~~~~^FB@?_ow-~~~~~~~~~}`N~~~~~~?i~~~~~~~~}@~~~~~~~~~~~~~~~~}||ZZFNFFBB@@@?`?p@}BEgD[ww{w{{{{~}~~~~~~~~~~~~Bx}~~~~~~V@}~~~~~~~~~~~^FB?_o{}~~~~-fN^~~~~~~~~{B~~~~~QS~~~~~~~~~Wb~~^NNFNFBFBB@@@??????????????A@LGWC^o?DYfNNNNN^N^N^^^^^~~~~~~~}~~~~~~~~Cx~~~~~~~~^FB?_o{}~~~~~~~~-@???@@@@@@@@?@@@@@@?@@@@@@@@@@??????????????????????????????????@??@???@?????????????@@@@@@@@@@@@@@@@@?@@@@@@@@@???@@@@@@@@@@@@?-

View File

@ -25,8 +25,7 @@
#00 ;img/width LDA #00 ;img/height LDA #30 SFT2 MUL2 .File/length DEO2
;img/data .File/read DEO2
<convert>
#010e DEO
#010f DEO
#800f DEO
BRK
@parse-size ( 00x00* -- w h )
@ -43,33 +42,20 @@
@<convert> ( -- )
#00 ;img/height LDA #30 SFT2 #0000
&v ( -- )
STH2k
#00 ;img/width LDA #30 SFT2 #0000
&w ( -- )
( DUP2 phex #2018 DEO
STH2kr phex #2018 DEO )
DUP2 STH2kr get-sixel #18 DEO
( #0a18 DEO )
INC2 GTH2k ?&w
POP2 POP2 POP2r
[ LIT "- ] #18 DEO
#0006 ADD2 GTH2k ?&v
POP2 POP2
JMP2r
STH2k #00 ;img/width LDA #30 SFT2 #0000
&w ( -- )
DUP2 STH2kr get-sixel #18 DEO
INC2 GTH2k ?&w
POP2 POP2 POP2r [ LIT "- ] #18 DEO
#0006 ADD2 GTH2k ?&v
POP2 POP2 JMP2r
@get-sixel ( x* y* -- byte )
SWP2 ,&x STR2
[ LITr 00 ]
DUP2 #0006 ADD2 SWP2
[ LITr 00 ] DUP2 #0006 ADD2
&l ( -- )
[ LITr 10 ] SFTr
[ LIT2 &x $2 ] OVR2 get-pixel STH ORAr
INC2 GTH2k ?&l
POP2 POP2
STHr [ LIT "? ] ADD
JMP2r
[ LITr 10 ] SFTr [ LIT2 &x $2 ] OVR2 get-pixel STH ORAr #0001 SUB2 LTH2k ?&l
POP2 POP2 STHr [ LIT "? ] ADD JMP2r
@get-row ( x* y* -- row* )
STH2k
@ -103,16 +89,6 @@ JMP2r
LDAk #00 NEQ [ JMP JMP2r ] &w INC2 LDAk ?&w
JMP2r
@phex ( short* -- )
SWP phex/b &b DUP #04 SFT phex/c &c #0f AND DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO
JMP2r
@<pstr> ( str* -- )
&w ( -- )
LDAk #18 DEO
INC2 LDAk ?&w
POP2 JMP2r
(
@|memory )

View File

@ -1,18 +1,36 @@
|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
|a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
|0000
@src $40
|0100
@on-reset ( -> )
#f07f .System/r DEO2
#f0d6 .System/g DEO2
#f0b2 .System/b DEO2
#0020 DUP2 .Screen/x DEO2
#f0ef .System/r DEO2
#f0e6 .System/g DEO2
#f0e2 .System/b DEO2
#0010 DUP2 .Screen/x DEO2
.Screen/y DEO2
#0050 DUP2 .Screen/width DEO2
#0120 DUP2 .Screen/width DEO2
.Screen/height DEO2
( | begin )
;sample <draw-sixels>
;on-console .Console/vector DEO2
BRK
@on-console ( -> )
.Console/read DEI DUP #20 LTH OVR #7f GTH ORA ?{
;src scap STA
BRK }
POP
( | load )
;src .File/name DEO2
#8000 .File/length DEO2
;img/data .File/read DEO2
;img/data <draw-sixels>
BRK
@<draw-sixels> ( data* -- )
@ -45,7 +63,7 @@
,&t STR
#0600
&l ( -- )
[ LIT &t $1 ] OVR SFT #01 AND .Screen/pixel DEO
[ LIT &t $1 ] OVR SFT #01 AND #02 ADD .Screen/pixel DEO
INC GTHk ?&l
POP2
( | advance )
@ -53,6 +71,9 @@
.Screen/y DEI2k #0006 SUB2 ROT DEO2
JMP2r
(
@|stdlib )
@sdec ( str* -- str* val* )
[ LIT2r 0000 ]
&w ( -- )
@ -62,7 +83,14 @@
( continue ) INC2 LDAk ?&w
&end STH2r JMP2r
@scap ( str* -- end* )
LDAk #00 NEQ [ JMP JMP2r ] &w INC2 LDAk ?&w
JMP2r
(
@|memory )
@sample [ "???owYn||~ywo??-?IRJaVNn^NVbJRI $1 ]
@sample-rle [ "||||!12w $1 ]
@img &data