mirror of
https://git.sr.ht/~rabbits/uxn
synced 2024-11-23 22:35:11 +00:00
103 lines
No EOL
2.9 KiB
Text
103 lines
No EOL
2.9 KiB
Text
( Dev/Mouse )
|
|
|
|
%RTN { JMP2r }
|
|
%++ { #0001 ADD2 }
|
|
%-- { #0001 SUB2 }
|
|
%8+ { #0008 ADD2 }
|
|
%ABS2 { DUP2 #000f SFT2 #ffff SWP2 SWP POP MUL2? }
|
|
|
|
;color { byte 1 }
|
|
;pointer { x 2 y 2 }
|
|
;circle { xc 2 yc 2 x 2 y 2 r 2 d 2 }
|
|
|
|
|0100 ;Console { pad 8 char 1 byte 1 short 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 }
|
|
|0170 ;Audio { ch1adsr 2 ch2adsr 2 ch3adsr 2 ch4adsr 2 ch1vol 1 ch1pitch 1 ch2vol 1 ch2pitch 1 ch3vol 1 ch3pitch 1 ch4vol 1 ch4pitch 1 }
|
|
|01F0 ;System { pad 8 r 2 g 2 b 2 }
|
|
|0200 ^RESET JMP
|
|
|0204 ,ERROR JMP2
|
|
|0208 ,FRAME JMP2
|
|
|
|
@RESET
|
|
|
|
( theme ) #03fd =System.r #0ef3 =System.g #0bf2 =System.b
|
|
|
|
#004f =Audio.ch1adsr #33 =Audio.ch1vol
|
|
|
|
BRK
|
|
|
|
@FRAME
|
|
|
|
( clear )
|
|
~circle.xc ~circle.yc ~circle.r #00 ,draw-circle JSR2
|
|
|
|
,draw-cursor JSR2
|
|
|
|
~Mouse.state #00 EQU ^$no-touch JNZ
|
|
~Mouse.x DUP2 =circle.xc
|
|
~Mouse.y DUP2 =circle.yc
|
|
#0000 =circle.r
|
|
( play sound ) ~Screen.width #000c DIV2 ADD2 #0002 DIV2 SWP POP =Audio.ch1pitch
|
|
( release ) #00 =Mouse.state
|
|
$no-touch
|
|
|
|
( draw )
|
|
~circle.xc ~circle.yc ~circle.r #0001 ADD2 #03 ,draw-circle 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 )
|
|
,cursor_icn =Sprite.addr
|
|
~pointer.x =Sprite.x
|
|
~pointer.y =Sprite.y
|
|
#11 ~Mouse.state #00 NEQ ADD =Sprite.color
|
|
|
|
RTN
|
|
|
|
@draw-circle ( xc yc r color )
|
|
|
|
( load ) =color =circle.r =circle.yc =circle.xc
|
|
#0000 =circle.x ~circle.r =circle.y
|
|
~circle.r #0002 MUL2 #0003 SUB2 =circle.d
|
|
( draw ) ,$seg JSR2
|
|
$loop
|
|
( incr ) ~circle.x ++ =circle.x
|
|
~circle.d #0000 #0001 ADD2 LTS2 ^$else JNZ
|
|
( decr ) ~circle.y -- =circle.y
|
|
~circle.x ~circle.y SUB2 #0004 MUL2 ~circle.d ADD2 #000a ADD2 =circle.d
|
|
,$end JMP2
|
|
$else
|
|
~circle.x #0004 MUL2 ~circle.d ADD2 #0006 ADD2 =circle.d
|
|
$end
|
|
( draw ) ,$seg JSR2
|
|
~circle.y ~circle.x #0001 SUB2 GTS2 ^$loop JNZ
|
|
RTN
|
|
$seg
|
|
~circle.xc ~circle.x ADD2 =Screen.x ~circle.yc ~circle.y ADD2 =Screen.y ~color =Screen.color
|
|
~circle.xc ~circle.x SUB2 =Screen.x ~circle.yc ~circle.y ADD2 =Screen.y ~color =Screen.color
|
|
~circle.xc ~circle.x ADD2 =Screen.x ~circle.yc ~circle.y SUB2 =Screen.y ~color =Screen.color
|
|
~circle.xc ~circle.x SUB2 =Screen.x ~circle.yc ~circle.y SUB2 =Screen.y ~color =Screen.color
|
|
~circle.xc ~circle.y ADD2 =Screen.x ~circle.yc ~circle.x ADD2 =Screen.y ~color =Screen.color
|
|
~circle.xc ~circle.y SUB2 =Screen.x ~circle.yc ~circle.x ADD2 =Screen.y ~color =Screen.color
|
|
~circle.xc ~circle.y ADD2 =Screen.x ~circle.yc ~circle.x SUB2 =Screen.y ~color =Screen.color
|
|
~circle.xc ~circle.y SUB2 =Screen.x ~circle.yc ~circle.x SUB2 =Screen.y ~color =Screen.color
|
|
|
|
RTN
|
|
|
|
@ERROR BRK
|
|
|
|
@clear_icn [ 0000 0000 0000 0000 ]
|
|
@cursor_icn [ 80c0 e0f0 f8e0 1000 ] |