home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / jsage / znode3 / modem / qt43src.lbr / SRSCRN.ZY / SRSCRN.ZY
Encoding:
Text File  |  1993-06-08  |  4.8 KB  |  226 lines

  1. ; srscrn.z - screen routines for displaying status of a transfer
  2.  
  3. .incl    "c:termcap"
  4.  
  5. .extern initsc            ; initialise everything
  6. initsc:
  7.     push    hl
  8.     ld    hl,0
  9.     ld    (packet),hl
  10.     ld    (terr),hl
  11.     ld    (perr),hl    ; clear the variables
  12.     call    clear        ; and the screen
  13.     ld    hl,30
  14.     call    moveto        ; set up for the title
  15.     pop    hl
  16.     call    prtslp        ; print protocol type
  17.     ld    hl,m1
  18. .dseg
  19. m1:    db    ' File Transfer\0'
  20. .cseg
  21.     call    prtslp        ; finish title
  22.     call    mtprt
  23.     dw    [5 << 8] + 10
  24.     db    'Packet:\0'
  25.     call    mtprt
  26.     dw    [5 << 8] + 26
  27.     db    '0\0'
  28.     call    mtprt
  29.     dw    [7 << 8] + 10
  30.     db    'Packet Errors:  0\0'
  31.     call    mtprt
  32.     dw    [9 << 8] + 10
  33.     db    'Total Errors:   0\0'
  34.     ret            ; print rest of screen background
  35.  
  36. .extern    initsn            ; finish setting up screen for send
  37. initsn:
  38.     call    mtprt
  39.     dw    [3 << 8] + 10
  40.     db    'Sending:\0'    ; direction for where filename goes
  41.     call    mtprt
  42.     dw    [11 << 8] + 10
  43.     db    'Sent:\0'    ; set up for K transferred printout
  44.     ret
  45.  
  46. .extern    initrc            ; finish setting up screen for receive
  47. initrc:
  48.     call    mtprt
  49.     dw    [3 << 8] + 10
  50.     db    'Receiving:\0'    ; direction for where filename goes
  51.     call    mtprt
  52.     dw    [11 << 8] + 10
  53.     db    'Received:\0'    ; and for K transferred
  54.     ret
  55.  
  56. .extern    pktok            ; register a good packet
  57. pktok:
  58.     ld    hl,kcnt        ; point at k count flag
  59.     ld    a,(hl)        ; get value
  60.     or    a
  61.     jr    z,nokprt    ; not set, so don't print
  62.     dec    (hl)        ; clear flag
  63.     call    one_k        ; and print a K
  64. nokprt:    ld    hl,dcnt        ; look at count till we need clear
  65.     ld    a,(hl)
  66.     or    a
  67.     jr    z,nocdg        ; no clear needed - bypass
  68.     dec    (hl)
  69.     jr    nz,nocdg    ; not yet ..... skip it
  70.     call    diag
  71.     db    0        ; OK there goes the message
  72.     xor    a
  73.     ld    (dcnt),a    ; and reset dcnt back to zero
  74. nocdg:    ld    hl,(perr)
  75.     ld    a,h
  76.     or    l
  77.     jr    z,ncperr
  78.     call    mtprt
  79.     dw    [7 << 8] + 26
  80.     db    '0     \0'    ; reset packet error count on screen
  81.     ld    hl,0
  82.     ld    (perr),hl    ; and in memory
  83. ncperr:    ld    a,(qcount)
  84.     or    a
  85.     ret    nz
  86.     ld    hl,[5 << 8] + 26
  87.     call    moveto        ; moveto where packet number goes
  88.     ld    hl,(packet)
  89.     inc    hl
  90.     ld    (packet),hl    ; bump
  91.     jp    decout        ; and print
  92.  
  93. .extern    pkterr            ; register a bad packet
  94. pkterr:
  95.     ld    hl,[7 << 8] + 26
  96.     call    moveto
  97.     ld    hl,(perr)
  98.     inc    hl
  99.     ld    (perr),hl    ; bump and print packet errors
  100.     call    decout
  101.     ld    hl,[9 << 8] + 26
  102.     call    moveto
  103.     ld    hl,(terr)
  104.     inc    hl
  105.     ld    (terr),hl    ; same for total errors
  106.     jp    decout
  107.  
  108. .extern    prfile            ; print the filename from auxfcb
  109. prfile:
  110.     push    hl
  111.     ld    a,d
  112.     and    e
  113.     inc    a        ; check if there's a real size
  114.     jr    z,noprte    ; skip if not - this is receive
  115.     push    de
  116.     call    mtprt
  117.     dw    [11 << 8] + 34
  118.     db    'out of   \0'    ; and file size print
  119.     pop    hl
  120.     call    decout        ; and print it
  121.     ld    hl,m2
  122.     call    prtslp        ; and the 'K'
  123. noprte:    ld    hl,0
  124.     ld    (kxfer),hl    ; reset count of K transferred
  125.     call    mtprt
  126.     dw    [11 << 8] + 26
  127.     db    '0'        ; and print 0K to start things
  128. m2:    db    'K    \0'
  129.     ld    hl,[3 << 8] + 26
  130.     call    moveto        ; move to where filename gets printed
  131.     pop    hl        ; get fcb address to hl
  132.     call    prtfl        ; print the filename
  133.     ld    b,14        ; 14 chars to nuke anything left over
  134.     jr    cleol
  135.  
  136. .extern    prtfl
  137. prtfl:
  138.     ld    c,(hl)        ; get user number to c
  139.     inc    hl
  140.     ld    a,(hl)        ; get drive code
  141.     inc    hl        ; point at first char of name
  142.     push    hl        ; save fcb address
  143.     push    bc        ; save user number
  144.     add    a,'@'        ; convert to a letter
  145.     ld    c,a
  146.     call    scrout        ; and print it
  147.     pop    hl        ; user number back to l
  148.     call    decob        ; and print it
  149.     ld    c,':'
  150.     call    scrout        ; add a ':'
  151.     pop    hl
  152. nodrv:    ld    b,8
  153.     call    pfilnm        ; print the name portion
  154.     ld    a,(hl)
  155.     cp    ' '        ; check for an extension
  156.     ret    z        ; no - all done
  157.     push    hl
  158.     ld    c,'.'
  159.     call    scrout        ; print a '.'
  160.     pop    hl
  161.     ld    b,3
  162.  
  163. pfilnm:    ld    a,(hl)        ; get a char from fcb
  164.     inc    hl
  165.     push    hl
  166.     push    bc
  167.     and    0x7f        ; ditch attribute bit
  168.     cp    ' '        ; is it printable?
  169.     ld    c,a
  170.     call    nz,scrout    ; print if so
  171.     pop    bc
  172.     pop    hl
  173.     djnz    pfilnm        ; loop till all done
  174.     ret
  175.  
  176. .extern    diag
  177. diag:
  178.     ld    a,3
  179.     ld    (dcnt),a    ; set so that 3 packets later we'll clear
  180.     ld    hl,[14 << 8] + 10
  181.     call    moveto        ; move to where messages go
  182.     pop    hl        ; string address to hl
  183.     push    hl        ; back on stack
  184.     call    prtslp        ; print it
  185.     pop    de        ; restore start to de
  186.     push    hl        ; save end
  187.     or    a
  188.     sbc    hl,de        ; get length
  189.     ld    a,50
  190.     sub    l        ; get 50 - length
  191.     ld    b,a        ; to b
  192. cleol:    ld    a,(tcbits)
  193.     and    b_cleol        ; clear to eol possible
  194.     jp    z,cleol        ; do it if so
  195.     ld    c,' '        ; put a space in c
  196. cleolp:    push    bc
  197.     call    scrout        ; and print it
  198.     pop    bc
  199.     djnz    cleolp        ; till count runs out
  200.     ret
  201.  
  202. .extern    one_k
  203. one_k:
  204.     ld    a,(qcount)
  205.     or    a
  206.     ret    nz
  207.     ld    hl,[11 << 8] + 26
  208.     call    moveto        ; move to where K printout goes
  209.     ld    hl,(kxfer)
  210.     inc    hl
  211.     ld    (kxfer),hl    ; add one to count
  212.     call    decout        ; print the number
  213.     ld    c,'K'
  214.     jp    scrout        ; and add a 'K'
  215.  
  216. .dseg
  217. .extern    kcnt
  218. kcnt:    db    0
  219.  
  220. .useg
  221. dcnt:    ds    1
  222. packet:    ds    2
  223. terr:    ds    2
  224. perr:    ds    2
  225. kxfer:    ds    2
  226.