M src/devices/ppu.c => src/devices/ppu.c +9 -0
@@ 58,6 58,15 @@ ppu_pixel(Ppu *p, uint8_t fg, uint16_t x, uint16_t y, uint8_t color)
}
void
+screen_wipe(Ppu *p, uint8_t fg, uint16_t x, uint16_t y)
+{
+ int v, h;
+ for(v = 0; v < 8; v++)
+ for(h = 0; h < 8; h++)
+ ppu_pixel(p, fg, x + h, y + v, 1);
+}
+
+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)
{
int v, h, opaque = (color % 5) || !color;
M src/devices/ppu.h => src/devices/ppu.h +1 -0
@@ 40,5 40,6 @@ typedef struct Ppu {
int ppu_init(Ppu *p, uint32_t *framebuffer);
void ppu_pixel(Ppu *p, uint8_t fg, uint16_t x, uint16_t y, uint8_t color);
+void screen_wipe(Ppu *p, uint8_t fg, uint16_t x, uint16_t y);
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 +6 -2
@@ 131,8 131,12 @@ screen_deo(Uint8 *d, Uint8 port)
if(addr >= 0xfff0)
return;
for(i = 0; i <= n; i++) {
- 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);
+ if(!(d[0xf] & 0xf))
+ screen_wipe(&ppu, fg, x + dy * i, y + dx * i);
+ else {
+ 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 */
POKDEV(0x8, x + dx); /* auto x+8 */