Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Widescreen asset support for Heretic #609

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 11 additions & 40 deletions source/d_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,32 +515,11 @@ static void D_showMemStats()
}
#endif

//
// D_DrawPillars
//
// Will draw pillars for pillarboxing the 4:3 subscreen.
//
void D_DrawPillars()
{
int wingwidth;

if(vbscreen.getVirtualAspectRatio() <= 4 * FRACUNIT / 3)
return;

wingwidth = (vbscreen.width - (vbscreen.height * 4 / 3)) / 2;
if(wingwidth <= 0)
return;

V_ColorBlock(&vbscreen, GameModeInfo->blackIndex, 0, 0, wingwidth, vbscreen.height);
V_ColorBlock(&vbscreen, GameModeInfo->blackIndex, vbscreen.width - wingwidth,
0, wingwidth, vbscreen.height);
}

//
// D_DrawWings
//
// haleyjd: Draw pillarboxing during non-play gamestates, or the wings of the
// status bar while it is visible. This is necessary when drawing patches at
// haleyjd: Draw wings of the status bar while it is visible.
// This is necessary when drawing patches at
// 4:3 aspect ratio over widescreen video modes.
//
void D_DrawWings()
Expand All @@ -556,25 +535,17 @@ void D_DrawWings()
if(wingwidth <= 0)
return;

if(gamestate == GS_LEVEL && !MN_CheckFullScreen())
if(gamestate == GS_LEVEL && !MN_CheckFullScreen() &&
(scaledwindow.height != SCREENHEIGHT || (automapactive && !automap_overlay)))
{
if(scaledwindow.height != SCREENHEIGHT || (automapactive && !automap_overlay))
{
unsigned int bottom = SCREENHEIGHT - 1;
unsigned int statbarh = static_cast<unsigned int>(GameModeInfo->StatusBar->height);

int ycoord = vbscreen.y1lookup[bottom - statbarh];
int blockheight = vbscreen.y2lookup[bottom] - ycoord + 1;
unsigned int bottom = SCREENHEIGHT - 1;
unsigned int statbarh = static_cast<unsigned int>(GameModeInfo->StatusBar->height);

int ycoord = vbscreen.y1lookup[bottom - statbarh];
int blockheight = vbscreen.y2lookup[bottom] - ycoord + 1;

R_VideoEraseScaled(0, ycoord, wingwidth, blockheight);
R_VideoEraseScaled(vbscreen.width - wingwidth, ycoord, wingwidth, blockheight);
}
}
else
{
V_ColorBlock(&vbscreen, GameModeInfo->blackIndex, 0, 0, wingwidth, vbscreen.height);
V_ColorBlock(&vbscreen, GameModeInfo->blackIndex, vbscreen.width - wingwidth,
0, wingwidth, vbscreen.height);
R_VideoEraseScaled(0, ycoord, wingwidth, blockheight);
R_VideoEraseScaled(vbscreen.width - wingwidth, ycoord, wingwidth, blockheight);
}
}

Expand Down
1 change: 0 additions & 1 deletion source/d_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ extern camera_t *camera;
//

void D_PageTicker();
void D_DrawPillars();
void D_DrawWings();
void D_AdvanceDemo();
void D_StartTitle();
Expand Down
16 changes: 8 additions & 8 deletions source/f_finale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ static void F_CastDrawer()

// erase the entire screen to a background
// Ty 03/30/98 bg texture extern
V_DrawFSBackground(&subscreen43, wGlobalDir.checkNumForName(DEH_String("BGCASTCALL")));
V_DrawFSBackground(&vbscreenyscaled, wGlobalDir.checkNumForName(DEH_String("BGCASTCALL")));

F_CastTitle();

Expand Down Expand Up @@ -685,7 +685,7 @@ static void F_BunnyScroll()
if(scrolled < 320 || ws_offset2 > 0)
V_DrawPatchGeneral(-scrolled + ws_offset1, 0, &vbscreenyscaled, p1, false);
if(ws_offset2 > 0)
D_DrawWings();
V_DrawPillars();
if(finalecount < 1130)
return;
if(finalecount < 1180)
Expand Down Expand Up @@ -726,7 +726,7 @@ static void F_DrawUnderwater()
palette = (byte *)wGlobalDir.cacheLumpName("E2PAL", PU_CACHE);
I_SetPalette(palette);

