Prev: $16E8 Up: Map Next: $176F
$16E9: Make a teacher wipe a blackboard
This corresponds to $71E8 in the ZX Spectrum version.
The address of this interruptible subcommand routine is placed into a teacher's buffer by the routines at $09E9 and $0A58.
$16E9 LDA #$17 Replace the address of this interruptible subcommand routine in the teacher's buffer with that of $170E below.
$16EB STA $AB
$16ED LDA #$0E
$16EF STA $AA
$16F1 JSR $1468 Get the identifier and coordinates of the blackboard closest to the teacher.
$16F4 LDA #$20 Wiping a blackboard requires 32 distinct actions (in 8 groups of 4: two paces forward, arm up, arm down).
$16F6 STA $AC
$16F8 LDA $15 Pick up the x-coordinate of the leftmost column of the blackboard.
$16FA CLC Add 7 and store the result at $AD. This is the x-coordinate of the rightmost column of the blackboard, and the first to be wiped.
$16FB ADC #$07
$16FD STA $AD
$16FF LDA $16 Pick up the y-coordinate of the top row of the blackboard and store it at $AE.
$1701 STA $AE
$1703 LDA #$00 Reset the blackboard pixel column counter at $19, and the number of the character who last wrote on the board at $1A.
$1705 STA $19
$1707 STA $1A
$1709 LDY $DA Pick up the blackboard identifier from $DA.
$170B JSR $1445 Restore the blackboard's buffer from page 0.
After the initial call to this routine, each subsequent call enters here.
$170E LDA $AC Pick up the number of board-wiping actions remaining.
$1710 BNE $1715 Branch unless the teacher has finished wiping the board.
$1712 JMP $1D28 Terminate this interruptible subcommand.
$1715 JSR $322E Update the SRB for the teacher's current animatory state and location.
$1718 DEC $AC Decrement the board-wiping action counter at $AC and pick up its new value.
$171A LDA $AC
$171C LSR A Is the teacher midstride or does he have his arm raised?
$171D BCS $1732 Branch if not.
$171F PHA Save the shifted board-wiping action counter temporarily.
$1720 LDA $26 Clear bits 0-2 of the teacher's animatory state at $26, thus moving him from the midstride position or lowering his arm.
$1722 AND #$F8
$1724 STA $26
$1726 PLA Restore the shifted board-wiping action counter.
$1727 LSR A Was the teacher midstride?
$1728 BCC $172C Branch if not.
$172A DEC $FC Decrement the teacher's x-coordinate at $FC, moving him forward to the next blackboard column.
$172C JSR $322E Update the SRB for the teacher's new animatory state and location.
$172F JMP $1769 Return.
$1732 LSR A Is the teacher ready to raise his arm (and wipe)?
$1733 BCC $173A Branch if so.
$1735 INC $26 Otherwise increment the teacher's animatory state at $26, moving him midstride on his way to the next blackboard column.
$1737 JMP $172C Jump back.
The teacher is ready to raise his arm and wipe a column of the board.
$173A LDA $26 Add 5 to the teacher's animatory state at $26, making him raise his arm.
$173C CLC
$173D ADC #$05
$173F STA $26
$1741 JSR $322E Update the SRB for the teacher's new animatory state.
$1744 LDA $AD Pick up the x-coordinate of the column of the blackboard to wipe.
$1746 SEC Subtract the x-coordinate of the leftmost column of the skool on screen; store the resulting screen x-coordinate at $49.
$1747 SBC $58
$1749 STA $49
$174B LDA $AE Pick up the y-coordinate of the top row of the blackboard to wipe and copy it to $4A.
$174D STA $4A
$174F JSR $36E3 Update the SRB for the character cell in the top row of the blackboard.
$1752 INC $4A Increment the y-coordinate at $4A.
$1754 JSR $36E3 Update the SRB for the character cell in the bottom row of the blackboard.
$1757 LDX $AD Pick up the x-coordinate of the column of the blackboard to wipe and copy it to $15.
$1759 STX $15
$175B LDY $AE Pick up the y-coordinate of the top row of the blackboard to wipe and copy it to $16.
$175D STY $16
$175F JSR $1994 Wipe the blackboard character cell in the top row clean.
$1762 INC $16 Increment the y-coordinate at $16.
$1764 JSR $1994 Wipe the blackboard character cell in the bottom row clean.
$1767 DEC $AD Decrement the blackboard column x-coordinate at $AD.
$1769 NOP
$176A NOP
$176B NOP
$176C NOP
$176D NOP
$176E RTS
Prev: $16E8 Up: Map Next: $176F