commit a94ec7a

Devine Lu Linvega  ·  2025-05-03 23:27:32 +0000 UTC
parent 9f7bb31
Moved screen vector outside of screen object
1 files changed,  +18, -22
+18, -22
  1@@ -255,8 +255,6 @@ system_deo(Uint8 port)
  2 #define CONSOLE_EOA 0x3
  3 #define CONSOLE_END 0x4
  4 
  5-static int console_vector;
  6-
  7 #undef _POSIX_C_SOURCE
  8 #define _POSIX_C_SOURCE 200112L
  9 
 10@@ -274,6 +272,8 @@ static int console_vector;
 11 #include <util.h>
 12 #endif
 13 
 14+static unsigned int console_vector;
 15+
 16 /* subprocess support */
 17 static char *fork_args[4] = {"/bin/sh", "-c", "", NULL};
 18 static int child_mode;
 19@@ -443,17 +443,6 @@ console_input(int c, int type)
 20 	return type != 4;
 21 }
 22 
 23-static void
 24-console_arguments(int i, int argc, char **argv)
 25-{
 26-	for(; i < argc; i++) {
 27-		char *p = argv[i];
 28-		while(*p)
 29-			console_input(*p++, CONSOLE_ARG);
 30-		console_input('\n', i == argc - 1 ? CONSOLE_END : CONSOLE_EOA);
 31-	}
 32-}
 33-
 34 static Uint8
 35 console_dei(Uint8 addr)
 36 {
 37@@ -483,14 +472,16 @@ console_deo(Uint8 addr)
 38 #define MAR2(x) (x + 0x10)
 39 
 40 typedef struct UxnScreen {
 41-	int width, height, vector, zoom, x1, y1, x2, y2;
 42+	int width, height, zoom, x1, y1, x2, y2;
 43 	Uint32 palette[16], *pixels;
 44 	Uint8 *fg, *bg;
 45 } UxnScreen;
 46 
 47+static unsigned int screen_vector;
 48+static UxnScreen uxn_screen;
 49+
 50 void emu_resize(void);
 51 
 52-static UxnScreen uxn_screen;
 53 static Uint8 blending[4][16] = {
 54 	{0, 0, 0, 0, 1, 0, 1, 1, 2, 2, 0, 2, 3, 3, 3, 0},
 55 	{0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3},
 56@@ -596,7 +587,7 @@ static void
 57 screen_deo(Uint8 addr)
 58 {
 59 	switch(addr) {
 60-	case 0x21: uxn_screen.vector = PEEK2(&uxn.dev[0x20]); return;
 61+	case 0x21: screen_vector = PEEK2(&uxn.dev[0x20]); return;
 62 	case 0x23: screen_apply(PEEK2(&uxn.dev[0x22]), uxn_screen.height); return;
 63 	case 0x25: screen_apply(uxn_screen.width, PEEK2(&uxn.dev[0x24])); return;
 64 	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;
 65@@ -703,7 +694,7 @@ screen_deo(Uint8 addr)
 66 /*
 67 @|Controller -------------------------------------------------------- */
 68 
 69-static int controller_vector;
 70+static unsigned int controller_vector;
 71 
 72 static void
 73 controller_down(Uint8 mask)
 74@@ -744,7 +735,7 @@ controller_deo(Uint8 addr)
 75 /*
 76 @|Mouse ------------------------------------------------------------- */
 77 
 78-static int mouse_vector;
 79+static unsigned int mouse_vector;
 80 
 81 static void
 82 mouse_down(Uint8 mask)
 83@@ -1288,8 +1279,8 @@ emu_run(void)
 84 			emu_event();
 85 		if(poll(&fds[1], 1, 0)) {
 86 			read(fds[1].fd, expirations, 8);
 87-			if(uxn_screen.vector)
 88-				uxn_eval(uxn_screen.vector);
 89+			if(screen_vector)
 90+				uxn_eval(screen_vector);
 91 			if(uxn_screen.x2 && uxn_screen.y2 && screen_changed())
 92 				emu_repaint();
 93 		}
 94@@ -1311,14 +1302,19 @@ main(int argc, char **argv)
 95 {
 96 	int i = 1;
 97 	if(argc == 2 && argv[1][0] == '-' && argv[1][1] == 'v')
 98-		return !fprintf(stdout, "Uxn11 - Varvara Emulator, 23 Apr 2025.\n");
 99+		return !fprintf(stdout, "Uxn11 - Varvara Emulator, 3 May 2025.\n");
100 	else if(argc == 1)
101 		return !fprintf(stdout, "usage: %s [-v] file.rom [args..]\n", argv[0]);
102 	else if(!display_init())
103 		return !fprintf(stdout, "Could not open display.\n");
104 	else if(!system_boot((Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), argv[i++], argc > 2))
105 		return !fprintf(stdout, "Could not load %s.\n", argv[i - 1]);
106-	console_arguments(i, argc, argv);
107+	for(; i < argc; i++) {
108+		char *p = argv[i];
109+		while(*p)
110+			console_input(*p++, CONSOLE_ARG);
111+		console_input('\n', i == argc - 1 ? CONSOLE_END : CONSOLE_EOA);
112+	}
113 	emu_run();
114 	console_close();
115 	XDestroyImage(ximage), XDestroyWindow(display, window), XCloseDisplay(display);