| Routines

7654: Check for walls, doors and windows in the path of a mouse, frog or pellet

Used by the routines at 76AC, 7854 and 7A16. Returns with the carry flag set if there is a wall, closed door or closed window blocking the path of the mouse, frog or pellet
Input
DE | Coordinates of the spot in front of the mouse/frog/pellet
7654 | PUSH HL |
7655 | LD HL,$7FF4 | 7FF4 contains the doors flags
7658 | LD A,E | A=x-coordinate of the point in front of the mouse/frog/pellet
7659 | CP $BE | This is the x-coordinate of the far wall of the girls' skool
765B | JR NC,$767F | Jump if the mouse/frog/pellet is facing this wall
765D | LD A,D | A=y-coordinate of the mouse/frog/pellet
765E | CP $05 | Is the mouse/frog/pellet on the top floor (or just below it)?
7660 | JR NC,$7682 | Jump if not
The mouse/frog/pellet is on the top floor.
7662 | LD A,E | A=x-coordinate of the point in front of the mouse/frog/pellet
7663 | CP $9F | This is the x-coordinate of the left wall of the girls' skool
7665 | JR Z,$767F | Jump if the mouse/frog/pellet is facing this wall
7667 | LD D,$01 | Set bit 0: left study door
7669 | CP $48 | This is the x-coordinate of the left study door
766B | JR Z,$767B | Jump if the mouse/frog/pellet is facing this door
766D | INC D | Set bit 1: right study door
766E | CP $54 | This is the x-coordinate of the right study door
7670 | JR Z,$767B | Jump if the mouse/frog/pellet is facing this door
7672 | LD D,$40 | Set bit 6: top-floor window
7674 | CP $5C | This is the x-coordinate of the top-floor window
7676 | JR Z,$767B | Jump if the mouse/frog/pellet is facing this window
7678 | AND A | Clear the carry flag: no obstacles ahead
7679 | POP HL | Restore the character number of the mouse/frog/pellet to H
767A | RET | Return with the carry flag reset
767B | LD A,D | A holds the identifier of the door or window in front of the mouse/frog/pellet
767C | AND (HL) | Is this door/window open?
767D | JR NZ,$7679 | Jump if so
767F | SCF | Set the carry flag: no admittance
7680 | POP HL | Restore the character number of the mouse/frog/pellet to H
7681 | RET | Return with the carry flag set
7682 | CP $0C |
7684 | LD A,E |
7685 | JR NC,$769E | Jump if the mouse/frog/pellet is on the bottom floor (or just above it)
The mouse/frog/pellet is on the middle floor.
7687 | CP $9F | This is the x-coordinate of the left wall of the girls' skool
7689 | JR Z,$767F | Jump if the mouse/frog/pellet is facing this wall
768B | CP $3E | This is the x-coordinate of the far wall of the Science Lab storeroom
768D | JR Z,$767F | Jump if the mouse/frog/pellet is facing this wall
768F | CP $35 | This is the x-coordinate of the Science Lab storeroom door
7691 | LD D,$04 | Set bit 2: Science Lab storeroom door
7693 | JR Z,$767B | Jump if the mouse/frog/pellet is facing this door
7695 | LD D,$80 | Set bit 7: middle-floor window
7697 | CP $5E | This is the x-coordinate of the middle-floor window
7699 | JR Z,$767B | Jump if the mouse/frog/pellet is facing this window
769B | AND A | Clear the carry flag: no obstacles ahead
769C | POP HL | Restore the character number of the mouse/frog/pellet to H
769D | RET | Return with the carry flag reset
The mouse/frog/pellet is on the bottom floor.
769E | LD D,$08 | Set bit 3: boys' skool door
76A0 | CP $5E | This is the x-coordinate of the boys' skool door
76A2 | JR Z,$767B | Jump if mouse/frog/pellet is facing this door
76A4 | LD D,$10 | Set bit 4: skool gate
76A6 | CP $85 | This is the x-coordinate of the skool gate
76A8 | JR Z,$767B | Jump if the mouse/frog/pellet is facing this
76AA | JR $769B | Otherwise it's all clear