emulators ui: add option for fixed factor scaling and bound scale vertically

front
qwx 2018-06-13 14:05:19 +02:00
parent 382c9ef92c
commit 09c6120444
12 changed files with 104 additions and 37 deletions

View 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

View 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:

View 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

View 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);

View 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;

View 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();
}

View 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);

View 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;

View 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;

View 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);

View 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);

View 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);