diff --git a/src/drivers/Qt/ConsoleVideoConf.cpp b/src/drivers/Qt/ConsoleVideoConf.cpp index 151c28d8..88793071 100644 --- a/src/drivers/Qt/ConsoleVideoConf.cpp +++ b/src/drivers/Qt/ConsoleVideoConf.cpp @@ -853,8 +853,7 @@ QSize ConsoleVideoConfDialog_t::calcNewScreenSize(void) if ( aspectCbx->isChecked() ) { xscale = xScaleBox->value(); - - yscale = xscale * aspectRatio * (double)nes_shm->video.xyRatio; + yscale = xscale * (double)nes_shm->video.xyRatio; } else { @@ -864,6 +863,21 @@ QSize ConsoleVideoConfDialog_t::calcNewScreenSize(void) rw=(int)((r-l)*xscale); rh=(int)((b-t)*yscale); + if ( aspectCbx->isChecked() ) + { + double rr; + + rr = (double)rh / (double)rw; + + if ( rr > aspectRatio ) + { + rw = (int)( (((double)rh) / aspectRatio) + 0.50); + } + else + { + rh = (int)( (((double)rw) * aspectRatio) + 0.50); + } + } out.setWidth( rw + dw ); out.setHeight( rh + dh ); } diff --git a/src/drivers/Qt/ConsoleViewerGL.cpp b/src/drivers/Qt/ConsoleViewerGL.cpp index 1791cf00..79801980 100644 --- a/src/drivers/Qt/ConsoleViewerGL.cpp +++ b/src/drivers/Qt/ConsoleViewerGL.cpp @@ -206,8 +206,6 @@ void ConsoleViewGL_t::setScaleXY( double xs, double ys ) if ( forceAspect ) { - xyRatio = xyRatio * aspectRatio; - if ( (xscale*xyRatio) < yscale ) { yscale = (xscale*xyRatio); @@ -340,15 +338,13 @@ void ConsoleViewGL_t::paintGL(void) if ( forceAspect ) { - xyRatio = xyRatio * aspectRatio; - if ( (xscaleTmp*xyRatio) < yscaleTmp ) { - yscaleTmp = (xscaleTmp*xyRatio); + yscaleTmp = xscaleTmp * xyRatio; } else { - xscaleTmp = (yscaleTmp/xyRatio); + xscaleTmp = yscaleTmp / xyRatio; } } @@ -368,8 +364,45 @@ void ConsoleViewGL_t::paintGL(void) yscaleTmp = yscale; } } + rw=(int)((r-l)*xscaleTmp); rh=(int)((b-t)*yscaleTmp); + + if ( forceAspect ) + { + int iw, ih, ax, ay; + + ax = (int)(aspectX+0.50); + ay = (int)(aspectY+0.50); + + iw = rw * ay; + ih = rh * ax; + + if ( iw > ih ) + { + rh = (rw * ay) / ax; + } + else + { + rw = (rh * ax) / ay; + } + + if ( rw > view_width ) + { + rw = view_width; + rh = (rw * ay) / ax; + } + + if ( rh > view_height ) + { + rh = view_height; + rw = (rh * ax) / ay; + } + } + + if ( rw > view_width ) rw = view_width; + if ( rh > view_height) rh = view_height; + sx=(view_width-rw)/2; sy=(view_height-rh)/2; diff --git a/src/drivers/Qt/ConsoleViewerSDL.cpp b/src/drivers/Qt/ConsoleViewerSDL.cpp index 7b86418a..5d0d9997 100644 --- a/src/drivers/Qt/ConsoleViewerSDL.cpp +++ b/src/drivers/Qt/ConsoleViewerSDL.cpp @@ -124,8 +124,6 @@ void ConsoleViewSDL_t::setScaleXY( double xs, double ys ) if ( forceAspect ) { - xyRatio = xyRatio * aspectRatio; - if ( (xscale*xyRatio) < yscale ) { yscale = (xscale*xyRatio); @@ -381,8 +379,6 @@ void ConsoleViewSDL_t::render(void) if ( forceAspect ) { - xyRatio = xyRatio * aspectRatio; - if ( (xscaleTmp*xyRatio) < yscaleTmp ) { yscaleTmp = (xscaleTmp*xyRatio); @@ -412,6 +408,42 @@ void ConsoleViewSDL_t::render(void) rw=(int)(nesWidth*xscaleTmp); rh=(int)(nesHeight*yscaleTmp); + + if ( forceAspect ) + { + int iw, ih, ax, ay; + + ax = (int)(aspectX+0.50); + ay = (int)(aspectY+0.50); + + iw = rw * ay; + ih = rh * ax; + + if ( iw > ih ) + { + rh = (rw * ay) / ax; + } + else + { + rw = (rh * ax) / ay; + } + + if ( rw > view_width ) + { + rw = view_width; + rh = (rw * ay) / ax; + } + + if ( rh > view_height ) + { + rh = view_height; + rw = (rh * ax) / ay; + } + } + + if ( rw > view_width ) rw = view_width; + if ( rh > view_height) rh = view_height; + sx=(view_width-rw)/2; sy=(view_height-rh)/2; diff --git a/src/drivers/Qt/ConsoleWindow.cpp b/src/drivers/Qt/ConsoleWindow.cpp index 6b55df99..8f33fafc 100644 --- a/src/drivers/Qt/ConsoleWindow.cpp +++ b/src/drivers/Qt/ConsoleWindow.cpp @@ -314,13 +314,29 @@ QSize consoleWin_t::calcRequiredSize(void) if ( forceAspect ) { - yscale = xscale * aspectRatio * (double)nes_shm->video.xyRatio; + yscale = xscale * (double)nes_shm->video.xyRatio; } rw=(int)((r-l)*xscale); rh=(int)((b-t)*yscale); //printf("view %i x %i \n", rw, rh ); + if ( forceAspect ) + { + double rr; + + rr = (double)rh / (double)rw; + + if ( rr > aspectRatio ) + { + rw = (int)( (((double)rh) / aspectRatio) + 0.50); + } + else + { + rh = (int)( (((double)rw) * aspectRatio) + 0.50); + } + } + out.setWidth( rw + dw ); out.setHeight( rh + dh );