home *** CD-ROM | disk | FTP | other *** search
/ The Don Maslin Archive / maslin_archive.zip / AARDVARK_Tape_Backups / maslin_c_d_3oct95 / ddrive / hold / msutils.lbr / unsys.s < prev    next >
Text File  |  1992-05-18  |  8KB  |  273 lines

  1. *#######################################################################
  2. *             PROGRAM UNSYS...UnSYS/Unprotect File Utility
  3. *
  4. *            Dr. David C. Wilcox
  5. *            DCW Industries, Inc.
  6. *         5354 Palm Dr., La Canada, CA  91011
  7. *               818/790-3844
  8. *
  9. *             January 25, 1986
  10. *#######################################################################
  11. boot    equ    00        *Warm Boot
  12. inchar    equ    01        *Console Input
  13. outchar    equ    02        *Console Output
  14. print    equ    09        *Print String
  15. sfirst    equ    17        *Search for First
  16. snext    equ    18        *Search for Next
  17. current    equ    25        *Return Current Disk
  18. setdma    equ    26        *Set DMA Address
  19. protect    equ    30        *Set File Attributes
  20. null    equ    00        *Ascii NUL
  21. ctrlc    equ    03        *Ascii ETX
  22. tab    equ    09        *Horizontal Tab
  23. lf    equ    10        *Line Feed
  24. cr    equ    13        *Carriage Return
  25. space    equ    32        *Space
  26. upmask    equ    $5f        *Upper Case Mask
  27. bdos    equ    $0002        *BDOS Entry Point
  28. *#######################################################################
  29. *  Special registers:
  30. *
  31. *    a6 = address of first parsed FCB
  32. *    d3 = drive designation
  33. *    d4 = number of file matches counter
  34. *#######################################################################
  35. *
  36. *  Locate FCB (for portability)
  37. *
  38.     link    a6,#0        *Mark stack frame
  39.     move.l    8(a6),a0    *Get base page address
  40.     lea    $5c(a0),a6    *Get address of FCB and save it in a6
  41. *
  42. *  Clear data registers and determine drive specification
  43. *
  44.     jsr    clear
  45.     jsr    getdrv
  46. *
  47. *  Check for no file specified
  48. *
  49.     cmpi.b    #space,1(a6)    *Is 1st char in filespec a space?
  50.     bne    begin
  51.     jsr    sysall        *If so, call sysall
  52. *
  53. *  Begin search for file name matches
  54. *
  55. begin:
  56.     move.l    #mydma,d1    *===================
  57.     move.w    #setdma,d0    *Set the DMA Address
  58.     trap    #bdos        *===================
  59.     move.l    a6,d1        *Load the FCB
  60.     move.w    #sfirst,d0    *and search for the first match
  61.     trap    #bdos
  62.     cmpi.b    #$ff,d0        *Is there no match?
  63.     beq    quit        *No match if it's zero so quit
  64. *
  65. *  Search for file name matches
  66. *
  67. search:
  68.     mulu    #32,d0        *Adjust for DMA offset of matching entry
  69.     move.l    #mydma,a3    *Point to mydma
  70.     adda.w    d0,a3        *and add the offset
  71.     movea.l    #bufadr,a4    *Point to buffer
  72.     move.l    (a4),a5
  73.     move.w    #32,d1        *Initialize the counter
  74. copy35:
  75.     move.b    (a3)+,(a5)+    *Copy contents of a3 to a5
  76.     subq    #1,d1        *Decrement the counter
  77.     bne    copy35        *and keep looping until it's zero
  78.     move.l    a5,bufadr    *Save buffer address
  79.     addq    #1,d4        *Increment file match counter
  80.     move.l    a6,d1        *=========================
  81.     move.w    #snext,d0    *Search for next occurance
  82.     trap    #bdos        *=========================
  83.     cmpi.b    #$ff,d0        *Is there no match?
  84.     bne    search        *Keep searching until all are found
  85.     movea.l    #buffer,a5    *Point to the original buffer
  86.     move.l    a5,bufadr    *Save buffer address
  87. *
  88. *  Protect Files
  89. *
  90. profile:
  91.     jsr    drivepr        *Display drive identifier
  92.     move.w    #8,d2        *Initialize file name character counter
  93.     movea.l    a5,a4        *Save a5
  94.     adda.l    #1,a5        *Skip drive designation
  95.     jsr    readmem        *Read and display file name
  96.     move.b    #'.',d1        *Send a "." to the console
  97.     jsr    conout
  98.     move.w    #3,d2        *Initialize filetype character counter
  99.     jsr    readmem        *Read and display filetype
  100.     move.b    #space,d1    *Send a space to the console
  101.     jsr    conout
  102.     move.b    #space,d1    *and then send another
  103.     jsr    conout
  104.     movea.l    a4,a5        *Retrieve a5
  105.     adda.l    #9,a5        *and...
  106.     bclr    #7,(a5)        *clear the R/O bit
  107.     adda.l    #1,a5        *and...
  108.     bclr    #7,(a5)        *clear the SYS bit
  109.     move.b    (a6),(a4)    *make sure we get the correct drive
  110.           move.w    a4,d1        *Load the FCB
  111.     move.w    #protect,d0    *Unprotect the file
  112.     trap    #bdos
  113.     move.l    #msgpro,d1    *Display the "is now..." message
  114.     jsr    pstring
  115. *
  116. *  Prepare for next file
  117. *
  118. nexfile:
  119.     subq    #1,d4        *Decrement file match counter
  120.     beq    quit        *If last file...quit
  121.     movea.l    #bufadr,a4    *Point to buffer
  122.     move.l    (a4),a5
  123.     adda.l    #32,a5        *Add 32 bytes to point to next match
  124.     move.l    a5,bufadr    *Save buffer address
  125.     jmp    profile        *Loop back for the next file
  126. *#######################################################################
  127. *                           Subroutines
  128. *#######################################################################
  129. *
  130. *  Clear data registers
  131. *
  132. clear:
  133.     clr.l    d1
  134.     clr.l    d2
  135.     clr.l    d3
  136.     clr.l    d4
  137.     rts
  138. *
  139. *  Send a character to the console
  140. *
  141. conout:
  142.     move.w    #outchar,d0
  143.     trap    #bdos
  144.     rts
  145. *
  146. *  Send a carriage return and a line feed to the console
  147. *
  148. crlf:
  149.     move.b    #cr,d1
  150.     jsr    conout
  151.     move.b    #lf,d1
  152.     jsr    conout
  153.     rts
  154. *
  155. *  Display drive identifier
  156. *
  157. drivepr:
  158.     move.b    d3,d1
  159.     jsr    conout
  160.     move.b    #':',d1
  161.     jsr    conout
  162.     rts
  163. *
  164. *  Determine drive number and make it ascii
  165. *
  166. getdrv:
  167.     move.b    (a6),d1        *Get drive number from FCB
  168.     cmpi.b    #0,d1        *Is it the default drive?
  169.     bne    ascii
  170.     jsr    logged        *If so, get physical drive number
  171. ascii:    addi.b    #64,d1        *Make it ascii
  172.     move.b    d1,d3        *and save it in d3
  173.     rts
  174. *
  175. *  Determine which is the logged drive
  176. *
  177. logged:
  178.     move.w    #current,d0    *Get current drive number
  179.     trap    #bdos
  180.     addq.b    #1,d0        *Increment for consistency with getdrv
  181.     move.w    d0,d1        *and save it in d1 for getdrv
  182.     rts
  183. *
  184. *  Send a String to the Console
  185. *
  186. pstring:
  187.     move.w    #print,d0
  188.     trap    #bdos
  189.     rts
  190. *
  191. *  Quit to CP/M
  192. *
  193. quit:
  194.     cmpi.b    #ctrlc,d0    *Is it a ^C?
  195.     beq    abort        *If so...display abort message
  196.     cmpi.b    #$ff,d0        *Is it a FF hex?
  197.     beq    nomatch        *If so...display "no match..." message
  198.     move.b    #boot,d0    *Otherwise...exit to CP/M
  199.     trap    #bdos
  200. abort:
  201.     move.l    #msgabt,d1    *Display "Program aborted" message
  202.     jsr    pstring
  203.     move.b    #boot,d0    *and exit to CP/M
  204.     trap    #bdos
  205. nomatch:
  206.     move.l    #msgnom,d1    *Display "No match..." message
  207.     jsr    pstring
  208.     move.b    #boot,d0    *and exit to CP/M
  209.     trap    #bdos
  210. *
  211. *  Read a string from memory and display it on the console
  212. *
  213. readmem:
  214.     move.b    (a5)+,d1    *Fetch character from memory
  215.     jsr    conout        *and send it to the console
  216.     subq    #1,d2
  217.     bne    readmem        *and keep looping until counter is zero
  218.     rts
  219. *
  220. *  Display default delete-file message on the console
  221. *
  222. sysall:
  223.     move.l    #msgal1,d1    *Display '*.*..." query
  224.     jsr    pstring
  225.     jsr    drivepr
  226.     move.l    #msgal2,d1
  227.     jsr    pstring
  228.     move.w    #inchar,d0    *Fetch keyboard response
  229.     trap    #bdos
  230.     move.b    d0,d2        *Save it
  231.     jsr    crlf        *Send a cr/lf to console
  232.     move.b    d2,d0        *Retrieve the response
  233.     andi.b    #upmask,d0    *Make it upper case
  234.     cmpi.b    #'Y',d0        *Test for "Y"
  235.     bne.b    abort        *If not...abort
  236.     movea.l    a6,a5        *Point to first character in file name
  237.     addq    #1,a5
  238.     move.w    #11,d2        *Initialize the counter
  239. loop1:
  240.     move.b    #'?',(a5)+    *Make compare file "????????.???"
  241.     subq    #1,d2
  242.     bne.b    loop1
  243.     move.w    #24,d2        *Reinitialize counter
  244. loop2:
  245.     move.b    #null,(a5)+    *Fill the rest of FCB with NULS
  246.     subq    #1,d2
  247.     bne.b    loop2
  248.     rts
  249. *#######################################################################
  250. *                 Console Messages
  251. *#######################################################################
  252. msgpro     dc.b    tab,'is now Directory (DIR), Read Write (RW)',cr,lf,'$'
  253. msgabt     dc.b    'Program aborted',cr,lf,'$'
  254. msgnom     dc.b    'No matching files on this disk',cr,lf,'$'
  255. msgal1     dc.b    'Use  $'
  256. msgal2    dc.b    '*.*  as file match? $'
  257. *#######################################################################
  258. *                    Storage Area
  259. *#######################################################################
  260.     even
  261. bufadr  dc.l    buffer
  262. mydma   dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  263.     dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  264.     dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  265.     dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  266.     dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  267.     dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  268.     dc.b    0,0,0,0,0,0,0,0
  269. buffer  dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  270.     dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  271. *#######################################################################
  272.         end
  273.