Prev: 63210 Up: Map Next: 63404
63309: Change the lesson
This routine is called from the main loop at 63210 when the lesson clock has counted down to zero. It sets each character up with the appropriate command list for the next lesson, and teleports some of the minor characters (specifically, little boys 1-8 and all the little girls) to their initial destinations if possible.
Input
HL 32740 (MSB of the lesson clock)
63309 LD (HL),16 Reset the MSB of the lesson clock to 16
63311 CALL 63576 Clear the flags at 32640 and 32641
63314 LD L,223 HL=32735 (which holds the current lesson number)
63316 LD A,(HL) Pick this up in A (192-255)
63317 INC A Next lesson
63318 OR 192 Roll over from 255 to 192 if necessary
63320 LD (HL),A Store the new lesson number
63321 LD E,A Point DE at the main timetable entry for this lesson
63322 LD D,181
63324 LD A,(DE) Pick up the lesson identifier (37-59) in A
63325 LD E,A Copy this to E
63326 LD D,210 The lesson descriptor table is at 53797
63328 LD A,(DE) Pick up the lesson descriptor in A
63329 INC L Store a copy of the lesson descriptor in 32736
63330 LD (HL),A
63331 DEC D D=209 (HAYLEY)
We now enter a loop to transfer the start address of a command list into bytes 27 and 28 of each character's buffer.
63332 LD H,D
63333 LD A,(DE) A=command list number for this lesson from the character's personal timetable
63334 EXX
63335 LD H,232 Page 232 holds the start addresses of the command lists
63337 LD L,A Pick up the LSB of the command list start address in A
63338 LD A,(HL)
63339 INC L Point HL' at the MSB
63340 EXX
63341 LD L,27 The LSB of the command list start address goes into byte 27 of the character's buffer
63343 LD (HL),A
63344 INC L Point HL at byte 28 of the character's buffer
63345 EXX
63346 LD A,(HL) A=MSB of the command list start address
63347 EXX
63348 LD (HL),A Place this into byte 28 of the character's buffer
63349 INC L Set bit 0 of byte 29 of the character's buffer, which will trigger a command list restart at the next available opportunity (i.e. after any subcommand routine whose address is currently in bytes 17 and 18 or bytes 9 and 10 of the character's buffer has finished its job; see 25296)
63350 SET 0,(HL)
63352 LD A,H Copy the character number to A
63353 CP 198 Are we dealing with one of the characters 198-209 (little boys nos. 9 and 10, the adults and the main kids)?
63355 JR NC,63395 Jump if so
We are dealing with one of the characters 183-197 (all the little girls, and little boys 1-8), who get special treatment at the start of a new lesson. Any of them who never venture into the area that's currently on-screen will be 'teleported' to the first destination in their new command list.
63357 SET 3,(HL) Set bit 3 of byte 29, signalling to the routine at 25134 (called later) that this character may be teleported
63359 EXX
63360 LD B,1 We let the routine at 25134 consider only one character at a time
63362 LD H,A H'=character number (183-197)
63363 LD A,(32767) A=X (leftmost column of the play area on screen)
63366 CP 80 Is X at least 80 (the middle of the assembly hall stage)?
63368 JR NC,63375 Jump if so
63370 LD A,H A=character number (183-197)
63371 CP 190 Now X<80, so set the carry flag if we're dealing with a little girl (none of whom should be on-screen)
63373 JR 63391
63375 CP 120 Set the carry flag if X<120
63377 LD A,H A=character number (183-197)
63378 JR NC,63388 Jump if X>=120 (which means none of the little boys 1-8 should be on-screen)
63380 CP 193 Are we dealing with little boys 4-8?
63382 JR NC,63394 Jump if so (they do venture this far into the playground)
63384 CP 186 Now 80<=X<=112, so reset the carry flag if we're dealing with little girls 4-7 (who never leave the girls' skool) or little boys 1-3 (who never venture beyond the assembly hall stage)
63386 JR 63390
63388 CP 190 Now X>=120, so reset the carry flag if we're dealing with a little boy
63390 CCF Set the carry flag if this character should be considered for teleportation
63391 CALL C,25134 Teleport this character if appropriate
63394 EXX
The loop that prepares each character for the new lesson continues here.
63395 DEC D Next character
63396 LD A,D Copy this character's number to A
63397 CP 182 Have we done all the characters yet?
63399 JR NZ,63332 Jump back if not
63401 JP 32433 Print the lesson and ring the bell
Prev: 63210 Up: Map Next: 63404