commit f6c66d5

Devine Lu Linvega  ·  2024-07-15 18:26:38 +0000 UTC
parent 0f7b483
Exit on F3
3 files changed,  +22, -27
+4, -3
 1@@ -36,9 +36,10 @@ bin/uxncli: ${CLI_src} src/uxncli.c
 2 	@ cc ${RELEASE_flags} ${CFLAGS} ${CLI_src} src/uxncli.c -lutil -o bin/uxncli
 3 bin/uxn11: ${EMU_src} src/uxn11.c
 4 	@ cc ${RELEASE_flags} ${CFLAGS} ${EMU_src} src/uxn11.c -lX11 -lutil -o bin/uxn11
 5+
 6 bin/uxnasm-debug: src/uxnasm.c
 7-	@ cc ${DEBUG_flags} ${CFLAGS} src/uxnasm.c -o bin/uxnasm
 8+	@ cc ${DEBUG_flags} ${CFLAGS} src/uxnasm.c -o bin/uxnasm-debug
 9 bin/uxncli-debug: ${CLI_src} src/uxncli.c
10-	@ cc ${DEBUG_flags} ${CFLAGS} ${CLI_src} src/uxncli.c -lutil -o bin/uxncli
11+	@ cc ${DEBUG_flags} ${CFLAGS} ${CLI_src} src/uxncli.c -lutil -o bin/uxncli-debug
12 bin/uxn11-debug: ${EMU_src} src/uxn11.c
13-	@ cc ${DEBUG_flags} ${CFLAGS} ${EMU_src} src/uxn11.c -lX11 -lutil -o bin/uxn11
14+	@ cc ${DEBUG_flags} ${CFLAGS} ${EMU_src} src/uxn11.c -lX11 -lutil -o bin/uxn11-debug
+2, -1
 1@@ -102,7 +102,7 @@ void
 2 system_deo(Uint8 port)
 3 {
 4 	switch(port) {
 5-	case 0x3:
 6+	case 0x3: {
 7 		Uint16 addr = PEEK2(uxn.dev + 2);
 8 		if(uxn.ram[addr] == 0x0) {
 9 			Uint8 value = uxn.ram[addr + 7];
10@@ -128,6 +128,7 @@ system_deo(Uint8 port)
11 		} else
12 			fprintf(stderr, "Unknown Expansion Command 0x%02x\n", uxn.ram[addr]);
13 		break;
14+	}
15 	case 0x4:
16 		uxn.wst.ptr = uxn.dev[4];
17 		break;
+16, -23
 1@@ -154,6 +154,7 @@ emu_event(void)
 2 		switch(sym) {
 3 		case XK_F1: toggle_scale(); break;
 4 		case XK_F2: uxn.dev[0x0e] = !uxn.dev[0x0e]; break;
 5+		case XK_F3: uxn.dev[0x0f] = 0xff; break;
 6 		case XK_F4: emu_restart(boot_rom, 0); break;
 7 		case XK_F5: emu_restart(boot_rom, 1); break;
 8 		}
 9@@ -168,16 +169,13 @@ emu_event(void)
10 	} break;
11 	case ButtonPress: {
12 		XButtonPressedEvent *e = (XButtonPressedEvent *)&ev;
13-		if(e->button == 4)
14-			mouse_scroll(0, 1);
15-		else if(e->button == 5)
16-			mouse_scroll(0, -1);
17-		else if(e->button == 6)
18-			mouse_scroll(1, 0);
19-		else if(e->button == 7)
20-			mouse_scroll(-1, 0);
21-		else
22-			mouse_down(0x1 << (e->button - 1));
23+		switch(e->button) {
24+		case 4: mouse_scroll(0, 1); break;
25+		case 5: mouse_scroll(0, -1); break;
26+		case 6: mouse_scroll(1, 0); break;
27+		case 7: mouse_scroll(-1, 0); break;
28+		default: mouse_down(0x1 << (e->button - 1));
29+		}
30 	} break;
31 	case ButtonRelease: {
32 		XButtonPressedEvent *e = (XButtonPressedEvent *)&ev;
33@@ -196,9 +194,9 @@ static int
34 display_init(void)
35 {
36 	Atom wmDelete;
37-	static Visual *visual;
38+	Visual *visual;
39 	XColor black = {0};
40-	static char empty[] = {0};
41+	char empty[] = {0};
42 	Pixmap bitmap;
43 	Cursor blank;
44 	display = XOpenDisplay(NULL);
45@@ -229,8 +227,7 @@ static int
46 emu_run(void)
47 {
48 	int i = 1, n;
49-	char expirations[8];
50-	char coninp[CONINBUFSIZE];
51+	char expirations[8], coninp[CONINBUFSIZE];
52 	struct pollfd fds[3];
53 	static const struct itimerspec screen_tspec = {{0, 16666666}, {0, 16666666}};
54 	/* timer */
55@@ -275,15 +272,11 @@ main(int argc, char **argv)
56 		i++;
57 	}
58 	rom = i == argc ? "boot.rom" : argv[i++];
59-	if(!system_boot((Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), rom)) {
60-		fprintf(stdout, "usage: %s [-v] file.rom [args..]\n", argv[0]);
61-		return 0;
62-	}
63-	if(!display_init()) {
64-		fprintf(stdout, "Could not open display.\n");
65-		return 0;
66-	}
67-	/* Game Loop */
68+	if(!system_boot((Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), rom))
69+		return !fprintf(stdout, "usage: %s [-v] file.rom [args..]\n", argv[0]);
70+	if(!display_init())
71+		return !fprintf(stdout, "Could not open display.\n");
72+	/* Event Loop */
73 	uxn.dev[0x17] = argc - i;
74 	if(uxn_eval(PAGE_PROGRAM)) {
75 		console_listen(i, argc, argv);