~rabbits/uxn

uxn/examples/devctrl.usm -rw-r--r-- 1.2 KiB
54da651cneauoire Added hover example 5 hours ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
( controller )

:dev/r fff8 ( const read port )
:dev/w fff9 ( const write port )

&Point2d { x 2 y 2 }

;pos Point2d 
;sprite 2

|0100 @RESET 

	#03 =dev/r ( set dev/read to controller ) 
	#02 =dev/w ( set dev/write to sprite ) 
	#0080 =pos.x #0040 =pos.y ( origin )

	#12 ,up_icn ~pos.x ~pos.y ,draw-sprite JSR

BRK

|c000 @FRAME 

	#03 =dev/r ( set dev/read to controller ) 

	,default_icn =sprite

	#00 IOR #10 NEQ ,next1 ROT JMP? POP2
		,up_icn =sprite
		~pos.y #0001 SUB2 =pos.y
	@next1
	#00 IOR #20 NEQ ,next2 ROT JMP? POP2
		,down_icn =sprite
		~pos.y #0001 ADD2 =pos.y
	@next2
	#00 IOR #40 NEQ ,next3 ROT JMP? POP2
		,left_icn =sprite
		~pos.x #0001 SUB2 =pos.x
	@next3
	#00 IOR #80 NEQ ,end ROT JMP? POP2
		,right_icn =sprite
		~pos.x #0001 ADD2 =pos.x
	@end
	( redraw )
	#13 ~sprite ~pos.x ~pos.y ,draw-sprite JSR

BRK

@default_icn [ 3c7e ffdb ffe7 7e3c ]
@up_icn      [ 2466 e7db ffff 7e3c ]
@down_icn    [ 3c7e ffff dbe7 6624 ]
@left_icn    [ 3c7e ef1f 1fef 7e3c ]
@right_icn   [ 3c7e f7f8 f8f7 7e3c ]

@draw-sprite
	IOW2 ( y byte )
	IOW2 ( x byte )
	IOW2 ( sprite address )
	IOW ( layer-color )
	RTS

|d000 @ERROR BRK 

|FFF0 [ 02ac 05bb 0b53 ] ( palette )
|FFFA .RESET .FRAME .ERROR