~rabbits/adelie

23cd3e9c073ebc11a6a1ebf05bdaada50c686091 — neauoire 1 year, 4 months ago fe5a56c
Make use of lambdas
1 files changed, 31 insertions(+), 49 deletions(-)

M src/adelie.tal
M src/adelie.tal => src/adelie.tal +31 -49
@@ 68,33 68,25 @@
@on-frame ( -> )
	( | animate )
	[ LIT &rate $1 ] INCk ,&rate STR
	#01 AND ?&>no-fade
		<animate-theme> &>no-fade
	#01 AND ?{ <animate-theme> }
	[ LIT &wait $1 ] DUP ?&on-timer
	[ LIT &f $1 ] INCk ,&f STR
	#3f AND ?&>no-watch
		<draw-interface> &>no-watch
	#3f AND ?{ <draw-interface> }
	POP BRK
	&on-timer ( time -> )
		#01 SUB DUP ,&wait STR
		?&>no-null
			next-slide &>no-null
		?{ next-slide }
		BRK

@on-button ( -> )
	.Controller/button DEI DUP #00 EQU ?&>no-button
	DUP #01 NEQ ?&>no-a
		next-slide &>no-a
	DUP #02 NEQ ?&>no-b
		prev-slide &>no-b
	DUP #04 NEQ ?&>no-s
		toggle-interface &>no-s
	DUP #08 NEQ ?&>no-S
		restart &>no-S
	DUP #40 NEQ ?&>no-l
		prev-slide &>no-l
	DUP #80 NEQ ?&>no-r
		next-slide &>no-r &>no-button
	.Controller/button DEI DUP #00 EQU ?{
		DUP #01 NEQ ?{ next-slide }
		DUP #02 NEQ ?{ prev-slide }
		DUP #04 NEQ ?{ toggle-interface }
		DUP #08 NEQ ?{ restart }
		DUP #40 NEQ ?{ prev-slide }
		DUP #80 NEQ ?{ next-slide }
		}
	POP BRK

@on-mouse ( -> )


@@ 150,8 142,7 @@
	( | replace 0a with 00 )
	#00 ;slides
	&w ( -- )
		LDAk #0a NEQ ?&>no-lb
			STAk &>no-lb
		LDAk #0a NEQ ?{ STAk }
		INC2 LDAk ?&w
	POP2 POP JMP2r
	&err-limit ( size* -> )


@@ 222,9 213,8 @@
	,&t STR2
	.eof LDZ2 ;slides
	&w ( -- )
		;dict/name OVR2 sseg #00 EQU ?&>no-name
			DUP2 next-word [ LIT2 &t $2 ] scmp ?&found
			&>no-name
		;dict/name OVR2 sseg #00 EQU ?{
			DUP2 next-word [ LIT2 &t $2 ] scmp ?&found }
		scap INC2 GTH2k ?&w
	POP2 POP2 .slide LDZ2 JMP2r
	&found ( eof* slides* -- )


@@ 276,9 266,7 @@
@find-op ( addr* -- cmd )
	STH2 #1000
	&l ( -- )
		#00 OVRk ADD2 ;op-tbl ADD2 LDA2 STH2kr sseg #01 NEQ ?&>continue
			NIP !&end
			&>continue
		#00 OVRk ADD2 ;op-tbl ADD2 LDA2 STH2kr sseg #01 NEQ ?{ NIP !&end }
		INC GTHk ?&l
	POP2 #00 &end POP2r #00 SWP DUP2 ADD2 ;fnc-tbl ADD2 LDA2 JMP2r



@@ 294,9 282,7 @@
		POP2 POP2 POPr #00 JMP2r

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


