Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • STJr/SRB2
  • Sryder/SRB2
  • wolfy852/SRB2
  • Alpha2244/SRB2
  • Inuyasha/SRB2
  • yoshibot/SRB2
  • TehRealSalt/SRB2
  • PrisimaTF/SRB2
  • Hatninja/SRB2
  • SteelT/SRB2
  • james/SRB2
  • ShaderWraith/SRB2
  • SinnamonLat/SRB2
  • mazmazz_/SRB2
  • filpAM/SRB2
  • chaoloveicemdboy/SRB2
  • Whooa21/SRB2
  • Machturne/SRB2
  • Golden/SRB2
  • Tatsuru/SRB2
  • Snu/SRB2
  • Zwip-Zwap_Zapony/SRB2
  • fickleheart/SRB2
  • alphaRexJames/SRB2
  • JJK/SRB2
  • diskpoppy/SRB2
  • Hannu_Hanhi/SRB2
  • ZipperQR/SRB2
  • kays/SRB2
  • spherallic/SRB2
  • Zippy_Zolton/SRB2
  • namiishere/SRB2
  • Ors/SRB2
  • SMS_Alfredo/SRB2
  • sonic_edge/SRB2
  • lavla/SRB2
  • ashi/SRB2
  • X.organic/SRB2
  • Fafabis/SRB2
  • Meziu/SRB2
  • v-rob/SRB2
  • tertu/SRB2
  • bitten2up/SRB2
  • flarn2006/SRB2
  • Krabs/SRB2
  • clairebun/SRB2
  • Lactozilla/SRB2
  • thehackstack/SRB2
  • Spice/SRB2
  • win8linux/SRB2
  • JohnFrostFox/SRB2
  • talktoneon726/SRB2
  • Wane/SRB2
  • Lamibe/SRB2
  • spectrumuk2/srb-2
  • nerdyminer18/srb-2
  • 256nil/SRB2
  • ARJr/SRB2
  • Alam/SRB2
  • Zenya/srb-2-marathon-demos
  • Acelite/srb-2-archivedmodifications
  • MIDIMan/SRB2
  • Lach/SRB2
  • Frostiikin/bounce-tweaks
  • Jaden/SRB2
  • Tyron/SRB2
  • Astronight/SRB2
  • Mari0shi06/SRB2
  • aiire/SRB2
  • Galactice/SRB2
  • srb2-ports/srb2-dreamcast
  • sdasdas/SRB2
  • chreas/srb-2-vr
  • StarManiaKG/the-story-of-sinically-rocketing-and-botching-the-2nd
  • LoganAir/SRB2
  • NepDisk/srb-2
  • alufolie91/SRB2
  • Felicia.iso/SRB2
  • twi/SRB2
  • BarrelsOFun/SRB2
  • Speed2411/SRB2
  • Leather_Realms/SRB2
  • Ayemar/SRB2
  • Acelite/SRB2
  • VladDoc/SRB2
  • kaldrum/model-features
  • strawberryfox417/SRB2
  • Lugent/SRB2
  • Jisk/SRB2
  • Rem/SRB2
  • Refrag/SRB2
  • Henry_3230/srb-3230
  • TehPuertoRicanSpartan2/tprs-srb2
  • Leminn/srb-2-marathon-stuff
  • chromaticpipe2/SRB2
  • MiguelGustavo15/SRB2
  • Maru/srb-2-tests
  • SilicDev/SRB2
  • UnmatchedBracket/SRB2
  • HybridDog/SRB2
  • xordspar0/SRB2
  • jsjhbewfhh/SRB2
  • Fancy2209/SRB2
  • Lorsoen/SRB2
  • shindoukin/SRB2
  • GamerOfDays/SRB2
  • Craftyawesome/SRB2
  • tenshi-tensai-tennoji/SRB2
  • Scarfdudebalder/SRB2
  • luigi-budd/srb-2-fix-interplag-lockon
  • mskluesner/SRB2
  • johnpetersa19/SRB2
  • Pheazant/SRB2
  • chromaticpipe2/srb2classic
  • romoney5/SRB2
  • PAS/SRB2Classic
  • BlueStaggo/SRB2
