home *** CD-ROM | disk | FTP | other *** search
-
- ; * *
- ; * SECTION.ASM *
- ; * v2.0 *
- ; * *
- ; *****************
- ;
- ; 06/27/82 by Ron Fowler, Westland, Michigan
- ; 02/26/84 fixed user specification in section table.
- ; Now requires 2-digit user spec. SFK
- ;
- ;
- ; This program is intended for RCPM systems where
- ; files are grouped into drive/user area by their
- ; classification. This program implements a naming
- ; convention, whereby a caller can move into a
- ; section by typing its name, rather than the random
- ; searching formerly needed.
- ;
- ; Syntax is: SECTION [<section-name>]
- ;
- ; If section-name is omitted, a short list of
- ; available sections is printed. The special
- ; form "SECTION ?" prints the detailed description
- ; of each section.
- ;
- ; You have to fill in the sections table
- ; (located near the end of this program) for your
- ; particular system.
- ;
- ;----< Examples of use: >-----
- ;
- ; A0>SECTION ATARI ;changes drive/user to atari area
- ; B4>SECTION MBASIC ;changes drive/user to mbasic area
- ; A6>SECTION ;prints short list of sections
- ; A9>SECTION ? ;prints the detailed list
- ;
- false equ 0 ;define truth and falsehood
- true equ not false
- ;
- ; the following equates may be
- ; customized to your preference
- ;
- descol equ 10 ;column # where description begins
- ;(in detailed list) (should be greater
- ;than longest section name) (but small
- ;enuf so display is not too long)
- perlin equ 4 ;names printed per line in short list
- tabpos equ 9 ;tab stops (set mod tabpos)
- ;should be at least one greater than
- ;longest section name.
- turbo equ false ;set TRUE if you'er running TurboDOS
- ;
- ; o/s conventions
- ;
- cpbase equ 0 ;set to 4200H for Heath
- ccpdrv equ cpbase+4 ;ccp user/drive storage loc
- bdos equ cpbase+5 ;system entry point
- dfcb equ cpbase+5CH ;default file control block
- dbuf equ cpbase+80H ;default buffer
- tpa equ cpbase+100H ;base of transient program area
- coninf equ 1 ;system call, get console char
- conotf equ 2 ;system call, console output
- printf equ 9 ;system call, print cons string
- cstsf equ 11 ;system call, get console status
- setdrv equ 14 ;system call, set/drive system call
- getdrv equ 25 ;system call, get drive # system call
- gsuser equ 32 ;system call, get/set user number
- ;
- ; character definitions
- ;
- cr equ 13 ;carriage-return code
- lf equ 10 ;linefeed code
- ;
- ; code begins....
- ;
- org tpa
- ;
- ;
- pbase: lxi h,0 ;save system stack
- dad sp
- shld spsave
- ;
- if not turbo
- lxi sp,stack ;load local stack
- mvi c,getdrv ;get current drive #
- call bdos
- push psw ;save it
- sta newdrv ;two ways
- endif
- ;
- call sect ;perform the section function
- ;
- if not turbo ;turbodos doesn't need this stuff
- lda newdrv ;get newly logged drive
- mov b,a ;save for comparison
- pop psw ;get old logged drive
- cmp b ;did logged drive change?
- jnz cpbase ;then relog with warm boot
- endif
- ;
- rst 0
- ;
- ; scan cmd line...if an arg exists, attempt to
- ; match it in the table. If no arg, dump a list
- ; of available sections.
- ;
- sect: lda dfcb+1 ;is there a cmd-line arg?
- cpi ' '
- jz prnqk ;then go print sections out
- cpi '?' ;wants detailed list?
- jz prntbl ;then go do it
- lxi h,dbuf ;something there, scan to it
- scanbk: inx h ; ignoring blanks
- mov a,m
- cpi ' '
- jz scanbk
- lxi d,table ;point de to the section table
- loop: push h ;save cmd line arg pointer
- eloop: ldax d ;test entry against table
- cpi 1 ;end of entry marker?
- jnz noend ;jump if not
- mov a,m ;yes, did user cmd terminate also?
- ora a
- jz match ;then declare a match
- jmp nomat ;else declare a mismatch
- noend: cmp m
- jnz nomat ;skip if no match
- inx h ;continue with comparison
- inx d
- jmp eloop
- ;
- ; here when an entry didn't match
- ;
- nomat: ldax d
- ora a ;entry terminator?
- inx d
- jnz nomat ;scan through it
- pop h ;restore cmd line arg pntr
- inx d ;end of entry, skip over user #
- inx d
- inx d ;and drive
- ldax d ;end of table?
- ora a ;(terminated by 0)
- jnz loop ;go scan another if not
- ;
- ; here when no match can be found
- ;
- lxi d,matmsg ;print out no-match message
- mvi c,printf
- call bdos
- jmp prnqk ;go give short list
- ;
- ; here when a match is found
- ;
- match: xchg ;hl==> user #
- scmat: inx h ;scan past description
- mov a,m ;looking for terminating null
- ora a
- jnz scmat
- inx h ;skip over terminator
- mov a,m ;fetch user #
- sui '0' ;subtract ascii bias
- ;
- ; the following patch allows 2-digit user numbers. it
- ; is the user's responsibility to comply with CP/M
- ; user number conventions.
- ;
- cpi 1
- jnz no10
- mvi a,10
- no10: mov e,a
- inx h
- mov a,m
- sui '0'
- add e
- mov e,a
- inx h ;point hl to drive #
- push d ;save user #
- push h ;and pointer
- mvi c,gsuser ;set user number
- call bdos
- pop h ;restore pointer to drive
- mov a,m ;fetch drive
- sui 'A' ;subtract ascii bias
- sta newdrv ;set new logged drive
- pop d ;restore user number in e
- mov d,a ;save drive #
- mov a,e ;fetch user number
- rlc ;rotate to high nybble
- rlc
- rlc
- rlc
- ora d ;"or" in the drive
- sta ccpdrv ;save for ccp use
- mvi c,setdrv ;...have to set drive explicitly
- mov e,d ;get drive in e
- call bdos ;set the drive
- pop h ;clear garbage from stack
- ret ;all done
- ;
- ; message printed when match failed
- ;
- matmsg: db cr,lf,'++ Entry not found ++'
- db cr,lf,cr,lf,'$'
- matms2: db cr,lf,'Type "SECTION ?" for detailed list'
- db cr,lf,' of available sections.',cr,lf
- db cr,lf,'Type "SECTION <section-name>" to log'
- db cr,lf,' into a particular section.'
- db cr,lf,'$'
- ;
- ; print "quick list"
- ;
- prnqk: lxi d,tblmsg
- mvi c,printf
- call bdos
- lxi h,table ;print abbreviated list
- qloop: mvi b,perlin ;get names-per-line counter
- qloop2: mov a,m ;end of table?
- ora A
- jz qkend ;then go print end msg
- call prathl ;else print the name
- qscan: mov a,m ;scan to description terminator
- inx h ;(this effectively ignores
- ora a ; the description)
- jnz qscan
- inx h ;skip over user #
- inx h
- inx h ;and drive #
- dcr b ;count down line entry counter
- jnz qtab ;go tab if line not full
- call crlf ;else turn up new line
- jmp qloop ;and continue
- ;
- ; tab between entry names
- ;
- qtab: mvi a,' ' ;seperate names with tabs
- call type
- lda column ;get column #
- qsub: sui tabpos ;test tab position
- jz qloop2 ;continue if at a tab position
- jnc qsub ;convert mod tabpos
- jmp qtab ;keep tabbing
- ;
- qkend: call crlf ;do newline
- lxi d,matms2 ;print ending message
- mvi c,printf
- call bdos
- call crlf
- ret
- ;
- ; here to print out a list of available section numbers
- ;
- prntbl: lxi d,tblmsg ;print heading message
- mvi c,printf
- call bdos
- call crlf ;turn up new line
- lxi h,table
- prloop: mov a,m ;end-of-table?
- ora a
- rz ;then all done
- call prathl ;print the name
- tab: mvi a,'.' ;tab over with leader
- call type
- lda column ;get column
- cpi descol ;at description column yet?
- jc tab ;then keep tabbing
- call prathl ;print description
- inx h ;skip over user #
- inx h ;and drive number
- call crlf ;turn up new line
- jmp prloop ;and continue
- ;
- ; print message @hl until null or 01 binary
- ;
- prathl: mov a,m ;fetch char
- inx h ;point past it
- ora a ;null?
- rz ;then done
- cpi 1 ;1 also terminates
- rz
- call type ;nope, print it
- call break ;check for console abort
- jmp prathl
- ;
- ; test for request from console to stop (^C)
- ;
- break: push h ;save 'em all
- push d
- push b
- mvi c,cstsf ;get console sts request
- call bdos
- ora a ;anything waiting?
- jz brback ;exit if not
- mvi c,coninf ;there, is, get it
- call bdos
- cpi 'S'-64 ;got pause request?
- mvi c,coninf
- cz bdos ;then wait for another character
- cpi 'C'-64 ;got abort request?
- jz quit ;then go abort
- brback: pop b ;else restore and return
- pop d
- pop h
- ret
- ;
- ; request from console to abort
- ;
- quit: lxi d,qmesg ;tell of quit
- mvi c,printf
- call bdos
- lhld spsave ;get stack pointer
- sphl
- ret
- ;
- qmesg: db cr,lf,'++ Aborted ++',cr,lf,'$'
- ;
- ; turn up a new line on display
- ;
- crlf: mvi a,cr ;print a return
- call type
- mvi a,lf ;get lf, fall into type
- ;
- ; Routine to print char in A on console,
- ; while maintaining column number.
- ;
- type: push h ;save everybody
- push d
- push b
- mov e,a ;align char for printing
- push psw ;save char
- mvi c,conotf
- call bdos ;print it
- pop psw ;restore char
- lxi h,column ;bump column counter
- cpi lf ;linefeed doesn't chang column
- jz nochg
- inr m
- cpi cr ;carriage-return zeroes it
- jnz nochg ;skip if not cr
- mvi m,0 ;is, zero column
- nochg: pop b ;restore & return
- pop d
- pop h
- ret
- ;
- ; dump heading message
- ;
- tblmsg: db cr,lf,'Available sections are:',cr,lf,'$'
-
- ;
- ;
- ; variables
- ;
- spsave: dw 0 ;stack-pointer save
- column: db 0 ;current column #
- newdrv: db 0 ;new drive # to log
- ds 20 ;the stack
- ;
- stack equ $ ;define it
- ;
- ;
- ;
- ;
- ; SECTIONS TABLE (located at end for easy patching with DDT)
- ;
- ; This is the table that defines the sections. Entry format is:
- ;
- ; <name>,sep,<description>,null,user,drive
- ;
- ; where <name> is the section name
- ; sep is a binary 1 used to terminate the match test
- ; <description> is a one-line-or-less comment printed when
- ; the list is dumped. Match testing terminates
- ; before this field.
- ; null is a binary 0 used to terminate the description
- ; user is the user number (00-15) of the section (ascii)
- ; drive is the drive (A-P) number of the section (ascii)
- ;
- ; the table ends with a <name> of zero (binary).
- ;
- ; Note: be sure to make section names ALL-CAPS, because the
- ; CCP converts command-line arguments to capitals. The
- ; description may be in lower case, since it has nothing
- ; to do with the matching process.
- ; Also: although the drive and user # is in ascii (for convenience
- ; in setting up the table), be sure to use caps for the
- ; drive designation. No error checking is done on the values.
- ;
- table: db 'SYSTEM',1,'System and Help',0
- db '00A' ;user 0, drive A
- ;
- db 'HELP',1,'HELP files',0
- db '01A' ;user 1, drive A
- ;
- db 'UTIL1',1,'Misc. utilities',0
- db '02A' ;user 2, drive A
- ;
- db 'MISC1',1,'Miscellaneous',0
- db '03A' ;user 3, drive A
- ;
- db 'MODEMS',1,'Modem transfer pgms (NOT MDM7)',0
- db '04A' ;user 4, drive A
- ;
- db 'NSTAR',1,'North Star files',0
- db '00B' ;user 0, drive B
- ;
- db 'RCPM',1,'Remote CP/M system software',0
- db '01B' ;user 6, drive A
- ;
- db 'LANG',1,'Programming languages',0
- db '02B' ;user 7, drive A
- ;
- db 'DIRS',1,'Directory utilities',0
- db '03B' ;user 8, drive A
- ;
- db 'MISC2',1,'Misc. files',0
- db '04B' ;user 9, drive A
- ;
- db 'MISC3',1,'Misc. files',0
- db '00C' ;user 0 drive B
- ;
- db 'SQ/USQ',1,'ASM versions of SQ,USQ etc',0
- db '01C' ;user 1, drive B
- ;
- db 'HAMS',1,'Ham radio files',0
- db '02C' ;user 2, drive B
- ;
- db 'ADVENT',1,'Adventure',0
- db '03C' ;user 3, drive B
- ;
- db 'PICTURE',1,'Printer art',0
- db '04C' ;user 4, drive B
- ;
- db 'SYSLIB',1,'Rick Conn''s SYSLIB files',0
- db '00D' ;user 5, drive B
- ;
- db 'BDSC',1,'BDS C source files',0
- db '01D'
- ;
- db 'CPM86',1,'CP/M 86 files',0
- db '02D'
- ;
- db 'IBMPC',1,'Files for the IBM PC',0
- db '03D'
- ;
- db 'TEXT',1,'Editors, text processors',0
- db '04D' ;user 2, drive C
- ;
- db 'NEWSTUFF',1,'New files (uploads)',0
- db '00E' ;user 3, drive C
- ;
- db 'DISKUTL',1,'Disk utilities',0
- db '01E' ;user 2, drive C
- ;
- db 'CPM+',1,'CP/M plus files',0
- db '02E' ;user 2, drive C
- ;
- db 'ZCPR2-I',1,'ZCPR2 files I',0
- db '03E' ;user 2, drive C
- ;
- db 'UTIL2',1,'Utilities',0
- db '04E' ;user 2, drive C
- ;
- db 'MDM7',1,'MDM7 files',0
- db '00F' ;user 2, drive C
- ;
- db 'FORTRAN',1,'F80 files',0
- db '01F' ;user 2, drive C
- ;
- db 'MODULES',1,'Linkable modules for M80/RMAC',0
- db '02F' ;user 2, drive C
- ;
- db 'ZCPR2-II',1,'All ZCPR2 files (less HELP)',0
- db '03F' ;user 2, drive C
- ;
- db 'BASIC',1,'What can I say...',0
- db '04F' ;user 2, drive C
- ;
- db 0 ;<<== end of table
- ;
- ; -----< end of SECTIONS table>-----
- ;
- end pbase ;that's all.