--- previous/src/resolution.c 2018/04/24 19:25:10 1.1 +++ previous/src/resolution.c 2018/04/24 19:29:53 1.1.1.3 @@ -22,6 +22,41 @@ const char Resolution_fileid[] = "Hatari #define Dprintf(a) #endif +static int DesktopWidth, DesktopHeight; + +/** + * Initilizes resolution settings (gets current desktop + * resolution, sets max Falcon/TT Videl zooming resolution). + */ +void Resolution_Init(void) +{ + /* Needs to be called after SDL video and configuration + * initialization, but before Hatari Screen init is called + * for the first time! + */ + fprintf(stderr,"FIXME: Resolution init!\n"); + DesktopWidth = 800; + DesktopHeight = 600; + + /* if user hasn't set own max zoom size, use desktop size */ + if (!(ConfigureParams.Screen.nMaxWidth && + ConfigureParams.Screen.nMaxHeight)) { + ConfigureParams.Screen.nMaxWidth = DesktopWidth; + ConfigureParams.Screen.nMaxHeight = DesktopHeight; + } + Dprintf(("Desktop resolution: %dx%d\n",DesktopWidth, DesktopHeight)); + Dprintf(("Configured Max res: %dx%d\n",ConfigureParams.Screen.nMaxWidth,ConfigureParams.Screen.nMaxHeight)); +} + +/** + * Get current desktop resolution + */ +void Resolution_GetDesktopSize(int *width, int *height) +{ + *width = DesktopWidth; + *height = DesktopHeight; +} + /** * Select best resolution from given SDL video modes. @@ -43,7 +78,7 @@ static bool Resolution_Select(SDL_Rect * *height = modes[i]->h; } } - Dprintf(("hostscreen: largest found video mode: %dx%d\n",*width,*height)); + Dprintf(("resolution: largest found video mode: %dx%d\n",*width,*height)); return true; } @@ -63,7 +98,7 @@ static bool Resolution_Select(SDL_Rect * } *width = bestw; *height = besth; - Dprintf(("hostscreen: video mode found: %dx%d\n",*width,*height)); + Dprintf(("resolution: video mode found: %dx%d\n",*width,*height)); return true; #undef TOO_LARGE } @@ -76,72 +111,34 @@ static bool Resolution_Select(SDL_Rect * */ void Resolution_Search(int *width, int *height, int *bpp) { - SDL_Rect **modes; - SDL_PixelFormat pixelformat; - Uint32 modeflags; - - /* Search in available modes the best suited */ - Dprintf(("hostscreen: video mode asked: %dx%dx%d\n", - *width, *height, *bpp)); - - /* Read available video modes */ - modeflags = 0 /*SDL_HWSURFACE | SDL_HWPALETTE*/; - if (bInFullScreen) - modeflags |= SDL_FULLSCREEN; - - /*--- Search a video mode with asked bpp ---*/ - if (*bpp != 0) { - pixelformat.BitsPerPixel = *bpp; - modes = SDL_ListModes(&pixelformat, modeflags); - if ((modes != (SDL_Rect **) 0) && (modes != (SDL_Rect **) -1)) { - Dprintf(("hostscreen: searching a good video mode (any bpp)\n")); - if (Resolution_Select(modes, width, height)) { - Dprintf(("hostscreen: video mode selected: %dx%dx%d\n", - *width, *height, *bpp)); - return; - } - } - } - - /*--- Search a video mode with any bpp ---*/ - modes = SDL_ListModes(NULL, modeflags); - if ((modes != (SDL_Rect **) 0) && (modes != (SDL_Rect **) -1)) { - Dprintf(("hostscreen: searching a good video mode\n")); - if (Resolution_Select(modes, width, height)) { - Dprintf(("hostscreen: video mode selected: %dx%dx%d\n", - *width, *height, *bpp)); - return; - } - } - - if (modes == (SDL_Rect **) 0) { - fprintf(stderr, "WARNING: No suitable video modes available!\n"); - } - - if (modes == (SDL_Rect **) -1) { - /* Any mode available */ - Dprintf(("hostscreen: All resolutions available.\n")); - } - - Dprintf(("hostscreen: video mode selected: %dx%dx%d\n", - *width, *height, *bpp)); + fprintf(stderr,"FIXME: Resolution_Search\n"); + Resolution_GetDesktopSize(width, height); } /** - * Set given width & height arguments to maximum size in the configuration, - * or if that's too large for the requested bit depth, to the largest - * available video mode size. + * Set given width & height arguments to maximum size allowed in the + * configuration, or if that's too large for the requested bit depth, + * to the largest available video mode size. */ void Resolution_GetLimits(int *width, int *height, int *bpp) { *width = *height = 0; /* constrain max size to what HW/SDL offers */ + Dprintf(("resolution: request limits for: %dx%dx%d\n", *width, *height, *bpp)); Resolution_Search(width, height, bpp); - if (!(*width && *width) || + + if (bInFullScreen && ConfigureParams.Screen.bKeepResolution) { + /* resolution change not allowed */ + Dprintf(("resolution: limit to desktop size\n")); + Resolution_GetDesktopSize(width, height); + return; + } + if (!(*width && *height) || + (ConfigureParams.Screen.nMaxWidth < *width && ConfigureParams.Screen.nMaxHeight < *height)) { - /* already within it, use user provided value */ + Dprintf(("resolution: limit to user configured max\n")); *width = ConfigureParams.Screen.nMaxWidth; *height = ConfigureParams.Screen.nMaxHeight; }