This code appears in the following versions (click to see it in the source code):
Code variations between these versions are shown below.
.OUCH JSR DORND \ Set A and X to random numbersName: OUCH Type: Subroutine Category: Flight Summary: Potentially lose cargo or equipment following damage
Our shields are dead and we are taking damage, so there is a small chance of losing cargo or equipment.
LDY #3 \ Set bit 1 of de, the equipment destruction flag, so STY de \ that when we call MESS below, " DESTROYED" is appended \ to the in-flight message STA QQ20,X \ A is 0 (as we didn't branch with the BNE above), so \ this sets QQ20+X to 0, which destroys any cargo or \ equipment we have of that type CPX #17 \ If X >= 17 then we just lost a piece of equipment, so BCS ou1 \ jump to ou1 to print the relevant message
.ou1 BEQ ou2 \ If X = 17, jump to ou2 to print "E.C.M.SYSTEM \ DESTROYED" and return from the subroutine using a tail \ call CPX #18 \ If X = 18, jump to ou3 to print "FUEL SCOOPS BEQ ou3 \ DESTROYED" and return from the subroutine using a tail \ call TXA \ Otherwise X is in the range 19 to 21 and the C flag is ADC #113-20 \ set (as we got here via a BCS to ou1), so we set A as \ follows: \ \ A = 113 - 20 + X + C \ = 113 - 19 + X \ = 113 to 115