Improved hot reload

This commit is contained in:
Devine Lu Linvega 2022-06-13 11:08:33 -07:00
parent 2b55c0732d
commit 406d2fb327
4 changed files with 17 additions and 11 deletions

View File

@ -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 void
screen_palette(UxnScreen *p, Uint8 *addr) screen_palette(UxnScreen *p, Uint8 *addr)
{ {
@ -82,18 +90,15 @@ screen_resize(UxnScreen *p, Uint16 width, Uint16 height)
if(bg && fg && pixels) { if(bg && fg && pixels) {
p->width = width; p->width = width;
p->height = height; p->height = height;
screen_clear(p, &p->bg); screen_clear(p);
screen_clear(p, &p->fg);
} }
} }
void void
screen_clear(UxnScreen *p, Layer *layer) screen_clear(UxnScreen *p)
{ {
Uint32 i, size = p->width * p->height; layer_clear(p, &p->bg);
for(i = 0; i < size; i++) layer_clear(p, &p->fg);
layer->pixels[i] = 0x00;
layer->changed = 1;
} }
void void

View File

@ -25,7 +25,7 @@ extern UxnScreen uxn_screen;
void screen_palette(UxnScreen *p, Uint8 *addr); void screen_palette(UxnScreen *p, Uint8 *addr);
void screen_resize(UxnScreen *p, Uint16 width, Uint16 height); 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); void screen_redraw(UxnScreen *p, Uint32 *pixels);
Uint8 screen_dei(Uint8 *d, Uint8 port); Uint8 screen_dei(Uint8 *d, Uint8 port);

View File

@ -17,8 +17,7 @@ WITH REGARD TO THIS SOFTWARE.
static const char *errors[] = { static const char *errors[] = {
"underflow", "underflow",
"overflow", "overflow",
"division by zero" "division by zero"};
};
static void static void
system_print(Stack *s, char *name) system_print(Stack *s, char *name)

View File

@ -105,7 +105,9 @@ emu_start(Uxn *u, char *rom)
{ {
if(!load_rom(u, rom)) if(!load_rom(u, rom))
return 0; return 0;
if(!uxn_screen.width || !uxn_screen.height)
screen_resize(&uxn_screen, WIDTH, HEIGHT); screen_resize(&uxn_screen, WIDTH, HEIGHT);
screen_clear(&uxn_screen);
if(!uxn_eval(u, PAGE_PROGRAM)) if(!uxn_eval(u, PAGE_PROGRAM))
return emu_error("Boot", "Failed to start rom."); return emu_error("Boot", "Failed to start rom.");
return 1; return 1;