; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ; * * ; * S C A N * ; * * ; * A ZCPR3 Buffered Bi-directional * ; * Video-oriented Text File Display Utility * ; * For Text and Library Member Files * ; * * ; * Copyright (c) 1988-91 * ; * by * ; * Terry Hazen * ; * 21460 Bear Creek Road * ; * Los Gatos, CA 95030 * ; * * ; * Voice.......... (408) 354-7188 * ; * Zee-Machine.... (408) 245-1420 * ; * Ladera Znode... (213) 670-9465 * ; * * ; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ; ; ; Revision History ; ---------------- ; ; 08/27/91 The WordStar mode now interprets 1Eh (WordStar soft ; v2.5 hyphen) as '-' while non-WordStar modes ignore it. ; WordStar mode interprets 0Fh (WordStar no-break space) ; as '^O' while non-WordStar modes now display it as a ; space. Fixed printer init routine, which bombed when ; there was no printer init string. Stopped interruption ; of display by pending commands during line up/down ; functions. Fixed bug in bottom-of-file last/nxt line ; routines introduced in v2.4. Changed video mode flag ; to 3 bit toggle for easier configuration. ; - Terry Hazen ; ; 06/12/91 Rewritten as dedicated ZCPR3 utility. Internal Z3TCAP ; v2.4 eliminated. Screen display routines rewritten for ; faster and smoother operation. String find routine ; rewritten for increased speed. Printer initialization ; string changed to length-prefixed string. ; - Terry Hazen ; ; 11/08/90 Fixed library directory routines to accept 2 byte ; v2.3a number of directory entries. Fixed bug introduced ; in v2.2 so FREAD now deals properly with empty files. ; - Terry Hazen ; ; 09/10/90 Added check for extended ZCPR3 environment at startup ; v2.3 so that when we are operating in extended ZCPR3 ; environments, we can locate CCP addresses for ; non-standard systems. Replaced command buffer routines ; with an adaptation of Joe Wright's BIOS keyboard ; buffer for better command buffer performance. Command ; help screen now automatically reflects current single- ; character commands directly from command table. Help ; screen now displays mostly alternate commands, since ; the default WordStar command set is assumed. ; - Terry Hazen ; ; 05/18/90 Changed find string routine so entire screen isn't ; v2.2 scrolled to mark next find when next find is still on ; current screen. Added mark and find place markers ; 0-9. Added command buffer that speeds up multiple ; command sequences by interrupting current display ; operation if more commands are pending. Fixed error ; that loaded wrong environmental processor speed ; value. Added additional ^QQ exit command. Many ; general code revisions. ; - Terry Hazen ; ; 01/01/90 Extensively revised to fix all known bugs in v2.0. ; v2.1 Uses added terminal capabilities defined in new ; extended Z3TCAP, including Delete and Insert Line, ; and terminal configuration flag byte, if they are ; available, for faster and better display. Added ^KR ; command to read in files without needing to return to ; the command line, ^KW command to write text being ; displayed to a file. Added patch byte for found string ; display line. Reduced number of text buffers to 2. ; Buffer size now initialized at startup to use all ; available memory up to CCP or lowest protected RSX. ; - Terry Hazen ; ; 10/27/88 Fixed several bugs causing problems with buffer ; v2.0A management and string find. Current find string now ; remains active when running under ZCPR3 GO command. ; - Terry Hazen ; ; 10/18/88 Completely redesigned and rewritten in Z80 code. ZCPR3 ; v2.0 compatible when operating in ZCPR3 environment. Gets ; terminal control sequences from Z3TCAP and supports DIR: ; form. Terminal control sequences can be patched into ; internal Z3TCAP for non-ZCPR environments. Added string ; find command, bottom of file command. ; - Terry Hazen ; ; 10/11/85 Initial release. ; v1.2 - Terry Hazen ; ;======================================================================= ; ; Overview ; -------- ; ; ..... ; ;======================================================================= ; ; Assemble with Z80ASM or equivalent: A0>Z80ASM SCAN ; ;======================================================================= ; ; Modules ; ------- ; ; SCAN.Z80 is divided into modules. For easier editing, each module ; is a separate file: ; ; Module Description ; ---------- ------------------------------------- ; SCAN.Z80 Equates, TCAP and user customization ; SCAN.0 Main code ; SCAN.1 Command argument parsing ; SCAN.2 File name handling ; SCAN.3 Disk input/output, buffer handling ; SCAN.4 Console input/output, help screens, status line ; SCAN.6 String find ; SCAN.5 General utility subroutines ; SCAN.7 ZCPR3 VLIB video routines ; SCAN.8 Initialization ; SCAN.9 Data area ; ;----------------------------------------------------------------------- ; ; System Equates ; off equ 0 on equ not off no equ 0 yes equ not no ; ; Version ; vers equ 25 ; Version number suffix equ ' ' ; Version suffix (eg: 'a' or ' ' if none) internal equ no ; Internal unreleased version int$vers equ 13 ; Internal version number month equ 08 ; Month day equ 27 ; Day year equ 91 ; Year ; ; ASCII values ; bell equ 7 ; Ring console bell bs equ 8 ; Back space tab equ 9 ; Tab over lf equ 10 ; Line feed ff equ 12 ; Form feed cr equ 13 ; Carriage return esc equ 27 ; Escape space equ 32 ; Space del equ 07fh ; Rubout eof equ 'Z'-040h ; CP/M end-of-file marker for text files ; ; CP/M functions ; conout equ 2 ; Console output listout equ 5 ; List character dconio equ 6 ; Direct console i/o pstring equ 9 ; Print string seldsk equ 14 ; Select disk open equ 15 ; Open file close equ 16 ; Close file srchfst equ 17 ; Search for first directory occurrence srchnxt equ 18 ; Search for next directory occurrence deletef equ 19 ; Delete file write equ 21 ; Write file record sequential create equ 22 ; Create file getdsk equ 25 ; Get current disk number setdma equ 26 ; Set DMA address setatt equ 30 ; Set file attributes setusr equ 32 ; Set user number getusr equ setusr ; Get current user number readr equ 33 ; Read file record random getlst equ 35 ; Get last record in file ; ; System addresses ; wboot equ 0000h ; Warm boot jump address bdos equ 0005h ; BDOS entry address cmdbuf equ 0080h ; CP/M default DMA/command buffer ; dfcb equ 005ch ; CP/M default FCB #1 dfcbfn equ dfcb+01 ; Start of filename dftype1 equ dfcb+09 ; Start of filename extension dextent equ dfcb+12 ; Extent ; ; FCB offset definitions ; fcbsz equ 36 ; Size of entire File Control Block fnamsz equ 11 ; Size of filename in FCB (name + type) ftypsz equ 3 ; Size of the "type" field in filename ; drvoff equ 0 ; Drive byte offset namoff equ 1 ; File name offset typoff equ 9 ; File type offset extoff equ 12 ; Extent byte offset recoff equ 33 ; Random record number offset ; ; Offsets into the ZCPR3 environment ; z3off equ 03h ; Offset to 'Z3ENV' string etypoff equ 08h ; Offset to environment type msgoff equ 22h ; Offset to message address efcboff equ 24h ; Offset to external FCB address qoff equ 28h ; Offset to quiet flag psoff equ 2bh ; Offset to processor speed mdoff equ 2ch ; Offset to max drive muoff equ 2dh ; Offset to max user coloff equ 31h ; Offset to number of columns linoff equ 32h ; Offset to number of lines drvcoff equ 34h ; Offset to DRVEC vector ccpoff equ 3fh ; Offset to CCP address ccpsoff equ 41h ; Offset to CCP size in records dosoff equ 42h ; Offset to DOS address dossoff equ 44h ; Offset to DOS size in records biooff equ 45h ; Offset to NZBIOS z3toff equ 80h ; Offset to Z3TCAP ; ; Misc equates ; fsmax equ 45 ; Maximum find string length of 45 lbrsign equ 2000h ; First library byte namesz equ 12 ; Max. size of a CP/M filename less DU: maxarg equ 2 ; Max no of command arguments accepted recsz equ 128 ; Size of a CP/M standard disk record mlen equ 18 ; Length of command message scmdlen equ 50 ; Length of command buffer ;======================================================================= ; ; Environmental definition ; main: jp init ; Do initialization z3env: db 'Z3ENV' ; This is a ZCPR3 utility db 1 ; External environment descriptor envptr: dw 0000h ; Z3ENV address (default for ; Z33+ or non-Z) ;======================================================================= ; ; Configuration area starts here ; ;======================================================================= ; ; The number of lines and columns displayed on your terminal. If either ; of these values are set to 0, SCAN will take the value from the ZCPR3 ; environment. To override the value in your ZCPR3 environment, set ; these values to suit your requirements ; lines: db 0 ; Number of lines displayed columns:db 0 ; Number of columns displayed ; ; Default ZCNFG filename ; db 'SCAN', db vers/10+'0',vers mod 10+'0' db ' ',0 ; 8 characters + termination ; ; Number of lines from the previous page displayed on a new page. The ; default overlap is 5 lines. ; overlap:db 5 ; Number of overlap lines ; ; The default video mode may be selected by setting D$VMODE. ; d$vmode:db 1 ; 1 = WS video mode default ; db 2 ; 2 = ZCPR3 video mode default ; db 4 ; 3 = ASCII video mode default ; ; Line on which found string is displayed. ; fsline: db 13 ; WordStar 3.0/4.0 default is line 13 ; ; Wildcard string search character. ; wcchr: db 'A'-40h ; Default is ^A, or 1h ; ; Printer initialization string, sent each time printer is selected. ; ptrinit:db 0 ; Length of string db 0,0,0,0,0,0 ; Six bytes max ; ; Fence string for library directory displays. ; fence: db ' | ',0 ;======================================================================= ; ; Display the command line HELP message and quit ; help: call ilprt name: db 'SCAN ' db 'Text File Display Utility ' db 'vers ' db vers/10+'0','.',vers mod 10+'0' if suffix db suffix endif db cr,lf,' Copyright (c) 1988-' db year/10+'0',year mod 10+'0' db ' by Terry Hazen' ; if internal ; Display internal revision number db cr,lf db tab,'[Internal Revision ' db int$vers/10+'0','.',int$vers mod 10+'0',' - ' db month/10+'0',month mod 10+'0','/' db day/10+'0',day mod 10+'0','/' db year/10+'0',year mod 10+'0',']' endif ; db cr,lf db 'Syntax: ',0 call print$name db 'afn',0 call print$name ; ; 'LBR' used as library filetype reference ; lbrtype:db 'LBRname[.LBR]',0 call print$name db 'LBRname LBRmember' db cr,lf,0 jp donex ; And we're done ;----------------------------------------------------------------------- ; ; Cancel all pending commands ; cancelcmd: call refresh ; Refresh screen ; ; Cancel commands without the screen refresh ; ccmd0: xor a ld (scmdbuf),a ; Clear command buffer ld sp,stack ; Clear stack and fall thru ;----------------------------------------------------------------------- ; ; Wait for and get a command from the console and jump to the ; appropriate routine. ; getcmd: call statchk ; Refresh status line if required ; getcmd0:ld hl,getcmd ; Put return address on the stack push hl ; ld a,(fileout) ; Get file output flag or a ; File output? call nz,wrtrecs ; Yes, write pending text to file jp c,newfile1 ; Quit if directory full ; ; Wait for next command to be entered, then parse it ; getcmd1:call ilprt ; Clear command display area db ' ',cr,0 call nextcmd ; Get next command, filter it ; ld hl,cmdaddr ; Point to command address table call lookup ; If good command, jump to cmd address jp refresh ; If bad command, refresh to avoid ; incomplete display when bad command ; interrupts screen refresh. ;----------------------------------------------------------------------- ; ; Find command in command table and jump to proper command routine ; lookup: push hl ; Save command address pointer dec hl ; Point to command length ld b,0 ld c,(hl) ; BC=command length dec hl ; Point to bottom of command table cpdr ; Scan table backwards pop hl ; Restore command address pointer ret nz ; Quit if no command match ; add hl,bc ; Add cmd offset*2 for cmd address add hl,bc ; HL has command address pointer call hldata ; Get command address in HL pop bc ; Clear stack push af ; Save command call curoff ; Turn cursor off pop af ; Restore command lä (cmd),á » Savå command jp (hl) ; And jump to the proper routine ;====================================================================== ; ; Default WordStar commands, which don't appear in HELP screen ; cmds: db 'J'-40h ; Help screen toggle (alternate) ; ; Next 4 commands are special in that they can't be interrupted by ; pending commands: ; idcmds: db 'W'-40h ; Up one line db 'E'-40h ; Up one line (alternate) db 'Z'-40h ; Down one line db 'X'-40h ; Down one line (alternate) idlen equ $-idcmds ; db 'S'-40h ; Display left db 'D'-40h ; Display right db 'C'-40h ; Down one page db 'R'-40h ; Up one page ; ; Commands automatically included in help screen ; commands: db 'T'-40h ; Top of file db 'F'-40h ; Find string db 'B'-40h ; End of file db 'L'-40h ; Find again cancel: db 'U'-40h ; Cancel command db '<' ; Up one page db '>' ; Down one page db space ; Down one page (alternate) db '/' ; Help screen toggle db '?' ; Help screen toggle (alternate) ; ; Next 4 commands are special in that they can't be interrupted by ; pending commands (the video mode command just happens to be in the ; middle of the 3 up/down line commands): ; idcmds1:db ',' ; Up one line db 'V'-40h ; Video mode toggle (alternate) db '.' ; Down one line db cr ; Down one line (alternate) idlen1 equ $-idcmds1 ; db 'P'-40h ; Printer toggle db bs ; Display left db tab ; Display right db esc ; Exit ; ; Two-command menu prefix commands - parse these first ; db 'O'-40h ; Video mode prefix db 'Q'-40h ; Quick mode prefix db 'K'-40h ; Block mode prefix db $-cmds ; Length of command table ; ; Command routine addresses ; cmdaddr:dw hschk dw lastline dw lastline dw nxtline dw nxtline dw left dw right dw nxtpage dw lastpage ; dw tof dw findstr dw bof dw findagain dw cancelcmd dw lastpage dw nxtpage dw nxtpage dw hschk dw hschk dw lastline dw setvmode dw nxtline dw nxtline dw printt dw left dw right dw exit ; dw modemenu ; ^O dw quickmenu ; ^Q dw blkmenu ; ^K ;----------------------------------------------------------------------- ; ; ^O prefix (Mode) command table ; omenu: db 'D'-40h ; ^OD - toggle video mode db $-omenu ; Length of command table ; ; ^O command routine addresses ; oaddr: dw setvmode ; ^OD ;----------------------------------------------------------------------- ; ; ^Q prefix (Quick) command table ; qmenu: db 'R'-40h ; ^QR - TOF db 'C'-40h ; ^QC - BOF db 'F'-40h ; ^QF - Find String db 'S'-40h ; ^QS - Return to left margin db 'Q'-40h ; ^QQ - Exit db $-qmenu ; Length of command table ; ; ^Q command routine addresses ; qaddr: dw tof ; ^QR dw bof ; ^QC dw findstr ; ^QF dw lmar ; ^QS dw exit ; ^QQ ;----------------------------------------------------------------------- ; ; ^K prefix (Exit) command table ; kmenu: db 'R'-40h ; ^KR - Read in another file db 'W'-40h ; ^KW - Write page to file db 'D'-40h ; ^KD - LBR Exit db 'Q'-40h ; ^KQ - LBR Exit db 'X'-40h ; ^KX - Exit db $-kmenu ; Length of command table ; ; ^K command routine addresses ; kaddr: dw rdfile ; ^KR dw wrtfile ; ^KW dw lbrexit ; ^KD dw lbrexit ; ^KQ dw exit ; ^KX ; ; Help screen titles ; scrnt: db 3 ; Number of messages db 06,15,'DISPLAY COMMANDS',0 db 06,47,'FIND COMMANDS',0 db 11,47,'TOGGLES',0 ; ; Patchable help screen messages ; scrn: db 18 ; Number of messages db 07,10,'Start of File',0 db 07,42,'Find String',0 db 08,10,'End of File',0 db 08,42,'Find Again',0 db 09,42,'Cancel Find',0 db 10,10,'Up One Screen',0 db 11,10,0 ; Down one screen, first alt db 11,11,'Down One Screen',0 db 12,42,0 ; Help/Text, first alt db 12,43,'Help/Text',0 db 13,10,'Up One Line',0 db 13,42,'Video Mode',0 db 14,10,0 ; Down one line, first alt db 14,11,'Down One Line',0 db 14,42,'Printer',0 db 16,10,'Display Left',0 db 17,10,'Display Right',0 db 20,38,0 ; Exit character ; ; Non-patchable help screen commands and messages ; scrnc: db 6 ; Number of messages db 15,42,'KW',0,15,46,'File Output',0 db 17,42,'KR',0,17,46,'Read New File',0 db 19,09,'K0-9',0,19,14,'Set Marker',0 db 19,39,'KD KQ',0,19,46,'EXIT',0 db 20,09,'Q0-9',0,20,14,'Go to Marker',0 db 20,42,'KX',0,20,46,'EXIT',0 ;----------------------------------------------------------------------- ; ; Parse ^O prefix commands ; modemenu: call cmddisp ; Display command and get next ld hl,oaddr ; Point to command address table call lookup ; Match command jp refresh ; Bad command, refresh screen ;----------------------------------------------------------------------- ; ; Parse ^Q prefix commands ; quickmenu: call cmddisp ; Display command and get next ld hl,qaddr ; Point to command address table call lookup ; If no match, check for digit ;----------------------------------------------------------------------- ; ; Find marked block ; Enter with A=ASCII marker number ; blockfind: call chkdig ; Check for digit 0-9 jp c,refresh ; Not digit, refresh screen ; call tblptr ; HL=pointer to correct table entry push af ; Save marker number push hl pop ix ; IX=marker TBUFPTR, high byte ; ld a,(hl) ; Any marker saved? or a jr nz,bfnd0 ; Yes, continue ; bfndun: pop af ; Discard marker number ret ; And quit ; ; Are we already there? ; bfnd0: inc hl ; Point to marker TBUFCRN call hldata ; HL=marker TBUFCRN ld de,(tbufcrn) ; DE=current TBUFCRN call cmphlde jr z,bfnd ; We're already here ; ; Is marker is at TOF? ; ld de,(tofcrn) ; DE=TOFCRN call cmphlde jr nz,bfnd1 ; No, continue ; call fbuf0 ; Fill buffers starting at TOF jr bfnd ; ; Check if marker TBUFPTR was TOB (DBUF0). If not, must be a BOF ; condition. We know low bytes will be the same, so only need to check ; high byte. ; bfnd1: ld b,a ; B=high byte of marker TBUFPTR ld a,(dbuf1+1) ; A=high byte of DBUF1 address cp b ; TOB? jr nz,bfnd2 ; Yes, continue ; call fbuf3 ; No, must be bottom of file, so load it jr bfnd ; and display marked screen ; ; Not bottom of file or current buffer, so refill buffers starting ; with marked TBUFCRN. ; bfnd2: xor a ; Reset flags ld (tofbuf),a ld (bofbuf),a ; ld (tbufcrn),hl ; Save new TBUFCRN ld (fcbcrn),hl ; And FCBCRN call fbufx ; Fill both buffers ; ; Now that the buffer contents are correct, display screen starting at ; marked TOSPTR. ; bfnd: ld l,(ix+3) ; Get TOSPTR for marker ld h,(ix+4) ld (tosptr),hl ; Set it ; ld a,on ; Set to refresh new screen ld (hscrn),a ; pop af ; Restore marker number jr disppm ; Display place marker ;----------------------------------------------------------------------- ; ; Parse ^K prefix commands ; blkmenu:call cmddisp ; Display command and get next ld hl,kaddr ; Point to address table and fall thru call lookup ; If no match, check for digit ;----------------------------------------------------------------------- ; ; Save place marker data ; Enter A=ASCII marker number ; blockmark: call chkdig ; Check for digit 0-9 jp c,refresh ; Not digit, refresh screen ; call tblptr ; HL=pointer to correct table entry ex de,hl ; DE=table pointer ld hl,tbufptr+1 ; Copy current TBUFPTR high byte, plus ld bc,5 ; TBUFCRN, TOSPTR to table ldir ; disppm: add '0' ; Make marker number ASCII ld (plmark),a ; Save it ; ld a,(hscrn) ; Check help screen toggle or a call nz,refresh ; call @xy db 2,1,1 ; Locate, set standout plmark equ $+1 ; Place mark number db '< >',0 ; Marker ret ;----------------------------------------------------------------------- ; ; Include the other modules ; include scan25.0 ; Main code include scan25.1 ; Command argument parsing include scan25.2 ; File name handling include scan25.3 ; Disk i/o, buffer & library routines include scan25.4 ; Console i/o, help screens, status line include scan25.5 ; General utility routines include scan25.6 ; String search routines include scan25.7 ; ZCPR3 VLIB video routines include scan25.8 ; Initialization include scan25.9 ; Data area ; ; end of equate module <> ; ;=======================================================================