From 221a00eba5f46470e92f9259fe1202851703ac8c Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 20 Sep 2008 21:11:04 +0000 Subject: Remove screens[] and all remaining use of it. Subversion-branch: /branches/raven-branch Subversion-revision: 1251 --- src/doom/r_draw.c | 44 ++++++++++++++++++++++++++------- src/doom/st_lib.c | 6 ++--- src/doom/st_lib.h | 2 +- src/doom/st_stuff.c | 13 +++++----- src/doom/st_stuff.h | 1 + src/doom/wi_stuff.c | 70 +++++++++++++++++++---------------------------------- src/v_video.c | 17 +++---------- src/v_video.h | 5 ---- 8 files changed, 74 insertions(+), 84 deletions(-) diff --git a/src/doom/r_draw.c b/src/doom/r_draw.c index d75aec3b..1b6420d9 100644 --- a/src/doom/r_draw.c +++ b/src/doom/r_draw.c @@ -77,7 +77,10 @@ int columnofs[MAXWIDTH]; // byte translations[3][256]; - +// Backing buffer containing the bezel drawn around the screen and +// surrounding background. + +static byte *background_buffer = NULL; // @@ -815,20 +818,39 @@ void R_FillBackScreen (void) char *name1 = DEH_String("FLOOR7_2"); // DOOM II border patch. - char *name2 = DEH_String("GRNROCK"); + char *name2 = DEH_String("GRNROCK"); + + 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; + } - char* name; - - if (scaledviewwidth == 320) 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 ; yy - 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 @@ STlib_updateMultIcon 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 @@ STlib_updateBinIcon 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; } diff --git a/src/doom/st_lib.h b/src/doom/st_lib.h index bf9a6f87..9345272c 100644 --- 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 diff --git a/src/doom/st_stuff.c b/src/doom/st_stuff.c index 97968f2a..e6ef0828 100644 --- 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 @@ static player_t* plyr; // 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 @@ void ST_refreshBackground(void) if (st_statusbaron) { - V_UseBuffer(screens[BG]); + V_UseBuffer(st_backing_screen); V_DrawPatch(ST_X, 0, sbar); @@ -442,7 +441,7 @@ void ST_refreshBackground(void) 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_Stop (void) 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); } + diff --git a/src/doom/st_stuff.h b/src/doom/st_stuff.h index c6b56fd6..31bd9764 100644 --- a/src/doom/st_stuff.h +++ b/src/doom/st_stuff.h @@ -82,6 +82,7 @@ typedef enum 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; diff --git a/src/doom/wi_stuff.c b/src/doom/wi_stuff.c index 85243d84..7a0edc9d 100644 --- a/src/doom/wi_stuff.c +++ b/src/doom/wi_stuff.c @@ -400,18 +400,17 @@ static patch_t* bp[MAXPLAYERS]; // 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,21 +1550,9 @@ typedef void (*load_callback_t)(char *lumpname, patch_t **variable); static void WI_loadUnloadData(load_callback_t callback) { - int i; - int 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++; - // } - //} + int i, j; + char name[9]; + anim_t *a; if (gamemode == commercial) { @@ -1692,6 +1679,24 @@ static void WI_loadUnloadData(load_callback_t callback) 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 @@ static void WI_loadCallback(char *name, patch_t **variable) void WI_loadData(void) { - char bg_lumpname[9]; - patch_t *bg; - if (gamemode == commercial) { NUMCMAPS = 32; @@ -1726,28 +1728,6 @@ void WI_loadData(void) // 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) diff --git a/src/v_video.c b/src/v_video.c index 5bb9e077..e2fc7eea 100644 --- 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_DrawBlock(int x, int y, int width, int height, byte *src) // 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. diff --git a/src/v_video.h b/src/v_video.h index ba1aab36..d304f8f8 100644 --- 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]; -- cgit v1.2.3