Removed the need for the pixel_canvas_t typedef

This commit is contained in:
Magnus Norddahl 2016-05-31 05:31:32 +02:00
parent 20b7743ec3
commit 045bad1b52
18 changed files with 561 additions and 329 deletions

View File

@ -66,12 +66,6 @@ union QWORD_UNION
typedef SDWORD fixed_t; typedef SDWORD fixed_t;
typedef DWORD dsfixed_t; // fixedpt used by span drawer typedef DWORD dsfixed_t; // fixedpt used by span drawer
#ifndef PALETTEOUTPUT
typedef uint32_t canvas_pixel_t;
#else
typedef BYTE canvas_pixel_t;
#endif
#define FIXED_MAX (signed)(0x7fffffff) #define FIXED_MAX (signed)(0x7fffffff)
#define FIXED_MIN (signed)(0x80000000) #define FIXED_MIN (signed)(0x80000000)

View File

@ -80,7 +80,7 @@ bool wipe_initMelt (int ticks)
int i, r; int i, r;
// copy start screen to main screen // copy start screen to main screen
screen->DrawBlock(0, 0, SCREENWIDTH, SCREENHEIGHT, (canvas_pixel_t *)wipe_scr_start); screen->DrawBlock(0, 0, SCREENWIDTH, SCREENHEIGHT, (BYTE *)wipe_scr_start);
// makes this wipe faster (in theory) // makes this wipe faster (in theory)
// to have stuff in column-major format // to have stuff in column-major format
@ -273,7 +273,7 @@ bool wipe_doBurn (int ticks)
// Draw the screen // Draw the screen
int xstep, ystep, firex, firey; int xstep, ystep, firex, firey;
int x, y; int x, y;
canvas_pixel_t *to; BYTE *to;
BYTE *fromold, *fromnew; BYTE *fromold, *fromnew;
const int SHIFT = 16; const int SHIFT = 16;
@ -338,7 +338,7 @@ bool wipe_doFade (int ticks)
fade += ticks * 2; fade += ticks * 2;
if (fade > 64) if (fade > 64)
{ {
screen->DrawBlock (0, 0, SCREENWIDTH, SCREENHEIGHT, (canvas_pixel_t *)wipe_scr_end); screen->DrawBlock (0, 0, SCREENWIDTH, SCREENHEIGHT, (BYTE *)wipe_scr_end);
return true; return true;
} }
else else
@ -349,7 +349,7 @@ bool wipe_doFade (int ticks)
DWORD *bg2rgb = Col2RGB8[bglevel]; DWORD *bg2rgb = Col2RGB8[bglevel];
BYTE *fromnew = (BYTE *)wipe_scr_end; BYTE *fromnew = (BYTE *)wipe_scr_end;
BYTE *fromold = (BYTE *)wipe_scr_start; BYTE *fromold = (BYTE *)wipe_scr_start;
canvas_pixel_t *to = screen->GetBuffer(); BYTE *to = screen->GetBuffer();
for (y = 0; y < SCREENHEIGHT; y++) for (y = 0; y < SCREENHEIGHT; y++)
{ {
@ -393,7 +393,7 @@ bool wipe_StartScreen (int type)
if (CurrentWipeType) if (CurrentWipeType)
{ {
wipe_scr_start = new short[SCREENWIDTH * SCREENHEIGHT / 2]; wipe_scr_start = new short[SCREENWIDTH * SCREENHEIGHT / 2];
screen->GetBlock (0, 0, SCREENWIDTH, SCREENHEIGHT, (canvas_pixel_t *)wipe_scr_start); screen->GetBlock (0, 0, SCREENWIDTH, SCREENHEIGHT, (BYTE *)wipe_scr_start);
return true; return true;
} }
return false; return false;
@ -407,8 +407,8 @@ void wipe_EndScreen (void)
if (CurrentWipeType) if (CurrentWipeType)
{ {
wipe_scr_end = new short[SCREENWIDTH * SCREENHEIGHT / 2]; wipe_scr_end = new short[SCREENWIDTH * SCREENHEIGHT / 2];
screen->GetBlock (0, 0, SCREENWIDTH, SCREENHEIGHT, (canvas_pixel_t *)wipe_scr_end); screen->GetBlock (0, 0, SCREENWIDTH, SCREENHEIGHT, (BYTE *)wipe_scr_end);
screen->DrawBlock (0, 0, SCREENWIDTH, SCREENHEIGHT, (canvas_pixel_t *)wipe_scr_start); // restore start scr. screen->DrawBlock (0, 0, SCREENWIDTH, SCREENHEIGHT, (BYTE *)wipe_scr_start); // restore start scr.
// Initialize the wipe // Initialize the wipe
(*wipes[(CurrentWipeType-1)*3])(0); (*wipes[(CurrentWipeType-1)*3])(0);

View File

@ -655,7 +655,6 @@ static bool FindFreeName (FString &fullname, const char *extension)
void M_ScreenShot (const char *filename) void M_ScreenShot (const char *filename)
{ {
#ifdef PALETTEOUTPUT
FILE *file; FILE *file;
FString autoname; FString autoname;
bool writepcx = (stricmp (screenshot_type, "pcx") == 0); // PNG is the default bool writepcx = (stricmp (screenshot_type, "pcx") == 0); // PNG is the default
@ -744,7 +743,6 @@ void M_ScreenShot (const char *filename)
Printf ("Could not create screenshot.\n"); Printf ("Could not create screenshot.\n");
} }
} }
#endif
} }
CCMD (screenshot) CCMD (screenshot)

View File

