[renderer] Abandon sw32 altogether

I'd been considering it for a while, but in the end, all the issues it
presented made me decide it wasn't worth merging and was never really
worth keeping: it was a neat proof of concept but of little actual use,
especially now everyone either has an OK GPU or would want to stick to
8-bit rendering anyway (sorry L-Havoc).

However, both it and my merge work are preserved in git history :)
This commit is contained in:
Bill Currie 2022-03-09 20:19:14 +09:00
parent 19348f678f
commit 5477352e93
33 changed files with 471 additions and 3092 deletions

View file

@ -83,7 +83,7 @@ struct gl_ctx_s *X11_GL_Context (void);
void X11_GL_Init_Cvars (void);
struct sw_ctx_s *X11_SW_Context (void);
void X11_SW_Init_Cvars (void); // sw and sw32 cvars shared
void X11_SW_Init_Cvars (void);
struct vulkan_ctx_s *X11_Vulkan_Context (void);
void X11_Vulkan_Init_Cvars (void);

View file

@ -14,7 +14,6 @@ extern vid_render_data_t vid_render_data;
extern vid_render_funcs_t gl_vid_render_funcs;
extern vid_render_funcs_t glsl_vid_render_funcs;
extern vid_render_funcs_t sw_vid_render_funcs;
extern vid_render_funcs_t sw32_vid_render_funcs;
extern vid_render_funcs_t vulkan_vid_render_funcs;
extern vid_render_funcs_t *vid_render_funcs;
@ -30,7 +29,6 @@ void R_LineGraph (int x, int y, int *h_vals, int count, int height);
void gl_R_Init (void);
void glsl_R_Init (void);
void sw_R_Init (void);
void sw32_R_Init (void);
void R_RenderFrame (SCR_Func *scr_funcs);
void R_Init_Cvars (void);
void R_InitEfrags (void);
@ -45,7 +43,6 @@ extern struct psystem_s r_psystem;
struct psystem_s *gl_ParticleSystem (void);
struct psystem_s *glsl_ParticleSystem (void);
struct psystem_s *sw_ParticleSystem (void);
struct psystem_s *sw32_ParticleSystem (void);
void R_RunParticles (float dT);
void R_NewMap (model_t *worldmodel, model_t **models, int num_models);

View file

@ -236,7 +236,7 @@ extern float leftclip, topclip, rightclip, bottomclip;
extern int r_acliptype;
extern finalvert_t *pfinalverts;
extern auxvert_t *pauxverts;
extern float ziscale, sw32_ziscale;
extern float ziscale;
extern float aliastransform[3][4];
qboolean R_AliasCheckBBox (void);

View file

@ -27,8 +27,6 @@ extern struct cvar_s *vid_gamma;
void VID_GetWindowSize (int def_w, int def_h);
extern unsigned short d_8to16table[256];
void VID_InitGamma (const byte *);
qboolean VID_SetGamma (double);
void VID_UpdateGamma (struct cvar_s *);

View file

@ -1,22 +1,6 @@
#ifndef __vid_sw_h
#define __vid_sw_h
#include "QF/qtypes.h"
struct surf_s;
struct vrect_s;
struct particle_s;
struct spanpackage_s;
struct qpic_s;
struct espan_s;
struct sspan_s;
typedef struct sw_draw_s {
#define SW_DRAW_FUNC(name, rettype, params) \
rettype (*name) params;
#include "vid_sw_draw.h"
} sw_draw_t;
struct vrect_s;
typedef struct sw_ctx_s {
int pixbytes;
@ -24,23 +8,10 @@ typedef struct sw_ctx_s {
void (*create_context) (struct sw_ctx_s *ctx);
void (*set_palette) (struct sw_ctx_s *ctx, const byte *palette);
void (*update) (struct sw_ctx_s *ctx, struct vrect_s *rects);
sw_draw_t *draw;
} sw_ctx_t;
extern sw_ctx_t *sw_ctx;
#define SW_DRAW_FUNC(name, rettype, params) \
rettype name##_8 params;
#include "vid_sw_draw.h"
#define SW_DRAW_FUNC(name, rettype, params) \
rettype name##_16 params;
#include "vid_sw_draw.h"
#define SW_DRAW_FUNC(name, rettype, params) \
rettype name##_32 params;
#include "vid_sw_draw.h"
struct tex_s *sw_SCR_CaptureBGR (void);
#endif//__vid_sw_h

View file

@ -1,25 +0,0 @@
#ifndef SW_DRAW_FUNC
#define SW_DRAW_FUNC(name, rettype, params)
#endif
SW_DRAW_FUNC(draw_solid_usrface, void, (struct surf_s *surf, int color))
SW_DRAW_FUNC(draw_particle, void, (struct particle_s *particle))
SW_DRAW_FUNC(polyset_draw_spans, void, (struct spanpackage_s *spanpackage))
SW_DRAW_FUNC(draw_character, void, (int x, int y, byte *source, int drawline))
SW_DRAW_FUNC(draw_pixel, void, (int x, int y, byte color))
SW_DRAW_FUNC(draw_subpic, void, (int x, int y, struct qpic_s *pic, int srcx, int srcy, int width, int height))
SW_DRAW_FUNC(draw_console_background, void, (int lines, byte *data))
SW_DRAW_FUNC(draw_rect, void, (struct vrect_s *rect, int rowbytes, byte *src, int transparent))
SW_DRAW_FUNC(draw_fill, void, (int x, int y, int w, int h, int c))
SW_DRAW_FUNC(draw_fadescreen, void, (void))
SW_DRAW_FUNC(draw_blendscreen, void, (quat_t color))
SW_DRAW_FUNC(warp_screen, void, (void))
SW_DRAW_FUNC(draw_turbulent_span, void, (void))
SW_DRAW_FUNC(draw_spans, void, (struct espan_s *span))
SW_DRAW_FUNC(draw_sky_scans, void, (struct espan_s *span))
SW_DRAW_FUNC(sprite_draw_spans, void, (struct sspan_s *span))
SW_DRAW_FUNC(draw_z_point, void, (void))
SW_DRAW_FUNC(line_grapn, void, (int x, int y, int *h_vals, int count, int height))
SW_DRAW_FUNC(make_sky, void, (void))
SW_DRAW_FUNC(capture_bgr, struct tex_s *, (void))
#undef SW_DRAW_FUNC

View file

@ -99,8 +99,8 @@ LClampHigh5:
#define pspans 4+16
.align 4
.globl C(draw_spans_8)
C(draw_spans_8):
.globl C(D_DrawSpans8)
C(D_DrawSpans8):
pushl %ebp // preserve caller's stack frame
pushl %edi
pushl %esi // preserve register variables

View file

@ -35,8 +35,6 @@
#include "d_local.h"
#include "r_internal.h"
#include "vid_internal.h"
#include "vid_sw.h"
static int miplevel;
@ -74,14 +72,15 @@ D_MipLevelForScale (float scale)
// FIXME: clean this up
void
draw_solid_usrface_8 (surf_t *surf, int color)
static void
D_DrawSolidSurface (surf_t *surf, int color)
{
espan_t *span;
byte *pdest;
int u, u2, pix;
pix = (color << 24) | (color << 16) | (color << 8) | color;
for (espan_t *span = surf->spans; span; span = span->pnext) {
for (span = surf->spans; span; span = span->pnext) {
pdest = (byte *) d_viewbuffer + screenwidth * span->v;
u = span->u;
u2 = span->u + span->count - 1;
@ -104,39 +103,6 @@ draw_solid_usrface_8 (surf_t *surf, int color)
}
}
void
draw_solid_usrface_16 (surf_t *surf, int color)
{
short *pdest, pix;
int u, u2;
pix = d_8to16table[color];
for (espan_t *span = surf->spans; span; span = span->pnext) {
pdest = (short *) d_viewbuffer + screenwidth * span->v;
u = span->u;
u2 = span->u + span->count - 1;
for (;u <= u2; u++) {
pdest[u] = pix;
}
}
}
void
draw_solid_usrface_32 (surf_t *surf, int color)
{
int *pdest, pix;
int u, u2;
pix = d_8to24table[color];
for (espan_t *span = surf->spans; span; span = span->pnext) {
pdest = (int *) d_viewbuffer + screenwidth * span->v;
u = span->u;
u2 = span->u + span->count - 1;
for (;u <= u2; u++) {
pdest[u] = pix;
}
}
}
static void
D_CalcGradients (msurface_t *pface)
@ -201,8 +167,7 @@ D_DrawSurfaces (void)
d_zistepv = s->d_zistepv;
d_ziorigin = s->d_ziorigin;
int color = (size_t) s->data & 0xff;
sw_ctx->draw->draw_solid_usrface (s, color);
D_DrawSolidSurface (s, ((size_t) s->data & 0xFF));
D_DrawZSpans (s->spans);
}
} else {
@ -218,10 +183,10 @@ D_DrawSurfaces (void)
if (s->flags & SURF_DRAWSKY) {
if (!r_skymade) {
sw_ctx->draw->make_sky ();
R_MakeSky ();
}
sw_ctx->draw->draw_sky_scans (s->spans);
D_DrawSkyScans (s->spans);
D_DrawZSpans (s->spans);
} else if (s->flags & SURF_DRAWBACKGROUND) {
// set up a gradient for the background surface that places
@ -230,8 +195,7 @@ D_DrawSurfaces (void)
d_zistepv = 0;
d_ziorigin = -0.9;
int color = r_clearcolor->int_val & 0xff;
sw_ctx->draw->draw_solid_usrface (s, color);
D_DrawSolidSurface (s, r_clearcolor->int_val & 0xFF);
D_DrawZSpans (s->spans);
} else if (s->flags & SURF_DRAWTURB) {
pface = s->data;

View file

@ -35,7 +35,6 @@
#include "d_local.h"
#include "r_internal.h"
#include "vid_internal.h"
#include "vid_sw.h"
#define NUM_MIPS 4
@ -46,7 +45,6 @@ float d_scalemip[NUM_MIPS - 1];
static float basemip[NUM_MIPS - 1] = { 1.0, 0.5 * 0.8, 0.25 * 0.8 };
float d_zitable[65536];
void (*d_drawspans) (espan_t *pspan);
@ -62,16 +60,7 @@ D_Init (void)
vr_data.vid->vid_internal->flush_caches = D_FlushCaches;
vr_data.vid->vid_internal->init_caches = D_InitCaches;
// LordHavoc: compute 1/zi table for use in rendering code everywhere
if (!d_zitable[1]) {
int i;
d_zitable[0] = 0;
for (i = 1;i < 65536;i++)
d_zitable[i] = (65536.0 * 65536.0 / (double) i);
}
VID_InitBuffers ();
VID_MakeColormaps ();
}
void
@ -93,7 +82,7 @@ D_SetupFrame (void)
if (r_dowarp)
screenwidth = WARP_WIDTH;
else
screenwidth = vid.rowbytes / sw_ctx->pixbytes;
screenwidth = vid.rowbytes;
d_roverwrapped = false;
d_initial_rover = sc_rover;
@ -103,7 +92,7 @@ D_SetupFrame (void)
for (i = 0; i < (NUM_MIPS - 1); i++)
d_scalemip[i] = basemip[i] * d_mipscale->value;
d_drawspans = sw_ctx->draw->draw_spans;
d_drawspans = D_DrawSpans8;
}
void

View file

@ -31,9 +31,8 @@
#include "QF/render.h"
#include "QF/sys.h"
#include "d_local.h"
#include "r_internal.h"
#include "vid_sw.h"
#include "d_local.h"
int d_vrectx, d_vrecty, d_vrectright_particle, d_vrectbottom_particle;
@ -71,7 +70,7 @@ D_ViewChanged (void)
if (r_dowarp)
rowpixels = WARP_WIDTH;
else
rowpixels = vid.rowbytes / sw_ctx->pixbytes;
rowpixels = vid.rowbytes;
scale_for_mip = xscale;
if (yscale > xscale)

View file

