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 / MENU.MAC < prev    next >
Text File  |  2000-06-30  |  31KB  |  1,510 lines

  1. ;
  2. ;  PROGRAM:  MENU
  3. ;  AUTHOR:  RICHARD CONN
  4. ;  VERSION:  3.2
  5. ;  DATE:  10 June 84
  6. ;  PREVIOUS VERSIONS:  3.1 (28 Mar 84), 3.0 (18 Mar 84)
  7. ;  DERIVATION. MENU 1.4 for ZCPR2
  8. ;
  9. VERS    EQU    32
  10.  
  11. ;
  12. ;    MENU is the ZCPR3 Menu Processor.  It loads, looks for the MENU.MNU
  13. ; file, and then displays it to the user (optionally) and prompts him for
  14. ; a single-character command.  The ZCPR3 Multiple Command Line Buffer must
  15. ; be installed for MENU to work, and MENU uses this buffer to chain to the
  16. ; programs selected by the user and return to itself at the proper place.
  17. ;
  18. ;    MENU supports multiple menus within one MENU.MNU file.  When a command
  19. ; is invoked, MENU returns to the menu the command came from.
  20. ;
  21. ;    MENU will ONLY RUN on ZCPR3 systems with the Multiple Command Line
  22. ; Buffer Option enabled.
  23. ;
  24.  
  25. ;
  26. ;  Menu Constants
  27. ;
  28. sysmenu        equ    0        ;System Menu Enabled? 0=no, 1=yes
  29.  
  30. ;  1 Special Menu Command Chars
  31. RNM        EQU    '>'        ;NEXT MENU
  32. RNMP        EQU    '.'        ;NEXT MENU PRIME (ALTERNATE)
  33. RLM        EQU    '<'        ;LAST MENU
  34. RLMP        EQU    ','        ;LAST MENU PRIME (ALTERNATE)
  35. RFM        EQU    '*'        ;FIRST MENU
  36. ;
  37.     if    sysmenu
  38. RSM        EQU    '$'        ;SYSTEM MENU (PASSWORD REQUIRED)
  39.                     ; THIS IS SAME AS CONTROL CHAR
  40.     endif        ;sysmenu
  41.  
  42. ;  2 Internal Menu Control Chars
  43. MCMD        EQU    ':'        ;COMMAND TO JUMP TO ANOTHER MENU
  44. PCHAR        EQU    '"'        ;INDICATES AUTO PROMPT FOR SPECIFIC CMD
  45. MINDIC        EQU    '#'        ;MENU SECTION INDICATOR
  46. MFIRST        EQU    '%'        ;FIRST MENU INDICATOR
  47. GOPTION        EQU    '-'        ;GLOBAL OPTION INDICATOR
  48. WOPTION        EQU    '!'        ;ACTIVATES WAIT UPON RETURN
  49.  
  50. ;  3 Menu Option Chars
  51. COPTION        EQU    'C'        ;DISPLAY COMMAND LINE TO USER
  52. DOPTION        EQU    'D'        ;DISPLAY MENU TO USER
  53. POPTION        EQU    'P'        ;PAGE OUT MENU DISPLAY TO USER
  54. XOPTION        EQU    'X'        ;DISABLE ZCPR3 RETURN
  55.  
  56. ;  4 Miscellaneous
  57. IBUFSZ        EQU    254        ;SIZE OF INPUT LINE BUFFER
  58. VARFLAG        EQU    '$'        ;VARIABLE FLAG
  59.                     ;(FOLLOWED BY D,U,Fn,Nn,Tn)
  60. CMDSEP        EQU    ';'        ;ZCPR3 COMMAND SEPARATOR
  61.  
  62. ;
  63. ;  Enter/Exit Standout Mode (Recommended that these values not be changed)
  64. ;
  65. DIM            EQU    'A'-'@'    ; ^A TO ENTER STANDOUT
  66. NOTDIM            EQU    'B'-'@'    ; ^B TO EXIT STANDOUT
  67.  
  68. ;
  69. ;  MACRO Library of Definitions
  70. ;
  71.     MACLIB    Z3BASE.LIB
  72.  
  73. ;
  74. ;  ZCPR3 CONSTANTS
  75. ;
  76. wboot    equ    0
  77. bentry    equ    5
  78. fcb    equ    5ch
  79. tbuff    equ    80h
  80. BEL    equ    7
  81. CR    equ    0dh
  82. LF    equ    0ah
  83. CTRLC    equ    'C'-'@'
  84. TAB    equ    'I'-'@'
  85. CTRLZ    equ    'Z'-'@'
  86.  
  87. ;
  88. ; MACROS TO PROVIDE Z80 EXTENSIONS
  89. ;   MACROS INCLUDE:
  90. ;
  91. ;    BR    - JUMP RELATIVE
  92. ;    BRC    - JUMP RELATIVE IF CARRY
  93. ;    BRNC    - JUMP RELATIVE IF NO CARRY
  94. ;    BRZ    - JUMP RELATIVE IF ZERO
  95. ;    BRNZ    - JUMP RELATIVE IF NO ZERO
  96. ;    BJNZ    - DECREMENT B AND JUMP RELATIVE IF NO ZERO
  97. ;    PUTRG    - SAVE REGISTERS
  98. ;    GETRG    - RESTORE REGISTERS
  99. ;
  100.  
  101. ;
  102. ;
  103. ; Z80 MACRO EXTENSIONS
  104. ;
  105. BR    MACRO    ?N    ;;JUMP RELATIVE
  106.     IF    I8080    ;;8080/8085
  107.     JMP    ?N
  108.     ELSE        ;;Z80
  109.     .Z80
  110.     JR    ?N
  111.     .8080
  112.     ENDIF        ;;I8080
  113.     ENDM
  114. ;
  115. BRC    MACRO    ?N    ;;JUMP RELATIVE ON CARRY
  116.     IF    I8080    ;;8080/8085
  117.     JC    ?N
  118.     ELSE        ;;Z80
  119.     .Z80
  120.     JR    C,?N
  121.     .8080
  122.     ENDIF        ;;I8080
  123.     ENDM
  124. ;
  125. BRNC    MACRO    ?N    ;;JUMP RELATIVE ON NO CARRY
  126.     IF    I8080    ;;8080/8085
  127.     JNC    ?N
  128.     ELSE        ;;Z80
  129.     .Z80
  130.     JR    NC,?N
  131.     .8080
  132.     ENDIF        ;;I8080
  133.     ENDM
  134. ;
  135. BRZ    MACRO    ?N    ;;JUMP RELATIVE ON ZERO
  136.     IF    I8080    ;;8080/8085
  137.     JZ    ?N
  138.     ELSE        ;;Z80
  139.     .Z80
  140.     JR    Z,?N
  141.     .8080
  142.     ENDIF        ;;I8080
  143.     ENDM
  144. ;
  145. BRNZ    MACRO    ?N    ;;JUMP RELATIVE ON NO ZERO
  146.     IF    I8080    ;;8080/8085
  147.     JNZ    ?N
  148.     ELSE        ;;Z80
  149.     .Z80
  150.     JR    NZ,?N
  151.     .8080
  152.     ENDIF        ;;I8080
  153.     ENDM
  154. ;
  155. BJNZ    MACRO    ?N    ;;DECREMENT B AND JUMP RELATIVE ON NO ZERO
  156.     IF    I8080    ;;8080/8085
  157.     DCR    B
  158.     JNZ    ?N
  159.     ELSE        ;;Z80
  160.     .Z80
  161.     DJNZ    ?N
  162.     .8080
  163.     ENDIF        ;;I8080
  164.     ENDM
  165. ;
  166. PUTRG    MACRO
  167.     PUSH    H    ;;SAVE REGISTERS IN ORDER
  168.     PUSH    D
  169.     PUSH    B
  170.     ENDM
  171. ;
  172. GETRG    MACRO
  173.     POP    B    ;;RESTORE REGISTERS IN ORDER
  174.     POP    D
  175.     POP    H
  176.     ENDM
  177. ;
  178. ; END OF Z80 MACRO EXTENSIONS
  179. ;
  180.  
  181. ;
  182. ;  Externals from SYSLIB
  183. ;
  184.     ext    z3vinit,cls,stndout,stndend
  185.     ext    getcl1,putcl,getsh2,qshell,retud,getefcb,shpush,shpop
  186.     ext    getshm,putshm,moveb,getfn2,pfn1,getcrt,getzrun,putzex,putcst
  187.     ext    eprint,cin,cout,caps,crlf,pafdc,madc,bline,initfcb,sksp
  188.     ext    f$open,f$close,f$read,codend,hmovb
  189.  
  190. ;
  191. ; Environment Definition
  192. ;
  193.     if    z3env ne 0
  194. ;
  195. ; External ZCPR3 Environment Descriptor
  196. ;
  197.     jmp    start
  198.     db    'Z3ENV'    ;This is a ZCPR3 Utility
  199.     db    1    ;External Environment Descriptor
  200. z3eadr:
  201.     dw    z3env
  202. start:
  203.     lhld    z3eadr    ;pt to ZCPR3 environment
  204. ;
  205.     else
  206. ;
  207. ; Internal ZCPR3 Environment Descriptor
  208. ;
  209.     MACLIB    SYSENV.LIB
  210. z3eadr:
  211.     jmp    start
  212.     SYSENV
  213. start:
  214.     lxi    h,z3eadr    ;pt to ZCPR3 environment
  215.     endif
  216.  
  217. ;
  218. ; Start of Program -- Initialize ZCPR3 Environment
  219. ;
  220.     call    z3vinit    ;initialize the ZCPR3 Env and the VLIB Env
  221.     jmp    strt
  222. ;
  223. ;  This is the FCB which defines the default name of the MENU.MNU file
  224. ;
  225.     if    sysmenu
  226. ppass:
  227.     db    'SYSTEM          ',0    ;system password
  228.     endif        ;sysmenu
  229. ;
  230. menufcb:
  231.     db    0        ;FCB for MENU.MNU
  232.     db    'MENU    '
  233.     db    'MNU'
  234.     ds    4
  235. scratch:            ;this doubles as a scratch area
  236.     ds    16        ;buffer definition is at end of program
  237.     ds    4        ;36 bytes total
  238.  
  239. ;
  240. ;  Start of Program
  241. ;
  242. strt:
  243. ;
  244. ; Check for Shell Stack
  245. ;
  246.     call    getsh2    ;get shell status
  247.     brnz    strt0    ;skip over shell init
  248.     call    eprint
  249.     db    ' No Shell Stack',0
  250.     ret
  251. ;
  252. ; See if Command Line Available
  253. ;
  254. strt0:
  255.     call    getcl1    ;get line
  256.     brnz    strt01
  257.     call    eprint
  258.     db    ' No Command Line',0
  259.     ret
  260. ;
  261. ; See if this program was invoked as a shell
  262. ;
  263. strt01:
  264.     call    qshell    ;find out from ZCPR3 environment
  265.     push    psw    ;save status
  266.     xra    a    ;A=0
  267.     call    putcst    ;put command status (normal = 0)
  268.     pop    psw    ;restore status
  269.     jz    menu    ;do not push onto stack if invoked as a shell
  270. ;
  271. ; Set Name of Shell from External FCB if Possible or From Default if Not
  272. ;
  273. setshn:
  274.     call    retud    ;get run address
  275.     lxi    h,shdisk    ;pt to shell disk
  276.     mov    a,b    ;get disk
  277.     adi    'A'    ;convert to letter
  278.     mov    m,a    ;set disk letter
  279.     inx    h    ;pt to user 10's
  280.     mov    a,c    ;get user number
  281.     mvi    b,10    ;subtract 10's
  282.     mvi    d,'0'    ;set char
  283. setshn1:
  284.     sub    b    ;subtract
  285.     brc    setshn2
  286.     inr    d    ;increment digit
  287.     br    setshn1
  288. setshn2:
  289.     add    b    ;get 1's
  290.     mov    m,d    ;set 10's digit for user
  291.     inx    h    ;pt to 1's digit
  292.     adi    '0'    ;compute 1's digit
  293.     mov    m,a    ;set 1's digit
  294.     call    getefcb    ;get ptr to external fcb
  295.     brz    strt02    ;no external FCB, so use default name
  296.     inx    h    ;pt to program name
  297.     lxi    d,shname    ;pt to string
  298.     mvi    b,8    ;8 chars
  299.     call    moveb    ;copy into buffer
  300. ;
  301. ; Check for File Name and Set It If Given
  302. ;
  303. strt02:
  304.     lxi    h,fcb+1    ;pt to file name
  305.     lxi    d,menufcb+1
  306.     mvi    b,11    ;11 chars
  307.     mov    a,m    ;get first char
  308.     cpi    ' '
  309.     cnz    moveb    ;copy if one present
  310. ;
  311. ; Set File Name in MENUFCB into Line
  312. ;
  313.     lxi    h,menufcb+1    ;set shell file name
  314.     lxi    d,shfile    ;pt to shell file
  315.     mvi    b,8    ;8 chars
  316. strt03:
  317.     mov    a,m    ;get next char
  318.     cpi    ' '    ;done?
  319.     brz    strt04
  320.     stax    d    ;put char
  321.     inx    d    ;pt to next
  322. strt04:
  323.     inx    h    ;pt to next
  324.     bjnz    strt03
  325.     mvi    a,'.'    ;put dot
  326.     stax    d
  327.     inx    d    ;pt to next
  328.     mvi    b,3    ;file type
  329. strt05:
  330.     mov    a,m    ;copy
  331.     stax    d
  332.     inx    h    ;pt to next
  333.     inx    d
  334.     bjnz    strt05
  335.     xra    a    ;store zero
  336.     stax    d
  337.  
  338. ;
  339. ; Set Menu Number
  340. ;
  341.     mvi    b,1    ;shell message 1
  342.     xra    a    ;menu 0
  343.     call    putshm    ;set message
  344.  
  345. ;
  346. ; Push Name of Shell onto Stack
  347. ;
  348.     lxi    h,shdisk    ;pt to name of shell
  349.     call    shpush    ;push shell onto stack
  350.     brnz    strt2
  351. ;
  352. ; Shell Successfully Installed
  353. ;
  354.     call    eprint
  355.     db    ' Shell Installed',0
  356.     ret
  357. ;
  358. ; Shell Stack Push Error
  359. ;
  360. strt2:
  361.     cpi    2    ;shell stack full?
  362.     brnz    strt3
  363. ;
  364. ; Shell Stack is Full
  365. ;
  366.     call    eprint
  367.     db    ' Shell Stack Full',0
  368.     ret
  369. ;
  370. ; Shell Stack Entry Size is too small for command line
  371. ;
  372. strt3:
  373.     call    eprint
  374.     db    ' Shell Stack Entry Size',0
  375.     ret
  376. ;
  377. ; Check for ZEX Execution and Pass ZEX if So
  378. ;
  379. menu:
  380.     call    getzrun        ;is ZEX running?
  381.     brz    runmenu        ;process menu if not
  382.     br    menuz1        ;skip new line
  383. menuzex:
  384.     call    crlf        ;new line
  385. menuz1:
  386.     call    eprint
  387.     db    'Menu> ',0
  388.     mvi    a,1        ;tell ZEX that it is prompted
  389.     call    putzex
  390.     call    codend        ;set up buffer
  391.     mvi    m,ibufsz    ;set size
  392.     mvi    a,0FFH        ;capitalize
  393.     call    bline        ;get line from ZEX
  394.     xra    a        ;A=0
  395.     call    putzex        ;resume ZEX normally
  396.     call    sksp        ;skip over leading spaces
  397.     mov    a,m        ;check for comment
  398.     cpi    ';'
  399.     brz    menuzex
  400.     xchg            ;DE pts to command line
  401.     xra    a        ;don't display command
  402.     sta    cpflag
  403.     jmp    runcmnd        ;run command pted to by DE
  404. ;
  405. ; Begin Menu Processing
  406. ;
  407. runmenu:
  408.     call    eprint
  409.     db    'MENU  Version '
  410.     db    (vers/10)+'0','.',(vers mod 10)+'0',0
  411. ;
  412. ; Check for Wait Flag and Wait if So
  413. ;
  414.     mvi    b,0        ;get shell message 0
  415.     call    getshm
  416.     ani    80h        ;check for wait flag
  417.     cnz    sak        ;Strike Any Key
  418. ;
  419. ; Open Menu File
  420. ;
  421.     lxi    h,fcb        ;copy FCB into MENU FCB
  422.     lxi    d,menufcb
  423.     mvi    b,36        ;36 bytes
  424.     push    d        ;save ptr
  425.     call    moveb
  426.     pop    d        ;pt to MENU.MNU FCB
  427.     call    initfcb        ;init fcb
  428.     call    f$open        ;open file
  429.     brz    menu1        ;abort if no menu
  430.     call    eprint
  431.     db    CR,LF,' File ',0
  432.     lxi    d,menufcb+1
  433.     call    pfn1
  434.     call    eprint
  435.     db    ' Not Found',0
  436.     jmp    shpop
  437. ;
  438. ;  Load MENU.MNU from disk
  439. ;
  440. menu1:
  441.     call    codend        ;get address of buffer for menu load
  442. mload:
  443.     lxi    d,menufcb    ;pt to FCB
  444.     call    f$read        ;read in next block
  445.     ora    a        ;error?
  446.     brnz    mloaddn        ;load done if error
  447.     lxi    d,tbuff        ;copy from TBUFF into memory pted to by HL
  448.     xchg            ;HL is source, DE is dest
  449.     mvi    b,128        ;128 bytes
  450.     call    hmovb
  451.     lhld    bentry+1    ;get address of top of TPA
  452.     mov    a,h        ;set to bottom of ZCPR3
  453.     sui    10
  454.     cmp    d        ;about to overflow ZCPR3?
  455.     brnc    mload1    ;continue if not
  456.     call    eprint
  457.     db    CR,LF,' TPA Full',0
  458.     ret
  459. mload1:
  460.     xchg            ;HL pts to next byte to load to
  461.     br    mload        ;continue load
  462.  
  463.  
  464. ;
  465. ;  Init Flags and Clear MSB of all bytes in Menu File
  466. ;
  467. mloaddn:
  468.     call    f$close        ;close input file
  469.     mvi    m,CTRLZ        ;ensure EOF mark
  470.     lxi    d,80H        ;pt to next block
  471.     dad    d
  472.     shld    ibuff        ;set ptr to input line buffer
  473.     mvi    m,ibufsz    ;set size
  474.     dad    d        ;allow 256 bytes
  475.     dad    d
  476.     shld    expline        ;set ptr to expand line
  477.     xra    a        ;A=0
  478.     sta    cflag        ;turn off command display
  479.     sta    dflag        ;turn off menu display
  480.     sta    pflag        ;disallow paging
  481.     sta    cpmok        ;turn off ZCPR3 return flag
  482.     call    codend        ;pt to beginning of file
  483.     push    h        ;save ptr
  484. menul1:
  485.     mov    a,m        ;get byte
  486.     ani    7FH        ;mask out MSB
  487.     mov    m,a        ;put byte
  488.     inx    h        ;pt to next
  489.     cpi    CTRLZ        ;EOF?
  490.     brnz    menul1        ;continue if not
  491. ;
  492. ;  Mark all Menu Sections
  493. ;
  494.     pop    h        ;HL pts to first byte of menu
  495.     mvi    b,0FFH        ;set menu counter
  496. ;
  497. ;  Skip to Next Menu
  498. ;
  499. menul2:
  500.     mov    a,m        ;get byte
  501.     cpi    CTRLZ        ;error?
  502.     jz    mstrerr        ;structure error if so
  503.     cpi    MINDIC        ;menu indicator (start of menu?)
  504.     brnz    menul4
  505.     ori    80H        ;beginning of menu found -- set MSB
  506.     mov    m,a        ;put byte
  507.     inr    b        ;increment menu count
  508.     inx    h        ;pt to next
  509.     mov    a,m        ;get byte
  510.     cpi    MINDIC        ;menu indicator (end of menu?)
  511.     brz    menul5        ;done if so
  512.     cpi    CTRLZ        ;error?
  513.     jz    mstrerr
  514. ;
  515.     if    sysmenu
  516.     cpi    RSM        ;system menu indicator?
  517.     brnz    menul3
  518.     mov    a,b        ;set system menu number
  519.     sta    smeno
  520.     mvi    a,0FFH        ;set flag
  521.     sta    smenfl        ;system menu present
  522.     dcx    h        ;back up to beginning of menu
  523.     shld    smenadr        ;start address
  524.     inx    h        ;pt to RSM
  525.     endif        ;sysmenu
  526. ;
  527. ;  Skip out Menu Display
  528. ;
  529. menul3:
  530.     call    lskipt        ;skip to beginning of next line
  531.     brz    menul4        ;found menu indicator
  532.     cpi    CTRLZ        ;error?
  533.     jz    mstrerr
  534.     br    menul3        ;continue if not
  535. ;
  536. ;  Skip to Next Menu
  537. ;
  538. menul4:
  539.     call    lskip        ;skip to beginning of next menu
  540.     br    menul2
  541. ;
  542. ;  Check Menu Options
  543. ;
  544. menul5:
  545.     call    codend        ;pt to beginning of file
  546.     mov    a,m        ;check for option
  547.     cpi    GOPTION        ;global option char?
  548.     jnz    mfile        ;if no global option, scan for menu files
  549.     inx    h        ;pt to option char
  550. option:
  551.     mov    a,m        ;get option char
  552.     call    caps        ;capitalize
  553.     inx    h        ;pt to next
  554.     cpi    CR        ;done?
  555.     brz    optdn
  556.     cpi    COPTION        ;display command?
  557.     brz    optc
  558.     cpi    DOPTION        ;display menu?
  559.     brz    optd
  560.     cpi    POPTION        ;paging?
  561.     brz    optp
  562.     cpi    XOPTION        ;exit OK?
  563.     jnz    mstrerr        ;option error if not
  564. ;
  565. ;  Disable Exit to ZCPR3
  566. ;
  567.     mvi    a,0FFH        ;turn flag off
  568.     sta    cpmok
  569.     br    option
  570. ;
  571. ;  Process Paging Option
  572. ;
  573. optp:
  574.     mvi    a,0FFH        ;set flag
  575.     sta    pflag
  576.     br    option
  577. ;
  578. ;  Process Display Menu Option
  579. ;
  580. optd:
  581.     mvi    a,0FFH        ;set flag
  582.     sta    dflag
  583.     br    option
  584. ;
  585. ;  Process Display Command Option
  586. ;
  587. optc:
  588.     mvi    a,0FFH        ;set flag
  589.     sta    cflag
  590.     br    option
  591.  
  592. ;
  593. ;  Option Processing Done
  594. ;
  595. optdn:
  596.     inx    h        ;skip LF
  597.  
  598. ;
  599. ;  Check for Menu Display
  600. ;
  601. mfile:
  602.     mov    a,m        ;get first byte
  603.     ani    7FH        ;mask
  604.     cpi    MINDIC        ;start of menu?
  605.     jnz    mstrerr
  606.  
  607. ;
  608. ;  Check and Set First Menu
  609. ;
  610.     shld    mstart        ;save start address of first menu item
  611.     mvi    m,MFIRST+80H    ;set first char of first menu
  612.  
  613. ;
  614. ;  Entry Point for Menu Display
  615. ;    On entry, HL pts to first byte of current menu
  616. ;
  617. dmenu:
  618.     mvi    b,1        ;shell message 1 contains menu number
  619.     call    getshm        ;get menu number flag
  620.     cnz    mchc0        ;skip to proper menu
  621.     shld    cstart        ;save start address of current menu
  622.     lda    cflag        ;copy display command flag for temp use
  623.     sta    cpflag
  624.     lda    dflag        ;copy display menu flag for temp use
  625.     sta    dpflag
  626.     lda    pflag        ;copy paging flag for temp use
  627.     sta    ppflag
  628.     inx    h        ;pt to first char after menu indicator char
  629. dispm1:
  630.     mov    a,m        ;get char
  631.     call    caps        ;capitalize
  632.     inx    h        ;pt to next
  633.     cpi    CR        ;end of options?
  634.     brz    dispm2
  635. ;
  636.     if    sysmenu
  637.     cpi    RSM        ;system menu?
  638.     brz    dispm1        ;ok if so
  639.     endif        ;sysmenu
  640. ;
  641.     cpi    COPTION        ;command display?
  642.     brz    dispmc
  643.     cpi    DOPTION        ;display?
  644.     brz    dispmd
  645.     cpi    POPTION        ;paging?
  646.     brz    dispmp
  647.     cpi    XOPTION        ;ZCPR3 return?
  648.     jnz    mstrerr        ;error if not
  649. ;
  650. ;  Toggle ZCPR3 Return Option
  651. ;
  652.     lda    cpmok        ;get flag
  653.     cma            ;toggle
  654.     sta    cpmok
  655.     br    dispm1
  656. ;
  657. ;  Toggle Paging Option
  658. ;
  659. dispmp:
  660.     lda    ppflag        ;get flag
  661.     cma            ;toggle
  662.     sta    ppflag
  663.     br    dispm1
  664. ;
  665. ;  Toggle Display Menu Option
  666. ;
  667. dispmd:
  668.     lda    dpflag        ;get flag
  669.     cma            ;toggle
  670.     sta    dpflag
  671.     br    dispm1
  672. ;
  673. ;  Toggle Display Command Option
  674. ;
  675. dispmc:
  676.     lda    cpflag        ;get flag
  677.     cma            ;toggle
  678.     sta    cpflag
  679.     br    dispm1
  680. ;
  681. ;  Done with Menu-Specific Option Processing
  682. ;
  683. dispm2:
  684.     call    lskip        ;skip to LF
  685.     lda    dpflag        ;display menu?
  686.     ora    a        ;0=no
  687.     brz    dispm8        ;skip over menu if not
  688.     call    getnlines    ;get line count in A
  689.     sta    pagcnt        ;set count
  690.     lda    ppflag        ;paging?
  691.     ora    a        ;0=no
  692.     push    psw        ;save flag
  693.     cnz    cls        ;clear screen if so
  694.     pop    psw        ;get flag
  695.     cz    crlf        ;else new line
  696. ;
  697. ;  Print Next Line of Menu if not Starting with ESCAPE Char (MINDIC)
  698. ;
  699. dispm3:
  700.     mov    a,m        ;get first char of line
  701.     ani    7FH        ;mask
  702.     cpi    MINDIC        ;done?
  703.     brz    dispm4
  704.     call    expand        ;expand line pted to by HL
  705.     push    h        ;save ptr to next line
  706.     xchg            ;HL pts to expanded line
  707.     call    lprintx        ;print line pted to by HL ending in <CR>
  708.     pop    h        ;pt to next line
  709.     br    dispm3
  710. ;
  711. ;  Done with Menu Display -- Page it out
  712. ;
  713. dispm4:
  714.     call    lskip        ;skip to first char of next line (option char)
  715.     shld    optstrt        ;set start address of options
  716.     lda    pagcnt        ;number of remaining lines
  717.     mov    b,a        ;count in B
  718.     ora    a        ;ok?
  719.     brz    dispm6        ;don't do anything if already there
  720.     lda    ppflag        ;page?
  721.     ora    a        ;0=No
  722.     brz    dispm6
  723. ;
  724. ;  Page Loop for Menu Display
  725. ;
  726. dispm5:
  727.     call    crlf        ;new line
  728.     bjnz    dispm5
  729. ;
  730. ;  Determine if Another Menu Follows
  731. ;
  732. dispm6:
  733.     xra    a        ;A=0
  734.     sta    nmenfl        ;set for no next menu
  735.     mov    a,m        ;ok?
  736.     ani    7FH        ;mask
  737.     cpi    CTRLZ        ;error if EOF
  738.     jz    mstrerr
  739.     cpi    MINDIC        ;next menu?
  740.     brnz    dispm7
  741.     inx    h        ;double indicator if end
  742.     mov    a,m
  743.     cpi    MINDIC        ;end?
  744.     brz    dispm9
  745. ;
  746.     if    sysmenu
  747.     cpi    RSM        ;system menu = no next menu
  748.     brz    dispm9
  749.     endif        ;sysmenu
  750. ;
  751.     mvi    a,0FFH        ;set next menu
  752.     sta    nmenfl
  753.     br    dispm9
  754. dispm7:
  755.     call    lskip        ;skip to next line
  756.     br    dispm6
  757.  
  758. ;
  759. ;  Skip over current menu so it is not displayed
  760. ;
  761. dispm8:
  762.     call    lskipt        ;skip to beginning of command
  763.     brnz    dispm8
  764.     call    lskip        ;skip over end of display indicator
  765.     shld    optstrt        ;set pointer to options
  766.     br    dispm6        ;determine if next menu available
  767. dispm9:
  768.  
  769. ;
  770. ;  Ready for Option Input
  771. ;    The following Flags/Values are now set:
  772. ;    CPFLAG -- Display Command Flag (0=No, 0FFH=Yes)
  773. ;    DPFLAG -- Display Menu Flag (0=No, 0FFH=Yes)
  774. ;    OPTSTRT -- Address of First Menu Option
  775. ;    NMENFL -- 0 if no next menu, 0FFH if next menu
  776. ;    MSTART -- Start Address of MINDIC Before Menu Display
  777. ;      (MSTART)=MFIRST with MSB Set
  778. prompt:
  779.     call    stndout        ;begin standout
  780.     mvi    a,0ffh
  781.     sta    pagcnt        ;turn off paging
  782.     sta    dpflag        ;turn on future menu displays
  783.     call    retud        ;get DU
  784.     mov    a,b        ;print D
  785.     adi    'A'
  786.     call    cout
  787.     mov    a,c        ;print U
  788.     call    pafdc
  789.     call    eprint
  790.     db    '> Command (CR=Menu',0
  791.     lda    cpmok        ;OK to return to ZCPR3?
  792.     ora    a        ;0=No
  793.     cnz    prmptc
  794.     lhld    cstart        ;pt to first char
  795.     mov    a,m        ;get it
  796.     ani    7FH        ;mask
  797.     cpi    MFIRST
  798.     cnz    prmptf        ;print previous menu prompt if not first menu
  799.     lda    nmenfl        ;next menu available?
  800.     ora    a        ;0=No
  801.     cnz    prmptn        ;print next menu prompt
  802.     call    eprint
  803.     db    ') - ',0
  804.     call    stndend        ;end standout
  805. prompt1:
  806.     call    cin        ;get response
  807.     call    caps        ;capitalize
  808.     mov    b,a        ;result in B
  809.  
  810. ;
  811. ;  Check for CR
  812. ;
  813.     cpi    CR        ;<CR>?
  814.     jz    dispm2        ;reprint menu if so
  815.  
  816. ;
  817. ;  Check for Reboot
  818. ;
  819.     lda    cpmok        ;ok to abort?
  820.     ora    a        ;0=No
  821.     brz    prmpt0
  822.     mov    a,b        ;get command
  823.     cpi    CTRLC        ;reboot?
  824.     jz    shpop        ;pop shell stack and return to OS if so
  825.  
  826. ;
  827. ;  Check for Command to Return to First Menu
  828. ;
  829. prmpt0:
  830.     mov    a,m        ;get it
  831.     ani    7FH        ;mask
  832.     cpi    MFIRST
  833.     brz    prmpt1
  834.     mov    a,b        ;get command
  835.     cpi    RFM        ;return to first menu?
  836.     brnz    prmpt1
  837.     lhld    mstart        ;pt to first menu
  838.     mvi    b,1        ;shell message 1 is menu number
  839.     xra    a        ;A=0=menu 0
  840.     jmp    putshm        ;reenter shell at first menu
  841.  
  842. ;
  843. ;  Check for Command to go to Next Menu
  844. ;
  845. prmpt1:
  846.     lda    nmenfl        ;next menu available?
  847.     ora    a        ;0=No
  848.     brz    prmpt2
  849.     mov    a,b        ;get command
  850.     cpi    RNMP        ;goto next menu?
  851.     brz    rnmx
  852.     cpi    RNM        ;goto next menu?
  853.     brnz    prmpt2
  854. rnmx:
  855.     mvi    b,1        ;shell message 1 is menu number
  856.     call    getshm        ;increment menu number
  857.     inr    a
  858.     jmp    putshm        ;reenter menu system at new menu
  859.  
  860. ;
  861. ;  Check for Command to go to Last Menu
  862. ;
  863. prmpt2:
  864.     mov    a,m        ;get menu char
  865.     ani    7FH        ;at first menu?
  866.     cpi    MFIRST
  867.     brz    prmpt3        ;skip if at first menu
  868.     mov    a,b        ;get command
  869.     cpi    RLMP        ;goto last menu?
  870.     brz    lstmnu
  871.     cpi    RLM        ;goto last menu?
  872.     brnz    prmpt3
  873. lstmnu:
  874.     mvi    b,1        ;shell message 1 is menu number
  875.     call    getshm        ;decrement menu number
  876.     dcr    a
  877.     jmp    putshm        ;reenter shell at last menu
  878.  
  879. ;
  880. ;  Check for Command to goto System Menu
  881. ;
  882. prmpt3:
  883.     if    sysmenu
  884. ;
  885.     lda    smenfl        ;system menu available?
  886.     ora    a        ;0=No
  887.     brz    prmpt4
  888.     mov    a,b        ;get command
  889.     cpi    RSM        ;system menu?
  890.     brnz    prmpt4
  891.     call    password    ;prompt for and get password
  892.     jnz    prompt        ;reprompt if error
  893.     lhld    smenadr        ;get address of system menu
  894.     lda    smeno        ;set system menu number
  895.     mvi    b,1        ;shell message 1 is menu number
  896.     jmp    putshm        ;reenter shell at system menu
  897. ;
  898.     endif        ;sysmenu
  899. ;
  900. ;  This is where additional functions may be added
  901. ;
  902. prmpt4:
  903.  
  904. ;
  905. ;  Check for Option Letter
  906. ;
  907.     lhld    optstrt        ;pt to first option char
  908. prmptx:
  909.     mov    a,m        ;get it
  910.     call    caps        ;capitalize
  911.     cpi    MINDIC        ;at next menu?
  912.     brz    prmpter
  913.     cmp    b        ;match user selection?
  914.     brz    prmptd
  915.     call    lskip        ;skip to next line
  916.     br    prmptx
  917.  
  918. ;
  919. ;  Invalid Option
  920. ;
  921. prmpter:
  922.     call    eprint
  923.     db    BEL,0
  924.     jmp    prompt1
  925.  
  926. ;
  927. ;  Process Option
  928. ;
  929. prmptd:
  930.     mov    a,b        ;output user selection
  931.     call    cout
  932.     mvi    b,0        ;shell message 0, bit 7 = wait flag
  933.     call    getshm
  934.     ani    7FH        ;set no wait
  935.     call    putshm
  936.     inx    h        ;pt to first letter of command
  937.     mov    a,m        ;get it
  938.     cpi    MCMD        ;invoke other menu?
  939.     jz    mchcmd        ;menu change command
  940.     cpi    WOPTION        ;turn on wait?
  941.     brnz    prmptg
  942.     mvi    b,0        ;shell message 0, bit 7 = wait flag
  943.     call    getshm
  944.     ori    80h        ;set wait flag
  945.     call    putshm        ;set shell message
  946.     inx    h        ;skip option char
  947. prmptg:
  948.     call    expand        ;expand line, DE pts to result
  949. ;
  950. ; Run Command Pted to by DE
  951. ;
  952. runcmnd:
  953.     call    getcl1        ;get address of command buffer
  954.     mov    b,h        ;... in BC also
  955.     mov    c,l
  956.     mvi    a,4        ;HL=HL+4 for address of first char
  957.     add    l
  958.     mov    l,a
  959.     mov    a,h
  960.     aci    0
  961.     mov    h,a
  962.     mov    a,l        ;store address
  963.     stax    b
  964.     inx    b
  965.     mov    a,h
  966.     stax    b
  967. ;
  968. ; Copy Command Line in DE into Buffer in HL
  969. ;
  970. cmdcpy:
  971.     ldax    d        ;get command letter
  972.     call    caps        ;capitalize it
  973.     ora    a        ;done?
  974.     brz    ccpyd
  975.     cpi    CR        ;done?
  976.     brz    ccpyd
  977.     cpi    PCHAR        ;prompt?
  978.     brz    ccpyp
  979.     mov    m,a        ;store it
  980.     inx    h        ;pt to next
  981.     inx    d
  982.     br    cmdcpy
  983. ccpyd:
  984.     mvi    m,0        ;store ending 0
  985.     jmp    cmddisp        ;optionally display command
  986. ;
  987. ;  Prompt User for Input and Accept It
  988. ;
  989. ccpyp:
  990.     inx    d        ;pt to first char of prompt
  991.     call    crlf        ;new line
  992. ccpyp1:
  993.     ldax    d        ;get char
  994.     cpi    PCHAR        ;end of prompt?
  995.     brz    ccpyp2
  996.     cpi    CR        ;new line?
  997.     brz    ccpyp3
  998.     call    cout        ;echo char
  999.     inx    d        ;pt to next char
  1000.     br    ccpyp1        ;continue looping
  1001. ccpyp2:
  1002.     inx    d        ;pt to char after closing PCHAR
  1003. ccpyp3:
  1004.     push    d        ;save ptr to next char
  1005.     xchg            ;DE pts to buffer
  1006.     mvi    a,0FFH        ;capitalize input from user
  1007.     lhld    ibuff        ;input line buffer
  1008.     call    bline        ;get input from user
  1009.     xchg            ;HL pts to buffer, DE pts to user input
  1010. cmdlp:
  1011.     ldax    d        ;get char from user
  1012.     ora    a        ;end of input?
  1013.     brz    cmdlp1        ;store rest of line
  1014.     mov    m,a        ;store char
  1015.     inx    h        ;pt to next
  1016.     inx    d
  1017.     br    cmdlp
  1018. cmdlp1:
  1019.     pop    d        ;DE pts to next char, HL pts to buffer
  1020.     br    cmdcpy        ;resume copying
  1021. ;
  1022. ;  Check for Display of Loaded Command and Do So if Set
  1023. ;
  1024. cmddisp:
  1025.     lda    cpflag        ;display command?
  1026.     ora    a        ;0=No
  1027.     rz            ;return to OS if so to run command
  1028.     call    crlf        ;new line
  1029.     call    getcl1        ;pt to first char
  1030.     mov    e,m        ;get low-order address
  1031.     inx    h
  1032.     mov    d,m        ;get high-order address
  1033.     xchg            ;HL pts to first char
  1034. cmdd1:
  1035.     mov    a,m        ;get char
  1036.     cpi    CMDSEP        ;done if command separator
  1037.     rz
  1038.     inx    h        ;pt to next
  1039.     call    cout        ;print char
  1040.     br    cmdd1
  1041.  
  1042. ;
  1043. ;  Menu Change Command -- Jump to Specified Menu
  1044. ;
  1045. mchcmd:
  1046.     inx    h        ;pt to menu number
  1047.     call    eval        ;convert to decimal number in A
  1048.     sta    menuno        ;save menu number
  1049.     call    mchc0        ;skip to desired menu to check for it
  1050.     lda    menuno        ;get menu number
  1051.     mvi    b,1        ;menu number is shell message 1
  1052.     jmp    putshm        ;set message and reenter shell
  1053.  
  1054. ;
  1055. ;  Entry Point if MENU is Reinvoked
  1056. ;
  1057. mchc0:
  1058.     mov    b,a        ;menu number in B
  1059.     inr    b        ;add 1 for initial offset
  1060.     lhld    mstart        ;pt to first menu
  1061. mchc1:
  1062.     dcr    b        ;count down
  1063.     rz            ;done if found
  1064. mchc2:
  1065.     call    lskipt        ;skip to next line
  1066.     brnz    mchc2        ;continue if not end of menu display
  1067. mchc3:
  1068.     call    lskipt        ;skip to next line
  1069.     brnz    mchc3        ;continue if not at end of menu commands
  1070.     inx    h        ;end of MENU.MNU?
  1071.     mov    a,m        ;yes if double MINDIC
  1072.     ani    7FH        ;mask
  1073.     cpi    MINDIC
  1074.     brz    mchcerr        ;error if so
  1075.     dcx    h        ;pt to first char
  1076.     br    mchc1        ;continue
  1077. ;
  1078. ; Premature End of Menu File
  1079. ;
  1080. mchcerr:
  1081.     pop    psw        ;clear stack
  1082.     jmp    mstrerr        ;menu structure error
  1083.  
  1084. ;
  1085. ;  Print Line pted to by HL Ending in <CR>
  1086. ;    Decrement PAGCNT
  1087. ;
  1088. lprintx:
  1089.     call    lprint        ;print without <CR>
  1090.     jmp    crlf        ;do <CR> <LF>
  1091. ;
  1092. ;  Print Line Pted to by HL; Decrement PAGCNT
  1093. ;
  1094. lprint:
  1095.     mvi    b,0        ;set tab counter
  1096. lprnt0:
  1097.     mov    a,m        ;get char
  1098.     inx    h        ;pt to next
  1099.     ani    7FH        ;mask MSB
  1100.     cpi    DIM        ;goto standout mode?
  1101.     brz    lprnt3
  1102.     cpi    NOTDIM        ;end standout mode?
  1103.     brz    lprnt4
  1104.     cpi    TAB        ;tabulate?
  1105.     brz    lprnt2
  1106.     cpi    CR        ;done?
  1107.     brz    lprnt1
  1108.     call    cout        ;print
  1109.     inr    b        ;incr tab counter
  1110.     br    lprnt0
  1111. lprnt1:
  1112.     inx    h        ;pt to first char of next line
  1113.     lda    pagcnt        ;count down pages
  1114.     dcr    a
  1115.     sta    pagcnt
  1116.     rnz
  1117.     call    getnlines    ;get line count in A
  1118.     sta    pagcnt
  1119.     call    eprint
  1120.     db    CR,LF,'Pause -',0
  1121.     br    sak1
  1122. lprnt2:
  1123.     mvi    a,' '        ;print <SP>
  1124.     call    cout
  1125.     inr    b        ;incr tab counter
  1126.     mov    a,b        ;done?
  1127.     ani    7        ;every 8
  1128.     brnz    lprnt2
  1129.     br    lprnt0
  1130. lprnt3:
  1131.     call    stndout        ;enter standout mode
  1132.     br    lprnt0
  1133. lprnt4:
  1134.     call    stndend        ;end standout mode
  1135.     br    lprnt0
  1136. ;
  1137. ;  Strike Any Key Message
  1138. ;
  1139. sak:
  1140.     mvi    b,0        ;clear any pending wait
  1141.     call    getshm
  1142.     ani    7FH        ;mask MSB
  1143.     call    putshm
  1144. sak1:
  1145.     call    stndout        ;goto standout
  1146.     call    eprint
  1147.     db    ' Strike Any Key - ',0
  1148.     call    stndend        ;exit standout
  1149.     call    cin        ;get response
  1150.     call    crlf        ;new line
  1151.     ret
  1152.  
  1153. ;
  1154. ;  Prompt for, input, and check password (only one chance)
  1155. ;    If accepted, return with Zero Flag Set; if not, return with NZ
  1156. ;
  1157.     if    sysmenu
  1158. password:
  1159.     call    eprint
  1160.     db    CR,LF,'Pass? ',0
  1161.     lhld    ibuff        ;pt to input line buffer
  1162.     xra    a        ;don't capitalize user input
  1163.     call    bline        ;get line from user
  1164.     lxi    d,ppass        ;pt to system password
  1165. pass1:
  1166.     ldax    d        ;get sys pass char
  1167.     cmp    m        ;ok?
  1168.     brnz    passerr        ;error if no match
  1169.     inx    h        ;pt to next
  1170.     inx    d
  1171.     ora    a        ;end of strings?
  1172.     brnz    pass1
  1173.     ret            ;return with zero set to show match
  1174. passerr:
  1175.     call    eprint
  1176.     db    CR,LF,' Password Error',0
  1177.     call    sak1        ;strike any key
  1178.     call    crlf
  1179.     mvi    a,0FFH        ;set no zero
  1180.     ora    a
  1181.     ret
  1182.     endif        ;sysmenu
  1183. ;
  1184. ;  Skip to Beginning of Next Line and Test First Char for Menu Indicator
  1185. ;
  1186. lskipt:
  1187.     call    lskip        ;skip
  1188.     mov    a,m        ;get char
  1189.     ani    7FH        ;mask
  1190.     cpi    MINDIC        ;test
  1191.     ret
  1192.  
  1193. ;
  1194. ;  Skip to Beginning of Next Line
  1195. ;
  1196. lskip:
  1197.     mov    a,m        ;get char
  1198.     ani    7FH        ;mask out MSB
  1199.     inx    h        ;pt to next
  1200.     cpi    LF
  1201.     brnz    lskip
  1202.     ret
  1203.  
  1204. ;
  1205. ;  Print ZCPR3 Return Prompt
  1206. ;
  1207. prmptc:
  1208.     call    eprint
  1209.     db    ', ^C=Z3',0
  1210.     ret
  1211. ;
  1212. ;  Print First/Last Menu Chars
  1213. ;
  1214. prmptf:
  1215.     call    eprint
  1216.     db    ', ',RFM,'=1st Menu, ',RLM,'=Prev Menu',0
  1217.     ret
  1218. ;
  1219. ;  Print next menu message
  1220. ;
  1221. prmptn:
  1222.     call    eprint
  1223.     db    ', ',RNM,'=Next Menu',0
  1224.     ret
  1225.  
  1226. ;
  1227. ;  Menu Structure Error -- FATAL
  1228. ;    This message is printed to indicate an error in the structure of
  1229. ; the MENU.MNU file.
  1230. ;
  1231. mstrerr:
  1232.     call    eprint
  1233.     db    CR,LF,' Structure Error',0
  1234.     jmp    shpop
  1235.  
  1236. ;
  1237. ; Expand Line Pted to by HL into Scratch Area
  1238. ;    Return with HL pting to next line, DE pting to current line
  1239. ;
  1240. expand:
  1241.     xchg
  1242.     lhld    expline        ;pt to buffer
  1243.     xchg
  1244. exp1:
  1245.     mov    a,m        ;get next char
  1246.     ani    7fh        ;mask MSB
  1247.     stax    d        ;store char
  1248.     cpi    CR        ;end of line?
  1249.     jz    expx
  1250.     inx    h        ;pt to next
  1251.     inx    d
  1252.     cpi    VARFLAG        ;variable follows?
  1253.     brnz    exp1
  1254. ;
  1255. ; Variable Identified - Process it
  1256. ;
  1257.     mov    a,m        ;get next char
  1258.     inx    h        ;pt to next
  1259.     cpi    VARFLAG        ;one variable char?
  1260.     brz    exp1        ;resume if double VARFLAG
  1261.     dcx    d        ;pt to variable position
  1262.     call    caps        ;capitalize variable
  1263.     cpi    'D'        ;current disk?
  1264.     brz    expdisk
  1265.     cpi    'U'        ;current user?
  1266.     brz    expuser
  1267.     cpi    'F'        ;filename.typ?
  1268.     brz    expfile
  1269.     cpi    'N'        ;filename?
  1270.     brz    expname
  1271.     cpi    'T'        ;filetype?
  1272.     brz    exptype
  1273.     br    exp1        ;resume expansion
  1274. ;
  1275. ; Expand Exit
  1276. ;
  1277. expx:
  1278.     inx    h        ;pt to line feed
  1279.     mov    a,m        ;get it
  1280.     cpi    LF        ;line feed?
  1281.     brnz    expx1
  1282.     inx    h        ;pt to char after line feed
  1283. expx1:
  1284.     xchg            ;DE pts to next line
  1285.     lhld    expline        ;pt to expanded line
  1286.     xchg            ;HL pts to next line, DE pts to expanded line
  1287.     ret
  1288.  
  1289. ;
  1290. ; Expand Disk
  1291. ;
  1292. expdisk:
  1293.     call    retud        ;get disk in B
  1294.     mov    a,b        ;get disk number (A=0)
  1295.     adi    'A'        ;convert to ASCII
  1296.     stax    d        ;store letter
  1297.     inx    d        ;pt to next
  1298.     br    exp1        ;resume expansion
  1299. ;
  1300. ; Expand User
  1301. ;
  1302. expuser:
  1303.     call    retud        ;get user in C
  1304.     mov    a,c        ;get user number
  1305.     mvi    b,10        ;subtract 10's
  1306.     mvi    c,'0'        ;set char
  1307. expu1:
  1308.     sub    b        ;-10
  1309.     brc    expu2
  1310.     inr    c        ;increment digit
  1311.     br    expu1
  1312. expu2:
  1313.     add    b        ;+10
  1314.     adi    '0'        ;convert 1's to ASCII
  1315.     mov    b,a        ;B=1's
  1316.     mov    a,c        ;get 10's
  1317.     stax    d        ;store 10's
  1318.     inx    d
  1319.     mov    a,b        ;get 1's
  1320.     stax    d        ;store 1's
  1321.     inx    d        ;pt to next
  1322.     br    exp1        ;resume
  1323. ;
  1324. ; Expand File
  1325. ;
  1326. expfile:
  1327.     call    getfnum        ;get file number
  1328.     jz    exp1        ;resume if error
  1329.     push    h        ;save ptr to next char
  1330.     call    ptfn        ;set ptr to file name
  1331.     call    putn        ;put file name
  1332.     mvi    a,'.'
  1333.     stax    d        ;store dot
  1334.     inx    d        ;pt to next
  1335.     call    putt        ;put file type
  1336.     pop    h        ;restore ptr
  1337.     jmp    exp1        ;resume
  1338. ;
  1339. ; Expand Name
  1340. ;
  1341. expname:
  1342.     call    getfnum        ;get file number
  1343.     jz    exp1        ;resume if error
  1344.     push    h        ;save ptr to next char
  1345.     call    ptfn        ;set ptr to file name
  1346.     call    putn        ;put file name
  1347.     pop    h        ;restore ptr
  1348.     jmp    exp1        ;resume
  1349. ;
  1350. ; Expand Type
  1351. ;
  1352. exptype:
  1353.     call    getfnum        ;get file number
  1354.     jz    exp1        ;resume if error
  1355.     push    h        ;save ptr to next char
  1356.     call    ptfn        ;set ptr to file name
  1357.     mvi    a,8        ;add 8
  1358.     add    l
  1359.     mov    l,a
  1360.     mov    a,h
  1361.     aci    0
  1362.     mov    h,a
  1363.     call    putt        ;put file type
  1364.     pop    h
  1365.     jmp    exp1        ;resume
  1366. ;
  1367. ; Pt to File Name whose Number (1-4) is in A
  1368. ;
  1369. ptfn:
  1370.     mov    b,a        ;get number in B
  1371.     call    getfn2        ;pt to file name 2
  1372.     push    d        ;save DE
  1373.     mov    a,b        ;file 0?
  1374.     ora    a
  1375.     brz    ptfnx
  1376.     lxi    d,11        ;size of file name and type
  1377. ptfn1:
  1378.     dad    d        ;pt to next
  1379.     bjnz    ptfn1
  1380. ptfnx:
  1381.     pop    d        ;restore DE
  1382.     ret
  1383. ;
  1384. ; Put File Name pted to by HL
  1385. ;
  1386. putn:
  1387.     mvi    b,8        ;8 chars
  1388.     br    putc
  1389. ;
  1390. ; Put File Type pted to by HL
  1391. ;
  1392. putt:
  1393.     mvi    b,3        ;3 chars
  1394. ;
  1395. ; Copy Chars from HL to DE for up to B bytes -- flush if space
  1396. ;
  1397. putc:
  1398.     mov    a,m        ;get next char
  1399.     cpi    ' '        ;skip spaces
  1400.     brz    putc1
  1401.     stax    d        ;put next char
  1402.     inx    d        ;pt to next
  1403. putc1:
  1404.     inx    h        ;pt to next
  1405.     bjnz    putc
  1406.     ret
  1407.  
  1408. ;
  1409. ; Get File Number (1 to 4)
  1410. ;    If valid number, return with value in A and HL pting to next char
  1411. ;    If not valid, return with Z and HL pting to last char (F, N, T)
  1412. ;
  1413. getfnum:
  1414.     mov    a,m        ;get char
  1415.     sui    '1'        ;convert
  1416.     brc    getfne        ;error
  1417.     cpi    4        ;range?
  1418.     brnc    getfne
  1419.     inx    h        ;pt to next char
  1420.     ret            ;NZ from CPI 4
  1421. getfne:
  1422.     dcx    h        ;error return
  1423.     xra    a
  1424.     ret
  1425.  
  1426. ;
  1427. ;  Return Number of Lines on CRT in A
  1428. ;
  1429. getnlines:
  1430.     push    h        ;save HL
  1431.     call    getcrt        ;get CRT info
  1432.     inx    h        ;pt to number of lines
  1433.     mov    a,m        ;get count
  1434.     pop    h        ;restore HL
  1435.     dcr    a        ;subtract 1 for footer
  1436.     ret
  1437.  
  1438. ;
  1439. ;  Convert char string pted to by HL into decimal number in A
  1440. ;    On Entry, HL pts to first digit char
  1441. ;    On Exit, HL pts to after last digit char and A=number
  1442. ;
  1443. eval:
  1444.     push    b        ;save BC
  1445.     mvi    b,0        ;set value
  1446. eval1:
  1447.     mov    a,m        ;get digit
  1448.     sui    '0'        ;convert to binary
  1449.     brc    eval2
  1450.     cpi    10        ;range?
  1451.     brnc    eval2
  1452.     inx    h        ;pt to next digit
  1453.     mov    c,a        ;new digit in C
  1454.     mov    a,b        ;multiply B by 10
  1455.     add    a        ;*2
  1456.     add    a        ;*4
  1457.     add    b        ;*5
  1458.     add    a        ;*10
  1459.     add    c        ;add in new digit
  1460.     mov    b,a        ;result in B
  1461.     br    eval1
  1462. eval2:
  1463.     mov    a,b        ;result in A
  1464.     pop    b        ;restore ptr
  1465.     ret
  1466.  
  1467. ;
  1468. ;  These buffers overlay the scratch area to save space
  1469. ;
  1470. optstrt    equ    scratch        ;Address of First Option in Current Menu
  1471. mstart    equ    optstrt+2    ;Address of First Menu
  1472. cstart    equ    mstart+2    ;Address of Current Menu
  1473. smenfl    equ    cstart+2    ;System Menu Available Flag (0=No)
  1474. smeno    equ    smenfl+1    ;System Menu Number
  1475. smenadr    equ    smeno+1        ;Address of First Byte of System Menu
  1476. nmenfl    equ    smenadr+2    ;Next Menu Available Flag (0=No)
  1477. menuno    equ    nmenfl+1    ;Number of Menu
  1478. pagcnt    equ    menuno+1    ;Paging Counter
  1479. cflag    equ    pagcnt+1    ;Display Command Line Flag
  1480. dflag    equ    cflag+1        ;Display Menu Flag
  1481. pflag    equ    dflag+1        ;Paging Flag
  1482.  
  1483. ;
  1484. ;  Buffers
  1485. ;
  1486. ibuff:
  1487.     ds    2        ;input line buffer
  1488. expline:
  1489.     ds    2        ;scratch area to expand lines in
  1490. cpflag:
  1491.     ds    1        ;Temp Display Command Line Flag
  1492. dpflag:
  1493.     ds    1        ;Temp Display Menu Flag
  1494. ppflag:
  1495.     ds    1        ;Temp Paging Flag
  1496. cpmok:
  1497.     ds    1        ;OK to Return to ZCPR3 (0=No)
  1498. tnum:
  1499.     ds    41        ;space for chars and ending 0
  1500. shdisk:
  1501.     db    'A'        ;disk to return to
  1502.     db    '00'        ;user to return to
  1503.     db    ':;'        ;log in and next command
  1504. shname:
  1505.     db    'MENU    '    ;program name (filled in at installation)
  1506. shfile:
  1507.     ds    13        ;file name (12) and ending 0
  1508.  
  1509.     end
  1510.