Skip to content

Commit

Permalink
Use local copy of fuzz_alpha for potential optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
JNechaevsky committed Dec 14, 2024
1 parent 7b0fedc commit da82f12
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/doom/r_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ void R_DrawFuzzColumn(void)
int i;
const int *fuzzoffsetbase; // [PN] local pointer to fuzzoffset
int local_fuzzpos = fuzzpos; // [PN] local copy of fuzzpos for potential optimization
const int fuzzalpha = fuzz_alpha; // [JN] local copy of fuzz alpha value for potential optimization

// [PN] Adjust borders
if (!dc_yl)
Expand Down Expand Up @@ -368,7 +369,7 @@ void R_DrawFuzzColumn(void)
{
int fuzz_offset = SCREENWIDTH * fuzzoffsetbase[local_fuzzpos];

*dest = I_BlendDark(dest[fuzz_offset], fuzz_alpha);
*dest = I_BlendDark(dest[fuzz_offset], fuzzalpha);

// [PN] Update fuzzpos
local_fuzzpos = (local_fuzzpos + 1) % FUZZTABLE;
Expand All @@ -386,7 +387,7 @@ void R_DrawFuzzColumn(void)
{
int fuzz_offset = SCREENWIDTH * (fuzzoffsetbase[local_fuzzpos] - FUZZOFF) / 2;

*dest = I_BlendDark(dest[fuzz_offset], fuzz_alpha);
*dest = I_BlendDark(dest[fuzz_offset], fuzzalpha);
}

// [PN] restore fuzzpos
Expand All @@ -411,6 +412,7 @@ void R_DrawFuzzColumnLow(void)
int i;
const int *fuzzoffsetbase;
int local_fuzzpos = fuzzpos; // [PN] local copy for optimization
const int fuzzalpha = fuzz_alpha; // [JN] local copy for optimization

// [PN] Adjust borders
if (!dc_yl)
Expand Down Expand Up @@ -441,8 +443,8 @@ void R_DrawFuzzColumnLow(void)
{
int fuzz_offset = SCREENWIDTH * fuzzoffsetbase[local_fuzzpos];

*dest = I_BlendDark(dest[fuzz_offset], fuzz_alpha);
*dest2 = I_BlendDark(dest2[fuzz_offset], fuzz_alpha);
*dest = I_BlendDark(dest[fuzz_offset], fuzzalpha);
*dest2 = I_BlendDark(dest2[fuzz_offset], fuzzalpha);

// [PN] Update fuzzpos
local_fuzzpos = (local_fuzzpos + 1) % FUZZTABLE;
Expand All @@ -461,8 +463,8 @@ void R_DrawFuzzColumnLow(void)
{
int fuzz_offset = SCREENWIDTH * (fuzzoffsetbase[local_fuzzpos] - FUZZOFF) / 2;

*dest = I_BlendDark(dest[fuzz_offset], fuzz_alpha);
*dest2 = I_BlendDark(dest2[fuzz_offset], fuzz_alpha);
*dest = I_BlendDark(dest[fuzz_offset], fuzzalpha);
*dest2 = I_BlendDark(dest2[fuzz_offset], fuzzalpha);
}

// [PN] Restore fuzzpos
Expand Down Expand Up @@ -574,6 +576,7 @@ void R_DrawFuzzBWColumn(void)
int i;
const int *fuzzoffsetbase;
int local_fuzzpos = fuzzpos; // [PN] local copy of fuzzpos
const int fuzzalpha = fuzz_alpha; // [JN] local copy of fuzz alpha value

// [PN] Adjust borders
if (!dc_yl)
Expand Down Expand Up @@ -601,7 +604,7 @@ void R_DrawFuzzBWColumn(void)
{
int fuzz_offset = SCREENWIDTH * fuzzoffsetbase[local_fuzzpos];

*dest = I_BlendDarkGrayscale(dest[fuzz_offset], fuzz_alpha);
*dest = I_BlendDarkGrayscale(dest[fuzz_offset], fuzzalpha);

// [PN] Update fuzzpos
local_fuzzpos = (local_fuzzpos + 1) % FUZZTABLE;
Expand All @@ -614,7 +617,7 @@ void R_DrawFuzzBWColumn(void)
if (cutoff)
{
int fuzz_offset = SCREENWIDTH * (fuzzoffsetbase[local_fuzzpos] - FUZZOFF) / 2;
*dest = I_BlendDarkGrayscale(dest[fuzz_offset], fuzz_alpha);
*dest = I_BlendDarkGrayscale(dest[fuzz_offset], fuzzalpha);
}

// [PN] Restore fuzzpos
Expand All @@ -635,6 +638,7 @@ void R_DrawFuzzBWColumnLow(void)
int i;
const int *fuzzoffsetbase;
int local_fuzzpos = fuzzpos; // [PN] local copy of fuzzpos
const int fuzzalpha = fuzz_alpha; // [JN] local copy of fuzz alpha value

// [PN] Adjust borders
if (!dc_yl)
Expand Down Expand Up @@ -665,8 +669,8 @@ void R_DrawFuzzBWColumnLow(void)
{
int fuzz_offset = SCREENWIDTH * fuzzoffsetbase[local_fuzzpos];

*dest = I_BlendDarkGrayscale(dest[fuzz_offset], fuzz_alpha);
*dest2 = I_BlendDarkGrayscale(dest2[fuzz_offset], fuzz_alpha);
*dest = I_BlendDarkGrayscale(dest[fuzz_offset], fuzzalpha);
*dest2 = I_BlendDarkGrayscale(dest2[fuzz_offset], fuzzalpha);

// [PN] Update fuzzpos
local_fuzzpos = (local_fuzzpos + 1) % FUZZTABLE;
Expand All @@ -681,8 +685,8 @@ void R_DrawFuzzBWColumnLow(void)
{
int fuzz_offset = SCREENWIDTH * (fuzzoffsetbase[local_fuzzpos] - FUZZOFF) / 2;

*dest = I_BlendDarkGrayscale(dest[fuzz_offset], fuzz_alpha);
*dest2 = I_BlendDarkGrayscale(dest2[fuzz_offset], fuzz_alpha);
*dest = I_BlendDarkGrayscale(dest[fuzz_offset], fuzzalpha);
*dest2 = I_BlendDarkGrayscale(dest2[fuzz_offset], fuzzalpha);
}

// [PN] Restore fuzzpos
Expand Down

0 comments on commit da82f12

Please sign in to comment.