uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

timer.tal (1886B)


      1 ( uxnemu timer.rom )
      2 
      3 |00 @System &vector $2 &expansion $2 &wst $1 &rst $1 &metadata $2 &r $2 &g $2 &b $2 &debug $1 &state $1
      4 |20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
      5 |80 @Controller &vector $2 &button $1 &key $1
      6 |c0 @DateTime &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1
      7 |100
      8 
      9 @on-reset ( -> )
     10 	;on-control .Controller/vector DEO2
     11 	#0080 DUP2 .Screen/width DEO2
     12 	.Screen/height DEO2
     13 	#f074 DUP2 .System/r DEO2
     14 	DUP2 .System/g DEO2
     15 	.System/b DEO2
     16 	Timer/start BRK
     17 
     18 @on-control ( -> )
     19 	.Controller/button DEI
     20 	( A ) DUP #01 NEQ ?{ Timer/pause }
     21 	( B ) DUP #02 NEQ ?{ Timer/start }
     22 	POP BRK
     23 
     24 (
     25 @|Objects )
     26 
     27 @Timer ( * )
     28 	&on-frame ( -> )
     29 		[ LIT &paused $1 ] ?{
     30 			[ LIT2 3c &frame 00 ] INCk ,&frame STR
     31 			EQU ?&on-second }
     32 		BRK
     33 	&on-second ( -> )
     34 		[ LIT2 00 _&frame ] STR
     35 		[ LIT2 ff &time $1 ] ADD DUP ?{ /end }
     36 		,&time STR
     37 		/<draw> BRK
     38 	&start ( -- )
     39 		[ LIT2 0f _&time ] STR
     40 		[ LIT2 00 _&paused ] STR
     41 		[ LIT2 0f _&frame ] STR
     42 		;&on-frame .Screen/vector DEO2
     43 		!&<draw>
     44 	&pause ( -- )
     45 		[ LIT2 00 _&paused ] LDR EQU
     46 		( ) INCk <set-dec-color>
     47 		,&paused STR
     48 		!&<draw>
     49 	&end ( -- )
     50 		#0000 .Screen/vector DEO2
     51 		#06 <set-dec-color>
     52 		!&<draw>
     53 	&<draw> ( -- )
     54 		,&time LDR !<draw-dec>
     55 
     56 (
     57 @|drawing )
     58 
     59 @<set-dec-color> ( color --  )
     60 	;<draw-num>/color STA
     61 	JMP2r
     62 
     63 @<draw-dec> ( dec -- )
     64 	#0010 DUP2 .Screen/x DEO2
     65 	.Screen/y DEO2
     66 	[ LIT2 01 -Screen/auto ] DEO
     67 	DUP
     68 	( x0 ) #0a DIV <draw-num>
     69 	( 0x ) #0a DIVk MUL SUB
     70 	( >> )
     71 
     72 @<draw-num> ( num -- )
     73 	#00 SWP #30 SFT2 ;numbers-icns ADD2 .Screen/addr DEO2
     74 	[ LIT2 &color 01 -Screen/sprite ] DEO
     75 	JMP2r
     76 
     77 @numbers-icns [
     78 	38c6 c6c6 c6c6 c638 8c78 1818 1818 187e
     79 	3c4e 860e 1c38 72fe 807e 0c10 7c0e 8e7c
     80 	0e1c 1c3c 6cff 0c1e c6f8 40c0 fc0e ce7c
     81 	3ac4 c0c0 fcce ce7c 807e 3e0c 1830 60c0
     82 	807c cece 7cce ce7c 807c cece 7c18 3060 ]
     83