@ -30,8 +30,6 @@
#include "d_local.h"
#include "r_internal.h"
#include "vid_internal.h"
#include "vid_sw.h"
#ifdef PIC
@ -40,7 +38,7 @@
#ifndef USE_INTEL_ASM
void
draw_particle_8 (particle_t *pparticle)
D_DrawParticle (particle_t *pparticle)
{
vec3_t local, transformed;
float zi;
@ -165,260 +163,3 @@ draw_particle_8 (particle_t *pparticle)
}
}
#endif // !USE_INTEL_ASM
void
draw_particle_16 (particle_t *pparticle)
{
vec3_t local, transformed;
float zi;
short *pz;
int i, izi, pix, count, u, v;
// transform point
VectorSubtract (pparticle->pos, r_origin, local);
transformed[0] = DotProduct (local, r_pright);
transformed[1] = DotProduct (local, r_pup);
transformed[2] = DotProduct (local, r_ppn);
if (transformed[2] < PARTICLE_Z_CLIP)
return;
// project the point
// FIXME: preadjust xcenter and ycenter
zi = 1.0 / transformed[2];
u = (int) (xcenter + zi * transformed[0] + 0.5);
v = (int) (ycenter - zi * transformed[1] + 0.5);
if ((v > d_vrectbottom_particle)
|| (u > d_vrectright_particle)
|| (v < d_vrecty) || (u < d_vrectx)) {
return;
}
pz = d_pzbuffer + (d_zwidth * v) + u;
izi = (int) (zi * 0x8000);
pix = izi >> d_pix_shift;
if (pix < d_pix_min)
pix = d_pix_min;
else if (pix > d_pix_max)
pix = d_pix_max;
unsigned short *pdest = (unsigned short *) d_viewbuffer +
d_scantable[v] + u,
pixcolor = d_8to16table[(int) pparticle->icolor];
switch (pix) {
case 1:
count = 1 << d_y_aspect_shift;
for (; count; count--, pz += d_zwidth, pdest += screenwidth) {
if (pz[0] <= izi) {
pz[0] = izi;
pdest[0] = pixcolor;
}
}
break;
case 2:
count = 2 << d_y_aspect_shift;
for (; count; count--, pz += d_zwidth, pdest += screenwidth) {
if (pz[0] <= izi) {
pz[0] = izi;
pdest[0] = pixcolor;
}
if (pz[1] <= izi) {
pz[1] = izi;
pdest[1] = pixcolor;
}
}
break;
case 3:
count = 3 << d_y_aspect_shift;
for (; count; count--, pz += d_zwidth, pdest += screenwidth) {
if (pz[0] <= izi) {
pz[0] = izi;
pdest[0] = pixcolor;
}
if (pz[1] <= izi) {
pz[1] = izi;
pdest[1] = pixcolor;
}
if (pz[2] <= izi) {
pz[2] = izi;
pdest[2] = pixcolor;
}
}
break;
case 4:
count = 4 << d_y_aspect_shift;
for (; count; count--, pz += d_zwidth, pdest += screenwidth) {
if (pz[0] <= izi) {
pz[0] = izi;
pdest[0] = pixcolor;
}
if (pz[1] <= izi) {
pz[1] = izi;
pdest[1] = pixcolor;
}
if (pz[2] <= izi) {
pz[2] = izi;
pdest[2] = pixcolor;
}
if (pz[3] <= izi) {
pz[3] = izi;
pdest[3] = pixcolor;
}
}
break;
default:
count = pix << d_y_aspect_shift;
for (; count; count--, pz += d_zwidth, pdest += screenwidth) {
for (i = 0; i < pix; i++) {
if (pz[i] <= izi) {
pz[i] = izi;
pdest[i] = pixcolor;
}
}
}
break;
}
}
void
draw_particle_32 (particle_t *pparticle)
{
vec3_t local, transformed;
float zi;
short *pz;
int i, izi, pix, count, u, v;
// transform point
VectorSubtract (pparticle->pos, r_origin, local);
transformed[0] = DotProduct (local, r_pright);
transformed[1] = DotProduct (local, r_pup);
transformed[2] = DotProduct (local, r_ppn);
if (transformed[2] < PARTICLE_Z_CLIP)
return;
// project the point
// FIXME: preadjust xcenter and ycenter
zi = 1.0 / transformed[2];
u = (int) (xcenter + zi * transformed[0] + 0.5);
v = (int) (ycenter - zi * transformed[1] + 0.5);
if ((v > d_vrectbottom_particle)
|| (u > d_vrectright_particle)
|| (v < d_vrecty) || (u < d_vrectx)) {
return;
}
pz = d_pzbuffer + (d_zwidth * v) + u;
izi = (int) (zi * 0x8000);
pix = izi >> d_pix_shift;
if (pix < d_pix_min)
pix = d_pix_min;
else if (pix > d_pix_max)
pix = d_pix_max;
int *pdest = (int *) d_viewbuffer + d_scantable[v] + u,
pixcolor = d_8to24table[(int) pparticle->icolor];
switch (pix) {
case 1:
count = 1 << d_y_aspect_shift;
for (; count; count--, pz += d_zwidth, pdest += screenwidth) {
if (pz[0] <= izi) {
pz[0] = izi;
pdest[0] = pixcolor;
}
}
break;
case 2:
count = 2 << d_y_aspect_shift;
for (; count; count--, pz += d_zwidth, pdest += screenwidth) {
if (pz[0] <= izi) {
pz[0] = izi;
pdest[0] = pixcolor;
}
if (pz[1] <= izi) {
pz[1] = izi;
pdest[1] = pixcolor;
}
}
break;
case 3:
count = 3 << d_y_aspect_shift;
for (; count; count--, pz += d_zwidth, pdest += screenwidth) {
if (pz[0] <= izi) {
pz[0] = izi;
pdest[0] = pixcolor;
}
if (pz[1] <= izi) {
pz[1] = izi;
pdest[1] = pixcolor;
}
if (pz[2] <= izi) {
pz[2] = izi;
pdest[2] = pixcolor;
}
}
break;
case 4:
count = 4 << d_y_aspect_shift;
for (; count; count--, pz += d_zwidth, pdest += screenwidth) {
if (pz[0] <= izi) {
pz[0] = izi;
pdest[0] = pixcolor;
}
if (pz[1] <= izi) {
pz[1] = izi;
pdest[1] = pixcolor;
}
if (pz[2] <= izi) {
pz[2] = izi;
pdest[2] = pixcolor;
}
if (pz[3] <= izi) {
pz[3] = izi;
pdest[3] = pixcolor;
}
}
break;
default:
count = pix << d_y_aspect_shift;
for (; count; count--, pz += d_zwidth, pdest += screenwidth) {
for (i = 0; i < pix; i++) {
if (pz[i] <= izi) {
pz[i] = izi;
pdest[i] = pixcolor;
}
}
}
break;
}
}

View file

@ -55,8 +55,8 @@
#define P 12+4
.align 4
.globl C(draw_particle_8)
C(draw_particle_8):
.globl C(D_DrawParticle)
C(D_DrawParticle):
pushl %ebp // preserve caller's stack frame
pushl %edi // preserve register variables
pushl %ebx

View file

@ -756,8 +756,8 @@ LDone:
.globl C(D_PolysetAff8Start)
C(D_PolysetAff8Start):
.globl C(polyset_draw_spans_8)
C(polyset_draw_spans_8):
.globl C(D_PolysetDrawSpans8)
C(D_PolysetDrawSpans8):
pushl %esi // preserve register variables
pushl %ebx

View file

@ -33,7 +33,6 @@
#include "d_local.h"
#include "r_internal.h"
#include "vid_sw.h"
int ubasestep, errorterm, erroradjustup, erroradjustdown;
@ -43,7 +42,7 @@ int ubasestep, errorterm, erroradjustup, erroradjustdown;
// !!! if this is changed, it must be changed in asm_draw.h too !!!
typedef struct spanpackage_s {
int pdest;
void *pdest;
short *pz;
int count;
byte *ptex;
@ -94,8 +93,7 @@ int d_aspancount, d_countextrastep;
spanpackage_t *a_spans;
spanpackage_t *d_pedgespanpackage;
static int ystart;
int d_pdest;
byte *d_ptex;
byte *d_pdest, *d_ptex;
short *d_pz;
int d_sfrac, d_tfrac, d_light, d_zi;
int d_ptexextrastep, d_sfracextrastep;
@ -596,7 +594,7 @@ InitGel (byte * palette)
#ifndef USE_INTEL_ASM
void
polyset_draw_spans_8 (spanpackage_t * pspanpackage)
D_PolysetDrawSpans8 (spanpackage_t * pspanpackage)
{
int lcount;
byte *lpdest;
@ -618,7 +616,7 @@ polyset_draw_spans_8 (spanpackage_t * pspanpackage)
}
if (lcount) {
lpdest = d_viewbuffer + pspanpackage->pdest;
lpdest = pspanpackage->pdest;
lptex = pspanpackage->ptex;
lpz = pspanpackage->pz;
lsfrac = pspanpackage->sfrac;
@ -653,178 +651,6 @@ polyset_draw_spans_8 (spanpackage_t * pspanpackage)
}
#endif // !USE_INTEL_ASM
void
polyset_draw_spans_16 (spanpackage_t * pspanpackage)
{
int i, j, texscantable[2*MAX_LBM_HEIGHT], *texscan;
// LordHavoc: compute skin row table
for (i = 0, j = -r_affinetridesc.skinheight * r_affinetridesc.skinwidth;
i < r_affinetridesc.skinheight*2;i++, j += r_affinetridesc.skinwidth)
texscantable[i] = j;
texscan = texscantable + r_affinetridesc.skinheight;
{
int lcount, count = 0;
short *lpdest;
byte *lptex;
int lsfrac, ltfrac;
int llight;
int lzi;
short *lpz;
do
{
lcount = d_aspancount - pspanpackage->count;
errorterm += erroradjustup;
if (errorterm >= 0)
{
d_aspancount += d_countextrastep;
errorterm -= erroradjustdown;
}
else
d_aspancount += ubasestep;
if (lcount)
{
lpdest = (short *) d_viewbuffer + pspanpackage->pdest;
lptex = pspanpackage->ptex;
lpz = pspanpackage->pz;
lsfrac = pspanpackage->sfrac;
ltfrac = pspanpackage->tfrac;
llight = pspanpackage->light;
lzi = pspanpackage->zi;
do
{
if ((lzi >> 16) < *lpz) // hidden
{
count = 0;
goto skiploop16;
}
drawloop16:
*lpz++ = lzi >> 16;
*lpdest++ = ((short *)acolormap)[(llight & 0xFF00) | lptex[texscan[ltfrac >> 16] + (lsfrac >> 16)]];
lzi += r_zistepx;
lsfrac += r_sstepx;
ltfrac += r_tstepx;
llight += r_lstepx;
}
while (--lcount);
goto done16;
do
{
if ((lzi >> 16) >= *lpz) // draw
{
lsfrac += r_sstepx * count;
ltfrac += r_tstepx * count;
llight += r_lstepx * count;
lpdest += count;
goto drawloop16;
}
skiploop16:
count++;
lzi += r_zistepx;
lpz++;
}
while (--lcount);
done16: ;
}
pspanpackage++;
}
while (pspanpackage->count != -999999);
}
}
void
polyset_draw_spans_32 (spanpackage_t * pspanpackage)
{
int i, j, texscantable[2*MAX_LBM_HEIGHT], *texscan;
// LordHavoc: compute skin row table
for (i = 0, j = -r_affinetridesc.skinheight * r_affinetridesc.skinwidth;
i < r_affinetridesc.skinheight*2;i++, j += r_affinetridesc.skinwidth)
texscantable[i] = j;
texscan = texscantable + r_affinetridesc.skinheight;
{
int lcount, count = 0;
int *lpdest;
byte *lptex;
int lsfrac, ltfrac;
int llight;
int lzi;
short *lpz;
do
{
lcount = d_aspancount - pspanpackage->count;
errorterm += erroradjustup;
if (errorterm >= 0)
{
d_aspancount += d_countextrastep;
errorterm -= erroradjustdown;
}
else
d_aspancount += ubasestep;
if (lcount)
{
lpdest = (int *) d_viewbuffer + pspanpackage->pdest;
lptex = pspanpackage->ptex;
lpz = pspanpackage->pz;
lsfrac = pspanpackage->sfrac;
ltfrac = pspanpackage->tfrac;
llight = pspanpackage->light;
lzi = pspanpackage->zi;
do
{
if ((lzi >> 16) < *lpz) // hidden
{
count = 0;
goto skiploop32;
}
drawloop32:
*lpz++ = lzi >> 16;
*lpdest++ =
vid.colormap32[(llight & 0xFF00) |
lptex[texscan[ltfrac >> 16] +
(lsfrac >> 16)]];
lzi += r_zistepx;
lsfrac += r_sstepx;
ltfrac += r_tstepx;
llight += r_lstepx;
}
while (--lcount);
goto done32;
do
{
if ((lzi >> 16) >= *lpz) // draw
{
lsfrac += r_sstepx * count;
ltfrac += r_tstepx * count;
llight += r_lstepx * count;
lpdest += count;
goto drawloop32;
}
skiploop32:
count++;
lzi += r_zistepx;
lpz++;
}
while (--lcount);
done32: ;
}
pspanpackage++;
}
while (pspanpackage->count != -999999);
}
}
void
D_RasterizeAliasPolySmooth (void)
@ -875,13 +701,7 @@ D_RasterizeAliasPolySmooth (void)
d_pdestbasestep = screenwidth + ubasestep;
d_pdestextrastep = d_pdestbasestep + 1;
#ifdef USE_INTEL_ASM
if (sw_ctx->pixbytes == 1) {
d_pdest = (int) d_viewbuffer + ystart * screenwidth + plefttop[0];
} else
#endif
d_pdest = ystart * screenwidth + plefttop[0];
d_pdest = (byte *) d_viewbuffer + ystart * screenwidth + plefttop[0];
d_pz = d_pzbuffer + ystart * d_zwidth + plefttop[0];
// TODO: can reuse partial expressions here
@ -947,13 +767,7 @@ D_RasterizeAliasPolySmooth (void)
d_pdestbasestep = screenwidth + ubasestep;
d_pdestextrastep = d_pdestbasestep + 1;
#ifdef USE_INTEL_ASM
if (sw_ctx->pixbytes == 1) {
d_pdest = (int) d_viewbuffer + ystart * screenwidth + plefttop[0];
} else
#endif
d_pdest = ystart * screenwidth + plefttop[0];
d_pdest = (byte *) d_viewbuffer + ystart * screenwidth + plefttop[0];
#ifdef USE_INTEL_ASM
d_pzbasestep = (d_zwidth + ubasestep) << 1;
d_pzextrastep = d_pzbasestep + 2;
@ -1010,7 +824,7 @@ D_RasterizeAliasPolySmooth (void)
originalcount = a_spans[initialrightheight].count;
a_spans[initialrightheight].count = -999999; // mark end of the
// spanpackages
sw_ctx->draw->polyset_draw_spans (a_spans);
D_PolysetDrawSpans8 (a_spans);
// scan out the bottom part of the right edge, if it exists
if (pedgetable->numrightedges == 2) {
@ -1033,7 +847,7 @@ D_RasterizeAliasPolySmooth (void)
d_countextrastep = ubasestep + 1;
a_spans[initialrightheight + height].count = -999999;
// mark end of the spanpackages
sw_ctx->draw->polyset_draw_spans (pstart);
D_PolysetDrawSpans8 (pstart);
}
}

View file

