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 / VMENU.MAC < prev    next >
Text File  |  2000-06-30  |  54KB  |  2,655 lines

  1. ;  PROGRAM:  VMENU
  2. ;  VERSION:  1.0
  3. ;  DATE:  26 June 84
  4. ;  AUTHOR:  Richard Conn
  5. ;  PREVIOUS VERSIONS:  None
  6. ;
  7. z3env    equ    0f400h
  8. VERS    EQU    10        ;version number
  9.  
  10. ; VMENU is copyright (c) 1984 by Richard Conn
  11. ; All Rights Reserved
  12. ; VMENU may be used freely by the ZCPR3 Community
  13.  
  14. ; VMENU is a screen-oriented, ZCPR3-specific file utility.  It can not be
  15. ; installed to run under conventional CP/M.  VMENU
  16. ; extensively employs cursor addressing to position a pointer on the
  17. ; screen, allow the user to manipulate the pointer (up, down, right, left,
  18. ; next screen, previous screen, GOTO file).  The pointer points to files
  19. ; in the current user directory and displays the user's position dynamically
  20. ; on the screen.  Once pointing to a file, user commands can be used to
  21. ; manipulate the file according to options presented in the menu displayed to
  22. ; the user.  MENU and VMENU are compatible.  In the way of being ZCPR3-
  23. ; specific, VMENU can chain to external programs via the Command Line Buffer
  24. ; and then return, and it recognizes Named Directories (so the user can log
  25. ; into B:, B4:, and MYDIR:, for example).
  26.  
  27. ; VMENU is installed by Z3INS.
  28.  
  29. ; VMENU works with ZCPR3 only, with 32k or more of RAM.
  30.  
  31. ; VMENU can be assembled for use with a Z80 or 8080 microprocessor.
  32.  
  33. ;
  34. ;  SYSLIB, Z3LIB, and VLIB References
  35. ;
  36.     ext    z3vinit,cls,gotoxy,ereol,vprint,envptr,stndout,stndend
  37.     ext    pafdc,dutdir
  38.     ext    qshell,getefcb,shpush,shpop,getcrt,getfn2,zprsfn
  39.     ext    putshm,getshm,getsh,getzrun,getcl1,putzex,putcst
  40.     ext    cin,cout,caps,crlf,bline,sksp
  41.     ext    f$open,f$read,f$close,initfcb
  42.     ext    retud
  43.     ext    codend
  44.  
  45. ;
  46. ;  Basic Definitions
  47. ;
  48. TRUE     EQU    0FFH        ;define true and..
  49. FALSE     EQU    0           ;..false.
  50. ;
  51. DIM     EQU    1        ;GOTO DIM
  52. BRIGHT     EQU    2        ;GOTO BRIGHT
  53. ELTSIZ     EQU    11        ;size of file name and type element
  54.  
  55. ;
  56. ; User-Customized Definition
  57. ;
  58. VMNAME     MACRO            ;;Name of VMENU
  59.      DB    'VMENU'
  60.      ENDM
  61. VMNFILL     MACRO            ;;Spaces to fill out name to 8 chars
  62.      DB    '   '
  63.      ENDM
  64. ;
  65. Z80     EQU    TRUE         ;TRUE to use Z80 Instructions
  66. WARMBOOT EQU    FALSE        ;set TRUE to warmboot on exit
  67. EPS     EQU    4*4        ;N lines x 4 cols per screen
  68.                 ;  EPS = Entries Per Screen
  69.  
  70. ;
  71. ;  Command Line Builder Constants
  72. ;
  73. FPESC     EQU    '%'        ;escape char
  74. FPDISK     EQU    'D'        ;disk only (D)
  75. FPUSER     EQU    'U'        ;user only (U)
  76. FPFILE     EQU    'F'        ;filename.typ
  77. FPNAME     EQU    'N'        ;file name only
  78. FPTYPE     EQU    'T'        ;file type only
  79. FPPTR     EQU    'P'        ;file entry being pointed to
  80. MNOTE     EQU    '#'        ;denotes comment area in macro file
  81. UIN1     EQU    27H        ;single quote for user input
  82. UIN2     EQU    22H        ;double quote for user input
  83.  
  84. ;
  85. ;  Menu Constants
  86. ;
  87.  
  88. ;  1 Special Menu Command Chars
  89. RNM        EQU    '>'        ;NEXT MENU
  90. RNMP        EQU    '.'        ;NEXT MENU PRIME (ALTERNATE)
  91. RLM        EQU    '<'        ;LAST MENU
  92. RLMP        EQU    ','        ;LAST MENU PRIME (ALTERNATE)
  93. RFM        EQU    '*'        ;FIRST MENU
  94.  
  95. ;  2 Internal Menu Control Chars
  96. MCMD        EQU    ':'        ;COMMAND TO JUMP TO ANOTHER MENU
  97. PCHAR        EQU    '"'        ;INDICATES AUTO PROMPT FOR SPECIFIC CMD
  98. MINDIC        EQU    '#'        ;MENU SECTION INDICATOR
  99. MFIRST        EQU    '%'        ;FIRST MENU INDICATOR
  100. GOPTION        EQU    '-'        ;GLOBAL OPTION INDICATOR
  101. WOPTION        EQU    '!'        ;ACTIVATES WAIT UPON RETURN
  102.  
  103. ;  3 Menu Option Chars
  104. XOPTION        EQU    'X'        ;DISABLE ZCPR3 RETURN
  105.  
  106. ;  4 Miscellaneous
  107. IBUFSZ        EQU    254        ;SIZE OF INPUT LINE BUFFER
  108. VARFLAG        EQU    '$'        ;VARIABLE FLAG
  109.                     ;(FOLLOWED BY D,U,Fn,Nn,Tn)
  110. CMDSEP        EQU    ';'        ;ZCPR3 COMMAND SEPARATOR
  111.  
  112. ;
  113. ; Cursor Positioning Addresses
  114. ;
  115. EPSLINE    EQU    (EPS/4)+3    ;position of last line of EPS + 1
  116. BANADR    EQU    1*256+24    ;banner address
  117. CURHOME    EQU    3*256+1        ;home address of cursor
  118. BOTADR    EQU    23*256+1    ;bottom of screen
  119. CPMADR    EQU    22*256+1    ;command prompt message
  120. CPADR    EQU    CPMADR+27    ;command prompt address (cursor position)
  121. ERADR    EQU    CPMADR+256+15    ;error message
  122. FNADR    EQU    1*256+62    ;address of current file name
  123. MOREADR    EQU    FNADR+1*256    ;address of more files message
  124. DUADR    EQU    1*256+4        ;address of current DU
  125.  
  126. ;
  127. ; System Functions
  128. ;
  129. RDCON    EQU    1
  130. WRCON    EQU    2
  131. PUNCH    EQU    4
  132. LIST    EQU    5
  133. DIRCON    EQU    6
  134. RDBUF    EQU    10
  135. CONST    EQU    11
  136. LOGIN    EQU    14
  137. OPEN    EQU    15
  138. CLOSE    EQU    16
  139. SRCHF    EQU    17
  140. SRCHN    EQU    18
  141. ERASE    EQU    19
  142. READ    EQU    20
  143. WRITE    EQU    21
  144. MAKE    EQU    22
  145. REN    EQU    23
  146. INQDISK    EQU    25
  147. SETDMA    EQU    26
  148. INQALC    EQU    27
  149. ATTR    EQU    30
  150. GETPARM    EQU    31
  151. SGUSER    EQU    32
  152. COMPSZ    EQU    35
  153.  
  154. ;
  155. ; System Addresses
  156. ;
  157. OS$BASE EQU    000H        ;system base..
  158. CCP    EQU    800H        ;..and 'ccp' length in bytes.
  159. GET    EQU    0FFH        ;get user area e-reg value
  160. BDOS    EQU    OS$BASE+05H
  161. FCB    EQU    OS$BASE+5CH
  162. FCBEXT    EQU    FCB+12
  163. FCBRNO    EQU    FCB+32
  164. FCB2    EQU    OS$BASE+6CH
  165. TBUFF    EQU    OS$BASE+80H
  166. TPA    EQU    OS$BASE+100H
  167.  
  168. ;
  169. ; ASCII Definitions
  170. ;
  171. CTRLC    EQU    'C'-'@'        ;..control-C..
  172. CTRLD    EQU    'D'-'@'
  173. CTRLE    EQU    'E'-'@'
  174. CTRLR    EQU    'R'-'@'
  175. CTRLS    EQU    'S'-'@'        ;..XOFF..
  176. CTRLX    EQU    'X'-'@'
  177. BEL    EQU    07H        ;..bell..
  178. BS    EQU    08H        ;..backspace..
  179. TAB    EQU    09H        ;..tab..
  180. LF    EQU    0AH        ;..linefeed..
  181. FF    EQU    0CH        ;..formfeed..
  182. CR    EQU    0DH        ;..carriage return..
  183. CAN    EQU    18H        ;..cancel..
  184. EOFCHAR    EQU    1AH        ;..end-of-file..
  185. CTRLZ    EQU    1AH        ;..clear screen..
  186. ESC    EQU    1BH        ;..and escape character.
  187.  
  188. ;
  189. ; MACROS TO PROVIDE Z80 EXTENSIONS
  190. ;   MACROS INCLUDE:
  191. ;
  192. ;    BR    - JUMP RELATIVE
  193. ;    BRC    - JUMP RELATIVE IF CARRY
  194. ;    BRNC    - JUMP RELATIVE IF NO CARRY
  195. ;    BRZ    - JUMP RELATIVE IF ZERO
  196. ;    BRNZ    - JUMP RELATIVE IF NO ZERO
  197. ;    BJNZ    - DECREMENT B AND JUMP RELATIVE IF NO ZERO
  198. ;
  199. BR    MACRO    ?N    ;;JUMP RELATIVE
  200.     IF    Z80
  201.      .z80
  202.      jr    ?N
  203.      .8080
  204.     ELSE
  205.      jmp    ?N
  206.     ENDIF
  207.     ENDM
  208. ;
  209. BRC    MACRO    ?N    ;;JUMP RELATIVE ON CARRY
  210.     IF    Z80
  211.      .z80
  212.      jr    c,?N
  213.      .8080
  214.     ELSE
  215.      jc    ?N
  216.     ENDIF
  217.     ENDM
  218. ;
  219. BRNC    MACRO    ?N    ;;JUMP RELATIVE ON NO CARRY
  220.     IF    Z80
  221.      .z80
  222.      jr    nc,?N
  223.      .8080
  224.     ELSE
  225.      jnc    ?N
  226.     ENDIF
  227.     ENDM
  228. ;
  229. BRZ    MACRO    ?N    ;;JUMP RELATIVE ON ZERO
  230.     IF    Z80
  231.      .z80
  232.      jr    z,?N
  233.      .8080
  234.     ELSE
  235.      jz    ?N
  236.     ENDIF
  237.     ENDM
  238. ;
  239. BRNZ    MACRO    ?N    ;;JUMP RELATIVE ON NO ZERO
  240.     IF    Z80
  241.      .z80
  242.      jr    nz,?N
  243.      .8080
  244.     ELSE
  245.      jnz    ?N
  246.     ENDIF
  247.     ENDM
  248. ;
  249. BJNZ    MACRO    ?N    ;;DECREMENT B AND JUMP RELATIVE ON NO ZERO
  250.     IF    Z80
  251.      .z80
  252.      djnz    ?N
  253.      .8080
  254.     ELSE
  255.      dcr    b
  256.      jnz    ?N
  257.     ENDIF
  258.     ENDM
  259. ;
  260. ; END OF Z80 MACRO EXTENSIONS
  261. ;
  262.  
  263. ;
  264. ; Environment Definition
  265. ;
  266.     if    z3env ne 0
  267. ;
  268. ; External ZCPR3 Environment Descriptor
  269. ;
  270.     jmp    start
  271.     db    'Z3ENV'    ;This is a ZCPR3 Utility
  272.     db    1    ;External Environment Descriptor
  273. z3eadr:
  274.     dw    z3env
  275. start:
  276.     lhld    z3eadr    ;pt to ZCPR3 environment
  277. ;
  278.     else
  279. ;
  280. ; Internal ZCPR3 Environment Descriptor
  281. ;
  282.     MACLIB    Z3BASE.LIB
  283.     MACLIB    SYSENV.LIB
  284. z3eadr:
  285.     jmp    start
  286.     SYSENV
  287. start:
  288.     lxi    h,z3eadr    ;pt to ZCPR3 environment
  289.     endif
  290.  
  291. ;
  292. ; Start of Program -- Initialize ZCPR3 Environment
  293. ;  Once Environment is Initialized, One of Three Major Functions
  294. ;  will be Performed:
  295. ;    1.  VMENU will be installed as a Shell if invoked explicitly
  296. ;        by user command
  297. ;    2.  The VMENU Function will be performed if VMENU is invoked
  298. ;        by ZCPR3 as a Shell and ZEX is not Running
  299. ;    3.  A Command Line will be Input by VMENU from ZEX and Passed
  300. ;        on to ZCPR3 without Processing
  301. ;
  302.     call    z3vinit        ;initialize the ZCPR3 Env and the VLIB Env
  303. ;
  304. ;  Set Opsys Stack Pointer
  305. ;
  306.     if    not WARMBOOT
  307.     lxi    h,0        ;clear hl-pair then..
  308.     dad    sp        ;..add stack address.
  309.     shld    stack
  310.     endif            ;not warmboot
  311.  
  312. ;
  313. ; Check to see if VMENU was executed as a shell
  314. ;
  315.     call    qshell        ;get and test message from ZCPR3
  316.     jz    runsh        ;execute shell procedures
  317. ;
  318. ; Initialize VMENU as a Shell
  319. ;
  320.     call    shtest1        ;there must be a shell stack
  321.     call    shtest2        ;there must be a command line buffer
  322. ;
  323. ; FUNCTION 1:  Set Up VMENU as a Shell
  324. ;  Run Shell Via Exit to Opsys
  325. ;
  326.     call    getefcb        ;determine name of program
  327.     brz    shgo1        ;name not given, so use default
  328.     inx    h        ;pt to name
  329.     lxi    d,filercmd    ;define name of program
  330.     mvi    b,8
  331.     call    moveb        ;copy name
  332. shgo1:
  333.     lxi    h,filercmd    ;establish shell
  334.     call    shpush        ;push onto shell stack
  335.     brnz    shgo2        ;error?
  336. ;
  337. ;  Establish File Selection
  338. ;    3rd System File = Name of Menu File (2nd token)
  339. ;    4th System File = Name of AFN to Select Files (1st token)
  340. ;
  341.     call    getfn2        ;setup file name
  342.     lxi    d,11        ;use 2nd system file
  343.     dad    d
  344.     xchg            ;destination in DE
  345.     lxi    h,joker        ;pt to joker
  346.     mvi    b,11        ;copy joker into 2nd system file
  347.     call    move        ;... so selection is on joker
  348.     xchg            ;HL now pts to 3rd system file
  349.     push    h        ;save ptr to name of Menu File
  350.     lxi    d,fcb2+1    ;pt to FCB
  351.     xchg
  352.     mvi    b,11        ;copy 11 chars
  353.     call    move
  354.     push    d        ;save ptr to file spec
  355.     lxi    h,fcb+1        ;pt to FCB (use 4th system file name)
  356.     mvi    b,11        ;copy 11 chars
  357.     call    move
  358.     pop    d        ;get ptr to file spec
  359.     lxi    h,joker        ;make wild if none
  360.     mvi    b,11        ;11 chars
  361.     ldax    d        ;get first char
  362.     cpi    ' '        ;wild if space
  363.     cz    moveb        ;copy
  364.     ldax    d
  365.     cpi    '/'        ;wild if option
  366.     cz    moveb
  367.     pop    d        ;get ptr to name of menu file
  368.     lxi    h,menufile    ;pt to menu file name (default)
  369.     ldax    d        ;check for no file name given
  370.     mvi    b,11        ;11 chars
  371.     cpi    ' '        ;if none, set default
  372.     cz    moveb
  373.     lxi    b,8        ;check file type
  374.     dad    b
  375.     xchg
  376.     dad    b
  377.     xchg
  378.     ldax    d        ;check for file type
  379.     mvi    b,3        ;3 chars
  380.     cpi    ' '        ;if none, set default
  381.     cz    move
  382. ;
  383. ;  Print Done Message
  384. ;
  385. simsg:
  386.     mvi    a,0        ;default to menu 0
  387.     mvi    b,1        ;shell message 1 contains menu number
  388.     call    putshm
  389. ;
  390.     mvi    b,0        ;shell message 0
  391.     mvi    a,0        ;no wait
  392.     call    putshm        ;set shell message
  393. ;
  394.     call    vprint
  395.     db    ' Shell Installed',0
  396. ;
  397.     jmp    os$ccp1        ;return to opsys
  398. ;
  399. ;  Error in Shell Stack Installation
  400. ;
  401. shgo2:
  402.     cpi    2        ;shell stack full
  403.     brnz    shgo3
  404.     call    vprint
  405.     db    ' Shell Stack Full',0
  406.     ret
  407. shgo3:
  408.     call    vprint
  409.     db    ' Shell Entry Size',0
  410.     ret
  411.  
  412. ;
  413. ;  VMENU was invoked as a Shell
  414. ;    Check for ZEX Input in Progress
  415. ;
  416. runsh:
  417.     call    getzrun        ;check ZEX message byte
  418.     jnz    zexrun        ;process ZEX command line if ZEX running
  419. ;
  420. ;  Check for Delay Before Resuming VMENU and Delay if Set
  421. ;
  422.     mvi    b,0
  423.     call    getshm        ;get shell message 0
  424.     ani    80h        ;check MSB
  425.     cnz    sak        ;pause for input
  426.     mvi    a,0        ;set normal command status
  427.     call    putcst
  428. ;
  429. ; FUNCTION 2: Run VMENU and Perform Main Function
  430. ;
  431.     call    setup        ;init buffers and pointers
  432.     call    stackset    ;setup stack
  433. ;
  434. ;  Begin VMENU Processing
  435. ;
  436. runsh2:
  437.     call    stackset    ;reset stack
  438.     call    fileload    ;load files
  439.     call    setscr        ;set up screen display variables
  440.     call    findcfile    ;locate current file
  441.     call    menuload    ;load menu file
  442. ;
  443. ;  Entry Point for Command Processing
  444. ;    Display Screen and Input/Process Command
  445. ;
  446. runsh3:
  447.     call    stackset    ;reset stack
  448.     call    refresh        ;refresh screen display
  449. ;
  450. ;  Display Current File and Input/Process Command
  451. ;
  452. loopfn:
  453.     call    prcfn1        ;print current file name
  454. ;
  455. ;  Input/Process Command
  456. ;
  457. loop:
  458.     call    stackset    ;reset stack
  459.     call    prompt        ;get command from user
  460.     call    cmdproc        ;process command in A
  461.     call    icmsg        ;print invalid command msg
  462.     br    loop        ;continue
  463. ;
  464. ;  Set Stack Pointer
  465. ;
  466. stackset:
  467.     pop    d        ;get return address
  468.     lhld    ibuf        ;top of stack
  469.     sphl            ;start local stack
  470.     push    d        ;return address on new stack
  471.     ret
  472. ;
  473. ; Check for Presence of Shell Stack
  474. ;
  475. shtest1:
  476.     call    getsh        ;get shell stack data
  477.     rnz
  478.     pop    psw        ;clear stack
  479.     call    vprint
  480.     db    'No Shell Stack',0
  481.     ret
  482.  
  483. ;
  484. ; Check for Command Line
  485. ;
  486. shtest2:
  487.     call    getcl1        ;get command line data
  488.     rnz
  489.     pop    psw        ;clear stack
  490.     call    vprint
  491.     db    'No Cmd Line',0
  492.     ret
  493.  
  494. ;
  495. ; FUNCTION 3: Run ZEX on Top of VMENU
  496. ;  Accept Command Line and Pass it to ZCPR3
  497. ;
  498. zexrun:
  499.     call    vprint        ;print prompt
  500.     db    'VMENU> ',0
  501.     mvi    a,1        ;tell ZEX that it is prompted
  502.     call    putzex
  503.     call    getcl1        ;pt to command line buffer
  504.     mov    a,l        ;set ptr to first char
  505.     adi    4
  506.     mov    c,a
  507.     mov    a,h
  508.     aci    0
  509.     mov    b,a        ;BC pts to first char
  510.     mov    m,c        ;store low
  511.     inx    h
  512.     mov    m,b        ;store high
  513.     inx    h        ;pt to char count
  514.     xchg            ;... in DE
  515.     mvi    c,rdbuf        ;input line via BDOS
  516.     push    d        ;save ptr
  517.     call    bdos
  518.     pop    h        ;pt to char count
  519.     inx    h
  520.     mov    e,m        ;get char count
  521.     inx    h        ;pt to first char
  522.     push    h        ;save ptr
  523.     mvi    d,0        ;DE=char count
  524.     dad    d
  525.     xra    a        ;A=0
  526.     mov    m,a        ;store ending 0
  527.     pop    h        ;pt to first char
  528.     call    sksp        ;skip to first non-blank character
  529.     mov    a,m        ;get it
  530.     cpi    ';'        ;comment line?
  531.     jz    zexrun1        ;process comment line
  532.     call    putzex        ;resume ZEX (A=0)
  533.     call    putcst        ;set command status to normal (A=0)
  534.     ret            ;return to opsys
  535. zexrun1:
  536.     call    crlf        ;new line
  537.     jmp    zexrun
  538.  
  539. ;
  540. ;**************************************************
  541. ;
  542. ; CRT Routine for VMENU
  543. ;
  544. VCLS:
  545.     CALL    CLS        ;try to clear the screen
  546.     RNZ            ;OK if done
  547.     PUSH    H        ;save regs
  548.     PUSH    B
  549.     CALL    GETCRT        ;get CRT Data
  550.     INX    H        ;get number of lines on screen
  551.     MOV    B,M        ;B=number of lines
  552. VCLS1:
  553.     CALL    CRLF        ;new line
  554.     BJNZ    VCLS1
  555.     POP    B        ;restore regs
  556.     POP    H
  557.     RET
  558. ;
  559. ; EREOL Routine for VMENU
  560. ;
  561. VEREOL:
  562.     CALL    EREOL        ;try to erase to EOL
  563.     RNZ            ;OK if done
  564.     PUSH    B        ;save count
  565.     MVI    A,' '        ;space out
  566.     CALL    VEREOL1        ;send B spaces
  567.     POP    B        ;get count
  568.     MVI    A,BS        ;backspace in
  569. VEREOL1:
  570.     CALL    COUT        ;send char
  571.     BJNZ    VEREOL1        ;count down
  572.     RET
  573. ;
  574. ;  Setup Screen Display Variables
  575. ;
  576. SETSCR:
  577.     LXI    H,CURHOME    ;set cursor home
  578.     SHLD    CURAT
  579.     LHLD    RING        ;set ring position
  580.     CALL    SETMORE        ;set more flag if more files on screen
  581. ;
  582. ;  Entry to Reset Ring Position at HL
  583. ;
  584. SETSCR1:
  585.     SHLD    RINGPOS        ;set current file to first file in ring
  586. ;
  587. ;  Entry to Reset Local Ring Position at HL
  588. ;
  589. SETSCR2:
  590.     SHLD    LOCBEG        ;front of ring
  591.     LXI    D,EPS*ELTSIZ    ;new end?
  592.     DAD    D
  593.     XCHG
  594.     LHLD    RINGEND        ;end of ring
  595.     XCHG
  596.     CALL    CMPDEHL
  597.     BRC    SETSCR3
  598.     XCHG
  599. SETSCR3:
  600.     XCHG
  601.     SHLD    LOCEND
  602.     RET
  603.  
  604. ;
  605. ;  Set More Flag - Count Files on Screen and See if Display Exceeded
  606. ;
  607. SETMORE:
  608.     PUSH    H        ;SAVE REGS
  609.     PUSH    D
  610.     PUSH    B
  611.     XRA    A        ;CLEAR FLAG
  612.     STA    MORE
  613.     MVI    B,EPS        ;COUNT DOWN
  614.     LXI    D,ELTSIZ    ;SIZE OF ELEMENT
  615. SETMORE1:
  616.     MOV    A,M        ;GET CHAR
  617.     ORA    A        ;DONE IF ZERO
  618.     JZ    SETMDONE
  619.     DAD    D        ;PT TO NEXT
  620.     DCR    B        ;COUNT DOWN
  621.     JNZ    SETMORE1
  622.     MOV    A,M        ;GET CHAR
  623.     ORA    A        ;DONE IF ZERO
  624.     JZ    SETMDONE
  625.     MVI    A,0FFH        ;SET FLAG
  626.     STA    MORE
  627. SETMDONE:
  628.     POP    B        ;RESTORE REGS
  629.     POP    D
  630.     POP    H
  631.     RET
  632.  
  633. ;
  634. ;  Search for Current File starting at position in HL
  635. ;
  636. FINDCFILE:
  637.     CALL    GETFN2        ;get ptr to current file
  638.     LXI    D,11
  639.     DAD    D        ;... which is 2nd System File
  640.     XCHG            ;... ptr in DE
  641. ;
  642. ;  Next group of EPS files for file display
  643. ;
  644. FINDCF1:
  645.     LXI    H,CURHOME    ;set cursor
  646.     SHLD    CURAT
  647.     LHLD    LOCBEG        ;pt to first file in list
  648.     MVI    B,EPS        ;number of files in display
  649. ;
  650. ; Check current file
  651. ;
  652. FINDCF2:
  653.     SHLD    RINGPOS        ;set position of current ring element
  654. ;
  655. ; Check for end of file ring
  656. ;
  657.     MOV    A,M        ;end of list?
  658.     ORA    A        ;done if so
  659.     BRZ    FINDCF4
  660. ;
  661. ; Compare candidate file against file in ring
  662. ;
  663.     PUSH    H        ;save ptr to file
  664.     PUSH    D        ;save ptr to System File
  665.     PUSH    B        ;save count
  666.     MVI    B,ELTSIZ    ;compare
  667.     CALL    CMPSTR
  668.     POP    B        ;get count
  669.     POP    D        ;get ptr to System File
  670.     POP    H        ;get ptr to file
  671.     BRZ    FINDCF5        ;we found it
  672.     BRC    FINDCF5        ;we found following file
  673. ;
  674. ; Advance to next file in ring
  675. ;
  676.     PUSH    B        ;save count
  677.     LXI    B,ELTSIZ    ;pt to next element
  678.     DAD    B
  679. ;
  680. ; Advance to next file on screen
  681. ;
  682.     PUSH    H
  683.     LHLD    CURAT        ;get cursor position
  684.     MOV    A,L
  685.     ADI    19        ;advance cursor
  686.     MOV    L,A
  687.     CPI    70
  688.     BRC    FINDCF3
  689.     MOV    A,H        ;get current line
  690.     LXI    H,CURHOME    ;get home row
  691.     MOV    H,A        ;set current line
  692.     INR    H        ;next line
  693. FINDCF3:
  694.     SHLD    CURAT        ;set cursor
  695.     POP    H
  696.     POP    B        ;get count
  697. ;
  698. ; Count down files in current display
  699. ;
  700.     BJNZ    FINDCF2        ;count down
  701.     MOV    A,M        ;any following elements in ring?
  702.     ORA    A        ;0=no
  703.     BRZ    FINDCF4
  704. ;
  705. ; End of current display - set new display
  706. ;
  707.     SHLD    LOCBEG        ;new local beginning
  708.     BR    FINDCF1        ;continue search
  709. ;
  710. ; File beyond end of file display - set pointers to first file
  711. ;
  712. FINDCF4:
  713.     LXI    H,CURHOME    ;set cursor to first file
  714.     SHLD    CURAT
  715.     LHLD    RING        ;pt to first file
  716.     SHLD    RINGPOS
  717.     SHLD    LOCBEG        ;set local beginning
  718. ;
  719. ; Done - Set Local Ring
  720. ;
  721. FINDCF5:
  722.     LHLD    LOCBEG        ;pt to local ring
  723.     JMP    SETSCR2
  724.  
  725. ;
  726. ; Display file name of current file
  727. ;   Side Effect: Change Name of 2nd System File to Current File
  728. ;
  729. PRCFN1:
  730.     LXI    H,FNADR        ;position cursor for file name print
  731.     CALL    GOTOXY
  732.     CALL    GETFN2        ;pt to system file name
  733.     LXI    D,11        ;pt to 2nd System File Name
  734.     DAD    D
  735.     XCHG            ;... in DE
  736.     LHLD    RINGPOS        ;pt to current file name
  737.     MVI    B,11        ;copy into 2nd System File Name
  738.     CALL    MOVEB
  739.     JMP    PRFN        ;print file name
  740. ;
  741. ; Process Command
  742. ;
  743. ICMSG:
  744.     CALL    ERMSG
  745.     DB    'Invld Cmd: ',0
  746.     MOV    A,B        ;get char
  747.     CPI    ' '        ;expand if less than space
  748.     JNC    COUT
  749.     MVI    A,'^'        ;control
  750.     CALL    COUT
  751.     MOV    A,B        ;get byte
  752.     ADI    '@'        ;convert to letter
  753.     JMP    COUT        ;return for loop processing
  754.  
  755. ;
  756. ; SET UP BUFFERS
  757. ;
  758. SETUP:
  759.     CALL    RETUD        ;get home DU
  760.     MOV    A,B
  761.     STA    H$DR        ;home drive
  762.     MOV    A,C
  763.     STA    H$U$A        ;home user area
  764.     CALL    CODEND        ;start of free space
  765.     LXI    D,256        ;256 bytes/unit
  766.     DAD    D
  767.     SHLD    IBUF        ;input line buffer and top of stack
  768.     MVI    M,IBUFSZ    ;number of bytes in line
  769.     DAD    D
  770.     SHLD    EXPLINE        ;expansion line
  771.     DAD    D
  772.     SHLD    MENUFCB        ;dummy FCB
  773.     DAD    D        ;next page
  774.     SHLD    BUFFER        ;free space to end of TPA
  775.  
  776. ;
  777. ;  Begin Further Inits
  778. ;
  779.     LHLD    ENVPTR        ;pt to ZCPR3 Env Desc
  780.     LXI    D,80H+10H    ;pt to cursor commands
  781.     DAD    D
  782.     LXI    D,CTABLE    ;pt to area
  783.     MVI    B,4        ;4 commands
  784. CURINIT:
  785.     MOV    A,M        ;get command
  786.     STAX    D        ;put it
  787.     INX    H        ;pt to next
  788.     INX    D
  789.     INX    D
  790.     INX    D
  791.     BJNZ    CURINIT
  792. ;
  793.     LHLD    BUFFER        ;base address
  794.     SHLD    RING        ;beginning of ring
  795. ;
  796.     XRA    A        ;clear error message flag
  797.     STA    ERMFLG
  798. ;
  799.     RET
  800.  
  801. ; e x i t
  802.  
  803. ; return to ccp
  804.  
  805. ;
  806. ; Entry point for VMENU exit
  807. ;
  808. OS$CCP:
  809.     CALL    SHPOP        ;clear shell stack
  810. ;
  811. ; Entry point for command line exec
  812. ;
  813. OS$CCP1:
  814.     LXI    D,TBUFF        ;..tidy up..
  815.     MVI    C,SETDMA    ;..before going home.
  816.     CALL    BDOS
  817.  
  818.      IF WARMBOOT
  819.     JMP    OS$BASE
  820.      ENDIF            ;warmboot
  821.  
  822.      IF    NOT WARMBOOT
  823.     LHLD    STACK        ;put pointer..
  824.     SPHL            ;..back to 'sp'.
  825.     RET            ;return to ccp
  826.      ENDIF            ;not warmboot
  827.  
  828. ;
  829. ;  FLOAD loads the files into the buffer, setting up the ring
  830. ;  Return with NZ if load OK, Z if no files loaded
  831. ;
  832. FILELOAD:
  833. ;
  834. ;  Set up file name from System File 4
  835. ;    Select all files if no entry in System File 4
  836. ;
  837.     CALL    GETFN2        ;pt to first system file name
  838.     LXI    D,11*3        ;pt to 4th file name
  839.     DAD    D
  840.     LXI    D,JOKER        ;setup Joker if none
  841.     XCHG
  842.     LDAX    D        ;any chars?
  843.     MVI    B,11        ;11 bytes
  844.     CPI    ' '
  845.     CZ    MOVEB
  846.     XCHG            ;HL pts to system file name
  847.     LXI    D,FCB+1        ;pt to FCB
  848.     MVI    B,11        ;11 bytes
  849.     CALL    MOVEB
  850. ;
  851. ; Build ring with filename positioned in default FCB area
  852. ;
  853.     LHLD    RING        ;pt to ring
  854.     MVI    B,ELTSIZ    ;set first element to 'noname'
  855. FILEL1:
  856.     MVI    M,1        ;store ^A's
  857.     INX    H        ;pt to next
  858.     BJNZ    FILEL1
  859.     SHLD    RINGPOS        ;set ring position
  860.     SHLD    RINGEND        ;set ring end in case this is the only one
  861.     MVI    M,0        ;store ending 0
  862.     MVI    C,SETDMA    ;initialize dma address..
  863.     LXI    D,TBUFF        ;..to default buffer.
  864.     CALL    BDOS
  865.     XRA    A        ;clear search 'fcb'..
  866.     STA    FCBEXT        ;extent byte..
  867.     STA    FCBRNO        ;..and record number.
  868.     LXI    D,FCB        ;default FCB for search
  869.     CMA
  870.     MVI    C,SRCHF        ;..of first occurrence.
  871.     CALL    BDOS
  872.     INR    A        ; 0ffh --> 00h if no file found
  873.     RZ
  874.  
  875. ; put each found name in ring.  a-reg --> offset into 'tbuf' name storage
  876.  
  877. SETRING:
  878.     DCR    A        ;un-do 'inr' from above and below
  879.     ADD    A        ;times 32 --> position index
  880.      ADD    A
  881.     ADD    A
  882.     ADD    A
  883.     ADD    A
  884.     ADI    TBUFF+1        ;add page offset and..
  885.     MOV    L,A        ;..put address into..
  886.     MVI    H,0        ;..hl-pair.
  887.     XCHG
  888.     LHLD    RINGPOS        ;pointer to current load point in ring
  889.     XCHG
  890.     MVI    B,ELTSIZ    ;move name to ring
  891.     CALL    MOVE
  892.     XCHG            ;de-pair contains next load point address
  893.     SHLD    RINGPOS        ;store and search..
  894.     MVI    C,SRCHN        ;..for next occurrence.
  895.     LXI    D,FCB        ;filename address field
  896.     CALL    BDOS
  897.     INR    A        ;if all done, 0ffh --> 00h.
  898.     BRNZ    SETRING        ;if not, put next name into ring.
  899. ;
  900. ; All filenames in ring -- setup ring size and copy-buffer start point
  901. ;
  902.     LHLD    RINGPOS        ;next load point of ring is start of buffer
  903.     SHLD    RINGEND        ;set ring end..
  904.     MVI    M,0        ;store ending 0
  905. ;
  906. ; Sort ring of filenames
  907. ;
  908. SORT:
  909.     LHLD    RING        ;initialize 'i' sort variable and..
  910.     SHLD    RINGI
  911.     LXI    D,ELTSIZ    ;..also 'j' variable.
  912.     DAD    D
  913.     SHLD    RINGJ
  914. ;
  915. ; Main Sort Loop
  916. ;
  917. SORTLP:
  918.     LHLD    RINGJ        ;compare names 'i & j'
  919.     XCHG
  920.     LHLD    RINGI
  921.     PUSH    H        ;save position pointers..
  922.     PUSH    D        ;..for potential swap.
  923.  
  924. ; sort by file name and type
  925.     MVI    B,ELTSIZ    ; # of characters to compare
  926.     CALL    CMPSTR        ;do comparison
  927.  
  928. ; final test for swapping purposes
  929. NOCMP:
  930.     POP    D
  931.     POP    H
  932.     MVI    B,ELTSIZ
  933.     BRNC    NOSWAP
  934. ;
  935. ; Swap if 'j' string larger than 'i'
  936. ;
  937. SWAP:
  938.     MOV    C,M        ;get character from one string..
  939.     LDAX    D        ;..and one from other string.
  940.     MOV    M,A        ;second into first
  941.     MOV    A,C        ;first into second
  942.     STAX    D
  943.     INX    H        ;bump swap pointers
  944.     INX    D
  945.     BJNZ    SWAP
  946. NOSWAP:
  947.     LHLD    RINGJ        ;increment 'j' pointer
  948.     LXI    D,ELTSIZ
  949.     DAD    D
  950.     SHLD    RINGJ
  951.     XCHG            ;see if end of 'j' loop
  952.     LHLD    RINGEND
  953.     CALL    CMPDEHL
  954.     BRNZ    SORTLP        ;no, so more 'j' looping.
  955.     LHLD    RINGI        ;bump 'i' pointer
  956.     LXI    D,ELTSIZ
  957.     DAD    D
  958.     SHLD    RINGI
  959.     DAD    D        ;set start over 'j' pointer
  960.     SHLD    RINGJ
  961.     XCHG            ;see if end of 'i' loop
  962.     LHLD    RINGEND
  963.     CALL    CMPDEHL
  964.     BRNZ    SORTLP        ;must be more 'i' loop to do
  965.     RET
  966. ;
  967. ; left to right compare of two strings (de-pair points to 'a' string;
  968. ; hl-pair, to 'b'; b-reg contains string length.)
  969. ;
  970. CMPSTR:
  971.     LDAX    D        ;get an 'a' string character and..
  972.     CMP    M        ;..check against 'b' string character.
  973.     RNZ            ;if not equal, set flag.
  974.     INX    H        ;bump compare..
  975.     INX    D        ;..pointers and..
  976.     BJNZ    CMPSTR        ;..do next character.
  977.     RET
  978.  
  979. ;
  980. ; Process command from table
  981. ;
  982. CTPROC:
  983.     MOV    B,A        ;command in B
  984.     LXI    H,CTABLE    ;pt to table
  985.     MOV    A,M        ;any cursor commands?
  986.     ORA    A
  987.     JNZ    CTPR1
  988.     LXI    H,CTAB1
  989. ;
  990. ; Command table scanner
  991. ;    HL = Table
  992. ;    B  = Command Letter
  993. ;
  994. CTPR1:
  995.     MOV    A,M        ;get table command char
  996.     ORA    A        ;end of table?
  997.     RZ            ;done if so
  998.     CMP    B        ;match?
  999.     BRZ    CTPR2
  1000.     INX    H        ;skip to next entry
  1001.     INX    H
  1002.     INX    H
  1003.     BR    CTPR1
  1004. CTPR2:
  1005.     INX    H        ;pt to address
  1006.     MOV    A,M        ;get low
  1007.     INX    H
  1008.     MOV    H,M        ;get high
  1009.     MOV    L,A
  1010.     XTHL            ;address on stack
  1011.     RET            ;"jump" to routine
  1012.  
  1013. ; Command Table
  1014. CTABLE:
  1015.     DB    0        ;user cursor positioning
  1016.     DW    UP
  1017.     DB    0
  1018.     DW    DOWN
  1019.     DB    0
  1020.     DW    FORWARD
  1021.     DB    0
  1022.     DW    REVERSE
  1023. CTAB1:
  1024.     DB    CTRLC        ;if exit, then to opsys
  1025.     DW    OS$CCP
  1026.     DB    CTRLR        ;screen refresh?
  1027.     DW    RUNSH3
  1028.     DB    CTRLE        ;system cursor positioning
  1029.     DW    UP
  1030.     DB    CTRLX
  1031.     DW    DOWN
  1032.     DB    CTRLD
  1033.     DW    FORWARD
  1034.     DB    CTRLS
  1035.     DW    REVERSE
  1036.     DB    CR        ;nop
  1037.     DW    LOOP
  1038.     DB    '+'        ;jump forward
  1039.     DW    JUMPF
  1040.     DB    '-'        ;jump backward
  1041.     DW    JUMPB
  1042.     DB    ' '        ;go forward
  1043.     DW    FORWARD
  1044.     DB    BS        ;back up?
  1045.     DW    REVERSE
  1046. ;
  1047.     DB    0        ;end of table
  1048.  
  1049. ;
  1050. ; COMMAND: - (Previous Screen)
  1051. ;
  1052. JUMPB:
  1053.     LXI    H,CURHOME    ;set cursor home
  1054.     SHLD    CURAT
  1055.     LHLD    RING        ;at front?
  1056.     XCHG
  1057.     LHLD    LOCBEG
  1058.     CALL    CMPDEHL
  1059.     BRZ    JUMPBW        ;back up and wrap around
  1060.     SHLD    LOCEND        ;set new end
  1061.     LXI    D,-EPS*ELTSIZ    ;back up
  1062.     DAD    D
  1063.     SHLD    LOCBEG        ;new beginning
  1064.     SHLD    RINGPOS        ;new position
  1065.     JMP    RUNSH3
  1066. JUMPBW:
  1067.     LHLD    LOCBEG        ;at first screen?
  1068.     XCHG
  1069.     LHLD    RING        ;pt to first element of ring
  1070.     CALL    CMPDEHL
  1071.     BRZ    JBW0        ;advance to end
  1072.     LXI    H,-EPS*ELTSIZ    ;back up
  1073.     DAD    D        ;first element of new local ring
  1074.     BR    JFW0
  1075. JBW0:
  1076.     LXI    D,EPS*ELTSIZ    ;pt to next screen
  1077.     DAD    D
  1078.     XCHG
  1079.     LHLD    RINGEND
  1080.     CALL    CMPDEHL
  1081.     XCHG
  1082.     BRZ    JBW1
  1083.     BRC    JBW0
  1084. JBW1:
  1085.     LXI    D,-EPS*ELTSIZ
  1086.     DAD    D        ;pt to first element of new local ring
  1087.     BR    JFW0
  1088. ;
  1089. ; COMMAND: + (Next Screen)
  1090. ;
  1091. JUMPF:
  1092.     LXI    H,CURHOME    ;set cursor to home
  1093.     SHLD    CURAT
  1094.     LHLD    LOCEND        ;see if Local End <= Ring End
  1095.     XCHG
  1096.     LHLD    RINGEND
  1097.     CALL    CMPDEHL
  1098.     BRZ    CMDLOOP
  1099.     LHLD    LOCEND        ;new screen starting at LOCEND
  1100.     BR    JFW0
  1101.  
  1102. ;
  1103. ;  Reset to Beginning of RING and Resume Command Looping
  1104. ;
  1105. CMDLOOP:
  1106.     CALL    SETSCR        ;reset all screen pointers
  1107. CMDLRET:
  1108.     JMP    RUNSH3
  1109. ;
  1110. ;  Reset RING Position to HL
  1111. ;
  1112. JFW0:
  1113.     CALL    SETSCR1        ;reset RINGPOS on ...
  1114.     BR    CMDLRET
  1115. ;
  1116. ;  Reset Local Ring to HL
  1117. ;
  1118. JFW0A:
  1119.     CALL    SETSCR2        ;reset LOCBEG on ...
  1120.     BR    CMDLRET
  1121.  
  1122. ;
  1123. ; COMMAND: ' ', Left-Arrow
  1124. ;
  1125. FORWARD:
  1126.     CALL    CLRCUR        ;clear cursor
  1127.     CALL    FOR0        ;position on screen and in ring
  1128.     CALL    SETCUR        ;set cursor
  1129.     JMP    LOOPFN
  1130. ;  advance routine
  1131. FOR0:
  1132.     LHLD    RINGPOS        ;at end of loop yet?
  1133.     LXI    D,ELTSIZ    ;i.e., will we be at end of loop?
  1134.     DAD    D
  1135.     XCHG
  1136.     LHLD    LOCEND
  1137.     CALL    CMPDEHL        ;compare 'present' to 'end'
  1138.     BRNZ    FORW        ;to next print position
  1139.     CALL    CUR$FIRST    ;position cursor
  1140.     LHLD    LOCBEG        ;set position pointer to beginning and..
  1141.     SHLD    RINGPOS
  1142.     RET
  1143. FORW:
  1144.     LHLD    RINGPOS        ;advance in ring
  1145.     LXI    D,ELTSIZ
  1146.     DAD    D
  1147.     SHLD    RINGPOS        ;new position
  1148.     CALL    CUR$NEXT    ;position cursor
  1149.     RET
  1150.  
  1151. ;
  1152. ; COMMAND: BS, Right-Arrow
  1153. ;
  1154. REVERSE:
  1155.     CALL    CLRCUR        ;clear cursor
  1156.     CALL    REV0        ;position on screen and in ring
  1157.     CALL    SETCUR        ;set cursor
  1158.     JMP    LOOPFN
  1159. ;  Back Up Routine
  1160. REV0:
  1161.     LHLD    LOCBEG
  1162.     XCHG
  1163.     LHLD    RINGPOS        ;see if at beginning of ring
  1164.     CALL    CMPDEHL
  1165.     BRNZ    REV1        ;skip position pointer reset if not..
  1166.     CALL    CUR$LAST    ;end of local ring
  1167.     LHLD    LOCEND        ;set to end +1 to backup to end
  1168.     LXI    D,-ELTSIZ
  1169.     DAD    D
  1170.     SHLD    RINGPOS
  1171.     RET
  1172. REV1:
  1173.     CALL    CUR$BACK    ;back up 1
  1174. REV2:
  1175.     LHLD    RINGPOS
  1176.     LXI    D,-ELTSIZ    ;one ring position..
  1177.     DAD    D        ;..backwards.
  1178.     SHLD    RINGPOS
  1179.     RET
  1180.  
  1181. ;
  1182. ; COMMAND: Up-Arrow
  1183. ;
  1184. UP:
  1185.     CALL    CLRCUR        ;clear cursor
  1186.     LHLD    RINGPOS        ;see if wrap around
  1187.     LXI    D,-ELTSIZ*4    ;4 entries
  1188.     DAD    D
  1189.     XCHG
  1190.     LHLD    LOCBEG        ;beginning of local screen
  1191.     CALL    CMPDEHL
  1192.     BRC    UP2        ;wrap around
  1193.     MVI    B,4        ;back up 4 entries
  1194. UP1:
  1195.     PUSH    B        ;save count
  1196.     CALL    REV0        ;back up in ring and on screen (no print)
  1197.     POP    B        ;get count
  1198.     BJNZ    UP1
  1199.     BR    DOWN1A
  1200. UP2:
  1201.     LHLD    RINGPOS        ;advance to beyond end
  1202.     LXI    D,ELTSIZ*4
  1203.     DAD    D
  1204.     XCHG
  1205.     LHLD    LOCEND        ;compare to local end
  1206.     XCHG
  1207.     CALL    CMPDEHL
  1208.     BRZ    DOWN1A        ;at end, so too far
  1209.     BRC    DOWN1A        ;beyond end, so back up
  1210.     SHLD    RINGPOS        ;new ring position
  1211.     LHLD    CURAT        ;advance cursor
  1212.     INR    H        ;next line
  1213.     SHLD    CURAT
  1214.     BR    UP2
  1215.  
  1216. ;
  1217. ; COMMAND: Down-Arrow
  1218. ;
  1219. DOWN:
  1220.     CALL    CLRCUR        ;clear cursor
  1221.     LHLD    RINGPOS        ;see if wrap around
  1222.     LXI    D,ELTSIZ*4    ;4 entries
  1223.     DAD    D
  1224.     XCHG
  1225.     LHLD    LOCEND        ;end of local screen
  1226.     XCHG
  1227.     CALL    CMPDEHL
  1228.     BRZ    DOWN2        ;wrap around
  1229.     BRC    DOWN2        ;wrap around
  1230.     MVI    B,4        ;forward 4 entries
  1231. DOWN1:
  1232.     PUSH    B        ;save count
  1233.     CALL    FOR0        ;advance in ring and on screen (no print)
  1234.     POP    B        ;get count
  1235.     BJNZ    DOWN1
  1236. DOWN1A:
  1237.     CALL    SETCUR        ;set cursor
  1238.     JMP    LOOPFN
  1239. DOWN2:
  1240.     LHLD    CURAT        ;preserve column
  1241.     MOV    B,L        ;column number in B
  1242.     LXI    H,CURHOME    ;home position
  1243.     SHLD    CURAT        ;set new position
  1244.     LHLD    LOCBEG        ;beginning of local ring
  1245.     SHLD    RINGPOS        ;new ring position
  1246. DOWN3:
  1247.     LHLD    CURAT        ;check for at top of column
  1248.     MOV    A,L        ;get col
  1249.     CMP    B        ;there?
  1250.     BRZ    DOWN1A
  1251.     LHLD    RINGPOS        ;advance in ring
  1252.     LXI    D,ELTSIZ    ;ELTSIZ bytes/entry
  1253.     DAD    D
  1254.     SHLD    RINGPOS
  1255.     LHLD    CURAT        ;get cursor position
  1256.     LXI    D,19        ;advance 19 bytes/screen entry
  1257.     DAD    D
  1258.     SHLD    CURAT
  1259.     BR    DOWN3
  1260.  
  1261. ;
  1262. ;**************************************************
  1263. ;
  1264. ; WORKHORSE Routines
  1265. ;
  1266. ; conin routine (waits for response)
  1267. ;
  1268. KEYIN:
  1269.     CALL    CIN        ;get input
  1270.     JMP    CAPS        ;capitalize
  1271.  
  1272. ;
  1273. ; Fill buffer with 'spaces' with count in b-reg
  1274. ;
  1275. FILL:
  1276.     MVI    M,' '        ;put in space character
  1277.     INX    H
  1278.     BJNZ    FILL        ;no, branch.
  1279.     RET
  1280. ;
  1281. ; Check for legal filename character -- return with carry set if illegal
  1282. ;
  1283. CKLEGAL:
  1284.     LDAX    D        ;get character from de-pair
  1285.     INX    D        ;point at next character
  1286.     CPI    ' '        ;less than space?
  1287.     RC            ;return carry if unpermitted character
  1288.     PUSH    H
  1289.         PUSH    B
  1290.     CPI    '['        ;if greater than 'z', exit with..
  1291.     BRNC    CKERR        ;..carry set.
  1292.     MVI    B,CHR$TEND-CHR$TBL
  1293.     LXI    H,CHR$TBL
  1294. CHR$LP:
  1295.     CMP    M  
  1296.     BRZ    CKERR
  1297.     INX    H
  1298.     BJNZ    CHR$LP
  1299.     ORA    A        ;clear carry for good character
  1300.     POP    B
  1301.     POP    H
  1302.     RET
  1303.  
  1304. CKERR:
  1305.     POP    B
  1306.     POP    H
  1307.     STC                 ;error exit with carry set
  1308.     RET
  1309.  
  1310. CHR$TBL:
  1311.     DB    ',',':',';','<','=','>'    ;invalid character table
  1312. CHR$TEND:
  1313.     DS    0
  1314. ;
  1315. ; Print file name pted to by HL
  1316. ;   Advance HL 11 bytes
  1317. ;
  1318. PRFN:
  1319.     MOV    A,M        ;check for 'noname'
  1320.     CPI    1        ;no name?
  1321.     BRZ    PRFN1
  1322.     MVI    B,8        ;8 chars
  1323.     CALL    PRFNS1
  1324.     MVI    A,'.'
  1325.     CALL    COUT
  1326.     MVI    B,3        ;file type and fall thru
  1327. PRFNS1:
  1328.     MOV    A,M        ;get char
  1329.     CALL    COUT
  1330.     INX    H        ;pt to next
  1331.     BJNZ    PRFNS1
  1332.     RET
  1333. PRFN1:
  1334.     CALL    VPRINT
  1335.     DB    ' No File'
  1336.     DB    ' '
  1337.     DB    '   ',0
  1338.     MVI    B,11        ;advance 11 chars
  1339. PRFN2:
  1340.     INX    H        ;pt to next
  1341.     BJNZ    PRFN2
  1342.     RET
  1343.  
  1344. ;
  1345. ; move subroutine -- move b-reg # of bytes from hl-pair to de-pair
  1346. ;
  1347. MOVE:
  1348.     MOV    A,M        ;get hl-pair referenced source byte
  1349.     ANI    7FH        ;strip attributes
  1350.     STAX    D        ;put to de-pair referenced destination
  1351.     INX    H        ;fix pointers for next search
  1352.     INX    D
  1353.     BJNZ    MOVE
  1354.     RET
  1355.  
  1356. MOVEB:
  1357.     PUSH    H        ;SAVE HL, DE
  1358.     PUSH    D
  1359.     CALL    MOVE
  1360.     POP    D        ;RESTORE DE, HL
  1361.     POP    H
  1362.     RET
  1363. ;
  1364. ; Compare de-pair to hl-pair and set flags accordingly
  1365. ;
  1366. CMPDEHL:
  1367.     MOV    A,D        ;see if high bytes set flags
  1368.     CMP    H
  1369.     RNZ            ;return if not equal
  1370.     MOV    A,E
  1371.     CMP    L        ;low bytes set flags instead
  1372.     RET
  1373. ;
  1374. ; Shift hl-pair b-reg bits (-1) to right (divider routine)
  1375. ;
  1376. SHIFTLP:
  1377.     DCR    B
  1378.     RZ
  1379.     MOV    A,H
  1380.     ORA    A
  1381.     RAR
  1382.     MOV    H,A
  1383.     MOV    A,L
  1384.     RAR
  1385.     MOV    L,A
  1386.     BR    SHIFTLP
  1387.  
  1388. ;
  1389. ;**************************************************
  1390. ;
  1391. ; MESSAGE Routines
  1392. ;
  1393. ; Print VMENU Banner
  1394. ;
  1395. BANNER:
  1396.     CALL    VCLS        ;clear screen
  1397.     LXI    H,BANADR
  1398.     CALL    GOTOXY
  1399.     CALL    VPRINT        ;print banner
  1400.     DB    'VMENU, Version '
  1401.     DB    VERS/10+'0','.',(VERS MOD 10)+'0'
  1402.      IF    Z80
  1403.     DB    '  ',DIM,'[Z80 Code]',BRIGHT
  1404.      ELSE
  1405.     DB    '  ',DIM,'[8080 Code]',BRIGHT
  1406.      ENDIF
  1407.     DB    0
  1408.     RET
  1409. ;
  1410. ; Print DU:DIR and MORE Message
  1411. ;
  1412. DIRMORE:
  1413.     LXI    H,DUADR        ; POSITION CURSOR
  1414.     CALL    GOTOXY
  1415.     CALL    RETUD        ; GET CURRENT DISK AND USER
  1416.     MOV    A,B        ; PRINT DISK
  1417.     ADI    'A'
  1418.     CALL    COUT
  1419.     MOV    A,C        ; PRINT USER
  1420.     CALL    PAFDC        ; FLOADING DECIMAL
  1421.     MVI    A,':'
  1422.     CALL    COUT
  1423.     CALL    DUTDIR        ; GET DIR NAME
  1424.     BRZ    NODIR
  1425.     MVI    B,8        ; 8 CHARS IN NAME
  1426. PRNAME:
  1427.     MOV    A,M        ; GET CHAR
  1428.     CPI    ' '+1        ; CHECK FOR DONE
  1429.     BRC    PRMORE
  1430.     CALL    COUT        ; PRINT CHAR
  1431.     INX    H
  1432.     BJNZ    PRNAME
  1433.     BR    PRMORE
  1434. NODIR:
  1435.     CALL    VPRINT
  1436.     DB    'Noname',0
  1437. PRMORE:
  1438.     LDA    MORE        ; CHECK FLAG
  1439.     ORA    A        ; 0=NO MORE
  1440.     RZ
  1441.     LXI    H,MOREADR
  1442.     CALL    GOTOXY        ; POSITION CURSOR
  1443.     CALL    VPRINT
  1444.     DB    DIM,'[More Files]',BRIGHT,0
  1445.     RET
  1446.  
  1447. ;
  1448. ; Home the Cursor
  1449. ;
  1450. CUR$FIRST:
  1451.     LXI    H,CURHOME    ; HOME ADDRESS
  1452.     SHLD    CURAT        ; SET CURSOR POSITION
  1453.     JMP    GOTOXY
  1454. ;
  1455. ; Last File Position
  1456. ;
  1457. CUR$LAST:
  1458.     LHLD    RINGPOS        ; ADVANCE
  1459.     SHLD    LOCPOS        ; SET LOCAL POSITION
  1460. CL0:
  1461.     LXI    D,ELTSIZ
  1462.     DAD    D
  1463.     XCHG
  1464.     LHLD    LOCEND        ; END OF LOCAL RING?
  1465.     CALL    CMPDEHL
  1466.     RZ
  1467.     XCHG            ; NEW POSITION
  1468.     SHLD    LOCPOS
  1469.     PUSH    H        ; SAVE POSITION
  1470.     CALL    CUR$NEXT    ; ADVANCE CURSOR
  1471.     POP    H        ; GET POSITION
  1472.     BR    CL0
  1473. ;
  1474. ; Advance the Cursor
  1475. ;
  1476. CUR$NEXT:
  1477.     LHLD    CURAT        ; COMPUTE NEW POSITION
  1478.     MOV    A,L        ; CHECK FOR NEW LINE
  1479.     ADI    19        ; SIZE OF EACH ENTRY
  1480.     CPI    70
  1481.     BRNC    CN1        ; ADVANCE TO NEXT LINE
  1482.     MOV    L,A        ; NEW POSITION
  1483.     SHLD    CURAT
  1484.     JMP    GOTOXY
  1485. CN1:
  1486.     MOV    A,H        ; GET LINE
  1487.     LXI    H,CURHOME    ; GET COL
  1488.     MOV    H,A        ; SET LINE AND FALL GO TO CUR$DOWN
  1489.     SHLD    CURAT
  1490.     BR    CUR$DOWN
  1491. ;
  1492. ; Back Up the Cursor
  1493. ;
  1494. CUR$BACK:
  1495.     LXI    H,CURHOME    ; GET HOME
  1496.     XCHG            ; ... IN DE
  1497.     LHLD    CURAT
  1498.     CALL    CMPDEHL        ; COMPARE
  1499.     BRZ    CUR$LAST    ; GOTO END IF LAST
  1500.     MOV    A,L        ; CHECK FOR FIRST COL
  1501.     CMP    E
  1502.     BRZ    CB1
  1503.     SUI    19        ; BACK UP ONE COL
  1504.     MOV    L,A
  1505.     SHLD    CURAT        ; NEW POS
  1506.     JMP    GOTOXY
  1507. CB1:
  1508.     MOV    A,E        ; GET HOME COL
  1509.     ADI    19*3        ; GET LAST COL
  1510.     MOV    L,A
  1511.     DCR    H        ; PREV LINE
  1512.     SHLD    CURAT
  1513.     JMP    GOTOXY
  1514. ;
  1515. ; Move Cursor Down One Line
  1516. ;
  1517. CUR$DOWN:
  1518.     LXI    H,CURHOME    ; GET HOME ADDRESS
  1519.     MOV    B,H        ; LINE IN B
  1520.     LHLD    CURAT        ; GET CURRENT ADDRESS
  1521.     INR    H        ; MOVE DOWN
  1522.     MOV    A,H        ; CHECK FOR TOO FAR
  1523.     SUB    B
  1524.     CPI    EPS/4
  1525.     BRNC    CD1
  1526.     SHLD    CURAT        ; OK, SO SET POSITION
  1527.     JMP    GOTOXY
  1528. CD1:
  1529.     MOV    A,L        ; GET COL
  1530.     LXI    H,CURHOME
  1531.     MOV    L,A
  1532.     SHLD    CURAT
  1533.     JMP    GOTOXY
  1534. ;
  1535. ; Refresh Screen
  1536. ;
  1537. REFRESH:
  1538.     LHLD    CURAT    ; SAVE CURSOR AND RING POSITIONS
  1539.     SHLD    SCURAT
  1540.     LHLD    RINGPOS
  1541.     SHLD    SRINGPOS
  1542.     CALL    BANNER        ; PRINT BANNER
  1543.     CALL    DIRMORE        ; PRINT CURRENT DIRECTORY AND MORE MESSAGE
  1544.     CALL    DISPFILES    ; DISPLAY FILES
  1545.     CALL    DISPMENU    ; DISPLAY MENU
  1546.     LHLD    SCURAT        ; RESTORE CURSOR AND RING POSITIONS
  1547.     SHLD    CURAT
  1548.     LHLD    SRINGPOS
  1549.     SHLD    RINGPOS
  1550.     CALL    SETCUR        ; RESTORE CURSOR ON SCREEN
  1551.     call    atcmd
  1552.     call    vprint
  1553.     db    DIM,'Command (CR=Menu',0
  1554.     lda    cpmok        ;OK to return to ZCPR3?
  1555.     ora    a        ;0=No
  1556.     cnz    prmptc
  1557.     lhld    cstart        ;pt to first char
  1558.     mov    a,m        ;get it
  1559.     ani    7FH        ;mask
  1560.     cpi    MFIRST
  1561.     cnz    prmptf        ;print previous menu prompt if not first menu
  1562.     lda    nmenfl        ;next menu available?
  1563.     ora    a        ;0=No
  1564.     cnz    prmptn        ;print next menu prompt
  1565.     call    vprint
  1566.     db    ') - ',BRIGHT,0
  1567.     RET
  1568.  
  1569. ;
  1570. ;  Print ZCPR3 Return Prompt
  1571. ;
  1572. prmptc:
  1573.     call    vprint
  1574.     db    ', ^C=Z3',0
  1575.     ret
  1576. ;
  1577. ;  Print First/Last Menu Chars
  1578. ;
  1579. prmptf:
  1580.     call    vprint
  1581.     db    ', ',RFM,'=1st Menu, ',RLM,'=Prev Menu',0
  1582.     ret
  1583. ;
  1584. ;  Print next menu message
  1585. ;
  1586. prmptn:
  1587.     call    vprint
  1588.     db    ', ',RNM,'=Next Menu',0
  1589.     ret
  1590.  
  1591. ;
  1592. ; Refresh File Display
  1593. ;
  1594. DISPFILES:
  1595.     CALL    CUR$FIRST    ; POSITION CURSOR AT FIRST POSITION
  1596.     LHLD    LOCBEG        ; PT TO FIRST FILE NAME
  1597.     SHLD    LOCPOS        ; SAVE LOCAL POSITION
  1598. DSPF1:
  1599.     LHLD    LOCEND        ; AT END?
  1600.     XCHG
  1601.     LHLD    LOCPOS
  1602.     CALL    CMPDEHL
  1603.     JZ    CUR$FIRST    ; POSITION AT FIRST ENTRY AND RETURN
  1604.     MVI    B,4        ; 4 SPACES
  1605.     MVI    A,' '
  1606. DSPF2:
  1607.     CALL    COUT
  1608.     BJNZ    DSPF2
  1609.     CALL    PRFN        ; PRINT FILE NAME (HL IS ADVANCED)
  1610.     SHLD    LOCPOS
  1611.     CALL    CUR$NEXT    ; ADVANCE CURSOR
  1612.     BR    DSPF1
  1613. ;
  1614. ; Position Cursor at CURAT
  1615. ;
  1616. SETCUR:
  1617.     LHLD    CURAT
  1618.     CALL    GOTOXY
  1619.     CALL    VPRINT
  1620.     DB    '-->',0
  1621.     RET
  1622. ;
  1623. ; Clear Cursor
  1624. ;
  1625. CLRCUR:
  1626.     LHLD    CURAT
  1627.     CALL    GOTOXY
  1628.     CALL    VPRINT
  1629.     DB    '   ',0
  1630.     RET
  1631. ;
  1632. ; Working Message
  1633. ;
  1634. WORKMSG:
  1635.     CALL    ERMSG
  1636.     DB    DIM,'Working ...',BRIGHT,0
  1637.     RET
  1638. ;
  1639. ; Error Message
  1640. ;
  1641. ERMSG:
  1642.     MVI    A,0FFH    ; SET ERROR MESSAGE FLAG
  1643.     STA    ERMFLG
  1644.     LXI    H,ERADR    ; GET ADDRESS
  1645.     CALL    GOTOXY
  1646.     JMP    VPRINT
  1647. ;
  1648. ; Clear Error Message
  1649. ;
  1650. ERCLR:
  1651.     XRA    A    ; CLEAR FLAG
  1652.     STA    ERMFLG
  1653.     LXI    H,ERADR    ; POSITION
  1654.     CALL    GOTOXY
  1655.     PUSH    B
  1656.     MVI    B,76-(ERADR MOD 255)
  1657.     CALL    VEREOL    ; ERASE TO EOL
  1658.     POP    B
  1659.     RET
  1660. ;
  1661. ; Position at Command Prompt and Clear It
  1662. ;
  1663. ATCMD:
  1664.     LXI    H,CPMADR    ; POSITION
  1665.     CALL    GOTOXY
  1666.     PUSH    B
  1667.     MVI    B,76-(CPMADR MOD 255)
  1668.     CALL    VEREOL        ; CLEAR MESSAGE
  1669.     POP    B
  1670.     LXI    H,CPMADR    ; REPOSITION
  1671.     JMP    GOTOXY
  1672. ;
  1673. ; Position at Bottom of Screen and Prompt for Continuation
  1674. ;
  1675. BOTTOM:
  1676.     LXI    H,BOTADR    ; POSITION
  1677.     CALL    GOTOXY
  1678. ;
  1679. ; Prompt for Continuation
  1680. ;
  1681. SAK:
  1682.     CALL    VPRINT
  1683.     DB    DIM,'Strike Any Key -- ',BRIGHT,0
  1684.     JMP    KEYIN
  1685.  
  1686. ;
  1687. ; Open Menu File
  1688. ;
  1689. menuload:
  1690.     lhld    menufcb        ;pt to menu fcb
  1691.     inx    h
  1692.     push    h
  1693.     call    getfn2        ;copy FCB into MENU FCB
  1694.     lxi    d,11*2        ;pt to 3rd system file name
  1695.     dad    d
  1696.     pop    d        ;DE pts to first char of MENU FCB file name
  1697.     mvi    b,11        ;11 bytes
  1698.     call    moveb
  1699.     dcx    d        ;pt to fcb
  1700.     call    initfcb        ;init fcb
  1701.     call    f$open        ;open file
  1702.     brz    menu1        ;abort if no menu
  1703.     call    vprint
  1704.     db    CR,LF,' File ',0
  1705.     lhld    menufcb        ;pt to file name
  1706.     inx    h
  1707.     call    prfn
  1708.     call    vprint
  1709.     db    ' Not Found',0
  1710.     jmp    os$ccp        ;abort
  1711. ;
  1712. ;  Load Menu File from disk
  1713. ;
  1714. menu1:
  1715.     call    menustrt    ;get address of buffer for menu load
  1716.     xchg            ;... in DE
  1717. ;
  1718. ;  Load next block from Menu File -- DE pts to Load Address
  1719. ;
  1720. mload:
  1721.     lhld    menufcb        ;pt to FCB
  1722.     xchg            ;... in DE, HL = load address
  1723.     call    f$read        ;read in next block
  1724.     ora    a        ;error?
  1725.     brnz    mloaddn        ;load done if error
  1726.     lxi    d,tbuff        ;copy from TBUFF into memory pted to by HL
  1727.     xchg            ;HL is source, DE is dest
  1728.     mvi    b,128        ;128 bytes
  1729.     call    move
  1730.     lhld    bdos+1        ;get address of top of TPA
  1731.     mov    a,h        ;set to bottom of ZCPR3
  1732.     sui    10
  1733.     cmp    d        ;about to overflow ZCPR3?
  1734.     brnc    mload        ;continue if not
  1735.     call    vprint
  1736.     db    CR,LF,' TPA Full',0
  1737.     jmp    os$ccp
  1738.  
  1739. ;
  1740. ;  Init Flags and Clear MSB of all bytes in Menu File
  1741. ;
  1742. mloaddn:
  1743.     call    f$close        ;close input file
  1744.     mvi    m,CTRLZ        ;ensure EOF mark
  1745.     xra    a        ;A=0
  1746.     sta    cpmok        ;turn off ZCPR3 return flag
  1747.     call    menustrt    ;pt to first menu char
  1748.     push    h        ;save ptr
  1749. menul1:
  1750.     mov    a,m        ;get byte
  1751.     ani    7FH        ;mask out MSB
  1752.     mov    m,a        ;put byte
  1753.     inx    h        ;pt to next
  1754.     cpi    CTRLZ        ;EOF?
  1755.     brnz    menul1        ;continue if not
  1756. ;
  1757. ;  Mark all Menu Sections
  1758. ;
  1759.     pop    h        ;HL pts to first byte of menu
  1760.     mvi    b,0FFH        ;set menu counter
  1761. ;
  1762. ;  Skip to Next Menu
  1763. ;
  1764. menul2:
  1765.     mov    a,m        ;get byte
  1766.     cpi    CTRLZ        ;error?
  1767.     jz    mstrerr        ;structure error if so
  1768.     cpi    MINDIC        ;menu indicator (start of menu?)
  1769.     brnz    menul4
  1770.     ori    80H        ;beginning of menu found -- set MSB
  1771.     mov    m,a        ;put byte
  1772.     inr    b        ;increment menu count
  1773.     inx    h        ;pt to next
  1774.     mov    a,m        ;get byte
  1775.     cpi    MINDIC        ;menu indicator (end of menu?)
  1776.     brz    menul5        ;done if so
  1777.     cpi    CTRLZ        ;error?
  1778.     jz    mstrerr
  1779. ;
  1780. ;  Skip out Menu Display
  1781. ;
  1782. menul3:
  1783.     call    lskipt        ;skip to beginning of next line
  1784.     brz    menul4        ;found menu indicator
  1785.     cpi    CTRLZ        ;error?
  1786.     jz    mstrerr
  1787.     br    menul3        ;continue if not
  1788. ;
  1789. ;  Skip to Next Menu
  1790. ;
  1791. menul4:
  1792.     call    lskipt        ;skip to beginning of next menu
  1793.     brz    menul2        ;resume if at beginning of next menu
  1794.     cpi    CTRLZ        ;error?
  1795.     jz    mstrerr
  1796.     br    menul4
  1797. ;
  1798. ;  Check Menu Options
  1799. ;
  1800. menul5:
  1801.     call    menustrt    ;pt to first menu char
  1802.     mov    a,m        ;check for option
  1803.     cpi    GOPTION        ;global option char?
  1804.     jnz    mfile        ;if no global option, scan for menu files
  1805.     inx    h        ;pt to option char
  1806. option:
  1807.     mov    a,m        ;get option char
  1808.     call    caps        ;capitalize
  1809.     inx    h        ;pt to next
  1810.     cpi    CR        ;done?
  1811.     brz    optdn
  1812.     cpi    XOPTION        ;exit OK?
  1813.     jnz    mstrerr        ;option error if not
  1814. ;
  1815. ;  Disable Exit to ZCPR3
  1816. ;
  1817.     mvi    a,0FFH        ;turn flag off
  1818.     sta    cpmok
  1819.     br    option
  1820. ;
  1821. ;  Option Processing Done
  1822. ;
  1823. optdn:
  1824.     inx    h        ;skip LF
  1825.  
  1826. ;
  1827. ;  Check for Menu Display
  1828. ;
  1829. mfile:
  1830.     mov    a,m        ;get first byte
  1831.     ani    7FH        ;mask
  1832.     cpi    MINDIC        ;start of menu?
  1833.     jnz    mstrerr
  1834.  
  1835. ;
  1836. ;  Check and Set First Menu
  1837. ;
  1838.     shld    mstart        ;save start address of first menu item
  1839.     mvi    m,MFIRST+80H    ;set first char of first menu
  1840.     ret
  1841.  
  1842. ;
  1843. ;  Entry Point for Menu Display
  1844. ;
  1845. dispmenu:
  1846.     mvi    h,epsline    ;pt to first line of menu
  1847.     mvi    l,1        ;col 1
  1848.     call    gotoxy        ;position there
  1849.     lhld    mstart        ;pt to first byte of current menu
  1850.     mvi    b,1        ;shell message 1 contains menu number
  1851.     call    getshm        ;get menu number flag
  1852.     cnz    mchc0        ;skip to proper menu
  1853.     shld    cstart        ;save start address of current menu
  1854.     inx    h        ;pt to first char after menu indicator char
  1855. dispm1:
  1856.     mov    a,m        ;get char
  1857.     call    caps        ;capitalize
  1858.     inx    h        ;pt to next
  1859.     cpi    CR        ;end of options?
  1860.     brz    dispm2
  1861.     cpi    XOPTION        ;ZCPR3 return?
  1862.     jnz    mstrerr        ;error if not
  1863. ;
  1864. ;  Toggle ZCPR3 Return Option
  1865. ;
  1866.     lda    cpmok        ;get flag
  1867.     cma            ;toggle
  1868.     sta    cpmok
  1869.     br    dispm1
  1870. ;
  1871. ;  Done with Menu-Specific Option Processing
  1872. ;
  1873. dispm2:
  1874.     call    lskip        ;skip to LF
  1875.     call    getnlines    ;get line count in A
  1876.     sta    pagcnt        ;set count
  1877. ;
  1878. ;  Print Next Line of Menu if not Starting with ESCAPE Char (MINDIC)
  1879. ;
  1880. dispm3:
  1881.     mov    a,m        ;get first char of line
  1882.     ani    7FH        ;mask
  1883.     cpi    MINDIC        ;done?
  1884.     brz    dispm4
  1885.     call    expand        ;expand line pted to by HL
  1886.     push    h        ;save ptr to next line
  1887.     xchg            ;HL pts to expanded line
  1888.     call    lprintx        ;print line pted to by HL ending in <CR>
  1889.     pop    h        ;pt to next line
  1890.     br    dispm3
  1891. ;
  1892. ;  Done with Menu Display
  1893. ;
  1894. dispm4:
  1895.     call    lskip        ;skip to first char of next line (option char)
  1896.     shld    optstrt        ;set start address of options
  1897. ;
  1898. ;  Determine if Another Menu Follows
  1899. ;
  1900.     xra    a        ;A=0
  1901.     sta    nmenfl        ;set for no next menu
  1902. dispm5:
  1903.     mov    a,m        ;ok?
  1904.     ani    7FH        ;mask
  1905.     cpi    CTRLZ        ;error if EOF
  1906.     jz    mstrerr
  1907.     cpi    MINDIC        ;next menu?
  1908.     brnz    dispm6
  1909.     inx    h        ;double indicator if end
  1910.     mov    a,m
  1911.     cpi    MINDIC        ;end?
  1912.     rz
  1913.     mvi    a,0FFH        ;set next menu
  1914.     sta    nmenfl
  1915.     ret
  1916. dispm6:
  1917.     call    lskip        ;skip to next line
  1918.     br    dispm5
  1919.  
  1920. ;
  1921. ;  Ready for Option Input
  1922. ;    The following Flags/Values are now set:
  1923. ;    OPTSTRT -- Address of First Menu Option
  1924. ;    NMENFL -- 0 if no next menu, 0FFH if next menu
  1925. ;    CSTART -- Address of First Char of Current Menu
  1926. ;    MSTART -- Start Address of MINDIC Before Menu Display
  1927. ;      (MSTART)=MFIRST with MSB Set
  1928. prompt:
  1929.     lxi    h,cpadr        ;position for input
  1930.     call    gotoxy
  1931.     mvi    a,0ffh
  1932.     sta    pagcnt        ;turn off paging
  1933.     call    keyin        ;get user input
  1934.     PUSH    PSW        ;save command
  1935.     LDA    ERMFLG        ;error message?
  1936.     ORA    A        ;0=no
  1937.     CNZ    ERCLR        ;erase old error message
  1938.     POP    PSW        ;get command
  1939.     ret
  1940.  
  1941. ;
  1942. ;  Process Command
  1943. ;
  1944. cmdproc:
  1945.     call    ctproc        ;process movement or exit command
  1946.  
  1947. ;
  1948. ;  Check for Command to Return to First Menu
  1949. ;
  1950.     lhld    cstart        ;pt to first char of menu
  1951.     mov    a,m        ;get it
  1952.     ani    7FH        ;mask
  1953.     cpi    MFIRST
  1954.     brz    prmpt1
  1955.     mov    a,b        ;get command
  1956.     cpi    RFM        ;return to first menu?
  1957.     brnz    prmpt1
  1958.     lhld    mstart        ;pt to first menu
  1959.     mvi    b,1        ;shell message 1 is menu number
  1960.     xra    a        ;A=0=menu 0
  1961.     jmp    putshm        ;reenter shell at first menu
  1962.  
  1963. ;
  1964. ;  Check for Command to go to Next Menu
  1965. ;
  1966. prmpt1:
  1967.     lda    nmenfl        ;next menu available?
  1968.     ora    a        ;0=No
  1969.     brz    prmpt2
  1970.     mov    a,b        ;get command
  1971.     cpi    RNMP        ;goto next menu?
  1972.     brz    rnmx
  1973.     cpi    RNM        ;goto next menu?
  1974.     brnz    prmpt2
  1975. rnmx:
  1976.     mvi    b,1        ;shell message 1 is menu number
  1977.     call    getshm        ;increment menu number
  1978.     inr    a
  1979.     call    putshm        ;reenter menu system at new menu
  1980.     jmp    os$ccp1
  1981. ;
  1982. ;  Check for Command to go to Last Menu
  1983. ;
  1984. prmpt2:
  1985.     mov    a,m        ;get menu char
  1986.     ani    7FH        ;at first menu?
  1987.     cpi    MFIRST
  1988.     brz    prmpt3        ;skip if at first menu
  1989.     mov    a,b        ;get command
  1990.     cpi    RLMP        ;goto last menu?
  1991.     brz    lstmnu
  1992.     cpi    RLM        ;goto last menu?
  1993.     brnz    prmpt3
  1994. lstmnu:
  1995.     mvi    b,1        ;shell message 1 is menu number
  1996.     call    getshm        ;decrement menu number
  1997.     dcr    a
  1998.     call    putshm        ;reenter shell at last menu
  1999.     jmp    os$ccp1
  2000. ;
  2001. ;  This is where additional functions may be added
  2002. ;
  2003. prmpt3:
  2004.  
  2005. ;
  2006. ;  Check for Option Letter
  2007. ;
  2008.     lhld    optstrt        ;pt to first option char
  2009. prmptx:
  2010.     mov    a,m        ;get it
  2011.     ani    7FH        ;mask MSB
  2012.     call    caps        ;capitalize
  2013.     cpi    MINDIC        ;at next menu?
  2014.     rz
  2015.     cmp    b        ;match user selection?
  2016.     brz    prmptd
  2017.     call    lskip        ;skip to next line
  2018.     br    prmptx
  2019.  
  2020. ;
  2021. ;  Process Option
  2022. ;
  2023. prmptd:
  2024.     mvi    b,0        ;shell message 0, bit 7 = wait flag
  2025.     call    getshm
  2026.     ani    7FH        ;set no wait
  2027.     call    putshm
  2028.     inx    h        ;pt to first letter of command
  2029.     mov    a,m        ;get it
  2030.     cpi    MCMD        ;invoke other menu?
  2031.     jz    mchcmd        ;menu change command
  2032.     cpi    WOPTION        ;turn on wait?
  2033.     brnz    prmptg
  2034.     mvi    b,0        ;shell message 0, bit 7 = wait flag
  2035.     call    getshm
  2036.     ori    80h        ;set wait flag
  2037.     call    putshm        ;set shell message
  2038.     inx    h        ;skip option char
  2039. prmptg:
  2040.     call    expand        ;expand line, DE pts to result
  2041. ;
  2042. ; Run Command Pted to by DE
  2043. ;
  2044. runcmnd:
  2045.     call    getcl1        ;get address of command buffer
  2046.     mov    b,h        ;... in BC also
  2047.     mov    c,l
  2048.     mvi    a,4        ;HL=HL+4 for address of first char
  2049.     add    l
  2050.     mov    l,a
  2051.     mov    a,h
  2052.     aci    0
  2053.     mov    h,a
  2054.     mov    a,l        ;store address
  2055.     stax    b
  2056.     inx    b
  2057.     mov    a,h
  2058.     stax    b
  2059. ;
  2060. ; Copy Command Line in DE into Buffer in HL
  2061. ;
  2062. cmdcpy:
  2063.     ldax    d        ;get command letter
  2064.     call    caps        ;capitalize it
  2065.     ora    a        ;done?
  2066.     brz    ccpyd
  2067.     cpi    CR        ;done?
  2068.     brz    ccpyd
  2069.     cpi    PCHAR        ;prompt?
  2070.     brz    ccpyp
  2071.     mov    m,a        ;store it
  2072.     inx    h        ;pt to next
  2073.     inx    d
  2074.     br    cmdcpy
  2075. ccpyd:
  2076.     mvi    m,0        ;store ending 0
  2077.     jmp    os$ccp1        ;optionally display command
  2078. ;
  2079. ;  Prompt User for Input and Accept It
  2080. ;
  2081. ccpyp:
  2082.     inx    d        ;pt to first char of prompt
  2083.     call    crlf        ;new line
  2084. ccpyp1:
  2085.     ldax    d        ;get char
  2086.     cpi    PCHAR        ;end of prompt?
  2087.     brz    ccpyp2
  2088.     cpi    CR        ;new line?
  2089.     brz    ccpyp3
  2090.     call    cout        ;echo char
  2091.     inx    d        ;pt to next char
  2092.     br    ccpyp1        ;continue looping
  2093. ccpyp2:
  2094.     inx    d        ;pt to char after closing PCHAR
  2095. ccpyp3:
  2096.     push    d        ;save ptr to next char
  2097.     xchg            ;DE pts to buffer
  2098.     mvi    a,0FFH        ;capitalize input from user
  2099.     lhld    ibuf        ;input line buffer
  2100.     call    bline        ;get input from user
  2101.     xchg            ;HL pts to buffer, DE pts to user input
  2102. cmdlp:
  2103.     ldax    d        ;get char from user
  2104.     ora    a        ;end of input?
  2105.     brz    cmdlp1        ;store rest of line
  2106.     mov    m,a        ;store char
  2107.     inx    h        ;pt to next
  2108.     inx    d
  2109.     br    cmdlp
  2110. cmdlp1:
  2111.     pop    d        ;DE pts to next char, HL pts to buffer
  2112.     br    cmdcpy        ;resume copying
  2113.  
  2114. ;
  2115. ;  Menu Change Command -- Jump to Specified Menu
  2116. ;
  2117. mchcmd:
  2118.     inx    h        ;pt to menu number
  2119.     call    eval        ;convert to decimal number in A
  2120.     sta    menuno        ;save menu number
  2121.     call    mchc0        ;skip to desired menu to check for it
  2122.     lda    menuno        ;get menu number
  2123.     mvi    b,1        ;menu number is shell message 1
  2124.     jmp    putshm        ;set message and reenter shell
  2125.  
  2126. ;
  2127. ;  Entry Point if MENU is Reinvoked
  2128. ;
  2129. mchc0:
  2130.     mov    b,a        ;menu number in B
  2131.     inr    b        ;increment for following decrement
  2132.     lhld    mstart        ;pt to start of menu
  2133. mchc1:
  2134.     dcr    b        ;count down
  2135.     rz            ;done if found
  2136. mchc2:
  2137.     call    lskipt        ;skip to next line
  2138.     brnz    mchc2        ;continue if not end of menu display
  2139.     cpi    CTRLZ        ;EOF?
  2140.     jz    mstrerr
  2141. mchc3:
  2142.     call    lskipt        ;skip to next line
  2143.     brnz    mchc3        ;continue if not at end of menu commands
  2144.     cpi    CTRLZ        ;EOF?
  2145.     jz    mstrerr
  2146.     inx    h        ;end of MENU.MNU?
  2147.     mov    a,m        ;yes if double MINDIC
  2148.     ani    7FH        ;mask
  2149.     cpi    MINDIC
  2150.     jz    mstrerr        ;error if so
  2151.     dcx    h        ;pt to first char
  2152.     br    mchc1        ;continue
  2153.  
  2154. ;
  2155. ;  Print Line pted to by HL Ending in <CR>
  2156. ;    Decrement PAGCNT
  2157. ;
  2158. lprintx:
  2159.     call    lprint        ;print without <CR>
  2160.     jmp    crlf        ;do <CR> <LF>
  2161. ;
  2162. ;  Print Line Pted to by HL; Decrement PAGCNT
  2163. ;
  2164. lprint:
  2165.     lda    pagcnt        ;check for page overflow
  2166.     ora    a        ;do nothing
  2167.     brz    lskip        ;... except skip out line
  2168.     mvi    b,0        ;set tab counter
  2169. lprnt0:
  2170.     mov    a,m        ;get char
  2171.     inx    h        ;pt to next
  2172.     ani    7FH        ;mask MSB
  2173.     cpi    DIM        ;goto standout mode?
  2174.     brz    lprnt3
  2175.     cpi    BRIGHT        ;end standout mode?
  2176.     brz    lprnt4
  2177.     cpi    TAB        ;tabulate?
  2178.     brz    lprnt2
  2179.     cpi    CR        ;done?
  2180.     brz    lprnt1
  2181.     call    cout        ;print
  2182.     inr    b        ;incr tab counter
  2183.     br    lprnt0
  2184. lprnt1:
  2185.     inx    h        ;pt to first char of next line
  2186.     lda    pagcnt        ;count down pages
  2187.     dcr    a
  2188.     sta    pagcnt
  2189.     ret
  2190. lprnt2:
  2191.     mvi    a,' '        ;print <SP>
  2192.     call    cout
  2193.     inr    b        ;incr tab counter
  2194.     mov    a,b        ;done?
  2195.     ani    7        ;every 8
  2196.     brnz    lprnt2
  2197.     br    lprnt0
  2198. lprnt3:
  2199.     call    stndout        ;enter standout mode
  2200.     br    lprnt0
  2201. lprnt4:
  2202.     call    stndend        ;end standout mode
  2203.     br    lprnt0
  2204.  
  2205. ;
  2206. ;  Skip to Beginning of Next Line and Test First Char for Menu Indicator
  2207. ;
  2208. lskipt:
  2209.     call    lskip        ;skip
  2210.     mov    a,m        ;get char
  2211.     ani    7FH        ;mask
  2212.     cpi    MINDIC        ;test
  2213.     ret
  2214.  
  2215. ;
  2216. ;  Skip to Beginning of Next Line
  2217. ;
  2218. lskip:
  2219.     mov    a,m        ;get char
  2220.     ani    7FH        ;mask out MSB
  2221.     cpi    CTRLZ        ;EOF?
  2222.     rz
  2223.     inx    h        ;pt to next
  2224.     cpi    LF        ;EOL?
  2225.     brnz    lskip
  2226.     ret
  2227.  
  2228. ;
  2229. ;  Menu Structure Error -- FATAL
  2230. ;    This message is printed to indicate an error in the structure of
  2231. ; the MENU.MNU file.
  2232. ;
  2233. mstrerr:
  2234.     call    vprint
  2235.     db    CR,LF,' Structure Error',0
  2236.     jmp    os$ccp
  2237.  
  2238. ;
  2239. ; Expand Line Pted to by HL into Scratch Area
  2240. ;    Return with HL pting to next line, DE pting to current line
  2241. ;
  2242. expand:
  2243.     xchg
  2244.     lxi    h,noname    ;init no name file
  2245.     mvi    m,1        ;set no entry
  2246.     lhld    expline        ;pt to buffer
  2247.     xchg
  2248. exp1:
  2249.     mov    a,m        ;get next char
  2250.     ani    7fh        ;mask MSB
  2251.     stax    d        ;store char
  2252.     cpi    CR        ;end of line?
  2253.     jz    expx
  2254.     inx    h        ;pt to next
  2255.     inx    d
  2256.     cpi    VARFLAG        ;variable follows?
  2257.     brnz    exp1
  2258. ;
  2259. ; Variable Identified - Process it
  2260. ;
  2261.     mov    a,m        ;get next char
  2262.     inx    h        ;pt to next
  2263.     cpi    VARFLAG        ;one variable char?
  2264.     brz    exp1        ;resume if double VARFLAG
  2265.     dcx    d        ;pt to variable position
  2266.     ani    7FH        ;mask
  2267.     call    caps        ;capitalize variable
  2268.     cpi    FPDISK        ;current disk?
  2269.     brz    expdisk
  2270.     cpi    FPUSER        ;current user?
  2271.     brz    expuser
  2272.     cpi    FPFILE        ;filename.typ?
  2273.     brz    expfile
  2274.     cpi    FPNAME        ;filename?
  2275.     brz    expname
  2276.     cpi    FPPTR        ;file being pointed to?
  2277.     brz    exppfile
  2278.     cpi    FPTYPE        ;filetype?
  2279.     brz    exptype
  2280.     br    exp1        ;resume expansion
  2281. ;
  2282. ; Expand Exit
  2283. ;
  2284. expx:
  2285.     inx    h        ;pt to line feed
  2286.     mov    a,m        ;get it
  2287.     cpi    LF        ;line feed?
  2288.     brnz    expx1
  2289.     inx    h        ;pt to char after line feed
  2290. expx1:
  2291.     xchg            ;DE pts to next line
  2292.     lhld    expline        ;pt to expanded line
  2293.     xchg            ;HL pts to next line, DE pts to expanded line
  2294.     ret
  2295.  
  2296. ;
  2297. ; Expand Disk
  2298. ;
  2299. expdisk:
  2300.     call    retud        ;get disk in B
  2301.     mov    a,b        ;get disk number (A=0)
  2302.     adi    'A'        ;convert to ASCII
  2303.     stax    d        ;store letter
  2304.     inx    d        ;pt to next
  2305.     br    exp1        ;resume expansion
  2306. ;
  2307. ; Expand User
  2308. ;
  2309. expuser:
  2310.     call    retud        ;get user in C
  2311.     mov    a,c        ;get user number
  2312.     mvi    b,10        ;subtract 10's
  2313.     mvi    c,'0'        ;set char
  2314. expu1:
  2315.     sub    b        ;-10
  2316.     brc    expu2
  2317.     inr    c        ;increment digit
  2318.     br    expu1
  2319. expu2:
  2320.     add    b        ;+10
  2321.     adi    '0'        ;convert 1's to ASCII
  2322.     mov    b,a        ;B=1's
  2323.     mov    a,c        ;get 10's
  2324.     stax    d        ;store 10's
  2325.     inx    d
  2326.     mov    a,b        ;get 1's
  2327.     stax    d        ;store 1's
  2328.     inx    d        ;pt to next
  2329.     br    exp1        ;resume
  2330. ;
  2331. ; Expand File
  2332. ;
  2333. expfile:
  2334.     call    getfnum        ;get file number
  2335.     jz    exp1        ;resume if error
  2336.     push    h        ;save ptr to next char
  2337.     call    ptfn        ;set ptr to file name
  2338.     call    putn        ;put file name
  2339.     mvi    a,'.'
  2340.     stax    d        ;store dot
  2341.     inx    d        ;pt to next
  2342.     call    putt        ;put file type
  2343.     pop    h        ;restore ptr
  2344.     jmp    exp1        ;resume
  2345. ;
  2346. ; Expand Name
  2347. ;
  2348. expname:
  2349.     call    getfnum        ;get file number
  2350.     jz    exp1        ;resume if error
  2351.     push    h        ;save ptr to next char
  2352.     call    ptfn        ;set ptr to file name
  2353.     call    putn        ;put file name
  2354.     pop    h        ;restore ptr
  2355.     jmp    exp1        ;resume
  2356. ;
  2357. ; Expand Type
  2358. ;
  2359. exptype:
  2360.     call    getfnum        ;get file number
  2361.     jz    exp1        ;resume if error
  2362.     push    h        ;save ptr to next char
  2363.     call    ptfn        ;set ptr to file name
  2364.     mvi    a,8        ;add 8
  2365.     add    l
  2366.     mov    l,a
  2367.     mov    a,h
  2368.     aci    0
  2369.     mov    h,a
  2370.     call    putt        ;put file type
  2371.     pop    h
  2372.     jmp    exp1        ;resume
  2373. ;
  2374. ; Expand File at Pointer
  2375. ;
  2376. exppfile:
  2377.     mov    a,m        ;get option char
  2378.     ani    7FH        ;mask
  2379.     call    caps        ;capitalize
  2380.     cpi    FPFILE        ;filename.typ?
  2381.     brz    exppf
  2382.     cpi    FPNAME        ;filename only?
  2383.     brz    exppn
  2384.     cpi    FPTYPE        ;filetype only?
  2385.     brz    exppt
  2386.     jmp    exp1        ;abort if error
  2387. ;
  2388. ; Extract full filename.typ of file being pointed to
  2389. ;
  2390. exppf:
  2391.     inx    h        ;pt to next char
  2392.     push    h        ;save ptr to next char
  2393.     lhld    ringpos        ;set ring position
  2394.     call    cknoname    ;check and substitute no file
  2395.     call    putn        ;put name pted to by HL
  2396.     mvi    a,'.'        ;store dot
  2397.     stax    d
  2398.     inx    d
  2399.     call    putt        ;put type pted to by HL
  2400.     pop    h
  2401.     jmp    exp1        ;continue
  2402. ;
  2403. ; Expand file name of file being pointed to
  2404. ;
  2405. exppn:
  2406.     inx    h        ;pt to next char
  2407.     push    h        ;save ptr to next char
  2408.     lhld    ringpos        ;set ring position
  2409.     call    cknoname    ;check and substitute no file
  2410.     call    putn        ;put name
  2411.     pop    h
  2412.     jmp    exp1
  2413. ;
  2414. ; Expand file type of file being pointed to
  2415. ;
  2416. exppt:
  2417.     inx    h        ;pt to next char
  2418.     push    h        ;save ptr to next char
  2419.     push    d        ;save DE
  2420.     lhld    ringpos        ;pt to ring entry
  2421.     call    cknoname    ;check and substitute no file
  2422.     lxi    d,8        ;pt to file type
  2423.     dad    d
  2424.     pop    d        ;get DE
  2425.     call    putt        ;put type
  2426.     pop    h
  2427.     jmp    exp1
  2428. ;
  2429. ; Check to see if HL pts to 'noname' and, if so, substitute name
  2430. ;
  2431. cknoname:
  2432.     push    d        ;save DE
  2433.     push    b        ;save BC
  2434.     call    ckno        ;do check
  2435.     pop    b        ;get BC
  2436.     pop    d        ;restore DE
  2437.     ret
  2438. ckno:
  2439.     mov    a,m        ;get char
  2440.     cpi    1        ;no name?
  2441.     rnz
  2442.     lxi    h,noname    ;pt to no name
  2443.     mov    a,m        ;check for definition
  2444.     cpi    1        ;no name?
  2445.     rnz
  2446.     xchg            ;HL pts to file name
  2447.     call    ermsg
  2448.     db    'File Name? ',0
  2449.     lhld    ibuf        ;pt to input buffer
  2450.     mvi    a,0ffh        ;capitalize input
  2451.     call    bline        ;get line from user
  2452.     call    sksp        ;skip spaces
  2453.     xchg
  2454.     lhld    menufcb        ;pt to dummy FCB
  2455.     xchg
  2456.     call    zprsfn        ;parse file name into FCB
  2457.     inx    d        ;pt to first char
  2458.     lxi    h,noname    ;pt to name buffer
  2459.     xchg
  2460.     mvi    b,11        ;copy into buffer
  2461.     call    moveb
  2462.     ret            ;HL pts to name
  2463. ;
  2464. ; Pt to File Name whose Number (1-4) is in A
  2465. ;
  2466. ptfn:
  2467.     mov    b,a        ;get number in B
  2468.     call    getfn2        ;pt to file name 2
  2469.     push    d        ;save DE
  2470.     mov    a,b        ;file 0?
  2471.     ora    a
  2472.     brz    ptfnx
  2473.     lxi    d,11        ;size of file name and type
  2474. ptfn1:
  2475.     dad    d        ;pt to next
  2476.     bjnz    ptfn1
  2477. ptfnx:
  2478.     pop    d        ;restore DE
  2479.     ret
  2480. ;
  2481. ; Put File Name pted to by HL
  2482. ;
  2483. putn:
  2484.     mvi    b,8        ;8 chars
  2485.     br    putc
  2486. ;
  2487. ; Put File Type pted to by HL
  2488. ;
  2489. putt:
  2490.     mvi    b,3        ;3 chars
  2491. ;
  2492. ; Copy Chars from HL to DE for up to B bytes -- flush if space
  2493. ;
  2494. putc:
  2495.     mov    a,m        ;get next char
  2496.     cpi    ' '        ;skip spaces
  2497.     brz    putc1
  2498.     stax    d        ;put next char
  2499.     inx    d        ;pt to next
  2500. putc1:
  2501.     inx    h        ;pt to next
  2502.     bjnz    putc
  2503.     ret
  2504.  
  2505. ;
  2506. ; Get File Number (1 to 4)
  2507. ;    If valid number, return with value in A and HL pting to next char
  2508. ;    If not valid, return with Z and HL pting to last char (F, N, T)
  2509. ;
  2510. getfnum:
  2511.     mov    a,m        ;get char
  2512.     sui    '1'        ;convert
  2513.     brc    getfne        ;error
  2514.     cpi    4        ;range?
  2515.     brnc    getfne
  2516.     inx    h        ;pt to next char
  2517.     ret            ;NZ from CPI 4
  2518. getfne:
  2519.     dcx    h        ;error return
  2520.     xra    a
  2521.     ret
  2522.  
  2523. ;
  2524. ;  Return Number of Lines on CRT in A
  2525. ;
  2526. getnlines:
  2527.     push    h        ;save HL
  2528.     call    getcrt        ;get CRT info
  2529.     inx    h        ;pt to number of lines
  2530.     mov    a,m        ;get count
  2531.     pop    h        ;restore HL
  2532.     sui    EPSLINE+1    ;subtract number of lines in file display
  2533.                 ; ... + 1 for footer
  2534.     ret
  2535.  
  2536. ;
  2537. ;  Convert char string pted to by HL into decimal number in A
  2538. ;    On Entry, HL pts to first digit char
  2539. ;    On Exit, HL pts to after last digit char and A=number
  2540. ;
  2541. eval:
  2542.     push    b        ;save BC
  2543.     mvi    b,0        ;set value
  2544. eval1:
  2545.     mov    a,m        ;get digit
  2546.     sui    '0'        ;convert to binary
  2547.     brc    eval2
  2548.     cpi    10        ;range?
  2549.     brnc    eval2
  2550.     inx    h        ;pt to next digit
  2551.     mov    c,a        ;new digit in C
  2552.     mov    a,b        ;multiply B by 10
  2553.     add    a        ;*2
  2554.     add    a        ;*4
  2555.     add    b        ;*5
  2556.     add    a        ;*10
  2557.     add    c        ;add in new digit
  2558.     mov    b,a        ;result in B
  2559.     br    eval1
  2560. eval2:
  2561.     mov    a,b        ;result in A
  2562.     pop    b        ;restore ptr
  2563.     ret
  2564.  
  2565. ;
  2566. ;  Compute Address of Buffer for Menu Load
  2567. ;
  2568. menustrt:
  2569.     lhld    ringend        ;get address of buffer for menu load
  2570.     inr    h        ;next page
  2571.     mvi    l,0
  2572.     ret
  2573.  
  2574. ;
  2575. ; S T O R A G E
  2576. ;
  2577. ; Initialized
  2578. ;
  2579. FILERCMD:
  2580.     VMNAME        ;VMENU Name
  2581.     VMNFILL        ;Filler
  2582.     DB    ' '    ;one space
  2583.     DB    0    ;end of shell command
  2584. JOKER:
  2585.     DB    '???????????'    ;*.* equivalent
  2586. MENUFILE:
  2587.     db    'MENU    '
  2588.     db    'VMN'
  2589.  
  2590. ;
  2591. ; Uninitialized
  2592. ;
  2593. STACK:
  2594.     DS    2
  2595. BUFFER:
  2596.     DS    2        ;buffer start
  2597. CURAT:
  2598.     DS    2        ;current cursor position
  2599. ERMFLG:
  2600.     DS    1        ;error message flag
  2601. EXPLINE:
  2602.     DS    2        ;buffer to expand line in
  2603. H$DR:
  2604.     DS    1        ;home drive
  2605. H$U$A:
  2606.     DS    1        ;home user area (must follow H$DR)
  2607. IBUF:
  2608.     DS    2        ;input line buffer
  2609. LOCBEG:
  2610.     DS    2        ;local beginning of ring
  2611. LOCEND:
  2612.     DS    2        ;local end of ring
  2613. LOCPOS:
  2614.     DS    2        ;local ring position (temp)
  2615. MENUFCB:
  2616.     DS    2        ;FCB for Menu File
  2617. NONAME:
  2618.     DS    11        ;dummy user-defined file name
  2619. RING:
  2620.     DS    2        ;ptr to beginning of ring
  2621. RINGI:
  2622.     DS    2        ;ring sort pointer
  2623. RINGJ:
  2624.     DS    2        ;another ring sort pointer
  2625. RINGEND:
  2626.     DS    2        ;current ring end pointer
  2627. RINGPOS:
  2628.     DS    2        ;current ring position in scan
  2629. SCURAT:
  2630.     DS    2        ;save cursor position
  2631. SRINGPOS:
  2632.     DS    2        ;save ring position
  2633. ;
  2634. ;  Menu Buffers
  2635. ;
  2636. more:
  2637.     ds    1        ;More Files Flag
  2638. optstrt:
  2639.     ds    2        ;Address of First Option in Current Menu
  2640. mstart:
  2641.     ds    2        ;Address of First Menu
  2642. cstart:
  2643.     ds    2        ;Address of Current Menu
  2644. nmenfl:
  2645.     ds    1        ;Next Menu Available Flag (0=No)
  2646. menuno:
  2647.     ds    1        ;Number of Menu
  2648. pagcnt:
  2649.     ds    1        ;Paging Counter
  2650. cpmok:
  2651.     ds    1        ;OK to Return to ZCPR3 (0=No)
  2652.  
  2653.     END
  2654.  
  2655.