Changed the screen.tal colors to fit the Varvara docs

This commit is contained in:
neauoire 2021-07-30 20:10:26 -07:00
parent d2c3d0e524
commit 8bf99e6d76
3 changed files with 49 additions and 34 deletions

View File

@ -54,7 +54,7 @@ then
fi fi
echo "Assembling.." echo "Assembling.."
./bin/uxnasm projects/examples/devices/piano.tal bin/piano.rom ./bin/uxnasm projects/examples/demos/piano.tal bin/piano.rom
echo "Running.." echo "Running.."
./bin/uxnemu bin/piano.rom ./bin/uxnemu bin/piano.rom

View File

@ -1,13 +1,12 @@
( dev/screen ) ( dev/screen )
%RTN { JMP2r } %RTN { JMP2r }
%MOD { DUP2 DIV MUL SUB }
%2// { #01 SFT2 } %2// { #01 SFT2 }
( devices ) ( devices )
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] |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 ) ( variables )
@ -20,9 +19,9 @@
|0100 ( -> ) |0100 ( -> )
( theme ) ( theme )
#025f .System/r DEO2 #f07f .System/r DEO2
#0c2f .System/g DEO2 #f0e0 .System/g DEO2
#0da4 .System/b DEO2 #f0c0 .System/b DEO2
( find screen center ) ( find screen center )
.Screen/width DEI2 2// .center/x STZ2 .Screen/width DEI2 2// .center/x STZ2
@ -32,25 +31,10 @@
;draw-table JSR2 ;draw-table JSR2
;draw-sprites JSR2 ;draw-sprites JSR2
;draw-circle JSR2 ;draw-circle JSR2
;draw-pixels JSR2
BRK 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 ( -- ) @draw-table ( -- )
#00 #10 #00 #10
@ -72,19 +56,49 @@ RTN
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 ( -- ) @draw-circle ( -- )
;preview_icn .Screen/addr DEO2 ;preview_icn .Screen/addr DEO2
.center/x LDZ2 #0048 ADD2 .Screen/x DEO2 .center/x LDZ2 #0048 ADD2 .Screen/x DEO2
.center/y LDZ2 #0030 ADD2 .Screen/y 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 .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/x LDZ2 #0048 ADD2 .Screen/x DEO2
.center/y LDZ2 #0038 ADD2 .Screen/y 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 .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 RTN

View File

@ -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(v = 0; v < 8; v++)
for(h = 0; h < 8; h++) { for(h = 0; h < 8; h++) {
Uint8 ch1 = ((sprite[v] >> (7 - h)) & 0x1); Uint8 ch1 = ((sprite[v] >> (7 - h)) & 0x1);
if(!(ch1 || color % 0x5))
continue;
if(x < p->width && y < p->height) {
Uint16 px = x + (flipx ? 7 - h : h); Uint16 px = x + (flipx ? 7 - h : h);
Uint16 py = y + (flipy ? 7 - v : v); Uint16 py = y + (flipy ? 7 - v : v);
if(!(ch1 || color % 0x5))
continue;
if(px < p->width && py < p->height) {
Uint8 pc = ch1 ? (color & 0x3) : (color >> 0x2); Uint8 pc = ch1 ? (color & 0x3) : (color >> 0x2);
layer->pixels[py * p->width + px] = layer->colors[pc]; 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++) { for(h = 0; h < 8; h++) {
Uint8 ch1 = ((sprite[v] >> (7 - h)) & 0x1) * color; Uint8 ch1 = ((sprite[v] >> (7 - h)) & 0x1) * color;
Uint8 ch2 = ((sprite[v + 8] >> (7 - h)) & 0x1) * color; Uint8 ch2 = ((sprite[v + 8] >> (7 - h)) & 0x1) * color;
putpixel(p, Uint16 px = x + (flipx ? 7 - h : h);
layer, Uint16 py = y + (flipy ? 7 - v : v);
x + (flipx ? 7 - h : h), if(px < p->width && py < p->height) {
y + (flipy ? 7 - v : v), Uint8 pc = ((ch1 + ch2 * 2) + color / 4) & 0x3;
(((ch1 + ch2 * 2) + color / 4) & 0x3)); layer->pixels[py * p->width + px] = layer->colors[pc];
}
} }
} }