@ -33,8 +33,6 @@
#include "d_local.h"
#include "r_internal.h"
#include "vid_internal.h"
#include "vid_sw.h"
byte *r_turb_pbase;
byte *r_turb_pdest;
@ -49,7 +47,7 @@ int r_turb_spancount;
the sine warp, to keep the edges from wrapping
*/
void
warp_screen_8 (void)
D_WarpScreen (void)
{
int w, h;
int u, v;
@ -98,105 +96,6 @@ warp_screen_8 (void)
}
}
void
warp_screen_16 (void)
{
int w, h;
int u, v;
int scr_x = vr_data.scr_view->xpos;
int scr_y = vr_data.scr_view->ylen;
int scr_w = vr_data.scr_view->xpos;
int scr_h = vr_data.scr_view->ylen;
short *dest;
int *turb;
int *col;
short **row;
short *rowptr[MAXHEIGHT];
int column[MAXWIDTH];
float wratio, hratio;
w = r_refdef.vrect.width;
h = r_refdef.vrect.height;
wratio = w / (float) scr_w;
hratio = h / (float) scr_h;
for (v = 0; v < scr_h + AMP2 * 2; v++) {
rowptr[v] = (short *) d_viewbuffer +
(r_refdef.vrect.y * screenwidth) +
(screenwidth * (int) ((float) v * hratio * h /
(h + AMP2 * 2)));
}
for (u = 0; u < scr_w + AMP2 * 2; u++) {
column[u] = r_refdef.vrect.x +
(int) ((float) u * wratio * w / (w + AMP2 * 2));
}
turb = intsintable + ((int) (vr_data.realtime * SPEED) & (CYCLE - 1));
dest = (short *) vid.buffer + scr_y * (vid.rowbytes >> 1) + scr_x;
for (v = 0; v < scr_h; v++, dest += (vid.rowbytes >> 1)) {
col = &column[turb[v]];
row = &rowptr[v];
for (u = 0; u < scr_w; u += 4) {
dest[u + 0] = row[turb[u + 0]][col[u + 0]];
dest[u + 1] = row[turb[u + 1]][col[u + 1]];
dest[u + 2] = row[turb[u + 2]][col[u + 2]];
dest[u + 3] = row[turb[u + 3]][col[u + 3]];
}
}
}
void
warp_screen_32 (void)
{
int w, h;
int u, v;
int scr_x = vr_data.scr_view->xpos;
int scr_y = vr_data.scr_view->ylen;
int scr_w = vr_data.scr_view->xpos;
int scr_h = vr_data.scr_view->ylen;
int *dest;
int *turb;
int *col;
int **row;
int *rowptr[MAXHEIGHT];
int column[MAXWIDTH];
float wratio, hratio;
w = r_refdef.vrect.width;
h = r_refdef.vrect.height;
wratio = w / (float) scr_w;
hratio = h / (float) scr_h;
for (v = 0; v < scr_h + AMP2 * 2; v++) {
rowptr[v] = (int *) d_viewbuffer +
(r_refdef.vrect.y * screenwidth) +
(screenwidth * (int) ((float) v * hratio * h /
(h + AMP2 * 2)));
}
for (u = 0; u < scr_w + AMP2 * 2; u++) {
column[u] = r_refdef.vrect.x +
(int) ((float) u * wratio * w / (w + AMP2 * 2));
}
turb = intsintable + ((int) (vr_data.realtime * SPEED) & (CYCLE - 1));
dest = (int *) vid.buffer + scr_y * (vid.rowbytes >> 2) + scr_x;
for (v = 0; v < scr_h; v++, dest += (vid.rowbytes >> 2)) {
col = &column[turb[v]];
row = &rowptr[v];
for (u = 0; u < scr_w; u += 4) {
dest[u + 0] = row[turb[u + 0]][col[u + 0]];
dest[u + 1] = row[turb[u + 1]][col[u + 1]];
dest[u + 2] = row[turb[u + 2]][col[u + 2]];
dest[u + 3] = row[turb[u + 3]][col[u + 3]];
}
}
}
#ifdef PIC
#undef USE_INTEL_ASM //XXX asm pic hack
@ -204,7 +103,7 @@ warp_screen_32 (void)
#ifndef USE_INTEL_ASM
void
draw_turbulent_span_8 (void)
D_DrawTurbulent8Span (void)
{
int sturb, tturb;
@ -222,41 +121,6 @@ draw_turbulent_span_8 (void)
}
#endif // !USE_INTEL_ASM
void
draw_turbulent_span_16 (void)
{
int sturb, tturb;
short *pdest = (short *) r_turb_pdest;
do {
sturb = ((r_turb_s + r_turb_turb[(r_turb_t >> 16) &
(CYCLE - 1)]) >> 16) & 63;
tturb = ((r_turb_t + r_turb_turb[(r_turb_s >> 16) &
(CYCLE - 1)]) >> 16) & 63;
*pdest++ = d_8to16table[r_turb_pbase[(tturb << 6) + sturb]];
r_turb_s += r_turb_sstep;
r_turb_t += r_turb_tstep;
} while (--r_turb_spancount > 0);
r_turb_pdest = (byte *)pdest;
}
void
draw_turbulent_span_32 (void)
{
int sturb, tturb;
int *pdest = (int *) r_turb_pdest;
do {
sturb = ((r_turb_s + r_turb_turb[(r_turb_t >> 16) &
(CYCLE - 1)]) >> 16) & 63;
tturb = ((r_turb_t + r_turb_turb[(r_turb_s >> 16) &
(CYCLE - 1)]) >> 16) & 63;
*pdest++ = d_8to24table[r_turb_pbase[(tturb << 6) + sturb]];
r_turb_s += r_turb_sstep;
r_turb_t += r_turb_tstep;
} while (--r_turb_spancount > 0);
r_turb_pdest = (byte *)pdest;
}
void
Turbulent (espan_t *pspan)
{
@ -372,7 +236,7 @@ Turbulent (espan_t *pspan)
r_turb_s = r_turb_s & ((CYCLE << 16) - 1);
r_turb_t = r_turb_t & ((CYCLE << 16) - 1);
sw_ctx->draw->draw_turbulent_span ();
D_DrawTurbulent8Span ();
r_turb_s = snext;
r_turb_t = tnext;
@ -384,7 +248,7 @@ Turbulent (espan_t *pspan)
#ifndef USE_INTEL_ASM
void
draw_spans_8 (espan_t *pspan)
D_DrawSpans8 (espan_t *pspan)
{
int count, spancount;
unsigned char *pbase, *pdest;
@ -509,285 +373,6 @@ draw_spans_8 (espan_t *pspan)
}
#endif
void
draw_spans_16 (espan_t *pspan)
{
short *pbase = (short *) cacheblock, *pdest;
int count;
fixed16_t s, t, snext, tnext, sstep, tstep;
float sdivz, tdivz, zi, z, du, dv;
float sdivz8stepu, tdivz8stepu, zi8stepu;
sstep = 0; // keep compiler happy
tstep = 0; // ditto
sdivz8stepu = d_sdivzstepu * 8;
tdivz8stepu = d_tdivzstepu * 8;
zi8stepu = d_zistepu * 8 * 65536;
do {
pdest = (short *) d_viewbuffer + (screenwidth * pspan->v) +
pspan->u;
count = pspan->count;
// calculate the initial s/z, t/z, 1/z, s, and t and clamp
du = (float) pspan->u;
dv = (float) pspan->v;
sdivz = d_sdivzorigin + dv * d_sdivzstepv + du * d_sdivzstepu;
tdivz = d_tdivzorigin + dv * d_tdivzstepv + du * d_tdivzstepu;
zi = (d_ziorigin + dv * d_zistepv + du * d_zistepu) * 65536.0f;
z = d_zitable[(unsigned short) zi];
s = (int) (sdivz * z) + sadjust;
s = bound(0, s, bbextents);
t = (int) (tdivz * z) + tadjust;
t = bound(0, t, bbextentt);
while(count >= 8) {
count -= 8;
// calculate s/z, t/z, zi->fixed s and t at far end of span,
// calculate s and t steps across span by shifting
sdivz += sdivz8stepu;
tdivz += tdivz8stepu;
zi += zi8stepu;
z = d_zitable[(unsigned short) zi];
// prevent round-off error on <0 steps from from causing
// overstepping & running off the edge of the texture
snext = (int) (sdivz * z) + sadjust;
snext = bound(8, snext, bbextents);
tnext = (int) (tdivz * z) + tadjust;
tnext = bound(8, tnext, bbextentt);
sstep = (snext - s) >> 3;
tstep = (tnext - t) >> 3;
pdest[0] = pbase[(t >> 16) * cachewidth + (s >> 16)];
s += sstep;
t += tstep;
pdest[1] = pbase[(t >> 16) * cachewidth + (s >> 16)];
s += sstep;
t += tstep;
pdest[2] = pbase[(t >> 16) * cachewidth + (s >> 16)];
s += sstep;
t += tstep;
pdest[3] = pbase[(t >> 16) * cachewidth + (s >> 16)];
s += sstep;
t += tstep;
pdest[4] = pbase[(t >> 16) * cachewidth + (s >> 16)];
s += sstep;
t += tstep;
pdest[5] = pbase[(t >> 16) * cachewidth + (s >> 16)];
s += sstep;
t += tstep;
pdest[6] = pbase[(t >> 16) * cachewidth + (s >> 16)];
s += sstep;
t += tstep;
pdest[7] = pbase[(t >> 16) * cachewidth + (s >> 16)];
s = snext;t = tnext;
pdest += 8;
}
if (count)
{
// calculate s/z, t/z, zi->fixed s and t at last pixel in span
// (so can't step off polygon), clamp, calculate s and t steps
// across span by division, biasing steps low so we don't run
// off the texture
//countminus1 = (float) (count - 1);
sdivz += d_sdivzstepu * count; //minus1;
tdivz += d_tdivzstepu * count; //minus1;
zi += d_zistepu * 65536.0f * count; //minus1;
z = d_zitable[(unsigned short) zi];
// prevent round-off error on <0 steps from from causing
// overstepping & running off the edge of the texture
snext = (int) (sdivz * z) + sadjust;
snext = bound(count, snext, bbextents);
tnext = (int) (tdivz * z) + tadjust;
tnext = bound(count, tnext, bbextentt);
if (count > 1) {
sstep = (snext - s) / count; //(count - 1);
tstep = (tnext - t) / count; //(count - 1);
if (count & 4)
{
pdest[0] = pbase[(t >> 16) * cachewidth + (s >> 16)];
s += sstep;
t += tstep;
pdest[1] = pbase[(t >> 16) * cachewidth + (s >> 16)];
s += sstep;
t += tstep;
pdest[2] = pbase[(t >> 16) * cachewidth + (s >> 16)];
s += sstep;
t += tstep;
pdest[3] = pbase[(t >> 16) * cachewidth + (s >> 16)];
s += sstep;t += tstep;
pdest += 4;
}
if (count & 2)
{
pdest[0] = pbase[(t >> 16) * cachewidth + (s >> 16)];
s += sstep;
t += tstep;
pdest[1] = pbase[(t >> 16) * cachewidth + (s >> 16)];
s += sstep;
t += tstep;
pdest += 2;
}
if (count & 1)
pdest[0] = pbase[(t >> 16) * cachewidth + (s >> 16)];
}
else
{
pdest[0] = pbase[(t >> 16) * cachewidth + (s >> 16)];
}
}
} while ((pspan = pspan->pnext) != NULL);
}
void
draw_spans_32 (espan_t *pspan)
{
int *pbase = (int *) cacheblock, *pdest;
int count;
fixed16_t s, t, snext, tnext, sstep, tstep;
float sdivz, tdivz, zi, z, du, dv;
float sdivz8stepu, tdivz8stepu, zi8stepu;
sstep = 0; // keep compiler happy
tstep = 0; // ditto
sdivz8stepu = d_sdivzstepu * 8;
tdivz8stepu = d_tdivzstepu * 8;
zi8stepu = d_zistepu * 8 * 65536;
do {
pdest = (int *) d_viewbuffer + (screenwidth * pspan->v) + pspan->u;
count = pspan->count;
// calculate the initial s/z, t/z, 1/z, s, and t and clamp
du = (float) pspan->u;
dv = (float) pspan->v;
sdivz = d_sdivzorigin + dv * d_sdivzstepv + du * d_sdivzstepu;
tdivz = d_tdivzorigin + dv * d_tdivzstepv + du * d_tdivzstepu;
zi = (d_ziorigin + dv * d_zistepv + du * d_zistepu) * 65536.0f;
z = d_zitable[(unsigned short) zi];
s = (int) (sdivz * z) + sadjust;
s = bound(0, s, bbextents);
t = (int) (tdivz * z) + tadjust;
t = bound(0, t, bbextentt);
while(count >= 8) {
count -= 8;
// calculate s/z, t/z, zi->fixed s and t at far end of span,
// calculate s and t steps across span by shifting
sdivz += sdivz8stepu;
tdivz += tdivz8stepu;
zi += zi8stepu;
z = d_zitable[(unsigned short) zi];
// prevent round-off error on <0 steps from from causing
// overstepping & running off the edge of the texture
snext = (int) (sdivz * z) + sadjust;
snext = bound(8, snext, bbextents);
tnext = (int) (tdivz * z) + tadjust;
tnext = bound(8, tnext, bbextentt);
sstep = (snext - s) >> 3;
tstep = (tnext - t) >> 3;
pdest[0] = pbase[(t >> 16) * cachewidth + (s >> 16)];
s += sstep;
t += tstep;
pdest[1] = pbase[(t >> 16) * cachewidth + (s >> 16)];
s += sstep;
t += tstep;
pdest[2] = pbase[(t >> 16) * cachewidth + (s >> 16)];
s += sstep;
t += tstep;
pdest[3] = pbase[(t >> 16) * cachewidth + (s >> 16)];
s += sstep;
t += tstep;
pdest[4] = pbase[(t >> 16) * cachewidth + (s >> 16)];
s += sstep;
t += tstep;
pdest[5] = pbase[(t >> 16) * cachewidth + (s >> 16)];
s += sstep;
t += tstep;
pdest[6] = pbase[(t >> 16) * cachewidth + (s >> 16)];
s += sstep;
t += tstep;
pdest[7] = pbase[(t >> 16) * cachewidth + (s >> 16)];
s = snext;
t = tnext;
pdest += 8;
}
if (count)
{
// calculate s/z, t/z, zi->fixed s and t at last pixel in span
// (so can't step off polygon), clamp, calculate s and t steps
// across span by division, biasing steps low so we don't run
// off the texture
//countminus1 = (float) (count - 1);
sdivz += d_sdivzstepu * count; //minus1;
tdivz += d_tdivzstepu * count; //minus1;
zi += d_zistepu * 65536.0f * count; //minus1;
z = d_zitable[(unsigned short) zi];
// prevent round-off error on <0 steps from from causing
// overstepping & running off the edge of the texture
snext = (int) (sdivz * z) + sadjust;
snext = bound(count, snext, bbextents);
tnext = (int) (tdivz * z) + tadjust;
tnext = bound(count, tnext, bbextentt);
if (count > 1) {
sstep = (snext - s) / count; //(count - 1);
tstep = (tnext - t) / count; //(count - 1);
if (count & 4)
{
pdest[0] = pbase[(t >> 16) * cachewidth + (s >> 16)];
s += sstep;
t += tstep;
pdest[1] = pbase[(t >> 16) * cachewidth + (s >> 16)];
s += sstep;
t += tstep;
pdest[2] = pbase[(t >> 16) * cachewidth + (s >> 16)];
s += sstep;
t += tstep;
pdest[3] = pbase[(t >> 16) * cachewidth + (s >> 16)];
s += sstep;
t += tstep;
pdest += 4;
}
if (count & 2)
{
pdest[0] = pbase[(t >> 16) * cachewidth + (s >> 16)];
s += sstep;
t += tstep;
pdest[1] = pbase[(t >> 16) * cachewidth + (s >> 16)];
s += sstep;
t += tstep;
pdest += 2;
}
if (count & 1)
pdest[0] = pbase[(t >> 16) * cachewidth + (s >> 16)];
}
else
{
pdest[0] = pbase[(t >> 16) * cachewidth + (s >> 16)];
}
}
} while ((pspan = pspan->pnext) != NULL);
}
#ifndef USE_INTEL_ASM
void
D_DrawZSpans (espan_t *pspan)

View file

@ -49,8 +49,8 @@
//----------------------------------------------------------------------
.align 4
.globl C(draw_turbulent_span_8)
C(draw_turbulent_span_8):
.globl C(D_DrawTurbulent8Span)
C(D_DrawTurbulent8Span):
pushl %ebp // preserve caller's stack frame pointer
pushl %esi // preserve register variables
pushl %edi

View file

@ -32,7 +32,6 @@
#include "d_local.h"
#include "r_internal.h"
#include "vid_sw.h"
#define SKY_SPAN_SHIFT 5
#define SKY_SPAN_MAX (1 << SKY_SPAN_SHIFT)
@ -66,7 +65,7 @@ D_Sky_uv_To_st (int u, int v, fixed16_t *s, fixed16_t *t)
}
void
draw_sky_scans_8 (espan_t *pspan)
D_DrawSkyScans (espan_t *pspan)
{
int count, spancount, u, v;
unsigned char *pdest;
@ -134,141 +133,3 @@ draw_sky_scans_8 (espan_t *pspan)
} while ((pspan = pspan->pnext) != NULL);
}
void
draw_sky_scans_16 (espan_t *pspan)
{
int count, spancount, u, v;
short *pdest;
fixed16_t s, t, snext, tnext, sstep, tstep;
int spancountminus1;
sstep = 0; // keep compiler happy
tstep = 0; // ditto
snext = 0; // ditto
tnext = 0; // ditto
do {
pdest = (short *) d_viewbuffer + screenwidth * pspan->v + pspan->u;
count = pspan->count;
// calculate the initial s & t
u = pspan->u;
v = pspan->v;
D_Sky_uv_To_st (u, v, &s, &t);
do {
if (count >= SKY_SPAN_MAX)
spancount = SKY_SPAN_MAX;
else
spancount = count;
count -= spancount;
if (count) {
u += spancount;
// calculate s and t at far end of span,
// calculate s and t steps across span by shifting
D_Sky_uv_To_st (u, v, &snext, &tnext);
sstep = (snext - s) >> SKY_SPAN_SHIFT;
tstep = (tnext - t) >> SKY_SPAN_SHIFT;
} else {
// calculate s and t at last pixel in span,
// calculate s and t steps across span by division
spancountminus1 = (float) (spancount - 1);
if (spancountminus1 > 0) {
u += spancountminus1;
D_Sky_uv_To_st (u, v, &snext, &tnext);
sstep = (snext - s) / spancountminus1;
tstep = (tnext - t) / spancountminus1;
}
}
do {
*pdest++ = ((short *) r_skysource)
[((t & R_SKY_TMASK) >> 8) + ((s & R_SKY_SMASK) >> 16)];
s += sstep;
t += tstep;
} while (--spancount > 0);
s = snext;
t = tnext;
} while (count > 0);
} while ((pspan = pspan->pnext) != NULL);
}
void
draw_sky_scans_32 (espan_t *pspan)
{
int count, spancount, u, v;
int *pdest;
fixed16_t s, t, snext, tnext, sstep, tstep;
int spancountminus1;
sstep = 0; // keep compiler happy
tstep = 0; // ditto
snext = 0; // ditto
tnext = 0; // ditto
do {
pdest = (int *) d_viewbuffer + screenwidth * pspan->v + pspan->u;
count = pspan->count;
// calculate the initial s & t
u = pspan->u;
v = pspan->v;
D_Sky_uv_To_st (u, v, &s, &t);
do {
if (count >= SKY_SPAN_MAX)
spancount = SKY_SPAN_MAX;
else
spancount = count;
count -= spancount;
if (count) {
u += spancount;
// calculate s and t at far end of span,
// calculate s and t steps across span by shifting
D_Sky_uv_To_st (u, v, &snext, &tnext);
sstep = (snext - s) >> SKY_SPAN_SHIFT;
tstep = (tnext - t) >> SKY_SPAN_SHIFT;
} else {
// calculate s and t at last pixel in span,
// calculate s and t steps across span by division
spancountminus1 = (float) (spancount - 1);
if (spancountminus1 > 0) {
u += spancountminus1;
D_Sky_uv_To_st (u, v, &snext, &tnext);
sstep = (snext - s) / spancountminus1;
tstep = (tnext - t) / spancountminus1;
}
}
do {
*pdest++ = ((int *) r_skysource)
[((t & R_SKY_TMASK) >> 8) + ((s & R_SKY_SMASK) >> 16)];
s += sstep;
t += tstep;
} while (--spancount > 0);
s = snext;
t = tnext;
} while (count > 0);
} while ((pspan = pspan->pnext) != NULL);
}

