home *** CD-ROM | disk | FTP | other *** search
- ; PROGRAM: ACMDUTL
- ; AUTHOR: Paul Pomerleau
- ; VERSION: 1.1
- ; DATE: 30 September 85
- VERS equ 11
- Z3ENV set 0f300h
-
- ; ACMDUTIL allows quick access to an ARUNZ alias file.
- ; It was written to eliminate the need to use a word processor
- ; on ALIAS.CMD. Ideally, the ALIAS.CMD file should be created
- ; by ACMDUTIL as this would produce an alphabetically sorted
- ; list.
- ; ACMDUTIL looks for ALIAS.CMD in the named directory
- ; specified by the string at DIRNAME (typically the ALIAS.CMD
- ; file is kept in base) so change it if you want to look for
- ; ALIAS.CMD in ROOT: for example.
-
- ext fi0$open, f0$get ; SYSLIB
- ext fo0$open, fo0$close, f0$put
- ext f$delete, f$rename
- ext subhd, instr, compb, bbline, print
- ext cout, bios, caps, getud, putud, sknsp
- ext z3init, dirndr, z3log ; Z3LIB
-
- ASEG
- .z80
-
- True equ 1
- False equ not True
- Linefeed equ 0ah
- Carriage equ 0dh
- CLINE equ 80h
- FCB1 equ 5ch
- FCB2 equ 6ch
-
- Drive equ 1
- User equ 0
- org 100h
-
- ;
- ; Environment Definition
- ;
- if Z3ENV ne 0
- ;
- ; External ZCPR3 Environment Descriptor
- ;
- jp START
- db 'Z3ENV' ;This is a ZCPR3 Utility
- db 1 ;External Environment Descriptor
- Z3EADR:
- dw Z3ENV
- START:
- ld hl,(Z3EADR) ;pt to ZCPR3 environment
- ;
- else
- ;
- ; Internal ZCPR3 Environment Descriptor
- ;
- MACLIB Z3BASE.LIB
- MACLIB SYSENV.LIB
- Z3EADR:
- jp START
- SYSENV
- START:
- ld hl,Z3EADR ;pt to ZCPR3 environment
- endif
- ;
- ; Start of Program
- ;
-
- call Z3INIT
- call PUTUD
- call PRINT
- db 'ACMDUTIL, Version ',(VERS / 10) + '0','.',(VERS mod 10) + '0',13,10,0
- ld a,(CLINE)
- or a
- jp z,NOTHELP
- ld a,(82h)
- cp '/'
- jp nz,NOTHELP
- call PRINT
- db 'A fast little ALIAS.CMD utility which displays, adds and '
- db 'deletes aliases.',13,10,13,10
- db 'Command line:',13,10
- db ' ACMDUTIL [DU:] [Alias name to display] <ret>',13,10
- db 'At the colon:',13,10
- db ' Name of alias <space> Alias text <ret> -- Creates an alias.',13,10
- db ' Name of alias <ret> -- Deletes an alias.',0
- ret
- NOTHELP:
- ld hl,FCB1 + 1
- ld a,(hl)
- cp ' '
- jr nz,ATODISP
- ld a,0ffh
- ld (DONTBASE),a
- ld a,(FCB1)
- ld (IFCB),a
- ld a,(FCB1 + 13)
- ld (IFCB + 13),a
- ld hl,FCB2 + 1
- ld a,(hl)
- cp ' '
- jp z,DOIT
- ATODISP:
- ld (APLACE + 1),hl
- call SKNSP
- ld (hl),0
- ld hl,LINEALIAS
- ld (ALIASCALL + 1),hl
- ld a,0ffh
- ld (NOWRITE),a
- call PRINT
- db 'Searching...',13,10,0
- DOIT:
- ld a,(DONTBASE)
- or a
- jr nz,NOBASE
- ld hl,DIRNAME
- call DIRNDR
- jr z,NOBASE
- ld a,b
- ld (IFCB),a
- ld (OFCB),a
- ld a,c
- ld (IFCB + 13),a
- ld (OFCB + 13),a
- NOBASE: ld de,IFCB
- call Z3LOG ; Log drive and user of FCB
- ld de,IFCB
- call FI0$OPEN
- ld de,OFCB
- ld a,(NOWRITE)
- or a
- call z,FO0$OPEN
- ALIASCALL:
- call GETALIAS
- COPYLOOP:
- call READLN
- call COMPARE
- jr nz,NOTSAME
- call SHOW
- ld a,(NOWRITE)
- or a
- jr nz,SAME
- call PRINT
- db 'Delete? (Y for yes) ',0
- GETC: ld a,3
- call BIOS
- cp ' '
- jr c,GETC
- call CAPS
- call COUT
- cp 'Y'
- jr z,COPY
- call WRITELN
- jr SAME
- COPY: call WRITEOURS
- jr SAME
- NOTSAME:
- call c,WRITEOURS
- call WRITELN
- SAME: xor a
- ld (BUFFER),a
- ld a,(EOFFLAG)
- or a
- jr z,COPYLOOP
- call WRITEOURS
- ld a,(NOWRITE)
- or a
- jr nz,DONE
- call FO0$CLOSE
- ld de,IFCB
- call F$DELETE
- ld hl,IFCB
- ld de,OFCB
- call F$RENAME
- DONE: ld a,(SHOWED)
- or a
- jr nz,WASTHERE
- ld a,(NOWRITE)
- or a
- jr z,WASTHERE
- call PRINT
- db 'No Alias Of That Name.',13,10,0
- WASTHERE:
- call GETUD
- ret
-
- LINEALIAS:
- APLACE: ld hl,0000
- jr GLEAN
- GETALIAS:
- call PRINT
- db ': ',0
- ld a,0ffh
- call BBLINE
- GLEAN: ld de,OURS
- ld a,(hl)
- GETLOOP:
- ld (de),a
- inc hl
- inc de
- ld a,(hl)
- or a
- jr nz,GETLOOP
- push de
- ld a,Carriage
- ld (de),a
- inc de
- ld a,Linefeed
- ld (de),a
- call COUT
- ld hl,OURS
- ld de,SPACE
- call INSTR
- pop de
- ret z
- ld a,' '
- ld (de),a
- ld a,0ffh
- ld (WRITFLAG),a
- ret
-
- WRITEOURS:
- ld de,BUFFER
- ld a,(NOWRITE)
- or a
- ret nz
- ld a,(WRITFLAG)
- or a
- ret nz
- cpl
- ld (WRITFLAG),a
- ld b,0ffh
- ld de,OURS
- jp WRITELOOP
-
- READLN:
- xor a
- ld (QUOTE),a
- ld b,0ffh
- ld de,BUFFER
- READLOOP:
- call F0$GET
- jr z,GOOD
- DONEREAD:
- ld hl,EOFFLAG
- xor a
- ld (de),a
- ld (hl),0ffh
- ret
- GOOD: cp '"'
- jr nz,NOTQUOTE
- ex af,af'
- ld a,(QUOTE)
- cpl
- ld (QUOTE),a
- ex af,af'
- NOTQUOTE:
- cp ';'
- jr nz,NOTSEMI
- ex af,af'
- xor a
- ld (QUOTE),a
- ex af,af'
- NOTSEMI:
- cp 1ah
- jr z,DONEREAD
- ex af,af'
- ld a,(QUOTE)
- or a
- jr nz,SKIPCAP
- ex af,af'
- call CAPS
- ex af,af'
- SKIPCAP:
- ex af,af'
- ld (de),a
- inc de
- cp Linefeed
- ret z
- djnz READLOOP
- ret
-
- WRITELN:
- ld b,0ffh
- ld de,BUFFER
- ld a,(NOWRITE)
- or a
- ret nz
- WRITELOOP:
- ld a,(de)
- or a
- ret z
- inc de
- call F0$PUT
- jr nz,WRITEERR
- cp Linefeed
- ret z
- djnz WRITELOOP
- ret
-
- COMPARE:
- call FINDSPACE
- ld b,a
- ld de,BUFFER
- ld hl,OURS
- jp COMPB
-
- FINDSPACE:
- ld hl,BUFFER
- ld de,SPACE
- call INSTR
- ld de,BUFFER
- call SUBHD
- ld a,l
- ret
-
- SHOW:
- ld a,0ffh
- ld (SHOWED),a
- ld hl,BUFFER
- ld b,0ffh
- SHOWLOOP:
- ld a,(hl)
- call COUT
- cp Linefeed
- jr z,SHOWSUB
- inc hl
- djnz SHOWLOOP
- SHOWSUB:
- ret
-
- WRITEERR:
- pop hl
- call PRINT
- db 'Write Error.',0
- jp DONE
-
- WRITFLAG:
- db 0
- DONTBASE:
- db 0
- NOWRITE:
- db 0
- EOFFLAG:
- db 0
- QUOTE: db 0
- SHOWED: db 0
- DIRNAME:
- db 'BASE '
- IFCB:
- db Drive,'ALIAS CMD',0,User
- db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
- OFCB:
- db Drive,'ALIAS $$$',0,User
- db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
- SPACE: db ' ',0
- BUFFER equ SPACE + 1000h ; 4k of externals allowed for
- OURS equ BUFFER + 0ffh
- end
- ADLOOP
- ret
-
- WRITELN:
- ld b,0ffh
- ld de,BUFFER
-