commit 1892352

neauoire  ·  2023-06-05 15:55:21 +0000 UTC
parent 5a8ee38
More selective redraw
2 files changed,  +8, -12
+1, -1
1@@ -23,4 +23,4 @@ void screen_redraw(void);
2 Uint8 screen_dei(Uxn *u, Uint8 addr);
3 void screen_deo(Uint8 *ram, Uint8 *d, Uint8 port);
4 
5-#define SCALE 3
6+#define SCALE 1
+7, -11
 1@@ -35,7 +35,7 @@ char *rom_path;
 2 
 3 #define WIDTH (64 * 8)
 4 #define HEIGHT (40 * 8)
 5-#define PAD 4
 6+#define PAD 0
 7 #define CONINBUFSIZE 256
 8 
 9 Uint16 deo_mask[] = {0xff28, 0x0300, 0xc028, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000, 0x0000, 0xa260, 0xa260, 0x0000, 0x0000, 0x0000, 0x0000};
10@@ -68,13 +68,6 @@ uxn_deo(Uxn *u, Uint8 addr)
11 	}
12 }
13 
14-static void
15-emu_draw(void)
16-{
17-	screen_redraw();
18-	XPutImage(display, window, DefaultGC(display, 0), ximage, 0, 0, PAD, PAD, uxn_screen.width * SCALE, uxn_screen.height * SCALE);
19-}
20-
21 static int
22 emu_start(Uxn *u, char *rom)
23 {
24@@ -125,7 +118,7 @@ emu_event(Uxn *u)
25 	XNextEvent(display, &ev);
26 	switch(ev.type) {
27 	case Expose:
28-		emu_draw();
29+		XPutImage(display, window, DefaultGC(display, 0), ximage, 0, 0, 0, 0, uxn_screen.width, uxn_screen.height);
30 		break;
31 	case ClientMessage: {
32 		XDestroyImage(ximage);
33@@ -237,8 +230,11 @@ main(int argc, char **argv)
34 			for(i = 0; i < n; i++)
35 				console_input(&u, coninp[i], CONSOLE_STD);
36 		}
37-		if(uxn_screen.x2)
38-			emu_draw();
39+		if(uxn_screen.x2) {
40+			int x1 = uxn_screen.x1, y1 = uxn_screen.y1, x2 = uxn_screen.x2, y2 = uxn_screen.y2;
41+			screen_redraw();
42+			XPutImage(display, window, DefaultGC(display, 0), ximage, x1, y1, x1, y1, x2 - x1, y2 - y1);
43+		}
44 	}
45 	XDestroyImage(ximage);
46 	return 0;