Routines |
Prev: 1793 | Up: Map | Next: 17F5 |
The routines in this part of the 16K program are used to produce listings of the current BASIC program. Each line has to have its line number evaluated, its tokens expanded and the appropriate cursors positioned.
|
||||
AUTO_LIST | 1795 | LD ($5C3F),SP | The stack pointer is saved at LIST-SP allowing the machine stack to be reset when the listing is finished (see PO_SCR). | |
1799 | LD (IY+$02),$10 | Signal 'automatic listing in the main screen' (set bit 4 of TV-FLAG and reset all other bits). | ||
179D | CALL CL_ALL | Clear this part of the screen. | ||
17A0 | SET 0,(IY+$02) | Switch to the editing area (set bit 0 of TV-FLAG). | ||
17A4 | LD B,(IY+$31) | Now clear the the lower part of the screen as well (see DF-SZ). | ||
17A7 | CALL CL_LINE | |||
17AA | RES 0,(IY+$02) | Then switch back (reset bit 0 of TV-FLAG). | ||
17AE | SET 0,(IY+$30) | Signal 'screen is clear' (set bit 0 of FLAGS2). | ||
17B2 | LD HL,($5C49) | Now fetch the the 'current' line number (E-PPC) and the 'automatic' line number (S-TOP). | ||
17B5 | LD DE,($5C6C) | |||
17B9 | AND A | If the 'current' number is less than the 'automatic' number then jump forward to update the 'automatic' number. | ||
17BA | SBC HL,DE | |||
17BC | ADD HL,DE | |||
17BD | JR C,AUTO_L_2 | |||
The 'automatic' number has now to be altered to give a listing with the 'current' line appearing near the bottom of the screen.
|
||||
17BF | PUSH DE | Save the 'automatic' number. | ||
17C0 | CALL LINE_ADDR | Find the address of the start of the 'current' line and produce an address roughly a 'screen before it' (negated). | ||
17C3 | LD DE,$02C0 | |||
17C6 | EX DE,HL | |||
17C7 | SBC HL,DE | |||
17C9 | EX (SP),HL | Save the 'result' on the machine stack whilst the 'automatic' line address is also found (in HL). | ||
17CA | CALL LINE_ADDR | |||
17CD | POP BC | The 'result' goes to the BC register pair. | ||
A loop is now entered. The 'automatic' line number is increased on each pass until it is likely that the 'current' line will show on a listing.
|
||||
AUTO_L_1 | 17CE | PUSH BC | Save the 'result'. | |
17CF | CALL NEXT_ONE | Find the address of the start of the line after the present 'automatic' line (in DE). | ||
17D2 | POP BC | Restore the 'result'. | ||
17D3 | ADD HL,BC | Perform the computation and jump forward if finished. | ||
17D4 | JR C,AUTO_L_3 | |||
17D6 | EX DE,HL | Move the next line's address to the HL register pair and collect its line number. | ||
17D7 | LD D,(HL) | |||
17D8 | INC HL | |||
17D9 | LD E,(HL) | |||
17DA | DEC HL | |||
17DB | LD ($5C6C),DE | Now S-TOP can be updated and the test repeated with the new line. | ||
17DF | JR AUTO_L_1 | |||
Now the 'automatic' listing can be made.
|
||||
AUTO_L_2 | 17E1 | LD ($5C6C),HL | When E-PPC is less than S-TOP. | |
AUTO_L_3 | 17E4 | LD HL,($5C6C) | Fetch the top line's number (S-TOP) and hence its address. | |
17E7 | CALL LINE_ADDR | |||
17EA | JR Z,AUTO_L_4 | If the line cannot be found use DE instead. | ||
17EC | EX DE,HL | |||
AUTO_L_4 | 17ED | CALL LIST_ALL | The listing is produced. | |
17F0 | RES 4,(IY+$02) | The return will be to here unless scrolling was needed to show the current line; reset bit 4 of TV-FLAG before returning. | ||
17F4 | RET |
Prev: 1793 | Up: Map | Next: 17F5 |