shithub: choc

Download patch

ref: bc95293e5f880bffd163504b425123213bd60e04
parent: 856eebe52624ba5d780436feb349ea5ff2ee46b4
author: Simon Howard <[email protected]>
date: Wed Jun 20 07:21:57 EDT 2007

Add x5 screen scale (thanks MikeRS!)

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 919

--- a/NEWS
+++ b/NEWS
@@ -30,7 +30,7 @@
        Doom .mus format to .mid a lot better.  As one example, tnt.wad
        Map02 is now a lot closer to how Vanilla says.  Also, the music 
        on the deca.wad titlescreen now plays!
-     * x3 and x4 display scale.
+     * x3, x4 and x5 display scale (thanks to MikeRS for x5 scale).
      * Fullscreen "letterbox" mode allows Chocolate Doom to run on machines
        where 1.6:1 aspect ratio modes are unavailable (320x200/640x400).
        The game runs in 320x240/640x480 instead, with black borders.
--- a/setup/display.c
+++ b/setup/display.c
@@ -47,6 +47,7 @@
     { "960x600",  "960x720",  3, NULL },
     { "640x400",  "640x480",  2, NULL },
     { "1280x800", "1280x960", 4, NULL },
+    { "1600x1000", "1600x1200", 5, NULL },
     { NULL,       NULL,       0, NULL },
 };
 
--- a/src/i_scale.c
+++ b/src/i_scale.c
@@ -190,6 +190,48 @@
     }
 }
 
+void I_Scale5x(int x1, int y1, int x2, int y2)
+{
+    byte *bufp, *screenp, *screenp2, *screenp3, *screenp4, *screenp5;
+    int x, y;
+    int multi_pitch;
+
+    multi_pitch = dest_pitch * 5;
+    bufp = src_buffer + y1 * SCREENWIDTH + x1;
+    screenp = (byte *) dest_buffer + (y1 * dest_pitch + x1) * 5;
+    screenp2 = screenp + dest_pitch;
+    screenp3 = screenp + dest_pitch * 2;
+    screenp4 = screenp + dest_pitch * 3;
+    screenp5 = screenp + dest_pitch * 4;
+
+    for (y=y1; y<y2; ++y)
+    {
+        byte *sp, *sp2, *sp3, *sp4, *sp5, *bp;
+        sp = screenp;
+        sp2 = screenp2;
+        sp3 = screenp3;
+        sp4 = screenp4;
+        sp5 = screenp5;
+        bp = bufp;
+
+        for (x=x1; x<x2; ++x)
+        {
+            *sp++ = *bp;  *sp++ = *bp;  *sp++ = *bp;  *sp++ = *bp;  *sp++ = *bp;
+            *sp2++ = *bp; *sp2++ = *bp; *sp2++ = *bp; *sp2++ = *bp; *sp2++ = *bp;
+            *sp3++ = *bp; *sp3++ = *bp; *sp3++ = *bp; *sp3++ = *bp; *sp3++ = *bp;
+            *sp4++ = *bp; *sp4++ = *bp; *sp4++ = *bp; *sp4++ = *bp; *sp4++ = *bp;
+            *sp5++ = *bp; *sp5++ = *bp; *sp5++ = *bp; *sp5++ = *bp; *sp5++ = *bp;
+            ++bp;
+        }
+        screenp += multi_pitch;
+        screenp2 += multi_pitch;
+        screenp3 += multi_pitch;
+        screenp4 += multi_pitch;
+        screenp5 += multi_pitch;
+        bufp += SCREENWIDTH;
+    }
+}
+
 // Search through the given palette, finding the nearest color that matches
 // the given color.
 
@@ -729,6 +771,70 @@
 
         // 100% line 4
         WriteLine4x(screenp, bufp);
