diff --git a/src/f_wipe.c b/src/f_wipe.c index 8cdc012a..025d047d 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -55,7 +55,7 @@ static void wipe_shittyColMajorXform(byte *array, int width, int height) static int wipe_initColorXForm(int width, int height, int ticks) { - memcpy(wipe_scr, wipe_scr_start, width*height); + V_PutBlock(0, 0, width, height, wipe_scr_start); return 0; } @@ -94,7 +94,7 @@ static int wipe_initMelt(int width, int height, int ticks) col_y = Z_Malloc(num_columns * sizeof(*col_y), PU_STATIC, NULL); // copy start screen to main screen - memcpy(wipe_scr, wipe_scr_start, width*height); + V_PutBlock(0, 0, width, height, wipe_scr_start); // makes this wipe faster (in theory) // to have stuff in column-major format @@ -152,14 +152,14 @@ static int wipe_doMelt(int width, int height, int ticks) for (y = 0; y < scroff; ++y) { *d = *s; - d += width; + d += video.pitch; s++; } s = wipe_scr_start + x * height; for (; y < height; ++y) { *d = *s; - d += width; + d += video.pitch; s++; } } diff --git a/src/i_video.c b/src/i_video.c index 9377ccea..f37d5621 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -436,20 +436,6 @@ void I_StartFrame(void) static void UpdateRender(void) { - int i; - - // Copy linear video buffer to rectangle on surface - - byte *dest = screenbuffer->pixels; - const pixel_t *src = I_VideoBuffer; - - for (i = 0; i < blit_rect.h; ++i) - { - memcpy(dest, src, blit_rect.w); - dest += screenbuffer->w; - src += blit_rect.w; - } - SDL_LowerBlit(screenbuffer, &blit_rect, argbbuffer, &blit_rect); SDL_UpdateTexture(texture, &blit_rect, argbbuffer->pixels, argbbuffer->pitch); SDL_RenderClear(renderer); @@ -639,9 +625,9 @@ void I_FinishUpdate(void) // I_ReadScreen // -void I_ReadScreen(byte *scr) +void I_ReadScreen(byte *dst) { - memcpy(scr, I_VideoBuffer, video.width * video.height * sizeof(*I_VideoBuffer)); + V_GetBlock(0, 0, video.width, video.height, dst); } // @@ -1381,6 +1367,8 @@ static void CreateSurfaces(void) w = (w + 3) & ~3; h = (h + 3) & ~3; + video.pitch = w; + // [FG] create paletted frame buffer if (screenbuffer != NULL) @@ -1393,14 +1381,12 @@ static void CreateSurfaces(void) 0, 0, 0, 0); SDL_FillRect(screenbuffer, NULL, 0); - if (I_VideoBuffer != NULL) - { - Z_Free(I_VideoBuffer); - } - - I_VideoBuffer = Z_Calloc(1, w * h * sizeof(*I_VideoBuffer), PU_STATIC, NULL); + I_VideoBuffer = screenbuffer->pixels; V_RestoreBuffer(); + // Clear the screen to black. + memset(I_VideoBuffer, 0, w * h * sizeof(*I_VideoBuffer)); + if (argbbuffer != NULL) { SDL_FreeSurface(argbbuffer); diff --git a/src/m_snapshot.c b/src/m_snapshot.c index 3c0985d0..6c001529 100644 --- a/src/m_snapshot.c +++ b/src/m_snapshot.c @@ -21,7 +21,6 @@ #include "doomtype.h" #include "doomstat.h" -#include "i_video.h" #include "m_io.h" #include "v_video.h" #include "r_main.h" @@ -123,7 +122,7 @@ static void M_TakeSnapshot (void) { for (x = video.deltaw; x < NONWIDEWIDTH + video.deltaw; x++) { - *p++ = s[V_ScaleY(y) * video.width + V_ScaleX(x)]; + *p++ = s[V_ScaleY(y) * video.pitch + V_ScaleX(x)]; } } @@ -164,7 +163,7 @@ boolean M_DrawSnapshot (int n, int x, int y, int w, int h) const fixed_t step_x = (SCREENWIDTH << FRACBITS) / rect.sw; const fixed_t step_y = (SCREENHEIGHT << FRACBITS) / rect.sh; - byte *dest = I_VideoBuffer + rect.sy * video.width + rect.sx; + byte *dest = I_VideoBuffer + rect.sy * video.pitch + rect.sx; fixed_t srcx, srcy; int destx, desty; @@ -172,7 +171,7 @@ boolean M_DrawSnapshot (int n, int x, int y, int w, int h) for (desty = 0, srcy = 0; desty < rect.sh; desty++, srcy += step_y) { - destline = dest + desty * video.width; + destline = dest + desty * video.pitch; srcline = snapshots[n] + (srcy >> FRACBITS) * SCREENWIDTH; for (destx = 0, srcx = 0; destx < rect.sw; destx++, srcx += step_x) diff --git a/src/r_draw.c b/src/r_draw.c index abbb0f9f..d1df014d 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -47,7 +47,7 @@ int viewwindowx; int viewwindowy; static byte **ylookup = NULL; static int *columnofs = NULL; -static int linesize = SCREENWIDTH; // killough 11/98 +static int linesize; // killough 11/98 // Color tables for different players, // translate a limited part to another @@ -824,7 +824,7 @@ void R_InitBuffer(void) { int i; - linesize = video.width; // killough 11/98 + linesize = video.pitch; // killough 11/98 // Handle resize, // e.g. smaller view windows diff --git a/src/r_voxel.c b/src/r_voxel.c index 1a3bc2a6..fe42eca6 100644 --- a/src/r_voxel.c +++ b/src/r_voxel.c @@ -813,7 +813,7 @@ static void VX_DrawColumn (vissprite_t * spr, int x, int y) boolean shadow = ((spr->mobjflags & MF_SHADOW) != 0); - int linesize = video.width; + int linesize = video.pitch; byte * dest = I_VideoBuffer + viewwindowy * linesize + viewwindowx; // iterate over screen columns diff --git a/src/st_stuff.c b/src/st_stuff.c index 64f4d25a..b837e131 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -342,7 +342,7 @@ static void ST_DrawSolidBackground(int st_x) { for (x = 0; x < depth; x++) { - byte *c = st_backing_screen + V_ScaleY(y) * video.width + V_ScaleX(x + offset); + byte *c = st_backing_screen + V_ScaleY(y) * video.pitch + V_ScaleX(x + offset); r += pal[3 * c[0] + 0]; g += pal[3 * c[0] + 1]; b += pal[3 * c[0] + 2]; @@ -1327,14 +1327,7 @@ void ST_Init(void) void ST_InitRes(void) { - vrect_t rect; - - rect.x = 0; - rect.y = 0; - rect.w = video.unscaledw; - rect.h = StatusBarBufferHeight(); - - V_ScaleRect(&rect); + int height = V_ScaleY(StatusBarBufferHeight()); if (st_backing_screen) { @@ -1342,7 +1335,7 @@ void ST_InitRes(void) } // killough 11/98: allocate enough for hires - st_backing_screen = Z_Malloc(rect.sw * rect.sh * sizeof(*st_backing_screen), PU_STATIC, 0); + st_backing_screen = Z_Malloc(video.pitch * height * sizeof(*st_backing_screen), PU_STATIC, 0); } void ST_Warnings(void) diff --git a/src/v_video.c b/src/v_video.c index d77d2bc4..987ee59f 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -970,7 +970,7 @@ void V_Init(void) int i; fixed_t frac, lastfrac; - linesize = video.width; + linesize = video.pitch; video.xscale = (video.width << FRACBITS) / video.unscaledw; video.yscale = (video.height << FRACBITS) / SCREENHEIGHT; diff --git a/src/v_video.h b/src/v_video.h index 44ec9d25..e4f8cb23 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -93,6 +93,7 @@ typedef struct { int width; int height; + int pitch; int unscaledw; // unscaled width with correction for widecreen int deltaw; // widescreen delta