Transposed backbuffer WIP

This commit is contained in:
Lactozilla 2023-11-28 10:05:25 -03:00
parent 8e7d8281bd
commit 1634a59804
10 changed files with 213 additions and 566 deletions

View file

@ -787,7 +787,7 @@ static void AM_drawPixel(INT32 xx, INT32 yy, INT32 cc)
UINT8 *dest = screens[0];
if (xx < 0 || yy < 0 || xx >= vid.width || yy >= vid.height)
return; // off the screen
dest[(yy*vid.width) + xx] = cc;
dest[(xx*vid.height) + yy] = cc;
}
//

View file

@ -1747,6 +1747,7 @@ static void CON_DrawHudlines(void)
// Lactozilla: Draws the console's background picture.
static void CON_DrawBackpic(void)
{
#if 0
patch_t *con_backpic;
lumpnum_t piclump;
int x, w, h;
@ -1790,6 +1791,7 @@ static void CON_DrawBackpic(void)
// Unlock the cached patch.
W_UnlockCachedPatch(con_backpic);
#endif
}
// draw the console background, text, and prompt if enough place

View file

@ -407,11 +407,13 @@ static void D_Display(void)
case GS_LEVEL:
if (!gametic)
break;
#if 0
HU_Erase();
AM_Drawer();
break;
case GS_INTERMISSION:
Y_IntermissionDrawer();
HU_Erase();
HU_Drawer();
@ -469,6 +471,9 @@ static void D_Display(void)
}
case GS_DEDICATEDSERVER:
case GS_NULL:
#else
default:
#endif
break;
}
@ -491,7 +496,7 @@ static void D_Display(void)
PS_START_TIMING(ps_rendercalltime);
if (players[displayplayer].mo || players[displayplayer].playerstate == PST_DEAD)
{
topleft = screens[0] + viewwindowy*vid.width + viewwindowx;
topleft = screens[0] + viewwindowx*vid.height + viewwindowy;
objectsdrawn = 0;
#ifdef HWRENDER
if (rendermode != render_soft)
@ -515,7 +520,7 @@ static void D_Display(void)
viewwindowy = vid.height / 2;
M_Memcpy(ylookup, ylookup2, viewheight*sizeof (ylookup[0]));
topleft = screens[0] + viewwindowy*vid.width + viewwindowx;
topleft = screens[0] + viewwindowx*vid.height + viewwindowy;
R_RenderPlayerView(&players[secondarydisplayplayer]);
@ -527,6 +532,7 @@ static void D_Display(void)
// Image postprocessing effect
if (rendermode == render_soft)
{
#if 0
if (!splitscreen)
R_ApplyViewMorph();
@ -534,11 +540,13 @@ static void D_Display(void)
V_DoPostProcessor(0, postimgtype, postimgparam);
if (postimgtype2)
V_DoPostProcessor(1, postimgtype2, postimgparam2);
#endif
}
PS_STOP_TIMING(ps_rendercalltime);
R_RestoreLevelInterpolators();
}
#if 0
if (lastdraw)
{
if (rendermode == render_soft)
@ -549,9 +557,11 @@ static void D_Display(void)
}
lastdraw = false;
}
#endif
PS_START_TIMING(ps_uitime);
#if 0
if (gamestate == GS_LEVEL)
{
ST_Drawer();
@ -560,6 +570,7 @@ static void D_Display(void)
}
else
F_TitleScreenDrawer();
#endif
}
else
{

View file

@ -41,9 +41,9 @@
#include "hardware/hw_main.h"
#endif
#if NUMSCREENS < 5
// #if NUMSCREENS < 5
#define NOWIPE // do not enable wipe image post processing for ARM, SH and MIPS CPUs
#endif
// #endif
typedef struct fademask_s {
UINT8* mask;

View file

@ -70,7 +70,7 @@ raster_bbox_seg
while (y < h)
{
topleft[x + y * vid.width] = pixel;
topleft[y + x * vid.height] = pixel;
y++;
}
}

File diff suppressed because it is too large Load diff

View file

@ -37,7 +37,7 @@ void R_DrawSpan_NPO2_8 (void)
UINT8 *source;
UINT8 *colormap;
UINT8 *dest;
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height;
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.width;
size_t count = (ds_x2 - ds_x1 + 1);
@ -46,9 +46,9 @@ void R_DrawSpan_NPO2_8 (void)
source = ds_source;
colormap = ds_colormap;
dest = ylookup[ds_y] + columnofs[ds_x1];
dest = &topleft[ds_x1*vid.height + ds_y];
if (dest+8 > deststop)
if (dest > deststop)
return;
fixedwidth = ds_flatwidth << FRACBITS;
@ -121,7 +121,7 @@ void R_DrawTiltedSpan_NPO2_8(void)
uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx);
vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx);
dest = ylookup[ds_y] + columnofs[ds_x1];
dest = &topleft[ds_x1*vid.height + ds_y];
source = ds_source;
//colormap = ds_colormap;
@ -311,7 +311,7 @@ void R_DrawTiltedTranslucentSpan_NPO2_8(void)
uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx);
vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx);
dest = ylookup[ds_y] + columnofs[ds_x1];
dest = &topleft[ds_x1*vid.height + ds_y];
source = ds_source;
//colormap = ds_colormap;
@ -499,7 +499,7 @@ void R_DrawTiltedSplat_NPO2_8(void)
uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx);
vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx);
dest = ylookup[ds_y] + columnofs[ds_x1];
dest = &topleft[ds_x1*vid.height + ds_y];
source = ds_source;
//colormap = ds_colormap;
@ -683,7 +683,7 @@ void R_DrawSplat_NPO2_8 (void)
UINT8 *source;
UINT8 *colormap;
UINT8 *dest;
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height;
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.width;
size_t count = (ds_x2 - ds_x1 + 1);
UINT32 val;
@ -693,7 +693,7 @@ void R_DrawSplat_NPO2_8 (void)
source = ds_source;
colormap = ds_colormap;
dest = ylookup[ds_y] + columnofs[ds_x1];
dest = &topleft[ds_x1*vid.height + ds_y];
fixedwidth = ds_flatwidth << FRACBITS;
fixedheight = ds_flatheight << FRACBITS;
@ -751,7 +751,7 @@ void R_DrawTranslucentSplat_NPO2_8 (void)
UINT8 *source;
UINT8 *colormap;
UINT8 *dest;
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height;
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.width;
size_t count = (ds_x2 - ds_x1 + 1);
UINT32 val;
@ -761,7 +761,7 @@ void R_DrawTranslucentSplat_NPO2_8 (void)
source = ds_source;
colormap = ds_colormap;
dest = ylookup[ds_y] + columnofs[ds_x1];
dest = &topleft[ds_x1*vid.height + ds_y];
fixedwidth = ds_flatwidth << FRACBITS;
fixedheight = ds_flatheight << FRACBITS;
@ -820,7 +820,7 @@ void R_DrawFloorSprite_NPO2_8 (void)
UINT8 *translation;
UINT8 *colormap;
UINT8 *dest;
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height;
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.width;
size_t count = (ds_x2 - ds_x1 + 1);
UINT32 val;
@ -831,7 +831,7 @@ void R_DrawFloorSprite_NPO2_8 (void)
source = (UINT16 *)ds_source;
colormap = ds_colormap;
translation = ds_translation;
dest = ylookup[ds_y] + columnofs[ds_x1];
dest = &topleft[ds_x1*vid.height + ds_y];
fixedwidth = ds_flatwidth << FRACBITS;
fixedheight = ds_flatheight << FRACBITS;
@ -890,7 +890,7 @@ void R_DrawTranslucentFloorSprite_NPO2_8 (void)
UINT8 *translation;
UINT8 *colormap;
UINT8 *dest;
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height;
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.width;
size_t count = (ds_x2 - ds_x1 + 1);
UINT32 val;
@ -901,7 +901,7 @@ void R_DrawTranslucentFloorSprite_NPO2_8 (void)
source = (UINT16 *)ds_source;
colormap = ds_colormap;
translation = ds_translation;
dest = ylookup[ds_y] + columnofs[ds_x1];
dest = &topleft[ds_x1*vid.height + ds_y];
fixedwidth = ds_flatwidth << FRACBITS;
fixedheight = ds_flatheight << FRACBITS;
@ -974,7 +974,7 @@ void R_DrawTiltedFloorSprite_NPO2_8(void)
uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx);
vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx);
dest = ylookup[ds_y] + columnofs[ds_x1];
dest = &topleft[ds_x1*vid.height + ds_y];
source = (UINT16 *)ds_source;
colormap = ds_colormap;
translation = ds_translation;
@ -1130,7 +1130,7 @@ void R_DrawTiltedTranslucentFloorSprite_NPO2_8(void)
uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx);
vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx);
dest = ylookup[ds_y] + columnofs[ds_x1];
dest = &topleft[ds_x1*vid.height + ds_y];
source = (UINT16 *)ds_source;
colormap = ds_colormap;
translation = ds_translation;
@ -1271,7 +1271,7 @@ void R_DrawTranslucentSpan_NPO2_8 (void)
UINT8 *source;
UINT8 *colormap;
UINT8 *dest;
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height;
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.width;
size_t count = (ds_x2 - ds_x1 + 1);
UINT32 val;
@ -1281,7 +1281,7 @@ void R_DrawTranslucentSpan_NPO2_8 (void)
source = ds_source;
colormap = ds_colormap;
dest = ylookup[ds_y] + columnofs[ds_x1];
dest = &topleft[ds_x1*vid.height + ds_y];
fixedwidth = ds_flatwidth << FRACBITS;
fixedheight = ds_flatheight << FRACBITS;
@ -1336,7 +1336,7 @@ void R_DrawWaterSpan_NPO2_8(void)
UINT8 *colormap;
UINT8 *dest;
UINT8 *dsrc;
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height;
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.width;
size_t count = (ds_x2 - ds_x1 + 1);
@ -1345,8 +1345,8 @@ void R_DrawWaterSpan_NPO2_8(void)
source = ds_source;
colormap = ds_colormap;
dest = ylookup[ds_y] + columnofs[ds_x1];
dsrc = screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1;
dest = &topleft[ds_x1*vid.height + ds_y];
dsrc = screens[1] + ds_x1*vid.height + (ds_y+ds_bgofs);
fixedwidth = ds_flatwidth << FRACBITS;
fixedheight = ds_flatheight << FRACBITS;
@ -1381,7 +1381,9 @@ void R_DrawWaterSpan_NPO2_8(void)
x = (xposition >> FRACBITS);
y = (yposition >> FRACBITS);
*dest++ = colormap[*(ds_transmap + (source[((y * ds_flatwidth) + x)] << 8) + *dsrc++)];
*dest = colormap[*(ds_transmap + (source[((y * ds_flatwidth) + x)] << 8) + *dsrc)];
dest += vid.height;
dsrc += vid.height;
xposition += xstep;
yposition += ystep;
}
@ -1418,8 +1420,8 @@ void R_DrawTiltedWaterSpan_NPO2_8(void)
uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx);
vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx);
dest = ylookup[ds_y] + columnofs[ds_x1];
dsrc = screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1;
dest = &topleft[ds_x1*vid.height + ds_y];
dsrc = screens[1] + ds_x1*vid.height + (ds_y+ds_bgofs);
source = ds_source;
//colormap = ds_colormap;
@ -1448,9 +1450,10 @@ void R_DrawTiltedWaterSpan_NPO2_8(void)
else
y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight;
*dest = *(ds_transmap + (colormap[source[((y * ds_flatwidth) + x)]] << 8) + *dsrc++);
*dest = *(ds_transmap + (colormap[source[((y * ds_flatwidth) + x)]] << 8) + *dsrc);
}
dest++;
dest += vid.height;
dsrc += vid.height;
iz += ds_szp->x;
uz += ds_sup->x;
vz += ds_svp->x;
@ -1498,9 +1501,10 @@ void R_DrawTiltedWaterSpan_NPO2_8(void)
else
y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight;
*dest = *(ds_transmap + (colormap[source[((y * ds_flatwidth) + x)]] << 8) + *dsrc++);
*dest = *(ds_transmap + (colormap[source[((y * ds_flatwidth) + x)]] << 8) + *dsrc);
}
dest++;
dest += vid.height;
dsrc += vid.height;
u += stepu;
v += stepv;
}
@ -1530,7 +1534,7 @@ void R_DrawTiltedWaterSpan_NPO2_8(void)
else
y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight;
*dest = *(ds_transmap + (colormap[source[((y * ds_flatwidth) + x)]] << 8) + *dsrc++);
*dest = *(ds_transmap + (colormap[source[((y * ds_flatwidth) + x)]] << 8) + *dsrc);
}
}
else
@ -1567,9 +1571,10 @@ void R_DrawTiltedWaterSpan_NPO2_8(void)
else
y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight;
*dest = *(ds_transmap + (colormap[source[((y * ds_flatwidth) + x)]] << 8) + *dsrc++);
*dest = *(ds_transmap + (colormap[source[((y * ds_flatwidth) + x)]] << 8) + *dsrc);
}
dest++;
dest += vid.height;
dsrc += vid.height;
u += stepu;
v += stepv;
}

