]> git.lizzy.rs Git - plan9front.git/commitdiff
emulators ui: add option for fixed factor scaling and bound scale vertically
authorqwx <devnull@localhost>
Wed, 13 Jun 2018 12:05:19 +0000 (14:05 +0200)
committerqwx <devnull@localhost>
Wed, 13 Jun 2018 12:05:19 +0000 (14:05 +0200)
12 files changed:
sys/man/1/atari
sys/man/1/nintendo
sys/man/1/sega
sys/src/games/2600/2600.c
sys/src/games/c64/c64.c
sys/src/games/eui.c
sys/src/games/eui.h
sys/src/games/gb/gb.c
sys/src/games/gba/gba.c
sys/src/games/md/md.c
sys/src/games/nes/nes.c
sys/src/games/snes/snes.c

index 63e5e819393598b4b663cc0701129006c0251a6d..f18731316e69bda0b83a8e817219e63cdbe54013 100644 (file)
@@ -1,10 +1,13 @@
-.SH ATARI 1
+.TH ATARI 1
 .SH NAME
 2600 \- emulator
 .SH SYNOPSIS
 .B games/2600
 [
 .B -a
+] [
+.B -x
+.I scale
 ]
 .I romfile
 .SH DESCRIPTION
@@ -26,6 +29,9 @@ Command line options:
 .TP
 .B -a
 Enable audio output.
+.TP
+.B -x
+Scale the screen to a given factor regardless of the window's size.
 .SH SOURCE
 .B /sys/src/games/2600
 .SH BUGS
index b1ea5cc7c8e9e24b99b05a65ec2c757221518e5d..d820b8c9cc0b3d62517f4392a24f055cef7113ae 100644 (file)
@@ -9,6 +9,9 @@ gb, gba, nes, snes \- emulators
 [
 .B -C
 .I ...
+] [
+.B -x
+.I scale
 ]
 .I romfile
 .br
@@ -21,18 +24,27 @@ gb, gba, nes, snes \- emulators
 ] [
 .B -s
 .I savetype
+] [
+.B -x
+.I scale
 ]
 .I romfile
 .br
 .B games/nes
 [
 .B -aos
+] [
+.B -x
+.I scale
 ]
 .I romfile
 .br
 .B games/snes
 [
 .B -ahmsT
+] [
+.B -x
+.I scale
 ]
 .I romfile
 .SH DESCRIPTION
@@ -62,6 +74,9 @@ Command line options:
 .TP
 .B -a
 Enable audio output.
+.TP
+.B -x
+Scale the screen to a given factor regardless of the window's size.
 .PP
 .B gb
 options:
index 5b0714b357d8378600cef232d273e35c04ff0880..6aa086ac6c8bcef73c3103d5e0b14984b2ebe36a 100644 (file)
@@ -5,6 +5,9 @@ md \- emulator
 .B games/md
 [
 .B -a
+] [
+.B -x
+.I scale
 ]
 .I romfile
 .SH DESCRIPTION
@@ -24,6 +27,9 @@ Command line options:
 .TP
 .B -a
 Enable audio output.
+.TP
+.B -x
+Scale the screen to a given factor regardless of the window's size.
 .SH SOURCE
 .B /sys/src/games/md
 .SH BUGS
index 728401d898792db5c0002a1a9305f0df41b9f75a..17f842ac59029c4ddd772d04f0a7a4e169e7a759 100644 (file)
@@ -49,6 +49,13 @@ loadrom(char *name)
        close(fd);
 }
 
+void
+usage(void)
+{
+       fprint(2, "usage: %s [-a] [-x scale] rom\n", argv0);
+       exits("usage");
+}
+
 void
 threadmain(int argc, char **argv)
 {
@@ -56,14 +63,14 @@ threadmain(int argc, char **argv)
        case 'a':
                initaudio();
                break;
+       case 'x':
+               fixscale = strtol(EARGF(usage()), nil, 0);
+               break;
        default:
-               goto usage;
+               usage();
        } ARGEND;
