Prev: F6EA Up: Map Next: F7AC
F74D: Change the lesson
This routine is called from the main loop at F6EA 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 7FE4 (MSB of the lesson clock)
Output
F74D LD (HL),$10 Reset the MSB of the lesson clock to 0x10
F74F CALL $F858 Clear the flags at 7F80 and 7F81
F752 LD L,$DF HL=7FDF (which holds the current lesson number)
F754 LD A,(HL) Pick this up in A (0xC0-0xFF)
F755 INC A Next lesson
F756 OR $C0 Roll over from 0xFF to 0xC0 if necessary
F758 LD (HL),A Store the new lesson number
F759 LD E,A Point DE at the main timetable entry for this lesson
F75A LD D,$B5
F75C LD A,(DE) Pick up the lesson identifier (0x25-0x3B) in A
F75D LD E,A Copy this to E
F75E LD D,$D2 The lesson descriptor table is at D225
F760 LD A,(DE) Pick up the lesson descriptor in A
F761 INC L Store a copy of the lesson descriptor in 7FE0
F762 LD (HL),A
F763 DEC D D=0xD1 (HAYLEY)
We now enter a loop to transfer the start address of a command list into bytes 0x1B and 0x1C of each character's buffer.
F764 LD H,D
F765 LD A,(DE) A=command list number for this lesson from the character's personal timetable
F766 EXX
F767 LD H,$E8 Page 0xE8 holds the start addresses of the command lists
F769 LD L,A Pick up the LSB of the command list start address in A
F76A LD A,(HL)
F76B INC L Point HL' at the MSB
F76C EXX
F76D LD L,$1B The LSB of the command list start address goes into byte 0x1B of the character's buffer
F76F LD (HL),A
F770 INC L Point HL at byte 0x1C of the character's buffer
F771 EXX
F772 LD A,(HL) A=MSB of the command list start address
F773 EXX
F774 LD (HL),A Place this into byte 0x1C of the character's buffer
F775 INC L Set bit 0 of byte 0x1D 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 0x11 and 0x12 or bytes 0x09 and 0x0A of the character's buffer has finished its job; see 62D0)
F776 SET 0,(HL)
F778 LD A,H Copy the character number to A
F779 CP $C6 Are we dealing with one of the characters 0xC6-0xD1 (little boys nos. 9 and 10, the adults and the main kids)?
F77B JR NC,$F7A3 Jump if so
We are dealing with one of the characters 0xB7-0xC5 (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.
F77D SET 3,(HL) Set bit 3 of byte 0x1D, signalling to the routine at 622E (called later) that this character may be teleported
F77F EXX
F780 LD B,$01 We let the routine at 622E consider only one character at a time
F782 LD H,A H'=character number (0xB7-0xC5)
F783 LD A,($7FFF) A=X (leftmost column of the play area on screen)
F786 CP $50 Is X at least 80 (the middle of the assembly hall stage)?
F788 JR NC,$F78F Jump if so
F78A LD A,H A=character number (0xB7-0xC5)
F78B CP $BE Now X<80, so set the carry flag if we're dealing with a little girl (none of whom should be on-screen)
F78D JR $F79F
F78F CP $78 Set the carry flag if X<120
F791 LD A,H A=character number (0xB7-0xC5)
F792 JR NC,$F79C Jump if X>=120 (which means none of the little boys 1-8 should be on-screen)
F794 CP $C1 Are we dealing with little boys 4-8?
F796 JR NC,$F7A2 Jump if so (they do venture this far into the playground)
F798 CP $BA 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)
F79A JR $F79E
F79C CP $BE Now X>=120, so reset the carry flag if we're dealing with a little boy
F79E CCF Set the carry flag if this character should be considered for teleportation
F79F CALL C,$622E Teleport this character if appropriate
F7A2 EXX
The loop that prepares each character for the new lesson continues here.
F7A3 DEC D Next character
F7A4 LD A,D Copy this character's number to A
F7A5 CP $B6 Have we done all the characters yet?
F7A7 JR NZ,$F764 Jump back if not
F7A9 JP $7EB1 Print the lesson and ring the bell
Prev: F6EA Up: Map Next: F7AC