home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / zcpr2 / comment.mqc / COMMENT.MAC
Encoding:
Text File  |  1985-02-10  |  5.6 KB  |  277 lines

  1. ;  PROGRAM:  COMMENT
  2. ;  AUTHOR:  Richard Conn
  3. ;  VERSION:  1.0
  4. ;  DATE:  18 APR 83
  5. ;  PREVIOUS VERSIONS:  None
  6.  
  7. vers    equ    10
  8.  
  9. ;
  10. ;    COMMENT echoes lines, with simple character editing, to the user's
  11. ; console.  This program is designed to facilitate communication between
  12. ; two users who see the same console via redirectable I/O.  They can chat
  13. ; freely to each other by using this program.
  14. ;
  15.  
  16. llen    equ    65    ;number of chars allowed before auto newline
  17.  
  18. fcb    equ    5ch    ;FCB
  19.  
  20. ctrlc    equ    'C'-'@'    ;Abort Character
  21. cr    equ    0dh    ;New Line
  22. lf    equ    0ah    ;Line Feed
  23. bs    equ    8    ;Back Space
  24. del    equ    7fh    ;Delete Char
  25. ctrlu    equ    'U'-'@'    ;^U
  26. ctrlx    equ    'X'-'@'    ;^X
  27.  
  28.     ext    cin, cout, crlf, print
  29.  
  30.  
  31. ;
  32. ;    This program is Copyright (c) 1983 by Richard Conn
  33. ;    All Rights Reserved
  34. ;
  35. ;    ZCPR2 and its utilities, including this one, are released
  36. ; to the public domain.  Anyone who wishes to USE them may do so with
  37. ; no strings attached.  The author assumes no responsibility or
  38. ; liability for the use of ZCPR2 and its utilities.
  39. ;
  40. ;    The author, Richard Conn, has sole rights to this program.
  41. ; ZCPR2 and its utilities may not be sold without the express,
  42. ; written permission of the author.
  43. ;
  44.  
  45. ;
  46. ;  Branch to Start of Program
  47. ;
  48.     jmp    start
  49.  
  50. ;
  51. ;******************************************************************
  52. ;
  53. ;  SINSFORM -- ZCPR2 Utility Standard General Purpose Initialization Format
  54. ;
  55. ;    This data block precisely defines the data format for
  56. ; initial features of a ZCPR2 system which are required for proper
  57. ; initialization of the ZCPR2-Specific Routines in SYSLIB.
  58. ;
  59.  
  60. ;
  61. ;  EXTERNAL PATH DATA
  62. ;
  63. EPAVAIL:
  64.     DB    0FFH    ; IS EXTERNAL PATH AVAILABLE? (0=NO, 0FFH=YES)
  65. EPADR:
  66.     DW    40H    ; ADDRESS OF EXTERNAL PATH IF AVAILABLE
  67.  
  68. ;
  69. ;  INTERNAL PATH DATA
  70. ;
  71. INTPATH:
  72.     DB    0,0    ; DISK, USER FOR FIRST PATH ELEMENT
  73.             ; DISK = 1 FOR A, '$' FOR CURRENT
  74.             ; USER = NUMBER, '$' FOR CURRENT
  75.     DB    0,0
  76.     DB    0,0
  77.     DB    0,0
  78.     DB    0,0
  79.     DB    0,0
  80.     DB    0,0
  81.     DB    0,0    ; DISK, USER FOR 8TH PATH ELEMENT
  82.     DB    0    ; END OF PATH
  83.  
  84. ;
  85. ;  MULTIPLE COMMAND LINE BUFFER DATA
  86. ;
  87. MCAVAIL:
  88.     DB    0FFH    ; IS MULTIPLE COMMAND LINE BUFFER AVAILABLE?
  89. MCADR:
  90.     DW    0FF00H    ; ADDRESS OF MULTIPLE COMMAND LINE BUFFER IF AVAILABLE
  91.  
  92. ;
  93. ;  DISK/USER LIMITS
  94. ;
  95. MDISK:
  96.     DB    4    ; MAXIMUM NUMBER OF DISKS
  97. MUSER:
  98.     DB    31    ; MAXIMUM USER NUMBER
  99.  
  100. ;
  101. ;  FLAGS TO PERMIT LOG IN FOR DIFFERENT USER AREA OR DISK
  102. ;
  103. DOK:
  104.     DB    0FFH    ; ALLOW DISK CHANGE? (0=NO, 0FFH=YES)
  105. UOK:
  106.     DB    0FFH    ; ALLOW USER CHANGE? (0=NO, 0FFH=YES)
  107.  
  108. ;
  109. ;  PRIVILEGED USER DATA
  110. ;
  111. PUSER:
  112.     DB    10    ; BEGINNING OF PRIVILEGED USER AREAS
  113. PPASS:
  114.     DB    'chdir',0    ; PASSWORD FOR MOVING INTO PRIV USER AREAS
  115.     DS    41-($-PPASS)    ; 40 CHARS MAX IN BUFFER + 1 for ending NULL
  116.  
  117. ;
  118. ;  CURRENT USER/DISK INDICATOR
  119. ;
  120. CINDIC:
  121.     DB    '$'    ; USUAL VALUE (FOR PATH EXPRESSIONS)
  122.  
  123. ;
  124. ;  DMA ADDRESS FOR DISK TRANSFERS
  125. ;
  126. DMADR:
  127.     DW    80H    ; TBUFF AREA
  128.  
  129. ;
  130. ;  NAMED DIRECTORY INFORMATION
  131. ;
  132. NDRADR:
  133.     DW    00000H    ; ADDRESS OF MEMORY-RESIDENT NAMED DIRECTORY
  134. NDNAMES:
  135.     DB    64    ; MAX NUMBER OF DIRECTORY NAMES
  136. DNFILE:
  137.     DB    'NAMES   '    ; NAME OF DISK NAME FILE
  138.     DB    'DIR'        ; TYPE OF DISK NAME FILE
  139.  
  140. ;
  141. ;  REQUIREMENTS FLAGS
  142. ;
  143. EPREQD:
  144.     DB    000H    ; EXTERNAL PATH?
  145. MCREQD:
  146.     DB    000H    ; MULTIPLE COMMAND LINE?
  147. MXREQD:
  148.     DB    000H    ; MAX USER/DISK?
  149. UDREQD:
  150.     DB    000H    ; ALLOW USER/DISK CHANGE?
  151. PUREQD:
  152.     DB    000H    ; PRIVILEGED USER?
  153. CDREQD:
  154.     DB    000H    ; CURRENT INDIC AND DMA?
  155. NDREQD:
  156.     DB    000H    ; NAMED DIRECTORIES?
  157. Z2CLASS:
  158.     DB    0    ; CLASS 0
  159.     DB    'ZCPR2'
  160.     DS    10    ; RESERVED
  161.  
  162. ;
  163. ;  END OF SINSFORM -- STANDARD DEFAULT PARAMETER DATA
  164. ;
  165. ;******************************************************************
  166. ;
  167.  
  168. ;
  169. ;  Start of Program
  170. ;
  171. start:
  172.  
  173.     call    print
  174.     db    'COMMENT, Version '
  175.     db    (vers/10)+'0','.',(vers mod 10)+'0',0
  176.     lda    fcb+1    ;check for help request
  177.     cpi    '/'    ;help?
  178.     jnz    cmt
  179. ;
  180. ;  Help for COMMENT
  181. ;
  182.     call    print
  183.     db    cr,lf,'COMMENT simply echoes the user''s input to his'
  184.     db    cr,lf,'screen until he types a ^C.  Simple line editing'
  185.     db    cr,lf,'via the ^H, DEL, ^U, and ^X functions is available.'
  186.     db    cr,lf
  187.     db    cr,lf,'COMMENT is intended to be used when two users are'
  188.     db    cr,lf,'seeing the same screen (via redirectable I/O) and'
  189.     db    cr,lf,'wish to converse freely.  Assuming that both consoles'
  190.     db    cr,lf,'are tied together on input and output, COMMENT allows'
  191.     db    cr,lf,'the two people to type freely to each other without'
  192.     db    cr,lf,'fear of disturbing the system.'
  193.     db    cr,lf
  194.     db    cr,lf,'COMMENT is invoked by simply typing "COMMENT".'
  195.     db    0
  196.     ret
  197. ;
  198. ;  Beginning of Comment Routine
  199. ;
  200. cmt:
  201.     call    print
  202.     db    cr,lf,'Strike ^C to Abort'
  203.     db    cr,lf,0
  204.     call    comment    ;print first prompt and set char count
  205. ;
  206. ;  Main Character Input Loop
  207. ;
  208. loop:
  209.     call    cin    ;input char
  210.     ani    7fh    ;mask MSB
  211.     cpi    ctrlc
  212.     rz
  213.     cpi    cr    ;new line?
  214.     jz    newline
  215.     cpi    bs    ;back up?
  216.     jz    back
  217.     cpi    del    ;back up?
  218.     jz    back
  219.     cpi    ctrlu    ;erase line?
  220.     jz    eraln
  221.     cpi    ctrlx    ;erase line?
  222.     jz    eraln
  223.     call    cout
  224.     cpi    ' '    ;printable char?
  225.     jc    loop
  226.     inr    c    ;increment char count
  227.     mvi    a,llen    ;check for nearing end of line
  228.     cmp    c
  229.     cz    comment
  230.     jmp    loop
  231. ;
  232. ;  Routine to begin a new line
  233. ;
  234. newline:
  235.     call    comment    ;new line, print prompt, set char count to zero
  236.     jmp    loop
  237. ;
  238. ;  Back up one character
  239. ;
  240. back:
  241.     mov    a,c    ;check for no chars
  242.     ora    a
  243.     jz    loop
  244.     call    back1    ;backup routine
  245.     jmp    loop    ;continue
  246. ;
  247. ;  General Routine for backing up
  248. ;
  249. back1:
  250.     dcr    c    ;count down
  251.     mvi    a,bs    ;backspace
  252.     call    cout
  253.     mvi    a,' '    ;space
  254.     call    cout
  255.     mvi    a,bs    ;backspace
  256.     jmp    cout
  257. ;
  258. ;  Erase Current Line
  259. ;
  260. eraln:
  261.     mov    a,c    ;done?
  262.     ora    a
  263.     jz    loop
  264.     call    back1    ;backup
  265.     jmp    eraln
  266. ;
  267. ;  Print User Prompt
  268. ;
  269. comment:
  270.     call    crlf
  271.     call    print
  272.     db    'Comment> ',0
  273.     mvi    c,0    ;set char count
  274.     ret
  275.  
  276.     end
  277.