~rabbits/potato

569bfa991ccbde6f51229bcb728a82d302afa75c — Devine Lu Linvega 1 year, 8 months ago 5e22e86
Added assembler
7 files changed, 752 insertions(+), 2 deletions(-)

A etc/clock.tal
M etc/icons10x10.chr
M src/apps.tal
A src/assembler.tal
M src/assets.tal
M src/desktop.tal
M src/potato.tal
A etc/clock.tal => etc/clock.tal +323 -0
@@ 0,0 1,323 @@
( simple graphical clock )

|00 @System     [ &vector $2 &pad      $6 &r      $2 &g     $2 &b      $2 ]
|10 @Console    [ &vector $2 &read     $1 &pad    $5 &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 ]
|c0 @DateTime   [ &year   $2 &month    $1 &day    $1 &hour  $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ]

|0000

@last
	&day $1 &sec $1
@center
	&x $2 &y $2
@date
	&x $2 &y $2
@time
	&x $2 &y $2
@needles
	&hx $2 &hy $2
	&mx $2 &my $2
	&sx $2 &sy $2
	&zx $2 &zy $2
@buf
	&d $3 &h $2 &s1 $1 &m $2 &s2 $1 &s $3
@line
	&x $2 &y $2 &dx $2 &dy $2 &e1 $2

|0100 ( -> )

	( theme )
	#0ff8 .System/r DEO2
	#0f08 .System/g DEO2
	#0f08 .System/b DEO2
	( resize )
	#00d0 .Screen/width DEO2
	#0120 .Screen/height DEO2
	( vectors )
	;on-frame .Screen/vector DEO2
	( center )
	.Screen/width DEI2 #01 SFT2
		DUP2 .center/x STZ2
		DUP2 #0028 SUB2 .date/x STZ2
		#0020 SUB2 .time/x STZ2
	.Screen/height DEI2 #01 SFT2
		DUP2 .center/y STZ2
		DUP2 #0078 SUB2 .date/y STZ2
		#006c ADD2 .time/y STZ2
	;draw-watchface JSR2
	( time buffer )
	LIT ":
		DUP .buf/s1 STZ
		.buf/s2 STZ

( continue )