View file

@ -688,15 +688,7 @@ void R_DrawMaskedColumn(column_t *column)
dc_texturemid = basetexturemid - (topdelta<<FRACBITS);
// Drawn by R_DrawColumn.
// This stuff is a likely cause of the splitscreen water crash bug.
// FIXTHIS: Figure out what "something more proper" is and do it.
// quick fix... something more proper should be done!!!
if (ylookup[dc_yl])
colfunc();
#ifdef PARANOIA
else
I_Error("R_DrawMaskedColumn: Invalid ylookup for dc_yl %d", dc_yl);
#endif
colfunc();
}
column = (column_t *)((UINT8 *)column + column->length + 4);
}
@ -755,12 +747,8 @@ void R_DrawFlippedMaskedColumn(column_t *column)
dc_texturemid = basetexturemid - (topdelta<<FRACBITS);
// Still drawn by R_DrawColumn.
if (ylookup[dc_yl])
colfunc();
#ifdef PARANOIA
else
I_Error("R_DrawMaskedColumn: Invalid ylookup for dc_yl %d", dc_yl);
#endif
colfunc();
Z_Free(dc_source);
}
column = (column_t *)((UINT8 *)column + column->length + 4);

View file

@ -259,7 +259,7 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen, SDL_bool
sw_texture_format = SDL_PIXELFORMAT_RGBA8888;
}
texture = SDL_CreateTexture(renderer, sw_texture_format, SDL_TEXTUREACCESS_STREAMING, width, height);
texture = SDL_CreateTexture(renderer, sw_texture_format, SDL_TEXTUREACCESS_STREAMING, height, width);
// Set up SW surface
if (vidSurface != NULL)
@ -272,7 +272,7 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen, SDL_bool
vid.buffer = NULL;
}
SDL_PixelFormatEnumToMasks(sw_texture_format, &bpp, &rmask, &gmask, &bmask, &amask);
vidSurface = SDL_CreateRGBSurface(0, width, height, bpp, rmask, gmask, bmask, amask);
vidSurface = SDL_CreateRGBSurface(0, height, width, bpp, rmask, gmask, bmask, amask);
}
}
@ -1227,6 +1227,7 @@ static inline boolean I_SkipFrame(void)
// I_FinishUpdate
//
static SDL_Rect src_rect = { 0, 0, 0, 0 };
static SDL_Rect dst_rect = { 0, 0, 0, 0 };
void I_FinishUpdate(void)
{
@ -1268,7 +1269,7 @@ void I_FinishUpdate(void)
}
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, texture, &src_rect, NULL);
SDL_RenderCopyEx(renderer, texture, NULL, &dst_rect, 90.0, NULL, SDL_FLIP_VERTICAL);
SDL_RenderPresent(renderer);
}
#ifdef HWRENDER
@ -1663,8 +1664,13 @@ INT32 VID_SetMode(INT32 modeNum)
vid.modenum = modeNum;
//Impl_SetWindowName("SRB2 "VERSIONSTRING);
src_rect.w = vid.width;
src_rect.h = vid.height;
src_rect.w = vid.height;
src_rect.h = vid.width;
dst_rect.x = (vid.width - vid.height) / 2;
dst_rect.y = (vid.height - vid.width) / 2;
dst_rect.w = vid.height;
dst_rect.h = vid.width;
refresh_rate = VID_GetRefreshRate();
@ -1741,12 +1747,12 @@ static void Impl_VideoSetupSDLBuffer(void)
// Set up the SDL palletized buffer (copied to vidbuffer before being rendered to texture)
if (vid.bpp == 1)
{
bufSurface = SDL_CreateRGBSurfaceFrom(screens[0],vid.width,vid.height,8,
bufSurface = SDL_CreateRGBSurfaceFrom(screens[0],vid.height,vid.width,8,
(int)vid.rowbytes,0x00000000,0x00000000,0x00000000,0x00000000); // 256 mode
}
else if (vid.bpp == 2) // Fury -- don't think this is used at all anymore
{
bufSurface = SDL_CreateRGBSurfaceFrom(screens[0],vid.width,vid.height,15,
bufSurface = SDL_CreateRGBSurfaceFrom(screens[0],vid.height,vid.width,15,
(int)vid.rowbytes,0x00007C00,0x000003E0,0x0000001F,0x00000000); // 555 mode
}
if (bufSurface)
@ -1762,11 +1768,11 @@ static void Impl_VideoSetupSDLBuffer(void)
static void Impl_VideoSetupBuffer(void)
{
// Set up game's software render buffer
vid.rowbytes = vid.width * vid.bpp;
vid.rowbytes = vid.height * vid.bpp;
vid.direct = NULL;
if (vid.buffer)
free(vid.buffer);
vid.buffer = calloc(vid.rowbytes*vid.height, NUMSCREENS);
vid.buffer = calloc(vid.rowbytes*vid.width, NUMSCREENS);
if (!vid.buffer)
{
I_Error("%s", M_GetText("Not enough memory for video buffer\n"));

View file

@ -460,6 +460,7 @@ static void CV_constextsize_OnChange(void)
void VID_BlitLinearScreen(const UINT8 *srcptr, UINT8 *destptr, INT32 width, INT32 height, size_t srcrowbytes,
size_t destrowbytes)
{
#if 0
if (srcrowbytes == destrowbytes)
M_Memcpy(destptr, srcptr, srcrowbytes * height);
else
@ -472,6 +473,14 @@ void VID_BlitLinearScreen(const UINT8 *srcptr, UINT8 *destptr, INT32 width, INT3
srcptr += srcrowbytes;
}
}
#else
(void)srcptr;
(void)destptr;
(void)width;
(void)height;
(void)srcrowbytes;
(void)destrowbytes;
#endif
}
static UINT8 hudplusalpha[11] = { 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0};
@ -514,7 +523,8 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca
UINT8 perplayershuffle = 0;
if (rendermode == render_none)
// if (rendermode == render_none)
if (true)
return;
#ifdef HWRENDER
@ -797,7 +807,8 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, IN
UINT8 perplayershuffle = 0;
if (rendermode == render_none)
// if (rendermode == render_none)
if (true)
return;
#ifdef HWRENDER
@ -1166,7 +1177,8 @@ void V_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c)
UINT8 perplayershuffle = 0;
if (rendermode == render_none)
// if (rendermode == render_none)
if (true)
return;
#ifdef HWRENDER
@ -1363,7 +1375,8 @@ void V_DrawFillConsoleMap(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c)
UINT32 alphalevel = 0;
UINT8 perplayershuffle = 0;
if (rendermode == render_none)
// if (rendermode == render_none)
if (true)
return;
#ifdef HWRENDER
@ -1558,7 +1571,8 @@ void V_DrawFadeFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c, UINT16 color, U
UINT8 *fadetable;
UINT8 perplayershuffle = 0;
if (rendermode == render_none)
// if (rendermode == render_none)
if (true)
return;
#ifdef HWRENDER
@ -1797,6 +1811,7 @@ void V_DrawPatchFill(patch_t *pat)
//
void V_DrawFadeScreen(UINT16 color, UINT8 strength)
{
#if 0
#ifdef HWRENDER
if (rendermode == render_opengl)
{
@ -1819,11 +1834,16 @@ void V_DrawFadeScreen(UINT16 color, UINT8 strength)
for (; buf < deststop; ++buf)
*buf = fadetable[*buf];
}
#else
(void)color;
(void)strength;
#endif
}
// Simple translucency with one color, over a set number of lines starting from the top.
void V_DrawFadeConsBack(INT32 plines)
{
#if 0
UINT8 *deststop, *buf;
#ifdef HWRENDER // not win32 only 19990829 by Kin
@ -1840,6 +1860,9 @@ void V_DrawFadeConsBack(INT32 plines)
deststop = screens[0] + vid.rowbytes * min(plines, vid.height);
for (buf = screens[0]; buf < deststop; ++buf)
*buf = consolebgmap[*buf];
#else
(void)plines;
#endif
}
// Very similar to F_DrawFadeConsBack, except we draw from the middle(-ish) of the screen to the bottom.
@ -3722,7 +3745,7 @@ void V_Init(void)
{
INT32 i;
UINT8 *base = vid.buffer;
const INT32 screensize = vid.rowbytes * vid.height;
const INT32 screensize = vid.rowbytes * vid.width;
LoadMapPalette();