~rabbits/adelie

b81876b7219e2a9a6c23663d1f19b1b4d85fd2e7 — Devine Lu Linvega 11 months ago df1d33e
Catch missing pictures
2 files changed, 29 insertions(+), 13 deletions(-)

M src/adelie.tal
M src/tga.tal
M src/adelie.tal => src/adelie.tal +27 -11
@@ 10,7 10,6 @@

(
@|TODO )
	( > catch missing icn file )
	( > display next slide title in speaker's notes )

|0000


@@ 32,7 31,7 @@
	( | startup )
	;&await-src .Console/vector DEO2
	.Console/type DEI ?&>has-arg
		;dict/usage <sprint>
		;dict/usage <print-str>
		#010f DEO &>has-arg
	BRK
	&await-src ( -> )


@@ 145,11 144,11 @@
	;slides .File/read DEO2
	( | check size )
	.File/success DEI2 ORAk ?&>no-empty
		POP2 ;errors/file-max <sprint>
		POP2 ;errors/file-max <print-str>
		#010f DEO
		BRK &>no-empty
	DUP2 #8000 NEQ2 ?&>no-maxsize
		POP2 ;errors/empty <sprint>
		POP2 ;errors/empty <print-str>
		#010f DEO
		BRK &>no-maxsize
	;slides ADD2 .eof STZ2


@@ 291,7 290,7 @@

@add-link ( addr* -- )
	.links/length LDZ #08 NEQ ?&>continue
		;errors/links-max !<sprint>
		;errors/links-max !<print-str>
		&>continue
	;links/data #00 .links/length LDZ #0a MUL ADD2 #000a mcpy
	( + ) .links/length LDZ INC .links/length STZ


@@ 324,10 323,23 @@
@op-pict ( addr* -- addr* )
	.pen/x LDZ2 .Screen/x DEO2
	.pen/y LDZ2 .Screen/y DEO2
	next-word DUP2 wcap #0004 SUB2 ;&tga-ext scmp ?&tga
	next-word DUP2 file-exists #00 EQU ?&err
	DUP2 wcap #0004 SUB2 ;&tga-ext scmp ?&tga
	DUP2 !<draw-icn>
	&tga DUP2 !<draw-tga>
	&tga-ext ".tga $1
	&err ( addr* -- )
		;errors/file-missing <print-str>
		DUP2 <print-str>
		#0a18 DEO
		JMP2r

@file-exists ( name* -- f )
	.File/name DEO2
	#0001 .File/length DEO2
	;&b .File/read DEO2
	.File/success DEI2 ORA JMP2r
	&b $1

@op-goto ( addr* -- addr* )
	[ LIT2 00 -pen/auto ] STZ


@@ 586,10 598,13 @@
		;&buf .File/read DEO2
		.pen/mode LDZ .Screen/sprite DEO
		INC DUP ?&x
	POP .Screen/x DEI2k #00 ,&w LDR #30 SFT2 SUB2 ROT DEO2
	.Screen/y DEI2k #0008 ADD2 ROT DEO2
	POP
	( x = 0 ) .Screen/x DEI2k #00 ,&w LDR #30 SFT2 SUB2 ROT DEO2
	( y + 8 ) .Screen/y DEI2k #0008 ADD2 ROT DEO2
	INC DUP ?&y
	POP [ LIT2 00 -Screen/auto ] DEO
	POP
	( | end )
	[ LIT2 00 -Screen/auto ] DEO
	JMP2r
	&buf $8



@@ 706,7 721,7 @@
		#0f AND DUP #09 GTH #27 MUL ADD LIT "0 ADD #18 DEO
		JMP2r

@<sprint> ( str* -- )
@<print-str> ( str* -- )
	!&a
	&w ( -- )
		LDAk #18 DEO


@@ 714,7 729,7 @@
	POP2 JMP2r

@<print-line> ( str* -- )
	<sprint>
	<print-str>
	#0a18 DEO
	JMP2r



@@ 792,6 807,7 @@
@errors &empty "Slides 20 "File 20 "Missing 0a $1
	&links-max "Links 20 "Limit 20 "Exceeded 0a $1
	&file-max "File-size 20 "Limit 20 "Exceeded 0a $1
	&file-missing "!! 20 "File 20 "missing: 20 $1

@op-tbl
	[

M src/tga.tal => src/tga.tal +2 -2
@@ 31,8 31,8 @@
	( ) DUP #03 EQU ?&rawm
	POP
	( | error )
	;&error-txt <sprint>
	#00 ;tga/image-type LDA DUP ADD ;tga-types ADD2 LDA2 <sprint>
	;&error-txt <print-str>
	#00 ;tga/image-type LDA DUP ADD ;tga-types ADD2 LDA2 <print-str>
	#0a18 DEO
	JMP2r
	&rawt ( type -- )