Prev: 71E1 Up: Map Next: 725E
71E8: Make a teacher wipe a blackboard (2)
Continues from 71DC.
Input
A Blackboard identifier (0xEC, 0xEE or 0xF0)
DE Coordinates of the top-left corner of the blackboard
H Teacher's character number (0xA3-0xA6)
71E8 LD L,$69 Replace the address of the interruptible subcommand routine at 71DC in bytes 0x69 and 0x6A of the teacher's buffer with 71F7 (below)
71EA LD (HL),$F7
71EC LD L,$6B Wiping a blackboard requires 32 distinct actions (in 8 groups of 4: two paces forward, arm up, arm down)
71EE LD (HL),$20
71F0 INC L Store the x-coordinate of the rightmost column of the blackboard (which will be wiped first) in byte 0x6C of the teacher's buffer
71F1 LD A,E
71F2 ADD A,$07
71F4 LD (HL),A
71F5 INC L Store the y-coordinate of the top row of the blackboard in byte 0x6D of the teacher's buffer
71F6 LD (HL),D
After the initial call to this routine, each subsequent call enters here.
71F7 LD L,$6B Decrement the number of board-wiping actions remaining
71F9 DEC (HL)
71FA BIT 7,(HL) Has the teacher finished wiping the board?
71FC JR NZ,$7250 Jump if so
71FE CALL $6214 Update the SRB for the teacher's current location
7201 LD L,$6B Is the teacher midstride or is his arm raised?
7203 BIT 0,(HL)
7205 JR Z,$7240 Jump if so
7207 BIT 1,(HL) Is the teacher ready to raise his arm (and wipe)?
7209 JR Z,$720F Jump if so
720B INC A A=animatory state of the teacher midstride
720C JP $61B0 Update the teacher's animatory state and update the SRB
The teacher is ready to raise his arm and wipe a column of the board.
720F ADD A,$05 A=animatory state of the teacher with his arm raised
7211 CP $48 Are we actually dealing with a teacher?
7213 JR NC,$7217 Jump if so
7215 ADD A,$08 If ANGELFACE or BOY WANDER were wiping the board, A would now hold the animatory state of the boy with his arm raised
7217 CALL $61B0 Update the teacher's animatory state and update the SRB
721A LD L,$6C E=x-coordinate of the blackboard column to wipe
721C LD E,(HL)
721D DEC (HL) Decrement the blackboard column x-coordinate
721E INC L D=y-coordinate of the top row of the blackboard column to wipe
721F LD D,(HL)
7220 CALL $7087 Update the SRB for the upper and lower character squares of the blackboard column that will be wiped
7223 INC D
7224 CALL $7087
7227 LD A,(DE) L=skool UDG reference for the lower character square of the blackboard column
7228 LD L,A
7229 ADD A,$08 E=skool UDG reference for the upper character square of the blackboard column
722B LD E,A
722C LD H,$80 Point HL at the base address of the UDG data for the lower character square of the blackboard column, and DE at the base address of the UDG data for the upper character square of the blackboard column
722E CP $E9
7230 JR NC,$7234
7232 LD H,$88
7234 LD D,H
7235 LD B,$08 There are 8 bytes in a UDG
7237 LD A,$FF All bits set means clean (no chalk)
7239 LD (HL),A Wipe the blackboard column clean by altering the skool UDG data directly
723A LD (DE),A
723B INC H
723C INC D
723D DJNZ $7239
723F RET
The teacher is midstride or his arm is raised.
7240 AND $F8 A=base animatory state of the teacher
7242 CP $48 Are we actually dealing with a teacher?
7244 JR NC,$7248 Jump if so
7246 AND $F0 If ANGELFACE or BOY WANDER were wiping the board, A would now hold the base animatory state of the boy
7248 BIT 1,(HL) Is the teacher's arm raised?
724A JR Z,$724D Jump if so
724C DEC E The teacher was midstride, so move him forward to the next blackboard column
724D JP $61B0 Update the teacher's animatory state and location and update the SRB
The teacher has finished wiping the board.
7250 CALL $7128 A=identifier of the blackboard the teacher is next to
7253 LD L,A HL=7FEC (Reading Room blackboard), 7FEE (White Room blackboard), or 7FF0 (Exam Room blackboard)
7254 LD H,$7F
7256 LD (HL),$01 The first clean pixel column is now column no. 1
7258 INC L Signal: no one has written on this blackboard
7259 LD (HL),$00
725B JP $62A4 Terminate this interruptible subcommand
Prev: 71E1 Up: Map Next: 725E