@@ 321,8 307,7 @@
	( | print speaker's notes )
	.eof LDZ2 OVR2
	&w ( -- )
		LDAk #09 NEQ ?&>no-tab
			DUP2 <print-line> &>no-tab
		LDAk #09 NEQ ?{ DUP2 <print-line> }
		;dict/name OVR2 sseg ?&end
		scap INC2 GTH2k ?&w
	&end POP2 POP2 #0a18 DEO


@@ 352,9 337,9 @@
@op-goto ( addr* -- addr* )
	[ LIT2 00 -pen/auto ] STZ
	next-word
	( set auto ) DUP2 ;&auto-txt scmp #00 EQU ?&>no-auto
	( set auto ) DUP2 ;&auto-txt scmp #00 EQU ?{
		[ LIT2 01 -pen/auto ] STZ
		JMP2r &>no-auto
		JMP2r }
	DUP2 shex #00 SWP #30 SFT2 .pen/x STZ2
	#0003 ADD2 DUP2 shex #00 SWP #30 SFT2 .pen/y STZ2
	JMP2r


@@ 480,8 465,7 @@
	JMP2r

@<draw-interface>
	.interface LDZ ?&>continue
		JMP2r &>continue
	.interface LDZ ?{ JMP2r }
	( | clear )
	#0000 .Screen/x DEO2
	#0030 .Screen/y DEO2


@@ 531,10 515,9 @@
	[ LIT2 15 -Screen/auto ] DEO
	&w ( -- )
		( | tab )
		LDAk #09 NEQ ?&>no-tab
		LDAk #09 NEQ ?{
			.Screen/x DEI2 #0080 ADD2 #77 SFT2 .Screen/x DEO2
			!&resume
		&>no-tab
			!&resume }
		( draw ) LDAk <draw-uf2-char>
		&resume INC2 LDAk ?&w
	POP2 JMP2r


@@ 550,11 533,10 @@
	.pen/mode LDZ ,&color STR
	[ LIT2 45 -Screen/auto ] DEO
	&w ( -- )
			( | tab )
		LDAk #09 NEQ ?&>no-tab
		( | tab )
		LDAk #09 NEQ ?{
			.Screen/x DEI2 #0080 ADD2 #77 SFT2 .Screen/x DEO2
			!&resume
		&>no-tab
			!&resume }
		( draw ) LDAk #20 SUB #00 SWP DUP2 #00c8 MUL2 ;font-uf5/glyphs ADD2 .Screen/addr DEO2
		;font-uf5 ADD2 LDA #00 SWP .Screen/x DEI2 ADD2 [ LIT &color $1 ] .Screen/sprite DEOk
		DEOk


@@ 596,9 578,9 @@
	( ) ,&h STR
	( ) ,&w STR
	( | is pos auto )
	.pen/auto LDZ #00 EQU ?&>no-auto
	.pen/auto LDZ #00 EQU ?{
		.center/x LDZ2 #00 ,&w LDR #30 SFT2 #01 SFT2 SUB2 .Screen/x DEO2
		.center/y LDZ2 #00 ,&h LDR #30 SFT2 #01 SFT2 SUB2 .Screen/y DEO2 &>no-auto
		.center/y LDZ2 #00 ,&h LDR #30 SFT2 #01 SFT2 SUB2 .Screen/y DEO2 }
	( | anchor )
	.Screen/x DEI2 ,&anchor STR2
	[ LIT2 00 &h $1 ] SUB


@@ 643,8 625,8 @@
@|stdlib )

@abs2 ( a* -- f )
	DUP2 #0f SFT2 EQU ?&end
	#0000 SWP2 SUB2 &end JMP2r
	DUP2 #0f SFT2 EQU ?{ #0000 SWP2 SUB2 }
	JMP2r

@lts2 ( a* b* -- f )
	#8000 STH2k ADD2 SWP2 STH2r ADD2 GTH2 JMP2r


@@ 715,9 697,9 @@
@<print-dec> ( short* -- )
	#2710 [ LIT2r 00fb ]
	&w ( -- )
		DIV2k #000a DIV2k MUL2 SUB2 SWPr EQUk OVR STHkr EQU AND ?&>skip
		DIV2k #000a DIV2k MUL2 SUB2 SWPr EQUk OVR STHkr EQU AND ?{
			DUP LIT "0 ADD #18 DEO
			INCr &>skip
			INCr }
		POP2 #000a DIV2 SWPr INCr STHkr ?&w
	POP2r POP2 POP2 JMP2r