any res bunny scroll, HOM detection, disk flash, st_bar solid colors

* Various fixes.
This commit is contained in:
Roman Fomin 2023-12-05 02:42:01 +07:00
parent 7be7a78e8a
commit 3d8c701a60
10 changed files with 146 additions and 195 deletions

View File

@ -2646,9 +2646,6 @@ void D_DoomMain(void)
I_Printf(VB_INFO, "S_Init: Setting up sound."); I_Printf(VB_INFO, "S_Init: Setting up sound.");
S_Init(snd_SfxVolume /* *8 */, snd_MusicVolume /* *8*/ ); S_Init(snd_SfxVolume /* *8 */, snd_MusicVolume /* *8*/ );
// [FG] init graphics (video.widedelta) before HUD widgets
I_InitGraphics();
I_Printf(VB_INFO, "HU_Init: Setting up heads up display."); I_Printf(VB_INFO, "HU_Init: Setting up heads up display.");
HU_Init(); HU_Init();
M_SetMenuFontSpacing(); M_SetMenuFontSpacing();
@ -2807,6 +2804,9 @@ void D_DoomMain(void)
I_SetFastdemoTimer(true); I_SetFastdemoTimer(true);
} }
// [FG] init graphics (video.widedelta) before HUD widgets
I_InitGraphics();
if (startloadgame >= 0) if (startloadgame >= 0)
{ {
char *file; char *file;

View File

@ -705,61 +705,19 @@ void F_CastDrawer (void)
V_DrawPatch (160, 170, patch); V_DrawPatch (160, 170, patch);
} }
//
// F_DrawPatchCol
//
// killough 11/98: reformatted and added hires support
static void F_DrawPatchCol(int x, patch_t *patch, int col)
{
// TODO
#if 0
const column_t *column =
(const column_t *)((byte *) patch + LONG(patch->columnofs[col]));
// step through the posts in a column
if (hires)
while (column->topdelta != 0xff)
{
byte *desttop = I_VideoBuffer + x*2;
const byte *source = (byte *) column + 3;
byte *dest = desttop + column->topdelta*SCREENWIDTH*4;
int count = column->length;
for (;count--; dest += SCREENWIDTH*4)
dest[0] = dest[SCREENWIDTH*2] = dest[1] = dest[SCREENWIDTH*2+1] =
*source++;
column = (column_t *)(source+1);
}
else
while (column->topdelta != 0xff)
{
byte *desttop = I_VideoBuffer + x;
const byte *source = (byte *) column + 3;
byte *dest = desttop + column->topdelta*SCREENWIDTH;
int count = column->length;
for (;count--; dest += SCREENWIDTH)
*dest = *source++;
column = (column_t *)(source+1);
}
#endif
}
// //
// F_BunnyScroll // F_BunnyScroll
// //
void F_BunnyScroll (void) void F_BunnyScroll (void)
{ {
int scrolled; int scrolled;
int x;
patch_t* p1; patch_t* p1;
patch_t* p2; patch_t* p2;
char name[16]; char name[16];
int stage; int stage;
static int laststage; static int laststage;
int p2offset, p1offset, pillar_width; int offset;
p1 = W_CacheLumpName ("PFUB2", PU_LEVEL); p1 = W_CacheLumpName ("PFUB2", PU_LEVEL);
p2 = W_CacheLumpName ("PFUB1", PU_LEVEL); p2 = W_CacheLumpName ("PFUB1", PU_LEVEL);
@ -769,44 +727,24 @@ void F_BunnyScroll (void)
if (scrolled < 0) if (scrolled < 0)
scrolled = 0; scrolled = 0;
pillar_width = (SCREENWIDTH - SHORT(p1->width)) / 2; offset = 0;
if (SHORT(p2->width) != SCREENWIDTH)
if (pillar_width > 0)
{ {
// [crispy] fill pillarboxes in widescreen mode offset = video.deltaw;
memset(I_VideoBuffer, 0, video.width * video.height);
}
else
{
pillar_width = 0;
} }
// Calculate the portion of PFUB2 that would be offscreen at original res. if (scrolled > 0)
p1offset = (SCREENWIDTH - SHORT(p1->width)) / 2; V_DrawPatch(320 - scrolled - offset, 0, p2);
if (scrolled < 320)
V_DrawPatch(-scrolled - offset, 0, p1);
if (SHORT(p2->width) == SCREENWIDTH) if (SHORT(p2->width) == SCREENWIDTH)
{ {
// Unity or original PFUBs. V_FillRect(0, 0, video.deltaw, SCREENHEIGHT, v_darkest_color);
// PFUB1 only contains the pixels that scroll off. V_FillRect(video.unscaledw - video.deltaw, 0,
p2offset = SCREENWIDTH - p1offset; video.deltaw, SCREENHEIGHT, v_darkest_color);
}
else
{
// Widescreen mod PFUBs.
// Right side of PFUB2 and left side of PFUB1 are identical.
p2offset = SCREENWIDTH + p1offset;
} }
for (x = pillar_width; x < SCREENWIDTH - pillar_width; x++)
{
int x2 = x - video.deltaw + scrolled;
if (x2 < p2offset)
F_DrawPatchCol (x, p1, x2 - p1offset);
else
F_DrawPatchCol (x, p2, x2 - p2offset);
}
if (finalecount < 1130) if (finalecount < 1130)
return; return;
if (finalecount < 1180) if (finalecount < 1180)

View File

@ -1405,8 +1405,8 @@ boolean HU_DemoProgressBar(boolean force)
return false; return false;
} }
V_DrawHorizLine(0, video.unscaledh - 2, progress, v_darkest_color); V_FillRect(0, video.unscaledh - 2, progress, 1, v_darkest_color);
V_DrawHorizLine(0, video.unscaledh - 1, progress, v_lightest_color); V_FillRect(0, video.unscaledh - 1, progress, 1, v_lightest_color);
return true; return true;
} }

