0
0
Fork 0
mirror of https://git.sr.ht/~rabbits/uxn synced 2024-12-02 18:47:26 +00:00
uxn/projects/tests/draw.usm

71 lines
1.5 KiB
Text
Raw Normal View History

2021-03-18 17:13:55 +00:00
( tests/draw )
%RTN { JMP2r }
%RTN? { JMP2r? }
2021-03-21 04:46:52 +00:00
%ABS { DUP #07 SHR #ff SWP MUL? }
%ABS2 { DUP2 #000f SFT2 #ffff SWP2 SWP POP MUL2? }
2021-03-18 17:13:55 +00:00
;cursor { x 2 y 2 }
;a { x 2 y 2 }
;b { x 2 y 2 }
;s { x 2 y 2 }
2021-03-21 04:46:52 +00:00
;d { x 2 y 2 }
;err { short 2 }
;err2 { short 2 }
;i { byte 1 }
;color { byte 1 }
2021-03-18 17:13:55 +00:00
|0100 @RESET
2021-03-21 04:46:52 +00:00
#0020 #0020 #0070 #0080 #01 ,draw-line JSR2
#0020 #0080 #0070 #0030 #02 ,draw-line JSR2
#00a0 #0020 #0050 #00b0 #03 ,draw-line JSR2
#00b0 #0090 #0030 #0010 #01 ,draw-line JSR2
2021-03-18 17:13:55 +00:00
BRK
@draw-line ( x1 y1 x2 y2 )
2021-03-21 04:46:52 +00:00
=color
=b.y =b.x =a.y =a.x
2021-03-18 17:13:55 +00:00
~b.x ~a.x SUB2 ABS2 =d.x
~b.y ~a.y SUB2 ABS2 #0000 SWP2 SUB2 =d.y
2021-03-21 04:46:52 +00:00
#ffff #00 ~a.x ~b.x LTS2 #0002 MUL2 ADD2 =s.x
#ffff #00 ~a.y ~b.y LTS2 #0002 MUL2 ADD2 =s.y
2021-03-18 17:13:55 +00:00
~d.x ~d.y ADD2 =err
$loop
2021-03-21 04:46:52 +00:00
~a.x =Screen.x ~a.y =Screen.y ~color =Screen.color
2021-03-18 17:13:55 +00:00
,$end ~a.x ~b.x EQU2 ~a.y ~b.y EQU2 #0101 EQU2 JMP2?
~err #0002 MUL2 =err2
2021-03-21 04:46:52 +00:00
,$skipy ~err2 ~d.y LTS2 JMP2?
2021-03-18 17:13:55 +00:00
~err ~d.y ADD2 =err
~a.x ~s.x ADD2 =a.x
$skipy
2021-03-21 04:46:52 +00:00
,$skipx ~err2 ~d.x GTS2 JMP2?
2021-03-18 17:13:55 +00:00
~err ~d.x ADD2 =err
~a.y ~s.y ADD2 =a.y
$skipx
,$loop JMP2
$end
RTN
|c000 @FRAME
|d000 @ERROR
|FF00 ;Console { pad 8 char 1 byte 1 short 2 }
2021-03-21 04:46:52 +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 }
|FF30 ;Controller { buttons 1 }
|FF40 ;Keys { key 1 }
|FF50 ;Mouse { x 2 y 2 state 1 chord 1 change 1 }
|FF60 ;File { pad 8 name 2 length 2 load 2 save 2 }
2021-03-18 17:13:55 +00:00
|FFF0 .RESET .FRAME .ERROR ( vectors )
|FFF8 [ 13fd 1ef3 1bf2 ] ( palette )