Browse code

New ctrl example

neauoire authored on 20/02/2021 18:34:10
Showing 2 changed files
... ...
@@ -20,5 +20,5 @@ cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werr
20 20
 # cc uxn.c emulator.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -L/usr/local/lib -lSDL2 -o bin/emulator
21 21
 
22 22
 # run
23
-./bin/assembler examples/drag.usm bin/boot.rom
23
+./bin/assembler examples/devctrl.usm bin/boot.rom
24 24
 ./bin/emulator bin/boot.rom
25 25
similarity index 56%
26 26
rename from examples/controller.usm
27 27
rename to examples/devctrl.usm
... ...
@@ -3,63 +3,59 @@
3 3
 :dev/r fff8 ( const read port )
4 4
 :dev/w fff9 ( const write port )
5 5
 
6
-;x 2 ;y 2
6
+;x 2 ;y 2 ;sprite 2
7 7
 
8 8
 |0100 @RESET 
9 9
 
10 10
 	#03 =dev/r ( set dev/read to controller ) 
11 11
 	#02 =dev/w ( set dev/write to sprite ) 
12 12
 	#0080 =x #0040 =y ( origin )
13
-	#0101 ,cursor_icn ~x ~y ,putsprite JSR ( draw sprite )
14 13
 
15
-BRK
16
-
17
-|0200 @SPRITESHEET
18
-
19
-@cursor_icn [ 80c0 e0f0 f8e0 1000 ]
14
+	#02 ,up_icn ~x ~y ,draw-sprite JSR
20 15
 
21 16
 BRK
22 17
 
23 18
 |c000 @FRAME 
24 19
 
25
-	#05 =dev/r ( set dev/read to mouse ) 
26
-
27
-	#04 IOR #01 NEQ ,next0 ROT JMP? POP2
28
-		#00 IOR2 =x #02 IOR2 =y
29
-
30
-	@next0
31
-
32 20
 	#03 =dev/r ( set dev/read to controller ) 
33 21
 
22
+	,default_icn =sprite
23
+
34 24
 	#00 IOR #10 NEQ ,next1 ROT JMP? POP2
25
+		,up_icn =sprite
35 26
 		~y #0001 SUB2 =y
36 27
 	@next1
37
-
38 28
 	#00 IOR #20 NEQ ,next2 ROT JMP? POP2
29
+		,down_icn =sprite
39 30
 		~y #0001 ADD2 =y
40
-
41 31
 	@next2
42 32
 	#00 IOR #40 NEQ ,next3 ROT JMP? POP2
33
+		,left_icn =sprite
43 34
 		~x #0001 SUB2 =x
44
-
45 35
 	@next3
46 36
 	#00 IOR #80 NEQ ,end ROT JMP? POP2
37
+		,right_icn =sprite
47 38
 		~x #0001 ADD2 =x
48
-
49 39
 	@end
50 40
 	( redraw )
51
-	#0101 ,cursor_icn ~x ~y ,putsprite JSR
41
+	#03 ~sprite ~x ~y ,draw-sprite JSR
52 42
 
53 43
 BRK
54 44
 
55
-@putsprite
56
-	IOW2 ( y short )
57
-	IOW2 ( x short )
45
+@default_icn [ 3c7e ffdb ffe7 7e3c ]
46
+@up_icn      [ 2466 e7db ffff 7e3c ]
47
+@down_icn    [ 3c7e ffff dbe7 6624 ]
48
+@left_icn    [ 3c7e ef1f 1fef 7e3c ]
49
+@right_icn   [ 3c7e f7f8 f8f7 7e3c ]
50
+
51
+@draw-sprite
52
+	IOW2 ( y byte )
53
+	IOW2 ( x byte )
58 54
 	IOW2 ( sprite address )
59
-	IOW2  ( redraw byte )
55
+	IOW ( layer-color )
60 56
 	RTS
61 57
 
62 58
 |d000 @ERROR BRK 
63 59
 
64
-|FFF0 [ f2ac 35bb 2b53 ] ( palette )
60
+|FFF0 [ 02ac 05bb 0b53 ] ( palette )
65 61
 |FFFA .RESET .FRAME .ERROR