Routines

61696: Make teacher conduct class


Used by tables of A&P numbers 22, 24, 58, 60 and 62 to make a teacher conduct a class (after having walked to the edge of the blackboard)

H Character number of teacher (201-204)

61696 3AE07F LD A,(32736) Pick up the lesson identifier in A
61699 E6F0 AND 240 Keep only the teacher-identifying bits
61701 07 RLCA
61702 07 RLCA
61703 07 RLCA
61704 07 RLCA
61705 C6C7 ADD A,199 A=character number of teacher taking ERIC's class (201-203)
61707 BC CP H Is this teacher taking ERIC's class?
61708 2832 JR Z,61760 Jump if so
61710 010F68 LD BC,26639 Routine at 26639: wipe board
61713 CD9F63 CALL 25503 Redirect control to 26639 and return to 61716 when done
61716 2E01 LD L,1
61718 7E LD A,(HL) A=teacher's x-coordinate
61719 C603 ADD A,3 A=x-coordinate of middle of blackboard
61721 2E0B LD L,11
61723 77 LD (HL),A Place it in byte 11 ready for the routine at 25581
61724 01ED63 LD BC,25581 Routine at 25581: walk to a location
61727 CD9F63 CALL 25503 Redirect control to 25581 and return to 61730 when done
61730 CD9162 CALL 25233 Get a random number in A
61733 018068 LD BC,26752 Routine at 26752: write on board
61736 FEA0 CP 160 Should the teacher write on the board?
61738 D49F63 CALL NC,25503 If so, redirect control to 26752 and return to 61741 when done
61741 CD5DF0 CALL 61533 Tell class what to do
61744 2E01 LD L,1
61746 7E LD A,(HL) A=teacher's x-coordinate
61747 EE03 XOR 3 Now A=x-coordinate of position 3 paces away from teacher
61749 2E0B LD L,11 Place this in byte 11 of the teacher's buffer, ready for the routine at 25581
61751 77 LD (HL),A
61752 01ED63 LD BC,25581 Routine at 25581: walk to a location
61755 CD9F63 CALL 25503 Redirect control to 25581 and return to 61758 when done
61758 18F0 JR 61744 Make the teacher pace up (or down) again

The teacher is taking ERIC's class. This is a far more difficult task...
61760 3A807F LD A,(32640)
61763 CBF7 SET 6,A Signal: ERIC should be in class now
61765 32807F LD (32640),A
61768 CD48F0 CALL 61512 Are ERIC and EINSTEIN both in class?
61771 2828 JR Z,61813 Jump if so

ERIC is not in class. EINSTEIN must therefore grass...
61773 0117F0 LD BC,61463 Routine at 61463: make EINSTEIN talk
61776 1E12 LD E,18 18: Please Sir...ERIC is not here
61778 CD9F63 CALL 25503 Make EINSTEIN grass on ERIC, then return control to 61781
61781 0ED0 LD C,208 208=EINSTEIN
61783 CD2FF0 CALL 61487 Give lines
61786 CD157D CALL 32021 Is ERIC in class?
61789 3A807F LD A,(32640)
61792 2808 JR Z,61802 Jump if he is
61794 CBFF SET 7,A Signal: teacher had to hunt down the tardy ERIC
61796 32807F LD (32640),A
61799 C3D0F0 JP 61648 Go and find ERIC

ERIC is in class now.
61802 07 RLCA Set carry if teacher's already had to chase ERIC
61803 0614 LD B,20 20: STAY TILL I DISMISS YOU
61805 3ED2 LD A,210 210=ERIC
61807 3801 JR C,61810 Jump if teacher's already had to chase or give lines to ERIC for being late or leaving early
61809 05 DEC B B=19: DON'T BE LATE AGAIN
61810 CD40F0 CALL 61504 Give lines
61813 3A807F LD A,(32640) Set bits 6 (ERIC should be in class) and 7 (teacher has reprimanded ERIC for being late or trying to leave early) at 32640
61816 F6C0 OR 192
61818 32807F LD (32640),A
61821 CD48F0 CALL 61512 Are ERIC and EINSTEIN both in class?
61824 20CB JR NZ,61773 Jump if ERIC is missing
61826 CD9162 CALL 25233 A=random number
61829 FEDC CP 220 Should EINSTEIN tell tales?
61831 3813 JR C,61852 Jump if not
61833 1E57 LD E,87 87: Please Sir...ERIC hit me
61835 0117F0 LD BC,61463 Routine at 61463: make EINSTEIN talk
61838 CD9F63 CALL 25503 Redirect control to 61463 and return to 61841 when done
61841 01D261 LD BC,25042 B=97: DON'T HIT YOUR MATES; C=210 (ERIC)
61844 CD2FF0 CALL 61487 Give lines
61847 CD48F0 CALL 61512 Are ERIC and EINSTEIN both in class?
61850 20B1 JR NZ,61773 Jump if ERIC's missing

