Browse code

Changed the screen.tal colors to fit the Varvara docs

neauoire authored on 31/07/2021 03:10:26
Showing 3 changed files
... ...
@@ -54,7 +54,7 @@ then
54 54
 fi
55 55
 
56 56
 echo "Assembling.."
57
-./bin/uxnasm projects/examples/devices/piano.tal bin/piano.rom
57
+./bin/uxnasm projects/examples/demos/piano.tal bin/piano.rom
58 58
 
59 59
 echo "Running.."
60 60
 ./bin/uxnemu bin/piano.rom
... ...
@@ -1,13 +1,12 @@
1 1
 ( dev/screen )
2 2
 
3 3
 %RTN { JMP2r }
4
-%MOD { DUP2 DIV MUL SUB }
5 4
 %2// { #01 SFT2 }
6 5
 
7 6
 ( devices )
8 7
 
9 8
 |00 @System     [ &vector $2 &pad      $6 &r      $2 &g     $2 &b      $2 ]
10
-|20 @Screen     [ &vector $2 &width    $2 &height $2 &pad   $2 &x      $2 &y     $2 &addr $2 &color $1 &sprite $1 ]
9
+|20 @Screen     [ &vector $2 &width    $2 &height $2 &pad   $2 &x      $2 &y     $2 &addr $2 &pixel $1 &sprite $1 ]
11 10
 
12 11
 ( variables )
13 12
 
... ...
@@ -20,9 +19,9 @@
20 19
 |0100 ( -> )
21 20
 	
22 21
 	( theme ) 
23
-	#025f .System/r DEO2
24
-	#0c2f .System/g DEO2 
25
-	#0da4 .System/b DEO2 
22
+	#f07f .System/r DEO2
23
+	#f0e0 .System/g DEO2 
24
+	#f0c0 .System/b DEO2 
26 25
 
27 26
 	( find screen center )
28 27
 	.Screen/width DEI2 2// .center/x STZ2
... ...
@@ -32,25 +31,10 @@
32 31
 	;draw-table JSR2
33 32
 	;draw-sprites JSR2
34 33
 	;draw-circle JSR2
34
+	;draw-pixels JSR2
35 35
 	
36 36
 BRK
37 37
 
38
-@draw-sprites ( -- )
39
-	
40
-	;preview_icn .Screen/addr DEO2
41
-	#00 #00
42
-	&loop
43
-		( move ) OVR #0f AND #40 SFT #02 DIV #00 SWP 
44
-			.center/x LDZ2 #0040 SUB2 ADD2 .Screen/x DEO2
45
-		( move ) OVR #f0 AND #02 DIV #00 SWP 
46
-			.center/y LDZ2 #0040 SUB2 ADD2 .Screen/y DEO2
47
-		( draw ) OVR .Screen/sprite DEO
48
-		( incr ) SWP #01 ADD SWP
49
-		NEQk ,&loop JCN
50
-	POP2
51
-	
52
-RTN
53
-
54 38
 @draw-table ( -- )
55 39
 	
56 40
 	#00 #10
... ...
@@ -72,19 +56,49 @@ RTN
72 56
 
73 57
 RTN
74 58
 
59
+@draw-sprites ( -- )
60
+	
61
+	;preview_icn .Screen/addr DEO2
62
+	#00 #00
63
+	&loop
64
+		( move ) OVR #0f AND #40 SFT #02 DIV #00 SWP 
65
+			.center/x LDZ2 #0040 SUB2 ADD2 .Screen/x DEO2
66
+		( move ) OVR #f0 AND #02 DIV #00 SWP 
67
+			.center/y LDZ2 #0040 SUB2 ADD2 .Screen/y DEO2
68
+		( draw ) OVR .Screen/sprite DEO
69
+		( incr ) SWP #01 ADD SWP
70
+		NEQk ,&loop JCN
71
+	POP2
72
+	
73
+RTN
74
+
75 75
 @draw-circle ( -- )
76 76
 	
77 77
 	;preview_icn .Screen/addr DEO2
78 78
 	.center/x LDZ2 #0048 ADD2 .Screen/x DEO2
79 79
 	.center/y LDZ2 #0030 ADD2 .Screen/y DEO2
80
-	#01 .Screen/sprite DEO
80
+	#81 .Screen/sprite DEO
81 81
 	.center/x LDZ2 #0050 ADD2 .Screen/x DEO2
82
-	#11 .Screen/sprite DEO
82
+	#91 .Screen/sprite DEO
83 83
 	.center/x LDZ2 #0048 ADD2 .Screen/x DEO2
84 84
 	.center/y LDZ2 #0038 ADD2 .Screen/y DEO2
85
-	#21 .Screen/sprite DEO
85
+	#a1 .Screen/sprite DEO
86 86
 	.center/x LDZ2 #0050 ADD2 .Screen/x DEO2
87
-	#31 .Screen/sprite DEO
87
+	#b1 .Screen/sprite DEO
88
+
89
+RTN
90
+
91
+@draw-pixels ( -- )
92
+	
93
+	.center/y LDZ2 #0040 SUB2 .Screen/y DEO2
94
+	.center/x LDZ2 #0048 ADD2 .Screen/x DEO2
95
+	#00 .Screen/pixel DEO
96
+	.center/x LDZ2 #0049 ADD2 .Screen/x DEO2
97
+	#01 .Screen/pixel DEO
98
+	.center/x LDZ2 #004a ADD2 .Screen/x DEO2
99
+	#02 .Screen/pixel DEO
100
+	.center/x LDZ2 #004b ADD2 .Screen/x DEO2
101
+	#03 .Screen/pixel DEO
88 102
 
89 103
 RTN
90 104
 
... ...
@@ -53,11 +53,11 @@ puticn(Ppu *p, Layer *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, Uin
53 53
 	for(v = 0; v < 8; v++)
54 54
 		for(h = 0; h < 8; h++) {
55 55
 			Uint8 ch1 = ((sprite[v] >> (7 - h)) & 0x1);
56
+			Uint16 px = x + (flipx ? 7 - h : h);
57
+			Uint16 py = y + (flipy ? 7 - v : v);
56 58
 			if(!(ch1 || color % 0x5))
57 59
 				continue;
58
-			if(x < p->width && y < p->height) {
59
-				Uint16 px = x + (flipx ? 7 - h : h);
60
-				Uint16 py = y + (flipy ? 7 - v : v);
60
+			if(px < p->width && py < p->height) {
61 61
 				Uint8 pc = ch1 ? (color & 0x3) : (color >> 0x2);
62 62
 				layer->pixels[py * p->width + px] = layer->colors[pc];
63 63
 			}
... ...
@@ -72,11 +72,12 @@ putchr(Ppu *p, Layer *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, Uin
72 72
 		for(h = 0; h < 8; h++) {
73 73
 			Uint8 ch1 = ((sprite[v] >> (7 - h)) & 0x1) * color;
74 74
 			Uint8 ch2 = ((sprite[v + 8] >> (7 - h)) & 0x1) * color;
75
-			putpixel(p,
76
-				layer,
77
-				x + (flipx ? 7 - h : h),
78
-				y + (flipy ? 7 - v : v),
79
-				(((ch1 + ch2 * 2) + color / 4) & 0x3));
75
+			Uint16 px = x + (flipx ? 7 - h : h);
76
+			Uint16 py = y + (flipy ? 7 - v : v);
77
+			if(px < p->width && py < p->height) {
78
+				Uint8 pc = ((ch1 + ch2 * 2) + color / 4) & 0x3;
79
+				layer->pixels[py * p->width + px] = layer->colors[pc];
80
+			}
80 81
 		}
81 82
 }
82 83