| Routines

F41F: Deal with ERIC when he's firing the catapult

Used by the routine at 6AD9 when bit 0 of ERIC's status flags at 7FFB is set (by the routine at F46E).
F41F | LD HL,$7FF6 | 7FF6 holds the catapult-firing action timer (initially 0x18)
F422 | DEC (HL) | Has ERIC finished firing the catapult?
F423 | JR NZ,$F434 | Jump if not
This entry point is used by the routines at F4A4 and F533 to restore ERIC's animatory state to what it was before he jumped or threw a punch.
F425 | XOR A | Clear all of ERIC's status flags at 7FFB
F426 | LD ($7FFB),A
F429 | LD H,$AC | 0xAC=ERIC
F42B | CALL $6214 | Update the SRB for ERIC's current animatory state
F42E | LD L,$66 | Restore ERIC's animatory state to what it was before he fired the catapult, jumped, or threw the punch
F430 | LD A,(HL)
F431 | JP $61B0 | Update ERIC's animatory state and location and update the SRB
ERIC hasn't finished firing the catapult. Check which phase of the firing action we're at.
F434 | LD A,(HL) | Pick up the current value of the action timer in A
F435 | LD H,$AC | 0xAC=ERIC
F437 | CP $12 | Is it time to raise the catapult to eye level?
F439 | JP Z,$7041 | Jump if so
F43C | CP $06 | Is it time to start lowering the catapult?
F43E | JP Z,$706B | Jump if so
F441 | CP $0C | Is it time to launch the pellet?
F443 | RET NZ | Return if not
It's time to launch the catapult pellet.
F444 | LD L,$60 | Byte 0x60 of ERIC's buffer holds his animatory state
F446 | LD A,(HL) | Pick this up in A
F447 | OR $7F | A=0x7F or 0xFF (catapult pellet)
F449 | INC L | Pick up ERIC's coordinates in DE; they will be the initial coordinates of the catapult pellet
F44A | LD D,(HL)
F44B | INC L
F44C | LD E,(HL)
F44D | DEC H | H=0xAB (ERIC's catapult pellet)
F44E | CALL $7057 | Launch the catapult pellet
F451 | CALL $FE75 | Play the catapult sound effect
F454 | LD B,$0D | Reprimand message 0x0D: CATAPULTS ARE FORBIDDEN
This entry point is used by the routines at F4A4 (with B=0x0E: DON'T HIT YOUR MATES) and F533 (with B=0x0F: YOU ARE NOT A KANGAROO).
F456 | LD H,$AC | 0xAC=ERIC
F458 | PUSH BC | Save the reprimand message identifier
F459 | CALL $6E3C | Check whether any teachers saw ERIC throw a punch, fire his catapult, or jump
F45C | POP BC | Restore the reprimand message identifier to B
F45D | RET NC | Return if ERIC wasn't seen by a teacher
F45E | EXX |
F45F | LD L,$61 | Byte 0x61 of the teacher's buffer holds his y-coordinate
F461 | LD D,(HL) | Pick up the coordinates of the teacher who saw ERIC in DE'
F462 | INC L
F463 | LD E,(HL)
F464 | PUSH DE |
F465 | EXX |
F466 | POP DE | Now DE holds the coordinates of the teacher who saw ERIC
F467 | LD A,H | A=0xAC (ERIC)
F468 | JP $7700 | Make the teacher give ERIC lines