Prev: 04132 Up: Map Next: 04185
04145: THE 'ED-EDGE' SUBROUTINE
Used by the routines at ED_LEFT and ED_DELETE.
The address of the cursor is in the HL register pair and will be decremented unless the cursor is already at the start of the line. Care is taken not to put the cursor between control characters and their parameters.
Input
HL Address of the cursor (K-CUR)
Output
HL New address of the cursor
ED_EDGE 04145 SCF DE will hold either E-LINE (for editing) or WORKSP (for INPUTing).
04146 CALL SET_DE
04149 SBC HL,DE The carry flag will become set if the cursor is already to be at the start of the line.
04151 ADD HL,DE
04152 INC HL Correct for the subtraction.
04153 POP BC Drop the return address.
04154 RET C Return via ED_LOOP if the carry flag is set.
04155 PUSH BC Restore the return address.
04156 LD B,H Move the current address of the cursor to BC.
04157 LD C,L
Now enter a loop to check that control characters are not split from their parameters.
ED_EDGE_1 04158 LD H,D HL will point to the character in the line after that addressed by DE.
04159 LD L,E
04160 INC HL
04161 LD A,(DE) Fetch a character code.
04162 AND 240 Jump forward if the code does not represent INK to TAB.
04164 CP 16
04166 JR NZ,ED_EDGE_2
04168 INC HL Allow for one parameter.
04169 LD A,(DE) Fetch the code anew.
04170 SUB 23 Carry is reset for TAB.
04172 ADC A,0 Note: this splits off AT and TAB but AT and TAB in this form are not implemented anyway so it makes no difference.
04174 JR NZ,ED_EDGE_2 Jump forward unless dealing with AT and TAB which would have two parameters, if used.
04176 INC HL
ED_EDGE_2 04177 AND A Prepare for true subtraction.
04178 SBC HL,BC The carry flag will be reset when the 'updated pointer' reaches K-CUR.
04180 ADD HL,BC
04181 EX DE,HL For the next loop use the 'updated pointer', but if exiting use the 'present pointer' for K-CUR. Note: it is the control character that is deleted when using DELETE.
04182 JR C,ED_EDGE_1
04184 RET
Prev: 04132 Up: Map Next: 04185