Inlined ppu_read

This commit is contained in:
neauoire 2021-12-24 10:02:23 -08:00
parent 3fb4d40eb0
commit cc6f2c8b29
1 changed files with 5 additions and 12 deletions

View File

@ -84,21 +84,14 @@ ppu_redraw(Ppu *p, Uint32 *screen)
{ {
Uint16 x, y; Uint16 x, y;
for(y = 0; y < p->height; ++y) for(y = 0; y < p->height; ++y)
for(x = 0; x < p->width; ++x) for(x = 0; x < p->width; ++x) {
screen[x + y * p->width] = p->palette[ppu_read(p, x, y)]; Uint32 row = (x + y * p->width);
Uint8 color = p->fg[row] ? p->fg[row] : p->bg[row];
screen[x + y * p->width] = p->palette[color];
}
p->reqdraw = 0; p->reqdraw = 0;
} }
Uint8
ppu_read(Ppu *p, Uint16 x, Uint16 y)
{
if(x < p->width && y < p->height) {
Uint32 row = (x + y * p->width);
return p->fg[row] ? p->fg[row] : p->bg[row];
}
return 0x0;
}
void void
ppu_write(Ppu *p, Uint8 *layer, Uint16 x, Uint16 y, Uint8 color) ppu_write(Ppu *p, Uint8 *layer, Uint16 x, Uint16 y, Uint8 color)
{ {