Visit Atarimax Store


Free-Net Logo
The Atari SIG Historical Archive
Created and hosted by: atarimax.com
[ HOME | GO ATARI | 8-BIT | ST/TT | PORTFOLIO | LYNX | JAGUAR | LIBRARY ]


Article #66 (75 is last):
From: aa700@cleveland.Freenet.Edu (Michael Current)
Newsgroups: freenet.sci.comp.atari.prog.8bit.resource
Subject: Writing ATARI DS/DD disks on PC
Reply-To: aa700@cleveland.Freenet.Edu (Michael Current)
Posted-By: xx004 (Atari SIG)
Date: Wed Jul  1 11:42:52 1998


From: alumno20 
Date: Tue, 19 May 1998 18:16:44 -0500

Here are some notes which may prove useful, comparing ATARI and PC
floppy disks.

Common densities in the AATARI 8-bit world are:

single density (SD), enhanced density (ED) and double density (DD). The
standard disk size is 5,25", and though most drives are single-sided,
there are others (mostly the latest ones) which are double-sided.
SIngle and enhanced density use 128-byte sectors, DD uses 256-byte
sectors. SD uses FM encoding, ED and DD use MFM.

Summarizing:

Density  sides TPS SPT BPS enc total bytes
SD         1   40  18  128 FM  92160 (90K)
ED         1   40  26  128 MFM 133120 (130K)
SS/DD      1   40  18  256 MFM 184320 (180K)
SS/DD      2   40  18  256 MFM 368640 (360K)

OTOH, the common densities in the PC world are:

single density (SD), double density (DD) and high density (HD). The
satndard disk sizes are 5,25" and 3,5", though I haven't ever heard of
any 3,5" SS/SD disks. Most drives today are double-sided, only in the
first times there were single-sided SD 5,25" drives and DD 3,5" drives.
SD used 256-byte sectors, both DD nad HD use 512-byte sectors. Again
here, SD used FM encoding, DD and HD use MFM encoding. There's another
density called quad density (QD), only common in 3,5" drives, which also
uses 512-byte sectors and MFM encoding, but it hasn't become widespread.
We must note that these sector sizes are just the standard ones, since
the controller lets you format your disks in other custom sizes.

So, summarizing for the PC/DOS:

Density size sides TPS SPT BPS enc total bytes
SD      5,25"      1   40  9   256 FM  92160 (90K)
SS/DD   5,25"      1   40  9   512 MFM 184320 (180K)
SS/DD   5,25"      2   40  9   512 MFM 368640 (360K)
DS/HD   5,25"      2   80  15  512 MFM 1228800 (1.2M)
SS/DD   3,5"       1   80  9   512 MFM 368640 (360K)
SS/DD   3,5"       2   80  9   512 MFM 737280 (720K)
DS/HD   3,5"       2   80  18  512 MFM 1474560 (1.44M)


What else? Let's take a look at how the drive writes to the diskette.
We'll analyze this from the point of view of the PC, since the interest
here is in writing a program capable of reading/writing ATARI 8-bit
disks using a PC 5,25" drive.
Normally, the PC writes to a 360K disk in the following way:
it begins from track 0 (outside) at side 0 (top), the continues with
track 0, side 1 (bottom), the comes track 1, side 0, then track 1, side
1, until it finally reaches track 39 (innermost), side 1 (bottom).
We end up with 720 sectors of 512 bytes each, numbered from 0 to 719.
Of course, we can program the controller to use 18 sectors per track,
each of 256 bytes instead, and they would be then numbered 0 to 1439.
The formula for calculating the logical sector based on the sector,
track and head is:

       Lsec=(track*2+head)*18+sector

And the formulae for calculating the track, head and sector corresponding
to a logical sector would be:

       sector=Lsec mod 18
       head=(Lsec div 18) mod 2
       track=(Lsec div 18) div 2

The "Util"program, which reads/writes ATARI 8-bit SS/DD disks, reads
and writes to the disk in the following way:
It begins from track 0 (outside) at side 0 (top), then goes on with
track 1, side 0, until it reaches track 39 (innermost), side 0 (top).
But it also can read/write DS disks; it does this in the following
way:
The first (top) side is read like on a SS disk, then, after reaching
track 39, side 0, it returns to track 0 (outermost), side 1 (bottom),
and goes on with track 1, side 1, and so on until track 39, side 1.
The formulae for the logical sectors in this case is:

       Lsec=(head*40+track)*18+sector

And the formulae for calculating the track, head and sector corresponding
to a logical sector would be:

       sector=Lsec mod 18
       track=(Lsec div 18) mod 40
       head=(Lsec div 18) div 40

The problem here is, the ATARI 8-bit DS drives use a different method:
after reading side 0, side 1 is read BACKWARDS, which doesn't only mean
that the tracks are read starting by track 39, side 1 until reaching
track 0, side 1, but also that the SECTORS in each track are read
beginning from sector 17 and ending at sector 0. Don't ask me why.
>From the ATARI 8-bit point of view, a DS disk written using Util will
have sectors 721-1440 reversed (let's also remember that ATARI 8-bit
computers begin numbering sectors at 1 instead at 0). Although one
can write a program to read and reverse those sectors, if you already
had data on them, it may have been overwritten by Util. So what's
needed is to change Util to write those sectors in the proper order.
>From the PC point of view, to properly write the sectors on an ATARI
8-bit diskette, we would have the formula:

       Lsec=head*1439+[track*18+sector]*[1-2*head]

And the formulae for calculating the track, head and sector corresponding
to a logical sector would be:

       head=(Lsec div 18) div 40
       track=[(Lsec div 18) mod 40]*(1-2*head)+39*head
       sector=[Lsec mod 18]*(1-2*head)+17*head

Just as a sidenote: remember also that ATARI 8-bit computers write data
in a way that's complementary to the PC; that is, it uses for a "1" the
value the PC uses for a "0", and vice-versa. This can easily be solved
by complementing the value after reading and before writing to disk.

So far, I haven't been able to decipher the source code from the Util
program in order to patch it. The author's help -or anyone else's- would
be greatly appreciated.
-- 
Michael Current, mailto:mcurrent@carleton.edu
8-bit Atari FAQ and Vendor Lists, http://www.faqs.org/faqs/atari-8-bit/
Cleveland Free-Net Atari SIG, telnet://freenet-in-c.cwru.edu (go atari)
St. Paul Atari Computer Enthusiasts, http://www.library.carleton.edu/space/


Visit Atarimax Store