Prev: 17F9 Up: Map Next: 18B6
1855: THE 'PRINT A WHOLE BASIC LINE' SUBROUTINE
Used by the routines at ED_EDIT and LIST.
The HL register pair points to the start of the line - the location holding the high byte of the line number.
Before the line number is printed it is tested to determine whether it comes before the 'current' line, is the 'current' line, or comes after.
Input
HL Address of the start of the BASIC line
Output
OUT_LINE 1855 LD BC,($5C49) Fetch the 'current' line number from E-PPC and compare it.
1859 CALL CP_LINES
185C LD D,">" Pre-load the D register with the current line cursor.
185E JR Z,OUT_LINE1 Jump forward if printing the 'current' line.
1860 LD DE,$0000 Load the D register with zero (it is not the cursor) and set E to hold +01 if the line is before the 'current' line and +00 if after. (The carry flag comes from CP_LINES.)
1863 RL E
OUT_LINE1 1865 LD (IY+$2D),E Save the line marker in BREG.
1868 LD A,(HL) Fetch the high byte of the line number and make a full return if the listing has been finished.
1869 CP $40
186B POP BC
186C RET NC
186D PUSH BC
186E CALL OUT_NUM_2 The line number can now be printed - with leading spaces.
1871 INC HL Move the pointer on to address the first command code in the line.
1872 INC HL
1873 INC HL
1874 RES 0,(IY+$01) Signal 'leading space allowed' (reset bit 0 of FLAGS).
1878 LD A,D Fetch the cursor code and jump forward unless the cursor is to be printed.
1879 AND A
187A JR Z,OUT_LINE3
187C RST $10 So print the cursor now.
This entry point is used by the routine at ED_COPY.
OUT_LINE2 187D SET 0,(IY+$01) Signal 'no leading space now' (set bit 0 of FLAGS).
OUT_LINE3 1881 PUSH DE Save the registers.
1882 EX DE,HL Move the pointer to DE.
1883 RES 2,(IY+$30) Signal 'not in quotes' (reset bit 2 of FLAGS2).
1887 LD HL,$5C3B This is FLAGS.
188A RES 2,(HL) Signal 'print in K-mode'.
188C BIT 5,(IY+$37) Jump forward unless in INPUT mode (bit 5 of FLAGX set).
1890 JR Z,OUT_LINE4
1892 SET 2,(HL) Signal 'print in L-mode'.
Now enter a loop to print all the codes in the rest of the BASIC line - jumping over floating-point forms as necessary.
OUT_LINE4 1894 LD HL,($5C5F) Fetch the syntax error pointer (X-PTR) and jump forward unless it is time to print the error marker.
1897 AND A
1898 SBC HL,DE
189A JR NZ,OUT_LINE5
189C LD A,"?" Print the error marker now. It is a flashing '?'.
189E CALL OUT_FLASH
OUT_LINE5 18A1 CALL OUT_CURS Consider whether to print the cursor.
18A4 EX DE,HL Move the pointer to HL now.
18A5 LD A,(HL) Fetch each character in turn.
18A6 CALL NUMBER If the character is a 'number marker' then the hidden floating-point form is not to be printed.
18A9 INC HL Update the pointer for the next pass.
18AA CP $0D Is the character a 'carriage return'?
18AC JR Z,OUT_LINE6 Jump if it is.
18AE EX DE,HL Switch the pointer to DE.
18AF CALL OUT_CHAR Print the character.
18B2 JR OUT_LINE4 Go around the loop for at least one further pass.
The line has now been printed.
OUT_LINE6 18B4 POP DE Restore the DE register pair and return.
18B5 RET
Prev: 17F9 Up: Map Next: 18B6