Redraw is now part of the PPU
This commit is contained in:
parent
0794070adf
commit
250e338d07
|
@ -75,6 +75,16 @@ ppu_clear(Ppu *p, Uint8 mask)
|
|||
p->pixels[i] &= mask;
|
||||
}
|
||||
|
||||
void
|
||||
ppu_redraw(Ppu *p, Uint32 *screen)
|
||||
{
|
||||
Uint16 x, y;
|
||||
for(y = 0; y < p->height; ++y)
|
||||
for(x = 0; x < p->width; ++x)
|
||||
screen[x + y * p->width] = p->palette[ppu_read(p, x, y)];
|
||||
p->reqdraw = 0;
|
||||
}
|
||||
|
||||
Uint8
|
||||
ppu_read(Ppu *p, Uint16 x, Uint16 y)
|
||||
{
|
||||
|
|
|
@ -29,6 +29,7 @@ typedef struct Ppu {
|
|||
void ppu_palette(Ppu *p, Uint8 *addr);
|
||||
void ppu_resize(Ppu *p, Uint16 width, Uint16 height);
|
||||
void ppu_clear(Ppu *p, Uint8 layer);
|
||||
void ppu_redraw(Ppu *p, Uint32 *screen);
|
||||
Uint8 ppu_read(Ppu *p, Uint16 x, Uint16 y);
|
||||
void ppu_write(Ppu *p, Uint8 layer, Uint16 x, Uint16 y, Uint8 color);
|
||||
void ppu_1bpp(Ppu *p, Uint8 layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, Uint8 flipx, Uint8 flipy);
|
||||
|
|
|
@ -152,18 +152,14 @@ capture_screen(void)
|
|||
static void
|
||||
redraw(Uxn *u)
|
||||
{
|
||||
Uint16 x, y;
|
||||
if(devsystem->dat[0xe])
|
||||
ppu_debug(&ppu, u->wst.dat, u->wst.ptr, u->rst.ptr, u->ram.dat);
|
||||
for(y = 0; y < ppu.height; ++y)
|
||||
for(x = 0; x < ppu.width; ++x)
|
||||
ppu_screen[x + y * ppu.width] = ppu.palette[ppu_read(&ppu, x, y)];
|
||||
ppu_redraw(&ppu, ppu_screen);
|
||||
if(SDL_UpdateTexture(gTexture, &gRect, ppu_screen, ppu.width * sizeof(Uint32)) != 0)
|
||||
error("SDL_UpdateTexture", SDL_GetError());
|
||||
SDL_RenderClear(gRenderer);
|
||||
SDL_RenderCopy(gRenderer, gTexture, NULL, NULL);
|
||||
SDL_RenderPresent(gRenderer);
|
||||
ppu.reqdraw = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in New Issue