Consistently use pixel_t for screen buffer (#2262)

This commit is contained in:
Alaux 2025-05-10 13:42:32 -03:00 committed by GitHub
parent 0ef7f192e3
commit 4d4d91de0a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 103 additions and 103 deletions

View File

@ -1090,7 +1090,7 @@ void AM_Ticker (void)
static void AM_clearFB(int color) static void AM_clearFB(int color)
{ {
int h = f_h; int h = f_h;
byte *src = I_VideoBuffer; pixel_t *src = I_VideoBuffer;
while (h--) while (h--)
{ {
memset(src, color, f_w); memset(src, color, f_w);
@ -1327,7 +1327,7 @@ static void AM_drawFline_Vanilla(fline_t* fl, int color)
// //
static void AM_putWuDot(int x, int y, int color, int weight) static void AM_putWuDot(int x, int y, int color, int weight)
{ {
byte *dest = &I_VideoBuffer[y * video.pitch + x]; pixel_t *dest = &I_VideoBuffer[y * video.pitch + x];
unsigned int *fg2rgb = Col2RGB8[weight]; unsigned int *fg2rgb = Col2RGB8[weight];
unsigned int *bg2rgb = Col2RGB8[64 - weight]; unsigned int *bg2rgb = Col2RGB8[64 - weight];
unsigned int fg, bg; unsigned int fg, bg;

View File

@ -43,9 +43,9 @@ static int wipe_columns;
// SCREEN WIPE PACKAGE // SCREEN WIPE PACKAGE
// //
static byte *wipe_scr_start; static pixel_t *wipe_scr_start;
static byte *wipe_scr_end; static pixel_t *wipe_scr_end;
static byte *wipe_scr; static pixel_t *wipe_scr;
// [FG] cross-fading screen wipe implementation // [FG] cross-fading screen wipe implementation
@ -67,9 +67,9 @@ static int wipe_doColorXForm(int width, int height, int ticks)
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
byte *sta = wipe_scr_start + y * width; pixel_t *sta = wipe_scr_start + y * width;
byte *end = wipe_scr_end + y * width; pixel_t *end = wipe_scr_end + y * width;
byte *dst = wipe_scr + y * video.pitch; pixel_t *dst = wipe_scr + y * video.pitch;
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
@ -399,8 +399,8 @@ static int wipe_doFizzle(int width, int height, int ticks)
vrect_t rect = {x, y, 1, 1}; vrect_t rect = {x, y, 1, 1};
V_ScaleRect(&rect); V_ScaleRect(&rect);
byte *src = wipe_scr_end + rect.sy * width + rect.sx; pixel_t *src = wipe_scr_end + rect.sy * width + rect.sx;
byte *dest = wipe_scr + rect.sy * video.pitch + rect.sx; pixel_t *dest = wipe_scr + rect.sy * video.pitch + rect.sx;
while (rect.sh--) while (rect.sh--)
{ {

View File

@ -915,7 +915,7 @@ void I_FinishUpdate(void)
// I_ReadScreen // I_ReadScreen
// //
void I_ReadScreen(byte *dst) void I_ReadScreen(pixel_t *dst)
{ {
V_GetBlock(0, 0, video.width, video.height, dst); V_GetBlock(0, 0, video.width, video.height, dst);
} }
@ -1104,7 +1104,7 @@ boolean I_WritePNGfile(char *filename)
// [FG] allocate memory for screenshot image // [FG] allocate memory for screenshot image
int pitch = rect.w * 3; int pitch = rect.w * 3;
int size = rect.h * pitch; int size = rect.h * pitch;
byte *pixels = malloc(size); pixel_t *pixels = malloc(size);
SDL_RenderReadPixels(renderer, &rect, SDL_PIXELFORMAT_RGB24, pixels, pitch); SDL_RenderReadPixels(renderer, &rect, SDL_PIXELFORMAT_RGB24, pixels, pitch);

View File

@ -60,7 +60,7 @@ void I_SetPalette(byte *palette);
void I_FinishUpdate(void); void I_FinishUpdate(void);
void I_ReadScreen(byte *dst); void I_ReadScreen(pixel_t *dst);
void I_ResetScreen(void); // killough 10/98 void I_ResetScreen(void); // killough 10/98
void I_ToggleVsync(void); // [JN] Calls native SDL vsync toggle void I_ToggleVsync(void); // [JN] Calls native SDL vsync toggle

View File

@ -31,10 +31,10 @@
static const char snapshot_str[] = "WOOF_SNAPSHOT"; static const char snapshot_str[] = "WOOF_SNAPSHOT";
static const int snapshot_len = arrlen(snapshot_str); static const int snapshot_len = arrlen(snapshot_str);
static const int snapshot_size = SCREENWIDTH * SCREENHEIGHT; static const int snapshot_size = (SCREENWIDTH * SCREENHEIGHT) * sizeof(pixel_t);
static byte *snapshots[10]; static pixel_t *snapshots[10];
static byte *current_snapshot; static pixel_t *current_snapshot;
static char savegametimes[10][32]; static char savegametimes[10][32];
const int MN_SnapshotDataSize(void) const int MN_SnapshotDataSize(void)
@ -132,9 +132,9 @@ static void TakeSnapshot(void)
current_snapshot = malloc(snapshot_size * sizeof(**snapshots)); current_snapshot = malloc(snapshot_size * sizeof(**snapshots));
} }
byte *p = current_snapshot; pixel_t *p = current_snapshot;
const byte *s = I_VideoBuffer; const pixel_t *s = I_VideoBuffer;
int x, y; int x, y;
for (y = 0; y < SCREENHEIGHT; y++) for (y = 0; y < SCREENHEIGHT; y++)
@ -148,7 +148,7 @@ static void TakeSnapshot(void)
R_SetViewSize(old_screenblocks); R_SetViewSize(old_screenblocks);
} }
void MN_WriteSnapshot(byte *p) void MN_WriteSnapshot(pixel_t *p)
{ {
TakeSnapshot(); TakeSnapshot();
@ -181,11 +181,11 @@ boolean MN_DrawSnapshot(int n, int x, int y, int w, int h)
const fixed_t step_x = (SCREENWIDTH << FRACBITS) / rect.sw; const fixed_t step_x = (SCREENWIDTH << FRACBITS) / rect.sw;
const fixed_t step_y = (SCREENHEIGHT << FRACBITS) / rect.sh; const fixed_t step_y = (SCREENHEIGHT << FRACBITS) / rect.sh;
byte *dest = I_VideoBuffer + rect.sy * video.pitch + rect.sx; pixel_t *dest = I_VideoBuffer + rect.sy * video.pitch + rect.sx;
fixed_t srcx, srcy; fixed_t srcx, srcy;
int destx, desty; int destx, desty;
byte *destline, *srcline; pixel_t *destline, *srcline;
for (desty = 0, srcy = 0; desty < rect.sh; desty++, srcy += step_y) for (desty = 0, srcy = 0; desty < rect.sh; desty++, srcy += step_y)
{ {

View File

@ -54,7 +54,7 @@ int viewwidth;
int viewheight; int viewheight;
int viewwindowx; int viewwindowx;
int viewwindowy; int viewwindowy;
static byte **ylookup = NULL; static pixel_t **ylookup = NULL;
static int *columnofs = NULL; static int *columnofs = NULL;
static int linesize; // killough 11/98 static int linesize; // killough 11/98
@ -112,7 +112,7 @@ byte dc_skycolor;
dc_x); \ dc_x); \
} \ } \
\ \
byte *dest = ylookup[dc_yl] + columnofs[dc_x]; \ pixel_t *dest = ylookup[dc_yl] + columnofs[dc_x]; \
\ \
const fixed_t fracstep = dc_iscale; \ const fixed_t fracstep = dc_iscale; \
fixed_t frac = dc_texturemid + (dc_yl - centery) * fracstep; \ fixed_t frac = dc_texturemid + (dc_yl - centery) * fracstep; \
@ -200,7 +200,7 @@ void R_DrawSkyColumn(void)
} }
#endif #endif
byte *dest = ylookup[dc_yl] + columnofs[dc_x]; pixel_t *dest = ylookup[dc_yl] + columnofs[dc_x];
const fixed_t fracstep = dc_iscale; const fixed_t fracstep = dc_iscale;
fixed_t frac = dc_texturemid + (dc_yl - centery) * fracstep; fixed_t frac = dc_texturemid + (dc_yl - centery) * fracstep;
@ -406,7 +406,7 @@ static void DrawFuzzColumnOriginal(void)
// or blocky mode removed. // or blocky mode removed.
// Does not work with blocky mode. // Does not work with blocky mode.
byte *dest = ylookup[dc_yl] + columnofs[dc_x]; pixel_t *dest = ylookup[dc_yl] + columnofs[dc_x];
// Looks like an attempt at dithering, // Looks like an attempt at dithering,
// using the colormap #6 (of 0-31, a bit brighter than average). // using the colormap #6 (of 0-31, a bit brighter than average).
@ -484,7 +484,7 @@ static void DrawFuzzColumnBlocky(void)
++count; ++count;
byte *dest = ylookup[dc_yl] + columnofs[dc_x]; pixel_t *dest = ylookup[dc_yl] + columnofs[dc_x];
int lines = fuzzblocksize - (dc_yl % fuzzblocksize); int lines = fuzzblocksize - (dc_yl % fuzzblocksize);
@ -578,7 +578,7 @@ static void DrawFuzzColumnRefraction(void)
++count; ++count;
byte *dest = ylookup[dc_yl] + columnofs[dc_x]; pixel_t *dest = ylookup[dc_yl] + columnofs[dc_x];
int lines = fuzzblocksize - (dc_yl % fuzzblocksize); int lines = fuzzblocksize - (dc_yl % fuzzblocksize);
@ -644,7 +644,7 @@ static void DrawFuzzColumnShadow(void)
} }
#endif #endif
byte *dest = ylookup[dc_yl] + columnofs[dc_x]; pixel_t *dest = ylookup[dc_yl] + columnofs[dc_x];
count++; // killough 1/99: minor tuning count++; // killough 1/99: minor tuning
@ -769,66 +769,66 @@ fixed_t ds_ystep;
// start of a 64*64 tile image // start of a 64*64 tile image
byte *ds_source; byte *ds_source;
#define R_DRAW_SPAN(NAME, SRCPIXEL) \ #define R_DRAW_SPAN(NAME, SRCPIXEL) \
static void DrawSpan##NAME(void) \ static void DrawSpan##NAME(void) \
{ \ { \
byte *dest = ylookup[ds_y] + columnofs[ds_x1]; \ pixel_t *dest = ylookup[ds_y] + columnofs[ds_x1]; \
\ \
unsigned count = ds_x2 - ds_x1 + 1; \ unsigned count = ds_x2 - ds_x1 + 1; \
\ \
unsigned xtemp, ytemp, spot; \ unsigned xtemp, ytemp, spot; \
\ \
while (count >= 4) \ while (count >= 4) \
{ \ { \
byte src; \ byte src; \
ytemp = (ds_yfrac >> 10) & 0x0FC0; \ ytemp = (ds_yfrac >> 10) & 0x0FC0; \
xtemp = (ds_xfrac >> 16) & 0x003F; \ xtemp = (ds_xfrac >> 16) & 0x003F; \
spot = xtemp | ytemp; \ spot = xtemp | ytemp; \
ds_xfrac += ds_xstep; \ ds_xfrac += ds_xstep; \
ds_yfrac += ds_ystep; \ ds_yfrac += ds_ystep; \
src = ds_source[spot]; \ src = ds_source[spot]; \
dest[0] = SRCPIXEL; \ dest[0] = SRCPIXEL; \
\ \
ytemp = (ds_yfrac >> 10) & 0x0FC0; \ ytemp = (ds_yfrac >> 10) & 0x0FC0; \
xtemp = (ds_xfrac >> 16) & 0x003F; \ xtemp = (ds_xfrac >> 16) & 0x003F; \
spot = xtemp | ytemp; \ spot = xtemp | ytemp; \
ds_xfrac += ds_xstep; \ ds_xfrac += ds_xstep; \
ds_yfrac += ds_ystep; \ ds_yfrac += ds_ystep; \
src = ds_source[spot]; \ src = ds_source[spot]; \
dest[1] = SRCPIXEL; \ dest[1] = SRCPIXEL; \
\ \
ytemp = (ds_yfrac >> 10) & 0x0FC0; \ ytemp = (ds_yfrac >> 10) & 0x0FC0; \
xtemp = (ds_xfrac >> 16) & 0x003F; \ xtemp = (ds_xfrac >> 16) & 0x003F; \
spot = xtemp | ytemp; \ spot = xtemp | ytemp; \
ds_xfrac += ds_xstep; \ ds_xfrac += ds_xstep; \
ds_yfrac += ds_ystep; \ ds_yfrac += ds_ystep; \
src = ds_source[spot]; \ src = ds_source[spot]; \
dest[2] = SRCPIXEL; \ dest[2] = SRCPIXEL; \
\ \
ytemp = (ds_yfrac >> 10) & 0x0FC0; \ ytemp = (ds_yfrac >> 10) & 0x0FC0; \
xtemp = (ds_xfrac >> 16) & 0x003F; \ xtemp = (ds_xfrac >> 16) & 0x003F; \
spot = xtemp | ytemp; \ spot = xtemp | ytemp; \
ds_xfrac += ds_xstep; \ ds_xfrac += ds_xstep; \
ds_yfrac += ds_ystep; \ ds_yfrac += ds_ystep; \
src = ds_source[spot]; \ src = ds_source[spot]; \
dest[3] = SRCPIXEL; \ dest[3] = SRCPIXEL; \
\ \
dest += 4; \ dest += 4; \
count -= 4; \ count -= 4; \
} \ } \
\ \
while (count) \ while (count) \
{ \ { \
byte src; \ byte src; \
ytemp = (ds_yfrac >> 10) & 0x0FC0; \ ytemp = (ds_yfrac >> 10) & 0x0FC0; \
xtemp = (ds_xfrac >> 16) & 0x003F; \ xtemp = (ds_xfrac >> 16) & 0x003F; \
spot = xtemp | ytemp; \ spot = xtemp | ytemp; \
ds_xfrac += ds_xstep; \ ds_xfrac += ds_xstep; \
ds_yfrac += ds_ystep; \ ds_yfrac += ds_ystep; \
src = ds_source[spot]; \ src = ds_source[spot]; \
*dest++ = SRCPIXEL; \ *dest++ = SRCPIXEL; \
count--; \ count--; \
} \ } \
} }
R_DRAW_SPAN(, ds_colormap[0][src]) R_DRAW_SPAN(, ds_colormap[0][src])

View File

@ -829,7 +829,7 @@ static void VX_DrawColumn (vissprite_t * spr, int x, int y)
boolean shadow = ((spr->mobjflags & MF_SHADOW) != 0); boolean shadow = ((spr->mobjflags & MF_SHADOW) != 0);
int linesize = video.pitch; int linesize = video.pitch;
byte * dest = I_VideoBuffer + viewwindowy * linesize + viewwindowx; pixel_t * dest = I_VideoBuffer + viewwindowy * linesize + viewwindowx;
// iterate over screen columns // iterate over screen columns
fixed_t ux = ((Ax - 1) | FRACMASK) + 1; fixed_t ux = ((Ax - 1) | FRACMASK) + 1;

View File

@ -1435,7 +1435,7 @@ static void DrawSolidBackground(void)
{ {
for (x = 0; x < depth; x++) for (x = 0; x < depth; x++)
{ {
byte *c = st_backing_screen + V_ScaleY(y) * video.pitch pixel_t *c = st_backing_screen + V_ScaleY(y) * video.pitch
+ V_ScaleX(x); + V_ScaleX(x);
r += pal[3 * c[0] + 0]; r += pal[3 * c[0] + 0];
g += pal[3 * c[0] + 1]; g += pal[3 * c[0] + 1];

View File

@ -272,7 +272,7 @@ static void (*drawcolfunc)(const patch_column_t *patchcol);
patchcol->y2, patchcol->x); \ patchcol->y2, patchcol->x); \
} \ } \
\ \
byte *dest = V_ADDRESS(dest_screen, patchcol->x, patchcol->y1); \ pixel_t *dest = V_ADDRESS(dest_screen, patchcol->x, patchcol->y1); \
\ \
const fixed_t fracstep = patchcol->step; \ const fixed_t fracstep = patchcol->step; \
fixed_t frac = \ fixed_t frac = \
@ -568,13 +568,13 @@ void V_ShadeScreen(void)
{ {
const byte *darkcolormap = &colormaps[0][20 * 256]; const byte *darkcolormap = &colormaps[0][20 * 256];
byte *row = dest_screen; pixel_t *row = dest_screen;
int height = video.height; int height = video.height;
while (height--) while (height--)
{ {
int width = video.width; int width = video.width;
byte *col = row; pixel_t *col = row;
while (width--) while (width--)
{ {
@ -656,7 +656,7 @@ void V_FillRect(int x, int y, int width, int height, byte color)
ScaleClippedRect(&dstrect); ScaleClippedRect(&dstrect);
byte *dest = V_ADDRESS(dest_screen, dstrect.sx, dstrect.sy); pixel_t *dest = V_ADDRESS(dest_screen, dstrect.sx, dstrect.sy);
while (dstrect.sh--) while (dstrect.sh--)
{ {
@ -677,7 +677,7 @@ void V_CopyRect(int srcx, int srcy, pixel_t *source, int width, int height,
int destx, int desty) int destx, int desty)
{ {
vrect_t srcrect, dstrect; vrect_t srcrect, dstrect;
byte *src, *dest; pixel_t *src, *dest;
int usew, useh; int usew, useh;
#ifdef RANGECHECK #ifdef RANGECHECK
@ -745,8 +745,8 @@ void V_CopyRect(int srcx, int srcy, pixel_t *source, int width, int height,
void V_DrawBlock(int x, int y, int width, int height, pixel_t *src) void V_DrawBlock(int x, int y, int width, int height, pixel_t *src)
{ {
const byte *source; const pixel_t *source;
byte *dest; pixel_t *dest;
vrect_t dstrect; vrect_t dstrect;
dstrect.x = x; dstrect.x = x;
@ -775,7 +775,7 @@ void V_DrawBlock(int x, int y, int width, int height, pixel_t *src)
int w; int w;
fixed_t xfrac, yfrac; fixed_t xfrac, yfrac;
int xtex, ytex; int xtex, ytex;
byte *row; pixel_t *row;
yfrac = 0; yfrac = 0;
@ -801,7 +801,7 @@ void V_DrawBlock(int x, int y, int width, int height, pixel_t *src)
void V_TileBlock64(int line, int width, int height, const byte *src) void V_TileBlock64(int line, int width, int height, const byte *src)
{ {
byte *dest, *row; pixel_t *dest, *row;
fixed_t xfrac, yfrac; fixed_t xfrac, yfrac;
int xtex, ytex, h; int xtex, ytex, h;
vrect_t dstrect; vrect_t dstrect;
@ -847,9 +847,9 @@ void V_TileBlock64(int line, int width, int height, const byte *src)
// No return value // No return value
// //
void V_GetBlock(int x, int y, int width, int height, byte *dest) void V_GetBlock(int x, int y, int width, int height, pixel_t *dest)
{ {
byte *src; pixel_t *src;
#ifdef RANGECHECK #ifdef RANGECHECK
if (x < 0 || x + width > video.width || y < 0 || y + height > video.height) if (x < 0 || x + width > video.width || y < 0 || y + height > video.height)
@ -870,9 +870,9 @@ void V_GetBlock(int x, int y, int width, int height, byte *dest)
// [FG] non hires-scaling variant of V_DrawBlock, used in disk icon drawing // [FG] non hires-scaling variant of V_DrawBlock, used in disk icon drawing
void V_PutBlock(int x, int y, int width, int height, byte *src) void V_PutBlock(int x, int y, int width, int height, pixel_t *src)
{ {
byte *dest; pixel_t *dest;
#ifdef RANGECHECK #ifdef RANGECHECK
if (x < 0 || x + width > video.width || y < 0 || y + height > video.height) if (x < 0 || x + width > video.width || y < 0 || y + height > video.height)