summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/doom/d_main.c1
-rw-r--r--src/doom/st_lib.c6
-rw-r--r--src/doom/st_stuff.c2
-rw-r--r--src/i_video.c34
-rw-r--r--src/i_video.h1
-rw-r--r--src/v_video.c110
-rw-r--r--src/v_video.h16
7 files changed, 67 insertions, 103 deletions
diff --git a/src/doom/d_main.c b/src/doom/d_main.c
index ef5c4317..6aaa5d9c 100644
--- a/src/doom/d_main.c
+++ b/src/doom/d_main.c
@@ -416,6 +416,7 @@ void D_DoomLoop (void)
I_SetGrabMouseCallback(D_GrabMouseCallback);
I_SetWindowTitle(gamedescription);
+ V_RestoreBuffer();
R_ExecuteSetViewSize();
D_StartGameLoop();
diff --git a/src/doom/st_lib.c b/src/doom/st_lib.c
index 11299a91..5c9a9d0c 100644
--- a/src/doom/st_lib.c
+++ b/src/doom/st_lib.c
@@ -123,7 +123,7 @@ STlib_drawNum
if (n->y - ST_Y < 0)
I_Error("drawNum: n->y - ST_Y < 0");
- V_CopyRect(x, n->y - ST_Y, BG, w*numdigits, h, x, n->y, FG);
+ V_CopyRect(x, n->y - ST_Y, screens[BG], 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, BG, w, h, x, y, FG);
+ V_CopyRect(x, y-ST_Y, screens[BG], w, h, x, y);
}
V_DrawPatch(mi->x, mi->y, FG, mi->p[*mi->inum]);
mi->oldinum = *mi->inum;
@@ -285,7 +285,7 @@ STlib_updateBinIcon
if (*bi->val)
V_DrawPatch(bi->x, bi->y, FG, bi->p);
else
- V_CopyRect(x, y-ST_Y, BG, w, h, x, y, FG);
+ V_CopyRect(x, y-ST_Y, screens[BG], w, h, x, y);
bi->oldval = *bi->val;
}
diff --git a/src/doom/st_stuff.c b/src/doom/st_stuff.c
index 22d98685..21e7e206 100644
--- a/src/doom/st_stuff.c
+++ b/src/doom/st_stuff.c
@@ -438,7 +438,7 @@ void ST_refreshBackground(void)
if (netgame)
V_DrawPatch(ST_FX, 0, BG, faceback);
- V_CopyRect(ST_X, 0, BG, ST_WIDTH, ST_HEIGHT, ST_X, ST_Y, FG);
+ V_CopyRect(ST_X, 0, screens[BG], ST_WIDTH, ST_HEIGHT, ST_X, ST_Y);
}
}
diff --git a/src/i_video.c b/src/i_video.c
index cc8cad6a..5adc6b40 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -101,7 +101,7 @@ static boolean initialised = false;
static boolean nomouse = false;
int usemouse = 1;
-// if true, screens[0] is screen->pixel
+// if true, I_VideoBuffer is screen->pixels
static boolean native_surface;
@@ -132,6 +132,10 @@ static int startup_delay = 1000;
static int grabmouse = true;
+// The screen buffer; this is modified to draw things to the screen
+
+byte *I_VideoBuffer = NULL;
+
// If true, game is running as a screensaver
boolean screensaver_mode = false;
@@ -304,9 +308,9 @@ static void LoadDiskImage(void)
for (y=0; y<disk_image_h; ++y)
{
memcpy(disk_image + disk_image_w * y,
- screens[0] + SCREENWIDTH * y,
+ I_VideoBuffer + SCREENWIDTH * y,
disk_image_w);
- memset(screens[0] + SCREENWIDTH * y, 0, disk_image_w);
+ memset(I_VideoBuffer + SCREENWIDTH * y, 0, disk_image_w);
}
W_ReleaseLumpName(disk_name);
@@ -689,7 +693,7 @@ static boolean BlitArea(int x1, int y1, int x2, int y2)
if (SDL_LockSurface(screen) >= 0)
{
- I_InitScale(screens[0],
+ I_InitScale(I_VideoBuffer,
(byte *) screen->pixels + (y_offset * screen->pitch)
+ x_offset,
screen->pitch);
@@ -738,7 +742,7 @@ void I_BeginRead(void)
for (y=0; y<disk_image_h; ++y)
{
byte *screenloc =
- screens[0]
+ I_VideoBuffer
+ (SCREENHEIGHT - 1 - disk_image_h + y) * SCREENWIDTH
+ (SCREENWIDTH - 1 - disk_image_w);
@@ -764,7 +768,7 @@ void I_EndRead(void)
for (y=0; y<disk_image_h; ++y)
{
byte *screenloc =
- screens[0]
+ I_VideoBuffer
+ (SCREENHEIGHT - 1 - disk_image_h + y) * SCREENWIDTH
+ (SCREENWIDTH - 1 - disk_image_w);
@@ -810,9 +814,9 @@ void I_FinishUpdate (void)
if (tics > 20) tics = 20;
for (i=0 ; i<tics*2 ; i+=4)
- screens[0][ (SCREENHEIGHT-1)*SCREENWIDTH + i] = 0xff;
+ I_VideoBuffer[ (SCREENHEIGHT-1)*SCREENWIDTH + i] = 0xff;
for ( ; i<20*4 ; i+=4)
- screens[0][ (SCREENHEIGHT-1)*SCREENWIDTH + i] = 0x0;
+ I_VideoBuffer[ (SCREENHEIGHT-1)*SCREENWIDTH + i] = 0x0;
}
// draw to screen
@@ -839,7 +843,7 @@ void I_FinishUpdate (void)
//
void I_ReadScreen (byte* scr)
{
- memcpy (scr, screens[0], SCREENWIDTH*SCREENHEIGHT);
+ memcpy(scr, I_VideoBuffer, SCREENWIDTH*SCREENHEIGHT);
}
@@ -1603,23 +1607,25 @@ void I_InitGraphics(void)
if (native_surface)
{
- screens[0] = (unsigned char *) screen->pixels;
+ I_VideoBuffer = (unsigned char *) screen->pixels;
- screens[0] += (screen->h - SCREENHEIGHT) / 2;
+ I_VideoBuffer += (screen->h - SCREENHEIGHT) / 2;
}
else
{
- screens[0] = (unsigned char *) Z_Malloc (SCREENWIDTH * SCREENHEIGHT,
- PU_STATIC, NULL);
+ I_VideoBuffer = (unsigned char *) Z_Malloc (SCREENWIDTH * SCREENHEIGHT,
+ PU_STATIC, NULL);
}
+ V_RestoreBuffer();
+
// "Loading from disk" icon
LoadDiskImage();
// Clear the screen to black.
- memset(screens[0], 0, SCREENWIDTH * SCREENHEIGHT);
+ memset(I_VideoBuffer, 0, SCREENWIDTH * SCREENHEIGHT);
// We need SDL to give us translated versions of keys as well
diff --git a/src/i_video.h b/src/i_video.h
index 60cb9d85..7e9698fe 100644
--- a/src/i_video.h
+++ b/src/i_video.h
@@ -109,6 +109,7 @@ extern int mouse_threshold;
extern int vanilla_keyboard_mapping;
extern boolean screensaver_mode;
extern int usegamma;
+extern byte *I_VideoBuffer;
#endif
diff --git a/src/v_video.c b/src/v_video.c
index a5c6b1b3..e5075c87 100644
--- a/src/v_video.c
+++ b/src/v_video.c
@@ -146,51 +146,44 @@ V_MarkRect
int height )
{
M_AddToBox (dirtybox, x, y);
- M_AddToBox (dirtybox, x+width-1, y+height-1);
+ M_AddToBox (dirtybox, x + width-1, y + height-1);
}
//
// V_CopyRect
//
-void
-V_CopyRect
-( int srcx,
- int srcy,
- int srcscrn,
- int width,
- int height,
- int destx,
- int desty,
- int destscrn )
+void V_CopyRect(int srcx, int srcy, byte *source,
+ int width, int height,
+ int destx, int desty)
{
- byte* src;
- byte* dest;
-
+ byte *src;
+ byte *dest;
+
#ifdef RANGECHECK
- if (srcx<0
- ||srcx+width >SCREENWIDTH
- || srcy<0
- || srcy+height>SCREENHEIGHT
- ||destx<0||destx+width >SCREENWIDTH
- || desty<0
- || desty+height>SCREENHEIGHT
- || (unsigned)srcscrn>4
- || (unsigned)destscrn>4)
+ if (srcx < 0
+ || srcx + width > SCREENWIDTH
+ || srcy < 0
+ || srcy + height > SCREENHEIGHT
+ || destx < 0
+ || destx + width > SCREENWIDTH
+ || desty < 0
+ || desty + height > SCREENHEIGHT)
{
- I_Error ("Bad V_CopyRect");
+ I_Error ("Bad V_CopyRect");
}
#endif
- V_MarkRect (destx, desty, width, height);
-
- src = screens[srcscrn]+SCREENWIDTH*srcy+srcx;
- dest = screens[destscrn]+SCREENWIDTH*desty+destx;
+
+ V_MarkRect(destx, desty, width, height);
+
+ src = source + SCREENWIDTH * srcy + srcx;
+ dest = I_VideoBuffer + SCREENWIDTH * desty + destx;
for ( ; height>0 ; height--)
{
- memcpy (dest, src, width);
- src += SCREENWIDTH;
- dest += SCREENWIDTH;
+ memcpy(dest, src, width);
+ src += SCREENWIDTH;
+ dest += SCREENWIDTH;
}
}
@@ -431,64 +424,31 @@ V_DrawBlock
}
-
-//
-// V_GetBlock
-// Gets a linear block of pixels from the view buffer.
-//
-void
-V_GetBlock
-( int x,
- int y,
- int scrn,
- int width,
- int height,
- byte* dest )
-{
- byte* src;
-
-#ifdef RANGECHECK
- if (x<0
- ||x+width >SCREENWIDTH
- || y<0
- || y+height>SCREENHEIGHT
- || (unsigned)scrn>4 )
- {
- I_Error ("Bad V_DrawBlock");
- }
-#endif
-
- src = screens[scrn] + y*SCREENWIDTH+x;
-
- while (height--)
- {
- memcpy (dest, src, width);
- src += SCREENWIDTH;
- dest += width;
- }
-}
-
-
-
-
//
// V_Init
//
void V_Init (void)
{
- int i;
- byte* base;
+ int i;
+ byte *base;
// stick these in low dos memory on PCs
- base = Z_Malloc(SCREENWIDTH * SCREENHEIGHT * 4, PU_STATIC, NULL);
+ base = Z_Malloc(SCREENWIDTH * SCREENHEIGHT * 3, PU_STATIC, NULL);
for (i=0 ; i<4 ; i++)
{
- screens[i] = base + i*SCREENWIDTH*SCREENHEIGHT;
+ screens[i + 1] = base + i*SCREENWIDTH*SCREENHEIGHT;
}
}
+// Restore screen buffer to the i_video screen buffer.
+
+void V_RestoreBuffer(void)
+{
+ screens[0] = I_VideoBuffer;
+}
+
//
// SCREEN SHOTS
//
diff --git a/src/v_video.h b/src/v_video.h
index a993fd1d..5312619a 100644
--- a/src/v_video.h
+++ b/src/v_video.h
@@ -54,17 +54,11 @@ extern const byte gammatable[5][256];
// Allocates buffer screens, call before R_Init.
void V_Init (void);
+// Draw a block from the specified source screen to the screen.
-void
-V_CopyRect
-( int srcx,
- int srcy,
- int srcscrn,
- int width,
- int height,
- int destx,
- int desty,
- int destscrn );
+void V_CopyRect(int srcx, int srcy, byte *source,
+ int width, int height,
+ int destx, int desty);
void
V_DrawPatch
@@ -111,4 +105,6 @@ V_MarkRect
void V_ScreenShot(void);
+void V_RestoreBuffer(void);
+
#endif