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 / CPM / UTILS / DIRUTL / D-29.ASM < prev    next >
Assembly Source File  |  2000-06-30  |  26KB  |  1,182 lines

  1. ;
  2. ;            D.ASM ver 2.9
  3. ;        RESTRICTED DIRECTORY LIST PROGRAM
  4. ;            (revised 08/12/82)
  5. ;
  6. ;D.COM is a directory list program, which writes
  7. ;4 or 5 entries on a line, separated by colons.
  8. ;  (THIS IS THE 'WHATSNEW' PROGRAM SEEN ON MANY RCPM SYSTEMS)
  9. ;
  10. ;The command contains an internal table of file names,
  11. ;which are not to be shown when just "D" is typed.
  12. ;(NOTE typing "D *.*" always shows all files)
  13. ;
  14. ;Why is this useful:  A typical CP/M disk contains many
  15. ;utility files: ed.com, asm.com, submit.com, etc.  When
  16. ;you do a directory listing, you typically aren't interested
  17. ;in seeing all those files, but rather just the "current"
  18. ;or "active" files.  This is what "D.COM" can do.
  19. ;
  20. ;NOTE: Direct CBIOS calls are used for input and output
  21. ;      in order to avoid echoing of inputted characters.
  22. ;      This keeps a noisy phone line from causing garbage
  23. ;      characters in the display.
  24. ;
  25. ;Revisions/updates: (in reverse order to minimize reading time)
  26. ;
  27. ;08/12/82 Added SUB file option to allow writing each new filename
  28. ;      that appears in the "New Files" display to a .SUB file
  29. ;      of the form:
  30. ;      XSUB
  31. ;      PIP
  32. ;      $1=$2 Fn.Ft$3
  33. ;      $1=$2 Fn.Ft$3
  34. ;      etc.
  35. ;      to allow a simple archive of new files to be performed
  36. ;      by: SUBMIT D A:=B: [G1]
  37. ;      Also repaired bug in EXIT routine and removed character
  38. ;      'gobbler' routine so that program will work better with
  39. ;      'type-ahead' BIOSes                 by Dave Hardy
  40. ;
  41. ;07/01/82 Modified TITLE feature to allow TITLE command to be
  42. ;      easily changed.  Previous version had hard-coded TITLE
  43. ;      command length and TITLE start.  Also removed TITSTART
  44. ;      symbol (no longer needed) and cleaned up some of the
  45. ;      comments (Dave Hardy)
  46. ;
  47. ;06/23/82 Added Title feature for disk.. allows you to set
  48. ;         the title for the disk.(See Below)
  49. ;                         Bob Bowerman.
  50. ;
  51. ;06/19/81 Added BIAS for modified or standard CP/M. Ted Shapin.
  52. ;
  53. ;06/13/81 Fixed names counter in files not found routine.
  54. ;      (KBP).
  55. ;
  56. ;06/12/81 Changed routines for printing so that CTL-C abort
  57. ;      will work properly.  Added ILPRT and TYPMEM routines
  58. ;      to reduce program size.  (KBP)
  59. ;
  60. ;05/20/81 Increased system file security by increasing pasword
  61. ;      option to 3 characters.  (By Howard Booker, W8IU)
  62. ;
  63. ;03/01/81 Added reset of DMA to 80H default on exit so D will
  64. ;      work properly with submit.  Deleted CEXIT routine,
  65. ;      which was no longer used.  Expanded documentation.
  66. ;      (KBP)
  67. ;
  68. ;02/28/81 Mod. of 2/21 changed by popular demand to use of direct
  69. ;         BIOS calls for freezing and aborting output. (CS)
  70. ;
  71. ;02/21/81 Abort on receipt of control-C character only (to prevent
  72. ;      premature exit on remote systems with noisy telephone
  73. ;      connections). Charlie Strom
  74. ;
  75. ;12/23/80 Changed sign-on message, revised documentation. (KBP)
  76. ;
  77. ;12/22/80 Fixed stack and file extent problems.  Fully expanded
  78. ;      macros so ASM may be used.  Fixed problem in LOK routine
  79. ;      By Keith Petersen, W8SDZ.
  80. ;
  81. ;12/07/80 Added drive select byte and expanded move macro in WRBACK
  82. ;      routine.  Also added "LOK" command.  By Ron Fowler.
  83. ;
  84. ;12/02/80 Added "NOSYS" equate to ignore system files, code to strip
  85. ;      attributes from files for CP/M 2.x, added date display and
  86. ;      print options.  Fixed up display format.  By Ron Fowler
  87. ;
  88. ;12/01/80 Added "FILES NOT FOUND" feature of updated
  89. ;      D.ASM of Ward Christensen.  By Ron Fowler.
  90. ;
  91. ;11/23/78 Originally written by Ward Christensen.
  92. ;
  93. ;===================================================
  94. ;
  95. ;Use:    D *.*    prints all names, 5 across.
  96. ;
  97. ;    D *.ASM prints selected files just like DIR.
  98. ;
  99. ;    D SET    builds a table (in D.COM) of all
  100. ;        names currently on the disk. (see *NOTE).
  101. ;
  102. ;    D SET <DATE>  adds the date for printing whenever
  103. ;        D is called by 'A>D<CR>' with no options.
  104. ;        If the date field is left blank, it will
  105. ;        be ignored. Note that the date must be 8
  106. ;        characters or less (see *NOTE).
  107. ;
  108. ;    D TIT <TITLE FOR DISK> sets an internal disk title
  109. ;        which prints out each time the program is
  110. ;        run (if a title has been set).(maximum of
  111. ;               circa 70 chars please although it will
  112. ;               handle a full CP/M input line.
  113. ;
  114. ;        NOTE: To get rid of title (and accompanying
  115. ;        print put type 'D TIT' and the title is
  116. ;               set to null.
  117. ;
  118. ;    D ADD FN.FT  adds a name to the table in
  119. ;        D.COM, so FN.FT won't be listed
  120. ;        by the 'D' command (see *NOTE).
  121. ;
  122. ;    D DEL FN.FT  deletes a name from the table
  123. ;        in D.COM, so if FN.FT is in the
  124. ;        directory, it will be listed by 'D'
  125. ;        (see *NOTE).
  126. ;
  127. ;    D SUB    causes a file named 'D.SUB' to be generated on
  128. ;        the currently logged-in drive.  The file contains
  129. ;        all of the 'New Files' names, and is of the form:
  130. ;
  131. ;        XSUB
  132. ;        PIP
  133. ;        $1<fn1.ft>$2
  134. ;        $1<fn2.ft>$2
  135. ;        $1<fn3.ft>$2
  136. ;        etc.
  137. ;
  138. ;        D.SUB can be used to archive 'New Files' with a
  139. ;        simple command line like:
  140. ;        SUBMIT D B:=A: [G5]
  141. ;        which would PIP all of the new files from B5: to A:
  142. ;
  143. ;    D    lists the directory, showing
  144. ;        only those files NOT in D.COM, as
  145. ;        put there by 'D SET' or 'D ADD FN.FT'
  146. ;
  147. ;*NOTE: the program must write itself back to disk,
  148. ;modified, so your disk must not be write protected.
  149. ;
  150. ;------------------------------------------------
  151. ;
  152. ;Examples:  Suppose your disk has: 
  153. ;    D.COM
  154. ;    ASM.COM
  155. ;    ED.COM        on it initially.
  156. ;    LOAD.COM
  157. ;    DDT.COM
  158. ;
  159. ;You would type:  D SET
  160. ;to set these names into the D.COM program.
  161. ;
  162. ;Typing "D" would then list:
  163. ;
  164. ;    -->New files
  165. ;    A: ++NONE++
  166. ;
  167. ;    -->Deleted files
  168. ;    A: ++NONE++
  169. ;
  170. ;Suppose you ED TEST.ASM, ASM it, and LOAD it.
  171. ;Typing D would then list:
  172. ;
  173. ;    -->New files
  174. ;    A: TEST    ASM : TEST    BAK : TEST    HEX : TEST    COM
  175. ;
  176. ;    -->Deleted files
  177. ;    A: ++NONE++
  178. ;
  179. ;i.e. it tells you of the "current" files on the disk.
  180. ;
  181. ;Now, supposing you wanted to add TEST.COM as a "regular"
  182. ;file on your disk.  Type:
  183. ;
  184. ;    D ADD TEST.COM
  185. ;
  186. ;Now, typing D will show:
  187. ;
  188. ;    -->New files
  189. ;    A: TEST    ASM : TEST    BAK : TEST    HEX
  190. ;
  191. ;    -->Deleted files
  192. ;    A: ++NONE++
  193. ;
  194. ;i.e. TEST.COM is now considered a "permanent" file.
  195. ;
  196. ;-----
  197. ;
  198. ;Now, suppose you accidentally erased ASM.COM from your
  199. ;disk.  Typing D gives:
  200. ;
  201. ;    -->New files
  202. ;    A: TEST    ASM : TEST    BAK : TEST    HEX
  203. ;
  204. ;    -->Deleted files
  205. ;    A: ASM     COM
  206. ;
  207. ;showing you are missing one of the "regular" files.
  208. ;
  209. ;If, in fact, you didn't want ASM.COM to be on the disk,
  210. ;type:
  211. ;
  212. ;    D DEL ASM.COM
  213. ;
  214. ;which will delete the name from the D.COM table, so ASM.COM
  215. ;won't show up as "deleted".
  216. ;
  217. ;===================================================
  218. ;
  219. ;    SPECIAL NOTES FOR REMOTE SYSTEM USE:
  220. ;
  221. ;If you keep a dedicated copy of this program on each drive of
  222. ;your remote system, you can 'dedicate' each copy of this program
  223. ;to a drive by filling in the byte at 103H with the drive number.
  224. ;This prevents such things as:
  225. ;
  226. ;    A>D B:
  227. ;        or
  228. ;    B>A:D
  229. ;
  230. ;Do this by using the command:
  231. ;
  232. ;    A>D LOK A:    to lock to a drive
  233. ;        or
  234. ;    A>D LOK     to unlock
  235. ;
  236. ;If the conditional 'NOSYS' is set TRUE, $SYS files in CP/M 2.x
  237. ;will be ignored in both directory listings and when the "ADD"
  238. ;option is invoked, unless the override char is specified.  This
  239. ;allows D.COM to be used as a "WHAT'S NEW" program for remote CP/M
  240. ;systems, where the $SYS files must not be listed.
  241. ;
  242. ;Examples:
  243. ;    A>D *.* S     displays everything
  244. ;    A>D SET S     puts ALL files in table
  245. ;    A>D SET 12/23/80 sets date for reference
  246. ;        (if you use 'D SET S', you lose the date option..
  247. ;        ..sorry about that).
  248. ;
  249. ;If you use this program on a remote system, you will likely
  250. ;want to change the commands (ADD, DEL, and SET) for security.
  251. ;You will also want to change the $SYS suppress override character.
  252. ;You may also want to change the name of the program to make the
  253. ;name itself more informative, e.g. "D.COM".
  254. ;
  255. ;-->IMPORTANT: If you want the program to be 'TAG'ed after every
  256. ;D SET (so it cannot be taken by XMODEM), see the note at label
  257. ;"WRBACK" for setting the F1 bit in the filename itself.
  258. ;
  259. ;Note that this program defines its own name for write-back
  260. ;purposes under the label "WRBACK".
  261. ;
  262. ;===================================================
  263. ;
  264. ;NOTE: If you add improvements or otherwise update
  265. ;this program, please modem a copy of the new file
  266. ;to "TECHNICAL CBBS" in Dearborn, Michigan - phone
  267. ;313-846-6127 (110, 300, 450 or 600 baud). Use the
  268. ;filename D-XX.NEW.  (KBP)
  269. ;
  270. ;===================================================
  271. ;
  272. ;  Define some stuff
  273. FALSE    EQU    0
  274. TRUE    EQU    NOT FALSE
  275. BIAS    EQU    0        ;For STD CP/M or 4200H for ALTCPM
  276. BDOS    EQU    5 + BIAS    ;CP/M's BDOS access jump
  277. FCB    EQU    5CH + BIAS    ;CP/M's file control block
  278. FCBRNO    EQU    FCB + 32    ;Rec # in FCB
  279. CPMBUFF    EQU    80H + BIAS    ;CP/M command line buffer
  280. CR    EQU    13        ;Carriage Return
  281. LF    EQU    10        ;Line Feed
  282. ;
  283. ;  Set the following for your system:
  284. NOSYS    EQU    TRUE    ;TRUE means ignore $SYS files
  285. FENCE    EQU    ':'    ;Character printed between filenames in display
  286. NPL    EQU    4    ;Number of names to be displayed on each line
  287. ;
  288. ; The leader string for the SUB file (XSUB, PIP) is located at label SUBF4
  289. ;
  290.     ORG    100H+BIAS
  291. ;
  292. DENTRY:    JMP    AROUND
  293. ;
  294. DRIVE:    DB    0    ;<---DRV # IS PUT HERE IF DEDICATED
  295. ;            (this can be done with the LOK command)
  296. ;Init local stack
  297. AROUND:    LXI    H,0    ;HL=0
  298.     DAD    SP    ;HL=STACK
  299.     SHLD    STACK    ;SAVE STACK POINTER
  300.     LXI    SP,STACK ;INIT LOCAL STACK
  301. ;
  302. ;Initialize direct CBIOS calls
  303.     LHLD    1+BIAS
  304.     LXI    D,3
  305.     DAD    D    ;HL=CONSTAT
  306.     SHLD    TYPES+1
  307.     DAD    D    ;HL=CONIN
  308.     SHLD    CIC+1
  309.     DAD    D    ;HL=CONOUT
  310.     SHLD    TYPEC+1
  311. ;
  312. ;Print ID message
  313.     CALL    ILPRT    ;PRINT:
  314.     DB    'D ver 2.9',CR,LF
  315.     DB    'CTL-S pauses, CTL-C aborts',CR,LF,0
  316. ;
  317. ;Print Disk Title
  318. ;
  319. PTITL    LXI    H,DTITLE    ;get title address
  320.     MOV    A,M    ;load it
  321.     CPI    0    ;end of string
  322.     JZ    CONT    ;don't print title
  323.     CALL    ILPRT    ;print heading
  324.     DB    'Title: ',0
  325.     LXI    H,DTITLE    ;load it again
  326. LOOP1:    MOV    A,M    ;...
  327.     CPI    0    ;zero?
  328.     JZ    ENDPRT    ;all done
  329.     CALL    TYPE    ;type this char
  330.     INX    H    ;next char
  331.     JMP    LOOP1    ;repeat ...
  332.  
  333. DTITLE:    DB    0    ;storage for
  334.     DS    7FH    ;title
  335. ENDPRT:    CALL    CRLF
  336. ;
  337. ;Set file control block
  338. CONT:    LDA    DRIVE
  339.     ORA    A    ;Non-dedicated?
  340.     JZ    NOND    ;Jump if so
  341.     STA    FCB
  342. ;
  343. NOND:    LHLD    FCB+17    ;Get $SYS override characters
  344.     SHLD    SYSTOO    ;and save for later
  345.     LDA    FCB+19
  346.     STA    SYSTOO+2
  347. ;
  348. ;See if request to add name to list
  349.     LXI    H,FCB+1
  350.     CALL    ADDCM2
  351. ADDCM:    DB    'ADD        '    ;11 characters (padded with spaces)
  352. ;
  353. ADDCM2:    POP    D    ;Make DE point to ADD command
  354.     LXI    B,ADDCM2-ADDCM    ;BC gets length of string
  355.     CALL    COMPR
  356.     JNZ    NOADD
  357. ;
  358. ;Got request to add name to table
  359.     CALL    DELNAM    ;FIRST, DELETE THE NAME
  360.     CALL    FINDFF    ;FIND END OF TABLE
  361.     XCHG        ;ADDR TO DE
  362. ;
  363. ;Move name to table
  364.     LXI    H,FCB+17
  365.     LXI    B,11
  366.     CALL    MOVER
  367.     MVI    A,0FFH
  368.     STAX    D    ;SET NEW END
  369.     JMP    WRBACK    ;WRITE PROGRAM BACK
  370. ;
  371. ;See if request to add title to disk
  372. ;
  373. NOADD:    LXI    H,FCB+1
  374.     CALL    NOADD1A
  375. NOADD1B:
  376.     DB    'TIT'        ;MUST be your command to set title
  377. TITLEN    DB    '        '    ;# spaces here + length of your command = 11
  378. NOADD1A:
  379.     POP    D    ;GET TO
  380.     LXI    B,NOADD1A-NOADD1B
  381.     CALL    COMPR
  382.     JNZ    NOADD2A
  383. ;
  384. ;Process the title or erase it, if none given
  385. ;
  386.     LXI    H,CPMBUFF    ;get length
  387.     MOV    A,M        ;move it to A
  388.     SUI    TITLEN-NOADD1B+1    ;but don't include the title command
  389.     JZ    TITNO        ;no title?
  390.     LXI    H,CPMBUFF+TITLEN-NOADD1B+2    ;Get START OF DTITLE
  391.     LXI    B,0000
  392.     MOV    C,A        ;Put length in BC
  393.     LXI    D,DTITLE        ;Place to store
  394.     CALL    MOVER        ;Move title in storage
  395.     MVI    A,00        ;And Mark End
  396.     STAX    D        ;Of string
  397.     JMP    WRBACK        ;And write back to disk
  398. ;        
  399. ;No title - Clear title
  400. ;
  401. TITNO:    LXI    H,DTITLE        ;load in space
  402.     MVI    M,00        ;store end of string
  403.     JMP    WRBACK        ;and write back to disk
  404. ;
  405. ;See if request to lock D.COM to a drive
  406. ;
  407. NOADD2A:
  408.     LXI    H,FCB+1
  409.     CALL    NOADD3
  410. NOADD2:    DB    'LOK        '
  411. ;
  412. NOADD3:    POP    D    ;GET TO
  413.     LXI    B,NOADD3-NOADD2
  414.     CALL    COMPR
  415.     JNZ    NOLOK
  416. ;
  417. ;Got request to lock
  418.     LDA    FCB+16
  419.     STA    DRIVE
  420.     STA    FCB
  421.     JMP    WRBACK
  422. ;
  423. ;See if request to DEL name from list
  424. ;
  425. NOLOK:    LXI    H,FCB+1
  426.     CALL    NOLOK3
  427. NOLOK2:    DB    'DEL        '
  428. ;
  429. NOLOK3:    POP    D    ;GET TO
  430.     LXI    B,NOLOK3-NOLOK2
  431.     CALL    COMPR
  432.     JNZ    NODEL
  433. ;
  434. ;Got request to delete a name from the file
  435.     CALL    DELNAM ;DELETE THE NAME
  436.     JNC    WRBACK    ;WRITE BACK IF OK
  437.     CALL    MSGXIT
  438.     DB    '++NAME NOT IN TABLE++$'
  439. ;
  440. ;See if request is to make SUB file
  441. ;
  442. NODEL:    LXI    H,FCB+1
  443.     CALL    SUBF3
  444. SUBF2:    DB    'SUB        '
  445. SUBF3:    POP    D
  446.     LXI    B,SUBF3-SUBF2
  447.     CALL    COMPR
  448.     JNZ    NOSUB
  449. ;
  450. ;Got request to make SUB file, so say so, and set flag to force it
  451.     CALL    SAYSUB        ;Notify console that SUB file will be made
  452.     DB    'Writing SUBMIT file...',CR,LF,'$'
  453. SAYSUB:    POP    D
  454.     MVI    C,9
  455.     CALL    BDOS
  456.     MVI    A,0FFH        ;Set SUBFLG to tell program to make SUB file
  457.     STA    SUBFLG
  458.     LXI    H,SUBBUF    ;Write SUB file start into file buffer
  459.     CALL    SUBF5        ;(XSUB, PIP, etc.)
  460. SUBF4:    DB    'XSUB',CR,LF,'PIP',CR,LF
  461. SUBF5:    POP    D        ;Use MOVER routine to copy it into SUB buffer
  462.     XCHG
  463.     LXI    B,SUBF5-SUBF4
  464.     CALL    MOVER
  465.     XCHG
  466.     SHLD    SUBPTR        ;Save SUB file buffer pointer
  467.     LXI    H,FCB+1        ;Then fill tail in with spaces to make
  468.     MVI    C,11        ;  program think that no options chosen
  469. NXSPC:    MVI    M,' '
  470.     DCR    C
  471.     INX    H
  472.     JNZ    NXSPC
  473.     MVI    C,36H        ;Initialize local FCB
  474.     LXI    H,LFCB        ;(Can't use default, because commands there)
  475. NXFCB:    MVI    M,0
  476.     DCR    C
  477.     INX    H
  478.     JNZ    NXFCB
  479.     LXI    D,LFCB+1    ;Set up local FCB to write D.SUB file
  480.     CALL    UWR2
  481. UWR1:    DB    'D       SUB',0
  482. UWR2:    POP    H
  483.     LXI    B,UWR2-UWR1
  484.     CALL    MOVER
  485.     MVI    C,ERASE        ;Erase old file, if it exists
  486.     LXI    D,LFCB
  487.     CALL    BDOS
  488.     XRA    A
  489.     STA    LFCB        ;Set up to write to DEFAULT drive
  490.     STA    FCBRNO        ;Initialize record number
  491.     MVI    C,MAKE        ;Create the file
  492.     LXI    D,LFCB
  493.     CALL    BDOS
  494.     JMP    NOSET        ;Then jump off to display names as usual
  495. ;
  496. ;See if request to set up table from directory
  497. ;
  498. NOSUB:    LXI    H,FCB+1
  499.     CALL    NODEL3
  500. NODEL2:    DB    'SET        '
  501. ;
  502. NODEL3:    POP    D    ;GET TO
  503.     LXI    B,NODEL3-NODEL2
  504.     CALL    COMPR
  505.     JNZ    NOSET
  506. ;
  507. ;Got request to setup table.
  508. ;Move the date (may be blank).
  509.     LXI    H,FCB+17
  510.     LXI    D,DATE
  511.     LXI    B,8
  512.     CALL    MOVER
  513.     MVI    A,1    ;TURN ON..
  514.     STA    SETFLG    ;..SET FLAG
  515.     MVI    A,0FFH    ;CLEAR..
  516.     STA    NAMES    ;..NAMES TABLE
  517.     CALL    FILLQ    ;MAKE FCB '????????.???'
  518. ;
  519. ;
  520. NOSET:    LDA    FCB+1    ;Get PRTFLG
  521.     SUI    ' '
  522.     STA    PRTFLG
  523.     PUSH    PSW
  524.     CZ    HEAD1
  525.     POP    PSW
  526.     JNZ    GOTNAM
  527.     CALL    FILLQ    ;MAKE NAME ????????.???
  528. ;
  529. GOTNAM:    LDA    FCB
  530.     ORA    A
  531.     JZ    NODISK
  532.     DCR    A
  533.     MOV    E,A
  534.     MVI    C,SELDSK
  535.     CALL    BDOS
  536. ;
  537. NODISK:    MVI    B,NPL    ;NAMES PER LINE
  538.     CALL    LINMRK
  539.     MVI    C,SRCHF
  540.     JMP    CALLIT
  541. ;
  542. LINE:    MVI    B,NPL    ;NAMES PER LINE
  543.     CALL    LINMRK
  544. ;
  545. NEXT:    MVI    C,SRCHN
  546. ;
  547. CALLIT:    PUSH    B
  548.     LXI    D,FCB
  549.     CALL    BDOS
  550.     INR    A
  551.     JZ    CKNONE
  552.     DCR    A
  553.     ANI    3
  554.     MOV    L,A
  555.     MVI    H,0
  556.     DAD    H
  557.     DAD    H
  558.     DAD    H
  559.     DAD    H
  560.     DAD    H
  561.     LXI    D,81H+BIAS
  562.     DAD    D
  563. ;
  564. ;Check for $SYS attribute, then clear all attributes
  565.     PUSH    H
  566.     LXI    D,9    ;SYS ATT OFFSET
  567.     DAD    D
  568.     MOV    A,M
  569.     ANI    80H
  570.     STA    SYSFLG
  571.     POP    H    ;RETRIEVE FILENAME PTR
  572.     PUSH    H
  573.     MVI    E,11    ;11 CHARS IN FILENAME
  574. ;
  575. ATTLP:    MOV    A,M    ;PICK UP CHAR
  576.     ANI    7FH    ;KILL ATTRIBUTE
  577.     MOV    M,A    ;PUT BACK DOWN
  578.     INX    H
  579.     DCR    E
  580.     JNZ    ATTLP
  581.     POP    H
  582. ;
  583. ;See if name is to be printed
  584.     XCHG        ;NAME POINTER TO DE
  585.     LDA    SETFLG    ;REQUEST TO SETUP TABLE?
  586.     ORA    A
  587.     JNZ    SETUP    ;GO SET ENTRY INTO TABLE
  588.     LDA    PRTFLG
  589.     ORA    A
  590.     JNZ    GOPRNT    ;EXPLICIT REQUEST FOR ALL
  591.     PUSH    D
  592.     LXI    H,NAMES
  593. ;
  594. CKNEXT:    POP    D    ;GET NAME POINTER
  595.     POP    B
  596.     PUSH    B
  597.     MOV    A,M    ;END OF TABLE?
  598.     INR    A    ;WAS IT 0FFH?
  599.     JZ    GOPRNT
  600.     MVI    B,0
  601.     MVI    C,11    ;NAME LENGTH
  602.     PUSH    D
  603. ;
  604. CKLP:    LDAX    D
  605.     CMP    M
  606.     JNZ    NOMACH
  607.     INX    D
  608.     INX    H
  609.     DCR    C
  610.     JNZ    CKLP    ;LOOP FOR 11 CHARS
  611. ;
  612. ;Got match, mark it found and don't print it
  613.     LXI    D,-11    ;POINT BACK TO NAME
  614.     DAD    D
  615.     MVI    M,0    ;MARK IT FOUND
  616.     POP    D    ;POP POINTER
  617.     POP    B
  618.     JMP    NEXT    ;SKIP THE NAME
  619. ;
  620. ;Name didn't match, try next
  621. ;
  622. NOMACH:    DAD    B    ;POINT TO NEXT NAME
  623.     JMP    CKNEXT
  624. ;
  625. ;Print the name
  626. ;
  627. GOPRNT:
  628.     IF    NOSYS
  629.     CALL    SYSCK
  630.     JZ    DONAME
  631.     LDA    SYSFLG
  632.     RAL
  633.     POP    B
  634.     JC    NEXT
  635.     PUSH    B
  636.     ENDIF        ;NOSYS
  637. ;
  638. ;
  639. DONAME:    LDA    SUBFLG    ;See if SUB file is to be made
  640.     ORA    A
  641.     CNZ    NAMSUB    ;If so, then write the name into the SUB buffer
  642.     MVI    A,1    ;SAY WE GOT ONE
  643.     STA    GOTFLG
  644.     MVI    C,8
  645.     XCHG        ;NAME BACK TO HL
  646.     CALL    TYPMEM
  647.     MVI    A,'.'
  648.     CALL    TYPE
  649.     MVI    C,3
  650.     CALL    TYPMEM
  651.     POP    B
  652.     CALL    SPACE
  653.     MVI    A,FENCE
  654.     DCR    B
  655.     PUSH    PSW
  656.     CNZ    TYPE
  657.     CALL    SPACE
  658.     POP    PSW
  659.     JNZ    NEXT
  660.     CALL    CRLF
  661.     JMP    LINE
  662. ;
  663. ;Write the filename pointed to by DE into the SUB file buffer
  664. ;  in the format: $1<fn.ft>$2<cr><lf>
  665. NAMSUB:    PUSH    H    ;Save HL (whatever's in it)
  666.     PUSH    D    ;Save filename pointer
  667.     PUSH    B    ;Save BC (whatever's in it)
  668.     LHLD    SUBPTR    ;Point HL to SUB buffer (DE points to filename)
  669.     MVI    C,8    ;Load counter for 8 characters of filename
  670.     MVI    M,'$'    ;First write '$1'
  671.     CALL    INCPTR    ;Increment file buffer pointer and write if full
  672.     MVI    M,'1'
  673.     CALL    INCPTR
  674. SNAM:    LDAX    D    ;Get a character of the name
  675.     CPI    ' '    ;Don't transfer spaces to SUB buffer
  676.     JZ    SNAM2
  677.     ANI    7FH    ;Trim off any nasty attributes
  678.     MOV    M,A    ;Put the character into the SUB buffer
  679.     CALL    INCPTR    ;Point to next SUB location
  680. SNAM2:    INX    D    ;Point to next character of filename
  681.     DCR    C    ;Decrement filename counter
  682.     JNZ    SNAM    ;Continue until all 8 characters read
  683.     MVI    M,'.'    ;Put a '.' into the SUB buffer to separate fn & ft
  684.     CALL    INCPTR    ;Point to next location in SUB buffer
  685.     MVI    C,3    ;Now do the 3 character long filetype
  686. SNAM3:    LDAX    D
  687.     CPI    ' '
  688.     JZ    SNAM4
  689.     ANI    7FH
  690.     MOV    M,A
  691.     CALL    INCPTR
  692. SNAM4:    INX    D
  693.     DCR    C
  694.     JNZ    SNAM3
  695.     MVI    M,'$'    ;Then write '$2<cr><lf>' on the end of the name
  696.     CALL    INCPTR
  697.     MVI    M,'2'
  698.     CALL    INCPTR
  699.     MVI    M,CR
  700.     CALL    INCPTR
  701.     MVI    M,LF
  702.     CALL    INCPTR
  703.     SHLD    SUBPTR    ;Save the new SUB buffer pointer
  704.     POP    B    ;Restore all the registers
  705.     POP    D
  706.     POP    H
  707.     RET        ;Then return back to DONAME
  708. ;
  709. ;Increment the HL file buffer pointer, and write the buffer if full
  710. ;
  711. INCPTR:    INX    H        ;See if buffer is full
  712.     MVI    A,(SUBBUF+80H) AND 0FFH
  713.     CMP    L    ;(See if LSH of HL = LSH of SUBBUF+80H)
  714.     RNZ            ;Return if buffer not full, else flush to disk
  715. WRTSBF:    LXI    H,SUBBUF    ;Reset pointer to start of buffer
  716. WRTSB2:    PUSH    H
  717.     PUSH    D
  718.     PUSH    B
  719.     LXI    D,SUBBUF    ;Set DMA address to SUB buffer
  720.     MVI    C,SETDMA
  721.     CALL    BDOS
  722.     LXI    D,LFCB        ;Write the buffer to disk
  723.     MVI    C,WRITE
  724.     CALL    BDOS
  725.     LXI    D,CPMBUFF    ;Now set DMA address back to default
  726.     MVI    C,SETDMA    ; so that other routines can read directory
  727.     CALL    BDOS
  728.     POP    B
  729.     POP    D
  730.     POP    H
  731.     ORA    A        ;Notify console and abort if write error
  732.     JNZ    WRERR
  733.     RET
  734. ;
  735. CKNONE:    LDA    GOTFLG        ;Some new files found?
  736.     ORA    A
  737.     JNZ    NOTFND        ;Jump if yes
  738.     LDA    PRTFLG        ;Print names?
  739.     ORA    A
  740.     JNZ    NOTFND        ;Jump if yes
  741.     CALL    ILPRT        ;Else say no new files found and fall through
  742.     DB    '++NONE++',CR,LF,0
  743. ;
  744. ;Print the files not found
  745. ;
  746. NOTFND: LDA    SETFLG    ;IS THIS 'D SET'?
  747.     ORA    A
  748.     JNZ    FINI    ;DONE IF SO
  749.     LDA    PRTFLG    ;ARE WE PRINTING?
  750.     ORA    A
  751.     JNZ    CKNON2    ;DONE IF NOT
  752. ;
  753. ;If this D.COM is dedicated ("DRIVE" is non-zero),
  754. ;then be sure to print the "FILES NOT FOUND"
  755.     LDA    DRIVE
  756.     ORA    A
  757.     JNZ    NOCHK
  758.     LDA    FCB    ;DRIVE SPECIFIED?
  759.     ORA    A
  760.     JNZ    FINI    ;SKIP NOT FOUND IF SO
  761. ;
  762. NOCHK:    CALL    HEAD2    ;PRINT NOT FND HEADER
  763.     LXI    H,NAMES ;START OF TABLE
  764.     LXI    D,11
  765. ;
  766. LINE2:    MVI    B,NPL
  767.     CALL    LINMRK
  768. ;
  769. NEXT2:    MOV    A,M    ;FIRST CHAR OF NAME
  770.     ORA    A    ;MARKED FOUND?
  771.     JZ    NOPRNT    ;JUMP IF SO
  772.     INR    A    ;CHECK FOR TABLE END
  773.     JZ    CKNON2    ;JUMP IF END
  774.     MVI    A,1
  775.     STA    GOTNF
  776.     MVI    C,8
  777.     CALL    TYPMEM
  778.     MVI    A,'.'
  779.     CALL    TYPE
  780.     MVI    C,3
  781.     CALL    TYPMEM
  782.     CALL    SPACE
  783.     MVI    A,FENCE
  784.     DCR    B
  785.     PUSH    PSW
  786.     CNZ    TYPE
  787.     CALL    SPACE
  788.     POP    PSW
  789.     JNZ    NEXT2
  790.     CALL    CRLF
  791.     JMP    LINE2
  792. ;
  793. NOPRNT:    DAD    D
  794.     JMP    NEXT2
  795. ;
  796. ;Print header
  797. ;
  798. HEAD1:    CALL    ILPRT    ;PRINT:
  799.     DB    CR,LF,'-->New files',0
  800.     JMP    HEAD3
  801. ;
  802. HEAD2:    CALL    ILPRT    ;PRINT:
  803.     DB    CR,LF,CR,LF,'-->Deleted files',0
  804. ;
  805. HEAD3:    LDA    DATE
  806.     CPI    ' '
  807.     JZ    NODATE
  808.     CALL    SYSCK
  809.     JZ    NODATE
  810.     CALL    ILPRT    ;PRINT:
  811.     DB    ' since '
  812. DATE:    DB    '        '    ;EIGHT SPACES
  813.     DB    0        ;STRING TERMINATOR
  814. ;
  815. NODATE: MVI    A,':'
  816.     CALL    TYPE
  817.     JMP    CRLF
  818. ;
  819. CKNON2: LDA    GOTNF
  820.     ORA    A
  821.     JNZ    FINI    ;JMP IF GOT NO 'NOT FOUND'S
  822.     LDA    PRTFLG
  823.     ORA    A
  824.     JNZ    FINI
  825.     CALL    ILPRT    ;PRINT: (THEN FALL INTO 'FINI')
  826.     DB    '++NONE++',CR,LF,0
  827. ;
  828. ;Finished.  If building table, write back.
  829. ;           If making a SUB file, then flush the file buffer and close it.
  830. FINI:    LDA    SUBFLG    ;See if SUB file is to be written
  831.     ORA    A
  832.     JNZ    WRTSUB    ;Jump if so,
  833.     LDA    SETFLG    ;Else see if SET was performed
  834.     ORA    A
  835.     JZ    EXIT    ;Jump out if not,
  836.     JMP    WRBACK    ;Else write the program back to disk
  837. ;
  838. ;Write the SUB file to the currently logged in disk as 'D.SUB'
  839. WRTSUB:    LHLD    SUBPTR    ;Fill unused part of last sector with EOF's
  840.     XCHG
  841.     LXI    H,SUBBUF+7FH
  842. WNXTS:    MVI    M,1AH
  843.     MOV    A,L
  844.     DCX    H
  845.     CMP    E
  846.     JNZ    WNXTS
  847.     CALL    WRTSB2    ;Write the last sector to disk
  848.     MVI    C,CLOSE    ;Close the file
  849.     LXI    D,LFCB
  850.     CALL    BDOS
  851.     INR    A    ;If close error, then notify console and abort
  852.     JZ    BADWCL
  853.     JMP    EXIT    ;Exit back to CP/M
  854. ;
  855. BADWCL:    CALL    MSGXIT
  856.     DB    'BAD CLOSE, SUB file incomplete$'
  857. ;
  858. ;Set up the name in the table
  859. ;
  860. SETUP:
  861.     IF    NOSYS
  862.     CALL    SYSCK
  863.     JZ    SETU2
  864.     LDA    SYSFLG
  865.     RAL
  866.     JC    SETSKP
  867.     ENDIF        ;NOSYS
  868. ;
  869. SETU2:    CALL    FINDFF    ;FIND END OF TABLE
  870.     XCHG        ;SETUP FOR MOVE
  871. ;(HL = name, DE = end of table)
  872.     LXI    B,11
  873.     CALL    MOVER
  874.     MVI    A,0FFH    ;GET TABLE END FLAG
  875.     STAX    D    ;STORE IT
  876. ;
  877. SETSKP: POP    B    ;DELETE STACK GARBAGE
  878.     JMP    NEXT    ;GET NEXT ENTRY
  879. ;
  880. ;Routine to type 'C' characters from memory (HL)
  881. ;
  882. TYPMEM:    MOV    A,M
  883.     CALL    TYPE
  884.     INX    H
  885.     DCR    C
  886.     JNZ    TYPMEM
  887.     RET
  888. ;
  889. ;Inline print routine - prints string pointed to
  890. ;by stack until a zero is found.  Returns to caller
  891. ;at next address after the zero terminator.
  892. ;
  893. ILPRT:    XTHL        ;SAVE HL, GET MSG ADRS
  894. ;
  895. ILPLP:    MOV    A,M    ;GET CHAR
  896.     CALL    TYPE    ;OUTPUT IT
  897.     INX    H    ;POINT TO NEXT
  898.     MOV    A,M    ;TEST
  899.     ORA    A    ;..FOR END
  900.     JNZ    ILPLP
  901.     XTHL        ;RESTORE HL, RET ADDR
  902.     RET        ;RET PAST MSG
  903. ;
  904. CRLF:    CALL    ILPRT    ;PRINT:
  905.     DB    CR,LF,0
  906.     RET
  907. ;
  908. SPACE:    MVI    A,' '    ;FALL INTO 'TYPE'
  909.  
  910. ;Print character in A to console
  911. ;
  912. TYPE:    PUSH    B
  913.     PUSH    D
  914.     PUSH    H
  915.     MOV    C,A    ;CHAR TO C FOR CBIOS
  916. TYPEC:    CALL    $-$    ;SUPPLIED AT START
  917. ;
  918. ;See if console key pressed
  919. ;
  920. TYPES:    CALL    $-$    ;SUPPLIED AT START
  921.     ORA    A    ;KEY PRESSED?
  922.     CNZ    CKKB    ;YES, SEE WHICH ONE
  923.     POP    H
  924.     POP    D
  925.     POP    B
  926.     RET
  927. ;
  928. CKKB:    CALL    CI    ;GET CHAR
  929.     CPI    'S'-40H    ;PAUSE?
  930.     CZ    CI    ;YES, GET NEXT CHAR
  931.     CPI    'C'-40H    ;ABORT?
  932.     RNZ        ;NO, RETURN
  933.     CALL    MSGXIT
  934.     DB    CR,LF,'++ABORTED++$'
  935. ;
  936. ;Move (BC) bytes from (HL) to (DE)
  937. ;
  938. MOVER:    MOV    A,M
  939.     STAX    D
  940.     INX    D
  941.     INX    H
  942.     DCX    B
  943.     MOV    A,B
  944.     ORA    C
  945.     JNZ    MOVER
  946.     RET
  947. ;
  948. ;Compare routine
  949. ;
  950. COMPR:    LDAX    D
  951.     CMP    M
  952.     RNZ
  953.     INX    D
  954.     INX    H
  955.     DCX    B
  956.     MOV    A,B
  957.     ORA    C
  958.     JNZ    COMPR
  959.     RET        ;EQUAL MEANS Z=1
  960. ;
  961. ;Routine to find 0FFH at end of table
  962. ;
  963. FINDFF:    LXI    H,NAMES
  964. ;
  965. FINDLP:    MOV    A,M
  966.     INX    H
  967.     INR    A    ;0FFH?
  968.     JNZ    FINDLP
  969.     DCX    H    ;BACK UP TO TABLE END
  970.     RET
  971. ;
  972. ;Delete the name from the table
  973. ;
  974. DELNAM:    LXI    H,NAMES
  975. ;
  976. DELLP:    MOV    A,M
  977.     CPI    0FFH
  978.     STC
  979.     RZ        ;NOT FOUND
  980.     LXI    D,FCB+17
  981.     LXI    B,11
  982.     CALL    COMPR
  983.     JZ    DELETE
  984.     DAD    B    ;CALC NEXT
  985.     JMP    DELLP
  986. ;
  987. ;Delete the name
  988. ;
  989. DELETE:    XCHG        ;NEXT NAME TO DE
  990.     LXI    H,-11    ;TO BACK UP..
  991.     DAD    D    ;..TO NAME TO DEL
  992. ;
  993. DELCH:    LDAX    D
  994.     MOV    M,A
  995.     INX    H
  996.     INX    D
  997.     INR    A    ;MOVED THE 0FFH?
  998.     JNZ    DELCH
  999.     ORA    A    ;SHOW FOUND
  1000.     RET
  1001. ;
  1002. ;Fill FCB with all '?'
  1003. ;
  1004. FILLQ:    LXI    H,FCB+1
  1005.     MVI    B,8+3
  1006.     MVI    A,'?'
  1007. ;
  1008. QMLOOP:    MOV    M,A
  1009.     INX    H
  1010.     DCR    B
  1011.     JNZ    QMLOOP
  1012.     RET
  1013. ;
  1014. ;Write back the program - note that you may set any of the
  1015. ;CP/M 2.x attribute bits in the file name (be sure to define
  1016. ;all 11 characters of the name).
  1017. ;
  1018. WRBACK: LXI    D,FCB+1
  1019.     CALL    WRBK2
  1020. WRBK1:    DB    'D'+80H        ;<--PUT 'D'+80H HERE TO SET TAG
  1021.     DB    '       COM'    ;SEE COMMENT ABOVE
  1022.     DB    0        ;EXTENT NUMBER
  1023. ;
  1024. WRBK2:    POP    H
  1025.     LXI    B,WRBK2-WRBK1
  1026.     CALL    MOVER
  1027.     MVI    C,ERASE
  1028.     LXI    D,FCB
  1029.     CALL    BDOS
  1030.     XRA    A    ;GET 0
  1031.     STA    SETFLG    ;CLEAR THE FLAGS..
  1032.     STA    GOTFLG
  1033.     STA    GOTNF
  1034.     STA    SYSTOO
  1035.     STA    FCBRNO    ;ZERO RECORD NUMBER
  1036.     MVI    C,MAKE
  1037.     LXI    D,FCB
  1038.     CALL    BDOS
  1039. ;
  1040. ;Before writing back, find end of table
  1041.     CALL    FINDFF
  1042.     MOV    B,H    ;B=END PAGE
  1043.     INR    B    ;FOR COMPARE
  1044.     LXI    D,100H+BIAS    ;STARTING ADDR
  1045. ;
  1046. WRLP:    PUSH    B
  1047.     PUSH    D
  1048.     PUSH    H
  1049.     MVI    C,SETDMA
  1050.     CALL    BDOS
  1051.     MVI    C,WRITE
  1052.     LXI    D,FCB
  1053.     CALL    BDOS
  1054.     POP    H
  1055.     POP    D
  1056.     POP    B
  1057.     ORA    A    ;SUCCESSFUL WRITE?
  1058.     JNZ    WRERR    ;..NO
  1059.     LXI    H,80H    ;POINT TO..
  1060.     DAD    D    ;..NEXT BLOCK
  1061.     XCHG        ;ADDR TO DE
  1062.     MOV    A,D    ;GET PAGE
  1063.     CMP    B    ;PAST TABLE END?
  1064.     JC    WRLP    ;LOOP UNTIL DONE
  1065.     MVI    C,CLOSE
  1066.     LXI    D,FCB
  1067.     CALL    BDOS
  1068.     INR    A    ;SUCCESSFUL CLOSE?
  1069.     JZ    BADCLS    ;..NO, PRINT ERR MSG
  1070.     CALL    MSGXIT ;OK, EXIT W/MSG
  1071.     DB    '++DONE++$'
  1072. ;
  1073. WRERR:    CALL    MSGXIT
  1074.     DB    '++WRITE ERROR++$'
  1075. ;
  1076. BADCLS:    CALL    MSGXIT
  1077.     DB    '++BAD CLOSE, D.COM CLOBBERED!!++$'
  1078. ;
  1079. ;Get console input via direct CBIOS call
  1080. ;
  1081. CI    PUSH    B    ;CONSOLE INPUT
  1082.     PUSH    D
  1083.     PUSH    H
  1084. CIC    CALL    $-$    ;SUPPLIED AT START
  1085.     POP    H
  1086.     POP    D
  1087.     POP    B
  1088.     RET
  1089. ;
  1090. ;Exit with message (error or informational)
  1091. ;
  1092. MSGXIT:    POP    D    ;GET MSG
  1093.     MVI    C,PRINT
  1094.     CALL    BDOS
  1095. ;
  1096. ;Exit, restoring DMA and stack, then return to CCP
  1097. ;
  1098. EXIT:    LXI    D,CPMBUFF    ;RESET DMA ADR TO NORMAL
  1099.     MVI    C,SETDMA
  1100.     CALL    BDOS
  1101.     LHLD    STACK    ;GET OLD STACK
  1102.     SPHL        ;RESTORE IT
  1103.     RET        ;Return to CCP
  1104. ;
  1105. LINMRK: PUSH    B
  1106.     PUSH    D
  1107.     PUSH    H
  1108.     LDA    FCB    ;GET DRIVE NAME FROM FCB
  1109.     ORA    A    ;ANY THERE?
  1110.     JNZ    GOTDRV    ;YES, GO PRINT IT
  1111.     MVI    C,CURDSK ;ELSE GET CURRENT DISK
  1112.     CALL    BDOS
  1113.     INR    A    ;MAKE 'A'=1
  1114. ;
  1115. GOTDRV:    ADI    40H    ;MAKE ASCII
  1116.     CALL    TYPE    ;PRINT DRIVE NAME
  1117.     CALL    ILPRT    ;PRINT
  1118.     DB    ': ',0
  1119.     POP    H
  1120.     POP    D
  1121.     POP    B
  1122.     RET
  1123. ;
  1124. ;Test for system file override
  1125. ;
  1126. SYSCK:    PUSH    H
  1127.     PUSH    D
  1128.     PUSH    B
  1129.     LXI    H,SYSTOO
  1130.     LXI    D,SYSOK
  1131.     MVI    B,3
  1132. ;
  1133. RSYSCK:    LDAX    D
  1134.     CMP    M
  1135.     INX    H
  1136.     INX    D
  1137.     JNZ    SYSOUT
  1138.     DCR    B
  1139.     JNZ    RSYSCK
  1140. ;
  1141. SYSOUT:    POP    B
  1142.     POP    D
  1143.     POP    H
  1144.     RET
  1145. ;
  1146.     DS    64    ;ROOM FOR STACK
  1147. STACK:    DS    2    ;OLD STACK STORED HERE
  1148. SUBFLG    DB    00H    ;Flag to order SUB file built
  1149. SUBPTR    DW    0000H    ;Pointer to end of SUB file
  1150. GOTFLG:    DB    0
  1151. GOTNF:    DB    0
  1152. SYSTOO:    DB    0,0,0
  1153. SYSOK:    DB    'S  '    ;SYS SUPPRESSION OVERRIDE CHARS
  1154. SETFLG:    DB    0    ;1 => SETUP TABLE
  1155. PRTFLG:    DB    0    ;PRINT ONLY SOME
  1156. SYSFLG:    DB    0    ;$SYS ATTRIB INDICATOR
  1157. LFCB    DS    36H    ;Local FCB used by SUB file write routines
  1158. SUBBUF    DS    128    ;Buffer used by SUB file write routines
  1159. NAMES    EQU    $    ;Names NOT to print are stored here (i.e. current DIR)
  1160. ;
  1161. ;Note the names are initially built by the "D SET" command
  1162. ;
  1163.     DB    0FFH    ;END OF TABLE
  1164. ;
  1165. ;  Miscellaneous BDOS equates
  1166. RDCON    EQU    1
  1167. DIO    EQU    6
  1168. PRINT    EQU    9
  1169. CONST    EQU    11
  1170. SELDSK    EQU    14
  1171. CLOSE    EQU    16
  1172. SRCHF    EQU    17
  1173. SRCHN    EQU    18
  1174. ERASE    EQU    19
  1175. READ    EQU    20
  1176. WRITE    EQU    21
  1177. MAKE    EQU    22
  1178. CURDSK    EQU    25
  1179. SETDMA    EQU    26
  1180. ;
  1181.     END
  1182.