Added Fn keys controls

This commit is contained in:
neauoire 2022-04-05 20:06:42 -07:00
parent eb8e241b50
commit 60b20eaaf7
4 changed files with 63 additions and 17 deletions

View File

@ -7,6 +7,7 @@ AllowShortEnumsOnASingleLine: true
AllowShortIfStatementsOnASingleLine: true AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: TopLevel AlwaysBreakAfterDefinitionReturnType: TopLevel
BreakBeforeTernaryOperators: false
BinPackArguments: false BinPackArguments: false
BinPackParameters: false BinPackParameters: false
BreakBeforeBraces: WebKit BreakBeforeBraces: WebKit

View File

@ -18,15 +18,17 @@ To use the last page of ram(`0xff00`) to host the working stack:
The stack mapping is 254 bytes of data, a byte for the pointer and a byte for an error code. The stack mapping is 254 bytes of data, a byte for the pointer and a byte for an error code.
## Graphical ## Building
### Graphical
All you need is X11. All you need is X11.
``` ```sh
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 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
``` ```
## Terminal ### Terminal
If you wish to build the emulator without graphics mode: If you wish to build the emulator without graphics mode:
@ -34,6 +36,12 @@ If you wish to build the emulator without graphics mode:
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 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
``` ```
## Run
```sh
bin/uxnemu bin/polycat.rom
```
## Devices ## Devices
- `00` system - `00` system
@ -46,6 +54,29 @@ cc src/devices/datetime.c src/devices/system.c src/devices/file.c src/uxn.c -DND
- `a0` file - `a0` file
- `c0` datetime - `c0` datetime
## Emulator Controls
- `F2` toggle debug
- `F4` load launcher.rom
### Buttons
- `LCTRL` A
- `LALT` B
- `LSHIFT` SEL
- `HOME` START
## Need a hand?
The following resources are a good place to start:
* [XXIIVV — uxntal](https://wiki.xxiivv.com/site/uxntal.html)
* [XXIIVV — uxntal cheatsheet](https://wiki.xxiivv.com/site/uxntal_cheatsheet.html)
* [XXIIVV — uxntal reference](https://wiki.xxiivv.com/site/uxntal_reference.html)
* [compudanzas — uxn tutorial](https://compudanzas.net/uxn_tutorial.html)
You can also find us in [`#uxn` on irc.esper.net](ircs://irc.esper.net:6697/#uxn).
## Contributing ## Contributing
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). 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).

View File

@ -41,8 +41,8 @@ console_input(Uxn *u, char c)
static void static void
console_deo(Uint8 *d, Uint8 port) console_deo(Uint8 *d, Uint8 port)
{ {
FILE *fd = port == 0x8 ? stdout : port == 0x9 ? stderr FILE *fd = port == 0x8 ? stdout : port == 0x9 ? stderr :
: 0; 0;
if(fd) { if(fd) {
fputc(d[port], fd); fputc(d[port], fd);
fflush(fd); fflush(fd);
@ -87,6 +87,23 @@ emu_redraw(void)
XPutImage(display, window, DefaultGC(display, 0), ximage, 0, 0, 0, 0, uxn_screen.width, uxn_screen.height); XPutImage(display, window, DefaultGC(display, 0), ximage, 0, 0, 0, 0, uxn_screen.width, uxn_screen.height);
} }
static int
emu_start(Uxn *u, char *rom)
{
free(u->ram);
if(!uxn_boot(u, (Uint8 *)calloc(0x10300, sizeof(Uint8))))
return emu_error("Boot", "Failed");
if(!load_rom(u, rom))
return emu_error("Load", "Failed");
fprintf(stderr, "Loaded %s\n", rom);
u->dei = emu_dei;
u->deo = emu_deo;
screen_resize(&uxn_screen, WIDTH, HEIGHT);
if(!uxn_eval(u, PAGE_PROGRAM))
return emu_error("Boot", "Failed to start rom.");
return 1;
}
static void static void
hide_cursor(void) hide_cursor(void)
{ {
@ -137,6 +154,10 @@ emu_event(Uxn *u)
KeySym sym; KeySym sym;
char buf[7]; char buf[7];
XLookupString((XKeyPressedEvent *)&ev, buf, 7, &sym, 0); XLookupString((XKeyPressedEvent *)&ev, buf, 7, &sym, 0);
if(sym == XK_F2)
system_inspect(u);
if(sym == XK_F4)
emu_start(u, "boot.rom");
controller_down(u, &u->dev[0x80], get_button(sym)); controller_down(u, &u->dev[0x80], get_button(sym));
controller_key(u, &u->dev[0x80], sym < 0x80 ? sym : (Uint8)buf[0]); controller_key(u, &u->dev[0x80], sym < 0x80 ? sym : (Uint8)buf[0]);
} break; } break;
@ -192,19 +213,12 @@ main(int argc, char **argv)
char expirations[8]; char expirations[8];
struct pollfd fds[2]; struct pollfd fds[2];
static const struct itimerspec screen_tspec = {{0, 16666666}, {0, 16666666}}; static const struct itimerspec screen_tspec = {{0, 16666666}, {0, 16666666}};
/* TODO: Try loading launcher.rom if present */
if(argc < 2) if(argc < 2)
return emu_error("Usage", "uxncli game.rom args"); return emu_error("Usage", "uxncli game.rom args");
/* start sequence */ /* start sequence */
if(!uxn_boot(&u, (Uint8 *)calloc(0x10300, sizeof(Uint8)))) if(!emu_start(&u, argv[1]))
return emu_error("Boot", "Failed"); return emu_error("Start", "Failed");
if(!load_rom(&u, argv[1]))
return emu_error("Load", "Failed");
fprintf(stderr, "Loaded %s\n", argv[1]);
u.dei = emu_dei;
u.deo = emu_deo;
screen_resize(&uxn_screen, WIDTH, HEIGHT);
if(!uxn_eval(&u, PAGE_PROGRAM))
return emu_error("Boot", "Failed to start rom.");
if(!init()) if(!init())
return emu_error("Init", "Failed"); return emu_error("Init", "Failed");
/* console vector */ /* console vector */

View File

@ -35,8 +35,8 @@ console_input(Uxn *u, char c)
static void static void
console_deo(Uint8 *d, Uint8 port) console_deo(Uint8 *d, Uint8 port)
{ {
FILE *fd = port == 0x8 ? stdout : port == 0x9 ? stderr FILE *fd = port == 0x8 ? stdout : port == 0x9 ? stderr :
: 0; 0;
if(fd) { if(fd) {
fputc(d[port], fd); fputc(d[port], fd);
fflush(fd); fflush(fd);