I don't have it completely figured out right now, but I'm using this space as scratch paper while I figure it out, and also so that anyone interested can view and/or contribute.
I will edit this post with whatever new things I discover, to eventually have it fully documented.
Rank is a 2-byte value stored at 0xC0D922 in main CPU memory. It's range is from 0x00-0x2F.
It is initialized to 0x14 at game start, on all difficulties, and without regard to auto/semiauto/manual powerup setting.
Power ups:
The game keeps track of how many of the missile, double/laser, and ? powerups you have activated. The double/laser are together because you cannot have both active at once.
The game also keeps track of how many options you have, for a maximum of 3. Even though some ships can have 4 options, the third one you activate is treated as a special case (see below). So having 4 options technically counts as 3.
In both variables, the maximum value is 3. The lower of these two values is the amount added to the rank.
A few examples:
Missile + Laser + Shield + 0 option = +0
Missile + 1 option = +1
Missile + 2 option = +1
2 options = +0
Missle + Laser/Double + Shield + 4 option = +3
The game considers your third option a special case, and with any ship, is +1 for having it.
Speed ups have no effect on rank.
(I'm sure there is a better way to express that formula but I can't think of it right now

There is a counter at 0xC0D926 that keeps track of the time since your last death.
More info as it comes...