Do not overdraw
This commit is contained in:
parent
765724d2af
commit
243c5866ac
|
@ -41,17 +41,21 @@ ppu_set_size(Ppu *p, Uint16 width, Uint16 height)
|
|||
Uint8
|
||||
ppu_read(Ppu *p, Uint16 x, Uint16 y)
|
||||
{
|
||||
if(x < p->width && y < p->height) {
|
||||
Uint32 row = (x + y * p->width) / 0x2;
|
||||
Uint8 shift = !(x & 0x1) << 2;
|
||||
Uint8 pix = p->pixels[row] >> shift;
|
||||
if(pix & 0x0c)
|
||||
pix = pix >> 2;
|
||||
return pix & 0x3;
|
||||
}
|
||||
return 0x0;
|
||||
}
|
||||
|
||||
void
|
||||
ppu_write(Ppu *p, Uint8 layer, Uint16 x, Uint16 y, Uint8 color)
|
||||
{
|
||||
if(x < p->width && y < p->height) {
|
||||
Uint32 row = (x + y * p->width) / 0x2;
|
||||
Uint8 shift = (!(x & 0x1) << 2) + (layer << 1);
|
||||
Uint8 pix = p->pixels[row];
|
||||
|
@ -61,6 +65,7 @@ ppu_write(Ppu *p, Uint8 layer, Uint16 x, Uint16 y, Uint8 color)
|
|||
p->pixels[row] = pixnew;
|
||||
if(pix != pixnew)
|
||||
p->reqdraw = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in New Issue