0
0
Fork 0
mirror of https://git.sr.ht/~rabbits/uxn synced 2024-11-27 08:13:01 +00:00
uxn/projects/examples/gui.hover.usm

103 lines
2.5 KiB
Text
Raw Normal View History

2021-03-01 03:49:53 +00:00
( draw routines )
2021-03-16 04:29:44 +00:00
%RTN { JMP2r }
2021-03-14 01:34:08 +00:00
;color { byte 1 }
;pointer { x 2 y 2 sprite 2 }
;rect { x1 2 y1 2 x2 2 y2 2 }
;r1 { x1 2 y1 2 x2 2 y2 2 }
;r2 { x1 2 y1 2 x2 2 y2 2 }
;r3 { x1 2 y1 2 x2 2 y2 2 }
2021-03-01 03:49:53 +00:00
|0100 @RESET
#0020 #0030 #0060 #0060 =r1.y2 =r1.x2 =r1.y1 =r1.x1
#0058 #0050 #0090 #0080 =r2.y2 =r2.x2 =r2.y1 =r2.x1
#0048 #0048 #0080 #0098 =r3.y2 =r3.x2 =r3.y1 =r3.x1
BRK
2021-03-14 01:34:08 +00:00
@FRAME
~pointer.x ~Mouse.x NEQU2
~pointer.y ~Mouse.y NEQU2
2021-03-01 03:49:53 +00:00
2021-03-14 01:34:08 +00:00
#0000 EQU2 BRK? ( Return if unchanged )
,pointer_icn =pointer.sprite
2021-03-01 03:49:53 +00:00
#01 =color
2021-03-01 16:55:16 +00:00
( matrix comparison )
2021-03-14 01:34:08 +00:00
~Mouse.x ~r1.x1 GTH2 ~Mouse.x ~r1.x2 LTH2 #0101 EQU2
~Mouse.y ~r1.y1 GTH2 ~Mouse.y ~r1.y2 LTH2 #0101 EQU2
2021-03-15 22:27:43 +00:00
#0101 NEQ2 ,$draw1 ROT JMP2? #02 =color ,hand_icn =pointer.sprite
2021-03-14 01:34:08 +00:00
$draw1 ~r1.x1 ~r1.y1 ~r1.x2 ~r1.y2 ~color ,line-rect JSR2
2021-03-01 03:49:53 +00:00
#01 =color
2021-03-01 16:55:16 +00:00
( 2-step comparison )
2021-03-15 22:27:43 +00:00
,$draw2 ~Mouse.x ~r2.x1 GTH2 ~Mouse.x ~r2.x2 LTH2 #0101 NEQ2 JMP2?
,$draw2 ~Mouse.y ~r2.y1 GTH2 ~Mouse.y ~r2.y2 LTH2 #0101 NEQ2 JMP2?
2021-03-14 01:34:08 +00:00
#03 =color ,hand_icn =pointer.sprite
$draw2 ~r2.x1 ~r2.y1 ~r2.x2 ~r2.y2 ~color ,line-rect JSR2
2021-03-01 03:49:53 +00:00
#01 =color
2021-03-01 16:55:16 +00:00
( 4-step comparison )
2021-03-15 22:27:43 +00:00
,$draw3 ~Mouse.x ~r3.x1 LTH2 JMP2?
,$draw3 ~Mouse.x ~r3.x2 GTH2 JMP2?
,$draw3 ~Mouse.y ~r3.y1 LTH2 JMP2?
,$draw3 ~Mouse.y ~r3.y2 GTH2 JMP2?
2021-03-14 01:34:08 +00:00
#02 =color ,hand_icn =pointer.sprite
$draw3 ~r3.x1 ~r3.y1 ~r3.x2 ~r3.y2 ~color ,line-rect JSR2
2021-03-01 03:49:53 +00:00
2021-03-11 03:41:46 +00:00
,draw-cursor JSR2
2021-03-01 03:49:53 +00:00
BRK
@draw-cursor
2021-03-14 01:34:08 +00:00
( clear last cursor )
,clear_icn =Sprite.addr
~pointer.x =Sprite.x
~pointer.y =Sprite.y
#10 =Sprite.color
2021-03-01 03:49:53 +00:00
2021-03-14 01:34:08 +00:00
( record pointer positions )
~Mouse.x =pointer.x ~Mouse.y =pointer.y
2021-03-01 03:49:53 +00:00
2021-03-14 01:34:08 +00:00
( draw new cursor )
~pointer.sprite =Sprite.addr
~pointer.x =Sprite.x
~pointer.y =Sprite.y
#11 =Sprite.color
2021-03-01 03:49:53 +00:00
2021-03-14 21:26:17 +00:00
RTN
2021-03-01 03:49:53 +00:00
@line-rect ( x1 y1 x2 y2 color )
2021-03-14 01:34:08 +00:00
( load ) =color =rect.y2 =rect.x2 DUP2 =Screen.y =rect.y1 DUP2 =Screen.x =rect.x1
2021-03-14 02:25:58 +00:00
$hor
2021-03-14 01:34:08 +00:00
( incr ) ~Screen.x #0001 ADD2 =Screen.x
( draw ) ~rect.y1 =Screen.y ~color =Screen.color
( draw ) ~rect.y2 =Screen.y ~color =Screen.color
2021-03-15 22:27:43 +00:00
,$hor ~Screen.x ~rect.x2 LTH2 JMP2?
2021-03-14 01:34:08 +00:00
~rect.y1 =Screen.y
2021-03-14 02:25:58 +00:00
$ver
2021-03-14 01:34:08 +00:00
( draw ) ~rect.x1 =Screen.x ~color =Screen.color
( draw ) ~rect.x2 =Screen.x ~color =Screen.color
( incr ) ~Screen.y #0001 ADD2 =Screen.y
2021-03-15 22:27:43 +00:00
,$ver ~Screen.y ~rect.y2 #0001 ADD2 LTH2 JMP2?
2021-03-01 03:49:53 +00:00
2021-03-14 21:26:17 +00:00
RTN
2021-03-01 03:49:53 +00:00
@clear_icn [ 0000 0000 0000 0000 ]
2021-03-01 17:16:40 +00:00
@pointer_icn [ 80c0 e0f0 f8e0 1000 ]
2021-03-01 03:49:53 +00:00
@hand_icn [ 4040 4070 f8f8 f870 ]
|d000 @ERROR BRK
2021-03-14 01:34:08 +00:00
|FF10 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|FF50 ;Mouse { x 2 y 2 state 1 chord 1 }
2021-03-01 03:49:53 +00:00
|FFF0 .RESET .FRAME .ERROR ( vectors )
|FFF8 [ 0f0f 0fff 0ff0 ] ( palette )