![]() |
Routines |
30636 | LD HL,32754 | Check (and decrement) the lines-giving delay counter 32754, and proceed only if it was <75 (the counter starts off at 0 for a new game, and is set to 150 by this routine after ERIC has been given lines) |
30639 | LD A,(HL) | |
30640 | AND A | |
30641 | JR Z,30647 | |
30643 | DEC (HL) | |
30644 | CP 75 | |
30646 | RET NC | |
30647 | LD BC,(44129) | Collect ERIC's coordinates in BC |
30651 | LD L,251 | HL=32763 (ERIC's status flags) |
30653 | BIT 2,(HL) | Is ERIC jumping? |
30655 | JR Z,30672 | Jump if not |
30657 | LD A,C | A=ERIC's y-coordinate |
30658 | LD C,155 | 155=top floor |
30660 | CP 156 | Is ERIC on the top floor? |
30662 | JR C,30672 | Jump if so |
30664 | LD C,162 | 162=middle floor |
30666 | CP 163 | Is ERIC on the middle floor? |
30668 | JR C,30672 | Jump if so |
30670 | LD C,169 | 169=bottom floor |
30672 | LD A,C | A=ERIC's y-coordinate (adjusted if he's jumping) |
30673 | LD DE,30608 | |
30676 | EX DE,HL | |
30677 | CP 155 | Is ERIC on the top floor? |
30679 | JR Z,30704 | Jump if so |
30681 | LD L,156 | HL=30620 |
30683 | CP 162 | Is ERIC on the middle floor? |
30685 | JR Z,30704 | Jump if so |
30687 | LD L,166 | HL=30630 |
30689 | CP 169 | Is ERIC on the bottom floor? |
30691 | JR Z,30704 | Jump if so |
30693 | EX DE,HL | HL=32763 (ERIC's status flags) |
30694 | BIT 7,(HL) | Reset zero flag if ERIC is sitting or lying on his back |
30696 | LD A,7 | This value is ignored |
30698 | JR Z,30712 | Jump unless ERIC is sitting |
30700 | LD A,0 | Lines message 0: DON'T SIT ON THE STAIRS |
30702 | JR 30776 | Make any nearby teacher give lines |
Top floor | Address | x | ID | Description | 30608 | 8 | 0 | Head's study (always off-limits) | 30610 | 16 | 7 | Head's study door to Revision Library | 30612 | 40 | 5 | Revision Library | 30614 | 57 | 1 | Reading Room | 30616 | 74 | 2 | Map Room | 30618 | 130 | 7 | Map Room door to fire escape | Middle floor | Address | x | ID | Description | 30620 | 10 | 0 | Staff room (always off-limits) | 30622 | 22 | 7 | Between Staff room and White Room | 30624 | 38 | 3 | White Room | 30626 | 70 | 4 | Exam Room | 30628 | 130 | 7 | Outside Exam Room door | Bottom floor | Address | x | ID | Description | 30630 | 34 | 7 | Left of dinner hall | 30632 | 51 | 6 | Dinner hall | 30634 | 130 | 7 | Right of dinner hall |
---|
ID | Meaning | 0 | ERIC should never be here (head's study or staff room) | 1 | Reading Room | 2 | Map Room | 3 | White Room | 4 | Exam Room | 5 | Revision Library | 6 | Dinner hall | 7 | None of the above |
---|
30704 | LD A,B | B=ERIC's x-coordinate |
30705 | CP (HL) | Compare it with the x-coordinate from the region table |
30706 | INC HL | |
30707 | INC HL | |
30708 | JR NC,30705 | Jump back until we've determined where ERIC is |
30710 | DEC HL | Point HL at the ID byte of the region table entry |
30711 | EX DE,HL | |
30712 | LD A,(DE) | A=ID of region ERIC's in (7 if he's on a staircase) |
30713 | AND A | |
30714 | LD A,1 | Lines message 1: THE ROOM IS PRIVATE |
30716 | JR Z,30776 | Jump if ERIC's in the head's study or the staff room |
30718 | LD A,(DE) | A=ID of region ERIC's in |
30719 | LD L,200 | HL=32712 (lesson status flags) |
30721 | BIT 7,(HL) | Jump if EINSTEIN has not had a chance to grass on ERIC for being absent yet, or dinner has not started yet, or this is PLAYTIME or REVISION LIBRARY |
30723 | JR Z,30763 | |
30725 | LD A,(32756) | 32756 holds the current lesson type identifier |
30728 | AND 7 | Keep only the 'room' bits (0-2) |
30730 | EX DE,HL | |
30731 | CP (HL) | Compare this with the region ID |
30732 | EX DE,HL | |
30733 | LD A,2 | Lines message 2: GET TO WHERE YOU SHOULD BE |
30735 | JR NZ,30776 | Jump if ERIC is not where he should be |
30737 | LD A,(HL) | A=(32712) |
30738 | RLCA | Set the carry flag if ERIC's lesson has started with ERIC present |
30739 | RLCA | |
30740 | LD A,(44128) | A=ERIC's animatory state |
30743 | JR NC,30754 | Jump if ERIC's lesson has not started |
30745 | AND 15 | ERIC's lesson has started; is ERIC sitting in a chair? |
30747 | CP 5 | |
30749 | RET Z | Return if so |
30750 | LD A,3 | Lines message 3: NOW FIND A SEAT |
30752 | JR 30776 | Make any nearby teacher give lines |
30754 | AND 7 | Is ERIC standing, or midstride, or sitting on a chair? |
30756 | CP 6 | |
30758 | RET C | Return if so |
30759 | LD A,4 | Lines message 4: GET OFF THE FLOOR |
30761 | JR 30776 | Make any nearby teacher give lines |
30763 | CP 5 | Is ERIC in a room? |
30765 | JR NC,30740 | Jump if not |
30767 | LD A,(32760) | Pick up the MSB of the lesson time counter in A |
30770 | CP 19 | Should ERIC have left the room he was in last period? |
30772 | JR NC,30740 | Jump if not |
30774 | JR 30725 | Otherwise check ERIC's location |
A | Meaning | 0 | ERIC is sitting on the stairs | 1 | ERIC is in the head's study or the staff room | 2 | ERIC is not in the room he should be in | 3 | ERIC is not sitting down when he should be | 4 | ERIC is sitting on the floor |
---|
30776 | LD D,A | D=0, 1, 2, 3 or 4 |
30777 | LD L,242 | HL=32754: lines-giving delay counter (0-73) |
30779 | LD A,(HL) | Is it too soon for the same teacher to give ERIC lines twice in a row? |
30780 | AND A | |
30781 | JR Z,30790 | Jump if not |
30783 | INC HL | Otherwise, collect from 32755 into H the character number of the teacher who last gave ERIC lines |
30784 | LD H,(HL) | |
30785 | LD L,98 | Store this teacher's x-coordinate in E, and set his x-coordinate to 255 temporarily, so he's out of range and will not be regarded as a lines-giving candidate |
30787 | LD E,(HL) | |
30788 | LD (HL),255 | |
30790 | PUSH DE | |
30791 | PUSH AF | |
30792 | LD D,C | DE=ERIC's coordinates |
30793 | LD E,B | |
30794 | LD HL,44128 | 44128 holds ERIC's animatory state |
30797 | CALL 28310 | Get the floor closest to ERIC (155, 162 or 169) in D |
30800 | CALL 28223 | Can ERIC be seen by a teacher? |
30803 | JR C,30816 | Jump if so |
30805 | POP AF | |
30806 | POP DE | |
30807 | RET Z | Return unless we need to restore the x-coordinate of the last teacher who gave ERIC lines |
30808 | LD A,(32755) | Restore the x-coordinate of the teacher who was temporarily placed out of lines-giving range |
30811 | LD H,A | |
30812 | LD L,98 | |
30814 | LD (HL),E | |
30815 | RET |
30816 | POP AF | |
30817 | POP DE | |
30818 | JR Z,30827 | Jump unless we need to restore the x-coordinate of the last teacher who gave ERIC lines |
30820 | LD A,(32755) | Restore the x-coordinate of the teacher who was temporarily placed out of lines-giving range |
30823 | LD H,A | |
30824 | LD L,98 | |
30826 | LD (HL),E | |
30827 | LD B,D | B=0, 1, 2, 3 or 4 (lines message ID) |
30828 | EXX | H=character number of the teacher who saw ERIC |
30829 | PUSH HL | |
30830 | EXX | |
30831 | POP HL | |
30832 | LD L,150 | Reset the lines-giving delay counter at 32754 to 150, and set 32755 to the character number of the teacher who saw ERIC |
30834 | LD (32754),HL | |
30837 | LD L,98 | DE=coordinates of teacher who saw ERIC |
30839 | LD E,(HL) | |
30840 | DEC L | |
30841 | LD D,(HL) | |
30842 | LD A,B | B=0, 1, 2, 3 or 4 (lines message ID) |
30843 | CP 2 | Was ERIC spotted somewhere other than where he should be? |
30845 | JR NZ,30883 | Jump if not |
30847 | LD A,(32756) | Pick up the current lesson descriptor in A |
30850 | AND 240 | Keep only the teacher bits (4-7) |
30852 | RRCA | A=character number of ERIC's teacher for this period |
30853 | RRCA | |
30854 | RRCA | |
30855 | RRCA | |
30856 | ADD A,163 | |
30858 | CP H | Was it ERIC's teacher who saw him? |
30859 | JR NZ,30883 | Jump if not |
30861 | LD B,5 | Lines message 5: COME ALONG WITH ME BOY |
30863 | LD A,(32712) | Set the zero flag if ERIC's teacher hasn't said 'COME ALONG WITH ME BOY' yet |
30866 | BIT 5,A | |
30868 | SET 5,A | Indicate that he has said this now |
30870 | JR Z,30880 | Jump if ERIC's teacher has just spotted him |
30872 | XOR 16 | |
30874 | INC B | B=6: HURRY UP YOU HORROR |
30875 | BIT 4,A | |
30877 | JR Z,30880 | |
30879 | INC B | B=7: DON'T TRY MY PATIENCE BOY |
30880 | LD (32712),A | |
30883 | LD A,172 | 172=ERIC |
30885 | JP 30464 | Give lines to ERIC |