From 03359e37ac942bc5d4d0f0f5fb650e15ddeb3bb0 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 10 Mar 2006 01:49:25 +0000 Subject: Add fullscreen "letterbox" mode for people without a functioning 320x200 video mode. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 415 --- src/i_video.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 57 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/i_video.c b/src/i_video.c index f1f2c844..e3c879cc 100644 --- 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 #include @@ -196,6 +196,17 @@ rcsid[] = "$Id: i_video.c 407 2006-03-03 19:18:48Z fraggle $"; #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 initialised = false; 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 @@ static boolean MouseShouldBeGrabbed() // 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 @@ void I_GetEvent(void) SDL_Event sdlevent; event_t event; + // possibly not needed + + SDL_PumpEvents(); + // put event-grabbing stuff in here while (SDL_PollEvent(&sdlevent)) @@ -599,6 +614,20 @@ static void UpdateGrab(void) 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) { @@ -610,7 +639,7 @@ static void BlitArea(int x1, int y1, int x2, int y2) { 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; ypitch * 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; ypixels); + + 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 -- cgit v1.2.3