0
0
Fork 0
mirror of https://git.sr.ht/~rabbits/uxn synced 2024-11-23 22:35:11 +00:00

Fixed PPU

This commit is contained in:
neauoire 2021-04-28 13:17:11 -07:00
parent 51770be781
commit 3d5e7f7e48

View file

@ -41,13 +41,12 @@ readpixel(Uint8 *sprite, Uint8 h, Uint8 v)
void
clear(Ppu *p)
{
int i, sz = p->height * p->width;
for(i = 0; i < sz; ++i) {
int i, sz = p->height * p->width, rows = sz / 4;
for(i = 0; i < sz; ++i)
p->output[i] = p->colors[0];
for(i = 0; i < rows; i++) {
p->fg[i] = 0;
p->bg[i] = 0;
p->fg[sz + i] = 0;
p->bg[sz + i] = 0;
}
}
@ -160,9 +159,9 @@ initppu(Ppu *p, Uint8 hor, Uint8 ver, Uint8 pad)
p->height = (8 * p->ver + p->pad * 2);
if(!(p->output = malloc(p->width * p->height * sizeof(Uint32))))
return 0;
if(!(p->bg = malloc(p->width * p->height * sizeof(Uint8) * 2)))
if(!(p->bg = malloc(p->width * p->height * sizeof(Uint8) / 4)))
return 0;
if(!(p->fg = malloc(p->width * p->height * sizeof(Uint8) * 2)))
if(!(p->fg = malloc(p->width * p->height * sizeof(Uint8) / 4)))
return 0;
clear(p);
return 1;