home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
CPM
/
PACKET
/
RLI120.ARK
/
TNC.LIB
< prev
next >
Wrap
Text File
|
1987-05-11
|
8KB
|
495 lines
;; TNC.LIB - 5/11/87 - Macros to deal with TAPR TNC.
;; Addresses where the time and tick counter kept.
timdef macro
timer equ 48h
sec equ 4ah
min equ 4bh
hr equ 4ch
day equ 4dh
mo equ 4eh
yr equ 4fh
endm
tncdefs macro
false equ 0
true equ not false
btime equ 1 ;; True during busy hours
qtime equ 2 ;; True during quiet (non-busy) hours
convtim equ 2 ;; Sec wait for converse mode
linktim equ 3 ;; Seconds wait before send link msg
cmdmax equ 255 ;; Max length of text string
iobyte equ 3 ;; IOBYTE address
;; Command type seen from TNC.
cdata equ 0 ;; String was data
cdiscmd equ 2 ;; Was *** DISCONNECTED
ctimcmd equ 3 ;; Nothing seen by timeout time
cnull equ 1 ;; Was a trailing LF (from CR,LF)
;; User modes.
lmode equ 1 ;; Local
gmode equ 2 ;; GateWay
smode equ 4 ;; Sysop
umode equ 8 ;; Normal user
;; Misc constants.
fcbsize equ 36 ;; File control block size
secsize equ 128 ;; Disc sector size
bufsize equ 16 ;; Sectors in file buffer.
linkcmd equ 'W'-40h ;; ^W = Escape from link
eof equ 'Z'-40h ;; ^Z = End of file
;; Values for iobyte.
ciob equ 0 ;; Console (TTY:)
raiob equ 1 ;; TNC on comm port (CRT:)
rbiob equ 2 ;; TNC on printer port (BAT:)
endm
;; Switch to local console.
console macro
mvim iobyte,ciob
endm
;; Switch console to master TNC
master macro
movb iobyte,mtnc
endm
;; Switch console to slave TNC
slave macro
movb iobyte,stnc
endm
asciictl macro
null equ 0
soh equ 1
stx equ 2
etx equ 3
eot equ 4
enq equ 5
ack equ 6
bel equ 7
bell equ 7
bs equ 8
ht equ 9
tab equ 9
lf equ 0ah
vt equ 0bh
ff equ 0ch
cr equ 0dh
so equ 0eh
si equ 0fh
dle equ 10h
dc1 equ 11h
dc2 equ 12h
dc3 equ 13h
dc4 equ 14h
nak equ 15h
syn equ 16h
etb equ 17h
can equ 18h
em equ 19h
subb equ 1ah
esc equ 1bh
fs equ 1ch
gs equ 1dh
rs equ 1eh
us equ 1fh
del equ 7fh
endm
;; Wait number of seconds in call argument.
;; No registers altered.
wait macro ?m
push hl
lxim timer,?m
call @wait
pop hl
endm
;; BDOS call codes, fixed address locations, etc.
dodosa macro func,addr
if not nul func
ld c,func
endif
if not nul addr
ld de,addr
endif
call dosent
endm
dodosv macro func,val
if not nul func
ld c,func
endif
if not nul val
ld a,(val)
ld e,a
endif
call dosent
endm
bdosdef macro
defdma equ 80h ;; Default disk buffer.
wboot equ 0 ;; Reboot jump address
dosent equ 5 ;; BDOS entry point
dfcb1 equ 5ch
dfcb2 equ 6ch
;; BDOS function codes.
reboot equ 0 ;; Terminate program
dconin equ 1 ;; Get character from console.
dconout equ 2 ;; Put character to console.
reader equ 3 ;; Get character from reader.
punch equ 4 ;; Put character to punch.
list equ 5 ;; Put character to list device.
getio equ 7 ;; Get iobyte.
setio equ 8 ;; Set iobyte.
bufout equ 9 ;; Put string to console.
bufin equ 10 ;; Get string from console.
dconst equ 11 ;; Get console status.
getver equ 12 ;; Get CP/M version
reset equ 13 ;; Reset disk system.
seldsk equ 14 ;; Select drive.
open equ 15 ;; Open file.
close equ 16 ;; Close file.
search equ 17 ;; Search for file.
next equ 18 ;; Get next file.
delete equ 19 ;; Delete file.
read equ 20 ;; Sequential disk read.
write equ 21 ;; Sequential disk write.
make equ 22 ;; Make file.
rename equ 23 ;; Rename file.
ckdsks equ 24 ;; Get drives on line vector.
ckcur equ 25 ;; Get current drive.
setdma equ 26 ;; Set disk I/O transfer address.
getalv equ 27 ;; Get allocation vector
getro equ 29 ;; Get read only vector
setatr equ 30 ;; Set file attributes
getdpb equ 31 ;; Return dpb pointer
sguser equ 32 ;; Set/Get user code
rrec equ 33 ;; Read random
wrec equ 34 ;; Write random
getend equ 35 ;; Return file end address
endm
ntobuf macro adr,ct
if not nul adr
ld hl,adr
endif
if not nul ct
ld b,ct
endif
call @ntobuf
endm
ctobuf macro adr
if not nul adr
ld hl,adr
endif
call @ctobuf
endm
openr macro cb
if not nul cb
ld hl,cb
ld de,rfcb
ld bc,fcbsize
ldir
endif
call @openr
endm
openw macro cb
if not nul cb
ld hl,cb
ld de,wfcb
ld bc,fcbsize
ldir
endif
call @openw
endm
opena macro cb
if not nul cb
ld hl,cb
ld de,wfcb
ld bc,fcbsize
ldir
endif
call @opena
endm
openwn macro cb
if not nul cb
ld hl,cb
ld de,wfcb
ld bc,fcbsize
ldir
endif
call @openn
endm
closew macro
call @closew
endm
;; Check cmd for type of string received:
;; null - either a single LF or a connect request.
;; disco - it was *** DISCONNECTED
;; tout - Timed out before getting any data.
ckcmd macro none,disco,tout
dec a
jp z,none
dec a
jp z,disco
dec a
jp z,tout
endm
retz macro
xor a
ret
endm
retnz macro
xor a
inc a
ret
endm
ckname macro addr
ld hl,addr
call ckname
endm
upper macro addr,len
if not nul addr
ld hl,addr
endif
if not nul len
ld c,len
endif
call @upper
endm
cmpm macro addr,dat
ld a,(addr)
cp dat
endm
comp macro fir,sec,nr
if not nul fir
ld hl,fir
endif
if not nul sec
ld de,sec
endif
if not nul nr
ld c,nr
endif
call @cmp
endm
compwc macro fir,sec,nr
if not nul fir
ld hl,fir
endif
if not nul sec
ld de,sec
endif
if not nul nr
ld c,nr
endif
call @cmpwc
endm
cmpcmd macro @t,@l
ld de,@t
ld c,@l
call @cmpcmd
endm
;; Create and clear a list.
maklst macro @l,@n,@w,@c
ld de,(@n) ;; # items on list
ld c,@w ;; Bytes / item
call muldec ;; Bytes in the list
ld hl,($memry) ;; First byte avail in pool memory
ld (@l),hl ;; Is start of list
add hl,de
ld ($memry),hl ;; New first byte of pool memory
ld hl,(@l) ;; Start of list
ld b,d
ld c,e ;; (BC) = bytes in list
ld e,@c ;; Char to clear with
call @fill ;; Clear the list
endm
;; Search a list.
srclst macro @t,@l,@n,@w,@c
push hl
lxim @srct,@t ;; Address of target string
movw @srcl,@l ;; Address of list
movw @srcn,@n ;; # items in list
lxim @srcw,@w ;; # bytes/item
lxim @srcc,@c ;; # bytes to compare
xor a ;; Zero says no wild cards
call @src
pop hl
endm
;; Search a list with wild cards
srclsw macro @t,@l,@n,@w,@c
push hl
lxim @srct,@t ;; Address of target string
movw @srcl,@l ;; Address of list
movw @srcn,@n ;; # items in list
lxim @srcw,@w ;; # bytes/item
lxim @srcc,@c ;; # bytes to compare
xor a ;; Non-zero says allow wild cards
inc a
call @src
pop hl
endm
;; Add item to a list.
addlst macro @t,@l,@n,@m,@w,@c
lxim @adlt,@t
movw @adll,@l
movw @adln,@n
movw @adlm,@m
lxim @adlw,@w
lxim @adlc,@c
call @adl
movw @n,@adln
endm
;; Return (HL) pointing to oldest item, remove item.
;; Return zero cleared if no items.
sublst macro @l,@n,@w
movw @adll,@l
movw @adln,@n
lxim @adlw,@w
call @slst
movw @n,@adln
endm
prtx macro adr
if not nul adr
ld hl,(adr)
endif
call @prtx
endm
docmd macro addr
ld hl,(addr)
call @docmd
endm
dtz macro addr
ld hl,(addr)
ld a,l
or h
endm
dcxm macro addr
ld hl,(addr)
dec hl
ld (addr),hl
endm
inxm macro addr
ld hl,(addr)
inc hl
ld (addr),hl
endm
movb macro addrt,addrf
ld a,(addrf)
ld (addrt),a
endm
movw macro addrt,addrf
ld hl,(addrf)
ld (addrt),hl
endm
lxim macro addr,val
ld hl,val
ld (addr),hl
endm
mvim macro addr,val
ld a,val
ld (addr),a
endm
zmov macro to,from,n
if not nul to
ld de,to
endif
if not nul from
ld hl,from
endif
if not nul n
ld bc,n
endif
ldir
endm
move macro to,from,n
if not nul to
ld hl,to
endif
if not nul from
ld de,from
endif
if not nul n
ld bc,n
endif
call @move
endm
movcmd macro to,off,max
if not nul to
ld hl,to
endif
ld de,off
ld bc,max
call @mcmd
endm
fill macro adr,nr,ch
if not nul adr
ld hl,adr
endif
if not nul nr
ld bc,nr
endif
ld e,ch
call @fill
endm