117 results
Select Git revision
Show changes
Commits on Source (1)
...@@ -8,8 +8,6 @@ target_sources(SRB2SDL2 PRIVATE comptime.c md5.c config.h.in) ...@@ -8,8 +8,6 @@ target_sources(SRB2SDL2 PRIVATE comptime.c md5.c config.h.in)
set(SRB2_ASM_SOURCES vid_copy.s) set(SRB2_ASM_SOURCES vid_copy.s)
set(SRB2_NASM_SOURCES tmap_mmx.nas tmap.nas)
### Configuration ### Configuration
set(SRB2_CONFIG_HAVE_PNG ON CACHE BOOL set(SRB2_CONFIG_HAVE_PNG ON CACHE BOOL
"Enable PNG support. Depends on zlib, so will be disabled if you don't enable that too.") "Enable PNG support. Depends on zlib, so will be disabled if you don't enable that too.")
...@@ -213,8 +211,7 @@ if(${SRB2_CONFIG_USEASM}) ...@@ -213,8 +211,7 @@ if(${SRB2_CONFIG_USEASM})
target_compile_definitions(SRB2SDL2 PRIVATE -DUSEASM) target_compile_definitions(SRB2SDL2 PRIVATE -DUSEASM)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse3 -mfpmath=sse") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse3 -mfpmath=sse")
target_sources(SRB2SDL2 PRIVATE ${SRB2_ASM_SOURCES} target_sources(SRB2SDL2 PRIVATE ${SRB2_ASM_SOURCES})
${SRB2_NASM_SOURCES})
else() else()
set(SRB2_USEASM OFF) set(SRB2_USEASM OFF)
target_compile_definitions(SRB2SDL2 PRIVATE -DNONX86 -DNORUSEASM) target_compile_definitions(SRB2SDL2 PRIVATE -DNONX86 -DNORUSEASM)
......
...@@ -210,7 +210,7 @@ sources+=\ ...@@ -210,7 +210,7 @@ sources+=\
$(call List,blua/Sourcefile)\ $(call List,blua/Sourcefile)\
depends:=$(basename $(filter %.c %.s,$(sources))) depends:=$(basename $(filter %.c %.s,$(sources)))
objects:=$(basename $(filter %.c %.s %.nas,$(sources))) objects:=$(basename $(filter %.c %.s,$(sources)))
depends:=$(depends:%=$(depdir)/%.d) depends:=$(depends:%=$(depdir)/%.d)
......
...@@ -20,7 +20,6 @@ endif ...@@ -20,7 +20,6 @@ endif
ifndef NOASM ifndef NOASM
ifndef NONX86 ifndef NONX86
sources+=tmap.nas tmap_mmx.nas
opts+=-DUSEASM opts+=-DUSEASM
endif endif
endif endif
......
...@@ -511,8 +511,10 @@ static void D_Display(void) ...@@ -511,8 +511,10 @@ static void D_Display(void)
M_Memcpy(ylookup, ylookup1, viewheight*sizeof (ylookup[0])); M_Memcpy(ylookup, ylookup1, viewheight*sizeof (ylookup[0]));
} }
} }
ps_rendercalltime = I_GetPreciseTime() - ps_rendercalltime;
// Image postprocessing effect // Image postprocessing effect
ps_postprocesstime = I_GetPreciseTime();
if (rendermode == render_soft) if (rendermode == render_soft)
{ {
if (!splitscreen) if (!splitscreen)
...@@ -523,7 +525,7 @@ static void D_Display(void) ...@@ -523,7 +525,7 @@ static void D_Display(void)
if (postimgtype2) if (postimgtype2)
V_DoPostProcessor(1, postimgtype2, postimgparam2); V_DoPostProcessor(1, postimgtype2, postimgparam2);
} }
ps_rendercalltime = I_GetPreciseTime() - ps_rendercalltime; ps_postprocesstime = I_GetPreciseTime() - ps_postprocesstime;
} }
if (lastdraw) if (lastdraw)
......
...@@ -537,6 +537,9 @@ INT32 I_GetKey(void); ...@@ -537,6 +537,9 @@ INT32 I_GetKey(void);
// Max gamepad/joysticks that can be detected/used. // Max gamepad/joysticks that can be detected/used.
#define MAX_JOYSTICKS 4 #define MAX_JOYSTICKS 4
// Software multithreading
#define MAX_RENDER_THREADS 8
#ifndef M_PIl #ifndef M_PIl
#define M_PIl 3.1415926535897932384626433832795029L #define M_PIl 3.1415926535897932384626433832795029L
#endif #endif
...@@ -608,13 +611,6 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; ...@@ -608,13 +611,6 @@ extern const char *compdate, *comptime, *comprevision, *compbranch;
/// Experimental attempts at preventing MF_PAPERCOLLISION objects from getting stuck in walls. /// Experimental attempts at preventing MF_PAPERCOLLISION objects from getting stuck in walls.
//#define PAPER_COLLISIONCORRECTION //#define PAPER_COLLISIONCORRECTION
/// FINALLY some real clipping that doesn't make walls dissappear AND speeds the game up
/// (that was the original comment from SRB2CB, sadly it is a lie and actually slows game down)
/// on the bright side it fixes some weird issues with translucent walls
/// \note SRB2CB port.
/// SRB2CB itself ported this from PrBoom+
#define NEWCLIP
/// OpenGL shaders /// OpenGL shaders
#define GL_SHADERS #define GL_SHADERS
......
This diff is collapsed.
...@@ -35,7 +35,6 @@ void HWR_ClearSkyDome(void); ...@@ -35,7 +35,6 @@ void HWR_ClearSkyDome(void);
void HWR_BuildSkyDome(void); void HWR_BuildSkyDome(void);
void HWR_DrawViewBorder(INT32 clearlines); void HWR_DrawViewBorder(INT32 clearlines);
void HWR_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum); void HWR_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum);
void HWR_InitTextureMapping(void);
void HWR_SetViewSize(void); void HWR_SetViewSize(void);
void HWR_DrawPatch(patch_t *gpatch, INT32 x, INT32 y, INT32 option); void HWR_DrawPatch(patch_t *gpatch, INT32 x, INT32 y, INT32 option);
void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap); void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap);
......
...@@ -15,25 +15,39 @@ ...@@ -15,25 +15,39 @@
#define I_THREADS_H #define I_THREADS_H
typedef void (*I_thread_fn)(void *userdata); typedef void (*I_thread_fn)(void *userdata);
typedef void * I_thread_handle;
#ifdef HAVE_SDL
#include <SDL.h>
#define ATOMIC_TYPE SDL_atomic_t
#else
#define ATOMIC_TYPE UINT32
#endif
typedef ATOMIC_TYPE I_Atomicval_t;
typedef I_Atomicval_t * I_Atomicptr_t;
typedef void * I_mutex; typedef void * I_mutex;
typedef void * I_cond; typedef void * I_cond;
void I_start_threads (void); void I_start_threads (void);
void I_stop_threads (void); void I_stop_threads (void);
void I_spawn_thread (const char *name, I_thread_fn, void *userdata); I_thread_handle I_spawn_thread (const char *name, I_thread_fn, void *userdata);
/* check in your thread whether to return early */ /* check in your thread whether to return early */
int I_thread_is_stopped (void); int I_thread_is_stopped (void);
void I_lock_mutex (I_mutex *);
void I_unlock_mutex (I_mutex);
void I_lock_mutex (I_mutex *); void I_hold_cond (I_cond *, I_mutex);
void I_unlock_mutex (I_mutex);
void I_hold_cond (I_cond *, I_mutex); void I_wake_one_cond (I_cond *);
void I_wake_all_cond (I_cond *);
void I_wake_one_cond (I_cond *); INT32 I_atomic_load (I_Atomicptr_t atomic);
void I_wake_all_cond (I_cond *); INT32 I_atomic_exchange (I_Atomicptr_t atomic, INT32 val);
#endif/*I_THREADS_H*/ #endif/*I_THREADS_H*/
#endif/*HAVE_THREADS*/ #endif/*HAVE_THREADS*/
...@@ -100,7 +100,30 @@ enum { ...@@ -100,7 +100,30 @@ enum {
PERF_COUNT, PERF_COUNT,
}; };
static void M_DrawPerfString(perfstatcol_t *col, int type) static void M_DrawPerfString(const char *string, INT32 lores_x, INT32 hires_x, INT32 flags)
{
const boolean hires = M_HighResolution();
INT32 draw_flags = V_MONOSPACE | flags;
if (hires)
draw_flags |= V_ALLOWLOWERCASE;
if (hires)
{
V_DrawFillConsoleMap(hires_x, draw_row, V_SmallStringWidth(string, draw_flags), 5, 0);
V_DrawSmallString(hires_x, draw_row, draw_flags, string);
draw_row += 5;
}
else
{
V_DrawFillConsoleMap(lores_x, draw_row, V_ThinStringWidth(string, draw_flags), 8, 0);
V_DrawThinString(lores_x, draw_row, draw_flags, string);
draw_row += 8;
}
}
static void M_DrawPerfMeasurement(perfstatcol_t *col, int type)
{ {
const boolean hires = M_HighResolution(); const boolean hires = M_HighResolution();
...@@ -122,15 +145,19 @@ static void M_DrawPerfString(perfstatcol_t *col, int type) ...@@ -122,15 +145,19 @@ static void M_DrawPerfString(perfstatcol_t *col, int type)
if (hires) if (hires)
{ {
V_DrawSmallString(col->hires_x, draw_row, draw_flags, const char *string = va("%s %d", row->hires_label, value);
va("%s %d", row->hires_label, value));
V_DrawFillConsoleMap(col->hires_x, draw_row, V_SmallStringWidth(string, draw_flags), 5, 0);
V_DrawSmallString(col->hires_x, draw_row, draw_flags, string);
draw_row += 5; draw_row += 5;
} }
else else
{ {
V_DrawThinString(col->lores_x, draw_row, draw_flags, const char *string = va("%s %d", row->lores_label, value);
va("%s %d", row->lores_label, value));
V_DrawFillConsoleMap(col->lores_x, draw_row, V_SmallStringWidth(string, draw_flags), 8, 0);
V_DrawThinString(col->lores_x, draw_row, draw_flags, string);
draw_row += 8; draw_row += 8;
} }
...@@ -139,12 +166,12 @@ static void M_DrawPerfString(perfstatcol_t *col, int type) ...@@ -139,12 +166,12 @@ static void M_DrawPerfString(perfstatcol_t *col, int type)
static void M_DrawPerfTiming(perfstatcol_t *col) static void M_DrawPerfTiming(perfstatcol_t *col)
{ {
M_DrawPerfString(col, PERF_TIME); M_DrawPerfMeasurement(col, PERF_TIME);
} }
static void M_DrawPerfCount(perfstatcol_t *col) static void M_DrawPerfCount(perfstatcol_t *col)
{ {
M_DrawPerfString(col, PERF_COUNT); M_DrawPerfMeasurement(col, PERF_COUNT);
} }
static void M_DrawRenderStats(void) static void M_DrawRenderStats(void)
...@@ -161,7 +188,7 @@ static void M_DrawRenderStats(void) ...@@ -161,7 +188,7 @@ static void M_DrawRenderStats(void)
}; };
perfstatrow_t rendercalltime_row[] = { perfstatrow_t rendercalltime_row[] = {
{"drwtime", "3d rendering: ", &ps_rendercalltime}, {"drwtime", "3D rendering: ", &ps_rendercalltime},
{0} {0}
}; };
...@@ -176,16 +203,6 @@ static void M_DrawRenderStats(void) ...@@ -176,16 +203,6 @@ static void M_DrawRenderStats(void)
{0} {0}
}; };
perfstatrow_t softwaretime_row[] = {
{"bsptime", "RenderBSPNode: ", &ps_bsptime},
{"sprclip", "R_ClipSprites: ", &ps_sw_spritecliptime},
{"portals", "Portals+Skybox:", &ps_sw_portaltime},
{"planes ", "R_DrawPlanes: ", &ps_sw_planetime},
{"masked ", "R_DrawMasked: ", &ps_sw_maskedtime},
{"other ", "Other: ", &extrarendertime},
{0}
};
perfstatrow_t uiswaptime_row[] = { perfstatrow_t uiswaptime_row[] = {
{"ui ", "UI render: ", &ps_uitime}, {"ui ", "UI render: ", &ps_uitime},
{"finupdt", "I_FinishUpdate:", &ps_swaptime}, {"finupdt", "I_FinishUpdate:", &ps_swaptime},
...@@ -197,14 +214,6 @@ static void M_DrawRenderStats(void) ...@@ -197,14 +214,6 @@ static void M_DrawRenderStats(void)
{0} {0}
}; };
perfstatrow_t rendercalls_row[] = {
{"bspcall", "BSP calls: ", &ps_numbspcalls},
{"sprites", "Sprites: ", &ps_numsprites},
{"drwnode", "Drawnodes: ", &ps_numdrawnodes},
{"plyobjs", "Polyobjects: ", &ps_numpolyobjects},
{0}
};
perfstatrow_t batchtime_row[] = { perfstatrow_t batchtime_row[] = {
{"batsort", "Batch sort: ", &ps_hw_batchsorttime}, {"batsort", "Batch sort: ", &ps_hw_batchsorttime},
{"batdraw", "Batch render:", &ps_hw_batchdrawtime}, {"batdraw", "Batch render:", &ps_hw_batchdrawtime},
...@@ -230,13 +239,10 @@ static void M_DrawRenderStats(void) ...@@ -230,13 +239,10 @@ static void M_DrawRenderStats(void)
perfstatcol_t rendercalltime_col = {20, 20, V_YELLOWMAP, rendercalltime_row}; perfstatcol_t rendercalltime_col = {20, 20, V_YELLOWMAP, rendercalltime_row};
perfstatcol_t opengltime_col = {24, 24, V_YELLOWMAP, opengltime_row}; perfstatcol_t opengltime_col = {24, 24, V_YELLOWMAP, opengltime_row};
perfstatcol_t softwaretime_col = {24, 24, V_YELLOWMAP, softwaretime_row};
perfstatcol_t uiswaptime_col = {20, 20, V_YELLOWMAP, uiswaptime_row}; perfstatcol_t uiswaptime_col = {20, 20, V_YELLOWMAP, uiswaptime_row};
perfstatcol_t tictime_col = {20, 20, V_GRAYMAP, tictime_row}; perfstatcol_t tictime_col = {20, 20, V_GRAYMAP, tictime_row};
perfstatcol_t rendercalls_col = {90, 115, V_BLUEMAP, rendercalls_row};
perfstatcol_t batchtime_col = {90, 115, V_REDMAP, batchtime_row}; perfstatcol_t batchtime_col = {90, 115, V_REDMAP, batchtime_row};
perfstatcol_t batchcount_col = {155, 200, V_PURPLEMAP, batchcount_row}; perfstatcol_t batchcount_col = {155, 200, V_PURPLEMAP, batchcount_row};
...@@ -256,12 +262,13 @@ static void M_DrawRenderStats(void) ...@@ -256,12 +262,13 @@ static void M_DrawRenderStats(void)
M_DrawPerfTiming(&rendercalltime_col); M_DrawPerfTiming(&rendercalltime_col);
// Remember to update this calculation when adding more 3d rendering stats! // Remember to update this calculation when adding more 3d rendering stats!
extrarendertime = ps_rendercalltime - ps_bsptime; extrarendertime = ps_rendercalltime;
#ifdef HWRENDER #ifdef HWRENDER
if (rendermode == render_opengl) if (rendermode == render_opengl)
{ {
extrarendertime -= extrarendertime =
ps_bsptime[0] +
ps_hw_skyboxtime + ps_hw_skyboxtime +
ps_hw_nodesorttime + ps_hw_nodesorttime +
ps_hw_nodedrawtime + ps_hw_nodedrawtime +
...@@ -280,13 +287,32 @@ static void M_DrawRenderStats(void) ...@@ -280,13 +287,32 @@ static void M_DrawRenderStats(void)
else else
#endif #endif
{ {
extrarendertime -= INT32 i = 0;
ps_sw_spritecliptime +
ps_sw_portaltime + perfstatrow_t other_row[] = {
ps_sw_planetime + {"postprc", "Postprocessing:", &ps_postprocesstime},
ps_sw_maskedtime; {0}
};
perfstatcol_t other_col = {24, 24, V_YELLOWMAP, other_row};
for (i = 0; i < numusablerendercontexts; i++) {
perfstatrow_t softwaretime_row[] = {
{"bsptime", "RenderBSPNode: ", &ps_bsptime[i]},
{"sprclip", "R_ClipSprites: ", &ps_sw_spritecliptime[i]},
{"portals", "Portals+Skybox:", &ps_sw_portaltime[i]},
{"planes ", "R_DrawPlanes: ", &ps_sw_planetime[i]},
{"masked ", "R_DrawMasked: ", &ps_sw_maskedtime[i]},
{0}
};
perfstatcol_t softwaretime_col = {28, 28, V_YELLOWMAP, softwaretime_row};
M_DrawPerfString(va("Thread %d:", i+1), 24, 24, V_REDMAP);
M_DrawPerfTiming(&softwaretime_col);
}
M_DrawPerfTiming(&softwaretime_col); M_DrawPerfTiming(&other_col);
} }
} }
...@@ -297,8 +323,41 @@ static void M_DrawRenderStats(void) ...@@ -297,8 +323,41 @@ static void M_DrawRenderStats(void)
if (rendering) if (rendering)
{ {
draw_row = 10; draw_row = 10;
M_DrawPerfCount(&rendercalls_col);
#ifdef HWRENDER
if (rendermode == render_opengl) {
perfstatrow_t rendercalls_row[] = {
{"bspcall", "BSP calls: ", &ps_numbspcalls},
{"sprites", "Sprites: ", &ps_numsprites},
{"drwnode", "Drawnodes: ", &ps_numdrawnodes},
{"plyobjs", "Polyobjects: ", &ps_numpolyobjects},
{0}
};
perfstatcol_t rendercalls_col = {90, 115, V_BLUEMAP, rendercalls_row};
M_DrawPerfCount(&rendercalls_col);
} else
#endif
{
INT32 i;
for (i = 0; i < numusablerendercontexts; i++) {
perfstatrow_t rendercalls_row[] = {
{"bspcall", "BSP calls: ", &ps_numbspcalls[i]},
{"sprites", "Sprites: ", &ps_numsprites[i]},
{"drwnode", "Drawnodes: ", &ps_numdrawnodes[i]},
{"plyobjs", "Polyobjects: ", &ps_numpolyobjects[i]},
{0}
};
perfstatcol_t rendercalls_col = {94, 120, V_BLUEMAP, rendercalls_row};
M_DrawPerfString(va("Thread %d:", i+1), 90, 115, V_REDMAP);
M_DrawPerfCount(&rendercalls_col);
}
}
#ifdef HWRENDER #ifdef HWRENDER
if (rendermode == render_opengl && cv_glbatching.value) if (rendermode == render_opengl && cv_glbatching.value)
......
This diff is collapsed.
...@@ -18,27 +18,16 @@ ...@@ -18,27 +18,16 @@
#pragma interface #pragma interface
#endif #endif
extern seg_t *curline;
extern side_t *sidedef;
extern line_t *linedef;
extern sector_t *frontsector;
extern sector_t *backsector;
extern boolean portalline; // is curline a portal seg?
// drawsegs are allocated on the fly... see r_segs.c
extern INT32 checkcoord[12][4]; extern INT32 checkcoord[12][4];
extern drawseg_t *curdrawsegs; struct bspcontext_s;
extern drawseg_t *drawsegs; struct rendercontext_s;
extern drawseg_t *ds_p; struct viewcontext_s;
extern INT32 doorclosed;
// BSP? // BSP?
void R_ClearClipSegs(void); void R_ClearClipSegs(struct bspcontext_s *context, INT32 start, INT32 end);
void R_PortalClearClipSegs(INT32 start, INT32 end); void R_ClearDrawSegs(struct bspcontext_s *context);
void R_ClearDrawSegs(void); void R_RenderBSPNode(struct rendercontext_s *context, INT32 bspnum);
void R_RenderBSPNode(INT32 bspnum);
void R_SortPolyObjects(subsector_t *sub); void R_SortPolyObjects(subsector_t *sub);
...@@ -46,8 +35,8 @@ extern size_t numpolys; // number of polyobjects in current subsector ...@@ -46,8 +35,8 @@ extern size_t numpolys; // number of polyobjects in current subsector
extern size_t num_po_ptrs; // number of polyobject pointers allocated extern size_t num_po_ptrs; // number of polyobject pointers allocated
extern polyobj_t **po_ptrs; // temp ptr array to sort polyobject pointers extern polyobj_t **po_ptrs; // temp ptr array to sort polyobject pointers
sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, sector_t *R_FakeFlat(struct viewcontext_s *viewcontext, sector_t *sec, sector_t *tempsec,
INT32 *ceilinglightlevel, boolean back); INT32 *floorlightlevel, INT32 *ceilinglightlevel, boolean back);
boolean R_IsEmptyLine(seg_t *line, sector_t *front, sector_t *back); boolean R_IsEmptyLine(seg_t *line, sector_t *front, sector_t *back);
INT32 R_GetPlaneLight(sector_t *sector, fixed_t planeheight, boolean underside); INT32 R_GetPlaneLight(sector_t *sector, fixed_t planeheight, boolean underside);
......
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 1993-1996 by id Software, Inc.
// Copyright (C) 2020 by Ethan Watson.
//
// 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_context.h
/// \brief Render context
#ifndef __R_CONTEXT__
#define __R_CONTEXT__
#include "r_defs.h"
#include "r_bsp.h"
#include "r_plane.h"
#include "r_splats.h"
#include "r_things.h"
//
// Render context is required for threaded rendering.
// So everything "global" goes in here. Everything.
//
typedef struct viewcontext_s
{
fixed_t x, y, z;
angle_t angle, aimingangle;
fixed_t cos, sin;
sector_t *sector;
player_t *player;
mobj_t *mobj;
} viewcontext_t;
typedef struct bspcontext_s
{
seg_t *curline;
side_t *sidedef;
line_t *linedef;
sector_t *frontsector;
sector_t *backsector;
// very ugly realloc() of drawsegs at run-time, I upped it to 512
// instead of 256.. and someone managed to send me a level with
// 896 drawsegs! So too bad here's a limit removal a-la-Boom
drawseg_t *curdrawsegs; /**< This is used to handle multiple lists for masked drawsegs. */
drawseg_t *drawsegs;
drawseg_t *ds_p;
drawseg_t *firstseg;
size_t maxdrawsegs;
// newend is one past the last valid seg
cliprange_t *newend;
cliprange_t solidsegs[MAXSEGS];
sector_t ftempsec;
sector_t btempsec;
UINT8 doorclosed;
// Linked list for portals.
struct portal_s *portal_base, *portal_cap;
// When rendering a portal, it establishes the depth of the current BSP traversal.
UINT8 portalrender;
boolean portalline;
line_t *portalclipline;
sector_t *portalcullsector;
INT32 portalclipstart, portalclipend;
} bspcontext_t;
typedef struct planecontext_s
{
//SoM: 3/23/2000: Use Boom visplane hashing.
visplane_t *visplanes[MAXVISPLANES];
visplane_t *freetail;
visplane_t **freehead;
visplane_t *floorplane;
visplane_t *ceilingplane;
visplane_t *currentplane;
planemgr_t ffloor[MAXFFLOORS];
INT32 numffloors;
//SoM: 3/23/2000: Use boom opening limit removal
size_t maxopenings;
INT16 *openings, *lastopening; /// \todo free leak
//
// Clip values are the solid pixel bounding the range.
// floorclip starts out SCREENHEIGHT
// ceilingclip starts out -1
//
INT16 floorclip[MAXVIDWIDTH], ceilingclip[MAXVIDWIDTH];
fixed_t frontscale[MAXVIDWIDTH];
//
// spanstart holds the start of a plane span
// initialized to 0 at start
//
INT32 spanstart[MAXVIDHEIGHT];
//
// texture mapping
//
lighttable_t **zlight;
fixed_t planeheight;
fixed_t cachedheight[MAXVIDHEIGHT];
fixed_t cacheddistance[MAXVIDHEIGHT];
fixed_t cachedxstep[MAXVIDHEIGHT];
fixed_t cachedystep[MAXVIDHEIGHT];
fixed_t xoffs, yoffs;
struct
{
INT32 offset;
fixed_t xfrac, yfrac;
boolean active;
} ripple;
struct rastery_s *prastertab;
struct rastery_s rastertab[MAXVIDHEIGHT];
} planecontext_t;
typedef struct spritecontext_s
{
UINT32 visspritecount;
UINT32 clippedvissprites;
vissprite_t *visspritechunks[MAXVISSPRITES >> VISSPRITECHUNKBITS];
vissprite_t overflowsprite;
lighttable_t **spritelights;
boolean *sectorvisited;
drawnode_t nodebankhead;
vissprite_t vsprsortedhead;
} spritecontext_t;
typedef struct wallcontext_s
{
angle_t normalangle;
// angle to line origin
angle_t angle1;
fixed_t distance;
//
// regular wall
//
angle_t centerangle;
fixed_t offset;
fixed_t offset2; // for splats
fixed_t scale, scalestep;
fixed_t midtexturemid, toptexturemid, bottomtexturemid;
fixed_t toptextureslide, midtextureslide, bottomtextureslide; // Defines how to adjust Y offsets along the wall for slopes
fixed_t midtextureback, midtexturebackslide; // Values for masked midtexture height calculation
INT32 *silhouette;
fixed_t *tsilheight;
fixed_t *bsilheight;
} wallcontext_t;
typedef struct rendercontext_s
{
// Setup
vbuffer_t buffer;
INT32 num;
INT32 begincolumn;
INT32 endcolumn;
viewcontext_t viewcontext;
bspcontext_t bspcontext;
planecontext_t planecontext;
spritecontext_t spritecontext;
colcontext_t colcontext;
spancontext_t spancontext;
} rendercontext_t;
#endif
...@@ -1240,8 +1240,8 @@ void R_PrecacheLevel(void) ...@@ -1240,8 +1240,8 @@ void R_PrecacheLevel(void)
return; return;
// do not flush the memory, Z_Malloc twice with same user will cause error in Z_CheckHeap() // do not flush the memory, Z_Malloc twice with same user will cause error in Z_CheckHeap()
if (rendermode != render_soft) // if (rendermode != render_soft)
return; // return;
// Precache flats. // Precache flats.
flatmemory = P_PrecacheLevelFlats(); flatmemory = P_PrecacheLevelFlats();
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
// SECTORS do store MObjs anyway. // SECTORS do store MObjs anyway.
#include "p_mobj.h" #include "p_mobj.h"
#include "screen.h" // MAXVIDWIDTH, MAXVIDHEIGHT #include "screen.h"
#ifdef HWRENDER #ifdef HWRENDER
#include "m_aatree.h" #include "m_aatree.h"
...@@ -41,6 +41,9 @@ typedef struct ...@@ -41,6 +41,9 @@ typedef struct
INT32 last; INT32 last;
} cliprange_t; } cliprange_t;
// Fix from boom.
#define MAXSEGS (MAXVIDWIDTH/2+1)
// Silhouette, needed for clipping segs (mainly) and sprites representing things. // Silhouette, needed for clipping segs (mainly) and sprites representing things.
#define SIL_NONE 0 #define SIL_NONE 0
#define SIL_BOTTOM 1 #define SIL_BOTTOM 1
...@@ -56,6 +59,15 @@ typedef UINT8 lighttable_t; ...@@ -56,6 +59,15 @@ typedef UINT8 lighttable_t;
#define CMF_FADEFULLBRIGHTSPRITES 1 #define CMF_FADEFULLBRIGHTSPRITES 1
#define CMF_FOG 4 #define CMF_FOG 4
typedef struct vbuffer_s
{
UINT8 *screens[5];
} vbuffer_t;
typedef struct {
float x, y, z;
} floatv3_t;
// ExtraColormap type. Use for extra_colormaps from now on. // ExtraColormap type. Use for extra_colormaps from now on.
typedef struct extracolormap_s typedef struct extracolormap_s
{ {
......
...@@ -62,14 +62,6 @@ UINT8 *topleft; ...@@ -62,14 +62,6 @@ UINT8 *topleft;
// COLUMN DRAWING CODE STUFF // COLUMN DRAWING CODE STUFF
// ========================================================================= // =========================================================================
lighttable_t *dc_colormap;
INT32 dc_x = 0, dc_yl = 0, dc_yh = 0;
fixed_t dc_iscale, dc_texturemid;
UINT8 dc_hires; // under MSVC boolean is a byte, while on other systems, it a bit,
// soo lets make it a byte on all system for the ASM code
UINT8 *dc_source;
// ----------------------- // -----------------------
// translucency stuff here // translucency stuff here
// ----------------------- // -----------------------
...@@ -78,48 +70,11 @@ UINT8 *dc_source; ...@@ -78,48 +70,11 @@ UINT8 *dc_source;
UINT8 *transtables; // translucency tables UINT8 *transtables; // translucency tables
UINT8 *blendtables[NUMBLENDMAPS]; UINT8 *blendtables[NUMBLENDMAPS];
/** \brief R_DrawTransColumn uses this
*/
UINT8 *dc_transmap; // one of the translucency tables
// ----------------------
// translation stuff here
// ----------------------
/** \brief R_DrawTranslatedColumn uses this
*/
UINT8 *dc_translation;
struct r_lightlist_s *dc_lightlist = NULL;
INT32 dc_numlights = 0, dc_maxlights, dc_texheight;
// ========================================================================= // =========================================================================
// SPAN DRAWING CODE STUFF // SPAN DRAWING CODE STUFF
// ========================================================================= // =========================================================================
INT32 ds_y, ds_x1, ds_x2; float focallengthf;
lighttable_t *ds_colormap;
lighttable_t *ds_translation; // Lactozilla: Sprite splat drawer
fixed_t ds_xfrac, ds_yfrac, ds_xstep, ds_ystep;
INT32 ds_waterofs, ds_bgofs;
UINT16 ds_flatwidth, ds_flatheight;
boolean ds_powersoftwo;
UINT8 *ds_source; // points to the start of a flat
UINT8 *ds_transmap; // one of the translucency tables
// Vectors for Software's tilted slope drawers
floatv3_t *ds_su, *ds_sv, *ds_sz;
floatv3_t *ds_sup, *ds_svp, *ds_szp;
float focallengthf, zeroheight;
/** \brief Variable flat sizes
*/
UINT32 nflatxshift, nflatyshift, nflatshiftup, nflatmask;
// ========================================================================= // =========================================================================
// TRANSLATION COLORMAP CODE // TRANSLATION COLORMAP CODE
...@@ -572,6 +527,15 @@ static void R_GenerateTranslationColormap(UINT8 *dest_colormap, INT32 skinnum, U ...@@ -572,6 +527,15 @@ static void R_GenerateTranslationColormap(UINT8 *dest_colormap, INT32 skinnum, U
dest_colormap[starttranscolor + i] = (UINT8)skincolors[color].ramp[i]; dest_colormap[starttranscolor + i] = (UINT8)skincolors[color].ramp[i];
} }
#ifdef HAVE_THREADS
static I_mutex r_colormap_mutex;
# define Lock_state() I_lock_mutex(&r_colormap_mutex)
# define Unlock_state() I_unlock_mutex(r_colormap_mutex)
#else/*HAVE_THREADS*/
# define Lock_state()
# define Unlock_state()
#endif/*HAVE_THREADS*/
/** \brief Retrieves a translation colormap from the cache. /** \brief Retrieves a translation colormap from the cache.
...@@ -589,13 +553,16 @@ UINT8* R_GetTranslationColormap(INT32 skinnum, skincolornum_t color, UINT8 flags ...@@ -589,13 +553,16 @@ UINT8* R_GetTranslationColormap(INT32 skinnum, skincolornum_t color, UINT8 flags
if (flags & GTC_CACHE) if (flags & GTC_CACHE)
{ {
Lock_state();
// Allocate table for skin if necessary // Allocate table for skin if necessary
if (!translationtablecache[skintableindex]) if (!translationtablecache[skintableindex])
translationtablecache[skintableindex] = Z_Calloc(MAXSKINCOLORS * sizeof(UINT8**), PU_STATIC, NULL); translationtablecache[skintableindex] = Z_Calloc(MAXSKINCOLORS * sizeof(UINT8**), PU_STATIC, NULL);
Unlock_state();
// Get colormap // Get colormap
ret = translationtablecache[skintableindex][color]; ret = translationtablecache[skintableindex][color];
Lock_state();
// Rebuild the cache if necessary // Rebuild the cache if necessary
if (skincolor_modified[color]) if (skincolor_modified[color])
{ {
...@@ -605,18 +572,21 @@ UINT8* R_GetTranslationColormap(INT32 skinnum, skincolornum_t color, UINT8 flags ...@@ -605,18 +572,21 @@ UINT8* R_GetTranslationColormap(INT32 skinnum, skincolornum_t color, UINT8 flags
skincolor_modified[color] = false; skincolor_modified[color] = false;
} }
Unlock_state();
} }
else ret = NULL; else ret = NULL;
// Generate the colormap if necessary // Generate the colormap if necessary
if (!ret) if (!ret)
{ {
Lock_state();
ret = Z_MallocAlign(NUM_PALETTE_ENTRIES, (flags & GTC_CACHE) ? PU_LEVEL : PU_STATIC, NULL, 8); ret = Z_MallocAlign(NUM_PALETTE_ENTRIES, (flags & GTC_CACHE) ? PU_LEVEL : PU_STATIC, NULL, 8);
R_GenerateTranslationColormap(ret, skinnum, color); R_GenerateTranslationColormap(ret, skinnum, color);
// Cache the colormap if desired // Cache the colormap if desired
if (flags & GTC_CACHE) if (flags & GTC_CACHE)
translationtablecache[skintableindex][color] = ret; translationtablecache[skintableindex][color] = ret;
Unlock_state();
} }
return ret; return ret;
...@@ -887,13 +857,37 @@ void R_DrawViewBorder(void) ...@@ -887,13 +857,37 @@ void R_DrawViewBorder(void)
// INCLUDE 8bpp DRAWING CODE HERE // INCLUDE 8bpp DRAWING CODE HERE
// ========================================================================== // ==========================================================================
#include "r_draw8.c" // R_CalcTiltedLighting
#include "r_draw8_npo2.c" // Exactly what it says on the tin. I wish I wasn't too lazy to explain things properly.
static void R_CalcTiltedLighting(spancontext_t *ds, 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 = ds->x1, right = ds->x2;
fixed_t step = (end-start)/(ds->x2-ds->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,
// INCLUDE 16bpp DRAWING CODE HERE // but I'm too bad at coding to not crash the game trying to do that. I guess this is fast enough for now...
// ==========================================================================
#ifdef HIGHCOLOR for (i = left; i <= right; i++) {
#include "r_draw16.c" ds->tiltlighting[i] = (start += step) >> FRACBITS;
#endif if (ds->tiltlighting[i] < 0)
ds->tiltlighting[i] = 0;
else if (ds->tiltlighting[i] >= MAXLIGHTSCALE)
ds->tiltlighting[i] = MAXLIGHTSCALE-1;
}
}
#define PLANELIGHTFLOAT (BASEVIDWIDTH * BASEVIDWIDTH / vid.width / ds->zeroheight / 21.0f * FIXED_TO_FLOAT(fovtan))
// Lighting is simple. It's just linear interpolation from start to end
#define CALC_TILTED_LIGHTING { \
float planelightfloat = PLANELIGHTFLOAT; \
float lightend = (iz + ds->szp->x*width) * planelightfloat; \
float lightstart = iz * planelightfloat; \
R_CalcTiltedLighting(ds, FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend)); \
}
#include "r_draw8.c"
#include "r_draw8_npo2.c"
...@@ -25,61 +25,7 @@ extern UINT8 *ylookup2[MAXVIDHEIGHT*4]; ...@@ -25,61 +25,7 @@ extern UINT8 *ylookup2[MAXVIDHEIGHT*4];
extern INT32 columnofs[MAXVIDWIDTH*4]; extern INT32 columnofs[MAXVIDWIDTH*4];
extern UINT8 *topleft; extern UINT8 *topleft;
// ------------------------- extern float focallengthf;
// COLUMN DRAWING CODE STUFF
// -------------------------
extern lighttable_t *dc_colormap;
extern INT32 dc_x, dc_yl, dc_yh;
extern fixed_t dc_iscale, dc_texturemid;
extern UINT8 dc_hires;
extern UINT8 *dc_source; // first pixel in a column
// translucency stuff here
extern UINT8 *dc_transmap;
// translation stuff here
extern UINT8 *dc_translation;
extern struct r_lightlist_s *dc_lightlist;
extern INT32 dc_numlights, dc_maxlights;
//Fix TUTIFRUTI
extern INT32 dc_texheight;
// -----------------------
// SPAN DRAWING CODE STUFF
// -----------------------
extern INT32 ds_y, ds_x1, ds_x2;
extern lighttable_t *ds_colormap;
extern lighttable_t *ds_translation;
extern fixed_t ds_xfrac, ds_yfrac, ds_xstep, ds_ystep;
extern INT32 ds_waterofs, ds_bgofs;
extern UINT16 ds_flatwidth, ds_flatheight;
extern boolean ds_powersoftwo;
extern UINT8 *ds_source;
extern UINT8 *ds_transmap;
typedef struct {
float x, y, z;
} floatv3_t;
// Vectors for Software's tilted slope drawers
extern floatv3_t *ds_su, *ds_sv, *ds_sz;
extern floatv3_t *ds_sup, *ds_svp, *ds_szp;
extern float focallengthf, zeroheight;
// Variable flat sizes
extern UINT32 nflatxshift;
extern UINT32 nflatyshift;
extern UINT32 nflatshiftup;
extern UINT32 nflatmask;
/// \brief Top border /// \brief Top border
#define BRDR_T 0 #define BRDR_T 0
...@@ -163,85 +109,180 @@ void R_DrawViewBorder(void); ...@@ -163,85 +109,180 @@ void R_DrawViewBorder(void);
#define TRANSPARENTPIXEL 255 #define TRANSPARENTPIXEL 255
// ----------------- typedef struct colcontext_s
// 8bpp DRAWING CODE {
// ----------------- void (*func) (struct colcontext_s *);
vbuffer_t *dest;
void R_DrawColumn_8(void); INT32 x, yl, yh;
void R_DrawShadeColumn_8(void); fixed_t iscale, texturemid;
void R_DrawTranslucentColumn_8(void); lighttable_t *colormap;
void R_DrawTranslatedColumn_8(void);
void R_DrawTranslatedTranslucentColumn_8(void);
void R_Draw2sMultiPatchColumn_8(void);
void R_Draw2sMultiPatchTranslucentColumn_8(void);
void R_DrawFogColumn_8(void);
void R_DrawColumnShadowed_8(void);
#define PLANELIGHTFLOAT (BASEVIDWIDTH * BASEVIDWIDTH / vid.width / zeroheight / 21.0f * FIXED_TO_FLOAT(fovtan)) UINT8 *source; // first pixel in a column
void R_DrawSpan_8(void); // translucency stuff here
void R_DrawTranslucentSpan_8(void); UINT8 *transmap;
void R_DrawTiltedSpan_8(void);
void R_DrawTiltedTranslucentSpan_8(void);
void R_DrawSplat_8(void); // translation stuff here
void R_DrawTranslucentSplat_8(void); UINT8 *translation;
void R_DrawTiltedSplat_8(void);
void R_DrawFloorSprite_8(void); struct r_lightlist_s *lightlist;
void R_DrawTranslucentFloorSprite_8(void); INT32 numlights, maxlights;
void R_DrawTiltedFloorSprite_8(void);
void R_DrawTiltedTranslucentFloorSprite_8(void);
void R_CalcTiltedLighting(fixed_t start, fixed_t end); //Fix TUTIFRUTI
extern INT32 tiltlighting[MAXVIDWIDTH]; INT32 texheight;
void R_DrawTranslucentWaterSpan_8(void); // vars for R_DrawMaskedColumn
void R_DrawTiltedTranslucentWaterSpan_8(void); // Rum and Raisin put these on the sprite context.
// I put them on the column context because it felt
// more appropriate (for [REDACTED] anyway)
INT16 *mfloorclip;
INT16 *mceilingclip;
void R_DrawFogSpan_8(void); fixed_t spryscale, sprtopscreen, sprbotscreen;
fixed_t windowtop, windowbottom;
// Lactozilla: Non-powers-of-two // column->length : for flipped column function pointers and multi-patch on 2sided wall = texture->height
void R_DrawSpan_NPO2_8(void); INT32 lengthcol;
void R_DrawTranslucentSpan_NPO2_8(void); } colcontext_t;
void R_DrawTiltedSpan_NPO2_8(void);
void R_DrawTiltedTranslucentSpan_NPO2_8(void);
void R_DrawSplat_NPO2_8(void); typedef struct spancontext_s
void R_DrawTranslucentSplat_NPO2_8(void); {
void R_DrawTiltedSplat_NPO2_8(void); void (*func) (struct spancontext_s *);
vbuffer_t *dest;
void R_DrawFloorSprite_NPO2_8(void); INT32 y, x1, x2;
void R_DrawTranslucentFloorSprite_NPO2_8(void); lighttable_t *colormap;
void R_DrawTiltedFloorSprite_NPO2_8(void); lighttable_t *translation;
void R_DrawTiltedTranslucentFloorSprite_NPO2_8(void);
void R_DrawTranslucentWaterSpan_NPO2_8(void); fixed_t xfrac, yfrac, xstep, ystep;
void R_DrawTiltedTranslucentWaterSpan_NPO2_8(void); INT32 waterofs, bgofs;
#ifdef USEASM UINT16 flatwidth, flatheight;
void ASMCALL R_DrawColumn_8_ASM(void); boolean powersoftwo;
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); UINT8 *source;
UINT8 *transmap;
void ASMCALL R_Draw2sMultiPatchColumn_8_MMX(void); // Vectors for Software's tilted slope drawers
void ASMCALL R_DrawSpan_8_MMX(void); floatv3_t *su, *sv, *sz;
#endif floatv3_t *sup, *svp, *szp;
floatv3_t slope_origin, slope_u, slope_v;
float zeroheight;
// ------------------ // Variable flat sizes
// 16bpp DRAWING CODE UINT32 nflatxshift;
// ------------------ UINT32 nflatyshift;
UINT32 nflatshiftup;
UINT32 nflatmask;
#ifdef HIGHCOLOR lighttable_t **zlight;
void R_DrawColumn_16(void); INT32 tiltlighting[MAXVIDWIDTH];
void R_DrawWallColumn_16(void); } spancontext_t;
void R_DrawTranslucentColumn_16(void);
void R_DrawTranslatedColumn_16(void); typedef void (*colfunc_t) (colcontext_t *);
void R_DrawSpan_16(void); typedef void (*spanfunc_t) (spancontext_t *);
#endif
// ---------------------------------------------
// color mode dependent drawer function pointers
// ---------------------------------------------
#define BASEDRAWFUNC 0
enum
{
COLDRAWFUNC_BASE = BASEDRAWFUNC,
COLDRAWFUNC_FUZZY,
COLDRAWFUNC_TRANS,
COLDRAWFUNC_SHADE,
COLDRAWFUNC_SHADOWED,
COLDRAWFUNC_TRANSTRANS,
COLDRAWFUNC_TWOSMULTIPATCH,
COLDRAWFUNC_TWOSMULTIPATCHTRANS,
COLDRAWFUNC_FOG,
COLDRAWFUNC_MAX
};
extern colfunc_t colfuncs[COLDRAWFUNC_MAX];
enum
{
SPANDRAWFUNC_BASE = BASEDRAWFUNC,
SPANDRAWFUNC_TRANS,
SPANDRAWFUNC_TILTED,
SPANDRAWFUNC_TILTEDTRANS,
SPANDRAWFUNC_SPLAT,
SPANDRAWFUNC_TRANSSPLAT,
SPANDRAWFUNC_TILTEDSPLAT,
SPANDRAWFUNC_SPRITE,
SPANDRAWFUNC_TRANSSPRITE,
SPANDRAWFUNC_TILTEDSPRITE,
SPANDRAWFUNC_TILTEDTRANSSPRITE,
SPANDRAWFUNC_WATER,
SPANDRAWFUNC_TILTEDWATER,
SPANDRAWFUNC_FOG,
SPANDRAWFUNC_MAX
};
extern spanfunc_t spanfuncs[SPANDRAWFUNC_MAX];
extern spanfunc_t spanfuncs_npo2[SPANDRAWFUNC_MAX];
// -----------------
// 8bpp DRAWING CODE
// -----------------
void R_DrawColumn_8(colcontext_t *dc);
void R_DrawShadeColumn_8(colcontext_t *dc);
void R_DrawTranslucentColumn_8(colcontext_t *dc);
void R_DrawTranslatedColumn_8(colcontext_t *dc);
void R_DrawTranslatedTranslucentColumn_8(colcontext_t *dc);
void R_Draw2sMultiPatchColumn_8(colcontext_t *dc);
void R_Draw2sMultiPatchTranslucentColumn_8(colcontext_t *dc);
void R_DrawFogColumn_8(colcontext_t *dc);
void R_DrawColumnShadowed_8(colcontext_t *dc);
void R_DrawSpan_8(spancontext_t *ds);
void R_DrawTranslucentSpan_8(spancontext_t *ds);
void R_DrawTiltedSpan_8(spancontext_t *ds);
void R_DrawTiltedTranslucentSpan_8(spancontext_t *ds);
void R_DrawSplat_8(spancontext_t *ds);
void R_DrawTranslucentSplat_8(spancontext_t *ds);
void R_DrawTiltedSplat_8(spancontext_t *ds);
void R_DrawFloorSprite_8(spancontext_t *ds);
void R_DrawTranslucentFloorSprite_8(spancontext_t *ds);
void R_DrawTiltedFloorSprite_8(spancontext_t *ds);
void R_DrawTiltedTranslucentFloorSprite_8(spancontext_t *ds);
void R_DrawTranslucentWaterSpan_8(spancontext_t *ds);
void R_DrawTiltedTranslucentWaterSpan_8(spancontext_t *ds);
void R_DrawFogSpan_8(spancontext_t *ds);
// Lactozilla: Non-powers-of-two
void R_DrawSpan_NPO2_8(spancontext_t *ds);
void R_DrawTranslucentSpan_NPO2_8(spancontext_t *ds);
void R_DrawTiltedSpan_NPO2_8(spancontext_t *ds);
void R_DrawTiltedTranslucentSpan_NPO2_8(spancontext_t *ds);
void R_DrawSplat_NPO2_8(spancontext_t *ds);
void R_DrawTranslucentSplat_NPO2_8(spancontext_t *ds);
void R_DrawTiltedSplat_NPO2_8(spancontext_t *ds);
void R_DrawFloorSprite_NPO2_8(spancontext_t *ds);
void R_DrawTranslucentFloorSprite_NPO2_8(spancontext_t *ds);
void R_DrawTiltedFloorSprite_NPO2_8(spancontext_t *ds);
void R_DrawTiltedTranslucentFloorSprite_NPO2_8(spancontext_t *ds);
void R_DrawTranslucentWaterSpan_NPO2_8(spancontext_t *ds);
void R_DrawTiltedTranslucentWaterSpan_NPO2_8(spancontext_t *ds);
// ========================================================================= // =========================================================================
#endif // __R_DRAW__ #endif // __R_DRAW__
// 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_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--);
}
This diff is collapsed.
This diff is collapsed.
...@@ -34,8 +34,7 @@ ...@@ -34,8 +34,7 @@
#include "r_textures.h" #include "r_textures.h"
#include "r_things.h" #include "r_things.h"
#include "r_draw.h" #include "r_draw.h"
#include "r_context.h"
extern drawseg_t *firstseg;
void SplitScreen_OnChange(void); void SplitScreen_OnChange(void);
......