| Routines

6B1B: Write a line of text into a graphic buffer

Used by the routines at 50B9 and 6B46. Writes a line of text into a graphic buffer (at 5B00 or E428) and centres it.
Input
DE | Message address
HL | Buffer address
6B1B | LD ($D60B),DE | Save the message address in bytes 0x0B and 0x0C of the character buffer in page 0xD6
This entry point is used by the routine at 6B46 to write the second line of text into the message box graphic buffer at E428.
6B1F | PUSH HL | Copy the buffer address to HL'
6B20 | EXX
6B21 | POP HL
6B22 | LD BC,$0000 | B=0 (during startup) or 64, C=0 (this instruction is set to LD BC,$4000 before the game starts; see 53A0)
6B25 | LD (HL),C | Create 64 (or 256) empty pixel columns in the buffer
6B26 | INC HL
6B27 | DJNZ $6B25
6B29 | DEC HL |
6B2A | EXX |
6B2B | LD H,$D6 | We are using the character buffer in page 0xD6 to process the message
6B2D | LD C,$FF | The message box is 255 (during startup) or 64 pixels wide (this instruction is set to LD C,$40 before the game starts; see 53A0)
6B2F | CALL $66CE | A=ASCII code of the next character in the message
6B32 | CP $03 | Is the ASCII code 0, 1 or 2 (end of line)?
6B34 | JR C,$6B3B | Jump if so to centre the text
6B36 | CALL $69E6 | Slide the bitmap for CHR$(A) into the buffer
6B39 | JR $6B2F | Jump back to do the next character
6B3B | SRL C | Now C=half the number of unused pixel columns left in the buffer
6B3D | RET Z | Return if this is zero (the buffer is full)
6B3E | CALL $69F4 | Create C empty pixel columns in the buffer, thus centring the message
6B41 | DEC C
6B42 | JR NZ,$6B3E
6B44 | RET |