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 / ZSYS / SIMTEL20 / ZCPR3 / SAK.MAC < prev    next >
Text File  |  2000-06-30  |  5KB  |  245 lines

  1. ;  PROGRAM:  SAK (Strike Any Key)
  2. ;  AUTHOR:  Richard Conn
  3. ;  VERSION:  2.0
  4. ;  DATE:  18 May 84
  5. ;  PREVIOUS VERSIONS:  1.0 (18 Apr 83)
  6. vers    equ    20
  7. z3env    SET    0f400h
  8.  
  9. ;
  10. ;    SAK (Strike Any Key) is used for the following purposes:
  11. ;        1) to wait for user interaction before continuing
  12. ;            and to allow the user to abort a Multiple
  13. ;            Command Line
  14. ;        2) to command the user's attention by ringing the
  15. ;            bell at his console
  16. ;
  17. ;    The SAK command line is:
  18. ;        SAK o...
  19. ;    SAK is invoked with the following options:
  20. ;        A     -- DO NOT Allow the User to Abort MCL
  21. ;        B     -- Ring Bell
  22. ;        Pnnnn -- Pause nnnn seconds and continue if no
  23. ;             response by that time
  24. ;
  25.     ext    z3init,wait1s,getcl1,qprint,qcrlf
  26.     ext    strtzex,stopzex,putzex
  27.     ext    pstr,print,condin,eval10,cout
  28.  
  29. tbuff    equ    80h    ;command line buffer
  30. cr    equ    0dh
  31. lf    equ    0ah
  32. ctrlc    equ    'C'-'@'
  33. ctrlg    equ    'G'-'@'
  34.  
  35. ;
  36. ; Environment Definition
  37. ;
  38.     if    z3env ne 0
  39. ;
  40. ; External ZCPR3 Environment Descriptor
  41. ;
  42.     jmp    start
  43.     db    'Z3ENV'    ;This is a ZCPR3 Utility
  44.     db    1    ;External Environment Descriptor
  45. z3eadr:
  46.     dw    z3env
  47. start:
  48.     lhld    z3eadr    ;pt to ZCPR3 environment
  49. ;
  50.     else
  51. ;
  52. ; Internal ZCPR3 Environment Descriptor
  53. ;
  54.     MACLIB    Z3BASE.LIB
  55.     MACLIB    SYSENV.LIB
  56. z3eadr:
  57.     jmp    start
  58.     SYSENV
  59. start:
  60.     lxi    h,z3eadr    ;pt to ZCPR3 environment
  61.     endif
  62.  
  63. ;
  64. ; Start of Program -- Initialize ZCPR3 Environment
  65. ;
  66.     call    z3init    ;initialize the ZCPR3 Env and the VLIB Env
  67.  
  68. ;  Init Options and Parse and Interpret Command Line
  69. ;
  70.     xra    a    ;turn options off
  71.     sta    mpflag    ;turn off message printed flag
  72.     sta    bell    ;turn off bell
  73.     sta    delay    ;turn off delay (pause)
  74.     sta    delay+1
  75.     mvi    a,0ffh    ;turn options on
  76.     sta    abortf    ;turn on abort
  77.     lxi    h,tbuff+1    ;pt to command line
  78. spskp:
  79.     mov    a,m    ;skip leading spaces
  80.     inx    h
  81.     cpi    ' '
  82.     jz    spskp
  83.     dcx    h    ;pt to char
  84.     cpi    '/'    ;option?
  85.     jnz    optdone
  86.     inx    h    ;skip option char
  87. opt:
  88.     mov    a,m    ;get option letter
  89.     ora    a    ;done?
  90.     jz    optdone
  91.     inx    h    ;pt to next
  92.     cpi    ' '    ;process text
  93.     jz    optdone
  94.     cpi    'A'    ;abort?
  95.     jz    optabort
  96.     cpi    'B'    ;bell?
  97.     jz    optbell
  98.     cpi    'P'    ;pause?
  99.     jz    optpause
  100.     call    print
  101.     db    'SAK, Version '
  102.     db    (vers/10)+'0','.',(vers mod 10)+'0'
  103.     db    cr,lf,'Syntax:'
  104.     db    cr,lf,'   SAK /o... text  -or-  SAK text'
  105.     db    cr,lf,'Options:'
  106.     db    cr,lf,' A     -- DO NOT Allow the User to Abort'
  107.     db    cr,lf,' B     -- Ring the Bell'
  108.     db    cr,lf,' Pnnnn -- Pause nnnn seconds and then resume'
  109.     db    0
  110.     ret
  111. ;
  112. ;  Process A option (Abort MCL)
  113. ;
  114. optabort:
  115.     xra    a    ;turn off abort
  116.     sta    abortf
  117.     jmp    opt
  118. ;
  119. ;  Process B option (Ring Bell)
  120. ;
  121. optbell:
  122.     mvi    a,0ffh    ;turn on bell
  123.     sta    bell
  124.     jmp    opt
  125. ;
  126. ;  Process Pnnnn option (Pause nnnn seconds)
  127. ;
  128. optpause:
  129.     call    eval10    ;convert argument to decimal value in DE
  130.     xchg        ;HL contains value
  131.     shld    delay
  132.     xchg        ;HL pts to next char
  133.     jmp    opt
  134. ;
  135. ;  Continue Command Processing
  136. ;
  137. optdone:
  138.     mov    a,m    ;any message?
  139.     ora    a
  140.     jz    optdn1
  141.     sta    mpflag    ;set message printed flag
  142.     call    print    ;new line
  143.     db    '  --> ',0
  144.     call    pstr    ;print message
  145.     call    print
  146.     db    ' <--  ',0
  147. optdn1:
  148.     call    stopzex    ;suspend ZEX processing
  149.     lhld    delay    ;get delay count in HL
  150. ;
  151. ;  Main Delay Loop
  152. ;
  153. sakloop:
  154. ;
  155. ;  Ring Bell if Option Selected
  156. ;
  157.     lda    bell    ;get flag
  158.     ora    a    ;set zero flag
  159.     cnz    bout    ;ring bell and delay
  160. ;
  161. ;  Get character if one is available
  162. ;
  163.     call    condin    ;optionally get character
  164.     jnz    gotchar    ;process character
  165. ;
  166. ;  Loop if No Delay
  167. ;
  168.     mov    a,h    ;check for no delay
  169.     ora    l
  170.     jz    sakloop
  171. ;
  172. ;  Delay and test for input
  173. ;
  174.     call    wait1s    ;delay 1 sec
  175.     dcx    h    ;count down
  176.     mov    a,h    ;done?
  177.     ora    l
  178.     jnz    sakloop
  179. ;
  180. ;  Process Input Character
  181. ;    If no input and timout instead, A=0 for continuation character
  182. ;
  183. gotchar:
  184.     cpi    ctrlc    ;abort?
  185.     jz    abort
  186. resume:
  187.     lda    mpflag    ;message printed?
  188.     ora    a    ;0=no
  189.     cnz    qcrlf    ;new line if yes
  190.     call    qprint
  191.     db    'Resuming ...',0
  192.     jmp    strtzex    ;resume ZEX processing
  193. ;
  194. ;  Abort Multiple Command Line if there is one
  195. ;
  196. abort:
  197.     lda    abortf    ;abort allowed?
  198.     ora    a    ;0=no
  199.     jz    resume
  200.     call    getcl1    ;get address of command line buffer
  201.     mov    a,h    ;any buffer?
  202.     ora    l
  203.     jz    abort1
  204.     mov    e,m    ;get address of next char
  205.     inx    h
  206.     mov    d,m
  207.     xchg        ;HL pts to next char
  208.     mvi    m,0    ;set no further command
  209. abort1:
  210.     lda    mpflag    ;message printed?
  211.     ora    a    ;0=no
  212.     cnz    qcrlf    ;new line if yes
  213.     call    qprint
  214.     db    'Aborting ...',0
  215.     jmp    strtzex    ;resume ZEX processing
  216. ;
  217. ;  Ring Bell and Delay Briefly
  218. ;
  219. bout:
  220.     mvi    a,ctrlg    ;ring bell
  221.     call    cout
  222.     push    h    ;save HL
  223.     lhld    delay    ;do not delay if pause already invoked
  224.     mov    a,h    ;zero delay?
  225.     ora    l
  226.     jnz    bout1    ;skip delay
  227.     call    wait1s    ;delay
  228. bout1:
  229.     pop    h
  230.     ret
  231.  
  232. ;
  233. ;  Other Buffers
  234. ;
  235. abortf:
  236.     ds    1    ;abort flag
  237. bell:
  238.     ds    1    ;bell flag
  239. delay:
  240.     ds    2    ;delay constant
  241. mpflag:
  242.     ds    1    ;message printed flag
  243.  
  244.     end
  245.