commit 60b20ea

neauoire  ·  2022-04-06 03:06:42 +0000 UTC
parent eb8e241
Added Fn keys controls
4 files changed,  +63, -17
+1, -0
1@@ -7,6 +7,7 @@ AllowShortEnumsOnASingleLine: true
2 AllowShortIfStatementsOnASingleLine: true
3 AllowShortLoopsOnASingleLine: true
4 AlwaysBreakAfterDefinitionReturnType: TopLevel
5+BreakBeforeTernaryOperators: false
6 BinPackArguments: false
7 BinPackParameters: false
8 BreakBeforeBraces: WebKit
+34, -3
 1@@ -18,15 +18,17 @@ To use the last page of ram(`0xff00`) to host the working stack:
 2 
 3 The stack mapping is 254 bytes of data, a byte for the pointer and a byte for an error code.
 4 
 5-## Graphical
 6+## Building 
 7+
 8+### Graphical
 9 
10 All you need is X11.
11 
12-```
13+```sh
14 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 -D_POSIX_C_SOURCE=199309L -DNDEBUG -Os -g0 -s -o bin/uxn11 -lX11
15 ```
16 
17-## Terminal
18+### Terminal
19 
20 If you wish to build the emulator without graphics mode:
21 
22@@ -34,6 +36,12 @@ If you wish to build the emulator without graphics mode:
23 cc src/devices/datetime.c src/devices/system.c src/devices/file.c src/uxn.c -DNDEBUG -Os -g0 -s src/uxncli.c -o bin/uxncli
24 ```
25 
26+## Run
27+
28+```sh
29+bin/uxnemu bin/polycat.rom
30+```
31+
32 ## Devices
33 
34 - `00` system
35@@ -46,6 +54,29 @@ cc src/devices/datetime.c src/devices/system.c src/devices/file.c src/uxn.c -DND
36 - `a0` file
37 - `c0` datetime
38 
39+## Emulator Controls
40+
41+- `F2` toggle debug
42+- `F4` load launcher.rom
43+
44+### Buttons
45+
46+- `LCTRL` A
47+- `LALT` B
48+- `LSHIFT` SEL 
49+- `HOME` START
50+
51+## Need a hand?
52+
53+The following resources are a good place to start:
54+
55+* [XXIIVV — uxntal](https://wiki.xxiivv.com/site/uxntal.html)
56+* [XXIIVV — uxntal cheatsheet](https://wiki.xxiivv.com/site/uxntal_cheatsheet.html)
57+* [XXIIVV — uxntal reference](https://wiki.xxiivv.com/site/uxntal_reference.html)
58+* [compudanzas — uxn tutorial](https://compudanzas.net/uxn_tutorial.html)
59+
60+You can also find us in [`#uxn` on irc.esper.net](ircs://irc.esper.net:6697/#uxn).
61+
62 ## Contributing
63 
64 Submit patches using [`git send-email`](https://git-send-email.io/) to the [~rabbits/public-inbox mailing list](https://lists.sr.ht/~rabbits/public-inbox).
+26, -12
 1@@ -41,8 +41,8 @@ console_input(Uxn *u, char c)
 2 static void
 3 console_deo(Uint8 *d, Uint8 port)
 4 {
 5-	FILE *fd = port == 0x8 ? stdout : port == 0x9 ? stderr
 6-												  : 0;
 7+	FILE *fd = port == 0x8 ? stdout : port == 0x9 ? stderr :
 8+                                                    0;
 9 	if(fd) {
10 		fputc(d[port], fd);
11 		fflush(fd);
12@@ -87,6 +87,23 @@ emu_redraw(void)
13 	XPutImage(display, window, DefaultGC(display, 0), ximage, 0, 0, 0, 0, uxn_screen.width, uxn_screen.height);
14 }
15 
16+static int
17+emu_start(Uxn *u, char *rom)
18+{
19+	free(u->ram);
20+	if(!uxn_boot(u, (Uint8 *)calloc(0x10300, sizeof(Uint8))))
21+		return emu_error("Boot", "Failed");
22+	if(!load_rom(u, rom))
23+		return emu_error("Load", "Failed");
24+	fprintf(stderr, "Loaded %s\n", rom);
25+	u->dei = emu_dei;
26+	u->deo = emu_deo;
27+	screen_resize(&uxn_screen, WIDTH, HEIGHT);
28+	if(!uxn_eval(u, PAGE_PROGRAM))
29+		return emu_error("Boot", "Failed to start rom.");
30+	return 1;
31+}
32+
33 static void
34 hide_cursor(void)
35 {
36@@ -137,6 +154,10 @@ emu_event(Uxn *u)
37 		KeySym sym;
38 		char buf[7];
39 		XLookupString((XKeyPressedEvent *)&ev, buf, 7, &sym, 0);
40+		if(sym == XK_F2)
41+			system_inspect(u);
42+		if(sym == XK_F4)
43+			emu_start(u, "boot.rom");
44 		controller_down(u, &u->dev[0x80], get_button(sym));
45 		controller_key(u, &u->dev[0x80], sym < 0x80 ? sym : (Uint8)buf[0]);
46 	} break;
47@@ -192,19 +213,12 @@ main(int argc, char **argv)
48 	char expirations[8];
49 	struct pollfd fds[2];
50 	static const struct itimerspec screen_tspec = {{0, 16666666}, {0, 16666666}};
51+	/* TODO: Try loading launcher.rom if present */
52 	if(argc < 2)
53 		return emu_error("Usage", "uxncli game.rom args");
54 	/* start sequence */
55-	if(!uxn_boot(&u, (Uint8 *)calloc(0x10300, sizeof(Uint8))))
56-		return emu_error("Boot", "Failed");
57-	if(!load_rom(&u, argv[1]))
58-		return emu_error("Load", "Failed");
59-	fprintf(stderr, "Loaded %s\n", argv[1]);
60-	u.dei = emu_dei;
61-	u.deo = emu_deo;
62-	screen_resize(&uxn_screen, WIDTH, HEIGHT);
63-	if(!uxn_eval(&u, PAGE_PROGRAM))
64-		return emu_error("Boot", "Failed to start rom.");
65+	if(!emu_start(&u, argv[1]))
66+		return emu_error("Start", "Failed");
67 	if(!init())
68 		return emu_error("Init", "Failed");
69 	/* console vector */
+2, -2
 1@@ -35,8 +35,8 @@ console_input(Uxn *u, char c)
 2 static void
 3 console_deo(Uint8 *d, Uint8 port)
 4 {
 5-	FILE *fd = port == 0x8 ? stdout : port == 0x9 ? stderr
 6-												  : 0;
 7+	FILE *fd = port == 0x8 ? stdout : port == 0x9 ? stderr :
 8+                                                    0;
 9 	if(fd) {
10 		fputc(d[port], fd);
11 		fflush(fd);