Started implementing the sprite port for the screen device
This commit is contained in:
parent
486e79c48d
commit
d2c3d0e524
2
build.sh
2
build.sh
|
@ -54,7 +54,7 @@ then
|
|||
fi
|
||||
|
||||
echo "Assembling.."
|
||||
./bin/uxnasm projects/examples/demos/piano.tal bin/piano.rom
|
||||
./bin/uxnasm projects/examples/devices/piano.tal bin/piano.rom
|
||||
|
||||
echo "Running.."
|
||||
./bin/uxnemu bin/piano.rom
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
( 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 ]
|
||||
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 &sprite $1 ]
|
||||
|
||||
( variables )
|
||||
|
||||
|
@ -44,7 +44,7 @@ BRK
|
|||
.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/color DEO
|
||||
( draw ) OVR .Screen/sprite DEO
|
||||
( incr ) SWP #01 ADD SWP
|
||||
NEQk ,&loop JCN
|
||||
POP2
|
||||
|
@ -60,12 +60,12 @@ RTN
|
|||
OVR #08 MUL #00 SWP
|
||||
.center/x LDZ2 #0040 SUB2 ADD2 .Screen/x DEO2
|
||||
.center/y LDZ2 #0050 SUB2 .Screen/y DEO2
|
||||
( draw ) #21 .Screen/color DEO
|
||||
( draw ) #01 .Screen/sprite DEO
|
||||
( y-axis )
|
||||
OVR #08 MUL #00 SWP
|
||||
.center/y LDZ2 #0040 SUB2 ADD2 .Screen/y DEO2
|
||||
.center/x LDZ2 #0050 SUB2 .Screen/x DEO2
|
||||
( draw ) #21 .Screen/color DEO
|
||||
( draw ) #01 .Screen/sprite DEO
|
||||
( incr ) SWP #01 ADD SWP
|
||||
LTHk ,&loop JCN
|
||||
POP2
|
||||
|
@ -77,14 +77,14 @@ RTN
|
|||
;preview_icn .Screen/addr DEO2
|
||||
.center/x LDZ2 #0048 ADD2 .Screen/x DEO2
|
||||
.center/y LDZ2 #0030 ADD2 .Screen/y DEO2
|
||||
#21 .Screen/color DEO
|
||||
#01 .Screen/sprite DEO
|
||||
.center/x LDZ2 #0050 ADD2 .Screen/x DEO2
|
||||
#61 .Screen/color DEO
|
||||
#11 .Screen/sprite DEO
|
||||
.center/x LDZ2 #0048 ADD2 .Screen/x DEO2
|
||||
.center/y LDZ2 #0038 ADD2 .Screen/y DEO2
|
||||
#a1 .Screen/color DEO
|
||||
#21 .Screen/sprite DEO
|
||||
.center/x LDZ2 #0050 ADD2 .Screen/x DEO2
|
||||
#f1 .Screen/color DEO
|
||||
#31 .Screen/sprite DEO
|
||||
|
||||
RTN
|
||||
|
||||
|
@ -99,4 +99,4 @@ RTN
|
|||
007c 8282 7c82 827c 007c 8282 7e02 827c
|
||||
007c 8202 7e82 827e 00fc 8282 fc82 82fc
|
||||
007c 8280 8080 827c 00fc 8282 8282 82fc
|
||||
007c 8280 f080 827c 007c 8280 f080 8080
|
||||
007c 8280 f080 827c 007c 8280 f080 8080
|
||||
|
|
|
@ -53,12 +53,14 @@ 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);
|
||||
if(ch1 == 1 || (color != 0x05 && color != 0x0a && color != 0x0f))
|
||||
putpixel(p,
|
||||
layer,
|
||||
x + (flipx ? 7 - h : h),
|
||||
y + (flipy ? 7 - v : v),
|
||||
ch1 ? color % 4 : color / 4);
|
||||
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);
|
||||
Uint8 pc = ch1 ? (color & 0x3) : (color >> 0x2);
|
||||
layer->pixels[py * p->width + px] = layer->colors[pc];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
10
src/uxnemu.c
10
src/uxnemu.c
|
@ -306,6 +306,16 @@ screen_talk(Device *d, Uint8 b0, Uint8 w)
|
|||
putchr(&ppu, layer, x, y, addr, d->dat[0xe] & 0xf, mode & 0x2, mode & 0x4);
|
||||
}
|
||||
reqdraw = 1;
|
||||
} else if(w && b0 == 0xf) {
|
||||
Uint16 x = mempeek16(d->dat, 0x8);
|
||||
Uint16 y = mempeek16(d->dat, 0xa);
|
||||
Layer *layer = d->dat[0xf] >> 0x6 & 0x1 ? &ppu.fg : &ppu.bg;
|
||||
Uint8 *addr = &d->mem[mempeek16(d->dat, 0xc)];
|
||||
if(d->dat[0xf] >> 0x7 & 0x1)
|
||||
putchr(&ppu, layer, x, y, addr, d->dat[0xf] & 0xf, d->dat[0xf] >> 0x4 & 0x1, d->dat[0xf] >> 0x5 & 0x1);
|
||||
else
|
||||
puticn(&ppu, layer, x, y, addr, d->dat[0xf] & 0xf, d->dat[0xf] >> 0x4 & 0x1, d->dat[0xf] >> 0x5 & 0x1);
|
||||
reqdraw = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue