diff --git a/projects/examples/demos/piano.tal b/projects/examples/demos/piano.tal index a6477ca..a052eb7 100644 --- a/projects/examples/demos/piano.tal +++ b/projects/examples/demos/piano.tal @@ -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 diff --git a/src/devices/ppu.c b/src/devices/ppu.c index 4d1b7d6..b8dfcca 100644 --- a/src/devices/ppu.c +++ b/src/devices/ppu.c @@ -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; } \ No newline at end of file diff --git a/src/uxnemu.c b/src/uxnemu.c index 887c3cb..d38d158 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -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;