home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / rcpm / lux8080.ark / LUX43.MAC < prev    next >
Text File  |  1984-12-27  |  47KB  |  1,838 lines

  1. ;
  2. ; LUX - A Library extension system - Version 4.3 as of  12/27/84
  3. ;
  4. ;    LUX Version 1.2B was Copyright 1983 by Steven R. Holtzclaw
  5. ;     and entered into the public domain.
  6. ;
  7. ; 12-27-84  Modified MAKELUX.MAC, and LUX42.MAC creating LUX43.MAC
  8. ; LUX 4.3   and MKLX8080.ASM of which now will operate identically
  9. ;        to the former LUX v4.2, but instead on any 8080 based
  10. ;        system. Why this was not done earlier we know not why.
  11. ;                               - Donald Phillips
  12. ;                               - Douglas Coatney
  13. ;                                 MicroBBS RCP/M (213) 598-8495
  14. ;        
  15. ;
  16. ; 10-07-84  Changed extended command mode to be useable with NULU10
  17. ; LUX 4.2   instead of LU300's command structure.  NULU is re-entrant
  18. ;           and only needs to be loaded into memory for use.
  19. ;           The extended commands are now "-L" to load NULU into the
  20. ;           command mode and list the directory, or "-F" which loads
  21. ;           NULU into the filesweep mode.  From either mode, NULU is
  22. ;           left in command mode until terminated. - [sls]
  23. ;
  24. ; 09-12-84  Added HARDCD equate for those of us supporting ZCPRs wheel
  25. ; LUX 4.1   but not using the maxdrv/maxusr values poked by ZCPR.
  26. ;           Also added RCPM functions for TIME (TOS) and NEW (WHATSNEW)
  27. ;           modules (impliment them as desired.)  Also added CMDJMP
  28. ;           equates for D and SD commands to work the same as DIR.
  29. ;           Changed internal error-handling to point out command
  30. ;           in error. - [sls]
  31. ;
  32. ; 09-07-84  Added auto-directory logic, added BYE function, with vector
  33. ; LUX 4.0   accessible from external program to force the removal of LUX.
  34. ;        Removed system-specific and trivial textual code.
  35. ;        Condensed revision info for quick reading. - [ mah ]
  36. ;
  37. ; Modification history in reverse order:
  38. ;
  39. ; [ srh ] - Steve R. Holtzclaw
  40. ; [ mah ] - Mark A. Howard    CNY TECHNICAL RCP/M     (315) 437-4890
  41. ; [ sls ] - Steve L. Sanders     DATA COM NETWORK SYSTEMS (813) 937-3608
  42. ;
  43. ;                    
  44. ; 08/28/84  Elimination of external HELP system, message format mods. - [ sls ]
  45. ; LUX 3.0
  46. ;
  47. ; 02/04/84  Command formats changed, error messages changed. - [ sls ]
  48. ; LUX 2.2
  49. ;
  50. ; 01/23/84  Added LU internal calls, ZCPR, and EXTCMD logic.  Reworked
  51. ; LUX 2.0   sone of the transients, and formatting changes. - [ mah ]
  52. ;
  53. ; 12/06/83  Added more code to test for altered BDOS/BIOS to eliminate
  54. ; LUX 1.2B  problems with non-std systems.  Dropped SD command. - [srh]
  55. ;
  56. ; 11/28/83  Make program self-relocating, works with BYELOW now. Error
  57. ; LUX 1.2A  reporting bug fixed.  - [ srh ]
  58. ;
  59. ; 11/26/83  Original release.  Adapted from ATTACH program. - [ srh ]
  60. ;
  61. ;----------------------------------------------------------------------------
  62. ;
  63.     .Z80
  64. ;
  65. TRUE    EQU    -1
  66. FALSE    EQU    NOT TRUE
  67. ;
  68. ;----------------------------------------------------------------------------
  69. ;
  70. ;    ====> This area must be edited for your configuration <====
  71. ;
  72. ;    Also: if RCPM is true, edit BYECMD equate at end of file if
  73. ;             your logoff program is NOT called BYE.COM
  74. ;
  75. ZCPR    EQU    TRUE        ; TRUE, if using nzcpr/zcmd/zcpr2/zcpr3
  76. HARDCD    EQU    TRUE        ; TRUE, use hard coded max values instead of
  77.                 ;       ZCPR's max drive/max user
  78. RCPM    EQU    TRUE        ; TRUE, if being used with a RCP/M system
  79. LUCMD    EQU    FALSE        ; TRUE, if using NULU10 extended commands
  80. HLPMSG    EQU    TRUE        ; TRUE, if helpful messages are wanted
  81. AUTODR    EQU    TRUE        ; TRUE, if auto-dir wanted when LUX is 
  82.                 ;       first attached to a LBR file
  83. HLPERS    EQU    3        ; give auto-help after this many errors
  84. ;
  85. ;    Note: if ZCPR and LUCMD are TRUE, extended commands
  86. ;          will be disabled when WHEEL byte is reset (remote mode).  
  87. ;          If LUCMD is TRUE and ZCPR is FALSE, extended commands 
  88. ;          will always be enabled.
  89. ;
  90. ;    The following equates define the drive and user number for each
  91. ;    auxiliary lux module.  (0=a, 1=b, etc)
  92. ;
  93. TYPDRV    EQU    0        ; drive number for type module
  94. TYPUSR    EQU    0        ; user number for type module
  95. DIRDRV    EQU    0        ; drive number for dir module
  96. DIRUSR    EQU    0        ; user number for dir module
  97. ;
  98. ;**********************************************************************
  99. ; note: The DIR.COM file must be a SD-xx.COM vers capable of $L option
  100. ;
  101. FILDRV    EQU    0        ; drive number for dir.com
  102. FILUSR    EQU    0        ; user number for dir.com
  103. ;**********************************************************************
  104. ;
  105. CHKDRV    EQU    0        ; drive number for chek module
  106. CHKUSR    EQU    0        ; user number for chek module
  107. CRCDRV    EQU    0        ; drive number for crck module
  108. CRCUSR    EQU    0        ; user number for crck module
  109. ;
  110. ;    Note - the following are only necessary if RCPM is TRUE
  111. ;
  112. CHTDRV    EQU    0        ; drive number for chat.com
  113. CHTUSR    EQU    0        ; user number for chat.com
  114. XMODRV    EQU    0        ; drive number for xmodem module
  115. XMOUSR    EQU    0        ; user number for xmodem module
  116. TIMDRV    EQU    0        ; drive number for time.com
  117. TIMUSR    EQU    0        ; user number for time.com
  118. NEWDRV    EQU    0        ; drive number for new.com
  119. NEWUSR    EQU    0        ; user number for new.com
  120. ;
  121. ;    Note - the following is only necessary if LUCMD is TRUE
  122. ;
  123. ; Designed for use with the new NULU10 utility, looks for
  124. ; the file called  NULU.COM  not  LU300.COM
  125. ;
  126. LUDRV    EQU    0        ; drive number for NULU.com
  127. LUUSR    EQU    15        ; user number for NULU.com
  128. ;
  129. ;----------------------------------------------------------------------------
  130. ;
  131. VERS    EQU    43        ; version number
  132. MODLVL    EQU    ' '        ; modification level
  133. BDOS    EQU    0005H
  134. TPA    EQU    0100H        ; cpm program area
  135. FCB1    EQU    005CH        ; first file control block
  136. FCB2    EQU    006CH        ; second file control block
  137. REBOOT    EQU    0000H        ; 
  138. CBUFF    EQU    080H        ; default command buffer
  139. ;
  140.     IF    HARDCD
  141. MAXDRV    EQU    6        ; max drive (0-15) 0=a: 1=b:, etc...
  142. MAXUSR    EQU    14        ; max user area (0-31)
  143.     ENDIF
  144. ;
  145. ZPRDRV    EQU    03DH        ; zcpr max drive location
  146. ZPRUSR    EQU    03FH        ; zcpr max user location
  147. WHEEL    EQU    03EH        ; zcpr wheel byte location
  148. ;
  149. ;    Macros used
  150. ;
  151. DRVUSR    MACRO    DRIVNO,USERNO,FNCNAM,RTN1,RTN2,RTN3,RTN4
  152.     CALL    FILTYP
  153.     DEFB    DRIVNO+'A'
  154. USERN1    DEFL    USERNO
  155.     IF    USERN1 GT 9
  156.     DEFB    (USERN1 /10)+'0'
  157.     USERN1    DEFL USERN1-10
  158.     ENDIF
  159.     DEFB    USERN1+'0'
  160.     DEFB    ':'
  161.     DEFB    FNCNAM
  162.     DEFB    0
  163.     IF    NOT NUL RTN1
  164.     CALL    RTN1
  165.     ENDIF
  166.     IF    NOT NUL RTN2
  167.     CALL    RTN2
  168.     ENDIF
  169.     IF    NOT NUL RTN3
  170.     CALL    RTN3
  171.     ENDIF
  172.     IF    NOT NUL RTN4
  173.     CALL    RTN4
  174.     ENDIF
  175.     JP    PROCES
  176.     ENDM
  177. ;
  178. DVUS    MACRO    DRIVNO,USERNO,FNCNAM,RTN1,RTN2,RTN3,RTN4
  179.     CALL    FILTYP
  180.     DEFB    DRIVNO+'A'
  181. USERN2    DEFL    USERNO
  182.     IF    USERN2 GT 9
  183.     DEFB    (USERN2 /10)+'0'
  184.     USERN2    DEFL USERN2-10
  185.     ENDIF
  186.     DEFB    USERN2+'0'
  187.     DEFB    ':'
  188.     DEFB    FNCNAM
  189.     DEFB    0
  190.     ENDM
  191. ;
  192. CMDJMP    MACRO    VERB,VECTOR
  193.     CALL    ILCMP
  194.     DEFB    VERB
  195.     DEFB    0
  196.     JP    NC,VECTOR
  197.     ENDM
  198. ;
  199. START    EQU    $
  200.     LD    SP,SSTACK    ; starting stack
  201.     CALL    ILPRT
  202.     DEFB    13,10,'LUX v'
  203.     DEFB    (VERS/10)+'0'
  204.     DEFB    '.'
  205.     DEFB    (VERS MOD 10)+'0',MODLVL
  206.     DEFB    ' as of 27-Dec-84',13,10,0
  207. ;
  208. ; set up max drive/user
  209. ;
  210.     IF    HARDCD        ; if HARDCD true, use spec'd values
  211.  
  212.     LD    A,MAXDRV    ; hard coded max drive
  213.     LD    (DRVMAX),A
  214.     LD    A,MAXUSR    ; hard coded max user
  215.     LD    (USRMAX),A
  216.  
  217.     ELSE
  218.  
  219.     LD    A,(ZPRDRV)    ; if not HARDCD, use ZCPR maximums
  220.     LD    (DRVMAX),A    ; max drive
  221.     LD    A,(ZPRUSR)    ; max user
  222.     DEC    A
  223.     LD    (USRMAX),A
  224.  
  225.     ENDIF
  226. ;
  227. ; check for a blank or null command line
  228. ;
  229.     LD    A,(CBUFF+1)    ; get byte from default command buffer
  230.     OR    A        ; if non-zero then there is a possible
  231.     JP    NZ,GTDVUS    ;    file specified
  232. ;
  233. SPCERR:    CALL    ILPRT        ; print the error message
  234.     DEFB    13,10
  235. ;
  236.     DEFB    '++ Examples of valid LUX commands ++',13,10
  237.     DEFB    13,10
  238.     DEFB    '   LUX FILENAME     <-Attach to FILENAME.LBR'
  239.     DEFB    ' on current drive/user',13,10
  240.     DEFB    '   LUX A4:FILENAME  <-Attach to FILENAME.LBR'
  241.     DEFB    ' on drive A:- USER 4',13,10
  242.     DEFB    '   LUX B1:FILENAME  <-Attach to FILENAME.LBR'
  243.     DEFB    ' on drive B:- USER 1',13,10
  244.     DEFB    13,10
  245.     DEFB    '   FILENAME must be a valid library (.LBR) file',13,10
  246.      DEFB    0
  247.  
  248.     JP    REBOOT        ; reboot since we have destroyed the ccp
  249. ;
  250. BDDRUS:    CALL    ILPRT
  251.     DEFB    13,10
  252.     DEFB    '++ Invalid drive/user number ++',7,13,10,0
  253.     JP    SPCERR
  254. ;
  255. ;
  256. GTDVUS:    LD    HL,CBUFF+2    ; index default key buffer
  257.     CALL    DRUSR        ; get requested drive/user
  258.     JP    C,SPCERR
  259. ;
  260. ; test for drive/user within range
  261. ;
  262.     PUSH    HL        ; save command line pointer
  263.     PUSH    BC        ; save drive/user spec
  264.     LD    A,(DRVMAX)    ; get max drive
  265.     CP    C
  266.     JP    C,BDDRUS
  267.     LD    A,(USRMAX)
  268.     CP    B
  269.     JP    C,BDDRUS
  270.     POP    HL
  271.     LD    (RQDDRV),HL    ; set the requested drive/user
  272.     POP    HL
  273.     EX    DE,HL        ; de is source address to create new fcb
  274.     LD    HL,FCB1        ; index fcb
  275.     CALL    SCANR1        ; create the new fcb
  276. ;
  277. ; force the default file type 
  278. ;
  279.     LD    HL,'BL'        ; set 'LB' into first two bytes of file type
  280.     LD    (FCB1+9),HL
  281.     LD    A,'R'        ; set 'R' into last byte of file type
  282.     LD    (FCB1+11),A
  283. ;
  284. ; get the library name from the fcb and store it
  285. ;
  286.     LD    HL,FCB1        ; source for move
  287.     LD    DE,LBRNAM-1    ; destination for move
  288.     LD    BC,9        ; max 8 character filename
  289. TMP010:    LD    A,(HL)
  290.     INC    HL
  291.     EX    DE,HL
  292.     LD    (HL),A
  293.     INC    HL
  294.     EX    DE,HL
  295.     DEC    C
  296.     JP    NZ,TMP010    ; LDIR replacement
  297. ;    LDIR            ; move to local name
  298. ;
  299. AMBTST:    LD    HL,FCB1+1    ; first byte of filename
  300.     LD    A,'?'        ; character to look for
  301.     LD    BC,11        ; search thru 11 bytes
  302. TMP110:    CP    (HL)
  303.     PUSH    AF
  304.     INC    HL
  305.     DEC    C
  306.     JP    NZ,TMP112
  307.     POP    AF
  308.     JP    TMP115
  309. TMP112:    POP    AF
  310.     JP    NZ,TMP110
  311. TMP115    EQU    $
  312. ;    CPIR            ; do search
  313.     JP    NZ,LOOKUP    ; no ? found - continue
  314. ;
  315. NOAMBG:    CALL    ILPRT        ; print the error message
  316.     DEFB    13,10
  317.     DEFB    '++ Ambiguous filenames are not allowed ++',7,13,10,0
  318.     JP    SPCERR
  319. ;
  320. ; look for the filename on directory
  321. ;
  322. LOOKUP:    CALL    GETOLD        ; get the current drive/user
  323.     CALL    SETNEW        ; set requested drive/user
  324.     LD    DE,080H        ; default dma address
  325.     LD    C,26
  326.     CALL    BDOS        ; set the dma address
  327.     LD    DE,FCB1        ; index filename specified
  328.     LD    C,17
  329.     CALL    BDOS        ; search for first
  330.     INC    A        ; does file exist?
  331.     JP    NZ,PGMSTR    ; jump to start of lux
  332. ;
  333. NOFILE:    CALL    SETOLD
  334.     CALL    ILPRT        ; print the error message
  335.     DEFB    13,10,'Can''t find ',0
  336.     CALL    DVUPRT
  337.     CALL    NAMPRT        ; print the filename
  338.     CALL    ILPRT
  339.     DEFB    ' - check the DIR',7,13,10,0
  340.     JP    0        ; reboot since we have destroyed the ccp
  341. ;
  342.     DEFS    64        ; 32 level stack for here
  343. SSTACK    EQU    $
  344. FINIS    EQU    $        ; finish of program loader
  345. ;
  346. LODLEN    EQU    FINIS-START    ; length of loader
  347.                 ; keep the program in line
  348.     DEFS    300H-LODLEN    ; add extra bytes here to make
  349.                 ; 'PGMSTR' start on a 100h byte boundary
  350. ;
  351. ;-----------------------------------------------------------------------
  352. ; this is the start of the relocated program - all of the code
  353. ; from 'START' to here is thrown away once lux begins execution
  354. ;-----------------------------------------------------------------------
  355. ;
  356. ; set up the bdos and bios patches
  357. ;   
  358. PGMSTR:    JP    INIT        ; jump to start of this module
  359.     DEFB    'LUX V4.20'    ; the name 'LUX' is a clue to other 
  360.                 ; programs that enables them to determine
  361.                 ; if lux is resident. 'L' is at bdos+3 when
  362.                 ; lux is resident
  363. ;
  364. ; this is the LUX removal routine, jumped to by the BYE command
  365. ; it is accessable to external programs, and is defined to exist at
  366. ; LUX+12 (looks like BDOS+12 when LUX is resident)
  367. ;
  368. REMOVE:    
  369. ;
  370.     IF    RCPM
  371. ;
  372.     LD    SP,TPA+100h    ; use the TPA for a stack
  373.     LD    BC,0        ; first select A0:
  374.     CALL    RESET        ;
  375.     LD    DE,80H        ; clear the DMA buffer
  376.     PUSH    DE        ;
  377.     PUSH    DE        ;
  378.     LD    B,80h        ; bytes to clear
  379.     XOR    A        ;
  380. RZRLP:    LD    (DE),A        ;
  381.     INC    DE        ;
  382.     DEC    B
  383.     JP    NZ,RZRLP    ; DJNZ replacement
  384. ;    DJNZ    RZRLP        ;
  385.     LD    A,BYELEN    ; store away the length of the command
  386.     LD    HL,BYECMD    ; now move the commands to the DMA
  387.     LD    (HL),A        ;
  388.     POP    DE        ; restore the DMA addr
  389.     LD    BC,BYELEN    ;
  390. TMP020:    LD    A,(HL)
  391.     INC    HL
  392.     EX    DE,HL
  393.     LD    (HL),A
  394.     INC    HL
  395.     EX    DE,HL
  396.     DEC    C
  397.     JP    NZ,TMP020    ; LDIR replacement
  398. ;    LDIR            ;
  399.     POP    DE        ; restore it again
  400.     LD    C,26        ; reset the DMA
  401.     CALL    BDOS        ;
  402.     LD    DE,SUBFCB    ; address the .SUB file FCB
  403.     LD    C,22        ; make the file
  404.     CALL    BDOS        ;
  405.     INC    A        ; check for errors
  406.     JP    Z,EXITER    ; oooops, no dir space
  407.     LD    DE,SUBFCB    ; else write the data
  408.     LD    C,21        ;
  409.     CALL    BDOS        ;
  410.     INC    A        ;
  411.     JP    Z,EXITER    ; oooops, no space left
  412.     LD    DE,SUBFCB    ;
  413.     LD    C,16        ; now close the file
  414.     CALL    BDOS        ;
  415.     LD    HL,0        ; now make the exit routine go to A0:
  416.     LD    (OLDDRV),HL    ;
  417. ;
  418.     ENDIF            ;RCPM
  419. ;
  420.     JP    UNPATH        ; unpatch the jump table, and warm boot
  421. ;
  422. ; error handler for REMOVE routine
  423. ;
  424.     IF    RCPM
  425. ;
  426. EXITER:    CALL    ILPRT        ; we had an error trying to make the .sub file
  427.     DB    13,10,7,'+ Error: Can''t remove LUX! Please +'
  428.     DB    13,10,'+        type CTRL-C to exit LUX, +'
  429.     DB    13,10,'+        then type BYE to logoff. +',0
  430.     LD    SP,STACK    ;
  431.     JP    GETCMD        ;
  432. ;
  433.     ENDIF            ;RCPM
  434. ;
  435. ; this is the LUX intialization
  436. ;
  437. INIT:    LD    HL,(1)        ; get warm boot vector
  438.     LD    (BIOS3),HL    ; save old warm boot vector
  439.     LD    HL,(6)        ; get bdos start
  440.     LD    (PGMSTR+1),HL    ; set new jump to bdos
  441.     LD    HL,PGMSTR    ; get local bdos vector
  442.     LD    (6),HL        ; set it in low memory
  443.     LD    SP,STACK    ; reset stack
  444. ;
  445. ; save the old bios vectors
  446. ;
  447.     LD    HL,(BIOS3)    ; bios wboot address
  448.     LD    DE,OWBOOT    ; local wboot address
  449.     LD    BC,12        ; 12 bytes to move
  450. TMP030:    LD    A,(HL)
  451.     INC    HL
  452.     EX    DE,HL
  453.     LD    (HL),A
  454.     INC    HL
  455.     EX    DE,HL
  456.     DEC    C
  457.     JP    NZ,TMP030    ; LDIR replacement
  458. ;    LDIR            ; move the block
  459. ;
  460. ; set up the new bios vectors
  461. ;
  462.     LD    DE,WBOOT    ; source is local table
  463.     LD    HL,(BIOS3)    ; destination is old bios
  464.     EX    DE,HL
  465.     LD    BC,12        ; 12 bytes to move
  466. TMP040:    LD    A,(HL)
  467.     INC    HL
  468.     EX    DE,HL
  469.     LD    (HL),A
  470.     INC    HL
  471.     EX    DE,HL
  472.     DEC    C
  473.     JP    NZ,TMP040    ; LDIR replacement
  474. ;    LDIR            ; move the block
  475. ;
  476.     LD    A,0FFH        ; set the auto-dir byte
  477.     LD    (DOADIR),A    ;
  478.     XOR    A        ; reset the error count
  479.     LD    (HLPCNT),A    ;
  480. ;
  481.     JP    ENTRY        ; initialize
  482. ;
  483. OWBOOT:    DEFB    0,0,0        ; old wboot vector is moved to here
  484. OCONST:    DEFB    0,0,0        ; old constat vector is moved to here
  485. OCONIN:    DEFB    0,0,0        ; old conin vector is moved to here
  486. OCONOU:    DEFB    0,0,0        ; old conout vector is moved to here
  487. ;
  488. WBOOT:    JP    ENTRY        ; vector warm boot to entry
  489. CONST:    JP    VCONST        ; check for carrier
  490. CONIN:    JP    VCONIN        ; vector conin to vconin
  491. CONOU:    JP    VCONOU        ; vector to conout
  492. ;
  493. VCONST:    JP    OCONST        ; jump to old constat routine
  494. ;
  495. VCONOU:    JP    OCONOU        ; jump to old conout routine
  496. ;
  497. VCONIN:    CALL    OCONIN        ; get a byte
  498.     CP    3        ; control c ?
  499.     RET    NZ        ; nope - let bios have it
  500.     LD    A,(ACTIVE)    ; is lux segment active?
  501.     OR    A
  502.     LD    A,3
  503.     RET    Z        ; not active - let bios have it
  504.     LD    SP,TPA        ; re initialize the stack
  505.     CALL    ILPRT        ; print the following
  506.     DEFB    'CTRL-C entered',13,10,13,10        ; dummy printout
  507.     DEFB    '           >> exiting LUX - standby',0
  508. ;
  509. UNPATH:    LD    DE,OWBOOT    ; index old warm boot vector
  510.     LD    HL,(BIOS3)    ; bios jump table
  511.     EX    DE,HL
  512.     LD    BC,12        ; 12 bytes to move
  513. TMP050:    LD    A,(HL)
  514.     INC    HL
  515.     EX    DE,HL
  516.     LD    (HL),A
  517.     INC    HL
  518.     EX    DE,HL
  519.     DEC    C
  520.     JP    NZ,TMP050    ; LDIR replacement
  521. ;    LDIR            ; move the old table back
  522.     CALL    SETOLD        ; set old drive/user
  523.     JP    0        ; warm boot - end of program
  524. ;
  525. ;    This is the LUX entry point
  526. ;
  527. ENTRY:    LD    SP,STACK    ; set up local stack
  528.     LD    HL,PGMSTR    ; dummy bdos vector
  529.     LD    (6),HL        ; set it
  530.     LD    HL,(BIOS3)    ; bios warm boot vector
  531.     LD    (1),HL        ; set it
  532.     LD    A,0C3H        ; (jmp)
  533.     LD    (0),A        ; reset warm boot jump
  534.     LD    (5),A        ; ...and bdos jump
  535. ;
  536.     CALL    OCONST        ; see if character waiting
  537.     OR    A        ; test result
  538.     JP    Z,ENTR1        ; ...if no character is waiting
  539.     CALL    OCONIN        ; get the console character
  540.                 ;    this is done to gobble any
  541.                 ;    possible garbage character
  542. ;
  543. ENTR1:    LD    A,0FFH
  544.     LD    (ACTIVE),A    ; set LUX active
  545. ;
  546. GETCMD:    CALL    SETNEW        ; reset drive/user
  547. ;    LD    IX,CBUFF+1    ; place to put command string
  548.     LD    HL,CBUFF+1
  549.     LD    (CPTRIX),HL
  550. ;    LD    IY,CBUFF+0    ; length of command
  551.     XOR    A
  552. ;    LD    (IY+0),A
  553.     LD    (CBUFF),A
  554. ;
  555.     IF    AUTODR
  556. ;
  557.     LD    A,(DOADIR)    ; shall we do a directory?
  558.     OR    A        ;
  559.     JP    Z,PROMPT    ; guess not
  560.     XOR    A        ; else zap the byte
  561.     LD    (DOADIR),A    ;
  562.     LD    A,3        ; fake a DIR command
  563.     LD    (CMDLEN),A    ;
  564.     LD    HL,'ID'        ;
  565.     LD    (CMDLIN+2),HL    ;
  566.     LD    L,'R'        ;
  567.     LD    H,0        ;
  568.     LD    (CMDLIN+4),HL    ;
  569.     JP    GOCNV        ; and do it 
  570. ;
  571.     ENDIF            ;AUTODR
  572. ;
  573. PROMPT:
  574.     IF    HLPMSG        ;
  575. ;
  576.     CALL    ILPRT        ; print the entry message
  577.     DEFB    13,10,'[ in LUX   CTRL-C to exit, HELP for menu ]',13,10,0
  578. ;
  579.     ENDIF            ;HLPMSG
  580. ;
  581. PRMPT2:
  582.     CALL    CRLF        ;
  583.     CALL    DVUPRT        ;print the LUX prompt
  584.     CALL    NAMPRT        ;drive/user, library name
  585.     CALL    ILPRT        ;
  586.     DEFB    '=>',0        ;
  587. ;
  588.     LD    DE,CMDLIN    ; index command line
  589.     LD    C,10
  590.     CALL    BDOS        ; read console buffer
  591.     LD    A,(CMDLEN)    ; get command length
  592.     OR    A        ; test it
  593.     JP    Z,GETCMD    ; if null command
  594.     LD    A,(CMDLIN+2)    ; get first character
  595.     CP    ';'        ; semicolon ok
  596.     JP    Z,PRMPT2    ; 
  597. GOCNV:    CALL    CNVBUF        ; convert the command line to upper case
  598. ;
  599. GETCM4:    LD    DE,CMDLIN+2    ; index data from the command line
  600. ;
  601.     CMDJMP    'HELP',QKHELP    ; quick help summary
  602.     CMDJMP  '?',QKHELP    ; alternate for HELP
  603.     CMDJMP    'TYPE',TIPE    ; file type command process
  604.     CMDJMP    'DIR',DIR    ; dir command process
  605.     CMDJMP    'D',DIR        ; alternate for DIR
  606.     CMDJMP    'SD',DIR    ; alternate for DIR
  607.     CMDJMP    'LUX',LUX    ; lux command process
  608.     CMDJMP    'FILES',FILES    ; run dir.com in "*.lbr" mode
  609.     CMDJMP    'CHEK',CHEK    ; run lchek
  610.     CMDJMP    'CRCK',CRCK    ; run lcrck
  611. ;
  612.     IF    RCPM
  613. ;
  614.     CMDJMP    'XMODEM',XMODEM    ; xmodem command process
  615.     CMDJMP    'SEND',SEND    ; synonym for XMODEM S
  616.     CMDJMP    'CHAT',CHAT    ; signal operator with chat.com
  617.     CMDJMP    'BYE',REMOVE    ; remove LUX, and run BYE
  618.     CMDJMP  'TIME',TIME    ; display timeon/current time
  619.     CMDJMP  'TOS',TIME    ; alternate for TIME
  620.     CMDJMP  'NEW',NEW    ; display new files list
  621.     CMDJMP  'WHATSNEW',NEW    ; alternate for NEW
  622. ;
  623.     ENDIF            ;RCPM
  624. ;
  625.     IF    ZCPR AND LUCMD AND RCPM
  626. ;
  627.     LD    A,(WHEEL)    ; check the wheel byte
  628.     OR    A        ;
  629.     JP    Z,CMDERR    ; don't allow SYSOP cmds if remote
  630. ;
  631.     ENDIF            ;ZCPR AND LUCMD AND RCPM
  632. ;
  633.     IF    LUCMD        ; extended LU commands
  634. ;
  635.     CMDJMP    '-L',LOAD    ; load NULU in command mode and display dir
  636. ;
  637.     CMDJMP  '-F',FSWP    ; load NULU in filesweep mode
  638. ;
  639.     ENDIF            ;LUCMD
  640. ;    
  641. CMDERR:    CALL    ILPRT
  642. ;
  643. ; this will actually print the command in error like this
  644. ;
  645. ;           ERROR --> dur <-- is not a valid LUX command.
  646. ;
  647.     DEFB    13,10,13,10,'ERROR --> ',0    ; point at command error
  648.     CALL    PRTERR        ; print the command just entered
  649.     LD    A,' '        ; and a space
  650.     CALL    CTYPE        
  651.     LD    HL,HLPCNT    ; address the error count
  652.     INC    (HL)        ; bump it
  653.     LD    A,HLPERS    ; have we reached the limit?
  654.     CP    (HL)        ;
  655.     JP    NZ,KPTRYN    ; no, jump around the rest
  656.     LD    (HL),0        ; else reset the count
  657.     JP    QKHELP        ; and give him help anyway 
  658. KPTRYN:    CALL    ILPRT        ; tell them it's no good
  659.     DEFB    '<-- Is not a valid LUX command.',7,13,10,0
  660.     JP    GETCMD        ;
  661. ;
  662. PRTERR:    LD    HL,CMDLIN+2    ; index command just entered
  663.     LD    A,(CMDLEN)    ; get the length
  664.     LD    B,A        ; into 'B'
  665. GETCM5:    LD    A,(HL)        ; get a byte
  666.     CP    020H        ; space ?
  667.     JP    Z,GETCM6    ; yes - dont print it
  668.     CP    000H        ; null
  669.     JP    Z,GETCM6    ; yes - all done
  670.     CALL    CTYPE        ; print the character
  671.     INC    HL        ; next character
  672.     DEC    B
  673.     JP    NZ,GETCM5    ; DJNZ replacement
  674. ;    DJNZ    GETCM5        ; loop for the rest
  675. GETCM6:    RET
  676. ;
  677. ; 'COMMAND TRANSLATION VECTORS
  678. ;
  679. ; 'SUMMARY OF AUX ROUTINES:
  680. ;
  681. ; 'FILTYP' installs the following 'DEFB' into new command line
  682. ;          specify the drive and user area for each command as in
  683. ;          the vectors below.  remember each 'DEFB' must end with a
  684. ;          zero.
  685. ;
  686. ; 'FILNAM' installs the current .lbr name into the new command line
  687. ;
  688. ; 'FILSPC' installs a space character into the new command line
  689. ;
  690. ; 'FILMEM' installs the requested member name into the new command line
  691. ;
  692. ;
  693. TIPE:    DRVUSR    TYPDRV,TYPUSR,'LUXTYP ',FILNAM,FILSPC,FILMEM,NULL
  694. ;
  695. DIR:    DRVUSR    DIRDRV,DIRUSR,'LUXDIR ',FILNAM,FILSPC,FILMEM,NULL
  696. ;
  697. FILES:     DRVUSR    FILDRV,FILUSR,'DIR *.LBR',NULL,NULL,NULL,NULL
  698. ;
  699. CHEK:    DRVUSR    CHKDRV,CHKUSR,'LUXCHK ',FILNAM,FILSPC,FILMEM,NULL
  700. ;
  701. CRCK:    DRVUSR    CRCDRV,CRCUSR,'LUXCRC ',FILNAM,FILSPC,FILMEM,NULL
  702. ;
  703.     IF    RCPM
  704. ;
  705. SEND:    DRVUSR    XMODRV,XMOUSR,'XMODEM L ',FILNAM,FILSPC,FILMEM,NULL
  706. ;
  707. CHAT:    DRVUSR    CHTDRV,CHTUSR,'CHAT',NULL,NULL,NULL,NULL
  708. ;
  709. TIME:    DRVUSR  TIMDRV,TIMUSR,'TIME',NULL,NULL,NULL,NULL
  710. ;
  711. NEW:    DRVUSR  NEWDRV,NEWUSR,'NEW',NULL,NULL,NULL,NULL
  712. ;
  713.     ENDIF                ; RCPM
  714. ;
  715.     IF    LUCMD            ;
  716. ;
  717. LOAD:    DVUS LUDRV,LUUSR,'NULU -O ',NULL,NULL,NULL,NULL
  718.     CALL    FILNAM            ;
  719.     CALL    FILTYP            ; * load NULU in command mode *
  720.     DEFB    ' -L',0            ; * and display the directory *
  721.     JP    PROCES            ; 
  722. ;
  723. FSWP:   DVUS LUDRV,LUUSR,'NULU -O ',NULL,NULL,NULL,NULL
  724.     CALL    FILNAM
  725.     CALL    FILTYP
  726.     DEFB    ' -F',0            ; * load NULU in filesweep mode *
  727.     JP    PROCES
  728. ;
  729. ; parse the ambiguous user/drive spec & filename, and place in command line
  730. ;
  731. AFNPRS:    CALL    FNDSPC            ; find the first space
  732.     JP    C,CMDERR        ; error if all scanned and no space
  733.     CALL    ADVANC            ; advance to next non-blank
  734.     JP    C,CMDERR        ; premature eol is error
  735. ;    PUSH    IX            ; drusr uses this ...
  736.     CALL    DRUSR            ; get drive/user, if any
  737. ;    POP    IX            ;
  738.     OR    A            ; did drive/user change?
  739.     JP    Z,SKPDVU        ;
  740.     PUSH    BC            ; skip over the drive spec in cmd line
  741.     LD    B,A            ; get bytes to skip
  742.     LD    HL,NXTWRD        ; address cmd pointer
  743. SKPTR:    INC    (HL)            ;
  744.      DEC    B
  745.     JP    NZ,SKPTR        ; DJNZ replacement
  746. ;    DJNZ    SKPTR            ;
  747.     POP    BC            ; restore user/drive spec
  748.     CALL    BDSDVU            ; convert to BDS usr/drv
  749.     JP    C,BDDRUS        ; if cy, then limits exceeded
  750. SKPDVU:    CALL    FILMEM            ; the rest is normal stuff
  751.     JP    PROCES            ;
  752. ;
  753.     ENDIF                ;LUCMD
  754. ;
  755. ; quick help summary
  756. ;
  757. QKHELP:    CALL    ILPRT
  758. ;
  759.     DEFB    13,10,13,10
  760.     DEFB    'You are presently attached to a library file with the',13,10
  761.     DEFB    'LUX utility.  These are the available commands:',13,10,10
  762.     DEFB    'LUX      filename    - Attach to another LBR file ',13,10
  763.     DEFB    'LUX   du:filename    - Attach to LBR file on specified du:',13,10
  764.     DEFB    'DIR, D, or SD        - Display attached library members',13,10
  765.     DEFB    'FILES                - Display other .LBR files on this du:',13,10
  766.     DEFB    'TYPE     filename.typ- Display ASCII file contents',13,10
  767.     DEFB    'CHEK     filename.typ- Run CHEK on requested member',13,10
  768.     DEFB    'CRCK     filename.typ- Run CRCK on requested member',13,10
  769. ;
  770.     IF    RCPM
  771. ;
  772.     DEFB    'SEND     filename.typ- Sends a library member file',13,10
  773.     DEFB    'XMODEM S filename.typ- Same as SEND command',13,10
  774.     DEFB    'CHAT                 - Chat with SYSOP (if available)',13,10
  775.     DEFB    'BYE                  - logs off the system',13,10
  776.     DEFB    'TIME (TOS)           - Displays timeon and current time',13,10
  777.     DEFB    'NEW (WHATSNEW)       - List of new files on-line',13,10
  778. ;
  779.     ENDIF            ; RCPM
  780. ;
  781.     DEFB    'HELP                 - Displays this menu',13,10
  782. ;
  783.     IF    NOT HLPMSG
  784. ;
  785.     DEFB    13,10,'[ in LUX   CTRL-C to exit, HELP for menu ]',13,10
  786. ;
  787.     ENDIF            ; NOT HLPMSG
  788. ;
  789.     DEFB    0
  790. ;
  791.     IF    LUCMD AND ZCPR AND RCPM
  792. ;
  793.     LD    A,(WHEEL)    ; should we display extended commands?
  794.     OR    A        ;
  795.     JP    Z,GETCMD    ; if wheel byte is reset, no
  796. ;
  797.     ENDIF            ;LUCMD AND ZCPR AND RCPM
  798. ;
  799.     IF    LUCMD
  800. ;
  801.     CALL    ILPRT        ;
  802.     DEFB    13,10,'[Hit any key] ',0
  803.     LD    C,1
  804.     CALL    BDOS        ;
  805.     CALL    CRLF        ;
  806.     CALL    CRLF        ;
  807.     CALL    ILPRT        ;
  808.     DEFB    13,10
  809.     DEFB    'NULU Extended Commands',13,10
  810.     DEFB     '======================',13,10,13,10
  811.     DEFB    '-L   NULU command mode and display DIR',13,10
  812.     DEFB    '-F   NULU filesweep mode',13,10,13,10
  813.     DEFB    'NULU is  re-entrant and  only needs to',13,10
  814.     DEFB    'loaded into memory.   All commands may',13,10
  815.     DEFB    'be listed with -M command once loaded.',13,10,13,10
  816.     DEFB    0
  817. ;
  818.     ENDIF            ;LUCMD
  819. ;
  820.     JP    GETCMD
  821. ;
  822. ; xmodem is a special case since the 'R' and 'L' options
  823. ; are invalid here
  824. ;
  825.     IF    RCPM
  826. ;
  827. XMODEM:    CALL    ADVANC        ; go to next character
  828.     LD    A,(HL)        ; get the character
  829.     CP    'S'        ; not legal here
  830.     JP    Z,XMODE1    ; ok to continue
  831.     CP    'R'        ; not legal here
  832.     JP    Z,XMODE2    ; execute error routine
  833.     CP    'L'        ; not legal here
  834.     JP    Z,XMODE3    ; execute error routine
  835.     DRVUSR    XMODRV,XMOUSR,'XMODEM',NULL,NULL,NULL,NULL
  836. ;
  837. XMODE1:    CALL    NXTSPC        ; look for next space
  838.     JP    SEND
  839. ;
  840. XMODE2:    CALL    CRLF
  841.     CALL    PRTERR        ; print the command
  842.     CALL    ILPRT        ; print the following
  843.     DEFB    ' can''t (R)eceive while in LUX',7,13,10,0
  844.     JP    GETCMD        ; return to command
  845. XMODE3:    CALL    CRLF
  846.     CALL    PRTERR        ; print the command
  847.     CALL    ILPRT        ; print the following
  848.     DEFB    ' only uses (S)end command while in LUX',7,13,10,0
  849.     JP    GETCMD
  850. ;
  851.     ENDIF            ; RCPM
  852. ;
  853. ; 'LUX' command process
  854. ;
  855. LUX:    LD    A,(CMDLEN)    ; get the length of the command line
  856.     CP    3        ; was input only 'LUX'
  857.     JP    Z,LUX04        ; error...
  858.     CALL    FNDSPC        ; find a space in command line
  859.     JP    C,LUX05        ; error if no space found
  860.     CALL    ADVANC        ; search for the next non-blank character
  861.     JP    C,LUX05        ; error if no more characters left
  862.     CALL    DRUSR        ; get drive/user
  863.     JP    C,LUX05        ; if drive/user specification error
  864.     PUSH    BC        ; save drive/user spec
  865.     PUSH    HL        ; save command line pointer
  866.     LD    H,B
  867.     LD    L,C
  868.     LD    (TMPDRV),HL    ; save the temporary drive/user
  869.     LD    A,(DRVMAX)    ; get max drive
  870.     CP    C
  871.     JP    C,LUX03        ; if out of range
  872.     LD    A,(USRMAX)
  873.     CP    B
  874.     JP    C,LUX03        ; if out of range
  875.     POP    HL
  876.     POP    BC
  877.     EX    DE,HL        ; de is source address to create new fcb
  878.     LD    HL,TMPFCB    ; index temporary fcb
  879.     CALL    SCANR1        ; create the new fcb
  880.     LD    HL,'BL'        ; set 'LB' into first two bytes of file type
  881.     LD    (TMPFCB+9),HL
  882.     LD    A,'R'        ; set 'R' into last byte of file type
  883.     LD    (TMPFCB+11),A
  884.     CALL    SETTMP        ; log into the requested drive/user
  885.     LD    DE,080H
  886.     LD    C,26        ; bdos set dma function
  887.     CALL    5        ; set dma address to 80h    
  888.     LD    DE,TMPFCB    ; index temporary fcb
  889.     LD    C,17        ; bdos search first function
  890.     CALL    5
  891.     INC    A        ; test for existence
  892.     JP    Z,LUX05        ; ...error - file not found
  893.     LD    HL,(TMPDRV)    ; get temporary drive/user
  894.     LD    (RQDDRV),HL    ; set new drive/user
  895.     LD    HL,TMPFCB+1    ; source address of new name
  896.     LD    DE,LBRNAM    ; current .lbr name
  897.     LD    BC,8        ; 8 character file name
  898. TMP060:    LD    A,(HL)
  899.     INC    HL
  900.     EX    DE,HL
  901.     LD    (HL),A
  902.     INC    HL
  903.     EX    DE,HL
  904.     DEC    C
  905.     JP    NZ,TMP060    ; LDIR replacement
  906. ;    LDIR            ; move it
  907.     CALL    ILPRT        ; for display neatness
  908.     DEFB    13,10,0        ;
  909.     LD    A,0FFH        ; set the auto-directory flag
  910.     LD    (DOADIR),A    ;
  911.     JP    GETCMD        ;
  912. ;
  913. LUX03:    POP    HL
  914.     POP    BC
  915. LUX04:    CALL    ILPRT
  916.     DEFB    13,10,'++ Invalid drive/user number ++',7,13,10,0
  917.     JP    GETCMD
  918. ;
  919. LUX05:    CALL    ILPRT
  920.     DEFB    13,10,10,'Can''t find ',0
  921.     CALL    DVUPR1
  922.     LD    B,8
  923.     LD    HL,TMPFCB+1
  924.     CALL    NAMPR1        ; print the file name
  925.     CALL    ILPRT
  926.     DEFB    ' - check your spelling',7,13,10,0
  927.     JP    GETCMD
  928. ;
  929. PROCES:    XOR    A        ; zero last byte of new command line
  930. ;    LD    (IX+0),A
  931.     LD    HL,(CPTRIX)
  932.     LD    (HL),A
  933.     LD    HL,CBUFF+1
  934.     LD    (HLPCNT),A    ; reset the error count
  935.     CALL    DRUSR        ; get drive/user
  936. ;    LD    (COMDRV),BC    ; set the com drive/user
  937.     PUSH    HL
  938.     LD    H,B
  939.     LD    L,C
  940.     LD    (COMDRV),HL
  941.     POP    HL
  942.     EX    DE,HL        ; de is source address to create new fcb
  943.     CALL    SCANER        ; create the new fcb
  944.     EX    DE,HL        ; into 'HL'
  945.     LD    DE,CBUFF+1    ; start of command buffer
  946.     PUSH    HL
  947.     PUSH    DE
  948.     OR    A        ; clear any cy
  949.     LD    A,H
  950.     SBC    A,D
  951.     LD    H,A
  952.     LD    A,L
  953.     SBC    A,E
  954.     LD    L,A        ; Replace SBC HL,DE
  955. ;    SBC    HL,DE        ; calculate length of move
  956.     LD    A,(CBUFF)    ; get command line length
  957.     SUB    L        ; calculate new length
  958.     LD    (CBUFF),A    ; put new length
  959.     LD    A,07EH        ; calculate length of block move
  960.     SUB    L    
  961.     LD    C,A        ; set into c
  962.     LD    B,0        ; 'b' gets zero
  963.     POP    DE        ; restore destination
  964.     POP    HL        ;    and source
  965. TMP070:    LD    A,(HL)
  966.     INC    HL
  967.     EX    DE,HL
  968.     LD    (HL),A
  969.     INC    HL
  970.     EX    DE,HL
  971.     DEC    C
  972.     JP    NZ,TMP070    ; LDIR replacement
  973. ;    LDIR            ; move the block down
  974.     LD    HL,FCB1        ; set up first fcb
  975.     LD    DE,CBUFF+1
  976.     CALL    SCANR1        
  977.     LD    HL,FCB2        ; set up second fcb
  978.     CALL    SCANR1
  979. ;
  980. ; force the default file type (.com) 
  981. ;
  982.     LD    HL,'OC'        ; 'CO'
  983.     LD    (DEFFCB+9),HL
  984.     LD    A,'M'        ; 'M'
  985.     LD    (DEFFCB+11),A
  986.     XOR    A        ; zero the record count and
  987.                 ;   the extent number
  988.     LD    (DEFFCB+15),A
  989.     LD    (DEFFCB+32),A
  990.     CALL    SETCOM        ; set com drive/user
  991. ;
  992.     LD    DE,TPA    
  993.     LD    C,01AH
  994.     CALL    BDOS        ; set dma to tpa
  995. ;
  996.     LD    DE,DEFFCB
  997.     LD    C,011H
  998.     CALL    BDOS        ; search for first
  999.     INC    A
  1000.     JP    NZ,PROCE1    ; file found
  1001. ;
  1002.     CALL    ILPRT
  1003.     DEFB    13,10,'Can''t find ',0
  1004.     LD    B,8
  1005.     LD    HL,DEFFCB+1
  1006.     CALL    NAMPR1        ; print the file name
  1007.     CALL    ILPRT        ; cr/lf
  1008.     DEFB    7,13,10,0
  1009.     JP    ENTRY        ; go for more commands
  1010. ;
  1011. PROCE1:    LD    DE,TPA    
  1012.     LD    C,01AH
  1013.     CALL    BDOS        ; set dma to tpa
  1014. ;
  1015.     LD    DE,DEFFCB
  1016.     LD    C,00FH
  1017.     CALL    BDOS        ; open file
  1018.     INC    A
  1019.     JP    NZ,PROCE2
  1020. ;
  1021.     CALL    ILPRT
  1022.     DEFB    13,10,'.COM File error - notify SYSOP',7,7,13,10,0
  1023.     JP    ENTRY
  1024. ;
  1025. ; load the .com file into memory @100h and call it 
  1026. ;
  1027. PROCE2:    LD    HL,080H
  1028.     LD    DE,080H
  1029. LODCOM:    ADD    HL,DE        ; add record size offset
  1030.     EX    DE,HL        ; get dma address into 'DE'
  1031.     PUSH    DE        ; save 'DE' and 'HL'
  1032.     PUSH    HL
  1033.     LD    C,01AH
  1034.     CALL    BDOS        ; set dma
  1035.     LD    DE,DEFFCB    ; index .com file name
  1036.     LD    C,014H
  1037.     CALL    BDOS        ; read a record
  1038.     POP    HL        ; restore 'DE' and 'HL'
  1039.     POP    DE
  1040.     EX    DE,HL        ; 'HL' is dma address again
  1041.     OR    A        ; end of file ?
  1042.     JP    Z,LODCOM    ; no - read another record
  1043. ;
  1044.     LD    C,13
  1045.     CALL    BDOS        ; reset drive system 
  1046.     CALL    SETNEW        ; set new drive/user
  1047.     XOR    A
  1048.     LD    (ACTIVE),A    ; clear command mode active
  1049.     CALL    CRLF
  1050.     CALL    TPA        ; call the loaded file @100h
  1051.     JP    ENTRY        ; go for more commands
  1052. ;
  1053. NAMPRT:    LD    B,8        ; 8 character file name
  1054.     LD    HL,LBRNAM    ; index .lbr name
  1055. NAMPR1:    LD    A,(HL)        ; get a byte
  1056.     CP    020H        ; space? 
  1057.     JP    Z,NAMPR2    ; yes - dont print
  1058.     CALL    CTYPE        ; else print the character
  1059. NAMPR2:    INC    HL        ; next character
  1060.     DEC    B
  1061.     JP    NZ,NAMPR1    ; DJNZ replacement
  1062. ;    DJNZ    NAMPR1        ; process 8 characters
  1063.     LD    A,'.'        ; print a seperator
  1064.     CALL    CTYPE
  1065.     LD    B,3        ; 3 character file type
  1066. NAMPR3:    LD    A,(HL)        ; get a character
  1067.     CALL    CTYPE        ; print it
  1068.     INC    HL        ; next character
  1069.     DEC    B
  1070.     JP    NZ,NAMPR3    ; DJNZ replacement
  1071. ;    DJNZ    NAMPR3        ; process 3 characters
  1072.     RET
  1073. ;
  1074. ; write a string of characters to the crt
  1075. ;
  1076. ILPRT:    EX    (SP),HL        ; save return address/get character pointer
  1077. ILPRT1:    LD    A,(HL)        ; get a byte
  1078.     OR    A        ; test it
  1079.     JP    Z,ILPRT2    ; null - end of string
  1080.     CALL    CTYPE        ; else type the character
  1081.     INC    HL        ; next character
  1082.     JP    ILPRT1        ; loop for more
  1083. ILPRT2:    INC    HL
  1084.     EX    (SP),HL        ; restore return address
  1085.     RET            ; return to caller
  1086. ;
  1087. ; write a string of characters to the command line
  1088. ;
  1089. ; works like ilprt above
  1090. ;
  1091. FILTYP:    EX    (SP),HL
  1092. FILTY1:    LD    A,(HL)        
  1093.     OR    A        
  1094.     JP    Z,FILTY2        
  1095.     CALL    PUTIN        
  1096.     INC    HL            
  1097.     JP    FILTY1
  1098. FILTY2:    EX    (SP),HL
  1099.     RET    
  1100. ;
  1101. ; fill command line with a space
  1102. ;
  1103. FILSPC:    LD    A,020H        ; space character
  1104.     CALL    PUTIN        ; fill in
  1105.     RET
  1106. ;
  1107. ; fill command line with .lbr name
  1108. ;
  1109. FILNAM:    LD    B,8        ; 8 character file name
  1110.     LD    HL,LBRNAM    ; index .lbr name
  1111. FILNA1:    LD    A,(HL)        ; get a character
  1112.     CP    020H        ; space ?
  1113.     JP    Z,FILNA2    ; yes - dont add to command line
  1114.     CALL    PUTIN        ; put character into command line
  1115. FILNA2:    INC    HL        ; next character
  1116.     DEC    B
  1117.     JP    NZ,FILNA1    ; DJNZ replacement
  1118. ;    DJNZ    FILNA1        ; process 8 characters
  1119.     LD    A,'.'        ; put in a seperator character
  1120.     CALL    PUTIN
  1121.     LD    B,3        ; 3 character file type
  1122. FILNA3:    LD    A,(HL)        ; get a character
  1123.     CALL    PUTIN        ; put in command line
  1124.     INC    HL        ; next character
  1125.     DEC    B
  1126.     JP    NZ,FILNA3    ; DJNZ replacement
  1127. ;    DJNZ    FILNA3        ; process 3 characters
  1128.     RET            ; return to caller
  1129. ;
  1130. ; fill command line with member name
  1131. ;
  1132. FILMEM:    CALL    PARSER        ; parse member name
  1133.     LD    HL,MEMBER    ; index member name
  1134.     LD    B,12        ; 12 character max
  1135. FILME1:    LD    A,(HL)        ; get a byte
  1136.     OR    A        ; end of input
  1137.     RET    Z        ; yes - return
  1138.     CALL    PUTIN        ; fill in one character
  1139.     INC    HL        ; next character
  1140.     DEC    B
  1141.     JP    NZ,FILME1    ; DJNZ replacement
  1142. ;    DJNZ    FILME1        ; continue looping
  1143.     RET            ; done
  1144. ;
  1145. ;PUTIN:    LD    (IX+0),A    ; stuff the character into command line
  1146. ;    INC    IX        ; get ready for next character
  1147. PUTIN:    PUSH    HL
  1148.     LD    HL,(CPTRIX)
  1149.     LD    (HL),A
  1150.     INC    HL
  1151.     LD    (CPTRIX),HL
  1152. ;    INC    (IY+0)        ; bump command line length
  1153.     LD    HL,CBUFF
  1154.     INC    (HL)
  1155.     POP    HL
  1156.     RET            ; return to caller
  1157. ;
  1158. ; parse out a member name
  1159. ;
  1160. PARSER:    LD    HL,MEMBER    ; index member name
  1161.     LD    B,12        ; max 12 character filename
  1162. PARSE1:    LD    (HL),0        ; zero character
  1163.     INC    HL        ; next character
  1164.     DEC    B
  1165.     JP    NZ,PARSE1    ; DJNZ replacement
  1166. ;    DJNZ    PARSE1        ; clear the entire member name
  1167.     CALL    ADVANC        ; advance to the next non blank character
  1168.     RET    C        ; if at the end of the line
  1169.     LD    DE,MEMBER    ; de is index to member (hl set by advanc)
  1170.     LD    HL,(NXTWRD)
  1171. PARSE2:    LD    A,(HL)        ; get source byte
  1172.     OR    A        ; end of input line ?
  1173.     RET    Z        ; yes - return
  1174.     LD    (DE),A        ; put byte
  1175.     INC    HL        ; next source
  1176.     INC    DE        ; next destination
  1177.     JP    PARSE2        ; continue looping
  1178. ;
  1179. ; advanc - advance the word at nxtwrd to the next non blank address
  1180. ; of the command line.  set carry if no more characters available
  1181. ;
  1182. ADVANC:    LD    HL,(NXTWRD)    ; get pointer to next word
  1183. ADVAN1:    LD    A,(HL)        ; get a byte
  1184.     OR    A        ; test flags
  1185.     JP    Z,ADVAN3    ; error - null character
  1186.     CP    020H        ; space ?
  1187.     JP    NZ,ADVAN2    ; yes - done
  1188.     INC    HL
  1189.     LD    (NXTWRD),HL    ; put pointer back
  1190.     JP    ADVAN1        ; loop for more 
  1191. ADVAN2:    OR    A        ; clear any carry
  1192.     RET
  1193. ADVAN3:    SCF            ; set error condition
  1194.     RET
  1195. ;
  1196. FNDSPC:    LD    HL,CMDLIN+2    ; index command line    
  1197. FND01:    LD    A,(HL)        ; get a byte from command line
  1198.     OR    A        ; eol ?
  1199.     JP    Z,FNDER        ; error...
  1200.     CP    020H        ; space?
  1201.      JP    Z,FNDEX        ; ...yes - go find requested file name
  1202.     INC    HL        ; next character
  1203.     JP    FND01        ; else continue the search
  1204. FNDER:    SCF            ; all characters scanned and no space found
  1205.     RET            ;
  1206. FNDEX:    LD    (NXTWRD),HL    ; set character location
  1207.     OR    A        ; assure carry reset
  1208.     RET            ;
  1209. ;
  1210. NXTSPC:    LD    HL,(NXTWRD)    ; get pointer to next word
  1211. NXTSP1:    LD    A,(HL)        ; get a byte
  1212.     OR    A        ; is it a null?
  1213.     JP    Z,NXTSP2    ; ...yes - return
  1214.     CP    020H        ; if at a space?
  1215.     JP    Z,NXTSP2    ; ...yes - return
  1216.     INC    HL        ; next character
  1217.     JP    NXTSP1        ; and continue looking
  1218. NXTSP2:    LD    (NXTWRD),HL
  1219.     RET
  1220. ;
  1221. ; in-line compare.  compares string addressed by 'de' to string after
  1222. ; call (ends with zero).  return with carry set means strings not the
  1223. ; same.  all registers except 'a'-reg are unaffected.
  1224. ;
  1225. ILCMP:    EX    (SP),HL
  1226.     PUSH    DE
  1227. ILCMP1:    LD    A,(HL)        ; get a byte from source
  1228.     OR    A        ; null
  1229.     JP    Z,SAME1        ; yes - same so far - test next char
  1230.     LD    A,(DE)        ; get a byte from command string
  1231.     CP    (HL)        ; same as source
  1232.     JP    NZ,NOTSAM    ; no - not the same
  1233.     INC    HL        ; next source
  1234.     INC    DE        ; next compare
  1235.     JP    ILCMP1        ; loop again
  1236. NOTSAM:    XOR    A        ; zero for the test
  1237. NSLP:    INC    HL        ; next immediate byte    
  1238.     CP    (HL)        ; null yet ?
  1239.     JP    NZ,NSLP        ; no - continue
  1240. SAME2:    SCF            ; set error condition
  1241. SAME:    EX    DE,HL        ; get command string pointer
  1242.     LD    (NXTWRD),HL    ; store it
  1243.     EX    DE,HL        ; restore return address
  1244.     POP    DE        ; restore source address
  1245.     INC    HL        ; adjust to stack
  1246.     EX    (SP),HL        ; replace return address/
  1247.     RET            ; return
  1248. SAME1:    LD    A,(DE)        ; get the next byte from command line
  1249.     OR    A        ; null ?
  1250.     JP    Z,SAME        ; yes - its ok
  1251.     CP    020H        ; space ?
  1252.     JP    Z,SAME        ; yes - thats ok too...
  1253.     JP    SAME2        ; not ok- must be another character
  1254. ;
  1255. CTYPE:    PUSH    AF        ; save all registers
  1256.     PUSH    BC
  1257.     PUSH    DE
  1258.     PUSH    HL
  1259.     AND    07FH        ; be sure its ascii
  1260.     LD    E,A        ; into 'E'
  1261.     LD    C,2        ; cpm console function
  1262.     CALL    BDOS
  1263.     POP    HL        ; restore all registers
  1264.     POP    DE
  1265.     POP    BC
  1266.     POP    AF
  1267.     RET            ; return to caller
  1268. ;
  1269. CRLF:    LD    A,13
  1270.     CALL    CTYPE
  1271.     LD    A,10
  1272.     JP    CTYPE
  1273. ;
  1274. ;
  1275. ; get the drive and user number for a file from command string
  1276. ; index by 'HL'
  1277. ;
  1278. ; on entry:
  1279. ;
  1280. ;    'HL' points to first byte of the command string
  1281. ;
  1282. ; on exit:
  1283. ;
  1284. ;    'HL' points to the byte following ':' in the command string if
  1285. ;         the ':' was found in the first 4 character positions.
  1286. ;    -or-
  1287. ;    'HL' points to the first byte of the command string if no ':'
  1288. ;         was found.
  1289. ;
  1290. ;    'C'  contains the requested drive number (0-15)
  1291. ;
  1292. ;    'B'  contains the requested user number (0-15)
  1293. ;
  1294. ;    'AF' the number of characters thru the ':' in the command string.
  1295. ;
  1296. ;    'CY' is set if drive or user number is out of range (0-15)
  1297. ;
  1298. ;------------------------------------------------------------------------------
  1299. ;
  1300. DRUSR:    LD    (TEMPHL),HL    ; save the pointer address
  1301. ;    LD    IX,(TEMPHL)    ; 'IX' get the pointer address
  1302.     LD    (CPTRIX),HL
  1303.     LD    BC,5        ; 
  1304.     LD    A,':'
  1305. TMP120:    CP    (HL)
  1306.     PUSH    AF
  1307.     INC    HL
  1308.     DEC    C
  1309.     JP    NZ,TMP122
  1310.     POP    AF
  1311.     JP    TMP125
  1312. TMP122:    POP    AF
  1313.     JP    NZ,TMP120
  1314. TMP125    EQU    $
  1315. ;    CPIR            ; search for the ':'
  1316.     LD    A,C        ; get 'B' result from 'CPIR' instruction
  1317.     LD    (LENGTH),A    ; keep for possible adjust
  1318.     EX    DE,HL        ; de points to the byte following ':'
  1319.     LD    HL,VTABLE    ; index address table
  1320.     ADD    HL,BC        ; add word offset
  1321.     ADD    HL,BC
  1322.     LD    A,(HL)        ; get routine lsb
  1323.     INC    HL
  1324.     LD    H,(HL)        ; get routine msb
  1325.     LD    L,A        
  1326.     LD    BC,0        ; set up drive/user storage
  1327.     JP    (HL)        ; execute
  1328. ;
  1329. VTABLE:    DEFW    DRUS0        ; b=0 -     filename.ext 
  1330.     DEFW    DRUS1        ; b=1 - a15:filename.ext
  1331.     DEFW    DRUS2        ; b=2 -  a1:filename.ext
  1332.     DEFW    DRUS3        ; b=3 -   a:filename.ext
  1333.     DEFW    DRUS4        ; b=4 -    :filename.ext
  1334. ;
  1335. ; format was - filename.ext
  1336. ;
  1337. DRUS0:    CALL    GETDFU        ; get the default user
  1338.     CALL    GETDFD        ; get the default drive
  1339.     LD    HL,(TEMPHL)    ; get old buffer pointer back
  1340.     XOR    A        ; zero move length
  1341.     RET            ; all done
  1342. ;
  1343. ; format was - duu:filename.ext
  1344. ;
  1345. DRUS1:    CALL    GETDRV        ; get the drive parameter
  1346. ;    LD    A,(IX+0)
  1347.     PUSH    HL
  1348.     LD    HL,(CPTRIX)
  1349.     LD    A,(HL)
  1350.     POP    HL
  1351.     CP    '0'
  1352.     JP    C,ERROR
  1353.     CP    '9'+1
  1354.     JP    NC,ERROR
  1355.     SUB    '0'
  1356.     LD    B,A        ; put in drive number
  1357. ;    SLA    B        ; * 2
  1358. ;    SLA    B        ; * 4
  1359. ;    SLA    B        ; * 8
  1360. ;    ADD    A,A        ; a * 2
  1361.     SLA    A        ; * 2
  1362.     SLA    A        ; * 4    
  1363.     ADD    A,B        ; + b (* 5)
  1364.     SLA    A        ; * 10
  1365.     LD    B,A
  1366. ;    INC    IX        ; skip the tens digit
  1367.     PUSH    HL
  1368.     LD    HL,(CPTRIX)
  1369.     INC    HL
  1370.     LD    (CPTRIX),HL
  1371.     POP    HL
  1372.     JP    GETUSR        ; get the user number
  1373. ;
  1374. ; format was - du:filename.ext
  1375. ;
  1376. DRUS2:    CALL    GETDRV        ; get the drive parameter
  1377.     JP    GETUSR        ; get the user number
  1378. ;
  1379. ; format was - d:filename.ext
  1380. ;
  1381. DRUS3:    CALL    GETDRV        ; get the drive parameter
  1382.     CALL    GETDFU        ; get the default user
  1383. ;
  1384. ; format was - :filename.ext
  1385. ;
  1386. DRUS4:    JP    DRUS5
  1387. ;
  1388. ;GETDRV:    LD    A,(IX+0)
  1389. GETDRV:    PUSH    HL
  1390.     LD    HL,(CPTRIX)
  1391.     LD    A,(HL)
  1392.     POP    HL
  1393.     CP    'A'
  1394.     JP    C,ERROR1
  1395.     CP    'Q'
  1396.     JP    NC,ERROR1
  1397.     SUB    'A'
  1398.     LD    C,A        ; put in drive number
  1399. ;    INC    IX
  1400.     PUSH    HL
  1401.     LD    HL,(CPTRIX)
  1402.     INC    HL
  1403.     LD    (CPTRIX),HL
  1404.     POP    HL
  1405.     RET
  1406. ;
  1407. ;GETUSR:    LD    A,(IX+0)
  1408. GETUSR:    PUSH    HL
  1409.     LD    HL,(CPTRIX)
  1410.     LD    A,(HL)
  1411.     POP    HL
  1412.     CP    '0'
  1413.     JP    C,ERROR
  1414.     CP    '9'+1
  1415.     JP    NC,ERROR
  1416.     SUB    '0'
  1417.     ADD    A,B
  1418.     LD    B,A
  1419. ;
  1420. ; adjust the byte in 'LENGTH'
  1421. ;
  1422. DRUS5:    EX    DE,HL        ; hl points to byte following ':' if any
  1423.     LD    A,(LENGTH)    ; get length of move
  1424.     OR    A        ; test it
  1425.     RET    Z        ; return if null/ clear carry
  1426.     LD    E,A
  1427.     LD    A,5
  1428.     SUB    E 
  1429.     LD    (LENGTH),A
  1430.     OR    A        ; clear any error
  1431.     RET
  1432. ;
  1433. ERROR1:    POP    DE        ; kill return address from subroutine
  1434. ERROR:    SCF            ; set error condition
  1435.     RET
  1436. ;
  1437. ; get default user
  1438. ;
  1439. GETDFU:    PUSH    BC
  1440.     PUSH    DE
  1441.     PUSH    HL
  1442.     LD    C,020H    
  1443.     LD    E,0FFH
  1444.     CALL    BDOS
  1445.     POP    HL
  1446.     POP    DE
  1447.     POP    BC
  1448.     LD    B,A        ; set 'B' register to current user
  1449.     RET
  1450. ;
  1451. ; get default drive
  1452. ;
  1453. GETDFD:    PUSH    BC
  1454.     PUSH    DE
  1455.     PUSH    HL
  1456.     LD    C,019H
  1457.     CALL    BDOS
  1458.     POP    HL
  1459.     POP    DE
  1460.     POP    BC
  1461.     LD    C,A        ; set 'C' register to current drive
  1462.     RET
  1463. ;
  1464. ; convert the drive/user bytes in BC to a BDS-C user/drive specification
  1465. ; and place in command line
  1466. ;
  1467. BDSDVU:    PUSH    BC        ; save drive/user spec
  1468.     PUSH    HL        ; save command line pointer
  1469.     LD    A,(DRVMAX)    ; check for max's exceeded
  1470.     CP    C        ;
  1471.     JP    C,DUERR        ;
  1472.     LD    A,(USRMAX)    ;
  1473.     CP    B        ;
  1474.     JP    C,DUERR        ;
  1475.     POP    HL        ;
  1476.     POP    BC        ;
  1477.     LD    A,B        ; get the user number
  1478.     CP    10        ; is it less than 10?
  1479.     JP    C,BDS2        ; yes, don't insert the '1'
  1480.     LD    A,'1'        ;
  1481.     CALL    PUTIN        ;
  1482.     LD    A,B        ; reget the user number
  1483.     SUB    10        ; subtract 10
  1484. BDS2:    ADD    A,'0'        ; add in ascii bias
  1485.     CALL    PUTIN        ;
  1486.     LD    A,'/'        ; now the stupid bds-c slash
  1487.     CALL    PUTIN        ;
  1488.     LD    A,C        ; get the drive number
  1489.     ADD    A,'A'        ; add ascii bias
  1490.     CALL    PUTIN        ;
  1491.     LD    A,':'        ;
  1492.     CALL    PUTIN        ;
  1493.     XOR    A        ; to indicate successfullness
  1494.     RET            ;
  1495. DUERR:    POP    HL        ; justify the stack
  1496.     POP    BC
  1497.     SCF            ; error flag
  1498.     RET            ;
  1499. ;
  1500. ; extract token from command line and place it into deffcb;
  1501. ;   format deffcb fcb if token resembles file name and type (filename.typ);
  1502. ;   on input, cibptr pts to char at which to start scan;
  1503. ;   on output, cibptr pts to char at which to continue and zero flag is reset
  1504. ;     if '?' is in token
  1505. ;
  1506. ; entry points:
  1507. ;    scaner - load token into first fcb
  1508. ;    scanr1 - load token into fcb pted to by hl
  1509. ;
  1510. ;
  1511. SCANER:    LD    HL,DEFFCB    ; point to deffcb
  1512. SCANR1:    XOR    A        ; set temporary drive number to default
  1513.     LD    (TEMPDR),A
  1514.     CALL    ADVNCE        ; skip to non-blank or end of line
  1515. ;    LD    (CIPTR),DE    ; set ptr to non-blank or end of line
  1516.     EX    DE,HL
  1517.     LD    (CIPTR),HL
  1518.     EX    DE,HL
  1519.     LD    A,(DE)
  1520.     OR    A
  1521.     JP    Z,SCANR2
  1522.     SBC    A,'A'-1
  1523.     LD    B,A
  1524.     INC    DE
  1525.     LD    A,(DE)
  1526.     CP    ':'
  1527.     JP    Z,SCANR3
  1528.     DEC    DE
  1529. SCANR2:    LD    A,(TDRIVE)    ; set 1st byte of deffcb as default drive
  1530.     LD    (HL),A
  1531.     JP    SCANR4
  1532. SCANR3:    LD    A,B
  1533.     LD    (TEMPDR),A
  1534.     LD    (HL),B
  1535.     INC    DE
  1536. SCANR4:    XOR    A        ; a=0
  1537.     LD    (QMCNT),A    ; init count of number of question marks in fcb
  1538.     LD    B,8        ; max of 8 chars in file name
  1539.     CALL    SCANF        ; fill fcb file name
  1540. ;
  1541. ; extract file type from possible filename.typ
  1542. ;
  1543.     LD    B,3        ; prepare to extract type
  1544.     CP    '.'        ; if (de) delimiter is a '.', we have a type
  1545.     JP    NZ,SCANR5    ; fill file type bytes with <sp>
  1546.     INC    DE        ; pt to char in command line after '.'
  1547.     CALL    SCANF        ; fill fcb file type
  1548.     JP    SCANR6        ; skip to next processing
  1549. SCANR5:    CALL    SCANF4        ; space fill
  1550. ;
  1551. ; fill in ex, s1, s2, and rc with zeroes
  1552. ;
  1553. SCANR6:    LD    B,4        ; 4 bytes
  1554. SCANR7:    INC    HL        ; pt to next byte in deffcb
  1555.     LD    (HL),0
  1556.     DEC    B
  1557.     JP    NZ,SCANR7    ; DJNZ replacement
  1558. ;    DJNZ    SCANR7
  1559. ;
  1560. ; scan complete -- de pts to delimiter byte after token
  1561. ;
  1562. ;    LD    (CIBPTR),DE
  1563.     EX    DE,HL
  1564.     LD    (CIBPTR),HL
  1565.     EX    DE,HL
  1566. ;
  1567. ; set zero flag to indicate presence of '?' in filename.typ
  1568. ;
  1569.     LD    A,(QMCNT)    ; get number of question marks
  1570.     OR    A        ; set zero flag to indicate any '?'
  1571.     RET    
  1572. ;
  1573. ;  scanf -- scan token pted to by de for a max of b bytes; place it into
  1574. ;    file name field pted to by hl; expand and interpret wild cards of
  1575. ;    '*' and '?'; on exit, de pts to terminating delimiter
  1576. ;
  1577. SCANF:    CALL    SDELM        ; done if delimiter encountered - <sp> fill
  1578.     JP    Z,SCANF4
  1579.     INC    HL        ; pt to next byte in deffcb
  1580.     CP    '*'        ; is (de) a wild card?
  1581.     JP    NZ,SCANF1    ; continue if not
  1582.     LD    (HL),'?'    ; place '?' in deffcb and dont advance de if so
  1583.     CALL    SCQ        ; scanner count question marks
  1584.     JP    SCANF2
  1585. SCANF1:    LD    (HL),A        ; store filename char in deffcb
  1586.     INC    DE        ; pt to next char in command line
  1587.     CP    '?'        ; check for question mark (wild)
  1588.     CALL    Z,SCQ        ; scanner count question marks
  1589. SCANF2:    DEC    B
  1590.     JP    NZ,SCANF    ; DJNZ replacement
  1591. ;    DJNZ    SCANF        ; decrement char count until 8 elapsed
  1592. SCANF3:    CALL    SDELM        ; 8 chars or more - skip until delimiter
  1593.     RET    Z        ; zero flag set if delimiter found
  1594.     INC    DE        ; pt to next char in command line
  1595.     JP    SCANF3
  1596. ;
  1597. ;  fill memory pointed to by hl with spaces for b bytes
  1598. ;
  1599. SCANF4:    INC    HL        ; pt to next byte in deffcb
  1600.     LD    (HL),' '    ; fill filename part with <sp>
  1601.     DEC    B
  1602.     JP    NZ,SCANF4    ; DJNZ replacement
  1603. ;    DJNZ    SCANF4
  1604.     RET    
  1605. ;
  1606. ;  increment question mark count for scanner
  1607. ;    this routine increments the count of the number of question marks in
  1608. ;    the current fcb entry
  1609. ;
  1610. SCQ:    LD    A,(QMCNT)    ; get count
  1611.     INC    A        ; increment
  1612.     LD    (QMCNT),A    ; put count
  1613.     RET    
  1614. ;
  1615. ; check to see if de pts to delimiter; if so, ret w/zero flag set
  1616. ;
  1617. SDELM:    LD    A,(DE)
  1618.     OR    A        ; 0=delimiter
  1619.     RET    Z
  1620.     CP    ' '        ; error if < <sp>
  1621.     RET    Z        ; <sp>=delimiter
  1622.     CP    '='        ; '='=delimiter
  1623.     RET    Z
  1624.     CP    5FH        ; underscore=delimiter
  1625.     RET    Z
  1626.     CP    '.'        ; '.'=delimiter
  1627.     RET    Z
  1628.     CP    ':'        ; ':'=delimiter
  1629.     RET    Z
  1630.     CP    ';'        ; ';'=delimiter
  1631.     RET    Z
  1632.     CP    '<'        ; '<'=delimiter
  1633.     RET    Z
  1634.     CP    '>'        ; '>'=delimiter
  1635.     RET    
  1636. ;
  1637. ; advance input ptr to first non-blank and fall through to sblank
  1638. ;
  1639. ;ADVNCE:    LD    (CIBPTR),DE
  1640. ADVNCE:    EX    DE,HL
  1641.     LD    (CIBPTR),HL
  1642.     EX    DE,HL
  1643. ;
  1644. ; skip string pted to by de (string ends in 0) until end of string
  1645. ;   or non-blank encountered (beginning of token)
  1646. ;
  1647. SBLANK:    LD    A,(DE)
  1648.     OR    A
  1649.     RET    Z
  1650.     CP    ' '
  1651.     RET    NZ
  1652.     INC    DE
  1653.     JP    SBLANK
  1654. ;
  1655. ;
  1656. ; capitalize string (ending in 0) in cmdlin and set ptr for parsing
  1657. ;
  1658. CNVBUF:    LD    HL,CMDLIN+1    ; pt to users command
  1659.     LD    B,(HL)        ; char count in b
  1660.     INC    B        ; add 1 in case of zero
  1661. CNVBF1:    INC    HL        ; pt to 1st valid char
  1662.     LD    A,(HL)        ; capitalize command char
  1663.     CALL    UCASE
  1664.     LD    (HL),A
  1665.     DEC    B
  1666.     JP    NZ,CNVBF1    ; DJNZ replacement
  1667. ;    DJNZ    CNVBF1        ; continue to end of command line
  1668. CNVBF2:    LD    (HL),0        ; store ending <null>
  1669.     LD    HL,CMDLIN+2    ; set command line ptr to 1st char
  1670.     LD    (CIBPTR),HL
  1671.     RET    
  1672. ;
  1673. ; convert char in a to upper case
  1674. ;
  1675. UCASE:    CP    61H        ; lower-case a
  1676.     RET    C
  1677.     CP    7BH        ; greater than lower-case z?
  1678.     RET    NC
  1679.     AND    5FH        ; capitalize
  1680.     RET    
  1681. ;
  1682. GETOLD:    CALL    GETDFU        ; get current user into 'B'
  1683.     CALL    GETDFD        ; get current driv into 'C'
  1684. ;    LD    (OLDDRV),BC    ; get the parameters
  1685.     PUSH    HL
  1686.     LD    H,B
  1687.     LD    L,C
  1688.     LD    (OLDDRV),HL
  1689.     POP    HL
  1690.     RET
  1691. ;
  1692. ;SETTMP:    LD    BC,(TMPDRV)
  1693. SETTMP:    PUSH    HL
  1694.     LD    HL,(TMPDRV)
  1695.     LD    B,H
  1696.     LD    C,L
  1697.     POP    HL
  1698.     JP    RESET
  1699. ;
  1700. ;SETOLD:    LD    BC,(OLDDRV)
  1701. SETOLD:    PUSH    HL
  1702.     LD    HL,(OLDDRV)
  1703.     LD    B,H
  1704.     LD    C,L
  1705.     POP    HL
  1706.     JP    RESET
  1707. ;
  1708. ;SETNEW:    LD    BC,(RQDDRV)    ; get the old drive number
  1709. SETNEW:    PUSH    HL
  1710.     LD    HL,(RQDDRV)
  1711.     LD    B,H
  1712.     LD    C,L
  1713.     POP    HL
  1714.     JP    RESET
  1715. ;
  1716. ;SETCOM:    LD    BC,(COMDRV)    ; get the old drive number
  1717. SETCOM:    PUSH    HL
  1718.     LD    HL,(COMDRV)
  1719.     LD    B,H
  1720.     LD    C,L
  1721.     POP    HL
  1722. ;
  1723. RESET:    PUSH    BC        ; save drive/user
  1724.     PUSH    BC
  1725.     LD    E,C        ; get selected drive
  1726.     LD    C,14        ; bdos function
  1727.     CALL    BDOS    
  1728.     POP    BC        ; restore drive/user
  1729.     LD    E,B        ; get selected user
  1730.     LD    C,32        ; bdis set user function
  1731.     CALL    BDOS        
  1732. ;
  1733. ; set up byte at 4h - some programs may look at it
  1734. ;
  1735.     POP    BC
  1736.     LD    A,B        ; get user number
  1737.     RLA    
  1738.     RLA
  1739.     RLA
  1740.     RLA
  1741.     AND    0F0H
  1742.     OR    C
  1743.     LD    (4),A
  1744.     RET
  1745. ;
  1746. DVUPR1:    LD    A,(TMPUSR)
  1747.     PUSH    AF
  1748.     LD    A,(TMPDRV)
  1749.     JP    DVUPR3
  1750. ;
  1751. DVUPRT:    LD    A,(RQDUSR)    ; get requested drive
  1752.     PUSH    AF
  1753.     LD    A,(RQDDRV)    ; get the requested user
  1754. DVUPR3:    ADD    A,'A'
  1755.     CALL    CTYPE        ; print the drive 'A'-'P'
  1756.     POP    AF
  1757.     CP    10        ; less that 10?
  1758.     JP    C,DVUPR2    ; yes - dont print the '1' 
  1759.     PUSH    AF
  1760.     LD    A,'1'
  1761.     CALL    CTYPE
  1762.     POP    AF
  1763.     SUB    10
  1764. DVUPR2:    ADD    A,'0'
  1765.     CALL    CTYPE
  1766.     LD    A,':'
  1767.     JP    CTYPE
  1768. ;
  1769. NULL:    RET
  1770. ;
  1771.     IF    RCPM
  1772. ;
  1773. SUBFCB:    DEFB    0        ; use current drive
  1774.     DEFB    '$$$     SUB'    ; 
  1775.     DEFB    0,0,0,0,0,0,0,0    ; rest of the fcb
  1776.     DEFB    0,0,0,0,0,0,0,0    ;
  1777.     DEFB    0,0,0,0,0    ;
  1778. ;
  1779.     DEFB    0,0,0,0        ; rfu
  1780. ;
  1781. ;    Edit this to contain the console commands necessary to
  1782. ;    execute the logoff sequence for your system.
  1783. ;
  1784. BYECMD:    DEFB    0    ;<====== do not touch
  1785. ;
  1786.     'BYE',13,10    ;<====== put any number of cmds here
  1787. ;
  1788.     DEFB    'Z'-40H    ;<====== do not touch
  1789. ;
  1790. BYELEN    EQU    $-BYECMD-1
  1791. ;
  1792.     ENDIF            ;RCPM    
  1793. ;
  1794. DOADIR:    DEFB    0
  1795. HLPCNT:    DEFB    0
  1796. BIOS3:    DEFW    0
  1797. DRVMAX:    DEFB    0
  1798. USRMAX:    DEFB    0
  1799. TEMPDR:    DEFB    0
  1800. CIPTR:    DEFW    0
  1801. TDRIVE:    DEFB    0
  1802. QMCNT:    DEFB    0
  1803. CIBPTR:    DEFW    0
  1804. TEMPHL:    DEFW    0
  1805. LENGTH:    DEFB    0
  1806. OLDDRV:    DEFB    0
  1807. OLDUSR:    DEFB    0
  1808. RQDDRV:    DEFB    0        ; requested drive
  1809. RQDUSR:    DEFB    0        ; requested user
  1810. COMDRV:    DEFB    0        ; drive to load com file
  1811. COMUSR:    DEFB    0        ; user to load com file
  1812. TMPDRV:    DEFB    0        ; temporary drive number
  1813. TMPUSR:    DEFB    0        ; temporary user number
  1814. ACTIVE:    DEFB    0        ; attach command mode active
  1815. NXTWRD:    DEFW    0
  1816.     DEFW    0
  1817. CMDLIN:    DEFB    79
  1818. CMDLEN:    DEFB    0
  1819.     DEFS    79
  1820.     DEFB    0
  1821. ;
  1822. MEMBER:    DEFB    '            '
  1823.     DEFB    0
  1824.     DEFB    0
  1825. LBRNAM:    DEFB    '        '    ; library file name
  1826.     DEFB    'LBR'
  1827. ;
  1828. CPTRIX:    DEFS    2        ;<IX> points to Command line
  1829. ;
  1830. TMPFCB:    DEFS    36
  1831. DEFFCB:    DEFS    36
  1832.     DEFS    80
  1833. STACK    EQU    $
  1834. ;
  1835. ;
  1836.     END
  1837.