Prev: 8822 Up: Map Next: 8B78
8B22: Print: ZX Printer
Used by the routine at PrintWriteACharacterToTheScreen.
Copies eight pixel rows of the text line at 5020 to the ZX printer through port FB when the printer-on flag at B6F2 is set.
ZXPrinter 8B22 LD A,($B6F2) Read the printer-on flag at B6F2.
8B25 AND A Return if the printer is off.
8B26 RET Z
8B27 PUSH HL Save the text pointer. The printer row count starts at 01.
8B28 PUSH DE
8B29 PUSH BC
8B2A LD D,$01
8B2C LD HL,$5020 Point HL at the text line.
8B2F XOR A Take zero for the first printer byte.
8B30 LD E,A Clear the marker's low byte.
ZXPrinter_WriteAByteToThePrinter 8B31 OUT ($FB),A Write a byte to the printer.
ZXPrinter_Loop 8B33 IN A,($FB) Read the printer port FB.
8B35 ADD A,A Double the printer status.
8B36 JP M,ZXPrinter_RestoreAndReturn Jump to ZXPrinter_RestoreAndReturn if bit 6 of the printer port is set (no printer attached).
8B39 JR NC,ZXPrinter_Loop Jump back to ZXPrinter_Loop while bit 7 of the printer port is clear.
8B3B PUSH HL Save the line address and the marker, and take the row count into A.
8B3C PUSH DE
8B3D LD A,D
8B3E CP $02 Compare the printer row count with 02.
8B40 SBC A,A Make A FF when that row count was below 02, and zero otherwise.
8B41 AND E Build the marker bit from E.
8B42 RLCA
8B43 AND E
8B44 LD D,A
ZXPrinter_ReadAByteFromThePointer 8B45 LD C,(HL) Read a byte from the pointer into C.
8B46 PUSH HL Count 08 passes.
8B47 LD B,$08
ZXPrinter_TakeThePrinterByte 8B49 LD A,D Take the byte being sent to the printer.
8B4A RLC C Rotate the next source bit into carry.
8B4C RRA Shift that bit into the byte for the printer.
8B4D LD H,A Remember the byte built so far.
ZXPrinter_WaitWhileThePrinterIsBusy 8B4E IN A,($FB) Read the printer port FB.
8B50 RRA Jump back to ZXPrinter_WaitWhileThePrinterIsBusy while the printer is busy.
8B51 JR NC,ZXPrinter_WaitWhileThePrinterIsBusy
8B53 LD A,H Take the byte built for the printer.
8B54 OUT ($FB),A Write a byte to the printer.
8B56 DJNZ ZXPrinter_TakeThePrinterByte Loop back to ZXPrinter_TakeThePrinterByte until 08 runs out.
8B58 POP HL Step along the text line at 5020 and continue while a character remains.
8B59 INC HL
8B5A LD A,L
8B5B AND $1F
8B5D JR NZ,ZXPrinter_ReadAByteFromThePointer
ZXPrinter_WaitUntilThePrinterIsReady 8B5F IN A,($FB) Read the printer port FB.
8B61 RRA Wait until the printer is ready (bit 0 of port FB).
8B62 JR NC,ZXPrinter_WaitUntilThePrinterIsReady
8B64 LD A,D Take the byte being sent to the printer.
8B65 RRCA Rotate the next bit out towards the printer.
8B66 OUT ($FB),A Write a byte to the printer.
8B68 POP DE Restore DE and HL from the stack, step to the next row, and jump back to ZXPrinter_WriteAByteToThePrinter if bit 3 of E is clear.
8B69 POP HL
8B6A INC H
8B6B INC E
8B6C BIT 3,E
8B6E JR Z,ZXPrinter_WriteAByteToThePrinter
8B70 LD A,$04 Send 04 to the printer port.
8B72 OUT ($FB),A Write a byte to the printer.
Restore the registers saved for the printer.
ZXPrinter_RestoreAndReturn 8B74 POP BC Restore BC, DE and HL from the stack.
8B75 POP DE
8B76 POP HL
8B77 RET Return.
Prev: 8822 Up: Map Next: 8B78