Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Peter Norton Programmer's Guide - Norton Guide http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]

  Service 05H (decimal 5) formats one track. The format service operates as
  do the read and write services except that you need not specify a sector
  number in CL. All other parameters are as shown in Figure 10-3.

  Because formatting is done one full track at a time, you cannot format
  individual sectors. However, on a diskette you can specify individual
  characteristics for each sector on a track.

  Every sector on a diskette track has 4 descriptive bytes associated with
  it. You specify these 4 bytes for each sector to be formatted by creating
  a table of 4-byte groups and passing the table's address in the register
  pair ES:BX. When you format a disk track, the 4-byte groups are written to
  the diskette immediately in front of the individual sectors in the track.
  The 4 bytes of data associated with a sector on the disk are known as
  address marks and are used by the disk controller to identify individual
  sectors during the read, write, and verify operations. The 4 bytes are
  referred to as C for cylinder, H for head, R for record (or sector
  number), and N for number of bytes per sector (also called the size code).

  When a sector is being read or written, the diskette controller searches
  the diskette track for the sector's ID, the essential part of which is R,
  the record or sector number. The cylinder and head parameters are not
  actually needed in this address mark because the read/write head is
  positioned mechanically at the proper track and the side is selected
  electronically, but they are recorded and tested as a safety check.

  The size code (N) can take on any one of the four standard values shown in
  Figure 10-4. The normal setting is code 2 (512 bytes).

  Sectors are numbered on the diskette in the order specified by R. On
  diskettes, the sectors are normally numbered in numeric sequence (unless
  rearranged for copy protection), but on fixed disks the order of the
  sectors can be rearranged (interleaved), either for better performance or
  to create timing differences for copy-protection purposes. The actual
  interleave used on a fixed disk depends on the capabilities of the
  disk-controller hardware. For example, the PC/XT's fixed disk has its
  sectors interleaved so that logically consecutive sectors are physically
  located six sectors apart.

  N              Sector Size (bytes)          Sector Size (KB)
  --------------------------------------------------------------------------
  0               128                         1/8
  1               256                         1/4
  2               512                         1/2
  3               1024                        1
  --------------------------------------------------------------------------

  Figure 10-4.  The four standard sizes of the N size code.

  To format a diskette track using service 05H, perform the following steps:

  1.  Call service 17H to inform the ROM BIOS what kind of diskette is to
      be formatted. (See page 208 for more about service 17H.) This service
      needs to be called only once.

  2.  Call service 18H to describe the diskette media to the ROM BIOS. (See
      page 209.)

  3.  Create a table of address marks for the track. There must be a 4-byte
      entry in the table for each sector. For example, for track 0, side 1
      of a typical nine-sector DOS diskette, the table would contain nine
      entries:

      0 1 1 2  0 1 2 2  0 1 3 2  ... 0 1 9 2

  4.  Call service 05H to format the track.

  The method for formatting a fixed-disk track is somewhat different. You
  should omit the calls to services 17H and 18H (steps 1 and 2 above)
  because there is no need to describe the disk media to the ROM BIOS. Also,
  with a PC/AT or PS/2, the table whose address you pass in 3 step has a
  format that consists only of alternating flag bytes (00H = good sector,
  80H = bad sector) and sector number (R) bytes. With a PC/XT, you don't
  need a table at all. Instead, you call service 05H with an interleave
  value in AL, and the ROM BIOS does the rest.

  You may want to verify the formatting process by following each call to
  service 05H with a call to service 04H.

  When a diskette track is formatted, the diskette drive pays attention to
  the diskette's index hole and uses it as a starting marker to format the
  track. The index hole is ignored in all other operations (read, write, or
  verify), and tracks are simply searched for by their address marks.

  Nothing in this format service specifies the initial data value written
  into each formatted sector of a diskette. That is controlled by the
  disk-base table. (See page 209.)

  --------------------------------------------------------------------------
  NOTE:
    Service 05H should not be used with ESDI drives in PS/2s. Use service
    1AH instead.
  --------------------------------------------------------------------------

  Using Service 05H for Copy Protection

  Diskette tracks can be formatted in all sorts of ways, but DOS can only
  read certain formats. Consequently, some copy-protection schemes are based
  on an unconventional format that prevents the ROM BIOS or the operating
  system from successfully reading and copying data. You can choose from
  several different copy-protection methods:

  .  You can rearrange the order of the sectors, which alters the access
     time in a way that the copy-protection scheme can detect.

  .  You can squeeze more sectors onto a track (10 is about the outside
     limit for 512-byte sectors on a 360 KB diskette).

  .  You can simply leave out a sector number.

  .  You can add a sector with an oddball address mark (for example, you can
     make C = 45 or R = 22).

  .  You can specify one or more sectors to be an unconventional size.

  Any of these techniques can be used either for copy protection or for
  changing the operating characteristics of the diskette. Depending on what
  options are used, a conventionally formatted diskette may have its
  copy-protection characteristics completely hidden from DOS.

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson