From 1634a598046d1268453e00a4bd22280da649075f Mon Sep 17 00:00:00 2001 From: Lactozilla Date: Tue, 28 Nov 2023 10:05:25 -0300 Subject: [PATCH] Transposed backbuffer WIP --- src/am_map.c | 2 +- src/console.c | 2 + src/d_main.c | 15 +- src/f_wipe.c | 4 +- src/r_bbox.c | 2 +- src/r_draw8.c | 610 +++++++++------------------------------------ src/r_draw8_npo2.c | 67 ++--- src/r_things.c | 18 +- src/sdl/i_video.c | 24 +- src/v_video.c | 35 ++- 10 files changed, 213 insertions(+), 566 deletions(-) diff --git a/src/am_map.c b/src/am_map.c index df3a45cff..de34b7483 100644 --- a/src/am_map.c +++ b/src/am_map.c @@ -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; } // diff --git a/src/console.c b/src/console.c index dbd7c938a..9f46e1796 100644 --- a/src/console.c +++ b/src/console.c @@ -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 diff --git a/src/d_main.c b/src/d_main.c index 274e4ceb3..13cc5c0de 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -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 { diff --git a/src/f_wipe.c b/src/f_wipe.c index 4bcfb029b..aa073b387 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -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; diff --git a/src/r_bbox.c b/src/r_bbox.c index 8ccad2bb5..8db924edf 100644 --- a/src/r_bbox.c +++ b/src/r_bbox.c @@ -70,7 +70,7 @@ raster_bbox_seg while (y < h) { - topleft[x + y * vid.width] = pixel; + topleft[y + x * vid.height] = pixel; y++; } } diff --git a/src/r_draw8.c b/src/r_draw8.c index b80a47984..6fa197aa8 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -42,9 +42,7 @@ void R_DrawColumn_8(void) // Framebuffer destination address. // Use ylookup LUT to avoid multiply with ScreenWidth. // Use columnofs LUT for subwindows? - - //dest = ylookup[dc_yl] + columnofs[dc_x]; - dest = &topleft[dc_yl*vid.width + dc_x]; + dest = &topleft[dc_x*vid.height + dc_yl]; count++; @@ -75,8 +73,7 @@ void R_DrawColumn_8(void) // Re-map color indices from wall texture column // using a lighting/special effects LUT. // heightmask is the Tutti-Frutti fix - *dest = colormap[source[frac>>FRACBITS]]; - dest += vid.width; + *dest++ = colormap[source[frac>>FRACBITS]]; // Avoid overflow. if (fracstep > 0x7FFFFFFF - frac) @@ -92,11 +89,9 @@ void R_DrawColumn_8(void) { while ((count -= 2) >= 0) // texture height is a power of 2 { - *dest = colormap[source[(frac>>FRACBITS) & heightmask]]; - dest += vid.width; + *dest++ = colormap[source[(frac>>FRACBITS) & heightmask]]; frac += fracstep; - *dest = colormap[source[(frac>>FRACBITS) & heightmask]]; - dest += vid.width; + *dest++ = colormap[source[(frac>>FRACBITS) & heightmask]]; frac += fracstep; } if (count & 1) @@ -125,9 +120,7 @@ void R_Draw2sMultiPatchColumn_8(void) // Framebuffer destination address. // Use ylookup LUT to avoid multiply with ScreenWidth. // Use columnofs LUT for subwindows? - - //dest = ylookup[dc_yl] + columnofs[dc_x]; - dest = &topleft[dc_yl*vid.width + dc_x]; + dest = &topleft[dc_x*vid.height + dc_yl]; count++; @@ -164,7 +157,7 @@ void R_Draw2sMultiPatchColumn_8(void) if (val != TRANSPARENTPIXEL) *dest = colormap[val]; - dest += vid.width; + dest++; // Avoid overflow. if (fracstep > 0x7FFFFFFF - frac) @@ -183,12 +176,12 @@ void R_Draw2sMultiPatchColumn_8(void) val = source[(frac>>FRACBITS) & heightmask]; if (val != TRANSPARENTPIXEL) *dest = colormap[val]; - dest += vid.width; + dest++; frac += fracstep; val = source[(frac>>FRACBITS) & heightmask]; if (val != TRANSPARENTPIXEL) *dest = colormap[val]; - dest += vid.width; + dest++; frac += fracstep; } if (count & 1) @@ -221,9 +214,7 @@ void R_Draw2sMultiPatchTranslucentColumn_8(void) // Framebuffer destination address. // Use ylookup LUT to avoid multiply with ScreenWidth. // Use columnofs LUT for subwindows? - - //dest = ylookup[dc_yl] + columnofs[dc_x]; - dest = &topleft[dc_yl*vid.width + dc_x]; + dest = &topleft[dc_x*vid.height + dc_yl]; count++; @@ -261,7 +252,7 @@ void R_Draw2sMultiPatchTranslucentColumn_8(void) if (val != TRANSPARENTPIXEL) *dest = *(transmap + (colormap[val]<<8) + (*dest)); - dest += vid.width; + dest++; // Avoid overflow. if (fracstep > 0x7FFFFFFF - frac) @@ -280,12 +271,12 @@ void R_Draw2sMultiPatchTranslucentColumn_8(void) val = source[(frac>>FRACBITS) & heightmask]; if (val != TRANSPARENTPIXEL) *dest = *(transmap + (colormap[val]<<8) + (*dest)); - dest += vid.width; + dest++; frac += fracstep; val = source[(frac>>FRACBITS) & heightmask]; if (val != TRANSPARENTPIXEL) *dest = *(transmap + (colormap[val]<<8) + (*dest)); - dest += vid.width; + dest++; frac += fracstep; } if (count & 1) @@ -321,8 +312,7 @@ void R_DrawShadeColumn_8(void) #endif // FIXME. As above. - //dest = ylookup[dc_yl] + columnofs[dc_x]; - dest = &topleft[dc_yl*vid.width + dc_x]; + dest = &topleft[dc_x*vid.height + dc_yl]; // Looks familiar. fracstep = dc_iscale; @@ -333,7 +323,7 @@ void R_DrawShadeColumn_8(void) do { *dest = colormaps[(dc_source[frac>>FRACBITS] <<8) + (*dest)]; - dest += vid.width; + dest++; frac += fracstep; } while (count--); } @@ -360,8 +350,7 @@ void R_DrawTranslucentColumn_8(void) #endif // FIXME. As above. - //dest = ylookup[dc_yl] + columnofs[dc_x]; - dest = &topleft[dc_yl*vid.width + dc_x]; + dest = &topleft[dc_x*vid.height + dc_yl]; // Looks familiar. fracstep = dc_iscale; @@ -393,7 +382,7 @@ void R_DrawTranslucentColumn_8(void) // using a lighting/special effects LUT. // heightmask is the Tutti-Frutti fix *dest = *(transmap + (colormap[source[frac>>FRACBITS]]<<8) + (*dest)); - dest += vid.width; + dest++; if ((frac += fracstep) >= heightmask) frac -= heightmask; } @@ -404,10 +393,10 @@ void R_DrawTranslucentColumn_8(void) while ((count -= 2) >= 0) // texture height is a power of 2 { *dest = *(transmap + (colormap[source[(frac>>FRACBITS)&heightmask]]<<8) + (*dest)); - dest += vid.width; + dest++; frac += fracstep; *dest = *(transmap + (colormap[source[(frac>>FRACBITS)&heightmask]]<<8) + (*dest)); - dest += vid.width; + dest++; frac += fracstep; } if (count & 1) @@ -431,7 +420,7 @@ void R_DrawDropShadowColumn_8(void) if (count <= 0) // Zero length, column does not exceed a pixel. return; - dest = &topleft[dc_yl*vid.width + dc_x]; + dest = &topleft[dc_x*vid.height + dc_yl]; { #define DSCOLOR 31 // palette index for the color of the shadow @@ -440,9 +429,9 @@ void R_DrawDropShadowColumn_8(void) while ((count -= 2) >= 0) { *dest = *(transmap_offset + (*dest)); - dest += vid.width; + dest++; *dest = *(transmap_offset + (*dest)); - dest += vid.width; + dest++; } if (count & 1) *dest = *(transmap_offset + (*dest)); @@ -465,8 +454,7 @@ void R_DrawTranslatedTranslucentColumn_8(void) return; // FIXME. As above. - //dest = ylookup[dc_yl] + columnofs[dc_x]; - dest = &topleft[dc_yl*vid.width + dc_x]; + dest = &topleft[dc_x*vid.height + dc_yl]; // Looks familiar. fracstep = dc_iscale; @@ -497,7 +485,7 @@ void R_DrawTranslatedTranslucentColumn_8(void) *dest = *(dc_transmap + (dc_colormap[dc_translation[dc_source[frac>>FRACBITS]]]<<8) + (*dest)); - dest += vid.width; + dest++; if ((frac += fracstep) >= heightmask) frac -= heightmask; } @@ -508,10 +496,10 @@ void R_DrawTranslatedTranslucentColumn_8(void) while ((count -= 2) >= 0) // texture height is a power of 2 { *dest = *(dc_transmap + (dc_colormap[dc_translation[dc_source[(frac>>FRACBITS)&heightmask]]]<<8) + (*dest)); - dest += vid.width; + dest++; frac += fracstep; *dest = *(dc_transmap + (dc_colormap[dc_translation[dc_source[(frac>>FRACBITS)&heightmask]]]<<8) + (*dest)); - dest += vid.width; + dest++; frac += fracstep; } if (count & 1) @@ -541,8 +529,7 @@ void R_DrawTranslatedColumn_8(void) #endif // FIXME. As above. - //dest = ylookup[dc_yl] + columnofs[dc_x]; - dest = &topleft[dc_yl*vid.width + dc_x]; + dest = &topleft[dc_x*vid.height + dc_yl]; // Looks familiar. fracstep = dc_iscale; @@ -557,10 +544,7 @@ void R_DrawTranslatedColumn_8(void) // used with PLAY sprites. // Thus the "green" ramp of the player 0 sprite // is mapped to gray, red, black/indigo. - *dest = dc_colormap[dc_translation[dc_source[frac>>FRACBITS]]]; - - dest += vid.width; - + *dest++ = dc_colormap[dc_translation[dc_source[frac>>FRACBITS]]]; frac += fracstep; } while (count--); } @@ -584,7 +568,7 @@ void R_DrawSpan_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); @@ -603,54 +587,15 @@ void R_DrawSpan_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; - 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 - // need! - dest[0] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]]; - xposition += xstep; - yposition += ystep; - - dest[1] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]]; - xposition += xstep; - yposition += ystep; - - dest[2] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]]; - xposition += xstep; - yposition += ystep; - - dest[3] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]]; - xposition += xstep; - yposition += ystep; - - dest[4] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]]; - xposition += xstep; - yposition += ystep; - - dest[5] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]]; - xposition += xstep; - yposition += ystep; - - dest[6] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]]; - xposition += xstep; - yposition += ystep; - - dest[7] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]]; - xposition += xstep; - yposition += ystep; - - dest += 8; - count -= 8; - } while (count-- && dest <= deststop) { - *dest++ = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]]; + *dest = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]]; + dest += vid.height; xposition += xstep; yposition += ystep; } @@ -683,7 +628,7 @@ void R_DrawTiltedSpan_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; @@ -699,7 +644,7 @@ void R_DrawTiltedSpan_8(void) colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); *dest = colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]]; - dest++; + dest += vid.height; iz += ds_szp->x; uz += ds_sup->x; vz += ds_svp->x; @@ -733,7 +678,7 @@ void R_DrawTiltedSpan_8(void) { colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); *dest = colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]]; - dest++; + dest += vid.height; u += stepu; v += stepv; } @@ -770,7 +715,7 @@ void R_DrawTiltedSpan_8(void) { colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); *dest = colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]]; - dest++; + dest += vid.height; u += stepu; v += stepv; } @@ -806,7 +751,7 @@ void R_DrawTiltedTranslucentSpan_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; @@ -821,7 +766,7 @@ void R_DrawTiltedTranslucentSpan_8(void) colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); *dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dest); - dest++; + dest += vid.height; iz += ds_szp->x; uz += ds_sup->x; vz += ds_svp->x; @@ -855,7 +800,7 @@ void R_DrawTiltedTranslucentSpan_8(void) { colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); *dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dest); - dest++; + dest += vid.height; u += stepu; v += stepv; } @@ -892,7 +837,7 @@ void R_DrawTiltedTranslucentSpan_8(void) { colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); *dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dest); - dest++; + dest += vid.height; u += stepu; v += stepv; } @@ -929,8 +874,8 @@ void R_DrawTiltedWaterSpan_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; @@ -944,8 +889,9 @@ void R_DrawTiltedWaterSpan_8(void) v = (INT64)(vz*z); colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - *dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dsrc++); - dest++; + *dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dsrc); + dest += vid.height; + dsrc += vid.height; iz += ds_szp->x; uz += ds_sup->x; vz += ds_svp->x; @@ -978,8 +924,9 @@ void R_DrawTiltedWaterSpan_8(void) for (i = SPANSIZE-1; i >= 0; i--) { colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - *dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dsrc++); - dest++; + *dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dsrc); + dest += vid.height; + dsrc += vid.height; u += stepu; v += stepv; } @@ -994,7 +941,7 @@ void R_DrawTiltedWaterSpan_8(void) u = (INT64)(startu); v = (INT64)(startv); colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - *dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dsrc++); + *dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dsrc); } else { @@ -1015,8 +962,9 @@ void R_DrawTiltedWaterSpan_8(void) for (; width != 0; width--) { colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - *dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dsrc++); - dest++; + *dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dsrc); + dest += vid.height; + dsrc += vid.height; u += stepu; v += stepv; } @@ -1051,7 +999,7 @@ void R_DrawTiltedSplat_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; @@ -1070,7 +1018,7 @@ void R_DrawTiltedSplat_8(void) if (val != TRANSPARENTPIXEL) *dest = colormap[val]; - dest++; + dest += vid.height; iz += ds_szp->x; uz += ds_sup->x; vz += ds_svp->x; @@ -1106,7 +1054,7 @@ void R_DrawTiltedSplat_8(void) val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]; if (val != TRANSPARENTPIXEL) *dest = colormap[val]; - dest++; + dest += vid.height; u += stepu; v += stepv; } @@ -1147,7 +1095,7 @@ void R_DrawTiltedSplat_8(void) val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]; if (val != TRANSPARENTPIXEL) *dest = colormap[val]; - dest++; + dest += vid.height; u += stepu; v += stepv; } @@ -1168,7 +1116,7 @@ void R_DrawSplat_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; @@ -1188,89 +1136,14 @@ void R_DrawSplat_8 (void) source = ds_source; colormap = ds_colormap; - dest = ylookup[ds_y] + columnofs[ds_x1]; + dest = &topleft[ds_x1*vid.height + ds_y]; - 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 - // need! - // - // 4194303 = (2048x2048)-1 (2048x2048 is maximum flat size) - // Why decimal? 0x3FFFFF == 4194303... ~Golden - val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 0x3FFFFF; - val = source[val]; - if (val != TRANSPARENTPIXEL) - dest[0] = colormap[val]; - xposition += xstep; - yposition += ystep; - - val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 0x3FFFFF; - val = source[val]; - if (val != TRANSPARENTPIXEL) - dest[1] = colormap[val]; - xposition += xstep; - yposition += ystep; - - val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 0x3FFFFF; - val = source[val]; - if (val != TRANSPARENTPIXEL) - dest[2] = colormap[val]; - xposition += xstep; - yposition += ystep; - - val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 0x3FFFFF; - val = source[val]; - if (val != TRANSPARENTPIXEL) - dest[3] = colormap[val]; - xposition += xstep; - yposition += ystep; - - val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 0x3FFFFF; - val = source[val]; - if (val != TRANSPARENTPIXEL) - dest[4] = colormap[val]; - xposition += xstep; - yposition += ystep; - - val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 0x3FFFFF; - val = source[val]; - if (val != TRANSPARENTPIXEL) - dest[5] = colormap[val]; - xposition += xstep; - yposition += ystep; - - val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 0x3FFFFF; - val = source[val]; - if (val != TRANSPARENTPIXEL) - dest[6] = colormap[val]; - xposition += xstep; - yposition += ystep; - - val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 0x3FFFFF; - val = source[val]; - if (val != TRANSPARENTPIXEL) - dest[7] = colormap[val]; - xposition += xstep; - yposition += ystep; - - dest += 8; - count -= 8; - } while (count-- && dest <= deststop) { val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; if (val != TRANSPARENTPIXEL) *dest = colormap[val]; - dest++; + dest += vid.height; xposition += xstep; yposition += ystep; } @@ -1288,7 +1161,7 @@ void R_DrawTranslucentSplat_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; @@ -1308,70 +1181,14 @@ void R_DrawTranslucentSplat_8 (void) source = ds_source; colormap = ds_colormap; - dest = ylookup[ds_y] + columnofs[ds_x1]; + dest = &topleft[ds_x1*vid.height + ds_y]; - 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 - // need! - val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; - if (val != TRANSPARENTPIXEL) - dest[0] = *(ds_transmap + (colormap[val] << 8) + dest[0]); - xposition += xstep; - yposition += ystep; - - val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; - if (val != TRANSPARENTPIXEL) - dest[1] = *(ds_transmap + (colormap[val] << 8) + dest[1]); - xposition += xstep; - yposition += ystep; - - val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; - if (val != TRANSPARENTPIXEL) - dest[2] = *(ds_transmap + (colormap[val] << 8) + dest[2]); - xposition += xstep; - yposition += ystep; - - val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; - if (val != TRANSPARENTPIXEL) - dest[3] = *(ds_transmap + (colormap[val] << 8) + dest[3]); - xposition += xstep; - yposition += ystep; - - val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; - if (val != TRANSPARENTPIXEL) - dest[4] = *(ds_transmap + (colormap[val] << 8) + dest[4]); - xposition += xstep; - yposition += ystep; - - val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; - if (val != TRANSPARENTPIXEL) - dest[5] = *(ds_transmap + (colormap[val] << 8) + dest[5]); - xposition += xstep; - yposition += ystep; - - val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; - if (val != TRANSPARENTPIXEL) - dest[6] = *(ds_transmap + (colormap[val] << 8) + dest[6]); - xposition += xstep; - yposition += ystep; - - val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; - if (val != TRANSPARENTPIXEL) - dest[7] = *(ds_transmap + (colormap[val] << 8) + dest[7]); - xposition += xstep; - yposition += ystep; - - dest += 8; - count -= 8; - } while (count-- && dest <= deststop) { val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; if (val != TRANSPARENTPIXEL) *dest = *(ds_transmap + (colormap[val] << 8) + *dest); - dest++; + dest += vid.height; xposition += xstep; yposition += ystep; } @@ -1390,7 +1207,7 @@ void R_DrawFloorSprite_8 (void) UINT8 *colormap; UINT8 *translation; 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; @@ -1411,78 +1228,14 @@ void R_DrawFloorSprite_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]; - 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 - // need! - val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val = source[val]; - if (val & 0xFF00) - dest[0] = colormap[translation[val & 0xFF]]; - xposition += xstep; - yposition += ystep; - - val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val = source[val]; - if (val & 0xFF00) - dest[1] = colormap[translation[val & 0xFF]]; - xposition += xstep; - yposition += ystep; - - val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val = source[val]; - if (val & 0xFF00) - dest[2] = colormap[translation[val & 0xFF]]; - xposition += xstep; - yposition += ystep; - - val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val = source[val]; - if (val & 0xFF00) - dest[3] = colormap[translation[val & 0xFF]]; - xposition += xstep; - yposition += ystep; - - val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val = source[val]; - if (val & 0xFF00) - dest[4] = colormap[translation[val & 0xFF]]; - xposition += xstep; - yposition += ystep; - - val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val = source[val]; - if (val & 0xFF00) - dest[5] = colormap[translation[val & 0xFF]]; - xposition += xstep; - yposition += ystep; - - val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val = source[val]; - if (val & 0xFF00) - dest[6] = colormap[translation[val & 0xFF]]; - xposition += xstep; - yposition += ystep; - - val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val = source[val]; - if (val & 0xFF00) - dest[7] = colormap[translation[val & 0xFF]]; - xposition += xstep; - yposition += ystep; - - dest += 8; - count -= 8; - } while (count-- && dest <= deststop) { val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; if (val & 0xFF00) *dest = colormap[translation[val & 0xFF]]; - dest++; + dest += vid.height; xposition += xstep; yposition += ystep; } @@ -1501,7 +1254,7 @@ void R_DrawTranslucentFloorSprite_8 (void) UINT8 *colormap; UINT8 *translation; 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; @@ -1522,70 +1275,14 @@ void R_DrawTranslucentFloorSprite_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]; - 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 - // need! - val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; - if (val & 0xFF00) - dest[0] = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + dest[0]); - xposition += xstep; - yposition += ystep; - - val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; - if (val & 0xFF00) - dest[1] = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + dest[1]); - xposition += xstep; - yposition += ystep; - - val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; - if (val & 0xFF00) - dest[2] = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + dest[2]); - xposition += xstep; - yposition += ystep; - - val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; - if (val & 0xFF00) - dest[3] = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + dest[3]); - xposition += xstep; - yposition += ystep; - - val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; - if (val & 0xFF00) - dest[4] = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + dest[4]); - xposition += xstep; - yposition += ystep; - - val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; - if (val & 0xFF00) - dest[5] = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + dest[5]); - xposition += xstep; - yposition += ystep; - - val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; - if (val & 0xFF00) - dest[6] = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + dest[6]); - xposition += xstep; - yposition += ystep; - - val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; - if (val & 0xFF00) - dest[7] = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + dest[7]); - xposition += xstep; - yposition += ystep; - - dest += 8; - count -= 8; - } while (count-- && dest <= deststop) { val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; if (val & 0xFF00) *dest = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + *dest); - dest++; + dest += vid.height; xposition += xstep; yposition += ystep; } @@ -1617,7 +1314,7 @@ void R_DrawTiltedFloorSprite_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; @@ -1651,7 +1348,7 @@ void R_DrawTiltedFloorSprite_8(void) val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]; if (val & 0xFF00) *dest = colormap[translation[val & 0xFF]]; - dest++; + dest += vid.height; u += stepu; v += stepv; @@ -1691,7 +1388,7 @@ void R_DrawTiltedFloorSprite_8(void) val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]; if (val & 0xFF00) *dest = colormap[translation[val & 0xFF]]; - dest++; + dest += vid.height; u += stepu; v += stepv; @@ -1726,7 +1423,7 @@ void R_DrawTiltedTranslucentFloorSprite_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; @@ -1760,7 +1457,7 @@ void R_DrawTiltedTranslucentFloorSprite_8(void) val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]; if (val & 0xFF00) *dest = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + *dest); - dest++; + dest += vid.height; u += stepu; v += stepv; @@ -1800,7 +1497,7 @@ void R_DrawTiltedTranslucentFloorSprite_8(void) val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]; if (val & 0xFF00) *dest = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + *dest); - dest++; + dest += vid.height; u += stepu; v += stepv; @@ -1821,7 +1518,7 @@ void R_DrawTranslucentSpan_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; @@ -1841,53 +1538,13 @@ void R_DrawTranslucentSpan_8 (void) source = ds_source; colormap = ds_colormap; - dest = ylookup[ds_y] + columnofs[ds_x1]; + dest = &topleft[ds_x1*vid.height + ds_y]; - 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 - // need! - dest[0] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[0]); - xposition += xstep; - yposition += ystep; - - dest[1] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[1]); - xposition += xstep; - yposition += ystep; - - dest[2] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[2]); - xposition += xstep; - yposition += ystep; - - dest[3] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[3]); - xposition += xstep; - yposition += ystep; - - dest[4] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[4]); - xposition += xstep; - yposition += ystep; - - dest[5] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[5]); - xposition += xstep; - yposition += ystep; - - dest[6] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[6]); - xposition += xstep; - yposition += ystep; - - dest[7] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[7]); - xposition += xstep; - yposition += ystep; - - dest += 8; - count -= 8; - } while (count-- && dest <= deststop) { val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); *dest = *(ds_transmap + (colormap[source[val]] << 8) + *dest); - dest++; + dest += vid.height; xposition += xstep; yposition += ystep; } @@ -1918,53 +1575,14 @@ void R_DrawWaterSpan_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); count = ds_x2 - ds_x1 + 1; - 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 - // need! - dest[0] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)]; - xposition += xstep; - yposition += ystep; - - dest[1] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)]; - xposition += xstep; - yposition += ystep; - - dest[2] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)]; - xposition += xstep; - yposition += ystep; - - dest[3] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)]; - xposition += xstep; - yposition += ystep; - - dest[4] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)]; - xposition += xstep; - yposition += ystep; - - dest[5] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)]; - xposition += xstep; - yposition += ystep; - - dest[6] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)]; - xposition += xstep; - yposition += ystep; - - dest[7] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)]; - xposition += xstep; - yposition += ystep; - - dest += 8; - count -= 8; - } while (count--) { - *dest++ = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)]; + *dest = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)]; + dest += vid.height; xposition += xstep; yposition += ystep; } @@ -1981,26 +1599,14 @@ void R_DrawFogSpan_8(void) size_t count; colormap = ds_colormap; - //dest = ylookup[ds_y] + columnofs[ds_x1]; - dest = &topleft[ds_y *vid.width + ds_x1]; + dest = &topleft[ds_x1*vid.height + ds_y]; count = ds_x2 - ds_x1 + 1; - while (count >= 4) - { - dest[0] = colormap[dest[0]]; - dest[1] = colormap[dest[1]]; - dest[2] = colormap[dest[2]]; - dest[3] = colormap[dest[3]]; - - dest += 4; - count -= 4; - } - while (count--) { *dest = colormap[*dest]; - dest++; + dest += vid.height; } } @@ -2011,7 +1617,7 @@ void R_DrawTiltedFogSpan_8(void) { int width = ds_x2 - ds_x1; - UINT8 *dest = ylookup[ds_y] + columnofs[ds_x1]; + UINT8 *dest = &topleft[ds_x1*vid.height + ds_y]; double iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); @@ -2021,7 +1627,7 @@ void R_DrawTiltedFogSpan_8(void) { UINT8 *colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); *dest = colormap[*dest]; - dest++; + dest += vid.height; } while (--width >= 0); } @@ -2033,9 +1639,12 @@ void R_DrawSolidColorSpan_8(void) size_t count = (ds_x2 - ds_x1 + 1); UINT8 source = ds_colormap[ds_source[0]]; - UINT8 *dest = ylookup[ds_y] + columnofs[ds_x1]; + UINT8 *dest = &topleft[ds_x1*vid.height + ds_y]; - memset(dest, source, count); + const UINT8 *deststop = screens[0] + vid.rowbytes * vid.width; + + while (count-- && dest <= deststop) + *dest++ = source; } /** \brief The R_DrawTransSolidColorSpan_8 function @@ -2046,14 +1655,14 @@ void R_DrawTransSolidColorSpan_8(void) size_t count = (ds_x2 - ds_x1 + 1); UINT8 source = ds_colormap[ds_source[0]]; - UINT8 *dest = ylookup[ds_y] + columnofs[ds_x1]; + UINT8 *dest = &topleft[ds_x1*vid.height + ds_y]; - const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height; + const UINT8 *deststop = screens[0] + vid.rowbytes * vid.width; while (count-- && dest <= deststop) { *dest = *(ds_transmap + (source << 8) + *dest); - dest++; + dest += vid.height; } } @@ -2065,7 +1674,7 @@ void R_DrawTiltedSolidColorSpan_8(void) int width = ds_x2 - ds_x1; UINT8 source = ds_source[0]; - UINT8 *dest = ylookup[ds_y] + columnofs[ds_x1]; + UINT8 *dest = &topleft[ds_x1*vid.height + ds_y]; double iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); @@ -2074,7 +1683,8 @@ void R_DrawTiltedSolidColorSpan_8(void) do { UINT8 *colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - *dest++ = colormap[source]; + *dest = colormap[source]; + dest += vid.height; } while (--width >= 0); } @@ -2086,7 +1696,7 @@ void R_DrawTiltedTransSolidColorSpan_8(void) int width = ds_x2 - ds_x1; UINT8 source = ds_source[0]; - UINT8 *dest = ylookup[ds_y] + columnofs[ds_x1]; + UINT8 *dest = &topleft[ds_x1*vid.height + ds_y]; double iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); @@ -2096,7 +1706,7 @@ void R_DrawTiltedTransSolidColorSpan_8(void) { UINT8 *colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); *dest = *(ds_transmap + (colormap[source] << 8) + *dest); - dest++; + dest += vid.height; } while (--width >= 0); } @@ -2107,16 +1717,17 @@ void R_DrawWaterSolidColorSpan_8(void) { UINT8 source = ds_source[0]; UINT8 *colormap = ds_colormap; - UINT8 *dest = ylookup[ds_y] + columnofs[ds_x1]; - UINT8 *dsrc = screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1; + UINT8 *dest = &topleft[ds_x1*vid.height + ds_y]; + UINT8 *dsrc = screens[1] + ds_x1*vid.height + (ds_y+ds_bgofs); size_t count = (ds_x2 - ds_x1 + 1); - const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height; + const UINT8 *deststop = screens[0] + vid.rowbytes * vid.width; while (count-- && dest <= deststop) { - *dest = colormap[*(ds_transmap + (source << 8) + *dsrc++)]; - dest++; + *dest = colormap[*(ds_transmap + (source << 8) + *dsrc)]; + dest += vid.height; + dsrc += vid.height; } } @@ -2128,8 +1739,8 @@ void R_DrawTiltedWaterSolidColorSpan_8(void) int width = ds_x2 - ds_x1; UINT8 source = ds_source[0]; - UINT8 *dest = ylookup[ds_y] + columnofs[ds_x1]; - UINT8 *dsrc = screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1; + UINT8 *dest = &topleft[ds_x1*vid.height + ds_y]; + UINT8 *dsrc = screens[1] + ds_x1*vid.height + (ds_y+ds_bgofs); double iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); @@ -2138,7 +1749,9 @@ void R_DrawTiltedWaterSolidColorSpan_8(void) do { UINT8 *colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - *dest++ = *(ds_transmap + (colormap[source] << 8) + *dsrc++); + *dest = *(ds_transmap + (colormap[source] << 8) + *dsrc); + dest += vid.height; + dsrc += vid.height; } while (--width >= 0); } @@ -2164,15 +1777,14 @@ void R_DrawFogColumn_8(void) // Framebuffer destination address. // Use ylookup LUT to avoid multiply with ScreenWidth. // Use columnofs LUT for subwindows? - //dest = ylookup[dc_yl] + columnofs[dc_x]; - dest = &topleft[dc_yl*vid.width + dc_x]; + dest = &topleft[dc_x*vid.height + dc_yl]; // Determine scaling, which is the only mapping to be done. do { // Simple. Apply the colormap to what's already on the screen. *dest = dc_colormap[*dest]; - dest += vid.width; + dest++; } while (count--); } diff --git a/src/r_draw8_npo2.c b/src/r_draw8_npo2.c index 91f3b06c4..e827455c7 100644 --- a/src/r_draw8_npo2.c +++ b/src/r_draw8_npo2.c @@ -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; } diff --git a/src/r_things.c b/src/r_things.c index 699013602..c919d9541 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -688,15 +688,7 @@ void R_DrawMaskedColumn(column_t *column) dc_texturemid = basetexturemid - (topdelta<length + 4); } @@ -755,12 +747,8 @@ void R_DrawFlippedMaskedColumn(column_t *column) dc_texturemid = basetexturemid - (topdelta<length + 4); diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 590d7d142..46b6ee9b3 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -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")); diff --git a/src/v_video.c b/src/v_video.c index 30aef92cc..67b47aac3 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -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();