@@ -289,7 +289,7 @@ wmsx.CanvasDisplay = function(room, mainElement) {
289289
290290 // console.error("Display Metrics Render:", renderWidth, renderHeight, internal ? "int" : "ext");
291291
292- var newTargetWidth , newTargetHeight , newScrTargetWidth ;
292+ var newTargetWidth , newTargetHeight , newScrTargetWidth , newAspectXCorrection ;
293293
294294 switch ( renderWidth ) {
295295 case 192 : case 384 : newTargetWidth = 384 ; break ;
@@ -300,6 +300,7 @@ wmsx.CanvasDisplay = function(room, mainElement) {
300300 default : newTargetWidth = 512 + 32 ;
301301 }
302302 newScrTargetWidth = newTargetWidth === 640 ? 640 : 512 + 32 ; // For the actual screen, use 512 for all modes, except 640
303+ newAspectXCorrection = newScrTargetWidth === 640 ? aspectXCorrectionVal : 1 ;
303304
304305 switch ( renderHeight ) {
305306 case 192 + 16 : newTargetHeight = 384 + 32 ; break ;
@@ -311,19 +312,20 @@ wmsx.CanvasDisplay = function(room, mainElement) {
311312
312313 // Main or Aux screen?
313314 if ( ( videoOutputMode === 0 || videoOutputMode === 4 ) === internal )
314- updateDisplayMetrics ( renderWidth , renderHeight , newTargetWidth , newScrTargetWidth , newTargetHeight ) ;
315+ updateDisplayMetrics ( renderWidth , renderHeight , newTargetWidth , newTargetHeight , newScrTargetWidth , newAspectXCorrection ) ;
315316 else
316- auxUpdateDisplayMetrics ( renderWidth , renderHeight , newTargetWidth , newScrTargetWidth , newTargetHeight ) ;
317+ auxUpdateDisplayMetrics ( renderWidth , renderHeight , newTargetWidth , newTargetHeight , newScrTargetWidth , newAspectXCorrection ) ;
317318 } ;
318319
319- function updateDisplayMetrics ( renderWidth , renderHeight , newTargetWidth , newScrTargetWidth , newTargetHeight ) {
320+ function updateDisplayMetrics ( renderWidth , renderHeight , newTargetWidth , newTargetHeight , newScrTargetWidth , newAspectXCorrection ) {
320321 updatePixelMetrics ( renderWidth , renderHeight , newScrTargetWidth , newTargetHeight ) ;
321322
322- if ( targetWidth === newTargetWidth && scrTargetWidth === newScrTargetWidth && targetHeight === newTargetHeight ) return ;
323+ if ( targetWidth === newTargetWidth && targetHeight === newTargetHeight && scrTargetWidth === newScrTargetWidth && aspectXCorrection === newAspectXCorrection ) return ;
323324
324325 targetWidth = newTargetWidth ;
325- scrTargetWidth = newScrTargetWidth ;
326326 targetHeight = newTargetHeight ;
327+ scrTargetWidth = newScrTargetWidth ;
328+ aspectXCorrection = newAspectXCorrection ;
327329
328330 updateCanvasContentSize ( ) ;
329331 if ( isFullscreen ) requestReadjust ( true ) ;
@@ -345,12 +347,13 @@ wmsx.CanvasDisplay = function(room, mainElement) {
345347 refreshPixelMetrics ( ) ;
346348 }
347349
348- function auxUpdateDisplayMetrics ( renderWidth , renderHeight , newTargetWidth , newScrTargetWidth , newTargetHeight ) {
349- if ( auxTargetWidth === newTargetWidth && auxScrTargetWidth === newScrTargetWidth && auxTargetHeight === newTargetHeight ) return ;
350+ function auxUpdateDisplayMetrics ( renderWidth , renderHeight , newTargetWidth , newTargetHeight , newScrTargetWidth , newAspectXCorrection ) {
351+ if ( auxTargetWidth === newTargetWidth && auxTargetHeight === newTargetHeight && auxScrTargetWidth === newScrTargetWidth && auxAspectXCorrection === newAspectXCorrection ) return ;
350352
351353 auxTargetWidth = newTargetWidth ;
352- auxScrTargetWidth = newScrTargetWidth ;
353354 auxTargetHeight = newTargetHeight ;
355+ auxScrTargetWidth = newScrTargetWidth ;
356+ auxAspectXCorrection = newAspectXCorrection ;
354357
355358 if ( ! auxWindow ) return false ; // auxWindow not ready
356359
@@ -374,7 +377,7 @@ wmsx.CanvasDisplay = function(room, mainElement) {
374377 }
375378
376379 function refreshPixelMetrics ( ) {
377- if ( controllersHub ) controllersHub . setScreenPixelScale ( pixelWidth * scaleY * aspectX , pixelHeight * scaleY ) ;
380+ if ( controllersHub ) controllersHub . setScreenPixelScale ( pixelWidth * scaleY * aspectX * aspectXCorrection , pixelHeight * scaleY ) ;
378381 }
379382
380383 this . getMonitor = function ( ) {
@@ -995,7 +998,7 @@ wmsx.CanvasDisplay = function(room, mainElement) {
995998 }
996999
9971000 function updateScale ( ) {
998- var width = Math . round ( scrTargetWidth * scaleY * aspectX ) ;
1001+ var width = Math . round ( scrTargetWidth * scaleY * aspectX * aspectXCorrection ) ;
9991002 var height = Math . round ( targetHeight * scaleY ) ;
10001003 canvas . style . width = "" + width + "px" ;
10011004 canvas . style . height = "" + height + "px" ;
@@ -1005,7 +1008,7 @@ wmsx.CanvasDisplay = function(room, mainElement) {
10051008 }
10061009
10071010 function auxUpdateScale ( changeWindow ) {
1008- var newWidth = Math . round ( auxScrTargetWidth * auxScaleY * auxAspectX ) ;
1011+ var newWidth = Math . round ( auxScrTargetWidth * auxScaleY * auxAspectX * auxAspectXCorrection ) ;
10091012 var newHeight = Math . ceil ( auxTargetHeight * auxScaleY ) ;
10101013 auxCanvas . style . width = "" + newWidth + "px" ;
10111014 auxCanvas . style . height = "" + newHeight + "px" ;
@@ -2173,14 +2176,14 @@ wmsx.CanvasDisplay = function(room, mainElement) {
21732176
21742177 function displayOptimalScaleY ( maxWidth , maxHeight ) {
21752178 var scY = maxHeight / targetHeight ;
2176- if ( scrTargetWidth * aspectX * scY > maxWidth )
2179+ if ( scrTargetWidth * aspectX * aspectXCorrection * scY > maxWidth )
21772180 scY = maxWidth / ( scrTargetWidth * aspectX ) ;
21782181 return scY ;
21792182 }
21802183
21812184 function auxDisplayOptimalScaleY ( maxWidth , maxHeight ) {
21822185 var scY = maxHeight / auxTargetHeight ;
2183- if ( auxScrTargetWidth * auxAspectX * scY > maxWidth )
2186+ if ( auxScrTargetWidth * auxAspectX * auxAspectXCorrection * scY > maxWidth )
21842187 scY = maxWidth / ( auxScrTargetWidth * auxAspectX ) ;
21852188 return scY ;
21862189 }
@@ -2377,7 +2380,7 @@ wmsx.CanvasDisplay = function(room, mainElement) {
23772380 var isLoading = false ;
23782381 var ledsStatePending , ledsInfoPending ;
23792382
2380- var aspectX = WMSX . SCREEN_DEFAULT_ASPECT ;
2383+ var aspectX = WMSX . SCREEN_DEFAULT_ASPECT , aspectXCorrection = 1 , aspectXCorrectionVal = 1 / aspectX ;
23812384 var scaleY = 1.0 ;
23822385 var scaleYBeforeUserFullscreen = 0 ;
23832386 var pixelWidth = 1 , pixelHeight = 1 ;
@@ -2396,7 +2399,7 @@ wmsx.CanvasDisplay = function(room, mainElement) {
23962399 var auxWindow , auxWindowAddWidth , auxWindowAddHeight ;
23972400 var auxCanvas , auxCanvasContext ;
23982401 var auxReadjustScreenSize = { w : 0 , wk : 0 , h : 0 , pw : 0 } ;
2399- var auxAspectX = WMSX . SCREEN_DEFAULT_ASPECT ;
2402+ var auxAspectX = WMSX . SCREEN_DEFAULT_ASPECT , auxAspectXCorrection = 1 ;
24002403 var auxScaleY = 1.1 ;
24012404 var auxTargetWidth = targetWidth , auxScrTargetWidth = scrTargetWidth , auxTargetHeight = targetHeight ;
24022405 var auxLogo , auxFsElementCenter ;
0 commit comments