Back to Skool Routines
28672: Check for walls, closed doors and ALBERT in front of ERIC or the bike
Used by the routines at 29194 (when the bike is travelling of its own accord, or ERIC is standing on the saddle) and 29278 (when ERIC is sitting on the bike). Returns with the zero flag set if a wall or closed door lies in ERIC's or the bike's path, or the carry flag set if ALBERT is impeding ERIC's or the bike's progress.
A ERIC's or the bike's animatory state
E ERIC's or the bike's x-coordinate
28672 RLCA Set the carry flag if ERIC or the bike is facing right
28673 LD HL,32756 32756 holds the doors flags
28676 LD A,E A=ERIC's/bike's x-coordinate
28677 JR NC,28722 Jump if ERIC/bike is facing left
28679 CP 189 189: far right of girls' skool
28681 RET Z Return with the zero flag set if ERIC/bike has hit the far wall of the girls' skool
28682 CP 93 93: just left of boys' skool door
28684 JR NZ,28692 Jump if ERIC/bike hasn't hit the boys' skool door
28686 BIT 3,(HL) Is the boys' skool door open?
28688 JR NZ,28719 Jump if so
28690 CP A Return with the zero flag set if ERIC/bike has hit the boys' skool door or the skool gate
28691 RET
28692 CP 132 132: just left of skool gate
28694 JR NZ,28702 Jump if ERIC/bike hasn't hit the skool gate
28696 BIT 4,(HL) Is the skool gate closed?
28698 JR Z,28690 Jump if so
28700 JR 28719
Neither the skool door nor the skool gate is in the way. What about ALBERT?
28702 LD A,(52480) A=ALBERT's animatory state
28705 CP 127 127: Is ALBERT facing left with his arm up?
28707 JR NZ,28719 Jump if not
28709 LD A,(52481) A=ALBERT's x-coordinate
28712 SUB 2 A=x-coordinate of spot 2 spaces in front of ALBERT
28714 CP E Is ERIC/bike here?
28715 JR NZ,28719 Jump if not
28717 SCF Signal: ALBERT is stopping ERIC/bike
28718 RET
No obstruction lies in ERIC's or the bike's path.
28719 LD A,L Set A to a non-zero value
28720 AND A Return with the zero and carry flags reset
28721 RET
ERIC or the bike is travelling to the left.
28722 CP 1 Has ERIC/bike hit the far left wall of the boys' skool?
28724 RET Z Return with the zero flag set if so
28725 CP 96 Is the boys' skool door in front of ERIC/bike?
28727 JR Z,28686 Jump back if so to check whether it's open
28729 CP 135 Is the skool gate in front of ERIC/bike?
28731 JR Z,28696 Jump back if so to check whether it's open
28733 AND A Return with the zero and carry flags reset
28734 RET