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:
punkrockguy318 2008-07-02 05:20:48 +00:00
parent baff2b3f27
commit 2a2a7536df
3 changed files with 59 additions and 4 deletions

View File

@ -151,6 +151,8 @@ InitConfig()
config->addOption('f', "fullscreen", "SDL.Fullscreen", 0);
config->addOption('b', "bpp", "SDL.BitsPerPixel", 32);
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("yscale", "SDL.YScale", 1.0);
config->addOption("xstretch", "SDL.XStretch", 0);

View File

@ -110,6 +110,18 @@ KillVideo()
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
* success, -1 on failure.
@ -121,6 +133,7 @@ InitVideo(FCEUGI *gi)
const SDL_VideoInfo *vinf;
int error, flags = 0;
int doublebuf, xstretch, ystretch, xres, yres;
FCEUI_printf("Initializing video...");
@ -142,6 +155,7 @@ InitVideo(FCEUGI *gi)
// check the starting, ending, and total scan lines
FCEUI_GetCurrentVidSystem(&s_srendline, &s_erendline);
s_tlines = s_erendline - s_srendline + 1;
// check for OpenGL and set the global flags
@ -169,10 +183,38 @@ InitVideo(FCEUGI *gi)
if(vinf->hw_available) {
flags |= SDL_HWSURFACE;
}
double auto_xscale = 0;
double auto_yscale = 0;
int autoscale;
// check if we are rendering fullscreen
if(s_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) {
@ -199,9 +241,18 @@ InitVideo(FCEUGI *gi)
if(s_fullscreen) {
int desbpp;
g_config->getOption("SDL.BitsPerPixel", &desbpp);
g_config->getOption("SDL.XScale", &s_exs);
g_config->getOption("SDL.YScale", &s_eys);
if (autoscale)
{
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);
#ifdef OPENGL

View File

@ -58,6 +58,8 @@ char *DriverUsage=
--nothrottle x Disables artificial speed throttling, if x is nonzero.\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\
--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)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\