-       if(argc != 1){
-       usage:
-               fprint(2, "usage: %s [ -23a ] rom\n", argv0);
-               exits("usage");
-       }
+       if(argc != 1)
+               usage();
        loadrom(argv[0]);
        initemu(PICW, PICH, 4, XRGB32, 1, nil);
        regkey("a", ' ', 1<<4);
index 2ca976fe717c4ff8187e15bab3d95dcea3c39720..439688e8f877dd6b9e15f044098a0663ea1057f8 100644 (file)
@@ -212,7 +212,7 @@ keyproc(void *)
 static void
 usage(void)
 {
-       fprint(2, "usage: %s [ -23a ] [ rom ]\n", argv0);
+       fprint(2, "usage: %s [-Nap] [-c cart] [-t tape] [-d bindir] [-x scale] rom\n", argv0);
        exits("usage");
 }
 
@@ -237,6 +237,9 @@ threadmain(int argc, char **argv)
        case 'd':
                bindir = strdup(EARGF(usage()));
                break;
+       case 'x':
+               fixscale = strtol(EARGF(usage()), nil, 0);
+               break;
        default:
                usage();
        } ARGEND;
index 8bd05e8502c56ddd3d14003c7788fda15200eae1..422d02d789cdb2271b48f0457c04ba16472f747b 100644 (file)
@@ -12,7 +12,7 @@ u64int keys, keys2;
 int trace, paused;
 int savereq, loadreq;
 QLock pauselock;
-int scale, warp10;
+int scale, fixscale, warp10;
 uchar *pic;
 Rectangle picr;
 Mousectl *mc;
@@ -188,11 +188,15 @@ screeninit(void)
 {
        Point p;
 
-       scale = Dx(screen->r) / vwdx;
-       if(scale <= 0)
-               scale = 1;
-       else if(scale > 16)
-               scale = 16;
+       if(!fixscale){
+               scale = Dx(screen->r) / vwdx;
+               if(Dy(screen->r) / vwdy < scale)
+                       scale = Dy(screen->r) / vwdy;
+               if(scale <= 0)
+                       scale = 1;
+               else if(scale > 16)
+                       scale = 16;
+       }
        p = divpt(addpt(screen->r.min, screen->r.max), 2);
        picr = Rpt(subpt(p, Pt(scale * vwdx/2, scale * vwdy/2)),
                addpt(p, Pt(scale * vwdx/2, scale * vwdy/2)));
@@ -319,5 +323,6 @@ initemu(int dx, int dy, int bpp, ulong chan, int dokey, void(*kproc)(void*))
        if(kproc == nil)
                proccreate(joyproc, nil, mainstacksize);
        bg = allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0xCCCCCCFF);
+       scale = fixscale;
        screeninit();
 }
index 949cf7cb2e48acd7500d21d12c6489b924b8253f..89d6fafbb331c9ba6fca01e58e5a5fe804ce35b7 100644 (file)
@@ -7,7 +7,7 @@ extern u64int keys, keys2;
 extern int trace, paused;
 extern int savereq, loadreq;
 extern QLock pauselock;
-extern int scale, warp10;
+extern int scale, fixscale, warp10;
 extern uchar *pic;
 
 void*  emalloc(ulong);
index b82729023b002070bd8775445669ac70ab283b64..5e038ddf4f71eff5f2c8eecac94e9e4f2ca11e4b 100644 (file)
@@ -221,7 +221,7 @@ flush(void)
 void
 usage(void)
 {
-       fprint(2, "usage: %s [-23aTcd] [-C col0,col1,col2,col3] rom\n", argv0);
+       fprint(2, "usage: %s [-aTcd] [-C col0,col1,col2,col3] [-x scale] rom\n", argv0);
        exits("usage");
 }
 
@@ -277,6 +277,9 @@ threadmain(int argc, char **argv)
        case 'C':
                colparse(EARGF(usage()));
                break;
+       case 'x':
+               fixscale = strtol(EARGF(usage()), nil, 0);
+               break;
        default:
                usage();
        } ARGEND;
