Prev: 61693 Up: Map Next: 62028
61696: Make a teacher conduct a class
Used by command lists 22, 24, 58, 60 and 62 to make a teacher conduct a class (after having walked to the edge of the blackboard).
Input
H Teacher's character number (201-204)
61696 LD A,(32736) 32736 holds the current lesson descriptor
61699 AND 240 Keep only the teacher-identifying bits and shift them into bits 0-3
61701 RLCA
61702 RLCA
61703 RLCA
61704 RLCA
61705 ADD A,199 Now A=character number of the teacher taking ERIC's class (201-203)
61707 CP H Is this teacher conducting ERIC's class?
61708 JR Z,61760 Jump if so
This teacher is not conducting ERIC's class, so he has it easy: wipe the board, write on the board (maybe), tell the class what to do, and pace up and down.
61710 LD BC,26639 Redirect control to the routine at 26639 (wipe board) and return to 61716 (below) when done
61713 CALL 25503
61716 LD L,1 Point HL at byte 1 of the teacher's buffer
61718 LD A,(HL) A=teacher's x-coordinate
61719 ADD A,3 A=x-coordinate of the middle of the blackboard
61721 LD L,11 Place this in byte 11 ready for the routine at 25581
61723 LD (HL),A
61724 LD BC,25581 Redirect control to the routine at 25581 (walk to a location) and return to 61730 (below) when done
61727 CALL 25503
61730 CALL 25233 A=random number
61733 LD BC,26752 Routine at 26752: write on board
61736 CP 160 Should the teacher write on the board?
61738 CALL NC,25503 If so, redirect control to the routine at 26752 and return to 61741 (below) when done
61741 CALL 61533 Tell the class what to do
61744 LD L,1 Point HL at byte 1 of the teacher's buffer
61746 LD A,(HL) A=teacher's x-coordinate
61747 XOR 3 Now A=x-coordinate of the location 3 paces behind the teacher
61749 LD L,11 Place this in byte 11 of the teacher's buffer, ready for the routine at 25581
61751 LD (HL),A
61752 LD BC,25581 Redirect control to the routine at 25581 (walk to a location) and return to 61758 (below) when done
61755 CALL 25503
61758 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 LD A,(32640) Set bit 6 at 32640, indicating that ERIC should be in class now
61763 SET 6,A
61765 LD (32640),A
61768 CALL 61512 Are ERIC and EINSTEIN both in class?
61771 JR Z,61813 Jump if so
ERIC is not in class, but EINSTEIN is. EINSTEIN must therefore grass.
61773 LD BC,61463 Routine at 61463: make EINSTEIN talk
61776 LD E,18 18: Please Sir...ERIC is not here
61778 CALL 25503 Make EINSTEIN grass on ERIC, and return to 61781 (below) when done
61781 LD C,208 208=EINSTEIN
61783 CALL 61487 Give lines to EINSTEIN (maybe)
61786 CALL 32021 Set the zero flag if ERIC is in class
61789 LD A,(32640) 32640 holds various game status flags
61792 JR Z,61802 Jump if ERIC is in class
61794 SET 7,A Set bit 7 at 32640: the teacher's next absence reprimand should be 'STAY TILL I DISMISS YOU'
61796 LD (32640),A
61799 JP 61648 Go and find ERIC
ERIC is in class now, having shown up while EINSTEIN was grassing on him for being absent.
61802 RLCA Push bit 7 of 32640 into the carry flag
61803 LD B,20 20: STAY TILL I DISMISS YOU
61805 LD A,210 210=ERIC
61807 JR C,61810 Jump if the teacher's already had to chase or give lines to ERIC for being late or leaving early
61809 DEC B B=19: DON'T BE LATE AGAIN
61810 CALL 61504 Give ERIC lines
61813 LD A,(32640) Set bits 6 (ERIC should be in class) and 7 (the teacher's next absence reprimand should be 'STAY TILL I DISMISS YOU') at 32640
61816 OR 192
61818 LD (32640),A
61821 CALL 61512 Is ERIC in class?
61824 JR NZ,61773 Jump if not
Now is EINSTEIN's chance to grass on ERIC for hitting him.
61826 CALL 25233 A=random number
61829 CP 220 Should EINSTEIN tell tales?
61831 JR C,61852 Jump if not
61833 LD E,87 87: Please Sir...ERIC hit me
61835 LD BC,61463 Redirect control to the routine at 61463 (make EINSTEIN talk) and return to 61841 (below) when done
61838 CALL 25503
61841 LD BC,25042 B=97: DON'T HIT YOUR MATES; C=210 (ERIC)
61844 CALL 61487 Give EINSTEIN or ERIC lines
61847 CALL 61512 Is ERIC in class?
61850 JR NZ,61773 Jump if not
Now is EINSTEIN's opportunity to grass on someone for writing on the blackboard. However, the opportunity is wasted, because the CALL to 26453 (at 61852 below) returns a valid blackboard ID only if the character is standing within four spaces of the left edge of the blackboard, which is not the case when the teacher is waiting for EINSTEIN to grass (teachers stand at the right edge of the blackboard for that, more than four spaces away). This is a bug.
61852 CALL 26453 Collect information about the blackboard
61855 INC B The intent here is to point BC at the second byte of the blackboard's buffer, which holds the character number of the person who last wrote on it; instead, BC points at 32516 if the teacher is on the top floor, or 32515 if he's on the middle floor
61856 LD C,B
61857 LD B,127
61859 LD A,(BC) Now A is supposed to hold the character number of the person who last wrote on the board; instead it holds the contents of 32515 or 32516 (bytes 3 and 4 of the SRB), which will never be 206 or 210
61860 CP 210 Did ERIC write on the board?
61862 JR Z,61879 Jump if so (this jump is never made)
61864 CP 206 Or did BOY WANDER?
61866 JR NZ,61899 Jump if not (this jump is always made)
61868 CALL 25233 A=random number
61871 CP 195 Should EINSTEIN blame BOY WANDER for writing on the board?
61873 LD A,206 206=BOY WANDER
61875 JR C,61879 Jump if so
61877 LD A,210 Blame ERIC instead
61879 LD (32656),A Place the character number of the scapegoat into 32656
61882 LD BC,61463 Routine at 61463: make EINSTEIN talk
61885 LD E,88 88: Please Sir...[7] wrote on the board
61887 CALL 25503 Redirect control to the routine at 61463 and return to 61890 (below) when done
61890 LD A,(32656) A=206 (BOY WANDER) or 210 (ERIC)
61893 LD C,A Copy the scapegoat's character number to C
61894 LD B,86 86: DON'T TOUCH BLACKBOARDS
61896 CALL 61487 Give lines to EINSTEIN, ERIC or BOY WANDER
The next section of code makes the teacher wipe the board. Note that the teacher may already have wiped the board at this point, and therefore will not be standing at the right edge of the board (the correct location to begin wiping); this is a bug.
61899 LD BC,26639 Redirect control to the routine at 26639 (wipe board) and return to 61905 (below) when done
61902 CALL 25503
61905 LD L,1 Point HL at byte 1 of the teacher's buffer
61907 LD A,(HL) A=teacher's x-coordinate
61908 ADD A,3 A=x-coordinate of the middle of the blackboard
61910 LD L,11 Place this in byte 11 of the teacher's buffer, ready for the routine at 25581
61912 LD (HL),A
61913 LD BC,25581 Redirect control to the routine at 25581 (walk to location) and return to 61919 (below) when done
61916 CALL 25503
The teacher has wiped the board, and is ready to start the class.
61919 CALL 61512 Is ERIC in class?
61922 JP NZ,61773 Jump if not
61925 CALL 25233 A=random number
61928 LD BC,26752 Routine at 26752: write on board
61931 CP 184 Should the teacher write on the board?
61933 CALL NC,25503 Redirect control to 26752 if so, and return to 61936 (below) when done
61936 CALL 61512 Is ERIC in class?
61939 JR NZ,61922 Jump if not
61941 CALL 25233 A=random number
61944 CP 232 Should this be a questions-and-answers lesson?
61946 JR C,61972 Jump if so
This is not going to be a questions-and-answers lesson.
61948 CALL 61533 Tell the class what to do
61951 CALL 61512 Is ERIC in class?
61954 JR NZ,61922 Jump if not
61956 LD L,1 Point HL at byte 1 of the teacher's buffer
61958 LD A,(HL) A=teacher's x-coordinate
61959 XOR 3 Now A=x-coordinate of location three paces behind the teacher
61961 LD L,11 Place this in byte 11 of the teacher's buffer ready for the routine at 25581
61963 LD (HL),A
61964 LD BC,25581 Redirect control to the routine at 25581 (walk to location) and return to 61970 (below) when done
61967 CALL 25503
61970 JR 61951 Check whether ERIC's in class, then pace up (or down) again
This is going to be a questions-and-answers lesson. Pick a question-answer word pair, and decide which word will be in the question, and which in the answer.
61972 CALL 25233 A=random number
61975 AND 135 Keep only bits 0-2 (the word pair identifier) and bit 7 (indicates which word will be in the question)
61977 PUSH AF Save bit 7 for now
61978 LD C,A
61979 LD DE,32652 Point DE at the first byte of message 10
61982 LD A,H Set A=160 (if the teacher is MR WITHIT), 176 (MR ROCKITT), or 192 (MR CREAK)
61983 SUB D
61984 ADD A,A
61985 ADD A,A
61986 ADD A,A
61987 ADD A,A
61988 OR C Now A holds the message number of a random mountain, animal or king
61989 LD (DE),A Place this into 32652 (message 10)
61990 ADD A,8 Set A to the message number of the corresponding country, habitat or date
61992 LD E,142 Place this into 32654 (the first byte of message 11)
61994 LD (DE),A
61995 POP AF Restore the random bit 7 to A
61996 RLCA Push it into the carry flag
61997 SBC A,A Set A to 73 or 75 (MR WITHIT), 77 or 79 (MR ROCKITT), 81 or 83 (MR CREAK); this is the message number for EINSTEIN's reply
61998 ADD A,H
61999 ADD A,H
62000 ADD A,A
62001 ADD A,39
62003 LD (53259),A Store it in byte 11 of EINSTEIN's buffer, ready for the routine at 61467
62006 INC A Set E to 74 or 76 (MR WITHIT), 78 or 80 (MR ROCKITT), 82 or 84 (MR CREAK); this is the message number for the teacher's question
62007 LD E,A
62008 LD BC,27144 Redirect control to the routine at 27144 (make character speak) and return to 62014 (below) when done
62011 CALL 25503
62014 LD BC,61467 Redirect control to the routine at 61467 (make EINSTEIN answer) and return to 62020 (below) when done
62017 CALL 25503
62020 CALL 61512 Is ERIC in class?
62023 JR Z,61972 Jump if so
62025 JP 61773 Otherwise make EINSTEIN grass on the absent ERIC
Prev: 61693 Up: Map Next: 62028