View File

@ -418,7 +418,7 @@ static inline void I_UpdateRender (void)
} }
static void I_DrawDiskIcon(), I_RestoreDiskBackground(); static void I_DrawDiskIcon(), I_RestoreDiskBackground();
//static unsigned int disk_to_draw, disk_to_restore; static unsigned int disk_to_draw, disk_to_restore;
static void CreateUpscaledTexture(boolean force); static void CreateUpscaledTexture(boolean force);
@ -566,28 +566,37 @@ void I_ReadScreen(byte *scr)
// killough 10/98: init disk icon // killough 10/98: init disk icon
// //
//static pixel_t *diskflash, *old_data; static pixel_t *diskflash, *old_data;
static vrect_t disk;
static void I_InitDiskFlash(void) static void I_InitDiskFlash(void)
{ {
// TODO pixel_t *temp;
#if 0
pixel_t temp[32*32]; disk.x = 0;
disk.y = 0;
disk.w = 16;
disk.h = 16;
V_ScaleRect(&disk);
temp = Z_Malloc(disk.sw * disk.sh * sizeof(*temp), PU_STATIC, 0);
if (diskflash) if (diskflash)
{ {
Z_Free(diskflash); Z_Free(diskflash);
Z_Free(old_data); Z_Free(old_data);
} }
diskflash = Z_Malloc((16<<hires) * (16<<hires) * sizeof(*diskflash), PU_STATIC, 0); diskflash = Z_Malloc(disk.sw * disk.sh * sizeof(*diskflash), PU_STATIC, 0);
old_data = Z_Malloc((16<<hires) * (16<<hires) * sizeof(*old_data), PU_STATIC, 0); old_data = Z_Malloc(disk.sw * disk.sh * sizeof(*old_data), PU_STATIC, 0);
V_GetBlock(0, 0, 16, 16, temp); V_GetBlock(0, 0, disk.sw, disk.sh, temp);
V_DrawPatchDirect(0-video.widedelta, 0, W_CacheLumpName("STDISK", PU_CACHE)); V_DrawPatch(-video.deltaw, 0, W_CacheLumpName("STDISK", PU_CACHE));
V_GetBlock(0, 0, 16, 16, diskflash); V_GetBlock(0, 0, disk.sw, disk.sh, diskflash);
V_DrawBlock(0, 0, 16, 16, temp); V_PutBlock(0, 0, disk.sw, disk.sh, temp);
#endif
Z_Free(temp);
} }
// //
@ -596,24 +605,21 @@ static void I_InitDiskFlash(void)
void I_BeginRead(unsigned int bytes) void I_BeginRead(unsigned int bytes)
{ {
//disk_to_draw += bytes; disk_to_draw += bytes;
} }
static void I_DrawDiskIcon(void) static void I_DrawDiskIcon(void)
{ {
// TODO
#if 0
if (!disk_icon || PLAYBACK_SKIP) if (!disk_icon || PLAYBACK_SKIP)
return; return;
if (disk_to_draw >= DISK_ICON_THRESHOLD) if (disk_to_draw >= DISK_ICON_THRESHOLD)
{ {
V_GetBlock(SCREENWIDTH-16, SCREENHEIGHT-16, 16, 16, old_data); V_GetBlock(video.width - disk.sw, video.height - disk.sh, disk.sw, disk.sh, old_data);
V_PutBlock(SCREENWIDTH-16, SCREENHEIGHT-16, 16, 16, diskflash); V_PutBlock(video.width - disk.sw, video.height - disk.sh, disk.sw, disk.sh, diskflash);
disk_to_restore = 1; disk_to_restore = 1;
} }
#endif
} }
// //
@ -627,20 +633,17 @@ void I_EndRead(void)
static void I_RestoreDiskBackground(void) static void I_RestoreDiskBackground(void)
{ {
// TODO
#if 0
if (!disk_icon || PLAYBACK_SKIP) if (!disk_icon || PLAYBACK_SKIP)
return; return;
if (disk_to_restore) if (disk_to_restore)
{ {
V_PutBlock(SCREENWIDTH-16, SCREENHEIGHT-16, 16, 16, old_data); V_PutBlock(video.width - disk.sw, video.height - disk.sh, disk.sw, disk.sh, old_data);
disk_to_restore = 0; disk_to_restore = 0;
} }
disk_to_draw = 0; disk_to_draw = 0;
#endif
} }
static const float gammalevels[9] = static const float gammalevels[9] =
@ -957,7 +960,6 @@ static void I_GetScreenDimensions(void)
// [FG] For performance reasons, SDL2 insists that the screen pitch, i.e. // [FG] For performance reasons, SDL2 insists that the screen pitch, i.e.
// the *number of bytes* that one horizontal row of pixels occupy in // the *number of bytes* that one horizontal row of pixels occupy in
// memory, must be a multiple of 4. // memory, must be a multiple of 4.
video.unscaledw = (video.unscaledw + 3) & ~3;
video.width = (video.width + 3) & ~3; video.width = (video.width + 3) & ~3;
video.height = (video.height + 3) & ~3; video.height = (video.height + 3) & ~3;
@ -1141,7 +1143,7 @@ static void I_ResetGraphicsMode(void)
SDL_RenderPresent(renderer); SDL_RenderPresent(renderer);
V_Init(); V_Init();
ST_Init(); ST_InitRes();
// [FG] create paletted frame buffer // [FG] create paletted frame buffer

