Prev: 725E Up: Map Next: 72C9
7264: Make a character write on a blackboard
The address of this interruptible subcommand routine is placed into bytes 0x69 and 0x6A of a character's buffer by the routines at 7D30, 7D9E and F300.
Input
H Character number (0xA3-0xA7)
7264 CALL $7128 Collect the identifier of the nearest blackboard in A
7267 LD C,A BC=7FED (Reading Room blackboard), 7FEF (White Room blackboard), or 7FF1 (Exam Room blackboard)
7268 LD B,$7F
726A INC C
726B LD A,(BC) A=number of the character who last wrote on the board
726C AND A Is the board dirty?
726D JP NZ,$62A4 Terminate this interruptible subcommand if so
7270 NOP
7271 NOP
7272 NOP
The board is clean, so the character can go ahead and write on it.
7273 LD A,H Store this character's number in the blackboard buffer, indicating that he wrote on it
7274 LD (BC),A
7275 LD L,$6E Zero out bytes 0x6D and 0x6E of the character's buffer (which hold the submessage address)
7277 LD (HL),$00
7279 DEC L
727A LD (HL),$00
727C ADD A,$43 A=0xEA (BOY WANDER) or 0xE6-0xE9 (a teacher)
727E CP $EA Are we dealing with a teacher?
7280 JR C,$7284 Jump if so
7282 LD A,$E5 A=0xE5 if we're dealing with BOY WANDER
7284 DEC L A holds the MSB of the blackboard message address; store this in byte 0x6C of the character's buffer
7285 LD (HL),A
7286 DEC L Get a random multiple of 32 in A; this will be the LSB of the blackboard message address, which is stored in byte 0x6B of the character's buffer
7287 CALL $61A1
728A AND $E0
728C LD (HL),A
728D LD L,$69 Replace the address of this routine in bytes 0x69 and 0x6A of the character's buffer with that of the entry point at 7291 (below)
728F LD (HL),$91
This entry point is used on subsequent calls.
7291 CALL $7142 Write a single letter on the blackboard
7294 JR NZ,$72A7 Jump unless the character has finished writing
7296 CALL $6214 Update the SRB for the character's current animatory state
7299 AND $F8 A=base animatory state of the teacher writing on the board
729B BIT 6,A Is it actually a teacher writing on the board?
729D JR NZ,$72A1 Jump if so
729F AND $F0 A=base animatory state of BOY WANDER
72A1 CALL $61B0 Update the character's animatory state and update the SRB
72A4 JP $62A4 Terminate this interruptible subcommand
The character hasn't finished writing on the board yet.
72A7 CALL $6214 Update the SRB for the character's current animatory state
72AA BIT 6,A Set the zero flag if BOY WANDER is writing on the board
72AC LD B,A B=character's current animatory state
72AD JR NZ,$72BF Jump if a teacher is writing on the board
BOY WANDER is writing on the board. Determine his next animatory state: 0x3C/0xBC or 0x3D/0xBD.
72AF AND $7F Drop the direction bit (bit 7) for now
72B1 CP $3C 0x3C=BOY WANDER writing (phase 1)
72B3 LD A,$7A A/2=0x3D=BOY WANDER writing (phase 2)
72B5 JR Z,$72B9 Jump if BOY WANDER is in writing phase 1
72B7 LD A,$78 A/2=0x3C=BOY WANDER writing (phase 1)
72B9 RL B Slide the direction bit into bit 7 of A, which will then hold BOY WANDER's next animatory state
72BB RRA
72BC JP $61B0 Update BOY WANDER's animatory state and update the SRB
A teacher is writing on the board. Toggle the status of his arm (up/down).
72BF AND $F8 A=base animatory state of the teacher
72C1 CP B Is the teacher's arm raised?
72C2 JR NZ,$72C6 Jump if not
72C4 ADD A,$05 A=animatory state of the teacher with his arm raised
72C6 JP $61B0 Update the teacher's animatory state and update the SRB
Prev: 725E Up: Map Next: 72C9