| Routines

26752: Make a character write on a blackboard

The address of this interruptible subcommand routine is placed into bytes 9 and 10 of the character's buffer by the routines at 32497 and 61696.
Input
H | Character number (201-204, 206)
26752 | CALL 26453 | Collect information about the board
26755 | INC B | Point BC at the second byte of the board's buffer
26756 | LD C,B
26757 | LD B,127
26759 | LD A,(BC) | Pick this up in A
26760 | AND A | Has the board been written on already?
26761 | JP NZ,25488 | Terminate this interruptible subcommand if so
26764 | LD A,H | A=character's number
26765 | LD (BC),A | Signal: this character wrote on the board
26766 | DEC C | Point BC at the first byte of the board's buffer (32596, 32602, 32608, 32614 or 32620) and initialise the pixel column to 1
26767 | LD A,1
26769 | LD (BC),A
26770 | LD L,16 | Make sure there are no (sub)submessage addresses lying around in bytes 13-16 of the character's buffer
26772 | LD (HL),0
26774 | LD L,14
26776 | LD (HL),0
26778 | LD A,H | A=character's number (201-204, 206)
26779 | CP 206 | Set E as follows: 32=MR WITHIT, 38=MR ROCKITT, 44=MR CREAK, 50=MISS TAKE, 56=BOY WANDER
26781 | ADC A,59
26783 | LD E,A
26784 | ADC A,A
26785 | ADD A,E
26786 | ADD A,A
26787 | LD E,A
26788 | CALL 25233 | Collect a random number between 0 and 5 in A
26791 | AND 7
26793 | CP 6
26795 | JR NC,26788
26797 | ADD A,E | Now E=blackboard message number
26798 | LD E,A
26799 | LD D,254 | Pick up the address of the message and place it into bytes 11 and 12 of the character's buffer
26801 | LD L,11
26803 | LD A,(DE)
26804 | LD (HL),A
26805 | INC D
26806 | INC L
26807 | LD A,(DE)
26808 | LD (HL),A
26809 | LD L,9 | Replace the address of this routine in bytes 9 and 10 of the character's buffer with 26813 (below)
26811 | LD (HL),189
26813 | CALL 26513 | Write one letter on the board
26816 | JR NZ,26829 | Jump unless the character has finished writing
This entry point is used by the routine at 27904.
26818 | CALL 25012 | Update the SRB for the character's current animatory state and location
26821 | AND 248 | A=base animatory state of the character (arm down)
26823 | CALL 24880 | Update the character's animatory state and update the SRB
26826 | JP 25488 | Terminate this interruptible subcommand
The character hasn't finished writing yet. Figure out his next arm movement (up or down).
26829 | CALL 25012 | Update the SRB for the character's current animatory state and location
26832 | RRCA | Set the carry flag if the character's arm is raised
26833 | RLCA
26834 | JR C,26841 | Jump if the character's arm is raised
26836 | OR 7 | A=animatory state of the character with his arm up
26838 | JP 24880 | Update the character's animatory state and location and update the SRB
26841 | AND 248 | A=base animatory state of character (arm down)
26843 | JR 26838 | Jump back to update the SRB