@@ -368,6 +368,13 @@ void Screen::resetDisplay(bool resetVideo)
368368 _clear.w = getWidth ();
369369 _clear.h = getHeight ();
370370
371+ double pixelRatioX = 1.0 ;
372+ double pixelRatioY = 1.0 ;
373+ if (Options::nonSquarePixelRatio && !Options::allowResize)
374+ {
375+ pixelRatioX = 0.75 ;
376+ pixelRatioY = 1.2 ;
377+ }
371378 bool cursorInBlackBands;
372379 if (!Options::keepAspectRatio)
373380 {
@@ -410,13 +417,17 @@ void Screen::resetDisplay(bool resetVideo)
410417 }
411418 else if (_scaleY > _scaleX && Options::keepAspectRatio)
412419 {
413- int targetHeight = (int )floor (_scaleX * (double )_baseHeight);
420+ int targetHeight = (int )floor (_scaleX * (double )_baseHeight * pixelRatioY );
414421 _topBlackBand = (getHeight () - targetHeight) / 2 ;
415422 if (_topBlackBand < 0 )
416423 {
417424 _topBlackBand = 0 ;
418425 }
419426 _bottomBlackBand = getHeight () - targetHeight - _topBlackBand;
427+ if (_bottomBlackBand < 0 )
428+ {
429+ _bottomBlackBand = 0 ;
430+ }
420431 _leftBlackBand = _rightBlackBand = 0 ;
421432 _cursorLeftBlackBand = 0 ;
422433
@@ -587,28 +598,41 @@ int Screen::getDY()
587598*/
588599void Screen::updateScale (int &type, int selection, int &width, int &height, bool change)
589600{
601+ double pixelRatioY = 1.0 ;
602+ double pixelRatioX = 1.0 ;
603+ if (Options::nonSquarePixelRatio && !Options::allowResize)
604+ {
605+ pixelRatioX = 0.75 ;
606+ pixelRatioY = 1.2 ;
607+ }
590608 type = selection;
591609 switch (type)
592610 {
593611 case SCALE_15X :
594- width = Screen::ORIGINAL_WIDTH * 1.5 ;
595- height = Screen::ORIGINAL_HEIGHT * 1.5 ;
612+ width = int ( floor ( Screen::ORIGINAL_WIDTH * 1.5 )) ;
613+ height = int ( floor ( Screen::ORIGINAL_HEIGHT * 1.5 )) ;
596614 break ;
597615 case SCALE_2X :
598- width = Screen::ORIGINAL_WIDTH * 2 ;
599- height = Screen::ORIGINAL_HEIGHT * 2 ;
616+ width = int ( floor ( Screen::ORIGINAL_WIDTH * 2 )) ;
617+ height = int ( floor ( Screen::ORIGINAL_HEIGHT * 2 )) ;
600618 break ;
601619 case SCALE_SCREEN_DIV_3 :
602- width = Options::newDisplayWidth / 3 ;
603- height = Options::newDisplayHeight / 3 ;
620+ width = int (floor (Options::displayWidth / 3 * pixelRatioY));
621+ height = int (floor (Options::displayHeight / 3 ));
622+ width = std::max (width, int (floor (Screen::ORIGINAL_WIDTH / pixelRatioX * pixelRatioY)));
623+ height = std::max (height, int (floor (Screen::ORIGINAL_HEIGHT * pixelRatioY)));
604624 break ;
605625 case SCALE_SCREEN_DIV_2 :
606- width = Options::newDisplayWidth / 2 ;
607- height = Options::newDisplayHeight / 2 ;
626+ width = int (floor (Options::displayWidth / 2 * pixelRatioY));
627+ height = int (floor (Options::displayHeight / 2 ));
628+ width = std::max (width, int (floor (Screen::ORIGINAL_WIDTH / pixelRatioX * pixelRatioY)));
629+ height = std::max (height, int (floor (Screen::ORIGINAL_HEIGHT * pixelRatioY)));
608630 break ;
609631 case SCALE_SCREEN :
610- width = Options::newDisplayWidth;
611- height = Options::newDisplayHeight;
632+ width = int (floor (Options::displayWidth * pixelRatioY));
633+ height = int (floor (Options::displayHeight));
634+ width = std::max (width, int (floor (Screen::ORIGINAL_WIDTH / pixelRatioX * pixelRatioY)));
635+ height = std::max (height, int (floor (Screen::ORIGINAL_HEIGHT * pixelRatioY)));
612636 break ;
613637 case SCALE_ORIGINAL :
614638 default :
0 commit comments