V_DrawBlock(0,0,&subscreen43,SCREENWIDTH,SCREENHEIGHT,
V_DrawBlockFS(&vbscreenyscaled,
(byte *)wGlobalDir.cacheLumpName("E2END", PU_CACHE));
finalestage = 3;
}
Expand All @@ -739,7 +739,7 @@ static void F_DrawUnderwater()

case 4:
Console.enabled = true;
V_DrawBlock(0,0,&subscreen43,SCREENWIDTH,SCREENHEIGHT,
V_DrawBlockFS(&vbscreenyscaled,
(byte *)wGlobalDir.cacheLumpName("TITLE", PU_CACHE));
break;
}
Expand Down Expand Up @@ -854,8 +854,8 @@ static void F_FinaleEndDrawer()
PatchLoader::CacheName(wGlobalDir, "ENDPIC", PU_CACHE));
break;
case FINALE_HTIC_CREDITS:
V_DrawBlock(0, 0, &subscreen43, SCREENWIDTH, SCREENHEIGHT,
(byte *)wGlobalDir.cacheLumpName(sw ? "ORDER" : "CREDIT", PU_CACHE));
V_DrawBlockFS(&vbscreenyscaled,
(byte *)wGlobalDir.cacheLumpName(sw ? "ORDER" : "CREDIT", PU_CACHE));
break;
case FINALE_HTIC_WATER:
F_DrawUnderwater();
Expand All @@ -864,8 +864,8 @@ static void F_FinaleEndDrawer()
F_DemonScroll();
break;
case FINALE_END_PIC:
V_DrawPatch(0, 0, &subscreen43,
PatchLoader::CacheName(wGlobalDir, LevelInfo.endPic, PU_CACHE));
V_DrawPatchFS(&vbscreenyscaled,
PatchLoader::CacheName(wGlobalDir, LevelInfo.endPic, PU_CACHE));
break;
default: // ?
break;
Expand Down
14 changes: 7 additions & 7 deletions source/hi_stuff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -988,26 +988,26 @@ static void HI_DrawBackground(void)
{
case INTR_LEAVING:
if(hi_exitpic)
V_DrawPatch(0, 0, &subscreen43, hi_exitpic);
V_DrawPatchFS(&vbscreenyscaled, hi_exitpic);
else
V_DrawBackground("FLOOR16", &subscreen43);
V_DrawBackground("FLOOR16", &vbscreenyscaled);
break;
case INTR_GOING:
case INTR_WAITING:
// Make sure to continue showing the last explicit exit pic if the next enterpic is not
// provided
if(estrnonempty(hi_wbs.li_lastexitpic) && estrempty(hi_wbs.li_nextenterpic))
V_DrawPatch(0, 0, &subscreen43, hi_exitpic);
V_DrawPatchFS(&vbscreenyscaled, hi_exitpic);
else if(hi_interpic)
V_DrawPatch(0, 0, &subscreen43, hi_interpic);
V_DrawPatchFS(&vbscreenyscaled, hi_interpic);
else
V_DrawBackground("FLOOR16", &subscreen43);
V_DrawBackground("FLOOR16", &vbscreenyscaled);
break;
default:
if(estrnonempty(hi_wbs.li_lastexitpic) && estrempty(hi_wbs.li_nextenterpic))
V_DrawPatch(0, 0, &subscreen43, hi_exitpic);
V_DrawPatchFS(&vbscreenyscaled, hi_exitpic);
else
V_DrawBackground("FLOOR16", &subscreen43);
V_DrawBackground("FLOOR16", &vbscreenyscaled);
break;
}
}
Expand Down
5 changes: 0 additions & 5 deletions source/mn_misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,11 +559,6 @@ static void MN_HelpDrawer()
// haleyjd: support raw lumps
int lumpnum = helpscreens[viewing_helpscreen].lumpnum;

// if the screen is larger than 4:3, we need to draw pillars ourselves,
// as D_Display won't be able to know if this widget is fullscreen or not
// in time to do it as usual.
D_DrawPillars();

