;; TNC.LIB 2/6/85 - Macros to deal with TAPR TNC. ;; xerdef macro ;; ;; Xerox PROM entry points. ;; xconot equ 0f00ch xconin equ 0f009h xconst equ 0f006h xlistst equ 0f012h xlist equ 0f018h xseldsk equ 0f01bh xhome equ 0f01eh xsettrk equ 0f021h xread equ 0f024h xwrite equ 0f027h endm ;; timdef macro timer equ 48h sec equ 4ah min equ 4bh hr equ 4ch day equ 4dh mo equ 4eh yr equ 4fh endm ;; cpmorgs macro ;; ;; Where the code is located in RAM ;; memsize equ 60 ccp equ 3400h+(memsize-20)*1024 ccp$len equ 800h bdos$len equ 0e00h bdos equ ccp+ccp$len bios equ bdos+bdos$len ;; ;; Where things are on the boot disc. ;; cpmtrk equ 0 cpmsec equ 2 boottrk equ 0 bootsec equ 1 bootorg equ 80h biostrk equ 1 biossec equ 20 endm ;; biosjmp macro jp bootc jp bootw jp const jp conin jp conout jp list jp punch jp reader jp home jp seldsk jp settrk jp setsec jp setdma jp read jp write jp listst jp sectrn endm ;; tncdefs macro ;; true equ 0ffffh false equ 0 ;; xerox equ true robin equ false ;; convtim equ 2 ;; Sec wait for converse mode cmdmax equ 255 ;; Max length of text string ;; iobyte equ 3 ;; IOBYTE address ;; ;; Command type seen from TNC. ;; cdata equ 80h cdiscmd equ 81h ctimcmd equ 82h cnull equ 83h ;; ;; Misc constants. ;; fcbsize equ 36 ;; File control block size secsize equ 128 ;; Disc sector size bufsize equ 32 ;; Sectors in file buffer. ;; linkcmd equ 'W'-40h ;; ^W = Escape from link eof equ 'Z'-40h ;; ^Z = End of file ;; ;; Values for iobyte. ;; if xerox ciob equ 0 ;; Console (TTY:) raiob equ 1 ;; TNC on comm port (CRT:) rbiob equ 2 ;; TNC on printer port (BAT:) endif if robin ciob equ 95h ;; Console (CRT:) raiob equ 96h ;; TNC on comm port (TTY:) rbiob equ 97h ;; TNC on printer port (BAT:) endif endm ;; ;; Switch to local console. ;; console macro mvim iobyte,ciob endm ;; ;; Make TNC on COMM port master. ;; tnca macro mvim stnc,rbiob mvim mtnc,raiob sta iobyte endm ;; ;; Make TNC on PRINTER port master. ;; tncb macro mvim stnc,raiob mvim mtnc,rbiob sta iobyte endm ;; ;; Switch console to master TNC ;; master macro movb iobyte,mtnc endm ;; ;; Switch console to slave TNC ;; slave macro movb iobyte,stnc endm ;; ;; Mail file structure. ;; mbs macro entry mnr,mcnt ;; ;; Mail file header sector. ;; mfhs: mnext: dw 1 mfhd: dw 0 mlhd: dw 0 mffree: dw 0 mlfree: dw 0 mnr: dw 1 mvers: db 1 mfree: dw 0 mcnt: dw 0 mfhsl equ $-mfhs rept 111 db 0 endm ;; Copy of mfhs tmfhs: tmnext: ds 2 tmfhd: ds 2 tmlhd: ds 2 tmffree: ds 2 tmlfree: ds 2 tmnr: ds 2 tmvers: ds 1 tmfree: ds 2 tmcnt: ds 2 ;; Temporaries mhprev: ds 2 mhcur: ds 2 msgnr: ds 2 mtemp: ds 128 ;; ;; Message header sector. ;; mhtitl equ 80 ;; Length of title mmhs: mhfmsg: dw 0 mhlmsg: dw 0 mhnext: dw 0 mhnr: dw 0 mhsize: dw 0 mhtype: db ' ' mhstat: db 'N' mhto: db ' ' mhfrom: db ' ' mhdate: db ' ' mhtime: db ' ' mhread: dw 0 rept 10 db 0 endm mhtit: rept mhtitl db ' ' endm ;; Temporaries. tmhlmsg: ds 2 tmhnext: ds 2 tmhsize: ds 2 ;; ;; Message text sector. ;; mmts: mtnext: dw 0 mttext: rept 126 db ' ' endm mtcnt: ds 1 mtptr: ds 2 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 h lxim timer,?m call @wait pop h endm ;; ;; BDOS call codes, fixed address locations, etc. ;; dodosa macro func,addr if not nul func mvi c,func endif if not nul addr lxi d,addr endif call dosent endm ; dodosv macro func,val if not nul func mvi c,func endif if not nul val lda val mov 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 ;; ;; 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 user 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 lxi h,adr endif if not nul ct mvi b,ct endif call @ntobuf endm ;; ctobuf macro adr if not nul adr lxi h,adr endif call @ctobuf endm ;; openr macro cb if not nul cb move rfcb,cb,fcbsize endif call @openr endm ;; openw macro cb if not nul cb move wfcb,cb,fcbsize endif call @openw endm ;; opena macro cb if not nul cb move wfcb,cb,fcbsize endif call @opena endm ;; openwn macro cb if not nul cb move wfcb,cb,fcbsize 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 lda cmdtyp cpi cnull jz none cpi cdiscmd jz disco cpi ctimcmd jz tout endm ;; ;; Generate the menu call table: ;; Arguments are: Character, Subroutine address. ;; gencall macro id,adr db id dw adr endm ;; ;; Do the menu to command subroutine thing. ;; Input: (DE) points to call table. (A) is select character. ;; (HL) points to routine to call on no find. ;; Output: Routine called. ;; tblcall macro tbl,nofind lxi d,tbl lxi h,nofind call @tc endm ;; retz macro xra a ret endm ;; retnz macro xra a inr a ret endm ;; ckname macro addr lxi h,addr call ckname endm ;; upper macro addr,len if not nul addr lxi h,addr endif if not nul len mvi c,len endif call @upper endm ;; cmpm macro addr,dat lda addr cpi dat endm ;; comp macro fir,sec,nr if not nul fir lxi h,fir endif if not nul sec lxi d,sec endif if not nul nr mvi c,nr endif call @cmp endm ;; cmpcmd macro tcmd,lcmd local tcmd,lcmd lxi d,tcmd mvi c,lcmd call @cmpcmd endm ;; Create and clear a list. maklst macro @l,@n,@w,@c lhld @n ;; # items on list xchg mvi c,@w ;; Bytes / item call muldec ;; Bytes in the list lhld $memry ;; First byte avail in pool memory shld @l ;; Is start of list dad d shld $memry ;; New first byte of pool memory lhld @l ;; Start of list mov b,d mov c,e ;; (BC) = bytes in list mvi e,@c ;; Char to clear with call @fill ;; Clear the list endm srclst macro @t,@l,@n,@w,@c push h 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 call @src pop h endm 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 instat macro if robin call @rcs else call const endif endm ;; inchar macro call @inch endm ;; outchar macro call @outch endm ;; prtx macro adr if not nul adr lhld adr endif call @prtx endm ;; docmd macro addr lhld addr call @prtx call wtcmd endm ;; dtz macro addr lhld addr mov a,l ora h endm ;; dcxm macro addr lhld addr dcx h shld addr endm ;; inxm macro addr lhld addr inx h shld addr endm ;; movb macro addrt,addrf lda addrf sta addrt endm ;; movw macro addrt,addrf lhld addrf shld addrt endm ;; lxim macro addr,val lxi h,val shld addr endm ;; mvim macro addr,val mvi a,val sta addr endm ;; move macro to,from,n if not nul to lxi h,to endif if not nul from lxi d,from endif if not nul n lxi b,n endif call @move endm ;; movcall macro to,off if not nul to lxi h,to endif lxi d,off call @mc endm ;; movcmd macro to,off,max if not nul to lxi h,to endif lxi d,off lxi b,max call @mcmd endm ;; fill macro adr,nr,ch if not nul adr lxi h,adr endif if not nul nr lxi b,nr endif mvi e,ch call @fill endm