home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / apple / appldisk.dzc / APPLDISK.DOC
Encoding:
Text File  |  1987-01-27  |  7.4 KB  |  201 lines

  1.  
  2.        APPLE II DISK SOFT SECTORING  - January 25, 1981
  3.                         by Gary Morris
  4.                  further editing by Bill Blue
  5.  
  6.  
  7. DISKETTE NIBBLIZING
  8.  
  9.   Data  stored on a diskette is encoded into  nibbles.   There
  10. are  128 possible nibbles (because bit 7 must always be a  1),
  11. however some are reserved for markers and sync.  When encoding
  12. data, the 256-8 bit bytes are split up into 342-6 bit nibbles.
  13.  
  14.   When  writing nibbles it takes 32 microseconds to shift  out
  15. the 8 bits,   plus one extra shift produces the trailing zero.
  16.  
  17.   A  nibble is read from the shift register by  waiting  until
  18. the  byte  in  the  shift register is negative (bit 7  is  1).
  19. This  signals that the nibble is fully shifted in.  The  shift
  20. register  is  zeroed  before the shift  is  started,  and  all
  21. nibbles have a 1 in bit 7 so it is easy to tell when the shift
  22. is complete.  One bit is shifted every 4 microseconds,  so  it
  23. takes 32 microseconds to fill the shift register plus an extra
  24. 4  for the 0 after the nibble,  for a total time of 36  micro-
  25. seconds.
  26.  
  27. SELF SYNC
  28.  
  29.   The self sync feature allows the software to search the data
  30. coming from the disk entering at any point.  The program looks
  31. until  it  finds the sync field.   Then it locks on and  steps
  32. into the true data and address  information.   The bit pattern
  33. is  then read in the proper sequence.   Zeroes act as a  frame
  34. for the 8 bit sync byte.   See the diagram at the end of  this
  35. article.
  36.  
  37.   The following dump is of actual nibbles that were stored  on
  38. a  diskette.  It  is from a 16 sector disk.  The  actual  data
  39. contents of the sector was 256 bytes of 0's.
  40.  
  41. *1328.14AF
  42.  
  43. 1328- FF FF FF FF FF FF FF FF
  44. 1330- FF FF FF D5 AA 96 AA AB
  45. 1338- AB BA AA AB AB BA DE AA
  46. 1340- E9 83 FE FF FC FF FF FF
  47. 1348- FF D5AA AD 96 96 96 96
  48. 1350- 96 96 96 96 96 96 96 96
  49. 1358- 96 96 96 96 96 96 96 96
  50. 1360- 96 96 96 same....
  51. 14A0- 96 96 96 DE AA EB EE FF
  52. 14A8- FF FF FF FF FF FF FF FF
  53.  
  54.  
  55. SOFT SECTOR FORMAT
  56.  
  57. -------------
  58. |   SYNC    | all $FF's
  59. |-----------|
  60. |  ADDRESS  | $D5,$AA,$96
  61. |  MARKERS  |
  62. |-----------|
  63. |  ADDRESS  | 4 pairs of nibbles, vol,
  64. |   FIELD   | track, sector, checksum
  65. |-----------|
  66. | TRAIL MARK| $DE,$AA,$EB
  67. |-----------|
  68. |           | inter-record gap,
  69. |           | contains sync nibbles.
  70. |-----------|
  71. |   SYNC    | all $FF's
  72. |-----------|
  73. | DATA MARK | $D5,$AA,$AD
  74. |           |
  75. |-----------|
  76. |   DATA    |
  77. |   FIELD   | actual data nibbles
  78. |           |
  79. |342 NIBBLES|
  80. | 256 BYTES |
  81. |           |
  82. |           |
  83. |-----------| checksum of data,
  84. | CHECKSUM  | EOR of all data nibbles
  85. |-----------|
  86. |TRAIL MARK | $DE,$AA,$EB
  87. |-----------|
  88. |           | inter-record gap,
  89. |           | leading to next sector
  90. 'vvvvvvvvvvv'
  91.  
  92. SELF-SYNC DIAGRAM
  93.  
  94. bit
  95. stream -->
  96.  
  97. 0111111110111111110111111110111111110111111110111111110111111110
  98.  ||||
  99.     ^  FB      FD      FE   ^  FF       FF       FF       FF
  100.     ^                       ^
  101.  
  102.    (1)                     (2)
  103.  
  104. Notes:
  105.  
  106. (1)  Coincidental entry point with state-machine reading data.
  107.  
  108. (2) Found sync,  8 bit bytes all ones tells software that data
  109. is properly framed to sync into data field.
  110.  
  111.        ------------------------------------------------
  112.  
  113.  
  114.        APPLE DISK CONTROLLER PROM'S -  January 25, 1981
  115.                     written by Gary Morris
  116.                  further editing by Bill Blue
  117.  
  118.  
  119. (1) Standard PROM configuration
  120.  
  121.   The two PROMs on the Apple Disk Controller are refered to as
  122. PROM  P5 and P6.  These PROMs (Programmable Read Only  Memory)
  123. have  256  - 8 bit bytes.   In the standard  Apple  (is  there
  124. really  such  a thing?) they are the original  PROMs  designed
  125. when  the  controller card was and at that time called P5  and
  126. P6.   When  Pascal  was released two new PROMs came  with  the
  127. package,  known as PROM P5A and P6A.   These allowed users  to
  128. use  the  Pascal system diskettes which were  16  sectors  per
  129. track instead of the old 13 sectors per track standard.   Then
  130. recently  DOS 3.3  became available which also came with  PROM
  131. P5A and P6A, allowing 16 sector density for use with Basic and
  132. turnkey  capability  (under DOS 3.3 with Basic)  for  language
  133. card users.
  134.  
  135. (2) What's on those PROMs?
  136.  
  137.   The purposes of the two PROMs are completely separate.  PROM
  138. P5 (or P5A) is mapped into the Apple at the 256 byte area  for
  139. the  slot the controller is in.   In slot 6 that would be from
  140. $C600-$C6FF.  The  actual contents is a 6502 machine  language
  141. program  that is the first step in the sequence to  start  the
  142. drive  and load DOS into RAM memory (known as  booting).  Once
  143. the boot is complete this code is not used unless you reboot.
  144.  
  145.   The  P6  (or P6A) is not accessible by the  6502  processor.
  146. It's  purpose is that of a state machine controller.   In  re-
  147. sponse  to  commands from the 6502 address bus decoders  (they
  148. determine  when a specific address is on the bus) it  performs
  149. actions  on  the disk drive hardware,  such as turning on  the
  150. motor,  controlling the shift register,  and other things.  It
  151. is  used every time anything is done with the  disk  hardware,
  152. every time you access a disk file.
  153.  
  154. (3) Differences between P5, P6 and P5A, P6A
  155.  
  156.   The  P5 PROM contains a machine language program  that boots
  157. a 13 sector diskette.  It starts the drive,  reads nibbles and
  158. can  decode the nibbles to find the correct address  and  data
  159. field markers for a 13 sector diskette.
  160.  
  161.   The  P6 PROM is the logic table for the state machine.  With
  162. this  PROM  in  place you can access 13 sector  diskettes  re-
  163. liably.   16 sector diskettes can be accessed but it is  unre-
  164. liable and occasionally a read cannot be done at all.
  165.  
  166.   The P5A PROM contains the code necessary to boot a 16 sector
  167. diskette.  It  operates  much  the same as the P5  except  the
  168. nibble  decoding  is different,  and the third  address  field
  169. nibble is changed from a $B5 to a $96.
  170.  
  171.   The  P6A  PROM  is the logic table  for  an  improved  state
  172. machine.  With  this  PROM the hardware has the capability  of
  173. accessing either 13 or 16 sector density reliably.
  174.  
  175. (4) Mixing up PROMs
  176.  
  177.   What can we do with this new knowledge?   Let me explain the
  178. configuration  of  controller cards on my Apple and  why  it's
  179. best for me. I have 3 drives, two in slot 6 and one in slot 5.
  180. I have a language card so I want 16 sector density.  PASCAL is
  181. nice  to work with with three drives so I need 16 sector  den-
  182. sity on all three drives.  However, I have some diskettes that
  183. have  protected  software that will only boot on a  13  sector
  184. controller card.
  185.  
  186.   To be able to have the best of both worlds, I have put PROMs
  187. P5A  and P6A on the controller in slot 6 and PROMs P5 and  P6A
  188. in slot 5.  In slot 5 I have the P5 with the boot code to read
  189. a 13 sector diskette,  and the P6A to work with either a 13 or
  190. 16 sector density.  This gives me the capability to boot those
  191. protected disks by doing a PR#5.  In slot 6 I have P5A and P6A
  192. so it boots 16 sector density and can access either 16 or  13.
  193. When  running Pascal or DOS 3.3 I can use the drive in slot  5
  194. with no errors caused by the P6.   If you try to use the P6 on
  195. 16 sector density it will read slower because of the number of
  196. retries  necessary to get a correct read (try a bad block scan
  197. of a 16  sector disk on a controller with a P6 and then try it
  198. with a P6A)
  199.  
  200.        ------------------------------------------------
  201. Ö≡