// haleyjd 05/18/09: use smart background drawer
V_DrawFSBackground(&vbscreenyscaled, lumpnum);
}
Expand Down
43 changes: 24 additions & 19 deletions source/st_hbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ static patch_t *PatchBLACKSQ;
// current state variables
static int chainhealth; // current position of the gem
static int chainwiggle; // small randomized addend for chain y coord.
static int ws_offset;

//
// ST_drawSmallNumber
Expand Down Expand Up @@ -270,19 +271,21 @@ static void ST_drawInvNum(int num, int x, int y)
static void ST_drawBackground()
{
// draw the background
V_DrawPatch(0, 158, &subscreen43, PatchLoader::CacheName(wGlobalDir, "BARBACK", PU_CACHE));
patch_t* barback = PatchLoader::CacheName(wGlobalDir, "BARBACK", PU_CACHE);
ws_offset = (vbscreenyscaled.unscaledw - barback->width) / 2 + barback->leftoffset;
V_DrawPatch(ws_offset, 158, &vbscreenyscaled, barback);

// patch the face eyes with the GOD graphics if the player
// is in god mode
if(plyr->cheats & CF_GODMODE)
{
V_DrawPatch(16, 167, &subscreen43, PatchLoader::CacheName(wGlobalDir, "GOD1", PU_CACHE));
V_DrawPatch(287, 167, &subscreen43, PatchLoader::CacheName(wGlobalDir, "GOD2", PU_CACHE));
V_DrawPatch(16 + ws_offset, 167, &vbscreenyscaled, PatchLoader::CacheName(wGlobalDir, "GOD1", PU_CACHE));
V_DrawPatch(287 + ws_offset, 167, &vbscreenyscaled, PatchLoader::CacheName(wGlobalDir, "GOD2", PU_CACHE));
}

// draw the tops of the faces
V_DrawPatch(0, 148, &subscreen43, PatchLoader::CacheName(wGlobalDir, "LTFCTOP", PU_CACHE));
V_DrawPatch(290, 148, &subscreen43, PatchLoader::CacheName(wGlobalDir, "RTFCTOP", PU_CACHE));
V_DrawPatch(ws_offset, 148, &vbscreenyscaled, PatchLoader::CacheName(wGlobalDir, "LTFCTOP", PU_CACHE));
V_DrawPatch(290 + ws_offset, 148, &vbscreenyscaled, PatchLoader::CacheName(wGlobalDir, "RTFCTOP", PU_CACHE));
}

#define SHADOW_BOX_WIDTH 16
Expand All @@ -296,24 +299,26 @@ static void ST_blockDrawerS(int x, int y, int startcmap, int mapdir)

fixed_t mapnum, mapstep;

x += ws_offset;

cx1 = x;
cy1 = y;
cx2 = x + SHADOW_BOX_WIDTH - 1;
cy2 = y + SHADOW_BOX_HEIGHT - 1;

realx = subscreen43.x1lookup[cx1];
realy = subscreen43.y1lookup[cy1];
w = subscreen43.x2lookup[cx2] - realx + 1;
h = subscreen43.y2lookup[cy2] - realy + 1;
realx = vbscreenyscaled.x1lookup[cx1];
realy = vbscreenyscaled.y1lookup[cy1];
w = vbscreenyscaled.x2lookup[cx2] - realx + 1;
h = vbscreenyscaled.y2lookup[cy2] - realy + 1;

dest = subscreen43.data + realx * subscreen43.pitch + realy;
dest = vbscreenyscaled.data + realx * vbscreenyscaled.pitch + realy;

mapstep = mapdir * (16 << FRACBITS) / w;

#ifdef RANGECHECK
// sanity check
if(realx < 0 || realx + w > subscreen43.width ||
realy < 0 || realy + h > subscreen43.height)
if(realx < 0 || realx + w > vbscreenyscaled.width ||
realy < 0 || realy + h > vbscreenyscaled.height)
{
I_Error("ST_blockDrawerS: block exceeds buffer boundaries.\n");
}
Expand All @@ -329,7 +334,7 @@ static void ST_blockDrawerS(int x, int y, int startcmap, int mapdir)
{
colormap = colormaps[0] + (mapnum >> FRACBITS) * 256;
*col = colormap[*col];
col += subscreen43.height;
col += vbscreenyscaled.height;
mapnum += mapstep;
}

Expand Down Expand Up @@ -376,18 +381,18 @@ static void ST_drawLifeChain()

