Prev: F2F5 Up: Map Next: F3F5
F300: Make a teacher conduct a class with ERIC
Continues from the routine at 7DB2. Makes a teacher conduct a class with ERIC, from the point of reaching the left edge of the blackboard or map (where the teacher waits for EINSTEIN to show up) until the end of the lesson.
Input
H Teacher's character number (0xA3-0xA6)
F300 CALL $7CD0 Make the teacher wait for EINSTEIN to sit down
F303 JR Z,$F32C Jump if ERIC is in the room
This entry point is used by the routine at F400.
F305 LD BC,$F103 F103: 'Please Sir...ERIC is not here'
F308 CALL $7CAF Make EINSTEIN say this
F30B CALL $7CE0 Make the teacher give lines to EINSTEIN for telling tales (if he's in the mood)
F30E CALL $7CFC Make the teacher tell the kids to read their books
F311 CALL $79D4 Set the zero flag if ERIC is in class
F314 LD A,($7FC8) Collect the lesson status flags from 7FC8
F317 JR Z,$F321 Jump if ERIC is in class
F319 SET 7,A Set bit 7 at 7FC8, indicating that the next lines message for absence (if any) should be no. 0x0B (AND STAY THIS TIME)
F31B LD ($7FC8),A
F31E JP $7C7B Make the teacher track down ERIC
F321 RLCA Set the carry flag if the absence lines reprimand should be...
F322 LD B,$0B ...0x0B: AND STAY THIS TIME
F324 JR C,$F327 Jump if this is the appropriate lines reprimand
F326 DEC B B=0x0A: NEVER BE LATE AGAIN
F327 LD A,$AC 0xAC=ERIC
F329 CALL $7CA4 Give lines to ERIC
ERIC is in class now.
F32C LD A,($7FC8) Set bit 7 (indicating that the next absence lines message should be 'AND STAY THIS TIME') and bit 6 (indicating that the lesson has started) at 7FC8
F32F OR $C0
F331 LD ($7FC8),A
F334 CALL $7CD0 Is ERIC in class?
F337 JR NZ,$F305 Jump if not
This is EINSTEIN's opportunity to tell tales about hitting and blackboard defacement.
F339 CALL $61A1 A=random number
F33C CP $E2 Should EINSTEIN tell the teacher that ERIC hit him?
F33E JR C,$F35E Jump if not (226 times out of 256)
F340 LD BC,$F0F9 F0F9: 'Please Sir...ERIC hit me'
F343 CP C The result of this comparison is ignored
F344 JR $F349
F346 LD BC,$F12D This instruction is never executed; anyway, F12D='WHAT HAPPENED IN THE YEAR THAT I WAS BORN'
F349 CALL $7CAF Make EINSTEIN tell the teacher that ERIC hit him
F34C CALL $7CE0 Make the teacher give lines to EINSTEIN for telling tales (if he's in the mood)
F34F INC L Did the teacher give lines to EINSTEIN?
F350 JR NZ,$F359 Jump if so
F352 LD B,$08 Lines reprimand 0x08: NOW DON'T DO IT AGAIN
F354 LD A,$AC 0xAC=ERIC
F356 CALL $7CA4 Give ERIC lines
F359 CALL $7CD0 Is ERIC in class?
F35C JR NZ,$F305 Jump if not
F35E CALL $7128 A=identifier of the blackboard closest to the teacher
F361 LD C,A Transfer this to C
F362 CP $EC Are we on the top floor?
F364 JR NZ,$F36C Jump if not
F366 INC L L=0x62
F367 LD A,(HL) A=teacher's x-coordinate
F368 CP $3A Are we in the Map Room?
F36A JR NC,$F3D3 Jump if so (no blackboard in there)
F36C INC C BC=7FED (Reading Room blackboard), 7FEF (White Room blackboard) or 7FF1 (Exam Room blackboard)
F36D LD B,$7F
F36F LD A,(BC) A=number of the character who last wrote on the board
F370 AND A Is the board clean?
F371 JR Z,$F3A1 Jump if so
F373 CP $A7 Did a teacher write on the board?
F375 JR C,$F3A1 Jump if so
F377 JR NZ,$F382 Jump unless BOY WANDER wrote on the board
F379 CALL $61A1 A=random number
F37C CP $C8 Set the carry flag 200 times out of 256
F37E LD A,$11 0x11='BOY WANDER'
F380 JR C,$F384 Jump if EINSTEIN is going to blame BOY WANDER
F382 LD A,$10 0x10='ERIC'
F384 LD BC,$F113 Insert ERIC's or BOY WANDER's name into the 'X wrote on the blackboard' message at F112
F387 LD (BC),A
F388 DEC C Point BC at the start of the message
F389 CALL $7CAF Make EINSTEIN tell a tale about ERIC or BOY WANDER writing on the blackboard
F38C CALL $7CE0 Make the teacher give lines to EINSTEIN for telling tales (if he's in the mood)
F38F INC L Did the teacher give lines to EINSTEIN?
F390 JR NZ,$F3A1 Jump if so
F392 LD A,($F113) A=0x10 ('ERIC') or 0x11 ('BOY WANDER')
F395 RRCA Set the carry flag if EINSTEIN blamed BOY WANDER
F396 LD A,$A7 0xA7=BOY WANDER
F398 JR C,$F39C Jump if EINSTEIN blamed BOY WANDER for writing on the board
F39A LD A,$AC 0xAC=ERIC
F39C LD B,$0C Lines reprimand 0x0C: DON'T TOUCH BLACKBOARDS
F39E CALL $7CA4 Make the teacher give lines to ERIC or BOY WANDER
With EINSTEIN's tales now safely told, it's time to wipe the blackboard.
F3A1 LD BC,$71DC Hand over control to the routine at 71DC, making the teacher wipe the blackboard
F3A4 CALL $7CF1
Control returns here after the teacher has wiped the blackboard.
F3A7 LD L,$62 A=teacher's x-coordinate (equal to that of the left edge of the blackboard)
F3A9 LD A,(HL)
F3AA ADD A,$03 Place the x-coordinate of the middle of the blackboard into byte 0x6B of the teacher's buffer, and the same value into byte 0x6C (which ensures that the routine at 633C will not relinquish control before the teacher has reached the middle of the blackboard)
F3AC LD L,$6B
F3AE LD (HL),A
F3AF INC L
F3B0 LD (HL),A
F3B1 LD BC,$633C Hand over control to the routine at 633C, making the teacher walk to the middle of the blackboard
F3B4 CALL $7CF1
Control returns here when the teacher has walked to the middle of the blackboard.
F3B7 CALL $61A1 A=random number
F3BA CP $B4 Should the teacher write on the blackboard?
F3BC JR C,$F3D3 Jump if not (180 times out of 256)
F3BE LD BC,$7264 Hand over control to the routine at 7264, making the teacher write on the blackboard
F3C1 CALL $7CF1
Control returns here when the teacher has finished writing on the blackboard.
F3C4 CALL $61A1 A=random number
F3C7 CP $A0 Should the teacher tell the kids to write an essay?
F3C9 JR C,$F3D3 Jump if not (10 times out of 16)
F3CB LD BC,$F2D6 F2D6: 'WRITE AN ESSAY WITH THIS TITLE'
F3CE CALL $7D26 Make the teacher tell the kids to write an essay
F3D1 JR $F3DD
F3D3 CALL $61A1 A=random number
F3D6 CP $F0 Is this going to be a questions-and-answers lesson?
F3D8 JR C,$F400 Jump if so (15 times out of 16)
F3DA CALL $7CFC Make the teacher tell the kids to go to a page in their books
Now we enter a loop that makes the teacher walk up and down next to the blackboard (or the map), checking periodically whether ERIC has gone AWOL.
F3DD CALL $7CD0 Is ERIC in class?
F3E0 JP NZ,$F305 Jump if not
F3E3 LD L,$62 Collect the teacher's x-coordinate from byte 0x62 of his buffer
F3E5 LD A,(HL)
F3E6 XOR $03 Now A holds the x-coordinate of the location 1 or 3 spaces behind the teacher
F3E8 LD L,$6B Place this into byte 0x6B of his buffer, and the same value into byte 0x6C (which ensures that the routine at 633C will not relinquish control before the teacher has reached that destination)
F3EA LD (HL),A
F3EB INC L
F3EC LD (HL),A
F3ED LD BC,$633C Hand over control to the routine at 633C, making the teacher turn round and walk 1 or 3 paces
F3F0 CALL $7CF1
F3F3 JR $F3DD Make the teacher turn round and walk 1 or 3 paces again
Prev: F2F5 Up: Map Next: F3F5