commit a5201767d7a6a54f10c9568cb2a51033df999b29
parent 8a32555893814e34c091eb4a4cd0ce94880c462d
Author: neauoire <aliceffekt@gmail.com>
Date: Sat, 18 Sep 2021 17:18:20 -0700
Clear on resize
Diffstat:
3 files changed, 15 insertions(+), 8 deletions(-)
diff --git 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
@@ -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
@@ -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;