; ; ; l3f18: push hl push bc jr nc,l3f96 ld de,(TxtEnd) ; Get end push de push de ex de,hl or a sbc hl,de ex (sp),hl or a sbc hl,bc jp nc,l3ed9 ld e,l ld d,h push de call DispLeft ; Test enough room pop de pop bc inc bc pop hl ld (TxtEnd),de ; Set end ld a,b l3f3c: sub HIGH _SavLen jr c,l3f4d ld b,a l3f41: push bc ld bc,_SavLen lddr ; Move down pop bc call PollIn ; Get character jr l3f3c l3f4d: ld a,c or b jr z,l3f53 lddr l3f53: pop bc pop hl ex de,hl inc de ld hl,(MemStrPtr) ; Get start of block pointer call l3f8e ld (MemStrPtr),hl ; .. set it ld hl,(MemEndPtr) ; Get end of block pointer call l3f8e ld (MemEndPtr),hl ; .. set it ld hl,(ScrBeg) ; Get start of screen address call l3f8e ld (ScrBeg),hl ; .. set it ld hl,(CurMemPtr) ; Get text pointer call l3f8e ld (CurMemPtr),hl ; .. set it ld hl,(EdtBlkPtr) call l3f8e ld (EdtBlkPtr),hl ld hl,(EdtCurPtr) call l3f8e ld (EdtCurPtr),hl ret ; ; ; l3f8e: call CmpAdr ; Compare addresses ret c ; .. HL= 2nd ; MinAdr: call CmpAdr ; Compare addresses ret c ; .. 1st < 2nd ex de,hl ; .. swap ret ; ; ; l4197: call EdCursor ; Set current cursor ld a,(@ScrCol) ; Get screen width dec a sub (iy+_EdCol) ; Subtract current column ld hl,(CurEdPtr) ; Get current pointer ld b,a set 0,(iy+16) call l3c41 res 0,(iy+16) ret ; ; Adjust for next end of line ; ENTRY Reg HL holds current pointer ; EXIT Reg HL holds pointer to next line ; Carry set if pointer behind end address ; NextEOL: push bc ex de,hl ld hl,(TxtEnd) ; Get end dec hl or a sbc hl,de ; .. get difference ld b,h ld c,l inc bc ex de,hl ld d,h ld e,l jr c,N.EOL.ex ; Out of text ld a,lf ; Find new line cpir jp po,N.EOL.ex ; .. none there or a pop bc ret N.EOL.ex: scf ; Set out of text ex de,hl pop bc ret ; ; Adjust for previous end of line ; ENTRY Reg HL holds current pointer ; EXIT Reg HL holds pointer to previous line ; Carry set if pointer below start address ; PrevEOL: push bc ld c,l ; Save pointer ld b,h ld a,lf call FixBeg ; Check against start jr c,P.EOL.ex ; .. yeap P.EOL.src: call FixBeg ; .. check again jr z,P.EOL.strt ; .. it's the start jr c,P.EOL.ex ; .. below start cp (hl) ; Find LF jr nz,P.EOL.src ; .. nope inc hl P.EOL.strt: pop bc ret P.EOL.ex: ld h,b ; Restore pointer ld l,c pop bc ret ; ; Adjust pointer for inserting one character ; RoomForOne: push hl ld bc,1 call MakeRoom ; Insert one character ld de,EDLine+_LinLen-1 ex de,hl or a sbc hl,de ; Get difference dec hl ld c,l ld b,h ld de,EDLine+_LinLen-2 ld l,e ld h,d dec hl ld a,c or b ; Test any jr z,l420c push de lddr ; .. move characters pop hl ld (hl),' ' ; Clear character l420c: pop hl ret ; ; Position cursor and give immediate string ; ENTRY Reg H holds column ; Reg L holds row ; CtrlStrXY: call ExecXY ; Set cursor CtrlStrJ: jp CtrlStr ; ; ################################################## ; >>> Redirected console out during edit session <<< ; ################################################## ; New.Conout: pop hl ex (sp),hl bit _LB,(iy+_Video) jr z,l4220 push hl Old.Conout: call $-$ ; -->> Overwritten l4220: ld a,(l4543) sub 2 ld (l4543),a ret nz jr .PollIn ; Get character ; ; Clear look ahead buffer ; ClrAhead: ld hl,(QueCur) ld (QueNew),hl ; .. set empty ret ; ; Poll character from input ; PollIn: push af push bc push de push hl call .PollIn ; Get it pop hl pop de pop bc pop af ret ; ; Poll character from input - no reg preserved ; .PollIn: ld hl,(QueNew) ; Get pointer call ChkAhead ; .. bump and check it ld de,(QueCur) ; Get current ex de,hl sbc hl,de ; Test same ex de,hl ret z ; .. yeap, no room push hl push ix push iy call xconstat ; Get state of console pop iy pop ix pop hl ret z ; .. none there call StatChk ; Get character ld (hl),a ; .. save ld (QueNew),hl ; .. set new ret ; ; Bump and check ahead pointer ; ENTRY Reg HL holds current pointer ; EXIT Reg HL holds position within the queue ; ChkAhead: inc hl ; Bump pointer ld de,Ahead+_Ahead or a ex de,hl sbc hl,de ; Test against top ex de,hl ret nz ; .. not the same ld hl,Ahead ; Return start of queue ret ; ; Get character from console ; EDCharIn: push hl push de ld de,(QueCur) ld hl,(QueNew) or a sbc hl,de ; Test look ahead buffer ex de,hl jr z,ECI.Kb ; .. empty, get from console call ChkAhead ; Get pointer ld a,(hl) ; .. fetch character ld (QueCur),hl ; .. set new position jr ECI.ex ECI.Kb: call StatChk ; Get from keyboard ECI.ex: pop de pop hl ret ; ; Test look ahead buffer empty ; EXIT Zero set if so ; IsAheadEmpty: push hl push de ld de,(QueCur) ld hl,(QueNew) or a sbc hl,de ; Test same pop de pop hl ret ; ; Get character from keyboard ; EXIT Accu holds key in range 00..1F, 20..7F ; or control in range 80..FF ; StatChk: push bc push de push hl push ix push iy call .StatChk pop iy pop ix pop hl pop de pop bc ret .StatChk: call XBIOS ; Get key # and state dw KM.GET jr nc,.StatChk ; .. none call SpecKey ; Test special jr z,.StatChk ld (KeyNum),bc call XBIOS ; Get key KM.XLT: dw $ ld (KeyChar),a call CtrlKey ; Test control key jr z,GotCtrl ; .. yeap ld a,(KeyChar) ret GotCtrl: ld a,(KeyStat) ; Get state add a,a ; Test ALT ld hl,ALTtab ld bc,ALTlen ld de,ALToff jr c,GetKey ; .. yeap and 11000000b ; Test shift ld hl,SHFtab ld bc,SHFlen ld de,SHFoff jr nz,GetKey ld hl,NormTab ld bc,NormLen ld de,NormOff GetKey: ld a,(KeyNum) cpir ; .. find key jr nz,.StatChk ; .. nope ex de,hl add hl,bc ; Get real index ld a,l set _MB,a ; .. set bit ret ; ; Find key index from table ; EXIT Zero set if found ; Reg BC holds index ; CtrlKey: ld a,(KeyNum) ld hl,CtrTab ld bc,CtrLen cpir ; Find key ret ; ; Find key index from table ; ENTRY Reg C holds key number ; EXIT Zero set if found ; SpecKey: push bc ld a,c ld hl,SpecTab ld bc,SpcLen cpir ; Find key pop bc ret ; MSGbase: dw TOP $DMY.ARG: db eof ; ; %%%%%%%%%%%%%%%%%%%%% ; %%% Control table %%% ; %%%%%%%%%%%%%%%%%%%%% ; CtrTab: SHFtab: NormTab: db 13,4,15,6,16,23,68,5,12 ALTtab: db 14,79,10,20 SHFlen equ $-SHFtab db 7,3 ALTlen equ $-ALTtab db 18,78,72,76,75,11,0,2,8,77 NormLen equ $-NormTab db 1,66,73 CtrLen equ $-CtrTab NormOff equ 0 SHFoff equ NormLen ALToff equ SHFlen+NormLen ; ; Special key table ; Holds SHIFT, ALT and EXTRA ; SpecTab: db 70,21,80,74 SpcLen equ $-SpecTab ; ; Delimiter table ; AllDelim: db '<>,[].*+-/$:=(){}^#''' BlnkDelim: db ' ',eot ; ; Editor control table ; CtrlTab: @CRep1 equ ($-CtrlTab) / 2 + MSB dw ED.SRCREP dw ED.END dw ED.WRBLK dw ED.RDBLK+@MSB @Copy equ ($-CtrlTab) / 2 + MSB dw ED.CPYBLK+@MSB @Canc equ ($-CtrlTab) / 2 + MSB dw ED.VISBLK dw ED.MRKEND @CDEL equ ($-CtrlTab) / 2 + MSB dw ED.LCHDEL+@MSB @NL equ ($-CtrlTab) / 2 + MSB dw ED.INSRT+@MSB @CR equ ($-CtrlTab) / 2 + MSB dw ED.NL @Move equ ($-CtrlTab) / 2 + MSB dw ED.MOVBLK+@MSB @Recal equ ($-CtrlTab) / 2 + MSB dw ED.RECCUR dw ED.FIND @LnDEL equ ($-CtrlTab) / 2 + MSB dw ED.LINDEL+@MSB dw ED.LDWN dw ED.LUP dw ED.PDWN @CWRgt equ ($-CtrlTab) / 2 + MSB dw ED.WRGT dw ED.TAB+@MSB dw ED.MRKBEG @CDell equ ($-CtrlTab) / 2 + MSB dw ED.CCHDEL+@MSB @CRgt equ ($-CtrlTab) / 2 + MSB dw ED.CRGT @CLft equ ($-CtrlTab) / 2 + MSB dw ED.CLFT dw ED.TXTEND dw ED.LEND ; dw ED.REPLC dw ED.DELBLK+@MSB dw ED.PGLAST dw ED.PG1ST dw ED.PUP @CWLft equ ($-CtrlTab) / 2 + MSB dw ED.WLFT dw ED.AUTOTAB dw ED.MRKWRD dw ED.RWRDEL+@MSB dw ED.BLKEND dw ED.BLKBEG dw ED.TXTBEG dw ED.LBEG ; dw ED.RESLIN+@MSB dw ED.INST @CRep2 equ ($-CtrlTab) / 2 + MSB dw ED.SRCREP dw ED.LENDEL+@MSB dw ED.SDWN dw ED.SUP ; KeyNum: db 0 KeyStat: db 0 KeyChar: db 0 ; ; Pointer table ; ; !!! Following bytes must be contigous !!! ; CurMemPtr: dw 0 ; Real memory address of text ; !!!!!!!!!!!!!!!!!!!!!!!!!!!!! ; --> Start of data for OVERLAY ; !!!!!!!!!!!!!!!!!!!!!!!!!!!!! CurEdPtr: dw EDLine ; Current edit line EdtBlkPtr: dw 0 l4456: dw EDLine EdtCurPtr: dw 0 l445a: dw EDLine ; ; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ; QueCur: dw Ahead QueNew: dw Ahead MemStrPtr: dw 0 ; Real start of block address MemEndPtr: dw 0 ; Real end of block address BlkStrPtr: dw 2 BlkEndPtr: dw 2 l4468: dw 0 ScrBeg: dw 0 ; Real start of screen adress ; ; The editor status block ; _Ed.Row equ 9 ; EditPSW: db 0 ; + 0 db 0 ; + 1 l446e: db 1 ; + 2 Rel.Col: db 1 ; + 3 : Relative column ED.Col: db 0 ; + 4 : Current column ED.Row: db 1 ; + 5 : Current row ED.Ins: db 0 ; + 6 : Insertion flag db 1 ; + 7 : Video bit NewFlg: db 0 ; + 8 : Change on control Ed..Row: db 1 ; + 9 : Another row l4476: db 0 ; +10 db 0 ; +11 l4478: db 0 ; +12 ED.Ind: db 0 ; +13 : Indention flag db 1 ; +14 db 1 ; +15 db 0 ; +16 FndStat: db 0 ; +17 : Find status bits FndFlg: db 0 ; +18 : 0 Find, -1 Replace ChgFlg: db FALSE ; +19 : Text change flag ED.Blk: db 0 ; +20 : Block flag db 0 ; +21 EDChCnt: db 3 ; +22 : Control character count EDChar: db 0,0,0 ; Max control characters ; l4486: dw 0 SrcEndPtr: dw 0 FndCnt: dw 0 ; Find and replace counter l448c: dw 0 l448e: dw 0 ; ; Find buffer ; $FndItm: db 30,0 ds 30+1 ; ; Replace buffer ; $RplItm: db 30,0 ds 30+1 ; ; Option buffer ; $OptBuf: db 10,0 ds 10+1 ; ; Filename buffer ; $BlkBuf: db 15,0 ds 15+1 ; FilFlg: db FALSE ; Indicate file defined CmpMode: db _Memory ; Default memory CmpStrt: dw strtprg ; Compiler start address AvailRAM: dw 0 ; ; MAIN file ; MFCB: ds FCBlen ; ; WORK file ; WFCB: ds FCBlen ; MSGFlg: db 0 ; TURBO.MSG flag CompFlg: db 0 ; 0 requires compiling l4543: db 0 TxtBeg: dw TOP ; Start of text TxtEnd: dw TOP ; End of text TopMem: dw 0 ; Top of free memory