Prev: $27D1 Up: Map Next: $284F
$27D2: Check whether anyone was or can be punched by ERIC or ANGELFACE
Used by the routines at $17E5, $2696 and $270D.
Input
X Target x-coordinate
Y Target y-coordinate
Output
A Character number of the potential victim (if any)
P Carry flag set if there is someone punchable at the target coordinates
$27D2 LDA $26 Pick up ERIC's or ANGELFACE's animatory state from $26 and store it at $0A.
$27D4 STA $0A
$27D6 STX $0B Store the target coordinates at $0B and $0C.
$27D8 STY $0C
$27DA JSR $33BF Restore ERIC's or ANGELFACE's buffer from page 0.
$27DD LDA $60 Pick up the current character number from $60.
$27DF PHA Save it temporarily.
$27E0 LDA #$14 Set the current character number at $60 to $14 (ERIC).
$27E2 STA $60
$27E4 JSR $3279 Copy ERIC's character buffer to page 0.
$27E7 LDA $FB Pick up ERIC's y-coordinate from $FB.
$27E9 CMP $0C Does it match the target y-coordinate?
$27EB BNE $2800 Branch if not.
$27ED LDA $FC Pick up ERIC's x-coordinate from $FC.
$27EF CMP $0B Does it match the target x-coordinate?
$27F1 BNE $2800 Branch if not.
$27F3 LDA $26 Pick up ERIC's animatory state from $26.
$27F5 EOR $0A Is ERIC facing the puncher?
$27F7 ASL A
$27F8 BCC $2800 Branch if not.
$27FA LDA $60 Pick up ERIC's character number from $60.
$27FC SEC Set the carry flag: there is someone (ERIC) at the target coordinates.
$27FD JMP $283E Jump forward.
$2800 LDA #$0F Set the current character number at $60 to $0F (ANGELFACE).
$2802 STA $60
Here we enter a loop to check whether ANGELFACE, BOY WONDER, EINSTEIN or any of the little boys are at the target location.
$2804 JSR $3279 Copy the current character's buffer to page 0.
$2807 LDA $FB Pick up the character's y-coordinate from $FB.
$2809 CMP $0C Does it match the target y-coordinate?
$280B BNE $2824 Branch if not.
$280D LDA $FC Pick up the character's x-coordinate from $FC.
$280F CMP $0B Does it match the target x-coordinate?
$2811 BNE $2824 Branch if not.
$2813 LDA $B1 Is the character currently controlled by an uninterruptible subcommand routine?
$2815 BNE $2824 Branch if so.
$2817 LDA $26 Pick up the character's animatory state from $26.
$2819 EOR $0A Is the character facing the puncher?
$281B ASL A
$281C BCC $2824 Branch if not.
$281E LDA $60 Pick up the current character's number from $60.
$2820 SEC Set the carry flag: there is someone at the target coordinates.
$2821 JMP $283E Jump forward.
$2824 LDA $60 Pick up the current character number from $60.
$2826 CMP #$11 Have we just checked character number $11 (EINSTEIN)?
$2828 BNE $2831 Branch if not.
$282A LDA #$00 Otherwise start checking the little boys.
$282C STA $60 Update the current character number at $60.
$282E JMP $2804 Jump back to the start of the loop.
$2831 CMP #$0A Is the current character number $0A (little boy no. 11)?
$2833 BNE $2839 Branch if not.
$2835 CLC Clear the carry flag: there is no one at the target coordinates.
$2836 JMP $283E Jump forward.
$2839 INC $60 Increment the current character number at $60.
$283B JMP $2804 Jump back to the start of the loop.
$283E STA $57 Store the character number of the potential victim at $57.
$2840 ROL A Rotate the carry flag into bit 0 of A and store it at $56 temporarily.
$2841 STA $56
$2843 PLA Restore the current character number to A.
$2844 STA $60 Update the current character number at $60.
$2846 JSR $3279 Copy the current character's buffer into page 0.
$2849 LDA $56 Restore the carry flag from bit 0 at $56.
$284B LSR A
$284C LDA $57 Pick up the character number of the potential victim.
$284E RTS
Prev: $27D1 Up: Map Next: $284F