Re: [hatari-users] Open Hatari in big window

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-users Archives ]


Hi,

On 2/26/20 12:51 AM, Vincent Rivière wrote:
On 23/02/2020 at 21:49, Eero Tamminen wrote:
Either "-z 2" or "--zoom 2".

-z 2 seems to be the default, because when I use it the result is the same.
On the other hand, -z 1 reduces the window.

I would like to get the biggest window with integer zoom ratio. Unfortunately, -z 3 does nothing.

Try the attached patch.  Code supports floating
point scaling factors, but command line option
currently only integer ones.

It requires Hatari to be built with SDL2, and
that you haven't disabled SdlRenderer use from
Hatari configuration file.


So unless using extended VDI video modes (I don't want that), it seems to be impossible to start Hatari in a big window :-(


	- Eero

diff --git a/src/configuration.c b/src/configuration.c
index 87fe724d..550b5b2e 100644
--- a/src/configuration.c
+++ b/src/configuration.c
@@ -98,6 +98,7 @@ static const struct Config_Tag configs_Screen[] =
 	{ "bForceMax", Bool_Tag, &ConfigureParams.Screen.bForceMax },
 	{ "nMaxWidth", Int_Tag, &ConfigureParams.Screen.nMaxWidth },
 	{ "nMaxHeight", Int_Tag, &ConfigureParams.Screen.nMaxHeight },
+	{ "nZoomFactor", Float_Tag, &ConfigureParams.Screen.nZoomFactor },
 #if WITH_SDL2
 	{ "bUseSdlRenderer", Bool_Tag, &ConfigureParams.Screen.bUseSdlRenderer },
 	{ "nRenderScaleQuality", Int_Tag, &ConfigureParams.Screen.nRenderScaleQuality },
@@ -834,6 +835,7 @@ void Configuration_SetDefault(void)
 	ConfigureParams.Screen.bShowStatusbar = true;
 	ConfigureParams.Screen.bShowDriveLed = true;
 	ConfigureParams.Screen.bCrop = false;
+	ConfigureParams.Screen.nZoomFactor = 1.0;
 	/* gives zoomed Falcon/TT windows about same size as ST/STE windows */
 	ConfigureParams.Screen.nMaxWidth = 2*NUM_VISIBLE_LINE_PIXELS;
 	ConfigureParams.Screen.nMaxHeight = 2*NUM_VISIBLE_LINES+STATUSBAR_MAX_HEIGHT;
diff --git a/src/includes/configuration.h b/src/includes/configuration.h
index 64d33510..189fb155 100644
--- a/src/includes/configuration.h
+++ b/src/includes/configuration.h
@@ -310,9 +310,10 @@ typedef struct
   bool bForceMax;
   int nMaxWidth;
   int nMaxHeight;
+  float nZoomFactor;
 #if WITH_SDL2
-  bool bUseSdlRenderer;
   int nRenderScaleQuality;
+  bool bUseSdlRenderer;
   bool bUseVsync;
 #endif
   bool DisableVideo;
diff --git a/src/options.c b/src/options.c
index c40a1bd6..c266efc7 100644
--- a/src/options.c
+++ b/src/options.c
@@ -265,7 +265,11 @@ static const opt_t HatariOptions[] = {
 	{ OPT_SPEC512, NULL, "--spec512",
 	  "<x>", "Spec512 palette threshold (0 <= x <= 512, 0=disable)" },
 	{ OPT_ZOOM, "-z", "--zoom",
+#if WITH_SDL2
+	  "<x>", "Screen scaling factor (1-8x)" },
+#else
 	  "<x>", "Double small resolutions (1=no, 2=yes)" },
+#endif
 	{ OPT_VIDEO_TIMING,   NULL, "--video-timing",
 	  "<x>", "Wakeup State for MMU/GLUE (x=ws1/ws2/ws3/ws4/random, default ws3)" },
 
@@ -1243,14 +1247,20 @@ bool Opt_ParseParameters(int argc, const char * const argv[])
 
 		case OPT_ZOOM:
 			zoom = atoi(argv[++i]);
-			if (zoom < 1)
+#if WITH_SDL2
+			if (zoom < 1 || zoom > 8)
+#else
+			if (zoom < 1 || zoom > 2)
+#endif
 			{
 				return Opt_ShowError(OPT_ZOOM, argv[i], "Invalid zoom value");
 			}
 			ConfigureParams.Screen.nMaxWidth = NUM_VISIBLE_LINE_PIXELS;
 			ConfigureParams.Screen.nMaxHeight = NUM_VISIBLE_LINES;
+			ConfigureParams.Screen.nZoomFactor = 1.0;
 			if (zoom > 1)
 			{
+				ConfigureParams.Screen.nZoomFactor = zoom/2.0;  /* affects only SDL2 */
 				ConfigureParams.Screen.nMaxWidth *= 2;
 				ConfigureParams.Screen.nMaxHeight *= 2;
 			}
diff --git a/src/screen.c b/src/screen.c
index 16249883..0c39f1b4 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -351,10 +351,16 @@ bool Screen_SetSDLVideoSize(int width, int height, int bitdepth, bool bForceChan
 
 #if WITH_SDL2
 	bUseSdlRenderer = ConfigureParams.Screen.bUseSdlRenderer && !bUseDummyMode;
+	float scale = ConfigureParams.Screen.nZoomFactor;
 
 	/* SDL Video attributes: */
 	win_width = width;
 	win_height = height;
+	if (bUseSdlRenderer)
+	{
+		win_width *= scale;
+		win_height *= scale;
+	}
 	if (bInFullScreen)
 	{
 		sdlVideoFlags = SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_GRABBED;
@@ -412,8 +418,8 @@ bool Screen_SetSDLVideoSize(int width, int height, int bitdepth, bool bForceChan
 #endif
 
 	/* Set new video mode */
-	DEBUGPRINT(("SDL screen request: %d x %d @ %d (%s)\n", width, height,
-	        bitdepth, bInFullScreen?"fullscreen":"windowed"));
+	DEBUGPRINT(("SDL screen request: %d x %d @ %d (%s) -> window: %d x %d\n", width, height,
+	        bitdepth, (bInFullScreen ? "fullscreen" : "windowed"), win_width, win_height));
 
 	if (sdlWindow)
 	{
@@ -451,6 +457,8 @@ bool Screen_SetSDLVideoSize(int width, int height, int bitdepth, bool bForceChan
 
 		if (bInFullScreen)
 			SDL_RenderSetLogicalSize(sdlRenderer, width, height);
+		else
+			SDL_RenderSetScale(sdlRenderer, scale, scale);
 
 		if (bitdepth == 16)
 		{


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/