~aleteoryx/uxn

ref: fecde3e896101f20ed3ece0b43938aabda4d3b1d uxn/gif.tal -rw-r--r-- 1.5 KiB
fecde3e8Aleteoryx rewritten for 4096 codes 7 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|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 @File1/vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2

|00
	@input/path $2f &end $1

%dbg! ( -- ) { #00 ?{ LIT2 01 -System/debug DEO } }
|100
@on-reset ( -> )
	;meta .System/metadata DEO2
	.Console/type DEI ?{ ;errs/usage die }
	;on-input .Console/vector DEO2
	BRK

@on-input ( -> ) 
	#0403 .Console/type DEI
	NEQk ?{ ;errs/usage die } NIP
	NEQk ?{ !readloop } POP2

	[ LIT2 -input/end &ptr -input/path ]
	NEQk ?{ ;errs/pathlimit die }
	.Console/read DEI SWP STZk INC ,&ptr STR
	POP2 BRK

@readloop ( -- )
	;input/path .File1/name DEO2
	.File1/success DEI
	BRK

@die ( str* -- )
	perr [ LIT2 81 -System/state ] DEO
	BRK
@pout ( str* -- )
	.Console/write ;puts/target STA
	!puts
@perr ( str* -- )
	.Console/error ;puts/target STA
	( >> )

@puts ( str* -- )
	LDAk DUP ?{ POP POP2 JMP2r }
	[ LIT &target -Console/write ] DEO
	INC2 !puts


@Gif/chunk &magic $ff
	&screen &wid $2 &hei $2 &pack $1 &bg $1 &aspect $1
	&colortab $300
	
@Gif/init ( -- )
	#06 /read
	/magic-ok? ?{ ;errs/corrupt die }
@Gif/read ( len* -- )
	#00 SWP .File1/length DEO2
	;/chunk .File1/read
	JMP2r


@errs/usage "usage: 20 "gif.rom 20 "image.gif 0a $1
	&pathlimit "GIF 20 "path 20 "limit 20 "exceeded. 0a $1
	&filename ": 20 "file 20 "unreadable 0a $1

@meta $1
	( name ) "GIF 0a
	( desc ) ".gif 20 "file 20 "renderer 0a
	( auth ) "By 20 "Aleteoryx 0a
	( date ) "20250319 $2