ref: 221a00eba5f46470e92f9259fe1202851703ac8c
parent: 10d63425ca7ee205aa986a4aaf34affadaa0434c
author: Simon Howard <[email protected]>
date: Sat Sep 20 17:11:04 EDT 2008
Remove screens[] and all remaining use of it. Subversion-branch: /branches/raven-branch Subversion-revision: 1251
--- a/src/doom/r_draw.c
+++ b/src/doom/r_draw.c
@@ -77,9 +77,12 @@
//
byte translations[3][256];
-
+// Backing buffer containing the bezel drawn around the screen and
+// surrounding background.
+static byte *background_buffer = NULL;
+
//
// R_DrawColumn
// Source is the top of the column to scale.
@@ -815,20 +818,39 @@
char *name1 = DEH_String("FLOOR7_2");
// DOOM II border patch.
- char *name2 = DEH_String("GRNROCK");
+ char *name2 = DEH_String("GRNROCK");
- char* name;
-
- if (scaledviewwidth == 320)
+ char *name;
+
+ // If we are running full screen, there is no need to do any of this,
+ // and the background buffer can be freed if it was previously in use.
+
+ if (scaledviewwidth == SCREENWIDTH)
+ {
+ if (background_buffer != NULL)
+ {
+ Z_Free(background_buffer);
+ background_buffer = NULL;
+ }
+
return;
+ }
+
+ // Allocate the background buffer if necessary
- if ( gamemode == commercial)
+ if (background_buffer == NULL)
+ {
+ background_buffer = Z_Malloc(SCREENWIDTH * (SCREENHEIGHT - SBARHEIGHT),
+ PU_STATIC, NULL);
+ }
+
+ if (gamemode == commercial)
name = name2;
else
name = name1;
src = W_CacheLumpName(name, PU_CACHE);
- dest = screens[1];
+ dest = background_buffer;
for (y=0 ; y<SCREENHEIGHT-SBARHEIGHT ; y++)
{
@@ -847,7 +869,7 @@
// Draw screen and bezel; this is done to a separate screen buffer.
- V_UseBuffer(screens[1]);
+ V_UseBuffer(background_buffer);
patch = W_CacheLumpName(DEH_String("brdr_t"),PU_CACHE);
@@ -900,7 +922,11 @@
// is not optiomal, e.g. byte by byte on
// a 32bit CPU, as GNU GCC/Linux libc did
// at one point.
- memcpy(I_VideoBuffer + ofs, screens[1] + ofs, count);
+
+ if (background_buffer != NULL)
+ {
+ memcpy(I_VideoBuffer + ofs, background_buffer + ofs, count);
+ }
}
--- a/src/doom/st_lib.c
+++ b/src/doom/st_lib.c
@@ -123,7 +123,7 @@
if (n->y - ST_Y < 0)
I_Error("drawNum: n->y - ST_Y < 0");
- V_CopyRect(x, n->y - ST_Y, screens[BG], w*numdigits, h, x, n->y);
+ V_CopyRect(x, n->y - ST_Y, st_backing_screen, w*numdigits, h, x, n->y);
// if non-number, do not draw it
if (num == 1994)
@@ -233,7 +233,7 @@
if (y - ST_Y < 0)
I_Error("updateMultIcon: y - ST_Y < 0");
- V_CopyRect(x, y-ST_Y, screens[BG], w, h, x, y);
+ V_CopyRect(x, y-ST_Y, st_backing_screen, w, h, x, y);
}
V_DrawPatch(mi->x, mi->y, mi->p[*mi->inum]);
mi->oldinum = *mi->inum;
@@ -285,7 +285,7 @@
if (*bi->val)
V_DrawPatch(bi->x, bi->y, bi->p);
else
- V_CopyRect(x, y-ST_Y, screens[BG], w, h, x, y);
+ V_CopyRect(x, y-ST_Y, st_backing_screen, w, h, x, y);
bi->oldval = *bi->val;
}
--- a/src/doom/st_lib.h
+++ b/src/doom/st_lib.h
@@ -35,7 +35,7 @@
//
// Background and foreground screen numbers
//
-#define BG 4
+
#define FG 0
--- a/src/doom/st_stuff.c
+++ b/src/doom/st_stuff.c
@@ -269,6 +269,8 @@
#define ST_MAPTITLEY 0
#define ST_MAPHEIGHT 1
+// graphics are drawn to a backing screen and blitted to the real screen
+byte *st_backing_screen;
// main player in game
static player_t* plyr;
@@ -276,9 +278,6 @@
// ST_Start() has just been called
static boolean st_firsttime;
-// used to execute ST_Init() only once
-static int veryfirsttime = 1;
-
// lump number for PLAYPAL
static int lu_palette;
@@ -433,7 +432,7 @@
if (st_statusbaron)
{
- V_UseBuffer(screens[BG]);
+ V_UseBuffer(st_backing_screen);
V_DrawPatch(ST_X, 0, sbar);
@@ -442,7 +441,7 @@
V_RestoreBuffer();
- V_CopyRect(ST_X, 0, screens[BG], ST_WIDTH, ST_HEIGHT, ST_X, ST_Y);
+ V_CopyRect(ST_X, 0, st_backing_screen, ST_WIDTH, ST_HEIGHT, ST_X, ST_Y);
}
}
@@ -1407,7 +1406,7 @@
void ST_Init (void)
{
- veryfirsttime = 0;
ST_loadData();
- screens[4] = (byte *) Z_Malloc(ST_WIDTH*ST_HEIGHT, PU_STATIC, 0);
+ st_backing_screen = (byte *) Z_Malloc(ST_WIDTH * ST_HEIGHT, PU_STATIC, 0);
}
+
--- a/src/doom/st_stuff.h
+++ b/src/doom/st_stuff.h
@@ -82,6 +82,7 @@
boolean ST_Responder(event_t* ev);
+extern byte *st_backing_screen;
extern cheatseq_t cheat_mus;
extern cheatseq_t cheat_god;
extern cheatseq_t cheat_ammo;
--- a/src/doom/wi_stuff.c
+++ b/src/doom/wi_stuff.c
@@ -400,18 +400,17 @@
// Name graphics of each level (centered)
static patch_t** lnames;
+// Buffer storing the backdrop
+static patch_t *background;
+
//
// CODE
//
// slam background
-// UNUSED static unsigned char *background=0;
-
-
void WI_slamBackground(void)
{
- memcpy(I_VideoBuffer, screens[1], SCREENWIDTH * SCREENHEIGHT);
- V_MarkRect (0, 0, SCREENWIDTH, SCREENHEIGHT);
+ V_DrawPatch(0, 0, background);
}
// The ticker is used to detect keys
@@ -1551,22 +1550,10 @@
static void WI_loadUnloadData(load_callback_t callback)
{
- int i;
- int j;
- char name[9];
- anim_t* a;
+ int i, j;
+ char name[9];
+ anim_t *a;
- // UNUSED unsigned char *pic = screens[1];
- // if (gamemode == commercial)
- // {
- // darken the background image
- // while (pic != screens[1] + SCREENHEIGHT*SCREENWIDTH)
- // {
- // *pic = colormaps[256*25 + *pic];
- // pic++;
- // }
- //}
-
if (gamemode == commercial)
{
for (i=0 ; i<NUMCMAPS ; i++)
@@ -1692,6 +1679,24 @@
callback(name, &bp[i]);
}
+ // Background image
+
+ if (gamemode == commercial)
+ {
+ strcpy(name, DEH_String("INTERPIC"));
+ }
+ else if (gamemode == retail && wbs->epsd == 3)
+ {
+ strcpy(name, DEH_String("INTERPIC"));
+ }
+ else
+ {
+ sprintf(name, DEH_String("WIMAP%d"), wbs->epsd);
+ }
+
+ // Draw backdrop and save to a temporary buffer
+
+ callback(name, &background);
}
static void WI_loadCallback(char *name, patch_t **variable)
@@ -1701,9 +1706,6 @@
void WI_loadData(void)
{
- char bg_lumpname[9];
- patch_t *bg;
-
if (gamemode == commercial)
{
NUMCMAPS = 32;
@@ -1726,28 +1728,6 @@
// dead face
bstar = W_CacheLumpName(DEH_String("STFDEAD0"), PU_STATIC);
-
- // Background image
-
- if (gamemode == commercial)
- {
- strcpy(bg_lumpname, DEH_String("INTERPIC"));
- }
- else if (gamemode == retail && wbs->epsd == 3)
- {
- strcpy(bg_lumpname, DEH_String("INTERPIC"));
- }
- else
- {
- sprintf(bg_lumpname, DEH_String("WIMAP%d"), wbs->epsd);
- }
-
- // Draw backdrop and save to a temporary buffer
-
- V_UseBuffer(screens[1]);
- bg = W_CacheLumpName(bg_lumpname, PU_CACHE);
- V_DrawPatch(0, 0, bg);
- V_RestoreBuffer();
}
static void WI_unloadCallback(char *name, patch_t **variable)
--- a/src/v_video.c
+++ b/src/v_video.c
@@ -46,9 +46,6 @@
static byte *dest_screen = NULL;
-// Each screen is [SCREENWIDTH*SCREENHEIGHT];
-byte *screens[5];
-
int dirtybox[4];
// Now where did these came from?
@@ -355,17 +352,9 @@
//
void V_Init (void)
{
- int i;
- byte *base;
-
- // stick these in low dos memory on PCs
-
- base = Z_Malloc(SCREENWIDTH * SCREENHEIGHT * 3, PU_STATIC, NULL);
-
- for (i=0 ; i<4 ; i++)
- {
- screens[i + 1] = base + i*SCREENWIDTH*SCREENHEIGHT;
- }
+ // no-op!
+ // There used to be separate screens that could be drawn to; these are
+ // now handled in the upper layers.
}
// Set the buffer that the code draws to.
--- a/src/v_video.h
+++ b/src/v_video.h
@@ -42,11 +42,6 @@
#define CENTERY (SCREENHEIGHT/2)
-// Screen 0 is the screen updated by I_Update screen.
-// Screen 1 is an extra buffer.
-
-extern byte *screens[5];
-
extern int dirtybox[4];
extern const byte gammatable[5][256];