uxn/examples/shapes.usm

75 lines
1.7 KiB
Plaintext
Raw Normal View History

2021-02-20 20:14:36 -05:00
( draw routines )
:dev/r fff8 ( std read port )
:dev/w fff9 ( std write port )
2021-02-21 16:23:36 -05:00
;color 1 ;x1 2 ;x2 2 ;y1 2 ;y2 2
2021-02-20 20:14:36 -05:00
|0100 @RESET
#01 =dev/w ( set dev/write to screen )
2021-02-21 16:23:36 -05:00
#01 =color
2021-02-21 19:52:51 -05:00
#0010 #0020 #0040 #0060 ,fill-rect JSR
2021-02-21 16:23:36 -05:00
#02 =color
2021-02-21 19:52:51 -05:00
#0020 #0030 #0050 #0070 ,fill-rect JSR
2021-02-21 16:23:36 -05:00
#03 =color
2021-02-21 19:52:51 -05:00
#0030 #0040 #0060 #0080 ,fill-rect JSR
2021-02-21 16:23:36 -05:00
#01 =color
2021-02-21 19:52:51 -05:00
#0070 #0020 #00a0 #0060 ,line-rect JSR
2021-02-21 16:23:36 -05:00
#02 =color
2021-02-21 19:52:51 -05:00
#0080 #0030 #00b0 #0070 ,line-rect JSR
2021-02-21 16:23:36 -05:00
#03 =color
2021-02-21 19:52:51 -05:00
#0090 #0040 #00c0 #0080 ,line-rect JSR
2021-02-21 16:23:36 -05:00
2021-02-20 20:14:36 -05:00
BRK
2021-02-21 16:23:36 -05:00
@line-ver ( x1 y1 y2 )
=y2 =y1 =x1
@line-ver-loop
( draw ) ~x1 ~y1 IOW2 IOW2 ~color IOW
( incr ) ~y1 #0001 ADD2 DUP2 =y1
~y2 NEQ2 ,line-ver-loop ROT JMP? POP2
RTS
@line-hor ( x1 y1 x2 )
=x2 =y1 =x1
@line-hor-loop
( draw ) ~x1 ~y1 IOW2 IOW2 ~color IOW
( incr ) ~x1 #0001 ADD2 DUP2 =x1
~x2 NEQ2 ,line-hor-loop ROT JMP? POP2
RTS
@line-rect ( x1 y1 x2 y2 )
=y2 =x2 ( stash x1 y1 ) DUP2 WSR2 =y1 DUP2 WSR2 =x1
@line-rect-hor
( draw ) ~x1 ~y1 IOW2 IOW2 ~color IOW
( draw ) ~x1 ~y2 IOW2 IOW2 ~color IOW
( 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 IOW2 IOW2 ~color IOW
( draw ) ~x2 ~y1 IOW2 IOW2 ~color IOW
~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 IOW2 IOW2 ~color IOW
( 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
2021-02-20 20:14:36 -05:00
|c000 @FRAME BRK
|d000 @ERROR BRK
2021-02-21 19:52:51 -05:00
|FFF0 [ 0f0f 0fff 0ff0 ] ( palette )
2021-02-20 20:14:36 -05:00
|FFFA .RESET .FRAME .ERROR ( vectors )