Prev: $1129 Up: Map Next: $126D
$11CF: Write a single character on a blackboard
This corresponds to $7142 in the ZX Spectrum version.
Used by the routines at $1129 and $184E.
Input
A Character code ($20-$7F)
$11CF STA $21 Store the address that holds the font character bitmap width at $21.
$11D1 LDA #$47
$11D3 STA $22
$11D5 LDA $19 Pick up the blackboard's pixel column counter from $19.
$11D7 ORA #$C0 Set bits 6 and 7.
$11D9 CLC Add 1 to advance to the next pixel column.
$11DA ADC #$01
$11DC BCS $11E5 Branch if we've reached the end of a line.
$11DE LDY #$00 Add the width of the font character bitmap.
$11E0 CLC
$11E1 ADC ($21),Y
$11E3 BCC $11ED Branch if the bitmap will fit on the current line.
$11E5 LDA $19 Set the blackboard's pixel column counter at $19 to either $00 (start of the top line) or $40 (start of the bottom line).
$11E7 AND #$40
$11E9 EOR #$40
$11EB STA $19
$11ED LDA $19 Pick up the blackboard's pixel column counter from $19.
$11EF AND #$3F Clear bits 6 and 7, divide by 8, and add the x-coordinate of the top left corner of the blackboard. This gives the play area x-coordinate of the target character cell.
$11F1 LSR A
$11F2 LSR A
$11F3 LSR A
$11F4 CLC
$11F5 ADC $15
$11F7 STA $15 Store this x-coordinate at $15.
$11F9 LDA $19 Pick up the blackboard's pixel column counter from $19.
$11FB CMP #$40 Are we on the top line of the blackboard?
$11FD BCC $1201 Branch if so.
$11FF INC $16 Increment the target blackboard character cell y-coordinate at $16.
$1201 LDA $15 Pick up the target blackboard character cell x-coordinate from $15.
$1203 SEC Subtract the x-coordinate of the leftmost column of the skool on screen, giving the screen x-coordinate.
$1204 SBC $58
$1206 STA $49 Store this screen x-coordinate at $49.
$1208 LDA $16 Copy the target blackboard character cell y-coordinate from $16 to $4A.
$120A STA $4A
$120C JSR $36E3 Update the SRB for the target blackboard character cell.
$120F INC $49 Increment the x-coordinate at $49.
$1211 JSR $36E3 Update the SRB for the next character cell to the right.
$1214 LDA $19 Pick up the blackboard's pixel column counter from $19.
$1216 AND #$07 Prepare a mask in A such that the only reset bit corresponds to the target pixel column in the target character cell.
$1218 TAX
$1219 INX
$121A LDA #$FF
$121C CLC
$121D ROR A
$121E DEX
$121F BNE $121D
$1221 STA $23 Store this mask at $23.
$1223 JSR $1294 Get the address of the skool tile corresponding to the blackboard character cell.
$1226 LDY #$00 Pick up the font character bitmap width and store this counter at $4E.
$1228 LDA ($21),Y
$122A STA $4E
The loop that draws the font character into the blackboard character cell starts here.
$122C INC $22 Point at the next pixel column of the font character bitmap.
$122E LDA #$08 There are 8 pixels in the column to be drawn.
$1230 STA $4F Store this counter at $4F.
$1232 LDA ($21),Y Pick up the next pixel column of the font character bitmap.
$1234 ROL A Push the bit to be drawn into the carry flag.
$1235 PHA Save the remainder of the pixel column temporarily.
$1236 BCC $123E Branch if the pixel is a 0 (nothing to draw).
$1238 LDA $23 Pick up the mask from $23 and apply it to the skool tile graphic data byte for the target blackboard character cell.
$123A AND ($1B),Y
$123C STA ($1B),Y
$123E INC $1C Move to the next byte of skool tile graphic data.
$1240 PLA Restore the remainder of the pixel column to A.
$1241 DEC $4F Have we drawn all 8 pixels in the column yet?
$1243 BNE $1234 Branch back if not.
$1245 INC $19 Increment the blackboard's pixel column counter at $19 and pick up the new value.
$1247 LDA $19
$1249 AND #$07 Have we just drawn in the rightmost pixel column of the target character cell?
$124B BEQ $1257 Branch if so.
$124D LDA $1C Reset the skool tile graphic data pointer back to the first byte in the tile.
$124F SEC
$1250 SBC #$08
$1252 STA $1C
$1254 JMP $125C Jump forward.
$1257 INC $15 Increment the target blackboard cell x-coordinate at $15.
$1259 JSR $1294 Get the address of the skool tile corresponding to the blackboard character cell.
$125C DEC $4E Have we drawn every pixel column in the font character bitmap now?
$125E BEQ $126A Branch if so.
$1260 SEC Otherwise shift the reset bit in the mask at $23 one place to right, ready for the next pixel column.
$1261 ROR $23
$1263 BCS $122C Branch unless the reset bit fell into the carry flag.
$1265 ROR $23 Rotate the reset bit into bit 7.
$1267 JMP $122C Jump back to start drawing the next pixel column.
$126A INC $19 Increment the blackboard's pixel column counter at $19.
$126C RTS
Prev: $1129 Up: Map Next: $126D