commit 32be4e8
Devine Lu Linvega
·
2025-04-08 23:00:57 +0000 UTC
parent 5ee804a
Set layers during size application
3 files changed,
+18,
-10
M
makefile
+3,
-2
1@@ -13,8 +13,9 @@ all: bin/uxnasm bin/uxncli bin/uxn11
2 run: all bin/mouse.rom
3 @ bin/uxn11 bin/mouse.rom
4 debug: bin/uxnasm-debug bin/uxncli-debug bin/uxn11-debug bin/opctest.rom bin/console.rom
5- @ bin/uxncli-debug bin/opctest.rom
6- @ bin/uxncli-debug bin/console.rom "foo bar" baz
7+ # @ bin/uxncli-debug bin/opctest.rom
8+ # @ bin/uxncli-debug bin/console.rom "foo bar" baz
9+ @ bin/uxn11-debug bin/mouse.rom
10 screen: bin/uxn11
11 @ uxnasm etc/screen.bounds.tal bin/test.rom
12 @ bin/uxn11 bin/test.rom
+11,
-2
1@@ -64,6 +64,15 @@ screen_palette(void)
2 screen_change(0, 0, uxn_screen.width, uxn_screen.height);
3 }
4
5+static void
6+screen_apply(int width, int height)
7+{
8+ int length = MAR2(width) * MAR2(height);
9+ uxn_screen.bg = realloc(uxn_screen.bg, length), uxn_screen.fg = realloc(uxn_screen.fg, length);
10+ uxn_screen.width = width, uxn_screen.height = height;
11+ uxn_screen.resize = 1;
12+}
13+
14 void
15 screen_resize(Uint16 width, Uint16 height, int scale)
16 {
17@@ -137,8 +146,8 @@ screen_deo(Uint8 addr)
18 {
19 switch(addr) {
20 case 0x21: uxn_screen.vector = PEEK2(&uxn.dev[0x20]); return;
21- case 0x23: uxn_screen.width = PEEK2(&uxn.dev[0x22]), uxn_screen.resize = 1; return;
22- case 0x25: uxn_screen.height = PEEK2(&uxn.dev[0x24]), uxn_screen.resize = 1; return;
23+ case 0x23: screen_apply(PEEK2(&uxn.dev[0x22]), uxn_screen.height); return;
24+ case 0x25: screen_apply(uxn_screen.width, PEEK2(&uxn.dev[0x24])); return;
25 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;
26 case 0x28:
27 case 0x29: rX = (uxn.dev[0x28] << 8) | uxn.dev[0x29], rX = twos(rX); return;
+4,
-6
1@@ -73,7 +73,6 @@ 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@@ -125,10 +124,10 @@ emu_event(void)
10 XNextEvent(display, &ev);
11 switch(ev.type) {
12 case Expose:
13- uxn_screen.x1 = uxn_screen.y1 = 0;
14+ /* uxn_screen.x1 = uxn_screen.y1 = 0;
15 uxn_screen.x2 = uxn_screen.width;
16 uxn_screen.y2 = uxn_screen.height;
17- emu_resize(uxn_screen.width, uxn_screen.height);
18+ emu_resize(uxn_screen.width, uxn_screen.height); */
19 break;
20 case ClientMessage:
21 uxn.dev[0x0f] = 0x80;
22@@ -199,7 +198,6 @@ display_floating(Display *dpy, Window win)
23 static int
24 display_init(void)
25 {
26-
27 Visual *visual;
28 XClassHint class = {"uxn11", "Uxn"};
29 /* start display */
30@@ -242,10 +240,10 @@ emu_run(void)
31 emu_event();
32 if(poll(&fds[1], 1, 0)) {
33 read(fds[1].fd, expirations, 8);
34- if(uxn_screen.vector)
35- uxn_eval(uxn_screen.vector);
36 if(uxn_screen.resize)
37 screen_resize(uxn_screen.width, uxn_screen.height, uxn_screen.scale);
38+ if(uxn_screen.vector)
39+ uxn_eval(uxn_screen.vector);
40 if(uxn_screen.x2 && uxn_screen.y2 && screen_changed()) {
41 int x = uxn_screen.x1 * uxn_screen.scale, y = uxn_screen.y1 * uxn_screen.scale;
42 int w = uxn_screen.x2 * uxn_screen.scale - x, h = uxn_screen.y2 * uxn_screen.scale - y;