Prev: $298B Up: Map Next: $2A43
$29C8: Check whether a character has been hit by a pellet or a stampeding boy
Used by the routines at $0FBA and $2873.
Input
X Target x-coordinate
Y Target y-coordinate
Output
A Number of character who was hit (or 0 if nobody was hit)
P Carry flag set if a character was knocked over
$29C8 CPX $8C61 Does ERIC's x-coordinate match that of the target?
$29CB BNE $29E2 Branch if not.
$29CD CPY $8C62 Does ERIC's y-coordinate match that of the target?
$29D0 BNE $29E2 Branch if not.
$29D2 LDA $2B Set bit 4 of ERIC's status flags at $2B: ERIC has been knocked down.
$29D4 ORA #$10
$29D6 STA $2B
$29D8 LDA #$00 Set ERIC's posture indicator at $14 to 0: ERIC is not standing up.
$29DA STA $14
$29DC LDA #$14 Character number $14 is ERIC.
$29DE SEC Set the carry flag: a character (ERIC) was knocked over.
$29DF JMP $2A42 Return.
$29E2 STX $0B Store the target coordinates at $0B and $0C.
$29E4 STY $0C
$29E6 JSR $33BF Restore the current character's buffer from page 0.
$29E9 LDA $60 Pick up the current character number from $60 and store it at $2F.
$29EB STA $2F
$29ED LDA #$0B Set the current character number at $60 to $0B (MR WACKER).
$29EF STA $60
Here we enter a loop to check whether any of the teachers or main kids (besides ERIC) were hit.
$29F1 JSR $3279 Copy the potential victim's character buffer to page 0.
$29F4 LDA $FC Pick up the potential victim's x-coordinate.
$29F6 CMP $0B Does it match that of the target?
$29F8 BNE $2A00 Branch if not.
$29FA LDA $FB Pick up the potential victim's y-coordinate.
$29FC CMP $0C Does it match that of the target?
$29FE BEQ $2A0B Branch if so.
$2A00 LDA $60 Pick up the current character number from $60.
$2A02 CMP #$11 Is it $11 (EINSTEIN)?
$2A04 BEQ $2A2E Branch if so (there is no one left to check).
$2A06 INC $60 Increment the current character number at $60.
$2A08 JMP $29F1 Jump back to check the next character.
$2A0B LDA $B1 Is the potential victim currently controlled by an uninterruptible subcommand?
$2A0D BEQ $2A19 Branch if not.
$2A0F LDA $60 Pick up the current character number from $60.
$2A11 CMP #$0F Is it $0B-$0E (a teacher)?
$2A13 BCS $2A00 Branch if not.
$2A15 CLC Clear the carry flag: no one was knocked over.
$2A16 JMP $2A31 Jump forward.
This entry point is used by the routines at $17E5 and $2696.
$2A19 LDA #$2A Place the address of the uninterruptible subcommand routine at $2A43 into the character's buffer.
$2A1B STA $B1
$2A1D LDA #$43
$2A1F STA $B0
$2A21 LDA #$14 Initialise the delay counter at $B2 that determines how long the character will stay down.
$2A23 STA $B2
$2A25 JSR $33BF Restore the character's buffer from page 0.
$2A28 LDA $60 Pick up the current character number from $60.
$2A2A SEC Set the carry flag: a character was knocked over.
$2A2B JMP $2A31 Jump forward.
$2A2E LDA #$00 A=0: no one was hit.
$2A30 CLC Clear the carry flag: no one was hit.
$2A31 STA $57 Store the victim's character number (or 0) at $57.
$2A33 ROL A Save the carry flag in bit 0 at $56 temporarily.
$2A34 STA $56
$2A36 LDA $2F Restore the saved character number from $2F.
$2A38 STA $60
$2A3A JSR $3279 Copy the current character's buffer into page 0.
$2A3D LDA $56 Restore the carry flag from bit 0 at $56.
$2A3F ROR A
$2A40 LDA $57 Pick up the victim's character number (or 0) from $57.
$2A42 RTS
Prev: $298B Up: Map Next: $2A43