Introduced two new options in SDL: --autoscale and --keepratio. Autoscale will try to find the best scaling options for the monitor resolution. If keepratio is on, the native NES ratio will not be changed. I set autoscale to a default option, so SDL people please test this.
This commit is contained in:
parent
baff2b3f27
commit
2a2a7536df
|
@ -151,6 +151,8 @@ InitConfig()
|
||||||
config->addOption('f', "fullscreen", "SDL.Fullscreen", 0);
|
config->addOption('f', "fullscreen", "SDL.Fullscreen", 0);
|
||||||
config->addOption('b', "bpp", "SDL.BitsPerPixel", 32);
|
config->addOption('b', "bpp", "SDL.BitsPerPixel", 32);
|
||||||
config->addOption("doublebuf", "SDL.DoubleBuffering", 0);
|
config->addOption("doublebuf", "SDL.DoubleBuffering", 0);
|
||||||
|
config->addOption("autoscale", "SDL.AutoScale", 1);
|
||||||
|
config->addOption("keepaspect", "SDL.KeepAspect", 1);
|
||||||
config->addOption("xscale", "SDL.XScale", 1.0);
|
config->addOption("xscale", "SDL.XScale", 1.0);
|
||||||
config->addOption("yscale", "SDL.YScale", 1.0);
|
config->addOption("yscale", "SDL.YScale", 1.0);
|
||||||
config->addOption("xstretch", "SDL.XStretch", 0);
|
config->addOption("xstretch", "SDL.XStretch", 0);
|
||||||
|
|
|
@ -110,6 +110,18 @@ KillVideo()
|
||||||
|
|
||||||
static int s_sponge;
|
static int s_sponge;
|
||||||
|
|
||||||
|
inline double GetXScale(int xres)
|
||||||
|
{
|
||||||
|
return ((double)xres) / NWIDTH;
|
||||||
|
}
|
||||||
|
inline double GetYScale(int yres)
|
||||||
|
{
|
||||||
|
return ((double)yres) / s_tlines;
|
||||||
|
//if(_integerscalefs)
|
||||||
|
// scale = (int)scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to initialize the graphical video display. Returns 0 on
|
* Attempts to initialize the graphical video display. Returns 0 on
|
||||||
* success, -1 on failure.
|
* success, -1 on failure.
|
||||||
|
@ -122,6 +134,7 @@ InitVideo(FCEUGI *gi)
|
||||||
int error, flags = 0;
|
int error, flags = 0;
|
||||||
int doublebuf, xstretch, ystretch, xres, yres;
|
int doublebuf, xstretch, ystretch, xres, yres;
|
||||||
|
|
||||||
|
|
||||||
FCEUI_printf("Initializing video...");
|
FCEUI_printf("Initializing video...");
|
||||||
|
|
||||||
// load the relevant configuration variables
|
// load the relevant configuration variables
|
||||||
|
@ -144,6 +157,7 @@ InitVideo(FCEUGI *gi)
|
||||||
s_tlines = s_erendline - s_srendline + 1;
|
s_tlines = s_erendline - s_srendline + 1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// check for OpenGL and set the global flags
|
// check for OpenGL and set the global flags
|
||||||
#ifdef OPENGL
|
#ifdef OPENGL
|
||||||
if(s_useOpenGL && !s_sponge) {
|
if(s_useOpenGL && !s_sponge) {
|
||||||
|
@ -170,9 +184,37 @@ InitVideo(FCEUGI *gi)
|
||||||
flags |= SDL_HWSURFACE;
|
flags |= SDL_HWSURFACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double auto_xscale = 0;
|
||||||
|
double auto_yscale = 0;
|
||||||
|
int autoscale;
|
||||||
// check if we are rendering fullscreen
|
// check if we are rendering fullscreen
|
||||||
if(s_fullscreen) {
|
if(s_fullscreen) {
|
||||||
flags |= SDL_FULLSCREEN;
|
flags |= SDL_FULLSCREEN;
|
||||||
|
g_config->getOption("SDL.AutoScale", &autoscale);
|
||||||
|
if(autoscale)
|
||||||
|
{
|
||||||
|
auto_xscale = GetXScale(xres);
|
||||||
|
auto_yscale = GetYScale(yres);
|
||||||
|
double native_ratio = ((double)NWIDTH) / s_tlines;
|
||||||
|
double screen_ratio = ((double)xres) / yres;
|
||||||
|
int keep_aspect;
|
||||||
|
g_config->getOption("SDL.KeepAspect", &keep_aspect);
|
||||||
|
// Try to choose resolution
|
||||||
|
|
||||||
|
if (screen_ratio < native_ratio)
|
||||||
|
{
|
||||||
|
// The screen is narrower than the original. Maximizing width will not clip
|
||||||
|
auto_xscale = auto_yscale = GetXScale(xres);
|
||||||
|
if (keep_aspect)
|
||||||
|
auto_yscale = GetYScale(yres);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto_yscale = auto_xscale = GetYScale(yres);
|
||||||
|
if (keep_aspect)
|
||||||
|
auto_xscale = GetXScale(xres);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(noframe) {
|
if(noframe) {
|
||||||
|
@ -200,8 +242,17 @@ InitVideo(FCEUGI *gi)
|
||||||
int desbpp;
|
int desbpp;
|
||||||
g_config->getOption("SDL.BitsPerPixel", &desbpp);
|
g_config->getOption("SDL.BitsPerPixel", &desbpp);
|
||||||
|
|
||||||
g_config->getOption("SDL.XScale", &s_exs);
|
if (autoscale)
|
||||||
g_config->getOption("SDL.YScale", &s_eys);
|
{
|
||||||
|
s_exs = auto_xscale;
|
||||||
|
s_eys = auto_yscale;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_config->getOption("SDL.XScale", &s_exs);
|
||||||
|
g_config->getOption("SDL.YScale", &s_eys);
|
||||||
|
}
|
||||||
|
|
||||||
g_config->getOption("SDL.SpecialFX", &s_eefx);
|
g_config->getOption("SDL.SpecialFX", &s_eefx);
|
||||||
|
|
||||||
#ifdef OPENGL
|
#ifdef OPENGL
|
||||||
|
|
|
@ -58,6 +58,8 @@ char *DriverUsage=
|
||||||
--nothrottle x Disables artificial speed throttling, if x is nonzero.\n\
|
--nothrottle x Disables artificial speed throttling, if x is nonzero.\n\
|
||||||
--frameskip x Sets # of frames to skip per emulated frame.\n\
|
--frameskip x Sets # of frames to skip per emulated frame.\n\
|
||||||
--(x/y)res x, -(x/y) x Sets horizontal/vertical resolution to x for full screen mode.\n\
|
--(x/y)res x, -(x/y) x Sets horizontal/vertical resolution to x for full screen mode.\n\
|
||||||
|
--autoscale x Enables autoscaling if x is nonzero \n\
|
||||||
|
--keepratio x Keeps native NES ratio when autoscaling if x is nonzero \n\
|
||||||
--(x/y)scale x Multiplies width/height by x (Real numbers >0 with OpenGL, otherwise integers >0).\n\
|
--(x/y)scale x Multiplies width/height by x (Real numbers >0 with OpenGL, otherwise integers >0).\n\
|
||||||
--(x/y)stretch x Stretchess to fill surface on x/y axis (fullscreen, only with OpenGL).\n\
|
--(x/y)stretch x Stretchess to fill surface on x/y axis (fullscreen, only with OpenGL).\n\
|
||||||
--bpp x, -b x Sets bits per pixel for SDL surface(and video mode in fs). 8, 16, 32.\n\
|
--bpp x, -b x Sets bits per pixel for SDL surface(and video mode in fs). 8, 16, 32.\n\
|
||||||
|
|
Loading…
Reference in New Issue