diff options
author | Bad Diode <bd@badd10de.dev> | 2022-03-14 10:12:49 +0100 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2022-03-14 10:12:49 +0100 |
commit | d87d43ce228e9b2e795fa85c5dee3708c2812625 (patch) | |
tree | 3e9ea394e97f3b9b4a7d0d6906e0980a7716cf06 | |
parent | dd6e5c4ee957006066c15fe4aba0c078c57fa15a (diff) | |
download | uxnfb-d87d43ce228e9b2e795fa85c5dee3708c2812625.tar.gz uxnfb-d87d43ce228e9b2e795fa85c5dee3708c2812625.zip |
Update the screen auto-byte to bring it up to spec
-rw-r--r-- | src/main.c | 26 |
1 files changed, 16 insertions, 10 deletions
@@ -364,27 +364,33 @@ screen_deo(Device *d, u8 port) { | |||
364 | if(d->dat[0x6] & 0x02) DEVPOKE16(0xa, y + 1); /* auto y+1 */ | 364 | if(d->dat[0x6] & 0x02) DEVPOKE16(0xa, y + 1); /* auto y+1 */ |
365 | } break; | 365 | } break; |
366 | case 0xf: { | 366 | case 0xf: { |
367 | u16 x, y, addr; | 367 | u16 x, y, dx, dy, addr; |
368 | u8 twobpp = !!(d->dat[0xf] & 0x80); | 368 | u8 twobpp = !!(d->dat[0xf] & 0x80); |
369 | DEVPEEK16(x, 0x8); | 369 | DEVPEEK16(x, 0x8); |
370 | DEVPEEK16(y, 0xa); | 370 | DEVPEEK16(y, 0xa); |
371 | DEVPEEK16(addr, 0xc); | 371 | DEVPEEK16(addr, 0xc); |
372 | if(addr > 0xfff8 - twobpp * 8) { | 372 | u8 n = d->dat[0x6] >> 4; |
373 | dx = (d->dat[0x6] & 0x01) << 3; | ||
374 | dy = (d->dat[0x6] & 0x02) << 2; | ||
375 | if(addr > 0x10000 - ((n + 1) << (3 + twobpp))) { | ||
373 | return; | 376 | return; |
374 | } | 377 | } |
375 | u8 *layer = (d->dat[0xf] & 0x40) ? pixels_fg : pixels_bg; | 378 | u8 *layer = (d->dat[0xf] & 0x40) ? pixels_fg : pixels_bg; |
376 | u8 color = d->dat[0xf] & 0xf; | 379 | u8 color = d->dat[0xf] & 0xf; |
377 | u8 flipx = d->dat[0xf] & 0x10; | 380 | u8 flipx = d->dat[0xf] & 0x10; |
378 | u8 flipy = d->dat[0xf] & 0x20; | 381 | u8 flipy = d->dat[0xf] & 0x20; |
379 | u8 *sprite = &d->u->ram[addr]; | 382 | for(size_t i = 0; i <= n; i++) { |
380 | if (twobpp) { | 383 | u8 *sprite = &d->u->ram[addr]; |
381 | ppu_2bpp(layer, x, y, sprite, color, flipx, flipy); | 384 | if (twobpp) { |
382 | } else { | 385 | ppu_2bpp(layer, x + dy * i, y + dx * i, sprite, color, flipx, flipy); |
383 | ppu_1bpp(layer, x, y, sprite, color, flipx, flipy); | 386 | } else { |
387 | ppu_1bpp(layer, x + dy * i, y + dx * i, sprite, color, flipx, flipy); | ||
388 | } | ||
389 | addr += (d->dat[0x6] & 0x04) << (1 + twobpp); | ||
384 | } | 390 | } |
385 | if(d->dat[0x6] & 0x04) DEVPOKE16(0xc, addr + 8 + twobpp * 8); /* auto addr+length */ | 391 | DEVPOKE16(0xc, addr); /* auto addr+length */ |
386 | if(d->dat[0x6] & 0x01) DEVPOKE16(0x8, x + 8); /* auto x+8 */ | 392 | DEVPOKE16(0x8, x + dx); /* auto x+8 */ |
387 | if(d->dat[0x6] & 0x02) DEVPOKE16(0xa, y + 8); /* auto y+8 */ | 393 | DEVPOKE16(0xa, y + dy); /* auto y+8 */ |
388 | } break; | 394 | } break; |
389 | } | 395 | } |
390 | reqdraw = 1; | 396 | reqdraw = 1; |