Update the screen auto-byte to bring it up to spec

This commit is contained in:
Bad Diode 2022-03-14 10:12:49 +01:00
parent dd6e5c4ee9
commit d87d43ce22
1 changed files with 16 additions and 10 deletions

View File

@ -364,27 +364,33 @@ screen_deo(Device *d, u8 port) {
if(d->dat[0x6] & 0x02) DEVPOKE16(0xa, y + 1); /* auto y+1 */ if(d->dat[0x6] & 0x02) DEVPOKE16(0xa, y + 1); /* auto y+1 */
} break; } break;
case 0xf: { case 0xf: {
u16 x, y, addr; u16 x, y, dx, dy, addr;
u8 twobpp = !!(d->dat[0xf] & 0x80); u8 twobpp = !!(d->dat[0xf] & 0x80);
DEVPEEK16(x, 0x8); DEVPEEK16(x, 0x8);
DEVPEEK16(y, 0xa); DEVPEEK16(y, 0xa);
DEVPEEK16(addr, 0xc); DEVPEEK16(addr, 0xc);
if(addr > 0xfff8 - twobpp * 8) { u8 n = d->dat[0x6] >> 4;
dx = (d->dat[0x6] & 0x01) << 3;
dy = (d->dat[0x6] & 0x02) << 2;
if(addr > 0x10000 - ((n + 1) << (3 + twobpp))) {
return; return;
} }
u8 *layer = (d->dat[0xf] & 0x40) ? pixels_fg : pixels_bg; u8 *layer = (d->dat[0xf] & 0x40) ? pixels_fg : pixels_bg;
u8 color = d->dat[0xf] & 0xf; u8 color = d->dat[0xf] & 0xf;
u8 flipx = d->dat[0xf] & 0x10; u8 flipx = d->dat[0xf] & 0x10;
u8 flipy = d->dat[0xf] & 0x20; u8 flipy = d->dat[0xf] & 0x20;
u8 *sprite = &d->u->ram[addr]; for(size_t i = 0; i <= n; i++) {
if (twobpp) { u8 *sprite = &d->u->ram[addr];
ppu_2bpp(layer, x, y, sprite, color, flipx, flipy); if (twobpp) {
} else { ppu_2bpp(layer, x + dy * i, y + dx * i, sprite, color, flipx, flipy);
ppu_1bpp(layer, x, y, sprite, color, flipx, flipy); } else {
ppu_1bpp(layer, x + dy * i, y + dx * i, sprite, color, flipx, flipy);
}
addr += (d->dat[0x6] & 0x04) << (1 + twobpp);
} }
if(d->dat[0x6] & 0x04) DEVPOKE16(0xc, addr + 8 + twobpp * 8); /* auto addr+length */ DEVPOKE16(0xc, addr); /* auto addr+length */
if(d->dat[0x6] & 0x01) DEVPOKE16(0x8, x + 8); /* auto x+8 */ DEVPOKE16(0x8, x + dx); /* auto x+8 */
if(d->dat[0x6] & 0x02) DEVPOKE16(0xa, y + 8); /* auto y+8 */ DEVPOKE16(0xa, y + dy); /* auto y+8 */
} break; } break;
} }
reqdraw = 1; reqdraw = 1;