; bishw111.asm VERS EQU 1 ;Version number REVS EQU 11 ;Revision number ; title 'BISHOW - buffered bidirectional ; file scroll utility' ; ; Ver 1.11, 29 July 84, Earl T. Boone ; - re formatted help messages ; - changed default line width to 78 ; - reformatted ASM file so the PRN file ; prints better on narrow printer (75 col) ; - removed all vestiges of 'SHORT' since the ; program is always longer than 1k anyway ; - removed conditional code generation for ; screen clear (if you don't want screen ; clear, don't issue screen clear function ; from subroutine CLRSCR) ; - worked on (solved?) problem of tabs not ; expanded correctly on top line ofscreen ; - worked on (solved?) problems on backing ; off front of file by issuing too many ; previous-line or previous-page commands ; - worked on (solved?) problem of running ; past end of file by giving too many ; next-line or next-page commands ; - worked on (solved?) problems of L ; command to jump to end of file ; - remaining KNOWN small problem is that if ; screen is displaying last line of file, ; and last line is not at bottom of screen, ; then a prev-line or prev-page command ; will back up a little farther than ; expected. (Not more than linmax) ; ; Ver 1.10, 2 Apr 84, Charlie Polete ; ...c/o Flanders BBS - (201) 584-9227 ; - added routine to position to end of file ; - fixed 'S' command for the final ?? time ; - moved VERS and REVS equates to top of program ; ; Ver 1.09, 17 Mar 84, Charlie Polete ; ...c/o Flanders BBS - (201) 584-9227 ; - fixed EXIT bug so ALL pending console ; characters get deleted ; - moved changeable routines to beginning ; of program ; - removed unnecessary conditional ; statements - consolidated others ; - added option to clear screen before a ; page display - PAGCLR ; - added display of sign-on message ; - fixed bug in 'S' command for lines ; displayed ... count was incremented if ; only carriage return entered ; ; Ver 1.08, 7 Dec 83, Bill Randle ; ...!tektronix!billr ; (billr.tek@rand-relay) ; - add code to send "lf" before next line ; for "next" command for use with Tek 4025 ; (if def'd). ; - fix bug in "S" command for Lines Displayed. ; - fix bug in code to read first page ; (file was not reopened). ; - add code to check for beginning of file ; so it doesn't go to disk unnecessarily. ; ; Ver 1.07, 1 Aug 83, Ted H. Emigh ; ...!mcnc!ecsvax!emigh ; - added screen width and height specification ; (BISHOW file.nam [width [lines]]) ; - added windowing capability. Helpful in ; looking at files wider than 80 columns ; (see notes below) ; ; Ver 1.06, 2 Jul 83, Chuck Forsberg ; - added commands for more, mince, vi ; familiarity. Bad cmd gives help ; ; Ver 1.051, 26 June 83, Dick Mead ; - added "?" for help on commands. ; ; Ver 1.05, 31 May 83, Bruce Ratoff ; - added 'N' (next line) and 'P' ; (previous line) cmds ; - decreased buffer from 8k to 4k ; (8k takes too long) ; ; Ver 1.04, 15 May 83, Keith Petersen, W8SDZ ; - fixed bug which caused display past ; end-of-file and added bogus eof in ; case none at file end ; - added strip of high-order bit in ; line count routine ; - added exit clear of any left-over ; keyboard character ; ; Ver 1.03, 11 May 83, Keith Petersen, W8SDZ ; - fixed to allow assembly with ASM.COM ; - fixed screen clear bug when crossing ; read boundries ; - added strip for high-order bit in ; character before printing (needed for ; WordStar files) ; - improved stack routines ; - fixed bug in console input routine ; - removed Z80 dependant code (now works ; on 8080 too) ; ; Ver 1.02, 06 May 83, Lucien Pan, Toronto, Canada ; - fixed some-minor bugs ; - returns to ccp w/o warm boot ; - filters form-feeds (useful in .PRN files) ; - scrolls foward/backwards by same number ; of lines ; - disable/enable cursor during scroll for H-19 ; ; Ver 1.01, 30 Mar 83 - added BDOS function 6. ; W.F.Mcgee ; ; Ver 1.00, 23 Aug 82 Phil Cary, ; 748 Kenilworth Parkway, ; Baton Rouge, LA 70808 ; ; BISHOW is a buffered, bidirectional version of ; SHOW.ASM which first appeared in Interface Age, ; November, 1981. That program could only scroll ; forward in a file, and read sectors from disk one ; at a time as they were sent to the console. I ; used SHOW frequently to take a quick look at a ; file without loading a big text editor, and to ; examine another file with the RUN command while ; in Wordstar. TYPE does not work since it is not ; a file that Wordstar can load and run. ; ; It was annoying when I went past the point I was ; looking for in a file with SHOW, and could not ; go backwards. Thus, this bidirectional version ; which uses random access reads. In addition, ; buffering was added so that the number of disk ; reads would be reduced, and moving back and ; forth in a moderate sized file would be speeded ; up. There is a trade off between the size of the ; buffer and the length of time it takes to refill ; the buffer which should be set to the user's ; preference. ; ; There are several customizing items in this ; program. One is the equate "maxsec" which sets ; the buffer size. Another is the string in the ; subroutine "clrscr" just after the org statement. ; This should be changed to erase the screen and ; home the cursor for the user's terminal. The ; program, as written, required a terminal with ; an erase screen and home cursor function. Some ; terminals do not allow the 80th column to be ; filled without going to the next line. For ; this reason, the screen width ("maxchr") ; initially is set to 79. The screen sizes can be ; changed using the "S" (screen) command. The ; parameters that can be changed are the maximum ; column displayed ("maxchr"), the minimum column ; displayed (allowing you to "window" the output), ; and the number of lines ("scroln"). A zero for ; the maximum column displayed will give an unlimited ; screen width. The maximum column displayed and ; the number of lines can be set when calling ; BISHOW, e.g., "BISHOW file.nam 79 24" will give ; 79 columns and 24 lines, and "BISHOW file.nam 79" ; will give 79 columns with the default number of ; lines. The last customizing item is the "short" ; equate. If this is chosen, the multiplicity of ; command forms is not allowed (see the beginning ; to change the commands used), and certain messages ; are shortened. This will allow BISHOW to fit into ; a 1K area. If "short" is false, the program is ; slightly over 1K. Finally, direct I/O to the ; console is used to avoid echoing the commands to ; the console as the CP/M write console function does. ; ; Just a small contribution to the public domain ; software as partial payment for the many fine ; and educational programs the system has given me. ; Phil Cary. ; ; FALSE EQU 0 TRUE EQU NOT FALSE ; ; Operational equates ; MAXSEC EQU 32 ;number of sectors in buffer SCROLN EQU 24 ;number of lines per scroll MAXCHR EQU 79 ;number of characters per line MINCHR EQU 01 ;start at char..each input line FULBUF SET DSKBUF+(MAXSEC*128) ;need to know end of buffer ; T4025 EQU FALSE ;assemble for Tek 4025 terminal ; BASE EQU 0 ;standard zero base CP/M ; ; BDOS functions ; CONIO EQU 6 ;direct console I/O RDCON EQU 10 ;read console buffer OPEN EQU 15 ;open file CLOSE EQU 16 ;close file STDMA EQU 26 ;set dma address READR EQU 33 ;read file random access COMPF EQU 35 ;compute file size ; ; Page zero equates ; WBOOT EQU BASE ;warm boot entry point BDOS EQU WBOOT+5 ;BDOS entry point FCB EQU WBOOT+5CH ;default fcb drive number FCBFN EQU FCB+1 ;start of filename FCBFT EQU FCB+9 ;start of filetype FCBEX EQU FCB+12 ;current extent number FCBRC EQU FCB+15 ;current record count FCBCRR EQU FCB+33 ;current record number, ; random access CMDTAIL EQU WBOOT+80H ;location of command tail TPA EQU WBOOT+100H ;transient program area ; ; ASCII equates ; ENDMSG EQU 0 ;null BELL EQU 7 ;bell TAB EQU 9 ;tab LF EQU 0AH ;line feed CR EQU 0DH ;carriage return EOF EQU 1AH ;end of file ESC EQU 1BH ;escape CMDC EQU 1FH ;control-us (4025 command char) SPACE EQU 20H ;space ; ; Any invalid command gives help ; in addition to quit, ^C ends the program ; Be sure to change the help2 printout ; BACK EQU 'B' ;scroll backward FIRST EQU '1' ;first page HELPME EQU '?' ;request HELP menu ENDFIL EQU 'L' ;go to end of file NEXT EQU CR ;next line NXTPAG EQU SPACE ;next page PREV EQU '-' ;previous line QUIT EQU 'Q' ;exit bishow SCREEN EQU 'S' ;set screen parameters ; ; ----------------------------------------------- ORG TPA ; JMP START ;skip over next subroutines ; ; ***************************************************** ; * Change the following routines for your hardware * ; ***************************************************** ; CSRDSB: ;Disable cursor command ; Change as needed - ACTIVATE ONE OR ADD YOURS ; CALL CDISP ; ; DB ESC,'x5' ;HEATH - disable cursor ; DB ESC,')' ;This works for me. ; ;no cursor disable on PE-550 ; NO DISABLE ON TVI 920C DB ENDMSG RET ; ; **************************************************** ; CSRABL: ;Enable cursor command ; Change as needed - ACTIVATE ONE OR ADD YOURS ; CALL CDISP ; ; DB ESC,'y5' ;HEATH - enable cursor ; DB ESC,'(' ;This works for me ; ;no cursor enable on PE-550 ; ;no enable on TVI 920C DB ENDMSG RET ; ; ***************************************************** ; CLRSCR: ; Clear screen and/or home cursor command ; Change as needed - ACTIVATE ONE OR ADD YOURS ; CALL CDISP ; ; DB 1AH ;clear screen for adm-3 ; ditto for TVI 920c ; DB ESC,'E' ; for H/Z-19 terminal. ; DB ESC,'I' ;This works for me ; setup for Tek 4024/4025 ; DB CMDC,'up34',CR ;home cursor ; DB CMDC,'dli100',CR ;clear screen ; setup for PE-550 ; DB ESC,'K' ;20 NULS FOR PE550 ; DB 07FH,07FH,07FH,07FH,07FH ; DB 07FH,07FH,07FH,07FH,07FH ; DB 07FH,07FH,07FH,07FH,07FH ; DB 07FH,07FH,07FH,07FH,07FH ; DB ENDMSG ; ; Some terminals require a delay after a screen clear ; operation. The following code wastes about 60 ; clock periods per trip around the loop (15 micro- ; seconds at 4MZ or 30 micro seconds at 2MZ.) ; Adjust the value loaded into BC to suit. ; PUSH B PUSH PSW LXI B,1 ;waste time WAIT: XTHL XTHL DCX B MOV A,B ORA C JNZ WAIT ; cursor is now at home position so set lin counter ; and character counter to zero STA LINCNT STA CHRCNT POP PSW POP B RET ;return from clrscr ; ; ************************************************ ; * END OF CHANGEABLE ROUTINES * ; ************************************************ ; ; HELP: CALL CDISP DB CR,LF DB 'Usage: d:bishow d:fn.ft' DB ' [cols [lines]]' DB CR,LF DB ENDMSG JMP EXIT1 ; HELP2: CALL CLRSCR CALL CH2 JMP GETCMD ; CH2 CALL CDISP DB CR,LF DB 'Commands:',CR,LF DB ' Next Page ' DB '= ^C,F,^F,^V,sp',CR,LF DB ' Back Page ' DB '= ^R,B,^B',CR,LF DB ' Next Line ' DB '= ^Z,N,+,cr,lf',CR,LF DB ' Previous Line ' DB '= ^W,P,-',CR,LF DB ' First Line ' DB '= 1',CR,LF DB ' Last line ' DB '= L',CR,LF DB ' Quit (exit to CP/M) ' DB '= Q,X',CR,LF DB ' Set Screen Parameters ' DB '= S',CR,LF DB ' Print These Help Msgs ' DB '= ?',CR,LF DB ENDMSG RET ; ; ----------------------------------------------- ; START: LXI H,0 ;get ccp's stack DAD SP SHLD STACK ;save old stack LXI SP,STACK ;set new stack ; CALL CDISP DB 'BISHOW v' DB (VERS MOD 10)+'0','.' DB REVS/10+'0',(REVS MOD 10)+'0' DB CR,LF,CR,LF,ENDMSG CALL CH2 CALL CDISP DB CR,LF DB 'Press any key to begin' DB CR,LF,ENDMSG ; SHOWIT: CALL CKCONS ;loop till character JZ SHOWIT ;so sign-on can be seen ; CALL CSRDSB ;Disable cursor LXI H,CMDTAIL ;point to command tail MOV B,M ;get number of char in tail INX H ;point to first character INR B ; EATSP: MOV A,M ;get character if there is one INX H DCR B ;b=number of characters left JZ OPENF ;no more characters CPI SPACE ;ignore spaces JZ EATSP ; FILNAM: MOV A,M ;get characters in file name INX H DCR B ;b=number of characters left JZ OPENF ;only file name in tail CPI SPACE ;wait for next space JNZ FILNAM LXI D,CHRMAX ;point to chr/line CALL GETNBR ;get number of characters/line JC HELP ;invalid number LXI D,LINMAX;point to number of lines CNZ GETNBR ;call only if characters still ; in command tail JC HELP ;invalid number ; ;when writing first page we need to clear the extent ; and record number in the fcb then (re)open ; the file so that CP/M will load in the proper set ; of allocation blocks. ; OPENF: XRA A ;get a 0 STA FCBEX ;zero current extent STA FCBCRR ;zero current record STA FCBCRR+1; both bytes STA FCBCRR+2; and the overflow DCR A ;now -1 STA BUFNUM ;set buffer number to -1 CALL OPNFIL ;open file in default fcb WRTFWX: CALL CLRSCR ;start with a clean slate WRTFW0: CALL FILBUF ;fill the disk buffer LXI H,DSKBUF;point to beginning of buffer WRTFW1: MOV A,M CPI EOF ;test for end of file JZ GETCMD WRTFWA: INX H ;bump pointer ANI 7FH ;strip high bit CPI 'L'-40H ;filter form-feeds JNZ NOTFF ; commonly found in .PRN files FILTER: PUSH PSW ;save status and character MVI A,'^' ;print '^' in front CALL CO1 ; of control character POP PSW ;restore status and character ADI 40H ;mask into displayable char CALL CO1 ;display filtered control char JMP FWDCNT NOTFF CALL CO1 ;put it on console CPI CR ;see if end of line JNZ WRTFW2 FWDCNT: LDA LINCNT ;get number of lines displayed INR A ;bump it STA LINCNT ; and store it MOV D,A ;save lincnt LDA LINMAX ;get max number of line CMP D ;compare with line count JZ GETCMD ;end of screen, get command WRTFW2: LXI D,FULBUF ;get end of buffer address MOV A,D ;compare high CMP H ; order bytes JNZ WRTFW1 ;if not equal, continue MOV A,E ;else compare low CMP L ; order bytes JNZ WRTFW1 ;continue with next character JMP WRTFW0 ;refill buffer and start over ; ; ----------------------------------------------- ; GETCMD: PUSH B PUSH D PUSH H GETCM1: CALL CKCONS ;direct console I/O JZ GETCM1 ;loop till char available POP H POP D POP B CPI 'a' ;change command to JC GETCM2 ; upper case CPI 'z'+1 JNC GETCM2 XRI 20H ;is lower case, make upper case ; GETCM2: CPI NXTPAG ;next page JZ WRTFWZ CPI 'F' ; F JZ WRTFWZ CPI 'F'-40H ;vi uses ^F JZ WRTFWZ CPI 'V'-40H ;mince uses ^V JZ WRTFWZ CPI 'C'-40H ;Wordstar uses ^C JZ WRTFWZ ; ... CPI BACK ;Previous page JZ WRTBAK CPI 'B'-40H ;vi uses ^B JZ WRTBAK CPI 'R'-40H ;Wordstar uses ^R JZ WRTBAK ; ... CPI NEXT ;next line? JZ WRTNXT CPI 'N' JZ WRTNXT CPI 'Z'-40H ;Wordstar uses ^Z JZ WRTNXT CPI '+' JZ WRTNXT CPI LF JZ WRTNXT ; ... CPI PREV ;prev line? JZ WRTPRV CPI 'P' JZ WRTPRV CPI 'W'-40H ;Wordstar uses ^W JZ WRTPRV ; ... CPI FIRST ;1st line? ; JZ CLSOPN JZ BAKCHK ; ... CPI ENDFIL ;last line? JZ POSEND ; ... CPI SCREEN ;set screen parameters JZ SETSCR ; ... CPI QUIT ;quit JZ EXIT ; ... JMP HELP2 ; ; ----------------------------------------------- ; WRTFWZ: MOV A,M CPI EOF JZ GETCMD WRTFWY: CALL CLRSCR ;clear screen before MOV A,M JMP WRTFWA ; full page display ; ; WRTNXT: ;write next line ; IF T4025 MVI A,LF CALL CO ;send a leading lf ENDIF ; LDA LINMAX DCR A ;fool wrtfw1 to write STA LINCNT ; just one line JMP WRTFW1 ; ; ----------------------------------------------- ; POSEND: LXI D,FCB ;find end of file MVI C,COMPF CALL BDOS LHLD FCBCRR ;record number LXI D,-MAXSEC LXI B,-1 POS2 INX B ;count 'buffer fulls' DAD D JC POS2 LXI H,0 LXI D,MAXSEC POS3 MOV A,B ;get record number ORA C ; of last 'buffer full' JZ POS4 DCX B DAD D JMP POS3 POS4 SHLD FCBCRR ; set record number CALL FILBUF ;read last 'buffer full' MVI A,EOF ;search for eof LXI H,DSKBUF-1 POS1 INX H CMP M JNZ POS1 LDA LINMAX ;Back up one page DCR A ;(less one line) JMP WRTBK0 ; ; ----------------------------------------------- ; WRTSAM: LDA LINMAX ;back up one screen JMP WRTBK0 ; WRTPRV: LDA LINMAX ;back up one screen + 1 line INR A JMP WRTBK0 ; WRTBAK: LDA LINMAX ;get screen line count ADD A ; multiply by 2 ; WRTBK0: INR A ; and add 1 STA LINCNT ; to backup to previous page ; CALL CLRSCR ;clear the screen ; WRTBK1: LXI D,DSKBUF-1;get addr of buffer start MOV A,D ;compare high CMP H ; order bytes JNZ WRTBK2 ;continue if not equal MOV A,E ;else, compare low CMP L ; order bytes JNZ WRTBK2 LXI D,MAXSEC;get the buffer size LHLD SECCNT ;get number sectors last read DAD D ;add them XCHG ; and put them in DE LHLD FCBCRR ;subtract low order byte MOV A,L SUB E ; from current record count MOV L,A MOV A,H ;same with high order byte SBB D ; but with borrow MOV H,A JM BAKCHK SHLD FCBCRR ;store new record count CALL FILBUF ;fill the buffer LXI H,FULBUF-1 ; and point to end of buffer WRTBK2: MOV A,M ;get a character ANI 7FH ;strip high bit DCX H ;decrement buffer CPI CR ;see if end of line JZ BAKCNT ; or form-feed CPI 'L'-40H ; and adjust line count if so JNZ WRTBK1 ;else, loop if not ; BAKCNT: LDA LINCNT ;else, get number of lines ; to move back DCR A ; and decrement it STA LINCNT ; store it JNZ WRTBK1 ; and loop if not there INX H ;else bump pointer INX H ; to account for dcx LDA FLBF+1 ;careful not to go CMP H ; off end of buffer JNZ WRTFWZ LDA FLBF CMP L JNZ WRTFWZ JMP WRTFWX ; BAKCHK: LXI H,0 ;force record cnt to zero SHLD FCBCRR CALL FILBUF ;fill buffer LXI H,DSKBUF;start at beginning of buffer JMP WRTFWZ ;go fill the screen ; CLSOPN: CALL CLOSF ;close before re-open JMP OPENF ; ; ----------------------------------------------- ; FILBUF: LXI D,DSKBUF;load start of disk buffer MVI B,MAXSEC;number of sectors to read LXI H,0 ;zero out the SHLD SECCNT ; number of sectors in buffer LDA BUFNUM ;bufnum can be -1, 0, or 1 CPI 1 ;if 1 then don't increment JZ FILBU1 INR A ;else increment & use as a flag STA BUFNUM ;to determine whether to reread ; FILBU1: PUSH B ;save all PUSH D ; registers from PUSH H ; BDOS clobber MVI C,STDMA ;set dma to CALL BDOS ; disk buffer LXI D,FCB ;set up to read MVI C,READR ; a record CALL BDOS ;do it PUSH PSW ;Save return info LHLD FCBCRR ;get current record number INX H ; bump it SHLD FCBCRR ; and save it LHLD SECCNT ;get sectors in buffer INX H ;bump it SHLD SECCNT ;store it POP PSW ;restore...result of read POP H ;...and POP D ;......all POP B ;.........registers ORA A ;read OK? JNZ RDERR ;no, last sector read DCR B ;decrement it RZ ;if done return LXI H,128 ;else, add 128 to DAD D ; dma address XCHG ;put it in de JMP FILBU1 ;read another sector ; ;We only get here if end of file ; RDERR: MVI A,EOF ;get bogus eof STAX D ;save at buffer end ; in case no eof in file XRA A ;get a zero to direct to start ; of buffer RET ; on ret ; ; ----------------------------------------------- ; OPNFIL: LDA FCBFN ;point to filename CPI SPACE ;anything there? JZ HELP ;no, give help message LXI D,FCB ;file name in default fcb MVI C,OPEN ;set up to open CALL BDOS ;do it INR A ;open OK? RNZ ;yes CALL CDISP ;else, give error msg and quit DB CR,LF,'File not found',ENDMSG JMP EXIT1 ;leave msg on screen on exit ; ; ----------------------------------------------- ; GETNBR: MOV A,M ;get first digit INX H DCR B ;b=number chars left in buffer RZ ;no digit CPI SPACE JZ GETNBR ;wait until next non-space PUSH D ;save location to save number MVI D,0 ;initialize number GNUM1: SUI 30H ;change ASCII to number JC INVNUM ;not a number CPI 10 CMC JC INVNUM ;not a number PUSH PSW ;save number MOV A,D ;multiply old number by 10 ADD A ;*2 ADD A ;*4 ADD D ;*5 ADD A ;*10 MOV D,A POP PSW ;restore new digit ADD D MOV D,A MOV A,M ;get next digit INX H DCR B JZ ENDNUM ;end of number CPI SPACE JNZ GNUM1 ; ENDNUM: MOV A,D ;save number XCHG ;set to restore save location POP H ;restore save location MOV M,A ;save digit XCHG ;put bufr locn where it belongs MOV A,B ;see if any chars left in bufr ORA A ;zero if no characters in bufr RET ; INVNUM: POP D ;correct stack RET ; ; ----------------------------------------------- ; ASCIIN: MVI B,100 ;divide by 100, change CALL DIVIDE ; to ASCII, store at hl MVI B,10 ;divide by 10, change CALL DIVIDE ; to ASCII, store at hl+1 MVI B,30H ;change ones place number ADD B ; to ASCII and store at hl+2 MOV M,A DCX H ;delete leading zeroes DCX H ; in the number MVI C,SPACE ; and replace with spaces MOV A,B CMP M ;check first digit for '0' JNZ CDISP ;not zero MOV M,C ;replace with space INX H CMP M ;check second digit for '0' JNZ CDISP ;not zero MOV M,C ;replace with space JMP CDISP ; ; ----------------------------------------------- ; SETSCR: PUSH H PUSH D PUSH B CALL CSRABL ;Enable cursor GETMAX: LDA CHRMAX ;get max nmbr characters LXI H,HUNS CALL ASCIIN ;put ASCII number in message DB CR,LF,'Maximum Column: ' HUNS: DB '000 New? ',ENDMSG CALL GETINP ;read input from console LXI D,CHRMAX ;set new chrmax in memory CALL GETNBR JC GETMAX ;if error, repeat last message GETMIN: LDA CHRMIN ;get minimum character display INR A ;bump it STA CHRMIN ;save..later gets decremented LXI H,HUN CALL ASCIIN ;put ASCII number in message DB LF,'Minimum Column: ' HUN: DB '000 New? ',ENDMSG CALL GETINP ;read input from console LXI D,CHRMIN ;set new chrmin in memory CALL GETNBR JC GETMIN ;if error, repeat last message LDA CHRMIN ;get minimum column DCR A ;decrement STA CHRMIN ;store corrected value GETLIN: LDA LINMAX ;get nmbr lines per display LXI H,HUND CALL ASCIIN ;put ASCII number in message DB LF,'Lines Displayed: ' HUND: DB '000 New? ',ENDMSG CALL GETINP ;read input from console LXI D,LINMAX ;set new linmax in memory CALL GETNBR JC GETLIN ;if error, repeat last message CALL CSRDSB ;Disable cursor POP B POP D POP H JMP WRTSAM ;write the same screen ; ; ----------------------------------------------- ; GETINP: MVI A,5 ;get set to read new max column STA CMDTAIL MVI C,RDCON LXI D,CMDTAIL CALL BDOS ;get maximum column LXI H,CMDTAIL+1 ;now, change to ASCII MOV B,M INX H INR B RET ;return with input in buffer ; ; ----------------------------------------------- ; DIVIDE: MVI C,'0'-1 ;extract dividend of a div c DIV1: INR C ;store in location pointed SUB B ; to by hl JNC DIV1 ADD B MOV M,C ;save ASCII digit INX H ;bump pointer to next location RET ; ; ----------------------------------------------- ; CDISP: XTHL ;exchange top of stack and HL CDIS1: MOV A,M ;HL now pointing to db message ORA A ;see if 0 at end of message INX H JZ CDIS2 ;yes, restore stack and return CALL CO ;no, print the character JMP CDIS1 ; and loop CDIS2: XTHL ;get return addr on stack RET ; and return ; ; ----------------------------------------------- ; CO: PUSH B ;Save the registers PUSH D ; from bdos PUSH H ; clobber PUSH PSW MOV E,A ;set up character MVI C,CONIO ; to send to console CALL BDOS ;do it POP PSW POP H ;restore POP D ; the registers POP B RET ; ; ----------------------------------------------- ; CO1: PUSH D ;Save the registers PUSH H MOV E,A ;Save A reg LXI H,CHRCNT ;Get address of char cnt CPI CR ;see if end of line JNZ NOTCR MVI M,0 ;reset character count JMP CO6 NOTCR CPI LF ;Print linefeed JZ CO6 ;but don't count it CPI TAB ;fix chrcnt for tabs JNZ NOTTAB TAB1: MVI A,SPACE ;expand tab CALL CO1 MOV A,M ;character count ANI 7 ;multiple of 8? JNZ TAB1 ;print more spaces JMP CO5 NOTTAB INR M ;increment character count LDA CHRMAX ;get max chars per line CMP M ;see if too many char JC CO5 ;don't print character LDA CHRMIN ;up to min display yet? CMP M JNC CO5 ;display character CO6 MOV A,E CALL CO CO5: MOV A,E POP H ;restore POP D ; the registers RET ; ; ----------------------------------------------- ; CLOSF: LXI D,FCB ;close file MVI C,CLOSE ;--in case this is MP/M CALL BDOS RET ; ; ----------------------------------------------- ; CKCONS: MVI E,0FFH ;clear console of characters MVI C,CONIO ;direct console I/O CALL BDOS ; get any waiting characters ORA A ;set for status or character RET ;Zero = no character waiting ;tested on return ; ; ----------------------------------------------- ; EXIT: CALL CLOSF ;Close the file CLCON: CALL CKCONS ;Clear ALL waiting characters JNZ CLCON ;Loop till no more characters EXIT1: CALL CSRABL ;Enable the cursor LHLD STACK ;get old stack SPHL RET ;return to CCP ; ; ----------------------------------------------- ; ; Memory allocation ; FLBF DW FULBUF SECCNT: DW 0 ;number of sectors in buffer LINMAX: DB SCROLN ;nbr lines to write on cons CHRMAX: DB MAXCHR ;nbr chars to display/line CHRMIN: DB MINCHR-1 ;character to start on line CHRCNT: DS 1 ;character number in line LINCNT: DS 1 ;line number on write BUFNUM: DS 1 ;flag for first buffer check DS 60 ;stack area STACK: DS 2 ;old stack saved here DSKBUF: EQU $ ;disk buffer area ; END TPA