mirror of
https://git.sr.ht/~rabbits/uxn
synced 2024-11-12 17:25:05 +00:00
102 lines
2.5 KiB
Text
102 lines
2.5 KiB
Text
( draw routines )
|
|
|
|
%RTN { JMP2r }
|
|
%RTN? { #00 EQU #02 JNZ STH2r JMP2 }
|
|
|
|
;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 }
|
|
|
|
|0110 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|
|
|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
|
|0150 ;Mouse { x 2 y 2 state 1 chord 1 }
|
|
|01F0 ;System { pad 8 r 2 g 2 b 2 }
|
|
|0200 ^RESET JMP
|
|
|0204 ,ERROR JMP2
|
|
|0208 ,FRAME JMP2
|
|
|
|
@RESET
|
|
|
|
( theme ) #0f0f =System.r #0fff =System.g #0ff0 =System.b
|
|
|
|
#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
|
|
|
|
@FRAME
|
|
|
|
,pointer_icn =pointer.sprite
|
|
|
|
#01 =color
|
|
( matrix comparison )
|
|
~Mouse.x ~r1.x1 GTH2 ~Mouse.x ~r1.x2 LTH2 #0101 EQU2
|
|
~Mouse.y ~r1.y1 GTH2 ~Mouse.y ~r1.y2 LTH2 #0101 EQU2
|
|
#0101 NEQ2 ^$draw1 JNZ #02 =color ,hand_icn =pointer.sprite
|
|
$draw1 ~r1.x1 ~r1.y1 ~r1.x2 ~r1.y2 ~color ,line-rect JSR2
|
|
|
|
#01 =color
|
|
( 2-step comparison )
|
|
~Mouse.x ~r2.x1 GTH2 ~Mouse.x ~r2.x2 LTH2 #0101 NEQ2 ^$draw2 JNZ
|
|
~Mouse.y ~r2.y1 GTH2 ~Mouse.y ~r2.y2 LTH2 #0101 NEQ2 ^$draw2 JNZ
|
|
#03 =color ,hand_icn =pointer.sprite
|
|
$draw2 ~r2.x1 ~r2.y1 ~r2.x2 ~r2.y2 ~color ,line-rect JSR2
|
|
|
|
#01 =color
|
|
( 4-step comparison )
|
|
~Mouse.x ~r3.x1 LTH2 ^$draw3 JNZ
|
|
~Mouse.x ~r3.x2 GTH2 ^$draw3 JNZ
|
|
~Mouse.y ~r3.y1 LTH2 ^$draw3 JNZ
|
|
~Mouse.y ~r3.y2 GTH2 ^$draw3 JNZ
|
|
#02 =color ,hand_icn =pointer.sprite
|
|
$draw3 ~r3.x1 ~r3.y1 ~r3.x2 ~r3.y2 ~color ,line-rect JSR2
|
|
|
|
,draw-cursor JSR2
|
|
|
|
BRK
|
|
|
|
@draw-cursor
|
|
|
|
( clear last cursor )
|
|
,clear_icn =Sprite.addr
|
|
~pointer.x =Sprite.x
|
|
~pointer.y =Sprite.y
|
|
#10 =Sprite.color
|
|
|
|
( record pointer positions )
|
|
~Mouse.x =pointer.x ~Mouse.y =pointer.y
|
|
|
|
( draw new cursor )
|
|
~pointer.sprite =Sprite.addr
|
|
~pointer.x =Sprite.x
|
|
~pointer.y =Sprite.y
|
|
#11 =Sprite.color
|
|
|
|
RTN
|
|
|
|
@line-rect ( x1 y1 x2 y2 color )
|
|
|
|
( load ) =color =rect.y2 =rect.x2 DUP2 =Screen.y =rect.y1 DUP2 =Screen.x =rect.x1
|
|
$hor
|
|
( incr ) ~Screen.x #0001 ADD2 =Screen.x
|
|
( draw ) ~rect.y1 =Screen.y ~color =Screen.color
|
|
( draw ) ~rect.y2 =Screen.y ~color =Screen.color
|
|
~Screen.x ~rect.x2 LTH2 ^$hor JNZ
|
|
~rect.y1 =Screen.y
|
|
$ver
|
|
( draw ) ~rect.x1 =Screen.x ~color =Screen.color
|
|
( draw ) ~rect.x2 =Screen.x ~color =Screen.color
|
|
( incr ) ~Screen.y #0001 ADD2 =Screen.y
|
|
~Screen.y ~rect.y2 #0001 ADD2 LTH2 ^$ver JNZ
|
|
|
|
RTN
|
|
|
|
@clear_icn [ 0000 0000 0000 0000 ]
|
|
@pointer_icn [ 80c0 e0f0 f8e0 1000 ]
|
|
@hand_icn [ 4040 4070 f8f8 f870 ]
|
|
|
|
@ERROR BRK
|