Renamed layer.p to layer.pixels
This commit is contained in:
parent
f79b092e71
commit
8a25a5e387
|
@ -50,23 +50,24 @@ ppu_palette(Ppu *p, Uint8 *addr)
|
||||||
}
|
}
|
||||||
for(i = 4; i < 16; ++i)
|
for(i = 4; i < 16; ++i)
|
||||||
p->palette[i] = p->palette[i / 4];
|
p->palette[i] = p->palette[i / 4];
|
||||||
p->fg.reqdraw = p->bg.reqdraw = 1;
|
p->fg.changed = p->bg.changed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ppu_resize(Ppu *p, Uint16 width, Uint16 height)
|
ppu_resize(Ppu *p, Uint16 width, Uint16 height)
|
||||||
{
|
{
|
||||||
Uint8
|
Uint8
|
||||||
*bg = realloc(p->bg.p, width * height),
|
*bg = realloc(p->bg.pixels, width * height),
|
||||||
*fg = realloc(p->fg.p, width * height);
|
*fg = realloc(p->fg.pixels, width * height);
|
||||||
if(!bg || !fg)
|
if(!bg || !fg)
|
||||||
return;
|
return;
|
||||||
p->bg.p = bg;
|
p->bg.pixels = bg;
|
||||||
p->fg.p = fg;
|
p->fg.pixels = fg;
|
||||||
p->width = width;
|
p->width = width;
|
||||||
p->height = height;
|
p->height = height;
|
||||||
ppu_clear(p, &p->bg);
|
ppu_clear(p, &p->bg);
|
||||||
ppu_clear(p, &p->fg);
|
ppu_clear(p, &p->fg);
|
||||||
|
p->fg.changed = p->bg.changed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -74,7 +75,8 @@ ppu_clear(Ppu *p, Layer *layer)
|
||||||
{
|
{
|
||||||
Uint32 i, size = p->width * p->height;
|
Uint32 i, size = p->width * p->height;
|
||||||
for(i = 0; i < size; ++i)
|
for(i = 0; i < size; ++i)
|
||||||
layer->p[i] = 0x00;
|
layer->pixels[i] = 0x00;
|
||||||
|
p->fg.changed = p->bg.changed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -82,8 +84,8 @@ ppu_redraw(Ppu *p, Uint32 *screen)
|
||||||
{
|
{
|
||||||
Uint32 i, size = p->width * p->height;
|
Uint32 i, size = p->width * p->height;
|
||||||
for(i = 0; i < size; ++i)
|
for(i = 0; i < size; ++i)
|
||||||
screen[i] = p->palette[p->fg.p[i] ? p->fg.p[i] : p->bg.p[i]];
|
screen[i] = p->palette[p->fg.pixels[i] ? p->fg.pixels[i] : p->bg.pixels[i]];
|
||||||
p->fg.reqdraw = p->bg.reqdraw = 0;
|
p->fg.changed = p->bg.changed = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -91,10 +93,10 @@ ppu_write(Ppu *p, Layer *layer, Uint16 x, Uint16 y, Uint8 color)
|
||||||
{
|
{
|
||||||
if(x < p->width && y < p->height) {
|
if(x < p->width && y < p->height) {
|
||||||
Uint32 i = (x + y * p->width);
|
Uint32 i = (x + y * p->width);
|
||||||
Uint8 prev = layer->p[i];
|
Uint8 prev = layer->pixels[i];
|
||||||
if(color != prev) {
|
if(color != prev) {
|
||||||
layer->p[i] = color;
|
layer->pixels[i] = color;
|
||||||
layer->reqdraw = 1;
|
layer->changed = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,14 +21,14 @@ typedef unsigned short Uint16;
|
||||||
typedef unsigned int Uint32;
|
typedef unsigned int Uint32;
|
||||||
|
|
||||||
typedef struct Layer {
|
typedef struct Layer {
|
||||||
Uint8 *p;
|
Uint8 *pixels;
|
||||||
Uint8 reqdraw;
|
Uint8 changed;
|
||||||
} Layer;
|
} Layer;
|
||||||
|
|
||||||
typedef struct Ppu {
|
typedef struct Ppu {
|
||||||
Layer fg, bg;
|
|
||||||
Uint16 width, height;
|
Uint16 width, height;
|
||||||
Uint32 palette[16];
|
Uint32 palette[16];
|
||||||
|
Layer fg, bg;
|
||||||
} Ppu;
|
} Ppu;
|
||||||
|
|
||||||
void ppu_palette(Ppu *p, Uint8 *addr);
|
void ppu_palette(Ppu *p, Uint8 *addr);
|
||||||
|
|
|
@ -105,7 +105,6 @@ set_zoom(Uint8 scale)
|
||||||
if(!gWindow)
|
if(!gWindow)
|
||||||
return;
|
return;
|
||||||
set_window_size(gWindow, (ppu.width + PAD * 2) * zoom, (ppu.height + PAD * 2) * zoom);
|
set_window_size(gWindow, (ppu.width + PAD * 2) * zoom, (ppu.height + PAD * 2) * zoom);
|
||||||
ppu.fg.reqdraw = ppu.bg.reqdraw = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -128,7 +127,6 @@ set_size(Uint16 width, Uint16 height, int is_resize)
|
||||||
return error("SDL_UpdateTexture", SDL_GetError());
|
return error("SDL_UpdateTexture", SDL_GetError());
|
||||||
if(is_resize)
|
if(is_resize)
|
||||||
set_window_size(gWindow, (ppu.width + PAD * 2) * zoom, (ppu.height + PAD * 2) * zoom);
|
set_window_size(gWindow, (ppu.width + PAD * 2) * zoom, (ppu.height + PAD * 2) * zoom);
|
||||||
ppu.fg.reqdraw = ppu.bg.reqdraw = 1;
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -550,7 +548,7 @@ run(Uxn *u)
|
||||||
}
|
}
|
||||||
breakout:
|
breakout:
|
||||||
uxn_eval(u, devscreen->vector);
|
uxn_eval(u, devscreen->vector);
|
||||||
if(ppu.fg.reqdraw || ppu.bg.reqdraw || devsystem->dat[0xe])
|
if(ppu.fg.changed || ppu.bg.changed || devsystem->dat[0xe])
|
||||||
redraw(u);
|
redraw(u);
|
||||||
if(!BENCH) {
|
if(!BENCH) {
|
||||||
elapsed = (SDL_GetPerformanceCounter() - begin) / (double)SDL_GetPerformanceFrequency() * 1000.0f;
|
elapsed = (SDL_GetPerformanceCounter() - begin) / (double)SDL_GetPerformanceFrequency() * 1000.0f;
|
||||||
|
|
Loading…
Reference in New Issue