home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / 22rsx / rxmd.ark.2 / RXMD15.MAC < prev    next >
Encoding:
Text File  |  1985-12-07  |  5.9 KB  |  243 lines

  1. ;
  2. ; Turn on checksum flag, insure sending 128 byte blocks
  3. ;
  4. setnak:    lda    bchflg
  5.     ora    a
  6.     jnz    setnak1;    In batch mode now, exit
  7.     xra    a
  8.     sta    crcflg;        Ensure in checksum mode
  9.     sta    kflg;        Defaults to 128 byte blocks
  10.     call    ilprt
  11.  db    cr,lf,'checksum requested',cr,lf,0
  12.     ret
  13. setnak1:
  14.     call    ilprt;        and ignore checksum request
  15.  db    cr,lf,'checksum not used for batch mode',cr,lf,0
  16. ;    "    "
  17. ; Waits for initial NAK - to ensure no data is sent until the receiving
  18. ; program is ready, this routine waits for the first timeout-nak or the
  19. ; letter 'C' for CRC from the receiver.  If CRC is in effect then Cyclic
  20. ; Redundancy Checks are used instead of checksums.  'E' contains the
  21. ; number of seconds to wait.  If the first character received is CANCEL
  22. ; (CTL-X) then the send will be aborted as though it had timed out.
  23. ;
  24. waitnak:
  25.     call    funchk;        Check function keys
  26.     mvi    b,1;        Timeout delay
  27.     mov    a,b
  28.     sta    remoff;        Show future diplays to local CRT only
  29.     call    recv;        Wait up to 1 sec for char
  30.     jc    waitn1;        No char this time
  31.     cpi    crc;        Was it a 'CRC' request?
  32.     jz    waitk
  33.     cpi    ksnd;        Requesting 1k?
  34.     jz    setk;        Exit if yes, otherwise set CRC
  35.     cpi    nak;        A 'NAK' indicating checksum?
  36.     jz    setnak;        Yes, go put checksum in effect
  37.     cpi    cancel;        Was it a cancel (CTL-X)?
  38.     jz    abort;        Yes, abort
  39. waitn1:    dcr    e;        Finished yet?
  40.     jz    abort;        Yes, abort
  41.     jmp    waitnak;    No, loop
  42. ;
  43. waitk:    mvi    b,1;        Got a 'C', wait up to 1 sec for 'K'
  44.     call    recv
  45.     jc    setcrc;        Didn't get anything so not using 1k
  46.     ani    7FH
  47.     cpi    '{'
  48.     jz    waitk;        Disregard noisy lines
  49.     cpi    ksnd
  50.     jz    setk;        Requesting 1k, else set CRC
  51. ;    "    "
  52. ; Turn on the flag for CRC
  53. ;
  54. setcrc:    lda    kflg;        KFLG manually set from 'SK'?
  55.     ora    a
  56.     jnz    setk;        If yes, keep it set
  57. setc1:    xra    a
  58.     sta    kflg;        Defaults to 128 byte blocks
  59.     inr    a
  60.     sta    crcflg;        Insures in CRC mode
  61.     call    ilprt
  62.  db    cr,lf,'CRC requested',cr,lf,0
  63.     ret
  64. ;
  65. ; Turn on the flag for 1k blocks and insure in CRC mode
  66. ;
  67. setk:    call    mspeed
  68.     cpi    5;        1k request for 1200 bps or more
  69.     jc    setc1;        Don't allow 1k if less than 1200 bps
  70.     sta    kflg;        Set the flag for 1k blocks
  71.     sta    crcflg;        Insures in 'CRC' mode
  72.     call    ilprt
  73.  db    cr,lf,'1k requested',cr,lf,0
  74.     ret
  75. ;
  76. ;
  77. ; This routine moves the filename from the default command line
  78. ; buffer to the file control block (FCB).
  79. ;
  80. movefcb:
  81.     lhld    savehl;        Get position on command line
  82.     call    getb;        Get numeric position
  83.     lxi    d,fcb+1
  84.     call    movenam;    Move name to FCB
  85.     xra    a
  86.     sta    fcbrno;        Zero record number
  87.     sta    fcbext;        Zero extent
  88.     lda    optsav;        This going to be a library file?
  89.     cpi    'L'
  90.     rnz;            If not, finished
  91. ;    "    "
  92. ; Handles library entries, first checks for proper .LBR extent.
  93. ; If no extent was included, it adds one itself.
  94.     shld    savehl
  95.     lxi    h,fcb+9;    1st 'typ' char
  96.     mov    a,m
  97.     cpi    ' '
  98.     jz    noext;        No type, make one
  99.     cpi    'L';        Check 1st char in type
  100.     jnz    lbrerr
  101.     inx    h
  102.     mov    a,m
  103.     cpi    'B';        Check 2nd char in type
  104.     jnz    lbrerr
  105.     inx    h
  106.     mov    a,m
  107.     cpi    'R';        Check 3rd char in type
  108.     jnz    lbrerr
  109. ;    "    "
  110. ; Get the name of the desired file in the library
  111. ;
  112. movef1:    lhld    savehl;        Get current position on command line
  113.     call    chkmsp;        See if valid library member file name
  114.     inr    b;        Increment for move name
  115.     lxi    d,memfcb;    Store member name in special buffer
  116. ;    "    "
  117. ; Move a file name from the 'TBUF' command line buffer into FCB
  118. ;
  119. movenam:
  120.     mvi    c,1
  121. ;    "    "
  122. moven1:    mov    a,m
  123.     cpi    ' '+1;        Name ends with space or return
  124.     jc    moven3;        Fill with spaces if needed
  125.     cpi    '.'
  126.     jz    chkfil;        File name might be less than 8 chars.
  127.     stax    d;        Store
  128.     inx    d;        Next position to store the character
  129.     inr    c;        One less to go
  130.     mov    a,c
  131.     cpi    12+1
  132.     jnc    noname;        11 chars. maximum filename plus extent
  133. ;    "    "
  134. moven2:    inx    h;        Next char. in file name
  135.     dcr    b
  136.     jnz    moven1
  137.     jmp    opterr;        End of name, see if done yet
  138. ;
  139. ; See if any spaces needed between file name and .ext
  140. chkfil:    mvi    a,8
  141.     call    fillsp;        Fill with spaces
  142.     jmp    moven2
  143. ;
  144. ; Fill filename and extension with blanks if needed
  145. moven3:    mvi    a,8
  146.     call    fillsp
  147.     mvi    a,11
  148. ;    "    "
  149. ; Fill filename area with spaces, and 1st .typ char.
  150. fillsp:    cmp    c
  151.     rc;            Up to 1st char in .ext now
  152.     xchg
  153.     mvi    m,' ';        Be sure there is a blank there now
  154.     xchg
  155.     inr    c
  156.     inx    d
  157.     jmp    fillsp
  158. ;
  159. ; Check for any spaces prior to library member file name, if none (or
  160. ; only spaces remaining), no name.
  161. ;
  162. chkmsp:    dcr    b
  163.     jz    memerr
  164.     mov    a,m
  165.     cpi    ' '+1
  166.     rnc
  167.     inx    h
  168.     jmp    chkmsp
  169. ;
  170. ; Gets the count of characters remaining on the command line
  171. ;
  172. getb:    mov    a,l
  173.     sui    tbuf+2;        Start location of 1st command
  174.     mov    b,a;        Store for now
  175.     lda    tbuf;        Find length of command line
  176.     sub    b;        Subtract those already used
  177.     mov    b,a;        Now have number of bytes remaining
  178.     ret
  179. ;
  180. lbrerr:    call    erxit
  181.  db    cr,lf,'++ Invalid library name ++','$'
  182. ;
  183. memerr:    call    ilprt
  184.  db    cr,lf,cr,lf,'++ No library member file requested ++',cr,lf,0
  185.     jmp    opterr
  186. ;
  187. ; Add .LBR extent to the library file name
  188. ;
  189. noext:    lxi    h,fcb+9;    Location of extent
  190.     mvi    m,'L'
  191.     inx    h
  192.     mvi    m,'B'
  193.     inx    h
  194.     mvi    m,'R'
  195.     jmp    movef1;        Now get the library member name
  196. ;
  197. ; Output to console (single or double on remoff flag)
  198. ; a,f
  199. ctype:    push    d
  200.     mov    e,a;        Character to 'E' in case BDOS (normal)
  201.     lda    remoff;        Want to bypass 'BYE' output to modem?
  202.     ora    a
  203.     push    psw
  204.     cnz    conout;        To local console only
  205.     pop    psw;            one or the other
  206.     mvi    a,wrcon;    BDOS console output, to CRT and modem
  207.     cz    dos;        Since 'BYE' intercepts the char.
  208.     pop    d
  209.     ret
  210. ;
  211. ; 0 terminated string hl^ to console (single/double on remoff flag)
  212. ; a,f,h,l
  213. tstr:    mov    a,m
  214.     inx    h
  215.     ora    a
  216.     rz
  217.     call    ctype
  218.     jmp    tstr
  219. ;
  220. ; cr/lf out
  221. ; a,f
  222. crlf:    call    ilprt
  223.  db    cr,lf,0
  224.     ret
  225. ;
  226. ; Inline print of message, 0 terminated
  227. ; a,f
  228. ilprt:    xthl;            Save HL, get HL=message
  229.     mov    a,m;        Get the char
  230.     inx    h
  231.     xthl
  232.     ora    a
  233.     rz;            past end of message
  234.     call    ctype
  235.     jmp    ilprt
  236. ;
  237. ; Check to see if SYSOP has typed a function key
  238. funchk:    push    psw
  239.     call    constat;    Does it all with BYERSX
  240.     pop    psw
  241.     ret
  242. ;
  243. ║b