Prev: 66E0 Up: Map Next: 6736
66E6: Change the lesson
This routine is called from the main loop at 6767 when the lesson clock has counted down to zero. It sets each character up with the appropriate command list for the next lesson.
66E6 LD HL,$1500 Reset the lesson clock at 7FF7
66E9 LD ($7FF7),HL
66EC LD HL,$7FF9 Advance the lesson number at 7FF9 by one and get the next lesson number (0x00-0x3F) in A
66EF INC (HL)
66F0 LD A,(HL)
66F1 CP $40
66F3 JR NZ,$66F7
66F5 XOR A
66F6 LD (HL),A
66F7 LD E,A E=lesson number (0x00-0x3F)
66F8 CALL $F905 Get the identifier for this lesson in A
66FB CP D D=0xFE; ring the bell unless this is the second PLAYTIME in a row (only PLAYTIMEs 0xFE and 0xFF follow another PLAYTIME)
66FC PUSH AF
66FD CALL C,$6752
6700 LD HL,$7FC8 Clear the flags at 7FC8, 7FC9, 7FCA and 7FCB, the unused bytes at 7FCC, MR CREAK's birth year question indicator at 7FDA, and the unused byte at 7FDB
6703 LD B,$14
6705 LD (HL),$00
6707 INC L
6708 DJNZ $6705
670A POP AF
670B LD E,A E=lesson identifier (0xE0-0xFF) from the main timetable
670C LD D,$AC Pick up the lesson descriptor (which determines who is teaching ERIC and in what room) and place it in 7FF4
670E LD A,(DE)
670F LD ($7FF4),A
6712 PUSH DE
6713 CALL $F9A5 Print the teacher and room names in the lesson box
6716 POP DE
6717 LD B,$14 There are 20 non-player characters to prepare for the new lesson, starting with little boy no. 1 (0x98)
6719 LD H,$98
This entry point is used by the routine at 7C47 with B=1 to restart the command list for a single character.
671B EXX
671C LD H,$FE The addresses of the command lists are in page 0xFE at FE80
671E EXX
671F LD D,H D=character number (0x98-0xAB)
6720 LD L,$7A Set bit 0 of byte 0x7A of the character's buffer; this will trigger a restart of the command list (see 6226)
6722 SET 0,(HL)
6724 LD L,$77
6726 LD A,(DE) Pick up the command list number for this lesson from the character's personal timetable
6727 EXX
6728 LD L,A A=LSB of the address of the command list
6729 LD A,(HL)
672A INC L Point HL' at the MSB of the address of the command list
672B EXX
672C LD (HL),A Copy the LSB to byte 0x77 of the character's buffer
672D INC L L=0x78
672E EXX
672F LD A,(HL) A=MSB of the address of the command list
6730 EXX
6731 LD (HL),A Copy the MSB to byte 0x78 of the character's buffer
6732 INC H Next character
6733 DJNZ $671F Jump back until all characters have been done
6735 RET
Prev: 66E0 Up: Map Next: 6736