Here is another example of how I would comment code. This is again from Teemu. When you comment like this you don't have to read the code, only comments, to find out what the code is doing.
void T_Command::Show_Keyboard_Code(int x, int y)
{
//construct key and command names to char buffer 'ot' to display it
char ot[16];
int p=0;
const char ac=cmd_data[cmd].actual_key;
//get the letter of keycode and add possible ~ or ^ index before it
//for alt+ or ctrl+ commands
SDL_Keycode k=cmd_data[cmd].key_code;
const int mk=cmd_data[cmd].mod_key_code;
if (mk==kmCtrl) ot[p++]='^';
else if (mk==kmAlt) ot[p++]='~';
//save the position of letter in 'ot' for possible lowercase change
int sp=p;
//handle special cases to get shorter key names than SDL2 has
switch (k)
{
case SDLK_ESCAPE: p+=sprintf(ot+p, "Esc"); break;
default:
{
if (ac!=0) ot[p++]=ac;
else p+=sprintf(ot+p, "%s", SDL_GetKeyName(k));
}
break;
}
//lowercase SDL keyname for letters (which for some reason are uppercase in SDL2)
if (k>=SDLK_a && k<=SDLK_z)
{
//..but only if it's a lowercase command (shift not pressed)
if (mk==kmNone) ot[sp]=(char)tolower(ot[sp]);
}
ot[p]=0;
//draw the underline between letter and command name
const int xa=n_str->Get_Line_Width(ot);
const int w=64-xa;
const int fw=n_str->Font_Width();
const int fh=n_str->Font_Height();
SDL_Color scol=t_gui->guitheme.Get_Window_Border_Color();
const int px=(x*fw)+xa;
const int py=(y*fh)+fh;
for (int t=0; t<w; t+=3)
t_gui->Draw_Shape(shape::Filled_Rectangle, px+t, py-5, 1, 1, scol);
//show debug commands in green
if (Is_Debug_Command()) n_str->Set_Color(cEmerald_Green);
else t_gui->Set_Font_Color(geWindow_Font);
//show letter and command name
n_str->Write_To(x, y, ot);
n_str->Write_To(x+5, y, cmd_data[cmd].command_name);
}