commit c58fecb

neauoire  ·  2022-03-27 17:01:06 +0000 UTC
parent ea1ce67
Started file, fixed issue with mouse
8 files changed,  +31, -14
+1, -1
1@@ -7,7 +7,7 @@ An emulator for the [Uxn stack-machine](https://wiki.xxiivv.com/site/uxn.html),
2 All you need is X11.
3 
4 ```
5-gcc src/uxn.c src/devices/system.c src/devices/screen.c src/devices/controller.c src/devices/mouse.c src/devices/datetime.c src/uxn11.c -DNDEBUG -Os -g0 -s -o bin/uxn11 -lX11
6+gcc src/uxn.c src/devices/system.c src/devices/screen.c src/devices/controller.c src/devices/mouse.c src/devices/file.c src/devices/datetime.c src/uxn11.c -DNDEBUG -Os -g0 -s -o bin/uxn11 -lX11
7 ```
8 
9 ## Terminal
+3, -3
 1@@ -9,10 +9,10 @@ echo "Building.."
 2 mkdir -p bin
 3 
 4 # Build(debug)
 5-gcc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined src/uxn.c src/devices/system.c src/devices/screen.c src/devices/controller.c src/devices/mouse.c src/devices/datetime.c src/uxn11.c -o bin/uxn11 -lX11
 6+gcc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined src/uxn.c src/devices/system.c src/devices/screen.c src/devices/controller.c src/devices/mouse.c src/devices/file.c src/devices/datetime.c src/uxn11.c -o bin/uxn11 -lX11
 7 
 8 # Build(release)
 9-# gcc src/uxn.c src/devices/system.c src/devices/screen.c src/devices/controller.c src/devices/mouse.c src/devices/datetime.c src/uxn11.c -o bin/uxn11 -lX11
10+# gcc src/uxn.c src/devices/system.c src/devices/screen.c src/devices/controller.c src/devices/mouse.c src/devices/file.c src/devices/datetime.c src/uxn11.c -o bin/uxn11 -lX11
11 
12 echo "Running.."
13-bin/uxn11 etc/controller.rom
14+bin/uxn11 etc/mouse.rom
R etc/clock.rom => etc/datetime.rom
+0, -0
+0, -0
+0, -0
+6, -6
 1@@ -1,3 +1,9 @@
 2+#include <stdio.h>
 3+#include <dirent.h>
 4+#include <string.h>
 5+#include <sys/stat.h>
 6+#include <unistd.h>
 7+
 8 #include "../uxn.h"
 9 #include "file.h"
10 
11@@ -13,12 +19,6 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 WITH REGARD TO THIS SOFTWARE.
13 */
14 
15-#include <stdio.h>
16-#include <dirent.h>
17-#include <string.h>
18-#include <sys/stat.h>
19-#include <unistd.h>
20-
21 typedef struct {
22 	FILE *f;
23 	DIR *dir;
+2, -2
 1@@ -1,8 +1,8 @@
 2+#include <stdio.h>
 3+
 4 #include "../uxn.h"
 5 #include "system.h"
 6 
 7-#include <stdio.h>
 8-
 9 /*
10 Copyright (c) 2022 Devine Lu Linvega, Andrew Alderwick
11 
+19, -2
 1@@ -7,6 +7,7 @@
 2 #include "devices/screen.h"
 3 #include "devices/controller.h"
 4 #include "devices/mouse.h"
 5+#include "devices/file.h"
 6 #include "devices/datetime.h"
 7 
 8 static XImage *ximage;
 9@@ -33,6 +34,14 @@ system_deo_special(Device *d, Uint8 port)
10 		screen_palette(&uxn_screen, &d->dat[0x8]);
11 }
12 
13+static int
14+console_input(Uxn *u, char c)
15+{
16+	Device *d = &u->dev[1];
17+	d->dat[0x2] = c;
18+	return uxn_eval(u, GETVECTOR(d));
19+}
20+
21 static void
22 console_deo(Device *d, Uint8 port)
23 {
24@@ -129,11 +138,11 @@ processEvent(void)
25 	} break;
26 	case ButtonPress: {
27 		XButtonPressedEvent *e = (XButtonPressedEvent *)&ev;
28-		mouse_down(devmouse, e->button);
29+		mouse_down(devmouse, 0x1 << e->button - 1);
30 	} break;
31 	case ButtonRelease: {
32 		XButtonPressedEvent *e = (XButtonPressedEvent *)&ev;
33-		mouse_up(devmouse, e->button);
34+		mouse_up(devmouse, 0x1 << e->button - 1);
35 	} break;
36 	case MotionNotify: {
37 		XMotionEvent *e = (XMotionEvent *)&ev;
38@@ -192,12 +201,20 @@ int
39 main(int argc, char **argv)
40 {
41 	Uxn u;
42+	int i;
43 	if(argc < 2)
44 		return error("Usage", "uxncli game.rom args");
45 	if(!start(&u, argv[1]))
46 		return error("Start", "Failed");
47 	if(!init())
48 		return error("Init", "Failed");
49+	/* console vector */
50+	for(i = 2; i < argc; i++) {
51+		char *p = argv[i];
52+		while(*p) console_input(&u, *p++);
53+		console_input(&u, '\n');
54+	}
55+	/* main loop */
56 	while(1) {
57 		processEvent();
58 		uxn_eval(&u, GETVECTOR(devscreen));