mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-09-22 03:12:00 -04:00
add more V_Scale* functions, various fixes
* Lighting fixes. * Remove video.unscaledh (it's always SCREENHEIGHT).
This commit is contained in:
parent
7859949a78
commit
1b5722120d
@ -247,7 +247,7 @@ void D_Display (void)
|
||||
|
||||
// save the current screen if about to wipe
|
||||
if ((wipe = gamestate != wipegamestate) && NOTSTRICTMODE(screen_melt))
|
||||
wipe_StartScreen(0, 0, video.unscaledw, video.unscaledh);
|
||||
wipe_StartScreen(0, 0, video.unscaledw, SCREENHEIGHT);
|
||||
|
||||
if (gamestate == GS_LEVEL && gametic)
|
||||
HU_Erase();
|
||||
@ -356,7 +356,7 @@ void D_Display (void)
|
||||
}
|
||||
|
||||
// wipe update
|
||||
wipe_EndScreen(0, 0, video.unscaledw, video.unscaledh);
|
||||
wipe_EndScreen(0, 0, video.unscaledw, SCREENHEIGHT);
|
||||
|
||||
wipestart = I_GetTime () - 1;
|
||||
|
||||
@ -370,7 +370,7 @@ void D_Display (void)
|
||||
}
|
||||
while (!tics);
|
||||
wipestart = nowtime;
|
||||
done = wipe_ScreenWipe(wipe_Melt, 0, 0, video.unscaledw, video.unscaledh, tics);
|
||||
done = wipe_ScreenWipe(wipe_Melt, 0, 0, video.unscaledw, SCREENHEIGHT, tics);
|
||||
M_Drawer(); // menu is drawn even on top of wipes
|
||||
I_FinishUpdate(); // page flip or blit buffer
|
||||
}
|
||||
|
@ -1405,8 +1405,8 @@ boolean HU_DemoProgressBar(boolean force)
|
||||
return false;
|
||||
}
|
||||
|
||||
V_FillRect(0, video.unscaledh - 2, progress, 1, v_darkest_color);
|
||||
V_FillRect(0, video.unscaledh - 1, progress, 1, v_lightest_color);
|
||||
V_FillRect(0, SCREENHEIGHT - 2, progress, 1, v_darkest_color);
|
||||
V_FillRect(0, SCREENHEIGHT - 1, progress, 1, v_lightest_color);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -960,6 +960,7 @@ static void I_GetScreenDimensions(void)
|
||||
// [FG] For performance reasons, SDL2 insists that the screen pitch, i.e.
|
||||
// the *number of bytes* that one horizontal row of pixels occupy in
|
||||
// memory, must be a multiple of 4.
|
||||
video.unscaledw = (video.unscaledw + 3) & ~3;
|
||||
video.width = (video.width + 3) & ~3;
|
||||
video.height = (video.height + 3) & ~3;
|
||||
|
||||
|
@ -33,7 +33,6 @@ typedef struct
|
||||
int width;
|
||||
int height;
|
||||
int unscaledw;
|
||||
int unscaledh;
|
||||
int deltaw;
|
||||
|
||||
fixed_t xscale;
|
||||
|
@ -114,24 +114,16 @@ static void M_TakeSnapshot (void)
|
||||
current_snapshot = malloc(snapshot_size * sizeof(**snapshots));
|
||||
}
|
||||
|
||||
int x, y;
|
||||
vrect_t rect;
|
||||
rect.w = NONWIDEWIDTH;
|
||||
rect.h = SCREENHEIGHT;
|
||||
|
||||
byte *p = current_snapshot;
|
||||
|
||||
const byte *s = I_VideoBuffer;
|
||||
|
||||
int x, y;
|
||||
for (y = 0; y < SCREENHEIGHT; y++)
|
||||
{
|
||||
for (x = video.deltaw; x < NONWIDEWIDTH + video.deltaw; x++)
|
||||
{
|
||||
rect.x = x;
|
||||
rect.y = y;
|
||||
V_ScaleRect(&rect);
|
||||
|
||||
*p++ = s[rect.sy * video.width + rect.sx];
|
||||
*p++ = s[V_ScaleY(y) * video.width + V_ScaleX(x)];
|
||||
}
|
||||
}
|
||||
|
||||
|
13
src/r_main.c
13
src/r_main.c
@ -27,7 +27,6 @@
|
||||
#include "r_draw.h"
|
||||
#include "r_sky.h"
|
||||
#include "r_voxel.h"
|
||||
#include "m_bbox.h"
|
||||
#include "v_video.h"
|
||||
#include "am_map.h"
|
||||
#include "st_stuff.h"
|
||||
@ -448,18 +447,18 @@ void R_ExecuteSetViewSize (void)
|
||||
{
|
||||
scaledviewwidth_nonwide = NONWIDEWIDTH;
|
||||
scaledviewwidth = video.unscaledw;
|
||||
scaledviewheight = video.unscaledh; // killough 11/98
|
||||
scaledviewheight = SCREENHEIGHT; // killough 11/98
|
||||
}
|
||||
// [crispy] hard-code to SCREENWIDTH and SCREENHEIGHT minus status bar height
|
||||
else if (setblocks == 10)
|
||||
{
|
||||
scaledviewwidth_nonwide = NONWIDEWIDTH;
|
||||
scaledviewwidth = video.unscaledw;
|
||||
scaledviewheight = video.unscaledh - ST_HEIGHT;
|
||||
scaledviewheight = SCREENHEIGHT - ST_HEIGHT;
|
||||
}
|
||||
else
|
||||
{
|
||||
const int st_screen = video.unscaledh - ST_HEIGHT;
|
||||
const int st_screen = SCREENHEIGHT - ST_HEIGHT;
|
||||
|
||||
scaledviewwidth_nonwide = setblocks * 32;
|
||||
scaledviewheight = (setblocks * st_screen / 10) & ~7; // killough 11/98
|
||||
@ -475,7 +474,7 @@ void R_ExecuteSetViewSize (void)
|
||||
if (scaledviewwidth == video.unscaledw)
|
||||
scaledviewy = 0;
|
||||
else
|
||||
scaledviewy = (video.unscaledh - ST_HEIGHT - scaledviewheight) / 2;
|
||||
scaledviewy = (SCREENHEIGHT - ST_HEIGHT - scaledviewheight) / 2;
|
||||
|
||||
view.x = scaledviewx;
|
||||
view.y = scaledviewy;
|
||||
@ -486,12 +485,12 @@ void R_ExecuteSetViewSize (void)
|
||||
|
||||
viewwidth = view.sw;
|
||||
viewheight = view.sh;
|
||||
viewwidth_nonwide = (scaledviewwidth_nonwide * video.xscale) >> FRACBITS;
|
||||
viewwidth_nonwide = V_ScaleX(scaledviewwidth_nonwide);
|
||||
|
||||
viewwindowx = view.sx;
|
||||
viewwindowy = view.sy;
|
||||
|
||||
viewblocks = (MIN(setblocks, 10) * video.yscale) >> FRACBITS;
|
||||
viewblocks = V_ScaleX(MIN(setblocks, 10));
|
||||
|
||||
centery = viewheight/2;
|
||||
centerx = viewwidth/2;
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include "doomstat.h"
|
||||
#include "i_video.h"
|
||||
#include "p_tick.h"
|
||||
#include "v_video.h"
|
||||
#include "r_main.h"
|
||||
#include "r_bsp.h"
|
||||
#include "r_plane.h"
|
||||
@ -157,7 +157,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, int x1, int x2)
|
||||
{
|
||||
if (!fixedcolormap) // calculate lighting
|
||||
{ // killough 11/98:
|
||||
unsigned index = spryscale >> (LIGHTSCALESHIFT + (video.xscale >> FRACBITS));
|
||||
unsigned index = FixedDiv(spryscale, video.xscale) >> LIGHTSCALESHIFT;
|
||||
|
||||
if (index >= MAXLIGHTSCALE )
|
||||
index = MAXLIGHTSCALE-1;
|
||||
@ -374,7 +374,7 @@ static void R_RenderSegLoop (void)
|
||||
texturecolumn >>= FRACBITS;
|
||||
|
||||
// calculate lighting
|
||||
index = rw_scale >> (LIGHTSCALESHIFT + (video.xscale >> FRACBITS)); // killough 11/98
|
||||
index = FixedDiv(rw_scale, video.xscale) >> LIGHTSCALESHIFT; // killough 11/98
|
||||
|
||||
if (index >= MAXLIGHTSCALE )
|
||||
index = MAXLIGHTSCALE-1;
|
||||
|
@ -664,7 +664,7 @@ void R_ProjectSprite (mobj_t* thing)
|
||||
vis->colormap[0] = vis->colormap[1] = fullcolormap; // full bright // killough 3/20/98
|
||||
else
|
||||
{ // diminished light
|
||||
int index = xscale>>(LIGHTSCALESHIFT+hires); // killough 11/98
|
||||
int index = FixedDiv(xscale, video.xscale) >> LIGHTSCALESHIFT; // killough 11/98
|
||||
if (index >= MAXLIGHTSCALE)
|
||||
index = MAXLIGHTSCALE-1;
|
||||
vis->colormap[0] = spritelights[index];
|
||||
|
@ -696,7 +696,7 @@ boolean VX_ProjectVoxel (mobj_t * thing)
|
||||
else
|
||||
{
|
||||
// diminished light
|
||||
int index = xscale >> (LIGHTSCALESHIFT + hires); // killough 11/98
|
||||
int index = FixedDiv(xscale, video.xscale) >> LIGHTSCALESHIFT; // killough 11/98
|
||||
|
||||
if (index < 0) index = 0;
|
||||
if (index > MAXLIGHTSCALE-1) index = MAXLIGHTSCALE-1;
|
||||
|
@ -325,11 +325,8 @@ static void ST_DrawSolidBackground(int st_x)
|
||||
// [FG] temporarily draw status bar to background buffer
|
||||
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 width = MIN(SHORT(sbar->width), video.unscaledw);
|
||||
const int depth = 16;
|
||||
int v;
|
||||
|
||||
@ -345,16 +342,12 @@ static void ST_DrawSolidBackground(int st_x)
|
||||
{
|
||||
for (x = 0; x < depth; x++)
|
||||
{
|
||||
rect.x = x + offset;
|
||||
rect.y = y;
|
||||
V_ScaleRect(&rect);
|
||||
|
||||
byte *c = st_backing_screen + rect.sy * video.width + rect.sx;
|
||||
byte *c = st_backing_screen + V_ScaleY(y) * video.width + V_ScaleX(x + offset);
|
||||
r += pal[3 * c[0] + 0];
|
||||
g += pal[3 * c[0] + 1];
|
||||
b += pal[3 * c[0] + 2];
|
||||
|
||||
c += rect.sw - 2 * rect.sx - 1;
|
||||
c += V_ScaleX(width - 2 * x - 1);
|
||||
r += pal[3 * c[0] + 0];
|
||||
g += pal[3 * c[0] + 1];
|
||||
b += pal[3 * c[0] + 2];
|
||||
@ -410,7 +403,7 @@ void ST_refreshBackground(boolean force)
|
||||
|
||||
const byte *src = W_CacheLumpNum(firstflat + R_FlatNumForName(name), PU_CACHE);
|
||||
|
||||
V_TileBlock64(video.unscaledh - ST_HEIGHT, video.unscaledw, ST_HEIGHT, src);
|
||||
V_TileBlock64(SCREENHEIGHT - ST_HEIGHT, video.unscaledw, ST_HEIGHT, src);
|
||||
|
||||
// [crispy] preserve bezel bottom edge
|
||||
if (scaledviewwidth == video.unscaledw)
|
||||
|
@ -427,7 +427,7 @@ static void V_DrawMaskedColumn(patch_column_t *patchcol, const int ytop,
|
||||
if (columntop >= 0)
|
||||
{
|
||||
// SoM: Make sure the lut is never referenced out of range
|
||||
if (columntop >= video.unscaledh)
|
||||
if (columntop >= SCREENHEIGHT)
|
||||
return;
|
||||
|
||||
patchcol->y1 = y1lookup[columntop];
|
||||
@ -441,10 +441,10 @@ static void V_DrawMaskedColumn(patch_column_t *patchcol, const int ytop,
|
||||
|
||||
if (columntop + column->length - 1 < 0)
|
||||
continue;
|
||||
if (columntop + column->length - 1 < video.unscaledh)
|
||||
if (columntop + column->length - 1 < SCREENHEIGHT)
|
||||
patchcol->y2 = y2lookup[columntop + column->length - 1];
|
||||
else
|
||||
patchcol->y2 = y2lookup[video.unscaledh - 1];
|
||||
patchcol->y2 = y2lookup[SCREENHEIGHT - 1];
|
||||
|
||||
// SoM: The failsafes should be completely redundant now...
|
||||
// haleyjd 05/13/08: fix clipping; y2lookup not clamped properly
|
||||
@ -620,6 +620,16 @@ void V_ScaleRect(vrect_t *rect)
|
||||
rect->sh = y2lookup[rect->y + rect->h - 1] - rect->sy + 1;
|
||||
}
|
||||
|
||||
int V_ScaleX(int x)
|
||||
{
|
||||
return x1lookup[x];
|
||||
}
|
||||
|
||||
int V_ScaleY(int y)
|
||||
{
|
||||
return y1lookup[y];
|
||||
}
|
||||
|
||||
static void V_ClipRect(vrect_t *rect)
|
||||
{
|
||||
// clip to left and top edges
|
||||
@ -633,8 +643,8 @@ static void V_ClipRect(vrect_t *rect)
|
||||
// clip right and bottom edges
|
||||
if (rect->cx2 >= video.unscaledw)
|
||||
rect->cx2 = video.unscaledw - 1;
|
||||
if (rect->cy2 >= video.unscaledh)
|
||||
rect->cy2 = video.unscaledh - 1;
|
||||
if (rect->cy2 >= SCREENHEIGHT)
|
||||
rect->cy2 = SCREENHEIGHT - 1;
|
||||
|
||||
// determine clipped width and height
|
||||
rect->cw = rect->cx2 - rect->cx1 + 1;
|
||||
@ -699,9 +709,9 @@ void V_CopyRect(int srcx, int srcy, pixel_t *source,
|
||||
#ifdef RANGECHECK
|
||||
// rejection if source rect is off-screen
|
||||
if (srcx + width < 0 || srcy + height < 0 ||
|
||||
srcx >= video.unscaledw || srcy >= video.unscaledh ||
|
||||
srcx >= video.unscaledw || srcy >= SCREENHEIGHT ||
|
||||
destx + width < 0 || desty + height < 0 ||
|
||||
destx >= video.unscaledw || desty >= video.unscaledh)
|
||||
destx >= video.unscaledw || desty >= SCREENHEIGHT)
|
||||
{
|
||||
I_Error("Bad V_CopyRect");
|
||||
}
|
||||
@ -947,7 +957,7 @@ void V_DrawBackground(const char *patchname)
|
||||
{
|
||||
const byte *src = W_CacheLumpNum(firstflat + R_FlatNumForName(patchname), PU_CACHE);
|
||||
|
||||
V_TileBlock64(0, video.unscaledw, video.unscaledh, src);
|
||||
V_TileBlock64(0, video.unscaledw, SCREENHEIGHT, src);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -111,6 +111,8 @@ typedef struct
|
||||
} vrect_t;
|
||||
|
||||
void V_ScaleRect(vrect_t *rect);
|
||||
int V_ScaleX(int x);
|
||||
int V_ScaleY(int y);
|
||||
|
||||
// Allocates buffer screens, call before R_Init.
|
||||
void V_Init (void);
|
||||
|
Loading…
x
Reference in New Issue
Block a user