| Routines

29284: Make a character write on a blackboard

The address of this interruptible subcommand routine is placed into bytes 105 and 106 of a character's buffer by the routines at 32048, 32158 and 62208.
Input
H | Character number (163-167)
29284 | CALL 28968 | Collect the identifier of the nearest blackboard in A
29287 | LD C,A | BC=32749 (Reading Room blackboard), 32751 (White Room blackboard), or 32753 (Exam Room blackboard)
29288 | LD B,127
29290 | INC C
29291 | LD A,(BC) | A=number of the character who last wrote on the board
29292 | AND A | Is the board dirty?
29293 | JP NZ,25252 | Terminate this interruptible subcommand if so
29296 | NOP |
29297 | NOP |
29298 | NOP |
The board is clean, so the character can go ahead and write on it.
29299 | LD A,H | Store this character's number in the blackboard buffer, indicating that he wrote on it
29300 | LD (BC),A
29301 | LD L,110 | Zero out bytes 109 and 110 of the character's buffer (which hold the submessage address)
29303 | LD (HL),0
29305 | DEC L
29306 | LD (HL),0
29308 | ADD A,67 | A=234 (BOY WANDER) or 230-233 (a teacher)
29310 | CP 234 | Are we dealing with a teacher?
29312 | JR C,29316 | Jump if so
29314 | LD A,229 | A=229 if we're dealing with BOY WANDER
29316 | DEC L | A holds the MSB of the blackboard message address; store this in byte 108 of the character's buffer
29317 | LD (HL),A
29318 | 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 107 of the character's buffer
29319 | CALL 24993
29322 | AND 224
29324 | LD (HL),A
29325 | LD L,105 | Replace the address of this routine in bytes 105 and 106 of the character's buffer with that of the entry point at 29329 (below)
29327 | LD (HL),145
This entry point is used on subsequent calls.
29329 | CALL 28994 | Write a single letter on the blackboard
29332 | JR NZ,29351 | Jump unless the character has finished writing
29334 | CALL 25108 | Update the SRB for the character's current animatory state
29337 | AND 248 | A=base animatory state of the teacher writing on the board
29339 | BIT 6,A | Is it actually a teacher writing on the board?
29341 | JR NZ,29345 | Jump if so
29343 | AND 240 | A=base animatory state of BOY WANDER
29345 | CALL 25008 | Update the character's animatory state and update the SRB
29348 | JP 25252 | Terminate this interruptible subcommand
The character hasn't finished writing on the board yet.
29351 | CALL 25108 | Update the SRB for the character's current animatory state
29354 | BIT 6,A | Set the zero flag if BOY WANDER is writing on the board
29356 | LD B,A | B=character's current animatory state
29357 | JR NZ,29375 | Jump if a teacher is writing on the board
BOY WANDER is writing on the board. Determine his next animatory state: 60/188 or 61/189.
29359 | AND 127 | Drop the direction bit (bit 7) for now
29361 | CP 60 | 60=BOY WANDER writing (phase 1)
29363 | LD A,122 | A/2=61=BOY WANDER writing (phase 2)
29365 | JR Z,29369 | Jump if BOY WANDER is in writing phase 1
29367 | LD A,120 | A/2=60=BOY WANDER writing (phase 1)
29369 | RL B | Slide the direction bit into bit 7 of A, which will then hold BOY WANDER's next animatory state
29371 | RRA
29372 | JP 25008 | 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).
29375 | AND 248 | A=base animatory state of the teacher
29377 | CP B | Is the teacher's arm raised?
29378 | JR NZ,29382 | Jump if not
29380 | ADD A,5 | A=animatory state of the teacher with his arm raised
29382 | JP 25008 | Update the teacher's animatory state and update the SRB