commit b31eb47
Devine Lu Linvega
·
2025-04-08 22:23:45 +0000 UTC
parent 84429bf
Removing flicker during resize
3 files changed,
+10,
-4
+3,
-2
1@@ -86,6 +86,7 @@ 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+ uxn_screen.reqw = uxn_screen.reqh = 0;
6 screen_change(0, 0, width, height);
7 emu_resize(width, height);
8 }
9@@ -136,8 +137,8 @@ screen_deo(Uint8 addr)
10 {
11 switch(addr) {
12 case 0x21: uxn_screen.vector = PEEK2(&uxn.dev[0x20]); return;
13- case 0x23: screen_resize(PEEK2(&uxn.dev[0x22]), uxn_screen.height, uxn_screen.scale); return;
14- case 0x25: screen_resize(uxn_screen.width, PEEK2(&uxn.dev[0x24]), uxn_screen.scale); return;
15+ case 0x23: uxn_screen.reqw = uxn_screen.width = PEEK2(&uxn.dev[0x22]); return;
16+ case 0x25: uxn_screen.reqh = uxn_screen.height = PEEK2(&uxn.dev[0x24]); return;
17 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;
18 case 0x28:
19 case 0x29: rX = (uxn.dev[0x28] << 8) | uxn.dev[0x29], rX = twos(rX); return;
+1,
-1
1@@ -10,7 +10,7 @@ WITH REGARD TO THIS SOFTWARE.
2 */
3
4 typedef struct UxnScreen {
5- int width, height, vector, x1, y1, x2, y2, scale;
6+ int width, height, reqw, reqh, vector, scale, x1, y1, x2, y2;
7 Uint32 palette[16], *pixels;
8 Uint8 *fg, *bg;
9 } UxnScreen;
+6,
-1
1@@ -73,6 +73,7 @@ emu_deo(Uint8 addr, Uint8 value)
2 int
3 emu_resize(int width, int height)
4 {
5+
6 width *= uxn_screen.scale, height *= uxn_screen.scale;
7 XResizeWindow(display, window, width, height);
8 ximage = XCreateImage(display, DefaultVisual(display, 0), DefaultDepth(display, DefaultScreen(display)), ZPixmap, 0, (char *)uxn_screen.pixels, width, height, 32, 0);
9@@ -243,6 +244,10 @@ emu_run(void)
10 read(fds[1].fd, expirations, 8);
11 if(uxn_screen.vector)
12 uxn_eval(uxn_screen.vector);
13+ if(uxn_screen.reqw || uxn_screen.reqh)
14+ screen_resize(uxn_screen.reqw ? uxn_screen.reqw : uxn_screen.width,
15+ uxn_screen.reqh ? uxn_screen.reqh : uxn_screen.height,
16+ uxn_screen.scale);
17 if(uxn_screen.x2 && uxn_screen.y2 && screen_changed()) {
18 int x = uxn_screen.x1 * uxn_screen.scale, y = uxn_screen.y1 * uxn_screen.scale;
19 int w = uxn_screen.x2 * uxn_screen.scale - x, h = uxn_screen.y2 * uxn_screen.scale - y;
20@@ -268,7 +273,7 @@ main(int argc, char **argv)
21 {
22 int i = 1;
23 if(argc == 2 && argv[1][0] == '-' && argv[1][1] == 'v')
24- return !fprintf(stdout, "Uxn11 - Varvara Emulator, 4 Apr 2025.\n");
25+ return !fprintf(stdout, "Uxn11 - Varvara Emulator, 8 Apr 2025.\n");
26 else if(argc == 1)
27 return !fprintf(stdout, "usage: %s [-v] file.rom [args..]\n", argv[0]);
28 else if(!display_init())