2023-11-27 16:43:11 -05:00
|
|
|
( uxncli tgachr.rom file.tga )
|
|
|
|
|
2023-11-27 17:34:40 -05:00
|
|
|
|00 @System &vector $2 &pad $6 &r $2 &g $2 &b $2
|
|
|
|
|10 @Console &vector $2 &read $1 &pad $5 &write $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
|
|
|
|
|90 @Mouse &vector $2 &x $2 &y $2 &state $1 &chord $1
|
|
|
|
|a0 @File1 &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
|
|
|
|
|b0 @File2 &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
|
2023-11-27 16:43:11 -05:00
|
|
|
|
|
|
|
|0000
|
|
|
|
|
2023-11-27 17:49:31 -05:00
|
|
|
@src $40
|
|
|
|
@dst $40
|
|
|
|
@image &id-length $1 &color-map $1 &image-type $1 &map $5 &x $2 &y $2 &w $2 &h $2 &depth $1 &descriptor $1
|
2023-11-27 16:43:11 -05:00
|
|
|
|
2023-11-27 17:49:31 -05:00
|
|
|
|0100
|
2023-11-27 16:43:11 -05:00
|
|
|
|
2023-11-27 17:49:31 -05:00
|
|
|
@on-reset ( -> )
|
2023-11-27 18:27:49 -05:00
|
|
|
;meta #06 DEO2
|
2023-11-27 17:43:50 -05:00
|
|
|
( | theme )
|
2023-11-27 17:34:40 -05:00
|
|
|
#26ae .System/r DEO2
|
|
|
|
#26ae .System/g DEO2
|
|
|
|
#26ae .System/b DEO2
|
2023-11-27 17:43:50 -05:00
|
|
|
( | size )
|
2023-11-27 17:34:40 -05:00
|
|
|
#0080 .Screen/width DEO2
|
|
|
|
#0100 .Screen/height DEO2
|
2023-11-27 17:43:50 -05:00
|
|
|
( | wait )
|
2023-11-27 16:43:11 -05:00
|
|
|
;await-src .Console/vector DEO2
|
2023-11-27 17:49:31 -05:00
|
|
|
BRK
|
2023-11-27 17:34:40 -05:00
|
|
|
|
2023-11-27 18:27:49 -05:00
|
|
|
@meta $1
|
|
|
|
( name ) "Tgachr 0a
|
|
|
|
( desc ) "TGA 20 "to 20 "CHR 20 "Converter 0a
|
|
|
|
( auth ) "By 20 "Devine 20 "Lu 20 "Linvega 0a
|
|
|
|
( date ) "27 20 "Nov 20 "2023 $1
|
|
|
|
( exts ) $1
|
|
|
|
|
2023-11-27 17:34:40 -05:00
|
|
|
(
|
|
|
|
@|vectors )
|
2023-11-27 16:43:11 -05:00
|
|
|
|
|
|
|
@await-src ( -> )
|
2023-11-27 17:49:31 -05:00
|
|
|
.Console/read DEI .src skey ?on-ready
|
|
|
|
BRK
|
2023-11-27 16:43:11 -05:00
|
|
|
|
|
|
|
@on-ready ( -> )
|
2023-11-27 17:49:31 -05:00
|
|
|
;src <file-open-tga>
|
|
|
|
;dst <pstr>/
|
|
|
|
#0a18 DEO
|
2023-11-27 18:08:08 -05:00
|
|
|
BRK
|
|
|
|
|
2023-11-27 18:27:49 -05:00
|
|
|
@<write-size> ( str* -- )
|
2023-11-27 18:08:08 -05:00
|
|
|
STH2
|
|
|
|
;image/w LDA2 #03 SFT2 NIP
|
|
|
|
( ) DUP #04 SFT hexc STH2kr STA
|
|
|
|
INC2r hexc STH2kr STA
|
|
|
|
INC2r LIT "x STH2kr STA
|
|
|
|
INC2r ;image/h LDA2 #03 SFT2 NIP
|
|
|
|
( ) DUP #04 SFT hexc STH2kr STA
|
|
|
|
INC2r hexc STH2kr STA
|
|
|
|
INC2r #00 STH2r STA
|
|
|
|
JMP2r
|
2023-11-27 16:43:11 -05:00
|
|
|
|
|
|
|
(
|
|
|
|
@|tga )
|
|
|
|
|
2023-11-27 17:49:31 -05:00
|
|
|
@<file-open-tga> ( path* -- )
|
2023-11-27 17:43:50 -05:00
|
|
|
( | header )
|
2023-11-27 17:34:40 -05:00
|
|
|
DUP2 .File1/name DEO2
|
|
|
|
#0012 .File1/length DEO2
|
|
|
|
;image .File1/read DEO2
|
2023-11-27 17:43:50 -05:00
|
|
|
( | flip endianness )
|
2023-11-27 17:34:40 -05:00
|
|
|
;image/w STH2k LDA2 SWP STH2r STA2
|
|
|
|
;image/h STH2k LDA2 SWP STH2r STA2
|
2023-11-27 18:08:08 -05:00
|
|
|
( | output path )
|
|
|
|
;src ;dst scpy ;dst
|
2023-11-27 18:27:49 -05:00
|
|
|
( ) DUP2 scap/ #0004 SUB2 <write-size>
|
2023-11-27 18:08:08 -05:00
|
|
|
( ) { ".chr 00 }
|
|
|
|
STH2r SWP2 scap/ scpy ;dst .File2/name DEO2
|
2023-11-27 17:43:50 -05:00
|
|
|
( | resize )
|
|
|
|
;image/w LDA2 #0040 ADD2 .Screen/width DEO2
|
|
|
|
;image/h LDA2 #0040 ADD2 .Screen/height DEO2
|
2023-11-27 17:34:40 -05:00
|
|
|
;image/w LDA2 #43 SFT2 .File2/length DEO2
|
2023-11-27 17:43:50 -05:00
|
|
|
( | print details )
|
2023-11-27 17:49:31 -05:00
|
|
|
;src-txt <pstr>
|
|
|
|
<pstr>/
|
|
|
|
[ LIT2 "( 18 ] DEO
|
|
|
|
#00 ;image/image-type LDA #10 SFT ;image-types ADD2 LDA2 <pstr>/
|
|
|
|
[ LIT2 ") 18 ] DEO
|
|
|
|
#0a18 DEO
|
2023-11-27 17:43:50 -05:00
|
|
|
( | get parser )
|
2023-11-27 17:49:31 -05:00
|
|
|
;image/image-type LDA #02 NEQk NIP ?{
|
2023-11-27 18:27:49 -05:00
|
|
|
;pixel-raw-true #0004 <parse-tga>
|
|
|
|
POP JMP2r }
|
2023-11-27 17:49:31 -05:00
|
|
|
#03 NEQk NIP ?{
|
2023-11-27 18:27:49 -05:00
|
|
|
;pixel-raw-bw #0001 <parse-tga>
|
|
|
|
POP JMP2r }
|
2023-11-27 17:43:50 -05:00
|
|
|
( | error )
|
2023-11-27 17:49:31 -05:00
|
|
|
;&err <pstr>
|
|
|
|
#0a18 DEO
|
|
|
|
JMP2r
|
2023-11-27 17:34:40 -05:00
|
|
|
&err "Unsupported 20 "tga-type: 20 $1
|
2023-11-27 16:43:11 -05:00
|
|
|
|
2023-11-27 18:27:49 -05:00
|
|
|
@<draw-row> ( -- )
|
|
|
|
#2000
|
|
|
|
&l ( -- )
|
|
|
|
#81 .Screen/sprite DEO
|
|
|
|
INC GTHk ?&l
|
|
|
|
POP2
|
|
|
|
( | move down )
|
|
|
|
#0020 .Screen/x DEO2
|
|
|
|
.Screen/y DEI2k #0008 ADD2 ROT DEO2
|
|
|
|
JMP2r
|
|
|
|
|
|
|
|
@<parse-tga> ( filter* length* -- )
|
2023-11-27 17:34:40 -05:00
|
|
|
#0020 .Screen/x DEO2
|
2023-11-27 17:43:50 -05:00
|
|
|
#0020 .Screen/y DEO2
|
2023-11-27 18:27:49 -05:00
|
|
|
#05 .Screen/auto DEO
|
2023-11-27 17:49:31 -05:00
|
|
|
.File1/length DEO2
|
|
|
|
,&filter STR2
|
2023-11-27 17:34:40 -05:00
|
|
|
#0000 ,&x STR2
|
|
|
|
#0000 ,&y STR2
|
2023-11-27 17:49:31 -05:00
|
|
|
&stream ( -- )
|
2023-11-27 17:34:40 -05:00
|
|
|
;&pixel STH2k .File1/read DEO2
|
2023-11-27 17:49:31 -05:00
|
|
|
[ LIT2 &x $2 ] [ LIT2 &y $2 ] #0007 AND2 STH2r [ LIT2 &filter $2 ] JSR2
|
|
|
|
( chr ) set-pixel
|
|
|
|
( on linebreak ) ,&x LDR2 INC2 DUP2 ,&x STR2
|
|
|
|
;image/w LDA2 NEQ2 ?&no-line
|
|
|
|
#0000 ,&x STR2
|
|
|
|
,&y LDR2 INC2 ,&y STR2
|
2023-11-27 18:27:49 -05:00
|
|
|
( on row ) ,&y LDR2 #0007 AND2 ORA ?&no-line
|
2023-11-27 17:49:31 -05:00
|
|
|
;buffer DUP2 .Screen/addr DEO2
|
|
|
|
.File2/write DEO2
|
2023-11-27 18:27:49 -05:00
|
|
|
<draw-row>
|
|
|
|
&no-line .File1/success DEI2 ORA ?&stream
|
2023-11-27 17:49:31 -05:00
|
|
|
JMP2r
|
2023-11-27 17:34:40 -05:00
|
|
|
&pixel $4
|
2023-11-27 16:43:11 -05:00
|
|
|
|
2023-11-27 17:49:31 -05:00
|
|
|
(
|
|
|
|
@|tools )
|
2023-11-27 16:43:11 -05:00
|
|
|
|
2023-11-27 17:34:40 -05:00
|
|
|
@set-pixel ( x* y* color -- )
|
|
|
|
STH
|
2023-11-27 17:49:31 -05:00
|
|
|
OVR2 SWP2
|
2023-11-27 17:43:50 -05:00
|
|
|
( | get addr )
|
2023-11-27 17:49:31 -05:00
|
|
|
DUP2 #0007 AND2 SWP2 #83 SFT2 ADD2 SWP2 #43 SFT2 ADD2 ;buffer ADD2
|
2023-11-27 17:34:40 -05:00
|
|
|
( ch1 ) OVR2 OVR2 STHkr #00 toggle-pixel
|
2023-11-27 18:27:49 -05:00
|
|
|
( ch2 ) #0008 ADD2 STHr #01
|
|
|
|
( >> )
|
2023-11-27 16:43:11 -05:00
|
|
|
|
2023-11-27 17:34:40 -05:00
|
|
|
@toggle-pixel ( x* addr* color -- )
|
2023-11-27 16:43:11 -05:00
|
|
|
STH2
|
2023-11-27 17:49:31 -05:00
|
|
|
LDAk STH
|
|
|
|
SWP2 NIP STHr SWP STH2r SFT #01 AND ?{
|
2023-11-27 17:34:40 -05:00
|
|
|
( mask ) #0107 ROT #07 AND SUB #40 SFT SFT #ff EOR AND
|
|
|
|
( save ) ROT ROT STA
|
2023-11-27 17:49:31 -05:00
|
|
|
JMP2r }
|
|
|
|
( mask ) #0107 ROT #07 AND SUB #40 SFT SFT ORA
|
|
|
|
( save ) ROT ROT STA
|
|
|
|
JMP2r
|
2023-11-27 17:34:40 -05:00
|
|
|
|
|
|
|
@pixel-raw-true ( pixel* -- color )
|
2023-11-27 17:49:31 -05:00
|
|
|
LDAk ,&b STR
|
|
|
|
INC2 LDAk ,&g STR
|
|
|
|
INC2 LDAk ,&r STR
|
|
|
|
INC2 LDA ,&a STR
|
|
|
|
[ LIT2 00 &r $1 ] [ LIT2 00 &g $1 ] [ LIT2 00 &b $1 ] ADD2 ADD2
|
|
|
|
( ) #0003 DIV2 NIP [ LIT &a $1 ] POP #06 SFT JMP2r
|
2023-11-27 17:34:40 -05:00
|
|
|
|
|
|
|
@pixel-raw-bw ( pixel* -- color )
|
2023-11-27 17:49:31 -05:00
|
|
|
( res ) LDA JMP2r
|
2023-11-27 16:43:11 -05:00
|
|
|
|
|
|
|
(
|
2023-11-27 17:34:40 -05:00
|
|
|
@|stdlib )
|
2023-11-27 16:43:11 -05:00
|
|
|
|
2023-11-27 17:49:31 -05:00
|
|
|
@<pstr> ( str* -- )
|
|
|
|
&w ( -- )
|
|
|
|
LDAk #18 DEO
|
|
|
|
INC2 & LDAk ?&w
|
|
|
|
POP2 JMP2r
|
2023-11-27 16:43:11 -05:00
|
|
|
|
2023-11-27 17:49:31 -05:00
|
|
|
@skey ( key buf -- proc )
|
|
|
|
OVR #21 LTH ?{
|
|
|
|
#00 SWP sput #00 JMP2r }
|
|
|
|
POP2 #01 JMP2r
|
2023-11-27 17:34:40 -05:00
|
|
|
|
2023-11-27 17:49:31 -05:00
|
|
|
@scap ( str* -- end* )
|
|
|
|
&w ( -- )
|
2023-11-27 18:08:08 -05:00
|
|
|
INC2 & LDAk ?&w
|
2023-11-27 17:49:31 -05:00
|
|
|
JMP2r
|
|
|
|
|
|
|
|
@sput ( chr str* -- )
|
2023-11-27 18:08:08 -05:00
|
|
|
scap/ STA
|
2023-11-27 17:49:31 -05:00
|
|
|
JMP2r
|
2023-11-27 16:43:11 -05:00
|
|
|
|
2023-11-27 17:49:31 -05:00
|
|
|
@slen ( str* -- len* )
|
2023-11-27 18:08:08 -05:00
|
|
|
DUP2 scap/ SWP2 SUB2 JMP2r
|
2023-11-27 17:49:31 -05:00
|
|
|
|
|
|
|
@scpy ( src* dst* -- )
|
|
|
|
STH2
|
|
|
|
&w ( -- )
|
|
|
|
LDAk STH2kr STA
|
|
|
|
INC2r INC2 LDAk ?&w
|
|
|
|
POP2 #00 STH2r STA
|
|
|
|
JMP2r
|
2023-11-27 16:43:11 -05:00
|
|
|
|
2023-11-27 18:27:49 -05:00
|
|
|
@hexc ( hex -- char )
|
|
|
|
#0f AND DUP #09 GTH #27 MUL ADD #30 ADD JMP2r
|
|
|
|
|
2023-11-27 17:34:40 -05:00
|
|
|
(
|
|
|
|
@|assets )
|
|
|
|
|
2023-11-27 17:49:31 -05:00
|
|
|
@src-txt
|
|
|
|
"Parsing 20 $1
|
2023-11-27 17:34:40 -05:00
|
|
|
|
2023-11-27 17:49:31 -05:00
|
|
|
@image-types-txts &no-image "no-data $1
|
2023-11-27 17:34:40 -05:00
|
|
|
&raw-color "RAW-color $1
|
|
|
|
&raw-true "RAW-true $1
|
|
|
|
&raw-bw "RAW-bw $1
|
|
|
|
&rle-color "RLE-color $1
|
|
|
|
&rle-true "RLE-true $1
|
|
|
|
&rle-bw "RLE-bw $1
|
|
|
|
&unknown "unknown $1
|
|
|
|
|
|
|
|
@image-types [
|
2023-11-27 17:49:31 -05:00
|
|
|
=image-types-txts/no-image =image-types-txts/raw-color
|
|
|
|
=image-types-txts/raw-true =image-types-txts/raw-bw
|
|
|
|
=image-types-txts/unknown =image-types-txts/unknown
|
|
|
|
=image-types-txts/unknown =image-types-txts/unknown
|
|
|
|
=image-types-txts/unknown =image-types-txts/rle-color
|
|
|
|
=image-types-txts/rle-true =image-types-txts/rle-bw ]
|
2023-11-27 17:34:40 -05:00
|
|
|
|
|
|
|
@buffer ( A row chr tiles for the width of the image )
|
2023-11-27 16:43:11 -05:00
|
|
|
|
2023-11-27 17:49:31 -05:00
|
|
|
|