home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / zcpr2 / sak.mqc / SAK.MAC
Text File  |  1985-02-09  |  8KB  |  369 lines

  1. ;  PROGRAM:  SAK (Strike Any Key)
  2. ;  AUTHOR:  Richard Conn
  3. ;  VERSION:  1.0
  4. ;  DATE:  18 April 1983
  5. ;  PREVIOUS VERSIONS:  None
  6. vers    equ    10
  7.  
  8. ;
  9. ;    SAK (Strike Any Key) is used for the following purposes:
  10. ;        1) to wait for user interaction before continuing
  11. ;            and to allow the user to abort a Multiple
  12. ;            Command Line
  13. ;        2) to command the user's attention by ringing the
  14. ;            bell at his console
  15. ;
  16. ;    The SAK command line is:
  17. ;        SAK o...
  18. ;    SAK is invoked with the following options:
  19. ;        A     -- DO NOT Allow the User to Abort MCL
  20. ;        B     -- Ring Bell
  21. ;        Pnnnn -- Pause nnnn seconds and continue if no
  22. ;             response by that time
  23. ;
  24.     ext    print, condin, eval10, pause, cline, cout, phldc
  25.  
  26. tbuff    equ    80h    ;command line buffer
  27. cr    equ    0dh
  28. lf    equ    0ah
  29. ctrlc    equ    'C'-'@'
  30. ctrlg    equ    'G'-'@'
  31.  
  32. ;
  33. ;    This program is Copyright (c) 1983 by Richard Conn
  34. ;    All Rights Reserved
  35. ;
  36. ;    ZCPR2 and its utilities, including this one, are released
  37. ; to the public domain.  Anyone who wishes to USE them may do so with
  38. ; no strings attached.  The author assumes no responsibility or
  39. ; liability for the use of ZCPR2 and its utilities.
  40. ;
  41. ;    The author, Richard Conn, has sole rights to this program.
  42. ; ZCPR2 and its utilities may not be sold without the express,
  43. ; written permission of the author.
  44. ;
  45.  
  46. ;
  47. ;  Branch to Start of Program
  48. ;
  49.     jmp    start
  50.  
  51. ;
  52. ;******************************************************************
  53. ;
  54. ;  SINSFORM -- ZCPR2 Utility Standard General Purpose Initialization Format
  55. ;
  56. ;    This data block precisely defines the data format for
  57. ; initial features of a ZCPR2 system which are required for proper
  58. ; initialization of the ZCPR2-Specific Routines in SYSLIB.
  59. ;
  60.  
  61. ;
  62. ;  EXTERNAL PATH DATA
  63. ;
  64. EPAVAIL:
  65.     DB    0FFH    ; IS EXTERNAL PATH AVAILABLE? (0=NO, 0FFH=YES)
  66. EPADR:
  67.     DW    40H    ; ADDRESS OF EXTERNAL PATH IF AVAILABLE
  68.  
  69. ;
  70. ;  INTERNAL PATH DATA
  71. ;
  72. INTPATH:
  73.     DB    0,0    ; DISK, USER FOR FIRST PATH ELEMENT
  74.             ; DISK = 1 FOR A, '$' FOR CURRENT
  75.             ; USER = NUMBER, '$' FOR CURRENT
  76.     DB    0,0
  77.     DB    0,0
  78.     DB    0,0
  79.     DB    0,0
  80.     DB    0,0
  81.     DB    0,0
  82.     DB    0,0    ; DISK, USER FOR 8TH PATH ELEMENT
  83.     DB    0    ; END OF PATH
  84.  
  85. ;
  86. ;  MULTIPLE COMMAND LINE BUFFER DATA
  87. ;
  88. MCAVAIL:
  89.     DB    0FFH    ; IS MULTIPLE COMMAND LINE BUFFER AVAILABLE?
  90. MCADR:
  91.     DW    0FF00H    ; ADDRESS OF MULTIPLE COMMAND LINE BUFFER IF AVAILABLE
  92.  
  93. ;
  94. ;  DISK/USER LIMITS
  95. ;
  96. MDISK:
  97.     DB    4    ; MAXIMUM NUMBER OF DISKS
  98. MUSER:
  99.     DB    31    ; MAXIMUM USER NUMBER
  100.  
  101. ;
  102. ;  FLAGS TO PERMIT LOG IN FOR DIFFERENT USER AREA OR DISK
  103. ;
  104. DOK:
  105.     DB    0FFH    ; ALLOW DISK CHANGE? (0=NO, 0FFH=YES)
  106. UOK:
  107.     DB    0FFH    ; ALLOW USER CHANGE? (0=NO, 0FFH=YES)
  108.  
  109. ;
  110. ;  PRIVILEGED USER DATA
  111. ;
  112. PUSER:
  113.     DB    10    ; BEGINNING OF PRIVILEGED USER AREAS
  114. PPASS:
  115.     DB    'chdir',0    ; PASSWORD FOR MOVING INTO PRIV USER AREAS
  116.     DS    41-($-PPASS)    ; 40 CHARS MAX IN BUFFER + 1 for ending NULL
  117.  
  118. ;
  119. ;  CURRENT USER/DISK INDICATOR
  120. ;
  121. CINDIC:
  122.     DB    '$'    ; USUAL VALUE (FOR PATH EXPRESSIONS)
  123.  
  124. ;
  125. ;  DMA ADDRESS FOR DISK TRANSFERS
  126. ;
  127. DMADR:
  128.     DW    80H    ; TBUFF AREA
  129.  
  130. ;
  131. ;  NAMED DIRECTORY INFORMATION
  132. ;
  133. NDRADR:
  134.     DW    00000H    ; ADDRESS OF MEMORY-RESIDENT NAMED DIRECTORY
  135. NDNAMES:
  136.     DB    64    ; MAX NUMBER OF DIRECTORY NAMES
  137. DNFILE:
  138.     DB    'NAMES   '    ; NAME OF DISK NAME FILE
  139.     DB    'DIR'        ; TYPE OF DISK NAME FILE
  140.  
  141. ;
  142. ;  REQUIREMENTS FLAGS
  143. ;
  144. EPREQD:
  145.     DB    000H    ; EXTERNAL PATH?
  146. MCREQD:
  147.     DB    0FFH    ; MULTIPLE COMMAND LINE?
  148. MXREQD:
  149.     DB    000H    ; MAX USER/DISK?
  150. UDREQD:
  151.     DB    000H    ; ALLOW USER/DISK CHANGE?
  152. PUREQD:
  153.     DB    000H    ; PRIVILEGED USER?
  154. CDREQD:
  155.     DB    000H    ; CURRENT INDIC AND DMA?
  156. NDREQD:
  157.     DB    000H    ; NAMED DIRECTORIES?
  158. Z2CLASS:
  159.     DB    6    ; CLASS 6 (for Processor Speed)
  160.     DB    'ZCPR2'
  161.     DS    10    ; RESERVED
  162.  
  163. ;
  164. ;  END OF SINSFORM -- STANDARD DEFAULT PARAMETER DATA
  165. ;
  166. ;******************************************************************
  167. ;
  168.  
  169. ;
  170. ;  ZCPR2 Class 6 Constants
  171. ;
  172. pspeed:
  173.     db    4    ;Processor Speed in MHz
  174. crtpage:
  175.     db    24    ;CRT page Size
  176.  
  177. ;
  178. ;  Other Buffers
  179. ;
  180. abortf:
  181.     ds    1    ;abort flag
  182. bell:
  183.     ds    1    ;bell flag
  184. delay:
  185.     ds    2    ;delay constant
  186.  
  187. ;
  188. ;  Start of Program
  189. ;
  190. start:
  191.  
  192. ;
  193. ;  Print Banner
  194. ;
  195.     call    print
  196.     db    'SAK, Version '
  197.     db    (vers/10)+'0','.',(vers mod 10)+'0',0
  198. ;
  199. ;  Init Options and Parse and Interpret Command Line
  200. ;
  201.     xra    a    ;turn options off
  202.     sta    bell    ;turn off bell
  203.     sta    delay    ;turn off delay (pause)
  204.     sta    delay+1
  205.     mvi    a,0ffh    ;turn options on
  206.     sta    abortf    ;turn on abort
  207.     lxi    h,tbuff    ;save command line
  208.     call    cline
  209. opt:
  210.     mov    a,m    ;get option letter
  211.     inx    h    ;pt to next
  212.     ora    a    ;done?
  213.     jz    optdone
  214.     cpi    ' '    ;skip spaces
  215.     jz    opt
  216.     cpi    'A'    ;abort?
  217.     jz    optabort
  218.     cpi    'B'    ;bell?
  219.     jz    optbell
  220.     cpi    'P'    ;pause?
  221.     jz    optpause
  222.     call    print
  223.     db    cr,lf,'SAK is invoked by a command line of the following form:'
  224.     db    cr,lf,'    SAK o...'
  225.     db    cr,lf,'where "o..." is zero or more options combined in any '
  226.     db    'order.'
  227.     db    cr,lf,'The options are:'
  228.     db    cr,lf,'    A     -- DO NOT Allow the User to Abort and Clear the '
  229.     db    'MCL Buffer'
  230.     db    cr,lf,'    B     -- Ring the Bell'
  231.     db    cr,lf,'    Pnnnn -- Pause nnnn seconds and then resume '
  232.     db    'automatically'
  233.     db    cr,lf,'SAK allows the user to strike ^C to abort and clear the'
  234.     db    cr,lf,'multiple command line buffer (if there is one) or any'
  235.     db    cr,lf,'other key to continue execution'
  236.     db    cr,lf,0
  237.     ret
  238. ;
  239. ;  Process A option (Abort MCL)
  240. ;
  241. optabort:
  242.     xra    a    ;turn off abort
  243.     sta    abortf
  244.     jmp    opt
  245. ;
  246. ;  Process B option (Ring Bell)
  247. ;
  248. optbell:
  249.     mvi    a,0ffh    ;turn on bell
  250.     sta    bell
  251.     jmp    opt
  252. ;
  253. ;  Process Pnnnn option (Pause nnnn seconds)
  254. ;
  255. optpause:
  256.     call    eval10    ;convert argument to decimal value in DE
  257.     xchg        ;HL contains value
  258.     shld    delay
  259.     call    print
  260.     db    cr,lf,'Pause Selected: ',0
  261.     call    phldc    ;print in decimal
  262.     call    print
  263.     db    ' Second Delay before Resuming',0
  264.     xchg        ;HL pts to next char
  265.     jmp    opt
  266. ;
  267. ;  Continue Command Processing
  268. ;
  269. optdone:
  270.     lhld    delay    ;get delay count in HL
  271.     lda    abortf    ;abort allowed?
  272.     ora    a    ;0=no
  273.     jz    noabort
  274.     call    print
  275.     db    cr,lf,'Please Strike ^C to Abort, Any Other Key to '
  276.     db    'Continue - ',0
  277.     jmp    sakloop
  278. noabort:
  279.     call    print
  280.     db    cr,lf,'Please Strike Any Key to Continue - ',0
  281. ;
  282. ;  Main Delay Loop
  283. ;
  284. sakloop:
  285. ;
  286. ;  Ring Bell if Option Selected
  287. ;
  288.     lda    bell    ;get flag
  289.     ora    a    ;set zero flag
  290.     cnz    bout    ;ring bell and delay
  291. ;
  292. ;  Get character if one is available
  293. ;
  294.     call    condin    ;optionally get character
  295.     jnz    gotchar    ;process character
  296. ;
  297. ;  Loop if No Delay
  298. ;
  299.     mov    a,h    ;check for no delay
  300.     ora    l
  301.     jz    sakloop
  302. ;
  303. ;  Delay and test for input
  304. ;
  305.     push    h    ;save second counter
  306.     lxi    h,10    ;1 full second delay
  307.     lda    pspeed    ;get processor speed
  308.     mov    b,a    ;... in B
  309.     call    pause    ;delay 1 sec
  310.     pop    h    ;get second counter
  311.     dcx    h    ;count down
  312.     mov    a,h    ;done?
  313.     ora    l
  314.     jnz    sakloop
  315. ;
  316. ;  Process Input Character
  317. ;    If no input and timout instead, A=0 for continuation character
  318. ;
  319. gotchar:
  320.     cpi    ctrlc    ;abort?
  321.     jz    abort
  322. resume:
  323.     call    print
  324.     db    cr,lf,'Resuming ...',0
  325.     ret
  326. ;
  327. ;  Abort Multiple Command Line if there is one
  328. ;
  329. abort:
  330.     lda    abortf    ;abort allowed?
  331.     ora    a    ;0=no
  332.     jz    resume
  333.     lda    mcavail    ;multiple command line available?
  334.     ora    a    ;0=no
  335.     jz    abort1
  336.     lhld    mcadr    ;get address of buffer
  337.     lxi    d,4    ;add 4
  338.     xchg
  339.     dad    d    ;HL=MC+4, DE=MC
  340.     mvi    m,0    ;set no further command
  341.     xchg        ;HL=MC, DE=MC+4 (next command char ptr)
  342.     mov    m,e    ;store ptr to next command
  343.     inx    h
  344.     mov    m,d
  345. abort1:
  346.     call    print
  347.     db    cr,lf,'Aborting ...',0
  348.     ret
  349. ;
  350. ;  Ring Bell and Delay Briefly
  351. ;
  352. bout:
  353.     mvi    a,ctrlg    ;ring bell
  354.     call    cout
  355.     push    h    ;save HL
  356.     lhld    delay    ;do not delay if pause already invoked
  357.     mov    a,h    ;zero delay?
  358.     ora    l
  359.     jnz    bout1    ;skip delay
  360.     lxi    h,4    ;0.4 sec delay
  361.     lda    pspeed    ;get processor speed
  362.     mov    b,a    ;... in B
  363.     call    pause    ;delay
  364. bout1:
  365.     pop    h
  366.     ret
  367.  
  368.     end
  369.