~rabbits/catclock

5dc06418abf63fcb6493c9e8d27b75dbbaed00b2 — Devine Lu Linvega 3 months ago eb9067e
LIT2 opt
1 files changed, 46 insertions(+), 47 deletions(-)

M src/catclock.tal
M src/catclock.tal => src/catclock.tal +46 -47
@@ 43,23 43,23 @@

	( init )
	#05 .timer/frame STZ
	;clear-screen JSR2
	clear-screen
	.center/y LDZ2 #0050 SUB2 .Screen/y DEO2
	#08 ;spritesheet/head ;draw-body JSR2
	#08 ;spritesheet/head draw-body

@on-frame ( -> )

	( once per second )
	.DateTime/second DEI
	DUP .timer/last LDZ EQU ,&same-sec JCN
		;make-needles JSR2
		;draw-needles JSR2
	DUP .timer/last LDZ EQU ?&same-sec
		make-needles
		draw-needles
		DUP .timer/last STZ
		&same-sec
	POP
	( every 5th frame )
	.timer/frame LDZ #05 NEQ ,&no-anim JCN
		.timer/anim LDZ ;draw-animation JSR2
	.timer/frame LDZ #05 NEQ ?&no-anim
		.timer/anim LDZ draw-animation
		.timer/anim LDZk INC #0f AND SWP STZ
		#00 .timer/frame STZ
		&no-anim


