May I ask why you do
"if (leftvol > 63) leftvol = 63;
if (rightvol > 63) rightvol = 63;"
rather than
"
leftvol &= 63;
rightvol &= 63;
" ?
Because I didn't know I could. I tend to code in non-clever ways. I'll leave the weirdness to the experts.
That's not exactly "clever" C code ... "+=", "-=", "*=", "/=", etc are pretty standard stuff.
OTOH ...
if (leftvol > 63) leftvol = 63;is actually very different to ...
leftvol &= 63;Your version clamps an over-the-limit value of 64 to the maximum of 63.
NightWolve's version wraps 64 back to 0 (which is pretty-much-never what you want in practice).
Given that neither are particularly good end-results, and that you're programming for a fairly-slow videogame console and not a medical life-saving device ... IMHO it's best not to waste the CPU cycles by even trying to clamp/wrap it, and just leave it up to the programmer to feed it legal values.