Prev: 0EF4 Up: Map Next: 0FA0
0F2C: THE 'EDITOR' ROUTINES
Used by the routines at MAIN_EXEC and INPUT.
The editor is called on two occasions:
First the 'error stack pointer' is saved and an alternative address provided.
EDITOR 0F2C LD HL,($5C3D) The current value of ERR-SP is saved on the machine stack.
0F2F PUSH HL
This entry point is used by the routine at ED_ERROR.
ED_AGAIN 0F30 LD HL,$107F This is ED_ERROR.
0F33 PUSH HL Any event that leads to the error handling routine (see ERR-SP) being used will come back to ED_ERROR.
0F34 LD ($5C3D),SP
A loop is now entered to handle each keystroke.
ED_LOOP 0F38 CALL WAIT_KEY Return once a key has been pressed.
0F3B PUSH AF Save the code temporarily.
0F3C LD D,$00 Fetch the duration of the keyboard click (PIP).
0F3E LD E,(IY-$01)
0F41 LD HL,$00C8 And the pitch.
0F44 CALL BEEPER Now make the 'pip'.
0F47 POP AF Restore the code.
0F48 LD HL,$0F38 Pre-load the machine stack with the address of ED_LOOP.
0F4B PUSH HL
Now analyse the code obtained.
0F4C CP $18 Accept all character codes, graphic codes and tokens.
0F4E JR NC,ADD_CHAR
0F50 CP $07 Also accept ','.
0F52 JR C,ADD_CHAR
0F54 CP $10 Jump forward if the code represents an editing key.
0F56 JR C,ED_KEYS
The control keys - INK to TAB - are now considered.
0F58 LD BC,$0002 INK and PAPER will require two locations.
0F5B LD D,A Copy the code to D.
0F5C CP $16 Jump forward with INK and PAPER.
0F5E JR C,ED_CONTR
AT and TAB would be handled as follows:
0F60 INC BC Three locations required.
0F61 BIT 7,(IY+$37) Jump forward unless dealing with 'INPUT LINE...' (bit 7 of FLAGX set).
0F65 JP Z,ED_IGNORE
0F68 CALL WAIT_KEY Get the second code and put it in E.
0F6B LD E,A
The other bytes for the control characters are now fetched.
ED_CONTR 0F6C CALL WAIT_KEY Get another code.
0F6F PUSH DE Save the previous codes.
0F70 LD HL,($5C5B) Fetch K-CUR.
0F73 RES 0,(IY+$07) Signal 'K mode' (reset bit 0 of MODE).
0F77 CALL MAKE_ROOM Make two or three spaces.
0F7A POP BC Restore the previous codes.
0F7B INC HL Point to the first location.
0F7C LD (HL),B Enter first code.
0F7D INC HL Then enter the second code which will be overwritten if there are only two codes - i.e. with INK and PAPER.
0F7E LD (HL),C
0F7F JR ADD_CH_1 Jump forward.
This entry point is used by the routine at ED_SYMBOL.
The address of this entry point is found in the initial channel information table.
The following subroutine actually adds a code to the current EDIT or INPUT line.
ADD_CHAR 0F81 RES 0,(IY+$07) Signal 'K mode' (reset bit 0 of MODE).
0F85 LD HL,($5C5B) Fetch the cursor position (K-CUR).
0F88 CALL ONE_SPACE Make a single space.
ADD_CH_1 0F8B LD (DE),A Enter the code into the space and set K-CUR to signal that the cursor is to occur at the location after. Then return indirectly to ED_LOOP.
0F8C INC DE
0F8D LD ($5C5B),DE
0F91 RET
The editing keys are dealt with as follows:
ED_KEYS 0F92 LD E,A The code is transferred to the DE register pair.
0F93 LD D,$00
0F95 LD HL,$0F99 The base address of the editing keys table.
0F98 ADD HL,DE The entry is addressed and then fetched into E.
0F99 LD E,(HL)
0F9A ADD HL,DE The address of the handling routine is saved on the machine stack.
0F9B PUSH HL
0F9C LD HL,($5C5B) The HL register pair is set to K-CUR and an indirect jump made to the required routine.
0F9F RET
Prev: 0EF4 Up: Map Next: 0FA0