cli: add scaling
the new command line parameter --scale allows to scale the window by a floating point factor. SDL2 stretches it in hardware to the desired size, which makes the scaled window run at almost identical speed to 1x scale.
This commit is contained in:
parent
b685818413
commit
90326ea1f9
|
@ -81,6 +81,7 @@ CommandLine::CommandLine()
|
||||||
, disable_limiter(0)
|
, disable_limiter(0)
|
||||||
, windowed_fullscreen(0)
|
, windowed_fullscreen(0)
|
||||||
, frameskip(0)
|
, frameskip(0)
|
||||||
|
, scale(1.0)
|
||||||
, _rtc_day(-1)
|
, _rtc_day(-1)
|
||||||
, _rtc_hour(-1)
|
, _rtc_hour(-1)
|
||||||
{
|
{
|
||||||
|
@ -123,6 +124,7 @@ static const char* help_string = \
|
||||||
" --windowed-fullscreen" ENDL
|
" --windowed-fullscreen" ENDL
|
||||||
" Launches in windowed fullscreen (same as alt+enter)" ENDL
|
" Launches in windowed fullscreen (same as alt+enter)" ENDL
|
||||||
#else
|
#else
|
||||||
|
" --scale N scale factor for window; default 1.0" ENDL
|
||||||
" --nojoy Disables joystick support" ENDL
|
" --nojoy Disables joystick support" ENDL
|
||||||
#endif
|
#endif
|
||||||
" --disable-sound Disables the sound output" ENDL
|
" --disable-sound Disables the sound output" ENDL
|
||||||
|
@ -198,6 +200,7 @@ ENDL
|
||||||
#define OPT_3D_TEXTURE_UPSCALE 81
|
#define OPT_3D_TEXTURE_UPSCALE 81
|
||||||
#define OPT_GPU_RESOLUTION_MULTIPLIER 82
|
#define OPT_GPU_RESOLUTION_MULTIPLIER 82
|
||||||
#define OPT_FRAMESKIP 83
|
#define OPT_FRAMESKIP 83
|
||||||
|
#define OPT_SCALE 84
|
||||||
#define OPT_JIT_SIZE 100
|
#define OPT_JIT_SIZE 100
|
||||||
|
|
||||||
#define OPT_CONSOLE_TYPE 200
|
#define OPT_CONSOLE_TYPE 200
|
||||||
|
@ -261,6 +264,7 @@ bool CommandLine::parse(int argc,char **argv)
|
||||||
{ "windowed-fullscreen", no_argument, &windowed_fullscreen, 1 },
|
{ "windowed-fullscreen", no_argument, &windowed_fullscreen, 1 },
|
||||||
#else
|
#else
|
||||||
{ "nojoy", no_argument, &_commandline_linux_nojoy, 1},
|
{ "nojoy", no_argument, &_commandline_linux_nojoy, 1},
|
||||||
|
{ "scale", required_argument, NULL, OPT_SCALE},
|
||||||
#endif
|
#endif
|
||||||
{ "frameskip", required_argument, NULL, OPT_FRAMESKIP},
|
{ "frameskip", required_argument, NULL, OPT_FRAMESKIP},
|
||||||
{ "disable-sound", no_argument, &disable_sound, 1},
|
{ "disable-sound", no_argument, &disable_sound, 1},
|
||||||
|
@ -339,6 +343,7 @@ bool CommandLine::parse(int argc,char **argv)
|
||||||
case OPT_3D_RENDER: _render3d = optarg; break;
|
case OPT_3D_RENDER: _render3d = optarg; break;
|
||||||
case OPT_3D_TEXTURE_UPSCALE: texture_upscale = atoi(optarg); break;
|
case OPT_3D_TEXTURE_UPSCALE: texture_upscale = atoi(optarg); break;
|
||||||
case OPT_GPU_RESOLUTION_MULTIPLIER: gpu_resolution_multiplier = atoi(optarg); break;
|
case OPT_GPU_RESOLUTION_MULTIPLIER: gpu_resolution_multiplier = atoi(optarg); break;
|
||||||
|
case OPT_SCALE: scale = atof(optarg); break;
|
||||||
case OPT_FRAMESKIP: frameskip = atoi(optarg); break;
|
case OPT_FRAMESKIP: frameskip = atoi(optarg); break;
|
||||||
|
|
||||||
//RTC settings
|
//RTC settings
|
||||||
|
|
|
@ -49,6 +49,7 @@ public:
|
||||||
int texture_upscale;
|
int texture_upscale;
|
||||||
int gpu_resolution_multiplier;
|
int gpu_resolution_multiplier;
|
||||||
int language;
|
int language;
|
||||||
|
float scale;
|
||||||
std::string nds_file;
|
std::string nds_file;
|
||||||
std::string play_movie_file;
|
std::string play_movie_file;
|
||||||
std::string record_movie_file;
|
std::string record_movie_file;
|
||||||
|
|
|
@ -262,17 +262,17 @@ static void
|
||||||
resizeWindow_stub (u16 width, u16 height, void *screen_texture) {
|
resizeWindow_stub (u16 width, u16 height, void *screen_texture) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void Draw(class configured_features *cfg) {
|
||||||
Draw( void) {
|
const float scale = cfg->scale;
|
||||||
|
const unsigned w = GPU_FRAMEBUFFER_NATIVE_WIDTH, h = GPU_FRAMEBUFFER_NATIVE_HEIGHT;
|
||||||
|
const int ws = w * scale, hs = h * scale;
|
||||||
const NDSDisplayInfo &displayInfo = GPU->GetDisplayInfo();
|
const NDSDisplayInfo &displayInfo = GPU->GetDisplayInfo();
|
||||||
const size_t pixCount = GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT;
|
const size_t pixCount = w * h;
|
||||||
ColorspaceApplyIntensityToBuffer16<false, false>(displayInfo.nativeBuffer16[NDSDisplayID_Main], pixCount, displayInfo.backlightIntensity[NDSDisplayID_Main]);
|
ColorspaceApplyIntensityToBuffer16<false, false>(displayInfo.nativeBuffer16[NDSDisplayID_Main], pixCount, displayInfo.backlightIntensity[NDSDisplayID_Main]);
|
||||||
ColorspaceApplyIntensityToBuffer16<false, false>(displayInfo.nativeBuffer16[NDSDisplayID_Touch], pixCount, displayInfo.backlightIntensity[NDSDisplayID_Touch]);
|
ColorspaceApplyIntensityToBuffer16<false, false>(displayInfo.nativeBuffer16[NDSDisplayID_Touch], pixCount, displayInfo.backlightIntensity[NDSDisplayID_Touch]);
|
||||||
static const SDL_Rect destrect[2] = {
|
SDL_Rect destrect[2] = {
|
||||||
{ 0,0,
|
{ 0, 0 , ws, hs},
|
||||||
GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT},
|
{ 0, hs, ws, hs},
|
||||||
{ 0, GPU_FRAMEBUFFER_NATIVE_HEIGHT,
|
|
||||||
GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT},
|
|
||||||
};
|
};
|
||||||
unsigned i, off = 0, n = pixCount*2;
|
unsigned i, off = 0, n = pixCount*2;
|
||||||
for(i = 0; i < 2; ++i) {
|
for(i = 0; i < 2; ++i) {
|
||||||
|
@ -481,9 +481,10 @@ int main(int argc, char ** argv) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nds_screen_size_ratio = my_config.scale;
|
||||||
sdl_videoFlags |= SDL_WINDOW_OPENGL;
|
sdl_videoFlags |= SDL_WINDOW_OPENGL;
|
||||||
window = SDL_CreateWindow( "Desmume SDL", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
window = SDL_CreateWindow( "Desmume SDL", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
||||||
256, 384, sdl_videoFlags );
|
256*my_config.scale, 384*my_config.scale, sdl_videoFlags );
|
||||||
|
|
||||||
if ( !window ) {
|
if ( !window ) {
|
||||||
fprintf( stderr, "Window creation failed: %s\n", SDL_GetError( ) );
|
fprintf( stderr, "Window creation failed: %s\n", SDL_GetError( ) );
|
||||||
|
@ -541,7 +542,7 @@ int main(int argc, char ** argv) {
|
||||||
DrawHUD();
|
DrawHUD();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Draw();
|
Draw(&my_config);
|
||||||
|
|
||||||
#ifdef HAVE_LIBAGG
|
#ifdef HAVE_LIBAGG
|
||||||
osd->clear();
|
osd->clear();
|
||||||
|
|
|
@ -259,7 +259,7 @@ u16 get_set_joy_key(int index) {
|
||||||
|
|
||||||
static signed long
|
static signed long
|
||||||
screen_to_touch_range( signed long scr, float size_ratio) {
|
screen_to_touch_range( signed long scr, float size_ratio) {
|
||||||
return (signed long)((float)scr * size_ratio);
|
return (signed long)((float)scr / size_ratio);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set mouse coordinates */
|
/* Set mouse coordinates */
|
||||||
|
|
Loading…
Reference in New Issue