View file

@ -95,8 +95,8 @@ LClampHigh5:
#define pspans 4+16
.align 4
.globl C(sprite_draw_spans_8)
C(sprite_draw_spans_8):
.globl C(D_SpriteDrawSpans)
C(D_SpriteDrawSpans):
pushl %ebp // preserve caller's stack frame
pushl %edi
pushl %esi // preserve register variables

View file

@ -32,8 +32,6 @@
#include "d_local.h"
#include "r_internal.h"
#include "vid_internal.h"
#include "vid_sw.h"
static int sprite_height;
static int minindex, maxindex;
@ -47,7 +45,7 @@ static sspan_t *sprite_spans;
#ifndef USE_INTEL_ASM
void
sprite_draw_spans_8 (sspan_t *pspan)
D_SpriteDrawSpans (sspan_t *pspan)
{
int count, spancount, izistep;
int izi;
@ -196,307 +194,6 @@ sprite_draw_spans_8 (sspan_t *pspan)
}
#endif
void
sprite_draw_spans_16 (sspan_t *pspan)
{
int count, spancount, izistep;
int izi;
byte *pbase;
short *pdest;
fixed16_t s, t, snext, tnext, sstep, tstep;
float sdivz, tdivz, zi, z, du, dv, spancountminus1;
float sdivz8stepu, tdivz8stepu, zi8stepu;
byte btemp;
short *pz;
sstep = 0; // keep compiler happy
tstep = 0; // ditto
pbase = (byte *) cacheblock;
sdivz8stepu = d_sdivzstepu * 8;
tdivz8stepu = d_tdivzstepu * 8;
zi8stepu = d_zistepu * 8 * 65536;
// we count on FP exceptions being turned off to avoid range problems
izistep = (int) (d_zistepu * 0x8000 * 0x10000);
do {
pdest = (short *) d_viewbuffer + screenwidth * pspan->v + pspan->u;
pz = d_pzbuffer + (d_zwidth * pspan->v) + pspan->u;
count = pspan->count;
if (count <= 0)
goto NextSpan2;
// calculate the initial s/z, t/z, 1/z, s, and t and clamp
du = (float) pspan->u;
dv = (float) pspan->v;
sdivz = d_sdivzorigin + dv * d_sdivzstepv + du * d_sdivzstepu;
tdivz = d_tdivzorigin + dv * d_tdivzstepv + du * d_tdivzstepu;
zi = (d_ziorigin + dv * d_zistepv + du * d_zistepu) * 65536.0f;
z = d_zitable[(int) zi];
// we count on FP exceptions being turned off to avoid range
// problems
izi = (int) (zi * 0x8000);
s = (int) (sdivz * z) + sadjust;
if (s > bbextents)
s = bbextents;
else if (s < 0)
s = 0;
t = (int) (tdivz * z) + tadjust;
if (t > bbextentt)
t = bbextentt;
else if (t < 0)
t = 0;
do {
// calculate s and t at the far end of the span
if (count >= 8)
spancount = 8;
else
spancount = count;
count -= spancount;
if (count) {
// calculate s/z, t/z, zi->fixed s and t at far end of
// span, calculate s and t steps across span by shifting
sdivz += sdivz8stepu;
tdivz += tdivz8stepu;
zi += zi8stepu;
z = d_zitable[(int) zi];
snext = (int) (sdivz * z) + sadjust;
if (snext > bbextents)
snext = bbextents;
else if (snext < 8)
snext = 8; // prevent round-off error on <0
// steps from causing overstepping
// & running off the texture's edge
tnext = (int) (tdivz * z) + tadjust;
if (tnext > bbextentt)
tnext = bbextentt;
else if (tnext < 8)
tnext = 8; // guard against round-off error on
// <0 steps
sstep = (snext - s) >> 3;
tstep = (tnext - t) >> 3;
} else {
// calculate s/z, t/z, zi->fixed s and t at last pixel in
// span (so can't step off polygon), clamp, calculate s
// and t steps across span by division, biasing steps
// low so we don't run off the texture
spancountminus1 = (float) (spancount - 1);
sdivz += d_sdivzstepu * spancountminus1;
tdivz += d_tdivzstepu * spancountminus1;
zi += d_zistepu * 65536.0f * spancountminus1;
z = d_zitable[(int) zi];
snext = (int) (sdivz * z) + sadjust;
if (snext > bbextents)
snext = bbextents;
else if (snext < 8)
snext = 8; // prevent round-off error on <0
// steps from from causing
// overstepping & running off the
// edge of the texture
tnext = (int) (tdivz * z) + tadjust;
if (tnext > bbextentt)
tnext = bbextentt;
else if (tnext < 8)
tnext = 8; // guard against round-off error on
// <0 steps
if (spancount > 1) {
sstep = (snext - s) / (spancount - 1);
tstep = (tnext - t) / (spancount - 1);
}
}
do {
btemp = pbase[(s >> 16) + (t >> 16) * cachewidth];
if (btemp != TRANSPARENT_COLOR) {
if (*pz <= (izi >> 16)) {
*pz = izi >> 16;
*pdest = d_8to16table[btemp];
}
}
izi += izistep;
pdest++;
pz++;
s += sstep;
t += tstep;
} while (--spancount > 0);
s = snext;
t = tnext;
} while (count > 0);
NextSpan2:
pspan++;
} while (pspan->count != DS_SPAN_LIST_END);
}
void
sprite_draw_spans_32 (sspan_t *pspan)
{
int count, spancount, izistep;
int izi;
byte *pbase;
int *pdest;
fixed16_t s, t, snext, tnext, sstep, tstep;
float sdivz, tdivz, zi, z, du, dv, spancountminus1;
float sdivz8stepu, tdivz8stepu, zi8stepu;
byte btemp;
short *pz;
sstep = 0; // keep compiler happy
tstep = 0; // ditto
pbase = (byte *) cacheblock;
sdivz8stepu = d_sdivzstepu * 8;
tdivz8stepu = d_tdivzstepu * 8;
zi8stepu = d_zistepu * 8 * 65536;
// we count on FP exceptions being turned off to avoid range problems
izistep = (int) (d_zistepu * 0x8000 * 0x10000);
do {
pdest = (int *) d_viewbuffer + screenwidth * pspan->v + pspan->u;
pz = d_pzbuffer + (d_zwidth * pspan->v) + pspan->u;
count = pspan->count;
if (count <= 0)
goto NextSpan4;
// calculate the initial s/z, t/z, 1/z, s, and t and clamp
du = (float) pspan->u;
dv = (float) pspan->v;
sdivz = d_sdivzorigin + dv * d_sdivzstepv + du * d_sdivzstepu;
tdivz = d_tdivzorigin + dv * d_tdivzstepv + du * d_tdivzstepu;
zi = (d_ziorigin + dv * d_zistepv + du * d_zistepu) * 65536.0f;
z = d_zitable[(int) zi];
// we count on FP exceptions being turned off to avoid range
// problems
izi = (int) (zi * 0x8000);
s = (int) (sdivz * z) + sadjust;
if (s > bbextents)
s = bbextents;
else if (s < 0)
s = 0;
t = (int) (tdivz * z) + tadjust;
if (t > bbextentt)
t = bbextentt;
else if (t < 0)
t = 0;
do {
// calculate s and t at the far end of the span
if (count >= 8)
spancount = 8;
else
spancount = count;
count -= spancount;
if (count) {
// calculate s/z, t/z, zi->fixed s and t at far end of
// span, calculate s and t steps across span by shifting
sdivz += sdivz8stepu;
tdivz += tdivz8stepu;
zi += zi8stepu;
z = d_zitable[(int) zi];
snext = (int) (sdivz * z) + sadjust;
if (snext > bbextents)
snext = bbextents;
else if (snext < 8)
snext = 8; // prevent round-off error on <0
// steps from causing overstepping
// & running off the texture's edge
tnext = (int) (tdivz * z) + tadjust;
if (tnext > bbextentt)
tnext = bbextentt;
else if (tnext < 8)
tnext = 8; // guard against round-off error on
// <0 steps
sstep = (snext - s) >> 3;
tstep = (tnext - t) >> 3;
} else {
// calculate s/z, t/z, zi->fixed s and t at last pixel in
// span (so can't step off polygon), clamp, calculate s
// and t steps across span by division, biasing steps low
// so we don't run off the texture
spancountminus1 = (float) (spancount - 1);
sdivz += d_sdivzstepu * spancountminus1;
tdivz += d_tdivzstepu * spancountminus1;
zi += d_zistepu * 65536.0f * spancountminus1;
z = d_zitable[(int) zi];
snext = (int) (sdivz * z) + sadjust;
if (snext > bbextents)
snext = bbextents;
else if (snext < 8)
snext = 8; // prevent round-off error on <0
// steps fromcausing overstepping
// & running off the texture's edge
tnext = (int) (tdivz * z) + tadjust;
if (tnext > bbextentt)
tnext = bbextentt;
else if (tnext < 8)
tnext = 8; // guard against round-off error on
// <0 steps
if (spancount > 1) {
sstep = (snext - s) / (spancount - 1);
tstep = (tnext - t) / (spancount - 1);
}
}
do {
btemp = pbase[(s >> 16) + (t >> 16) * cachewidth];
if (btemp != TRANSPARENT_COLOR) {
if (*pz <= (izi >> 16)) {
*pz = izi >> 16;
*pdest = d_8to24table[btemp];
}
}
izi += izistep;
pdest++;
pz++;
s += sstep;
t += tstep;
} while (--spancount > 0);
s = snext;
t = tnext;
} while (count > 0);
NextSpan4:
pspan++;
} while (pspan->count != DS_SPAN_LIST_END);
}
static void
D_SpriteScanLeftEdge (void)
{
@ -715,5 +412,5 @@ D_DrawSprite (void)
D_SpriteCalculateGradients ();
D_SpriteScanLeftEdge ();
D_SpriteScanRightEdge ();
sw_ctx->draw->sprite_draw_spans (sprite_spans);
D_SpriteDrawSpans (sprite_spans);
}

