commit 6745e96

Devine Lu Linvega  ·  2024-12-24 00:31:00 +0000 UTC
parent 6ce45b5
Cache the screen vector address
3 files changed,  +8, -7
+4, -3
 1@@ -120,9 +120,9 @@ void
 2 screen_redraw(void)
 3 {
 4 	int i, x, y, k, l;
 5-	Uint16 x1 = uxn_screen.x1, y1 = uxn_screen.y1;
 6-	Uint16 x2 = uxn_screen.x2 > uxn_screen.width ? uxn_screen.width : uxn_screen.x2;
 7-	Uint16 y2 = uxn_screen.y2 > uxn_screen.height ? uxn_screen.height : uxn_screen.y2;
 8+	int x1 = uxn_screen.x1 < 0 ? 0 : uxn_screen.x1, y1 = uxn_screen.y1 < 0 ? 0 : uxn_screen.y1;
 9+	int x2 = uxn_screen.x2 > uxn_screen.width ? uxn_screen.width : uxn_screen.x2;
10+	int y2 = uxn_screen.y2 > uxn_screen.height ? uxn_screen.height : uxn_screen.y2;
11 	Uint32 palette[16], *pixels = uxn_screen.pixels;
12 	uxn_screen.x1 = uxn_screen.y1 = 9000;
13 	uxn_screen.x2 = uxn_screen.y2 = 0;
14@@ -167,6 +167,7 @@ void
15 screen_deo(Uint8 addr)
16 {
17 	switch(addr) {
18+	case 0x21: uxn_screen.vector = PEEK2(&uxn.dev[0x20]); return;
19 	case 0x23: screen_resize(PEEK2(&uxn.dev[0x22]), uxn_screen.height, uxn_screen.scale); return;
20 	case 0x25: screen_resize(uxn_screen.width, PEEK2(&uxn.dev[0x24]), uxn_screen.scale); return;
21 	case 0x26: rMX = uxn.dev[0x26] & 0x1, rMY = uxn.dev[0x26] & 0x2, rMA = uxn.dev[0x26] & 0x4, rML = uxn.dev[0x26] >> 4, rDX = rMX << 3, rDY = rMY << 2; return;
+1, -1
1@@ -10,7 +10,7 @@ WITH REGARD TO THIS SOFTWARE.
2 */
3 
4 typedef struct UxnScreen {
5-	int width, height, x1, y1, x2, y2, scale;
6+	int width, height, vector, x1, y1, x2, y2, scale;
7 	Uint32 palette[4], *pixels;
8 	Uint8 *fg, *bg;
9 } UxnScreen;
+3, -3
 1@@ -237,8 +237,8 @@ emu_run(void)
 2 			emu_event();
 3 		if(poll(&fds[1], 1, 0)) {
 4 			read(fds[1].fd, expirations, 8);
 5-			if(uxn.dev[0x20])
 6-				uxn_eval(uxn.dev[0x20] << 8 | uxn.dev[0x21]);
 7+			if(uxn_screen.vector)
 8+				uxn_eval(uxn_screen.vector);
 9 			if(screen_changed()) {
10 				int x = uxn_screen.x1 * uxn_screen.scale, y = uxn_screen.y1 * uxn_screen.scale;
11 				int w = uxn_screen.x2 * uxn_screen.scale - x, h = uxn_screen.y2 * uxn_screen.scale - y;
12@@ -261,7 +261,7 @@ main(int argc, char **argv)
13 {
14 	int i = 1;
15 	if(argc == 2 && argv[1][0] == '-' && argv[1][1] == 'v')
16-		return !fprintf(stdout, "Uxn11 - Varvara Emulator, 18 Dec 2024.\n");
17+		return !fprintf(stdout, "Uxn11 - Varvara Emulator, 23 Dec 2024.\n");
18 	else if(argc == 1)
19 		return !fprintf(stdout, "usage: %s [-v] file.rom [args..]\n", argv[0]);
20 	else if(!display_init())