Prev: $3AB4 Up: Map Next: $3B46
$3AD5: Change the lesson
This corresponds to $66E6 in the ZX Spectrum version.
Called from the main loop at $0800.
$3AD5 LDA #$0F Reset the MSB of the lesson clock at $40 to $0F.
$3AD7 STA $40
$3AD9 INC $41 Increment the current lesson number at $41 and pick up the new value.
$3ADB LDA $41
$3ADD CMP #$40 Is it $40?
$3ADF BNE $3AE5 Branch if not.
$3AE1 LDA #$00 Otherwise reset the lesson number to 0.
$3AE3 STA $41
$3AE5 LDA #$00 Prepare to address the main timetable at $5D00.
$3AE7 STA $4E
$3AE9 LDA #$5D
$3AED LDY $41 Pick up the current lesson identifier ($E0-$FF) from the main timetable and store it at $42.
$3AEF LDA ($4E),Y
$3AF1 STA $42
$3AF3 TAY Transfer the current lesson identifier to Y.
$3AF4 LDA #$8C The table of lesson descriptors is in page $8C.
$3AF6 STA $4F
$3AF8 LDA ($4E),Y Copy the lesson descriptor for the new lesson to $70.
$3AFA STA $70
$3AFC JSR $2573 Print the teacher and room name in the lesson box.
$3AFF JSR $3B46 Select a special PLAYTIME occasionally.
$3B02 LDA #$03 Set the sound effect identifier at $2C to 3: the bell is ringing.
$3B04 STA $2C
$3B06 LDA #$21 Initialise the sound effect timer at $2D.
$3B08 STA $2D
$3B0A JSR $392D Clear all the signal flags.
$3B0D LDX #$12 There are 18 characters (11 little boys, 4 teachers and 3 main kids) to prepare for the new lesson.
$3B0F LDA #$00 Reset the identifier of the next lines reprimand for the teacher fetching the truant ERIC at $C8.
$3B11 STA $C8
$3B13 STA $C2 Reset the birth year question indicator at $C2.
$3B15 STA $60 Set the current character number at $60 to $00 (little boy no. 1).
$3B17 STA $50 Prepare to address the characters' personal timetables, starting with little boy no. 1's at $78E0.
$3B19 LDA #$78
$3B1B STA $51
Now we enter a loop to update the command list start address for each character.
$3B1D TXA Save the character counter on the stack.
$3B1F JSR $3279 Copy the current character's buffer to page 0.
$3B22 LDY $42 Pick up the lesson identifier ($E0-$FF) from $42.
$3B24 LDA ($50),Y Obtain the command list number from the character's personal timetable and store it at $43.
$3B26 STA $43
$3B28 LDY #$00 Collect the start address of the command list from the table at $4480 and store it in the character's buffer at $3D.
$3B2A LDA ($43),Y
$3B2C STA $3D
$3B2F LDA ($43),Y
$3B31 STA $3E
$3B33 LDA $3F Set bit 7 at $3F, triggering a command list restart at the next available opportunity.
$3B35 ORA #$80
$3B37 STA $3F
$3B39 JSR $33BF Restore the current character's buffer from page 0.
$3B3C INC $60 Increment the current character number at $60.
$3B3E INC $51 Next character's personal timetable.
$3B40 PLA Restore the character counter to X.
$3B41 TAX
$3B42 DEX Have we dealt with every character yet?
$3B43 BNE $3B1D Branch back if not.
$3B45 RTS
Prev: $3AB4 Up: Map Next: $3B46