0
0
Fork 0
mirror of https://git.sr.ht/~rabbits/uxn synced 2024-11-16 11:15:06 +00:00

Clear on resize

This commit is contained in:
neauoire 2021-09-18 17:18:20 -07:00
parent 8a32555893
commit a5201767d7
3 changed files with 15 additions and 8 deletions

View file

@ -54,9 +54,6 @@
;on-mouse .Mouse/vector DEO2
;on-message .Console/vector DEO2
#0160 .Screen/width DEO2
#0100 .Screen/height DEO2
( find center )
.Screen/width DEI2 2// .center/x STZ2
.Screen/height DEI2 2// .center/y STZ2

View file

@ -19,6 +19,18 @@ static Uint8 blending[5][16] = {
{2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2},
{1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0}};
static void
ppu_clear(Ppu *p)
{
int x, y;
for(y = 0; y < p->height; ++y) {
for(x = 0; x < p->width; ++x) {
ppu_pixel(p, p->bg, x, y, 0);
ppu_pixel(p, p->fg, x, y, 0);
}
}
}
void
ppu_pixel(Ppu *p, Uint8 *layer, Uint16 x, Uint16 y, Uint8 color)
{
@ -78,15 +90,18 @@ ppu_init(Ppu *p, Uint8 hor, Uint8 ver)
p->height = 8 * ver;
p->bg = calloc(1, p->width / 4 * p->height * sizeof(Uint8));
p->fg = calloc(1, p->width / 4 * p->height * sizeof(Uint8));
ppu_clear(p);
return p->bg && p->fg;
}
int
ppu_resize(Ppu *p, Uint8 hor, Uint8 ver)
{
ppu_clear(p);
p->width = 8 * hor;
p->height = 8 * ver;
p->bg = realloc(p->bg, p->width / 4 * p->height * sizeof(Uint8));
p->fg = realloc(p->fg, p->width / 4 * p->height * sizeof(Uint8));
ppu_clear(p);
return p->bg && p->fg;
}

View file

@ -298,11 +298,6 @@ update_palette(Uint8 *addr)
void
set_size(Uint16 width, Uint16 height)
{
int i;
/* clear */
for(i = 0; i < ppu.height * ppu.width; ++i)
ppu_screen[i] = palette[0];
/* resize */
ppu_resize(&ppu, width / 8, height / 8);
gRect.w = ppu.width;
gRect.h = ppu.height;