commit 7e6e439
pita
·
2026-07-24 13:11:48 +0000 UTC
parent e7d38ed
removed double buffering honest mistake, (by pnthr)
2 files changed,
+44,
-30
+29,
-21
1@@ -1416,34 +1416,16 @@ emu_resize(void)
2 active_buf = 0;
3 }
4
5-static void frame_callback(void *, struct wl_callback *, uint32_t);
6-
7-static const struct wl_callback_listener frame_listener = {
8- .done = frame_callback,
9-};
10-
11 void
12 emu_redraw(void)
13 {
14 if(!emu_configured)
15 return;
16- wl_callback_add_listener(wl_surface_frame(emu_surf), &frame_listener, NULL);
17 wl_surface_attach(emu_surf, emu_bufs[active_buf], 0, 0);
18 wl_surface_damage_buffer(emu_surf, 0, 0, screen_width * screen_zoom, screen_height * screen_zoom);
19 wl_surface_commit(emu_surf);
20 }
21
22-static void
23-frame_callback(void *data, struct wl_callback *cb, uint32_t time)
24-{
25- wl_callback_destroy(cb);
26- int old = active_buf;
27- active_buf ^= 1;
28- memcpy((Uint8 *)shm_data + active_buf * shm_bufsize,
29- (Uint8 *)shm_data + old * shm_bufsize, shm_bufsize);
30- screen_pixels = (int *)((Uint8 *)shm_data + active_buf * shm_bufsize);
31-}
32-
33 static void
34 emu_restart(unsigned int soft)
35 {
36@@ -1685,8 +1667,17 @@ reg_global(void *d, struct wl_registry *reg, uint32_t name, const char *iface, u
37 }
38 }
39
40+static void
41+reg_global_remove(void *d, struct wl_registry *reg, uint32_t name)
42+{
43+ (void)d;
44+ (void)reg;
45+ (void)name;
46+}
47+
48 static const struct wl_registry_listener reg_listener = {
49 .global = reg_global,
50+ .global_remove = reg_global_remove,
51 };
52
53
54@@ -1742,6 +1733,14 @@ emu_run(void)
55 while(!dev[0x0f]) {
56 wl_display_dispatch_pending(emu_dpy);
57 wl_display_flush(emu_dpy);
58+ if(wl_display_dispatch_pending(emu_dpy) < 0 || wl_display_get_error(emu_dpy)) {
59+ dev[0x0f] = 0x80;
60+ break;
61+ }
62+ if(wl_display_flush(emu_dpy) < 0 && errno != EAGAIN) {
63+ dev[0x0f] = 0x80;
64+ break;
65+ }
66 struct timespec now;
67 clock_gettime(CLOCK_MONOTONIC, &now);
68 long long now_ms = (long long)now.tv_sec * 1000 + now.tv_nsec / 1000000;
69@@ -1762,10 +1761,19 @@ emu_run(void)
70 if(timeout < 0)
71 timeout = 0;
72 /* only pull stdin while it's still active */
73- if(poll(fds, stdin_active ? 2 : 1, timeout) <= 0)
74+ if(poll(fds, stdin_active ? 2 : 1, timeout) <= 0) {
75+ if(wl_display_get_error(emu_dpy)) {
76+ dev[0x0f] = 0x80;
77+ break;
78+ }
79 continue;
80- if(fds[0].revents & POLLIN)
81- wl_display_dispatch(emu_dpy);
82+ }
83+ if(fds[0].revents & (POLLIN | POLLHUP | POLLERR | POLLNVAL)) {
84+ if(wl_display_dispatch(emu_dpy) < 0 || wl_display_get_error(emu_dpy)) {
85+ dev[0x0f] = 0x80;
86+ break;
87+ }
88+ }
89 has_input = stdin_active && (fds[1].revents & POLLIN);
90 if(has_input || (stdin_active && (fds[1].revents & POLLHUP))) {
91 int i, n = read(STDIN_FILENO, coninp, CONINBUFSIZE - 1);
+15,
-9
1@@ -641,9 +641,6 @@ audio_start(int instance, Uint8 *d)
2 c->period = NOTE_PERIOD * 337 / 2 / c->len;
3 else
4 c->period = NOTE_PERIOD;
5- /* Debug Print */
6- fprintf(stderr, "[APU %d] PLAY: addr=0x%04x len=%u adsr=0x%04x vol=%d/%d pitch=%d repeat=%d\n",
7- instance, addr, c->len, adsr, c->volume[0], c->volume[1], pitch, c->repeat);
8
9 }
10
11@@ -730,10 +727,6 @@ audio_finished_handler(int instance)
12 {
13 Uint8 *port_value = &dev[0x30 + 0x10 * instance];
14 Uint16 vector = port_value[0] << 8 | port_value[1];
15-
16- /* Debug Print */
17- fprintf(stderr, "[APU %d] FINISHED: vector=0x%04x\n", instance, vector);
18-
19 if(vector)
20 uxn_eval(vector);
21 }
22@@ -877,6 +870,8 @@ mouse_deo_vector(void)
23 #include <sys/stat.h>
24 #include <string.h>
25
26+static char *theme_file = NULL;
27+
28 typedef struct {
29 union {
30 FILE *f;
31@@ -1060,7 +1055,11 @@ static unsigned int
32 file_init(unsigned int id, Uint16 addr)
33 {
34 file_reset(id);
35- ufs[id].filepath = (char *)&ram[addr];
36+ char *path = (char *)&ram[addr];
37+ if(theme_file && strcmp(path, ".theme") == 0)
38+ ufs[id].filepath = theme_file;
39+ else
40+ ufs[id].filepath = path;
41 return 0;
42 }
43
44@@ -1804,8 +1803,15 @@ main(int argc, char **argv)
45 {
46 int i = 1;
47 if(argc == 1)
48- return !fprintf(stdout, "usage: %s [-v] file.rom [args..]\n", argv[0]);
49+ return !fprintf(stdout, "usage: %s [-v] [-t path/to/.theme] [-l x y] file.rom [args..]\n", argv[0]);
50 while(i < argc && argv[i][0] == '-') {
51+ if(!strcmp(argv[i], "-t")) {
52+ if(i + 1 >= argc)
53+ return !fprintf(stdout, "usage: %s [-v] [-t theme] [-l x y] file.rom [args..]\n", argv[0]);
54+ theme_file = argv[++i];
55+ i++;
56+ continue;
57+ }
58 if(!strcmp(argv[i], "-v"))
59 return !fprintf(stdout, "%s - Varvara Emulator(79K), 10 Jul 2026.\n", argv[0]);
60 if(!strcmp(argv[i], "--")){ i++; break; }