View File

@ -482,7 +482,6 @@ void R_ExecuteSetViewSize (void)
view.w = scaledviewwidth; view.w = scaledviewwidth;
view.h = scaledviewheight; view.h = scaledviewheight;
V_ClipRect(&view);
V_ScaleRect(&view); V_ScaleRect(&view);
viewwidth = view.sw; viewwidth = view.sw;
@ -754,12 +753,11 @@ void R_RenderPlayerView (player_t* player)
R_ClearSprites (); R_ClearSprites ();
VX_ClearVoxels (); VX_ClearVoxels ();
// TODO
#if 0
if (autodetect_hom) if (autodetect_hom)
{ // killough 2/10/98: add flashing red HOM indicators { // killough 2/10/98: add flashing red HOM indicators
pixel_t c[47*47]; pixel_t c[47*47];
extern int lastshottic; extern int lastshottic;
const int linesize = video.width;
int i , color = !flashing_hom || (gametic % 20) < 9 ? 0xb0 : 0; int i , color = !flashing_hom || (gametic % 20) < 9 ? 0xb0 : 0;
memset(I_VideoBuffer+viewwindowy*linesize,color,viewheight*linesize); memset(I_VideoBuffer+viewwindowy*linesize,color,viewheight*linesize);
for (i=0;i<47*47;i++) for (i=0;i<47*47;i++)
@ -822,11 +820,10 @@ void R_RenderPlayerView (player_t* player)
c[i] = t=='/' ? color : t; c[i] = t=='/' ? color : t;
} }
if (gametic-lastshottic < TICRATE*2 && gametic-lastshottic > TICRATE/8) if (gametic-lastshottic < TICRATE*2 && gametic-lastshottic > TICRATE/8)
V_DrawBlock((viewwindowx + viewwidth/2 - 24)>>hires, V_DrawBlock(scaledviewx + scaledviewwidth/2 - 24,
(viewwindowy + viewheight/2 - 24)>>hires, 47, 47, c); scaledviewy + scaledviewheight/2 - 24, 47, 47, c);
R_DrawViewBorder(); R_DrawViewBorder();
} }
#endif
// check for new console commands. // check for new console commands.
NetUpdate (); NetUpdate ();

