ref: 09c61204440ea7d23015b09f908e4105b68cc7b6
parent: 382c9ef92cf0830f5639906ffd5f363ecefd670a
author: qwx <devnull@localhost>
date: Wed Jun 13 10:05:19 EDT 2018
emulators ui: add option for fixed factor scaling and bound scale vertically
--- a/sys/man/1/atari
+++ b/sys/man/1/atari
@@ -1,4 +1,4 @@
-.SH ATARI 1
+.TH ATARI 1
.SH NAME
2600 \- emulator
.SH SYNOPSIS
@@ -5,6 +5,9 @@
.B games/2600
[
.B -a
+] [
+.B -x
+.I scale
]
.I romfile
.SH DESCRIPTION
@@ -26,6 +29,9 @@
.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
--- a/sys/man/1/nintendo
+++ b/sys/man/1/nintendo
@@ -9,6 +9,9 @@
[
.B -C
.I ...
+] [
+.B -x
+.I scale
]
.I romfile
.br
@@ -21,6 +24,9 @@
] [
.B -s
.I savetype
+] [
+.B -x
+.I scale
]
.I romfile
.br
@@ -27,6 +33,9 @@
.B games/nes
[
.B -aos
+] [
+.B -x
+.I scale
]
.I romfile
.br
@@ -33,6 +42,9 @@
.B games/snes
[
.B -ahmsT
+] [
+.B -x
+.I scale
]
.I romfile
.SH DESCRIPTION
@@ -62,6 +74,9 @@
.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:
--- a/sys/man/1/sega
+++ b/sys/man/1/sega
@@ -5,6 +5,9 @@
.B games/md
[
.B -a
+] [
+.B -x
+.I scale
]
.I romfile
.SH DESCRIPTION
@@ -24,6 +27,9 @@
.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
--- a/sys/src/games/2600/2600.c
+++ b/sys/src/games/2600/2600.c
@@ -50,6 +50,13 @@
}
void
+usage(void)
+{
+ fprint(2, "usage: %s [-a] [-x scale] rom\n", argv0);
+ exits("usage");
+}
+
+void
threadmain(int argc, char **argv)
{
ARGBEGIN {
@@ -56,14 +63,14 @@
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);
--- a/sys/src/games/c64/c64.c
+++ b/sys/src/games/c64/c64.c
@@ -212,7 +212,7 @@
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");
}
@@ -236,6 +236,9 @@
break;
case 'd':
bindir = strdup(EARGF(usage()));
+ break;
+ case 'x':
+ fixscale = strtol(EARGF(usage()), nil, 0);
break;
default:
usage();
--- a/sys/src/games/eui.c
+++ b/sys/src/games/eui.c
@@ -12,7 +12,7 @@
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 @@
{
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 @@
if(kproc == nil)
proccreate(joyproc, nil, mainstacksize);
bg = allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0xCCCCCCFF);
+ scale = fixscale;
screeninit();
}
--- a/sys/src/games/eui.h
+++ b/sys/src/games/eui.h
@@ -7,7 +7,7 @@
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);
--- a/sys/src/games/gb/gb.c
+++ b/sys/src/games/gb/gb.c
@@ -221,7 +221,7 @@
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");
}
@@ -276,6 +276,9 @@
break;
case 'C':
colparse(EARGF(usage()));
+ break;
+ case 'x':
+ fixscale = strtol(EARGF(usage()), nil, 0);
break;
default:
usage();
--- a/sys/src/games/gba/gba.c
+++ b/sys/src/games/gba/gba.c
@@ -220,7 +220,7 @@
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");
}
@@ -242,6 +242,9 @@
break;
case 'b':
biosfile = strdup(EARGF(usage()));
+ break;
+ case 'x':
+ fixscale = strtol(EARGF(usage()), nil, 0);
break;
default:
usage();
--- a/sys/src/games/md/md.c
+++ b/sys/src/games/md/md.c
@@ -103,6 +103,13 @@
}
void
+usage(void)
+{
+ fprint(2, "usage: %s [-a] [-x scale] rom\n", argv0);
+ exits("usage");
+}
+
+void
threadmain(int argc, char **argv)
{
int t;
@@ -111,14 +118,14 @@
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);
--- a/sys/src/games/nes/nes.c
+++ b/sys/src/games/nes/nes.c
@@ -118,6 +118,13 @@
}
void
+usage(void)
+{
+ fprint(2, "usage: %s [-aos] [-x scale] rom\n", argv0);
+ exits("usage");
+}
+
+void
threadmain(int argc, char **argv)
{
int t, sflag;
@@ -133,15 +140,14 @@
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);
--- a/sys/src/games/snes/snes.c
+++ b/sys/src/games/snes/snes.c
@@ -109,6 +109,13 @@
}
void
+usage(void)
+{
+ fprint(2, "usage: %s [-23ahmsT] [-x scale] rom\n", argv0);
+ exits("usage");
+}
+
+void
threadmain(int argc, char **argv)
{
int t;
@@ -129,15 +136,14 @@
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);