uxn/projects/examples/dev.screen.usm

73 lines
1.5 KiB
Plaintext

( Screen )
;center { x 2 y 2 }
;timer { byte 1 }
( devices )
|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 }
|01F0 .RESET .FRAME .ERROR ( vectors )
|01F8 [ f0ac f0bb f053 ] ( palette )
( program )
|0200 @RESET
( find screen center )
~Screen.width #0002 DIV2 =center.x
~Screen.height #0002 DIV2 =center.y
( draw hor line )
#0000 =Screen.x ~center.y =Screen.y
#0000 ~Screen.width ( from/to )
$draw-hor NOP
( draw ) #01 =Screen.color
( incr ) SWP2 #0002 ADD2 DUP2 =Screen.x SWP2
OVR2 OVR2 LTH2 ^$draw-hor SWP JMP?
POP2 POP2
( draw ver line )
~center.x =Screen.x #0000 =Screen.y
#0000 ~Screen.height ( from/to )
$draw-ver NOP
( draw ) #02 =Screen.color
( incr ) SWP2 #0002 ADD2 DUP2 =Screen.y SWP2
OVR2 OVR2 LTH2 ^$draw-ver SWP JMP?
POP2 POP2
( draw blending modes )
#0020 =Sprite.x #0020 =Sprite.y ,icon =Sprite.addr
#00 #10
$draw-blends NOP
( move ) OVR #00 SWP #0008 MUL2 #0020 ADD2 =Sprite.x
( draw ) OVR =Sprite.color
( incr ) SWP #01 ADD SWP
DUP2 LTH ^$draw-blends SWP JMP?
POP POP
BRK
@FRAME
( update colors every 40 frames )
~timer #40 NEQ ,skip1 ROT JMP2?
#0fac #01fa STR2 #f0bb #01fc STR2 #f053 #01f8 STR2
@skip1
~timer #80 NEQ ,skip2 ROT JMP2?
#00fc #01fc STR2 #f0bb #01f8 STR2 #f053 #01fa STR2
@skip2
~timer #c0 NEQ ,skip3 ROT JMP2?
#000f #01f8 STR2 #0f0f #01fa STR2 #0100 #01fc STR2
@skip3
~timer #00 NEQ ,skip4 ROT JMP2?
#f0ac #01f8 STR2 #f0bb #01fa STR2 #f053 #01fc STR2
@skip4
~timer #01 ADD =timer
BRK
@icon [ 3c7e e7c3 c3e7 7e3c ]
@ERROR BRK