commit 7fb8ec6
Devine Lu Linvega
·
2025-01-21 17:02:09 +0000 UTC
parent d098eee
Improved resizing
2 files changed,
+9,
-15
+1,
-1
1@@ -88,8 +88,8 @@ screen_resize(Uint16 width, Uint16 height, int scale)
2 for(i = 0; i < length; i++)
3 uxn_screen.bg[i] = uxn_screen.fg[i] = 0;
4 }
5+ screen_change(0, 0, width, height);
6 emu_resize(width, height);
7- screen_change(0, 0, width + 8, height + 8);
8 }
9
10 void
+8,
-14
1@@ -74,14 +74,9 @@ emu_deo(Uint8 addr, Uint8 value)
2 int
3 emu_resize(int w, int h)
4 {
5- if(window) {
6- static Visual *visual;
7- w *= uxn_screen.scale, h *= uxn_screen.scale;
8- visual = DefaultVisual(display, 0);
9- ximage = XCreateImage(display, visual, DefaultDepth(display, DefaultScreen(display)), ZPixmap, 0, (char *)uxn_screen.pixels, w, h, 32, 0);
10- XResizeWindow(display, window, w, h);
11- XMapWindow(display, window);
12- }
13+ w *= uxn_screen.scale, h *= uxn_screen.scale;
14+ XResizeWindow(display, window, w, h);
15+ ximage = XCreateImage(display, DefaultVisual(display, 0), DefaultDepth(display, DefaultScreen(display)), ZPixmap, 0, (char *)uxn_screen.pixels, w, h, 32, 0);
16 return 1;
17 }
18
19@@ -191,23 +186,23 @@ display_init(void)
20 Atom wmDelete;
21 Visual *visual;
22 XClassHint class = {"uxn11", "Uxn"};
23+ /* start display */
24 display = XOpenDisplay(NULL);
25 if(!display)
26 return system_error("init", "Display failed");
27- screen_resize(WIDTH, HEIGHT, 1);
28 /* start window */
29 visual = DefaultVisual(display, 0);
30 if(visual->class != TrueColor)
31 return system_error("init", "True-color visual failed");
32- window = XCreateSimpleWindow(display, RootWindow(display, 0), 0, 0, uxn_screen.width, uxn_screen.height, 1, 0, 0);
33+ window = XCreateSimpleWindow(display, RootWindow(display, 0), 0, 0, WIDTH, HEIGHT, 1, 0, 0);
34 XSelectInput(display, window, ButtonPressMask | ButtonReleaseMask | PointerMotionMask | ExposureMask | KeyPressMask | KeyReleaseMask);
35 wmDelete = XInternAtom(display, "WM_DELETE_WINDOW", True);
36 XSetWMProtocols(display, window, &wmDelete, 1);
37 XStoreName(display, window, "uxn11");
38 XSetClassHint(display, window, &class);
39 XMapWindow(display, window);
40- ximage = XCreateImage(display, visual, DefaultDepth(display, DefaultScreen(display)), ZPixmap, 0, (char *)uxn_screen.pixels, uxn_screen.width, uxn_screen.height, 32, 0);
41 display_hidecursor();
42+ screen_resize(WIDTH, HEIGHT, 1);
43 return 1;
44 }
45
46@@ -242,8 +237,7 @@ emu_run(void)
47 }
48 if((fds[2].revents & POLLIN) != 0) {
49 int i = 1, n = read(fds[2].fd, coninp, CONINBUFSIZE - 1);
50- coninp[n] = 0;
51- for(i = 0; i < n; i++)
52+ for(i = 0, coninp[n] = 0; i < n; i++)
53 console_input(coninp[i], CONSOLE_STD);
54 }
55 }
56@@ -255,7 +249,7 @@ main(int argc, char **argv)
57 {
58 int i = 1;
59 if(argc == 2 && argv[1][0] == '-' && argv[1][1] == 'v')
60- return !fprintf(stdout, "Uxn11 - Varvara Emulator, 20 Jan 2025.\n");
61+ return !fprintf(stdout, "Uxn11 - Varvara Emulator, 21 Jan 2025.\n");
62 else if(argc == 1)
63 return !fprintf(stdout, "usage: %s [-v] file.rom [args..]\n", argv[0]);
64 else if(!display_init())