uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit d1dc14391271459e4c11f18115812c3b74569c15
parent 6021b2b63d0c8d43930f75c19f9d7c61881dbb1a
Author: Devine Lu Linvega <aliceffekt@gmail.com>
Date:   Mon, 17 Apr 2023 09:36:55 -0700

(uxnemu) Only set zoom scale once on boot

Diffstat:
MREADME.md | 10++++++----
Mbuild.sh | 2+-
Msrc/uxncli.c | 2+-
Msrc/uxnemu.c | 24++++++++++--------------
4 files changed, 18 insertions(+), 20 deletions(-)

diff --git a/README.md b/README.md @@ -86,18 +86,20 @@ You can send events from Uxn to another application, or another instance of uxn, uxnemu orca.rom | shim ``` -## Emulator Options +## GUI Emulator Options -- `-s 1`, `-s 2` or `-s 3` set zoom (default 1) +- `-1x` Force small scale +- `-2x` Force medium scale +- `-3x` Force large scale -## Emulator Controls +## GUI Emulator Controls - `F1` toggle zoom - `F2` toggle debug - `F3` capture screen - `F4` load launcher.rom -### Buttons +### GUI Buttons - `LCTRL` A - `LALT` B diff --git a/build.sh b/build.sh @@ -117,6 +117,6 @@ echo "Assembling(piano).." ./bin/uxnasm projects/software/piano.tal bin/piano.rom echo "Running.." -./bin/uxnemu bin/piano.rom +./bin/uxnemu -2x bin/piano.rom echo "Done." diff --git a/src/uxncli.c b/src/uxncli.c @@ -64,7 +64,7 @@ main(int argc, char **argv) for(i = 2; i < argc; i++) { char *p = argv[i]; while(*p) console_input(&u, *p++, CONSOLE_ARG); - console_input(&u, '\n', i == argc-1 ? CONSOLE_END : CONSOLE_EOA); + console_input(&u, '\n', i == argc - 1 ? CONSOLE_END : CONSOLE_EOA); } while(!u.dev[0x0f]) { int c = fgetc(stdin); diff --git a/src/uxnemu.c b/src/uxnemu.c @@ -267,9 +267,9 @@ start(Uxn *u, char *rom) } static void -set_zoom(Uint8 scale) +set_zoom(Uint8 z) { - zoom = zoom > 2 ? 1 : zoom + 1; + zoom = z; set_window_size(gWindow, (uxn_screen.width + PAD * 2) * zoom, (uxn_screen.height + PAD * 2) * zoom); } @@ -351,7 +351,7 @@ static void do_shortcut(Uxn *u, SDL_Event *event) { if(event->key.keysym.sym == SDLK_F1) - set_zoom(zoom); + set_zoom(zoom == 3 ? 1 : zoom + 1); else if(event->key.keysym.sym == SDLK_F2) system_inspect(u); else if(event->key.keysym.sym == SDLK_F3) @@ -490,28 +490,24 @@ main(int argc, char **argv) { SDL_DisplayMode DM; Uxn u = {0}; - int i, loaded = 0; + int i = 1, loaded = 0; if(!init()) return error("Init", "Failed to initialize emulator."); screen_resize(&uxn_screen, WIDTH, HEIGHT); /* set default zoom */ - if(SDL_GetCurrentDisplayMode(0, &DM) == 0) + if(strcmp(argv[i], "-1x") == 0 || strcmp(argv[i], "-2x") == 0 || strcmp(argv[i], "-3x") == 0) + set_zoom(argv[i++][1] - '0'); + else if(SDL_GetCurrentDisplayMode(0, &DM) == 0) set_zoom(DM.w / 1280); - for(i = 1; i < argc; i++) { - /* get default zoom from flags */ - if(strcmp(argv[i], "-s") == 0) { - if(i < argc - 1) - set_zoom(atoi(argv[++i])); - else - return error("Opt", "-s No scale provided."); - } else if(!loaded++) { + for(; i < argc; i++) { + if(!loaded++) { if(!start(&u, argv[i])) return error("Boot", "Failed to boot."); rom_path = argv[i]; } else { char *p = argv[i]; while(*p) console_input(&u, *p++, CONSOLE_ARG); - console_input(&u, '\n', i == argc ? CONSOLE_END : CONSOLE_EOA); + console_input(&u, '\n', i == argc - 1 ? CONSOLE_END : CONSOLE_EOA); } } if(!loaded && !start(&u, "launcher.rom"))