diff --git a/src/devices/screen.c b/src/devices/screen.c index 5f239de..f61b318 100644 --- a/src/devices/screen.c +++ b/src/devices/screen.c @@ -53,6 +53,14 @@ screen_blit(UxnScreen *p, Layer *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 } } +static void layer_clear(UxnScreen *p, Layer *layer) +{ + Uint32 i, size = p->width * p->height; + for(i = 0; i < size; i++) + layer->pixels[i] = 0x00; + layer->changed = 1; +} + void screen_palette(UxnScreen *p, Uint8 *addr) { @@ -82,18 +90,15 @@ screen_resize(UxnScreen *p, Uint16 width, Uint16 height) if(bg && fg && pixels) { p->width = width; p->height = height; - screen_clear(p, &p->bg); - screen_clear(p, &p->fg); + screen_clear(p); } } void -screen_clear(UxnScreen *p, Layer *layer) +screen_clear(UxnScreen *p) { - Uint32 i, size = p->width * p->height; - for(i = 0; i < size; i++) - layer->pixels[i] = 0x00; - layer->changed = 1; + layer_clear(p, &p->bg); + layer_clear(p, &p->fg); } void diff --git a/src/devices/screen.h b/src/devices/screen.h index 011cafe..cbe051a 100644 --- a/src/devices/screen.h +++ b/src/devices/screen.h @@ -25,7 +25,7 @@ extern UxnScreen uxn_screen; void screen_palette(UxnScreen *p, Uint8 *addr); void screen_resize(UxnScreen *p, Uint16 width, Uint16 height); -void screen_clear(UxnScreen *p, Layer *layer); +void screen_clear(UxnScreen *p); void screen_redraw(UxnScreen *p, Uint32 *pixels); Uint8 screen_dei(Uint8 *d, Uint8 port); diff --git a/src/devices/system.c b/src/devices/system.c index f9a83a4..c6f44ba 100644 --- a/src/devices/system.c +++ b/src/devices/system.c @@ -17,8 +17,7 @@ WITH REGARD TO THIS SOFTWARE. static const char *errors[] = { "underflow", "overflow", - "division by zero" -}; + "division by zero"}; static void system_print(Stack *s, char *name) diff --git a/src/uxn11.c b/src/uxn11.c index c3ac56a..93d9142 100644 --- a/src/uxn11.c +++ b/src/uxn11.c @@ -105,7 +105,9 @@ emu_start(Uxn *u, char *rom) { if(!load_rom(u, rom)) return 0; - screen_resize(&uxn_screen, WIDTH, HEIGHT); + if(!uxn_screen.width || !uxn_screen.height) + screen_resize(&uxn_screen, WIDTH, HEIGHT); + screen_clear(&uxn_screen); if(!uxn_eval(u, PAGE_PROGRAM)) return emu_error("Boot", "Failed to start rom."); return 1;