M src/devices/ppu.c => src/devices/ppu.c +7 -7
@@ 43,17 43,17 @@ render_all(Ppu *p)
}
void
-ppu_pixel(Ppu *p, uint8_t layer, uint16_t x, uint16_t y, uint8_t color)
+ppu_pixel(Ppu *p, uint8_t fg, uint16_t x, uint16_t y, uint8_t color)
{
if(x >= WIDTH || y >= HEIGHT) return;
int offset = y * STRIDE_WORDS + x / 32;
- uint32_t *px = &p->pixels[offset * 3 + layer];
+ uint32_t *px = &p->pixels[offset * 3 + fg];
uint32_t mask = 1 << ((x & 0x18) + (7 - (x & 0x7)));
if(color & 0x01)
- p->pixels[offset * 3 + layer] |= mask;
+ p->pixels[offset * 3 + fg] |= mask;
else
- p->pixels[offset * 3 + layer] &= ~mask;
- if(layer) {
+ p->pixels[offset * 3 + fg] &= ~mask;
+ if(fg) {
if(color)
p->pixels[offset * 3 + 2] |= mask;
else
@@ 63,7 63,7 @@ ppu_pixel(Ppu *p, uint8_t layer, uint16_t x, uint16_t y, uint8_t color)
}
void
-screen_blit(Ppu *p, uint8_t layer, uint16_t x, uint16_t y, uint8_t *sprite, uint8_t color, uint8_t flipx, uint8_t flipy, uint8_t twobpp)
+screen_blit(Ppu *p, uint8_t fg, uint16_t x, uint16_t y, uint8_t *sprite, uint8_t color, uint8_t flipx, uint8_t flipy, uint8_t twobpp)
{
int v, h, opaque = blending[4][color];
for(v = 0; v < 8; v++) {
@@ 72,7 72,7 @@ screen_blit(Ppu *p, uint8_t layer, uint16_t x, uint16_t y, uint8_t *sprite, uint
uint8_t ch = (c & 1) | ((c >> 7) & 2);
if(opaque || ch)
ppu_pixel(p,
- layer,
+ fg,
x + (flipx ? 7 - h : h),
y + (flipy ? 7 - v : v),
blending[ch][color]);
M src/devices/ppu.h => src/devices/ppu.h +2 -2
@@ 39,6 39,6 @@ typedef struct Ppu {
} Ppu;
int ppu_init(Ppu *p, uint32_t *framebuffer);
-void ppu_pixel(Ppu *p, uint8_t layer, uint16_t x, uint16_t y, uint8_t color);
-void screen_blit(Ppu *p, uint8_t layer, uint16_t x, uint16_t y, uint8_t *sprite, uint8_t color, uint8_t flipx, uint8_t flipy, uint8_t twobpp);
+void ppu_pixel(Ppu *p, uint8_t fg, uint16_t x, uint16_t y, uint8_t color);
+void screen_blit(Ppu *p, uint8_t fg, uint16_t x, uint16_t y, uint8_t *sprite, uint8_t color, uint8_t flipx, uint8_t flipy, uint8_t twobpp);
void render_all(Ppu *p);
M src/main.c => src/main.c +4 -4
@@ 109,10 109,10 @@ screen_deo(Uint8 *d, Uint8 port)
switch(port) {
case 0xe: {
Uint16 x, y;
- Uint8 layer = d[0xe] & 0x40;
+ Uint8 fg = !!(d[0xe] & 0x40);
PEKDEV(x, 0x8);
PEKDEV(y, 0xa);
- ppu_pixel(&ppu, !!layer, x, y, d[0xe] & 0x3);
+ ppu_pixel(&ppu, fg, x, y, d[0xe] & 0x3);
if(d[0x6] & 0x01) POKDEV(0x8, x + 1); /* auto x+1 */
if(d[0x6] & 0x02) POKDEV(0xa, y + 1); /* auto y+1 */
pd->graphics->markUpdatedRows(y, y);
@@ 121,7 121,7 @@ screen_deo(Uint8 *d, Uint8 port)
case 0xf: {
Uint16 x, y, dx, dy, addr;
Uint8 i, n, twobpp = !!(d[0xf] & 0x80);
- Uint8 layer = d[0xf] & 0x40;
+ Uint8 fg = !!(d[0xf] & 0x40);
PEKDEV(x, 0x8);
PEKDEV(y, 0xa);
PEKDEV(addr, 0xc);
@@ 133,7 133,7 @@ screen_deo(Uint8 *d, Uint8 port)
if(addr > 0x10000 - ((n + 1) << (3 + twobpp)))
return;
for(i = 0; i <= n; i++) {
- screen_blit(&ppu, !!layer, x + dy * i, y + dx * i, &u.ram[addr], d[0xf] & 0xf, d[0xf] & 0x10, d[0xf] & 0x20, twobpp);
+ screen_blit(&ppu, fg, x + dy * i, y + dx * i, &u.ram[addr], d[0xf] & 0xf, d[0xf] & 0x10, d[0xf] & 0x20, twobpp);
addr += (d[0x6] & 0x04) << (1 + twobpp);
}
POKDEV(0xc, addr); /* auto addr+length */