home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
ENTERPRS
/
CPM
/
UTILS
/
S
/
TURBOPAT.ARC
/
TURBOPAT.Z80
< prev
Wrap
Text File
|
1989-09-27
|
13KB
|
534 lines
;*****************************************************************************
;*****************************************************************************
;* *
;* TURBOPAT.Z80 VERSION 1.1 (1/85) *
;* *
;* TURBOPAT is a public-domain patch to version 2.00A of the *
;* Z-80 CP/M version of TURBO PASCAL released by Borland *
;* International. It is meant to be assembled by CROWECPM *
;* or an equivalent Z-80 assembler, and installed in TURBO *
;* as a straightforward overlay. The installation may be *
;* accomplished with DDT or MLOAD. *
;* When installed, TURBOPAT improves TURBO's *
;* file-handling capability by adding optional entabbing and automatic *
;* detabbing of workfiles, and by adding 'reName' and 'Update' *
;* commands to the main menu. It also modifies the TURBO editor's *
;* 'tab' command (i.e. ^I). TURBO's tab command moves the cursor *
;* to the location immediately under the next word, but TURBOPAT's *
;* tabs are simply set every eight spaces. See the accompanying *
;* .DOC file for additional information. *
;* Space is created for TURBOPAT within TURBO by deleting *
;* the little-used directory command. The 'X' command may still *
;* be used to run an external directory program, of course. *
;* It is hoped that TURBOPAT will be of particular value *
;* to those who wish to use the TURBO editor to write assembly *
;* language programs, which require tabs as field delimiters. *
;* Send comments to the author, *
;* *
;* Robert S. Maier *
;* 3607 Greystone Dr. #2222 *
;* Austin, TX 78731 *
;* *
;*****************************************************************************
;*****************************************************************************
;
BLREAD EQU 247BH
BLOMAX EQU 7A6DH
PBDOJP EQU 25DBH
DSKFER EQU 2606H
DMABUF EQU 77D8H
MENU EQU 2177H
POSCUR EQU 4333H
BEGLIN EQU 79EEH
RTCHCK EQU 3AFBH
CHRMOV EQU 389EH
LINDWN EQU 36C0H
REPOSI EQU 3EF2H
TYPE EQU 225H
COLONI EQU 215EH
LOFNFT EQU 2C4BH
FCB0 EQU 4400H
CPMFCB EQU 5CH
CHGDRV EQU 2BEFH
RUNFIL EQU 29B1H
RUNEXT EQU 2A4EH
OPTION EQU 2281H
COMPIL EQU 2730H
SAVFIL EQU 2541H
EDTFIL EQU 2A12H
QUIT EQU 2A3EH
MEMORY EQU 2648H
COMFIL EQU 264CH
STARTA EQU 2658H
ENDADD EQU 2676H
CHNFIL EQU 2650H
FNDRTE EQU 26A4H
CRFFLG EQU 4401H
SAVACT EQU 2593H
TOPOFF EQU 2CB0H
TOPOFG EQU 2CC0H
MFDRIV EQU 43DDH
MFLFCB EQU 43DCH
NFILOP EQU 24C4H
JMPOFD EQU 24A6H
OUSTOF EQU 2509H
WORKFN EQU 4401H
PROMPT EQU 2138H
;
;
;MODIFY THE MENU TO INCORPORATE NEW COMMANDS
;
ORG 2154H
DEFW MENUST ;change loc of list of menu subroutines
;
ORG 2157H
DEFB 0DH ;13 commands on the new main menu
;
ORG 21C5H ;visibly modify the menu
DEFB 8DH
DEFB 8AH
DEFB 8AH
DEFB 'E'+80H
DEFM 'dit'
DEFB 9
DEFB ' '
DEFB 'S'+80H
DEFM 'ave'
DEFB 9
DEFB 8
DEFB 'U'+80H
DEFM 'pdate'
DEFB 9
DEFM 're'
DEFB 'N'+80H
DEFM 'ame'
DEFB 9
DEFB 'T'+80H
DEFM 'abs o'
MENUB1: DEFB 'f'
MENUB2: DEFB 'f'
DEFB 0DH
DEFB 0AH
DEFB 0AH
DEFB 'C'+80H
DEFM 'ompile'
DEFB 9
DEFB ' '
DEFB 'R'+80H
DEFM 'un'
DEFB 9
DEFB 8
DEFB 'O'+80H
DEFM 'ptions'
DEFB 9
DEFB 'Q'+80H
DEFM 'uit'
DEFB 9
DEFB 'e'
DEFB 'X'+80H
DEFM 'ecute'
;
ORG 234BH
LD HL,MENUCP ;change loc of list of options menu commands
LD DE,MENUSU ;and corresponding subroutines
;
ORG 2368H
MENUCO: DEFM 'ULWRXTON' ;main menu commands
MENUCP: DEFM 'MCSEQ' ;main and options menu commands
DEFM 'HF' ;options menu commands
;
MENUST: DEFW UPDATE ;following sbrtns are for main menu
DEFW CHGDRV
DEFW LOADF
DEFW RUNFIL
DEFW RUNEXT
DEFW TOGTAB
DEFW OPTION
DEFW RENAME
DEFW MAINFL
DEFW COMPIL
DEFW SAVER
DEFW EDTFIL
DEFW QUIT
MENUSU: DEFW MEMORY ;following sbrtns are for options menu
DEFW COMFIL
DEFW STARTA
DEFW ENDADD
DEFW QUITME
DEFW CHNFIL
DEFW FNDRTE
QUITME: POP HL ;foll. routines are unchanged from
JP MENU ;TURBO, but are shifted by one byte
;as the above tables are too long
MAINFL: CALL TYPE
DEFB 0DH
DEFB 0AH
DEFM 'Main file name'
DEFB 0
CALL TOPOFG
CALL COLONI
LD A,0
LD (MFDRIV),A
RET Z
CALL LOFNFT
LD DE,MFLFCB
LD HL,CPMFCB
LD BC,24H
LDIR
RET
LOADF: LD HL,NFILOP
LD (JMPOFD),HL
CALL OUSTOF
CALL TYPE
DEFB 0DH
DEFB 0AH
DEFM 'Work file name'
DEFB 0
CALL COLONI
LD A,0
LD (WORKFN),A
CALL Z,TOPOFF ;slight mod here which saves
JP Z,PROMPT ;abovementioned byte
NOP
;
;
ORG 234CH
DEFW MENUCP ;modify loc of the list of optionsmenu subs
;
;
;PATCH IN THE INITIALIZATION ROUTINE FOR THE READ SUBROUTINE
ORG 2477H
JR PTCHER ;input to init req'd for read patch
NOP
PTCINO: NOP ;output from init req'd for read patch
;
;PATCH IN THE NEW READ SUBROUTINE ITSELF
ORG 2495H
JP INPTCH
;
PTCHER: ;init patch for read sbrtn
LD (BLOMAX),BC
EXX
LD L,7 ;set L'=00000111b as tabs every 8 spaces
LD DE,0 ;reset col counter (D') and quote flag
EXX
JR PTCINO+1
;
;PATCH TO THE SAVE SUBROUTINE
ORG SAVACT+4
JP SAVPAT
;
;PATCH IN THE NEW WRITE SUBROUTINE
ORG 25B3H
JP INITI
PWRIC: JP WRIC ;target of jp is mod by T command
TABFLG: DEFB 0FFH ;tab flag shows whether tabbing enabled
DSKOT: PUSH BC ;foll. subrtn taken from TURBO
PUSH HL
LD C,15H
CALL PBDOJP
POP HL
POP BC
OR A
JR NZ,DSKFER
LD DE,DMABUF
LD A,B
LD B,80H
CP 1AH
JP NZ,WRIA
EOF: LD A,B
SUB 80H
LD A,1AH
JR NZ,PWRIC
NOP
;
;The foll. subroutines are placed where TURBO located its directory
;subroutine, i.e. the subroutine handling the 'D' command.
;
;
ORG 2AB4H
;START OF ENTAB ON/OFF TOGGLE SUBROUTINE
;
TOGTAB: LD BC,TABFLG ;check whether entabbing on
LD A,(BC)
OR A
JR Z,TURNON
LD DE,OFFVAL ;if on, get loc of table of substitutes
JR CONTIN
TURNON: LD DE,ONVAL ;if off, get (different) values for same
CONTIN: CPL
LD (BC),A
LD HL,BYTESL ;get loc of table of bytes to change
LD B,5 ;5 bytes to be modified
MOVBYT: LD A,(DE) ;get new value for byte
INC DE ;move to next in table
PUSH BC
LD C,(HL)
INC HL
LD B,(HL)
INC HL
LD (BC),A ;load new value into spec byte
POP BC
DJNZ MOVBYT ;repeat
JP MENU ;when fin, jp to menu
BYTESL: DEFW MENUB1
DEFW MENUB2
DEFW PWRIC+1
DEFW PWRIC+2
DEFW JUMPER+1
OFFVAL: DEFM 'n '
DEFW OWRIC
DEFB 69H ;this is OWRIC-JUMPER-2
ONVAL: DEFM 'ff'
DEFW WRIC
DEFB 0
;START OF NEW WRITE SUBROUTINE
;
INITI:
LD B,80H ;reset relative location in write buffer
EXX
LD DE,0 ;reset blank and column counters
LD HL,0107H ;set ' flag and set columns every 8 spaces
EXX
WRIA:
LD A,(HL) ;store file char in A
INC HL ;bump position in file
JUMPER: JR NEXINS ;jump to next instr unless ENTAB disabled
NEXINS: PUSH BC ;Save current rel loc (unprimed B)
EXX
BIT 0,H ;test bit 0 of H', i.e.
;test whether quoteflag set
JR NZ,QUOTAT ;IF ' FLAG SET, DON'T tabify
CP ' ' ;20H
JR Z,BLANKS ;if flag not set and char=blank, jp to sbrtn
QUOTAT: CP ' '
JR C,NOPRNT ;if char nonprintable, jump to subroutine
CP 27H ;if char is a quotation mark,
JR NZ,NOQUOT
LD H,1 ;set ' flag (H')
NOQUOT: INC E ;bump col counter (E')
JR CHRSO ;jump to 'characters out' subrtn
NOPRNT: CP 0DH
JR Z,CARRE ;if char is <cr> then jump to appr subrtn
CHRSO: LD C,A ;OUTPUT CHARACTERS SUBROUTINE
LD A,D ;test blank counter (D')
OR A
JR NZ,BLASTR ;if string blanks stored, output them instead
LD A,C
CHRSP: POP BC ;clean up stack
EXX ;otherwise
LD (DE),A ;load char immy into write buffer and
INC DE ;bump position in write buffer
JR PREOT1 ;and jump to pre-output (of patch) sbrtn
CARRE: ;<cr> output sbrtn
LD DE,0 ;RESET COLUMN, BLANK COUNTERS
LD H,0 ;RESET ' FLAG
JR CHRSP
BLANKS:
INC D ;bump blank counter (D')
INC E ;bump column counter (E')
LD A,E
AND L ;AND the column (E') with 07h (i.e. L')
;i.e. test whether column=0 (mod 8)
JR NZ,NOCTLI ;if so, subst. TAB for the blanks
LD D,0 ;reset blanks counter (D')
LD A,9 ;use TAB as the char to be written to file
JR CHRSP ;write it
NOCTLI: POP BC ;clean up stack
EXX
JR WRIA ;blank not output, so get another char
BLASTR:
POP BC ;pop (from BC) into BC' e.g. the rel buf loc.
LD A,B ;from the rel loc in write buffer
SUB D ;subtract the contents of blank-counter (D')
LD C,D ;if they'll all fit into write buffer use
JR NC,ALLFIT ;D' as the no. of blanks.
LD C,B ;Otherwise use the no. of bytes left in buffer
ALLFIT: LD A,B ;Begin the blank-string subrtn proper.
SUB C ;Subtr from B' the no. of blnks to be output
LD B,A ;compute new buffer rel loc, place in B'
LD A,D
SUB C
LD D,A ;reset the blank-counter D' (poss not to 0)
DEC E ;dec column counter as file char isn't written
PUSH BC ;save the new buffer rel loc from B'
EXX
POP BC ;and pop it back into unprimed B, and C' to C
DEC HL ;decrement HL to consider the filechar again
LD A,' ' ;20H
BLALOO: ;output the string of blanks to write buffer
LD (DE),A
INC DE
DEC C ;C' was used to specify the no. to be output
JR NZ,BLALOO
PREOT: INC B ;inc b as it was decremented by 1 too much
PREOT1: DJNZ CLZTST ;if write buffer full,write it to disk
LD B,A
JP DSKOT
CLZTST: CP 1AH ;otherwise check whether filechar was ^Z
JR NZ,WRIA ;if no EOF char, get next char and repeat
JP EOF ;if filechar was EOF then jp to appr sbrtn
;
;
WRIC: PUSH BC ;Save current rel loc in buffer
EXX
JR CHRSO
;
OWRIC: LD (DE),A ;this sbrtn substs for WRIC if ENTAB
INC DE ;is not enabled. I.e. it is what orig.
JR PREOT1 ;appeared in TURBO.
;
;
;
;START OF NEW READ SUBROUTINE
;
INPTCH: ;B is no. of chars in read buffer
LD A,(DE) ;get char fr read buffer
AND 7FH ;strip bit 7
CP ' ' ;20H
JR C,NOTPRN ;if not printable, jp
EXX
CP 27H
JR NZ,BMPLOD ;if char is not ', bump the col counter
LD A,E ;i.e. D' and load it into the file in
CPL ;memory. If it is ',
LD E,A ;complement the quoteflag (E')
LD A,27H
JR BMPLOD
NOTPRN: CP 0DH ;<CR>?
JR NZ,NOTCR ;if so,
EXX
LD DE,0 ;reset column counter (D') and quoteflag (E')
JR EXLOAD
NOTCR: CP 1AH
RET Z ;if eof reached, ret immy
EXX
BIT 0,E ;test whether quote flag is set
JR NZ,EXLOAD ;if quote flag set, don't expand tabs
CP 9 ;if a tab, expand it
JR NZ,EXLOAD
EXPTAB: ;EXPAND TAB INTO SPACES
LD A,D
CPL ;Compute no. of spaces
AND L ;L' contains 07h permanently
LD B,A ;and place in B'
LD A,' ' ;20H
JR Z,BMPLOD
TABLP: ;tab loop sbrtn; outputs the spaces
EXX
LD (HL),A
INC HL ;bump position in file in memory
EXX
INC D ;bump col counter
DJNZ TABLP ;B' contained no. of spaces to be output
BMPLOD: INC D ;bump col counter (I.e. D')
EXLOAD:
EXX
LD (HL),A ;load char fr. buffer to file
INC HL
INC DE
DJNZ INPTCH ;dec b (orig.80H) and repeat
JP BLREAD ;when finished w/ buffer, read next blk
;
;START OF THE NEW RENAME COMMAND SUBROUTINE
;
RENAME: LD A,(CRFFLG) ;if 'current wfile flag' not set,
OR A ;then no current wfile
JR Z,PMENU ;so jump back to menu
CALL TYPE
DEFB 0DH
DEFB 0AH
DEFM 'New name'
DEFB 0
CALL COLONI ;call colon + input sbrtn
CALL LOFNFT ;load new fn.ft
JR Z,PMENU
LD DE,FCB0 ;move new fn.ft from FCB to TURBO's storage
LD HL,CPMFCB
LD BC,24H
LDIR
PMENU: JP MENU ;jp back to TURBO main menu
;START OF THE NEW UPDATE COMMAND
;
UPDATE: LD A,13H
LD (SAVACT),A ;delete file, not rename
SAVER: LD A,(CRFFLG) ;test whether a current workfile
OR A
JR Z,PMENU ;if not return to menu
JP SAVFIL ;otherwise save/update the file
;
;START OF THE PATCH TO SAVE ROUTINE
;
SAVPAT: LD HL,(4427H)
PUSH AF
LD A,17H
LD (SAVACT),A ;restore rename, not delete
POP AF
JP SAVACT+7
;
;
;A PATCH WHICH ADJUSTS FOR THE NEW LOCATION OF THE 'LOADF' SUBRTN
;
ORG 2C7BH
CALL LOADF
;
;START OF THE PATCH TO THE TAB EDIT COMMAND
;
ORG 3985H
TABCO: LD HL,(POSCUR) ;get curr cursor pos in linbuf
LD DE,BEGLIN ;get beginning of linbuf
OR A ;reset C flag
SBC HL,DE
LD A,L ;calc rel pos in linbuf
LD H,11111000B ;mask off first 5 bits
AND H
LD H,7
DEFB 84H ;this is 'ADD H' instruction
LD H,0
LD L,A
ADD HL,DE ;compute new pos in linbuf
CALL RTCHCK ;add 1 and check whether at rt end
RET NC ;if so ret immy
JP CHRMOV ;if otherwise, implement shift
;
;a slight mod to the <CR> edit command follows. This will cause
;the auto-indent feature to work correctly.
;
ORG 381DH
JP TABCO
;
;Initialise the auto-indent flag to 'off' instead of 'on',
;as TURBO originally had it. (This is a matter of personal
;preference!)
ORG 435AH
DEFB 1
END