@@ 83,12 83,12 @@ BRK
@make-needles ( -- )

	[ #00 .DateTime/second DEI ] DUP2 ADD2 ;sin60 ADD2 LDA2
		#0090 ,circle JSR .needles/sx STZ2 .needles/sy STZ2
		#0090 circle .needles/sx STZ2 .needles/sy STZ2
	[ #00 .DateTime/minute DEI ] DUP2 ADD2 ;sin60 ADD2 LDA2
		#0090 ,circle JSR .needles/mx STZ2 .needles/my STZ2
		#0090 circle .needles/mx STZ2 .needles/my STZ2
	[ #00 .DateTime/hour DEI #0c ( mod ) DIVk MUL SUB #20 SFTk NIP ADD ]
	[ #00 .DateTime/minute DEI #0f DIV ADD2 ] DUP2 ADD2 ;sin60 ADD2 LDA2
		#00b0 ,circle JSR .needles/hx STZ2 .needles/hy STZ2
		#00b0 circle .needles/hx STZ2 .needles/hy STZ2

JMP2r



@@ 105,19 105,19 @@ JMP2r
@draw-animation ( state -- )

	DUP STHk
	#04 .Screen/auto DEO
	[ LIT2 04 -Screen/auto ] DEO
	( eyes )
	( reverse ) DUP #08 LTH ,&no-rev JCN #0f SWP SUB &no-rev
	( reverse ) DUP #08 LTH ?&no-rev #0f SWP SUB &no-rev
	#0c MUL #00 SWP #30 SFT2 ;spritesheet/eyes ADD2 .Screen/addr DEO2
	#0c00
	&loop-eyes
		DUP #06 ( mod ) DIVk MUL SUB #00 SWP #30 SFT2 .center/x LDZ2 #0018 SUB2 ADD2 .Screen/x DEO2
		DUP #06 DIV #00 SWP #30 SFT2 .center/y LDZ2 #0030 SUB2 ADD2 .Screen/y DEO2
		#01 .Screen/sprite DEO
		INC GTHk ,&loop-eyes JCN
		[ LIT2 01 -Screen/sprite ] DEO
		INC GTHk ?&loop-eyes
	POP2

	STHr #07 GTH ,&tail-reverse JCN
	STHr #07 GTH ?&tail-reverse

	( tail )



@@ 127,8 127,8 @@ JMP2r
		#00 OVRk
			( x ) #03 AND #30 SFT2 .center/x LDZ2 ADD2 #0010 SUB2 .Screen/x DEO2
			( y ) #32 SFT2 .center/y LDZ2 ADD2 #0015 ADD2 .Screen/y DEO2
		#04 .Screen/sprite DEO
		INC GTHk ,&loop-tail JCN
		[ LIT2 04 -Screen/sprite ] DEO
		INC GTHk ?&loop-tail
	POP2

JMP2r


@@ 141,8 141,8 @@ JMP2r
		#00 OVRk
			( x ) #03 AND [ #04 SWP SUB ] #30 SFT2 .center/x LDZ2 ADD2 #0018 SUB2 .Screen/x DEO2
			( y ) #32 SFT2 .center/y LDZ2 ADD2 #0015 ADD2 .Screen/y DEO2
		#14 .Screen/sprite DEO
		INC GTHk ,&loop-tail-reverse JCN
		[ LIT2 14 -Screen/sprite ] DEO
		INC GTHk ?&loop-tail-reverse
	POP2

JMP2r


@@ 150,59 150,58 @@ JMP2r
@draw-needles ( mask -- )

	.center/y LDZ2 #0010 SUB2 .Screen/y DEO2
	#05 ;spritesheet/body ;draw-body JSR2
	#05 ;spritesheet/body draw-body
	( draw )
	#00 .Screen/auto DEO
	[ LIT2 00 -Screen/auto ] DEO
	.center/x LDZ2 .center/y LDZ2
		OVR2 OVR2 .needles/sx LDZ2 .needles/sy LDZ2 #02 ,draw-line JSR
		OVR2 OVR2 .needles/mx LDZ2 .needles/my LDZ2 #00 ,draw-line JSR
		OVR2 OVR2 .needles/hx LDZ2 .needles/hy LDZ2 #00 ,draw-line JSR
		OVR2 OVR2 .needles/sx LDZ2 .needles/sy LDZ2 #02 draw-line
		OVR2 OVR2 .needles/mx LDZ2 .needles/my LDZ2 #00 draw-line
		OVR2 OVR2 .needles/hx LDZ2 .needles/hy LDZ2 #00 draw-line
	( middle )
	#0001 SUB2 .Screen/y DEO2
	#0001 SUB2 .Screen/x DEO2
	;middle-icn .Screen/addr DEO2
	#0a .Screen/sprite DEO
	[ LIT2 0a -Screen/sprite ] DEO

JMP2r

@draw-body ( height addr* -- )

	#76 .Screen/auto DEO
	[ LIT2 76 -Screen/auto ] DEO
	.center/x LDZ2 #0020 SUB2 .Screen/x DEO2
	.Screen/addr DEO2
	#00
	&ver
		#04 .Screen/sprite DEO
		INC GTHk ,&ver JCN
		[ LIT2 04 -Screen/sprite ] DEO
		INC GTHk ?&ver
	POP2

JMP2r

@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
	( load ) ,&color STR ,&y STR2 ,&x STR2 .line/y STZ2 .line/x STZ2
	,&x LDR2 .line/x LDZ2 SUB2 abs2 .line/dx STZ2
	#0000 ,&y LDR2 .line/y LDZ2 SUB2 abs2 SUB2 .line/dy STZ2
	#ffff #00 .line/x LDZ2 ,&x LDR2 lts2 DUP2 ADD2 ADD2 ,&sx STR2
	#ffff #00 .line/y LDZ2 ,&y LDR2 lts2 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
			[ LIT2 &color $1 -Screen/pixel ] DEO
			AND ?&end
		.line/e1 LDZ2 DUP2 ADD2 DUP2
		.line/dy LDZ2 ;lts2 JSR2 ,&skipy JCN
		.line/dy LDZ2 lts2 ?&skipy
			.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/dx LDZ2 gts2 ?&skipx
			.line/e1 LDZ2 .line/dx LDZ2 ADD2 .line/e1 STZ2
			.line/y LDZ2 [ LIT2 &sy $2 ] ADD2 .line/y STZ2
		&skipx
		,&loop JMP
		!&loop
	&end
	POPr

JMP2r



@@ 212,17 211,17 @@ JMP2r
	.Screen/height DEI2 #02 SFT2 NIP ,&y STR
	;fill-icn .Screen/addr DEO2
	#0000 DUP2 .Screen/x DEO2 .Screen/y DEO2
	#11 .Screen/auto DEO
	[ LIT2 11 -Screen/auto ] DEO
	[ LIT &y $1 ] #00
	&v
		[ LIT &x $1 ] #00
		&h
			#01 .Screen/sprite DEO
			INC GTHk ,&h JCN
			[ LIT2 01 -Screen/sprite ] DEO
			INC GTHk ?&h
		POP2
		#0000 .Screen/x DEO2
		.Screen/y DEI2k #0010 ADD2 ROT DEO2
		INC GTHk ,&v JCN
		INC GTHk ?&v
	POP2

JMP2r


@@ 410,9 409,9 @@ JMP2r
	0000 0000 0000 0000 0000 0000 0000 0000

@appicon ( 3x3 )
0000 0000 0000 0000 1f7f 7fff ffff ffff 0000 0000 0000 0000 ffff ffff ffff ffff 
0000 0000 0000 0000 f8fe feff ffff ffff 0000 0000 0000 0000 ffff ffff ffff ffff 
0018 0018 0099 6600 ffff ffff ffff ffff 0000 0000 0000 0000 ffff ffff ffff ffff 
0000 0000 0000 0000 ffff ffff ff7f 7f1f 0000 0000 0000 0000 ffff ffff ffff ffff 
0000 0000 0000 0000 1f7f 7fff ffff ffff 0000 0000 0000 0000 ffff ffff ffff ffff
0000 0000 0000 0000 f8fe feff ffff ffff 0000 0000 0000 0000 ffff ffff ffff ffff
0018 0018 0099 6600 ffff ffff ffff ffff 0000 0000 0000 0000 ffff ffff ffff ffff
0000 0000 0000 0000 ffff ffff ff7f 7f1f 0000 0000 0000 0000 ffff ffff ffff ffff
0000 0000 0000 0000 ffff ffff fffe fef8