commit 8bf99e6d7620b8bf54fe8ae6031969ec39a0ccb6
parent d2c3d0e524e801485c3f5cae89ea976d8146941f
Author: neauoire <aliceffekt@gmail.com>
Date: Fri, 30 Jul 2021 20:10:26 -0700
Changed the screen.tal colors to fit the Varvara docs
Diffstat:
3 files changed, 49 insertions(+), 34 deletions(-)
diff --git a/build.sh b/build.sh
@@ -54,7 +54,7 @@ then
fi
echo "Assembling.."
-./bin/uxnasm projects/examples/devices/piano.tal bin/piano.rom
+./bin/uxnasm projects/examples/demos/piano.tal bin/piano.rom
echo "Running.."
./bin/uxnemu bin/piano.rom
diff --git a/projects/examples/devices/screen.tal b/projects/examples/devices/screen.tal
@@ -1,13 +1,12 @@
( dev/screen )
%RTN { JMP2r }
-%MOD { DUP2 DIV MUL SUB }
%2// { #01 SFT2 }
( devices )
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
-|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 &sprite $1 ]
+|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 ]
( variables )
@@ -20,9 +19,9 @@
|0100 ( -> )
( theme )
- #025f .System/r DEO2
- #0c2f .System/g DEO2
- #0da4 .System/b DEO2
+ #f07f .System/r DEO2
+ #f0e0 .System/g DEO2
+ #f0c0 .System/b DEO2
( find screen center )
.Screen/width DEI2 2// .center/x STZ2
@@ -32,25 +31,10 @@
;draw-table JSR2
;draw-sprites JSR2
;draw-circle JSR2
+ ;draw-pixels JSR2
BRK
-@draw-sprites ( -- )
-
- ;preview_icn .Screen/addr DEO2
- #00 #00
- &loop
- ( move ) OVR #0f AND #40 SFT #02 DIV #00 SWP
- .center/x LDZ2 #0040 SUB2 ADD2 .Screen/x DEO2
- ( move ) OVR #f0 AND #02 DIV #00 SWP
- .center/y LDZ2 #0040 SUB2 ADD2 .Screen/y DEO2
- ( draw ) OVR .Screen/sprite DEO
- ( incr ) SWP #01 ADD SWP
- NEQk ,&loop JCN
- POP2
-
-RTN
-
@draw-table ( -- )
#00 #10
@@ -72,19 +56,49 @@ RTN
RTN
+@draw-sprites ( -- )
+
+ ;preview_icn .Screen/addr DEO2
+ #00 #00
+ &loop
+ ( move ) OVR #0f AND #40 SFT #02 DIV #00 SWP
+ .center/x LDZ2 #0040 SUB2 ADD2 .Screen/x DEO2
+ ( move ) OVR #f0 AND #02 DIV #00 SWP
+ .center/y LDZ2 #0040 SUB2 ADD2 .Screen/y DEO2
+ ( draw ) OVR .Screen/sprite DEO
+ ( incr ) SWP #01 ADD SWP
+ NEQk ,&loop JCN
+ POP2
+
+RTN
+
@draw-circle ( -- )
;preview_icn .Screen/addr DEO2
.center/x LDZ2 #0048 ADD2 .Screen/x DEO2
.center/y LDZ2 #0030 ADD2 .Screen/y DEO2
- #01 .Screen/sprite DEO
+ #81 .Screen/sprite DEO
.center/x LDZ2 #0050 ADD2 .Screen/x DEO2
- #11 .Screen/sprite DEO
+ #91 .Screen/sprite DEO
.center/x LDZ2 #0048 ADD2 .Screen/x DEO2
.center/y LDZ2 #0038 ADD2 .Screen/y DEO2
- #21 .Screen/sprite DEO
+ #a1 .Screen/sprite DEO
.center/x LDZ2 #0050 ADD2 .Screen/x DEO2
- #31 .Screen/sprite DEO
+ #b1 .Screen/sprite DEO
+
+RTN
+
+@draw-pixels ( -- )
+
+ .center/y LDZ2 #0040 SUB2 .Screen/y DEO2
+ .center/x LDZ2 #0048 ADD2 .Screen/x DEO2
+ #00 .Screen/pixel DEO
+ .center/x LDZ2 #0049 ADD2 .Screen/x DEO2
+ #01 .Screen/pixel DEO
+ .center/x LDZ2 #004a ADD2 .Screen/x DEO2
+ #02 .Screen/pixel DEO
+ .center/x LDZ2 #004b ADD2 .Screen/x DEO2
+ #03 .Screen/pixel DEO
RTN
diff --git a/src/devices/ppu.c b/src/devices/ppu.c
@@ -53,11 +53,11 @@ puticn(Ppu *p, Layer *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, Uin
for(v = 0; v < 8; v++)
for(h = 0; h < 8; h++) {
Uint8 ch1 = ((sprite[v] >> (7 - h)) & 0x1);
+ Uint16 px = x + (flipx ? 7 - h : h);
+ Uint16 py = y + (flipy ? 7 - v : v);
if(!(ch1 || color % 0x5))
continue;
- if(x < p->width && y < p->height) {
- Uint16 px = x + (flipx ? 7 - h : h);
- Uint16 py = y + (flipy ? 7 - v : v);
+ if(px < p->width && py < p->height) {
Uint8 pc = ch1 ? (color & 0x3) : (color >> 0x2);
layer->pixels[py * p->width + px] = layer->colors[pc];
}
@@ -72,11 +72,12 @@ putchr(Ppu *p, Layer *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, Uin
for(h = 0; h < 8; h++) {
Uint8 ch1 = ((sprite[v] >> (7 - h)) & 0x1) * color;
Uint8 ch2 = ((sprite[v + 8] >> (7 - h)) & 0x1) * color;
- putpixel(p,
- layer,
- x + (flipx ? 7 - h : h),
- y + (flipy ? 7 - v : v),
- (((ch1 + ch2 * 2) + color / 4) & 0x3));
+ Uint16 px = x + (flipx ? 7 - h : h);
+ Uint16 py = y + (flipy ? 7 - v : v);
+ if(px < p->width && py < p->height) {
+ Uint8 pc = ((ch1 + ch2 * 2) + color / 4) & 0x3;
+ layer->pixels[py * p->width + px] = layer->colors[pc];
+ }
}
}