home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 110_01 / ddndisk.c < prev    next >
Text File  |  1984-03-03  |  4KB  |  96 lines

  1. /*
  2.  
  3. This program rewritten Sept 9, 1981 by Robert Ward.  All but some low
  4. level functions and the command line argument handling have been 
  5. redone.  The object was to create code that would work with double
  6. density and other controllers. 
  7.  
  8. To compile correctly for your system. You must know the number of 
  9. sectors per track (SPT), the number of tracks per disk (TPD),
  10. the maximum blocks on a drive (MAXBLKS), the size of each sector in 
  11. bytes (SECSIZE), the size of each block in sectors (BLKSIZE), and the
  12. location of your sector translate table (we are assuming cpm 2.2x), and
  13. the size of the directory(DIRSIZE). 
  14.  
  15. All of these items are set in #define statements on or about line 100.
  16. Most of the information is available by "stat" on the drive. The 
  17. TXTABLE value may be found by loading ddt, loading a program that 
  18. does file I/O, putting a break (FF?) at vector 16 (sectran call) in
  19. the bios. Once the breakpoint is set, execute the program and 
  20. the value in DE when the breakpoint is encountered is TXTABLE for
  21. that density disk only!
  22. */
  23. /*
  24.     DISK UTILITY PROGRAM
  25.  
  26.     Written by Richard Damon
  27.     Version 1.0 May 1980
  28.  
  29.     This program allows the operator to examine and modify
  30. a CPM diskette.
  31.  
  32.     The commands available in this package are :
  33.  
  34. Tn  set current track to n (0-76)
  35. Sn  set current sector to n (1-SECS_PER_TRACK)
  36. Dn  set current disk number to n (0-3)
  37. Bn  set current track and sector to point to block n (0-F2)
  38. N   set current track and sector to next sector/block
  39.     next sector if last set command was for track or sector
  40.     next block if last set command was for block
  41. I   increment sector, if sector>SECS_PER_TRACK set to 1 and increment track
  42. R   read sector/block into buffer
  43. W   write sector/block from buffer
  44. P   print out contents of buffer, allong with track/sector/block information
  45. Ea n n n n
  46.     edit buffer starting from location a filling with values n n n.
  47. Fn  Fill buffer with value n
  48. X   exit program
  49. M   print disk allocation map
  50.  
  51. Notes:
  52.     1)  Multiple commands may be specified on a line except for X
  53. which must be the only command on the line followed by return.
  54.     2)  Commands may be in upper or lower case letters
  55.     3)  Spaces are ignored except in the E command where they are used
  56.     as separaters for the numbers
  57.  
  58. Typical commands:
  59. d0t0s1rp    read in the track 0 sector 1 of disk 0 (Drive A) and print it
  60. e1A 4F 20 11    set buffer location 1A to 4F, 1B to 20, and 1C to 11.
  61. e0a 00w        set buffer location 0a to 0 and write buffer
  62.             Note no space after last data byte
  63. nrp        get next buffer and print it
  64.  
  65. Disk Allocation Map
  66.     The M command is designed to allow the directory blocks (blocks 0 and 1)
  67. to be printed out in a convient format. The directory is print out in the
  68. following format:
  69.  
  70.  Section 1:
  71.     The top half of the directory listing is a listing of the name
  72.     inforamtion of the directory entries.  Each line corresponds to 1 sector
  73.     of the directory.  A typical entry would be f=DISKTESTCOM/1 4c
  74.     The first letter is a code letter used to referance into section 2.
  75.     The equal sign indicats that the file exists, a star here indicates
  76.       that this entry is a deleted file.
  77.     Next comes the filename and extension.
  78.     The following /n is printed if this is other then the first extent 
  79.       (extent 0) of a file where n is the extent number of this entry.
  80.     The following number is the hex record count for this extent.
  81.  
  82.  Section 2:
  83.     The bottom half of the directory listing is a disk allocation map
  84.     showing which blocks are in use and by which file. Free blocks are
  85.     indicated by a dot while used blocks are marked by the file control
  86.     letter asigned to a file in section 1.  This listing has been blocked off
  87.     in groups of 8 and 16 to ease reading.
  88.  
  89. CPM FILE STRUCTURE
  90.  
  91.     To help the user of this program the following is a brief description
  92. of the format used in CPM.  The first 2 tracks of a disk are reserved
  93. for the bootstrap and the copy of the CPM operating system.  Tracks 2
  94. through 76 store the data.  To speed up disk access CPM does not store
  95. consecutive data in consecutive sectors.  Insteed it uses every 6th sector
  96. for data. Thus to