mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Merge branch 'templated-drawing' into 'master'
Use C++ templates for DrawColumn/Span See merge request KartKrew/Kart!1728
This commit is contained in:
commit
4168c9ccaf
17 changed files with 3387 additions and 5481 deletions
|
|
@ -72,7 +72,7 @@ add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32
|
|||
r_data.c
|
||||
r_debug.cpp
|
||||
r_debug_parser.cpp
|
||||
r_draw.c
|
||||
r_draw.cpp
|
||||
r_fps.c
|
||||
r_main.cpp
|
||||
r_plane.cpp
|
||||
|
|
|
|||
2484
src/libdivide.h
2484
src/libdivide.h
File diff suppressed because it is too large
Load diff
|
|
@ -1091,6 +1091,7 @@ typedef struct
|
|||
|
||||
//Fix TUTIFRUTI
|
||||
INT32 texheight;
|
||||
INT32 sourcelength;
|
||||
|
||||
UINT8 r8_flatcolor;
|
||||
} drawcolumndata_t;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// terms of the GNU General Public License, version 2.
|
||||
// See the 'LICENSE' file for more details.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \file r_draw.c
|
||||
/// \file r_draw.cpp
|
||||
/// \brief span / column drawer functions, for 8bpp and 16bpp
|
||||
/// All drawing to the view buffer is accomplished in this file.
|
||||
/// The other refresh files only know about ccordinates,
|
||||
|
|
@ -33,24 +33,24 @@
|
|||
#include "hardware/hw_main.h"
|
||||
#endif
|
||||
|
||||
#include <tracy/tracy/Tracy.hpp>
|
||||
|
||||
// --------------------------------------------
|
||||
// assembly or c drawer routines for 8bpp/16bpp
|
||||
// --------------------------------------------
|
||||
coldrawfunc_t *colfunc;
|
||||
|
||||
coldrawfunc_t *colfuncs[COLDRAWFUNC_MAX];
|
||||
#ifdef USE_COL_SPAN_ASM
|
||||
coldrawfunc_t *colfuncs_asm[COLDRAWFUNC_MAX];
|
||||
#endif
|
||||
coldrawfunc_t *colfuncs_bm[COLDRAWFUNC_MAX];
|
||||
|
||||
int colfunctype;
|
||||
|
||||
spandrawfunc_t *spanfunc;
|
||||
|
||||
spandrawfunc_t *spanfuncs[SPANDRAWFUNC_MAX];
|
||||
spandrawfunc_t *spanfuncs_bm[SPANDRAWFUNC_MAX];
|
||||
spandrawfunc_t *spanfuncs_npo2[SPANDRAWFUNC_MAX];
|
||||
#ifdef USE_COL_SPAN_ASM
|
||||
spandrawfunc_t *spanfuncs_asm[SPANDRAWFUNC_MAX];
|
||||
#endif
|
||||
spandrawfunc_t *spanfuncs_bm_npo2[SPANDRAWFUNC_MAX];
|
||||
spandrawfunc_t *spanfuncs_flat[SPANDRAWFUNC_MAX];
|
||||
|
||||
drawcolumndata_t g_dc;
|
||||
|
|
@ -212,17 +212,17 @@ static void R_AllocateBlendTables(void)
|
|||
{
|
||||
if (i == blendtab_modulate)
|
||||
continue;
|
||||
blendtables[i] = Z_MallocAlign((NUMTRANSTABLES + 1) * 0x10000, PU_STATIC, NULL, 16);
|
||||
blendtables[i] = static_cast<UINT8 *>(Z_MallocAlign((NUMTRANSTABLES + 1) * 0x10000, PU_STATIC, NULL, 16));
|
||||
}
|
||||
|
||||
// Modulation blending only requires a single table
|
||||
blendtables[blendtab_modulate] = Z_MallocAlign(0x10000, PU_STATIC, NULL, 16);
|
||||
blendtables[blendtab_modulate] = static_cast<UINT8 *>(Z_MallocAlign(0x10000, PU_STATIC, NULL, 16));
|
||||
}
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
static void R_GenerateBlendTables_Thread(void *userdata)
|
||||
{
|
||||
struct GenerateBlendTables_State *state = userdata;
|
||||
struct GenerateBlendTables_State *state = static_cast<struct GenerateBlendTables_State *>(userdata);
|
||||
|
||||
R_GenerateBlendTables_Core(state);
|
||||
|
||||
|
|
@ -239,8 +239,7 @@ void R_InitTranslucencyTables(void)
|
|||
// Load here the transparency lookup tables 'TINTTAB'
|
||||
// NOTE: the TINTTAB resource MUST BE aligned on 64k for the asm
|
||||
// optimised code (in other words, transtables pointer low word is 0)
|
||||
transtables = Z_MallocAlign(NUMTRANSTABLES*0x10000, PU_STATIC,
|
||||
NULL, 16);
|
||||
transtables = static_cast<UINT8 *>(Z_MallocAlign(NUMTRANSTABLES*0x10000, PU_STATIC, NULL, 16));
|
||||
|
||||
W_ReadLump(W_GetNumForName("TRANS10"), transtables);
|
||||
W_ReadLump(W_GetNumForName("TRANS20"), transtables+0x10000);
|
||||
|
|
@ -260,11 +259,11 @@ void R_GenerateBlendTables(void)
|
|||
{
|
||||
#ifdef HAVE_THREADS
|
||||
// Allocate copies for the worker thread since the originals can be freed in the main thread.
|
||||
struct GenerateBlendTables_State *state = malloc(sizeof *state);
|
||||
struct GenerateBlendTables_State *state = static_cast<struct GenerateBlendTables_State *>(malloc(sizeof *state));
|
||||
size_t palsize = 256 * sizeof(RGBA_t);
|
||||
|
||||
state->masterPalette = memcpy(malloc(palsize), pMasterPalette, palsize);
|
||||
state->gammaCorrectedPalette = memcpy(malloc(palsize), pGammaCorrectedPalette, palsize);
|
||||
state->masterPalette = static_cast<RGBA_t *>(memcpy(malloc(palsize), pMasterPalette, palsize));
|
||||
state->gammaCorrectedPalette = static_cast<RGBA_t *>(memcpy(malloc(palsize), pGammaCorrectedPalette, palsize));
|
||||
|
||||
I_spawn_thread("blend-tables",
|
||||
R_GenerateBlendTables_Thread, state);
|
||||
|
|
@ -313,7 +312,7 @@ void R_GenerateTranslucencyTable(UINT8 *table, RGBA_t* sourcepal, int style, UIN
|
|||
}
|
||||
}
|
||||
|
||||
#define ClipTransLevel(trans) max(min((trans), NUMTRANSMAPS-2), 0)
|
||||
#define ClipTransLevel(trans) std::clamp<INT32>(trans, 0, NUMTRANSMAPS-2)
|
||||
|
||||
UINT8 *R_GetTranslucencyTable(INT32 alphalevel)
|
||||
{
|
||||
|
|
@ -364,7 +363,7 @@ UINT8* R_GetTranslationColormap(INT32 skinnum, skincolornum_t color, UINT8 flags
|
|||
{
|
||||
// Allocate table for skin if necessary
|
||||
if (!translationtablecache[skintableindex])
|
||||
translationtablecache[skintableindex] = Z_Calloc(MAXSKINCOLORS * sizeof(UINT8**), PU_STATIC, NULL);
|
||||
translationtablecache[skintableindex] = static_cast<UINT8 **>(Z_Calloc(MAXSKINCOLORS * sizeof(UINT8**), PU_STATIC, NULL));
|
||||
|
||||
// Get colormap
|
||||
ret = translationtablecache[skintableindex][color];
|
||||
|
|
@ -383,7 +382,7 @@ UINT8* R_GetTranslationColormap(INT32 skinnum, skincolornum_t color, UINT8 flags
|
|||
// Generate the colormap if necessary
|
||||
if (!ret)
|
||||
{
|
||||
ret = Z_MallocAlign(NUM_PALETTE_ENTRIES, (flags & GTC_CACHE) ? PU_LEVEL : PU_STATIC, NULL, 8);
|
||||
ret = static_cast<UINT8 *>(Z_MallocAlign(NUM_PALETTE_ENTRIES, (flags & GTC_CACHE) ? PU_LEVEL : PU_STATIC, NULL, 8));
|
||||
K_GenerateKartColormap(ret, skinnum, color); //R_GenerateTranslationColormap(ret, skinnum, color); // SRB2kart
|
||||
|
||||
// Cache the colormap if desired
|
||||
|
|
@ -425,7 +424,7 @@ UINT16 R_GetColorByName(const char *name)
|
|||
UINT16 R_GetSuperColorByName(const char *name)
|
||||
{
|
||||
UINT16 i, color = SKINCOLOR_NONE;
|
||||
char *realname = Z_Malloc(MAXCOLORNAME+1, PU_STATIC, NULL);
|
||||
char *realname = static_cast<char *>(Z_Malloc(MAXCOLORNAME+1, PU_STATIC, NULL));
|
||||
snprintf(realname, MAXCOLORNAME+1, "Super %s 1", name);
|
||||
for (i = 1; i < numskincolors; i++)
|
||||
if (!stricmp(skincolors[i].name, realname)) {
|
||||
|
|
@ -655,17 +654,8 @@ void R_DrawViewBorder(void)
|
|||
#endif
|
||||
|
||||
// ==========================================================================
|
||||
// INCLUDE 8bpp DRAWING CODE HERE
|
||||
// INCLUDE MAIN DRAWERS CODE HERE
|
||||
// ==========================================================================
|
||||
|
||||
#include "r_draw8.c"
|
||||
#include "r_draw8_npo2.c"
|
||||
#include "r_draw8_flat.c"
|
||||
|
||||
// ==========================================================================
|
||||
// INCLUDE 16bpp DRAWING CODE HERE
|
||||
// ==========================================================================
|
||||
|
||||
#ifdef HIGHCOLOR
|
||||
#include "r_draw16.c"
|
||||
#endif
|
||||
#include "r_draw_column.cpp"
|
||||
#include "r_draw_span.cpp"
|
||||
176
src/r_draw.h
176
src/r_draw.h
|
|
@ -64,22 +64,20 @@ extern float zeroheight;
|
|||
|
||||
extern lumpnum_t viewborderlump[8];
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------
|
||||
// color mode dependent drawer function pointers
|
||||
// ---------------------------------------------
|
||||
|
||||
#define USE_COL_SPAN_ASM 0
|
||||
|
||||
#define BASEDRAWFUNC 0
|
||||
|
||||
typedef void (coldrawfunc_t)(drawcolumndata_t*);
|
||||
typedef void (spandrawfunc_t)(drawspandata_t*);
|
||||
|
||||
enum
|
||||
{
|
||||
COLDRAWFUNC_BASE = BASEDRAWFUNC,
|
||||
COLDRAWFUNC_FUZZY,
|
||||
COLDRAWFUNC_TRANS,
|
||||
COLDRAWFUNC_SHADE,
|
||||
COLDRAWFUNC_SHADOWED,
|
||||
COLDRAWFUNC_TRANSTRANS,
|
||||
COLDRAWFUNC_TWOSMULTIPATCH,
|
||||
|
|
@ -90,15 +88,11 @@ enum
|
|||
COLDRAWFUNC_MAX
|
||||
};
|
||||
|
||||
typedef void (coldrawfunc_t)(drawcolumndata_t*);
|
||||
typedef void (spandrawfunc_t)(drawspandata_t*);
|
||||
|
||||
extern coldrawfunc_t *colfunc;
|
||||
extern coldrawfunc_t *colfuncs[COLDRAWFUNC_MAX];
|
||||
#ifdef USE_COL_SPAN_ASM
|
||||
extern coldrawfunc_t *colfuncs_asm[COLDRAWFUNC_MAX];
|
||||
#endif
|
||||
extern int colfunctype;
|
||||
extern coldrawfunc_t *colfunc;
|
||||
|
||||
extern coldrawfunc_t *colfuncs[COLDRAWFUNC_MAX];
|
||||
extern coldrawfunc_t *colfuncs_bm[COLDRAWFUNC_MAX];
|
||||
|
||||
enum
|
||||
{
|
||||
|
|
@ -110,6 +104,7 @@ enum
|
|||
SPANDRAWFUNC_SPLAT,
|
||||
SPANDRAWFUNC_TRANSSPLAT,
|
||||
SPANDRAWFUNC_TILTEDSPLAT,
|
||||
SPANDRAWFUNC_TILTEDTRANSSPLAT,
|
||||
|
||||
SPANDRAWFUNC_SPRITE,
|
||||
SPANDRAWFUNC_TRANSSPRITE,
|
||||
|
|
@ -120,16 +115,17 @@ enum
|
|||
SPANDRAWFUNC_TILTEDWATER,
|
||||
|
||||
SPANDRAWFUNC_FOG,
|
||||
SPANDRAWFUNC_TILTEDFOG,
|
||||
|
||||
SPANDRAWFUNC_MAX
|
||||
};
|
||||
|
||||
extern spandrawfunc_t *spanfunc;
|
||||
|
||||
extern spandrawfunc_t *spanfuncs[SPANDRAWFUNC_MAX];
|
||||
extern spandrawfunc_t *spanfuncs_bm[SPANDRAWFUNC_MAX];
|
||||
extern spandrawfunc_t *spanfuncs_npo2[SPANDRAWFUNC_MAX];
|
||||
#ifdef USE_COL_SPAN_ASM
|
||||
extern spandrawfunc_t *spanfuncs_asm[SPANDRAWFUNC_MAX];
|
||||
#endif
|
||||
extern spandrawfunc_t *spanfuncs_bm_npo2[SPANDRAWFUNC_MAX];
|
||||
extern spandrawfunc_t *spanfuncs_flat[SPANDRAWFUNC_MAX];
|
||||
|
||||
// ------------------------------------------------
|
||||
|
|
@ -202,90 +198,98 @@ void R_DrawViewBorder(void);
|
|||
// 8bpp DRAWING CODE
|
||||
// -----------------
|
||||
|
||||
void R_DrawColumn_8(drawcolumndata_t* dc);
|
||||
void R_DrawShadeColumn_8(drawcolumndata_t* dc);
|
||||
void R_DrawTranslucentColumn_8(drawcolumndata_t* dc);
|
||||
void R_DrawDropShadowColumn_8(drawcolumndata_t* dc);
|
||||
void R_DrawTranslatedColumn_8(drawcolumndata_t* dc);
|
||||
void R_DrawTranslatedTranslucentColumn_8(drawcolumndata_t* dc);
|
||||
void R_Draw2sMultiPatchColumn_8(drawcolumndata_t* dc);
|
||||
void R_Draw2sMultiPatchTranslucentColumn_8(drawcolumndata_t* dc);
|
||||
void R_DrawFogColumn_8(drawcolumndata_t* dc);
|
||||
void R_DrawColumnShadowed_8(drawcolumndata_t* dc);
|
||||
void R_DrawColumn(drawcolumndata_t* dc);
|
||||
void R_DrawTranslucentColumn(drawcolumndata_t* dc);
|
||||
void R_DrawDropShadowColumn(drawcolumndata_t* dc);
|
||||
void R_DrawTranslatedColumn(drawcolumndata_t* dc);
|
||||
void R_DrawTranslatedTranslucentColumn(drawcolumndata_t* dc);
|
||||
void R_Draw2sMultiPatchColumn(drawcolumndata_t* dc);
|
||||
void R_Draw2sMultiPatchTranslucentColumn(drawcolumndata_t* dc);
|
||||
void R_DrawFogColumn(drawcolumndata_t* dc);
|
||||
void R_DrawColumnShadowed(drawcolumndata_t* dc);
|
||||
|
||||
#define PLANELIGHTFLOAT (BASEVIDWIDTH * BASEVIDWIDTH / vid.width / ds->zeroheight / 21.0f * FIXED_TO_FLOAT(fovtan[viewssnum]))
|
||||
void R_DrawColumn_Brightmap(drawcolumndata_t* dc);
|
||||
void R_DrawTranslucentColumn_Brightmap(drawcolumndata_t* dc);
|
||||
void R_DrawTranslatedColumn_Brightmap(drawcolumndata_t* dc);
|
||||
void R_DrawTranslatedTranslucentColumn_Brightmap(drawcolumndata_t* dc);
|
||||
void R_Draw2sMultiPatchColumn_Brightmap(drawcolumndata_t* dc);
|
||||
void R_Draw2sMultiPatchTranslucentColumn_Brightmap(drawcolumndata_t* dc);
|
||||
void R_DrawColumnShadowed_Brightmap(drawcolumndata_t* dc);
|
||||
|
||||
void R_DrawSpan_8(drawspandata_t* ds);
|
||||
void R_DrawTranslucentSpan_8(drawspandata_t* ds);
|
||||
void R_DrawTiltedSpan_8(drawspandata_t* ds);
|
||||
void R_DrawTiltedTranslucentSpan_8(drawspandata_t* ds);
|
||||
void R_DrawSpan(drawspandata_t* ds);
|
||||
void R_DrawTranslucentSpan(drawspandata_t* ds);
|
||||
void R_DrawSplat(drawspandata_t* ds);
|
||||
void R_DrawTranslucentSplat(drawspandata_t* ds);
|
||||
void R_DrawFloorSprite(drawspandata_t* ds);
|
||||
void R_DrawTranslucentFloorSprite(drawspandata_t* ds);
|
||||
void R_DrawTranslucentWaterSpan(drawspandata_t* ds);
|
||||
void R_DrawFogSpan(drawspandata_t* ds);
|
||||
|
||||
void R_DrawSplat_8(drawspandata_t* ds);
|
||||
void R_DrawTranslucentSplat_8(drawspandata_t* ds);
|
||||
void R_DrawTiltedSplat_8(drawspandata_t* ds);
|
||||
void R_DrawSpan_Tilted(drawspandata_t* ds);
|
||||
void R_DrawTranslucentSpan_Tilted(drawspandata_t* ds);
|
||||
void R_DrawSplat_Tilted(drawspandata_t* ds);
|
||||
void R_DrawTranslucentSplat_Tilted(drawspandata_t* ds);
|
||||
void R_DrawFloorSprite_Tilted(drawspandata_t* ds);
|
||||
void R_DrawTranslucentFloorSprite_Tilted(drawspandata_t* ds);
|
||||
void R_DrawTranslucentWaterSpan_Tilted(drawspandata_t* ds);
|
||||
void R_DrawFogSpan_Tilted(drawspandata_t* ds);
|
||||
|
||||
void R_DrawFloorSprite_8(drawspandata_t* ds);
|
||||
void R_DrawTranslucentFloorSprite_8(drawspandata_t* ds);
|
||||
void R_DrawTiltedFloorSprite_8(drawspandata_t* ds);
|
||||
void R_DrawTiltedTranslucentFloorSprite_8(drawspandata_t* ds);
|
||||
void R_DrawSpan_NPO2(drawspandata_t* ds);
|
||||
void R_DrawTranslucentSpan_NPO2(drawspandata_t* ds);
|
||||
void R_DrawSplat_NPO2(drawspandata_t* ds);
|
||||
void R_DrawTranslucentSplat_NPO2(drawspandata_t* ds);
|
||||
void R_DrawFloorSprite_NPO2(drawspandata_t* ds);
|
||||
void R_DrawTranslucentFloorSprite_NPO2(drawspandata_t* ds);
|
||||
void R_DrawTranslucentWaterSpan_NPO2(drawspandata_t* ds);
|
||||
|
||||
void R_CalcTiltedLighting(INT32 *lightbuffer, INT32 x1, INT32 x2, fixed_t start, fixed_t end);
|
||||
void R_DrawSpan_Tilted_NPO2(drawspandata_t* ds);
|
||||
void R_DrawTranslucentSpan_Tilted_NPO2(drawspandata_t* ds);
|
||||
void R_DrawSplat_Tilted_NPO2(drawspandata_t* ds);
|
||||
void R_DrawTranslucentSplat_Tilted_NPO2(drawspandata_t* ds);
|
||||
void R_DrawFloorSprite_Tilted_NPO2(drawspandata_t* ds);
|
||||
void R_DrawTranslucentFloorSprite_Tilted_NPO2(drawspandata_t* ds);
|
||||
void R_DrawTranslucentWaterSpan_Tilted_NPO2(drawspandata_t* ds);
|
||||
|
||||
void R_DrawTranslucentWaterSpan_8(drawspandata_t* ds);
|
||||
void R_DrawTiltedTranslucentWaterSpan_8(drawspandata_t* ds);
|
||||
void R_DrawSpan_Brightmap(drawspandata_t* ds);
|
||||
void R_DrawTranslucentSpan_Brightmap(drawspandata_t* ds);
|
||||
void R_DrawSplat_Brightmap(drawspandata_t* ds);
|
||||
void R_DrawTranslucentSplat_Brightmap(drawspandata_t* ds);
|
||||
void R_DrawFloorSprite_Brightmap(drawspandata_t* ds);
|
||||
void R_DrawTranslucentFloorSprite_Brightmap(drawspandata_t* ds);
|
||||
void R_DrawTranslucentWaterSpan_Brightmap(drawspandata_t* ds);
|
||||
|
||||
void R_DrawFogSpan_8(drawspandata_t* ds);
|
||||
void R_DrawSpan_Tilted_Brightmap(drawspandata_t* ds);
|
||||
void R_DrawTranslucentSpan_Tilted_Brightmap(drawspandata_t* ds);
|
||||
void R_DrawSplat_Tilted_Brightmap(drawspandata_t* ds);
|
||||
void R_DrawTranslucentSplat_Tilted_Brightmap(drawspandata_t* ds);
|
||||
void R_DrawFloorSprite_Tilted_Brightmap(drawspandata_t* ds);
|
||||
void R_DrawTranslucentFloorSprite_Tilted_Brightmap(drawspandata_t* ds);
|
||||
void R_DrawTranslucentWaterSpan_Tilted_Brightmap(drawspandata_t* ds);
|
||||
|
||||
// Lactozilla: Non-powers-of-two
|
||||
void R_DrawSpan_NPO2_8(drawspandata_t* ds);
|
||||
void R_DrawTranslucentSpan_NPO2_8(drawspandata_t* ds);
|
||||
void R_DrawTiltedSpan_NPO2_8(drawspandata_t* ds);
|
||||
void R_DrawTiltedTranslucentSpan_NPO2_8(drawspandata_t* ds);
|
||||
void R_DrawSpan_Brightmap_NPO2(drawspandata_t* ds);
|
||||
void R_DrawTranslucentSpan_Brightmap_NPO2(drawspandata_t* ds);
|
||||
void R_DrawSplat_Brightmap_NPO2(drawspandata_t* ds);
|
||||
void R_DrawTranslucentSplat_Brightmap_NPO2(drawspandata_t* ds);
|
||||
void R_DrawFloorSprite_Brightmap_NPO2(drawspandata_t* ds);
|
||||
void R_DrawTranslucentFloorSprite_Brightmap_NPO2(drawspandata_t* ds);
|
||||
void R_DrawTranslucentWaterSpan_Brightmap_NPO2(drawspandata_t* ds);
|
||||
|
||||
void R_DrawSplat_NPO2_8(drawspandata_t* ds);
|
||||
void R_DrawTranslucentSplat_NPO2_8(drawspandata_t* ds);
|
||||
void R_DrawTiltedSplat_NPO2_8(drawspandata_t* ds);
|
||||
|
||||
void R_DrawFloorSprite_NPO2_8(drawspandata_t* ds);
|
||||
void R_DrawTranslucentFloorSprite_NPO2_8(drawspandata_t* ds);
|
||||
void R_DrawTiltedFloorSprite_NPO2_8(drawspandata_t* ds);
|
||||
void R_DrawTiltedTranslucentFloorSprite_NPO2_8(drawspandata_t* ds);
|
||||
|
||||
void R_DrawTranslucentWaterSpan_NPO2_8(drawspandata_t* ds);
|
||||
void R_DrawTiltedTranslucentWaterSpan_NPO2_8(drawspandata_t* ds);
|
||||
void R_DrawSpan_Tilted_Brightmap_NPO2(drawspandata_t* ds);
|
||||
void R_DrawTranslucentSpan_Tilted_Brightmap_NPO2(drawspandata_t* ds);
|
||||
void R_DrawSplat_Tilted_Brightmap_NPO2(drawspandata_t* ds);
|
||||
void R_DrawTranslucentSplat_Tilted_Brightmap_NPO2(drawspandata_t* ds);
|
||||
void R_DrawFloorSprite_Tilted_Brightmap_NPO2(drawspandata_t* ds);
|
||||
void R_DrawTranslucentFloorSprite_Tilted_Brightmap_NPO2(drawspandata_t* ds);
|
||||
void R_DrawTranslucentWaterSpan_Tilted_Brightmap_NPO2(drawspandata_t* ds);
|
||||
|
||||
// Debugging - highlight surfaces in flat colors
|
||||
void R_DrawColumn_Flat_8(drawcolumndata_t* dc);
|
||||
void R_DrawSpan_Flat_8(drawspandata_t* ds);
|
||||
void R_DrawTiltedSpan_Flat_8(drawspandata_t* ds);
|
||||
|
||||
#ifdef USEASM
|
||||
void ASMCALL R_DrawColumn_8_ASM(void);
|
||||
void ASMCALL R_DrawShadeColumn_8_ASM(void);
|
||||
void ASMCALL R_DrawTranslucentColumn_8_ASM(void);
|
||||
void ASMCALL R_Draw2sMultiPatchColumn_8_ASM(void);
|
||||
|
||||
void ASMCALL R_DrawColumn_8_MMX(void);
|
||||
|
||||
void ASMCALL R_Draw2sMultiPatchColumn_8_MMX(void);
|
||||
void ASMCALL R_DrawSpan_8_MMX(void);
|
||||
#endif
|
||||
|
||||
// ------------------
|
||||
// 16bpp DRAWING CODE
|
||||
// ------------------
|
||||
|
||||
#ifdef HIGHCOLOR
|
||||
void R_DrawColumn_16(void);
|
||||
void R_DrawWallColumn_16(void);
|
||||
void R_DrawTranslucentColumn_16(void);
|
||||
void R_DrawTranslatedColumn_16(void);
|
||||
void R_DrawSpan_16(void);
|
||||
#endif
|
||||
void R_DrawColumn_Flat(drawcolumndata_t* dc);
|
||||
void R_DrawSpan_Flat(drawspandata_t* ds);
|
||||
void R_DrawTiltedSpan_Flat(drawspandata_t* ds);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
#endif // __cplusplus
|
||||
|
||||
// =========================================================================
|
||||
#endif // __R_DRAW__
|
||||
|
|
|
|||
214
src/r_draw16.c
214
src/r_draw16.c
|
|
@ -1,214 +0,0 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2020 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
// See the 'LICENSE' file for more details.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \file r_draw16.c
|
||||
/// \brief 16bpp (HIGHCOLOR) span/column drawer functions
|
||||
/// \note no includes because this is included as part of r_draw.c
|
||||
|
||||
// ==========================================================================
|
||||
// COLUMNS
|
||||
// ==========================================================================
|
||||
|
||||
/// \brief kick out the upper bit of each component (we're in 5 : 5 : 5)
|
||||
#define HIMASK1 0x7bde
|
||||
|
||||
/** \brief The R_DrawColumn_16 function
|
||||
standard upto 128high posts column drawer
|
||||
*/
|
||||
void R_DrawColumn_16(void)
|
||||
{
|
||||
INT32 count;
|
||||
INT16 *dest;
|
||||
fixed_t frac, fracstep;
|
||||
|
||||
count = dc_yh - dc_yl + 1;
|
||||
|
||||
// Zero length, column does not exceed a pixel.
|
||||
if (count <= 0)
|
||||
return;
|
||||
|
||||
#ifdef RANGECHECK
|
||||
if (dc_x >= vid.width || dc_yl < 0 || dc_yh >= vid.height)
|
||||
I_Error("R_DrawColumn_16: %d to %d at %d", dc_yl, dc_yh, dc_x);
|
||||
#endif
|
||||
|
||||
// Framebuffer destination address.
|
||||
// Use ylookup LUT to avoid multiply with ScreenWidth.
|
||||
// Use columnofs LUT for subwindows?
|
||||
dest = (INT16 *)(void *)(ylookup[dc_yl] + columnofs[dc_x]);
|
||||
|
||||
// Determine scaling, which is the only mapping to be done.
|
||||
fracstep = dc_iscale;
|
||||
frac = dc_texturemid + (dc_yl - centery)*fracstep;
|
||||
|
||||
// Inner loop that does the actual texture mapping, e.g. a DDA-like scaling.
|
||||
// This is as fast as it gets.
|
||||
|
||||
do
|
||||
{
|
||||
// Re-map color indices from wall texture column using a lighting/special effects LUT.
|
||||
*dest = hicolormaps[((INT16 *)(void *)dc_source)[(frac>>FRACBITS)&127]>>1];
|
||||
|
||||
dest += vid.width;
|
||||
frac += fracstep;
|
||||
} while (--count);
|
||||
}
|
||||
|
||||
/** \brief The R_DrawWallColumn_16 function
|
||||
LAME cutnpaste: same as R_DrawColumn_16 but wraps around 256
|
||||
instead of 128 for the tall sky textures (256x240)
|
||||
*/
|
||||
void R_DrawWallColumn_16(void)
|
||||
{
|
||||
INT32 count;
|
||||
INT16 *dest;
|
||||
fixed_t frac, fracstep;
|
||||
|
||||
count = dc_yh - dc_yl + 1;
|
||||
|
||||
// Zero length, column does not exceed a pixel.
|
||||
if (count <= 0)
|
||||
return;
|
||||
|
||||
#ifdef RANGECHECK
|
||||
if (dc_x >= vid.width || dc_yl < 0 || dc_yh >= vid.height)
|
||||
I_Error("R_DrawWallColumn_16: %d to %d at %d", dc_yl, dc_yh, dc_x);
|
||||
#endif
|
||||
|
||||
dest = (INT16 *)(void *)(ylookup[dc_yl] + columnofs[dc_x]);
|
||||
|
||||
fracstep = dc_iscale;
|
||||
frac = dc_texturemid + (dc_yl - centery)*fracstep;
|
||||
|
||||
do
|
||||
{
|
||||
*dest = hicolormaps[((INT16 *)(void *)dc_source)[(frac>>FRACBITS)&255]>>1];
|
||||
|
||||
dest += vid.width;
|
||||
frac += fracstep;
|
||||
} while (--count);
|
||||
}
|
||||
|
||||
/** \brief The R_DrawTranslucentColumn_16 function
|
||||
LAME cutnpaste: same as R_DrawColumn_16 but does
|
||||
translucent
|
||||
*/
|
||||
void R_DrawTranslucentColumn_16(void)
|
||||
{
|
||||
INT32 count;
|
||||
INT16 *dest;
|
||||
fixed_t frac, fracstep;
|
||||
|
||||
// check out coords for src*
|
||||
if ((dc_yl < 0) || (dc_x >= vid.width))
|
||||
return;
|
||||
|
||||
count = dc_yh - dc_yl;
|
||||
if (count < 0)
|
||||
return;
|
||||
|
||||
#ifdef RANGECHECK
|
||||
if (dc_x >= vid.width || dc_yl < 0 || dc_yh >= vid.height)
|
||||
I_Error("R_DrawTranslucentColumn_16: %d to %d at %d", dc_yl, dc_yh, dc_x);
|
||||
#endif
|
||||
|
||||
// FIXME. As above.
|
||||
dest = (INT16 *)(void *)(ylookup[dc_yl] + columnofs[dc_x]);
|
||||
|
||||
// Looks familiar.
|
||||
fracstep = dc_iscale;
|
||||
frac = dc_texturemid + (dc_yl - centery)*fracstep;
|
||||
|
||||
// Here we do an additional index re-mapping.
|
||||
do
|
||||
{
|
||||
*dest = (INT16)((INT16)((color8to16[dc_source[frac>>FRACBITS]]>>1) & 0x39ce)
|
||||
+ (INT16)(((*dest & HIMASK1)) & 0x7fff));
|
||||
|
||||
dest += vid.width;
|
||||
frac += fracstep;
|
||||
} while (count--);
|
||||
}
|
||||
|
||||
/** \brief The R_DrawTranslatedColumn_16 function
|
||||
?
|
||||
*/
|
||||
void R_DrawTranslatedColumn_16(void)
|
||||
{
|
||||
INT32 count;
|
||||
INT16 *dest;
|
||||
fixed_t frac, fracstep;
|
||||
|
||||
count = dc_yh - dc_yl;
|
||||
if (count < 0)
|
||||
return;
|
||||
|
||||
#ifdef RANGECHECK
|
||||
if (dc_x >= vid.width || dc_yl < 0 || dc_yh >= vid.height)
|
||||
I_Error("R_DrawTranslatedColumn_16: %d to %d at %d", dc_yl, dc_yh, dc_x);
|
||||
#endif
|
||||
|
||||
dest = (INT16 *)(void *)(ylookup[dc_yl] + columnofs[dc_x]);
|
||||
|
||||
// Looks familiar.
|
||||
fracstep = dc_iscale;
|
||||
frac = dc_texturemid + (dc_yl - centery)*fracstep;
|
||||
|
||||
// Here we do an additional index re-mapping.
|
||||
do
|
||||
{
|
||||
*dest = color8to16[dc_colormap[dc_translation[dc_source[frac>>FRACBITS]]]];
|
||||
dest += vid.width;
|
||||
|
||||
frac += fracstep;
|
||||
} while (count--);
|
||||
}
|
||||
|
||||
// ==========================================================================
|
||||
// SPANS
|
||||
// ==========================================================================
|
||||
|
||||
/** \brief The R_*_16 function
|
||||
Draws the actual span.
|
||||
*/
|
||||
void R_DrawSpan_16(void)
|
||||
{
|
||||
fixed_t xfrac, yfrac;
|
||||
INT16 *dest;
|
||||
INT32 count, spot;
|
||||
|
||||
#ifdef RANGECHECK
|
||||
if (ds_x2 < ds_x1 || ds_x1 < 0 || ds_x2 >= vid.width || ds_y > vid.height)
|
||||
I_Error("R_DrawSpan_16: %d to %d at %d", ds_x1, ds_x2, ds_y);
|
||||
#endif
|
||||
|
||||
xfrac = ds_xfrac;
|
||||
yfrac = ds_yfrac;
|
||||
|
||||
dest = (INT16 *)(void *)(ylookup[ds_y] + columnofs[ds_x1]);
|
||||
|
||||
// We do not check for zero spans here?
|
||||
count = ds_x2 - ds_x1;
|
||||
|
||||
if (count <= 0) // We do now!
|
||||
return;
|
||||
|
||||
do
|
||||
{
|
||||
// Current texture index in u, v.
|
||||
spot = ((yfrac>>(16-6))&(63*64)) + ((xfrac>>16)&63);
|
||||
|
||||
// Lookup pixel from flat texture tile, re-index using light/colormap.
|
||||
*dest++ = hicolormaps[((INT16 *)(void *)ds_source)[spot]>>1];
|
||||
|
||||
// Next step in u, v.
|
||||
xfrac += ds_xstep;
|
||||
yfrac += ds_ystep;
|
||||
} while (count--);
|
||||
}
|
||||
2564
src/r_draw8.c
2564
src/r_draw8.c
File diff suppressed because it is too large
Load diff
|
|
@ -1,80 +0,0 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2020 by Sonic Team Junior.
|
||||
// Copyright (C) 2023 by Kart Krew.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
// See the 'LICENSE' file for more details.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \file r_draw8_flat.c
|
||||
/// \brief 8bpp span/column drawer functions for debugging (draws in flat colors only)
|
||||
/// \note no includes because this is included as part of r_draw.c
|
||||
|
||||
void R_DrawColumn_Flat_8 (drawcolumndata_t* dc)
|
||||
{
|
||||
INT32 count;
|
||||
UINT8 color = dc->lightmap[dc->r8_flatcolor];
|
||||
register UINT8 *dest;
|
||||
|
||||
count = dc->yh - dc->yl;
|
||||
|
||||
if (count < 0) // Zero length, column does not exceed a pixel.
|
||||
return;
|
||||
|
||||
#ifdef RANGECHECK
|
||||
if ((unsigned)dc->x >= (unsigned)vid.width || dc->yl < 0 || dc->yh >= vid.height)
|
||||
return;
|
||||
#endif
|
||||
|
||||
// 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];
|
||||
|
||||
count++;
|
||||
|
||||
do
|
||||
{
|
||||
*dest = color;
|
||||
dest += vid.width;
|
||||
} while (--count);
|
||||
}
|
||||
|
||||
void R_DrawSpan_Flat_8 (drawspandata_t* ds)
|
||||
{
|
||||
UINT8 *dest = ylookup[ds->y] + columnofs[ds->x1];
|
||||
|
||||
memset(dest, ds->colormap[ds->r8_flatcolor], (ds->x2 - ds->x1) + 1);
|
||||
}
|
||||
|
||||
void R_DrawTiltedSpan_Flat_8 (drawspandata_t* ds)
|
||||
{
|
||||
// x1, x2 = ds_x1, ds_x2
|
||||
int width = ds->x2 - ds->x1;
|
||||
double iz = ds->szp.z + ds->szp.y*(centery-ds->y) + ds->szp.x*(ds->x1-centerx);
|
||||
INT32 tiltlighting[MAXVIDWIDTH];
|
||||
|
||||
UINT8 *dest = ylookup[ds->y];
|
||||
|
||||
// Lighting is simple. It's just linear interpolation from start to end
|
||||
{
|
||||
float planelightfloat = PLANELIGHTFLOAT;
|
||||
float lightstart, lightend;
|
||||
|
||||
lightend = (iz + ds->szp.x*width) * planelightfloat;
|
||||
lightstart = iz * planelightfloat;
|
||||
|
||||
R_CalcTiltedLighting(tiltlighting, ds->x1, ds->x2, FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend));
|
||||
//CONS_Printf("tilted lighting %f to %f (foc %f)\n", lightstart, lightend, focallengthf);
|
||||
}
|
||||
|
||||
while (ds->x1 <= ds->x2)
|
||||
{
|
||||
dest[ds->x1] = ds->planezlight[tiltlighting[ds->x1]][ds->r8_flatcolor];
|
||||
ds->x1++;
|
||||
}
|
||||
}
|
||||
1618
src/r_draw8_npo2.c
1618
src/r_draw8_npo2.c
File diff suppressed because it is too large
Load diff
430
src/r_draw_column.cpp
Normal file
430
src/r_draw_column.cpp
Normal file
|
|
@ -0,0 +1,430 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2021 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
// See the 'LICENSE' file for more details.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \file r_draw_column.cpp
|
||||
/// \brief column drawer functions
|
||||
/// \note no includes because this is included as part of r_draw.cpp
|
||||
|
||||
// ==========================================================================
|
||||
// COLUMNS
|
||||
// ==========================================================================
|
||||
|
||||
// A column is a vertical slice/span of a wall texture that uses
|
||||
// a has a constant z depth from top to bottom.
|
||||
//
|
||||
|
||||
enum DrawColumnType
|
||||
{
|
||||
DC_BASIC = 0x0000,
|
||||
DC_COLORMAP = 0x0001,
|
||||
DC_TRANSMAP = 0x0002,
|
||||
DC_BRIGHTMAP = 0x0004,
|
||||
DC_HOLES = 0x0008,
|
||||
DC_LIGHTLIST = 0x0010,
|
||||
};
|
||||
|
||||
template<DrawColumnType Type>
|
||||
static constexpr UINT8 R_GetColumnTranslated(drawcolumndata_t* dc, UINT8 col)
|
||||
{
|
||||
if constexpr (Type & DrawColumnType::DC_COLORMAP)
|
||||
{
|
||||
return dc->translation[col];
|
||||
}
|
||||
else
|
||||
{
|
||||
return col;
|
||||
}
|
||||
}
|
||||
|
||||
template<DrawColumnType Type>
|
||||
static constexpr UINT8 R_GetColumnBrightmapped(drawcolumndata_t* dc, UINT32 bit, UINT8 col)
|
||||
{
|
||||
col = R_GetColumnTranslated<Type>(dc, col);
|
||||
|
||||
if constexpr (Type & DrawColumnType::DC_BRIGHTMAP)
|
||||
{
|
||||
if (dc->brightmap[bit] == BRIGHTPIXEL)
|
||||
{
|
||||
return dc->fullbright[col];
|
||||
}
|
||||
}
|
||||
|
||||
return dc->colormap[col];
|
||||
}
|
||||
|
||||
template<DrawColumnType Type>
|
||||
static constexpr UINT8 R_GetColumnTranslucent(drawcolumndata_t* dc, UINT8 *dest, UINT32 bit, UINT8 col)
|
||||
{
|
||||
col = R_GetColumnBrightmapped<Type>(dc, bit, col);
|
||||
|
||||
if constexpr (Type & DrawColumnType::DC_TRANSMAP)
|
||||
{
|
||||
return *(dc->transmap + (col << 8) + (*dest));
|
||||
}
|
||||
else
|
||||
{
|
||||
return col;
|
||||
}
|
||||
}
|
||||
|
||||
template<DrawColumnType Type>
|
||||
static constexpr UINT8 R_DrawColumnPixel(drawcolumndata_t* dc, UINT8 *dest, UINT32 bit)
|
||||
{
|
||||
UINT8 col = dc->source[bit];
|
||||
|
||||
if constexpr (Type & DrawColumnType::DC_HOLES)
|
||||
{
|
||||
if (col == TRANSPARENTPIXEL)
|
||||
{
|
||||
return *dest;
|
||||
}
|
||||
}
|
||||
|
||||
return R_GetColumnTranslucent<Type>(dc, dest, bit, col);
|
||||
}
|
||||
|
||||
/** \brief The R_DrawColumn function
|
||||
Experiment to make software go faster. Taken from the Boom source
|
||||
*/
|
||||
template<DrawColumnType Type>
|
||||
static void R_DrawColumnTemplate(drawcolumndata_t *dc)
|
||||
{
|
||||
INT32 count;
|
||||
UINT8 *dest;
|
||||
|
||||
count = dc->yh - dc->yl;
|
||||
|
||||
if (count < 0) // Zero length, column does not exceed a pixel.
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef RANGECHECK
|
||||
if ((unsigned)dc->x >= (unsigned)vid.width || dc->yl < 0 || dc->yh >= vid.height)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if constexpr (Type & DrawColumnType::DC_LIGHTLIST)
|
||||
{
|
||||
constexpr DrawColumnType NewType = static_cast<DrawColumnType>(Type & ~DC_LIGHTLIST);
|
||||
INT32 i, realyh, height, bheight = 0, solid = 0;
|
||||
drawcolumndata_t dc_copy = *dc;
|
||||
|
||||
realyh = dc_copy.yh;
|
||||
|
||||
// This runs through the lightlist from top to bottom and cuts up the column accordingly.
|
||||
for (i = 0; i < dc_copy.numlights; i++)
|
||||
{
|
||||
// If the height of the light is above the column, get the colormap
|
||||
// anyway because the lighting of the top should be affected.
|
||||
solid = dc_copy.lightlist[i].flags & FOF_CUTSOLIDS;
|
||||
height = dc_copy.lightlist[i].height >> LIGHTSCALESHIFT;
|
||||
|
||||
if (solid)
|
||||
{
|
||||
bheight = dc_copy.lightlist[i].botheight >> LIGHTSCALESHIFT;
|
||||
|
||||
if (bheight < height)
|
||||
{
|
||||
// confounded slopes sometimes allow partial invertedness,
|
||||
// even including cases where the top and bottom heights
|
||||
// should actually be the same!
|
||||
// swap the height values as a workaround for this quirk
|
||||
INT32 temp = height;
|
||||
height = bheight;
|
||||
bheight = temp;
|
||||
}
|
||||
}
|
||||
|
||||
if (height <= dc_copy.yl)
|
||||
{
|
||||
dc_copy.colormap = dc_copy.lightlist[i].rcolormap;
|
||||
dc_copy.fullbright = colormaps;
|
||||
|
||||
if (encoremap)
|
||||
{
|
||||
dc_copy.colormap += COLORMAP_REMAPOFFSET;
|
||||
dc_copy.fullbright += COLORMAP_REMAPOFFSET;
|
||||
}
|
||||
|
||||
if (solid && dc_copy.yl < bheight)
|
||||
{
|
||||
dc_copy.yl = bheight;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// Found a break in the column!
|
||||
dc_copy.yh = height;
|
||||
|
||||
if (dc_copy.yh > realyh)
|
||||
{
|
||||
dc_copy.yh = realyh;
|
||||
}
|
||||
|
||||
R_DrawColumnTemplate<NewType>(&dc_copy);
|
||||
if (solid)
|
||||
{
|
||||
dc_copy.yl = bheight;
|
||||
}
|
||||
else
|
||||
{
|
||||
dc_copy.yl = dc_copy.yh + 1;
|
||||
}
|
||||
|
||||
dc_copy.colormap = dc_copy.lightlist[i].rcolormap;
|
||||
dc_copy.fullbright = colormaps;
|
||||
if (encoremap)
|
||||
{
|
||||
dc_copy.colormap += COLORMAP_REMAPOFFSET;
|
||||
dc_copy.fullbright += COLORMAP_REMAPOFFSET;
|
||||
}
|
||||
}
|
||||
|
||||
dc_copy.yh = realyh;
|
||||
|
||||
if (dc_copy.yl <= realyh)
|
||||
{
|
||||
R_DrawColumnTemplate<NewType>(&dc_copy);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fixed_t fracstep;
|
||||
fixed_t frac;
|
||||
INT32 heightmask;
|
||||
INT32 npow2min;
|
||||
INT32 npow2max;
|
||||
|
||||
// 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];
|
||||
|
||||
count++;
|
||||
|
||||
// Determine scaling, which is the only mapping to be done.
|
||||
fracstep = dc->iscale;
|
||||
//frac = dc_texturemid + (dc_yl - centery)*fracstep;
|
||||
frac = (dc->texturemid + FixedMul((dc->yl << FRACBITS) - centeryfrac, fracstep)) * (!dc->hires);
|
||||
|
||||
// Inner loop that does the actual texture mapping, e.g. a DDA-like scaling.
|
||||
// This is as fast as it gets.
|
||||
heightmask = dc->texheight-1;
|
||||
if (dc->sourcelength <= 0)
|
||||
{
|
||||
// Note: we need to unconditionally clamp in npow2 draw loop to avoid a CPU branch
|
||||
// This is to just render it effectively the identity function.
|
||||
npow2min = INT32_MIN;
|
||||
npow2max = INT32_MAX;
|
||||
}
|
||||
else
|
||||
{
|
||||
npow2min = -1;
|
||||
npow2max = dc->sourcelength;
|
||||
}
|
||||
|
||||
if (dc->texheight & heightmask) // not a power of 2 -- killough
|
||||
{
|
||||
heightmask++;
|
||||
heightmask <<= FRACBITS;
|
||||
|
||||
if (frac < 0)
|
||||
{
|
||||
while ((frac += heightmask) < 0)
|
||||
{
|
||||
;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (frac >= heightmask)
|
||||
{
|
||||
frac -= heightmask;
|
||||
}
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
// Re-map color indices from wall texture column
|
||||
// using a lighting/special effects LUT.
|
||||
// heightmask is the Tutti-Frutti fix
|
||||
|
||||
// -1 is the lower clamp bound because column posts have a "safe" byte before the real data
|
||||
// and a few bytes after as well
|
||||
*dest = R_DrawColumnPixel<Type>(dc, dest, std::clamp(frac >> FRACBITS, npow2min, npow2max));
|
||||
|
||||
dest += vid.width;
|
||||
|
||||
// Avoid overflow.
|
||||
if (fracstep > 0x7FFFFFFF - frac)
|
||||
{
|
||||
frac += fracstep - heightmask;
|
||||
}
|
||||
else
|
||||
{
|
||||
frac += fracstep;
|
||||
}
|
||||
|
||||
while (frac >= heightmask)
|
||||
{
|
||||
frac -= heightmask;
|
||||
}
|
||||
}
|
||||
while (--count);
|
||||
}
|
||||
else
|
||||
{
|
||||
while ((count -= 2) >= 0) // texture height is a power of 2
|
||||
{
|
||||
*dest = R_DrawColumnPixel<Type>(dc, dest, (frac>>FRACBITS) & heightmask);
|
||||
|
||||
dest += vid.width;
|
||||
frac += fracstep;
|
||||
|
||||
*dest = R_DrawColumnPixel<Type>(dc, dest, (frac>>FRACBITS) & heightmask);
|
||||
|
||||
dest += vid.width;
|
||||
frac += fracstep;
|
||||
}
|
||||
|
||||
if (count & 1)
|
||||
{
|
||||
*dest = R_DrawColumnPixel<Type>(dc, dest, (frac>>FRACBITS) & heightmask);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define DEFINE_COLUMN_FUNC(name, flags) \
|
||||
void name(drawcolumndata_t *dc) \
|
||||
{ \
|
||||
ZoneScoped; \
|
||||
constexpr DrawColumnType opt = static_cast<DrawColumnType>(flags); \
|
||||
R_DrawColumnTemplate<opt>(dc); \
|
||||
}
|
||||
|
||||
#define DEFINE_COLUMN_COMBO(name, flags) \
|
||||
DEFINE_COLUMN_FUNC(name, flags) \
|
||||
DEFINE_COLUMN_FUNC(name ## _Brightmap, flags|DC_BRIGHTMAP)
|
||||
|
||||
DEFINE_COLUMN_COMBO(R_DrawColumn, DC_BASIC)
|
||||
DEFINE_COLUMN_COMBO(R_DrawTranslucentColumn, DC_TRANSMAP)
|
||||
DEFINE_COLUMN_COMBO(R_DrawTranslatedColumn, DC_COLORMAP)
|
||||
DEFINE_COLUMN_COMBO(R_DrawColumnShadowed, DC_LIGHTLIST)
|
||||
DEFINE_COLUMN_COMBO(R_DrawTranslatedTranslucentColumn, DC_COLORMAP|DC_TRANSMAP)
|
||||
DEFINE_COLUMN_COMBO(R_Draw2sMultiPatchColumn, DC_HOLES)
|
||||
DEFINE_COLUMN_COMBO(R_Draw2sMultiPatchTranslucentColumn, DC_HOLES|DC_TRANSMAP)
|
||||
|
||||
void R_DrawFogColumn(drawcolumndata_t *dc)
|
||||
{
|
||||
ZoneScoped;
|
||||
|
||||
INT32 count;
|
||||
UINT8 *dest;
|
||||
|
||||
count = dc->yh - dc->yl;
|
||||
|
||||
// Zero length, column does not exceed a pixel.
|
||||
if (count < 0)
|
||||
return;
|
||||
|
||||
#ifdef RANGECHECK
|
||||
if ((unsigned)dc->x >= (unsigned)vid.width || dc->yl < 0 || dc->yh >= vid.height)
|
||||
return;
|
||||
#endif
|
||||
|
||||
// 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];
|
||||
|
||||
// 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;
|
||||
}
|
||||
while (count--);
|
||||
}
|
||||
|
||||
void R_DrawDropShadowColumn(drawcolumndata_t *dc)
|
||||
{
|
||||
ZoneScoped;
|
||||
|
||||
// Hack: A cut-down copy of R_DrawTranslucentColumn_8 that does not read texture
|
||||
// data since something about calculating the texture reading address for drop shadows is broken.
|
||||
// dc_texturemid and dc_iscale get wrong values for drop shadows, however those are not strictly
|
||||
// needed for the current design of the shadows, so this function bypasses the issue
|
||||
// by not using those variables at all.
|
||||
|
||||
INT32 count;
|
||||
UINT8 *dest;
|
||||
|
||||
count = dc->yh - dc->yl + 1;
|
||||
|
||||
if (count <= 0) // Zero length, column does not exceed a pixel.
|
||||
return;
|
||||
|
||||
dest = &topleft[dc->yl*vid.width + dc->x];
|
||||
|
||||
const UINT8 *transmap_offset = dc->transmap + (dc->shadowcolor << 8);
|
||||
while ((count -= 2) >= 0)
|
||||
{
|
||||
*dest = *(transmap_offset + (*dest));
|
||||
dest += vid.width;
|
||||
*dest = *(transmap_offset + (*dest));
|
||||
dest += vid.width;
|
||||
}
|
||||
|
||||
if (count & 1)
|
||||
*dest = *(transmap_offset + (*dest));
|
||||
}
|
||||
|
||||
void R_DrawColumn_Flat(drawcolumndata_t *dc)
|
||||
{
|
||||
ZoneScoped;
|
||||
|
||||
INT32 count;
|
||||
UINT8 color = dc->lightmap[dc->r8_flatcolor];
|
||||
UINT8 *dest;
|
||||
|
||||
count = dc->yh - dc->yl;
|
||||
|
||||
if (count < 0) // Zero length, column does not exceed a pixel.
|
||||
return;
|
||||
|
||||
#ifdef RANGECHECK
|
||||
if ((unsigned)dc->x >= (unsigned)vid.width || dc->yl < 0 || dc->yh >= vid.height)
|
||||
return;
|
||||
#endif
|
||||
|
||||
// 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];
|
||||
|
||||
count++;
|
||||
|
||||
do
|
||||
{
|
||||
*dest = color;
|
||||
dest += vid.width;
|
||||
}
|
||||
while (--count);
|
||||
}
|
||||
866
src/r_draw_span.cpp
Normal file
866
src/r_draw_span.cpp
Normal file
|
|
@ -0,0 +1,866 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2021 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
// See the 'LICENSE' file for more details.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \file r_draw_span.cpp
|
||||
/// \brief span drawer functions
|
||||
/// \note no includes because this is included as part of r_draw.cpp
|
||||
|
||||
using namespace libdivide;
|
||||
|
||||
// ==========================================================================
|
||||
// SPANS
|
||||
// ==========================================================================
|
||||
|
||||
#define SPANSIZE 16
|
||||
#define INVSPAN 0.0625f
|
||||
|
||||
// <Callum> 4194303 = (2048x2048)-1 (2048x2048 is maximum flat size)
|
||||
#define MAXFLATBYTES 4194303
|
||||
|
||||
#define PLANELIGHTFLOAT (BASEVIDWIDTH * BASEVIDWIDTH / vid.width / ds->zeroheight / 21.0f * FIXED_TO_FLOAT(fovtan[viewssnum]))
|
||||
|
||||
enum DrawSpanType
|
||||
{
|
||||
DS_BASIC = 0x0000,
|
||||
DS_COLORMAP = 0x0001,
|
||||
DS_TRANSMAP = 0x0002,
|
||||
DS_BRIGHTMAP = 0x0004,
|
||||
DS_HOLES = 0x0008,
|
||||
DS_RIPPLE = 0x0010,
|
||||
DS_SPRITE = 0x0020,
|
||||
};
|
||||
|
||||
template<DrawSpanType Type>
|
||||
static constexpr UINT8 R_GetSpanTranslated(drawspandata_t* ds, UINT8 col)
|
||||
{
|
||||
if constexpr (Type & DrawSpanType::DS_COLORMAP)
|
||||
{
|
||||
return ds->translation[col];
|
||||
}
|
||||
else
|
||||
{
|
||||
return col;
|
||||
}
|
||||
}
|
||||
|
||||
template<DrawSpanType Type>
|
||||
static constexpr UINT8 R_GetSpanBrightmapped(drawspandata_t* ds, UINT8 *colormap, UINT32 bit, UINT8 col)
|
||||
{
|
||||
col = R_GetSpanTranslated<Type>(ds, col);
|
||||
|
||||
if constexpr (Type & DrawSpanType::DS_BRIGHTMAP)
|
||||
{
|
||||
UINT8 brightCol = 31;
|
||||
|
||||
if constexpr (Type & DrawSpanType::DS_SPRITE)
|
||||
{
|
||||
UINT16 *spriteSource = reinterpret_cast<UINT16 *>(ds->brightmap);
|
||||
UINT16 spriteCol = spriteSource[bit];
|
||||
|
||||
if (spriteCol & 0xFF00)
|
||||
{
|
||||
brightCol = (spriteCol & 0xFF);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
brightCol = ds->brightmap[bit];
|
||||
}
|
||||
|
||||
if (brightCol == BRIGHTPIXEL)
|
||||
{
|
||||
return ds->fullbright[col];
|
||||
}
|
||||
}
|
||||
|
||||
return colormap[col];
|
||||
}
|
||||
|
||||
template<DrawSpanType Type>
|
||||
static constexpr UINT8 R_GetSpanTranslucent(drawspandata_t* ds, UINT8 *dsrc, UINT8 *colormap, UINT32 bit, UINT8 col)
|
||||
{
|
||||
col = R_GetSpanBrightmapped<Type>(ds, colormap, bit, col);
|
||||
|
||||
if constexpr (Type & DrawSpanType::DS_TRANSMAP)
|
||||
{
|
||||
return *(ds->transmap + (col << 8) + (*dsrc));
|
||||
}
|
||||
else
|
||||
{
|
||||
return col;
|
||||
}
|
||||
}
|
||||
|
||||
template<DrawSpanType Type>
|
||||
static constexpr UINT8 R_DrawSpanPixel(drawspandata_t* ds, UINT8 *dsrc, UINT8 *colormap, UINT32 bit)
|
||||
{
|
||||
UINT8 col = 0;
|
||||
|
||||
if constexpr (Type & DrawSpanType::DS_SPRITE)
|
||||
{
|
||||
UINT16 *spriteSource = reinterpret_cast<UINT16 *>(ds->source);
|
||||
UINT16 spriteCol = spriteSource[bit];
|
||||
|
||||
if (spriteCol & 0xFF00)
|
||||
{
|
||||
col = (spriteCol & 0xFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
return *dsrc;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
col = ds->source[bit];
|
||||
}
|
||||
|
||||
if constexpr (Type & DrawSpanType::DS_HOLES)
|
||||
{
|
||||
if (col == TRANSPARENTPIXEL)
|
||||
{
|
||||
return *dsrc;
|
||||
}
|
||||
}
|
||||
|
||||
return R_GetSpanTranslucent<Type>(ds, dsrc, colormap, bit, col);
|
||||
}
|
||||
|
||||
/** \brief The R_DrawSpan_8 function
|
||||
Draws the actual span.
|
||||
*/
|
||||
template<DrawSpanType Type>
|
||||
static void R_DrawSpanTemplate(drawspandata_t* ds)
|
||||
{
|
||||
fixed_t xposition;
|
||||
fixed_t yposition;
|
||||
fixed_t xstep, ystep;
|
||||
UINT32 bit;
|
||||
|
||||
UINT8 *dest;
|
||||
UINT8 *dsrc;
|
||||
|
||||
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height;
|
||||
|
||||
size_t count = (ds->x2 - ds->x1 + 1);
|
||||
size_t i;
|
||||
|
||||
xposition = ds->xfrac; yposition = ds->yfrac;
|
||||
xstep = ds->xstep; ystep = ds->ystep;
|
||||
|
||||
if constexpr (Type & DS_RIPPLE)
|
||||
{
|
||||
yposition += ds->waterofs;
|
||||
}
|
||||
|
||||
// SoM: we only need 6 bits for the integer part (0 thru 63) so the rest
|
||||
// can be used for the fraction part. This allows calculation of the memory address in the
|
||||
// texture with two shifts, an OR and one AND. (see below)
|
||||
// for texture sizes > 64 the amount of precision we can allow will decrease, but only by one
|
||||
// bit per power of two (obviously)
|
||||
// Ok, because I was able to eliminate the variable spot below, this function is now FASTER
|
||||
// than the original span renderer. Whodathunkit?
|
||||
xposition <<= ds->nflatshiftup; yposition <<= ds->nflatshiftup;
|
||||
xstep <<= ds->nflatshiftup; ystep <<= ds->nflatshiftup;
|
||||
|
||||
dest = ylookup[ds->y] + columnofs[ds->x1];
|
||||
if constexpr (Type & DS_RIPPLE)
|
||||
{
|
||||
dsrc = screens[1] + (ds->y + ds->bgofs) * vid.width + ds->x1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dsrc = dest;
|
||||
}
|
||||
|
||||
if (dest+8 > 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!
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
bit = (((UINT32)yposition >> ds->nflatyshift) & ds->nflatmask) | ((UINT32)xposition >> ds->nflatxshift);
|
||||
|
||||
dest[i] = R_DrawSpanPixel<Type>(ds, &dsrc[i], ds->colormap, bit);
|
||||
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
}
|
||||
|
||||
dest += 8;
|
||||
dsrc += 8;
|
||||
|
||||
count -= 8;
|
||||
}
|
||||
|
||||
while (count-- && dest <= deststop)
|
||||
{
|
||||
bit = (((UINT32)yposition >> ds->nflatyshift) & ds->nflatmask) | ((UINT32)xposition >> ds->nflatxshift);
|
||||
|
||||
*dest = R_DrawSpanPixel<Type>(ds, dsrc, ds->colormap, bit);
|
||||
|
||||
dest++;
|
||||
dsrc++;
|
||||
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
}
|
||||
}
|
||||
|
||||
// R_CalcTiltedLighting
|
||||
// Exactly what it says on the tin. I wish I wasn't too lazy to explain things properly.
|
||||
static void R_CalcTiltedLighting(INT32 *lightbuffer, INT32 x1, INT32 x2, fixed_t start, fixed_t end)
|
||||
{
|
||||
// ZDoom uses a different lighting setup to us, and I couldn't figure out how to adapt their version
|
||||
// of this function. Here's my own.
|
||||
INT32 left = x1, right = x2;
|
||||
fixed_t step = (end-start)/(x2 - x1 + 1);
|
||||
INT32 i;
|
||||
|
||||
// I wanna do some optimizing by checking for out-of-range segments on either side to fill in all at once,
|
||||
// but I'm too bad at coding to not crash the game trying to do that. I guess this is fast enough for now...
|
||||
|
||||
for (i = left; i <= right; i++)
|
||||
{
|
||||
lightbuffer[i] = (start += step) >> FRACBITS;
|
||||
|
||||
if (lightbuffer[i] < 0)
|
||||
{
|
||||
lightbuffer[i] = 0;
|
||||
}
|
||||
else if (lightbuffer[i] >= MAXLIGHTSCALE)
|
||||
{
|
||||
lightbuffer[i] = MAXLIGHTSCALE-1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<DrawSpanType Type>
|
||||
static void R_DrawTiltedSpanTemplate(drawspandata_t* ds)
|
||||
{
|
||||
// x1, x2 = ds_x1, ds_x2
|
||||
int width = ds->x2 - ds->x1;
|
||||
double iz, uz, vz;
|
||||
UINT32 u, v;
|
||||
int i;
|
||||
|
||||
UINT8 *colormap;
|
||||
UINT8 *dest;
|
||||
UINT8 *dsrc;
|
||||
|
||||
double startz, startu, startv;
|
||||
double izstep, uzstep, vzstep;
|
||||
double endz, endu, endv;
|
||||
UINT32 stepu, stepv;
|
||||
UINT32 bit;
|
||||
INT32 tiltlighting[MAXVIDWIDTH];
|
||||
|
||||
INT32 x1 = ds->x1;
|
||||
const INT32 nflatxshift = ds->nflatxshift;
|
||||
const INT32 nflatyshift = ds->nflatyshift;
|
||||
const INT32 nflatmask = ds->nflatmask;
|
||||
|
||||
iz = ds->szp.z + ds->szp.y*(centery-ds->y) + ds->szp.x*(ds->x1-centerx);
|
||||
|
||||
// Lighting is simple. It's just linear interpolation from start to end
|
||||
if constexpr (!(Type & DS_SPRITE))
|
||||
{
|
||||
float planelightfloat = PLANELIGHTFLOAT;
|
||||
float lightstart, lightend;
|
||||
|
||||
lightend = (iz + ds->szp.x*width) * planelightfloat;
|
||||
lightstart = iz * planelightfloat;
|
||||
|
||||
R_CalcTiltedLighting(tiltlighting, ds->x1, ds->x2, FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend));
|
||||
//CONS_Printf("tilted lighting %f to %f (foc %f)\n", lightstart, lightend, focallengthf);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
colormap = ds->colormap;
|
||||
|
||||
dest = ylookup[ds->y] + columnofs[ds->x1];
|
||||
if constexpr (Type & DS_RIPPLE)
|
||||
{
|
||||
dsrc = screens[1] + (ds->y + ds->bgofs) * vid.width + ds->x1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dsrc = dest;
|
||||
}
|
||||
|
||||
#if 0 // The "perfect" reference version of this routine. Pretty slow.
|
||||
// Use it only to see how things are supposed to look.
|
||||
i = 0;
|
||||
do
|
||||
{
|
||||
double z = 1.f/iz;
|
||||
u = (INT64)(uz*z);
|
||||
v = (INT64)(vz*z);
|
||||
|
||||
bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift);
|
||||
if constexpr (!(Type & DS_SPRITE))
|
||||
{
|
||||
colormap = planezlight[tiltlighting[ds->x1]] + (ds->colormap - colormaps);
|
||||
}
|
||||
*dest = R_DrawSpanPixel<Type>(ds, dsrc, colormap, bit);
|
||||
dest++;
|
||||
ds->x1++;
|
||||
dsrc++;
|
||||
iz += ds_szp->x;
|
||||
uz += ds_sup->x;
|
||||
vz += ds_svp->x;
|
||||
} while (--width >= 0);
|
||||
#else
|
||||
startz = 1.f/iz;
|
||||
startu = uz*startz;
|
||||
startv = vz*startz;
|
||||
|
||||
izstep = ds->szp.x * SPANSIZE;
|
||||
uzstep = ds->sup.x * SPANSIZE;
|
||||
vzstep = ds->svp.x * SPANSIZE;
|
||||
//x1 = 0;
|
||||
width++;
|
||||
|
||||
while (width >= SPANSIZE)
|
||||
{
|
||||
iz += izstep;
|
||||
uz += uzstep;
|
||||
vz += vzstep;
|
||||
|
||||
endz = 1.f/iz;
|
||||
endu = uz*endz;
|
||||
endv = vz*endz;
|
||||
stepu = (INT64)((endu - startu) * INVSPAN);
|
||||
stepv = (INT64)((endv - startv) * INVSPAN);
|
||||
u = (INT64)(startu);
|
||||
v = (INT64)(startv);
|
||||
|
||||
x1 = ds->x1;
|
||||
|
||||
for (i = 0; i < SPANSIZE; i++)
|
||||
{
|
||||
bit = (((v + stepv * i) >> nflatyshift) & nflatmask) | ((u + stepu * i) >> nflatxshift);
|
||||
|
||||
if constexpr (!(Type & DS_SPRITE))
|
||||
{
|
||||
colormap = ds->planezlight[tiltlighting[x1 + i]] + (ds->colormap - colormaps);
|
||||
}
|
||||
|
||||
dest[i] = R_DrawSpanPixel<Type>(ds, &dsrc[i], colormap, bit);
|
||||
}
|
||||
|
||||
ds->x1 += SPANSIZE;
|
||||
dest += SPANSIZE;
|
||||
dsrc += SPANSIZE;
|
||||
startu = endu;
|
||||
startv = endv;
|
||||
width -= SPANSIZE;
|
||||
}
|
||||
|
||||
if (width > 0)
|
||||
{
|
||||
if (width == 1)
|
||||
{
|
||||
u = (INT64)(startu);
|
||||
v = (INT64)(startv);
|
||||
bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift);
|
||||
if constexpr (!(Type & DS_SPRITE))
|
||||
{
|
||||
colormap = ds->planezlight[tiltlighting[ds->x1]] + (ds->colormap - colormaps);
|
||||
}
|
||||
*dest = R_DrawSpanPixel<Type>(ds, dsrc, colormap, bit);
|
||||
ds->x1++;
|
||||
}
|
||||
else
|
||||
{
|
||||
double left = width;
|
||||
iz += ds->szp.x * left;
|
||||
uz += ds->sup.x * left;
|
||||
vz += ds->svp.x * left;
|
||||
|
||||
endz = 1.f/iz;
|
||||
endu = uz*endz;
|
||||
endv = vz*endz;
|
||||
left = 1.f/left;
|
||||
stepu = (INT64)((endu - startu) * left);
|
||||
stepv = (INT64)((endv - startv) * left);
|
||||
u = (INT64)(startu);
|
||||
v = (INT64)(startv);
|
||||
|
||||
for (; width != 0; width--)
|
||||
{
|
||||
bit = ((v >> ds->nflatyshift) & ds->nflatmask) | (u >> ds->nflatxshift);
|
||||
if constexpr (!(Type & DS_SPRITE))
|
||||
{
|
||||
colormap = ds->planezlight[tiltlighting[ds->x1]] + (ds->colormap - colormaps);
|
||||
}
|
||||
*dest = R_DrawSpanPixel<Type>(ds, dsrc, colormap, bit);
|
||||
dest++;
|
||||
ds->x1++;
|
||||
dsrc++;
|
||||
u += stepu;
|
||||
v += stepv;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/** \brief The R_DrawSpan_NPO2 function
|
||||
Draws the actual span.
|
||||
*/
|
||||
template<DrawSpanType Type>
|
||||
static void R_DrawNPO2SpanTemplate(drawspandata_t* ds)
|
||||
{
|
||||
fixed_t xposition;
|
||||
fixed_t yposition;
|
||||
fixed_t xstep, ystep;
|
||||
fixed_t x, y;
|
||||
fixed_t fixedwidth, fixedheight;
|
||||
|
||||
UINT8 *dest;
|
||||
UINT8 *dsrc;
|
||||
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height;
|
||||
|
||||
size_t count = (ds->x2 - ds->x1 + 1);
|
||||
|
||||
xposition = ds->xfrac; yposition = ds->yfrac;
|
||||
xstep = ds->xstep; ystep = ds->ystep;
|
||||
|
||||
if constexpr (Type & DS_RIPPLE)
|
||||
{
|
||||
yposition += ds->waterofs;
|
||||
}
|
||||
|
||||
dest = ylookup[ds->y] + columnofs[ds->x1];
|
||||
|
||||
if constexpr (Type & DS_RIPPLE)
|
||||
{
|
||||
dsrc = screens[1] + (ds->y + ds->bgofs) * vid.width + ds->x1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dsrc = dest;
|
||||
}
|
||||
|
||||
if (dest+8 > deststop)
|
||||
return;
|
||||
|
||||
fixedwidth = ds->flatwidth << FRACBITS;
|
||||
fixedheight = ds->flatheight << FRACBITS;
|
||||
|
||||
// Fix xposition and yposition if they are out of bounds.
|
||||
if (xposition < 0)
|
||||
xposition = fixedwidth - ((UINT32)(fixedwidth - xposition) % fixedwidth);
|
||||
else if (xposition >= fixedwidth)
|
||||
xposition %= fixedwidth;
|
||||
if (yposition < 0)
|
||||
yposition = fixedheight - ((UINT32)(fixedheight - yposition) % fixedheight);
|
||||
else if (yposition >= fixedheight)
|
||||
yposition %= fixedheight;
|
||||
|
||||
while (count-- && dest <= deststop)
|
||||
{
|
||||
// The loops here keep the texture coordinates within the texture.
|
||||
// They will rarely iterate multiple times, and are cheaper than a modulo operation,
|
||||
// even if using libdivide.
|
||||
if (xstep < 0) // These if statements are hopefully hoisted by the compiler to above this loop
|
||||
while (xposition < 0)
|
||||
xposition += fixedwidth;
|
||||
else
|
||||
while (xposition >= fixedwidth)
|
||||
xposition -= fixedwidth;
|
||||
if (ystep < 0)
|
||||
while (yposition < 0)
|
||||
yposition += fixedheight;
|
||||
else
|
||||
while (yposition >= fixedheight)
|
||||
yposition -= fixedheight;
|
||||
|
||||
x = (xposition >> FRACBITS);
|
||||
y = (yposition >> FRACBITS);
|
||||
|
||||
*dest = R_DrawSpanPixel<Type>(ds, dsrc, ds->colormap, ((y * ds->flatwidth) + x));
|
||||
dest++;
|
||||
dsrc++;
|
||||
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief The R_DrawTiltedSpan_NPO2_8 function
|
||||
Draw slopes! Holy sheit!
|
||||
*/
|
||||
template<DrawSpanType Type>
|
||||
static void R_DrawTiltedNPO2SpanTemplate(drawspandata_t* ds)
|
||||
{
|
||||
// x1, x2 = ds_x1, ds_x2
|
||||
int width = ds->x2 - ds->x1;
|
||||
double iz, uz, vz;
|
||||
UINT32 u, v;
|
||||
int i;
|
||||
|
||||
UINT8 *colormap;
|
||||
UINT8 *dest;
|
||||
UINT8 *dsrc;
|
||||
|
||||
double startz, startu, startv;
|
||||
double izstep, uzstep, vzstep;
|
||||
double endz, endu, endv;
|
||||
UINT32 stepu, stepv;
|
||||
INT32 tiltlighting[MAXVIDWIDTH];
|
||||
|
||||
struct libdivide_u32_t x_divider = libdivide_u32_gen(ds->flatwidth);
|
||||
struct libdivide_u32_t y_divider = libdivide_u32_gen(ds->flatheight);
|
||||
|
||||
iz = ds->szp.z + ds->szp.y*(centery-ds->y) + ds->szp.x*(ds->x1-centerx);
|
||||
|
||||
// Lighting is simple. It's just linear interpolation from start to end
|
||||
if constexpr (!(Type & DS_SPRITE))
|
||||
{
|
||||
float planelightfloat = PLANELIGHTFLOAT;
|
||||
float lightstart, lightend;
|
||||
|
||||
lightend = (iz + ds->szp.x*width) * planelightfloat;
|
||||
lightstart = iz * planelightfloat;
|
||||
|
||||
R_CalcTiltedLighting(tiltlighting, ds->x1, ds->x2, FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend));
|
||||
//CONS_Printf("tilted lighting %f to %f (foc %f)\n", lightstart, lightend, focallengthf);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
colormap = ds->colormap;
|
||||
|
||||
dest = ylookup[ds->y] + columnofs[ds->x1];
|
||||
|
||||
if constexpr (Type & DS_RIPPLE)
|
||||
{
|
||||
dsrc = screens[1] + (ds->y + ds->bgofs) * vid.width + ds->x1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dsrc = dest;
|
||||
}
|
||||
|
||||
#if 0 // The "perfect" reference version of this routine. Pretty slow.
|
||||
// Use it only to see how things are supposed to look.
|
||||
i = 0;
|
||||
do
|
||||
{
|
||||
double z = 1.f/iz;
|
||||
u = (INT64)(uz*z);
|
||||
v = (INT64)(vz*z);
|
||||
|
||||
if constexpr (!(Type & DS_SPRITE))
|
||||
{
|
||||
colormap = ds->planezlight[tiltlighting[ds->x1++]] + (ds->colormap - colormaps);
|
||||
}
|
||||
|
||||
// Lactozilla: Non-powers-of-two
|
||||
{
|
||||
fixed_t x = (((fixed_t)u) >> FRACBITS);
|
||||
fixed_t y = (((fixed_t)v) >> FRACBITS);
|
||||
|
||||
// Carefully align all of my Friends.
|
||||
if (x < 0)
|
||||
x += (libdivide_u32_do((UINT32)(-x-1), &x_divider) + 1) * ds_flatwidth;
|
||||
else
|
||||
x -= libdivide_u32_do((UINT32)x, &x_divider) * ds_flatwidth;
|
||||
if (y < 0)
|
||||
y += (libdivide_u32_do((UINT32)(-y-1), &y_divider) + 1) * ds_flatheight;
|
||||
else
|
||||
y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight;
|
||||
|
||||
*dest = R_DrawSpanPixel<Type>(ds, dsrc, colormap, ((y * ds->flatwidth) + x));
|
||||
}
|
||||
dest++;
|
||||
dsrc++;
|
||||
iz += ds_szp->x;
|
||||
uz += ds_sup->x;
|
||||
vz += ds_svp->x;
|
||||
} while (--width >= 0);
|
||||
#else
|
||||
startz = 1.f/iz;
|
||||
startu = uz*startz;
|
||||
startv = vz*startz;
|
||||
|
||||
izstep = ds->szp.x * SPANSIZE;
|
||||
uzstep = ds->sup.x * SPANSIZE;
|
||||
vzstep = ds->svp.x * SPANSIZE;
|
||||
//x1 = 0;
|
||||
width++;
|
||||
|
||||
while (width >= SPANSIZE)
|
||||
{
|
||||
iz += izstep;
|
||||
uz += uzstep;
|
||||
vz += vzstep;
|
||||
|
||||
endz = 1.f/iz;
|
||||
endu = uz*endz;
|
||||
endv = vz*endz;
|
||||
stepu = (INT64)((endu - startu) * INVSPAN);
|
||||
stepv = (INT64)((endv - startv) * INVSPAN);
|
||||
u = (INT64)(startu);
|
||||
v = (INT64)(startv);
|
||||
|
||||
for (i = SPANSIZE-1; i >= 0; i--)
|
||||
{
|
||||
if constexpr (!(Type & DS_SPRITE))
|
||||
{
|
||||
colormap = ds->planezlight[tiltlighting[ds->x1++]] + (ds->colormap - colormaps);
|
||||
}
|
||||
|
||||
// Lactozilla: Non-powers-of-two
|
||||
{
|
||||
fixed_t x = (((fixed_t)u) >> FRACBITS);
|
||||
fixed_t y = (((fixed_t)v) >> FRACBITS);
|
||||
|
||||
// Carefully align all of my Friends.
|
||||
if (x < 0)
|
||||
x += (libdivide_u32_do((UINT32)(-x-1), &x_divider) + 1) * ds->flatwidth;
|
||||
else
|
||||
x -= libdivide_u32_do((UINT32)x, &x_divider) * ds->flatwidth;
|
||||
if (y < 0)
|
||||
y += (libdivide_u32_do((UINT32)(-y-1), &y_divider) + 1) * ds->flatheight;
|
||||
else
|
||||
y -= libdivide_u32_do((UINT32)y, &y_divider) * ds->flatheight;
|
||||
|
||||
*dest = R_DrawSpanPixel<Type>(ds, dsrc, colormap, ((y * ds->flatwidth) + x));
|
||||
}
|
||||
dest++;
|
||||
dsrc++;
|
||||
u += stepu;
|
||||
v += stepv;
|
||||
}
|
||||
startu = endu;
|
||||
startv = endv;
|
||||
width -= SPANSIZE;
|
||||
}
|
||||
if (width > 0)
|
||||
{
|
||||
if (width == 1)
|
||||
{
|
||||
u = (INT64)(startu);
|
||||
v = (INT64)(startv);
|
||||
|
||||
if constexpr (!(Type & DS_SPRITE))
|
||||
{
|
||||
colormap = ds->planezlight[tiltlighting[ds->x1++]] + (ds->colormap - colormaps);
|
||||
}
|
||||
|
||||
// Lactozilla: Non-powers-of-two
|
||||
{
|
||||
fixed_t x = (((fixed_t)u) >> FRACBITS);
|
||||
fixed_t y = (((fixed_t)v) >> FRACBITS);
|
||||
|
||||
// Carefully align all of my Friends.
|
||||
if (x < 0)
|
||||
x += (libdivide_u32_do((UINT32)(-x-1), &x_divider) + 1) * ds->flatwidth;
|
||||
else
|
||||
x -= libdivide_u32_do((UINT32)x, &x_divider) * ds->flatwidth;
|
||||
if (y < 0)
|
||||
y += (libdivide_u32_do((UINT32)(-y-1), &y_divider) + 1) * ds->flatheight;
|
||||
else
|
||||
y -= libdivide_u32_do((UINT32)y, &y_divider) * ds->flatheight;
|
||||
|
||||
*dest = R_DrawSpanPixel<Type>(ds, dsrc, colormap, ((y * ds->flatwidth) + x));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
double left = width;
|
||||
iz += ds->szp.x * left;
|
||||
uz += ds->sup.x * left;
|
||||
vz += ds->svp.x * left;
|
||||
|
||||
endz = 1.f/iz;
|
||||
endu = uz*endz;
|
||||
endv = vz*endz;
|
||||
left = 1.f/left;
|
||||
stepu = (INT64)((endu - startu) * left);
|
||||
stepv = (INT64)((endv - startv) * left);
|
||||
u = (INT64)(startu);
|
||||
v = (INT64)(startv);
|
||||
|
||||
for (; width != 0; width--)
|
||||
{
|
||||
if constexpr (!(Type & DS_SPRITE))
|
||||
{
|
||||
colormap = ds->planezlight[tiltlighting[ds->x1++]] + (ds->colormap - colormaps);
|
||||
}
|
||||
|
||||
// Lactozilla: Non-powers-of-two
|
||||
{
|
||||
fixed_t x = (((fixed_t)u) >> FRACBITS);
|
||||
fixed_t y = (((fixed_t)v) >> FRACBITS);
|
||||
|
||||
// Carefully align all of my Friends.
|
||||
if (x < 0)
|
||||
x += (libdivide_u32_do((UINT32)(-x-1), &x_divider) + 1) * ds->flatwidth;
|
||||
else
|
||||
x -= libdivide_u32_do((UINT32)x, &x_divider) * ds->flatwidth;
|
||||
if (y < 0)
|
||||
y += (libdivide_u32_do((UINT32)(-y-1), &y_divider) + 1) * ds->flatheight;
|
||||
else
|
||||
y -= libdivide_u32_do((UINT32)y, &y_divider) * ds->flatheight;
|
||||
|
||||
*dest = R_DrawSpanPixel<Type>(ds, dsrc, colormap, ((y * ds->flatwidth) + x));
|
||||
}
|
||||
dest++;
|
||||
dsrc++;
|
||||
u += stepu;
|
||||
v += stepv;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#define DEFINE_SPAN_FUNC(name, flags, template) \
|
||||
void name(drawspandata_t* ds) \
|
||||
{ \
|
||||
ZoneScoped; \
|
||||
constexpr DrawSpanType opt = static_cast<DrawSpanType>(flags); \
|
||||
template<opt>(ds); \
|
||||
}
|
||||
|
||||
#define DEFINE_SPAN_COMBO(name, flags) \
|
||||
DEFINE_SPAN_FUNC(name, flags, R_DrawSpanTemplate) \
|
||||
DEFINE_SPAN_FUNC(name ## _Tilted, flags, R_DrawTiltedSpanTemplate) \
|
||||
DEFINE_SPAN_FUNC(name ## _NPO2, flags, R_DrawNPO2SpanTemplate) \
|
||||
DEFINE_SPAN_FUNC(name ## _Tilted_NPO2, flags, R_DrawTiltedNPO2SpanTemplate) \
|
||||
DEFINE_SPAN_FUNC(name ## _Brightmap, flags|DS_BRIGHTMAP, R_DrawSpanTemplate) \
|
||||
DEFINE_SPAN_FUNC(name ## _Tilted_Brightmap, flags|DS_BRIGHTMAP, R_DrawTiltedSpanTemplate) \
|
||||
DEFINE_SPAN_FUNC(name ## _Brightmap_NPO2, flags|DS_BRIGHTMAP, R_DrawNPO2SpanTemplate) \
|
||||
DEFINE_SPAN_FUNC(name ## _Tilted_Brightmap_NPO2, flags|DS_BRIGHTMAP, R_DrawTiltedNPO2SpanTemplate)
|
||||
|
||||
DEFINE_SPAN_COMBO(R_DrawSpan, DS_BASIC)
|
||||
DEFINE_SPAN_COMBO(R_DrawTranslucentSpan, DS_TRANSMAP)
|
||||
DEFINE_SPAN_COMBO(R_DrawSplat, DS_HOLES)
|
||||
DEFINE_SPAN_COMBO(R_DrawTranslucentSplat, DS_TRANSMAP|DS_HOLES)
|
||||
DEFINE_SPAN_COMBO(R_DrawFloorSprite, DS_COLORMAP|DS_SPRITE)
|
||||
DEFINE_SPAN_COMBO(R_DrawTranslucentFloorSprite, DS_COLORMAP|DS_TRANSMAP|DS_SPRITE)
|
||||
DEFINE_SPAN_COMBO(R_DrawTranslucentWaterSpan, DS_TRANSMAP|DS_RIPPLE)
|
||||
|
||||
void R_DrawFogSpan(drawspandata_t* ds)
|
||||
{
|
||||
ZoneScoped;
|
||||
|
||||
UINT8 *colormap;
|
||||
UINT8 *dest;
|
||||
|
||||
size_t count;
|
||||
|
||||
colormap = ds->colormap;
|
||||
|
||||
//dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||
dest = &topleft[ds->y *vid.width + ds->x1];
|
||||
|
||||
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++;
|
||||
}
|
||||
}
|
||||
|
||||
void R_DrawFogSpan_Tilted(drawspandata_t* ds)
|
||||
{
|
||||
ZoneScoped;
|
||||
|
||||
// x1, x2 = ds_x1, ds_x2
|
||||
int width = ds->x2 - ds->x1;
|
||||
double iz = ds->szp.z + ds->szp.y*(centery-ds->y) + ds->szp.x*(ds->x1-centerx);
|
||||
INT32 tiltlighting[MAXVIDWIDTH];
|
||||
|
||||
UINT8 *dest = ylookup[ds->y] + columnofs[ds->x1];
|
||||
|
||||
// Lighting is simple. It's just linear interpolation from start to end
|
||||
{
|
||||
float planelightfloat = PLANELIGHTFLOAT;
|
||||
float lightstart, lightend;
|
||||
|
||||
lightend = (iz + ds->szp.x*width) * planelightfloat;
|
||||
lightstart = iz * planelightfloat;
|
||||
|
||||
R_CalcTiltedLighting(tiltlighting, ds->x1, ds->x2, FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend));
|
||||
//CONS_Printf("tilted lighting %f to %f (foc %f)\n", lightstart, lightend, focallengthf);
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
UINT8 *colormap = ds->planezlight[tiltlighting[ds->x1++]] + (ds->colormap - colormaps);
|
||||
*dest = colormap[*dest];
|
||||
dest++;
|
||||
}
|
||||
while (--width >= 0);
|
||||
}
|
||||
|
||||
void R_DrawSpan_Flat(drawspandata_t* ds)
|
||||
{
|
||||
ZoneScoped;
|
||||
|
||||
UINT8 *dest = ylookup[ds->y] + columnofs[ds->x1];
|
||||
memset(dest, ds->colormap[ds->r8_flatcolor], (ds->x2 - ds->x1) + 1);
|
||||
}
|
||||
|
||||
void R_DrawTiltedSpan_Flat(drawspandata_t* ds)
|
||||
{
|
||||
ZoneScoped;
|
||||
|
||||
// x1, x2 = ds_x1, ds_x2
|
||||
int width = ds->x2 - ds->x1;
|
||||
double iz = ds->szp.z + ds->szp.y*(centery-ds->y) + ds->szp.x*(ds->x1-centerx);
|
||||
INT32 tiltlighting[MAXVIDWIDTH];
|
||||
|
||||
UINT8 *dest = ylookup[ds->y];
|
||||
|
||||
// Lighting is simple. It's just linear interpolation from start to end
|
||||
{
|
||||
float planelightfloat = PLANELIGHTFLOAT;
|
||||
float lightstart, lightend;
|
||||
|
||||
lightend = (iz + ds->szp.x*width) * planelightfloat;
|
||||
lightstart = iz * planelightfloat;
|
||||
|
||||
R_CalcTiltedLighting(tiltlighting, ds->x1, ds->x2, FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend));
|
||||
//CONS_Printf("tilted lighting %f to %f (foc %f)\n", lightstart, lightend, focallengthf);
|
||||
}
|
||||
|
||||
while (ds->x1 <= ds->x2)
|
||||
{
|
||||
dest[ds->x1] = ds->planezlight[tiltlighting[ds->x1]][ds->r8_flatcolor];
|
||||
ds->x1++;
|
||||
}
|
||||
}
|
||||
|
|
@ -962,7 +962,7 @@ void R_DrawSinglePlane(drawspandata_t *ds, visplane_t *pl, boolean allow_paralle
|
|||
{
|
||||
dc.yl = pl->top[dc.x];
|
||||
dc.yh = pl->bottom[dc.x];
|
||||
R_DrawColumn_Flat_8(&dc);
|
||||
R_DrawColumn_Flat(&dc);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -1202,6 +1202,12 @@ void R_DrawSinglePlane(drawspandata_t *ds, visplane_t *pl, boolean allow_paralle
|
|||
case SPANDRAWFUNC_SPLAT:
|
||||
spanfunctype = SPANDRAWFUNC_TILTEDSPLAT;
|
||||
break;
|
||||
case SPANDRAWFUNC_TRANSSPLAT:
|
||||
spanfunctype = SPANDRAWFUNC_TILTEDTRANSSPLAT;
|
||||
break;
|
||||
case SPANDRAWFUNC_FOG:
|
||||
spanfunctype = SPANDRAWFUNC_TILTEDFOG;
|
||||
break;
|
||||
default:
|
||||
spanfunctype = SPANDRAWFUNC_TILTED;
|
||||
break;
|
||||
|
|
@ -1240,77 +1246,6 @@ void R_DrawSinglePlane(drawspandata_t *ds, visplane_t *pl, boolean allow_paralle
|
|||
|
||||
for (x = pl->minx; x <= stop; x++)
|
||||
R_MakeSpans(mapfunc, spanfunc, ds, x, pl->top[x-1], pl->bottom[x-1], pl->top[x], pl->bottom[x], allow_parallel);
|
||||
|
||||
/*
|
||||
QUINCUNX anti-aliasing technique (sort of)
|
||||
|
||||
Normally, Quincunx antialiasing staggers pixels
|
||||
in a 5-die pattern like so:
|
||||
|
||||
o o
|
||||
o
|
||||
o o
|
||||
|
||||
To simulate this, we offset the plane by
|
||||
FRACUNIT/4 in each direction, and draw
|
||||
at 50% translucency. The result is
|
||||
a 'smoothing' of the texture while
|
||||
using the palette colors.
|
||||
*/
|
||||
#ifdef QUINCUNX
|
||||
if (spanfunc == spanfuncs[BASEDRAWFUNC])
|
||||
{
|
||||
INT32 i;
|
||||
ds_transmap = R_GetTranslucencyTable(tr_trans50);
|
||||
spanfunc = spanfuncs[SPANDRAWFUNC_TRANS];
|
||||
for (i=0; i<4; i++)
|
||||
{
|
||||
xoffs = pl->xoffs;
|
||||
yoffs = pl->yoffs;
|
||||
|
||||
switch(i)
|
||||
{
|
||||
case 0:
|
||||
xoffs -= FRACUNIT/4;
|
||||
yoffs -= FRACUNIT/4;
|
||||
break;
|
||||
case 1:
|
||||
xoffs -= FRACUNIT/4;
|
||||
yoffs += FRACUNIT/4;
|
||||
break;
|
||||
case 2:
|
||||
xoffs += FRACUNIT/4;
|
||||
yoffs -= FRACUNIT/4;
|
||||
break;
|
||||
case 3:
|
||||
xoffs += FRACUNIT/4;
|
||||
yoffs += FRACUNIT/4;
|
||||
break;
|
||||
}
|
||||
ds->planeheight = abs(pl->height - pl->viewz);
|
||||
|
||||
if (light >= LIGHTLEVELS)
|
||||
light = LIGHTLEVELS-1;
|
||||
|
||||
if (light < 0)
|
||||
light = 0;
|
||||
|
||||
planezlight = zlight[light];
|
||||
|
||||
// set the maximum value for unsigned
|
||||
pl->top[pl->maxx+1] = 0xffff;
|
||||
pl->top[pl->minx-1] = 0xffff;
|
||||
pl->bottom[pl->maxx+1] = 0x0000;
|
||||
pl->bottom[pl->minx-1] = 0x0000;
|
||||
|
||||
stop = pl->maxx + 1;
|
||||
|
||||
for (x = pl->minx; x <= stop; x++)
|
||||
R_MakeSpans(mapfunc, x, pl->top[x-1], pl->bottom[x-1],
|
||||
pl->top[x], pl->bottom[x]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void R_PlaneBounds(visplane_t *plane)
|
||||
|
|
|
|||
|
|
@ -129,6 +129,7 @@ static void R_Render2sidedMultiPatchColumn(drawcolumndata_t* dc, column_t *colum
|
|||
if (dc->yl <= dc->yh && dc->yh < vid.height && dc->yh > 0)
|
||||
{
|
||||
dc->source = (UINT8 *)column + 3;
|
||||
dc->sourcelength = 0;
|
||||
if (brightmap != NULL)
|
||||
{
|
||||
dc->brightmap = (UINT8 *)brightmap + 3;
|
||||
|
|
@ -136,13 +137,29 @@ static void R_Render2sidedMultiPatchColumn(drawcolumndata_t* dc, column_t *colum
|
|||
|
||||
drawcolumndata_t dc_copy = *dc;
|
||||
coldrawfunc_t* colfunccopy = colfunc;
|
||||
|
||||
// FIXME: do something better to look these up WITHOUT affecting global state...
|
||||
if (R_CheckColumnFunc(BASEDRAWFUNC) == true)
|
||||
{
|
||||
colfunccopy = colfuncs[COLDRAWFUNC_TWOSMULTIPATCH];
|
||||
if (brightmap != NULL)
|
||||
{
|
||||
colfunccopy = colfuncs_bm[COLDRAWFUNC_TWOSMULTIPATCH];
|
||||
}
|
||||
else
|
||||
{
|
||||
colfunccopy = colfuncs[COLDRAWFUNC_TWOSMULTIPATCH];
|
||||
}
|
||||
}
|
||||
else if (R_CheckColumnFunc(COLDRAWFUNC_FUZZY) == true)
|
||||
{
|
||||
colfunccopy = colfuncs[COLDRAWFUNC_TWOSMULTIPATCHTRANS];
|
||||
if (brightmap != NULL)
|
||||
{
|
||||
colfunccopy = colfuncs_bm[COLDRAWFUNC_TWOSMULTIPATCHTRANS];
|
||||
}
|
||||
else
|
||||
{
|
||||
colfunccopy = colfuncs[COLDRAWFUNC_TWOSMULTIPATCHTRANS];
|
||||
}
|
||||
}
|
||||
|
||||
colfunccopy(const_cast<drawcolumndata_t*>(&dc_copy));
|
||||
|
|
@ -688,7 +705,7 @@ void R_RenderMaskedSegRange(drawseg_t *drawseg, INT32 x1, INT32 x2)
|
|||
|
||||
if (debug)
|
||||
{
|
||||
colfunc = R_DrawColumn_Flat_8;
|
||||
colfunc = R_DrawColumn_Flat;
|
||||
dc->r8_flatcolor = R_DebugLineColor(ldef);
|
||||
R_RenderMaskedSegLoopDebug(dc, drawseg, x1, x2, colfunc_2s);
|
||||
}
|
||||
|
|
@ -1318,6 +1335,7 @@ static void R_DrawWallColumn(drawcolumndata_t* dc, INT32 yl, INT32 yh, fixed_t m
|
|||
dc->source = R_GetColumn(texture, texturecolumn);
|
||||
dc->brightmap = (brightmapped ? R_GetBrightmapColumn(texture, texturecolumn) : NULL);
|
||||
dc->texheight = textureheight[texture] >> FRACBITS;
|
||||
dc->sourcelength = 0;
|
||||
R_SetColumnFunc(colfunctype, dc->brightmap != NULL);
|
||||
coldrawfunc_t* colfunccopy = colfunc;
|
||||
drawcolumndata_t dc_copy = *dc;
|
||||
|
|
|
|||
|
|
@ -30,20 +30,8 @@ static void prepare_rastertab(void);
|
|||
|
||||
static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis);
|
||||
|
||||
#ifdef USEASM
|
||||
void ASMCALL rasterize_segment_tex_asm(INT32 x1, INT32 y1, INT32 x2, INT32 y2, INT32 tv1, INT32 tv2, INT32 tc, INT32 dir);
|
||||
#endif
|
||||
|
||||
static void rasterize_segment_tex(INT32 x1, INT32 y1, INT32 x2, INT32 y2, INT32 tv1, INT32 tv2, INT32 tc, INT32 dir)
|
||||
{
|
||||
#ifdef USEASM
|
||||
if (R_ASM)
|
||||
{
|
||||
rasterize_segment_tex_asm(x1, y1, x2, y2, tv1, tv2, tc, dir);
|
||||
return;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
fixed_t xs, xe, count;
|
||||
fixed_t dx0, dx1;
|
||||
|
|
|
|||
|
|
@ -688,6 +688,7 @@ void R_DrawMaskedColumn(drawcolumndata_t* dc, column_t *column, column_t *bright
|
|||
if (dc->yl <= dc->yh && dc->yh > 0)
|
||||
{
|
||||
dc->source = (UINT8 *)column + 3;
|
||||
dc->sourcelength = column->length;
|
||||
if (brightmap != NULL)
|
||||
{
|
||||
dc->brightmap = (UINT8 *)brightmap + 3;
|
||||
|
|
@ -773,6 +774,7 @@ void R_DrawFlippedMaskedColumn(drawcolumndata_t* dc, column_t *column, column_t
|
|||
if (dc->yl <= dc->yh && dc->yh > 0)
|
||||
{
|
||||
dc->source = static_cast<UINT8*>(ZZ_Alloc(column->length));
|
||||
dc->sourcelength = column->length;
|
||||
for (s = (UINT8 *)column+2+column->length, d = dc->source; d < dc->source+column->length; --s)
|
||||
*d++ = *s;
|
||||
|
||||
|
|
@ -981,7 +983,7 @@ static void R_DrawVisSprite(vissprite_t *vis)
|
|||
}
|
||||
|
||||
dc.texturemid = vis->texturemid;
|
||||
dc.texheight = 0;
|
||||
dc.texheight = patch->height;
|
||||
|
||||
frac = vis->startfrac;
|
||||
windowtop = windowbottom = sprbotscreen = INT32_MAX;
|
||||
|
|
@ -1172,7 +1174,7 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis)
|
|||
|
||||
dc.iscale = FixedDiv(FRACUNIT, vis->scale);
|
||||
dc.texturemid = FixedDiv(vis->texturemid, this_scale);
|
||||
dc.texheight = 0;
|
||||
dc.texheight = patch->height;
|
||||
|
||||
frac = vis->startfrac;
|
||||
spryscale = vis->scale;
|
||||
|
|
|
|||
249
src/screen.c
249
src/screen.c
|
|
@ -72,126 +72,121 @@ UINT8 *scr_borderpatch; // flat used to fill the reduced view borders set at ST_
|
|||
|
||||
// =========================================================================
|
||||
|
||||
// Short and Tall sky drawer, for the current color mode
|
||||
void (*walldrawerfunc)(void);
|
||||
|
||||
boolean R_ASM = true;
|
||||
boolean R_486 = false;
|
||||
boolean R_586 = false;
|
||||
boolean R_MMX = false;
|
||||
boolean R_SSE = false;
|
||||
boolean R_3DNow = false;
|
||||
boolean R_MMXExt = false;
|
||||
boolean R_SSE2 = false;
|
||||
|
||||
void SCR_SetDrawFuncs(void)
|
||||
{
|
||||
//
|
||||
// setup the right draw routines for either 8bpp or 16bpp
|
||||
// setup the right draw routines
|
||||
//
|
||||
if (true)//vid.bpp == 1) //Always run in 8bpp. todo: remove all 16bpp code?
|
||||
{
|
||||
colfuncs[BASEDRAWFUNC] = R_DrawColumn_8;
|
||||
spanfuncs[BASEDRAWFUNC] = R_DrawSpan_8;
|
||||
|
||||
colfuncs[COLDRAWFUNC_FUZZY] = R_DrawTranslucentColumn_8;
|
||||
colfuncs[COLDRAWFUNC_TRANS] = R_DrawTranslatedColumn_8;
|
||||
colfuncs[COLDRAWFUNC_SHADE] = R_DrawShadeColumn_8;
|
||||
colfuncs[COLDRAWFUNC_SHADOWED] = R_DrawColumnShadowed_8;
|
||||
colfuncs[COLDRAWFUNC_TRANSTRANS] = R_DrawTranslatedTranslucentColumn_8;
|
||||
colfuncs[COLDRAWFUNC_TWOSMULTIPATCH] = R_Draw2sMultiPatchColumn_8;
|
||||
colfuncs[COLDRAWFUNC_TWOSMULTIPATCHTRANS] = R_Draw2sMultiPatchTranslucentColumn_8;
|
||||
colfuncs[COLDRAWFUNC_FOG] = R_DrawFogColumn_8;
|
||||
colfuncs[COLDRAWFUNC_DROPSHADOW] = R_DrawDropShadowColumn_8;
|
||||
colfuncs[BASEDRAWFUNC] = R_DrawColumn;
|
||||
colfuncs[COLDRAWFUNC_FUZZY] = R_DrawTranslucentColumn;
|
||||
colfuncs[COLDRAWFUNC_TRANS] = R_DrawTranslatedColumn;
|
||||
colfuncs[COLDRAWFUNC_SHADOWED] = R_DrawColumnShadowed;
|
||||
colfuncs[COLDRAWFUNC_TRANSTRANS] = R_DrawTranslatedTranslucentColumn;
|
||||
colfuncs[COLDRAWFUNC_TWOSMULTIPATCH] = R_Draw2sMultiPatchColumn;
|
||||
colfuncs[COLDRAWFUNC_TWOSMULTIPATCHTRANS] = R_Draw2sMultiPatchTranslucentColumn;
|
||||
colfuncs[COLDRAWFUNC_FOG] = R_DrawFogColumn;
|
||||
colfuncs[COLDRAWFUNC_DROPSHADOW] = R_DrawDropShadowColumn;
|
||||
|
||||
spanfuncs[SPANDRAWFUNC_TRANS] = R_DrawTranslucentSpan_8;
|
||||
spanfuncs[SPANDRAWFUNC_TILTED] = R_DrawTiltedSpan_8;
|
||||
spanfuncs[SPANDRAWFUNC_TILTEDTRANS] = R_DrawTiltedTranslucentSpan_8;
|
||||
spanfuncs[SPANDRAWFUNC_SPLAT] = R_DrawSplat_8;
|
||||
spanfuncs[SPANDRAWFUNC_TRANSSPLAT] = R_DrawTranslucentSplat_8;
|
||||
spanfuncs[SPANDRAWFUNC_TILTEDSPLAT] = R_DrawTiltedSplat_8;
|
||||
spanfuncs[SPANDRAWFUNC_SPRITE] = R_DrawFloorSprite_8;
|
||||
spanfuncs[SPANDRAWFUNC_TRANSSPRITE] = R_DrawTranslucentFloorSprite_8;
|
||||
spanfuncs[SPANDRAWFUNC_TILTEDSPRITE] = R_DrawTiltedFloorSprite_8;
|
||||
spanfuncs[SPANDRAWFUNC_TILTEDTRANSSPRITE] = R_DrawTiltedTranslucentFloorSprite_8;
|
||||
spanfuncs[SPANDRAWFUNC_WATER] = R_DrawTranslucentWaterSpan_8;
|
||||
spanfuncs[SPANDRAWFUNC_TILTEDWATER] = R_DrawTiltedTranslucentWaterSpan_8;
|
||||
spanfuncs[SPANDRAWFUNC_FOG] = R_DrawFogSpan_8;
|
||||
colfuncs_bm[BASEDRAWFUNC] = R_DrawColumn_Brightmap;
|
||||
colfuncs_bm[COLDRAWFUNC_FUZZY] = R_DrawTranslucentColumn_Brightmap;
|
||||
colfuncs_bm[COLDRAWFUNC_TRANS] = R_DrawTranslatedColumn_Brightmap;
|
||||
colfuncs_bm[COLDRAWFUNC_SHADOWED] = R_DrawColumnShadowed_Brightmap;
|
||||
colfuncs_bm[COLDRAWFUNC_TRANSTRANS] = R_DrawTranslatedTranslucentColumn_Brightmap;
|
||||
colfuncs_bm[COLDRAWFUNC_TWOSMULTIPATCH] = R_Draw2sMultiPatchColumn_Brightmap;
|
||||
colfuncs_bm[COLDRAWFUNC_TWOSMULTIPATCHTRANS] = R_Draw2sMultiPatchTranslucentColumn_Brightmap;
|
||||
colfuncs_bm[COLDRAWFUNC_FOG] = NULL; // Not needed
|
||||
colfuncs_bm[COLDRAWFUNC_DROPSHADOW] = NULL; // Not needed
|
||||
|
||||
// Lactozilla: Non-powers-of-two
|
||||
spanfuncs_npo2[BASEDRAWFUNC] = R_DrawSpan_NPO2_8;
|
||||
spanfuncs_npo2[SPANDRAWFUNC_TRANS] = R_DrawTranslucentSpan_NPO2_8;
|
||||
spanfuncs_npo2[SPANDRAWFUNC_TILTED] = R_DrawTiltedSpan_NPO2_8;
|
||||
spanfuncs_npo2[SPANDRAWFUNC_TILTEDTRANS] = R_DrawTiltedTranslucentSpan_NPO2_8;
|
||||
spanfuncs_npo2[SPANDRAWFUNC_SPLAT] = R_DrawSplat_NPO2_8;
|
||||
spanfuncs_npo2[SPANDRAWFUNC_TRANSSPLAT] = R_DrawTranslucentSplat_NPO2_8;
|
||||
spanfuncs_npo2[SPANDRAWFUNC_TILTEDSPLAT] = R_DrawTiltedSplat_NPO2_8;
|
||||
spanfuncs_npo2[SPANDRAWFUNC_SPRITE] = R_DrawFloorSprite_NPO2_8;
|
||||
spanfuncs_npo2[SPANDRAWFUNC_TRANSSPRITE] = R_DrawTranslucentFloorSprite_NPO2_8;
|
||||
spanfuncs_npo2[SPANDRAWFUNC_TILTEDSPRITE] = R_DrawTiltedFloorSprite_NPO2_8;
|
||||
spanfuncs_npo2[SPANDRAWFUNC_TILTEDTRANSSPRITE] = R_DrawTiltedTranslucentFloorSprite_NPO2_8;
|
||||
spanfuncs_npo2[SPANDRAWFUNC_WATER] = R_DrawTranslucentWaterSpan_NPO2_8;
|
||||
spanfuncs_npo2[SPANDRAWFUNC_TILTEDWATER] = R_DrawTiltedTranslucentWaterSpan_NPO2_8;
|
||||
spanfuncs_npo2[SPANDRAWFUNC_FOG] = NULL; // Not needed
|
||||
spanfuncs[BASEDRAWFUNC] = R_DrawSpan;
|
||||
spanfuncs[SPANDRAWFUNC_TRANS] = R_DrawTranslucentSpan;
|
||||
spanfuncs[SPANDRAWFUNC_TILTED] = R_DrawSpan_Tilted;
|
||||
spanfuncs[SPANDRAWFUNC_TILTEDTRANS] = R_DrawTranslucentSpan_Tilted;
|
||||
spanfuncs[SPANDRAWFUNC_SPLAT] = R_DrawSplat;
|
||||
spanfuncs[SPANDRAWFUNC_TRANSSPLAT] = R_DrawTranslucentSplat;
|
||||
spanfuncs[SPANDRAWFUNC_TILTEDSPLAT] = R_DrawSplat_Tilted;
|
||||
spanfuncs[SPANDRAWFUNC_TILTEDTRANSSPLAT] = R_DrawTranslucentSplat_Tilted;
|
||||
spanfuncs[SPANDRAWFUNC_SPRITE] = R_DrawFloorSprite;
|
||||
spanfuncs[SPANDRAWFUNC_TRANSSPRITE] = R_DrawTranslucentFloorSprite;
|
||||
spanfuncs[SPANDRAWFUNC_TILTEDSPRITE] = R_DrawFloorSprite_Tilted;
|
||||
spanfuncs[SPANDRAWFUNC_TILTEDTRANSSPRITE] = R_DrawTranslucentFloorSprite_Tilted;
|
||||
spanfuncs[SPANDRAWFUNC_WATER] = R_DrawTranslucentWaterSpan;
|
||||
spanfuncs[SPANDRAWFUNC_TILTEDWATER] = R_DrawTranslucentWaterSpan_Tilted;
|
||||
spanfuncs[SPANDRAWFUNC_FOG] = R_DrawFogSpan;
|
||||
spanfuncs[SPANDRAWFUNC_TILTEDFOG] = R_DrawFogSpan_Tilted;
|
||||
|
||||
// Debugging - highlight surfaces in flat colors
|
||||
spanfuncs_flat[BASEDRAWFUNC] = R_DrawSpan_Flat_8;
|
||||
spanfuncs_flat[SPANDRAWFUNC_TRANS] = R_DrawSpan_Flat_8;
|
||||
spanfuncs_flat[SPANDRAWFUNC_TILTED] = R_DrawTiltedSpan_Flat_8;
|
||||
spanfuncs_flat[SPANDRAWFUNC_TILTEDTRANS] = R_DrawTiltedSpan_Flat_8;
|
||||
spanfuncs_flat[SPANDRAWFUNC_SPLAT] = R_DrawSpan_Flat_8;
|
||||
spanfuncs_flat[SPANDRAWFUNC_TRANSSPLAT] = R_DrawSpan_Flat_8;
|
||||
spanfuncs_flat[SPANDRAWFUNC_TILTEDSPLAT] = R_DrawTiltedSpan_Flat_8;
|
||||
spanfuncs_flat[SPANDRAWFUNC_SPRITE] = R_DrawSpan_Flat_8;
|
||||
spanfuncs_flat[SPANDRAWFUNC_TRANSSPRITE] = R_DrawSpan_Flat_8;
|
||||
spanfuncs_flat[SPANDRAWFUNC_TILTEDSPRITE] = R_DrawTiltedSpan_Flat_8;
|
||||
spanfuncs_flat[SPANDRAWFUNC_TILTEDTRANSSPRITE] = R_DrawTiltedSpan_Flat_8;
|
||||
spanfuncs_flat[SPANDRAWFUNC_WATER] = R_DrawSpan_Flat_8;
|
||||
spanfuncs_flat[SPANDRAWFUNC_TILTEDWATER] = R_DrawTiltedSpan_Flat_8;
|
||||
spanfuncs_flat[SPANDRAWFUNC_FOG] = R_DrawSpan_Flat_8; // Not needed
|
||||
spanfuncs_bm[BASEDRAWFUNC] = R_DrawSpan_Brightmap;
|
||||
spanfuncs_bm[SPANDRAWFUNC_TRANS] = R_DrawTranslucentSpan_Brightmap;
|
||||
spanfuncs_bm[SPANDRAWFUNC_TILTED] = R_DrawSpan_Tilted_Brightmap;
|
||||
spanfuncs_bm[SPANDRAWFUNC_TILTEDTRANS] = R_DrawTranslucentSpan_Tilted_Brightmap;
|
||||
spanfuncs_bm[SPANDRAWFUNC_SPLAT] = R_DrawSplat_Brightmap;
|
||||
spanfuncs_bm[SPANDRAWFUNC_TRANSSPLAT] = R_DrawTranslucentSplat_Brightmap;
|
||||
spanfuncs_bm[SPANDRAWFUNC_TILTEDSPLAT] = R_DrawSplat_Tilted_Brightmap;
|
||||
spanfuncs_bm[SPANDRAWFUNC_TILTEDTRANSSPLAT] = R_DrawTranslucentSplat_Tilted_Brightmap;
|
||||
spanfuncs_bm[SPANDRAWFUNC_SPRITE] = R_DrawFloorSprite_Brightmap;
|
||||
spanfuncs_bm[SPANDRAWFUNC_TRANSSPRITE] = R_DrawTranslucentFloorSprite_Brightmap;
|
||||
spanfuncs_bm[SPANDRAWFUNC_TILTEDSPRITE] = R_DrawFloorSprite_Tilted_Brightmap;
|
||||
spanfuncs_bm[SPANDRAWFUNC_TILTEDTRANSSPRITE] = R_DrawTranslucentFloorSprite_Tilted_Brightmap;
|
||||
spanfuncs_bm[SPANDRAWFUNC_WATER] = R_DrawTranslucentWaterSpan_Brightmap;
|
||||
spanfuncs_bm[SPANDRAWFUNC_TILTEDWATER] = R_DrawTranslucentWaterSpan_Tilted_Brightmap;
|
||||
spanfuncs_bm[SPANDRAWFUNC_FOG] = NULL; // Not needed
|
||||
spanfuncs_bm[SPANDRAWFUNC_TILTEDFOG] = NULL; // Not needed
|
||||
|
||||
#if (defined(RUSEASM) && defined(USE_COL_SPAN_ASM))
|
||||
if (R_ASM)
|
||||
{
|
||||
if (R_MMX)
|
||||
{
|
||||
colfuncs_asm[BASEDRAWFUNC] = R_DrawColumn_8_MMX;
|
||||
//colfuncs_asm[COLDRAWFUNC_SHADE] = R_DrawShadeColumn_8_ASM;
|
||||
//colfuncs_asm[COLDRAWFUNC_FUZZY] = R_DrawTranslucentColumn_8_ASM;
|
||||
colfuncs_asm[COLDRAWFUNC_TWOSMULTIPATCH] = R_Draw2sMultiPatchColumn_8_MMX;
|
||||
spanfuncs_asm[BASEDRAWFUNC] = R_DrawSpan_8_MMX;
|
||||
}
|
||||
else
|
||||
{
|
||||
colfuncs_asm[BASEDRAWFUNC] = R_DrawColumn_8_ASM;
|
||||
//colfuncs_asm[COLDRAWFUNC_SHADE] = R_DrawShadeColumn_8_ASM;
|
||||
//colfuncs_asm[COLDRAWFUNC_FUZZY] = R_DrawTranslucentColumn_8_ASM;
|
||||
colfuncs_asm[COLDRAWFUNC_TWOSMULTIPATCH] = R_Draw2sMultiPatchColumn_8_ASM;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// Lactozilla: Non-powers-of-two
|
||||
spanfuncs_npo2[BASEDRAWFUNC] = R_DrawSpan_NPO2;
|
||||
spanfuncs_npo2[SPANDRAWFUNC_TRANS] = R_DrawTranslucentSpan_NPO2;
|
||||
spanfuncs_npo2[SPANDRAWFUNC_TILTED] = R_DrawSpan_Tilted_NPO2;
|
||||
spanfuncs_npo2[SPANDRAWFUNC_TILTEDTRANS] = R_DrawTranslucentSpan_Tilted_NPO2;
|
||||
spanfuncs_npo2[SPANDRAWFUNC_SPLAT] = R_DrawSplat_NPO2;
|
||||
spanfuncs_npo2[SPANDRAWFUNC_TRANSSPLAT] = R_DrawTranslucentSplat_NPO2;
|
||||
spanfuncs_npo2[SPANDRAWFUNC_TILTEDSPLAT] = R_DrawSplat_Tilted_NPO2;
|
||||
spanfuncs_npo2[SPANDRAWFUNC_TILTEDTRANSSPLAT] = R_DrawTranslucentSplat_Tilted_NPO2;
|
||||
spanfuncs_npo2[SPANDRAWFUNC_SPRITE] = R_DrawFloorSprite_NPO2;
|
||||
spanfuncs_npo2[SPANDRAWFUNC_TRANSSPRITE] = R_DrawTranslucentFloorSprite_NPO2;
|
||||
spanfuncs_npo2[SPANDRAWFUNC_TILTEDSPRITE] = R_DrawFloorSprite_Tilted_NPO2;
|
||||
spanfuncs_npo2[SPANDRAWFUNC_TILTEDTRANSSPRITE] = R_DrawTranslucentFloorSprite_Tilted_NPO2;
|
||||
spanfuncs_npo2[SPANDRAWFUNC_WATER] = R_DrawTranslucentWaterSpan_NPO2;
|
||||
spanfuncs_npo2[SPANDRAWFUNC_TILTEDWATER] = R_DrawTranslucentWaterSpan_Tilted_NPO2;
|
||||
spanfuncs_npo2[SPANDRAWFUNC_FOG] = NULL; // Not needed
|
||||
spanfuncs_npo2[SPANDRAWFUNC_TILTEDFOG] = NULL; // Not needed
|
||||
|
||||
R_SetColumnFunc(BASEDRAWFUNC, false);
|
||||
R_SetSpanFunc(BASEDRAWFUNC, false, false);
|
||||
}
|
||||
/* else if (vid.bpp > 1)
|
||||
{
|
||||
I_OutputMsg("using highcolor mode\n");
|
||||
spanfunc = basespanfunc = R_DrawSpan_16;
|
||||
transcolfunc = R_DrawTranslatedColumn_16;
|
||||
transtransfunc = R_DrawTranslucentColumn_16; // No 16bit operation for this function
|
||||
spanfuncs_bm_npo2[BASEDRAWFUNC] = R_DrawSpan_Brightmap_NPO2;
|
||||
spanfuncs_bm_npo2[SPANDRAWFUNC_TRANS] = R_DrawTranslucentSpan_Brightmap_NPO2;
|
||||
spanfuncs_bm_npo2[SPANDRAWFUNC_TILTED] = R_DrawSpan_Tilted_Brightmap_NPO2;
|
||||
spanfuncs_bm_npo2[SPANDRAWFUNC_TILTEDTRANS] = R_DrawTranslucentSpan_Tilted_Brightmap_NPO2;
|
||||
spanfuncs_bm_npo2[SPANDRAWFUNC_SPLAT] = R_DrawSplat_Brightmap_NPO2;
|
||||
spanfuncs_bm_npo2[SPANDRAWFUNC_TRANSSPLAT] = R_DrawTranslucentSplat_Brightmap_NPO2;
|
||||
spanfuncs_bm_npo2[SPANDRAWFUNC_TILTEDSPLAT] = R_DrawSplat_Tilted_Brightmap_NPO2;
|
||||
spanfuncs_bm_npo2[SPANDRAWFUNC_TILTEDTRANSSPLAT] = R_DrawTranslucentSplat_Tilted_Brightmap_NPO2;
|
||||
spanfuncs_bm_npo2[SPANDRAWFUNC_SPRITE] = R_DrawFloorSprite_Brightmap_NPO2;
|
||||
spanfuncs_bm_npo2[SPANDRAWFUNC_TRANSSPRITE] = R_DrawTranslucentFloorSprite_Brightmap_NPO2;
|
||||
spanfuncs_bm_npo2[SPANDRAWFUNC_TILTEDSPRITE] = R_DrawFloorSprite_Tilted_Brightmap_NPO2;
|
||||
spanfuncs_bm_npo2[SPANDRAWFUNC_TILTEDTRANSSPRITE] = R_DrawTranslucentFloorSprite_Tilted_Brightmap_NPO2;
|
||||
spanfuncs_bm_npo2[SPANDRAWFUNC_WATER] = R_DrawTranslucentWaterSpan_Brightmap_NPO2;
|
||||
spanfuncs_bm_npo2[SPANDRAWFUNC_TILTEDWATER] = R_DrawTranslucentWaterSpan_Tilted_Brightmap_NPO2;
|
||||
spanfuncs_bm_npo2[SPANDRAWFUNC_FOG] = NULL; // Not needed
|
||||
spanfuncs_bm_npo2[SPANDRAWFUNC_TILTEDFOG] = NULL; // Not needed
|
||||
|
||||
colfunc = basecolfunc = R_DrawColumn_16;
|
||||
shadecolfunc = NULL; // detect error if used somewhere..
|
||||
fuzzcolfunc = R_DrawTranslucentColumn_16;
|
||||
walldrawerfunc = R_DrawWallColumn_16;
|
||||
}*/
|
||||
else
|
||||
I_Error("unknown bytes per pixel mode %d\n", vid.bpp);
|
||||
/*
|
||||
if (SCR_IsAspectCorrect(vid.width, vid.height))
|
||||
CONS_Alert(CONS_WARNING, M_GetText("Resolution is not aspect-correct!\nUse a multiple of %dx%d\n"), BASEVIDWIDTH, BASEVIDHEIGHT);
|
||||
*/
|
||||
// Debugging - highlight surfaces in flat colors
|
||||
spanfuncs_flat[BASEDRAWFUNC] = R_DrawSpan_Flat;
|
||||
spanfuncs_flat[SPANDRAWFUNC_TRANS] = R_DrawSpan_Flat;
|
||||
spanfuncs_flat[SPANDRAWFUNC_TILTED] = R_DrawTiltedSpan_Flat;
|
||||
spanfuncs_flat[SPANDRAWFUNC_TILTEDTRANS] = R_DrawTiltedSpan_Flat;
|
||||
spanfuncs_flat[SPANDRAWFUNC_SPLAT] = R_DrawSpan_Flat;
|
||||
spanfuncs_flat[SPANDRAWFUNC_TRANSSPLAT] = R_DrawSpan_Flat;
|
||||
spanfuncs_flat[SPANDRAWFUNC_TILTEDSPLAT] = R_DrawTiltedSpan_Flat;
|
||||
spanfuncs_flat[SPANDRAWFUNC_TILTEDTRANSSPLAT] = R_DrawTiltedSpan_Flat;
|
||||
spanfuncs_flat[SPANDRAWFUNC_SPRITE] = R_DrawSpan_Flat;
|
||||
spanfuncs_flat[SPANDRAWFUNC_TRANSSPRITE] = R_DrawSpan_Flat;
|
||||
spanfuncs_flat[SPANDRAWFUNC_TILTEDSPRITE] = R_DrawTiltedSpan_Flat;
|
||||
spanfuncs_flat[SPANDRAWFUNC_TILTEDTRANSSPRITE] = R_DrawTiltedSpan_Flat;
|
||||
spanfuncs_flat[SPANDRAWFUNC_WATER] = R_DrawSpan_Flat;
|
||||
spanfuncs_flat[SPANDRAWFUNC_TILTEDWATER] = R_DrawTiltedSpan_Flat;
|
||||
spanfuncs_flat[SPANDRAWFUNC_FOG] = R_DrawSpan_Flat;
|
||||
spanfuncs_flat[SPANDRAWFUNC_TILTEDFOG] = R_DrawTiltedSpan_Flat;
|
||||
|
||||
R_SetColumnFunc(BASEDRAWFUNC, false);
|
||||
R_SetSpanFunc(BASEDRAWFUNC, false, false);
|
||||
}
|
||||
|
||||
void R_SetColumnFunc(size_t id, boolean brightmapped)
|
||||
|
|
@ -202,14 +197,12 @@ void R_SetColumnFunc(size_t id, boolean brightmapped)
|
|||
|
||||
if (debugrender_highlight != 0)
|
||||
{
|
||||
colfunc = R_DrawColumn_Flat_8;
|
||||
colfunc = R_DrawColumn_Flat;
|
||||
}
|
||||
#ifdef USE_COL_SPAN_ASM
|
||||
else if (colfuncs_asm[id] != NULL && brightmapped == false)
|
||||
else if (brightmapped == true && colfuncs_bm[id] != NULL)
|
||||
{
|
||||
colfunc = colfuncs_asm[id];
|
||||
colfunc = colfuncs_bm[id];
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
colfunc = colfuncs[id];
|
||||
|
|
@ -225,19 +218,27 @@ void R_SetSpanFunc(size_t id, boolean npo2, boolean brightmapped)
|
|||
return;
|
||||
}
|
||||
|
||||
if (spanfuncs_npo2[id] != NULL && npo2 == true)
|
||||
if (brightmapped == true && spanfuncs_bm[id] != NULL)
|
||||
{
|
||||
spanfunc = spanfuncs_npo2[id];
|
||||
if (npo2 == true && spanfuncs_bm_npo2[id] != NULL)
|
||||
{
|
||||
spanfunc = spanfuncs_bm_npo2[id];
|
||||
}
|
||||
else
|
||||
{
|
||||
spanfunc = spanfuncs_bm[id];
|
||||
}
|
||||
}
|
||||
#ifdef USE_COL_SPAN_ASM
|
||||
else if (spanfuncs_asm[id] != NULL && brightmapped == false)
|
||||
{
|
||||
spanfunc = spanfuncs_asm[id];
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
spanfunc = spanfuncs[id];
|
||||
if (npo2 == true && spanfuncs_npo2[id] != NULL)
|
||||
{
|
||||
spanfunc = spanfuncs_npo2[id];
|
||||
}
|
||||
else
|
||||
{
|
||||
spanfunc = spanfuncs[id];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -267,7 +268,7 @@ boolean R_CheckColumnFunc(size_t id)
|
|||
|
||||
for (i = 0; i < COLDRAWFUNC_MAX; i++)
|
||||
{
|
||||
if (colfunc == colfuncs[id] || colfunc == colfuncs_asm[id])
|
||||
if (colfunc == colfuncs[id] || colfunc == colfuncs_bm[id])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
11
src/screen.h
11
src/screen.h
|
|
@ -118,17 +118,6 @@ struct vmode_t
|
|||
#define NUMSPECIALMODES 4
|
||||
extern vmode_t specialmodes[NUMSPECIALMODES];
|
||||
|
||||
// -----
|
||||
// CPUID
|
||||
// -----
|
||||
extern boolean R_ASM;
|
||||
extern boolean R_486;
|
||||
extern boolean R_586;
|
||||
extern boolean R_MMX;
|
||||
extern boolean R_3DNow;
|
||||
extern boolean R_MMXExt;
|
||||
extern boolean R_SSE2;
|
||||
|
||||
// ----------------
|
||||
// screen variables
|
||||
// ----------------
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue