Thanks, that's very helpful. I understand almost all of what you posted. There's just one thing that baffles me.
I stepped through a test, starting from C2/79D3, and ending at C2/7AEF, so see exactly how it reaches the "adjusted damage" value.
That would be simple enough, except for this:
$C2/95A7 A5 41 LDA $41 [$00:0041] A:00E1 X:08C0 Y:0000 P:envmxdiZc
$C2/95A9 A8 TAY A:0003 X:08C0 Y:0000 P:envmxdizc
...Which doesn't make sense, because at that point in the execution, there should be a
zero in $41:
$C2/9580 64 41 STZ $41 [$00:0041] A:F0B4 X:08C0 Y:0005 P:envMxdizc
Instead, it ended up returning a 3.
The only explanation I can think of is that it has something to do with the 17 RORs that were performed on $40 between C2/9580 and and C2/95A7.
So my question is, if all it did is rotate a bunch of zeros, then how did it produce a 3?