View file

@ -37,7 +37,6 @@
#include "compat.h"
#include "d_local.h"
#include "r_internal.h"
#include "vid_sw.h"
float surfscale;
@ -70,7 +69,7 @@ D_SurfaceCacheForRes (void *data, int width, int height)
if (pix > 64000)
size += (pix - 64000) * 3;
return size * sw_ctx->pixbytes;
return size;
}
static void
@ -142,7 +141,7 @@ D_SCAlloc (int width, int size)
if ((width < 0) || (width > 512)) // FIXME shouldn't really have a max
Sys_Error ("D_SCAlloc: bad cache width %d", width);
if ((size <= 0) || (size > 0x40000 * sw_ctx->pixbytes)) // FIXME ditto
if ((size <= 0) || (size > 0x40000)) // FIXME ditto
Sys_Error ("D_SCAlloc: bad cache size %d", size);
// This adds the offset of data[0] in the surfcache_t struct.
@ -196,8 +195,7 @@ D_SCAlloc (int width, int size)
new->width = width;
// DEBUG
if (width > 0)
new->height = (size - sizeof (*new) + sizeof (new->data)) /
(width * sw_ctx->pixbytes);
new->height = (size - sizeof (*new) + sizeof (new->data)) / width;
new->owner = NULL; // should be set properly after return
@ -254,14 +252,14 @@ D_CacheSurface (msurface_t *surface, int miplevel)
surfscale = 1.0 / (1 << miplevel);
r_drawsurf.surfmip = miplevel;
r_drawsurf.surfwidth = surface->extents[0] >> miplevel;
r_drawsurf.rowbytes = r_drawsurf.surfwidth * sw_ctx->pixbytes;
r_drawsurf.rowbytes = r_drawsurf.surfwidth;
r_drawsurf.surfheight = surface->extents[1] >> miplevel;
// allocate memory if needed
if (!cache) {
// if a texture just animated, don't reallocate it
cache = D_SCAlloc (r_drawsurf.surfwidth,
r_drawsurf.rowbytes * r_drawsurf.surfheight);
r_drawsurf.surfwidth * r_drawsurf.surfheight);
surface->cachespots[miplevel] = cache;
cache->owner = &surface->cachespots[miplevel];
cache->mipscale = surfscale;

View file

@ -30,12 +30,10 @@
#include "d_local.h"
#include "r_internal.h"
#include "vid_internal.h"
#include "vid_sw.h"
void
draw_z_point_8 (void)
D_DrawZPoint (void)
{
byte *pdest;
short *pz;
@ -50,35 +48,3 @@ draw_z_point_8 (void)
*pdest = r_zpointdesc.color;
}
}
void
draw_z_point_16 (void)
{
short *pz;
int izi;
pz = d_pzbuffer + (d_zwidth * r_zpointdesc.v) + r_zpointdesc.u;
izi = (int) (r_zpointdesc.zi * 0x8000);
if (*pz <= izi) {
*pz = izi;
((short *) d_viewbuffer) [d_scantable[r_zpointdesc.v]
+ r_zpointdesc.u] = d_8to16table[r_zpointdesc.color];
}
}
void
draw_z_point_32 (void)
{
short *pz;
int izi;
pz = d_pzbuffer + (d_zwidth * r_zpointdesc.v) + r_zpointdesc.u;
izi = (int) (r_zpointdesc.zi * 0x8000);
if (*pz <= izi) {
*pz = izi;
((int *) d_viewbuffer) [d_scantable[r_zpointdesc.v]
+ r_zpointdesc.u] = d_8to24table[r_zpointdesc.color];
}
}

File diff suppressed because it is too large Load diff

View file

@ -37,8 +37,9 @@
#include "vid_sw.h"
/* SCREEN SHOTS */
tex_t *
capture_bgr_8 (void)
sw_SCR_CaptureBGR (void)
{
int count, x, y;
tex_t *tex;
@ -65,21 +66,3 @@ capture_bgr_8 (void)
}
return tex;
}
tex_t *
capture_bgr_16 (void)
{
return capture_bgr_8 ();//FIXME
}
tex_t *
capture_bgr_32 (void)
{
return capture_bgr_8 ();//FIXME
}
tex_t *
sw_SCR_CaptureBGR (void)
{
return sw_ctx->draw->capture_bgr ();
}

View file

@ -55,8 +55,8 @@ C(R_Surf8Start):
//----------------------------------------------------------------------
.align 4
.globl C(R_DrawSurfaceBlock8_mip0)
C(R_DrawSurfaceBlock8_mip0):
.globl C(R_DrawSurfaceBlock_mip0)
C(R_DrawSurfaceBlock_mip0):
pushl %ebp // preserve caller's stack frame
pushl %edi
pushl %esi // preserve register variables
@ -70,7 +70,7 @@ C(R_DrawSurfaceBlock8_mip0):
movl %eax,sb_v
movl C(prowdestbase),%edi
movl C(psource),%esi
movl C(pbasesource),%esi
Lv_loop_mip0:
@ -256,8 +256,8 @@ LBPatch15:
movl %edx,C(lightright)
jc Lblockloop8_mip0
// if (psource >= r_sourcemax)
// psource -= stepback;
// if (pbasesource >= r_sourcemax)
// pbasesource -= stepback;
cmpl C(r_sourcemax),%esi
jb LSkip_mip0
@ -281,8 +281,8 @@ LSkip_mip0:
//----------------------------------------------------------------------
.align 4
.globl C(R_DrawSurfaceBlock8_mip1)
C(R_DrawSurfaceBlock8_mip1):
.globl C(R_DrawSurfaceBlock_mip1)
C(R_DrawSurfaceBlock_mip1):
pushl %ebp // preserve caller's stack frame
pushl %edi
pushl %esi // preserve register variables
@ -296,7 +296,7 @@ C(R_DrawSurfaceBlock8_mip1):
movl %eax,sb_v
movl C(prowdestbase),%edi
movl C(psource),%esi
movl C(pbasesource),%esi
Lv_loop_mip1:
@ -426,8 +426,8 @@ LBPatch29:
jc Lblockloop8_mip1
// if (psource >= r_sourcemax)
// psource -= stepback;
// if (pbasesource >= r_sourcemax)
// pbasesource -= stepback;
cmpl C(r_sourcemax),%esi
jb LSkip_mip1
@ -451,8 +451,8 @@ LSkip_mip1:
//----------------------------------------------------------------------
.align 4
.globl C(R_DrawSurfaceBlock8_mip2)
C(R_DrawSurfaceBlock8_mip2):
.globl C(R_DrawSurfaceBlock_mip2)
C(R_DrawSurfaceBlock_mip2):
pushl %ebp // preserve caller's stack frame
pushl %edi
pushl %esi // preserve register variables
@ -466,7 +466,7 @@ C(R_DrawSurfaceBlock8_mip2):
movl %eax,sb_v
movl C(prowdestbase),%edi
movl C(psource),%esi
movl C(pbasesource),%esi
Lv_loop_mip2:
@ -566,8 +566,8 @@ LBPatch21:
jc Lblockloop8_mip2
// if (psource >= r_sourcemax)
// psource -= stepback;
// if (pbasesource >= r_sourcemax)
// pbasesource -= stepback;
cmpl C(r_sourcemax),%esi
jb LSkip_mip2
@ -591,8 +591,8 @@ LSkip_mip2:
//----------------------------------------------------------------------
.align 4
.globl C(R_DrawSurfaceBlock8_mip3)
C(R_DrawSurfaceBlock8_mip3):
.globl C(R_DrawSurfaceBlock_mip3)
C(R_DrawSurfaceBlock_mip3):
pushl %ebp // preserve caller's stack frame
pushl %edi
pushl %esi // preserve register variables
@ -606,7 +606,7 @@ C(R_DrawSurfaceBlock8_mip3):
movl %eax,sb_v
movl C(prowdestbase),%edi
movl C(psource),%esi
movl C(pbasesource),%esi
Lv_loop_mip3:
@ -708,8 +708,8 @@ LBPatch31:
addl %edx,%esi
addl %ebp,%edi
// if (psource >= r_sourcemax)
// psource -= stepback;
// if (pbasesource >= r_sourcemax)
// pbasesource -= stepback;
cmpl C(r_sourcemax),%esi
jb LSkip_mip3

View file

