commit f19b456

Devie Lu Linvega  ·  2025-12-23 18:35:31 +0000 UTC
parent b264bee
Cleanup
1 files changed,  +25, -33
+25, -33
  1@@ -37,7 +37,6 @@ static Window window;
  2 #define HEIGHT (40 * 8)
  3 
  4 #define PEEK2(d) (*(d) << 8 | (d)[1])
  5-#define POKE2(d, v) { *(d) = (v) >> 8; (d)[1] = (v); }
  6 #define CLAMP(v, a, b) { if(v < a) v = a; else if(v >= b) v = b; }
  7 #define TWOS(v) (v & 0x8000 ? (int)v - 0x10000 : (int)v)
  8 
  9@@ -184,13 +183,9 @@ system_expansion(const Uint16 exp)
 10 	Uint16 length = PEEK2(aptr + 1), limit;
 11 	unsigned int bank = PEEK2(aptr + 3) * 0x10000;
 12 	unsigned int addr = PEEK2(aptr + 5);
 13-	if(ram[exp] == 0x0) {
 14-		unsigned int dst_value = ram[exp + 7];
 15-		Uint16 a = addr;
 16-		if(bank < BANKS_CAP)
 17-			for(limit = a + length; a != limit; a++)
 18-				ram[bank + a] = dst_value;
 19-	} else if(ram[exp] == 0x1) {
 20+	if(ram[exp] == 0x0)
 21+		memset(ram + addr, ram[exp + 7], length);
 22+	else if(ram[exp] == 0x1) {
 23 		unsigned int dst_bank = PEEK2(aptr + 7) * 0x10000;
 24 		unsigned int dst_addr = PEEK2(aptr + 9);
 25 		Uint16 a = addr, c = dst_addr;
 26@@ -937,7 +932,7 @@ file_delete(unsigned int id)
 27 static void
 28 file_success(unsigned int port, unsigned int value)
 29 {
 30-	POKE2(&dev[port], value);
 31+	dev[port] = value >> 8, dev[port + 1] = value;
 32 }
 33 
 34 /* file registers */
 35@@ -1085,6 +1080,15 @@ get_button(KeySym sym)
 36 	return 0x00;
 37 }
 38 
 39+static void
 40+display_center(void)
 41+{
 42+	Screen *screen = ScreenOfDisplay(display, 0);
 43+	int desktop_width = screen->width, desktop_height = screen->height;
 44+	int x = desktop_width / 2 - screen_width / 2, y = desktop_height / 2 - screen_height / 2;
 45+	window = XCreateSimpleWindow(display, RootWindow(display, 0), x, y, screen_width, screen_height, 1, 0, 0);
 46+}
 47+
 48 static void
 49 display_hidecursor(void)
 50 {
 51@@ -1098,40 +1102,28 @@ display_hidecursor(void)
 52 }
 53 
 54 static void
 55-display_floating(Display *dpy, Window win)
 56+display_floating(void)
 57 {
 58 	Atom wmDelete = XInternAtom(display, "WM_DELETE_WINDOW", True);
 59-	Atom wmType = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False);
 60-	Atom wmDialog = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False);
 61+	Atom wmType = XInternAtom(display, "_NET_WM_WINDOW_TYPE", False);
 62+	Atom wmDialog = XInternAtom(display, "_NET_WM_WINDOW_TYPE_DIALOG", False);
 63+	XClassHint class = {"uxn11", "Uxn"};
 64 	XSetWMProtocols(display, window, &wmDelete, 1);
 65-	XChangeProperty(dpy, win, wmType, 4, 32, PropModeReplace, (Uint8 *)&wmDialog, 1);
 66+	XChangeProperty(display, window, wmType, 4, 32, PropModeReplace, (Uint8 *)&wmDialog, 1);
 67+	XSelectInput(display, window, ButtonPressMask | ButtonReleaseMask | PointerMotionMask | ExposureMask | KeyPressMask | KeyReleaseMask | LeaveWindowMask);
 68+	XStoreName(display, window, "uxn11");
 69+	XSetClassHint(display, window, &class);
 70+	XMapWindow(display, window);
 71 }
 72 
 73 static unsigned int
 74 display_init(void)
 75 {
 76-	Screen *screen;
 77-	Visual *visual;
 78-	XClassHint class = {"uxn11", "Uxn"};
 79-	int desktop_width, desktop_height;
 80-	/* start display */
 81 	display = XOpenDisplay(NULL);
 82-	if(!display)
 83-		return !fprintf(stderr, "Display: failed\n");
 84-	/* start window */
 85-	visual = DefaultVisual(display, 0);
 86-	if(visual->class != TrueColor)
 87-		return !fprintf(stderr, "Display: True-color visual failed\n");
 88-	/* center */
 89-	screen = ScreenOfDisplay(display, 0);
 90-	desktop_width = screen->width, desktop_height = screen->height;
 91-	window = XCreateSimpleWindow(display, RootWindow(display, 0), desktop_width / 2 - screen_width / 2, desktop_height / 2 - screen_height / 2, screen_width, screen_height, 1, 0, 0);
 92+	if(!display) return !fprintf(stderr, "Display: failed\n");
 93+	display_center();
 94 	display_hidecursor();
 95-	display_floating(display, window);
 96-	XSelectInput(display, window, ButtonPressMask | ButtonReleaseMask | PointerMotionMask | ExposureMask | KeyPressMask | KeyReleaseMask | LeaveWindowMask);
 97-	XStoreName(display, window, "uxn11");
 98-	XSetClassHint(display, window, &class);
 99-	XMapWindow(display, window);
100+	display_floating();
101 	return 1;
102 }
103