uxn-utils/gui/teatime/teatime.tal

204 lines
4.3 KiB
Tal
Raw Normal View History

2024-07-24 13:40:14 -04:00
( teatimer )
|00 @System &vector $2 &expansion $2 &wst $1 &rst $1 &metadata $2 &r $2 &g $2 &b $2 &debug $1 &state $1
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
|80 @Controller &vector $2 &button $1 &key $1
2024-07-24 14:30:30 -04:00
|90 @Mouse &vector $2 &x $2 &y $1 &ylb $1 &state $1 &chord $1 &pad $4 &scrolly &scrolly-hb $1 &scrolly-lb $1
2024-07-24 13:40:14 -04:00
|c0 @DateTime &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1
2024-07-24 18:33:24 -04:00
2024-07-24 13:40:14 -04:00
|000
2024-07-24 17:18:32 -04:00
2024-07-24 18:33:24 -04:00
@timeleft $2
@height $2
2024-07-24 13:40:14 -04:00
2024-07-24 13:46:14 -04:00
|100
@on-reset ( -> )
2024-07-24 13:40:14 -04:00
( | meta )
;meta #06 DEO2
( | theme )
2024-07-24 17:18:32 -04:00
#f0f7 .System/r DEO2
2024-07-24 15:33:30 -04:00
#f0fc .System/g DEO2
2024-07-24 17:18:32 -04:00
#f0f8 .System/b DEO2
2024-07-24 13:40:14 -04:00
( | vector )
;on-frame .Screen/vector DEO2
;on-mouse .Mouse/vector DEO2
( | screen size )
2024-07-24 18:33:24 -04:00
#0078 .Screen/width DEO2
2024-07-24 14:30:30 -04:00
#0110 .Screen/height DEO2
<redraw>
2024-07-24 13:46:14 -04:00
BRK
2024-07-24 13:40:14 -04:00
2024-07-24 15:00:19 -04:00
@on-frame-freeze ( -> )
[ LIT &lock $1 ] INCk ,&lock STR
?{ ;on-frame .Screen/vector DEO2 }
2024-07-24 13:40:14 -04:00
BRK
2024-07-24 15:00:19 -04:00
@on-frame ( -> )
2024-07-24 18:33:24 -04:00
.timeleft LDZ2 ORAk ?{ POP2 BRK }
2024-07-24 15:00:19 -04:00
[ LIT2 40 &f $1 ] INCk ,&f STR
NEQ ?{
[ LIT2 00 _&f ] STR
2024-07-24 18:42:07 -04:00
#0001 SUB2 DUP2 <set-seconds>
ORAk ?{ <ring> } }
2024-07-24 15:00:19 -04:00
POP2 BRK
2024-07-24 13:40:14 -04:00
@on-mouse ( -> )
2024-07-24 14:30:30 -04:00
#4100 [ LIT2 00 -Mouse/state ] DEI NEQ #30 SFT2 ;hand-icn ADD2 <update-cursor>
.Mouse/state DEI ?{ BRK }
( | down )
2024-07-24 15:00:19 -04:00
<freeze-timer>
2024-07-24 17:29:27 -04:00
.Mouse/y DEI2 #0010 SUB2 DUP2 #00f0 GTH2 ?{ DUP2 #22 SFT2 <set-height> }
2024-07-24 15:33:30 -04:00
POP2 BRK
2024-07-24 13:40:14 -04:00
2024-07-24 13:46:14 -04:00
@meta 00
2024-07-24 17:18:32 -04:00
( name ) "Teatime 0a
( details ) "A 20 "Countdown 20 "Timer 0a
2024-07-24 13:46:14 -04:00
( author ) "By 20 "Dave 20 "Van 20 "Ee 0a
2024-07-24 17:18:32 -04:00
( date ) "24 20 "Jul 20 "2024 $1
2024-07-24 13:46:14 -04:00
( elements ) 00
2024-07-24 13:40:14 -04:00
2024-07-24 14:30:30 -04:00
(
@|core )
2024-07-24 18:42:07 -04:00
@<ring> ( -- )
( bell ) #0718 DEO
JMP2r
2024-07-24 15:00:19 -04:00
@<freeze-timer> ( -- )
;on-frame-freeze .Screen/vector DEO2
#c0 ;on-frame-freeze/lock STA
JMP2r
2024-07-24 15:33:30 -04:00
@<set-height> ( distance* -- )
2024-07-24 18:33:24 -04:00
#00f0 SWP2 SUB2 #02 SFT2 #000f MUL2
2024-07-24 15:02:59 -04:00
2024-07-24 15:33:30 -04:00
@<set-seconds> ( seconds* -- )
2024-07-24 18:33:24 -04:00
DUP2 .timeleft LDZ2 EQU2 ?{ .timeleft STZ2
2024-07-24 18:20:55 -04:00
<draw-remains> !<redraw-bar> }
2024-07-24 15:33:30 -04:00
POP2 JMP2r
2024-07-24 14:30:30 -04:00
2024-07-24 13:40:14 -04:00
(
@|drawing )
2024-07-24 13:46:14 -04:00
2024-07-24 14:30:30 -04:00
@<redraw> ( -- )
2024-07-24 14:48:24 -04:00
<redraw-bar>
2024-07-24 18:20:55 -04:00
<draw-labels>
2024-07-24 18:33:24 -04:00
( >> )
2024-07-24 14:30:30 -04:00
2024-07-24 17:18:32 -04:00
@<draw-markers> ( -- )
2024-07-24 18:33:24 -04:00
[ LIT2 00 -Screen/auto ] DEO
2024-07-24 17:29:27 -04:00
#00f1 #0000
2024-07-24 17:18:32 -04:00
&>l ( -- )
( | every 5th )
DUP #03 AND ?{
DUP2 #0009 ADD2 .Screen/y DEO2
#0030 .Screen/x DEO2
2024-07-24 17:29:27 -04:00
DUP #02 SFT #03 AND #00 EQU #00 SWP #30 SFT2 ;mark-icn ADD2 .Screen/addr DEO2
2024-07-24 18:33:24 -04:00
[ LIT2 05 -Screen/sprite ] DEO }
2024-07-24 17:18:32 -04:00
INC2 GTH2k ?&>l
POP2 POP2 JMP2r
2024-07-24 18:20:55 -04:00
@<draw-labels> ( -- )
#003c .Screen/x DEO2
#00a9 .Screen/y DEO2
;dict/min5 <draw-uf2>
#003c .Screen/x DEO2
#0059 .Screen/y DEO2
;dict/min10 <draw-uf2>
#003c .Screen/x DEO2
#000d .Screen/y DEO2
2024-07-24 18:33:24 -04:00
;dict/min15
( >> )
2024-07-24 18:20:55 -04:00
@<draw-uf2> ( addr* -- )
[ LIT2 15 -Screen/auto ] DEO
&>while ( -- )
LDAk <draw-char>
INC2 LDAk ?&>while
POP2 JMP2r
2024-07-24 18:33:24 -04:00
@<draw-remains> ( -- )
#003c .Screen/x DEO2
#00f5 .Screen/y DEO2
[ LIT2 15 -Screen/auto ] DEO
.timeleft LDZ2 ORAk ?{ POP2 ;dict/min0 !<draw-uf2> }
( | minutes )
( x0 ) DUP2 #0258 DIV2 NIP DUP #00 EQU ?{
DUP [ LIT "0 ] ADD <draw-char> }
POP
( 0x ) DUP2 #003c DIV2 NIP <draw-uf2-dec>
( : ) [ LIT ": ] <draw-char>
( | seconds )
( x0 ) DUP2 #003c DIV2k MUL2 SUB2 #000a DIV2 NIP <draw-uf2-dec>
( 0x ) #000a DIV2k MUL2 SUB2 NIP
( >> )
2024-07-24 18:26:22 -04:00
@<draw-uf2-dec> ( -- )
#0a DIVk MUL SUB [ LIT "0 ] ADD
( >> )
2024-07-24 18:20:55 -04:00
@<draw-char> ( char -- )
#20 SUB #00 SWP
( addr ) DUP2 #50 SFT2 ;font/glyphs ADD2 .Screen/addr DEO2
( move ) ;font ADD2 LDA #00 SWP .Screen/x DEI2 ADD2
( draw ) [ LIT2 01 -Screen/sprite ] DEOk DEO
.Screen/x DEO2
JMP2r
2024-07-24 14:30:30 -04:00
@<redraw-bar> ( -- )
2024-07-24 17:18:32 -04:00
;halftone-icn .Screen/addr DEO2
2024-07-24 14:30:30 -04:00
( | top )
#0010 .Screen/x DEO2
#0010 .Screen/y DEO2
[ LIT2 f1 -Screen/auto ] DEO
2024-07-24 17:18:32 -04:00
[ LIT2 01 -Screen/sprite ] DEOk DEOk DEOk DEO
2024-07-24 14:30:30 -04:00
( | bottom )
#0010 .Screen/x DEO2
#0090 .Screen/y DEO2
2024-07-24 17:29:27 -04:00
[ LIT2 d1 -Screen/auto ] DEO
2024-07-24 17:18:32 -04:00
[ LIT2 01 -Screen/sprite ] DEOk DEOk DEOk DEO
2024-07-24 14:30:30 -04:00
( >> )
@<draw-bar> ( -- )
2024-07-24 17:49:30 -04:00
( y2 ) .Screen/height DEI2 #0010 SUB2
2024-07-24 18:33:24 -04:00
( y1 ) #0100 .timeleft LDZ2 #000f DIV2 #20 SFT2 SUB2
2024-07-24 17:49:30 -04:00
( | paint )
2024-07-24 17:18:32 -04:00
[ LIT2 32 -Screen/auto ] DEO
;line-icn .Screen/addr DEO2
2024-07-24 14:30:30 -04:00
#0010 .Screen/x DEO2
2024-07-24 17:49:30 -04:00
( | fill )
[ LIT2r 05 -Screen/sprite ]
2024-07-24 14:30:30 -04:00
&>l ( -- )
DUP2 .Screen/y DEO2
DEOkr
INC2 GTH2k ?&>l
POP2 POP2 POP2r JMP2r
2024-07-24 13:40:14 -04:00
2024-07-24 14:30:30 -04:00
@<update-cursor> ( color addr* -- )
[ LIT2 00 -Screen/auto ] DEO
;fill-icn .Screen/addr DEO2
#40 <draw-cursor>
.Screen/addr DEO2
.Mouse/x DEI2 ,<draw-cursor>/x STR2
.Mouse/y DEI2 ,<draw-cursor>/y STR2
( >> )
@<draw-cursor> ( color -- )
[ LIT2 &x $2 ] .Screen/x DEO2
[ LIT2 &y $2 ] .Screen/y DEO2
.Screen/sprite DEO
JMP2r
2024-07-24 13:40:14 -04:00
(
@|assets )
2024-07-24 18:20:55 -04:00
@dict
&min0 "Done. $1
&min5 "5 20 "Min $1
&min10 "10 20 "Min $1
&min15 "15 20 "Min $1
2024-07-24 17:18:32 -04:00
~assets.tal
2024-07-24 13:46:14 -04:00