... | ... |
@@ -54,9 +54,9 @@ then |
54 | 54 |
fi |
55 | 55 |
|
56 | 56 |
echo "Assembling.." |
57 |
-./bin/uxnasm projects/examples/demos/piano.tal bin/piano.rom |
|
57 |
+./bin/uxnasm projects/examples/devices/screen.tal bin/screen.rom |
|
58 | 58 |
|
59 | 59 |
echo "Running.." |
60 |
-./bin/uxnemu bin/piano.rom |
|
60 |
+./bin/uxnemu bin/screen.rom |
|
61 | 61 |
|
62 | 62 |
echo "Done." |
... | ... |
@@ -1,7 +1,6 @@ |
1 | 1 |
( dev/screen ) |
2 | 2 |
|
3 | 3 |
%RTN { JMP2r } |
4 |
-%2// { #01 SFT2 } |
|
5 | 4 |
|
6 | 5 |
( devices ) |
7 | 6 |
|
... | ... |
@@ -24,13 +23,16 @@ |
24 | 23 |
#f0c0 .System/b DEO2 |
25 | 24 |
|
26 | 25 |
( find screen center ) |
27 |
- .Screen/width DEI2 2// .center/x STZ2 |
|
28 |
- .Screen/height DEI2 2// .center/y STZ2 |
|
26 |
+ .Screen/width DEI2 #01 SFT2 #0020 SUB2 .center/x STZ2 |
|
27 |
+ .Screen/height DEI2 #01 SFT2 .center/y STZ2 |
|
29 | 28 |
|
30 | 29 |
( draw ) |
31 | 30 |
;draw-table JSR2 |
32 | 31 |
;draw-sprites JSR2 |
33 |
- ;draw-circle JSR2 |
|
32 |
+ |
|
33 |
+ ;draw-1bpp JSR2 |
|
34 |
+ ;draw-2bpp JSR2 |
|
35 |
+ |
|
34 | 36 |
;draw-pixels JSR2 |
35 | 37 |
|
36 | 38 |
BRK |
... | ... |
@@ -72,19 +74,53 @@ RTN |
72 | 74 |
|
73 | 75 |
RTN |
74 | 76 |
|
75 |
-@draw-circle ( -- ) |
|
77 |
+@draw-1bpp ( -- ) |
|
78 |
+ |
|
79 |
+ #00 #10 |
|
80 |
+ &loop |
|
81 |
+ ( color ) OVR STH |
|
82 |
+ ( y ) OVR #04 DIV [ #00 SWP ] #0010 MUL2 |
|
83 |
+ [ .center/y LDZ2 #0040 SUB2 ADD2 ] STH2 |
|
84 |
+ ( x ) OVR #03 AND [ #00 SWP ] #0010 MUL2 #0040 ADD2 |
|
85 |
+ [ .center/x LDZ2 #0008 ADD2 ADD2 ] |
|
86 |
+ STH2r STHr #00 ;draw-circle JSR2 |
|
87 |
+ SWP #01 ADD SWP |
|
88 |
+ LTHk ,&loop JCN |
|
89 |
+ POP2 |
|
90 |
+ |
|
91 |
+RTN |
|
92 |
+ |
|
93 |
+@draw-2bpp ( -- ) |
|
94 |
+ |
|
95 |
+ #00 #10 |
|
96 |
+ &loop |
|
97 |
+ ( color ) OVR STH |
|
98 |
+ ( y ) OVR #04 DIV [ #00 SWP ] #0010 MUL2 |
|
99 |
+ [ .center/y LDZ2 ADD2 ] STH2 |
|
100 |
+ ( x ) OVR #03 AND [ #00 SWP ] #0010 MUL2 #0040 ADD2 |
|
101 |
+ [ .center/x LDZ2 #0008 ADD2 ADD2 ] |
|
102 |
+ STH2r STHr #80 ;draw-circle JSR2 |
|
103 |
+ SWP #01 ADD SWP |
|
104 |
+ LTHk ,&loop JCN |
|
105 |
+ POP2 |
|
76 | 106 |
|
107 |
+RTN |
|
108 |
+ |
|
109 |
+@draw-circle ( x* y* color depth -- ) |
|
110 |
+ |
|
111 |
+ ADD STH |
|
77 | 112 |
;preview_icn .Screen/addr DEO2 |
78 |
- .center/x LDZ2 #0048 ADD2 .Screen/x DEO2 |
|
79 |
- .center/y LDZ2 #0030 ADD2 .Screen/y DEO2 |
|
80 |
- #81 .Screen/sprite DEO |
|
81 |
- .center/x LDZ2 #0050 ADD2 .Screen/x DEO2 |
|
82 |
- #91 .Screen/sprite DEO |
|
83 |
- .center/x LDZ2 #0048 ADD2 .Screen/x DEO2 |
|
84 |
- .center/y LDZ2 #0038 ADD2 .Screen/y DEO2 |
|
85 |
- #a1 .Screen/sprite DEO |
|
86 |
- .center/x LDZ2 #0050 ADD2 .Screen/x DEO2 |
|
87 |
- #b1 .Screen/sprite DEO |
|
113 |
+ .Screen/y DEO2 |
|
114 |
+ .Screen/x DEO2 |
|
115 |
+ |
|
116 |
+ #00 STHkr ADD .Screen/sprite DEO |
|
117 |
+ .Screen/x DEI2 #0008 ADD2 .Screen/x DEO2 |
|
118 |
+ #10 STHkr ADD .Screen/sprite DEO |
|
119 |
+ .Screen/x DEI2 #0008 SUB2 .Screen/x DEO2 |
|
120 |
+ .Screen/y DEI2 #0008 ADD2 .Screen/y DEO2 |
|
121 |
+ #20 STHkr ADD .Screen/sprite DEO |
|
122 |
+ .Screen/x DEI2 #0008 ADD2 .Screen/x DEO2 |
|
123 |
+ #30 STHr ADD .Screen/sprite DEO |
|
88 | 124 |
|
89 | 125 |
RTN |
90 | 126 |
|
... | ... |
@@ -12,6 +12,16 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
12 | 12 |
WITH REGARD TO THIS SOFTWARE. |
13 | 13 |
*/ |
14 | 14 |
|
15 |
+static Uint8 blending1bpp[2][16] = { |
|
16 |
+ {0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3}, |
|
17 |
+ {0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3}}; |
|
18 |
+ |
|
19 |
+static Uint8 blending2bpp[4][16] = { |
|
20 |
+ {0, 0, 0, 0, 1, 0, 1, 1, 2, 2, 0, 2, 3, 3, 3, 0}, |
|
21 |
+ {0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3}, |
|
22 |
+ {1, 2, 3, 1, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2, 3, 1}, |
|
23 |
+ {2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2}}; |
|
24 |
+ |
|
15 | 25 |
void |
16 | 26 |
clear(Ppu *p) |
17 | 27 |
{ |
... | ... |
@@ -40,7 +50,7 @@ puticn(Ppu *p, Uint8 layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, Uint |
40 | 50 |
layer, |
41 | 51 |
x + (flipx ? 7 - h : h), |
42 | 52 |
y + (flipy ? 7 - v : v), |
43 |
- ch1 ? (color & 0x3) : (color >> 0x2)); |
|
53 |
+ blending1bpp[ch1][color]); |
|
44 | 54 |
} |
45 | 55 |
} |
46 | 56 |
|
... | ... |
@@ -52,13 +62,13 @@ putchr(Ppu *p, Uint8 layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, Uint |
52 | 62 |
for(h = 0; h < 8; h++) { |
53 | 63 |
Uint8 ch1 = ((sprite[v] >> (7 - h)) & 0x1); |
54 | 64 |
Uint8 ch2 = ((sprite[v + 8] >> (7 - h)) & 0x1); |
55 |
- Uint8 id = ch1 + ch2 * 2; |
|
56 |
- if(id || color > 0x7) |
|
65 |
+ Uint8 ch = ch1 + ch2 * 2; |
|
66 |
+ if(ch || (color != 0x05 && color != 0x0a && color != 0x0f)) |
|
57 | 67 |
putpixel(p, |
58 | 68 |
layer, |
59 | 69 |
x + (flipx ? 7 - h : h), |
60 | 70 |
y + (flipy ? 7 - v : v), |
61 |
- (id < 2 ? id : color / 2 + id * (color % 8)) & 0x3); |
|
71 |
+ blending2bpp[ch][color]); |
|
62 | 72 |
} |
63 | 73 |
} |
64 | 74 |
|