Browse code

Fixed shapes example

neauoire authored on 21/02/2021 01:14:36
Showing 5 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/paint.usm bin/boot.rom
23
+./bin/assembler examples/shapes.usm bin/boot.rom
24 24
 ./bin/emulator bin/boot.rom
... ...
@@ -27,11 +27,10 @@ BRK
27 27
 	#00 IOR2 =mousex #02 IOR2 =mousey
28 28
 	( record mouse state )
29 29
 	#04 IOR #11 ADD =state
30
-
30
+	( detect click )
31 31
 	#04 IOR #01 NEQ ,no-click ROT JMP? POP2
32 32
 		#50 =timer
33 33
 	@no-click
34
-
35 34
 	( draw mouse )
36 35
 	~state ,cursor_icn ~mousex ~mousey ,draw-sprite JSR
37 36
 	( animate )
... ...
@@ -42,4 +42,4 @@ BRK
42 42
 |c000 @FRAME BRK
43 43
 |d000 @ERROR BRK 
44 44
 |FFF0 [ f0ac f0bb f053 ] ( palette )
45
-|FFFA .RESET .FRAME .ERROR
45
+|FFFA .RESET .FRAME .ERROR ( vectors )
46 46
deleted file mode 100644
... ...
@@ -1,96 +0,0 @@
1
-( draw routines )
2
-
3
-:dev/r fff8 ( std read port )
4
-:dev/w fff9 ( std write port )
5
-
6
-;x_ 2 ;y_ 2 ;x 2 ;y 2 ;w 2 ;h 2 ;color 1
7
-;x0 2 ;y0 2 ;x1 2 ;y1 2 ;dx 2 ;dy 2 ;err1 2 ;err2 2 ( line )
8
-
9
-|0100 @RESET
10
-
11
-	( set dev/write to screen ) 
12
-	#01 =dev/w ( set dev/write to sprite ) 
13
-
14
-	#01 ,color STR
15
-	( fill rect x y w h )
16
-	#0020 #0020 #0060 #0040 ,fillrect JSR
17
-
18
-	#02 ,color STR
19
-	( fill rect x y w h )
20
-	#0030 #0030 #0040 #0060 ,fillrect JSR
21
-
22
-	#03 ,color STR
23
-	( fill rect x y w h )
24
-	#0040 #0040 #0060 #0040 ,fillrect JSR
25
-
26
-	#01 ,color STR
27
-	( fill rect x y w h )
28
-	#00a0 #0010 #0020 #0020 ,fillrect JSR
29
-
30
-	#02 ,color STR
31
-	( fill rect x y w h )
32
-	#00b0 #0040 #0020 #0020 ,linerect JSR
33
-
34
-	#03 ,color STR
35
-	( fill rect x y w h )
36
-	#0058 #0028 #0050 #0050 ,linerect JSR
37
-
38
-	#01 ,color STR
39
-	( fill rect x y w h )
40
-	#0028 #0038 #0050 #0030 ,linerect JSR
41
-
42
-	,redraw JSR
43
-
44
-BRK
45
-
46
-@fillrect
47
-	,h STR2 ,w STR2 ,y STR2 ,x STR2
48
-	,x LDR2 ,x_ STR2 ,y LDR2 ,y_ STR2
49
-	@fillrectrow
50
-		,x LDR2 ,x_ STR2
51
-		@fillrectcol
52
-			( draw ) ,x_ LDR2 ,y_ LDR2 ,putpixel JSR
53
-			,x_ LDR2 #0001 ADD2 ,x_ STR2 
54
-			,x_ LDR2 ,w LDR2 ,x LDR2 ADD2 LTH2 ,fillrectcol ROT JMP? POP2
55
-		,y_ LDR2 #0001 ADD2 ,y_ STR2 
56
-		,y_ LDR2 ,h LDR2 ,y LDR2 ADD2 LTH2 ,fillrectrow ROT JMP? POP2
57
-	RTS
58
-
59
-@linerect
60
-	,h STR2 ,w STR2 ,y STR2 ,x STR2
61
-	,x LDR2 ,x_ STR2 ,y LDR2 ,y_ STR2
62
-	@linerectcol
63
-		( draw ) ,x LDR2 ,y_ LDR2 ,putpixel JSR
64
-		( draw ) ,x LDR2 ,w LDR2 ADD2 ,y_ LDR2 ,putpixel JSR
65
-		,y_ LDR2 #0001 ADD2 ,y_ STR2 
66
-		,y_ LDR2 ,h LDR2 ,y LDR2 ADD2 LTH2 ,linerectcol ROT JMP? POP2
67
-	@linerectrow
68
-		( draw ) ,x_ LDR2 ,y LDR2 ,putpixel JSR
69
-		( draw ) ,x_ LDR2 ,y LDR2 ,h LDR2 ADD2 ,putpixel JSR
70
-		,x_ LDR2 #0001 ADD2 ,x_ STR2 
71
-		,x_ LDR2 ,w LDR2 ,x LDR2 ADD2 #0001 ADD2 LTH2 ,linerectrow ROT JMP? POP2
72
-	RTS
73
-
74
-@diff16
75
-	OVR2 OVR2 GTH2 ,diff16sub ROT JMP? POP2
76
-	SWP2 @diff16sub SUB2
77
-RTS
78
-
79
-@redraw
80
-	#0000 IOW2
81
-	#0000 IOW2
82
-	#00 IOW
83
-	#01 IOW
84
-	RTS
85
-
86
-@putpixel 
87
-	IOW2 ( y short )
88
-	IOW2 ( x short )
89
-	,color LDR IOW  ( color byte )
90
-	#00 IOW  ( redraw byte )
91
-	RTS
92
-
93
-|c000 @FRAME BRK 
94
-|d000 @ERROR BRK 
95
-|FFF0 [ f2ac 35bb 2b53 ] ( palette )
96
-|FFFA .RESET .FRAME .ERROR
97 0
new file mode 100644
... ...
@@ -0,0 +1,79 @@
1
+( draw routines )
2
+
3
+:dev/r fff8 ( std read port )
4
+:dev/w fff9 ( std write port )
5
+
6
+;x_ 2 ;y_ 2 ;x 2 ;y 2 ;w 2 ;h 2 ;color 1
7
+
8
+|0100 @RESET
9
+
10
+	#01 =dev/w ( set dev/write to screen ) 
11
+
12
+	#01 ,color STR
13
+	( fill rect x y w h )
14
+	#0020 #0020 #0060 #0040 ,fillrect JSR
15
+
16
+	#02 ,color STR
17
+	( fill rect x y w h )
18
+	#0030 #0030 #0040 #0060 ,fillrect JSR
19
+
20
+	#03 ,color STR
21
+	( fill rect x y w h )
22
+	#0040 #0040 #0060 #0040 ,fillrect JSR
23
+
24
+	#01 ,color STR
25
+	( fill rect x y w h )
26
+	#00a0 #0010 #0020 #0020 ,fillrect JSR
27
+
28
+	#02 ,color STR
29
+	( fill rect x y w h )
30
+	#00b0 #0040 #0020 #0020 ,linerect JSR
31
+
32
+	#03 ,color STR
33
+	( fill rect x y w h )
34
+	#0058 #0028 #0050 #0050 ,linerect JSR
35
+
36
+	#01 ,color STR
37
+	( fill rect x y w h )
38
+	#0028 #0038 #0050 #0030 ,linerect JSR
39
+
40
+BRK
41
+
42
+@fillrect
43
+	=h  =w  =y  =x 
44
+	~x  =x_  ~y  =y_ 
45
+	@fillrectrow
46
+		~x  =x_ 
47
+		@fillrectcol
48
+			( draw ) ~x_  ~y_  ,putpixel JSR
49
+			~x_  #0001 ADD2 =x_  
50
+			~x_  ~w  ~x  ADD2 LTH2 ,fillrectcol ROT JMP? POP2
51
+		~y_  #0001 ADD2 =y_  
52
+		~y_  ~h  ~y  ADD2 LTH2 ,fillrectrow ROT JMP? POP2
53
+	RTS
54
+
55
+@linerect
56
+	=h  =w  =y  =x 
57
+	~x  =x_  ~y  =y_ 
58
+	@linerectcol
59
+		( draw ) ~x  ~y_  ,putpixel JSR
60
+		( draw ) ~x  ~w  ADD2 ~y_  ,putpixel JSR
61
+		~y_  #0001 ADD2 =y_  
62
+		~y_  ~h  ~y  ADD2 LTH2 ,linerectcol ROT JMP? POP2
63
+	@linerectrow
64
+		( draw ) ~x_  ~y  ,putpixel JSR
65
+		( draw ) ~x_  ~y  ~h  ADD2 ,putpixel JSR
66
+		~x_  #0001 ADD2 =x_  
67
+		~x_  ~w  ~x  ADD2 #0001 ADD2 LTH2 ,linerectrow ROT JMP? POP2
68
+	RTS
69
+
70
+@putpixel 
71
+	IOW2 ( y short )
72
+	IOW2 ( x short )
73
+	,color LDR IOW  ( color byte )
74
+	RTS
75
+
76
+|c000 @FRAME BRK 
77
+|d000 @ERROR BRK 
78
+|FFF0 [ f2ac 35bb 2b53 ] ( palette )
79
+|FFFA .RESET .FRAME .ERROR ( vectors )
0 80
\ No newline at end of file