uxn/examples/gui.shapes.usm

59 lines
1.5 KiB
Plaintext

( draw routines )
&Screen { width 2 height 2 pad 4 y 2 x 2 color 1 red 1 green 1 blue 1 }
;color 1 ;x1 2 ;x2 2 ;y1 2 ;y2 2
|0100 @RESET
#01 =color
#0010 #0020 #0040 #0060 ,fill-rect JSR
#02 =color
#0020 #0030 #0050 #0070 ,fill-rect JSR
#03 =color
#0030 #0040 #0060 #0080 ,fill-rect JSR
#01 =color
#0070 #0020 #00a0 #0060 ,line-rect JSR
#02 =color
#0080 #0030 #00b0 #0070 ,line-rect JSR
#03 =color
#0090 #0040 #00c0 #0080 ,line-rect JSR
BRK
@line-rect ( x1 y1 x2 y2 )
=y2 =x2 ( stash x1 y1 ) DUP2 WSR2 =y1 DUP2 WSR2 =x1
@line-rect-hor
( draw ) ~x1 ~y1 =dev/screen.y =dev/screen.x ~color =dev/screen.color
( draw ) ~x1 ~y2 =dev/screen.y =dev/screen.x ~color =dev/screen.color
( incr ) ~x1 #0001 ADD2 DUP2 =x1
~x2 #0001 ADD2 LTH2 ,line-rect-hor ROT JMP? POP2
( restore x1 y1 ) RSW2 =x1 RSW2 =y1
@line-rect-ver
( incr ) ~y1 #0001 ADD2 DUP2 =y1
( draw ) ~x1 ~y1 =dev/screen.y =dev/screen.x ~color =dev/screen.color
( draw ) ~x2 ~y1 =dev/screen.y =dev/screen.x ~color =dev/screen.color
~y2 #0001 SUB2 LTH2 ,line-rect-ver ROT JMP? POP2
RTS
@fill-rect ( x1 y1 x2 y2 )
=y2 =x2 ( stash x1 y1 ) =y1 DUP2 WSR2 =x1
@fill-rect-ver
RSW2 DUP2 =x1 WSR2
@fill-rect-hor
( draw ) ~x1 ~y1 =dev/screen.y =dev/screen.x ~color =dev/screen.color
( incr ) ~x1 #0001 ADD2 DUP2 =x1
~x2 LTH2 ,fill-rect-hor ROT JMP? POP2
~y1 #0001 ADD2 DUP2 =y1
~y2 LTH2 ,fill-rect-ver ROT JMP? POP2
RSW2 POP2
RTS
|c000 @FRAME BRK
|d000 @ERROR BRK
|FF10 ;dev/screen Screen
|FFF0 [ 0f0f 0fff 0ff0 ] ( palette )
|FFFA .RESET .FRAME .ERROR ( vectors )