index ec8c1bc7a183d9dfe830274eabe1095f177be177..a306c756a8fa7bfdebf56e32ff88d16fd91b6fbf 100644 (file)
@@ -220,7 +220,7 @@ flush(void)
 void
 usage(void)
 {
-       fprint(2, "usage: %s [-aT] [-s savetype] [-b biosfile] rom\n", argv0);
+       fprint(2, "usage: %s [-a] [-s savetype] [-b biosfile] [-x scale] rom\n", argv0);
        exits("usage");
 }
 
@@ -243,6 +243,9 @@ threadmain(int argc, char **argv)
        case 'b':
                biosfile = strdup(EARGF(usage()));
                break;
+       case 'x':
+               fixscale = strtol(EARGF(usage()), nil, 0);
+               break;
        default:
                usage();
        } ARGEND;
index 2c0ed3fda978ac6543815d780fb253f4f2a981c2..e9060e61cb26f3dc61c05ed7c3c187ee049b1549 100644 (file)
@@ -102,6 +102,13 @@ loadrom(char *file)
        }
 }
 
+void
+usage(void)
+{
+       fprint(2, "usage: %s [-a] [-x scale] rom\n", argv0);
+       exits("usage");
+}
+
 void
 threadmain(int argc, char **argv)
 {
@@ -111,14 +118,14 @@ threadmain(int argc, char **argv)
        case 'a':
                initaudio();
                break;
+       case 'x':
+               fixscale = strtol(EARGF(usage()), nil, 0);
+               break;
        default:
-               ;
+               usage();
        } ARGEND;
-       
-       if(argc != 1){
-               fprint(2, "usage: %s [-23a] rom\n", argv0);
-               threadexitsall("usage");
-       }
+       if(argc < 1)
+               usage();
        loadrom(*argv);
        initemu(320, 224, 4, XRGB32, 1, nil);
        regkey("a", 'c', 1<<5);
index 38984efff30a9cb71103065541f323e3bfba228b..92c470f216641b2e79f97a8a7d17f0b25858c383 100644 (file)
@@ -117,6 +117,13 @@ loadrom(char *file, int sflag)
        mapper[map](INIT, 0);
 }
 
+void
+usage(void)
+{
+       fprint(2, "usage: %s [-aos] [-x scale] rom\n", argv0);
+       exits("usage");
+}
+
 void
 threadmain(int argc, char **argv)
 {
@@ -133,15 +140,14 @@ threadmain(int argc, char **argv)
        case 's':
                sflag = 1;
                break;
+       case 'x':
+               fixscale = strtol(EARGF(usage()), nil, 0);
+               break;
        default:
-               goto usage;
+               usage();
        } ARGEND;
-
-       if(argc != 1){
-       usage:
-               fprint(2, "usage: %s [-23aos] rom\n", argv0);
-               threadexitsall("usage");
-       }
+       if(argc < 1)
+               usage();
        loadrom(argv[0], sflag);
        initemu(256, 240 - oflag * 16, 4, XRGB32, 1, nil);
        regkey("b", 'z', 1<<1);
index 7d37fcbc3ea9d24a154ee97731d09ac5c3e1536f..ba90408455e1e43fb7543380568984e9a400d337 100644 (file)
@@ -108,6 +108,13 @@ loadbat(char *file)
        }
 }
 
+void
+usage(void)
+{
+       fprint(2, "usage: %s [-23ahmsT] [-x scale] rom\n", argv0);
+       exits("usage");
+}
+
 void
 threadmain(int argc, char **argv)
 {
@@ -129,15 +136,14 @@ threadmain(int argc, char **argv)
        case 'h':
                hirom++;
                break;
+       case 'x':
+               fixscale = strtol(EARGF(usage()), nil, 0);
+               break;
        default:
-               goto usage;
+               usage();
        } ARGEND;
-       
-       if(argc != 1){
-usage:
-               fprint(2, "usage: %s [-23ahmsT] rom\n", argv0);
-               threadexitsall("usage");
-       }
+       if(argc < 1)
+               usage();
        loadrom(argv[0]);
        initemu(256, 239, 2, RGB15, !mouse, nil);
        regkey("b", 'z', 1<<31);