+        screenp += dest_pitch; bufp += SCREENWIDTH;
+    }
+}
+
+static void WriteLine5x(byte *dest, byte *src)
+{
+    int x;
+
+    for (x=0; x<SCREENWIDTH; ++x)
+    {
+        dest[0] = *src;
+        dest[1] = *src;
+        dest[2] = *src;
+        dest[3] = *src;
+        dest[4] = *src;
+        dest += 5;
+        ++src;
+    }
+}
+
+void I_Stretch5x(int x1, int y1, int x2, int y2)
+{
+    byte *bufp, *screenp;
+    int y;
+
+    // Only works with full screen update
+
+    if (x1 != 0 || y1 != 0 || x2 != SCREENWIDTH || y2 != SCREENHEIGHT)
+    {
+        return;
+    }    
+
+    // Need to byte-copy from buffer into the screen buffer
+
+    bufp = src_buffer + y1 * SCREENWIDTH + x1;
+    screenp = (byte *) dest_buffer + y1 * dest_pitch + x1;
+
+    // For every 1 line of src_buffer, 6 lines are written to dest_buffer.
+    // (200 -> 1200)
+
+    for (y=0; y<SCREENHEIGHT; y += 1)
+    {
+        // 100% line 0
+        WriteLine5x(screenp, bufp);
+        screenp += dest_pitch;
+
+        // 100% line 0
+        WriteLine5x(screenp, bufp);
+        screenp += dest_pitch;
+
+        // 100% line 0
+        WriteLine5x(screenp, bufp);
+        screenp += dest_pitch;
+
+        // 100% line 0
+        WriteLine5x(screenp, bufp);
+        screenp += dest_pitch;
+
+        // 100% line 0
+        WriteLine5x(screenp, bufp);
+        screenp += dest_pitch;
+
+        // 100% line 0
+        WriteLine5x(screenp, bufp);
         screenp += dest_pitch; bufp += SCREENWIDTH;
     }
 }
--- a/src/i_scale.h
+++ b/src/i_scale.h
@@ -39,6 +39,7 @@
 void I_Scale2x(int x1, int y1, int x2, int y2);
 void I_Scale3x(int x1, int y1, int x2, int y2);
 void I_Scale4x(int x1, int y1, int x2, int y2);
+void I_Scale5x(int x1, int y1, int x2, int y2);
 
 // Aspect ratio correcting scale up functions
 
@@ -46,6 +47,7 @@
 void I_Stretch2x(int x1, int y1, int x2, int y2);
 void I_Stretch3x(int x1, int y1, int x2, int y2);
 void I_Stretch4x(int x1, int y1, int x2, int y2);
+void I_Stretch5x(int x1, int y1, int x2, int y2);
 
 #endif /* #ifndef __I_SCALE__ */
 
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -640,6 +640,10 @@
         { 
             scale_function = I_Stretch4x;
         }
+        else if (screenmultiply == 5)
+        {
+            scale_function = I_Stretch5x;
+        }
         else
         {
             I_Error("No aspect ratio stretching function for screenmultiply=%i",
@@ -663,6 +667,10 @@
         {
             scale_function = I_Scale4x;
         }
+        else if (screenmultiply == 5)
+        {
+            scale_function = I_Scale5x;
+        }
         else
         {
             I_Error("No scale function found!");
@@ -962,7 +970,7 @@
 
     nomouse = M_CheckParm("-nomouse") > 0;
 
-    // 2x, 3x, 4x scale mode
+    // 2x, 3x, 4x, 5x scale mode
  
     //!
     // @category video 
@@ -1008,10 +1016,21 @@
         screenmultiply = 4;
     }
 
+    //!
+    // @category video
+    //
+    // Double up the screen to 5x its size.
+    //
+
+    if (M_CheckParm("-5"))
+    {
+        screenmultiply = 5;
+    }
+
     if (screenmultiply < 1)
         screenmultiply = 1;
-    if (screenmultiply > 4)
-        screenmultiply = 4;
+    if (screenmultiply > 5)
+        screenmultiply = 5;
 }
 
 static void AutoAdjustSettings(void)