From d87d43ce228e9b2e795fa85c5dee3708c2812625 Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Mon, 14 Mar 2022 10:12:49 +0100 Subject: [PATCH] Update the screen auto-byte to bring it up to spec --- src/main.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/main.c b/src/main.c index 8894133..fcd42a4 100644 --- a/src/main.c +++ b/src/main.c @@ -364,27 +364,33 @@ screen_deo(Device *d, u8 port) { if(d->dat[0x6] & 0x02) DEVPOKE16(0xa, y + 1); /* auto y+1 */ } break; case 0xf: { - u16 x, y, addr; + u16 x, y, dx, dy, addr; u8 twobpp = !!(d->dat[0xf] & 0x80); DEVPEEK16(x, 0x8); DEVPEEK16(y, 0xa); 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; } u8 *layer = (d->dat[0xf] & 0x40) ? pixels_fg : pixels_bg; u8 color = d->dat[0xf] & 0xf; u8 flipx = d->dat[0xf] & 0x10; u8 flipy = d->dat[0xf] & 0x20; - u8 *sprite = &d->u->ram[addr]; - if (twobpp) { - ppu_2bpp(layer, x, y, sprite, color, flipx, flipy); - } else { - ppu_1bpp(layer, x, y, sprite, color, flipx, flipy); + for(size_t i = 0; i <= n; i++) { + u8 *sprite = &d->u->ram[addr]; + if (twobpp) { + ppu_2bpp(layer, x + dy * i, y + dx * i, 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 */ - if(d->dat[0x6] & 0x01) DEVPOKE16(0x8, x + 8); /* auto x+8 */ - if(d->dat[0x6] & 0x02) DEVPOKE16(0xa, y + 8); /* auto y+8 */ + DEVPOKE16(0xc, addr); /* auto addr+length */ + DEVPOKE16(0x8, x + dx); /* auto x+8 */ + DEVPOKE16(0xa, y + dy); /* auto y+8 */ } break; } reqdraw = 1;