Prev: 04000 Up: Map Next: 04083
04009: THE 'EDIT KEY' SUBROUTINE
The address of this routine is derived from an offset found in the editing keys table.
When in 'editing mode' pressing the EDIT key will bring down the 'current BASIC line'. However in 'INPUT mode' the action of the EDIT key is to clear the current reply and allow a fresh one.
ED_EDIT 04009 LD HL,(23625) Fetch the current line number (E-PPC).
04012 BIT 5,(IY+55) But jump forward if in 'INPUT mode' (bit 5 of FLAGX set).
04016 JP NZ,CLEAR_SP
04019 CALL LINE_ADDR Find the address of the start of the current line and hence its number.
04022 CALL LINE_NO
04025 LD A,D If the line number returned is zero then simply clear the editing area.
04026 OR E
04027 JP Z,CLEAR_SP
04030 PUSH HL Save the address of the line.
04031 INC HL Move on to collect the length of the line.
04032 LD C,(HL)
04033 INC HL
04034 LD B,(HL)
04035 LD HL,10 Add 10 to the length and test that there is sufficient room for a copy of the line.
04038 ADD HL,BC
04039 LD B,H
04040 LD C,L
04041 CALL TEST_ROOM
04044 CALL CLEAR_SP Now clear the editing area.
04047 LD HL,(23633) Fetch the current channel address (CURCHL) and exchange it for the address of the line.
04050 EX (SP),HL
04051 PUSH HL Save it temporarily.
04052 LD A,255 Open channel 'R' so that the line will be copied to the editing area.
04054 CALL CHAN_OPEN
04057 POP HL Fetch the address of the line.
04058 DEC HL Go to before the line.
04059 DEC (IY+15) Decrement the current line number (E-PPC) so as to avoid printing the cursor.
04062 CALL OUT_LINE Print the BASIC line.
04065 INC (IY+15) Increment the current line number (E-PPC). Note: the decrementing of the line number does not always stop the cursor from being printed.
04068 LD HL,(23641) Fetch the start of the line in the editing area (E-LINE) and step past the line number and the length to find the address for K-CUR.
04071 INC HL
04072 INC HL
04073 INC HL
04074 INC HL
04075 LD (23643),HL
04078 POP HL Fetch the former channel address and set the appropriate flags before returning to ED_LOOP.
04079 CALL CHAN_FLAG
04082 RET
Prev: 04000 Up: Map Next: 04083