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 / JSAGE / ZSUS / PROGPACK / FRESET10.ASM < prev    next >
Assembly Source File  |  2000-06-30  |  4KB  |  139 lines

  1. ; Routine:    FRESET -- fast drive reset and login
  2. ; Author:    Bridger Mitchell (Plu*Perfect Systems)
  3. ; CPU:        Z80-compatible
  4. ; Date:        January 2, 1988
  5. ; Version:    1.0
  6. ; This routine (fast-)resets and logs in the CP/M drive in register
  7. ; (A).  When possible, it uses BDOS function 37 (logoff drives). 
  8. ; In most cases FRESET is significantly faster than using function 13
  9. ; (reset all drives) to do a general reset.
  10. ; FRESET functions correctly with Digital Research's CP/M 2.2 BDOS,
  11. ; which contains a bug that does not allow the logged-in drive to
  12. ; be reset with function 37.
  13. ; Some CP/M BDOS emulators (such as ZRDOS, PZDOS, ...) have changed
  14. ; the operation of the general-reset function 13, in order to speed
  15. ; up warm-boots and disk-resets on systems with hard-drives. In this
  16. ; case, a non-removable drive (hard disk, ram disk), after it
  17. ; has been initially logged in, remains logged in after a general
  18. ; reset.
  19. ; On such systems it is **essential** that any program that uses
  20. ; BIOS disk functions to write to a non-removable drive also cause
  21. ; the disk's allocation map to be rebuilt before any BDOS disk
  22. ; functions are used.  DU (DU3) and UNERASE are probably the most
  23. ; common examples of such programs; they modify the disk directory.
  24. ; For these systems, the drive must first be logged off with
  25. ; function 37 and then logged in.  Calling FRESET within such
  26. ; programs will ensure that the disk's allocation map is recomputed.
  27. ; The FRESET algorithm:
  28. ;
  29. ;   if requested_drive is logged in
  30. ;     if a second drive is logged in
  31. ;         log into the second drive
  32. ;     logoff requested drive (fn.37)
  33. ;         if no second drive was logged in
  34. ;         do general reset (fn. 13)    
  35. ;   log into requested drive
  36. ; Note:  Unnumbered version dated 12/27/87 did not provide for
  37. ; logging out the drive in one special case, namely when only that
  38. ; one drive is currently logged in.  Thanks to Howard Goldstein
  39. ; for spotting the problem.
  40. ;
  41. xbdos    equ    5
  42.  
  43. ;    Fast-reset drive (A)
  44. ;    A = 0 ... 15  for  A: ... P:
  45. ;    
  46. CSEG
  47. freset:
  48.     ld    (reqdrv),a    ; save requested drive
  49.     push    af
  50.     ld    c,24        ; get vector of logged-in drives
  51.     call    xbdos
  52.     pop    af        ; (recover requested drive)
  53.     push    hl        ; save logged-in vector
  54.     call    fshftr        ; shift requested drive's bit to bit 0
  55.     bit    0,l        ; is requested drive logged in?
  56.     pop    hl        ;  (recover (unshifted) logged vector)
  57.     jr    z,flogit    ; ..z - no, just log it in
  58.     ld    e,0        ;  initialize drive index/count
  59.     jr    frese2
  60. ;
  61. frese1:    ld    a,1        ; shift vector right 1 bit
  62.     call    fshftr
  63. frese2:    bit    0,l        ; if drive is not logged in
  64.     jr    z,frese3    ; ..check next drive
  65.     ld    a,(reqdrv)    ; or if it is the requested drive
  66.     cp    e        ; 
  67.     jr    z,frese3    ; ..check next drive
  68. ;
  69. ; found a second logged-in drive, so switch to it
  70. ;
  71.     call    fslctit        ; select e'th drive
  72.     call    flogout        ; log out requested drive
  73.     jr    flogit        ; then log into it and exit.
  74. ;
  75. frese3:    inc    e        ; increment drive count
  76.     ld    a,e        
  77.     cp    16
  78.     jr    c,frese1    ; .. and continue for 16 drives 
  79. ;
  80. ; no second drive found,
  81. ;
  82.     call    flogout        ; log out requested drive
  83.     ld    c,13        ; do general reset, then (re)log requested
  84.     call    xbdos        ; 
  85. ;
  86. ; log into requested drive
  87. ;
  88. flogit:    ld    a,(reqdrv)
  89.     ld    e,a
  90. ;
  91. fslctit:ld    c,14        ; select bdos drive
  92. jxbdos:    jp    xbdos    
  93. ;
  94. ; log out the requested drive
  95. ;
  96. flogout:ld    a,(reqdrv)    ; set up bit to log out drive
  97.     ld    hl,1
  98.     call    fshftl
  99.     ex    de,hl
  100.     ld    c,37        ; log out drive in DE vector
  101.     jr    jxbdos
  102. ;
  103. ;
  104. ; shift hl right (a) bits
  105. ;
  106. fshftr:
  107.     inc    a
  108. shftr1:    dec    a
  109.     ret    z
  110.     srl    h
  111.     rr    l    
  112.     jr    shftr1
  113. ;
  114. ;
  115. ; shift hl left (a) bits
  116. ;
  117. fshftl:
  118.     inc    a
  119. shftl1:    dec    a
  120.     ret    z
  121.     add    hl,hl
  122.     jr    shftl1    
  123.  
  124. ;--------------------
  125. DSEG
  126. reqdrv:    ds    1
  127.  
  128.     end
  129.     z,frese3    ; ..check next drive
  130. ;
  131. ; found a second logged-in drive, so switch to it
  132. ;
  133.     call    fslctit        ; select e'