shithub: choc

Download patch

ref: 03359e37ac942bc5d4d0f0f5fb650e15ddeb3bb0
parent: d0e68cd18f5a0fb1a821e11df1d489bf3e87b7f3
author: Simon Howard <[email protected]>
date: Thu Mar 9 20:49:25 EST 2006

Add fullscreen "letterbox" mode for people without a functioning 320x200
video mode.

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

--- a/src/i_video.c
+++ b/src/i_video.c
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: i_video.c 407 2006-03-03 19:18:48Z fraggle $
+// $Id: i_video.c 415 2006-03-10 01:49:25Z fraggle $
 //
 // Copyright(C) 1993-1996 Id Software, Inc.
 // Copyright(C) 2005 Simon Howard
@@ -175,7 +175,7 @@
 //-----------------------------------------------------------------------------
 
 static const char
-rcsid[] = "$Id: i_video.c 407 2006-03-03 19:18:48Z fraggle $";
+rcsid[] = "$Id: i_video.c 415 2006-03-10 01:49:25Z fraggle $";
 
 #include <SDL.h>
 #include <ctype.h>
@@ -196,6 +196,17 @@
 #include "w_wad.h"
 #include "z_zone.h"
 
+// Alternate screenheight for letterbox mode
+
+#define LETTERBOX_SCREENHEIGHT 240
+
+enum
+{
+    FULLSCREEN_OFF,
+    FULLSCREEN_ON,
+    FULLSCREEN_LETTERBOX,
+};
+
 extern void M_QuitDOOM();
 
 static SDL_Surface *screen;
@@ -215,7 +226,7 @@
 static boolean native_surface;
 
 // Run in full screen mode?  (int type for config code)
-int fullscreen = true;
+int fullscreen = FULLSCREEN_ON;
 
 // Grab the mouse? (int type for config code)
 int grabmouse = true;
@@ -257,7 +268,7 @@
     // always grab the mouse when full screen (dont want to 
     // see the mouse pointer)
 
-    if (fullscreen)
+    if (fullscreen != FULLSCREEN_OFF)
         return true;
 
     // if we specify not to grab the mouse, never grab
@@ -462,6 +473,10 @@
     SDL_Event sdlevent;
     event_t event;
 
+    // possibly not needed
+    
+    SDL_PumpEvents();
+
     // put event-grabbing stuff in here
     
     while (SDL_PollEvent(&sdlevent))
@@ -599,7 +614,21 @@
 static void BlitArea(int x1, int y1, int x2, int y2)
 {
     int w = x2 - x1;
+    int y_offset;
 
+    // Y offset when running in letterbox mode
+
+    if (fullscreen == FULLSCREEN_LETTERBOX)
+    {
+        y_offset = (LETTERBOX_SCREENHEIGHT - SCREENHEIGHT) / 2;
+    }
+    else
+    {
+        y_offset = 0;
+    }
+    
+    // Need to byte-copy from buffer into the screen buffer
+
     if (screenmultiply == 1 && !native_surface)
     {
         byte *bufp, *screenp;
@@ -610,7 +639,7 @@
         {
             pitch = screen->pitch;
             bufp = screens[0] + y1 * SCREENWIDTH + x1;
-            screenp = (byte *) screen->pixels + y1 * pitch + x1;
+            screenp = (byte *) screen->pixels + (y1 + y_offset) * pitch + x1;
     
             for (y=y1; y<y2; ++y)
             {
@@ -635,7 +664,9 @@
         {
             pitch = screen->pitch * 2;
             bufp = screens[0] + y1 * SCREENWIDTH + x1;
-            screenp = (byte *) screen->pixels + (y1 * pitch) +  (x1 * 2);
+            screenp = (byte *) screen->pixels 
+                    + (y1 + y_offset) * pitch 
+                    + x1 * 2;
             screenp2 = screenp + screen->pitch;
     
             for (y=y1; y<y2; ++y)
@@ -738,6 +769,9 @@
 
     if (!initialised)
         return;
+
+    if (noblit)
+        return;
     
     UpdateGrab();
 
@@ -871,14 +905,14 @@
 
     if (M_CheckParm("-window") || M_CheckParm("-nofullscreen"))
     {
-        fullscreen = false;
+        fullscreen = FULLSCREEN_OFF;
     }
     else if (M_CheckParm("-fullscreen"))
     {
-        fullscreen = true;
+        fullscreen = FULLSCREEN_ON;
     }
 
-    if (fullscreen)
+    if (fullscreen != FULLSCREEN_OFF)
     {
         flags |= SDL_FULLSCREEN;
     }
@@ -900,8 +934,12 @@
         screenmultiply = 2;
 
     windowwidth = SCREENWIDTH * screenmultiply;
-    windowheight = SCREENHEIGHT * screenmultiply;
 
+    if (fullscreen == FULLSCREEN_LETTERBOX)
+        windowheight = LETTERBOX_SCREENHEIGHT * screenmultiply;
+    else
+        windowheight = SCREENHEIGHT * screenmultiply;
+
     screen = SDL_SetVideoMode(windowwidth, windowheight, 8, flags);
 
     if (screen == NULL)
@@ -951,9 +989,18 @@
     // screen when we do an update
 
     if (native_surface)
+    {
 	screens[0] = (unsigned char *) (screen->pixels);
+
+        if (fullscreen == FULLSCREEN_LETTERBOX)
+        {
+            screens[0] += ((LETTERBOX_SCREENHEIGHT - SCREENHEIGHT) * screen->pitch) / 2;
+        }
+    }
     else
+    {
 	screens[0] = (unsigned char *) Z_Malloc (SCREENWIDTH * SCREENHEIGHT, PU_STATIC, NULL);
+    }
 
     // Loading from disk icon