Prev: 26336 Up: Map Next: 26422
26342: Change the lesson
This routine is called from the main loop at 26471 when the lesson clock has counted down to zero. It sets each character up with the appropriate command list for the next lesson.
26342 LD HL,5376 Reset the lesson clock at 32759
26345 LD (32759),HL
26348 LD HL,32761 Advance the lesson number at 32761 by one and get the next lesson number (0-63) in A
26351 INC (HL)
26352 LD A,(HL)
26353 CP 64
26355 JR NZ,26359
26357 XOR A
26358 LD (HL),A
26359 LD E,A E=lesson number (0-63)
26360 CALL 63749 Get the identifier for this lesson in A
26363 CP D D=254; ring the bell unless this is the second PLAYTIME in a row (only PLAYTIMEs 254 and 255 follow another PLAYTIME)
26364 PUSH AF
26365 CALL C,26450
26368 LD HL,32712 Clear the flags at 32712, 32713, 32714 and 32715, the unused bytes at 32716, MR CREAK's birth year question indicator at 32730, and the unused byte at 32731
26371 LD B,20
26373 LD (HL),0
26375 INC L
26376 DJNZ 26373
26378 POP AF
26379 LD E,A E=lesson identifier (224-255) from the main timetable
26380 LD D,172 Pick up the lesson descriptor (which determines who is teaching ERIC and in what room) and place it in 32756
26382 LD A,(DE)
26383 LD (32756),A
26386 PUSH DE
26387 CALL 63909 Print the teacher and room names in the lesson box
26390 POP DE
26391 LD B,20 There are 20 non-player characters to prepare for the new lesson, starting with little boy no. 1 (152)
26393 LD H,152
This entry point is used by the routine at 31815 with B=1 to restart the command list for a single character.
26395 EXX
26396 LD H,254 The addresses of the command lists are in page 254 at 65152
26398 EXX
26399 LD D,H D=character number (152-171)
26400 LD L,122 Set bit 0 of byte 122 of the character's buffer; this will trigger a restart of the command list (see 25126)
26402 SET 0,(HL)
26404 LD L,119
26406 LD A,(DE) Pick up the command list number for this lesson from the character's personal timetable
26407 EXX
26408 LD L,A A=LSB of the address of the command list
26409 LD A,(HL)
26410 INC L Point HL' at the MSB of the address of the command list
26411 EXX
26412 LD (HL),A Copy the LSB to byte 119 of the character's buffer
26413 INC L L=120
26414 EXX
26415 LD A,(HL) A=MSB of the address of the command list
26416 EXX
26417 LD (HL),A Copy the MSB to byte 120 of the character's buffer
26418 INC H Next character
26419 DJNZ 26399 Jump back until all characters have been done
26421 RET
Prev: 26336 Up: Map Next: 26422