Edit Key - M.Loftus (Your Spectrum-Issue 16-Page 56) Cast your minds back - many moons (and issues ago), YS projects manager, Penny Page, set you all a small task. How, she asked, could you alter the Speccy's editing facilities so that the cursor could be moved up and down an edit line, as well as from left to right. At last, we bring you a solution to the problem. To get it going just type in the loader program, run it and save it as usual. Then to start the routine type RANDOMIZE USR 65123. To disable it, type RANDOMIZE USR 65133. You can also change the speed of the cursor simply by entering: POKE 65053, new value POKE 65065, new value. The new value is the number of characters to be moved each time. OK, put on the green eye shade (just like the one I wear! Ed) and get editing. [NOTE: The hex loader routine printed in the magazine was wrong in that] [both the FOR loop and the checksum ignored the last nine bytes of the ] [machine code routine, so that the loader appeared to work but the end ] [of the routine was omitted. The file "Hex Loader" on EDIT_KEY.TAP has ] [been corrected. ] 0100 K48 DEFL 0FDFFH 0150 ORG K48 0200 VECTR DEFW K48+2 0250 RST 38H Line 250 Calls the ROM routine that reads the keyboard and updates the system variable FRAMES. 0300 DI 0350 PUSH AF 0400 PUSH HL 0450 PUSH BC 0500 PUSH DE 0550 LD A,(23560) Line 550 Loads 'A' with the value of the last key or the 'NO-KEY' value. 0600 CP 10 0650 JR Z,START Lines 600-650 Check if the last key was Cursor Down. If so jump to START. 0700 CP 11 0750 JR Z,START Lines 700-750 If the last key pressed was Cursor Up then also jump to START. 0800 JP END Line 800 If neither Up or Down was pressed then jump to END. 0850 START CP 10 0900 JR Z,ADD Lines 850-900 If Down was being pressed then jump to ADD. 0950 LD HL,(23643) 1000 LD BC,31 1050 AND A 1100 SBC HL,BC 1150 PUSH HL 1200 JR TEST Lines 950-1200 Assuming that Up must have been pressed read the cursor position, move 31 characters down the line and jump to TEST. 1250 ADD LD HL,(23643) 1300 LD BC,31 1350 ADD HL,BC 1400 PUSH HL Lines 1250-1400 Read the cursor position. Move 31 characters up the line. 1450 TEST LD HL,(23649) 1500 DEC HL 1550 DEC HL 1600 POP BC 1650 PUSH BC 1700 AND A 1750 SBC HL,BC 1800 JR C,END1 Lines 1450-1800 Test to see if the cursor is going off the end of the line, and if so jump to END1. 1850 LD HL,(23641) 1900 POP BC 1950 PUSH BC 2000 AND A 2050 SBC HL,BC 2100 JR NC,END1 2150 POP HL Lines 1850-2100 Test to see if the cursor is going too far up the line, if so then jump to END1. 2200 LD (23643),HL Line 2200 Stores the new cursor position. 2250 LD A,(23560) 2300 CP 10 2350 JR NZ,UP Lines 2250-2350 If Down wasn't the last key pressed then jump to UP. 2400 LD A,9 2450 LD (23560),A 2500 JR END Lines 2400-2500 Make Basic think that the Cursor Right was pressed and jump to END. 2550 UP LD A,8 2600 LD (23560),A Lines 2550-2600 Make Basic think that Cursor Left was pressed. 2650 END POP DE 2700 POP BC 2750 POP HL 2800 POP AF 2850 EI 2900 RET 2950 END1 POP HL 3000 JR END Lines 2650-2900 Restore all preserved registers, enable interrupts and return to Basic. 3050 GO LD A,(VECTR+1) 3055 SUB 1 3100 LD I,A 3150 IM2 3200 RET Lines 3050-3200 Set up the interrupt routine, set interrupt mode 2 and return to Basic. 3250 STOP LD A,3FH 3300 LD I,A 3350 IM1 3400 RET 3450 END Lines 3250-3400 Switch the routine off by setting interrupt mode 1 and return to Basic. ------------------------------------------------------------------------------ TYPE: Utility COMMENT: This info file was typed by Jim Grimwood Downloaded from: Desert Island Disks -- http://www.image.dk/~frankie/ Maintained by: Michael Bruhn -- frankie@image.dk