Prev: 0B03 Up: Map Next: 0BDB
0B24: THE 'PRINT ANY CHARACTER(S)' SUBROUTINE
Used by the routine at PO_ABLE.
Ordinary character codes, token codes and user-defined graphic codes, and graphic codes are dealt with separately.
Input
A Character code
B Line number
C Column number
HL Display file address or printer buffer address
PO_ANY 0B24 CP $80 Jump forward with ordinary character codes.
0B26 JR C,PO_CHAR
0B28 CP $90 Jump forward with token codes and UDG codes.
0B2A JR NC,PO_T_UDG
0B2C LD B,A Move the graphic code.
0B2D CALL PO_GR_1 Construct the graphic form.
0B30 CALL PO_FETCH HL has been disturbed so 'fetch' again.
0B33 LD DE,$5C92 Make DE point to the start of the graphic form, i.e. MEMBOT.
0B36 JR PR_ALL Jump forward to print the graphic character.
Graphic characters are constructed in an ad hoc manner in the calculator's memory area, i.e. mem-0 and mem-1.
PO_GR_1 0B38 LD HL,$5C92 This is MEMBOT.
0B3B CALL PO_GR_2 In effect call the following subroutine twice.
PO_GR_2 0B3E RR B Determine bit 0 (and later bit 2) of the graphic code.
0B40 SBC A,A
0B41 AND $0F The A register will hold +00 or +0F depending on the value of the bit in the code.
0B43 LD C,A Save the result in C.
0B44 RR B Determine bit 1 (and later bit 3) of the graphic code.
0B46 SBC A,A
0B47 AND $F0 The A register will hold +00 or +F0.
0B49 OR C The two results are combined.
0B4A LD C,$04 The A register holds half the character form and has to be used four times. This is done for the upper half of the character form and then the lower.
PO_GR_3 0B4C LD (HL),A
0B4D INC HL
0B4E DEC C
0B4F JR NZ,PO_GR_3
0B51 RET
Token codes and user-defined graphic codes are now separated.
PO_T_UDG 0B52 SUB $A5 Jump forward with token codes.
0B54 JR NC,PO_T
0B56 ADD A,$15 UDG codes are now +00 to +0F.
0B58 PUSH BC Save the current position values on the machine stack.
0B59 LD BC,($5C7B) Fetch the base address of the UDG area (from UDG) and jump forward.
0B5D JR PO_CHAR_2
PO_T 0B5F CALL PO_TOKENS Now print the token and return via PO_FETCH.
0B62 JP PO_FETCH
This entry point is used by the routine at PO_RIGHT.
The required character form is identified.
PO_CHAR 0B65 PUSH BC The current position is saved.
0B66 LD BC,($5C36) The base address of the character area is fetched (CHARS).
PO_CHAR_2 0B6A EX DE,HL The print address is saved.
0B6B LD HL,$5C3B This is FLAGS.
0B6E RES 0,(HL) Allow for a leading space.
0B70 CP " " Jump forward if the character is not a 'space'.
0B72 JR NZ,PO_CHAR_3
0B74 SET 0,(HL) But 'suppress' if it is.
PO_CHAR_3 0B76 LD H,$00 Now pass the character code to the HL register pair.
0B78 LD L,A
0B79 ADD HL,HL The character code is in effect multiplied by 8.
0B7A ADD HL,HL
0B7B ADD HL,HL
0B7C ADD HL,BC The base address of the character form is found.
0B7D POP BC The current position is fetched and the base address passed to the DE register pair.
0B7E EX DE,HL
The following subroutine is used to print all '8*8' bit characters. On entry the DE register pair holds the base address of the character form, the HL register the destination address and the BC register pair the current 'line and column' values.
PR_ALL 0B7F LD A,C Fetch the column number.
0B80 DEC A Move one column rightwards.
0B81 LD A,$21 Jump forward unless a new line is indicated.
0B83 JR NZ,PR_ALL_1
0B85 DEC B Move down one line.
0B86 LD C,A Column number is +21.
0B87 BIT 1,(IY+$01) Jump forward if handling the screen (bit 1 of FLAGS reset).
0B8B JR Z,PR_ALL_1
0B8D PUSH DE Save the base address whilst the printer buffer is emptied.
0B8E CALL COPY_BUFF
0B91 POP DE
0B92 LD A,C Copy the new column number.
PR_ALL_1 0B93 CP C Test whether a new line is being used. If it is see if the display requires to be scrolled.
0B94 PUSH DE
0B95 CALL Z,PO_SCR
0B98 POP DE
Now consider the present state of INVERSE and OVER.
0B99 PUSH BC Save the position values and the destination address on the machine stack.
0B9A PUSH HL
0B9B LD A,($5C91) Fetch P-FLAG and read bit 0.
0B9E LD B,$FF Prepare the 'OVER mask' in the B register, i.e. OVER 0=+00 and OVER 1=+FF.
0BA0 RRA
0BA1 JR C,PR_ALL_2
0BA3 INC B
PR_ALL_2 0BA4 RRA Read bit 2 of P-FLAG and prepare the 'INVERSE mask' in the C register, i.e. INVERSE 0=+00 and INVERSE 1=+FF.
0BA5 RRA
0BA6 SBC A,A
0BA7 LD C,A
0BA8 LD A,$08 Set the A register to hold the 'pixel-line' counter and clear the carry flag.
0BAA AND A
0BAB BIT 1,(IY+$01) Jump forward if handling the screen (bit 1 of FLAGS reset).
0BAF JR Z,PR_ALL_3
0BB1 SET 1,(IY+$30) Signal 'printer buffer no longer empty' (set bit 1 of FLAGS2).
0BB5 SCF Set the carry flag to show that the printer is being used.
PR_ALL_3 0BB6 EX DE,HL Exchange the destination address with the base address before entering the loop.
The character can now be printed. Eight passes of the loop are made - one for each 'pixel-line'.
PR_ALL_4 0BB7 EX AF,AF' The carry flag is set when using the printer. Save this flag in F'.
0BB8 LD A,(DE) Fetch the existing 'pixel-line'.
0BB9 AND B Use the 'OVER mask' and then 'XOR' the result with the 'pixel-line' of the character form.
0BBA XOR (HL)
0BBB XOR C Finally consider the 'INVERSE mask'.
0BBC LD (DE),A Enter the result.
0BBD EX AF,AF' Fetch the printer flag and jump forward if required.
0BBE JR C,PR_ALL_6
0BC0 INC D Update the destination address.
PR_ALL_5 0BC1 INC HL Update the 'pixel-line' address of the character form.
0BC2 DEC A Decrease the counter and loop back unless it is zero.
0BC3 JR NZ,PR_ALL_4
Once the character has been printed the attribute byte is to be set as required.
0BC5 EX DE,HL Make the H register hold a correct high-address for the character area.
0BC6 DEC H
0BC7 BIT 1,(IY+$01) Set the attribute byte only if handling the screen (bit 1 of FLAGS reset).
0BCB CALL Z,PO_ATTR
0BCE POP HL Restore the original destination address and the position values.
0BCF POP BC
0BD0 DEC C Decrease the column number and increase the destination address before returning.
0BD1 INC HL
0BD2 RET
When the printer is being used the destination address has to be updated in increments of +20.
PR_ALL_6 0BD3 EX AF,AF' Save the printer flag again.
0BD4 LD A,$20 The required increment value.
0BD6 ADD A,E Add the value and pass the result back to the E register.
0BD7 LD E,A
0BD8 EX AF,AF' Fetch the flag.
0BD9 JR PR_ALL_5 Jump back into the loop.
Prev: 0B03 Up: Map Next: 0BDB