]> git.sesse.net Git - pistorm/commitdiff
Fix scaling/centering for RTG modes
authorbeeanyew <beeanyew@gmail.com>
Tue, 11 May 2021 19:12:17 +0000 (21:12 +0200)
committerbeeanyew <beeanyew@gmail.com>
Tue, 11 May 2021 19:12:17 +0000 (21:12 +0200)
platforms/amiga/rtg/rtg-output-raylib.c

index 83a2fad4b5e310b374880927d9c06c821e05f90c..672eab730b9ba22dd7098f92c5c2283dc4ee3c9c 100644 (file)
@@ -162,10 +162,6 @@ reinit_raylib:;
     dstscale.x = dstscale.y = 0;
     dstscale.width = width;
     dstscale.height = height;
-    scale_x = 1.0f;
-    scale_y = 1.0f;
-    origin.x = 0.0f;
-    origin.y = 0.0f;
 
     if (dstscale.height * 2 <= GetScreenHeight()) {
         if (width == 320) {
@@ -182,10 +178,23 @@ reinit_raylib:;
                 dstscale.width += width;
             }
         }
-        scale_x = dstscale.width / (float)width;
-        scale_y = dstscale.height / (float)height;
+    } else if (dstscale.width > GetScreenWidth() || dstscale.height > GetScreenHeight()) {
+        if (dstscale.width > GetScreenWidth()) {
+            dstscale.height = dstscale.height * ((float)GetScreenWidth() / (float)width);
+            dstscale.width = GetScreenWidth();
+        }
+        if (dstscale.height > GetScreenHeight()) {
+            dstscale.width = dstscale.width * ((float)GetScreenHeight() / (float)height);
+            dstscale.height = GetScreenHeight();
+        }
     }
 
+    scale_x = dstscale.width / (float)width;
+    scale_y = dstscale.height / (float)height;
+
+    origin.x = (dstscale.width - GetScreenWidth()) * 0.5;
+    origin.y = (dstscale.height - GetScreenHeight()) * 0.5;
+
     while (1) {
         if (rtg_on) {
             BeginDrawing();