View File

@ -20,7 +20,6 @@
#ifndef __R_THINGS__ #ifndef __R_THINGS__
#define __R_THINGS__ #define __R_THINGS__
#include "doomdef.h"
#include "m_fixed.h" #include "m_fixed.h"
#include "r_defs.h" #include "r_defs.h"

View File

@ -32,9 +32,6 @@
#include "r_main.h" #include "r_main.h"
#include "am_map.h" #include "am_map.h"
#include "m_cheat.h" #include "m_cheat.h"
#include "s_sound.h"
#include "sounds.h"
#include "dstrings.h"
#include "m_misc2.h" #include "m_misc2.h"
#include "m_swap.h" #include "m_swap.h"
#include "i_printf.h" #include "i_printf.h"
@ -318,22 +315,24 @@ void ST_Stop(void);
int st_solidbackground; int st_solidbackground;
static void ST_DrawSolidBackground(void) static void ST_DrawSolidBackground(int st_x)
{ {
// TODO
#if 0
// [FG] calculate average color of the 16px left and right of the status bar // [FG] calculate average color of the 16px left and right of the status bar
const int vstep[][2] = {{0, 1}, {1, 2}, {2, ST_HEIGHT}}; const int vstep[][2] = {{0, 1}, {1, 2}, {2, ST_HEIGHT}};
const int hstep = video.width;
const int lo = MAX(st_x + video.widedelta - SHORT(sbar->leftoffset), 0);
const int w = MIN(SHORT(sbar->width), SCREENWIDTH);
const int depth = 16;
byte *pal = W_CacheLumpName("PLAYPAL", PU_STATIC); byte *pal = W_CacheLumpName("PLAYPAL", PU_STATIC);
int v;
// [FG] temporarily draw status bar to background buffer // [FG] temporarily draw status bar to background buffer
V_DrawPatch(st_x, 0, sbar); V_DrawPatch(st_x, 0, sbar);
vrect_t rect;
rect.w = MIN(SHORT(sbar->width), video.unscaledw);
rect.h = ST_HEIGHT;
const int offset = MAX(st_x + video.deltaw - SHORT(sbar->leftoffset), 0);
const int depth = 16;
int v;
// [FG] separate colors for the top rows // [FG] separate colors for the top rows
for (v = 0; v < arrlen(vstep); v++) for (v = 0; v < arrlen(vstep); v++)
{ {
@ -346,12 +345,16 @@ static void ST_DrawSolidBackground(void)
{ {
for (x = 0; x < depth; x++) for (x = 0; x < depth; x++)
{ {
byte *c = st_backing_screen + y * hstep + ((x + lo) << hires); rect.x = x + offset;
rect.y = y;
V_ScaleRect(&rect);
byte *c = st_backing_screen + rect.sy * video.width + rect.sx;
r += pal[3 * c[0] + 0]; r += pal[3 * c[0] + 0];
g += pal[3 * c[0] + 1]; g += pal[3 * c[0] + 1];
b += pal[3 * c[0] + 2]; b += pal[3 * c[0] + 2];
c += (w - 2 * x - 1) << hires; c += rect.sw - 2 * rect.sx - 1;
r += pal[3 * c[0] + 0]; r += pal[3 * c[0] + 0];
g += pal[3 * c[0] + 1]; g += pal[3 * c[0] + 1];
b += pal[3 * c[0] + 2]; b += pal[3 * c[0] + 2];
@ -365,15 +368,10 @@ static void ST_DrawSolidBackground(void)
// [FG] tune down to half saturation (for empiric reasons) // [FG] tune down to half saturation (for empiric reasons)
col = I_GetPaletteIndex(pal, r/2, g/2, b/2); col = I_GetPaletteIndex(pal, r/2, g/2, b/2);
// [FG] fill background buffer with average status bar color V_FillRect(0, v0, video.unscaledw, v1 - v0, col);
for (y = (v0 << hires); y < (v1 << hires); y++)
{
memset(dest + y * (SCREENWIDTH << hires), col, (SCREENWIDTH << hires));
}
} }
Z_ChangeTag (pal, PU_CACHE); Z_ChangeTag (pal, PU_CACHE);
#endif
} }
void ST_refreshBackground(boolean force) void ST_refreshBackground(boolean force)
@ -387,7 +385,7 @@ void ST_refreshBackground(boolean force)
if (SHORT(sbar->width) > video.unscaledw && SHORT(sbar->leftoffset) == 0) if (SHORT(sbar->width) > video.unscaledw && SHORT(sbar->leftoffset) == 0)
{ {
st_x = ST_X + (video.unscaledw - SHORT(sbar->width)) / 2; st_x = ST_X + (SCREENWIDTH - SHORT(sbar->width)) / 2;
} }
else else
{ {
@ -398,14 +396,11 @@ void ST_refreshBackground(boolean force)
if (video.unscaledw != ST_WIDTH) if (video.unscaledw != ST_WIDTH)
{ {
// TODO
#if 0
if (st_solidbackground) if (st_solidbackground)
{ {
ST_DrawSolidBackground(); ST_DrawSolidBackground(st_x);
} }
else else
#endif
{ {
// [crispy] this is our own local copy of R_FillBackScreen() to fill // [crispy] this is our own local copy of R_FillBackScreen() to fill
// the entire background of st_backing_screen with the bezel // the entire background of st_backing_screen with the bezel
@ -426,7 +421,7 @@ void ST_refreshBackground(boolean force)
for (x = 0; x < video.deltaw; x += 8) for (x = 0; x < video.deltaw; x += 8)
{ {
V_DrawPatch(x - video.deltaw, 0, patch); V_DrawPatch(x - video.deltaw, 0, patch);
V_DrawPatch(video.unscaledw - x - 8 - video.deltaw, 0, patch); V_DrawPatch(SCREENWIDTH + video.deltaw - x - 8, 0, patch);
} }
} }
} }
@ -463,9 +458,9 @@ void ST_refreshBackground(boolean force)
V_CopyRect(0, 0, st_backing_screen, V_CopyRect(0, 0, st_backing_screen,
video.deltaw, ST_HEIGHT, video.deltaw, ST_HEIGHT,
0, ST_Y); 0, ST_Y);
V_CopyRect(video.unscaledw - video.deltaw, 0, st_backing_screen, V_CopyRect(SCREENWIDTH + video.deltaw, 0, st_backing_screen,
video.deltaw, ST_HEIGHT, video.deltaw, ST_HEIGHT,
video.unscaledw - video.deltaw, ST_Y); SCREENWIDTH + video.deltaw, ST_Y);
} }
} }
} }
@ -1338,16 +1333,18 @@ static int StatusBarBufferHeight(void)
void ST_Init(void) void ST_Init(void)
{ {
vrect_t rect;
ST_loadData(); ST_loadData();
}
void ST_InitRes(void)
{
vrect_t rect;
rect.x = 0; rect.x = 0;
rect.y = 0; rect.y = 0;
rect.w = video.unscaledw; rect.w = video.unscaledw;
rect.h = StatusBarBufferHeight(); rect.h = StatusBarBufferHeight();
V_ClipRect(&rect);
V_ScaleRect(&rect); V_ScaleRect(&rect);
if (st_backing_screen) if (st_backing_screen)

View File

@ -53,7 +53,9 @@ void ST_Init(void);
void ST_Warnings(void); void ST_Warnings(void);
// [crispy] forcefully initialize the status bar backing screen // [crispy] forcefully initialize the status bar backing screen
extern void ST_refreshBackground(boolean force); void ST_refreshBackground(boolean force);
void ST_InitRes(void);
// killough 5/2/98: moved from m_misc.c: // killough 5/2/98: moved from m_misc.c:

View File

@ -553,7 +553,7 @@ void V_DrawPatchInt(int x, int y, patch_t *patch, boolean flipped,
#ifdef RANGECHECK #ifdef RANGECHECK
if(texturecolumn < 0 || texturecolumn >= w) if(texturecolumn < 0 || texturecolumn >= w)
{ {
I_Error("V_DrawPatchInt: bad texturecolumn %d\n", texturecolumn); I_Error("V_DrawPatchInt: bad texturecolumn %d", texturecolumn);
} }
#endif #endif
@ -604,7 +604,9 @@ void V_DrawPatchFullScreen(patch_t *patch)
// [crispy] fill pillarboxes in widescreen mode // [crispy] fill pillarboxes in widescreen mode
if (video.unscaledw != NONWIDEWIDTH) if (video.unscaledw != NONWIDEWIDTH)
{ {
memset(dest_screen, v_darkest_color, video.width * video.height); V_FillRect(0, 0, video.deltaw, SCREENHEIGHT, v_darkest_color);
V_FillRect(video.unscaledw - video.deltaw, 0,
video.deltaw, SCREENHEIGHT, v_darkest_color);
} }
V_DrawPatchInt(x, 0, patch, false, NULL); V_DrawPatchInt(x, 0, patch, false, NULL);
@ -612,23 +614,13 @@ void V_DrawPatchFullScreen(patch_t *patch)
void V_ScaleRect(vrect_t *rect) void V_ScaleRect(vrect_t *rect)
{ {
rect->sx = x1lookup[rect->cx1]; rect->sx = x1lookup[rect->x];
rect->sy = y1lookup[rect->cy1]; rect->sy = y1lookup[rect->y];
rect->sw = x2lookup[rect->cx2] - rect->sx + 1; rect->sw = x2lookup[rect->x + rect->w - 1] - rect->sx + 1;
rect->sh = y2lookup[rect->cy2] - rect->sy + 1; rect->sh = y2lookup[rect->y + rect->h - 1] - rect->sy + 1;
#ifdef RANGECHECK
// sanity check - out-of-bounds values should not come out of the scaling
// arrays so long as they are accessed within bounds.
if(rect->sx < 0 || rect->sx + rect->sw > video.width ||
rect->sy < 0 || rect->sy + rect->sh > video.height)
{
I_Error("V_ScaleRect: internal error - invalid scaling lookups");
}
#endif
} }
void V_ClipRect(vrect_t *rect) static void V_ClipRect(vrect_t *rect)
{ {
// clip to left and top edges // clip to left and top edges
rect->cx1 = rect->x >= 0 ? rect->x : 0; rect->cx1 = rect->x >= 0 ? rect->x : 0;
@ -649,6 +641,45 @@ void V_ClipRect(vrect_t *rect)
rect->ch = rect->cy2 - rect->cy1 + 1; rect->ch = rect->cy2 - rect->cy1 + 1;
} }
static void V_ScaleClippedRect(vrect_t *rect)
{
rect->sx = x1lookup[rect->cx1];
rect->sy = y1lookup[rect->cy1];
rect->sw = x2lookup[rect->cx2] - rect->sx + 1;
rect->sh = y2lookup[rect->cy2] - rect->sy + 1;
#ifdef RANGECHECK
// sanity check - out-of-bounds values should not come out of the scaling
// arrays so long as they are accessed within bounds.
if(rect->sx < 0 || rect->sx + rect->sw > video.width ||
rect->sy < 0 || rect->sy + rect->sh > video.height)
{
I_Error("V_ScaleRect: internal error - invalid scaling lookups");
}
#endif
}
void V_FillRect(int x, int y, int width, int height, byte color)
{
vrect_t dstrect;
dstrect.x = x;
dstrect.y = y;
dstrect.w = width;
dstrect.h = height;
V_ClipRect(&dstrect);
V_ScaleClippedRect(&dstrect);
byte* dest = V_ADDRESS(dest_screen, dstrect.sx, dstrect.sy);
while (dstrect.sh--)
{
memset(dest, color, dstrect.sw);
dest += linesize;
}
}
// //
// V_CopyRect // V_CopyRect
// //
@ -700,8 +731,8 @@ void V_CopyRect(int srcx, int srcy, pixel_t *source,
if (dstrect.cw <= 0 || dstrect.ch <= 0) if (dstrect.cw <= 0 || dstrect.ch <= 0)
return; return;
V_ScaleRect(&srcrect); V_ScaleClippedRect(&srcrect);
V_ScaleRect(&dstrect); V_ScaleClippedRect(&dstrect);
// use the smaller of the two scaled rect widths / heights // use the smaller of the two scaled rect widths / heights
usew = (srcrect.sw < dstrect.sw ? srcrect.sw : dstrect.sw); usew = (srcrect.sw < dstrect.sw ? srcrect.sw : dstrect.sw);
@ -749,7 +780,7 @@ void V_DrawBlock(int x, int y, int width, int height, pixel_t *src)
dx = dstrect.cx1 - x; dx = dstrect.cx1 - x;
dy = dstrect.cy1 - y; dy = dstrect.cy1 - y;
V_ScaleRect(&dstrect); V_ScaleClippedRect(&dstrect);
source = src + dy * width + dx; source = src + dy * width + dx;
dest = V_ADDRESS(dest_screen, dstrect.sx, dstrect.sy); dest = V_ADDRESS(dest_screen, dstrect.sx, dstrect.sy);
@ -794,7 +825,6 @@ void V_TileBlock64(int line, int width, int height, const byte *src)
dstrect.w = width; dstrect.w = width;
dstrect.h = height; dstrect.h = height;
V_ClipRect(&dstrect);
V_ScaleRect(&dstrect); V_ScaleRect(&dstrect);
h = dstrect.sh; h = dstrect.sh;
@ -837,20 +867,18 @@ void V_GetBlock(int x, int y, int width, int height, byte *dest)
#ifdef RANGECHECK #ifdef RANGECHECK
if (x<0 if (x<0
||x+width >SCREENWIDTH || x+width >video.width
|| y<0 || y<0
|| y+height>SCREENHEIGHT ) || y+height>video.height )
I_Error ("Bad V_GetBlock"); I_Error ("Bad V_GetBlock");
#endif #endif
if (hires) // killough 11/98: hires support src = V_ADDRESS(dest_screen, x, y);
y<<=2, x<<=1, width<<=1, height<<=1;
src = dest_screen + y*SCREENWIDTH+x;
while (height--) while (height--)
{ {
memcpy (dest, src, width); memcpy (dest, src, width);
src += SCREENWIDTH << hires; src += linesize;
dest += width; dest += width;
} }
} }
@ -863,32 +891,22 @@ void V_PutBlock(int x, int y, int width, int height, byte *src)
#ifdef RANGECHECK #ifdef RANGECHECK
if (x<0 if (x<0
||x+width >SCREENWIDTH ||x+width >video.width
|| y<0 || y<0
|| y+height>SCREENHEIGHT ) || y+height>video.height )
I_Error ("Bad V_PutBlock"); I_Error ("Bad V_PutBlock");
#endif #endif
if (hires) dest = V_ADDRESS(dest_screen, x, y);
y<<=2, x<<=1, width<<=1, height<<=1;
dest = dest_screen + y*SCREENWIDTH+x;
while (height--) while (height--)
{ {
memcpy (dest, src, width); memcpy (dest, src, width);
dest += SCREENWIDTH << hires; dest += linesize;
src += width; src += width;
} }
} }
void V_DrawHorizLine(int x, int y, int width, byte color)
{
byte line[WIDE_SCREENWIDTH];
memset(line, color, width);
V_DrawBlock(x, y, width, 1, line);
}
void V_ShadeScreen(void) void V_ShadeScreen(void)
{ {
int y; int y;
@ -945,9 +963,9 @@ void V_Init(void)
x1lookup[0] = 0; x1lookup[0] = 0;
lastfrac = frac = 0; lastfrac = frac = 0;
for(i = 0; i < video.width; i++) for (i = 0; i < video.width; i++)
{ {
if(frac >> FRACBITS > lastfrac >> FRACBITS) if (frac >> FRACBITS > lastfrac >> FRACBITS)
{ {
x1lookup[frac >> FRACBITS] = i; x1lookup[frac >> FRACBITS] = i;
x2lookup[lastfrac >> FRACBITS] = i - 1; x2lookup[lastfrac >> FRACBITS] = i - 1;
@ -961,9 +979,9 @@ void V_Init(void)
y1lookup[0] = 0; y1lookup[0] = 0;
lastfrac = frac = 0; lastfrac = frac = 0;
for(i = 0; i < video.height; i++) for (i = 0; i < video.height; i++)
{ {
if(frac >> FRACBITS > lastfrac >> FRACBITS) if (frac >> FRACBITS > lastfrac >> FRACBITS)
{ {
y1lookup[frac >> FRACBITS] = i; y1lookup[frac >> FRACBITS] = i;
y2lookup[lastfrac >> FRACBITS] = i - 1; y2lookup[lastfrac >> FRACBITS] = i - 1;
@ -972,8 +990,8 @@ void V_Init(void)
frac += video.ystep; frac += video.ystep;
} }
y2lookup[video.unscaledh - 1] = video.height - 1; y2lookup[SCREENHEIGHT - 1] = video.height - 1;
y1lookup[video.unscaledh] = y2lookup[video.unscaledh] = video.height; y1lookup[SCREENHEIGHT] = y2lookup[SCREENHEIGHT] = video.height;
} }
// Set the buffer that the code draws to. // Set the buffer that the code draws to.

View File

@ -110,8 +110,6 @@ typedef struct
int sh; // scaled height int sh; // scaled height
} vrect_t; } vrect_t;
void V_ClipRect(vrect_t *rect);
void V_ScaleRect(vrect_t *rect); void V_ScaleRect(vrect_t *rect);
// Allocates buffer screens, call before R_Init. // Allocates buffer screens, call before R_Init.
@ -151,7 +149,7 @@ void V_GetBlock(int x, int y, int width, int height, pixel_t *dest);
void V_PutBlock(int x, int y, int width, int height, pixel_t *src); void V_PutBlock(int x, int y, int width, int height, pixel_t *src);
void V_DrawHorizLine(int x, int y, int width, byte color); void V_FillRect(int x, int y, int width, int height, byte color);
void V_ShadeScreen(void); void V_ShadeScreen(void);