Optimized ppu_redraw
This commit is contained in:
parent
cc6f2c8b29
commit
0a040824b7
|
@ -12,8 +12,6 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
WITH REGARD TO THIS SOFTWARE.
|
WITH REGARD TO THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* byte: p0-bg | p0-fg | p1-bg | p1-fg */
|
|
||||||
|
|
||||||
static Uint8 blending[5][16] = {
|
static Uint8 blending[5][16] = {
|
||||||
{0, 0, 0, 0, 1, 0, 1, 1, 2, 2, 0, 2, 3, 3, 3, 0},
|
{0, 0, 0, 0, 1, 0, 1, 1, 2, 2, 0, 2, 3, 3, 3, 0},
|
||||||
{0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3},
|
{0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3},
|
||||||
|
@ -58,10 +56,10 @@ ppu_palette(Ppu *p, Uint8 *addr)
|
||||||
void
|
void
|
||||||
ppu_resize(Ppu *p, Uint16 width, Uint16 height)
|
ppu_resize(Ppu *p, Uint16 width, Uint16 height)
|
||||||
{
|
{
|
||||||
Uint8 *bg, *fg;
|
Uint8
|
||||||
if(!(bg = realloc(p->bg, width * height)))
|
*bg = realloc(p->bg, width * height),
|
||||||
return;
|
*fg = realloc(p->fg, width * height);
|
||||||
if(!(fg = realloc(p->fg, width * height)))
|
if(!bg || !fg)
|
||||||
return;
|
return;
|
||||||
p->bg = bg;
|
p->bg = bg;
|
||||||
p->fg = fg;
|
p->fg = fg;
|
||||||
|
@ -82,13 +80,9 @@ ppu_clear(Ppu *p, Uint8 *layer)
|
||||||
void
|
void
|
||||||
ppu_redraw(Ppu *p, Uint32 *screen)
|
ppu_redraw(Ppu *p, Uint32 *screen)
|
||||||
{
|
{
|
||||||
Uint16 x, y;
|
Uint32 i, size = p->width * p->height;
|
||||||
for(y = 0; y < p->height; ++y)
|
for(i = 0; i < size; ++i)
|
||||||
for(x = 0; x < p->width; ++x) {
|
screen[i] = p->palette[p->fg[i] ? p->fg[i] : p->bg[i]];
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ void ppu_palette(Ppu *p, Uint8 *addr);
|
||||||
void ppu_resize(Ppu *p, Uint16 width, Uint16 height);
|
void ppu_resize(Ppu *p, Uint16 width, Uint16 height);
|
||||||
void ppu_clear(Ppu *p, Uint8 *layer);
|
void ppu_clear(Ppu *p, Uint8 *layer);
|
||||||
void ppu_redraw(Ppu *p, Uint32 *screen);
|
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_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);
|
void ppu_1bpp(Ppu *p, Uint8 *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, Uint8 flipx, Uint8 flipy);
|
||||||
void ppu_2bpp(Ppu *p, Uint8 *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, Uint8 flipx, Uint8 flipy);
|
void ppu_2bpp(Ppu *p, Uint8 *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, Uint8 flipx, Uint8 flipy);
|
||||||
|
|
Loading…
Reference in New Issue