| Routines

6FA0: 'A' pressed - down

The address of this routine is found in the table of keypress handling routines at E550. It is called from the main loop at F6EA when 'A' or '6' is pressed.
6FA0 | CALL $6E50 | Check whether ERIC is on a staircase
6FA3 | LD L,$00 | Point HL at byte 0x00 of ERIC's buffer
6FA5 | JR C,$6FEA | Jump if ERIC's on a staircase
6FA7 | BIT 7,(HL) | Check the 'direction' bit of ERIC's animatory state
6FA9 | LD A,D | A=ERIC's y-coordinate
6FAA | JR Z,$6FD1 | Jump if ERIC is facing left
6FAC | CP $03 | Is ERIC on the top floor?
6FAE | JR Z,$6FC8 | Jump if so
6FB0 | CP $0A | Is ERIC on the middle floor?
6FB2 | JR Z,$6FC3 | Jump if so
6FB4 | CP $0E | Is ERIC on the assembly hall stage?
6FB6 | JP NZ,$6F21 | Move ERIC one space to the right if not
6FB9 | LD A,E | A=ERIC's x-coordinate
6FBA | CP $50 | This is the x-coordinate of the top of the stairs leading from the stage to the bottom floor
6FBC | JR NZ,$6FB6 | Jump if ERIC is not here
This entry point is used by the routines at 6E9B, 6F14 and 6F2C.
6FBE | LD B,D | B=ERIC's post-midstride y-coordinate (down a stair)
6FBF | INC B
6FC0 | JP $6F64 | Move ERIC one space right or left too
ERIC is on the middle floor, facing right.
6FC3 | LD A,E | A=ERIC's x-coordinate
6FC4 | CP $0F | This is the x-coordinate of the top of the stairs leading down to the bottom floor at the far left of the boy's skool
6FC6 | JR $6FBC | Move ERIC down a stair if he's here
ERIC is on the top floor, facing right.
6FC8 | LD A,E | A=ERIC's x-coordinate
6FC9 | CP $54 | This is the x-coordinate of the top of the stairs just outside the head's study
6FCB | JR Z,$6FBE | Move ERIC down a stair if he's here
6FCD | CP $B3 | This is the x-coordinate of the top of the stairs leading down to the middle floor in the girls' skool
6FCF | JR $6FBC | Move ERIC down a stair if he's here
ERIC is facing left.
6FD1 | CP $0A | Is ERIC on the middle floor?
6FD3 | JR Z,$6FE1 | Jump if so
6FD5 | CP $03 | Is ERIC on the top floor?
6FD7 | JP NZ,$6F39 | Move ERIC one space left if not
6FDA | LD A,E | A=ERIC's x-coordinate
6FDB | CP $1A | This is the x-coordinate of the top of the stairs leading down from the Revision Library
6FDD | JR NZ,$6FD7 | Move ERIC one space left if he's not here
6FDF | JR $6FBE | Otherwise move him down a stair
ERIC is on the middle floor, facing left.
6FE1 | LD A,E | A=ERIC's x-coordinate
6FE2 | CP $55 | This is the x-coordinate of the top of the stairs leading down to the stage
6FE4 | JR Z,$6FBE | Move ERIC down a stair if he's here
6FE6 | CP $B7 | This is the x-coordinate of the top of the stairs leading down to the bottom floor in the girls' skool
6FE8 | JR $6FDD | Move ERIC down a stair if he's here
ERIC is on a staircase.
6FEA | XOR (HL) | Reset the carry flag if ERIC is facing the wrong way to descend the stairs
6FEB | RLA
6FEC | JP NC,$6E38 | Turn ERIC round if he's facing the wrong way
6FEF | JR $6FBE | Otherwise move him down a stair