@on-frame ( -> )

	( once per second )
	.DateTime/second DEI
	DUP .last/sec LDZ EQU ,&same-sec JCN
		( make time )
		.DateTime/hour DEI .buf/h ;decimal JSR2
		.DateTime/minute DEI .buf/m ;decimal JSR2
		DUP .buf/s ;decimal JSR2
		( draw label )
		.time/x LDZ2 .Screen/x DEO2
		.time/y LDZ2 .Screen/y DEO2
		;buf/h ;draw-text JSR2
		( draw needles )
		#00 ;draw-needles JSR2
		;make-needles JSR2
		#01 ;draw-needles JSR2
		DUP .last/sec STZ
		&same-sec
	POP

	( once per day )
	.DateTime/day DEI
	DUP .last/day LDZ EQU ,&same-day JCN
		( make date )
		DUP .buf/d ;decimal JSR2
		( draw label )
		.date/x LDZ2 .Screen/x DEO2
		.date/y LDZ2 .Screen/y DEO2
		[ #00 .DateTime/dotw DEI #20 SFT ] ;week-txt ADD2 ;draw-text JSR2
		[ #00 .DateTime/month DEI #20 SFT ] ;month-txt ADD2 ;draw-text JSR2
		;buf/d ;draw-text JSR2
		DUP .last/day STZ
		&same-day
	POP

BRK

@draw-needles ( draw -- )

	STH
	.center/x LDZ2 .center/y LDZ2
	OVR2 OVR2
	.needles/mx LDZ2 .needles/my LDZ2 #01 STHkr MUL
		;draw-line JSR2
	OVR2 OVR2
	.needles/hx LDZ2 .needles/hy LDZ2 #01 STHkr MUL
		;draw-line JSR2
	.needles/sx LDZ2 .needles/sy LDZ2
	.needles/zx LDZ2 .needles/zy LDZ2 #02 STHr MUL
		;draw-line JSR2

	( middle )
	#0001 SUB2 .Screen/y DEO2
	#0001 SUB2 .Screen/x DEO2
	;middle-icn .Screen/addr DEO2
	#0a .Screen/sprite DEO

JMP2r

@draw-text ( addr* -- )

	( auto addr ) #15 .Screen/auto DEO
	&while
		LDAk
		DUP ;is-lc JSR2 ,&lc JCN
		DUP ;is-uc JSR2 ,&uc JCN
		DUP ;is-num JSR2 ,&num JCN
		DUP LIT "/ EQU ,&slash JCN
		DUP LIT ": EQU ,&colon JCN
		POP ;font/blank
		&end
		.Screen/addr DEO2
		#03 .Screen/sprite DEO
		INC2 LDAk ,&while JCN
	POP2
	#00 .Screen/sprite DEO
	( auto none ) #00 .Screen/auto DEO

JMP2r
	&lc #61 SUB #00 SWP #40 SFT2 ;font/lc ADD2 ,&end JMP
	&uc #41 SUB #00 SWP #40 SFT2 ;font/uc ADD2 ,&end JMP
	&num #30 SUB #00 SWP #40 SFT2 ;font/num ADD2 ,&end JMP
	&slash POP ;font/slash ,&end JMP
	&colon POP ;font/colon ,&end JMP

@draw-line ( x1* y1* x2* y2* color -- )

	( load ) STH ,&y STR2 ,&x STR2 .line/y STZ2 .line/x STZ2
	,&x LDR2 .line/x LDZ2 SUB2 ;abs2 JSR2 .line/dx STZ2
	#0000 ,&y LDR2 .line/y LDZ2 SUB2 ;abs2 JSR2 SUB2 .line/dy STZ2
	#ffff #00 .line/x LDZ2 ,&x LDR2 ;lts2 JSR2 DUP2 ADD2 ADD2 ,&sx STR2
	#ffff #00 .line/y LDZ2 ,&y LDR2 ;lts2 JSR2 DUP2 ADD2 ADD2 ,&sy STR2
	.line/dx LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2
	&loop
		.line/x LDZ2 DUP2 .Screen/x DEO2 [ LIT2 &x $2 ] EQU2
		.line/y LDZ2 DUP2 .Screen/y DEO2 [ LIT2 &y $2 ] EQU2
			STHkr .Screen/pixel DEO
			AND ,&end JCN
		.line/e1 LDZ2 DUP2 ADD2 DUP2
		.line/dy LDZ2 ;lts2 JSR2 ,&skipy JCN
			.line/e1 LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2
			.line/x LDZ2 [ LIT2 &sx $2 ] ADD2 .line/x STZ2
		&skipy
		.line/dx LDZ2 ;gts2 JSR2 ,&skipx JCN
			.line/e1 LDZ2 .line/dx LDZ2 ADD2 .line/e1 STZ2
			.line/y LDZ2 [ LIT2 &sy $2 ] ADD2 .line/y STZ2
		&skipx
		,&loop JMP
	&end
	POPr

JMP2r

@draw-watchface ( -- )

	#3c00
	&loop
		( dots )
		#00 OVRk ADD2 ;table ADD2 LDA2
			#0018 ;circle JSR2
			.Screen/x DEO2 .Screen/y DEO2 #01 .Screen/pixel DEO
		( markers )
		DUP #05 ;mod JSR2 ,&no-marker JCN
			#00 OVRk ADD2 ;table ADD2 LDA2
			STH2k #0018 ;circle JSR2 SWP2
			STH2r #001c ;circle JSR2 SWP2
				#01 ;draw-line JSR2
			&no-marker
		INC GTHk ;&loop JCN2
	POP2

JMP2r

@make-needles ( -- )

	[ #00 .DateTime/second DEI #1e ADD #3c ;mod JSR2 ] DUP2 ADD2 ;table ADD2 LDA2
		#00a0 ,circle JSR .needles/zx STZ2 .needles/zy STZ2
	[ #00 .DateTime/second DEI ] DUP2 ADD2 ;table ADD2 LDA2
		#0020 ,circle JSR .needles/sx STZ2 .needles/sy STZ2
	[ #00 .DateTime/minute DEI ] DUP2 ADD2 ;table ADD2 LDA2
		#0022 ,circle JSR .needles/mx STZ2 .needles/my STZ2
	[ #00 .DateTime/hour DEI #0c ;mod JSR2 #20 SFTk NIP ADD ]
	( minute offset ) [ #00 .DateTime/minute DEI #0f DIV ADD2 ] DUP2 ADD2 ;table ADD2 LDA2
		#002a ,circle JSR .needles/hx STZ2 .needles/hy STZ2

JMP2r

@circle ( cx cy radius* -- y* x* )

	STH2 SWP
	#00 SWP #40 SFT2 STH2kr DIV2 .center/x LDZ2 ADD2 #0800 STH2kr DIV2 SUB2
	STH2 SWP2r
	#00 SWP #40 SFT2 STH2kr DIV2 .center/y LDZ2 ADD2 #0800 STH2kr DIV2 SUB2
	POP2r STH2r

JMP2r

@decimal ( value* zp-label -- )

	STH
	DUP #0a DIV #30 ADD STHkr STZ
	#0a ;mod JSR2 #30 ADD STHr INC STZ

JMP2r

@mod DIVk MUL SUB JMP2r
@abs2 DUP2 #0f SFT2 EQU #05 JCN #0000 SWP2 SUB2 JMP2r
@lts2 #8000 STH2k ADD2 SWP2 STH2r ADD2 GTH2 JMP2r
@gts2 #8000 STH2k ADD2 SWP2 STH2r ADD2 LTH2 JMP2r
@is-uc DUP #40 GTH SWP #5b LTH AND JMP2r
@is-lc DUP #60 GTH SWP #7b LTH AND JMP2r
@is-num DUP #2f GTH SWP #3a LTH AND JMP2r

@week-txt
	"Sun $1 "Mon $1 "Tue $1 "Wed $1 "Thu $1 "Fri $1
	"Sat $1

@month-txt
	"Jan $1 "Feb $1 "Mar $1 "Apr $1 "May $1 "Jun $1
	"Jul $1 "Aug $1 "Sep $1 "Oct $1 "Nov $1 "Dec $1

@table ( 60 positions on a circle )
	8000 8d00 9a02 a706 b40b c011 cb18 d520
	df2a e734 ee40 f44b f958 fd65 ff72 ff80
	ff8d fd9a f9a7 f4b4 eec0 e7cb dfd5 d5df
	cbe7 c0ee b4f4 a7f9 9afd 8dff 80ff 72ff
	65fd 58f9 4bf4 40ee 34e7 2adf 20d5 18cb
	11c0 0bb4 06a7 029a 008d 0080 0072 0265
	0658 0b4b 113f 1834 202a 2a20 3418 3f11
	4b0b 5806 6502 7200

@middle-icn
	40e0 4000 0000 0000

@font
	&num
	0018 2442 4242 4242 4242 4242 4224 1800
	0008 1828 0808 0808 0808 0808 0808 1c00
	0018 2442 4202 0202 0408 1020 4040 7e00
	0018 2442 0202 0438 0402 0202 0204 7800
	000c 0c14 1414 2424 2444 447e 0404 0e00
	007e 4040 4040 5864 4202 0202 0204 7800
	000c 1020 4040 5864 4242 4242 4224 1800
	007e 4202 0204 0404 0808 0810 1010 1000
	0018 2442 4242 2418 2442 4242 4224 1800
	0018 2442 4242 4242 261a 0202 0408 3000
	&uc
	0010 1028 2844 4444 8282 fe82 8282 0000
	00f8 4442 4242 4478 4442 4242 44f8 0000
	003c 4282 8280 8080 8080 8282 423c 0000
	00f8 4442 4242 4242 4242 4242 44f8 0000
	00fc 4240 4040 4878 4840 4040 42fc 0000
	80fe 4240 4040 447c 4440 4040 40e0 0000
	003a 4682 8080 8e82 8282 8282 463a 0000
	00ee 4444 4444 447c 4444 4444 44ee 0000
	0038 1010 1010 1010 1010 1010 1038 0000
	000e 0404 0404 0404 0404 4444 2810 0000
	00ee 4448 4850 5060 5050 4848 44ee 0000
	00e0 4040 4040 4040 4040 4040 42fe 0000
	0082 c6c6 c6aa aaaa 9292 9282 8282 0000
	00e2 4262 6262 5252 4a4a 4646 42e2 0000
	0038 4482 8282 8282 8282 8282 4438 0000
	00f8 4442 4242 4244 7840 4040 40f0 0000
	0038 4482 8282 8282 8282 829a 643a 0000
	00f8 4442 4242 4478 4844 4442 42e2 0000
	0010 2844 4440 2010 0804 4444 2810 0000
	00fe 9210 1010 1010 1010 1010 1038 0000
	00ee 4444 4444 4444 4444 4444 4438 0000
	0082 8282 8282 8244 4444 2828 1010 0000
	0082 8292 9292 9292 92ba aa44 4444 0000
	0042 4242 2424 1818 1824 2442 4242 0000
	0082 8282 4444 2828 1010 1010 1038 0000
	007e 4204 0408 0810 1020 2040 427e 0000
	&lc
	0000 0000 0030 0808 3848 4848 4834 0000
	0060 2020 202c 3222 2222 2222 322c 0000
	0000 0000 001c 2240 4040 4040 221c 0000
	000c 0404 0434 4c44 4444 4444 4c36 0000
	0000 0000 0018 2424 3c20 2020 2418 0000
	000c 1210 1038 1010 1010 1010 1038 0000
	0000 0000 0034 4a48 4830 4038 4444 4438
	00c0 4040 4058 6444 4444 4444 44ee 0000
	0010 0000 0030 1010 1010 1010 1038 0000
	0008 0000 0018 0808 0808 0808 0808 2810
	0060 2020 2022 2224 2438 2424 2272 0000
	0030 1010 1010 1010 1010 1010 1038 0000
	0000 0000 00a4 da92 9292 9292 9292 0000
	0000 0000 00d8 6444 4444 4444 44ee 0000
	0000 0000 0038 4482 8282 8282 4438 0000
	0000 0000 00d8 6442 4242 4242 6458 40e0
	0000 0000 0034 4c84 8484 8484 4c34 040e
	0000 0000 0068 3420 2020 2020 2070 0000
	0000 0000 0018 2424 1008 0424 2418 0000
	0010 1010 107c 1010 1010 1010 1408 0000
	0000 0000 00cc 4444 4444 4444 4c36 0000
	0000 0000 00ee 4444 4428 2828 1010 0000
	0000 0000 0092 9292 9292 92aa 4444 0000
	0000 0000 00ee 4428 1010 1028 44ee 0000
	0000 0000 00ee 4444 4448 2828 1010 2040
	0000 0000 007c 4408 0810 2020 447c 0000
	&colon
	0000 0000 0010 1000 0000 0000 1010 0000
	&slash
	0202 0404 0808 1010 2020 4040 8080 0000
	&blank
	0000 0000 0000 0000 0000 0000 0000 0000


M etc/icons10x10.chr => etc/icons10x10.chr +0 -0
M src/apps.tal => src/apps.tal +1 -1
@@ 1120,4 1120,4 @@ JMP2r

@size-apps-end

~src/manifest.tal
~src/assembler.tal

A src/assembler.tal => src/assembler.tal +364 -0
@@ 0,0 1,364 @@

@on-error ( id* name* -> )

	#0a18 DEO
	( print ) ;err pstr pstr #2018 DEO pstr ;dict/asm-in pstr ;scope pstr ;dict/asm-dot pstr
	( halt ) #010f DEO

BRK

@handle-file ( f* -- )

	.File/name DEO2
	#0001 .File/length DEO2
	&s
		;&c .File/read DEO2
		.File/success DEI2 ORA ?&continue
			,&c LDR #00 EQU ?&err JMP2r
		&continue [ LIT &c $1 ] handle-char
!&s
	&err .File/name DEI2 ;err/source !on-error

@handle-char ( c -- )

	#20 GTHk NIP ?&append POP
	;token LDAk ?&run POP2

JMP2r
	&append ( c -- ) ;token DUP2 slen #001f LTH2 ?sput POP JMP2r
	&run ( t* -- ) DUP2 handle-token !sclr

@handle-token ( t* -- )

	LDAk LIT "( EQU ?&on-parens
	LDAk LIT ") EQU ?&on-parens
	[ LIT &sleep $1 ] ?&on-sleep

!parse
	&on-parens ( t* -- ) LDA LIT "( EQU ,&sleep STR JMP2r
	&on-sleep ( t* -- ) POP2 JMP2r

(
@|core )

@assemble ( src* dst* buffer* -- )

	DUP2 ;create-label/symbols STA2
	;find-label/symbols STA2

	( prepare output )
	.Disk/name DEO2
	#01 .Disk/delete DEO
	#0001 .Disk/length DEO2
	( pass1 )
	#0100 set-head
	;dict/asm-reset ;scope scpy
	DUP2 handle-file
	( pass2 )
	#0100 set-head
	;dict/asm-reset ;scope scpy
	#00 ;write/skip STA
	handle-file

JMP2r

@parse ( t* -- )

	LDAk ,&rune STR
	( runes )
	;runes/err ;runes
	&l
		LDAk [ LIT &rune $1 ] NEQ ?&no-runic
			NIP2 INC2 LDA2 JMP2
			&no-runic
		#0003 ADD2 GTH2k ?&l
	POP2 POP2
	( non-runic )
	DUP2 is-hex ?lib/rawhex
	DUP2 is-opcode ?lib/opcode
	lib/litjsi

JMP2r

@lib
	&padabs INC2 get-hex write-pad !set-head
	&padrel INC2 get-hex !write-fill
	&toplab INC2 ;scope OVR2 SWP2 scpy !create-label
	&sublab INC2 make-sublabel !create-label
	&litrel #80 write
	&rawrel INC2 get-ref get-rel INC !write
	&litzep #80 write
	&rawzep INC2 get-ref LDA2 NIP !write
	&litabs #a0 write
	&rawabs INC2 get-ref LDA2 !write-short
	&litjci #20 write INC2 !write-call
	&litjmi #40 write INC2 !write-call
	&litjsi #60 write !write-call
	&lithex INC2 DUP2 slen NIP #02 SFT #a080 ROT [ JMP SWP POP ] write
	&rawhex !write-hex
	&rawstr INC2 !write-str
	&opcode find-opcode !write
	&inc INC2k ;include STH2k scpy sclr STH2r !handle-file
	&ignore POP2 JMP2r

(
@|primitives )

@write-pad ( addr* -- dest* )

	;write/head LDA2
	LTH2k ?&no-pad
		SUB2k write-fill POP2 JMP2r
		&no-pad
	OVR2 #0100 LTH2 ?&no-err
		;token ;err/rewind !on-error
		&no-err
	POP2

JMP2r

@write-fill ( len* -- )

	#0000 EQU2k ?&skip
	&l
		#00 write
		INC2 GTH2k ?&l
	&skip
	POP2 POP2

JMP2r

@write-str ( str* -- )

	&w
		LDAk write
		INC2 LDAk ?&w
	POP2

JMP2r

@write-call ( str* -- )

	get-ref LDA2 ;write/head LDA2 INC2 INC2 SUB2

!write-short

@write-hex ( str* -- )

	DUP2 slen OVR2 get-hex SWP2 NIP
	DUP #02 EQU ?&byte
	DUP #04 EQU ?&short
	POP POP2
	;err/number !on-error
	&byte POP NIP2 NIP !write
	&short POP NIP2 ( fall through )

@write-short ( short* -- )

	SWP write

@write ( byte -- )

	,&b STR
	[ LIT2 &head 0100 ] #0100 LTH2 ?&ignore
	[ LIT &skip 01 ] ?&pass1
	[ LIT2 &length $2 ] ,&head LDR2 LTH2 ?&ignore
	( pass2 ) ;&b .Disk/write DEO2
	&ignore

!move-head

&pass1 ( -- )

	[ LIT &b $1 ] #00 EQU ?&no-record
		,&head LDR2 ;write/length STA2
		&no-record

!move-head

(
@|helpers )

@get-hex ( str* -- value* )

	DUP2 is-hex ?&valid
		;err/number !on-error
		&valid

!shex

@get-rel ( label* -- distance )

	;write/skip LDA ?&fill
	LDA2k ;write/head LDA2 SUB2 #0003 SUB2
	DUP2 #0080 ADD2 POP ?&fail
	NIP2 NIP

JMP2r
	&fail POP2 #0003 ADD2 ;err/distance !on-error
	&fill POP2 #ff JMP2r

@get-ref ( token* -- <label*> )

	;write/skip LDA #00 EQU ?&no-write
		POP2 ;&fill JMP2r
		&no-write
	LDAk LIT "& NEQ ?&no-sub
		INC2 make-sublabel
		&no-sub
	find-label
		INC2k ORA ?&found
			POP2 ;err/reference !on-error
			&found
	( count )
	INC2k INC2 LDAk INC ROT ROT STA

JMP2r
	&fill ffff "[empty] $1

@create-label ( name* -- )

	;write/skip LDA #00 EQU ?&skip
	( not hex ) DUP2 is-hex ?&invalid
	( not opc ) DUP2 is-opcode ?&invalid
	( not dup ) DUP2 find-label INC2 ORA ?&not-unique
	( save addr ) ;write/head LDA2 [ LIT2 &symbols $2 ] STH2k STA2
	( move ) INC2r INC2r INC2r
	( save name ) DUP2 STH2kr scpy
	( move ) slen STH2r ADD2 INC2 ,&symbols STR2
	( stats ) [ LIT2 &count $2 ] INC2 ,&count STR2

JMP2r
	&invalid ;err/invalid !on-error
	&not-unique ;err/duplicate !on-error
	&skip POP2 JMP2r

@make-sublabel ( name* -- sublabel* )

	;scope ;sublabel STH2k scpy
	LIT "/ STH2kr sput
	STH2kr scat
	STH2r

JMP2r

@is-hex ( str* -- f )

	&w
		LDAk chex INC ?&valid
			POP2 #00 JMP2r &valid
		INC2 LDAk ?&w
	POP2
	#01

JMP2r

@is-opcode ( string* -- f )

	DUP2 ;opcodes/brk scmp3 ?find-opcode/on-brk

@find-opcode ( name* -- byte )

	STH2
	#2000
	&l
		#00 OVR #03 MUL ;opcodes ADD2 STH2kr scmp3 ?&on-found
		INC GTHk ?&l
	POP2 POP2r #00

JMP2r
	&on-found
		NIP ( LITk ) DUP #00 EQU #70 SFT ADD
		STH2r #0003 ADD2 find-modes ADD JMP2r
	&on-brk POP2 #01 JMP2r

@find-modes ( mode* -- byte )

	LITr 00
	&w
		LDAk #20
		OVR LIT "2 EQU ?&end DUP ADD
		OVR LIT "r EQU ?&end DUP ADD
		OVR LIT "k EQU ?&end DUP ADD
		OVR #21 LTH ?&end
			;token ;err/mode !on-error
		&end NIP STH ORAr
		INC2 LDAk ?&w
	POP2 STHr

JMP2r

@find-label ( name* -- <addr*> )

	STH2
	[ LIT2 &symbols $2 ]
	&w
		#0003 ADD2 DUP2 STH2kr scmp ?&found
		scap INC2 INC2k INC2 INC2 LDA ?&w
	POP2
	POP2r
	#ffff

JMP2r
	&found #0003 SUB2 POP2r JMP2r

@move-head ( -- )

	;write/head LDA2 INC2

@set-head ( v* -- )

	;write/head STA2

JMP2r

(
@|stdlib )

@sclr ( str* -- ) LDAk ?&w POP2 JMP2r &w STH2k #00 STH2r STA INC2 LDAk ?&w POP2 JMP2r
@scmp3 ( a* b* -- f ) LDA2k ROT2 LDA2k ROT2 EQU2 STH INC2 LDA2 SWP2 INC2 LDA2 EQU2 STHr AND JMP2r

@pdec ( short* -- )

	#00 ,&z STR
	#2710 pdec/parse
	#03e8 pdec/parse
	#0064 pdec/parse
	#000a pdec/parse
	NIP #30 ADD #18 DEO

JMP2r

&parse ( short* den* -- short* )

	DIV2k DUPk [ LIT &z $1 ] EQU ?&skip
	DUP #30 ADD #18 DEO #ff ,&z STR
	&skip POP MUL2 SUB2

JMP2r

(
@|assets )

@runes
	"| =lib/padabs "$ =lib/padrel
	"@ =lib/toplab "& =lib/sublab
	", =lib/litrel "_ =lib/rawrel
	". =lib/litzep "- =lib/rawzep
	"; =lib/litabs "= =lib/rawabs
	"? =lib/litjci "! =lib/litjmi
	"[ =lib/ignore "] =lib/ignore
	"# =lib/lithex "" =lib/rawstr
	"~ =lib/inc
	&err

(
@|memory )

@token $20
@scope $20
@sublabel $20
@include $30

~src/manifest.tal


M src/assets.tal => src/assets.tal +38 -0
@@ 12,6 12,7 @@
	&delete "Delete $1
	&clone "Clone $1
	&open "Open $1
	&assemble "Assemble $1
	&ok "OK $1
	&red "Red $1
	&green "Green $1


@@ 21,6 22,7 @@
	&pcm-ext ".pcm $1
	&rom-ext ".rom $1
	&uf2-ext ".uf2 $1
	&tal-ext ".tal $1
	&home-ext ". $1
	&parent-ext ".. $1
	&snarf-ext ".snarf $1


@@ 35,6 37,36 @@
		"Jul $1 "Aug $1 "Sep $1 "Oct $1 "Nov $1 "Dec $1
	&err-space "Space 20 "Unavailable $1
	&no-metadata "Metadata 20 "Missing $1
	( assembler )
	&asm-input "Input(.tal): 20 $1
	&asm-output "Output(.rom): 20 $1
	&asm-assembled "Assembled 20 $1
	&asm-reset "INIT $1
	&asm-spacer 20 "-> 20 $1
	&asm-in ", 20 "in 20 $1
	&asm-bytes 20 "bytes( $1
	&asm-end ") &asm-dot ". 0a $1
	&asm-labels 20 "labels $1
	&asm-unused "-- 20 "Unused 20 "label: 20 $1
	&asm-sym-ext ".sym $1


@err "!! 20 "Error: 20 $1
	&source "Source $1
	&duplicate "Duplicate  $1
	&number "Number $1
	&reference "Reference $1
	&distance "Distance $1
	&invalid "Invalid $1
	&mode "Mode $1
	&rewind "Rewind $1

@opcodes
	"LIT "INC "POP "NIP "SWP "ROT "DUP "OVR
	"EQU "NEQ "GTH "LTH "JMP "JCN "JSR "STH
	"LDZ "STZ "LDR "STR "LDA "STA "DEI "DEO
	"ADD "SUB "MUL "DIV "AND "ORA "EOR "SFT
	&brk "BRK

( icn )



@@ 279,6 311,12 @@ ffff 7eff e7ff 00ff ffff ffff ffff ffff a0a0 a0a0 a0a0 60e0 f0f0 f0f0 f0f0 f0f0
	0301 0000 0000 0000 0703 0100 0000 0000
	ffff 7e00 0000 0000 ffff ff7e 0000 0000
	c080 0000 0000 0000 e0c0 8000 0000 0000
	&source
	0000 0101 0f0f 0f00 0001 020e 1010 101f 0000 8181 ffff ff00 0081 427e 0000 00ff 
	0000 8080 f0f0 f000 0080 4070 0808 08f8 0f0f 0f0f 0f0f 0f0f 1f1f 1f1f 1f1f 1f1f 
	ffff 7eff e7ff ffff ffff ffff ffff ffff f0f0 f0f0 f0f0 f0f0 f8f8 f8f8 f8f8 f8f8 
	0f00 0000 0000 0000 1f0f 0000 0000 0000 ff00 0000 0000 0000 ffff 0000 0000 0000 
	f000 0000 0000 0000 f8f0 0000 0000 0000
@frame1-chr
	( e ) 0000 0000 070f 0f0f 0000 0007 0f1f 1f1f
	( h ) 0000 0000 ffff ffff 0000 00ff ffff ffff

M src/desktop.tal => src/desktop.tal +2 -1
@@ 7,11 7,12 @@
		01 "t =open-tile "Wallpaper $1
		01 "k =open-color "Theme $1
		01 "q =exit "Exit $1
	04 "File $1
	05 "File $1
		01 "n =file-create "Create $1
		01 "r =file-rename "Rename $1
		01 "d =file-clone "Clone $1
		01 08 =file-delete "Delete $1
		00 00 =file-assemble "Assemble $1
	05 "Open $1
		05 "D =open-as-meta "As 20 "Meta $1
		05 "T =open-as-text "As 20 "Text $1

M src/potato.tal => src/potato.tal +24 -0
@@ 305,6 305,28 @@ JMP2r

JMP2r

@file-assemble ( -- )

	;dict/assemble get-sel-file
		DUP2 is-file-locked ?&err
		#0005 ADD2
			DUP2 ,&target STR2
			;&callback !add-form

( .. )
	&err #0005 ADD2 !add-err

&callback ( -- )

	( src* ) [ LIT2 &target $2 ] make-src
	( dst* ) ;buf/form make-dst
	( buffer ) mem-ptr
		assemble

JMP2r

( .. )

( open a file )

@open-file ( file* -- )


@@ 827,6 849,7 @@ JMP2r
	DUP2 #0005 ADD2 ;dict/chr-ext has-ext ?&picture
	DUP2 #0005 ADD2 ;dict/icn-ext has-ext ?&picture
	DUP2 #0005 ADD2 ;dict/pcm-ext has-ext ?&sound
	DUP2 #0005 ADD2 ;dict/tal-ext has-ext ?&source
	DUP2 #0005 ADD2 ;dict/uf2-ext has-ext ?&font
	POP2 ;icons/text !draw-icon



@@ 836,6 859,7 @@ JMP2r
	&picture POP2 ;icons/picture !draw-icon
	&sound POP2 ;icons/sound !draw-icon
	&font POP2 ;icons/font !draw-icon
	&source POP2 ;icons/source !draw-icon

@draw-item-text ( file* id -- file* )