Prev: $108B Up: Map Next: $11CF
$1129: Make a character write on a blackboard
This corresponds to $7264 in the ZX Spectrum version.
The address of this interruptible subcommand routine is placed into a character's buffer by the routines at $09E9, $0A58 and $28AB.
$1129 JSR $1468 Copy the details of the blackboard nearest to the character into page 0.
$112C LDA $19 Is the blackboard clean?
$112E BEQ $1133 Branch if so.
$1130 JMP $1D28 Otherwise terminate this interruptible subcommand.
$1133 LDA $60 Pick up the current character number from $60 and store it in the second byte of the blackboard buffer as a record of who last wrote on the blackboard.
$1135 STA $1A
$1137 LDA #$00 Clear any existing submessage address from $AE.
$1139 STA $AE
$113B STA $AF
$113D LDA $60 Pick up the current character number from $60.
$113F SEC Reduce A to 0-3 (a teacher) or 5 (BOY WONDER).
$1140 SBC #$0B
$1142 CMP #$05 Is the current character BOY WONDER?
$1144 BNE $1149 Branch if not.
$1146 SEC Set the carry flag to prepare for subtraction.
$1147 SBC #$01 Subtract 1. Now A holds 4.
$1149 CLC Add $53 to obtain the base page number of the blackboard messages for this character ($53-$57) and store it at $AD.
$114A ADC #$53
$114C STA $AD
$114E LDA $D41B Generate random value between 0 and 7.
$1151 AND #$07
$1153 ASL A Multiply by 32, giving the LSB of the address of a blackboard message.
$1154 ASL A
$1155 ASL A
$1156 ASL A
$1157 ASL A
$1158 STA $AC Store this LSB at $AC.
$115A LDA #$11 Replace the address of this interruptible subcommand routine in the character's buffer with that of $1167 below.
$115C STA $AB
$115E LDA #$67
$1160 STA $AA
$1162 LDY $DA Pick up the blackboard identifier from $DA.
$1164 JSR $1445 Restore the blackboard buffer from page 0.
After the initial call to this routine, each subsequent call enters here.
$1167 JSR $1468 Copy the details of the blackboard nearest to the character into page 0.
$116A JSR $108B Get the code of the next character to be written on the blackboard.
$116D CMP #$00 Is the message finished?
$116F BNE $118D Branch if not.
$1171 JSR $322E Update the SRB for the character's current animatory state and location.
$1174 LDA $26 Pick up the character's animatory state.
$1176 ASL A Is a teacher (as opposed to BOY WONDER) writing on the blackboard?
$1177 ASL A
$1178 BCS $1181 Branch if so.
$117A LDA $26 Pick up BOY WONDER's animatory state.
$117C AND #$F0 Clear bits 0-3, lowering his arm.
$117E JMP $1185 Jump forward.
$1181 LDA $26 Pick up the teacher's animatory state.
$1183 AND #$F8 Clear bits 0-2, lowering his arm.
$1185 STA $26 Update the character's animatory state.
$1187 JSR $322E Update the SRB for the character's new animatory state.
$118A JMP $1D28 Terminate this interruptible subcommand.
The character hasn't finished writing on the board yet.
$118D CMP #$02 Is the next character in the message a newline?
$118F BNE $1198 Branch if not.
$1191 LDA #$40 Update the blackboard's pixel column counter at $19 to $40 (start of the second line).
$1193 STA $19
$1195 JMP $11C9 Jump forward.
$1198 JSR $11CF Write the character on the blackboard.
$119B JSR $322E Update the SRB for the character's current animatory state and location.
$119E LDA $26 Pick up the character's animatory state.
$11A0 ASL A Is BOY WONDER (as opposed to a teacher) writing on the blackboard?
$11A1 ASL A
$11A2 BCC $11B4 Branch if so.
A teacher is writing on the blackboard.
$11A4 LDA $26 Pick up the teacher's animatory state.
$11A6 AND #$F8 Clear bits 0-2.
$11A8 CMP $26 Is the teacher's arm raised?
$11AA BNE $11AF Branch if so.
$11AC CLC Add 5 to the teacher's animatory state, thus raising his arm.
$11AD ADC #$05
$11AF STA $26 Update the teacher's animatory state (raising or lowering his arm).
$11B1 JMP $11C6 Jump forward.
BOY WONDER is writing on the blackboard.
$11B4 LDA $26 Pick up BOY WONDER's animatory state.
$11B6 AND #$80 Keep only the direction bit (bit 7).
$11B8 CLC Add $3C - the animatory state of BOY WONDER with his arm raised (phase 1).
$11B9 ADC #$3C
$11BB CMP $26 Is BOY WONDER's arm raised (phase 1)?
$11BD BEQ $11C4 Branch if so.
$11BF STA $26 Otherwise set BOY WONDER's animatory state to $3C/$BC (arm raised, phase 1).
$11C1 JMP $11C6 Jump forward.
$11C4 INC $26 Set BOY WONDER's animatory state to $3D/$BD (arm raised, phase 2).
$11C6 JSR $322E Update the SRB for the character's new animatory state.
$11C9 LDY $DA Pick up the blackboard identifier from $DA.
$11CB JSR $1445 Restore the blackboard buffer from page 0.
$11CE RTS
Prev: $108B Up: Map Next: $11CF