commit 406d2fb

Devine Lu Linvega  ·  2022-06-13 18:08:33 +0000 UTC
parent 2b55c07
Improved hot reload
4 files changed,  +17, -11
+12, -7
 1@@ -53,6 +53,14 @@ screen_blit(UxnScreen *p, Layer *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8
 2 	}
 3 }
 4 
 5+static void layer_clear(UxnScreen *p, Layer *layer)
 6+{
 7+	Uint32 i, size = p->width * p->height;
 8+	for(i = 0; i < size; i++)
 9+		layer->pixels[i] = 0x00;
10+	layer->changed = 1;
11+}
12+
13 void
14 screen_palette(UxnScreen *p, Uint8 *addr)
15 {
16@@ -82,18 +90,15 @@ screen_resize(UxnScreen *p, Uint16 width, Uint16 height)
17 	if(bg && fg && pixels) {
18 		p->width = width;
19 		p->height = height;
20-		screen_clear(p, &p->bg);
21-		screen_clear(p, &p->fg);
22+		screen_clear(p);
23 	}
24 }
25 
26 void
27-screen_clear(UxnScreen *p, Layer *layer)
28+screen_clear(UxnScreen *p)
29 {
30-	Uint32 i, size = p->width * p->height;
31-	for(i = 0; i < size; i++)
32-		layer->pixels[i] = 0x00;
33-	layer->changed = 1;
34+	layer_clear(p, &p->bg);
35+	layer_clear(p, &p->fg);
36 }
37 
38 void
+1, -1
1@@ -25,7 +25,7 @@ extern UxnScreen uxn_screen;
2 
3 void screen_palette(UxnScreen *p, Uint8 *addr);
4 void screen_resize(UxnScreen *p, Uint16 width, Uint16 height);
5-void screen_clear(UxnScreen *p, Layer *layer);
6+void screen_clear(UxnScreen *p);
7 void screen_redraw(UxnScreen *p, Uint32 *pixels);
8 
9 Uint8 screen_dei(Uint8 *d, Uint8 port);
+1, -2
 1@@ -17,8 +17,7 @@ WITH REGARD TO THIS SOFTWARE.
 2 static const char *errors[] = {
 3 	"underflow",
 4 	"overflow",
 5-	"division by zero"
 6-};
 7+	"division by zero"};
 8 
 9 static void
10 system_print(Stack *s, char *name)
+3, -1
 1@@ -105,7 +105,9 @@ emu_start(Uxn *u, char *rom)
 2 {
 3 	if(!load_rom(u, rom))
 4 		return 0;
 5-	screen_resize(&uxn_screen, WIDTH, HEIGHT);
 6+	if(!uxn_screen.width || !uxn_screen.height)
 7+		screen_resize(&uxn_screen, WIDTH, HEIGHT);
 8+	screen_clear(&uxn_screen);
 9 	if(!uxn_eval(u, PAGE_PROGRAM))
10 		return emu_error("Boot", "Failed to start rom.");
11 	return 1;