Routines

28576: 'A' pressed - down


The address of this routine is found in the keypress table at 58624

28576 CD506E CALL 28240 Is ERIC on a staircase?
28579 2E00 LD L,0
28581 3843 JR C,28650 Jump if so
28583 CB7E BIT 7,(HL) Is ERIC facing left?
28585 7A LD A,D
28586 2825 JR Z,28625 Jump if so
28588 FE03 CP 3 Is ERIC on the top floor?
28590 2818 JR Z,28616 Jump if so
28592 FE0A CP 10 Is ERIC on the middle floor?
28594 280F JR Z,28611 Jump if so
28596 FE0E CP 14 Is ERIC on the assembly hall stage?
28598 C2216F JP NZ,28449 Move ERIC one space to the right if not
28601 7B LD A,E A=ERIC's x-coordinate
28602 FE50 CP 80 80: Top of stairs leading from stage to bottom floor
28604 20F8 JR NZ,28598 Jump if ERIC is not here

This entry point is used by the routines at 28315, 28436 and 28460:
28606 42 LD B,D
28607 04 INC B B=ERIC's new y-coordinate (down a stair)
28608 C3646F JP 28516 Move ERIC one space right too

ERIC is on the middle floor, facing right.
28611 7B LD A,E A=ERIC's x-coordinate
28612 FE0F CP 15 15: Top of stairs leading down to bottom floor in boy's skool
28614 18F4 JR 28604 Move ERIC down a stair if he's here

ERIC is on the top floor, facing right.
28616 7B LD A,E A=ERIC's x-coordinate
28617 FE54 CP 84 84: Top of stairs just outside head's study
28619 28F1 JR Z,28606 Move ERIC down a stair if he's here
28621 FEB3 CP 179 179: Top of stairs leading down to middle floor in girls' skool
28623 18EB JR 28604 Move ERIC down a stair if he's here

ERIC is facing left.
28625 FE0A CP 10 Is ERIC on the middle floor?
28627 280C JR Z,28641 Jump if so
28629 FE03 CP 3 Is ERIC on the top floor?
28631 C2396F JP NZ,28473 Move ERIC one space left if not
28634 7B LD A,E A=ERIC's x-coordinate
28635 FE1A CP 26 26: Top of stairs leading down from revision library
28637 20F8 JR NZ,28631 Move ERIC one space left if he's not here
28639 18DD JR 28606 Otherwise move him down a stair

ERIC is on the middle floor, facing left.
28641 7B LD A,E A=ERIC's x-coordinate
28642 FE55 CP 85 85: Top of stairs leading down to stage
28644 28D8 JR Z,28606 Move ERIC down a stair if he's here
28646 FEB7 CP 183 183: Top of stairs leading down to bottom floor in girls' skool
28648 18F3 JR 28637 Move ERIC down a stair if he's here

ERIC is on a staircase.
28650 AE XOR (HL) Set the carry flag if ERIC is facing the wrong way to descend the stairs
28651 17 RLA
28652 D2386E JP NC,28216 Turn ERIC round if he's facing the wrong way
28655 18CD JR 28606 Otherwise move him down a stair