@ -33,21 +33,23 @@
#include "QF/render.h"
#include "r_internal.h"
#include "vid_internal.h"
#include "vid_sw.h"
/*
R_LineGraph
Called by only R_DisplayTime
*/
void
line_grapn_8 (int x, int y, int *h_vals, int count, int height)
R_LineGraph (int x, int y, int *h_vals, int count, int height)
{
int h, i, s, color;
int offset = vid.rowbytes;
byte *dest;
// FIXME: disable on no-buffer adapters, or put in the driver
s = height;
while (count--) {
dest = ((byte*)vid.buffer) + offset * y + x++;
dest = ((byte*)vid.buffer) + vid.rowbytes * y + x++;
h = *h_vals++;
@ -63,80 +65,8 @@ line_grapn_8 (int x, int y, int *h_vals, int count, int height)
if (h > s)
h = s;
for (i = 0; i < h; i++, dest -= offset) {
for (i = 0; i < h; i++, dest -= vid.rowbytes) {
dest[0] = color;
}
}
}
void
line_grapn_16 (int x, int y, int *h_vals, int count, int height)
{
int h, i, s, color;
int offset = vid.rowbytes >> 1;
uint16_t *dest;
// FIXME: disable on no-buffer adapters, or put in the driver
s = height;
while (count--) {
dest = ((uint16_t*)vid.buffer) + offset * y + x++;
h = *h_vals++;
if (h == 10000)
color = d_8to16table[0x6f]; // yellow
else if (h == 9999)
color = d_8to16table[0x4f]; // red
else if (h == 9998)
color = d_8to16table[0xd0]; // blue
else
color = d_8to16table[0xff]; // pink
if (h > s)
h = s;
for (i = 0; i < h; i++, dest -= offset) {
dest[0] = color;
}
}
}
void
line_grapn_32 (int x, int y, int *h_vals, int count, int height)
{
int h, i, s, color;
int offset = vid.rowbytes >> 2;
uint32_t *dest;
// FIXME: disable on no-buffer adapters, or put in the driver
s = height;
while (count--) {
dest = ((uint32_t*)vid.buffer) + offset * y + x++;
h = *h_vals++;
if (h == 10000)
color = d_8to24table[0x6f]; // yellow
else if (h == 9999)
color = d_8to24table[0x4f]; // red
else if (h == 9998)
color = d_8to24table[0xd0]; // blue
else
color = d_8to24table[0xff]; // pink
if (h > s)
h = s;
for (i = 0; i < h; i++, dest -= offset) {
dest[0] = color;
}
}
}
void
R_LineGraph (int x, int y, int *h_vals, int count, int height)
{
sw_ctx->draw->line_grapn (x, y, h_vals, count, height);
}

View file

@ -39,7 +39,6 @@
#include "d_ifacea.h"
#include "r_internal.h"
#include "vid_sw.h"
#define LIGHT_MIN 5 // lowest light value we'll allow, to
// avoid the need for inner-loop light
@ -564,12 +563,6 @@ R_AliasSetupSkin (entity_t *ent)
r_affinetridesc.skinheight = pmdl->skinheight;
acolormap = vid.colormap8;
if (sw_ctx->pixbytes != 1) {
if (sw_ctx->pixbytes == 2)
acolormap = vid.colormap16;
else
acolormap = vid.colormap32;
}
if (ent->renderer.skin) {
tex_t *base;
@ -662,12 +655,6 @@ R_AliasDrawModel (alight_t *plighting)
if (!acolormap)
acolormap = vid.colormap8;
if (acolormap == vid.colormap8 && sw_ctx->pixbytes != 1) {
if (sw_ctx->pixbytes == 2)
acolormap = vid.colormap16;
else
acolormap = vid.colormap32;
}
if (r_affinetridesc.drawtype) {
D_PolysetUpdateTables (); // FIXME: precalc...

View file

@ -54,28 +54,11 @@
#include "mod_internal.h"
#include "r_internal.h"
#include "vid_internal.h"
#include "vid_sw.h"
#ifdef PIC
# undef USE_INTEL_ASM //XXX asm pic hack
#endif
static sw_draw_t sw_draw_8 = {
#define SW_DRAW_FUNC(name, rettype, params) \
.name = name##_8,
#include "vid_sw_draw.h"
};
static sw_draw_t sw_draw_16 = {
#define SW_DRAW_FUNC(name, rettype, params) \
.name = name##_16,
#include "vid_sw_draw.h"
};
static sw_draw_t sw_draw_32 = {
#define SW_DRAW_FUNC(name, rettype, params) \
.name = name##_32,
#include "vid_sw_draw.h"
};
void *colormap;
static vec3_t viewlightvec;
static alight_t r_viewlighting = { 128, 192, viewlightvec };
@ -134,15 +117,6 @@ sw_R_Init (void)
{
int dummy;
switch (sw_ctx->pixbytes) {
case 1: sw_ctx->draw = &sw_draw_8; break;
case 2: sw_ctx->draw = &sw_draw_16; break;
case 4: sw_ctx->draw = &sw_draw_32; break;
default:
Sys_Error("R_Init: unsupported pixbytes %i",
sw_ctx->pixbytes);
}
r_ent_queue = EntQueue_New (mod_num_types);
// get stack position so we can guess if we are going to overflow
@ -832,7 +806,7 @@ R_RenderView_ (void)
dp_time2 = Sys_DoubleTime ();
if (r_dowarp)
sw_ctx->draw->warp_screen ();
D_WarpScreen ();
if (r_timegraph->int_val)
R_TimeGraph ();

View file

@ -48,7 +48,6 @@
#include "compat.h"
#include "r_internal.h"
#include "vid_sw.h"
void
R_DrawParticles (void)
@ -59,10 +58,9 @@ R_DrawParticles (void)
R_RunParticles (vr_data.frametime);
void (*draw) (struct particle_s *particle) = sw_ctx->draw->draw_particle;
for (unsigned i = 0; i < r_psystem.numparticles; i++) {
particle_t *p = &r_psystem.particles[i];
draw (p);
D_DrawParticle (p);
}
}

View file

@ -28,13 +28,9 @@
# include "config.h"
#endif
#include <string.h>
#include "QF/render.h"
#include "r_internal.h"
#include "vid_internal.h"
#include "vid_sw.h"
static int iskyspeed = 8;
@ -51,12 +47,10 @@ int r_skymade;
byte bottomsky[128 * 131];
byte bottommask[128 * 131];
// sky and topsky both pack in here, 128
// bytes of sky on the left of each scan,
// 128 bytes of topsky on the right, because
// the low-level drawers need 256-byte widths
byte skydata[128 * 256];
byte skytex[128 * 256 * 4];
byte newsky[128 * 256]; // newsky and topsky both pack in here, 128
// bytes of newsky on the left of each scan,
// 128 bytes of topsky on the right, because
// the low-level drawers need 256-byte widths
/*
@ -67,116 +61,116 @@ byte skytex[128 * 256 * 4];
void
R_InitSky (texture_t *mt)
{
memcpy (skydata, (byte *) mt + mt->offsets[0], 128 * 256);
r_skysource = skytex;
int i, j;
byte *src;
src = (byte *) mt + mt->offsets[0];
for (i = 0; i < 128; i++) {
for (j = 0; j < 128; j++) {
newsky[(i * 256) + j + 128] = src[i * 256 + j + 128];
}
}
for (i = 0; i < 128; i++) {
for (j = 0; j < 131; j++) {
if (src[i * 256 + (j & 0x7F)]) {
bottomsky[(i * 131) + j] = src[i * 256 + (j & 0x7F)];
bottommask[(i * 131) + j] = 0;
} else {
bottomsky[(i * 131) + j] = 0;
bottommask[(i * 131) + j] = 0xff;
}
}
}
r_skysource = newsky;
}
void
make_sky_8 (void)
R_MakeSky (void)
{
int x, y, xshift1, yshift1, xshift2, yshift2;
byte *base1, *base2;
int x, y;
int ofs, baseofs;
int xshift, yshift;
byte *pnewsky;
static int xlast = -1, ylast = -1;
xshift2 = r_skytime * r_skyspeed * 2.0f;
yshift2 = r_skytime * r_skyspeed * 2.0f;
xshift = r_skytime * r_skyspeed;
yshift = r_skytime * r_skyspeed;
if ((xshift2 == xlast) && (yshift2 == ylast))
if ((xshift == xlast) && (yshift == ylast))
return;
xlast = xshift2;
ylast = yshift2;
xshift1 = xshift2 >> 1;
yshift1 = yshift2 >> 1;
xlast = xshift;
ylast = yshift;
byte *out = (byte *) skytex;
for (y = 0;y < 128;y++)
{
base1 = &skydata[((y + yshift1) & 127) * 256];
base2 = &skydata[((y + yshift2) & 127) * 256 + 128];
for (x = 0;x < 128;x++)
{
if (base1[(x + xshift1) & 127])
*out = base1[(x + xshift1) & 127];
else
*out = base2[(x + xshift2) & 127];
out++;
pnewsky = &newsky[0];
for (y = 0; y < SKYSIZE; y++) {
baseofs = ((y + yshift) & SKYMASK) * 131;
for (x = 0; x < SKYSIZE; x++) {
ofs = baseofs + ((x + xshift) & SKYMASK);
*pnewsky = (*(pnewsky + 128) & bottommask[ofs]) | bottomsky[ofs];
pnewsky = pnewsky + 1;
}
out += 128;
pnewsky += 128;
}
r_skymade = 1;
}
void
make_sky_16 (void)
{
int x, y, xshift1, yshift1, xshift2, yshift2;
byte *base1, *base2;
static int xlast = -1, ylast = -1;
xshift2 = r_skytime * r_skyspeed * 2.0f;
yshift2 = r_skytime * r_skyspeed * 2.0f;
if ((xshift2 == xlast) && (yshift2 == ylast))
return;
xlast = xshift2;
ylast = yshift2;
xshift1 = xshift2 >> 1;
yshift1 = yshift2 >> 1;
unsigned short *out = (unsigned short *) skytex;
for (y = 0;y < 128;y++)
{
base1 = &skydata[((y + yshift1) & 127) * 256];
base2 = &skydata[((y + yshift2) & 127) * 256 + 128];
for (x = 0;x < 128;x++)
{
if (base1[(x + xshift1) & 127])
*out = d_8to16table[base1[(x + xshift1) & 127]];
else
*out = d_8to16table[base2[(x + xshift2) & 127]];
out++;
}
out += 128;
}
r_skymade = 1;
}
void
make_sky_32 (void)
R_GenSkyTile (void *pdest)
{
int x, y, xshift1, yshift1, xshift2, yshift2;
byte *base1, *base2;
static int xlast = -1, ylast = -1;
int x, y;
int ofs, baseofs;
int xshift, yshift;
unsigned int *pnewsky;
unsigned int *pd;
xshift2 = r_skytime * r_skyspeed * 2.0f;
yshift2 = r_skytime * r_skyspeed * 2.0f;
xshift = r_skytime * r_skyspeed;
yshift = r_skytime * r_skyspeed;
if ((xshift2 == xlast) && (yshift2 == ylast))
return;
pnewsky = (unsigned int *) &newsky[0];
pd = (unsigned int *) pdest;
xlast = xshift2;
ylast = yshift2;
xshift1 = xshift2 >> 1;
yshift1 = yshift2 >> 1;
for (y = 0; y < SKYSIZE; y++) {
baseofs = ((y + yshift) & SKYMASK) * 131;
unsigned int *out = (unsigned int *) skytex;
for (y = 0;y < 128;y++) {
base1 = &skydata[((y + yshift1) & 127) * 256];
base2 = &skydata[((y + yshift2) & 127) * 256 + 128];
for (x = 0;x < 128;x++) {
if (base1[(x + xshift1) & 127])
*out = d_8to24table[base1[(x + xshift1) & 127]];
else
*out = d_8to24table[base2[(x + xshift2) & 127]];
out++;
// FIXME: clean this up
#if UNALIGNED_OK
for (x = 0; x < SKYSIZE; x += 4) {
ofs = baseofs + ((x + xshift) & SKYMASK);
// PORT: unaligned dword access to bottommask and bottomsky
*pd = (*(pnewsky + (128 / sizeof (unsigned int))) &
*(unsigned int *) &bottommask[ofs]) |
*(unsigned int *) &bottomsky[ofs];
pnewsky++;
pd++;
}
out += 128;
#else
for (x = 0; x < SKYSIZE; x++) {
ofs = baseofs + ((x + xshift) & SKYMASK);
*(byte *) pd = (*((byte *) pnewsky + 128) &
*(byte *) & bottommask[ofs]) |
*(byte *) & bottomsky[ofs];
pnewsky = (unsigned int *) ((byte *) pnewsky + 1);
pd = (unsigned int *) ((byte *) pd + 1);
}
#endif
pnewsky += 128 / sizeof (unsigned int);
}
r_skymade = 1;
}
void
R_SetSkyFrame (void)
{

View file

@ -1,5 +1,5 @@
/*
rsurf.c
sw_rsurf.c
surface-related refresh code
@ -33,63 +33,43 @@
#include "QF/scene/entity.h"
#include "compat.h"
#include "r_internal.h"
#include "vid_sw.h"
#ifdef PIC
# undef USE_INTEL_ASM //XXX asm pic hack
#endif
drawsurf_t r_drawsurf;
int sourcetstep;
static int lightleft, blocksize;
int sourcesstep, sourcetstep;
#ifndef USE_INTEL_ASM
static int lightleft;
#endif
static int blocksize;
int lightdelta, lightdeltastep;
int lightright, lightleftstep, lightrightstep, blockdivshift;
static unsigned int blockdivmask;
byte *prowdestbase;
byte *psource;
int surfrowbytes;
unsigned int *r_lightptr;
void *prowdestbase;
unsigned char *pbasesource;
int surfrowbytes; // used by ASM files
unsigned int *r_lightptr;
int r_stepback;
int r_lightwidth;
static int r_numhblocks;
int r_numvblocks;
static byte *r_source;
byte *r_sourcemax;
static unsigned char *r_source;
unsigned char *r_sourcemax;
void R_DrawSurfaceBlock8_mip0 (void);
void R_DrawSurfaceBlock8_mip1 (void);
void R_DrawSurfaceBlock8_mip2 (void);
void R_DrawSurfaceBlock8_mip3 (void);
static void R_DrawSurfaceBlock16_mip0 (void);
static void R_DrawSurfaceBlock16_mip1 (void);
static void R_DrawSurfaceBlock16_mip2 (void);
static void R_DrawSurfaceBlock16_mip3 (void);
static void R_DrawSurfaceBlock32_mip0 (void);
static void R_DrawSurfaceBlock32_mip1 (void);
static void R_DrawSurfaceBlock32_mip2 (void);
static void R_DrawSurfaceBlock32_mip3 (void);
void R_DrawSurfaceBlock_mip0 (void);
void R_DrawSurfaceBlock_mip1 (void);
void R_DrawSurfaceBlock_mip2 (void);
void R_DrawSurfaceBlock_mip3 (void);
static void (*surfmiptable8[4]) (void) = {
R_DrawSurfaceBlock8_mip0,
R_DrawSurfaceBlock8_mip1,
R_DrawSurfaceBlock8_mip2,
R_DrawSurfaceBlock8_mip3
};
static void (*surfmiptable[4]) (void) = {
R_DrawSurfaceBlock_mip0, R_DrawSurfaceBlock_mip1,
R_DrawSurfaceBlock_mip2, R_DrawSurfaceBlock_mip3};
static void (*surfmiptable16[4]) (void) = {
R_DrawSurfaceBlock16_mip0,
R_DrawSurfaceBlock16_mip1,
R_DrawSurfaceBlock16_mip2,
R_DrawSurfaceBlock16_mip3
};
static void (*surfmiptable32[4]) (void) = {
R_DrawSurfaceBlock32_mip0,
R_DrawSurfaceBlock32_mip1,
R_DrawSurfaceBlock32_mip2,
R_DrawSurfaceBlock32_mip3
};
static unsigned blocklights[34 * 34]; //FIXME make dynamic
static unsigned int blocklights[34 * 34]; //FIXME make dynamic
static void
@ -202,30 +182,14 @@ R_BuildLightMap (void)
if (surf->dlightframe == r_framecount)
R_AddDynamicLights ();
/*
* JohnnyonFlame:
* 32 and 16bpp modes uses the positive lighting, unlike 8bpp
*/
switch (sw_ctx->pixbytes) {
case 1:
// bound, invert, and shift
for (i = 0; i < size; i++) {
t = (255 * 256 - blocklights[i]) >> (8 - VID_CBITS);
// bound, invert, and shift
for (i = 0; i < size; i++) {
t = (255 * 256 - (int) blocklights[i]) >> (8 - VID_CBITS);
if (t < (1 << 6))
t = (1 << 6);
if (t < (1 << 6))
t = (1 << 6);
blocklights[i] = t;
}
break;
default:
// LordHavoc: changed to positive (not inverse) lighting
for (i = 0; i < size; i++) {
t = bound(256, blocklights[i] >> (8 - VID_CBITS),
256 * (VID_GRADES - 1));
blocklights[i] = t;
}
break;
blocklights[i] = t;
}
}
@ -266,47 +230,34 @@ R_DrawSurface (void)
//==============================
pblockdrawer = surfmiptable[r_drawsurf.surfmip];
// TODO: needs to be set only when there is a display settings change
horzblockstep = blocksize;
smax = mt->width >> r_drawsurf.surfmip;
twidth = texwidth;
tmax = mt->height >> r_drawsurf.surfmip;
sourcetstep = texwidth;
r_stepback = tmax * twidth;
r_sourcemax = r_source + (tmax * smax);
soffset = r_drawsurf.surf->texturemins[0];
basetoffset = r_drawsurf.surf->texturemins[1];
switch (sw_ctx->pixbytes) {
case 1:
pblockdrawer = surfmiptable8[r_drawsurf.surfmip];
break;
case 2:
pblockdrawer = surfmiptable16[r_drawsurf.surfmip];
break;
case 4:
pblockdrawer = surfmiptable32[r_drawsurf.surfmip];
break;
default:
Sys_Error("R_DrawSurface: unsupported r_pixbytes %i", sw_ctx->pixbytes);
pblockdrawer = NULL;
}
horzblockstep = blocksize * sw_ctx->pixbytes;
r_sourcemax = r_source + (tmax * smax);
// << 16 components are to guarantee positive values for %
basetptr = r_source + (((basetoffset >> r_drawsurf.surfmip) +
(tmax << 16)) % tmax) * twidth;
soffset = (((soffset >> r_drawsurf.surfmip) + (smax << 16)) % smax);
soffset = ((soffset >> r_drawsurf.surfmip) + (smax << 16)) % smax;
basetptr = &r_source[((((basetoffset >> r_drawsurf.surfmip)
+ (tmax << 16)) % tmax) * twidth)];
pcolumndest = (byte *) r_drawsurf.surfdat;
pcolumndest = r_drawsurf.surfdat;
for (u = 0; u < r_numhblocks; u++) {
r_lightptr = blocklights + u;
prowdestbase = pcolumndest;
psource = basetptr + soffset;
pbasesource = basetptr + soffset;
(*pblockdrawer) ();
@ -318,16 +269,15 @@ R_DrawSurface (void)
}
}
//=============================================================================
#ifndef USE_INTEL_ASM
void
R_DrawSurfaceBlock8_mip0 (void)
R_DrawSurfaceBlock_mip0 (void)
{
int v, i, b, lightstep, light;
unsigned char pix, *prowdest;
int v, i, b, lightstep, lighttemp, light;
unsigned char pix, *psource, *prowdest;
psource = pbasesource;
prowdest = prowdestbase;
for (v = 0; v < r_numvblocks; v++) {
@ -340,13 +290,15 @@ R_DrawSurfaceBlock8_mip0 (void)
lightrightstep = (r_lightptr[1] - lightright) >> 4;
for (i = 0; i < 16; i++) {
lightstep = (lightleft - lightright) >> 4;
lighttemp = lightleft - lightright;
lightstep = lighttemp >> 4;
light = lightright;
for (b = 15; b >= 0; b--) {
pix = psource[b];
prowdest[b] = vid.colormap8[(light & 0xFF00) + pix];
prowdest[b] = ((unsigned char *) vid.colormap8)
[(light & 0xFF00) + pix];
light += lightstep;
}
@ -362,11 +314,12 @@ R_DrawSurfaceBlock8_mip0 (void)
}
void
R_DrawSurfaceBlock8_mip1 (void)
R_DrawSurfaceBlock_mip1 (void)
{
int v, i, b, lightstep, light;
unsigned char pix, *prowdest;
int v, i, b, lightstep, lighttemp, light;
unsigned char pix, *psource, *prowdest;
psource = pbasesource;
prowdest = prowdestbase;
for (v = 0; v < r_numvblocks; v++) {
@ -379,13 +332,15 @@ R_DrawSurfaceBlock8_mip1 (void)
lightrightstep = (r_lightptr[1] - lightright) >> 3;
for (i = 0; i < 8; i++) {
lightstep = (lightleft - lightright) >> 3;
lighttemp = lightleft - lightright;
lightstep = lighttemp >> 3;
light = lightright;
for (b = 7; b >= 0; b--) {
pix = psource[b];
prowdest[b] = vid.colormap8[(light & 0xFF00) + pix];
prowdest[b] = ((unsigned char *) vid.colormap8)
[(light & 0xFF00) + pix];
light += lightstep;
}
@ -401,11 +356,12 @@ R_DrawSurfaceBlock8_mip1 (void)
}
void
R_DrawSurfaceBlock8_mip2 (void)
R_DrawSurfaceBlock_mip2 (void)
{
int v, i, b, lightstep, light;
unsigned char pix, *prowdest;
int v, i, b, lightstep, lighttemp, light;
unsigned char pix, *psource, *prowdest;
psource = pbasesource;
prowdest = prowdestbase;
for (v = 0; v < r_numvblocks; v++) {
@ -418,13 +374,15 @@ R_DrawSurfaceBlock8_mip2 (void)
lightrightstep = (r_lightptr[1] - lightright) >> 2;
for (i = 0; i < 4; i++) {
lightstep = (lightleft - lightright) >> 2;
lighttemp = lightleft - lightright;
lightstep = lighttemp >> 2;
light = lightright;
for (b = 3; b >= 0; b--) {
pix = psource[b];
prowdest[b] = vid.colormap8[(light & 0xFF00) + pix];
prowdest[b] = ((unsigned char *) vid.colormap8)
[(light & 0xFF00) + pix];
light += lightstep;
}
@ -440,11 +398,12 @@ R_DrawSurfaceBlock8_mip2 (void)
}
void
R_DrawSurfaceBlock8_mip3 (void)
R_DrawSurfaceBlock_mip3 (void)
{
int v, i, b, lightstep, light;
unsigned char pix, *prowdest;
int v, i, b, lightstep, lighttemp, light;
unsigned char pix, *psource, *prowdest;
psource = pbasesource;
prowdest = prowdestbase;
for (v = 0; v < r_numvblocks; v++) {
@ -457,13 +416,15 @@ R_DrawSurfaceBlock8_mip3 (void)
lightrightstep = (r_lightptr[1] - lightright) >> 1;
for (i = 0; i < 2; i++) {
lightstep = (lightleft - lightright) >> 1;
lighttemp = lightleft - lightright;
lightstep = lighttemp >> 1;
light = lightright;
for (b = 1; b >= 0; b--) {
pix = psource[b];
prowdest[b] = vid.colormap8[(light & 0xFF00) + pix];
prowdest[b] = ((unsigned char *) vid.colormap8)
[(light & 0xFF00) + pix];
light += lightstep;
}
@ -481,423 +442,33 @@ R_DrawSurfaceBlock8_mip3 (void)
#endif
static void
R_DrawSurfaceBlock16_mip0 (void)
R_GenTurbTile (byte *pbasetex, void *pdest)
{
int k, v;
int lightstep, light;
unsigned short *prowdest;
int *turb;
int i, j, s, t;
byte *pd;
prowdest = (unsigned short *) prowdestbase;
turb = sintable + ((int) (vr_data.realtime * SPEED) & (CYCLE - 1));
pd = (byte *) pdest;
for (v = 0; v < r_numvblocks; v++)
{
lightleft = r_lightptr[0];
lightright = r_lightptr[1];
r_lightptr += r_lightwidth;
lightleftstep = (r_lightptr[0] - lightleft) >> 4;
lightrightstep = (r_lightptr[1] - lightright) >> 4;
for (k = 0; k < 16; k++)
{
light = lightleft;
lightstep = (lightright - lightleft) >> 4;
prowdest[0] = vid.colormap16[(light & 0xFF00) + psource[0]];
light += lightstep;
prowdest[1] = vid.colormap16[(light & 0xFF00) + psource[1]];
light += lightstep;
prowdest[2] = vid.colormap16[(light & 0xFF00) + psource[2]];
light += lightstep;
prowdest[3] = vid.colormap16[(light & 0xFF00) + psource[3]];
light += lightstep;
prowdest[4] = vid.colormap16[(light & 0xFF00) + psource[4]];
light += lightstep;
prowdest[5] = vid.colormap16[(light & 0xFF00) + psource[5]];
light += lightstep;
prowdest[6] = vid.colormap16[(light & 0xFF00) + psource[6]];
light += lightstep;
prowdest[7] = vid.colormap16[(light & 0xFF00) + psource[7]];
light += lightstep;
prowdest[8] = vid.colormap16[(light & 0xFF00) + psource[8]];
light += lightstep;
prowdest[9] = vid.colormap16[(light & 0xFF00) + psource[9]];
light += lightstep;
prowdest[10] = vid.colormap16[(light & 0xFF00) + psource[10]];
light += lightstep;
prowdest[11] = vid.colormap16[(light & 0xFF00) + psource[11]];
light += lightstep;
prowdest[12] = vid.colormap16[(light & 0xFF00) + psource[12]];
light += lightstep;
prowdest[13] = vid.colormap16[(light & 0xFF00) + psource[13]];
light += lightstep;
prowdest[14] = vid.colormap16[(light & 0xFF00) + psource[14]];
light += lightstep;
prowdest[15] = vid.colormap16[(light & 0xFF00) + psource[15]];
psource += sourcetstep;
lightright += lightrightstep;
lightleft += lightleftstep;
prowdest += (surfrowbytes >> 1);
for (i = 0; i < TILE_SIZE; i++) {
for (j = 0; j < TILE_SIZE; j++) {
s = (((j << 16) + turb[i & (CYCLE - 1)]) >> 16) & 63;
t = (((i << 16) + turb[j & (CYCLE - 1)]) >> 16) & 63;
*pd++ = *(pbasetex + (t << 6) + s);
}
if (psource >= r_sourcemax)
psource -= r_stepback;
}
}
static void
R_DrawSurfaceBlock16_mip1 (void)
{
int k, v;
int lightstep, light;
unsigned short *prowdest;
prowdest = (unsigned short *) prowdestbase;
for (v = 0; v < r_numvblocks; v++)
{
lightleft = r_lightptr[0];
lightright = r_lightptr[1];
r_lightptr += r_lightwidth;
lightleftstep = (r_lightptr[0] - lightleft) >> 3;
lightrightstep = (r_lightptr[1] - lightright) >> 3;
for (k = 0; k < 8; k++)
{
light = lightleft;
lightstep = (lightright - lightleft) >> 3;
prowdest[0] = vid.colormap16[(light & 0xFF00) + psource[0]];
light += lightstep;
prowdest[1] = vid.colormap16[(light & 0xFF00) + psource[1]];
light += lightstep;
prowdest[2] = vid.colormap16[(light & 0xFF00) + psource[2]];
light += lightstep;
prowdest[3] = vid.colormap16[(light & 0xFF00) + psource[3]];
light += lightstep;
prowdest[4] = vid.colormap16[(light & 0xFF00) + psource[4]];
light += lightstep;
prowdest[5] = vid.colormap16[(light & 0xFF00) + psource[5]];
light += lightstep;
prowdest[6] = vid.colormap16[(light & 0xFF00) + psource[6]];
light += lightstep;
prowdest[7] = vid.colormap16[(light & 0xFF00) + psource[7]];
psource += sourcetstep;
lightright += lightrightstep;
lightleft += lightleftstep;
prowdest += (surfrowbytes >> 1);
}
if (psource >= r_sourcemax)
psource -= r_stepback;
}
}
static void
R_DrawSurfaceBlock16_mip2 (void)
{
int k, v;
int lightstep, light;
unsigned short *prowdest;
prowdest = (unsigned short *) prowdestbase;
for (v = 0; v < r_numvblocks; v++)
{
lightleft = r_lightptr[0];
lightright = r_lightptr[1];
r_lightptr += r_lightwidth;
lightleftstep = (r_lightptr[0] - lightleft) >> 2;
lightrightstep = (r_lightptr[1] - lightright) >> 2;
for (k = 0; k < 4; k++)
{
light = lightleft;
lightstep = (lightright - lightleft) >> 2;
prowdest[0] = vid.colormap16[(light & 0xFF00) + psource[0]];
light += lightstep;
prowdest[1] = vid.colormap16[(light & 0xFF00) + psource[1]];
light += lightstep;
prowdest[2] = vid.colormap16[(light & 0xFF00) + psource[2]];
light += lightstep;
prowdest[3] = vid.colormap16[(light & 0xFF00) + psource[3]];
psource += sourcetstep;
lightright += lightrightstep;
lightleft += lightleftstep;
prowdest += (surfrowbytes >> 1);
}
if (psource >= r_sourcemax)
psource -= r_stepback;
}
}
static void
R_DrawSurfaceBlock16_mip3 (void)
{
int v;
unsigned short *prowdest;
prowdest = (unsigned short *) prowdestbase;
for (v = 0; v < r_numvblocks; v++)
{
lightleft = r_lightptr[0];
lightright = r_lightptr[1];
r_lightptr += r_lightwidth;
lightleftstep = (r_lightptr[0] - lightleft) >> 1;
lightrightstep = (r_lightptr[1] - lightright) >> 1;
prowdest[0] = vid.colormap16[(lightleft & 0xFF00) + psource[0]];
prowdest[1] = vid.colormap16[(((lightleft + lightright) >> 1) &
0xFF00) + psource[1]];
psource += sourcetstep;
lightright += lightrightstep;
lightleft += lightleftstep;
prowdest += (surfrowbytes >> 1);
prowdest[0] = vid.colormap16[(lightleft & 0xFF00) + psource[0]];
prowdest[1] = vid.colormap16[(((lightleft + lightright) >> 1) &
0xFF00) + psource[1]];
psource += sourcetstep;
prowdest += (surfrowbytes >> 1);
if (psource >= r_sourcemax)
psource -= r_stepback;
}
}
static void
R_DrawSurfaceBlock32_mip0 (void)
{
int k, v;
int lightstep, light;
unsigned int *prowdest;
prowdest = (unsigned int *) prowdestbase;
for (v = 0; v < r_numvblocks; v++)
{
lightleft = r_lightptr[0];
lightright = r_lightptr[1];
r_lightptr += r_lightwidth;
lightleftstep = (r_lightptr[0] - lightleft) >> 4;
lightrightstep = (r_lightptr[1] - lightright) >> 4;
for (k = 0; k < 16; k++)
{
light = lightleft;
lightstep = (lightright - lightleft) >> 4;
prowdest[0] = vid.colormap32[(light & 0xFF00) + psource[0]];
light += lightstep;
prowdest[1] = vid.colormap32[(light & 0xFF00) + psource[1]];
light += lightstep;
prowdest[2] = vid.colormap32[(light & 0xFF00) + psource[2]];
light += lightstep;
prowdest[3] = vid.colormap32[(light & 0xFF00) + psource[3]];
light += lightstep;
prowdest[4] = vid.colormap32[(light & 0xFF00) + psource[4]];
light += lightstep;
prowdest[5] = vid.colormap32[(light & 0xFF00) + psource[5]];
light += lightstep;
prowdest[6] = vid.colormap32[(light & 0xFF00) + psource[6]];
light += lightstep;
prowdest[7] = vid.colormap32[(light & 0xFF00) + psource[7]];
light += lightstep;
prowdest[8] = vid.colormap32[(light & 0xFF00) + psource[8]];
light += lightstep;
prowdest[9] = vid.colormap32[(light & 0xFF00) + psource[9]];
light += lightstep;
prowdest[10] = vid.colormap32[(light & 0xFF00) + psource[10]];
light += lightstep;
prowdest[11] = vid.colormap32[(light & 0xFF00) + psource[11]];
light += lightstep;
prowdest[12] = vid.colormap32[(light & 0xFF00) + psource[12]];
light += lightstep;
prowdest[13] = vid.colormap32[(light & 0xFF00) + psource[13]];
light += lightstep;
prowdest[14] = vid.colormap32[(light & 0xFF00) + psource[14]];
light += lightstep;
prowdest[15] = vid.colormap32[(light & 0xFF00) + psource[15]];
psource += sourcetstep;
lightright += lightrightstep;
lightleft += lightleftstep;
prowdest += (surfrowbytes >> 2);
}
if (psource >= r_sourcemax)
psource -= r_stepback;
}
}
static void
R_DrawSurfaceBlock32_mip1 (void)
{
int k, v;
int lightstep, light;
unsigned int *prowdest;
prowdest = (unsigned int *) prowdestbase;
for (v = 0; v < r_numvblocks; v++)
{
lightleft = r_lightptr[0];
lightright = r_lightptr[1];
r_lightptr += r_lightwidth;
lightleftstep = (r_lightptr[0] - lightleft) >> 3;
lightrightstep = (r_lightptr[1] - lightright) >> 3;
for (k = 0; k < 8; k++)
{
light = lightleft;
lightstep = (lightright - lightleft) >> 3;
prowdest[0] = vid.colormap32[(light & 0xFF00) + psource[0]];
light += lightstep;
prowdest[1] = vid.colormap32[(light & 0xFF00) + psource[1]];
light += lightstep;
prowdest[2] = vid.colormap32[(light & 0xFF00) + psource[2]];
light += lightstep;
prowdest[3] = vid.colormap32[(light & 0xFF00) + psource[3]];
light += lightstep;
prowdest[4] = vid.colormap32[(light & 0xFF00) + psource[4]];
light += lightstep;
prowdest[5] = vid.colormap32[(light & 0xFF00) + psource[5]];
light += lightstep;
prowdest[6] = vid.colormap32[(light & 0xFF00) + psource[6]];
light += lightstep;
prowdest[7] = vid.colormap32[(light & 0xFF00) + psource[7]];
psource += sourcetstep;
lightright += lightrightstep;
lightleft += lightleftstep;
prowdest += (surfrowbytes >> 2);
}
if (psource >= r_sourcemax)
psource -= r_stepback;
}
}
static void
R_DrawSurfaceBlock32_mip2 (void)
{
int k, v;
int lightstep, light;
unsigned int *prowdest;
prowdest = (unsigned int *) prowdestbase;
for (v = 0; v < r_numvblocks; v++)
{
lightleft = r_lightptr[0];
lightright = r_lightptr[1];
r_lightptr += r_lightwidth;
lightleftstep = (r_lightptr[0] - lightleft) >> 2;
lightrightstep = (r_lightptr[1] - lightright) >> 2;
for (k = 0; k < 4; k++)
{
light = lightleft;
lightstep = (lightright - lightleft) >> 2;
prowdest[0] = vid.colormap32[(light & 0xFF00) + psource[0]];
light += lightstep;
prowdest[1] = vid.colormap32[(light & 0xFF00) + psource[1]];
light += lightstep;
prowdest[2] = vid.colormap32[(light & 0xFF00) + psource[2]];
light += lightstep;
prowdest[3] = vid.colormap32[(light & 0xFF00) + psource[3]];
psource += sourcetstep;
lightright += lightrightstep;
lightleft += lightleftstep;
prowdest += (surfrowbytes >> 2);
}
if (psource >= r_sourcemax)
psource -= r_stepback;
}
}
static void
R_DrawSurfaceBlock32_mip3 (void)
{
int v;
unsigned int *prowdest;
prowdest = (unsigned int *) prowdestbase;
for (v = 0; v < r_numvblocks; v++)
{
lightleft = r_lightptr[0];
lightright = r_lightptr[1];
r_lightptr += r_lightwidth;
lightleftstep = (r_lightptr[0] - lightleft) >> 1;
lightrightstep = (r_lightptr[1] - lightright) >> 1;
prowdest[0] = vid.colormap32[(lightleft & 0xFF00) + psource[0]];
prowdest[1] = vid.colormap32[(((lightleft + lightright) >> 1) &
0xFF00) + psource[1]];
psource += sourcetstep;
lightright += lightrightstep;
lightleft += lightleftstep;
prowdest += (surfrowbytes >> 2);
prowdest[0] = vid.colormap32[(lightleft & 0xFF00) + psource[0]];
prowdest[1] = vid.colormap32[(((lightleft + lightright) >> 1) &
0xFF00) + psource[1]];
psource += sourcetstep;
lightright += lightrightstep;
lightleft += lightleftstep;
prowdest += (surfrowbytes >> 2);
if (psource >= r_sourcemax)
psource -= r_stepback;
}
}
/*
void
R_DrawSurfaceBlock32 (void)
R_GenTile (msurface_t *psurf, void *pdest)
{
int k, v;
int lightstep, light;
unsigned int *prowdest;
prowdest = prowdestbase;
for (v = 0; v < r_numvblocks; v++) {
lightleft = r_lightptr[0];
lightright = r_lightptr[1];
r_lightptr += r_lightwidth;
lightleftstep = (r_lightptr[0] - lightleft) >> blockdivshift;
lightrightstep = (r_lightptr[1] - lightright) >> blockdivshift;
for (k = 0; k < blocksize; k++) {
int b;
lightstep = (lightright - lightleft) >> blockdivshift;
light = lightleft;
for (b = 0;b < blocksize;b++, light += lightstep)
prowdest[b] = vid.colormap32[(light & 0xFF00) + psource[b]];
psource += sourcetstep;
lightright += lightrightstep;
lightleft += lightleftstep;
prowdest += (surfrowbytes >> 2);
}
if (psource >= r_sourcemax)
psource -= r_stepback;
if (psurf->flags & SURF_DRAWTURB) {
R_GenTurbTile (((byte *) psurf->texinfo->texture +
psurf->texinfo->texture->offsets[0]), pdest);
} else if (psurf->flags & SURF_DRAWSKY) {
R_GenSkyTile (pdest);
} else {
Sys_Error ("Unknown tile type");
}
}
*/

View file

@ -1,9 +1,9 @@
/*
vid_common_sw.c
general video driver functions
Common software video driver functions
Copyright (C) 1996-1997 Id Software, Inc.
Copyright (C) 2001 Jeff Teunissen <deek@quakeforge.net>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@ -28,130 +28,11 @@
# include "config.h"
#endif
#include "QF/cvar.h"
#include <stdlib.h>
#include <math.h>
#include "QF/mathlib.h"
#include "QF/qargs.h"
#include "QF/sys.h"
#include "QF/va.h"
#include "QF/vid.h"
#include "compat.h"
#include "r_internal.h"
#include "vid_internal.h"
unsigned short d_8to16table[256];
/*
VID_MakeColormap32
LordHavoc: makes a 32bit color*light table, RGBA order, no endian,
may need to be re-ordered to hardware at display time
*/
static void
VID_MakeColormap32 (void *outcolormap, byte *pal)
{
int c, l;
byte *out;
out = (byte *)&d_8to24table;
/*
* Generates colors not affected by lighting, such as
* HUD pieces and general sprites (such as explosions)
*/
for (c = 0; c < 256; c++) {
*out++ = pal[c*3+2];
*out++ = pal[c*3+1];
*out++ = pal[c*3+0];
*out++ = 255;
}
d_8to24table[255] = 0; // 255 is transparent
out = (byte *) outcolormap;
/*
* Generates colors affected by lighting, such as the
* world and other models that give it life, like foes and pickups.
*/
for (l = 0;l < VID_GRADES;l++)
{
for (c = 0;c < vid.fullbright;c++)
{
out[(l*256+c)*4+0] = bound(0, (pal[c*3+2] * l) >> (VID_CBITS - 1),
255);
out[(l*256+c)*4+1] = bound(0, (pal[c*3+1] * l) >> (VID_CBITS - 1),
255);
out[(l*256+c)*4+2] = bound(0, (pal[c*3+0] * l) >> (VID_CBITS - 1),
255);
out[(l*256+c)*4+3] = 255;
}
for (;c < 255;c++)
{
out[(l*256+c)*4+0] = pal[c*3+2];
out[(l*256+c)*4+1] = pal[c*3+1];
out[(l*256+c)*4+2] = pal[c*3+0];
out[(l*256+c)*4+3] = 255;
}
out[(l*256+255)*4+0] = 0;
out[(l*256+255)*4+1] = 0;
out[(l*256+255)*4+2] = 0;
out[(l*256+255)*4+3] = 0;
}
}
static unsigned short
lh24to16bit (int red, int green, int blue)
{
red = bound(0, red, 255);
green = bound(0, green, 255);
blue = bound(0, blue, 255);
red >>= 3;
green >>= 2;
blue >>= 3;
red <<= 11;
green <<= 5;
return (unsigned short) (red | green | blue);
}
/*
VID_MakeColormap16
LordHavoc: makes a 16bit color*light table, RGB order, native endian,
may need to be translated to hardware order at display time
*/
static void
VID_MakeColormap16 (void *outcolormap, byte *pal)
{
int c, l;
unsigned short *out;
out = (unsigned short *)&d_8to16table;
for (c = 0; c < 256; c++)
*out++ = lh24to16bit(pal[c*3+0], pal[c*3+1], pal[c*3+2]);
d_8to16table[255] = 0; // 255 is transparent
out = (unsigned short *) outcolormap;
for (l = 0;l < VID_GRADES;l++)
{
for (c = 0;c < vid.fullbright;c++)
out[l*256+c] = lh24to16bit(
(pal[c*3+0] * l) >> (VID_CBITS - 1),
(pal[c*3+1] * l) >> (VID_CBITS - 1),
(pal[c*3+2] * l) >> (VID_CBITS - 1));
for (;c < 255;c++)
out[l*256+c] = lh24to16bit(pal[c*3+0], pal[c*3+1], pal[c*3+2]);
out[l*256+255] = 0;
}
}
/*
VID_MakeColormaps
LordHavoc: makes 8bit, 16bit, and 32bit colormaps and palettes
*/
void
VID_MakeColormaps (void)
{
vid.colormap16 = malloc (256*VID_GRADES * sizeof (unsigned short));
vid.colormap32 = malloc (256*VID_GRADES * sizeof (unsigned int));
SYS_CHECKMEM (vid.colormap16 && vid.colormap32);
VID_MakeColormap16(vid.colormap16, vid.palette);
VID_MakeColormap32(vid.colormap32, vid.palette);
}

View file

@ -50,8 +50,6 @@ static win_palette_t st2d_8to32table[256];
static byte current_palette[768];
static int palette_changed;
static cvar_t *vid_bitdepth;
static LPDIRECTDRAW dd_Object;
static HINSTANCE hInstDDraw;
static LPDIRECTDRAWSURFACE dd_frontbuffer;
@ -476,27 +474,10 @@ Win_SW_Context (void)
ctx->choose_visual = win_choose_visual;
ctx->create_context = win_create_context;
ctx->update = win_sw_update;
#if 0 //FIXME need to figure out 16 and 32 bit buffers
switch (vid_bitdepth->int_val) {
case 8:
ctx->pixbytes = 1;
break;
case 16:
ctx->pixbytes = 2;
break;
case 32:
ctx->pixbytes = 4;
break;
default:
Sys_Error ("X11_SW32_Context: unsupported bit depth");
}
#endif
return ctx;
}
void
Win_SW_Init_Cvars (void)
{
vid_bitdepth = Cvar_Get ("vid_bitdepth", "8", CVAR_ROM, NULL, "Sets "
"display bitdepth (supported modes: 8 16 32)");
}

View file

@ -69,8 +69,6 @@ int XShmGetEventBase (Display *x); // for broken X11 headers
static GC x_gc;
static cvar_t *vid_bitdepth;
static qboolean doShm;
static XShmSegmentInfo x_shminfo[2];
@ -648,27 +646,11 @@ X11_SW_Context (void)
ctx->set_palette = x11_set_palette;
ctx->choose_visual = x11_choose_visual;
ctx->create_context = x11_create_context;
switch (vid_bitdepth->int_val) {
case 8:
ctx->pixbytes = 1;
break;
case 16:
ctx->pixbytes = 2;
break;
case 32:
ctx->pixbytes = 4;
break;
default:
Sys_Error ("X11_SW32_Context: unsupported bit depth");
}
ctx->update = x11_sw8_update;
return ctx;
}
void
X11_SW_Init_Cvars (void)
{
// FIXME: vid_colorbpp in common GL setup, make consistent with sdl32 scheme
vid_bitdepth = Cvar_Get ("vid_bitdepth", "8", CVAR_ROM, NULL, "Sets "
"display bitdepth (supported modes: 8 16 32)");
}