uxn

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

button.tal (2473B)


      1 |00 @System &vector $2 &expansion $2 &wst $1 &rst $1 &metadata $2 &r $2 &g $2 &b $2 &debug $1 &state $1
      2 |20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
      3 |80 @Controller &vector $2 &button $1 &key $1
      4 |90 @Mouse &vector $2 &x $2 &y $2 &state $1 &chord $1 &pad $4 &scrolly &scrolly-hb $1 &scrolly-lb $1
      5 
      6 |0100
      7 
      8 @on-reset ( -> )
      9 	#5c0f .System/r DEO2
     10 	#6d0f .System/g DEO2
     11 	#6d0f .System/b DEO2
     12 	#0038 DUP2 .Screen/width DEO2
     13 	.Screen/height DEO2
     14 	;on-mouse .Mouse/vector DEO2
     15 	;button-chr <draw-button>
     16 	BRK
     17 
     18 @on-frame ( -> )
     19 	[ LIT2 18 &time 00 ] INCk ,&time STR
     20 	EQU ?{ BRK }
     21 	#0000 .Screen/vector DEO2
     22 	;button-chr/up <draw-button>
     23 	[ LIT2 "! 18 ] DEO
     24 	BRK
     25 
     26 @on-mouse ( -> )
     27 	[ LIT2 00 -Mouse/state ] DEI NEQ #42 ADD ;pointer-icn <update-pointer>
     28 	.Mouse/state DEI ?{ BRK }
     29 	.Mouse/x DEI2 .Mouse/y DEI2 within-button ?{ BRK }
     30 	;button-chr/down <draw-button>
     31 	;on-frame .Screen/vector DEO2
     32 	#10 ;on-frame/time STA
     33 	[ LIT2 00 -Mouse/state ] DEO
     34 	BRK
     35 
     36 @within-button ( x* y* -- f )
     37 	#0010 SUB2 #0018 LTH2 STH
     38 	#0010 SUB2 #0018 LTH2 STHr AND JMP2r
     39 
     40 (
     41 @|drawing )
     42 
     43 @<draw-button> ( addr* -- )
     44 	[ LIT2 26 -Screen/auto ] DEO
     45 	#0010 DUP2 .Screen/x DEO2
     46 	.Screen/y DEO2
     47 	.Screen/addr DEO2
     48 	[ LIT2 81 -Screen/sprite ] DEOk DEOk DEO
     49 	JMP2r
     50 
     51 @<update-pointer> ( color addr* -- )
     52 	[ LIT2 00 -Screen/auto ] DEO
     53 	;fill-icn .Screen/addr DEO2
     54 	#40 <draw-pointer>
     55 	.Mouse/x DEI2 ,<draw-pointer>/x STR2
     56 	.Mouse/y DEI2 ,<draw-pointer>/y STR2
     57 	.Screen/addr DEO2
     58 
     59 @<draw-pointer> ( color -- )
     60 	[ LIT2 &x $2 ] .Screen/x DEO2
     61 	[ LIT2 &y $2 ] .Screen/y DEO2
     62 	.Screen/sprite DEO
     63 	JMP2r
     64 
     65 (
     66 @|assets )
     67 
     68 @fill-icn [ ffff ffff ffff ffff ]
     69 
     70 @pointer-icn [ 80c0 e0f0 f8e0 1000 ]
     71 
     72 @button-chr 
     73 &up [
     74 	0000 1f3f 3f3f 3f3f 001f 3f7f 7f7f 7f7f
     75 	0000 ffff ffff ffff 00ff ffff ffff ffff
     76 	0000 f8fc fcfc fcfc 00f8 fcfe fefe fefe
     77 	3f3f 3f3f 3f3f 3f3f 7f7f 7f7f 7f7f 7f7f
     78 	e7e7 e781 c3e7 ffff ffff ffff ffff ffff
     79 	fcfc fcfc fcfc fcfc fefe fefe fefe fefe
     80 	3f3f 3f3f 3f1f 0000 7f7f 7f5f 4020 1f00
     81 	ffff ffff ffff 0000 ffff ffff 0000 ff00
     82 	fcfc fcfc fcf8 0000 fefe fefa 0204 f800 ] 
     83 &down [
     84 	0000 001f 3f3f 3f3f 0000 1f3f 7f7f 7f7f
     85 	0000 00ff ffff ffff 0000 ffff ffff ffff
     86 	0000 00f8 fcfc fcfc 0000 f8fc fefe fefe
     87 	3f3f 3f3f 3f3f 3f3f 7f7f 7f7f 7f7f 7f7f
     88 	ffe7 e7e7 81c3 e7ff ffff ffff ffff ffff
     89 	fcfc fcfc fcfc fcfc fefe fefe fefe fefe
     90 	3f3f 3f3f 3f1f 0000 7f7f 7f7f 5f20 1f00
     91 	ffff ffff ffff 0000 ffff ffff ff00 ff00
     92 	fcfc fcfc fcf8 0000 fefe fefe fa04 f800 ]
     93