uxn

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

hover.tal (2919B)


      1 ( GUI Hover )
      2 
      3 |00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
      4 |20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 ]
      5 |90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &wheel $1 ]
      6 
      7 ( variables )
      8 
      9 |0000
     10 
     11 @color $1
     12 @pointer [ &x $2 &y $2 &sprite $2 ]
     13 @r1 [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
     14 @r2 [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
     15 @r3 [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
     16 
     17 ( program )
     18 
     19 |0100
     20 
     21 	( theme ) 
     22 	#0f0f .System/r DEO2 
     23 	#0fff .System/g DEO2 
     24 	#0ff0 .System/b DEO2
     25 
     26 	( vectors ) ;on-mouse .Mouse/vector DEO2
     27 	
     28 	#0020 #0030 #0060 #0060 .r1/y2 STZ2 .r1/x2 STZ2 .r1/y1 STZ2 .r1/x1 STZ2
     29 	#0058 #0050 #0090 #0080 .r2/y2 STZ2 .r2/x2 STZ2 .r2/y1 STZ2 .r2/x1 STZ2
     30 	#0048 #0048 #0080 #0098 .r3/y2 STZ2 .r3/x2 STZ2 .r3/y1 STZ2 .r3/x1 STZ2
     31 
     32 ( no BRK, run through to on-mouse )
     33 
     34 @on-mouse
     35 	
     36 	;pointer_icn .pointer/sprite STZ2
     37 
     38 	#01 .color STZ
     39 	.Mouse/x DEI2 .Mouse/y DEI2 .r1 ;within-rect JSR2 #00 EQU ,&draw1 JCN 
     40 		#02 .color STZ 
     41 		;hand_icn .pointer/sprite STZ2
     42 		&draw1 
     43 	.r1/x1 LDZ2 .r1/y1 LDZ2 .r1/x2 LDZ2 .r1/y2 LDZ2 .color LDZ ;line-rect JSR2
     44 	
     45 	#01 .color STZ
     46 	.Mouse/x DEI2 .Mouse/y DEI2 .r2 ;within-rect JSR2 #00 EQU ,&draw2 JCN 
     47 		#03 .color STZ 
     48 		;hand_icn .pointer/sprite STZ2
     49 		&draw2 
     50 	.r2/x1 LDZ2 .r2/y1 LDZ2 .r2/x2 LDZ2 .r2/y2 LDZ2 .color LDZ ;line-rect JSR2
     51 	
     52 	#01 .color STZ
     53 	.Mouse/x DEI2 .Mouse/y DEI2 .r3 ;within-rect JSR2 #00 EQU ,&draw3 JCN 
     54 		#02 .color STZ 
     55 		;hand_icn .pointer/sprite STZ2
     56 		&draw3 
     57 	.r3/x1 LDZ2 .r3/y1 LDZ2 .r3/x2 LDZ2 .r3/y2 LDZ2 .color LDZ ;line-rect JSR2
     58 
     59 	( clear last cursor )
     60 	.pointer/x LDZ2 .Screen/x DEO2
     61 	.pointer/y LDZ2 .Screen/y DEO2
     62 	#40 .Screen/sprite DEO
     63 
     64 	( record pointer positions )
     65 	.Mouse/x DEI2 DUP2 .pointer/x STZ2 .Screen/x DEO2 
     66 	.Mouse/y DEI2 DUP2 .pointer/y STZ2 .Screen/y DEO2
     67 	.pointer/sprite LDZ2 .Screen/addr DEO2
     68 
     69 	( draw new cursor )
     70 	#41 .Screen/sprite DEO
     71 
     72 BRK
     73 
     74 @within-rect ( x* y* rect -- flag )
     75 	
     76 	STH
     77 	( y < rect.y1 ) DUP2 STHkr INC INC LDZ2 LTH2 ,&skip JCN
     78 	( y > rect.y2 ) DUP2 STHkr #06 ADD LDZ2 GTH2 ,&skip JCN
     79 	SWP2
     80 	( x < rect.x1 ) DUP2 STHkr LDZ2 LTH2 ,&skip JCN
     81 	( x > rect.x2 ) DUP2 STHkr #04 ADD LDZ2 GTH2 ,&skip JCN
     82 	POP2 POP2 POPr
     83 	#01 
     84 JMP2r
     85 	&skip
     86 	POP2 POP2 POPr
     87 	#00
     88 
     89 JMP2r
     90 
     91 @line-rect ( x1* y1* x2* y2* color -- )
     92 
     93 	STH
     94 	DUP2 ,&ver-y2 STR2 ,&hor-y2 STR2
     95 	DUP2 ,&ver-x2 STR2 ,&hor-x2 STR2
     96 	DUP2 ,&ver-y1 STR2 ,&hor-y1 STR2
     97 	DUP2 ,&ver-x1 STR2 ,&hor-x1 STR2
     98 	( horizontal )
     99 	[ LIT2 &hor-x2 $2 ] INC2 [ LIT2 &hor-x1 $2 ]
    100 	&hor
    101 		DUP2 .Screen/x DEO2
    102 		[ LIT2 &hor-y1 $2 ] .Screen/y DEO2 STHkr .Screen/pixel DEOk
    103 		[ LIT2 &hor-y2 $2 ] .Screen/y DEO2 DEO
    104 		INC2 GTH2k ,&hor JCN
    105 	POP2 POP2
    106 	( vertical )
    107 	[ LIT2 &ver-y2 $2 ] [ LIT2 &ver-y1 $2 ]
    108 	&ver
    109 		DUP2 .Screen/y DEO2
    110 		[ LIT2 &ver-x1 $2 ] .Screen/x DEO2 STHkr .Screen/pixel DEOk
    111 		[ LIT2 &ver-x2 $2 ] .Screen/x DEO2 DEO
    112 		INC2 GTH2k ,&ver JCN
    113 	POP2 POP2
    114 	POPr
    115 
    116 JMP2r
    117 
    118 @pointer_icn [ 80c0 e0f0 f8e0 1000 ]
    119 @hand_icn    [ 4040 4070 f8f8 f870 ]