The PPU require-draw flag is renamed to reqdraw

This commit is contained in:
neauoire 2021-09-29 16:14:13 -07:00
parent 7f3a889771
commit f3b3823b0c
3 changed files with 6 additions and 5 deletions

View File

@ -22,7 +22,7 @@ static Uint8 blending[5][16] = {
void void
ppu_frame(Ppu *p) ppu_frame(Ppu *p)
{ {
p->redraw = 0; p->reqdraw = 0;
p->i0 = p->width / PPW + p->height * p->stride; p->i0 = p->width / PPW + p->height * p->stride;
p->i1 = 0; p->i1 = 0;
} }
@ -53,7 +53,7 @@ ppu_write(Ppu *p, int fg, Uint16 x, Uint16 y, Uint8 color)
p->dat[i] &= ~(3 << shift); p->dat[i] &= ~(3 << shift);
p->dat[i] |= color << shift; p->dat[i] |= color << shift;
if((v ^ p->dat[i]) != 0) { if((v ^ p->dat[i]) != 0) {
p->redraw = 1; p->reqdraw = 1;
p->i0 = p->i0 < i ? p->i0 : i; p->i0 = p->i0 < i ? p->i0 : i;
p->i1 = p->i1 > i ? p->i1 : i; p->i1 = p->i1 > i ? p->i1 : i;
} }

View File

@ -22,8 +22,9 @@ typedef unsigned short Uint16;
typedef unsigned int Uint32; typedef unsigned int Uint32;
typedef struct Ppu { typedef struct Ppu {
Uint8 reqdraw;
Uint16 width, height; Uint16 width, height;
unsigned int i0, i1, redraw, *dat, stride; unsigned int i0, i1, *dat, stride;
} Ppu; } Ppu;
Uint8 ppu_read(Ppu *p, Uint16 x, Uint16 y); Uint8 ppu_read(Ppu *p, Uint16 x, Uint16 y);

View File

@ -220,7 +220,7 @@ redraw(Uxn *u)
SDL_Rect up = gRect; SDL_Rect up = gRect;
if(devsystem->dat[0xe]) if(devsystem->dat[0xe])
draw_inspect(&ppu, u->wst.dat, u->wst.ptr, u->rst.ptr, u->ram.dat); draw_inspect(&ppu, u->wst.dat, u->wst.ptr, u->rst.ptr, u->ram.dat);
if(!reqdraw && ppu.redraw) { if(!reqdraw && ppu.reqdraw) {
y0 = ppu.i0 / ppu.stride; y0 = ppu.i0 / ppu.stride;
y1 = ppu.i1 / ppu.stride + 1; y1 = ppu.i1 / ppu.stride + 1;
up.y += y0; up.y += y0;
@ -546,7 +546,7 @@ run(Uxn *u)
} }
} }
uxn_eval(u, devscreen->vector); uxn_eval(u, devscreen->vector);
if(reqdraw || ppu.redraw || devsystem->dat[0xe]) if(reqdraw || ppu.reqdraw || devsystem->dat[0xe])
redraw(u); redraw(u);
if(!BENCH) { if(!BENCH) {
elapsed = (SDL_GetPerformanceCounter() - start) / (double)SDL_GetPerformanceFrequency() * 1000.0f; elapsed = (SDL_GetPerformanceCounter() - start) / (double)SDL_GetPerformanceFrequency() * 1000.0f;