Compare commits

...
Author SHA1 Message Date
Alug d122f80d53 cache vid.height 2025-10-11 21:20:42 +02:00
indev ab4a4ae42f Update VHS effect for transposed drawing 2025-10-11 21:11:00 +03:00
Alug f9b6e94744 style fix 2025-10-11 17:35:22 +02:00
Alug 80bbf1c777 fix intermission background 2025-10-11 17:32:52 +02:00
Alug 9d18846134 move "newview sky" check before skyplane loop
saves us some pointless work going through all planes if we dont need to draw the sky
2025-10-10 23:37:13 +02:00
Alug 93c4278753 double kSpanTaskGranularity
seems to slightly speed up spans now
2025-10-10 23:32:35 +02:00
Alug 38c2648cce fix compiler warning 2025-10-10 23:03:40 +02:00
Alug 2a9bce9481 remove stride variable from column drawers
not needed since we increment per pixel now
also inlines the drawpixel stuff
2025-10-10 23:02:37 +02:00
Alug ad7c6b711f Merge branch 'Saturn-Next' into transposesoft 2025-10-10 22:42:07 +02:00
indev f2aafbb8f6 Fix V_FLIP handling for V_DrawStretchyFixedPatch 2025-10-10 23:32:23 +03:00
indev 4b125a3446 Fix POSTIMG_MIRROR and POSTIMG_FLIP (POSTIMG_MIRROR|POSTIMG_FLIP don't need to be changed) 2025-10-10 23:02:41 +03:00
Alug 5b3d6a4ff8 size_t deez 2025-10-10 22:02:46 +02:00
Alug 65b41cc59f merge I_ReadScreen loops
both did the same thing
2025-10-10 21:52:50 +02:00
Alug 5baaa3207d fix gif recording 2025-10-10 21:49:29 +02:00
Alug 5164628b6b fix wipes 2025-10-10 21:44:33 +02:00
Alug 8434c29d47 use the other titled span drawer loop + fix warnings
seems to be faster in this case
2025-10-10 21:38:35 +02:00
Alug e85d8d6185 fix most things
fix patch drawers mostly (V_FLIP seems broken)
fix VID_BlitLinearScreen
fix wöter ripples
fix screenshots

gif recording is still wonky, but atleast doesent draw complete garbage
wipes are still broken
flipcam and encore aswell
2025-10-10 21:22:01 +02:00
Alug f10470fadf WIP: transpose software renderer
so far, level renders correctly
some patches also render correctly
everything else is still broken
2025-10-10 20:18:19 +02:00
10 changed files with 303 additions and 206 deletions

No files matched your search

+1 -1
View File
@@ -785,7 +785,7 @@ static void AM_drawPixel(INT32 xx, INT32 yy, INT32 cc)
{
if (xx < 0 || yy < 0 || xx >= f_w || yy >= f_h)
return; // off the screen
am_buf[(yy*f_w) + xx] = cc;
am_buf[(xx*f_h) + yy] = cc;
}
//
+1 -1
View File
@@ -609,7 +609,7 @@ static boolean D_Display(void)
{
if (rendermode == render_soft)
{
VID_BlitLinearScreen(vid.screens[0], vid.screens[1], vid.width, vid.height, vid.width, vid.width);
VID_BlitLinearScreen(vid.screens[0], vid.screens[1], vid.width, vid.height, vid.height, vid.height);
}
lastdraw = false;
+10 -10
View File
@@ -249,16 +249,16 @@ static void F_DoWipe(fademask_t *fademask)
draw_linestart = scrypos[masky];
draw_lineend = scrypos[masky + 1];
relativepos = (draw_linestart * vid.width) + draw_rowstart;
draw_linestogo = draw_lineend - draw_linestart;
relativepos = (draw_rowstart * vid.height) + draw_linestart;
draw_linestogo = draw_rowend - draw_rowstart;
if (*mask == 0)
{
// shortcut - memcpy source to work
while (draw_linestogo--)
{
M_Memcpy(w_base+relativepos, s_base+relativepos, draw_rowend-draw_rowstart);
relativepos += vid.width;
M_Memcpy(w_base+relativepos, s_base+relativepos, draw_lineend-draw_linestart);
relativepos += vid.height;
}
}
else if (*mask == 10)
@@ -266,8 +266,8 @@ static void F_DoWipe(fademask_t *fademask)
// shortcut - memcpy target to work
while (draw_linestogo--)
{
M_Memcpy(w_base+relativepos, e_base+relativepos, draw_rowend-draw_rowstart);
relativepos += vid.width;
M_Memcpy(w_base+relativepos, e_base+relativepos, draw_lineend-draw_linestart);
relativepos += vid.height;
}
}
else
@@ -281,12 +281,12 @@ static void F_DoWipe(fademask_t *fademask)
w = w_base + relativepos;
s = s_base + relativepos;
e = e_base + relativepos;
draw_rowstogo = draw_rowend - draw_rowstart;
draw_rowstogo = draw_lineend - draw_linestart;
while (draw_rowstogo--)
*w++ = transtbl[ ( *e++ << 8 ) + *s++ ];
relativepos += vid.width;
relativepos += vid.height;
}
// END DRAWING LOOP
}
@@ -314,7 +314,7 @@ void F_WipeStartScreen(void)
}
#endif
wipe_scr_start = vid.screens[3];
I_ReadScreen(wipe_scr_start, 1);
M_Memcpy(wipe_scr_start, vid.screens[0], vid.width*vid.height);
#endif
}
@@ -331,7 +331,7 @@ void F_WipeEndScreen(void)
}
#endif
wipe_scr_end = vid.screens[4];
I_ReadScreen(wipe_scr_end, 1);
M_Memcpy(wipe_scr_end, vid.screens[0], vid.width*vid.height);
V_DrawBlock(0, 0, 0, vid.width, vid.height, wipe_scr_start);
#endif
}
+1 -1
View File
@@ -30,7 +30,7 @@ extern INT32 linesize;
FUNCINLINE static ATTRINLINE UINT8 *R_Address(INT32 px, INT32 py)
{
return renderscreen + (py + viewwindowy) * linesize + (viewwindowx + px);
return renderscreen + (py + viewwindowy) + (viewwindowx + px) * vid.height;
}
+13 -12
View File
@@ -31,7 +31,8 @@ enum DrawColumnType
};
template<DrawColumnType Type>
static constexpr UINT8 R_GetColumnTranslated(drawcolumndata_t* dc, UINT8 col, const UINT8 * restrict colormap)
FUNCINLINE static ATTRINLINE constexpr UINT8
R_GetColumnTranslated(drawcolumndata_t* dc, UINT8 col, const UINT8 * restrict colormap)
{
if constexpr (Type & DrawColumnType::DC_COLORMAP)
{
@@ -42,7 +43,8 @@ static constexpr UINT8 R_GetColumnTranslated(drawcolumndata_t* dc, UINT8 col, co
}
template<DrawColumnType Type>
static constexpr UINT8 R_GetColumnTranslucent(drawcolumndata_t* dc, UINT8 * restrict dest, UINT8 col, const UINT8 * restrict colormap)
FUNCINLINE static ATTRINLINE constexpr UINT8
R_GetColumnTranslucent(drawcolumndata_t* dc, UINT8 * restrict dest, UINT8 col, const UINT8 * restrict colormap)
{
col = R_GetColumnTranslated<Type>(dc, col, colormap);
@@ -57,7 +59,8 @@ static constexpr UINT8 R_GetColumnTranslucent(drawcolumndata_t* dc, UINT8 * rest
}
template<DrawColumnType Type>
static constexpr UINT8 R_DrawColumnPixel(drawcolumndata_t* dc, UINT8 * restrict dest, UINT32 bit, const UINT8 * restrict source, const UINT8 * restrict colormap)
FUNCINLINE static ATTRINLINE constexpr UINT8
R_DrawColumnPixel(drawcolumndata_t* dc, UINT8 * restrict dest, UINT32 bit, const UINT8 * restrict source, const UINT8 * restrict colormap)
{
UINT8 col = source[bit];
@@ -187,7 +190,6 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc)
const intptr_t heightmask = dc->sourcelength-1;
constexpr INT32 npow2min = -1;
const INT32 npow2max = dc->sourcelength;
const INT32 stride = vid.width;
const UINT8 * restrict source = dc->source;
const lighttable_t * restrict colormap = dc->colormap;
@@ -208,12 +210,12 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc)
while(count--)
{
*dest = R_DrawColumnPixel<Type>(dc, dest, (frac>>FRACBITS) & heightmask, source, colormap);
dest += stride;
dest++;
frac += fracstep;
}
}
break;
case -1:
case npow2min:
{
if (frac < 0)
// adjust in case we underread
@@ -223,7 +225,7 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc)
while (--count >= 0)
{
*dest = R_DrawColumnPixel<Type>(dc, dest, frac>>FRACBITS, source, colormap);
dest += stride;
dest++;
frac += fracstep;
}
}
@@ -235,11 +237,11 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc)
while ((count -= 2) >= 0) // texture height is a power of 2 -- killough
{
*dest = R_DrawColumnPixel<Type>(dc, dest, (frac>>FRACBITS) & heightmask, source, colormap);
dest += stride;
dest++;
frac += fracstep;
*dest = R_DrawColumnPixel<Type>(dc, dest, (frac>>FRACBITS) & heightmask, source, colormap);
dest += stride;
dest++;
frac += fracstep;
}
@@ -277,7 +279,7 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc)
// and a few bytes after as well
*dest = R_DrawColumnPixel<Type>(dc, dest, CLAMP((frac >> FRACBITS), npow2min, npow2max), source, colormap);
dest += stride;
dest++;
#if __SIZEOF_POINTER__ < 8 // 64-bit systems have large enough numbers for this to be a non-issue
// Avoid overflow.
@@ -343,7 +345,6 @@ void R_DrawFogColumn(drawcolumndata_t* dc)
// Framebuffer destination address.
dest = R_Address(dc->x, dc->yl);
const INT32 stride = vid.width;
const lighttable_t * restrict colormap = dc->colormap;
// Determine scaling, which is the only mapping to be done.
@@ -351,6 +352,6 @@ void R_DrawFogColumn(drawcolumndata_t* dc)
{
// Simple. Apply the colormap to what's already on the screen.
*dest = colormap[*dest];
dest += stride;
dest++;
} while (count--);
}
+45 -25
View File
@@ -50,7 +50,8 @@ enum DrawSpanType
};
template<DrawSpanType Type>
static constexpr UINT8 R_GetSpanTranslated(drawspandata_t* ds, UINT8 col)
FUNCINLINE static ATTRINLINE constexpr UINT8
R_GetSpanTranslated(drawspandata_t* ds, UINT8 col)
{
if constexpr (Type & DrawSpanType::DS_COLORMAP)
{
@@ -63,7 +64,8 @@ static constexpr UINT8 R_GetSpanTranslated(drawspandata_t* ds, UINT8 col)
}
template<DrawSpanType Type>
static constexpr UINT8 R_GetSpanTranslucent(drawspandata_t* ds, UINT8 *dsrc, const UINT8 *colormap, UINT8 col)
FUNCINLINE static ATTRINLINE constexpr UINT8
R_GetSpanTranslucent(drawspandata_t* ds, UINT8 *dsrc, const UINT8 *colormap, UINT8 col)
{
col = colormap[R_GetSpanTranslated<Type>(ds, col)];
@@ -78,7 +80,8 @@ static constexpr UINT8 R_GetSpanTranslucent(drawspandata_t* ds, UINT8 *dsrc, con
}
template<DrawSpanType Type>
static constexpr UINT8 R_DrawSpanPixel(drawspandata_t* ds, UINT8 *dsrc, const UINT8 *colormap, UINT32 bit, const UINT8 *source)
FUNCINLINE static ATTRINLINE constexpr UINT8
R_DrawSpanPixel(drawspandata_t* ds, UINT8 *dsrc, const UINT8 *colormap, UINT32 bit, const UINT8 *source)
{
UINT8 col = source[bit];
@@ -107,15 +110,17 @@ static void R_DrawSpanTemplate(drawspandata_t* ds)
UINT8 * restrict dest = R_Address(ds->x1, ds->y);
UINT8 * restrict dsrc;
const UINT8 * restrict deststop = vid.screens[0] + vid.width * vid.height;
const UINT8 * restrict deststop = vid.screens[0] + vid.height *vid.width;
if (dest+8 > deststop)
if (dest > deststop)
{
return;
}
intptr_t count = (ds->x2 - ds->x1 + 1);
size_t i;
//size_t i;
const INT32 stride = vid.height;
xposition = ds->xfrac; yposition = ds->yfrac;
xstep = ds->xstep; ystep = ds->ystep;
@@ -140,14 +145,14 @@ static void R_DrawSpanTemplate(drawspandata_t* ds)
if constexpr (Type & DS_RIPPLE)
{
dsrc = vid.screens[1] + (ds->y + ds->bgofs) * vid.width + ds->x1;
dsrc = vid.screens[1] + (ds->y + ds->bgofs) + ds->x1 * vid.height;
}
else
{
dsrc = dest;
}
while (count >= 8)
/*while (count >= 8)
{
// SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't
// have the uber complicated math to calculate it now, so that was a memory write we didn't
@@ -167,7 +172,7 @@ static void R_DrawSpanTemplate(drawspandata_t* ds)
dsrc += 8;
count -= 8;
}
}*/
while (count-- && dest <= deststop)
{
@@ -175,8 +180,8 @@ static void R_DrawSpanTemplate(drawspandata_t* ds)
*dest = R_DrawSpanPixel<Type>(ds, dsrc, colormap, bit, source);
dest++;
dsrc++;
dest += stride;
dsrc += stride;
xposition += xstep;
yposition += ystep;
@@ -235,11 +240,11 @@ static void R_DrawTiltedSpanTemplate(drawspandata_t* ds)
UINT32 stepu, stepv;
UINT32 bit;
INT32 x1 = ds->x1;
//INT32 x1 = ds->x1;
const INT32 nflatxshift = ds->nflatxshift;
const INT32 nflatyshift = ds->nflatyshift;
const INT32 nflatmask = ds->nflatmask;
const INT32 stride = vid.width;
const INT32 stride = vid.height;
local_for_thread std::vector<INT32> tiltlighting;
iz = ds->szp.z + ds->szp.y*(centery-ds->y) + ds->szp.x*(ds->x1-centerx);
@@ -255,7 +260,7 @@ static void R_DrawTiltedSpanTemplate(drawspandata_t* ds)
if constexpr (Type & DS_RIPPLE)
{
dsrc = vid.screens[1] + (ds->y + ds->bgofs) * stride + ds->x1;
dsrc = vid.screens[1] + (ds->y + ds->bgofs) + ds->x1 * stride;
}
else
{
@@ -307,18 +312,31 @@ static void R_DrawTiltedSpanTemplate(drawspandata_t* ds)
u = (INT64)(startu);
v = (INT64)(startv);
x1 = ds->x1;
//x1 = ds->x1;
for (i = 0; i < SPANSIZE; i++)
// not sure which one does a better job
for (i = SPANSIZE-1; i >= 0; i--)
{
bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift);
colormap = ds->planezlight[tiltlighting[ds->x1++]] + (ds->colormap - colormaps);
*dest = R_DrawSpanPixel<Type>(ds, dsrc, colormap, bit, source);
dest += stride;
dsrc += stride;
u += stepu;
v += stepv;
}
/*for (i = 0; i < SPANSIZE; i++)
{
bit = (((v + stepv * i) >> nflatyshift) & nflatmask) | ((u + stepu * i) >> nflatxshift);
colormap = ds->planezlight[tiltlighting[x1 + i]] + (ds->colormap - colormaps);
dest[i] = R_DrawSpanPixel<Type>(ds, &dsrc[i], colormap, bit, source);
dest[i * stride] = R_DrawSpanPixel<Type>(ds, &dsrc[i * stride], colormap, bit, source);
}
ds->x1 += SPANSIZE;
dest += SPANSIZE;
dsrc += SPANSIZE;
dest += SPANSIZE * stride;
dsrc += SPANSIZE * stride;*/
startu = endu;
startv = endv;
width -= SPANSIZE;
@@ -356,9 +374,9 @@ static void R_DrawTiltedSpanTemplate(drawspandata_t* ds)
bit = ((v >> ds->nflatyshift) & ds->nflatmask) | (u >> ds->nflatxshift);
colormap = ds->planezlight[tiltlighting[ds->x1]] + (ds->colormap - colormaps);
*dest = R_DrawSpanPixel<Type>(ds, dsrc, colormap, bit, source);
dest++;
dest += stride;
dsrc += stride;
ds->x1++;
dsrc++;
u += stepu;
v += stepv;
}
@@ -394,7 +412,9 @@ void R_DrawFogSpan(drawspandata_t* ds)
intptr_t count = ds->x2 - ds->x1 + 1;
while (count >= 4)
const INT32 stride = vid.height;
/*while (count >= 4)
{
dest[0] = colormap[dest[0]];
dest[1] = colormap[dest[1]];
@@ -403,12 +423,12 @@ void R_DrawFogSpan(drawspandata_t* ds)
dest += 4;
count -= 4;
}
}*/
while (count--)
{
*dest = colormap[*dest];
dest++;
dest += stride;
}
}
@@ -429,7 +449,7 @@ void R_DrawFogSpan_Tilted(drawspandata_t* ds)
{
UINT8 *colormap = ds->planezlight[tiltlighting[ds->x1++]] + (ds->colormap - colormaps);
*dest = colormap[*dest];
dest++;
dest += stride;
}
while (--width >= 0);
}
+17 -15
View File
@@ -630,8 +630,9 @@ static void R_MakeSpans(void (*mapfunc)(drawspandata_t* ds, void(*spanfunc)(draw
// coarse enough to not be too slow due to task scheduling overhead.
// To safely do this, we need to copy part of spanstart to a local.
// This is essentially loop unrolling across threads.
constexpr const int kSpanTaskGranularity = 8;
constexpr const int kSpanTaskGranularity = 16;
drawspandata_t ds_copy = *ds;
while (t1 < t2 && t1 <= b1)
{
INT32 spanstartcopy[kSpanTaskGranularity] = {0};
@@ -749,6 +750,13 @@ void R_DrawSkyPlanes(void)
visplane_t *pl;
INT32 i;
// If we're not supposed to draw the sky (e.g. for skyboxes), don't do anything!
// This probably utterly ruins sky rendering for FOFs and polyobjects, unfortunately
if (!newview->sky)
{
return;
}
#ifdef HAVE_THREADS
srb2::ThreadPool::Sema tp_sema;
srb2::g_main_threadpool->begin_sema();
@@ -777,13 +785,6 @@ static void R_DrawSkyPlane(visplane_t *pl, void(*colfunc2)(drawcolumndata_t*), b
if (!(pl->minx <= pl->maxx))
return;
// If we're not supposed to draw the sky (e.g. for skyboxes), don't do anything!
// This probably utterly ruins sky rendering for FOFs and polyobjects, unfortunately
if (!newview->sky)
{
return;
}
drawcolumndata_t dc = {};
const INT32 texture = texturetranslation[skytexture];
@@ -813,12 +814,12 @@ static void R_DrawSkyPlane(visplane_t *pl, void(*colfunc2)(drawcolumndata_t*), b
R_CheckTextureCache(texture);
#ifdef HAVE_THREADS
// Tune concurrency granularity here to maximize throughput
// The cheaper colfunc is, the more coarse the task should be
constexpr const int kSkyPlaneMacroColumns = 8;
while (x <= pl->maxx)
{
// Tune concurrency granularity here to maximize throughput
// The cheaper colfunc is, the more coarse the task should be
constexpr const int kSkyPlaneMacroColumns = 8;
auto thunk = [=]() mutable -> void {
for (int i = 0; i < kSkyPlaneMacroColumns && i + x <= pl->maxx; i++)
{
@@ -1156,13 +1157,14 @@ void R_DrawSinglePlane(drawspandata_t* ds, visplane_t *pl, boolean allow_paralle
}
}
offset = (scry*vid.width) + scrx;
//offset = (scry*vid.width) + scrx;
offset = (scrx*vid.height) + scry;
// No idea if this works
VID_BlitLinearScreen(renderscreen + offset,
vid.screens[1] + (top*vid.width), // intentionally not +offset
vid.screens[1] + top, // intentionally not +offset
viewwidth, bottom-top,
vid.width, vid.width);
vid.height, vid.height);
}
}
}
+18 -10
View File
@@ -1304,7 +1304,7 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
SDL_DestroyTexture(texture);
}
texture = SDL_CreateTexture(renderer, sw_texture_format, SDL_TEXTUREACCESS_STREAMING, width, height);
texture = SDL_CreateTexture(renderer, sw_texture_format, SDL_TEXTUREACCESS_STREAMING, height, width);
}
}
@@ -1339,6 +1339,7 @@ void I_UpdateNoBlit(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)
{
@@ -1368,13 +1369,13 @@ void I_FinishUpdate(void)
void *pixels;
int pitch;
SDL_LockTexture(texture, NULL, &pixels, &pitch);
int step = pitch / 4 - vid.width;
int step = pitch / 4 - vid.height;
UINT32 *restrict dst = pixels;
UINT8 *restrict src = vid.screens[0];
UINT32 *restrict palette = localPalette;
for (INT32 y = 0; y < vid.height; y++)
for (INT32 y = 0; y < vid.width; y++)
{
UINT8 *restrict end = src + vid.width;
UINT8 *restrict end = src + vid.height;
do *dst++ = palette[*src++];
while (src < end);
dst += step;
@@ -1382,7 +1383,8 @@ void I_FinishUpdate(void)
SDL_UnlockTexture(texture);
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, texture, &src_rect, NULL);
//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
@@ -1413,18 +1415,17 @@ void I_ReadScreen(UINT8 * restrict scr, INT32 scale)
{
if (rendermode != render_soft)
I_Error("I_ReadScreen: called while in non-software mode");
else if (scale == 1)
VID_BlitLinearScreen(vid.screens[0], scr, vid.width, vid.height, vid.width, vid.width);
else
{
UINT8 * restrict source = vid.screens[0];
uintptr_t w = vid.width/scale*scale, h = vid.height/scale*scale;
// size_t saves a lea + movsxd over INT32. mind your types!
// uintptr_t is even better since it's guaranteed to be the size of a pointer
for (uintptr_t y = 0; y < h; y += scale)
for (uintptr_t x = 0; x < w; x += scale)
*scr++ = source[y*vid.width + x];
*scr++ = source[x*vid.height + y];
}
}
@@ -1562,8 +1563,15 @@ INT32 VID_SetMode(INT32 modeNum)
SDLSetMode(vid.width, vid.height, USE_FULLSCREEN);
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();
+196 -130
View File
@@ -614,9 +614,9 @@ static void CV_constextsize_OnChange(void)
// --------------------------------------------------------------------------
void VID_BlitLinearScreen(const UINT8 *restrict srcptr, UINT8 *restrict destptr, INT32 width, INT32 height, size_t srcrowbytes, size_t destrowbytes)
{
if (srcrowbytes == destrowbytes && srcrowbytes == (size_t)width)
if (srcrowbytes == destrowbytes && srcrowbytes == (size_t)height)
{
size_t i = srcrowbytes * height;
size_t i = srcrowbytes * width;
#if defined(__SSE__)
while (i >= 16)
{
@@ -631,9 +631,9 @@ void VID_BlitLinearScreen(const UINT8 *restrict srcptr, UINT8 *restrict destptr,
}
else
{
while (height--)
while (width--)
{
M_Memcpy(destptr, srcptr, width);
M_Memcpy(destptr, srcptr, height);
destptr += destrowbytes;
srcptr += srcrowbytes;
@@ -663,7 +663,7 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca
fixed_t col, ofs, colfrac, rowfrac, fdup, vdup;
INT32 dup;
const column_t *column;
UINT8 *desttop, *dest, *deststart, *destend;
UINT8 *desttop, *dest/*, *deststart, *destend*/;
const UINT8 *source, *deststop;
fixed_t pwidth; // patch width
fixed_t offx = 0; // x offset
@@ -791,13 +791,10 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca
if (!desttop)
return;
deststop = desttop + vid.width * vid.height;
if (scrn & V_NOSCALESTART)
{
x >>= FRACBITS;
y >>= FRACBITS;
desttop += (y*vid.width) + x;
}
else
{
@@ -843,9 +840,8 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca
y += (vid.height - (BASEVIDHEIGHT * dup)) / 2;
}
}
desttop += (y*vid.width) + x;
}
desttop += (x*vid.height) + y;
if (pscale != FRACUNIT) // scale width properly
{
@@ -857,29 +853,29 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca
else
pwidth = patch->width * dup;
deststart = desttop;
destend = desttop + pwidth;
//deststart = desttop;
//destend = desttop + pwidth*vid.height;
const INT32 stride = vid.width;
for (col = 0; (col>>FRACBITS) < patch->width; col += colfrac, ++offx, desttop++)
for (col = 0; (col>>FRACBITS) < patch->width; col += colfrac, ++offx, desttop += vid.height)
{
INT32 topdelta, prevdelta = -1;
if (scrn & V_FLIP) // offx is measured from right edge instead of left
{
if (x+pwidth-offx < 0) // don't draw off the left of the screen (WRAP PREVENTION)
break;
if (x+pwidth-offx >= stride) // don't draw off the right of the screen (WRAP PREVENTION)
if (x+pwidth-offx >= vid.width) // don't draw off the right of the screen (WRAP PREVENTION)
continue;
}
else
{
if (x+offx < 0) // don't draw off the left of the screen (WRAP PREVENTION)
continue;
if (x+offx >= stride) // don't draw off the right of the screen (WRAP PREVENTION)
if (x+offx >= vid.width) // don't draw off the right of the screen (WRAP PREVENTION)
break;
}
column = (const column_t *)((const UINT8 *)(patch->columns) + (patch->columnofs[col>>FRACBITS]));
INT32 realcol = (scrn & V_FLIP) ? ((patch->width-(col>>FRACBITS)-1)<<FRACBITS) : col;
column = (const column_t *)((const UINT8 *)(patch->columns) + (patch->columnofs[realcol>>FRACBITS]));
switch (patchdrawtype)
{
@@ -892,15 +888,16 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca
prevdelta = topdelta;
source = (const UINT8 *)(column) + 3;
dest = desttop;
if (scrn & V_FLIP)
dest = deststart + (destend - desttop);
dest += FixedInt(FixedMul(topdelta<<FRACBITS,vdup))*stride;
dest += FixedInt(FixedMul(topdelta<<FRACBITS,vdup));
for (ofs = 0; dest < deststop && (ofs>>FRACBITS) < column->length; ofs += rowfrac)
UINT8 *col_start = vid.screens[0] + ((x + offx)*vid.height);
deststop = col_start + vid.height;
for (ofs = 0; dest < deststop && (size_t)(ofs>>FRACBITS) < column->length; ofs += rowfrac)
{
if (dest >= vid.screens[scrn&V_PARAMMASK]) // don't draw off the top of the screen (CRASH PREVENTION)
if (dest >= col_start) // don't draw off the top of the screen (CRASH PREVENTION)
*dest = source[ofs>>FRACBITS];
dest += stride;
dest++;
}
column = (const column_t *)((const UINT8 *)column + column->length + 4);
}
@@ -915,15 +912,16 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca
prevdelta = topdelta;
source = (const UINT8 *)(column) + 3;
dest = desttop;
if (scrn & V_FLIP)
dest = deststart + (destend - desttop);
dest += FixedInt(FixedMul(topdelta<<FRACBITS,vdup))*stride;
dest += FixedInt(FixedMul(topdelta<<FRACBITS,vdup));
for (ofs = 0; dest < deststop && (ofs>>FRACBITS) < column->length; ofs += rowfrac)
UINT8 *col_start = vid.screens[0] + ((x + offx)*vid.height);
deststop = col_start + vid.height;
for (ofs = 0; dest < deststop && (size_t)(ofs>>FRACBITS) < column->length; ofs += rowfrac)
{
if (dest >= vid.screens[scrn&V_PARAMMASK]) // don't draw off the top of the screen (CRASH PREVENTION)
if (dest >= col_start) // don't draw off the top of the screen (CRASH PREVENTION)
*dest = *(v_colormap + source[ofs>>FRACBITS]);
dest += stride;
dest++;
}
column = (const column_t *)((const UINT8 *)column + column->length + 4);
}
@@ -938,15 +936,16 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca
prevdelta = topdelta;
source = (const UINT8 *)(column) + 3;
dest = desttop;
if (scrn & V_FLIP)
dest = deststart + (destend - desttop);
dest += FixedInt(FixedMul(topdelta<<FRACBITS,vdup))*stride;
dest += FixedInt(FixedMul(topdelta<<FRACBITS,vdup));
for (ofs = 0; dest < deststop && (ofs>>FRACBITS) < column->length; ofs += rowfrac)
UINT8 *col_start = vid.screens[0] + ((x + offx)*vid.height);
deststop = col_start + vid.height;
for (ofs = 0; dest < deststop && (size_t)(ofs>>FRACBITS) < column->length; ofs += rowfrac)
{
if (dest >= vid.screens[scrn&V_PARAMMASK]) // don't draw off the top of the screen (CRASH PREVENTION)
if (dest >= col_start) // don't draw off the top of the screen (CRASH PREVENTION)
*dest = *(v_translevel + ((source[ofs>>FRACBITS]<<8)&0xff00) + (*dest&0xff));
dest += stride;
dest++;
}
column = (const column_t *)((const UINT8 *)column + column->length + 4);
}
@@ -961,15 +960,16 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca
prevdelta = topdelta;
source = (const UINT8 *)(column) + 3;
dest = desttop;
if (scrn & V_FLIP)
dest = deststart + (destend - desttop);
dest += FixedInt(FixedMul(topdelta<<FRACBITS,vdup))*stride;
dest += FixedInt(FixedMul(topdelta<<FRACBITS,vdup));
for (ofs = 0; dest < deststop && (ofs>>FRACBITS) < column->length; ofs += rowfrac)
UINT8 *col_start = vid.screens[0] + ((x + offx)*vid.height);
deststop = col_start + vid.height;
for (ofs = 0; dest < deststop && (size_t)(ofs>>FRACBITS) < column->length; ofs += rowfrac)
{
if (dest >= vid.screens[scrn&V_PARAMMASK]) // don't draw off the top of the screen (CRASH PREVENTION)
if (dest >= col_start) // don't draw off the top of the screen (CRASH PREVENTION)
*dest = *(v_translevel + (((*(v_colormap + source[ofs>>FRACBITS]))<<8)&0xff00) + (*dest&0xff));
dest += stride;
dest++;
}
column = (const column_t *)((const UINT8 *)column + column->length + 4);
}
@@ -1039,13 +1039,10 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_
if (!desttop)
return;
deststop = desttop + vid.width * vid.height;
if (scrn & V_NOSCALESTART)
{
x >>= FRACBITS;
y >>= FRACBITS;
desttop += (y*vid.width) + x;
}
else
{
@@ -1079,20 +1076,18 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_
y += (vid.height - (BASEVIDHEIGHT * vid.dup)) / 2;
}
}
desttop += (y*vid.width) + x;
}
const INT32 stride = vid.width;
desttop += (y*vid.width) + x;
for (col = sx<<FRACBITS; (col>>FRACBITS) < patch->width && ((col>>FRACBITS) - sx) < w; col += colfrac, ++x, desttop++)
for (col = sx<<FRACBITS; (col>>FRACBITS) < patch->width && ((col>>FRACBITS) - sx) < w; col += colfrac, ++x, desttop += vid.height)
{
INT32 topdelta, prevdelta = -1;
if (x < 0) // don't draw off the left of the screen (WRAP PREVENTION)
continue;
if (x >= stride) // don't draw off the right of the screen (WRAP PREVENTION)
if (x >= vid.width) // don't draw off the right of the screen (WRAP PREVENTION)
break;
column = (const column_t *)((const UINT8 *)(patch->columns) + (patch->columnofs[col>>FRACBITS]));
@@ -1110,17 +1105,20 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_
dest = desttop;
if (topdelta-sy > 0)
{
dest += FixedInt(FixedMul((topdelta-sy)<<FRACBITS,fdup))*stride;
dest += FixedInt(FixedMul((topdelta-sy)<<FRACBITS,fdup));
ofs = 0;
}
else
ofs = (sy-topdelta)<<FRACBITS;
for (; dest < deststop && (ofs>>FRACBITS) < column->length && (((ofs>>FRACBITS) - sy) + topdelta) < h; ofs += rowfrac)
UINT8 *col_start = vid.screens[0] + (x*vid.height);
deststop = col_start + vid.height;
for (; dest < deststop && (size_t)(ofs>>FRACBITS) < column->length && (((ofs>>FRACBITS) - sy) + topdelta) < h; ofs += rowfrac)
{
if (dest >= vid.screens[scrn&V_PARAMMASK]) // don't draw off the top of the screen (CRASH PREVENTION)
if (dest >= col_start) // don't draw off the top of the screen (CRASH PREVENTION)
*dest = source[ofs>>FRACBITS];
dest += stride;
dest++;
}
column = (const column_t *)((const UINT8 *)column + column->length + 4);
}
@@ -1137,17 +1135,20 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_
dest = desttop;
if (topdelta-sy > 0)
{
dest += FixedInt(FixedMul((topdelta-sy)<<FRACBITS,fdup))*stride;
dest += FixedInt(FixedMul((topdelta-sy)<<FRACBITS,fdup));
ofs = 0;
}
else
ofs = (sy-topdelta)<<FRACBITS;
for (; dest < deststop && (ofs>>FRACBITS) < column->length && (((ofs>>FRACBITS) - sy) + topdelta) < h; ofs += rowfrac)
UINT8 *col_start = vid.screens[0] + (x*vid.height);
deststop = col_start + vid.height;
for (; dest < deststop && (size_t)(ofs>>FRACBITS) < column->length && (((ofs>>FRACBITS) - sy) + topdelta) < h; ofs += rowfrac)
{
if (dest >= vid.screens[scrn&V_PARAMMASK]) // don't draw off the top of the screen (CRASH PREVENTION)
if (dest >= col_start) // don't draw off the top of the screen (CRASH PREVENTION)
*dest = *(v_translevel + ((source[ofs>>FRACBITS]<<8)&0xff00) + (*dest&0xff));
dest += stride;
dest++;
}
column = (const column_t *)((const UINT8 *)column + column->length + 4);
}
@@ -1189,8 +1190,8 @@ void V_DrawBlock(INT32 x, INT32 y, INT32 scrn, INT32 width, INT32 height, const
I_Error("Bad V_DrawBlock");
#endif
dest = vid.screens[scrn] + y*vid.width + x;
deststop = vid.screens[scrn] + vid.width * vid.height;
dest = vid.screens[scrn] + x*vid.height + y;
deststop = vid.screens[scrn] + vid.height * vid.width;
while (height--)
{
@@ -1209,7 +1210,7 @@ void V_DrawBlock(INT32 x, INT32 y, INT32 scrn, INT32 width, INT32 height, const
// alug: now with translucency support X)
void V_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c)
{
UINT8 *dest;
UINT8 *dest, *desttop;
const UINT8 *deststop;
UINT32 alphalevel = ((c & V_ALPHAMASK) >> V_ALPHASHIFT);
@@ -1285,8 +1286,8 @@ void V_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c)
if (y + h > vid.height)
h = vid.height-y;
dest = vid.screens[0] + y*vid.width + x;
deststop = vid.screens[0] + vid.width * vid.height;
dest = desttop = vid.screens[0] + x*vid.height + y;
deststop = vid.screens[0] + vid.height * vid.width;
if (alphalevel)
{
@@ -1312,16 +1313,31 @@ void V_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c)
if (alphalevel)
{
const UINT8 *fadetable = ((UINT8 *)transtables + ((alphalevel-1)<<FF_TRANSSHIFT) + (c*256));
for (;(--h >= 0) && dest < deststop; dest += vid.width)
for (;(--h >= 0) && desttop < deststop; desttop++)
{
for (x = 0; x < w; x++)
dest[x] = fadetable[dest[x]];
dest = desttop;
UINT8 *row_end = dest + (w * vid.height);
while (dest < row_end)
{
*dest = fadetable[*dest];
dest += vid.height;
}
}
}
else
{
for (;(--h >= 0) && dest < deststop; dest += vid.width)
memset(dest, c, w);
for (;(--h >= 0) && desttop < deststop; desttop++)
{
dest = desttop;
UINT8 *row_end = dest + (w * vid.height);
while (dest < row_end)
{
*dest = c;
dest += vid.height;
}
}
}
}
@@ -1367,8 +1383,8 @@ static UINT32 V_GetHWConsBackColor(void)
void V_DrawFillConsoleMap(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c)
{
UINT8 *dest;
INT32 u, v;
UINT8 *dest, *desttop;
INT32 v;
UINT32 alphalevel = 0;
if (rendermode == render_none)
@@ -1435,7 +1451,7 @@ void V_DrawFillConsoleMap(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c)
if (y + h > vid.height)
h = vid.height-y;
dest = vid.screens[0] + y*vid.width + x;
dest = desttop = vid.screens[0] + x*vid.height + y;
if ((alphalevel = ((c & V_ALPHAMASK) >> V_ALPHASHIFT)))
{
@@ -1460,11 +1476,14 @@ void V_DrawFillConsoleMap(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c)
if (!alphalevel)
{
for (v = 0; v < h; v++, dest += vid.width)
for (v = 0; v < h; v++, desttop++)
{
for (u = 0; u < w; u++)
dest = desttop;
UINT8 *row_end = dest + w*vid.height;
while (dest < row_end)
{
dest[u] = consolebgmap[dest[u]];
*dest = consolebgmap[*dest];
dest += vid.height;
}
}
}
@@ -1475,11 +1494,14 @@ void V_DrawFillConsoleMap(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c)
w = clip(w,vid.width);
h = clip(h,vid.height);
#undef clip
for (v = 0; v < h; v++, dest += vid.width)
for (v = 0; v < h; v++, desttop++)
{
for (u = 0; u < w; u++)
dest = desttop;
UINT8 *row_end = dest + w*vid.height;
while (dest < row_end)
{
dest[u] = fadetable[consolebgmap[dest[u]]];
*dest = fadetable[consolebgmap[*dest]];
dest += vid.height;
}
}
}
@@ -1494,7 +1516,8 @@ void V_DrawFillConsoleMap(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c)
//
void V_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 c)
{
UINT8 *dest;
UINT8 *dest, *desttop;
const UINT8 *deststop;
INT32 w, h, wait = 0;
@@ -1569,19 +1592,28 @@ void V_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 c)
if (h > w)
h = w;
dest = vid.screens[0] + y*vid.width + x;
deststop = vid.screens[0] + vid.width * vid.height;
dest = desttop = vid.screens[0] + x*vid.height + y;
deststop = vid.screens[0] + vid.height * vid.width;
c &= 255;
for (;(--h >= 0) && dest < deststop; dest += vid.width)
for (;(--h >= 0) && desttop < deststop; desttop++)
{
memset(dest, c, w);
dest = desttop;
UINT8 *row_end = dest + (w * vid.height);
while (dest < row_end)
{
*dest = c;
dest += vid.height;
}
if (wait)
wait--;
else
w--;
}
}
//
@@ -1592,7 +1624,7 @@ void V_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatnum)
INT32 u, v;
fixed_t dx, dy, xfrac, yfrac;
const UINT8 *src, *deststop;
UINT8 *flat, *dest;
UINT8 *flat, *dest, *desttop;
size_t size, lflatsize, flatshift;
#ifdef HWRENDER
@@ -1639,7 +1671,7 @@ void V_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatnum)
flat = W_CacheLumpNum(flatnum, PU_CACHE);
dest = vid.screens[0] + y*vid.dup*vid.width + x*vid.dup;
dest = desttop = vid.screens[0] + y*vid.dup*vid.width + x*vid.dup;
deststop = vid.screens[0] + vid.width * vid.height;
// from V_DrawScaledPatch
@@ -1663,15 +1695,18 @@ void V_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatnum)
dy = FixedDiv(FRACUNIT, vid.dup<<(FRACBITS-2));
yfrac = 0;
for (v = 0; v < h; v++, dest += vid.width)
for (v = 0; v < h; v++, desttop++)
{
xfrac = 0;
src = flat + (((yfrac>>FRACBITS) & (lflatsize - 1)) << flatshift);
dest = desttop;
for (u = 0; u < w; u++)
{
if (&dest[u] > deststop)
if (dest > deststop)
return;
dest[u] = src[(xfrac>>FRACBITS)&(lflatsize-1)];
*dest = src[(xfrac>>FRACBITS)&(lflatsize-1)];
dest += vid.height;
xfrac += dx;
}
yfrac += dy;
@@ -1743,7 +1778,7 @@ void V_DrawVhsEffect(boolean rewind)
UINT8 *buf = vid.screens[0], *tmp = vid.screens[4];
UINT16 y;
UINT32 x, pos = 0;
INT32 x;
UINT8 *normalmapstart = ((UINT8 *)transtables + (8<<FF_TRANSSHIFT|(19<<8)));
#ifdef HQ_VHS
@@ -1777,32 +1812,40 @@ void V_DrawVhsEffect(boolean rewind)
}
#endif
for (y = 0; y < vid.height; y+=2)
// Since we go through columns now instead of rows, we need to keep same random offset values for each row
// Don't need a random value for each row, just a bunch of values to cycle through will do
#define ROWOFFSLEN 128
SINT8 rowoffs[ROWOFFSLEN];
for (y = 0; y < ROWOFFSLEN; y++)
rowoffs[y] = M_RandomKey(vid.dup<<1);
for (x = 0; x < vid.width; ++x)
{
thismapstart = normalmapstart;
offs = 0;
if (y >= uby && y < uby+barsize)
for (y = 0; y < vid.height; y++)
{
thismapstart -= (2<<FF_TRANSSHIFT) - (5<<8);
offs += updistort * 2.0f * min(y-uby, uby+barsize-y) / barsize;
}
offs = rowoffs[y/2 % ROWOFFSLEN];
if (y >= dby && y < dby+barsize)
{
thismapstart -= (2<<FF_TRANSSHIFT) - (5<<8);
offs -= downdistort * 2.0f * min(y-dby, dby+barsize-y) / barsize;
}
thismapstart = normalmapstart;
offs += M_RandomKey(vid.dup<<1);
if (y >= uby && y < uby+barsize)
{
thismapstart -= (2<<FF_TRANSSHIFT) - (5<<8);
offs += updistort * 2.0f * min(y-uby, uby+barsize-y) / barsize;
}
// lazy way to avoid crashes
if ((y == 0 && offs < 0) || (y >= vid.height-2 && offs > 0))
offs = 0;
if (y >= dby && y < dby+barsize)
{
thismapstart -= (2<<FF_TRANSSHIFT) - (5<<8);
offs -= downdistort * 2.0f * min(y-dby, dby+barsize-y) / barsize;
}
for (x = min(pos+(size_t)vid.width*2, (size_t)vid.width*vid.height); pos < x; pos++)
{
tmp[pos] = thismapstart[buf[pos+offs]];
INT32 pos = x*vid.height + y;
INT32 offspos = pos + offs*vid.height;
if (offspos < 0 || offspos > vid.width*vid.height)
offspos = pos;
tmp[pos] = thismapstart[buf[offspos]];
#ifdef HQ_VHS
tmp[pos] = tmapstart[buf[pos]<<8 | tmp[pos]];
#endif
@@ -1810,6 +1853,7 @@ void V_DrawVhsEffect(boolean rewind)
}
memcpy(buf, tmp, vid.width*vid.height);
#undef ROWOFFSLEN
}
//
@@ -1837,7 +1881,7 @@ void V_DrawFadeScreen(UINT16 color, UINT8 strength)
: ((color & 0xFF00) // Color is not palette index?
? ((UINT8 *)colormaps + strength*256) // Do COLORMAP fade.
: ((UINT8 *)transtables + ((9-strength)<<FF_TRANSSHIFT) + color*256)); // Else, do TRANSMAP** fade.
const UINT8 *deststop = vid.screens[0] + vid.width * vid.height;
const UINT8 *deststop = vid.screens[0] + vid.height * vid.width;
UINT8 *buf = vid.screens[0];
// heavily simplified -- we don't need to know x or y
@@ -1849,7 +1893,7 @@ void V_DrawFadeScreen(UINT16 color, UINT8 strength)
// Simple translucency with one color, over a set number of lines starting from the top.
void V_DrawFadeConsBack(INT32 plines)
{
UINT8 *deststop, *buf;
UINT8 *deststop, *dest, *desttop;
#ifdef HWRENDER // not win32 only 19990829 by Kin
if (rendermode == render_opengl)
@@ -1862,9 +1906,18 @@ void V_DrawFadeConsBack(INT32 plines)
// heavily simplified -- we don't need to know x or y position,
// just the stop position
deststop = vid.screens[0] + vid.width * min(plines, vid.height);
for (buf = vid.screens[0]; buf < deststop; ++buf)
*buf = consolebgmap[*buf];
dest = desttop = vid.screens[0];
deststop = vid.screens[0] + min(plines, vid.height);
for (; desttop < deststop; desttop++)
{
dest = desttop;
UINT8 *row_end = dest + (vid.width * vid.height);
while (dest < row_end)
{
*dest = consolebgmap[*dest];
dest += vid.height;
}
}
}
// Gets string colormap, used for 0x80 color codes
@@ -3599,7 +3652,7 @@ void V_DoPostProcessor(INT32 view, INT32 param)
if (thiscam->postimg & POSTIMG_WATER)
{
INT32 y;
INT32 y, x;
// Set disStart to a range from 0 to FINEANGLE, incrementing by 128 per tic
angle_t disStart = (((leveltime-1)*128) + (R_GetTimeFrac(RTF_LEVEL) / (FRACUNIT/128))) & FINEMASK;
INT32 newpix;
@@ -3609,7 +3662,7 @@ void V_DoPostProcessor(INT32 view, INT32 param)
for (y = yoffset; y < yoffset+viewheight; y++)
{
sine = (FINESINE(disStart)*5)>>FRACBITS;
newpix = abs(sine);
/*newpix = abs(sine);
if (sine < 0)
{
@@ -3632,7 +3685,7 @@ void V_DoPostProcessor(INT32 view, INT32 param)
tmpscr[(y*vid.width)+xoffset+viewwidth-newpix] = srcscr[(y*vid.width)+xoffset+(viewwidth-1)];
newpix--;
}
}
}*/
/*
Unoptimized version
@@ -3648,6 +3701,18 @@ void V_DoPostProcessor(INT32 view, INT32 param)
tmpscr[y*vid.width + x] = srcscr[y*vid.width+newpix]; // *(transme + (srcscr[y*vid.width+x]<<8) + srcscr[y*vid.width+newpix]);
}*/
for (x = 0; x < vid.width; x++)
{
newpix = (x + sine);
if (newpix < 0)
newpix = 0;
else if (newpix >= vid.width)
newpix = vid.width-1;
tmpscr[y + x*vid.height] = srcscr[y+newpix*vid.height]; // *(transme + (srcscr[y*vid.width+x]<<8) + srcscr[y*vid.width+newpix]);
}
disStart += 22;//the offset into the displacement map, increment each game loop
disStart &= FINEMASK; //clip it to FINEMASK
}
@@ -3658,7 +3723,7 @@ void V_DoPostProcessor(INT32 view, INT32 param)
}
else if (thiscam->postimg & POSTIMG_HEAT) // Heat wave
{
INT32 y;
INT32 y, x;
// Make sure table is built
if (heatshifter == NULL || lastheight != viewheight)
@@ -3683,11 +3748,12 @@ void V_DoPostProcessor(INT32 view, INT32 param)
if (heatshifter[heatindex[view]++])
{
// Shift this row of pixels to the right by 2
tmpscr[(y*vid.width)+xoffset] = srcscr[(y*vid.width)+xoffset];
M_Memcpy(&tmpscr[(y*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset+vid.dup], viewwidth-vid.dup);
tmpscr[y] = srcscr[y];
for (x = vid.dup; x < vid.width; x++)
tmpscr[y+x*vid.height] = srcscr[y+(x-vid.dup)*vid.height];
}
else
M_Memcpy(&tmpscr[(y*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset], viewwidth);
else for (x = 0; x < vid.width; x++)
tmpscr[y+x*vid.height] = srcscr[y+x*vid.height];
heatindex[view] %= viewheight;
}
@@ -3719,10 +3785,11 @@ void V_DoPostProcessor(INT32 view, INT32 param)
if ((thiscam->postimg & POSTIMG_FLIP) && !(thiscam->postimg & POSTIMG_MIRROR)) // Flip the screen upside-down
{
INT32 y, y2;
INT32 x, y, y2;
for (y = yoffset, y2 = yoffset+viewheight - 1; y < yoffset+viewheight; y++, y2--)
M_Memcpy(&tmpscr[(y2*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset], viewwidth);
for (x = xoffset; x < xoffset+viewwidth; x++)
for (y = yoffset, y2 = yoffset+(viewheight-1); y < yoffset+viewheight; y++, y2--)
tmpscr[x*vid.height + y2] = srcscr[x*vid.height + y];
UINT8 *tmp = tmpscr;
tmpscr = srcscr;
@@ -3730,11 +3797,10 @@ void V_DoPostProcessor(INT32 view, INT32 param)
}
else if ((thiscam->postimg & POSTIMG_MIRROR) && !(thiscam->postimg & POSTIMG_FLIP)) // Flip the screen on the x axis
{
INT32 y, x, x2;
INT32 x, x2;
for (y = yoffset; y < yoffset+viewheight; y++)
for (x = xoffset, x2 = xoffset+(viewwidth-1); x < xoffset+viewwidth; x++, x2--)
tmpscr[y*vid.width + x2] = srcscr[y*vid.width + x];
for (x = xoffset, x2 = xoffset+viewwidth - 1; x < xoffset+viewwidth; x++, x2--)
M_Memcpy(&tmpscr[(x2*vid.height)+yoffset], &srcscr[(x*vid.height)+yoffset], viewheight);
UINT8 *tmp = tmpscr;
tmpscr = srcscr;
@@ -3754,7 +3820,7 @@ void V_DoPostProcessor(INT32 view, INT32 param)
}
VID_BlitLinearScreen(srcscr+vid.width*yoffset+xoffset, tmpscr+vid.width*yoffset+xoffset,
viewwidth, viewheight, vid.width, vid.width);
viewwidth, viewheight, vid.height, vid.height);
#endif
}
@@ -3810,7 +3876,7 @@ UINT8 GetColorLUTDirect(colorlookup_t *lut, UINT8 r, UINT8 g, UINT8 b)
void V_Init(void)
{
INT32 i;
INT32 screensize = vid.width * vid.height;
INT32 screensize = vid.height * vid.width;
for (i = 0; i < NUMSCREENS; i++)
{
+1 -1
View File
@@ -450,7 +450,7 @@ void Y_IntermissionDrawer(void)
else
{
if (rendermode == render_soft)
VID_BlitLinearScreen(vid.screens[1], vid.screens[0], vid.width, vid.height, vid.width, vid.width);
VID_BlitLinearScreen(vid.screens[1], vid.screens[0], vid.width, vid.height, vid.height, vid.height);
#ifdef HWRENDER
else if (rendermode == render_opengl)
HWR_DrawIntermissionBG();