;TXTOVW.SRC -- Source code for TXTOVW.200, insert/overwrite utility ;Type ESC,1 sequence to go into insert mode, and ESC,2 for overwrite mode. ;Also supports disabled word wrapping. ;Type ESC,3 to disable word wrapping, ESC,4 to enable it. ; ;James Yi 73327,1653 ;Tandy 200 version -- 03/07/87 ; ; ; wrap equ $f20c prevky equ 61387 keystr equ 61386 files equ 10794 print equ 26526 errtrp equ 61236 bell equ 20293 input equ 21744 Menu equ 26532 opendo equ 11635 rst7A equ 62731 RST7B equ 62781 shkey equ 64781 ORG 63574 ;prev screen ; Call files ;List files LXI H,Error ;Get Resume adr SHLD errtrp ;Set Error trap lxi h,29140 CALL 28192 XRA A Error CNZ bell ;Beep if error CALL 29003 LXI H,29124 ;Get prompt msg CALL print ;Print it CALL input ;Input file nam RST 2 ;Test 1st chr ANA A ;CR or CTRL-C? JZ menu ;Abort CALL openDO ;Open file PUSH H ; LHLD rst7A ;Save original SHLD Hook1 ;values of LHLD RST7B SHLD Hook2 ;hooks. LXI H,Pat1 ;Reload them SHLD RST7A ;with LXI H,Pat2 ;Overwrite SHLD rst7b ;patches. ; JMP $731c ;Jump to editor ; ; ;RST 7 hook patch 2, called upon ;exiting from TEXT editor. Pat2 call expat lhld hook2 ;exe org hook pchl expat PUSH H LHLD Hook1 SHLD rst7a ;Restore LHLD Hook2 ;original SHLD rst7b ;hooks POP H ;upon exit. RET ; ; ;RST 7 hook patch 1, called by Chget ;Chget is a rom subroutine at 4855, ;which prompts for a keystroke. Pat1 call ovpat lhld hook1 ;exec orig hook pchl ovpat DI ;needed to protect stack PUSH B PUSH D LXI H,0 DAD SP XCHG ;Save SP to DE ;Unwind the stack, in order to retrace ;the call origin. MVI A,22 ;Go back 11 Loop1 INX SP ;layers. DCR A JNZ loop1 ;If it was called from the TEXT editor, swap the return address with that of overwrite intercept patch. LXI H,Int XTHL ;Swap LXI B,29609 ;Originated DB 8 ;from editor? JZ Res ;Yes DAD BC ;If not, do not XTHL ;swap. ;Restore stack pointer Res XCHG SPHL POP D POP B EI RET ; ; ;ROM intercept patch - a jump to this ;patch, instead of returning to TEXT ;editor's insert routine, is enabled ;by Pat1 ;This patch recognizes Ins/Ovw toggle ;and overwrites. Int STA keystr ;Save keystroke PUSH PSW CALL 31188 POP PSW JC 30943 CPI 127 ;DEL? JZ 29945 ;Yes mov b,a lda prevky ;look at previous keystroke cpi 27 ;ESC sequence? jnz cont mov a,b cpi '1' ;ovw mode? jz toggle sui '2' ;ins mode? jz toggle dcr a ;ww off? jz stwrap cpi 1 ;ww on? jnz cont stwrap sta wrap ret toggle sta sw ret ; Cont mov a,b cpi 9 ;tab? jz inov CPI 32 ;FNkey or CTRL? JC 29630 ;Yes ; ;Insert or overwrite visible character. ;main loop (29690) ; inov PUSH b CALL 30320 CALL 33238 CALL 33332 POP b CALL Ins ;Insert it JC 29828 ;Memory full JMP 29820 ;Back to editor ;Insert routine -- ;Overwrite unless the mode is Insert, ;or the cursor is at the end of file or end of line. Ins XCHG ;Save HL to DE LDA Sw ORA A ;Insert mode? MOV A,B JZ 30584 ;Yes, insert LHLD 62997 RST 3 ;End of file? MOV A,B JZ 30584 ;Yes, insert LDAX D CPI 13 ;End of line? JNZ Ovw ;No, overwrite INX D LDAX D DCX D CPI 10 ;End of line? MOV A,B JZ 30584 ;Yes, insert Ovw XCHG mov a,m cpi 9 jz tab mov a,b cpi 9 jz tab mov m,a rst 4 pop b ret tab push b call 29945 pop psw jmp 30584 ; ; Sw DB 00 ;Toggle switch Hook1 DW 00 ;Chget hook Hook2 DW 00 ;Menu hook ; END ;