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 / BEEHIVE / ZCAT / SAK22A.Z80 < prev    next >
Text File  |  2000-06-30  |  6KB  |  298 lines

  1. ;  PROGRAM:  SAK (Strike Any Key)
  2. ;  AUTHOR:  Richard Conn
  3. ;  VERSION:  2.2
  4. ;  DATE:  1 October 85
  5. ;  PREVIOUS VERSIONS:  1.0 (18 Apr 83), 2.0 (18 May 84), 2.1 (8 June 85)
  6.  
  7. ; Version 22a - added screen highlighting to built-in help msg.
  8. ;                                21 August 1986 - Frank Gaude'
  9.  
  10. vers    equ    22    ; Changed to allow the BIOS to return from
  11.             ; CONIN: with the zero flag set.  CONDIN:
  12.             ; subroutine in SYSLIB assumes, incorrectly,
  13.             ; this flag will always be non-zero.
  14.             ;        Joe Wright  21 September 1985
  15.             ;        program updated by Ken Davidson
  16. z3env    set    0fe00h
  17.  
  18. ;
  19. ;    SAK (Strike Any Key) is used for the following purposes:
  20. ;        1) to wait for user interaction before continuing
  21. ;            and to allow the user to abort a Multiple
  22. ;            Command Line
  23. ;        2) to command the user's attention by ringing the
  24. ;            bell at his console
  25. ;        3) abort ZEX command file in execution (2.1 - RLC)
  26. ;
  27. ;    The SAK command line is:
  28. ;        SAK o...
  29. ;    SAK is invoked with the following options:
  30. ;        A     -- DO NOT Allow the User to Abort MCL
  31. ;        B     -- Ring Bell
  32. ;        Pnnnn -- Pause nnnn seconds and continue if no
  33. ;             response by that time
  34. ;        Z     -- Allow the User to Abort ZEX
  35. ;
  36.     ext    z3vinit,wait1s,getcl1,qprint,qcrlf
  37.     ext    strtzex,stopzex,putzex,getznc,getzrun
  38.     ext    pstr,print,vprint,cst,cin,eval10,cout
  39.  
  40. tbuff    equ    80h    ;command line buffer
  41. cr    equ    0dh
  42. lf    equ    0ah
  43. ctrlc    equ    'C'-'@'
  44. ctrlg    equ    'G'-'@'
  45. dim    equ    1
  46. bright  equ    2
  47.  
  48. ;
  49. ; Environment Definition
  50. ;
  51.     if    z3env ne 0
  52. ;
  53. ; External ZCPR3 Environment Descriptor
  54. ;
  55.     jp    start
  56.     db    'Z3ENV'    ;This is a ZCPR3 Utility
  57.     db    1    ;External Environment Descriptor
  58. z3eadr:
  59.     dw    z3env
  60. start:
  61.     ld    hl,(z3eadr)    ;pt to ZCPR3 environment
  62. ;
  63.     else
  64. ;
  65. ; Internal ZCPR3 Environment Descriptor
  66. ;
  67.     MACLIB    Z3BASE.LIB
  68.     MACLIB    SYSENV.LIB
  69. z3eadr:
  70.     jp    start
  71.     SYSENV
  72. start:
  73.     ld    hl,z3eadr    ;pt to ZCPR3 environment
  74.     endif
  75.  
  76. ;
  77. ; Start of Program -- Initialize ZCPR3 Environment
  78. ;
  79.     call    z3vinit    ;initialize the ZCPR3 Env and the VLIB Env
  80.  
  81. ;  Init Options and Parse and Interpret Command Line
  82. ;
  83.     xor    a    ;turn options off
  84.     ld    (mpflag),a    ;turn off message printed flag
  85.     ld    (bell),a    ;turn off bell
  86.     ld    (delay),a    ;turn off delay (pause)
  87.     ld    (delay+1),a
  88.     ld    (stopz),a    ;(2.1 - RLC) do not abort ZEX
  89.     ld    a,0ffh            ;turn options on
  90.     ld    (abortf),a    ;turn on abort
  91.     ld    hl,tbuff+1    ;pt to command line
  92. spskp:
  93.     ld    a,(hl)    ;skip leading spaces
  94.     inc    hl
  95.     cp    ' '
  96.     jp    z,spskp
  97.     dec    hl    ;pt to char
  98.     cp    '/'    ;option?
  99.     jp    nz,optdone
  100.     inc    hl    ;skip option char
  101. opt:
  102.     ld    a,(hl)    ;get option letter
  103.     or    a    ;done?
  104.     jp    z,optdone
  105.     inc    hl    ;pt to next
  106.     cp    ' '    ;process text
  107.     jp    z,optdone
  108.     cp    'A'    ;abort?
  109.     jp    z,optabort
  110.     cp    'B'    ;bell?
  111.     jp    z,optbell
  112.     cp    'P'    ;pause?
  113.     jp    z,optpause
  114.     cp    'Z'    ;(2.1 - RLC) ZEX abort?
  115.     jp    z,optzex
  116.     call    vprint
  117.     db    'SAK, Version ',[vers/10]+'0','.',[vers mod 10]+'0'
  118.     db    cr,lf,dim,'Syntax:',bright,cr,lf
  119.     db    '   SAK /o... text',dim,' -or- ',bright,'SAK text'
  120.     db    cr,lf,dim,'Options:',bright,cr,lf
  121.     db    ' A     -- ',dim,'DO NOT Allow Abort',bright,cr,lf
  122.     db    ' B     -- ',dim,'Ring Bell',bright,cr,lf
  123.     db    ' Pnnnn -- ',dim,'Pause',bright,' nnnn ',dim,'secs'
  124.     db    bright,cr,lf
  125.     db    ' Z     -- ',dim,'Allow to Abort ZEX',bright,cr,lf
  126.     db    0
  127.     ret
  128.  
  129. ;
  130. ;  Process A option (Abort MCL)
  131. ;
  132. optabort:
  133.     xor    a    ;turn off abort
  134.     ld    (abortf),a
  135.     jp    opt
  136. ;
  137. ;  Process B option (Ring Bell)
  138. ;
  139. optbell:
  140.     ld    a,0ffh    ;turn on bell
  141.     ld    (bell),a
  142.     jp    opt
  143. ;
  144. ;  Process Pnnnn option (Pause nnnn seconds)
  145. ;
  146. optpause:
  147.     call    eval10    ;convert argument to decimal value in DE
  148.     ex    de,hl        ;HL contains value
  149.     ld    (delay),hl
  150.     ex    de,hl        ;HL pts to next char
  151.     jp    opt
  152. ;
  153. ;  (2.1 - RLC) Process Z option (Allow ZEX abort)
  154. ;
  155. optzex:
  156.     ld    a,0ffh    ;allow abort
  157.     ld    (stopz),a
  158.     jp    opt
  159. ;
  160. ;  Continue Command Processing
  161. ;
  162. optdone:
  163.     ld    a,(hl)    ;any message?
  164.     or    a
  165.     jp    z,optdn1
  166.     ld    (mpflag),a    ;set message printed flag
  167.     call    print    ;new line
  168.     db    '  --> ',0
  169.     call    pstr    ;print message
  170.     call    print
  171.     db    ' <--  ',0
  172. optdn1:
  173.     call    stopzex    ;suspend ZEX processing
  174.     ld    hl,(delay)    ;get delay count in HL
  175. ;
  176. ;  Main Delay Loop
  177. ;
  178. sakloop:
  179. ;
  180. ;  Ring Bell if Option Selected
  181. ;
  182.     ld    a,(bell)    ;get flag
  183.     or    a    ;set zero flag
  184.     call    nz,bout    ;ring bell and delay
  185. ;
  186. ;  Get character if one is available
  187. ;
  188. ;    call    condin    ;optionally get character
  189. ;    jp    nz,gotchar    ;process character
  190. ;
  191. ;  This change in case the BIOS CONIN: returns with zero flag set.
  192. ;
  193.     call    cst
  194.     jr    nz,nochar
  195. getchar:
  196.     call    cin
  197.     jp    gotchar
  198. nochar:
  199.  
  200. ;  Loop if No Delay
  201. ;
  202.     ld    a,h    ;check for no delay
  203.     or    l
  204.     jp    z,sakloop
  205. ;
  206. ;  Delay and test for input
  207. ;
  208.     call    wait1s    ;delay 1 sec
  209.     dec    hl    ;count down
  210.     ld    a,h    ;done?
  211.     or    l
  212.     jp    nz,sakloop
  213. ;
  214. ;  Process Input Character
  215. ;    If no input and timout instead, A=0 for continuation character
  216. ;
  217. gotchar:
  218.     cp    ctrlc    ;abort?
  219.     jp    z,abort
  220. resume:
  221.     ld    a,(mpflag)    ;message printed?
  222.     or    a    ;0=no
  223.     call    nz,qcrlf    ;new line if yes
  224.     call    qprint
  225.     db    'Resuming ...',0
  226.     jp    strtzex    ;resume ZEX processing
  227. ;
  228. ;  Abort Multiple Command Line if there is one
  229. ;
  230. abort:
  231.     ld    a,(abortf)    ;abort allowed?
  232.     or    a    ;0=no
  233.     jp    z,resume
  234.     call    getcl1    ;get address of command line buffer
  235.     ld    a,h    ;any buffer?
  236.     or    l
  237.     jp    z,abort1
  238.     ld    e,(hl)    ;get address of next char
  239.     inc    hl
  240.     ld    d,(hl)
  241.     ex    de,hl        ;HL pts to next char
  242.     ld    (hl),0    ;set no further command
  243. abort1:
  244.     ld    a,(mpflag)    ;message printed?
  245.     or    a    ;0=no
  246.     call    nz,qcrlf    ;new line if yes
  247.     call    qprint
  248.     db    'Aborting ...',0
  249.     call    getzrun    ;(2.1 - RLC) is ZEX running?
  250.     ret    z        ;(2.1 - RLC) done if not
  251.     call    strtzex    ;(2.1 - RLC) resume ZEX processing
  252.     ld    a,(stopz)    ;(2.1 - RLC) stop ZEX?
  253.     or    a    ;(2.1 - RLC) 0=no
  254.     ret    z        ;(2.1 - RLC) resume processing
  255.     call    getznc    ;(2.1 - RLC) get next ZEX char
  256.     ld    (hl),0ffh    ;(2.1 - RLC) store abort ZEX code
  257.     ret
  258.  
  259. ;
  260. ;  Ring Bell and Delay Briefly
  261. ;
  262. bout:
  263.     ld    a,ctrlg    ;ring bell
  264.     call    cout
  265.     push    hl    ;save HL
  266.     ld    hl,(delay)    ;do not delay if pause already invoked
  267.     ld    a,h    ;zero delay?
  268.     or    l
  269.     jp    nz,bout1    ;skip delay
  270.     call    wait1s    ;delay
  271. bout1:
  272.     pop    hl
  273.     ret
  274.  
  275. ;
  276. ;  Other Buffers
  277. ;
  278. abortf:
  279.     ds    1    ;abort flag
  280. bell:
  281.     ds    1    ;bell flag
  282. delay:
  283.     ds    2    ;delay constant
  284. mpflag:
  285.     ds    1    ;message printed flag
  286. stopz:
  287.     ds    1    ;(2.1 - RLC) stop ZEX flag
  288.  
  289.     end
  290. l flag
  291. delay:
  292.     ds    2    ;delay constant
  293. mpflag:
  294.     ds    1    ;message printed flag
  295. stopz:
  296.     ds    1    ;(2.1 - RLC) stop ZEX flag
  297.  
  298.     e