Skip to content

Commit

Permalink
Rename variables to avoid shadowing
Browse files Browse the repository at this point in the history
  • Loading branch information
LegalizeAdulthood committed Feb 18, 2024
1 parent 98c1d46 commit e5ba839
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 60 deletions.
35 changes: 15 additions & 20 deletions common/diskvid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,48 +624,43 @@ static void write_cache_lru()
switch (pixelshift)
{
case 0:
for (int i = 0; i < BLOCKLEN; ++i)
for (int j = 0; j < BLOCKLEN; ++j)
{
mem_putc(*(pixelptr++));
}
break;
case 1:
for (int i = 0; i < BLOCKLEN/2; ++i)
for (int j = 0; j < BLOCKLEN/2; ++j)
{
tmpchar = (BYTE)(*(pixelptr++) << 4);
tmpchar = (BYTE)(tmpchar + *(pixelptr++));
mem_putc(tmpchar);
}
break;
case 2:
for (int i = 0; i < BLOCKLEN/4; ++i)
for (int j = 0; j < BLOCKLEN/4; ++j)
{
for (int j = 6; j >= 0; j -= 2)
for (int k = 6; k >= 0; k -= 2)
{
tmpchar = (BYTE)((tmpchar << 2) + *(pixelptr++));
}
mem_putc(tmpchar);
}
break;
case 3:
for (int i = 0; i < BLOCKLEN/8; ++i)
for (int j = 0; j < BLOCKLEN/8; ++j)
{
// clang-format off
mem_putc((BYTE)
((((((((((((((*pixelptr
<< 1)
| *(pixelptr+1))
<< 1)
| *(pixelptr+2))
<< 1)
| *(pixelptr+3))
<< 1)
| *(pixelptr+4))
<< 1)
| *(pixelptr+5))
<< 1)
| *(pixelptr+6))
<< 1)
| *(pixelptr+7)));
(((((((*pixelptr << 1
| *(pixelptr + 1)) << 1
| *(pixelptr + 2)) << 1
| *(pixelptr + 3)) << 1
| *(pixelptr + 4)) << 1
| *(pixelptr + 5)) << 1
| *(pixelptr + 6)) << 1
| *(pixelptr + 7)));
// clang-format on
pixelptr += 8;
}
break;
Expand Down
8 changes: 3 additions & 5 deletions common/editpal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2545,14 +2545,12 @@ static void PalTable__other_key(int key, RGBEditor *rgb, void *info)
case 'T':
case 't': // s(T)ripe mode
{
int key;

Cursor_Hide();
PalTable__DrawStatus(me, true);
key = getakeynohelp();
const int key2 = getakeynohelp();
Cursor_Show();

if (key >= '1' && key <= '9')
if (key2 >= '1' && key2 <= '9')
{
int a = me->curr[0],
b = me->curr[1];
Expand All @@ -2568,7 +2566,7 @@ static void PalTable__other_key(int key, RGBEditor *rgb, void *info)

if (a != b)
{
mkpalrange(&me->pal[a], &me->pal[b], &me->pal[a], b-a, key-'0');
mkpalrange(&me->pal[a], &me->pal[b], &me->pal[a], b-a, key2-'0');
PalTable__UpdateDAC(me);
}
}
Expand Down
14 changes: 7 additions & 7 deletions common/encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ bool encoder()
else
{
// uh oh - better fake it
for (int i = 0; i < 256; i += 16)
for (int j = 0; j < 256; j += 16)
{
if (!shftwrite((BYTE *)paletteEGA, 16))
{
Expand Down Expand Up @@ -673,14 +673,14 @@ bool encoder()
esave_info.max_random_mutation = g_evolve_info.max_random_mutation;
esave_info.ecount = g_evolve_info.ecount;
}
for (int i = 0; i < NUM_GENES; i++)
for (int j = 0; j < NUM_GENES; j++)
{
esave_info.mutate[i] = (short)g_gene_bank[i].mutate;
esave_info.mutate[j] = (short)g_gene_bank[j].mutate;
}

for (int i = 0; i < sizeof(esave_info.future) / sizeof(short); i++)
for (int j = 0; j < sizeof(esave_info.future) / sizeof(short); j++)
{
esave_info.future[i] = 0;
esave_info.future[j] = 0;
}

// some XFRACT logic for the doubles needed here
Expand All @@ -707,9 +707,9 @@ bool encoder()
osave_info.oy3rd = g_orbit_corner_3_y;
osave_info.keep_scrn_coords = (short) (g_keep_screen_coords ? 1 : 0);
osave_info.drawmode = g_draw_mode;
for (int i = 0; i < sizeof(osave_info.future) / sizeof(short); i++)
for (short &j : osave_info.future)
{
osave_info.future[i] = 0;
j = 0;
}

// some XFRACT logic for the doubles needed here
Expand Down
8 changes: 4 additions & 4 deletions common/fracsubr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1552,7 +1552,7 @@ void sleepms(long ms)
* last call has elapsed.
*/
#define MAX_INDEX 2
static uclock_t next_time[MAX_INDEX];
static uclock_t s_next_time[MAX_INDEX];
void wait_until(int index, uclock_t wait_time)
{
if (g_debug_flag == debug_flags::force_old_sleep)
Expand All @@ -1562,21 +1562,21 @@ void wait_until(int index, uclock_t wait_time)
else
{
uclock_t now;
while ((now = usec_clock()) < next_time[index])
while ((now = usec_clock()) < s_next_time[index])
{
if (driver_key_pressed())
{
break;
}
}
next_time[index] = now + wait_time*100; // wait until this time next call
s_next_time[index] = now + wait_time*100; // wait until this time next call
}
}

void reset_clock()
{
restart_uclock();
std::fill(std::begin(next_time), std::end(next_time), 0);
std::fill(std::begin(s_next_time), std::end(s_next_time), 0);
}

#define LOG2 0.693147180F
Expand Down
32 changes: 16 additions & 16 deletions common/fractals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1727,17 +1727,17 @@ int MPCHalleyFractal()
MPC mpcXtoAlessOne, mpcXtoA;
MPC mpcXtoAplusOne; // a-1, a, a+1
MPC mpcFX, mpcF1prime, mpcF2prime, mpcHalnumer1;
MPC mpcHalnumer2, mpcHaldenom, mpctmp;
MPC mpcHalnumer2, mpcHaldenom, mpctmp2;

g_mp_overflow = 0;
mpcXtoAlessOne.x = mpcold.x;
mpcXtoAlessOne.y = mpcold.y;
for (int ihal = 2; ihal < g_degree; ihal++)
{
mpctmp.x = *pMPsub(*pMPmul(mpcXtoAlessOne.x, mpcold.x), *pMPmul(mpcXtoAlessOne.y, mpcold.y));
mpctmp.y = *pMPadd(*pMPmul(mpcXtoAlessOne.x, mpcold.y), *pMPmul(mpcXtoAlessOne.y, mpcold.x));
mpcXtoAlessOne.x = mpctmp.x;
mpcXtoAlessOne.y = mpctmp.y;
mpctmp2.x = *pMPsub(*pMPmul(mpcXtoAlessOne.x, mpcold.x), *pMPmul(mpcXtoAlessOne.y, mpcold.y));
mpctmp2.y = *pMPadd(*pMPmul(mpcXtoAlessOne.x, mpcold.y), *pMPmul(mpcXtoAlessOne.y, mpcold.x));
mpcXtoAlessOne.x = mpctmp2.x;
mpcXtoAlessOne.y = mpctmp2.y;
}
mpcXtoA.x = *pMPsub(*pMPmul(mpcXtoAlessOne.x, mpcold.x), *pMPmul(mpcXtoAlessOne.y, mpcold.y));
mpcXtoA.y = *pMPadd(*pMPmul(mpcXtoAlessOne.x, mpcold.y), *pMPmul(mpcXtoAlessOne.y, mpcold.x));
Expand All @@ -1753,21 +1753,21 @@ int MPCHalleyFractal()
mpcF1prime.x = *pMPsub(*pMPmul(g_halley_mp_a_plus_one, mpcXtoA.x), g_mp_one);
mpcF1prime.y = *pMPmul(g_halley_mp_a_plus_one, mpcXtoA.y); // F'

mpctmp.x = *pMPsub(*pMPmul(mpcF2prime.x, mpcFX.x), *pMPmul(mpcF2prime.y, mpcFX.y));
mpctmp.y = *pMPadd(*pMPmul(mpcF2prime.x, mpcFX.y), *pMPmul(mpcF2prime.y, mpcFX.x));
mpctmp2.x = *pMPsub(*pMPmul(mpcF2prime.x, mpcFX.x), *pMPmul(mpcF2prime.y, mpcFX.y));
mpctmp2.y = *pMPadd(*pMPmul(mpcF2prime.x, mpcFX.y), *pMPmul(mpcF2prime.y, mpcFX.x));
// F * F"

mpcHaldenom.x = *pMPadd(mpcF1prime.x, mpcF1prime.x);
mpcHaldenom.y = *pMPadd(mpcF1prime.y, mpcF1prime.y); // 2 * F'

mpcHalnumer1 = MPCdiv(mpctmp, mpcHaldenom); // F"F/2F'
mpctmp.x = *pMPsub(mpcF1prime.x, mpcHalnumer1.x);
mpctmp.y = *pMPsub(mpcF1prime.y, mpcHalnumer1.y); // F' - F"F/2F'
mpcHalnumer2 = MPCdiv(mpcFX, mpctmp);
mpcHalnumer1 = MPCdiv(mpctmp2, mpcHaldenom); // F"F/2F'
mpctmp2.x = *pMPsub(mpcF1prime.x, mpcHalnumer1.x);
mpctmp2.y = *pMPsub(mpcF1prime.y, mpcHalnumer1.y); // F' - F"F/2F'
mpcHalnumer2 = MPCdiv(mpcFX, mpctmp2);

mpctmp = MPCmul(g_mpc_temp_param, mpcHalnumer2); // mpctmpparm is
mpctmp2 = MPCmul(g_mpc_temp_param, mpcHalnumer2); // mpctmpparm is
// relaxation coef.
mpcnew = MPCsub(mpcold, mpctmp);
mpcnew = MPCsub(mpcold, mpctmp2);
g_new_z = MPC2cmplx(mpcnew);
return MPCHalleybailout() || g_mp_overflow;
#else
Expand Down Expand Up @@ -2113,11 +2113,11 @@ static int TryFloatFractal(int (*fpFractal)())
int TrigXTrigFractal()
{
#if !defined(XFRACT)
LComplex ltmp2;
LComplex ltmp3;
// z = trig0(z)*trig1(z)
LCMPLXtrig0(g_l_old_z, g_l_temp);
LCMPLXtrig1(g_l_old_z, ltmp2);
LCMPLXmult(g_l_temp, ltmp2, g_l_new_z);
LCMPLXtrig1(g_l_old_z, ltmp3);
LCMPLXmult(g_l_temp, ltmp3, g_l_new_z);
if (g_overflow)
{
TryFloatFractal(TrigXTrigfpFractal);
Expand Down
16 changes: 8 additions & 8 deletions common/framain2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,11 @@ main_state big_while_loop(bool *const kbdmore, bool *const stacked, bool const r
if (g_map_specified)
{
// but there's a map=, so load that
for (int i = 0; i < 256; ++i)
for (int j = 0; j < 256; ++j)
{
g_dac_box[i][0] = g_map_clut[i][0];
g_dac_box[i][1] = g_map_clut[i][1];
g_dac_box[i][2] = g_map_clut[i][2];
g_dac_box[j][0] = g_map_clut[j][0];
g_dac_box[j][1] = g_map_clut[j][1];
g_dac_box[j][2] = g_map_clut[j][2];
}
spindac(0, 1);
}
Expand Down Expand Up @@ -1114,9 +1114,9 @@ main_state main_menu_switch(int *kbdchar, bool *frommandel, bool *kbdmore, bool
int err;
double oldparm[MAX_PARAMS];
fractal_type oldtype = g_fractal_type;
for (int i = 0; i < MAX_PARAMS; ++i)
for (int j = 0; j < MAX_PARAMS; ++j)
{
oldparm[i] = g_params[i];
oldparm[j] = g_params[j];
}
if (g_fractal_type != fractal_type::ANT)
{
Expand All @@ -1143,9 +1143,9 @@ main_state main_menu_switch(int *kbdchar, bool *frommandel, bool *kbdmore, bool
driver_unstack_screen();
}
g_fractal_type = oldtype;
for (int i = 0; i < MAX_PARAMS; ++i)
for (int j = 0; j < MAX_PARAMS; ++j)
{
g_params[i] = oldparm[i];
g_params[j] = oldparm[j];
}
if (err >= 0)
{
Expand Down

0 comments on commit e5ba839

Please sign in to comment.