home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.tar / ftp.whtech.com / club100 / ref / dostip.009 < prev    next >
Text File  |  2006-10-19  |  5KB  |  121 lines

  1. DOSTIP.009/Direct Sector Access using DSKO$
  2. ===========================================
  3. joel dinda
  4. [75725,1134]
  5.  
  6. Among Powr-DOS's many virtues is that it provides TDD1 users the capability to
  7. bypass the TDD file structure and access disk sectors directly.  The most
  8. obvious applications for this capability are utility programs (there are
  9. several such in this Library) and (random access?) database programs (aside:
  10. database programmers will have to write their own file-management routines, a
  11. matter this discussion ignores).  This file lists all-in-one-place those things
  12. someone writing such a program will need to know.
  13.  
  14. First I'll talk about syntax, then I'll discuss some necessary concerns,
  15. finally I'll discuss some background matters.
  16.  
  17. **WARNING:  This is an advanced and fairly specialized programming tip.  Only
  18. fairly experienced M100(etc) programmers will understand some of this
  19. discussion.  Lots of it is pretty opaque.  While it's not intended to
  20. intimidate, you've got to be writing a pretty sophisticated program to want to
  21. know these things.
  22.  
  23. FLOPY2/TDD2 users/programmers will want to read TD2TIP.009.  Besides differing
  24. in technical details, that TIP includes some comparative information this file
  25. lacks.
  26.  
  27. Syntax
  28. ======
  29. The necessary command is:
  30.       DSKO$ Y,S,BF
  31. Where:
  32.       Y indicates the activity you wish to provoke.
  33.       
  34.       S indicates the diskette sector being transferred.
  35.       
  36.       BF indicates the RAM address reserved (by you) for the file transfer. 
  37.       (Call it a buffer [BF]; this is the lowest address [possibly HIMEM] in
  38.       the buffer.  I discuss this further below.)
  39.       
  40. Y options:
  41. -----------
  42.       0 attempts to read the diskette.
  43.       Anything else attempts to write to the diskette.
  44.       
  45. S options:
  46. -----------
  47.       Sector number you want to read from/write to RAM.
  48.       
  49. BF options:
  50. -----------
  51.       Any legal RAM address--but some are far better than others.  I'll return
  52.       to this momentarily.
  53.       
  54. Necessary Concerns:
  55. ===================
  56. Is Powr-DOS there?
  57. ------------------
  58. Check to see if Powr-DOS is actually installed.  The P-DOS command provided for
  59. this purpose is LFILES V:
  60.       0 ON ERROR GOTO 101:LFILESV:ON ERROR GOTO 100: ...
  61.       100 ... ELSE PRINT "Error"ERR"in line"ERL:PRINT "Press <Any
  62.       Key>":T$=INPUT$(1):LFILES MENU
  63.       101 BEEP:PRINT "No Powr-DOS":END
  64. Of uncertain significance:  Those of us who converted from Powr-Disk to
  65. Powr-DOS discovered that P-Disk doesn't handle LFILESV well.  I've decided
  66. that's not an important concern.
  67.  
  68. Buffers
  69. -------
  70. Next create one or more buffers for your program's use.
  71.  
  72. You'll need one buffer for each sector you intend to duplicate in RAM at any
  73. one time; the exact number will depend either upon the nature of your
  74. application or the amount of RAM available.  Each buffer will be 1292 bytes
  75. long; it should be locked in with some variation of the following instruction:
  76.       CLEAR256,HIMEM-(1292*(number of buffers))
  77.  
  78. It is *always* good practice to restore HIMEM to its previous value when the
  79. program finishes; there are at least two workable schemes.  Folks who use
  80. MAXRAM instead of HIMEM in programs which overwrite high memory are despicable
  81. creatures; they should, at least, warn users that they're destroying files.
  82.  
  83. Error Trapping
  84. --------------
  85. While Powr-DOS provides a fairly extensive set of error messages, most users
  86. only want to know whether the problem's in the drive or with the disk.  I've
  87. long used this sort of error trap with Powr-DOS programs:
  88.       99 ... ELSE IF ERR>62 AND ERR<66 THEN PRINT "Disk Error" ELSE IF ERR>58
  89.       AND ERR<67 THEN PRINT "Drive Error" ELSE PRINT "Error"ERR"in line"ERL
  90.       100 PRINT "Press <Any Key>": ...
  91.       
  92. Background
  93. ==========
  94. Much of the technical information was obtained by studying the Powr-DOS manual,
  95. from hints left by Ed Giese of Acroatix on this SIG, and by systematic
  96. experimentation.  Some of the discussion follows from fairly extensive
  97. experience with Powr-DOS.
  98.  
  99. Buffer Format:
  100. --------------
  101. The first 1280 bytes of the sector (actually, buffer) (call them BF+0 thru
  102. BF+1279) duplicate in RAM the information in the diskette sector.  Except for
  103. Sector 0 (the directory sector), this this could be anything (TDD1 doesn't
  104. inflict any format.)  Unless modified, Sector 0 conforms to the information in
  105. SECTR0.TDD, available from this Library.
  106.  
  107. BF+1280 is the file vector:
  108.       0 means the sector's empty;
  109.       255 is an EOF marker; and
  110.       any other number indicates "file continues here".
  111. Since file deletions do *not* modify these vectors, these may be misleading.
  112.  
  113. The remaining 11 bytes (BF+1281 thru BF+1291) are of unknown consequence.  They
  114. appear to always be zero; presumably they could contain information with
  115. meaning to the drive.
  116.  
  117.  
  118. Enough.  That should point you in the right direction....
  119. joel
  120. 4july88
  121.