@ -65,7 +65,7 @@ extern int ST_Y;
BYTE* viewimage; BYTE* viewimage;
extern "C" { extern "C" {
int ylookup[MAXHEIGHT]; int ylookup[MAXHEIGHT];
canvas_pixel_t *dc_destorg; BYTE* dc_destorg;
} }
int scaledviewwidth; int scaledviewwidth;
@ -99,6 +99,7 @@ void (*R_DrawSpanMaskedAddClamp)(void);
void (*R_FillSpan)(void); void (*R_FillSpan)(void);
void (*R_FillColumnHoriz)(void); void (*R_FillColumnHoriz)(void);
void (*R_DrawFogBoundary)(int x1, int x2, short *uclip, short *dclip); void (*R_DrawFogBoundary)(int x1, int x2, short *uclip, short *dclip);
void (*R_MapTiltedPlane)(int y, int x1);
void (*R_MapColoredPlane)(int y, int x1); void (*R_MapColoredPlane)(int y, int x1);
void (*R_DrawParticle)(vissprite_t *); void (*R_DrawParticle)(vissprite_t *);
fixed_t (*tmvline1_add)(); fixed_t (*tmvline1_add)();
@ -133,7 +134,7 @@ void (*rt_tlateadd4cols)(int sx, int yl, int yh);
void (*rt_tlateaddclamp4cols)(int sx, int yl, int yh); void (*rt_tlateaddclamp4cols)(int sx, int yl, int yh);
void (*rt_tlatesubclamp4cols)(int sx, int yl, int yh); void (*rt_tlatesubclamp4cols)(int sx, int yl, int yh);
void (*rt_tlaterevsubclamp4cols)(int sx, int yl, int yh); void (*rt_tlaterevsubclamp4cols)(int sx, int yl, int yh);
void (*rt_initcols)(canvas_pixel_t *buffer); void (*rt_initcols)(BYTE *buffer);
// //
// R_DrawColumn // R_DrawColumn
@ -158,7 +159,7 @@ DWORD *dc_destblend; // blending lookups
// first pixel in a column (possibly virtual) // first pixel in a column (possibly virtual)
const BYTE* dc_source; const BYTE* dc_source;
canvas_pixel_t* dc_dest; BYTE* dc_dest;
int dc_count; int dc_count;
DWORD vplce[4]; DWORD vplce[4];
@ -236,7 +237,7 @@ void R_InitShadeMaps()
void R_DrawColumnP_C (void) void R_DrawColumnP_C (void)
{ {
int count; int count;
canvas_pixel_t* dest; BYTE* dest;
fixed_t frac; fixed_t frac;
fixed_t fracstep; fixed_t fracstep;
@ -281,7 +282,7 @@ void R_DrawColumnP_C (void)
void R_DrawColumnP_RGBA_C() void R_DrawColumnP_RGBA_C()
{ {
int count; int count;
canvas_pixel_t* dest; uint32_t* dest;
fixed_t frac; fixed_t frac;
fixed_t fracstep; fixed_t fracstep;
@ -292,7 +293,7 @@ void R_DrawColumnP_RGBA_C()
return; return;
// Framebuffer destination address. // Framebuffer destination address.
dest = dc_dest; dest = (uint32_t*)dc_dest;
uint32_t light = calc_light_multiplier(dc_light); uint32_t light = calc_light_multiplier(dc_light);
@ -328,7 +329,7 @@ void R_DrawColumnP_RGBA_C()
void R_FillColumnP_C (void) void R_FillColumnP_C (void)
{ {
int count; int count;
canvas_pixel_t* dest; BYTE* dest;
count = dc_count; count = dc_count;
@ -352,14 +353,14 @@ void R_FillColumnP_C (void)
void R_FillColumnP_RGBA() void R_FillColumnP_RGBA()
{ {
int count; int count;
canvas_pixel_t* dest; uint32_t* dest;
count = dc_count; count = dc_count;
if (count <= 0) if (count <= 0)
return; return;
dest = dc_dest; dest = (uint32_t*)dc_dest;
uint32_t light = calc_light_multiplier(dc_light); uint32_t light = calc_light_multiplier(dc_light);
@ -378,7 +379,7 @@ void R_FillColumnP_RGBA()
void R_FillAddColumn_C (void) void R_FillAddColumn_C (void)
{ {
int count; int count;
canvas_pixel_t *dest; BYTE *dest;
count = dc_count; count = dc_count;
if (count <= 0) if (count <= 0)
@ -405,13 +406,13 @@ void R_FillAddColumn_C (void)
void R_FillAddColumn_RGBA_C() void R_FillAddColumn_RGBA_C()
{ {
int count; int count;
canvas_pixel_t *dest; uint32_t *dest;
count = dc_count; count = dc_count;
if (count <= 0) if (count <= 0)
return; return;
dest = dc_dest; dest = (uint32_t*)dc_dest;
int pitch = dc_pitch; int pitch = dc_pitch;
uint32_t fg_red = (dc_srccolor >> 12) & 0xf8; uint32_t fg_red = (dc_srccolor >> 12) & 0xf8;
@ -436,7 +437,7 @@ void R_FillAddColumn_RGBA_C()
void R_FillAddClampColumn_C (void) void R_FillAddClampColumn_C (void)
{ {
int count; int count;
canvas_pixel_t *dest; BYTE *dest;
count = dc_count; count = dc_count;
if (count <= 0) if (count <= 0)
@ -469,13 +470,13 @@ void R_FillAddClampColumn_C (void)
void R_FillAddClampColumn_RGBA() void R_FillAddClampColumn_RGBA()
{ {
int count; int count;
canvas_pixel_t *dest; uint32_t *dest;
count = dc_count; count = dc_count;
if (count <= 0) if (count <= 0)
return; return;
dest = dc_dest; dest = (uint32_t*)dc_dest;
int pitch = dc_pitch; int pitch = dc_pitch;
uint32_t fg_red = (dc_srccolor >> 12) & 0xf8; uint32_t fg_red = (dc_srccolor >> 12) & 0xf8;
@ -500,7 +501,7 @@ void R_FillAddClampColumn_RGBA()
void R_FillSubClampColumn_C (void) void R_FillSubClampColumn_C (void)
{ {
int count; int count;
canvas_pixel_t *dest; BYTE *dest;
count = dc_count; count = dc_count;
if (count <= 0) if (count <= 0)
@ -532,13 +533,13 @@ void R_FillSubClampColumn_C (void)
void R_FillSubClampColumn_RGBA() void R_FillSubClampColumn_RGBA()
{ {
int count; int count;
canvas_pixel_t *dest; uint32_t *dest;
count = dc_count; count = dc_count;
if (count <= 0) if (count <= 0)
return; return;
dest = dc_dest; dest = (uint32_t*)dc_dest;
int pitch = dc_pitch; int pitch = dc_pitch;
uint32_t fg_red = (dc_srccolor >> 12) & 0xf8; uint32_t fg_red = (dc_srccolor >> 12) & 0xf8;
@ -563,7 +564,7 @@ void R_FillSubClampColumn_RGBA()
void R_FillRevSubClampColumn_C (void) void R_FillRevSubClampColumn_C (void)
{ {
int count; int count;
canvas_pixel_t *dest; BYTE *dest;
count = dc_count; count = dc_count;
if (count <= 0) if (count <= 0)
@ -595,13 +596,13 @@ void R_FillRevSubClampColumn_C (void)
void R_FillRevSubClampColumn_RGBA() void R_FillRevSubClampColumn_RGBA()
{ {
int count; int count;
canvas_pixel_t *dest; uint32_t *dest;
count = dc_count; count = dc_count;
if (count <= 0) if (count <= 0)
return; return;
dest = dc_dest; dest = (uint32_t*)dc_dest;
int pitch = dc_pitch; int pitch = dc_pitch;
uint32_t fg_red = (dc_srccolor >> 12) & 0xf8; uint32_t fg_red = (dc_srccolor >> 12) & 0xf8;
@ -673,7 +674,7 @@ void R_InitFuzzTable (int fuzzoff)
void R_DrawFuzzColumnP_C (void) void R_DrawFuzzColumnP_C (void)
{ {
int count; int count;
canvas_pixel_t *dest; BYTE *dest;
// Adjust borders. Low... // Adjust borders. Low...
if (dc_yl == 0) if (dc_yl == 0)
@ -745,7 +746,7 @@ void R_DrawFuzzColumnP_C (void)
void R_DrawFuzzColumnP_RGBA_C() void R_DrawFuzzColumnP_RGBA_C()
{ {
int count; int count;
canvas_pixel_t *dest; uint32_t *dest;
// Adjust borders. Low... // Adjust borders. Low...
if (dc_yl == 0) if (dc_yl == 0)
@ -763,7 +764,7 @@ void R_DrawFuzzColumnP_RGBA_C()
count++; count++;
dest = ylookup[dc_yl] + dc_x + dc_destorg; dest = ylookup[dc_yl] + dc_x + (uint32_t*)dc_destorg;
// Note: this implementation assumes this function is only used for the pinky shadow effect (i.e. no other fancy colormap than black) // Note: this implementation assumes this function is only used for the pinky shadow effect (i.e. no other fancy colormap than black)
// I'm not sure if this is really always the case or not. // I'm not sure if this is really always the case or not.
@ -890,7 +891,7 @@ algorithm that uses RGB tables.
void R_DrawAddColumnP_C (void) void R_DrawAddColumnP_C (void)
{ {
int count; int count;
canvas_pixel_t *dest; BYTE *dest;
fixed_t frac; fixed_t frac;
fixed_t fracstep; fixed_t fracstep;
@ -928,7 +929,7 @@ void R_DrawAddColumnP_C (void)
void R_DrawAddColumnP_RGBA_C() void R_DrawAddColumnP_RGBA_C()
{ {
int count; int count;
canvas_pixel_t *dest; uint32_t *dest;
fixed_t frac; fixed_t frac;
fixed_t fracstep; fixed_t fracstep;
@ -936,7 +937,7 @@ void R_DrawAddColumnP_RGBA_C()
if (count <= 0) if (count <= 0)
return; return;
dest = dc_dest; dest = (uint32_t*)dc_dest;
fracstep = dc_iscale; fracstep = dc_iscale;
frac = dc_texturefrac; frac = dc_texturefrac;
@ -980,7 +981,7 @@ void R_DrawAddColumnP_RGBA_C()
void R_DrawTranslatedColumnP_C (void) void R_DrawTranslatedColumnP_C (void)
{ {
int count; int count;
canvas_pixel_t* dest; BYTE* dest;
fixed_t frac; fixed_t frac;
fixed_t fracstep; fixed_t fracstep;
@ -1012,7 +1013,7 @@ void R_DrawTranslatedColumnP_C (void)
void R_DrawTranslatedColumnP_RGBA_C() void R_DrawTranslatedColumnP_RGBA_C()
{ {
int count; int count;
canvas_pixel_t* dest; uint32_t* dest;
fixed_t frac; fixed_t frac;
fixed_t fracstep; fixed_t fracstep;
@ -1022,7 +1023,7 @@ void R_DrawTranslatedColumnP_RGBA_C()
uint32_t light = calc_light_multiplier(dc_light); uint32_t light = calc_light_multiplier(dc_light);
dest = dc_dest; dest = (uint32_t*)dc_dest;
fracstep = dc_iscale; fracstep = dc_iscale;
frac = dc_texturefrac; frac = dc_texturefrac;
@ -1047,7 +1048,7 @@ void R_DrawTranslatedColumnP_RGBA_C()
void R_DrawTlatedAddColumnP_C() void R_DrawTlatedAddColumnP_C()
{ {
int count; int count;
canvas_pixel_t *dest; BYTE *dest;
fixed_t frac; fixed_t frac;
fixed_t fracstep; fixed_t fracstep;
@ -1086,7 +1087,7 @@ void R_DrawTlatedAddColumnP_C()
void R_DrawTlatedAddColumnP_RGBA_C() void R_DrawTlatedAddColumnP_RGBA_C()
{ {
int count; int count;
canvas_pixel_t *dest; uint32_t *dest;
fixed_t frac; fixed_t frac;
fixed_t fracstep; fixed_t fracstep;
@ -1096,7 +1097,7 @@ void R_DrawTlatedAddColumnP_RGBA_C()
uint32_t light = calc_light_multiplier(dc_light); uint32_t light = calc_light_multiplier(dc_light);
dest = dc_dest; dest = (uint32_t*)dc_dest;
fracstep = dc_iscale; fracstep = dc_iscale;
frac = dc_texturefrac; frac = dc_texturefrac;
@ -1135,7 +1136,7 @@ void R_DrawTlatedAddColumnP_RGBA_C()
void R_DrawShadedColumnP_C (void) void R_DrawShadedColumnP_C (void)
{ {
int count; int count;
canvas_pixel_t *dest; BYTE *dest;
fixed_t frac, fracstep; fixed_t frac, fracstep;
count = dc_count; count = dc_count;
@ -1170,7 +1171,7 @@ void R_DrawShadedColumnP_C (void)
void R_DrawShadedColumnP_RGBA_C() void R_DrawShadedColumnP_RGBA_C()
{ {
int count; int count;
canvas_pixel_t *dest; uint32_t *dest;
fixed_t frac, fracstep; fixed_t frac, fracstep;
count = dc_count; count = dc_count;
@ -1178,7 +1179,7 @@ void R_DrawShadedColumnP_RGBA_C()
if (count <= 0) if (count <= 0)
return; return;
dest = dc_dest; dest = (uint32_t*)dc_dest;
fracstep = dc_iscale; fracstep = dc_iscale;
frac = dc_texturefrac; frac = dc_texturefrac;
@ -1217,7 +1218,7 @@ void R_DrawShadedColumnP_RGBA_C()
void R_DrawAddClampColumnP_C () void R_DrawAddClampColumnP_C ()
{ {
int count; int count;
canvas_pixel_t *dest; BYTE *dest;
fixed_t frac; fixed_t frac;
fixed_t fracstep; fixed_t fracstep;
@ -1234,24 +1235,20 @@ void R_DrawAddClampColumnP_C ()
const BYTE *source = dc_source; const BYTE *source = dc_source;
BYTE *colormap = dc_colormap; BYTE *colormap = dc_colormap;
int pitch = dc_pitch; int pitch = dc_pitch;
uint32_t light = calc_light_multiplier(dc_light); DWORD *fg2rgb = dc_srcblend;
DWORD *bg2rgb = dc_destblend;
do do
{ {
uint32_t fg = shade_pal_index(colormap[source[frac >> FRACBITS]], light); DWORD a = fg2rgb[colormap[source[frac >> FRACBITS]]] + bg2rgb[*dest];
uint32_t fg_red = (fg >> 16) & 0xff; DWORD b = a;
uint32_t fg_green = (fg >> 8) & 0xff;
uint32_t fg_blue = fg & 0xff;
uint32_t bg_red = (*dest >> 16) & 0xff; a |= 0x01f07c1f;
uint32_t bg_green = (*dest >> 8) & 0xff; b &= 0x40100400;
uint32_t bg_blue = (*dest) & 0xff; a &= 0x3fffffff;
b = b - (b >> 5);
uint32_t red = clamp<uint32_t>(fg_red + bg_red, 0, 255); a |= b;
uint32_t green = clamp<uint32_t>(fg_green + bg_green, 0, 255); *dest = RGB32k.All[a & (a >> 15)];
uint32_t blue = clamp<uint32_t>(fg_blue + bg_blue, 0, 255);
*dest = 0xff000000 | (red << 16) | (green << 8) | blue;
dest += pitch; dest += pitch;
frac += fracstep; frac += fracstep;
} while (--count); } while (--count);
@ -1261,7 +1258,7 @@ void R_DrawAddClampColumnP_C ()
void R_DrawAddClampColumnP_RGBA_C() void R_DrawAddClampColumnP_RGBA_C()
{ {
int count; int count;
canvas_pixel_t *dest; uint32_t *dest;
fixed_t frac; fixed_t frac;
fixed_t fracstep; fixed_t fracstep;
@ -1269,7 +1266,7 @@ void R_DrawAddClampColumnP_RGBA_C()
if (count <= 0) if (count <= 0)
return; return;
dest = dc_dest; dest = (uint32_t*)dc_dest;
fracstep = dc_iscale; fracstep = dc_iscale;
frac = dc_texturefrac; frac = dc_texturefrac;
@ -1306,7 +1303,7 @@ void R_DrawAddClampColumnP_RGBA_C()
void R_DrawAddClampTranslatedColumnP_C () void R_DrawAddClampTranslatedColumnP_C ()
{ {
int count; int count;
canvas_pixel_t *dest; BYTE *dest;
fixed_t frac; fixed_t frac;
fixed_t fracstep; fixed_t fracstep;
@ -1347,7 +1344,7 @@ void R_DrawAddClampTranslatedColumnP_C ()
void R_DrawAddClampTranslatedColumnP_RGBA_C() void R_DrawAddClampTranslatedColumnP_RGBA_C()
{ {
int count; int count;
canvas_pixel_t *dest; uint32_t *dest;
fixed_t frac; fixed_t frac;
fixed_t fracstep; fixed_t fracstep;
@ -1355,7 +1352,7 @@ void R_DrawAddClampTranslatedColumnP_RGBA_C()
if (count <= 0) if (count <= 0)
return; return;
dest = dc_dest; dest = (uint32_t*)dc_dest;
fracstep = dc_iscale; fracstep = dc_iscale;
frac = dc_texturefrac; frac = dc_texturefrac;
@ -1393,7 +1390,7 @@ void R_DrawAddClampTranslatedColumnP_RGBA_C()
void R_DrawSubClampColumnP_C () void R_DrawSubClampColumnP_C ()
{ {
int count; int count;
canvas_pixel_t *dest; BYTE *dest;
fixed_t frac; fixed_t frac;
fixed_t fracstep; fixed_t fracstep;
@ -1432,7 +1429,7 @@ void R_DrawSubClampColumnP_C ()
void R_DrawSubClampColumnP_RGBA_C() void R_DrawSubClampColumnP_RGBA_C()
{ {
int count; int count;
canvas_pixel_t *dest; uint32_t *dest;
fixed_t frac; fixed_t frac;
fixed_t fracstep; fixed_t fracstep;
@ -1440,7 +1437,7 @@ void R_DrawSubClampColumnP_RGBA_C()
if (count <= 0) if (count <= 0)
return; return;
dest = dc_dest; dest = (uint32_t*)dc_dest;
fracstep = dc_iscale; fracstep = dc_iscale;
frac = dc_texturefrac; frac = dc_texturefrac;
@ -1477,7 +1474,7 @@ void R_DrawSubClampColumnP_RGBA_C()
void R_DrawSubClampTranslatedColumnP_C () void R_DrawSubClampTranslatedColumnP_C ()
{ {
int count; int count;
canvas_pixel_t *dest; BYTE *dest;
fixed_t frac; fixed_t frac;
fixed_t fracstep; fixed_t fracstep;
@ -1517,7 +1514,7 @@ void R_DrawSubClampTranslatedColumnP_C ()
void R_DrawSubClampTranslatedColumnP_RGBA_C() void R_DrawSubClampTranslatedColumnP_RGBA_C()
{ {
int count; int count;
canvas_pixel_t *dest; uint32_t *dest;
fixed_t frac; fixed_t frac;
fixed_t fracstep; fixed_t fracstep;
@ -1525,7 +1522,7 @@ void R_DrawSubClampTranslatedColumnP_RGBA_C()
if (count <= 0) if (count <= 0)
return; return;
dest = dc_dest; dest = (uint32_t*)dc_dest;
fracstep = dc_iscale; fracstep = dc_iscale;
frac = dc_texturefrac; frac = dc_texturefrac;
@ -1563,7 +1560,7 @@ void R_DrawSubClampTranslatedColumnP_RGBA_C()
void R_DrawRevSubClampColumnP_C () void R_DrawRevSubClampColumnP_C ()
{ {
int count; int count;
canvas_pixel_t *dest; BYTE *dest;
fixed_t frac; fixed_t frac;
fixed_t fracstep; fixed_t fracstep;
@ -1602,7 +1599,7 @@ void R_DrawRevSubClampColumnP_C ()
void R_DrawRevSubClampColumnP_RGBA_C() void R_DrawRevSubClampColumnP_RGBA_C()
{ {
int count; int count;
canvas_pixel_t *dest; uint32_t *dest;
fixed_t frac; fixed_t frac;
fixed_t fracstep; fixed_t fracstep;
@ -1610,7 +1607,7 @@ void R_DrawRevSubClampColumnP_RGBA_C()
if (count <= 0) if (count <= 0)
return; return;
dest = dc_dest; dest = (uint32_t*)dc_dest;
fracstep = dc_iscale; fracstep = dc_iscale;
frac = dc_texturefrac; frac = dc_texturefrac;
@ -1647,7 +1644,7 @@ void R_DrawRevSubClampColumnP_RGBA_C()
void R_DrawRevSubClampTranslatedColumnP_C () void R_DrawRevSubClampTranslatedColumnP_C ()
{ {
int count; int count;
canvas_pixel_t *dest; BYTE *dest;
fixed_t frac; fixed_t frac;
fixed_t fracstep; fixed_t fracstep;
@ -1687,7 +1684,7 @@ void R_DrawRevSubClampTranslatedColumnP_C ()
void R_DrawRevSubClampTranslatedColumnP_RGBA_C() void R_DrawRevSubClampTranslatedColumnP_RGBA_C()
{ {
int count; int count;
canvas_pixel_t *dest; uint32_t *dest;
fixed_t frac; fixed_t frac;
fixed_t fracstep; fixed_t fracstep;
@ -1695,7 +1692,7 @@ void R_DrawRevSubClampTranslatedColumnP_RGBA_C()
if (count <= 0) if (count <= 0)
return; return;
dest = dc_dest; dest = (uint32_t*)dc_dest;
fracstep = dc_iscale; fracstep = dc_iscale;
frac = dc_texturefrac; frac = dc_texturefrac;
@ -1855,7 +1852,7 @@ void R_DrawSpanP_C (void)
dsfixed_t yfrac; dsfixed_t yfrac;
dsfixed_t xstep; dsfixed_t xstep;
dsfixed_t ystep; dsfixed_t ystep;
canvas_pixel_t* dest; BYTE* dest;
const BYTE* source = ds_source; const BYTE* source = ds_source;
const BYTE* colormap = ds_colormap; const BYTE* colormap = ds_colormap;
int count; int count;
@ -1927,7 +1924,7 @@ void R_DrawSpanP_RGBA_C()
dsfixed_t yfrac; dsfixed_t yfrac;
dsfixed_t xstep; dsfixed_t xstep;
dsfixed_t ystep; dsfixed_t ystep;
canvas_pixel_t* dest; uint32_t* dest;
const BYTE* source = ds_source; const BYTE* source = ds_source;
const BYTE* colormap = ds_colormap; const BYTE* colormap = ds_colormap;
int count; int count;
@ -1945,7 +1942,7 @@ void R_DrawSpanP_RGBA_C()
xfrac = ds_xfrac; xfrac = ds_xfrac;
yfrac = ds_yfrac; yfrac = ds_yfrac;
dest = ylookup[ds_y] + ds_x1 + dc_destorg; dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg;
count = ds_x2 - ds_x1 + 1; count = ds_x2 - ds_x1 + 1;
@ -2051,7 +2048,7 @@ void R_DrawSpanMaskedP_C (void)
dsfixed_t yfrac; dsfixed_t yfrac;
dsfixed_t xstep; dsfixed_t xstep;
dsfixed_t ystep; dsfixed_t ystep;
canvas_pixel_t* dest; BYTE* dest;
const BYTE* source = ds_source; const BYTE* source = ds_source;
const BYTE* colormap = ds_colormap; const BYTE* colormap = ds_colormap;
int count; int count;
@ -2114,7 +2111,7 @@ void R_DrawSpanMaskedP_RGBA_C()
dsfixed_t yfrac; dsfixed_t yfrac;
dsfixed_t xstep; dsfixed_t xstep;
dsfixed_t ystep; dsfixed_t ystep;
canvas_pixel_t* dest; uint32_t* dest;
const BYTE* source = ds_source; const BYTE* source = ds_source;
const BYTE* colormap = ds_colormap; const BYTE* colormap = ds_colormap;
int count; int count;
@ -2125,7 +2122,7 @@ void R_DrawSpanMaskedP_RGBA_C()
xfrac = ds_xfrac; xfrac = ds_xfrac;
yfrac = ds_yfrac; yfrac = ds_yfrac;
dest = ylookup[ds_y] + ds_x1 + dc_destorg; dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg;
count = ds_x2 - ds_x1 + 1; count = ds_x2 - ds_x1 + 1;
@ -2179,7 +2176,7 @@ void R_DrawSpanTranslucentP_C (void)
dsfixed_t yfrac; dsfixed_t yfrac;
dsfixed_t xstep; dsfixed_t xstep;
dsfixed_t ystep; dsfixed_t ystep;
canvas_pixel_t* dest; BYTE* dest;
const BYTE* source = ds_source; const BYTE* source = ds_source;
const BYTE* colormap = ds_colormap; const BYTE* colormap = ds_colormap;
int count; int count;
@ -2241,7 +2238,7 @@ void R_DrawSpanTranslucentP_RGBA_C()
dsfixed_t yfrac; dsfixed_t yfrac;
dsfixed_t xstep; dsfixed_t xstep;
dsfixed_t ystep; dsfixed_t ystep;
canvas_pixel_t* dest; uint32_t* dest;
const BYTE* source = ds_source; const BYTE* source = ds_source;
const BYTE* colormap = ds_colormap; const BYTE* colormap = ds_colormap;
int count; int count;
@ -2252,7 +2249,7 @@ void R_DrawSpanTranslucentP_RGBA_C()
xfrac = ds_xfrac; xfrac = ds_xfrac;
yfrac = ds_yfrac; yfrac = ds_yfrac;
dest = ylookup[ds_y] + ds_x1 + dc_destorg; dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg;
count = ds_x2 - ds_x1 + 1; count = ds_x2 - ds_x1 + 1;
@ -2323,7 +2320,7 @@ void R_DrawSpanMaskedTranslucentP_C (void)
dsfixed_t yfrac; dsfixed_t yfrac;
dsfixed_t xstep; dsfixed_t xstep;
dsfixed_t ystep; dsfixed_t ystep;
canvas_pixel_t* dest; BYTE* dest;
const BYTE* source = ds_source; const BYTE* source = ds_source;
const BYTE* colormap = ds_colormap; const BYTE* colormap = ds_colormap;
int count; int count;
@ -2399,7 +2396,7 @@ void R_DrawSpanMaskedTranslucentP_RGBA_C()
dsfixed_t yfrac; dsfixed_t yfrac;
dsfixed_t xstep; dsfixed_t xstep;
dsfixed_t ystep; dsfixed_t ystep;
canvas_pixel_t* dest; uint32_t* dest;
const BYTE* source = ds_source; const BYTE* source = ds_source;
const BYTE* colormap = ds_colormap; const BYTE* colormap = ds_colormap;
int count; int count;
@ -2412,7 +2409,7 @@ void R_DrawSpanMaskedTranslucentP_RGBA_C()
xfrac = ds_xfrac; xfrac = ds_xfrac;
yfrac = ds_yfrac; yfrac = ds_yfrac;
dest = ylookup[ds_y] + ds_x1 + dc_destorg; dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg;
count = ds_x2 - ds_x1 + 1; count = ds_x2 - ds_x1 + 1;
@ -2491,7 +2488,7 @@ void R_DrawSpanAddClampP_C (void)
dsfixed_t yfrac; dsfixed_t yfrac;
dsfixed_t xstep; dsfixed_t xstep;
dsfixed_t ystep; dsfixed_t ystep;
canvas_pixel_t* dest; BYTE* dest;
const BYTE* source = ds_source; const BYTE* source = ds_source;
const BYTE* colormap = ds_colormap; const BYTE* colormap = ds_colormap;
int count; int count;
@ -2561,7 +2558,7 @@ void R_DrawSpanAddClampP_RGBA_C()
dsfixed_t yfrac; dsfixed_t yfrac;
dsfixed_t xstep; dsfixed_t xstep;
dsfixed_t ystep; dsfixed_t ystep;
canvas_pixel_t* dest; uint32_t* dest;
const BYTE* source = ds_source; const BYTE* source = ds_source;
const BYTE* colormap = ds_colormap; const BYTE* colormap = ds_colormap;
int count; int count;
@ -2574,7 +2571,7 @@ void R_DrawSpanAddClampP_RGBA_C()
xfrac = ds_xfrac; xfrac = ds_xfrac;
yfrac = ds_yfrac; yfrac = ds_yfrac;
dest = ylookup[ds_y] + ds_x1 + dc_destorg; dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg;
count = ds_x2 - ds_x1 + 1; count = ds_x2 - ds_x1 + 1;
@ -2643,7 +2640,7 @@ void R_DrawSpanMaskedAddClampP_C (void)
dsfixed_t yfrac; dsfixed_t yfrac;
dsfixed_t xstep; dsfixed_t xstep;
dsfixed_t ystep; dsfixed_t ystep;
canvas_pixel_t* dest; BYTE* dest;
const BYTE* source = ds_source; const BYTE* source = ds_source;
const BYTE* colormap = ds_colormap; const BYTE* colormap = ds_colormap;
int count; int count;
@ -2725,7 +2722,7 @@ void R_DrawSpanMaskedAddClampP_RGBA_C()
dsfixed_t yfrac; dsfixed_t yfrac;
dsfixed_t xstep; dsfixed_t xstep;
dsfixed_t ystep; dsfixed_t ystep;
canvas_pixel_t* dest; uint32_t* dest;
const BYTE* source = ds_source; const BYTE* source = ds_source;
const BYTE* colormap = ds_colormap; const BYTE* colormap = ds_colormap;
int count; int count;
@ -2738,7 +2735,7 @@ void R_DrawSpanMaskedAddClampP_RGBA_C()
xfrac = ds_xfrac; xfrac = ds_xfrac;
yfrac = ds_yfrac; yfrac = ds_yfrac;
dest = ylookup[ds_y] + ds_x1 + dc_destorg; dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg;
count = ds_x2 - ds_x1 + 1; count = ds_x2 - ds_x1 + 1;
@ -2819,7 +2816,7 @@ void R_FillSpan_C (void)
void R_FillSpan_RGBA() void R_FillSpan_RGBA()
{ {
canvas_pixel_t *dest = ylookup[ds_y] + ds_x1 + dc_destorg; uint32_t *dest = ylookup[ds_y] + ds_x1 + (uint32_t*)dc_destorg;
int count = (ds_x2 - ds_x1 + 1); int count = (ds_x2 - ds_x1 + 1);
uint32_t light = calc_light_multiplier(ds_light); uint32_t light = calc_light_multiplier(ds_light);
uint32_t color = shade_pal_index(ds_color, light); uint32_t color = shade_pal_index(ds_color, light);
@ -2843,7 +2840,7 @@ extern "C" void R_SetupDrawSlabC(const BYTE *colormap)
slabcolormap = colormap; slabcolormap = colormap;
} }
extern "C" void R_DrawSlabC(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *vptr, canvas_pixel_t *p) extern "C" void R_DrawSlabC(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *vptr, BYTE *p)
{ {
int x; int x;
const BYTE *colormap = slabcolormap; const BYTE *colormap = slabcolormap;
@ -3017,7 +3014,7 @@ DWORD vlinec1 ()
BYTE *colormap = dc_colormap; BYTE *colormap = dc_colormap;
int count = dc_count; int count = dc_count;
const BYTE *source = dc_source; const BYTE *source = dc_source;
canvas_pixel_t *dest = dc_dest; BYTE *dest = dc_dest;
int bits = vlinebits; int bits = vlinebits;
int pitch = dc_pitch; int pitch = dc_pitch;
@ -3039,7 +3036,7 @@ DWORD vlinec1_RGBA()
BYTE *colormap = dc_colormap; BYTE *colormap = dc_colormap;
int count = dc_count; int count = dc_count;
const BYTE *source = dc_source; const BYTE *source = dc_source;
canvas_pixel_t *dest = dc_dest; uint32_t *dest = (uint32_t*)dc_dest;
int bits = vlinebits; int bits = vlinebits;
int pitch = dc_pitch; int pitch = dc_pitch;
@ -3058,7 +3055,7 @@ DWORD vlinec1_RGBA()
#if !defined(X86_ASM) #if !defined(X86_ASM)
void vlinec4 () void vlinec4 ()
{ {
canvas_pixel_t *dest = dc_dest; BYTE *dest = dc_dest;
int count = dc_count; int count = dc_count;
int bits = vlinebits; int bits = vlinebits;
DWORD place; DWORD place;
@ -3076,7 +3073,7 @@ void vlinec4 ()
void vlinec4_RGBA() void vlinec4_RGBA()
{ {
canvas_pixel_t *dest = dc_dest; uint32_t *dest = (uint32_t*)dc_dest;
int count = dc_count; int count = dc_count;
int bits = vlinebits; int bits = vlinebits;
@ -3162,7 +3159,7 @@ DWORD mvlinec1 ()
BYTE *colormap = dc_colormap; BYTE *colormap = dc_colormap;
int count = dc_count; int count = dc_count;
const BYTE *source = dc_source; const BYTE *source = dc_source;
canvas_pixel_t *dest = dc_dest; BYTE *dest = dc_dest;
int bits = mvlinebits; int bits = mvlinebits;
int pitch = dc_pitch; int pitch = dc_pitch;
@ -3188,7 +3185,7 @@ DWORD mvlinec1_RGBA()
BYTE *colormap = dc_colormap; BYTE *colormap = dc_colormap;
int count = dc_count; int count = dc_count;
const BYTE *source = dc_source; const BYTE *source = dc_source;
canvas_pixel_t *dest = dc_dest; uint32_t *dest = (uint32_t*)dc_dest;
int bits = mvlinebits; int bits = mvlinebits;
int pitch = dc_pitch; int pitch = dc_pitch;
@ -3211,7 +3208,7 @@ DWORD mvlinec1_RGBA()
#if !defined(X86_ASM) #if !defined(X86_ASM)
void mvlinec4 () void mvlinec4 ()
{ {
canvas_pixel_t *dest = dc_dest; BYTE *dest = dc_dest;
int count = dc_count; int count = dc_count;
int bits = mvlinebits; int bits = mvlinebits;
DWORD place; DWORD place;
@ -3230,7 +3227,7 @@ void mvlinec4 ()
void mvlinec4_RGBA() void mvlinec4_RGBA()
{ {
canvas_pixel_t *dest = dc_dest; uint32_t *dest = (uint32_t*)dc_dest;
int count = dc_count; int count = dc_count;
int bits = mvlinebits; int bits = mvlinebits;
DWORD place; DWORD place;
@ -3260,7 +3257,7 @@ extern int wallshade;
static void R_DrawFogBoundarySection (int y, int y2, int x1) static void R_DrawFogBoundarySection (int y, int y2, int x1)
{ {
BYTE *colormap = dc_colormap; BYTE *colormap = dc_colormap;
canvas_pixel_t *dest = ylookup[y] + dc_destorg; BYTE *dest = ylookup[y] + dc_destorg;
for (; y < y2; ++y) for (; y < y2; ++y)
{ {
@ -3278,7 +3275,7 @@ static void R_DrawFogBoundaryLine (int y, int x)
{ {
int x2 = spanend[y]; int x2 = spanend[y];
BYTE *colormap = dc_colormap; BYTE *colormap = dc_colormap;
canvas_pixel_t *dest = ylookup[y] + dc_destorg; BYTE *dest = ylookup[y] + dc_destorg;
do do
{ {
@ -3380,7 +3377,7 @@ void R_DrawFogBoundary_C (int x1, int x2, short *uclip, short *dclip)
static void R_DrawFogBoundarySection_RGBA(int y, int y2, int x1) static void R_DrawFogBoundarySection_RGBA(int y, int y2, int x1)
{ {
BYTE *colormap = dc_colormap; BYTE *colormap = dc_colormap;
canvas_pixel_t *dest = ylookup[y] + dc_destorg; uint32_t *dest = ylookup[y] + (uint32_t*)dc_destorg;
uint32_t light = calc_light_multiplier(dc_light); uint32_t light = calc_light_multiplier(dc_light);
@ -3400,7 +3397,7 @@ static void R_DrawFogBoundaryLine_RGBA(int y, int x)
{ {
int x2 = spanend[y]; int x2 = spanend[y];
BYTE *colormap = dc_colormap; BYTE *colormap = dc_colormap;
canvas_pixel_t *dest = ylookup[y] + dc_destorg; uint32_t *dest = ylookup[y] + (uint32_t*)dc_destorg;
uint32_t light = calc_light_multiplier(dc_light); uint32_t light = calc_light_multiplier(dc_light);
@ -3518,7 +3515,7 @@ fixed_t tmvline1_add_C ()
BYTE *colormap = dc_colormap; BYTE *colormap = dc_colormap;
int count = dc_count; int count = dc_count;
const BYTE *source = dc_source; const BYTE *source = dc_source;
canvas_pixel_t *dest = dc_dest; BYTE *dest = dc_dest;
int bits = tmvlinebits; int bits = tmvlinebits;
int pitch = dc_pitch; int pitch = dc_pitch;
@ -3551,7 +3548,7 @@ fixed_t tmvline1_add_RGBA()
BYTE *colormap = dc_colormap; BYTE *colormap = dc_colormap;
int count = dc_count; int count = dc_count;
const BYTE *source = dc_source; const BYTE *source = dc_source;
canvas_pixel_t *dest = dc_dest; uint32_t *dest = (uint32_t*)dc_dest;
int bits = tmvlinebits; int bits = tmvlinebits;
int pitch = dc_pitch; int pitch = dc_pitch;
@ -3589,7 +3586,7 @@ fixed_t tmvline1_add_RGBA()
void tmvline4_add_C () void tmvline4_add_C ()
{ {
canvas_pixel_t *dest = dc_dest; BYTE *dest = dc_dest;
int count = dc_count; int count = dc_count;
int bits = tmvlinebits; int bits = tmvlinebits;
@ -3622,13 +3619,10 @@ void tmvline4_add_C ()
void tmvline4_add_RGBA() void tmvline4_add_RGBA()
{ {
canvas_pixel_t *dest = dc_dest; uint32_t *dest = (uint32_t*)dc_dest;
int count = dc_count; int count = dc_count;
int bits = tmvlinebits; int bits = tmvlinebits;
DWORD *fg2rgb = dc_srcblend;
DWORD *bg2rgb = dc_destblend;
uint32_t light[4]; uint32_t light[4];
light[0] = calc_light_multiplier(palookuplight[0]); light[0] = calc_light_multiplier(palookuplight[0]);
light[1] = calc_light_multiplier(palookuplight[1]); light[1] = calc_light_multiplier(palookuplight[1]);
@ -3670,7 +3664,7 @@ fixed_t tmvline1_addclamp_C ()
BYTE *colormap = dc_colormap; BYTE *colormap = dc_colormap;
int count = dc_count; int count = dc_count;
const BYTE *source = dc_source; const BYTE *source = dc_source;
canvas_pixel_t *dest = dc_dest; BYTE *dest = dc_dest;
int bits = tmvlinebits; int bits = tmvlinebits;
int pitch = dc_pitch; int pitch = dc_pitch;
@ -3708,7 +3702,7 @@ fixed_t tmvline1_addclamp_RGBA()
BYTE *colormap = dc_colormap; BYTE *colormap = dc_colormap;
int count = dc_count; int count = dc_count;
const BYTE *source = dc_source; const BYTE *source = dc_source;
canvas_pixel_t *dest = dc_dest; uint32_t *dest = (uint32_t*)dc_dest;
int bits = tmvlinebits; int bits = tmvlinebits;
int pitch = dc_pitch; int pitch = dc_pitch;
@ -3746,7 +3740,7 @@ fixed_t tmvline1_addclamp_RGBA()
void tmvline4_addclamp_C () void tmvline4_addclamp_C ()
{ {
canvas_pixel_t *dest = dc_dest; BYTE *dest = dc_dest;
int count = dc_count; int count = dc_count;
int bits = tmvlinebits; int bits = tmvlinebits;
@ -3778,7 +3772,7 @@ void tmvline4_addclamp_C ()
void tmvline4_addclamp_RGBA() void tmvline4_addclamp_RGBA()
{ {
canvas_pixel_t *dest = dc_dest; uint32_t *dest = (uint32_t*)dc_dest;
int count = dc_count; int count = dc_count;
int bits = tmvlinebits; int bits = tmvlinebits;
@ -3823,7 +3817,7 @@ fixed_t tmvline1_subclamp_C ()
BYTE *colormap = dc_colormap; BYTE *colormap = dc_colormap;
int count = dc_count; int count = dc_count;
const BYTE *source = dc_source; const BYTE *source = dc_source;
canvas_pixel_t *dest = dc_dest; BYTE *dest = dc_dest;
int bits = tmvlinebits; int bits = tmvlinebits;
int pitch = dc_pitch; int pitch = dc_pitch;
@ -3858,7 +3852,7 @@ fixed_t tmvline1_subclamp_RGBA()
BYTE *colormap = dc_colormap; BYTE *colormap = dc_colormap;
int count = dc_count; int count = dc_count;
const BYTE *source = dc_source; const BYTE *source = dc_source;
canvas_pixel_t *dest = dc_dest; uint32_t *dest = (uint32_t*)dc_dest;
int bits = tmvlinebits; int bits = tmvlinebits;
int pitch = dc_pitch; int pitch = dc_pitch;
@ -3893,7 +3887,7 @@ fixed_t tmvline1_subclamp_RGBA()
void tmvline4_subclamp_C () void tmvline4_subclamp_C ()
{ {
canvas_pixel_t *dest = dc_dest; BYTE *dest = dc_dest;
int count = dc_count; int count = dc_count;
int bits = tmvlinebits; int bits = tmvlinebits;
@ -3924,7 +3918,7 @@ void tmvline4_subclamp_C ()
void tmvline4_subclamp_RGBA() void tmvline4_subclamp_RGBA()
{ {
canvas_pixel_t *dest = dc_dest; uint32_t *dest = (uint32_t*)dc_dest;
int count = dc_count; int count = dc_count;
int bits = tmvlinebits; int bits = tmvlinebits;
@ -3969,7 +3963,7 @@ fixed_t tmvline1_revsubclamp_C ()
BYTE *colormap = dc_colormap; BYTE *colormap = dc_colormap;
int count = dc_count; int count = dc_count;
const BYTE *source = dc_source; const BYTE *source = dc_source;
canvas_pixel_t *dest = dc_dest; BYTE *dest = dc_dest;
int bits = tmvlinebits; int bits = tmvlinebits;
int pitch = dc_pitch; int pitch = dc_pitch;
@ -4004,7 +3998,7 @@ fixed_t tmvline1_revsubclamp_RGBA()
BYTE *colormap = dc_colormap; BYTE *colormap = dc_colormap;
int count = dc_count; int count = dc_count;
const BYTE *source = dc_source; const BYTE *source = dc_source;
canvas_pixel_t *dest = dc_dest; uint32_t *dest = (uint32_t*)dc_dest;
int bits = tmvlinebits; int bits = tmvlinebits;
int pitch = dc_pitch; int pitch = dc_pitch;
@ -4039,7 +4033,7 @@ fixed_t tmvline1_revsubclamp_RGBA()
void tmvline4_revsubclamp_C () void tmvline4_revsubclamp_C ()
{ {
canvas_pixel_t *dest = dc_dest; BYTE *dest = dc_dest;
int count = dc_count; int count = dc_count;
int bits = tmvlinebits; int bits = tmvlinebits;
@ -4070,7 +4064,7 @@ void tmvline4_revsubclamp_C ()
void tmvline4_revsubclamp_RGBA() void tmvline4_revsubclamp_RGBA()
{ {
canvas_pixel_t *dest = dc_dest; uint32_t *dest = (uint32_t*)dc_dest;
int count = dc_count; int count = dc_count;
int bits = tmvlinebits; int bits = tmvlinebits;
@ -4168,6 +4162,7 @@ void R_InitColumnDrawers ()
R_FillColumnHoriz = R_FillColumnHorizP_RGBA_C; R_FillColumnHoriz = R_FillColumnHorizP_RGBA_C;
R_DrawFogBoundary = R_DrawFogBoundary_RGBA; R_DrawFogBoundary = R_DrawFogBoundary_RGBA;
R_MapTiltedPlane = R_MapColoredPlane_RGBA;
R_MapColoredPlane = R_MapColoredPlane_RGBA; R_MapColoredPlane = R_MapColoredPlane_RGBA;
R_DrawParticle = R_DrawParticle_RGBA; R_DrawParticle = R_DrawParticle_RGBA;
@ -4262,6 +4257,7 @@ void R_InitColumnDrawers ()
R_FillColumnHoriz = R_FillColumnHorizP_C; R_FillColumnHoriz = R_FillColumnHorizP_C;
R_DrawFogBoundary = R_DrawFogBoundary_C; R_DrawFogBoundary = R_DrawFogBoundary_C;
R_MapTiltedPlane = R_MapColoredPlane_C;
R_MapColoredPlane = R_MapColoredPlane_C; R_MapColoredPlane = R_MapColoredPlane_C;
R_DrawParticle = R_DrawParticle_C; R_DrawParticle = R_DrawParticle_C;

View File

@ -45,7 +45,7 @@ extern "C" DWORD *dc_destblend;
// first pixel in a column // first pixel in a column
extern "C" const BYTE* dc_source; extern "C" const BYTE* dc_source;
extern "C" canvas_pixel_t *dc_dest, *dc_destorg; extern "C" BYTE* dc_dest, *dc_destorg;
extern "C" int dc_count; extern "C" int dc_count;
extern "C" DWORD vplce[4]; extern "C" DWORD vplce[4];
@ -55,7 +55,7 @@ extern "C" fixed_t palookuplight[4];
extern "C" const BYTE* bufplce[4]; extern "C" const BYTE* bufplce[4];
// [RH] Temporary buffer for column drawing // [RH] Temporary buffer for column drawing
extern "C" canvas_pixel_t *dc_temp; extern "C" BYTE *dc_temp;
extern "C" unsigned int dc_tspans[4][MAXHEIGHT]; extern "C" unsigned int dc_tspans[4][MAXHEIGHT];
extern "C" unsigned int *dc_ctspan[4]; extern "C" unsigned int *dc_ctspan[4];
extern "C" unsigned int horizspans[4]; extern "C" unsigned int horizspans[4];
@ -228,13 +228,13 @@ extern void (*rt_tlateaddclamp4cols)(int sx, int yl, int yh);
extern void (*rt_tlatesubclamp4cols)(int sx, int yl, int yh); extern void (*rt_tlatesubclamp4cols)(int sx, int yl, int yh);
extern void (*rt_tlaterevsubclamp4cols)(int sx, int yl, int yh); extern void (*rt_tlaterevsubclamp4cols)(int sx, int yl, int yh);
extern void (*rt_initcols)(canvas_pixel_t *buffer); extern void (*rt_initcols)(BYTE *buffer);
void rt_draw4cols (int sx); void rt_draw4cols (int sx);
// [RH] Preps the temporary horizontal buffer. // [RH] Preps the temporary horizontal buffer.
void rt_initcols_pal (canvas_pixel_t *buffer); void rt_initcols_pal (BYTE *buffer);
void rt_initcols_rgba (canvas_pixel_t *buffer); void rt_initcols_rgba (BYTE *buffer);
extern void (*R_DrawFogBoundary)(int x1, int x2, short *uclip, short *dclip); extern void (*R_DrawFogBoundary)(int x1, int x2, short *uclip, short *dclip);
@ -313,7 +313,7 @@ void R_FillSpan_RGBA_C(void);
#endif #endif
extern "C" void R_SetupDrawSlab(const BYTE *colormap); extern "C" void R_SetupDrawSlab(const BYTE *colormap);
extern "C" void R_DrawSlab(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *vptr, canvas_pixel_t *p); extern "C" void R_DrawSlab(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *vptr, BYTE *p);
extern "C" int ds_y; extern "C" int ds_y;
extern "C" int ds_x1; extern "C" int ds_x1;

View File

@ -47,6 +47,8 @@
#include "r_things.h" #include "r_things.h"
#include "v_video.h" #include "v_video.h"
EXTERN_CVAR(Bool, r_swtruecolor)
// I should have commented this stuff better. // I should have commented this stuff better.
// //
// dc_temp is the buffer R_DrawColumnHoriz writes into. // dc_temp is the buffer R_DrawColumnHoriz writes into.
@ -57,8 +59,8 @@
// dc_ctspan is advanced while drawing into dc_temp. // dc_ctspan is advanced while drawing into dc_temp.
// horizspan is advanced up to dc_ctspan when drawing from dc_temp to the screen. // horizspan is advanced up to dc_ctspan when drawing from dc_temp to the screen.
canvas_pixel_t dc_tempbuff[MAXHEIGHT*4]; BYTE dc_tempbuff[MAXHEIGHT*4];
canvas_pixel_t *dc_temp; BYTE *dc_temp;
unsigned int dc_tspans[4][MAXHEIGHT]; unsigned int dc_tspans[4][MAXHEIGHT];
unsigned int *dc_ctspan[4]; unsigned int *dc_ctspan[4];
unsigned int *horizspan[4]; unsigned int *horizspan[4];
@ -73,8 +75,8 @@ extern "C" void R_SetupAddClampCol();
// Copies one span at hx to the screen at sx. // Copies one span at hx to the screen at sx.
void rt_copy1col_c (int hx, int sx, int yl, int yh) void rt_copy1col_c (int hx, int sx, int yl, int yh)
{ {
canvas_pixel_t *source; BYTE *source;
canvas_pixel_t *dest; BYTE *dest;
int count; int count;
int pitch; int pitch;
@ -148,8 +150,8 @@ void rt_copy4cols_c (int sx, int yl, int yh)
void rt_map1col_c (int hx, int sx, int yl, int yh) void rt_map1col_c (int hx, int sx, int yl, int yh)
{ {
BYTE *colormap; BYTE *colormap;
canvas_pixel_t *source; BYTE *source;
canvas_pixel_t *dest; BYTE *dest;
int count; int count;
int pitch; int pitch;
@ -183,8 +185,8 @@ void rt_map1col_c (int hx, int sx, int yl, int yh)
void rt_map4cols_c (int sx, int yl, int yh) void rt_map4cols_c (int sx, int yl, int yh)
{ {
BYTE *colormap; BYTE *colormap;
canvas_pixel_t *source; BYTE *source;
canvas_pixel_t *dest; BYTE *dest;
int count; int count;
int pitch; int pitch;
@ -227,7 +229,7 @@ void rt_map4cols_c (int sx, int yl, int yh)
void rt_Translate1col(const BYTE *translation, int hx, int yl, int yh) void rt_Translate1col(const BYTE *translation, int hx, int yl, int yh)
{ {
int count = yh - yl + 1; int count = yh - yl + 1;
canvas_pixel_t *source = &dc_temp[yl*4 + hx]; BYTE *source = &dc_temp[yl*4 + hx];
// Things we do to hit the compiler's optimizer with a clue bat: // Things we do to hit the compiler's optimizer with a clue bat:
// 1. Parallelism is explicitly spelled out by using a separate // 1. Parallelism is explicitly spelled out by using a separate
@ -274,7 +276,7 @@ void rt_Translate1col(const BYTE *translation, int hx, int yl, int yh)
void rt_Translate4cols(const BYTE *translation, int yl, int yh) void rt_Translate4cols(const BYTE *translation, int yl, int yh)
{ {
int count = yh - yl + 1; int count = yh - yl + 1;
canvas_pixel_t *source = &dc_temp[yl*4]; BYTE *source = &dc_temp[yl*4];
int c0, c1; int c0, c1;
BYTE b0, b1; BYTE b0, b1;
@ -330,8 +332,8 @@ void rt_tlate4cols_c (int sx, int yl, int yh)
void rt_add1col_c (int hx, int sx, int yl, int yh) void rt_add1col_c (int hx, int sx, int yl, int yh)
{ {
BYTE *colormap; BYTE *colormap;
canvas_pixel_t *source; BYTE *source;
canvas_pixel_t *dest; BYTE *dest;
int count; int count;
int pitch; int pitch;
@ -364,8 +366,8 @@ void rt_add1col_c (int hx, int sx, int yl, int yh)
void rt_add4cols_c (int sx, int yl, int yh) void rt_add4cols_c (int sx, int yl, int yh)
{ {
BYTE *colormap; BYTE *colormap;
canvas_pixel_t *source; BYTE *source;
canvas_pixel_t *dest; BYTE *dest;
int count; int count;
int pitch; int pitch;
@ -435,8 +437,8 @@ void rt_tlateadd4cols_c (int sx, int yl, int yh)
void rt_shaded1col_c (int hx, int sx, int yl, int yh) void rt_shaded1col_c (int hx, int sx, int yl, int yh)
{ {
BYTE *colormap; BYTE *colormap;
canvas_pixel_t *source; BYTE *source;
canvas_pixel_t *dest; BYTE *dest;
int count; int count;
int pitch; int pitch;
@ -467,8 +469,8 @@ void rt_shaded1col_c (int hx, int sx, int yl, int yh)
void rt_shaded4cols_c (int sx, int yl, int yh) void rt_shaded4cols_c (int sx, int yl, int yh)
{ {
BYTE *colormap; BYTE *colormap;
canvas_pixel_t *source; BYTE *source;
canvas_pixel_t *dest; BYTE *dest;
int count; int count;
int pitch; int pitch;
@ -513,8 +515,8 @@ void rt_shaded4cols_c (int sx, int yl, int yh)
void rt_addclamp1col_c (int hx, int sx, int yl, int yh) void rt_addclamp1col_c (int hx, int sx, int yl, int yh)
{ {
BYTE *colormap; BYTE *colormap;
canvas_pixel_t *source; BYTE *source;
canvas_pixel_t *dest; BYTE *dest;
int count; int count;
int pitch; int pitch;
@ -550,8 +552,8 @@ void rt_addclamp1col_c (int hx, int sx, int yl, int yh)
void rt_addclamp4cols_c (int sx, int yl, int yh) void rt_addclamp4cols_c (int sx, int yl, int yh)
{ {
BYTE *colormap; BYTE *colormap;
canvas_pixel_t *source; BYTE *source;
canvas_pixel_t *dest; BYTE *dest;
int count; int count;
int pitch; int pitch;
@ -629,8 +631,8 @@ void rt_tlateaddclamp4cols_c (int sx, int yl, int yh)
void rt_subclamp1col_c (int hx, int sx, int yl, int yh) void rt_subclamp1col_c (int hx, int sx, int yl, int yh)
{ {
BYTE *colormap; BYTE *colormap;
canvas_pixel_t *source; BYTE *source;
canvas_pixel_t *dest; BYTE *dest;
int count; int count;
int pitch; int pitch;
@ -664,8 +666,8 @@ void rt_subclamp1col_c (int hx, int sx, int yl, int yh)
void rt_subclamp4cols_c (int sx, int yl, int yh) void rt_subclamp4cols_c (int sx, int yl, int yh)
{ {
BYTE *colormap; BYTE *colormap;
canvas_pixel_t *source; BYTE *source;
canvas_pixel_t *dest; BYTE *dest;
int count; int count;
int pitch; int pitch;
@ -738,8 +740,8 @@ void rt_tlatesubclamp4cols_c (int sx, int yl, int yh)
void rt_revsubclamp1col_c (int hx, int sx, int yl, int yh) void rt_revsubclamp1col_c (int hx, int sx, int yl, int yh)
{ {
BYTE *colormap; BYTE *colormap;
canvas_pixel_t *source; BYTE *source;
canvas_pixel_t *dest; BYTE *dest;
int count; int count;
int pitch; int pitch;
@ -773,8 +775,8 @@ void rt_revsubclamp1col_c (int hx, int sx, int yl, int yh)
void rt_revsubclamp4cols_c (int sx, int yl, int yh) void rt_revsubclamp4cols_c (int sx, int yl, int yh)
{ {
BYTE *colormap; BYTE *colormap;
canvas_pixel_t *source; BYTE *source;
canvas_pixel_t *dest; BYTE *dest;
int count; int count;
int pitch; int pitch;
@ -1007,7 +1009,7 @@ void rt_draw4cols (int sx)
// Before each pass through a rendering loop that uses these routines, // Before each pass through a rendering loop that uses these routines,
// call this function to set up the span pointers. // call this function to set up the span pointers.
void rt_initcols_pal (canvas_pixel_t *buff) void rt_initcols_pal (BYTE *buff)
{ {
int y; int y;
@ -1021,7 +1023,7 @@ void rt_initcols_pal (canvas_pixel_t *buff)
void R_DrawColumnHorizP_C (void) void R_DrawColumnHorizP_C (void)
{ {
int count = dc_count; int count = dc_count;
canvas_pixel_t *dest; BYTE *dest;
fixed_t fracstep; fixed_t fracstep;
fixed_t frac; fixed_t frac;
@ -1082,7 +1084,7 @@ void R_FillColumnHorizP_C (void)
{ {
int count = dc_count; int count = dc_count;
BYTE color = dc_color; BYTE color = dc_color;
canvas_pixel_t *dest; BYTE *dest;
if (count <= 0) if (count <= 0)
return; return;
@ -1113,6 +1115,7 @@ void R_FillColumnHorizP_C (void)
void R_DrawMaskedColumnHoriz (const BYTE *column, const FTexture::Span *span) void R_DrawMaskedColumnHoriz (const BYTE *column, const FTexture::Span *span)
{ {
int pixelsize = r_swtruecolor ? 4 : 1;
const fixed_t texturemid = FLOAT2FIXED(dc_texturemid); const fixed_t texturemid = FLOAT2FIXED(dc_texturemid);
while (span->Length != 0) while (span->Length != 0)
{ {
@ -1182,7 +1185,7 @@ void R_DrawMaskedColumnHoriz (const BYTE *column, const FTexture::Span *span)
} }
} }
dc_source = column + top; dc_source = column + top;
dc_dest = ylookup[dc_yl] + dc_x + dc_destorg; dc_dest = (ylookup[dc_yl] + dc_x) * pixelsize + dc_destorg;
dc_count = dc_yh - dc_yl + 1; dc_count = dc_yh - dc_yl + 1;
hcolfunc_pre (); hcolfunc_pre ();
} }

View File

@ -43,8 +43,8 @@
#include "r_things.h" #include "r_things.h"
#include "v_video.h" #include "v_video.h"
canvas_pixel_t dc_temp_rgbabuff_rgba[MAXHEIGHT*4]; uint32_t dc_temp_rgbabuff_rgba[MAXHEIGHT*4];
canvas_pixel_t *dc_temp_rgba; uint32_t *dc_temp_rgba;
// Defined in r_draw_t.cpp: // Defined in r_draw_t.cpp:
extern unsigned int dc_tspans[4][MAXHEIGHT]; extern unsigned int dc_tspans[4][MAXHEIGHT];
@ -54,8 +54,8 @@ extern unsigned int *horizspan[4];
// Copies one span at hx to the screen at sx. // Copies one span at hx to the screen at sx.
void rt_copy1col_RGBA_c (int hx, int sx, int yl, int yh) void rt_copy1col_RGBA_c (int hx, int sx, int yl, int yh)
{ {
canvas_pixel_t *source; uint32_t *source;
canvas_pixel_t *dest; uint32_t *dest;
int count; int count;
int pitch; int pitch;
@ -64,7 +64,7 @@ void rt_copy1col_RGBA_c (int hx, int sx, int yl, int yh)
return; return;
count++; count++;
dest = ylookup[yl] + sx + dc_destorg; dest = ylookup[yl] + sx + (uint32_t*)dc_destorg;
source = &dc_temp_rgba[yl*4 + hx]; source = &dc_temp_rgba[yl*4 + hx];
pitch = dc_pitch; pitch = dc_pitch;
@ -106,8 +106,8 @@ void rt_copy4cols_RGBA_c (int sx, int yl, int yh)
void rt_map1col_RGBA_c (int hx, int sx, int yl, int yh) void rt_map1col_RGBA_c (int hx, int sx, int yl, int yh)
{ {
BYTE *colormap; BYTE *colormap;
canvas_pixel_t *source; uint32_t *source;
canvas_pixel_t *dest; uint32_t *dest;
int count; int count;
int pitch; int pitch;
@ -119,7 +119,7 @@ void rt_map1col_RGBA_c (int hx, int sx, int yl, int yh)
uint32_t light = calc_light_multiplier(dc_light); uint32_t light = calc_light_multiplier(dc_light);
colormap = dc_colormap; colormap = dc_colormap;
dest = ylookup[yl] + sx + dc_destorg; dest = ylookup[yl] + sx + (uint32_t*)dc_destorg;
source = &dc_temp_rgba[yl*4 + hx]; source = &dc_temp_rgba[yl*4 + hx];
pitch = dc_pitch; pitch = dc_pitch;
@ -143,8 +143,8 @@ void rt_map1col_RGBA_c (int hx, int sx, int yl, int yh)
void rt_map4cols_RGBA_c (int sx, int yl, int yh) void rt_map4cols_RGBA_c (int sx, int yl, int yh)
{ {
BYTE *colormap; BYTE *colormap;
canvas_pixel_t *source; uint32_t *source;
canvas_pixel_t *dest; uint32_t *dest;
int count; int count;
int pitch; int pitch;
@ -156,7 +156,7 @@ void rt_map4cols_RGBA_c (int sx, int yl, int yh)
uint32_t light = calc_light_multiplier(dc_light); uint32_t light = calc_light_multiplier(dc_light);
colormap = dc_colormap; colormap = dc_colormap;
dest = ylookup[yl] + sx + dc_destorg; dest = ylookup[yl] + sx + (uint32_t*)dc_destorg;
source = &dc_temp_rgba[yl*4]; source = &dc_temp_rgba[yl*4];
pitch = dc_pitch; pitch = dc_pitch;
@ -188,7 +188,7 @@ void rt_map4cols_RGBA_c (int sx, int yl, int yh)
void rt_Translate1col_RGBA_c(const BYTE *translation, int hx, int yl, int yh) void rt_Translate1col_RGBA_c(const BYTE *translation, int hx, int yl, int yh)
{ {
int count = yh - yl + 1; int count = yh - yl + 1;
canvas_pixel_t *source = &dc_temp_rgba[yl*4 + hx]; uint32_t *source = &dc_temp_rgba[yl*4 + hx];
// Things we do to hit the compiler's optimizer with a clue bat: // Things we do to hit the compiler's optimizer with a clue bat:
// 1. Parallelism is explicitly spelled out by using a separate // 1. Parallelism is explicitly spelled out by using a separate
@ -235,7 +235,7 @@ void rt_Translate1col_RGBA_c(const BYTE *translation, int hx, int yl, int yh)
void rt_Translate4cols_RGBA_c(const BYTE *translation, int yl, int yh) void rt_Translate4cols_RGBA_c(const BYTE *translation, int yl, int yh)
{ {
int count = yh - yl + 1; int count = yh - yl + 1;
canvas_pixel_t *source = &dc_temp_rgba[yl*4]; uint32_t *source = &dc_temp_rgba[yl*4];
int c0, c1; int c0, c1;
BYTE b0, b1; BYTE b0, b1;
@ -291,8 +291,8 @@ void rt_tlate4cols_RGBA_c (int sx, int yl, int yh)
void rt_add1col_RGBA_c (int hx, int sx, int yl, int yh) void rt_add1col_RGBA_c (int hx, int sx, int yl, int yh)
{ {
BYTE *colormap; BYTE *colormap;
canvas_pixel_t *source; uint32_t *source;
canvas_pixel_t *dest; uint32_t *dest;
int count; int count;
int pitch; int pitch;
@ -301,7 +301,7 @@ void rt_add1col_RGBA_c (int hx, int sx, int yl, int yh)
return; return;
count++; count++;
dest = ylookup[yl] + sx + dc_destorg; dest = ylookup[yl] + sx + (uint32_t*)dc_destorg;
source = &dc_temp_rgba[yl*4 + hx]; source = &dc_temp_rgba[yl*4 + hx];
pitch = dc_pitch; pitch = dc_pitch;
colormap = dc_colormap; colormap = dc_colormap;
@ -333,8 +333,8 @@ void rt_add1col_RGBA_c (int hx, int sx, int yl, int yh)
void rt_add4cols_RGBA_c (int sx, int yl, int yh) void rt_add4cols_RGBA_c (int sx, int yl, int yh)
{ {
BYTE *colormap; BYTE *colormap;
canvas_pixel_t *source; uint32_t *source;
canvas_pixel_t *dest; uint32_t *dest;
int count; int count;
int pitch; int pitch;
@ -343,7 +343,7 @@ void rt_add4cols_RGBA_c (int sx, int yl, int yh)
return; return;
count++; count++;
dest = ylookup[yl] + sx + dc_destorg; dest = ylookup[yl] + sx + (uint32_t*)dc_destorg;
source = &dc_temp_rgba[yl*4]; source = &dc_temp_rgba[yl*4];
pitch = dc_pitch; pitch = dc_pitch;
colormap = dc_colormap; colormap = dc_colormap;
@ -392,8 +392,8 @@ void rt_tlateadd4cols_RGBA_c(int sx, int yl, int yh)
void rt_shaded1col_RGBA_c (int hx, int sx, int yl, int yh) void rt_shaded1col_RGBA_c (int hx, int sx, int yl, int yh)
{ {
BYTE *colormap; BYTE *colormap;
canvas_pixel_t *source; uint32_t *source;
canvas_pixel_t *dest; uint32_t *dest;
int count; int count;
int pitch; int pitch;
@ -403,7 +403,7 @@ void rt_shaded1col_RGBA_c (int hx, int sx, int yl, int yh)
count++; count++;
colormap = dc_colormap; colormap = dc_colormap;
dest = ylookup[yl] + sx + dc_destorg; dest = ylookup[yl] + sx + (uint32_t*)dc_destorg;
source = &dc_temp_rgba[yl*4 + hx]; source = &dc_temp_rgba[yl*4 + hx];
pitch = dc_pitch; pitch = dc_pitch;
@ -434,8 +434,8 @@ void rt_shaded1col_RGBA_c (int hx, int sx, int yl, int yh)
void rt_shaded4cols_RGBA_c (int sx, int yl, int yh) void rt_shaded4cols_RGBA_c (int sx, int yl, int yh)
{ {
BYTE *colormap; BYTE *colormap;
canvas_pixel_t *source; uint32_t *source;
canvas_pixel_t *dest; uint32_t *dest;
int count; int count;
int pitch; int pitch;
@ -445,7 +445,7 @@ void rt_shaded4cols_RGBA_c (int sx, int yl, int yh)
count++; count++;
colormap = dc_colormap; colormap = dc_colormap;
dest = ylookup[yl] + sx + dc_destorg; dest = ylookup[yl] + sx + (uint32_t*)dc_destorg;
source = &dc_temp_rgba[yl*4]; source = &dc_temp_rgba[yl*4];
pitch = dc_pitch; pitch = dc_pitch;
@ -479,8 +479,8 @@ void rt_shaded4cols_RGBA_c (int sx, int yl, int yh)
void rt_addclamp1col_RGBA_c (int hx, int sx, int yl, int yh) void rt_addclamp1col_RGBA_c (int hx, int sx, int yl, int yh)
{ {
BYTE *colormap; BYTE *colormap;
canvas_pixel_t *source; uint32_t *source;
canvas_pixel_t *dest; uint32_t *dest;
int count; int count;
int pitch; int pitch;
@ -489,7 +489,7 @@ void rt_addclamp1col_RGBA_c (int hx, int sx, int yl, int yh)
return; return;
count++; count++;
dest = ylookup[yl] + sx + dc_destorg; dest = ylookup[yl] + sx + (uint32_t*)dc_destorg;
source = &dc_temp_rgba[yl*4 + hx]; source = &dc_temp_rgba[yl*4 + hx];
pitch = dc_pitch; pitch = dc_pitch;
colormap = dc_colormap; colormap = dc_colormap;
@ -520,8 +520,8 @@ void rt_addclamp1col_RGBA_c (int hx, int sx, int yl, int yh)
void rt_addclamp4cols_RGBA_c (int sx, int yl, int yh) void rt_addclamp4cols_RGBA_c (int sx, int yl, int yh)
{ {
BYTE *colormap; BYTE *colormap;
canvas_pixel_t *source; uint32_t *source;
canvas_pixel_t *dest; uint32_t *dest;
int count; int count;
int pitch; int pitch;
@ -530,7 +530,7 @@ void rt_addclamp4cols_RGBA_c (int sx, int yl, int yh)
return; return;
count++; count++;
dest = ylookup[yl] + sx + dc_destorg; dest = ylookup[yl] + sx + (uint32_t*)dc_destorg;
source = &dc_temp_rgba[yl*4]; source = &dc_temp_rgba[yl*4];
pitch = dc_pitch; pitch = dc_pitch;
colormap = dc_colormap; colormap = dc_colormap;
@ -578,8 +578,8 @@ void rt_tlateaddclamp4cols_RGBA_c (int sx, int yl, int yh)
void rt_subclamp1col_RGBA_c (int hx, int sx, int yl, int yh) void rt_subclamp1col_RGBA_c (int hx, int sx, int yl, int yh)
{ {
BYTE *colormap; BYTE *colormap;
canvas_pixel_t *source; uint32_t *source;
canvas_pixel_t *dest; uint32_t *dest;
int count; int count;
int pitch; int pitch;
@ -588,7 +588,7 @@ void rt_subclamp1col_RGBA_c (int hx, int sx, int yl, int yh)
return; return;
count++; count++;
dest = ylookup[yl] + sx + dc_destorg; dest = ylookup[yl] + sx + (uint32_t*)dc_destorg;
source = &dc_temp_rgba[yl*4 + hx]; source = &dc_temp_rgba[yl*4 + hx];
pitch = dc_pitch; pitch = dc_pitch;
colormap = dc_colormap; colormap = dc_colormap;
@ -619,8 +619,8 @@ void rt_subclamp1col_RGBA_c (int hx, int sx, int yl, int yh)
void rt_subclamp4cols_RGBA_c (int sx, int yl, int yh) void rt_subclamp4cols_RGBA_c (int sx, int yl, int yh)
{ {
BYTE *colormap; BYTE *colormap;
canvas_pixel_t *source; uint32_t *source;
canvas_pixel_t *dest; uint32_t *dest;
int count; int count;
int pitch; int pitch;
@ -629,7 +629,7 @@ void rt_subclamp4cols_RGBA_c (int sx, int yl, int yh)
return; return;
count++; count++;
dest = ylookup[yl] + sx + dc_destorg; dest = ylookup[yl] + sx + (uint32_t*)dc_destorg;
source = &dc_temp_rgba[yl*4]; source = &dc_temp_rgba[yl*4];
pitch = dc_pitch; pitch = dc_pitch;
colormap = dc_colormap; colormap = dc_colormap;
@ -678,8 +678,8 @@ void rt_tlatesubclamp4cols_RGBA_c (int sx, int yl, int yh)
void rt_revsubclamp1col_RGBA_c (int hx, int sx, int yl, int yh) void rt_revsubclamp1col_RGBA_c (int hx, int sx, int yl, int yh)
{ {
BYTE *colormap; BYTE *colormap;
canvas_pixel_t *source; uint32_t *source;
canvas_pixel_t *dest; uint32_t *dest;
int count; int count;
int pitch; int pitch;
@ -690,7 +690,7 @@ void rt_revsubclamp1col_RGBA_c (int hx, int sx, int yl, int yh)
DWORD *fg2rgb = dc_srcblend; DWORD *fg2rgb = dc_srcblend;
DWORD *bg2rgb = dc_destblend; DWORD *bg2rgb = dc_destblend;
dest = ylookup[yl] + sx + dc_destorg; dest = ylookup[yl] + sx + (uint32_t*)dc_destorg;
source = &dc_temp_rgba[yl*4 + hx]; source = &dc_temp_rgba[yl*4 + hx];
pitch = dc_pitch; pitch = dc_pitch;
colormap = dc_colormap; colormap = dc_colormap;
@ -721,8 +721,8 @@ void rt_revsubclamp1col_RGBA_c (int hx, int sx, int yl, int yh)
void rt_revsubclamp4cols_RGBA_c (int sx, int yl, int yh) void rt_revsubclamp4cols_RGBA_c (int sx, int yl, int yh)
{ {
BYTE *colormap; BYTE *colormap;
canvas_pixel_t *source; uint32_t *source;
canvas_pixel_t *dest; uint32_t *dest;
int count; int count;
int pitch; int pitch;
@ -733,7 +733,7 @@ void rt_revsubclamp4cols_RGBA_c (int sx, int yl, int yh)
DWORD *fg2rgb = dc_srcblend; DWORD *fg2rgb = dc_srcblend;
DWORD *bg2rgb = dc_destblend; DWORD *bg2rgb = dc_destblend;
dest = ylookup[yl] + sx + dc_destorg; dest = ylookup[yl] + sx + (uint32_t*)dc_destorg;
source = &dc_temp_rgba[yl*4]; source = &dc_temp_rgba[yl*4];
pitch = dc_pitch; pitch = dc_pitch;
colormap = dc_colormap; colormap = dc_colormap;
@ -780,11 +780,11 @@ void rt_tlaterevsubclamp4cols_RGBA_c (int sx, int yl, int yh)
// Before each pass through a rendering loop that uses these routines, // Before each pass through a rendering loop that uses these routines,
// call this function to set up the span pointers. // call this function to set up the span pointers.
void rt_initcols_rgba (canvas_pixel_t *buff) void rt_initcols_rgba (BYTE *buff)
{ {
int y; int y;
dc_temp_rgba = buff == NULL ? dc_temp_rgbabuff_rgba : buff; dc_temp_rgba = buff == NULL ? dc_temp_rgbabuff_rgba : (uint32_t*)buff;
for (y = 3; y >= 0; y--) for (y = 3; y >= 0; y--)
horizspan[y] = dc_ctspan[y] = &dc_tspans[y][0]; horizspan[y] = dc_ctspan[y] = &dc_tspans[y][0];
} }
@ -794,7 +794,7 @@ void rt_initcols_rgba (canvas_pixel_t *buff)
void R_DrawColumnHorizP_RGBA_C (void) void R_DrawColumnHorizP_RGBA_C (void)
{ {
int count = dc_count; int count = dc_count;
canvas_pixel_t *dest; uint32_t *dest;
fixed_t fracstep; fixed_t fracstep;
fixed_t frac; fixed_t frac;
@ -855,7 +855,7 @@ void R_FillColumnHorizP_RGBA_C (void)
{ {
int count = dc_count; int count = dc_count;
BYTE color = dc_color; BYTE color = dc_color;
canvas_pixel_t *dest; uint32_t *dest;
if (count <= 0) if (count <= 0)
return; return;

View File

@ -577,9 +577,12 @@ void R_HighlightPortal (PortalDrawseg* pds)
// [ZZ] NO OVERFLOW CHECKS HERE // [ZZ] NO OVERFLOW CHECKS HERE
// I believe it won't break. if it does, blame me. :( // I believe it won't break. if it does, blame me. :(
if (r_swtruecolor) // Assuming this is just a debug function
return;
BYTE color = (BYTE)BestColor((DWORD *)GPalette.BaseColors, 255, 0, 0, 0, 255); BYTE color = (BYTE)BestColor((DWORD *)GPalette.BaseColors, 255, 0, 0, 0, 255);
canvas_pixel_t* pixels = RenderTarget->GetBuffer(); BYTE* pixels = RenderTarget->GetBuffer();
// top edge // top edge
for (int x = pds->x1; x < pds->x2; x++) for (int x = pds->x1; x < pds->x2; x++)
{ {
@ -624,12 +627,26 @@ void R_EnterPortal (PortalDrawseg* pds, int depth)
int Ytop = pds->ceilingclip[x-pds->x1]; int Ytop = pds->ceilingclip[x-pds->x1];
int Ybottom = pds->floorclip[x-pds->x1]; int Ybottom = pds->floorclip[x-pds->x1];
canvas_pixel_t *dest = RenderTarget->GetBuffer() + x + Ytop * spacing; if (r_swtruecolor)
for (int y = Ytop; y <= Ybottom; y++)
{ {
*dest = color; uint32_t *dest = (uint32_t*)RenderTarget->GetBuffer() + x + Ytop * spacing;
dest += spacing;
uint32_t c = GPalette.BaseColors[color].d;
for (int y = Ytop; y <= Ybottom; y++)
{
*dest = c;
dest += spacing;
}
}
else
{
BYTE *dest = RenderTarget->GetBuffer() + x + Ytop * spacing;
for (int y = Ytop; y <= Ybottom; y++)
{
*dest = color;
dest += spacing;
}
} }
} }
@ -795,10 +812,11 @@ void R_EnterPortal (PortalDrawseg* pds, int depth)
void R_SetupBuffer () void R_SetupBuffer ()
{ {
static canvas_pixel_t *lastbuff = NULL; static BYTE *lastbuff = NULL;
int pitch = RenderTarget->GetPitch(); int pitch = RenderTarget->GetPitch();
canvas_pixel_t *lineptr = RenderTarget->GetBuffer() + viewwindowy*pitch + viewwindowx; int pixelsize = r_swtruecolor ? 4 : 1;
BYTE *lineptr = RenderTarget->GetBuffer() + (viewwindowy*pitch + viewwindowx) * pixelsize;
if (dc_pitch != pitch || lineptr != lastbuff) if (dc_pitch != pitch || lineptr != lastbuff)
{ {

View File

@ -354,12 +354,12 @@ void R_CalcTiltedLighting (double lval, double lend, int width)
// //
//========================================================================== //==========================================================================
void R_MapTiltedPlane (int y, int x1) void R_MapTiltedPlane_C (int y, int x1)
{ {
int x2 = spanend[y]; int x2 = spanend[y];
int width = x2 - x1; int width = x2 - x1;
double iz, uz, vz; double iz, uz, vz;
canvas_pixel_t *fb; BYTE *fb;
DWORD u, v; DWORD u, v;
int i; int i;
@ -478,6 +478,130 @@ void R_MapTiltedPlane (int y, int x1)
#endif #endif
} }
void R_MapTiltedPlane_RGBA (int y, int x1)
{
int x2 = spanend[y];
int width = x2 - x1;
double iz, uz, vz;
uint32_t *fb;
DWORD u, v;
int i;
iz = plane_sz[2] + plane_sz[1]*(centery-y) + plane_sz[0]*(x1-centerx);
// Lighting is simple. It's just linear interpolation from start to end
if (plane_shade)
{
uz = (iz + plane_sz[0]*width) * planelightfloat;
vz = iz * planelightfloat;
R_CalcTiltedLighting (vz, uz, width);
}
uz = plane_su[2] + plane_su[1]*(centery-y) + plane_su[0]*(x1-centerx);
vz = plane_sv[2] + plane_sv[1]*(centery-y) + plane_sv[0]*(x1-centerx);
fb = ylookup[y] + x1 + (uint32_t*)dc_destorg;
BYTE vshift = 32 - ds_ybits;
BYTE ushift = vshift - ds_xbits;
int umask = ((1 << ds_xbits) - 1) << ds_ybits;
#if 0 // The "perfect" reference version of this routine. Pretty slow.
// Use it only to see how things are supposed to look.
i = 0;
do
{
double z = 1.f/iz;
u = SQWORD(uz*z) + pviewx;
v = SQWORD(vz*z) + pviewy;
ds_colormap = tiltlighting[i];
ds_light = 0;
fb[i++] = ds_colormap[ds_source[(v >> vshift) | ((u >> ushift) & umask)]];
iz += plane_sz[0];
uz += plane_su[0];
vz += plane_sv[0];
} while (--width >= 0);
#else
//#define SPANSIZE 32
//#define INVSPAN 0.03125f
//#define SPANSIZE 8
//#define INVSPAN 0.125f
#define SPANSIZE 16
#define INVSPAN 0.0625f
double startz = 1.f/iz;
double startu = uz*startz;
double startv = vz*startz;
double izstep, uzstep, vzstep;
izstep = plane_sz[0] * SPANSIZE;
uzstep = plane_su[0] * SPANSIZE;
vzstep = plane_sv[0] * SPANSIZE;
x1 = 0;
width++;
while (width >= SPANSIZE)
{
iz += izstep;
uz += uzstep;
vz += vzstep;
double endz = 1.f/iz;
double endu = uz*endz;
double endv = vz*endz;
DWORD stepu = SQWORD((endu - startu) * INVSPAN);
DWORD stepv = SQWORD((endv - startv) * INVSPAN);
u = SQWORD(startu) + pviewx;
v = SQWORD(startv) + pviewy;
for (i = SPANSIZE-1; i >= 0; i--)
{
fb[x1] = *(tiltlighting[x1] + ds_source[(v >> vshift) | ((u >> ushift) & umask)]);
x1++;
u += stepu;
v += stepv;
}
startu = endu;
startv = endv;
width -= SPANSIZE;
}
if (width > 0)
{
if (width == 1)
{
u = SQWORD(startu);
v = SQWORD(startv);
fb[x1] = *(tiltlighting[x1] + ds_source[(v >> vshift) | ((u >> ushift) & umask)]);
}
else
{
double left = width;
iz += plane_sz[0] * left;
uz += plane_su[0] * left;
vz += plane_sv[0] * left;
double endz = 1.f/iz;
double endu = uz*endz;
double endv = vz*endz;
left = 1.f/left;
DWORD stepu = SQWORD((endu - startu) * left);
DWORD stepv = SQWORD((endv - startv) * left);
u = SQWORD(startu) + pviewx;
v = SQWORD(startv) + pviewy;
for (; width != 0; width--)
{
fb[x1] = *(tiltlighting[x1] + ds_source[(v >> vshift) | ((u >> ushift) & umask)]);
x1++;
u += stepu;
v += stepv;
}
}
}
#endif
}
//========================================================================== //==========================================================================
// //
// R_MapColoredPlane // R_MapColoredPlane
@ -491,7 +615,7 @@ void R_MapColoredPlane_C (int y, int x1)
void R_MapColoredPlane_RGBA(int y, int x1) void R_MapColoredPlane_RGBA(int y, int x1)
{ {
canvas_pixel_t *dest = ylookup[y] + x1 + dc_destorg; uint32_t *dest = ylookup[y] + x1 + (uint32_t*)dc_destorg;
int count = (spanend[y] - x1 + 1); int count = (spanend[y] - x1 + 1);
uint32_t light = calc_light_multiplier(ds_light); uint32_t light = calc_light_multiplier(ds_light);
uint32_t color = shade_pal_index(ds_color, light); uint32_t color = shade_pal_index(ds_color, light);

View File

@ -94,6 +94,10 @@ void R_DrawTiltedPlane (visplane_t *pl, double xscale, double yscale, fixed_t al
void R_MapVisPlane (visplane_t *pl, void (*mapfunc)(int y, int x1)); void R_MapVisPlane (visplane_t *pl, void (*mapfunc)(int y, int x1));
extern void(*R_MapColoredPlane)(int y, int x1); extern void(*R_MapColoredPlane)(int y, int x1);
extern void(*R_MapTiltedPlane)(int y, int x1);
void R_MapTiltedPlane_C(int y, int x1);
void R_MapTiltedPlane_RGBA(int y, int x);
void R_MapColoredPlane_C(int y, int x1); void R_MapColoredPlane_C(int y, int x1);
void R_MapColoredPlane_RGBA(int y, int x1); void R_MapColoredPlane_RGBA(int y, int x1);

View File

@ -1071,7 +1071,7 @@ void R_RenderFakeWallRange (drawseg_t *ds, int x1, int x2)
} }
// prevlineasm1 is like vlineasm1 but skips the loop if only drawing one pixel // prevlineasm1 is like vlineasm1 but skips the loop if only drawing one pixel
inline fixed_t prevline1 (fixed_t vince, BYTE *colormap, fixed_t light, int count, fixed_t vplce, const BYTE *bufplce, canvas_pixel_t *dest) inline fixed_t prevline1 (fixed_t vince, BYTE *colormap, fixed_t light, int count, fixed_t vplce, const BYTE *bufplce, BYTE *dest)
{ {
dc_iscale = vince; dc_iscale = vince;
dc_colormap = colormap; dc_colormap = colormap;
@ -1107,6 +1107,8 @@ void wallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *l
//extern cycle_t WallScanCycles; //extern cycle_t WallScanCycles;
//clock (WallScanCycles); //clock (WallScanCycles);
int pixelsize = r_swtruecolor ? 4 : 1;
rw_pic->GetHeight(); // Make sure texture size is loaded rw_pic->GetHeight(); // Make sure texture size is loaded
fracbits = 32 - rw_pic->HeightBits; fracbits = 32 - rw_pic->HeightBits;
setupvline(fracbits); setupvline(fracbits);
@ -1144,7 +1146,7 @@ void wallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *l
} }
dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS);
dc_dest = ylookup[y1ve[0]] + x + dc_destorg; dc_dest = (ylookup[y1ve[0]] + x)*pixelsize + dc_destorg;
dc_count = y2ve[0] - y1ve[0]; dc_count = y2ve[0] - y1ve[0];
iscale = swal[x] * yrepeat; iscale = swal[x] * yrepeat;
dc_iscale = xs_ToFixed(fracbits, iscale); dc_iscale = xs_ToFixed(fracbits, iscale);
@ -1202,7 +1204,7 @@ void wallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *l
{ {
if (!(bad & 1)) if (!(bad & 1))
{ {
prevline1(vince[z],palookupoffse[z],palookuplight[z],y2ve[z]-y1ve[z],vplce[z],bufplce[z],ylookup[y1ve[z]]+x+z+dc_destorg); prevline1(vince[z],palookupoffse[z],palookuplight[z],y2ve[z]-y1ve[z],vplce[z],bufplce[z],(ylookup[y1ve[z]]+x+z)*pixelsize+dc_destorg);
} }
bad >>= 1; bad >>= 1;
} }
@ -1213,23 +1215,23 @@ void wallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *l
{ {
if (u4 > y1ve[z]) if (u4 > y1ve[z])
{ {
vplce[z] = prevline1(vince[z],palookupoffse[z], palookuplight[z],u4-y1ve[z],vplce[z],bufplce[z],ylookup[y1ve[z]]+x+z+dc_destorg); vplce[z] = prevline1(vince[z],palookupoffse[z], palookuplight[z],u4-y1ve[z],vplce[z],bufplce[z],(ylookup[y1ve[z]]+x+z)*pixelsize+dc_destorg);
} }
} }
if (d4 > u4) if (d4 > u4)
{ {
dc_count = d4-u4; dc_count = d4-u4;
dc_dest = ylookup[u4]+x+dc_destorg; dc_dest = (ylookup[u4]+x)*pixelsize+dc_destorg;
dovline4(); dovline4();
} }
canvas_pixel_t *i = x+ylookup[d4]+dc_destorg; BYTE *i = (x+ylookup[d4])*pixelsize+dc_destorg;
for (z = 0; z < 4; ++z) for (z = 0; z < 4; ++z)
{ {
if (y2ve[z] > d4) if (y2ve[z] > d4)
{ {
prevline1(vince[z],palookupoffse[0],palookuplight[0],y2ve[z]-d4,vplce[z],bufplce[z],i+z); prevline1(vince[z],palookupoffse[0],palookuplight[0],y2ve[z]-d4,vplce[z],bufplce[z],i+z*pixelsize);
} }
} }
} }
@ -1248,7 +1250,7 @@ void wallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *l
} }
dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS);
dc_dest = ylookup[y1ve[0]] + x + dc_destorg; dc_dest = (ylookup[y1ve[0]] + x) * pixelsize + dc_destorg;
dc_count = y2ve[0] - y1ve[0]; dc_count = y2ve[0] - y1ve[0];
iscale = swal[x] * yrepeat; iscale = swal[x] * yrepeat;
dc_iscale = xs_ToFixed(fracbits, iscale); dc_iscale = xs_ToFixed(fracbits, iscale);
@ -1435,7 +1437,7 @@ static void wallscan_np2_ds(drawseg_t *ds, int x1, int x2, short *uwal, short *d
} }
} }
inline fixed_t mvline1 (fixed_t vince, BYTE *colormap, int count, fixed_t vplce, const BYTE *bufplce, canvas_pixel_t *dest) inline fixed_t mvline1 (fixed_t vince, BYTE *colormap, int count, fixed_t vplce, const BYTE *bufplce, BYTE *dest)
{ {
dc_iscale = vince; dc_iscale = vince;
dc_colormap = colormap; dc_colormap = colormap;
@ -1451,7 +1453,8 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_
double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x)) double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x))
{ {
int x, fracbits; int x, fracbits;
canvas_pixel_t *p; BYTE *pixel;
int pixelsize, pixelshift;
int y1ve[4], y2ve[4], u4, d4, startx, dax, z; int y1ve[4], y2ve[4], u4, d4, startx, dax, z;
char bad; char bad;
float light = rw_light - rw_lightstep; float light = rw_light - rw_lightstep;
@ -1473,6 +1476,9 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_
//extern cycle_t WallScanCycles; //extern cycle_t WallScanCycles;
//clock (WallScanCycles); //clock (WallScanCycles);
pixelsize = r_swtruecolor ? 4 : 1;
pixelshift = r_swtruecolor ? 2 : 0;
rw_pic->GetHeight(); // Make sure texture size is loaded rw_pic->GetHeight(); // Make sure texture size is loaded
fracbits = 32- rw_pic->HeightBits; fracbits = 32- rw_pic->HeightBits;
setupmvline(fracbits); setupmvline(fracbits);
@ -1480,7 +1486,7 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_
basecolormapdata = basecolormap->Maps; basecolormapdata = basecolormap->Maps;
x = startx = x1; x = startx = x1;
p = x + dc_destorg; pixel = x * pixelsize + dc_destorg;
bool fixed = (fixedcolormap != NULL || fixedlightlev >= 0); bool fixed = (fixedcolormap != NULL || fixedlightlev >= 0);
if (fixed) if (fixed)
@ -1489,9 +1495,13 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_
palookupoffse[1] = dc_colormap; palookupoffse[1] = dc_colormap;
palookupoffse[2] = dc_colormap; palookupoffse[2] = dc_colormap;
palookupoffse[3] = dc_colormap; palookupoffse[3] = dc_colormap;
palookuplight[0] = 0;
palookuplight[1] = 0;
palookuplight[2] = 0;
palookuplight[3] = 0;
} }
for(; (x < x2) && (((size_t)p/sizeof(canvas_pixel_t)) & 3); ++x, ++p) for(; (x < x2) && (((size_t)pixel >> pixelshift) & 3); ++x, pixel += pixelsize)
{ {
light += rw_lightstep; light += rw_lightstep;
y1ve[0] = uwal[x];//max(uwal[x],umost[x]); y1ve[0] = uwal[x];//max(uwal[x],umost[x]);
@ -1505,7 +1515,7 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_
} }
dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS);
dc_dest = ylookup[y1ve[0]] + p; dc_dest = ylookup[y1ve[0]] * pixelsize + pixel;
dc_count = y2ve[0] - y1ve[0]; dc_count = y2ve[0] - y1ve[0];
iscale = swal[x] * yrepeat; iscale = swal[x] * yrepeat;
dc_iscale = xs_ToFixed(fracbits, iscale); dc_iscale = xs_ToFixed(fracbits, iscale);
@ -1514,7 +1524,7 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_
domvline1(); domvline1();
} }
for(; x < x2-3; x += 4, p+= 4) for(; x < x2-3; x += 4, pixel += 4 * pixelsize)
{ {
bad = 0; bad = 0;
for (z = 3, dax = x+3; z >= 0; --z, --dax) for (z = 3, dax = x+3; z >= 0; --z, --dax)
@ -1539,7 +1549,16 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_
for (z = 0; z < 4; ++z) for (z = 0; z < 4; ++z)
{ {
light += rw_lightstep; light += rw_lightstep;
palookupoffse[z] = basecolormapdata + (GETPALOOKUP (light, wallshade) << COLORMAPSHIFT); if (r_swtruecolor)
{
palookupoffse[z] = basecolormapdata;
palookuplight[z] = LIGHTSCALE(light, wallshade);
}
else
{
palookupoffse[z] = basecolormapdata + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT);
palookuplight[z] = 0;
}
} }
} }
@ -1552,7 +1571,7 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_
{ {
if (!(bad & 1)) if (!(bad & 1))
{ {
mvline1(vince[z],palookupoffse[z],y2ve[z]-y1ve[z],vplce[z],bufplce[z],ylookup[y1ve[z]]+p+z); mvline1(vince[z],palookupoffse[z],y2ve[z]-y1ve[z],vplce[z],bufplce[z],(ylookup[y1ve[z]]+z)*pixelsize+pixel);
} }
bad >>= 1; bad >>= 1;
} }
@ -1563,27 +1582,27 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_
{ {
if (u4 > y1ve[z]) if (u4 > y1ve[z])
{ {
vplce[z] = mvline1(vince[z],palookupoffse[z],u4-y1ve[z],vplce[z],bufplce[z],ylookup[y1ve[z]]+p+z); vplce[z] = mvline1(vince[z],palookupoffse[z],u4-y1ve[z],vplce[z],bufplce[z],(ylookup[y1ve[z]]+z)*pixelsize+pixel);
} }
} }
if (d4 > u4) if (d4 > u4)
{ {
dc_count = d4-u4; dc_count = d4-u4;
dc_dest = ylookup[u4]+p; dc_dest = ylookup[u4]*pixelsize+pixel;
domvline4(); domvline4();
} }
canvas_pixel_t *i = p+ylookup[d4]; BYTE *i = pixel+ylookup[d4]*pixelsize;
for (z = 0; z < 4; ++z) for (z = 0; z < 4; ++z)
{ {
if (y2ve[z] > d4) if (y2ve[z] > d4)
{ {
mvline1(vince[z],palookupoffse[0],y2ve[z]-d4,vplce[z],bufplce[z],i+z); mvline1(vince[z],palookupoffse[0],y2ve[z]-d4,vplce[z],bufplce[z],i+z*pixelsize);
} }
} }
} }
for(; x < x2; ++x, ++p) for(; x < x2; ++x, pixel += pixelsize)
{ {
light += rw_lightstep; light += rw_lightstep;
y1ve[0] = uwal[x]; y1ve[0] = uwal[x];
@ -1597,7 +1616,7 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_
} }
dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS);
dc_dest = ylookup[y1ve[0]] + p; dc_dest = ylookup[y1ve[0]]*pixelsize + pixel;
dc_count = y2ve[0] - y1ve[0]; dc_count = y2ve[0] - y1ve[0];
iscale = swal[x] * yrepeat; iscale = swal[x] * yrepeat;
dc_iscale = xs_ToFixed(fracbits, iscale); dc_iscale = xs_ToFixed(fracbits, iscale);
@ -1611,7 +1630,7 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_
NetUpdate (); NetUpdate ();
} }
inline void preptmvline1 (fixed_t vince, BYTE *colormap, fixed_t light, int count, fixed_t vplce, const BYTE *bufplce, canvas_pixel_t *dest) inline void preptmvline1 (fixed_t vince, BYTE *colormap, fixed_t light, int count, fixed_t vplce, const BYTE *bufplce, BYTE *dest)
{ {
dc_iscale = vince; dc_iscale = vince;
dc_colormap = colormap; dc_colormap = colormap;
@ -1628,7 +1647,8 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f
fixed_t (*tmvline1)(); fixed_t (*tmvline1)();
void (*tmvline4)(); void (*tmvline4)();
int x, fracbits; int x, fracbits;
canvas_pixel_t *p; BYTE *pixel;
int pixelsize, pixelshift;
int y1ve[4], y2ve[4], u4, d4, startx, dax, z; int y1ve[4], y2ve[4], u4, d4, startx, dax, z;
char bad; char bad;
float light = rw_light - rw_lightstep; float light = rw_light - rw_lightstep;
@ -1651,6 +1671,9 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f
//extern cycle_t WallScanCycles; //extern cycle_t WallScanCycles;
//clock (WallScanCycles); //clock (WallScanCycles);
pixelsize = r_swtruecolor ? 4 : 1;
pixelshift = r_swtruecolor ? 2 : 0;
rw_pic->GetHeight(); // Make sure texture size is loaded rw_pic->GetHeight(); // Make sure texture size is loaded
fracbits = 32 - rw_pic->HeightBits; fracbits = 32 - rw_pic->HeightBits;
setuptmvline(fracbits); setuptmvline(fracbits);
@ -1659,7 +1682,7 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f
fixed_t centeryfrac = FLOAT2FIXED(CenterY); fixed_t centeryfrac = FLOAT2FIXED(CenterY);
x = startx = x1; x = startx = x1;
p = x + dc_destorg; pixel = x * pixelsize + dc_destorg;
bool fixed = (fixedcolormap != NULL || fixedlightlev >= 0); bool fixed = (fixedcolormap != NULL || fixedlightlev >= 0);
if (fixed) if (fixed)
@ -1674,7 +1697,7 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f
palookuplight[3] = 0; palookuplight[3] = 0;
} }
for(; (x < x2) && (((size_t)p / sizeof(canvas_pixel_t)) & 3); ++x, ++p) for(; (x < x2) && (((size_t)pixel >> pixelshift) & 3); ++x, pixel += pixelsize)
{ {
light += rw_lightstep; light += rw_lightstep;
y1ve[0] = uwal[x];//max(uwal[x],umost[x]); y1ve[0] = uwal[x];//max(uwal[x],umost[x]);
@ -1687,7 +1710,7 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f
} }
dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS);
dc_dest = ylookup[y1ve[0]] + p; dc_dest = ylookup[y1ve[0]] * pixelsize + pixel;
dc_count = y2ve[0] - y1ve[0]; dc_count = y2ve[0] - y1ve[0];
iscale = swal[x] * yrepeat; iscale = swal[x] * yrepeat;
dc_iscale = xs_ToFixed(fracbits, iscale); dc_iscale = xs_ToFixed(fracbits, iscale);
@ -1696,7 +1719,7 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f
tmvline1(); tmvline1();
} }
for(; x < x2-3; x += 4, p+= 4) for(; x < x2-3; x += 4, pixel += 4 * pixelsize)
{ {
bad = 0; bad = 0;
for (z = 3, dax = x+3; z >= 0; --z, --dax) for (z = 3, dax = x+3; z >= 0; --z, --dax)
@ -1742,7 +1765,7 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f
{ {
if (!(bad & 1)) if (!(bad & 1))
{ {
preptmvline1(vince[z],palookupoffse[z],palookuplight[z],y2ve[z]-y1ve[z],vplce[z],bufplce[z],ylookup[y1ve[z]]+p+z); preptmvline1(vince[z],palookupoffse[z],palookuplight[z],y2ve[z]-y1ve[z],vplce[z],bufplce[z],(ylookup[y1ve[z]]+z)*pixelsize+pixel);
tmvline1(); tmvline1();
} }
bad >>= 1; bad >>= 1;
@ -1754,7 +1777,7 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f
{ {
if (u4 > y1ve[z]) if (u4 > y1ve[z])
{ {
preptmvline1(vince[z],palookupoffse[z],palookuplight[z],u4-y1ve[z],vplce[z],bufplce[z],ylookup[y1ve[z]]+p+z); preptmvline1(vince[z],palookupoffse[z],palookuplight[z],u4-y1ve[z],vplce[z],bufplce[z],(ylookup[y1ve[z]]+z)*pixelsize+pixel);
vplce[z] = tmvline1(); vplce[z] = tmvline1();
} }
} }
@ -1762,21 +1785,21 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f
if (d4 > u4) if (d4 > u4)
{ {
dc_count = d4-u4; dc_count = d4-u4;
dc_dest = ylookup[u4]+p; dc_dest = ylookup[u4]*pixelsize+pixel;
tmvline4(); tmvline4();
} }
canvas_pixel_t *i = p+ylookup[d4]; BYTE *i = pixel+ylookup[d4]*pixelsize;
for (z = 0; z < 4; ++z) for (z = 0; z < 4; ++z)
{ {
if (y2ve[z] > d4) if (y2ve[z] > d4)
{ {
preptmvline1(vince[z],palookupoffse[0],palookuplight[0],y2ve[z]-d4,vplce[z],bufplce[z],i+z); preptmvline1(vince[z],palookupoffse[0],palookuplight[0],y2ve[z]-d4,vplce[z],bufplce[z],i+z*pixelsize);
tmvline1(); tmvline1();
} }
} }
} }
for(; x < x2; ++x, ++p) for(; x < x2; ++x, pixel += pixelsize)
{ {
light += rw_lightstep; light += rw_lightstep;
y1ve[0] = uwal[x]; y1ve[0] = uwal[x];
@ -1789,7 +1812,7 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f
} }
dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS);
dc_dest = ylookup[y1ve[0]] + p; dc_dest = ylookup[y1ve[0]] * pixelsize + pixel;
dc_count = y2ve[0] - y1ve[0]; dc_count = y2ve[0] - y1ve[0];
iscale = swal[x] * yrepeat; iscale = swal[x] * yrepeat;
dc_iscale = xs_ToFixed(fracbits, iscale); dc_iscale = xs_ToFixed(fracbits, iscale);

View File

@ -98,6 +98,7 @@ EXTERN_CVAR (Bool, st_scale)
EXTERN_CVAR(Bool, r_shadercolormaps) EXTERN_CVAR(Bool, r_shadercolormaps)
EXTERN_CVAR(Int, r_drawfuzz) EXTERN_CVAR(Int, r_drawfuzz)
EXTERN_CVAR(Bool, r_deathcamera); EXTERN_CVAR(Bool, r_deathcamera);
EXTERN_CVAR(Bool, r_swtruecolor)
// //
// Sprite rotation 0 is facing the viewer, // Sprite rotation 0 is facing the viewer,
@ -132,7 +133,7 @@ EXTERN_CVAR (Bool, r_drawvoxels)
// //
int OffscreenBufferWidth, OffscreenBufferHeight; int OffscreenBufferWidth, OffscreenBufferHeight;
canvas_pixel_t *OffscreenColorBuffer; BYTE *OffscreenColorBuffer;
FCoverageBuffer *OffscreenCoverageBuffer; FCoverageBuffer *OffscreenCoverageBuffer;
// //
@ -244,6 +245,7 @@ bool sprflipvert;
void R_DrawMaskedColumn (const BYTE *column, const FTexture::Span *span) void R_DrawMaskedColumn (const BYTE *column, const FTexture::Span *span)
{ {
int pixelsize = r_swtruecolor ? 4 : 1;
const fixed_t centeryfrac = FLOAT2FIXED(CenterY); const fixed_t centeryfrac = FLOAT2FIXED(CenterY);
const fixed_t texturemid = FLOAT2FIXED(dc_texturemid); const fixed_t texturemid = FLOAT2FIXED(dc_texturemid);
while (span->Length != 0) while (span->Length != 0)
@ -314,7 +316,7 @@ void R_DrawMaskedColumn (const BYTE *column, const FTexture::Span *span)
} }
} }
dc_source = column + top; dc_source = column + top;
dc_dest = ylookup[dc_yl] + dc_x + dc_destorg; dc_dest = (ylookup[dc_yl] + dc_x) * pixelsize + dc_destorg;
dc_count = dc_yh - dc_yl + 1; dc_count = dc_yh - dc_yl + 1;
colfunc (); colfunc ();
} }
@ -688,6 +690,7 @@ void R_DrawVisVoxel(vissprite_t *spr, int minslabz, int maxslabz, short *cliptop
// Blend the voxel, if that's what we need to do. // Blend the voxel, if that's what we need to do.
if ((flags & ~DVF_MIRRORED) != 0) if ((flags & ~DVF_MIRRORED) != 0)
{ {
int pixelsize = r_swtruecolor ? 4 : 1;
for (int x = 0; x < viewwidth; ++x) for (int x = 0; x < viewwidth; ++x)
{ {
if (!(flags & DVF_SPANSONLY) && (x & 3) == 0) if (!(flags & DVF_SPANSONLY) && (x & 3) == 0)
@ -702,7 +705,7 @@ void R_DrawVisVoxel(vissprite_t *spr, int minslabz, int maxslabz, short *cliptop
dc_yl = span->Start; dc_yl = span->Start;
dc_yh = span->Stop - 1; dc_yh = span->Stop - 1;
dc_count = span->Stop - span->Start; dc_count = span->Stop - span->Start;
dc_dest = ylookup[span->Start] + x + dc_destorg; dc_dest = (ylookup[span->Start] + x) * pixelsize + dc_destorg;
colfunc(); colfunc();
} }
else else
@ -2602,7 +2605,7 @@ static void R_DrawMaskedSegsBehindParticle (const vissprite_t *vis)
void R_DrawParticle_C (vissprite_t *vis) void R_DrawParticle_C (vissprite_t *vis)
{ {
int spacing; int spacing;
canvas_pixel_t *dest; BYTE *dest;
BYTE color = vis->Style.colormap[vis->startfrac]; BYTE color = vis->Style.colormap[vis->startfrac];
int yl = vis->y1; int yl = vis->y1;
int ycount = vis->y2 - yl + 1; int ycount = vis->y2 - yl + 1;
@ -2668,7 +2671,7 @@ void R_DrawParticle_C (vissprite_t *vis)
void R_DrawParticle_RGBA(vissprite_t *vis) void R_DrawParticle_RGBA(vissprite_t *vis)
{ {
int spacing; int spacing;
canvas_pixel_t *dest; uint32_t *dest;
BYTE color = vis->Style.colormap[vis->startfrac]; BYTE color = vis->Style.colormap[vis->startfrac];
int yl = vis->y1; int yl = vis->y1;
int ycount = vis->y2 - yl + 1; int ycount = vis->y2 - yl + 1;
@ -2698,7 +2701,7 @@ void R_DrawParticle_RGBA(vissprite_t *vis)
dc_x = x; dc_x = x;
if (R_ClipSpriteColumnWithPortals(vis)) if (R_ClipSpriteColumnWithPortals(vis))
continue; continue;
dest = ylookup[yl] + x + dc_destorg; dest = ylookup[yl] + x + (uint32_t*)dc_destorg;
for (int y = 0; y < ycount; y++) for (int y = 0; y < ycount; y++)
{ {
uint32_t bg_red = (*dest >> 16) & 0xff; uint32_t bg_red = (*dest >> 16) & 0xff;
@ -2759,6 +2762,8 @@ void R_DrawVoxel(const FVector3 &globalpos, FAngle viewangle,
R_SetupDrawSlab(colormap); R_SetupDrawSlab(colormap);
int pixelsize = r_swtruecolor ? 4 : 1;
// Select mip level // Select mip level
i = abs(DMulScale6(dasprx - globalposx, cosang, daspry - globalposy, sinang)); i = abs(DMulScale6(dasprx - globalposx, cosang, daspry - globalposy, sinang));
i = DivScale6(i, MIN(daxscale, dayscale)); i = DivScale6(i, MIN(daxscale, dayscale));
@ -3012,7 +3017,7 @@ void R_DrawVoxel(const FVector3 &globalpos, FAngle viewangle,
if (!(flags & DVF_OFFSCREEN)) if (!(flags & DVF_OFFSCREEN))
{ {
// Draw directly to the screen. // Draw directly to the screen.
R_DrawSlab(xxr - xxl, yplc[xxl], z2 - z1, yinc, col, ylookup[z1] + lxt + xxl + dc_destorg); R_DrawSlab(xxr - xxl, yplc[xxl], z2 - z1, yinc, col, (ylookup[z1] + lxt + xxl) * pixelsize + dc_destorg);
} }
else else
{ {
@ -3243,12 +3248,12 @@ void R_CheckOffscreenBuffer(int width, int height, bool spansonly)
{ {
if (OffscreenColorBuffer == NULL) if (OffscreenColorBuffer == NULL)
{ {
OffscreenColorBuffer = new canvas_pixel_t[width * height]; OffscreenColorBuffer = new BYTE[width * height * 4];
} }
else if (OffscreenBufferWidth != width || OffscreenBufferHeight != height) else if (OffscreenBufferWidth != width || OffscreenBufferHeight != height)
{ {
delete[] OffscreenColorBuffer; delete[] OffscreenColorBuffer;
OffscreenColorBuffer = new canvas_pixel_t[width * height]; OffscreenColorBuffer = new BYTE[width * height * 4];
} }
} }
OffscreenBufferWidth = width; OffscreenBufferWidth = width;

View File

@ -179,7 +179,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms)
fixedcolormap = dc_colormap; fixedcolormap = dc_colormap;
ESPSResult mode = R_SetPatchStyle (parms.style, parms.Alpha, 0, parms.fillcolor); ESPSResult mode = R_SetPatchStyle (parms.style, parms.Alpha, 0, parms.fillcolor);
canvas_pixel_t *destorgsave = dc_destorg; BYTE *destorgsave = dc_destorg;
dc_destorg = screen->GetBuffer(); dc_destorg = screen->GetBuffer();
if (dc_destorg == NULL) if (dc_destorg == NULL)
{ {
@ -1021,7 +1021,7 @@ void DCanvas::PUTTRANSDOT (int xx, int yy, int basecolor, int level)
if (r_swtruecolor) if (r_swtruecolor)
{ {
canvas_pixel_t *spot = GetBuffer() + oldyyshifted + xx; uint32_t *spot = (uint32_t*)GetBuffer() + oldyyshifted + xx;
uint32_t fg = shade_pal_index(basecolor, calc_light_multiplier(0)); uint32_t fg = shade_pal_index(basecolor, calc_light_multiplier(0));
uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_red = (fg >> 16) & 0xff;
@ -1040,7 +1040,7 @@ void DCanvas::PUTTRANSDOT (int xx, int yy, int basecolor, int level)
} }
else else
{ {
canvas_pixel_t *spot = GetBuffer() + oldyyshifted + xx; BYTE *spot = GetBuffer() + oldyyshifted + xx;
DWORD *bg2rgb = Col2RGB8[1+level]; DWORD *bg2rgb = Col2RGB8[1+level];
DWORD *fg2rgb = Col2RGB8[63-level]; DWORD *fg2rgb = Col2RGB8[63-level];
DWORD fg = fg2rgb[basecolor]; DWORD fg = fg2rgb[basecolor];
@ -1091,27 +1091,62 @@ void DCanvas::DrawLine(int x0, int y0, int x1, int y1, int palColor, uint32 real
{ {
swapvalues (x0, x1); swapvalues (x0, x1);
} }
memset (GetBuffer() + y0*GetPitch() + x0, palColor, deltaX+1); if (r_swtruecolor)
{
uint32_t *spot = (uint32_t*)GetBuffer() + y0*GetPitch() + x0;
for (int i = 0; i <= deltaX; i++)
spot[i] = palColor;
}
else
{
memset (GetBuffer() + y0*GetPitch() + x0, palColor, deltaX+1);
}
} }
else if (deltaX == 0) else if (deltaX == 0)
{ // vertical line { // vertical line
canvas_pixel_t *spot = GetBuffer() + y0*GetPitch() + x0; if (r_swtruecolor)
int pitch = GetPitch ();
do
{ {
*spot = palColor; uint32_t *spot = (uint32_t*)GetBuffer() + y0*GetPitch() + x0;
spot += pitch; int pitch = GetPitch();
} while (--deltaY != 0); do
{
*spot = palColor;
spot += pitch;
} while (--deltaY != 0);
}
else
{
BYTE *spot = GetBuffer() + y0*GetPitch() + x0;
int pitch = GetPitch();
do
{
*spot = palColor;
spot += pitch;
} while (--deltaY != 0);
}
} }
else if (deltaX == deltaY) else if (deltaX == deltaY)
{ // diagonal line. { // diagonal line.
canvas_pixel_t *spot = GetBuffer() + y0*GetPitch() + x0; if (r_swtruecolor)
int advance = GetPitch() + xDir;
do
{ {
*spot = palColor; uint32_t *spot = (uint32_t*)GetBuffer() + y0*GetPitch() + x0;
spot += advance; int advance = GetPitch() + xDir;
} while (--deltaY != 0); do
{
*spot = palColor;
spot += advance;
} while (--deltaY != 0);
}
else
{
BYTE *spot = GetBuffer() + y0*GetPitch() + x0;
int advance = GetPitch() + xDir;
do
{
*spot = palColor;
spot += advance;
} while (--deltaY != 0);
}
} }
else else
{ {
@ -1231,7 +1266,6 @@ void DCanvas::DrawPixel(int x, int y, int palColor, uint32 realcolor)
void DCanvas::Clear (int left, int top, int right, int bottom, int palcolor, uint32 color) void DCanvas::Clear (int left, int top, int right, int bottom, int palcolor, uint32 color)
{ {
int x, y; int x, y;
canvas_pixel_t *dest;
if (left == right || top == bottom) if (left == right || top == bottom)
{ {
@ -1261,12 +1295,26 @@ void DCanvas::Clear (int left, int top, int right, int bottom, int palcolor, uin
palcolor = PalFromRGB(color); palcolor = PalFromRGB(color);
} }
dest = Buffer + top * Pitch + left; if (r_swtruecolor)
x = right - left;
for (y = top; y < bottom; y++)
{ {
memset(dest, palcolor, x); uint32_t *dest = (uint32_t*)Buffer + top * Pitch + left;
dest += Pitch; x = right - left;
for (y = top; y < bottom; y++)
{
for (int i = 0; i < x; i++)
dest[i] = palcolor;
dest += Pitch;
}
}
else
{
BYTE *dest = Buffer + top * Pitch + left;
x = right - left;
for (y = top; y < bottom; y++)
{
memset(dest, palcolor, x);
dest += Pitch;
}
} }
} }
@ -1452,11 +1500,14 @@ void DCanvas::FillSimplePoly(FTexture *tex, FVector2 *points, int npoints,
// V_DrawBlock // V_DrawBlock
// Draw a linear block of pixels into the view buffer. // Draw a linear block of pixels into the view buffer.
// //
void DCanvas::DrawBlock (int x, int y, int _width, int _height, const canvas_pixel_t *src) const void DCanvas::DrawBlock (int x, int y, int _width, int _height, const BYTE *src) const
{ {
if (r_swtruecolor)
return;
int srcpitch = _width; int srcpitch = _width;
int destpitch; int destpitch;
canvas_pixel_t *dest; BYTE *dest;
if (ClipBox (x, y, _width, _height, src, srcpitch)) if (ClipBox (x, y, _width, _height, src, srcpitch))
{ {
@ -1468,7 +1519,7 @@ void DCanvas::DrawBlock (int x, int y, int _width, int _height, const canvas_pix
do do
{ {
memcpy (dest, src, _width * sizeof(canvas_pixel_t)); memcpy (dest, src, _width);
src += srcpitch; src += srcpitch;
dest += destpitch; dest += destpitch;
} while (--_height); } while (--_height);
@ -1478,9 +1529,12 @@ void DCanvas::DrawBlock (int x, int y, int _width, int _height, const canvas_pix
// V_GetBlock // V_GetBlock
// Gets a linear block of pixels from the view buffer. // Gets a linear block of pixels from the view buffer.
// //
void DCanvas::GetBlock (int x, int y, int _width, int _height, canvas_pixel_t *dest) const void DCanvas::GetBlock (int x, int y, int _width, int _height, BYTE *dest) const
{ {
const canvas_pixel_t *src; if (r_swtruecolor)
return;
const BYTE *src;
#ifdef RANGECHECK #ifdef RANGECHECK
if (x<0 if (x<0
@ -1496,14 +1550,14 @@ void DCanvas::GetBlock (int x, int y, int _width, int _height, canvas_pixel_t *d
while (_height--) while (_height--)
{ {
memcpy (dest, src, _width * sizeof(canvas_pixel_t)); memcpy (dest, src, _width);
src += Pitch; src += Pitch;
dest += _width; dest += _width;
} }
} }
// Returns true if the box was completely clipped. False otherwise. // Returns true if the box was completely clipped. False otherwise.
bool DCanvas::ClipBox (int &x, int &y, int &w, int &h, const canvas_pixel_t *&src, const int srcpitch) const bool DCanvas::ClipBox (int &x, int &y, int &w, int &h, const BYTE *&src, const int srcpitch) const
{ {
if (x >= Width || y >= Height || x+w <= 0 || y+h <= 0) if (x >= Width || y >= Height || x+w <= 0 || y+h <= 0)
{ // Completely clipped off screen { // Completely clipped off screen

View File

@ -345,7 +345,6 @@ void DCanvas::Dim (PalEntry color, float damount, int x1, int y1, int w, int h)
return; return;
int gap; int gap;
canvas_pixel_t *spot;
int x, y; int x, y;
if (x1 >= Width || y1 >= Height) if (x1 >= Width || y1 >= Height)
@ -365,11 +364,12 @@ void DCanvas::Dim (PalEntry color, float damount, int x1, int y1, int w, int h)
return; return;
} }
spot = Buffer + x1 + y1*Pitch;
gap = Pitch - w; gap = Pitch - w;
if (r_swtruecolor) if (r_swtruecolor)
{ {
uint32_t *spot = (uint32_t*)Buffer + x1 + y1*Pitch;
uint32_t fg = color.d; uint32_t fg = color.d;
uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_red = (fg >> 16) & 0xff;
uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff;
@ -402,6 +402,8 @@ void DCanvas::Dim (PalEntry color, float damount, int x1, int y1, int w, int h)
} }
else else
{ {
BYTE *spot = Buffer + x1 + y1*Pitch;
DWORD *bg2rgb; DWORD *bg2rgb;
DWORD fg; DWORD fg;
@ -441,12 +443,12 @@ void DCanvas::Dim (PalEntry color, float damount, int x1, int y1, int w, int h)
// //
//========================================================================== //==========================================================================
void DCanvas::GetScreenshotBuffer(const canvas_pixel_t *&buffer, int &pitch, ESSType &color_type) void DCanvas::GetScreenshotBuffer(const BYTE *&buffer, int &pitch, ESSType &color_type)
{ {
Lock(true); Lock(true);
buffer = GetBuffer(); buffer = GetBuffer();
pitch = GetPitch(); pitch = GetPitch();
color_type = SS_PAL; color_type = r_swtruecolor ? SS_BGRA : SS_PAL;
} }
//========================================================================== //==========================================================================
@ -797,8 +799,8 @@ DSimpleCanvas::DSimpleCanvas (int width, int height)
Pitch = width + MAX(0, CPU.DataL1LineSize - 8); Pitch = width + MAX(0, CPU.DataL1LineSize - 8);
} }
} }
MemBuffer = new canvas_pixel_t[Pitch * height]; MemBuffer = new BYTE[Pitch * height * 4];
memset (MemBuffer, 0, Pitch * height * sizeof(canvas_pixel_t)); memset (MemBuffer, 0, Pitch * height * 4);
} }
//========================================================================== //==========================================================================
@ -917,7 +919,7 @@ void DFrameBuffer::DrawRateStuff ()
{ {
int i = I_GetTime(false); int i = I_GetTime(false);
int tics = i - LastTic; int tics = i - LastTic;
canvas_pixel_t *buffer = GetBuffer(); BYTE *buffer = GetBuffer();
LastTic = i; LastTic = i;
if (tics > 20) tics = 20; if (tics > 20) tics = 20;
@ -925,10 +927,21 @@ void DFrameBuffer::DrawRateStuff ()
// Buffer can be NULL if we're doing hardware accelerated 2D // Buffer can be NULL if we're doing hardware accelerated 2D
if (buffer != NULL) if (buffer != NULL)
{ {
buffer += (GetHeight()-1) * GetPitch(); if (r_swtruecolor)
{
for (i = 0; i < tics*2; i += 2) buffer[i] = 0xff; uint32_t *buffer32 = (uint32_t*)buffer;
for ( ; i < 20*2; i += 2) buffer[i] = 0x00; buffer32 += (GetHeight() - 1) * GetPitch();
for (i = 0; i < tics * 2; i += 2) buffer32[i] = 0xffffffff;
for (; i < 20 * 2; i += 2) buffer32[i] = 0xff000000;
}
else
{
buffer += (GetHeight() - 1) * GetPitch();
for (i = 0; i < tics * 2; i += 2) buffer[i] = 0xff;
for (; i < 20 * 2; i += 2) buffer[i] = 0x00;
}
} }
else else
{ {

View File

@ -189,7 +189,7 @@ public:
virtual ~DCanvas (); virtual ~DCanvas ();
// Member variable access // Member variable access
inline canvas_pixel_t *GetBuffer () const { return Buffer; } inline BYTE *GetBuffer () const { return Buffer; }
inline int GetWidth () const { return Width; } inline int GetWidth () const { return Width; }
inline int GetHeight () const { return Height; } inline int GetHeight () const { return Height; }
inline int GetPitch () const { return Pitch; } inline int GetPitch () const { return Pitch; }
@ -202,10 +202,10 @@ public:
virtual bool IsLocked () { return Buffer != NULL; } // Returns true if the surface is locked virtual bool IsLocked () { return Buffer != NULL; } // Returns true if the surface is locked
// Draw a linear block of pixels into the canvas // Draw a linear block of pixels into the canvas
virtual void DrawBlock (int x, int y, int width, int height, const canvas_pixel_t *src) const; virtual void DrawBlock (int x, int y, int width, int height, const BYTE *src) const;
// Reads a linear block of pixels into the view buffer. // Reads a linear block of pixels into the view buffer.
virtual void GetBlock (int x, int y, int width, int height, canvas_pixel_t *dest) const; virtual void GetBlock (int x, int y, int width, int height, BYTE *dest) const;
// Dim the entire canvas for the menus // Dim the entire canvas for the menus
virtual void Dim (PalEntry color = 0); virtual void Dim (PalEntry color = 0);
@ -237,7 +237,7 @@ public:
// Retrieves a buffer containing image data for a screenshot. // Retrieves a buffer containing image data for a screenshot.
// Hint: Pitch can be negative for upside-down images, in which case buffer // Hint: Pitch can be negative for upside-down images, in which case buffer
// points to the last row in the buffer, which will be the first row output. // points to the last row in the buffer, which will be the first row output.
virtual void GetScreenshotBuffer(const canvas_pixel_t *&buffer, int &pitch, ESSType &color_type); virtual void GetScreenshotBuffer(const BYTE *&buffer, int &pitch, ESSType &color_type);
// Releases the screenshot buffer. // Releases the screenshot buffer.
virtual void ReleaseScreenshotBuffer(); virtual void ReleaseScreenshotBuffer();
@ -262,13 +262,13 @@ public:
void DrawChar (FFont *font, int normalcolor, int x, int y, BYTE character, int tag_first, ...); void DrawChar (FFont *font, int normalcolor, int x, int y, BYTE character, int tag_first, ...);
protected: protected:
canvas_pixel_t *Buffer; BYTE *Buffer;
int Width; int Width;
int Height; int Height;
int Pitch; int Pitch;
int LockCount; int LockCount;
bool ClipBox (int &left, int &top, int &width, int &height, const canvas_pixel_t *&src, const int srcpitch) const; bool ClipBox (int &left, int &top, int &width, int &height, const BYTE *&src, const int srcpitch) const;
void DrawTextureV(FTexture *img, double x, double y, uint32 tag, va_list tags) = delete; void DrawTextureV(FTexture *img, double x, double y, uint32 tag, va_list tags) = delete;
virtual void DrawTextureParms(FTexture *img, DrawParms &parms); virtual void DrawTextureParms(FTexture *img, DrawParms &parms);
bool ParseDrawTextureTags (FTexture *img, double x, double y, uint32 tag, va_list tags, DrawParms *parms, bool fortext) const; bool ParseDrawTextureTags (FTexture *img, double x, double y, uint32 tag, va_list tags, DrawParms *parms, bool fortext) const;
@ -297,7 +297,7 @@ public:
void Unlock (); void Unlock ();
protected: protected:
canvas_pixel_t *MemBuffer; BYTE *MemBuffer;
DSimpleCanvas() {} DSimpleCanvas() {}
}; };

View File

@ -1316,7 +1316,7 @@ void D3DFB::Draw3DPart(bool copy3d)
else else
{ {
uint32_t *dest = (uint32_t *)lockrect.pBits; uint32_t *dest = (uint32_t *)lockrect.pBits;
uint32_t *src = MemBuffer; uint32_t *src = (uint32_t*)MemBuffer;
for (int y = 0; y < Height; y++) for (int y = 0; y < Height; y++)
{ {
memcpy(dest, src, Width * sizeof(uint32_t)); memcpy(dest, src, Width * sizeof(uint32_t));
@ -1744,7 +1744,7 @@ void D3DFB::SetBlendingRect(int x1, int y1, int x2, int y2)
// //
//========================================================================== //==========================================================================
void D3DFB::GetScreenshotBuffer(const canvas_pixel_t *&buffer, int &pitch, ESSType &color_type) void D3DFB::GetScreenshotBuffer(const BYTE *&buffer, int &pitch, ESSType &color_type)
{ {
D3DLOCKED_RECT lrect; D3DLOCKED_RECT lrect;
@ -1770,7 +1770,7 @@ void D3DFB::GetScreenshotBuffer(const canvas_pixel_t *&buffer, int &pitch, ESSTy
} }
else else
{ {
buffer = (const canvas_pixel_t *)lrect.pBits; buffer = (const BYTE *)lrect.pBits;
pitch = lrect.Pitch; pitch = lrect.Pitch;
color_type = SS_BGRA; color_type = SS_BGRA;
} }

View File

@ -999,8 +999,8 @@ DDrawFB::LockSurfRes DDrawFB::LockSurf (LPRECT lockrect, LPDIRECTDRAWSURFACE toL
LOG1 ("Final result after restoration attempts: %08lx\n", hr); LOG1 ("Final result after restoration attempts: %08lx\n", hr);
return NoGood; return NoGood;
} }
Buffer = (canvas_pixel_t *)desc.lpSurface; Buffer = (BYTE *)desc.lpSurface;
Pitch = desc.lPitch / sizeof(canvas_pixel_t); Pitch = desc.lPitch;
BufferingNow = false; BufferingNow = false;
return wasLost ? GoodWasLost : Good; return wasLost ? GoodWasLost : Good;
} }

View File

@ -252,7 +252,7 @@ public:
bool PaintToWindow (); bool PaintToWindow ();
void SetVSync (bool vsync); void SetVSync (bool vsync);
void NewRefreshRate(); void NewRefreshRate();
void GetScreenshotBuffer(const canvas_pixel_t *&buffer, int &pitch, ESSType &color_type); void GetScreenshotBuffer(const BYTE *&buffer, int &pitch, ESSType &color_type);
void ReleaseScreenshotBuffer(); void ReleaseScreenshotBuffer();
void SetBlendingRect (int x1, int y1, int x2, int y2); void SetBlendingRect (int x1, int y1, int x2, int y2);
bool Begin2D (bool copy3d); bool Begin2D (bool copy3d);