uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit c494e42cf2bdee38e842002f2a38e4108f869378
parent bac54f1fd9a9f372e4fdd5e7585cf465159f0e45
Author: neauoire <aliceffekt@gmail.com>
Date:   Wed, 29 Sep 2021 20:54:27 -0700

Drawing is pixel-perfect again

Diffstat:
Msrc/devices/ppu.c | 24++++++++++++++++--------
Msrc/uxnemu.c | 1-
2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/src/devices/ppu.c b/src/devices/ppu.c @@ -24,12 +24,6 @@ static Uint8 blending[5][16] = { {2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2}, {1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0}}; -static Uint16 -ppu_row(Ppu *p, Uint16 x, Uint16 y) -{ - return (y % 8) + ((x / 8 + y / 8 * p->width / 8) * 16); -} - static void ppu_clear(Ppu *p) { @@ -46,9 +40,22 @@ Uint8 ppu_read(Ppu *p, Uint16 x, Uint16 y) { int row = (x + y * p->width) / 0x2; - int shift = (1 - (x & 0x1)) * 0x4; - return p->pixels[row] & 0x3; + if(x % 2) { + if(p->pixels[row] & 0x0c) { + return (p->pixels[row] >> 0x2) & 0x3; + } else { + return (p->pixels[row] >> 0x0) & 0x3; + } + } else { + if(p->pixels[row] & 0xc0) { + return (p->pixels[row] >> 0x6) & 0x3; + } else { + return (p->pixels[row] >> 0x4) & 0x3; + } + } + + return 0; } void @@ -65,6 +72,7 @@ ppu_write(Ppu *p, Uint8 layer, Uint16 x, Uint16 y, Uint8 color) next |= color << (4 + (layer * 2)); } p->pixels[row] = next; + p->reqdraw = 1; } void diff --git a/src/uxnemu.c b/src/uxnemu.c @@ -410,7 +410,6 @@ screen_talk(Device *d, Uint8 b0, Uint8 w) } if(d->dat[0x6] & 0x01) poke16(d->dat, 0x8, x + 8); /* auto x+8 */ if(d->dat[0x6] & 0x02) poke16(d->dat, 0xa, y + 8); /* auto y+8 */ - ppu.reqdraw = 1; break; } }