From 045bad1b5287d75f2c9f3d84e4a6cc2975499c18 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 31 May 2016 05:31:32 +0200 Subject: [PATCH] Removed the need for the pixel_canvas_t typedef --- src/basictypes.h | 6 -- src/f_wipe.cpp | 14 +-- src/m_misc.cpp | 2 - src/r_draw.cpp | 234 ++++++++++++++++++++--------------------- src/r_draw.h | 12 +-- src/r_drawt.cpp | 71 +++++++------ src/r_drawt_rgba.cpp | 94 ++++++++--------- src/r_main.cpp | 34 ++++-- src/r_plane.cpp | 130 ++++++++++++++++++++++- src/r_plane.h | 4 + src/r_segs.cpp | 93 ++++++++++------ src/r_things.cpp | 23 ++-- src/v_draw.cpp | 112 +++++++++++++++----- src/v_video.cpp | 35 ++++-- src/v_video.h | 14 +-- src/win32/fb_d3d9.cpp | 6 +- src/win32/fb_ddraw.cpp | 4 +- src/win32/win32iface.h | 2 +- 18 files changed, 561 insertions(+), 329 deletions(-) diff --git a/src/basictypes.h b/src/basictypes.h index 45e33a4a7..ff2cd972e 100644 --- a/src/basictypes.h +++ b/src/basictypes.h @@ -66,12 +66,6 @@ union QWORD_UNION typedef SDWORD fixed_t; 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_MIN (signed)(0x80000000) diff --git a/src/f_wipe.cpp b/src/f_wipe.cpp index a86f93fc4..7e1ec678e 100644 --- a/src/f_wipe.cpp +++ b/src/f_wipe.cpp @@ -80,7 +80,7 @@ bool wipe_initMelt (int ticks) int i, r; // 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) // to have stuff in column-major format @@ -273,7 +273,7 @@ bool wipe_doBurn (int ticks) // Draw the screen int xstep, ystep, firex, firey; int x, y; - canvas_pixel_t *to; + BYTE *to; BYTE *fromold, *fromnew; const int SHIFT = 16; @@ -338,7 +338,7 @@ bool wipe_doFade (int ticks) fade += ticks * 2; 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; } else @@ -349,7 +349,7 @@ bool wipe_doFade (int ticks) DWORD *bg2rgb = Col2RGB8[bglevel]; BYTE *fromnew = (BYTE *)wipe_scr_end; BYTE *fromold = (BYTE *)wipe_scr_start; - canvas_pixel_t *to = screen->GetBuffer(); + BYTE *to = screen->GetBuffer(); for (y = 0; y < SCREENHEIGHT; y++) { @@ -393,7 +393,7 @@ bool wipe_StartScreen (int type) if (CurrentWipeType) { 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 false; @@ -407,8 +407,8 @@ void wipe_EndScreen (void) if (CurrentWipeType) { wipe_scr_end = new short[SCREENWIDTH * SCREENHEIGHT / 2]; - screen->GetBlock (0, 0, SCREENWIDTH, SCREENHEIGHT, (canvas_pixel_t *)wipe_scr_end); - screen->DrawBlock (0, 0, SCREENWIDTH, SCREENHEIGHT, (canvas_pixel_t *)wipe_scr_start); // restore start scr. + screen->GetBlock (0, 0, SCREENWIDTH, SCREENHEIGHT, (BYTE *)wipe_scr_end); + screen->DrawBlock (0, 0, SCREENWIDTH, SCREENHEIGHT, (BYTE *)wipe_scr_start); // restore start scr. // Initialize the wipe (*wipes[(CurrentWipeType-1)*3])(0); diff --git a/src/m_misc.cpp b/src/m_misc.cpp index 79416c31d..87f61f253 100644 --- a/src/m_misc.cpp +++ b/src/m_misc.cpp @@ -655,7 +655,6 @@ static bool FindFreeName (FString &fullname, const char *extension) void M_ScreenShot (const char *filename) { -#ifdef PALETTEOUTPUT FILE *file; FString autoname; 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"); } } -#endif } CCMD (screenshot) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index cd34a71b4..f939406bb 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -65,7 +65,7 @@ extern int ST_Y; BYTE* viewimage; extern "C" { int ylookup[MAXHEIGHT]; -canvas_pixel_t *dc_destorg; +BYTE* dc_destorg; } int scaledviewwidth; @@ -99,6 +99,7 @@ void (*R_DrawSpanMaskedAddClamp)(void); void (*R_FillSpan)(void); void (*R_FillColumnHoriz)(void); 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_DrawParticle)(vissprite_t *); 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_tlatesubclamp4cols)(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 @@ -158,7 +159,7 @@ DWORD *dc_destblend; // blending lookups // first pixel in a column (possibly virtual) const BYTE* dc_source; -canvas_pixel_t* dc_dest; +BYTE* dc_dest; int dc_count; DWORD vplce[4]; @@ -236,7 +237,7 @@ void R_InitShadeMaps() void R_DrawColumnP_C (void) { int count; - canvas_pixel_t* dest; + BYTE* dest; fixed_t frac; fixed_t fracstep; @@ -281,7 +282,7 @@ void R_DrawColumnP_C (void) void R_DrawColumnP_RGBA_C() { int count; - canvas_pixel_t* dest; + uint32_t* dest; fixed_t frac; fixed_t fracstep; @@ -292,7 +293,7 @@ void R_DrawColumnP_RGBA_C() return; // Framebuffer destination address. - dest = dc_dest; + dest = (uint32_t*)dc_dest; uint32_t light = calc_light_multiplier(dc_light); @@ -328,7 +329,7 @@ void R_DrawColumnP_RGBA_C() void R_FillColumnP_C (void) { int count; - canvas_pixel_t* dest; + BYTE* dest; count = dc_count; @@ -352,14 +353,14 @@ void R_FillColumnP_C (void) void R_FillColumnP_RGBA() { int count; - canvas_pixel_t* dest; + uint32_t* dest; count = dc_count; if (count <= 0) return; - dest = dc_dest; + dest = (uint32_t*)dc_dest; uint32_t light = calc_light_multiplier(dc_light); @@ -378,7 +379,7 @@ void R_FillColumnP_RGBA() void R_FillAddColumn_C (void) { int count; - canvas_pixel_t *dest; + BYTE *dest; count = dc_count; if (count <= 0) @@ -405,13 +406,13 @@ void R_FillAddColumn_C (void) void R_FillAddColumn_RGBA_C() { int count; - canvas_pixel_t *dest; + uint32_t *dest; count = dc_count; if (count <= 0) return; - dest = dc_dest; + dest = (uint32_t*)dc_dest; int pitch = dc_pitch; uint32_t fg_red = (dc_srccolor >> 12) & 0xf8; @@ -436,7 +437,7 @@ void R_FillAddColumn_RGBA_C() void R_FillAddClampColumn_C (void) { int count; - canvas_pixel_t *dest; + BYTE *dest; count = dc_count; if (count <= 0) @@ -469,13 +470,13 @@ void R_FillAddClampColumn_C (void) void R_FillAddClampColumn_RGBA() { int count; - canvas_pixel_t *dest; + uint32_t *dest; count = dc_count; if (count <= 0) return; - dest = dc_dest; + dest = (uint32_t*)dc_dest; int pitch = dc_pitch; uint32_t fg_red = (dc_srccolor >> 12) & 0xf8; @@ -500,7 +501,7 @@ void R_FillAddClampColumn_RGBA() void R_FillSubClampColumn_C (void) { int count; - canvas_pixel_t *dest; + BYTE *dest; count = dc_count; if (count <= 0) @@ -532,13 +533,13 @@ void R_FillSubClampColumn_C (void) void R_FillSubClampColumn_RGBA() { int count; - canvas_pixel_t *dest; + uint32_t *dest; count = dc_count; if (count <= 0) return; - dest = dc_dest; + dest = (uint32_t*)dc_dest; int pitch = dc_pitch; uint32_t fg_red = (dc_srccolor >> 12) & 0xf8; @@ -563,7 +564,7 @@ void R_FillSubClampColumn_RGBA() void R_FillRevSubClampColumn_C (void) { int count; - canvas_pixel_t *dest; + BYTE *dest; count = dc_count; if (count <= 0) @@ -595,13 +596,13 @@ void R_FillRevSubClampColumn_C (void) void R_FillRevSubClampColumn_RGBA() { int count; - canvas_pixel_t *dest; + uint32_t *dest; count = dc_count; if (count <= 0) return; - dest = dc_dest; + dest = (uint32_t*)dc_dest; int pitch = dc_pitch; uint32_t fg_red = (dc_srccolor >> 12) & 0xf8; @@ -673,7 +674,7 @@ void R_InitFuzzTable (int fuzzoff) void R_DrawFuzzColumnP_C (void) { int count; - canvas_pixel_t *dest; + BYTE *dest; // Adjust borders. Low... if (dc_yl == 0) @@ -745,7 +746,7 @@ void R_DrawFuzzColumnP_C (void) void R_DrawFuzzColumnP_RGBA_C() { int count; - canvas_pixel_t *dest; + uint32_t *dest; // Adjust borders. Low... if (dc_yl == 0) @@ -763,7 +764,7 @@ void R_DrawFuzzColumnP_RGBA_C() 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) // 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) { int count; - canvas_pixel_t *dest; + BYTE *dest; fixed_t frac; fixed_t fracstep; @@ -928,7 +929,7 @@ void R_DrawAddColumnP_C (void) void R_DrawAddColumnP_RGBA_C() { int count; - canvas_pixel_t *dest; + uint32_t *dest; fixed_t frac; fixed_t fracstep; @@ -936,7 +937,7 @@ void R_DrawAddColumnP_RGBA_C() if (count <= 0) return; - dest = dc_dest; + dest = (uint32_t*)dc_dest; fracstep = dc_iscale; frac = dc_texturefrac; @@ -980,7 +981,7 @@ void R_DrawAddColumnP_RGBA_C() void R_DrawTranslatedColumnP_C (void) { int count; - canvas_pixel_t* dest; + BYTE* dest; fixed_t frac; fixed_t fracstep; @@ -1012,7 +1013,7 @@ void R_DrawTranslatedColumnP_C (void) void R_DrawTranslatedColumnP_RGBA_C() { int count; - canvas_pixel_t* dest; + uint32_t* dest; fixed_t frac; fixed_t fracstep; @@ -1022,7 +1023,7 @@ void R_DrawTranslatedColumnP_RGBA_C() uint32_t light = calc_light_multiplier(dc_light); - dest = dc_dest; + dest = (uint32_t*)dc_dest; fracstep = dc_iscale; frac = dc_texturefrac; @@ -1047,7 +1048,7 @@ void R_DrawTranslatedColumnP_RGBA_C() void R_DrawTlatedAddColumnP_C() { int count; - canvas_pixel_t *dest; + BYTE *dest; fixed_t frac; fixed_t fracstep; @@ -1086,7 +1087,7 @@ void R_DrawTlatedAddColumnP_C() void R_DrawTlatedAddColumnP_RGBA_C() { int count; - canvas_pixel_t *dest; + uint32_t *dest; fixed_t frac; fixed_t fracstep; @@ -1096,7 +1097,7 @@ void R_DrawTlatedAddColumnP_RGBA_C() uint32_t light = calc_light_multiplier(dc_light); - dest = dc_dest; + dest = (uint32_t*)dc_dest; fracstep = dc_iscale; frac = dc_texturefrac; @@ -1135,7 +1136,7 @@ void R_DrawTlatedAddColumnP_RGBA_C() void R_DrawShadedColumnP_C (void) { int count; - canvas_pixel_t *dest; + BYTE *dest; fixed_t frac, fracstep; count = dc_count; @@ -1170,7 +1171,7 @@ void R_DrawShadedColumnP_C (void) void R_DrawShadedColumnP_RGBA_C() { int count; - canvas_pixel_t *dest; + uint32_t *dest; fixed_t frac, fracstep; count = dc_count; @@ -1178,7 +1179,7 @@ void R_DrawShadedColumnP_RGBA_C() if (count <= 0) return; - dest = dc_dest; + dest = (uint32_t*)dc_dest; fracstep = dc_iscale; frac = dc_texturefrac; @@ -1217,7 +1218,7 @@ void R_DrawShadedColumnP_RGBA_C() void R_DrawAddClampColumnP_C () { int count; - canvas_pixel_t *dest; + BYTE *dest; fixed_t frac; fixed_t fracstep; @@ -1234,24 +1235,20 @@ void R_DrawAddClampColumnP_C () const BYTE *source = dc_source; BYTE *colormap = dc_colormap; int pitch = dc_pitch; - uint32_t light = calc_light_multiplier(dc_light); + DWORD *fg2rgb = dc_srcblend; + DWORD *bg2rgb = dc_destblend; do { - uint32_t fg = shade_pal_index(colormap[source[frac >> FRACBITS]], light); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; + DWORD a = fg2rgb[colormap[source[frac >> FRACBITS]]] + bg2rgb[*dest]; + DWORD b = a; - uint32_t bg_red = (*dest >> 16) & 0xff; - uint32_t bg_green = (*dest >> 8) & 0xff; - uint32_t bg_blue = (*dest) & 0xff; - - uint32_t red = clamp(fg_red + bg_red, 0, 255); - uint32_t green = clamp(fg_green + bg_green, 0, 255); - uint32_t blue = clamp(fg_blue + bg_blue, 0, 255); - - *dest = 0xff000000 | (red << 16) | (green << 8) | blue; + a |= 0x01f07c1f; + b &= 0x40100400; + a &= 0x3fffffff; + b = b - (b >> 5); + a |= b; + *dest = RGB32k.All[a & (a >> 15)]; dest += pitch; frac += fracstep; } while (--count); @@ -1261,7 +1258,7 @@ void R_DrawAddClampColumnP_C () void R_DrawAddClampColumnP_RGBA_C() { int count; - canvas_pixel_t *dest; + uint32_t *dest; fixed_t frac; fixed_t fracstep; @@ -1269,7 +1266,7 @@ void R_DrawAddClampColumnP_RGBA_C() if (count <= 0) return; - dest = dc_dest; + dest = (uint32_t*)dc_dest; fracstep = dc_iscale; frac = dc_texturefrac; @@ -1306,7 +1303,7 @@ void R_DrawAddClampColumnP_RGBA_C() void R_DrawAddClampTranslatedColumnP_C () { int count; - canvas_pixel_t *dest; + BYTE *dest; fixed_t frac; fixed_t fracstep; @@ -1347,7 +1344,7 @@ void R_DrawAddClampTranslatedColumnP_C () void R_DrawAddClampTranslatedColumnP_RGBA_C() { int count; - canvas_pixel_t *dest; + uint32_t *dest; fixed_t frac; fixed_t fracstep; @@ -1355,7 +1352,7 @@ void R_DrawAddClampTranslatedColumnP_RGBA_C() if (count <= 0) return; - dest = dc_dest; + dest = (uint32_t*)dc_dest; fracstep = dc_iscale; frac = dc_texturefrac; @@ -1393,7 +1390,7 @@ void R_DrawAddClampTranslatedColumnP_RGBA_C() void R_DrawSubClampColumnP_C () { int count; - canvas_pixel_t *dest; + BYTE *dest; fixed_t frac; fixed_t fracstep; @@ -1432,7 +1429,7 @@ void R_DrawSubClampColumnP_C () void R_DrawSubClampColumnP_RGBA_C() { int count; - canvas_pixel_t *dest; + uint32_t *dest; fixed_t frac; fixed_t fracstep; @@ -1440,7 +1437,7 @@ void R_DrawSubClampColumnP_RGBA_C() if (count <= 0) return; - dest = dc_dest; + dest = (uint32_t*)dc_dest; fracstep = dc_iscale; frac = dc_texturefrac; @@ -1477,7 +1474,7 @@ void R_DrawSubClampColumnP_RGBA_C() void R_DrawSubClampTranslatedColumnP_C () { int count; - canvas_pixel_t *dest; + BYTE *dest; fixed_t frac; fixed_t fracstep; @@ -1517,7 +1514,7 @@ void R_DrawSubClampTranslatedColumnP_C () void R_DrawSubClampTranslatedColumnP_RGBA_C() { int count; - canvas_pixel_t *dest; + uint32_t *dest; fixed_t frac; fixed_t fracstep; @@ -1525,7 +1522,7 @@ void R_DrawSubClampTranslatedColumnP_RGBA_C() if (count <= 0) return; - dest = dc_dest; + dest = (uint32_t*)dc_dest; fracstep = dc_iscale; frac = dc_texturefrac; @@ -1563,7 +1560,7 @@ void R_DrawSubClampTranslatedColumnP_RGBA_C() void R_DrawRevSubClampColumnP_C () { int count; - canvas_pixel_t *dest; + BYTE *dest; fixed_t frac; fixed_t fracstep; @@ -1602,7 +1599,7 @@ void R_DrawRevSubClampColumnP_C () void R_DrawRevSubClampColumnP_RGBA_C() { int count; - canvas_pixel_t *dest; + uint32_t *dest; fixed_t frac; fixed_t fracstep; @@ -1610,7 +1607,7 @@ void R_DrawRevSubClampColumnP_RGBA_C() if (count <= 0) return; - dest = dc_dest; + dest = (uint32_t*)dc_dest; fracstep = dc_iscale; frac = dc_texturefrac; @@ -1647,7 +1644,7 @@ void R_DrawRevSubClampColumnP_RGBA_C() void R_DrawRevSubClampTranslatedColumnP_C () { int count; - canvas_pixel_t *dest; + BYTE *dest; fixed_t frac; fixed_t fracstep; @@ -1687,7 +1684,7 @@ void R_DrawRevSubClampTranslatedColumnP_C () void R_DrawRevSubClampTranslatedColumnP_RGBA_C() { int count; - canvas_pixel_t *dest; + uint32_t *dest; fixed_t frac; fixed_t fracstep; @@ -1695,7 +1692,7 @@ void R_DrawRevSubClampTranslatedColumnP_RGBA_C() if (count <= 0) return; - dest = dc_dest; + dest = (uint32_t*)dc_dest; fracstep = dc_iscale; frac = dc_texturefrac; @@ -1855,7 +1852,7 @@ void R_DrawSpanP_C (void) dsfixed_t yfrac; dsfixed_t xstep; dsfixed_t ystep; - canvas_pixel_t* dest; + BYTE* dest; const BYTE* source = ds_source; const BYTE* colormap = ds_colormap; int count; @@ -1927,7 +1924,7 @@ void R_DrawSpanP_RGBA_C() dsfixed_t yfrac; dsfixed_t xstep; dsfixed_t ystep; - canvas_pixel_t* dest; + uint32_t* dest; const BYTE* source = ds_source; const BYTE* colormap = ds_colormap; int count; @@ -1945,7 +1942,7 @@ void R_DrawSpanP_RGBA_C() xfrac = ds_xfrac; 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; @@ -2051,7 +2048,7 @@ void R_DrawSpanMaskedP_C (void) dsfixed_t yfrac; dsfixed_t xstep; dsfixed_t ystep; - canvas_pixel_t* dest; + BYTE* dest; const BYTE* source = ds_source; const BYTE* colormap = ds_colormap; int count; @@ -2114,7 +2111,7 @@ void R_DrawSpanMaskedP_RGBA_C() dsfixed_t yfrac; dsfixed_t xstep; dsfixed_t ystep; - canvas_pixel_t* dest; + uint32_t* dest; const BYTE* source = ds_source; const BYTE* colormap = ds_colormap; int count; @@ -2125,7 +2122,7 @@ void R_DrawSpanMaskedP_RGBA_C() xfrac = ds_xfrac; 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; @@ -2179,7 +2176,7 @@ void R_DrawSpanTranslucentP_C (void) dsfixed_t yfrac; dsfixed_t xstep; dsfixed_t ystep; - canvas_pixel_t* dest; + BYTE* dest; const BYTE* source = ds_source; const BYTE* colormap = ds_colormap; int count; @@ -2241,7 +2238,7 @@ void R_DrawSpanTranslucentP_RGBA_C() dsfixed_t yfrac; dsfixed_t xstep; dsfixed_t ystep; - canvas_pixel_t* dest; + uint32_t* dest; const BYTE* source = ds_source; const BYTE* colormap = ds_colormap; int count; @@ -2252,7 +2249,7 @@ void R_DrawSpanTranslucentP_RGBA_C() xfrac = ds_xfrac; 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; @@ -2323,7 +2320,7 @@ void R_DrawSpanMaskedTranslucentP_C (void) dsfixed_t yfrac; dsfixed_t xstep; dsfixed_t ystep; - canvas_pixel_t* dest; + BYTE* dest; const BYTE* source = ds_source; const BYTE* colormap = ds_colormap; int count; @@ -2399,7 +2396,7 @@ void R_DrawSpanMaskedTranslucentP_RGBA_C() dsfixed_t yfrac; dsfixed_t xstep; dsfixed_t ystep; - canvas_pixel_t* dest; + uint32_t* dest; const BYTE* source = ds_source; const BYTE* colormap = ds_colormap; int count; @@ -2412,7 +2409,7 @@ void R_DrawSpanMaskedTranslucentP_RGBA_C() xfrac = ds_xfrac; 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; @@ -2491,7 +2488,7 @@ void R_DrawSpanAddClampP_C (void) dsfixed_t yfrac; dsfixed_t xstep; dsfixed_t ystep; - canvas_pixel_t* dest; + BYTE* dest; const BYTE* source = ds_source; const BYTE* colormap = ds_colormap; int count; @@ -2561,7 +2558,7 @@ void R_DrawSpanAddClampP_RGBA_C() dsfixed_t yfrac; dsfixed_t xstep; dsfixed_t ystep; - canvas_pixel_t* dest; + uint32_t* dest; const BYTE* source = ds_source; const BYTE* colormap = ds_colormap; int count; @@ -2574,7 +2571,7 @@ void R_DrawSpanAddClampP_RGBA_C() xfrac = ds_xfrac; 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; @@ -2643,7 +2640,7 @@ void R_DrawSpanMaskedAddClampP_C (void) dsfixed_t yfrac; dsfixed_t xstep; dsfixed_t ystep; - canvas_pixel_t* dest; + BYTE* dest; const BYTE* source = ds_source; const BYTE* colormap = ds_colormap; int count; @@ -2725,7 +2722,7 @@ void R_DrawSpanMaskedAddClampP_RGBA_C() dsfixed_t yfrac; dsfixed_t xstep; dsfixed_t ystep; - canvas_pixel_t* dest; + uint32_t* dest; const BYTE* source = ds_source; const BYTE* colormap = ds_colormap; int count; @@ -2738,7 +2735,7 @@ void R_DrawSpanMaskedAddClampP_RGBA_C() xfrac = ds_xfrac; 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; @@ -2819,7 +2816,7 @@ void R_FillSpan_C (void) 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); uint32_t light = calc_light_multiplier(ds_light); uint32_t color = shade_pal_index(ds_color, light); @@ -2843,7 +2840,7 @@ extern "C" void R_SetupDrawSlabC(const BYTE *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; const BYTE *colormap = slabcolormap; @@ -3017,7 +3014,7 @@ DWORD vlinec1 () BYTE *colormap = dc_colormap; int count = dc_count; const BYTE *source = dc_source; - canvas_pixel_t *dest = dc_dest; + BYTE *dest = dc_dest; int bits = vlinebits; int pitch = dc_pitch; @@ -3039,7 +3036,7 @@ DWORD vlinec1_RGBA() BYTE *colormap = dc_colormap; int count = dc_count; const BYTE *source = dc_source; - canvas_pixel_t *dest = dc_dest; + uint32_t *dest = (uint32_t*)dc_dest; int bits = vlinebits; int pitch = dc_pitch; @@ -3058,7 +3055,7 @@ DWORD vlinec1_RGBA() #if !defined(X86_ASM) void vlinec4 () { - canvas_pixel_t *dest = dc_dest; + BYTE *dest = dc_dest; int count = dc_count; int bits = vlinebits; DWORD place; @@ -3076,7 +3073,7 @@ void vlinec4 () void vlinec4_RGBA() { - canvas_pixel_t *dest = dc_dest; + uint32_t *dest = (uint32_t*)dc_dest; int count = dc_count; int bits = vlinebits; @@ -3162,7 +3159,7 @@ DWORD mvlinec1 () BYTE *colormap = dc_colormap; int count = dc_count; const BYTE *source = dc_source; - canvas_pixel_t *dest = dc_dest; + BYTE *dest = dc_dest; int bits = mvlinebits; int pitch = dc_pitch; @@ -3188,7 +3185,7 @@ DWORD mvlinec1_RGBA() BYTE *colormap = dc_colormap; int count = dc_count; const BYTE *source = dc_source; - canvas_pixel_t *dest = dc_dest; + uint32_t *dest = (uint32_t*)dc_dest; int bits = mvlinebits; int pitch = dc_pitch; @@ -3211,7 +3208,7 @@ DWORD mvlinec1_RGBA() #if !defined(X86_ASM) void mvlinec4 () { - canvas_pixel_t *dest = dc_dest; + BYTE *dest = dc_dest; int count = dc_count; int bits = mvlinebits; DWORD place; @@ -3230,7 +3227,7 @@ void mvlinec4 () void mvlinec4_RGBA() { - canvas_pixel_t *dest = dc_dest; + uint32_t *dest = (uint32_t*)dc_dest; int count = dc_count; int bits = mvlinebits; DWORD place; @@ -3260,7 +3257,7 @@ extern int wallshade; static void R_DrawFogBoundarySection (int y, int y2, int x1) { BYTE *colormap = dc_colormap; - canvas_pixel_t *dest = ylookup[y] + dc_destorg; + BYTE *dest = ylookup[y] + dc_destorg; for (; y < y2; ++y) { @@ -3278,7 +3275,7 @@ static void R_DrawFogBoundaryLine (int y, int x) { int x2 = spanend[y]; BYTE *colormap = dc_colormap; - canvas_pixel_t *dest = ylookup[y] + dc_destorg; + BYTE *dest = ylookup[y] + dc_destorg; 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) { 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); @@ -3400,7 +3397,7 @@ static void R_DrawFogBoundaryLine_RGBA(int y, int x) { int x2 = spanend[y]; 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); @@ -3518,7 +3515,7 @@ fixed_t tmvline1_add_C () BYTE *colormap = dc_colormap; int count = dc_count; const BYTE *source = dc_source; - canvas_pixel_t *dest = dc_dest; + BYTE *dest = dc_dest; int bits = tmvlinebits; int pitch = dc_pitch; @@ -3551,7 +3548,7 @@ fixed_t tmvline1_add_RGBA() BYTE *colormap = dc_colormap; int count = dc_count; const BYTE *source = dc_source; - canvas_pixel_t *dest = dc_dest; + uint32_t *dest = (uint32_t*)dc_dest; int bits = tmvlinebits; int pitch = dc_pitch; @@ -3589,7 +3586,7 @@ fixed_t tmvline1_add_RGBA() void tmvline4_add_C () { - canvas_pixel_t *dest = dc_dest; + BYTE *dest = dc_dest; int count = dc_count; int bits = tmvlinebits; @@ -3622,13 +3619,10 @@ void tmvline4_add_C () void tmvline4_add_RGBA() { - canvas_pixel_t *dest = dc_dest; + uint32_t *dest = (uint32_t*)dc_dest; int count = dc_count; int bits = tmvlinebits; - DWORD *fg2rgb = dc_srcblend; - DWORD *bg2rgb = dc_destblend; - uint32_t light[4]; light[0] = calc_light_multiplier(palookuplight[0]); light[1] = calc_light_multiplier(palookuplight[1]); @@ -3670,7 +3664,7 @@ fixed_t tmvline1_addclamp_C () BYTE *colormap = dc_colormap; int count = dc_count; const BYTE *source = dc_source; - canvas_pixel_t *dest = dc_dest; + BYTE *dest = dc_dest; int bits = tmvlinebits; int pitch = dc_pitch; @@ -3708,7 +3702,7 @@ fixed_t tmvline1_addclamp_RGBA() BYTE *colormap = dc_colormap; int count = dc_count; const BYTE *source = dc_source; - canvas_pixel_t *dest = dc_dest; + uint32_t *dest = (uint32_t*)dc_dest; int bits = tmvlinebits; int pitch = dc_pitch; @@ -3746,7 +3740,7 @@ fixed_t tmvline1_addclamp_RGBA() void tmvline4_addclamp_C () { - canvas_pixel_t *dest = dc_dest; + BYTE *dest = dc_dest; int count = dc_count; int bits = tmvlinebits; @@ -3778,7 +3772,7 @@ void tmvline4_addclamp_C () void tmvline4_addclamp_RGBA() { - canvas_pixel_t *dest = dc_dest; + uint32_t *dest = (uint32_t*)dc_dest; int count = dc_count; int bits = tmvlinebits; @@ -3823,7 +3817,7 @@ fixed_t tmvline1_subclamp_C () BYTE *colormap = dc_colormap; int count = dc_count; const BYTE *source = dc_source; - canvas_pixel_t *dest = dc_dest; + BYTE *dest = dc_dest; int bits = tmvlinebits; int pitch = dc_pitch; @@ -3858,7 +3852,7 @@ fixed_t tmvline1_subclamp_RGBA() BYTE *colormap = dc_colormap; int count = dc_count; const BYTE *source = dc_source; - canvas_pixel_t *dest = dc_dest; + uint32_t *dest = (uint32_t*)dc_dest; int bits = tmvlinebits; int pitch = dc_pitch; @@ -3893,7 +3887,7 @@ fixed_t tmvline1_subclamp_RGBA() void tmvline4_subclamp_C () { - canvas_pixel_t *dest = dc_dest; + BYTE *dest = dc_dest; int count = dc_count; int bits = tmvlinebits; @@ -3924,7 +3918,7 @@ void tmvline4_subclamp_C () void tmvline4_subclamp_RGBA() { - canvas_pixel_t *dest = dc_dest; + uint32_t *dest = (uint32_t*)dc_dest; int count = dc_count; int bits = tmvlinebits; @@ -3969,7 +3963,7 @@ fixed_t tmvline1_revsubclamp_C () BYTE *colormap = dc_colormap; int count = dc_count; const BYTE *source = dc_source; - canvas_pixel_t *dest = dc_dest; + BYTE *dest = dc_dest; int bits = tmvlinebits; int pitch = dc_pitch; @@ -4004,7 +3998,7 @@ fixed_t tmvline1_revsubclamp_RGBA() BYTE *colormap = dc_colormap; int count = dc_count; const BYTE *source = dc_source; - canvas_pixel_t *dest = dc_dest; + uint32_t *dest = (uint32_t*)dc_dest; int bits = tmvlinebits; int pitch = dc_pitch; @@ -4039,7 +4033,7 @@ fixed_t tmvline1_revsubclamp_RGBA() void tmvline4_revsubclamp_C () { - canvas_pixel_t *dest = dc_dest; + BYTE *dest = dc_dest; int count = dc_count; int bits = tmvlinebits; @@ -4070,7 +4064,7 @@ void tmvline4_revsubclamp_C () void tmvline4_revsubclamp_RGBA() { - canvas_pixel_t *dest = dc_dest; + uint32_t *dest = (uint32_t*)dc_dest; int count = dc_count; int bits = tmvlinebits; @@ -4168,6 +4162,7 @@ void R_InitColumnDrawers () R_FillColumnHoriz = R_FillColumnHorizP_RGBA_C; R_DrawFogBoundary = R_DrawFogBoundary_RGBA; + R_MapTiltedPlane = R_MapColoredPlane_RGBA; R_MapColoredPlane = R_MapColoredPlane_RGBA; R_DrawParticle = R_DrawParticle_RGBA; @@ -4262,6 +4257,7 @@ void R_InitColumnDrawers () R_FillColumnHoriz = R_FillColumnHorizP_C; R_DrawFogBoundary = R_DrawFogBoundary_C; + R_MapTiltedPlane = R_MapColoredPlane_C; R_MapColoredPlane = R_MapColoredPlane_C; R_DrawParticle = R_DrawParticle_C; diff --git a/src/r_draw.h b/src/r_draw.h index db109dbee..2348914b6 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -45,7 +45,7 @@ extern "C" DWORD *dc_destblend; // first pixel in a column 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" DWORD vplce[4]; @@ -55,7 +55,7 @@ extern "C" fixed_t palookuplight[4]; extern "C" const BYTE* bufplce[4]; // [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_ctspan[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_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); // [RH] Preps the temporary horizontal buffer. -void rt_initcols_pal (canvas_pixel_t *buffer); -void rt_initcols_rgba (canvas_pixel_t *buffer); +void rt_initcols_pal (BYTE *buffer); +void rt_initcols_rgba (BYTE *buffer); extern void (*R_DrawFogBoundary)(int x1, int x2, short *uclip, short *dclip); @@ -313,7 +313,7 @@ void R_FillSpan_RGBA_C(void); #endif 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_x1; diff --git a/src/r_drawt.cpp b/src/r_drawt.cpp index 9520f59b3..485ed7ab3 100644 --- a/src/r_drawt.cpp +++ b/src/r_drawt.cpp @@ -47,6 +47,8 @@ #include "r_things.h" #include "v_video.h" +EXTERN_CVAR(Bool, r_swtruecolor) + // I should have commented this stuff better. // // dc_temp is the buffer R_DrawColumnHoriz writes into. @@ -57,8 +59,8 @@ // dc_ctspan is advanced while drawing into dc_temp. // horizspan is advanced up to dc_ctspan when drawing from dc_temp to the screen. -canvas_pixel_t dc_tempbuff[MAXHEIGHT*4]; -canvas_pixel_t *dc_temp; +BYTE dc_tempbuff[MAXHEIGHT*4]; +BYTE *dc_temp; unsigned int dc_tspans[4][MAXHEIGHT]; unsigned int *dc_ctspan[4]; unsigned int *horizspan[4]; @@ -73,8 +75,8 @@ extern "C" void R_SetupAddClampCol(); // Copies one span at hx to the screen at sx. void rt_copy1col_c (int hx, int sx, int yl, int yh) { - canvas_pixel_t *source; - canvas_pixel_t *dest; + BYTE *source; + BYTE *dest; int count; 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) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + BYTE *source; + BYTE *dest; int count; 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) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + BYTE *source; + BYTE *dest; int count; 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) { 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: // 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) { int count = yh - yl + 1; - canvas_pixel_t *source = &dc_temp[yl*4]; + BYTE *source = &dc_temp[yl*4]; int c0, c1; 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) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + BYTE *source; + BYTE *dest; int count; 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) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + BYTE *source; + BYTE *dest; int count; 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) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + BYTE *source; + BYTE *dest; int count; 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) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + BYTE *source; + BYTE *dest; int count; 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) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + BYTE *source; + BYTE *dest; int count; 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) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + BYTE *source; + BYTE *dest; int count; 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) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + BYTE *source; + BYTE *dest; int count; 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) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + BYTE *source; + BYTE *dest; int count; 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) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + BYTE *source; + BYTE *dest; int count; 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) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + BYTE *source; + BYTE *dest; int count; int pitch; @@ -1007,7 +1009,7 @@ void rt_draw4cols (int sx) // Before each pass through a rendering loop that uses these routines, // 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; @@ -1021,7 +1023,7 @@ void rt_initcols_pal (canvas_pixel_t *buff) void R_DrawColumnHorizP_C (void) { int count = dc_count; - canvas_pixel_t *dest; + BYTE *dest; fixed_t fracstep; fixed_t frac; @@ -1082,7 +1084,7 @@ void R_FillColumnHorizP_C (void) { int count = dc_count; BYTE color = dc_color; - canvas_pixel_t *dest; + BYTE *dest; if (count <= 0) return; @@ -1113,6 +1115,7 @@ void R_FillColumnHorizP_C (void) void R_DrawMaskedColumnHoriz (const BYTE *column, const FTexture::Span *span) { + int pixelsize = r_swtruecolor ? 4 : 1; const fixed_t texturemid = FLOAT2FIXED(dc_texturemid); while (span->Length != 0) { @@ -1182,7 +1185,7 @@ void R_DrawMaskedColumnHoriz (const BYTE *column, const FTexture::Span *span) } } 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; hcolfunc_pre (); } diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index e8111be8f..872cb4b89 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -43,8 +43,8 @@ #include "r_things.h" #include "v_video.h" -canvas_pixel_t dc_temp_rgbabuff_rgba[MAXHEIGHT*4]; -canvas_pixel_t *dc_temp_rgba; +uint32_t dc_temp_rgbabuff_rgba[MAXHEIGHT*4]; +uint32_t *dc_temp_rgba; // Defined in r_draw_t.cpp: 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. void rt_copy1col_RGBA_c (int hx, int sx, int yl, int yh) { - canvas_pixel_t *source; - canvas_pixel_t *dest; + uint32_t *source; + uint32_t *dest; int count; int pitch; @@ -64,7 +64,7 @@ void rt_copy1col_RGBA_c (int hx, int sx, int yl, int yh) return; count++; - dest = ylookup[yl] + sx + dc_destorg; + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl*4 + hx]; 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) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + uint32_t *source; + uint32_t *dest; int count; 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); colormap = dc_colormap; - dest = ylookup[yl] + sx + dc_destorg; + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl*4 + hx]; 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) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + uint32_t *source; + uint32_t *dest; int count; 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); colormap = dc_colormap; - dest = ylookup[yl] + sx + dc_destorg; + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl*4]; 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) { 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: // 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) { 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; 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) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + uint32_t *source; + uint32_t *dest; int count; int pitch; @@ -301,7 +301,7 @@ void rt_add1col_RGBA_c (int hx, int sx, int yl, int yh) return; count++; - dest = ylookup[yl] + sx + dc_destorg; + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl*4 + hx]; pitch = dc_pitch; 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) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + uint32_t *source; + uint32_t *dest; int count; int pitch; @@ -343,7 +343,7 @@ void rt_add4cols_RGBA_c (int sx, int yl, int yh) return; count++; - dest = ylookup[yl] + sx + dc_destorg; + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl*4]; pitch = dc_pitch; 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) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + uint32_t *source; + uint32_t *dest; int count; int pitch; @@ -403,7 +403,7 @@ void rt_shaded1col_RGBA_c (int hx, int sx, int yl, int yh) count++; colormap = dc_colormap; - dest = ylookup[yl] + sx + dc_destorg; + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl*4 + hx]; 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) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + uint32_t *source; + uint32_t *dest; int count; int pitch; @@ -445,7 +445,7 @@ void rt_shaded4cols_RGBA_c (int sx, int yl, int yh) count++; colormap = dc_colormap; - dest = ylookup[yl] + sx + dc_destorg; + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl*4]; 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) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + uint32_t *source; + uint32_t *dest; int count; int pitch; @@ -489,7 +489,7 @@ void rt_addclamp1col_RGBA_c (int hx, int sx, int yl, int yh) return; count++; - dest = ylookup[yl] + sx + dc_destorg; + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl*4 + hx]; pitch = dc_pitch; 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) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + uint32_t *source; + uint32_t *dest; int count; int pitch; @@ -530,7 +530,7 @@ void rt_addclamp4cols_RGBA_c (int sx, int yl, int yh) return; count++; - dest = ylookup[yl] + sx + dc_destorg; + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl*4]; pitch = dc_pitch; 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) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + uint32_t *source; + uint32_t *dest; int count; int pitch; @@ -588,7 +588,7 @@ void rt_subclamp1col_RGBA_c (int hx, int sx, int yl, int yh) return; count++; - dest = ylookup[yl] + sx + dc_destorg; + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl*4 + hx]; pitch = dc_pitch; 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) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + uint32_t *source; + uint32_t *dest; int count; int pitch; @@ -629,7 +629,7 @@ void rt_subclamp4cols_RGBA_c (int sx, int yl, int yh) return; count++; - dest = ylookup[yl] + sx + dc_destorg; + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl*4]; pitch = dc_pitch; 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) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + uint32_t *source; + uint32_t *dest; int count; int pitch; @@ -690,7 +690,7 @@ void rt_revsubclamp1col_RGBA_c (int hx, int sx, int yl, int yh) DWORD *fg2rgb = dc_srcblend; 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]; pitch = dc_pitch; 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) { BYTE *colormap; - canvas_pixel_t *source; - canvas_pixel_t *dest; + uint32_t *source; + uint32_t *dest; int count; int pitch; @@ -733,7 +733,7 @@ void rt_revsubclamp4cols_RGBA_c (int sx, int yl, int yh) DWORD *fg2rgb = dc_srcblend; DWORD *bg2rgb = dc_destblend; - dest = ylookup[yl] + sx + dc_destorg; + dest = ylookup[yl] + sx + (uint32_t*)dc_destorg; source = &dc_temp_rgba[yl*4]; pitch = dc_pitch; 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, // 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; - 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--) 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) { int count = dc_count; - canvas_pixel_t *dest; + uint32_t *dest; fixed_t fracstep; fixed_t frac; @@ -855,7 +855,7 @@ void R_FillColumnHorizP_RGBA_C (void) { int count = dc_count; BYTE color = dc_color; - canvas_pixel_t *dest; + uint32_t *dest; if (count <= 0) return; diff --git a/src/r_main.cpp b/src/r_main.cpp index d85cd62a0..9dc61eea3 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -577,9 +577,12 @@ void R_HighlightPortal (PortalDrawseg* pds) // [ZZ] NO OVERFLOW CHECKS HERE // 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); - canvas_pixel_t* pixels = RenderTarget->GetBuffer(); + BYTE* pixels = RenderTarget->GetBuffer(); // top edge 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 Ybottom = pds->floorclip[x-pds->x1]; - canvas_pixel_t *dest = RenderTarget->GetBuffer() + x + Ytop * spacing; - - for (int y = Ytop; y <= Ybottom; y++) + if (r_swtruecolor) { - *dest = color; - dest += spacing; + uint32_t *dest = (uint32_t*)RenderTarget->GetBuffer() + x + Ytop * 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 () { - static canvas_pixel_t *lastbuff = NULL; + static BYTE *lastbuff = NULL; 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) { diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 8d0c882ba..a71590c9d 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -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 width = x2 - x1; double iz, uz, vz; - canvas_pixel_t *fb; + BYTE *fb; DWORD u, v; int i; @@ -478,6 +478,130 @@ void R_MapTiltedPlane (int y, int x1) #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 @@ -491,7 +615,7 @@ void R_MapColoredPlane_C (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); uint32_t light = calc_light_multiplier(ds_light); uint32_t color = shade_pal_index(ds_color, light); diff --git a/src/r_plane.h b/src/r_plane.h index ac63501e3..7505ac995 100644 --- a/src/r_plane.h +++ b/src/r_plane.h @@ -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)); 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_RGBA(int y, int x1); diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 548cd994f..8c71f0fb7 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -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 -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_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; //clock (WallScanCycles); + int pixelsize = r_swtruecolor ? 4 : 1; + rw_pic->GetHeight(); // Make sure texture size is loaded fracbits = 32 - rw_pic->HeightBits; 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_dest = ylookup[y1ve[0]] + x + dc_destorg; + dc_dest = (ylookup[y1ve[0]] + x)*pixelsize + dc_destorg; dc_count = y2ve[0] - y1ve[0]; iscale = swal[x] * yrepeat; 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)) { - 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; } @@ -1213,23 +1215,23 @@ void wallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *l { 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) { dc_count = d4-u4; - dc_dest = ylookup[u4]+x+dc_destorg; + dc_dest = (ylookup[u4]+x)*pixelsize+dc_destorg; dovline4(); } - canvas_pixel_t *i = x+ylookup[d4]+dc_destorg; + BYTE *i = (x+ylookup[d4])*pixelsize+dc_destorg; for (z = 0; z < 4; ++z) { 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_dest = ylookup[y1ve[0]] + x + dc_destorg; + dc_dest = (ylookup[y1ve[0]] + x) * pixelsize + dc_destorg; dc_count = y2ve[0] - y1ve[0]; iscale = swal[x] * yrepeat; 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_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)) { int x, fracbits; - canvas_pixel_t *p; + BYTE *pixel; + int pixelsize, pixelshift; int y1ve[4], y2ve[4], u4, d4, startx, dax, z; char bad; 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; //clock (WallScanCycles); + pixelsize = r_swtruecolor ? 4 : 1; + pixelshift = r_swtruecolor ? 2 : 0; + rw_pic->GetHeight(); // Make sure texture size is loaded fracbits = 32- rw_pic->HeightBits; setupmvline(fracbits); @@ -1480,7 +1486,7 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_ basecolormapdata = basecolormap->Maps; x = startx = x1; - p = x + dc_destorg; + pixel = x * pixelsize + dc_destorg; bool fixed = (fixedcolormap != NULL || fixedlightlev >= 0); if (fixed) @@ -1489,9 +1495,13 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_ palookupoffse[1] = dc_colormap; palookupoffse[2] = 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; 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_dest = ylookup[y1ve[0]] + p; + dc_dest = ylookup[y1ve[0]] * pixelsize + pixel; dc_count = y2ve[0] - y1ve[0]; iscale = swal[x] * yrepeat; dc_iscale = xs_ToFixed(fracbits, iscale); @@ -1514,7 +1524,7 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_ domvline1(); } - for(; x < x2-3; x += 4, p+= 4) + for(; x < x2-3; x += 4, pixel += 4 * pixelsize) { bad = 0; 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) { 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)) { - 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; } @@ -1563,27 +1582,27 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_ { 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) { dc_count = d4-u4; - dc_dest = ylookup[u4]+p; + dc_dest = ylookup[u4]*pixelsize+pixel; domvline4(); } - canvas_pixel_t *i = p+ylookup[d4]; + BYTE *i = pixel+ylookup[d4]*pixelsize; for (z = 0; z < 4; ++z) { 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; 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_dest = ylookup[y1ve[0]] + p; + dc_dest = ylookup[y1ve[0]]*pixelsize + pixel; dc_count = y2ve[0] - y1ve[0]; iscale = swal[x] * yrepeat; dc_iscale = xs_ToFixed(fracbits, iscale); @@ -1611,7 +1630,7 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_ 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_colormap = colormap; @@ -1628,7 +1647,8 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f fixed_t (*tmvline1)(); void (*tmvline4)(); int x, fracbits; - canvas_pixel_t *p; + BYTE *pixel; + int pixelsize, pixelshift; int y1ve[4], y2ve[4], u4, d4, startx, dax, z; char bad; 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; //clock (WallScanCycles); + pixelsize = r_swtruecolor ? 4 : 1; + pixelshift = r_swtruecolor ? 2 : 0; + rw_pic->GetHeight(); // Make sure texture size is loaded fracbits = 32 - rw_pic->HeightBits; setuptmvline(fracbits); @@ -1659,7 +1682,7 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f fixed_t centeryfrac = FLOAT2FIXED(CenterY); x = startx = x1; - p = x + dc_destorg; + pixel = x * pixelsize + dc_destorg; bool fixed = (fixedcolormap != NULL || fixedlightlev >= 0); if (fixed) @@ -1674,7 +1697,7 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f 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; 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_dest = ylookup[y1ve[0]] + p; + dc_dest = ylookup[y1ve[0]] * pixelsize + pixel; dc_count = y2ve[0] - y1ve[0]; iscale = swal[x] * yrepeat; dc_iscale = xs_ToFixed(fracbits, iscale); @@ -1696,7 +1719,7 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f tmvline1(); } - for(; x < x2-3; x += 4, p+= 4) + for(; x < x2-3; x += 4, pixel += 4 * pixelsize) { bad = 0; 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)) { - 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(); } bad >>= 1; @@ -1754,7 +1777,7 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f { 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(); } } @@ -1762,21 +1785,21 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f if (d4 > u4) { dc_count = d4-u4; - dc_dest = ylookup[u4]+p; + dc_dest = ylookup[u4]*pixelsize+pixel; tmvline4(); } - canvas_pixel_t *i = p+ylookup[d4]; + BYTE *i = pixel+ylookup[d4]*pixelsize; for (z = 0; z < 4; ++z) { 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(); } } } - for(; x < x2; ++x, ++p) + for(; x < x2; ++x, pixel += pixelsize) { light += rw_lightstep; 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_dest = ylookup[y1ve[0]] + p; + dc_dest = ylookup[y1ve[0]] * pixelsize + pixel; dc_count = y2ve[0] - y1ve[0]; iscale = swal[x] * yrepeat; dc_iscale = xs_ToFixed(fracbits, iscale); diff --git a/src/r_things.cpp b/src/r_things.cpp index 22538bd40..2abcc0e12 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -98,6 +98,7 @@ EXTERN_CVAR (Bool, st_scale) EXTERN_CVAR(Bool, r_shadercolormaps) EXTERN_CVAR(Int, r_drawfuzz) EXTERN_CVAR(Bool, r_deathcamera); +EXTERN_CVAR(Bool, r_swtruecolor) // // Sprite rotation 0 is facing the viewer, @@ -132,7 +133,7 @@ EXTERN_CVAR (Bool, r_drawvoxels) // int OffscreenBufferWidth, OffscreenBufferHeight; -canvas_pixel_t *OffscreenColorBuffer; +BYTE *OffscreenColorBuffer; FCoverageBuffer *OffscreenCoverageBuffer; // @@ -244,6 +245,7 @@ bool sprflipvert; 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 texturemid = FLOAT2FIXED(dc_texturemid); while (span->Length != 0) @@ -314,7 +316,7 @@ void R_DrawMaskedColumn (const BYTE *column, const FTexture::Span *span) } } 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; 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. if ((flags & ~DVF_MIRRORED) != 0) { + int pixelsize = r_swtruecolor ? 4 : 1; for (int x = 0; x < viewwidth; ++x) { 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_yh = span->Stop - 1; dc_count = span->Stop - span->Start; - dc_dest = ylookup[span->Start] + x + dc_destorg; + dc_dest = (ylookup[span->Start] + x) * pixelsize + dc_destorg; colfunc(); } else @@ -2602,7 +2605,7 @@ static void R_DrawMaskedSegsBehindParticle (const vissprite_t *vis) void R_DrawParticle_C (vissprite_t *vis) { int spacing; - canvas_pixel_t *dest; + BYTE *dest; BYTE color = vis->Style.colormap[vis->startfrac]; int yl = vis->y1; int ycount = vis->y2 - yl + 1; @@ -2668,7 +2671,7 @@ void R_DrawParticle_C (vissprite_t *vis) void R_DrawParticle_RGBA(vissprite_t *vis) { int spacing; - canvas_pixel_t *dest; + uint32_t *dest; BYTE color = vis->Style.colormap[vis->startfrac]; int yl = vis->y1; int ycount = vis->y2 - yl + 1; @@ -2698,7 +2701,7 @@ void R_DrawParticle_RGBA(vissprite_t *vis) dc_x = x; if (R_ClipSpriteColumnWithPortals(vis)) continue; - dest = ylookup[yl] + x + dc_destorg; + dest = ylookup[yl] + x + (uint32_t*)dc_destorg; for (int y = 0; y < ycount; y++) { uint32_t bg_red = (*dest >> 16) & 0xff; @@ -2759,6 +2762,8 @@ void R_DrawVoxel(const FVector3 &globalpos, FAngle viewangle, R_SetupDrawSlab(colormap); + int pixelsize = r_swtruecolor ? 4 : 1; + // Select mip level i = abs(DMulScale6(dasprx - globalposx, cosang, daspry - globalposy, sinang)); i = DivScale6(i, MIN(daxscale, dayscale)); @@ -3012,7 +3017,7 @@ void R_DrawVoxel(const FVector3 &globalpos, FAngle viewangle, if (!(flags & DVF_OFFSCREEN)) { // 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 { @@ -3243,12 +3248,12 @@ void R_CheckOffscreenBuffer(int width, int height, bool spansonly) { if (OffscreenColorBuffer == NULL) { - OffscreenColorBuffer = new canvas_pixel_t[width * height]; + OffscreenColorBuffer = new BYTE[width * height * 4]; } else if (OffscreenBufferWidth != width || OffscreenBufferHeight != height) { delete[] OffscreenColorBuffer; - OffscreenColorBuffer = new canvas_pixel_t[width * height]; + OffscreenColorBuffer = new BYTE[width * height * 4]; } } OffscreenBufferWidth = width; diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 984375f25..ed6571ad3 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -179,7 +179,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) fixedcolormap = dc_colormap; 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(); if (dc_destorg == NULL) { @@ -1021,7 +1021,7 @@ void DCanvas::PUTTRANSDOT (int xx, int yy, int basecolor, int level) 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_red = (fg >> 16) & 0xff; @@ -1040,7 +1040,7 @@ void DCanvas::PUTTRANSDOT (int xx, int yy, int basecolor, int level) } else { - canvas_pixel_t *spot = GetBuffer() + oldyyshifted + xx; + BYTE *spot = GetBuffer() + oldyyshifted + xx; DWORD *bg2rgb = Col2RGB8[1+level]; DWORD *fg2rgb = Col2RGB8[63-level]; 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); } - 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) { // vertical line - canvas_pixel_t *spot = GetBuffer() + y0*GetPitch() + x0; - int pitch = GetPitch (); - do + if (r_swtruecolor) { - *spot = palColor; - spot += pitch; - } while (--deltaY != 0); + uint32_t *spot = (uint32_t*)GetBuffer() + y0*GetPitch() + x0; + int pitch = GetPitch(); + 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) { // diagonal line. - canvas_pixel_t *spot = GetBuffer() + y0*GetPitch() + x0; - int advance = GetPitch() + xDir; - do + if (r_swtruecolor) { - *spot = palColor; - spot += advance; - } while (--deltaY != 0); + uint32_t *spot = (uint32_t*)GetBuffer() + y0*GetPitch() + x0; + int advance = GetPitch() + xDir; + 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 { @@ -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) { int x, y; - canvas_pixel_t *dest; 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); } - dest = Buffer + top * Pitch + left; - x = right - left; - for (y = top; y < bottom; y++) + if (r_swtruecolor) { - memset(dest, palcolor, x); - dest += Pitch; + uint32_t *dest = (uint32_t*)Buffer + top * Pitch + left; + 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 // 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 destpitch; - canvas_pixel_t *dest; + BYTE *dest; 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 { - memcpy (dest, src, _width * sizeof(canvas_pixel_t)); + memcpy (dest, src, _width); src += srcpitch; dest += destpitch; } while (--_height); @@ -1478,9 +1529,12 @@ void DCanvas::DrawBlock (int x, int y, int _width, int _height, const canvas_pix // V_GetBlock // 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 if (x<0 @@ -1496,14 +1550,14 @@ void DCanvas::GetBlock (int x, int y, int _width, int _height, canvas_pixel_t *d while (_height--) { - memcpy (dest, src, _width * sizeof(canvas_pixel_t)); + memcpy (dest, src, _width); src += Pitch; dest += _width; } } // 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) { // Completely clipped off screen diff --git a/src/v_video.cpp b/src/v_video.cpp index 2fb46e88a..01043b8bc 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -345,7 +345,6 @@ void DCanvas::Dim (PalEntry color, float damount, int x1, int y1, int w, int h) return; int gap; - canvas_pixel_t *spot; int x, y; 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; } - spot = Buffer + x1 + y1*Pitch; gap = Pitch - w; if (r_swtruecolor) { + uint32_t *spot = (uint32_t*)Buffer + x1 + y1*Pitch; + uint32_t fg = color.d; uint32_t fg_red = (fg >> 16) & 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 { + BYTE *spot = Buffer + x1 + y1*Pitch; + DWORD *bg2rgb; 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); buffer = GetBuffer(); 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); } } - MemBuffer = new canvas_pixel_t[Pitch * height]; - memset (MemBuffer, 0, Pitch * height * sizeof(canvas_pixel_t)); + MemBuffer = new BYTE[Pitch * height * 4]; + memset (MemBuffer, 0, Pitch * height * 4); } //========================================================================== @@ -917,7 +919,7 @@ void DFrameBuffer::DrawRateStuff () { int i = I_GetTime(false); int tics = i - LastTic; - canvas_pixel_t *buffer = GetBuffer(); + BYTE *buffer = GetBuffer(); LastTic = i; if (tics > 20) tics = 20; @@ -925,10 +927,21 @@ void DFrameBuffer::DrawRateStuff () // Buffer can be NULL if we're doing hardware accelerated 2D if (buffer != NULL) { - buffer += (GetHeight()-1) * GetPitch(); - - for (i = 0; i < tics*2; i += 2) buffer[i] = 0xff; - for ( ; i < 20*2; i += 2) buffer[i] = 0x00; + if (r_swtruecolor) + { + uint32_t *buffer32 = (uint32_t*)buffer; + 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 { diff --git a/src/v_video.h b/src/v_video.h index 27c09ee36..fa1ce83df 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -189,7 +189,7 @@ public: virtual ~DCanvas (); // 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 GetHeight () const { return Height; } inline int GetPitch () const { return Pitch; } @@ -202,10 +202,10 @@ public: virtual bool IsLocked () { return Buffer != NULL; } // Returns true if the surface is locked // 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. - 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 virtual void Dim (PalEntry color = 0); @@ -237,7 +237,7 @@ public: // Retrieves a buffer containing image data for a screenshot. // 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. - 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. virtual void ReleaseScreenshotBuffer(); @@ -262,13 +262,13 @@ public: void DrawChar (FFont *font, int normalcolor, int x, int y, BYTE character, int tag_first, ...); protected: - canvas_pixel_t *Buffer; + BYTE *Buffer; int Width; int Height; int Pitch; 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; 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; @@ -297,7 +297,7 @@ public: void Unlock (); protected: - canvas_pixel_t *MemBuffer; + BYTE *MemBuffer; DSimpleCanvas() {} }; diff --git a/src/win32/fb_d3d9.cpp b/src/win32/fb_d3d9.cpp index 0cc9045ee..0cd847b97 100644 --- a/src/win32/fb_d3d9.cpp +++ b/src/win32/fb_d3d9.cpp @@ -1316,7 +1316,7 @@ void D3DFB::Draw3DPart(bool copy3d) else { uint32_t *dest = (uint32_t *)lockrect.pBits; - uint32_t *src = MemBuffer; + uint32_t *src = (uint32_t*)MemBuffer; for (int y = 0; y < Height; y++) { 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; @@ -1770,7 +1770,7 @@ void D3DFB::GetScreenshotBuffer(const canvas_pixel_t *&buffer, int &pitch, ESSTy } else { - buffer = (const canvas_pixel_t *)lrect.pBits; + buffer = (const BYTE *)lrect.pBits; pitch = lrect.Pitch; color_type = SS_BGRA; } diff --git a/src/win32/fb_ddraw.cpp b/src/win32/fb_ddraw.cpp index 9be571f98..fbdf035a3 100644 --- a/src/win32/fb_ddraw.cpp +++ b/src/win32/fb_ddraw.cpp @@ -999,8 +999,8 @@ DDrawFB::LockSurfRes DDrawFB::LockSurf (LPRECT lockrect, LPDIRECTDRAWSURFACE toL LOG1 ("Final result after restoration attempts: %08lx\n", hr); return NoGood; } - Buffer = (canvas_pixel_t *)desc.lpSurface; - Pitch = desc.lPitch / sizeof(canvas_pixel_t); + Buffer = (BYTE *)desc.lpSurface; + Pitch = desc.lPitch; BufferingNow = false; return wasLost ? GoodWasLost : Good; } diff --git a/src/win32/win32iface.h b/src/win32/win32iface.h index d26765100..0b3333d63 100644 --- a/src/win32/win32iface.h +++ b/src/win32/win32iface.h @@ -252,7 +252,7 @@ public: bool PaintToWindow (); void SetVSync (bool vsync); 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 SetBlendingRect (int x1, int y1, int x2, int y2); bool Begin2D (bool copy3d);