Now's EINSTEIN's chance to grass on someone for writing on the blackboard.
61852 CD5567 CALL 26453 Collect information about the blackboard
61855 04 INC B
61856 48 LD C,B
61857 067F LD B,127
61859 0A LD A,(BC) A=character number of person who last wrote on blackboard
61860 FED2 CP 210 Was it ERIC?
61862 280F JR Z,61879 Jump if so
61864 FECE CP 206 Or was it BOY WANDER?
61866 201F JR NZ,61899 Jump if not
61868 CD9162 CALL 25233 A=random number
61871 FEC3 CP 195 Should EINSTEIN blame BOY WANDER for writing on the board?
61873 3ECE LD A,206 206=BOY WANDER
61875 3802 JR C,61879 Jump if so
61877 3ED2 LD A,210 Blame ERIC instead
61879 32907F LD (32656),A
61882 0117F0 LD BC,61463 Routine at 61463: make EINSTEIN talk
61885 1E58 LD E,88 88: Please Sir...X wrote on the board
61887 CD9F63 CALL 25503 Redirect control to 61463 and return to 61890 when done
61890 3A907F LD A,(32656)
61893 4F LD C,A
61894 0656 LD B,86 86: DON'T TOUCH BLACKBOARDS
61896 CD2FF0 CALL 61487 Give lines

It's time to wipe the board.
61899 010F68 LD BC,26639 Routine at 26639: wipe board
61902 CD9F63 CALL 25503 Redirect control to 26639 and return to 61905 when done
61905 2E01 LD L,1
61907 7E LD A,(HL) A=teacher's x-coordinate
61908 C603 ADD A,3 A=x-coordinate of middle of blackboard
61910 2E0B LD L,11 Place it in byte 11 of the teacher's buffer, ready for the routine at 25581
61912 77 LD (HL),A
61913 01ED63 LD BC,25581 Routine at 25581: walk to location
61916 CD9F63 CALL 25503 Redirect control to 25581 and return to 61919 when done

The teacher has wiped the board, and is ready to start the class.
61919 CD48F0 CALL 61512 Are ERIC and EINSTEIN both in class?
61922 C24DF1 JP NZ,61773 Jump if ERIC's missing
61925 CD9162 CALL 25233 Get a random number in A
61928 018068 LD BC,26752 Routine at 26752: write on board
61931 FEB8 CP 184 Should the teacher write on the board?
61933 D49F63 CALL NC,25503 Redirect control to 26752 if so, and return to 61936 when done
61936 CD48F0 CALL 61512 Are ERIC and EINSTEIN both in class?
61939 20ED JR NZ,61922 Jump if ERIC's missing
61941 CD9162 CALL 25233 Get random number in A
61944 FEE8 CP 232 Should this be a questions-and-answers lesson?
61946 3818 JR C,61972 Jump if so
61948 CD5DF0 CALL 61533 Tell class what to do
61951 CD48F0 CALL 61512 Are ERIC and EINSTEIN both in class?
61954 20DE JR NZ,61922 Jump if ERIC's missing
61956 2E01 LD L,1
61958 7E LD A,(HL) A=x-coordinate of teacher
61959 EE03 XOR 3 Now A=x-coordinate of location three paces away from teacher
61961 2E0B LD L,11 Place this in byte 11 of the teacher's buffer ready for the routine at 25581
61963 77 LD (HL),A
61964 01ED63 LD BC,25581 Routine at 25581: walk to location
61967 CD9F63 CALL 25503 Redirect control to 25581 and return to 61970 when done
61970 18EB JR 61951

This is going to be one of those questions-and-answers lessons.
61972 CD9162 CALL 25233 Get random number in A
61975 E687 AND 135 Keep only bits 0-2 and 7
61977 F5 PUSH AF
61978 4F LD C,A
61979 118C7F LD DE,32652
61982 7C LD A,H
61983 92 SUB D
61984 87 ADD A,A
61985 87 ADD A,A
61986 87 ADD A,A
61987 87 ADD A,A
61988 B1 OR C Now A=message number of mountain, animal or king
61989 12 LD (DE),A
61990 C608 ADD A,8 A=message number of corresponding country, habitat or date
61992 1E8E LD E,142 DE=32654
61994 12 LD (DE),A
61995 F1 POP AF
61996 07 RLCA
61997 9F SBC A,A
61998 84 ADD A,H
61999 84 ADD A,H
62000 87 ADD A,A
62001 C627 ADD A,39 Now A=message number for EINSTEIN's reply
62003 320BD0 LD (53259),A Store it in byte 11 of EINSTEIN's buffer
62006 3C INC A A=message number for teacher's question
62007 5F LD E,A
62008 01086A LD BC,27144 Routine at 27144: ask question
62011 CD9F63 CALL 25503 Redirect control to 27144 and return to 62014 when done
62014 011BF0 LD BC,61467 Routine at 61467: make EINSTEIN give answer
62017 CD9F63 CALL 25503 Redirect control to 61467 and return to 62020 when done
62020 CD48F0 CALL 61512 Are ERIC and EINSTEIN both in class?
62023 28CB JR Z,61972 Jump if they are
62025 C34DF1 JP 61773 Jump elsewhere if ERIC's missing