diff options
author | Simon Howard | 2006-03-10 01:49:25 +0000 |
---|---|---|
committer | Simon Howard | 2006-03-10 01:49:25 +0000 |
commit | 03359e37ac942bc5d4d0f0f5fb650e15ddeb3bb0 (patch) | |
tree | 123d6bbde13dcb05d2a7fc69b88f11804ab6febc | |
parent | d0e68cd18f5a0fb1a821e11df1d489bf3e87b7f3 (diff) | |
download | chocolate-doom-03359e37ac942bc5d4d0f0f5fb650e15ddeb3bb0.tar.gz chocolate-doom-03359e37ac942bc5d4d0f0f5fb650e15ddeb3bb0.tar.bz2 chocolate-doom-03359e37ac942bc5d4d0f0f5fb650e15ddeb3bb0.zip |
Add fullscreen "letterbox" mode for people without a functioning 320x200
video mode.
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 415
-rw-r--r-- | src/i_video.c | 67 |
1 files changed, 57 insertions, 10 deletions
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 <SDL.h> #include <ctype.h> @@ -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; y<y2; ++y) { @@ -635,7 +664,9 @@ static void BlitArea(int x1, int y1, int x2, int y2) { 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 @@ void I_FinishUpdate (void) if (!initialised) return; + + if (noblit) + return; UpdateGrab(); @@ -871,14 +905,14 @@ void I_InitGraphics(void) 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,7 +934,11 @@ void I_InitGraphics(void) 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); @@ -951,9 +989,18 @@ void I_InitGraphics(void) // 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 |