home *** CD-ROM | disk | FTP | other *** search
- ;===========================================================================
- ;
- ; VFMACRO.Z80
- ;
- ;===========================================================================
-
- ; CMACRO - Process Macro Command
-
- noteflag:
- db 0 ; Place to keep track of whether macro help
- ; screen has been displayed
-
- cmacro:
- push af
- xor a ; Clear macro help screen flag
- ld (noteflag),a
- pop af
- cmacro1:
- push af ; Save macro command
- ld hl,macfcb ; Set up name of macro file
- ld de,s$fcb ; (typically vfiler.cmd)
- ld b,12 ; 12 chars
- call moveb
- call initfcb ; Init fcb
- ld a,0ffh ; Search current directory
- call pfind ; And along path for macro command file
- jr nz,cmfound ; Macro command file found!
-
- ; Error - Macro command file not found.
-
- call erclr ; Position cursor on message line
- ld hl,macfcb+1
- call prfnskip ; Print macro command file name.
- call vprint
- db ' NOT Found',0
- jp loop
-
- ; Ok - Found macro command file.
- ; Now find definition of this macro.
-
- cmfound:
- call logud ; Log in du: where command file was found.
- call fi0$close ; Close input file if previously opened
- ld de,s$fcb ; Pt to fcb
- call fi0$open ; Open for byte-oriented input
- pop af ; Get command
- ld c,a ; In c
-
- ; Search for macro definition
-
- cmfl1:
- call f0$get ; Get first char of line
- jp nz,cmflerr ; Eof encountered - no definition.
- and 7fh ; Mask char
- call caps ; Force upper case
- cp c ; Match?
- jr z,cmfl3 ; Br if so.
-
- ; No match. Skip remainder of this line.
-
- cmfl2:
- call f0$get ; Skip out line
- jp nz,cmflerr ; Eof encountered - no definition.
- and 7fh ; Mask char
- cp lf ; Eol?
- jr nz,cmfl2
- jr cmfl1 ; Try next line.
-
- ; Found command
- ; - If Macro note, print built-in documentation (if any)
- ; - For normal command, build up command and execute it.
-
- cmfl3:
- ld a,mnote ; Macro note?
- cp c
- jp z,cmflnote ; Br if so.
-
- ; Skip leading blanks in command line
-
- ld hl,(bufstart) ; Pt to first char of macro command line buffer.
- cmfl4:
- call f0$get ; Get next char
- jr nz,cmfl6 ; Eof? mark end of buffer and go
- and 7fh ; Mask char
- cp ' ' ; Skip leading blanks
- jr z,cmfl4
-
- ; Test for shell wait command (!)
-
- cp fpwait
- jr nz,cmfl5 ; If not wait command, go on
- ld a,0ffh
- ld (shwait),a
- jr cmfl4 ; Back for next character
-
- ; Build command line in buffer
-
- cmfl5:
- cp cr ; Eol?
- jr z,cmfl6 ; Mark end of buffer and go
- cp eof ; Eof?
- jr z,cmfl6 ; Mark end of buffer and go
-
- cp fpesc ; File-pointed escape char (%)
- jp z,cmflix ; Insert parameter info in buffer if so.
-
- cp uin1 ; Start user input prompt?
- jr z,cmfl5a ; Prompt user and get response.
- cp uin2 ; Alternate start user input prompt?
- jr z,cmfl5a ; Prompt user and get response.
-
- cmfl50:
- ld (hl),a ; Store ordinary command char.
- inc hl ; Pt to next
- cmfl51:
- call f0$get ; Get next char
- jr nz,cmfl6 ; Eof? mark end of buffer and go
- and 7fh ; Mask char
- jr cmfl5 ; Try next char.
-
- ; User input required - print prompt and get it
-
- cmfl5a:
- push hl ; Save current buffer ptr
- call atcmd ; Pos'n cursor at command prompt line
-
- cmfl5b:
- call f0$get ; Get next char of prompt.
- jr nz,cmfl5b1 ; Eof? get eof, and then user response.
- and 7fh ; Mask char
- cp uin1 ; Input prompt terminated?
- jr z,cmfl5c ; Ok. now get response for this one.
- cp uin2 ; Alternate input prompt terminated?
- jr z,cmfl5c ; Ok. now get response for this one.
-
- cp cr ; End of line forces end of prompt?
- jr z,cmfl5c ; Ok. now get response.
- cp eof ; Eof?
- jr z,cmfl5c ; Ok. now get response.
- call cout ; Display prompt character and continue.
- jr cmfl5b
-
- cmfl5b1:
- ld a,eof ; Eof
- cmfl5c:
- push af ; Save offending char
- call getzcmd ; Get command line (up to 253 chars).
- pop af ; Restore char
- pop de ; De pts to next char pos'n in command buffer
- ld b,a ; Save terminating char in b
-
- cmfl5d:
- ld a,(hl) ; Copy chars until
- or a ; Zero string terminator.
- jr z,cmfl5e
- ld (de),a ; Save char
- inc hl ; Pt to next
- inc de
- jr cmfl5d
-
- cmfl5e:
- ex de,hl ; Hl pts to next char in buffer
- ld a,b ; Check offending char
- cp uin1 ; End of prompt for user input?
- jr z,cmfl51 ; Ok. get next char and continue with command.
- cp uin2 ; Alternate end of prompt for user input?
- jr z,cmfl51 ; Ok. get next char and continue with command.
- jr cmfl5 ; No, check it out.
-
- ; Terminate command buffer and test for content
-
- cmfl6:
- ld (hl),0 ; Store ending 0
- ld hl,(bufstart) ; Pt to first char of macro command.
- ld a,(hl) ; Get first char
- or a ; Empty?
- jr z,cmflerr ; Br if invalid.
-
- ; Command line seems ok. Try to chain
-
- ld bc,(du$req) ; Get current du
- call logud ; And set it up.
- call chain ; Chain to command line pted to by hl
- jp loop
-
-
- ; CMFLERR - Error return - null command line <or> command not defined.
-
- cmflerr:
- push bc ; Save command char.
- ld bc,(du$req) ; Get current du
- call logud ; And set it up.
- pop bc
- ld a,c ; Get invalid command
- ret
-
-
- ; CMFLNOTE - Print documentation built into the macro file
-
- cmflnote:
- ld a,0ffh ; Set flag to show note screen drawn
- ld (noteflag),a
- call vcls ; New screen
- if exptab
- ld c,0 ; Set tab counter
- endif
-
- cmfln1:
- call f0$get ; Get next char
- jr nz,cmfln4 ; Eof? documentation complete.
- and 7fh ; Mask char
- cp eof ; Eof?
- jr z,cmfln4 ; Documentation complete.
-
- if exptab
- cp tab ; Tab process
- jr z,cmfln2
- cp bright ; Enhanced video indicator?
- jr nz,cmfln1a
- call stndout ; Turn it on
- jr cmfln1 ; Back for next character
- cmfln1a:
- cp dim ; Normal video indicator?
- jr nz,cmfln1b
- call stndend ; Turn it off
- jr cmfln1 ; Back for next character
- cmfln1b:
- call cout ; Print character.
- cp cr ; New line?
- jr z,cmfln3
- inc c ; New pos
- cp lf
- jr nz,cmfln1
- dec c ; Back up position count
- jr cmfln1
-
- cmfln2:
- ld a,' ' ; Space over for tab
- call cout
- inc c ; Incr position
- ld a,c ; Done?
- and 7 ; Every 8
- jr nz,cmfln2
- jr cmfln1
-
- cmfln3:
- ld c,0 ; Beg-of-line for cr
- jr cmfln1
-
- else ; No tab expansion
-
- cp bright ; Bright video indicator?
- jr nz,cmfln3a
- call stndend ; Turn off dim mode
- jr cmfln1 ; Back for next character
- cmfln3a:
- cp dim ; Dim video indicator?
- jr nz,cmfln3b
- call stndout ; Turn it on
- jr cmfln1 ; Back for next character
- cmfln3b:
- call cout ; Print character.
- jr cmfln1 ; Get next..
- endif
-
- cmfln4:
- call vprint
- db 'File Name : ',0
- ld bc,(du$req) ; Get current du
- call logud ; And set it up.
- ld hl,(ringpos) ; Print current file
- inc hl
- call prfnskip
- call vprint
- db cr,lf,lf,'Enter Macro Choice or RETURN - ',0
- call dkeyin
- call caps
- call cout ; Echo choice
- pop de ; Get ret address
- cp ' ' + 1 ; If control character or space, return
- jp c,runsh4a
- push de ; Replace ret address
- jp cmacro1 ; Try again.
-
-
- ; CMFLIX - Insert parameter info for file pted to (% prefix command)
-
- cmflix:
- call f0$get ; Get next char
- jp nz,cmfl6 ; Eof? mark end of buffer and go
- and 7fh ; Mask char
- call caps ; Capitalize
- ld b,a ; Save char in B
- ex de,hl ; Save buffer pointer in DE
-
- ld hl,cmfl51 ; Push return address
- push hl ; on stack
- ld hl,ptable ; Point to parameter vector table
-
- cmflix1:
- ld a,(hl) ; Read char from jump table
- inc hl ; Point to jump vector
- or a ; See if end of table
- jr z,cmflich ; If so, store the character
- cp b ; Does it match the char from file?
- jr z,cmflix2 ; If so, jump
- inc hl ; Else, point to next entry
- inc hl
- jr cmflix1
-
- cmflix2: ; We have a match
- ld a,(hl) ; Get low byte of address
- inc hl
- ld h,(hl) ; Get high byte of address
- ld l,a
- push hl ; Push jump address onto stack
- ex de,hl ; Restore HL to point to buffer
- ret
-
- ptable: ; Parameter table
-
- db fpptr ; Complete file spec (du:fn.ft)
- dw cmflia
-
- db fpptr1 ; Complete file spec (alternate)
- dw cmflia
-
- db fpdisk ; Current disk
- dw cmflifd
-
- db fpuser ; Current user
- dw cmflifu
-
- db fpfile ; File name and type
- dw cmfliff
-
- db fpname ; File name
- dw cmflifn
-
- db fptype ; File type
- dw cmflift
-
- db fphdu ; Home directory in DU form
- dw cmflifh
-
- db fphdir ; Home directory in DIR form
- dw cmflifr
-
- db fpcdir ; Current DIR
- dw cmflifc
-
- db 0 ; End of table marker
-
-
- ;---------- Store the character after the '%'
-
- cmflich:
- ex de,hl
- ld (hl),b
- ret
-
- ;---------- Build full file spec (DU:FN.FT)
-
- cmflia:
- call cmflifd ; Get disk
- call cmflifu ; Get user
- ld (hl),':' ; Du separator
- inc hl ; Fall thru to file name.type
-
- ;---------- Build file name and type
-
- cmfliff:
- call ringchk ; Check for empty ring
- ret z ; If empty, write nothing
- call cmflifn ; Get file name
- ld (hl),'.' ; Name.type separator
- inc hl ; Fall thru to file type
-
- ;---------- Build file type
-
- cmflift:
- call ringchk ; Check for empty ring
- ret z ; If empty, write nothing
- ex de,hl ; Save ptr to next char.
- ld hl,(ringpos) ; Pt to current file
- ld bc,9 ; Type
- add hl,bc
- ld b,3 ; 3 chars in filetype
- call cmfl5x
- ex de,hl ; Hl pts to next
- ret
-
- ;---------- Build file name
-
- cmflifn:
- call ringchk ; Check for empty ring
- ret z ; If empty, write nothing
- ex de,hl ; Save ptr to next char.
- ld hl,(ringpos) ; Pt to current file
- inc hl
- ld b,8 ; 8 chars in filename
- call cmfl5x
- ex de,hl ; Hl pts to next
- ret
-
- ;---------- Build currect directory in DIR form
-
- cmflifc:
- ld bc,(du$req) ; Get current du:
- cmflifc0:
- ex de,hl ; Save ptr to next char.
- call dutdir ; Scan named directory table.
- jr nz,cmflc1 ; Br if resolved.
- ld hl,nodir ; Use 'noname'.
- cmflc1:
- ld b,8 ; Maximum dir length
- ex de,hl ; Hl pts to next
- cmflc2:
- ld a,(de) ; Get character.
- cp ' ' ; Done if space encountered.
- ret z
- ld (hl),a ; Save character
- inc hl ; Pt to next char
- inc de
- djnz cmflc2 ; Loop until end or blank.
- ret
-
- ;---------- Build current drive letter
-
- cmflifd:
- ld a,(du$req+1) ; Get current drive.
- cmflifd0:
- add a,'A' ; Make it ascii
- ld (hl),a
- inc hl ; Pt to next char
- ret
-
- ;---------- Build current user number
-
- cmflifu:
- ld a,(du$req) ; Get current user.
- cmflifu0:
- cp 10 ; Less than 10?
- jr c,cmflifu3
- ld b,'0' ; Compute 10's
- cmflifu1:
- sub 10 ; Subtract 10's
- jr c,cmflifu2
- inc b
- jr cmflifu1
- cmflifu2:
- add a,10
- ld (hl),b ; Store 10's
- inc hl
- cmflifu3:
- add a,'0' ; Store 1's
- ld (hl),a
- inc hl
- ret
-
- ;---------- Build home directory in DIR form
-
- cmflifr:
- ld bc,(du$orig)
- jr cmflifc0
-
- ;---------- Build home directory in DU form
-
- cmflifh:
- ld a,(du$orig+1) ; Drive first
- call cmflifd0
- ld a,(du$orig) ; Then user
- jr cmflifu0
-
-
- ringchk: ; Check for empty ring
- push hl
- ld hl,(ringcnt) ; Get count of files in ring
- ld a,h
- or l
- pop hl
- ret ; Z if ring empty
-
-
- ; CMFL5X - Copy string into command line until ' '.
-
- cmfl5x: ld a,(hl) ; Get char
- cp ' '
- jr z,cmfl5x1
- ld (de),a ; Put char
- inc hl ; Pt to next char
- inc de
- djnz cmfl5x
- ret
-
- cmfl5x1:
- inc hl ; Advance
- djnz cmfl5x1
- ret
-