Why don't I have a custom title by now?!
Weapons 8 and 9 are the chainsaw and supershotgun, presumably, following their order in the code:
// The defined weapons,
// including a marker indicating
// user has not changed weapon.
// No pending weapon change.
In vanilla Doom, when you have the chainsaw in your inventory and press the 1 key, you do not select the chainsaw: you still select the fist. But there is a hack to replace it with the chainsaw, unless you have the berserk item or you are already using the chainsaw.
if (newweapon == wp_fist
&& !(player->readyweapon == wp_chainsaw
newweapon = wp_chainsaw;
In plain English: "If the fists are selected, and the player owns a chainsaw but does not have the berserk or is not already using a chainsaw, then replace the selection of the fists by that of the chainsaw."
Likewise for the supershotgun:
if ( (gamemode == commercial)
&& newweapon == wp_shotgun
&& player->readyweapon != wp_supershotgun)
newweapon = wp_supershotgun;
"If we're in Doom II and the player selects the shotgun but has a supershotgun he isn't currently using, select the supershotgun instead."