// draw the chain -- links repeat every 17 pixels, so we
// wrap the chain back to the starting position every 17
V_DrawPatch(2 + (chainpos%17), y, &subscreen43,
V_DrawPatch(2 + (chainpos%17) + ws_offset, y, &vbscreenyscaled,
PatchLoader::CacheName(wGlobalDir, "CHAIN", PU_CACHE));

// draw the gem (17 is the far left pos., 273 is max)
// TODO: fix life gem for multiplayer modes
V_DrawPatch(17 + chainpos, y, &subscreen43,
PatchLoader::CacheName(wGlobalDir, "LIFEGEM2", PU_CACHE));
V_DrawPatch(17 + chainpos + ws_offset, y, &vbscreenyscaled,
PatchLoader::CacheName(wGlobalDir, "LIFEGEM2", PU_CACHE));

// draw face patches to cover over spare ends of chain
V_DrawPatch(0, 190, &subscreen43, PatchLoader::CacheName(wGlobalDir, "LTFACE", PU_CACHE));
V_DrawPatch(276, 190, &subscreen43, PatchLoader::CacheName(wGlobalDir, "RTFACE", PU_CACHE));
V_DrawPatch(ws_offset, 190, &vbscreenyscaled, PatchLoader::CacheName(wGlobalDir, "LTFACE", PU_CACHE));
V_DrawPatch(276 + ws_offset, 190, &vbscreenyscaled, PatchLoader::CacheName(wGlobalDir, "RTFACE", PU_CACHE));

// use the colormap to shadow the ends of the chain
ST_chainShadow();
}
Expand Down
30 changes: 28 additions & 2 deletions source/v_video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,15 +664,39 @@ void V_DrawMaskedBlockTR(int x, int y, VBuffer *buffer, int width, int height,
buffer->MaskedBlockDrawer(x, y, buffer, width, height, srcpitch, src, cmap);
}

//
// V_DrawPillars
//
// Will draw pillars for pillarboxing the 4:3 subscreen.
//
void V_DrawPillars()
{
int wingwidth;

if (vbscreen.getVirtualAspectRatio() <= 4 * FRACUNIT / 3)
return;

wingwidth = (vbscreen.width - (vbscreen.height * 4 / 3)) / 2;
if (wingwidth <= 0)
return;

V_ColorBlock(&vbscreen, GameModeInfo->blackIndex, 0, 0, wingwidth, vbscreen.height);
V_ColorBlock(&vbscreen, GameModeInfo->blackIndex, vbscreen.width - wingwidth,
0, wingwidth, vbscreen.height);
}

//
// V_DrawBlockFS
//
// haleyjd 05/18/09: Convenience routine to do V_DrawBlock but with
// the assumption that the graphic is fullscreen, 320x200.
//
// If drawing to widescreen, center align.
void V_DrawBlockFS(VBuffer *buffer, const byte *src)
{
buffer->BlockDrawer(0, 0, buffer, SCREENWIDTH, SCREENHEIGHT, src);
V_DrawPillars();

buffer->BlockDrawer((buffer->unscaledw - SCREENWIDTH) / 2, 0, buffer, SCREENWIDTH, SCREENHEIGHT, src);
}

//
Expand All @@ -681,9 +705,11 @@ void V_DrawBlockFS(VBuffer *buffer, const byte *src)
// haleyjd 05/18/09: Convenience routine to do V_DrawPatch but with
// the assumption that the graphic is fullscreen, 320x200.
//
// If wider than the screen, center align.
// If drawing to widescreen, center align.
void V_DrawPatchFS(VBuffer *buffer, patch_t *patch)
{
V_DrawPillars();

V_DrawPatchGeneral((buffer->unscaledw - patch->width) / 2, 0, buffer, patch, false);
}

Expand Down
1 change: 1 addition & 0 deletions source/v_video.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ void V_DrawMaskedBlockTR(int x, int y, VBuffer *buffer, int width, int height,
void V_DrawBlockFS(VBuffer *buffer, const byte *src);
void V_DrawPatchFS(VBuffer *buffer, patch_t *patch);
void V_DrawFSBackground(VBuffer *dest, int lumpnum);
void V_DrawPillars();

// V_FindBestColor (haleyjd)
// A function that requantizes a color into the default game palette
Expand Down