Prev: 1024 Up: Map Next: 1059
1031: 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 1031 SCF DE will hold either E-LINE (for editing) or WORKSP (for INPUTing).
1032 CALL SET_DE
1035 SBC HL,DE The carry flag will become set if the cursor is already to be at the start of the line.
1037 ADD HL,DE
1038 INC HL Correct for the subtraction.
1039 POP BC Drop the return address.
103A RET C Return via ED_LOOP if the carry flag is set.
103B PUSH BC Restore the return address.
103C LD B,H Move the current address of the cursor to BC.
103D LD C,L
Now enter a loop to check that control characters are not split from their parameters.
ED_EDGE_1 103E LD H,D HL will point to the character in the line after that addressed by DE.
103F LD L,E
1040 INC HL
1041 LD A,(DE) Fetch a character code.
1042 AND $F0 Jump forward if the code does not represent INK to TAB.
1044 CP $10
1046 JR NZ,ED_EDGE_2
1048 INC HL Allow for one parameter.
1049 LD A,(DE) Fetch the code anew.
104A SUB $17 Carry is reset for TAB.
104C ADC A,$00 Note: this splits off AT and TAB but AT and TAB in this form are not implemented anyway so it makes no difference.
104E JR NZ,ED_EDGE_2 Jump forward unless dealing with AT and TAB which would have two parameters, if used.
1050 INC HL
ED_EDGE_2 1051 AND A Prepare for true subtraction.
1052 SBC HL,BC The carry flag will be reset when the 'updated pointer' reaches K-CUR.
1054 ADD HL,BC
1055 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.
1056 JR C,ED_EDGE_1
1058 RET
Prev: 1024 Up: Map Next: 1059