| Routines

62668: Make ALBERT keep an eye out for ERIC during lessons

The address of this continual subcommand routine is placed into bytes 23 and 24 of ALBERT's buffer by command list 76. Makes ALBERT raise his arm and alert MR WACKER if ERIC enters the 'danger zone' (within 6 spaces to the left of ALBERT). Also makes ALBERT lower his arm if ERIC leaves the danger zone.
Input
H | 205 (ALBERT)
62668 | LD L,0 | Point HL at byte 0 of ALBERT's buffer
62670 | LD A,(HL) | A=ALBERT's animatory state
62671 | OR 250 | Is ALBERT midstride or lying on his back?
62673 | RET PO | Return if so
62674 | LD DE,(53761) | Collect ERIC's coordinates in DE
62678 | LD A,D | A=ERIC's y-coordinate
62679 | CP 14 | Is ERIC above the level of the stage?
62681 | JR C,62698 | Jump if so
62683 | LD A,E | A=ERIC's x-coordinate
62684 | CP 96 | Is ERIC inside the boys' skool?
62686 | JR C,62698 | Jump if so
62688 | LD L,1 | Point HL at byte 1 of ALBERT's buffer
62690 | CP (HL) | Is ERIC to the left of ALBERT?
62691 | JR NC,62698 | Jump if not
62693 | ADD A,6 | Is ERIC within 6 spaces to the left of ALBERT?
62695 | CP (HL)
62696 | JR NC,62711 | Jump if so
ERIC's not in the danger zone. Make ALBERT lower his arm if he has it raised.
62698 | LD L,0 | Point HL at byte 0 of ALBERT's buffer
62700 | LD A,(HL) | A=ALBERT's animatory state
62701 | CP 127 | 127: Is ALBERT facing left with his arm up?
62703 | RET NZ | Return if not
62704 | POP BC | Drop the return address (25431) from the stack
62705 | POP BC | Drop the character buffer reference used by the routine at 25296
62706 | LD A,120 | 120: ALBERT facing left, standing, with his arm down
62708 | JP 62452 | Update ALBERT's animatory state and SRB
ERIC is in the danger zone near ALBERT.
62711 | DEC L | L=0
62712 | POP BC | Drop the return address (25431) from the stack
62713 | POP BC | Drop the character buffer reference used by the routine at 25296
62714 | BIT 7,(HL) | Is ALBERT facing right?
62716 | JP NZ,25648 | Turn ALBERT round if so
62719 | LD A,127 | 127: ALBERT facing left with his arm up
62721 | CP (HL) | Is ALBERT already holding ERIC back?
62722 | RET Z | Return if so
62723 | CALL 62452 | Make ALBERT put his arm up and update the SRB
62726 | LD HL,32640 | 32640 holds various game status flags
62729 | BIT 1,(HL) | Is MR WACKER already looking for ERIC in order to expel him?
62731 | JR NZ,62750 | Jump if so
62733 | BIT 2,(HL) | Is MR WACKER already looking for the truant ERIC?
62735 | JR NZ,62750 | Jump if so
62737 | SET 2,(HL) | Signal: MR WACKER is looking for the truant ERIC
62739 | LD HL,51227 | Place the address of the command list at 62766 into bytes 27 and 28 of MR WACKER's buffer; this command list contains a single entry: the address of the routine at 32054
62742 | LD (HL),46
62744 | INC L
62745 | LD (HL),245
62747 | INC L | Set bit 0 of byte 29 of MR WACKER's buffer, triggering a command list restart (at 62766)
62748 | SET 0,(HL)
62750 | LD H,205 | 205=ALBERT
62752 | CALL 29696 | Determine the coordinates at which to print ALBERT's exclamation
62755 | CALL 27276 | Save the area of the screen that will be overwritten by the message box
62758 | LD BC,25138 | B=98 (MR WACKER^HE'S ESCAPING), C=50 (INK 2: PAPER 6)
62761 | LD A,2 | The border colour will be red
62763 | JP 29811 | Make ALBERT sound the alarm