Skip to content

Commit

Permalink
Use unified flat filling function (#1116)
Browse files Browse the repository at this point in the history
* Doom: use unified flat filling function

* Doom: StBar background was also done

* Const's are actually possible

Thanks linter for warning

* Heretic: use unified flat filling function

* Hexen: use unified flat filling function

* Strife: use unified flat filling function

* Code style: remove unnecessary spaces

* Reduce scope of `x` variables
  • Loading branch information
JNechaevsky authored Nov 30, 2023
1 parent f9ddf41 commit 8618898
Show file tree
Hide file tree
Showing 17 changed files with 64 additions and 270 deletions.
24 changes: 3 additions & 21 deletions src/doom/f_finale.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ void F_TextWrite (void)
byte* src;
pixel_t* dest;

int x,y,w;
int w;

Check warning on line 275 in src/doom/f_finale.c

View workflow job for this annotation

GitHub Actions / cpp-linter (clang)

/src/doom/f_finale.c:275:10 [cppcoreguidelines-init-variables]

variable 'w' is not initialized

Check warning on line 275 in src/doom/f_finale.c

View workflow job for this annotation

GitHub Actions / cpp-linter (clang)

/src/doom/f_finale.c:275:10 [readability-identifier-length]

variable name 'w' is too short, expected at least 3 characters
signed int count;
char *ch; // [crispy] un-const
int c;
Expand All @@ -283,26 +283,8 @@ void F_TextWrite (void)
src = W_CacheLumpName ( finaleflat , PU_CACHE);
dest = I_VideoBuffer;

for (y=0 ; y<SCREENHEIGHT ; y++)
{
#ifndef CRISPY_TRUECOLOR
for (x=0 ; x<SCREENWIDTH/64 ; x++)
{
memcpy (dest, src+((y&63)<<6), 64);
dest += 64;
}
if (SCREENWIDTH&63)
{
memcpy (dest, src+((y&63)<<6), SCREENWIDTH&63);
dest += (SCREENWIDTH&63);
}
#else
for (x=0 ; x<SCREENWIDTH ; x++)
{
*dest++ = colormaps[src[((y&63)<<6) + (x&63)]];
}
#endif
}
// [crispy] use unified flat filling function
V_FillFlat(0, SCREENHEIGHT, 0, SCREENWIDTH, src, dest);

V_MarkRect (0, 0, SCREENWIDTH, SCREENHEIGHT);

Expand Down
15 changes: 2 additions & 13 deletions src/doom/m_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1438,27 +1438,16 @@ static void M_DrawCrispnessBackground(void)
{
const byte *src = crispness_background;
pixel_t *dest;
int x, y;

// [NS] Try to load the background from a lump.
int lump = W_CheckNumForName("CRISPYBG");
if (lump != -1 && W_LumpLength(lump) >= 64*64)
{
src = W_CacheLumpNum(lump, PU_STATIC);
src = W_CacheLumpNum(lump, PU_CACHE);
}
dest = I_VideoBuffer;

for (y = 0; y < SCREENHEIGHT; y++)
{
for (x = 0; x < SCREENWIDTH; x++)
{
#ifndef CRISPY_TRUECOLOR
*dest++ = src[(y & 63) * 64 + (x & 63)];
#else
*dest++ = colormaps[src[(y & 63) * 64 + (x & 63)]];
#endif
}
}
V_FillFlat(0, SCREENHEIGHT, 0, SCREENWIDTH, src, dest);

inhelpscreens = true;
}
Expand Down
23 changes: 2 additions & 21 deletions src/doom/r_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1126,27 +1126,8 @@ void R_FillBackScreen (void)
src = W_CacheLumpName(name, PU_CACHE);
dest = background_buffer;

for (y=0 ; y<SCREENHEIGHT-SBARHEIGHT ; y++)
{
#ifndef CRISPY_TRUECOLOR
for (x=0 ; x<SCREENWIDTH/64 ; x++)
{
memcpy (dest, src+((y&63)<<6), 64);
dest += 64;
}

if (SCREENWIDTH&63)
{
memcpy (dest, src+((y&63)<<6), SCREENWIDTH&63);
dest += (SCREENWIDTH&63);
}
#else
for (x=0 ; x<SCREENWIDTH ; x++)
{
*dest++ = colormaps[src[((y&63)<<6) + (x&63)]];
}
#endif
}
// [crispy] use unified flat filling function
V_FillFlat(0, SCREENHEIGHT-SBARHEIGHT, 0, SCREENWIDTH, src, dest);

// Draw screen and bezel; this is done to a separate screen buffer.

Expand Down
15 changes: 3 additions & 12 deletions src/doom/st_stuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,29 +407,20 @@ void ST_refreshBackground(boolean force)
// so it appears to the left and right of the status bar in widescreen mode
if ((SCREENWIDTH >> crispy->hires) != ST_WIDTH)
{
int x, y;
byte *src;
pixel_t *dest;
const char *name = (gamemode == commercial) ? DEH_String("GRNROCK") : DEH_String("FLOOR7_2");

src = W_CacheLumpName(name, PU_CACHE);
dest = st_backing_screen;

for (y = SCREENHEIGHT-(ST_HEIGHT<<crispy->hires); y < SCREENHEIGHT; y++)
{
for (x = 0; x < SCREENWIDTH; x++)
{
#ifndef CRISPY_TRUECOLOR
*dest++ = src[((y&63)<<6) + (x&63)];
#else
*dest++ = colormaps[src[((y&63)<<6) + (x&63)]];
#endif
}
}
// [crispy] use unified flat filling function
V_FillFlat(SCREENHEIGHT-(ST_HEIGHT<<crispy->hires), SCREENHEIGHT, 0, SCREENWIDTH, src, dest);

// [crispy] preserve bezel bottom edge
if (scaledviewwidth == SCREENWIDTH)
{
int x;

Check warning on line 423 in src/doom/st_stuff.c

View workflow job for this annotation

GitHub Actions / cpp-linter (clang)

/src/doom/st_stuff.c:423:8 [cppcoreguidelines-init-variables]

variable 'x' is not initialized

Check warning on line 423 in src/doom/st_stuff.c

View workflow job for this annotation

GitHub Actions / cpp-linter (clang)

/src/doom/st_stuff.c:423:8 [readability-identifier-length]

variable name 'x' is too short, expected at least 3 characters
patch_t *const patch = W_CacheLumpName(DEH_String("brdr_b"), PU_CACHE);

for (x = 0; x < WIDESCREENDELTA; x += 8)
Expand Down
23 changes: 2 additions & 21 deletions src/heretic/f_finale.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ void F_TextWrite(void)
{
byte *src;
pixel_t *dest;
int x, y;
int count;
const char *ch;
int c;
Expand All @@ -163,26 +162,8 @@ void F_TextWrite(void)
//
src = W_CacheLumpName(finaleflat, PU_CACHE);
dest = I_VideoBuffer;
for (y = 0; y < SCREENHEIGHT; y++)
{
#ifndef CRISPY_TRUECOLOR
for (x = 0; x < SCREENWIDTH / 64; x++)
{
memcpy(dest, src + ((y & 63) << 6), 64);
dest += 64;
}
if (SCREENWIDTH & 63)
{
memcpy(dest, src + ((y & 63) << 6), SCREENWIDTH & 63);
dest += (SCREENWIDTH & 63);
}
#else
for (x = 0; x < SCREENWIDTH; x++)
{
*dest++ = colormaps[src[((y & 63) << 6) + (x & 63)]];
}
#endif
}
// [crispy] use unified flat filling function
V_FillFlat(0, SCREENHEIGHT, 0, SCREENWIDTH, src, dest);

// V_MarkRect (0, 0, SCREENWIDTH, SCREENHEIGHT);

Expand Down
24 changes: 2 additions & 22 deletions src/heretic/in_lude.c
Original file line number Diff line number Diff line change
Expand Up @@ -618,35 +618,15 @@ void IN_Drawer(void)

void IN_DrawStatBack(void)
{
int x;
int y;

byte *src;
pixel_t *dest;

src = W_CacheLumpName(DEH_String("FLOOR16"), PU_CACHE);
dest = I_VideoBuffer;

for (y = 0; y < SCREENHEIGHT; y++)
{
#ifndef CRISPY_TRUECOLOR
for (x = 0; x < SCREENWIDTH / 64; x++)
{
memcpy(dest, src + ((y & 63) << 6), 64);
dest += 64;
}
if (SCREENWIDTH & 63)
{
memcpy(dest, src + ((y & 63) << 6), SCREENWIDTH & 63);
dest += (SCREENWIDTH & 63);
}
#else
for (x = 0; x < SCREENWIDTH; x++)
{
*dest++ = colormaps[src[((y & 63) << 6) + (x & 63)]];
}
#endif
}
// [crispy] use unified flat filling function
V_FillFlat(0, SCREENHEIGHT, 0, SCREENWIDTH, src, dest);
}

//========================================================================
Expand Down
22 changes: 1 addition & 21 deletions src/heretic/mn_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2560,7 +2560,6 @@ static void M_DrawCrispnessBackground(void)
{
byte *src;
pixel_t *dest;
int x, y;

if (gamemode == shareware)
{
Expand All @@ -2572,26 +2571,7 @@ static void M_DrawCrispnessBackground(void)
}
dest = I_VideoBuffer;

for (y = 0; y < SCREENHEIGHT; y++)
{
#ifndef CRISPY_TRUECOLOR
for (x = 0; x < SCREENWIDTH / 64; x++)
{
memcpy(dest, src + ((y & 63) << 6), 64);
dest += 64;
}
if (SCREENWIDTH & 63)
{
memcpy(dest, src + ((y & 63) << 6), SCREENWIDTH & 63);
dest += (SCREENWIDTH & 63);
}
#else
for (x = 0; x < SCREENWIDTH; x++)
{
*dest++ = colormaps[src[(y & 63) * 64 + (x & 63)]];
}
#endif
}
V_FillFlat(0, SCREENHEIGHT, 0, SCREENWIDTH, src, dest);

SB_state = -1;
}
Expand Down
49 changes: 8 additions & 41 deletions src/heretic/r_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,26 +493,9 @@ void R_DrawViewBorder(void)
}
dest = I_VideoBuffer;

for (y = 0; y < SCREENHEIGHT - SBARHEIGHT; y++)
{
#ifndef CRISPY_TRUECOLOR
for (x = 0; x < SCREENWIDTH / 64; x++)
{
memcpy(dest, src + ((y & 63) << 6), 64);
dest += 64;
}
if (SCREENWIDTH & 63)
{
memcpy(dest, src + ((y & 63) << 6), SCREENWIDTH & 63);
dest += (SCREENWIDTH & 63);
}
#else
for (x = 0; x < SCREENWIDTH; x++)
{
*dest++ = colormaps[src[((y & 63) << 6) + (x & 63)]];
}
#endif
}
// [crispy] use unified flat filling function
V_FillFlat(0, SCREENHEIGHT - SBARHEIGHT, 0, SCREENWIDTH, src, dest);

for (x = (viewwindowx >> crispy->hires); x < (viewwindowx + viewwidth) >> crispy->hires; x += 16)
{
V_DrawPatch(x - WIDESCREENDELTA, (viewwindowy >> crispy->hires) - 4,
Expand Down Expand Up @@ -556,7 +539,6 @@ void R_DrawTopBorder(void)
{
byte *src;
pixel_t *dest;
int x, y;

if (scaledviewwidth == SCREENWIDTH)
return;
Expand All @@ -571,28 +553,13 @@ void R_DrawTopBorder(void)
}
dest = I_VideoBuffer;

for (y = 0; y < (30 << crispy->hires); y++)
{
#ifndef CRISPY_TRUECOLOR
for (x = 0; x < SCREENWIDTH / 64; x++)
{
memcpy(dest, src + ((y & 63) << 6), 64);
dest += 64;
}
if (SCREENWIDTH & 63)
{
memcpy(dest, src + ((y & 63) << 6), SCREENWIDTH & 63);
dest += (SCREENWIDTH & 63);
}
#else
for (x = 0; x < SCREENWIDTH; x++)
{
*dest++ = colormaps[src[((y & 63) << 6) + (x & 63)]];
}
#endif
}
// [crispy] use unified flat filling function
V_FillFlat(0, 30 << crispy->hires, 0, SCREENWIDTH, src, dest);

if ((viewwindowy >> crispy->hires) < 25)
{
int x;

Check warning on line 561 in src/heretic/r_draw.c

View workflow job for this annotation

GitHub Actions / cpp-linter (clang)

/src/heretic/r_draw.c:561:13 [cppcoreguidelines-init-variables]

variable 'x' is not initialized

Check warning on line 561 in src/heretic/r_draw.c

View workflow job for this annotation

GitHub Actions / cpp-linter (clang)

/src/heretic/r_draw.c:561:13 [readability-identifier-length]

variable name 'x' is too short, expected at least 3 characters

for (x = (viewwindowx >> crispy->hires); x < (viewwindowx + viewwidth) >> crispy->hires; x += 16)
{
V_DrawPatch(x - WIDESCREENDELTA, (viewwindowy >> crispy->hires) - 4,
Expand Down
14 changes: 2 additions & 12 deletions src/heretic/sb_bar.c
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,6 @@ static void RefreshBackground()

if ((SCREENWIDTH >> crispy->hires) != ORIGWIDTH)
{
int x, y;
byte *src;
pixel_t *dest;
const char *name = (gamemode == shareware) ?
Expand All @@ -616,21 +615,12 @@ static void RefreshBackground()
src = W_CacheLumpName(name, PU_CACHE);
dest = st_backing_screen;

for (y = SCREENHEIGHT - (42 << crispy->hires); y < SCREENHEIGHT; y++)
{
for (x = 0; x < SCREENWIDTH; x++)
{
#ifndef CRISPY_TRUECOLOR
*dest++ = src[((y & 63) << 6) + (x & 63)];
#else
*dest++ = colormaps[src[((y & 63) << 6) + (x & 63)]];
#endif
}
}
V_FillFlat(SCREENHEIGHT - (42 << crispy->hires), SCREENHEIGHT, 0, SCREENWIDTH, src, dest);

// [crispy] preserve bezel bottom edge
if (scaledviewwidth == SCREENWIDTH)
{
int x;

Check warning on line 623 in src/heretic/sb_bar.c

View workflow job for this annotation

GitHub Actions / cpp-linter (clang)

/src/heretic/sb_bar.c:623:17 [cppcoreguidelines-init-variables]

variable 'x' is not initialized

Check warning on line 623 in src/heretic/sb_bar.c

View workflow job for this annotation

GitHub Actions / cpp-linter (clang)

/src/heretic/sb_bar.c:623:17 [readability-identifier-length]

variable name 'x' is too short, expected at least 3 characters
patch_t *const patch = W_CacheLumpName("bordb", PU_CACHE);

for (x = 0; x < WIDESCREENDELTA; x += 16)
Expand Down
15 changes: 1 addition & 14 deletions src/hexen/mn_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2557,24 +2557,11 @@ static void DrawMouseMenu(void)
static void M_DrawCrispnessBackground(void)
{
byte *src, *dest;
int x, y;

src = W_CacheLumpName("F_022", PU_CACHE);
dest = I_VideoBuffer;

for (y = 0; y < SCREENHEIGHT; y++)
{
for (x = 0; x < SCREENWIDTH / 64; x++)
{
memcpy(dest, src + ((y & 63) << 6), 64);
dest += 64;
}
if (SCREENWIDTH & 63)
{
memcpy(dest, src + ((y & 63) << 6), SCREENWIDTH & 63);
dest += (SCREENWIDTH & 63);
}
}
V_FillFlat(0, SCREENHEIGHT, 0, SCREENWIDTH, src, dest);

SB_state = -1;
}
Expand Down
Loading

0 comments on commit 8618898

Please sign in to comment.