Jump to content
IGNORED

SIO <> ATX Track/Sector


LessNick

Recommended Posts

Hello there o/

 

Can anyone explain to me, in a simpler way, how the request for a sector number (block?) from the Atari Side via SIO is transliterate to the Track/Sector position on a real floppy disk?

How does a disk drive generally understand what they want from it and which sector needs to be read?

 

Let's take for example a disk image in ATR format. Everything there is quite simple, the sectors follow each other in order.

Knowing the sector size, it is not difficult to calculate the offset within the disk image when requested by SIO.

 

Working with a regular disk in ATX format turned out to be a little difficult. There is already redundant information about partitioning into tracks/sectors.

But nevertheless, even here the sectors have numbering, and even if they are not in order, but mixed up first odd, then even, you can, at the very least, get an offset with the desired data block.

 

It’s a little more difficult to calculate the correct offset to the beginning of a data block if there are different numbers of sectors on different tracks, for example more or less than 18.

But this problem is also solvable in principle.

 

But I’m completely at a loss as to what actually happens when there are no sequential sector numbers on the track (for example, 5, 8, 16), but there are sectors with numbers outside the numbering (for example, 36, 29, 66).

I understand that this is some kind of clever copy protection (or something like that), but how does the drive positioning work in this case?

 

For example, a request came from Atari to read sector number 716. Having calculated according to the description of the ATX structure, we got the position Track 39, Sector 4 and...

 

Tadaaam! There is no sector number 4, there are sectors number 3 and 6, but 4 and 5 are missing. And what should you do in this case? Return an error that the sector was not found?

But I have a strong belief that because of this mess with numbering, I actually get the wrong offset to the data.

 

Thank you very much in advance for your answer.

 

Link to comment
Share on other sites

Just now, TGB1718 said:

Heh, this is the first thing I read. Without this page, I would not have been able to understand the structure of the ATX format at all.

Although it must be admitted that it is written rather confusingly and the purpose of some areas on the floppy disk remains unknown.

 

Perhaps the information there is a little outdated, since on the same git sdrive-max there is slightly different information in the header files.

 

Link to comment
Share on other sites

1 minute ago, Ray Gillman said:

Not an answer but a question. Is it possible sector 3 is the fourth counting from 0?

It’s difficult to answer exactly how it will actually be by position, but the title description clearly indicates the sector number and it doesn't matter what position is it.

As far as I understand, this could be virtually any number.

 

For example, when creating an ATX image in the ATR Tools program, you can see how the numbering changes depending on the selected Sector Layout.

 

image.thumb.png.2d7c75c44be583874e3749a79709bdf2.png image.thumb.png.1e740ddf971e6f0221f139e5d5506d42.png image.thumb.png.a17fc8d4c00ded70ffb139fb1e5dbb65.png

 

And when editing a track, you can set any sector number, including 0th

 

image.thumb.png.d3b4b7ca47238571e5fe5b5df0315589.png

 

I don't presume to say that ATR Tool is an ideal program, but it at least gives some idea of how it all works.

 

Link to comment
Share on other sites

56 minutes ago, TGB1718 said:

Use the latest version: https://www.a8preservation.com/#/guides/atx

 

1 hour ago, LessNick said:

For example, a request came from Atari to read sector number 716. Having calculated according to the description of the ATX structure, we got the position Track 39, Sector 4 and...

This is exactly true - independent of how many sectors are on any track and how many sectors are on track 39.

 

1 hour ago, LessNick said:

There is no sector number 4, there are sectors number 3 and 6, but 4 and 5 are missing. And what should you do in this case? Return an error that the sector was not found?

This is also the correct answer. If the sector is not there, you have a "missing" sector which was the earliest method of copy protection.

 

1 hour ago, LessNick said:

But I’m completely at a loss as to what actually happens when there are no sequential sector numbers on the track (for example, 5, 8, 16)

The ATX image is somehow structured like a tree and you must calculate the expected position of the sector you want - which is what you did in your example for sector 716.
Then follow the tree to track 39 and check if you can find a sector 4.

 

Side note: If a track contains more than one instance of a sector, you must apply the correct "rotational timing" to decide which instance to return to the computer (duplicate sector copy protection).

 

1 hour ago, LessNick said:

but there are sectors with numbers outside the numbering (for example, 36, 29, 66).

I understand that this is some kind of clever copy protection (or something like that), but how does the drive positioning work in this case?

This cannot be read or verified with unmodified diks drives. They only know sectors 1-18 or 1-26, depending on the disk's format (SD/DD or ED).
But there is software specifically made for modified drives which loads code TO the drive and executes is there. This code can then read sectors outside the standard ranges. Disk Master (for Happy and Speedy) from a German company comes to mind and AFAIK some version of Super Archiver do the same.

 

 

  • Thanks 1
Link to comment
Share on other sites

28 minutes ago, Ray Gillman said:

Not an answer but a question. Is it possible sector 3 is the fourth counting from 0?

Sector numbers are always counted from 1.

But sectors #0 can be written to a track. These fall into the same category as LessNick's examples 36, 29, 66.

Link to comment
Share on other sites

1 minute ago, DjayBee said:

Thank you very much for the link, I'll definitely read it.

2 minutes ago, DjayBee said:

This is also the correct answer. If the sector is not there, you have a "missing" sector which was the earliest method of copy protection.

Just woow!

 

2 minutes ago, DjayBee said:

(duplicate sector copy protection)

o_O Oh, now it’s a little clearer why duplicate sectors are needed.

 

Thank you very much again for the clarification.

Link to comment
Share on other sites

To add to this, the way that real disk drives handle this is through density detection, usually when the disk is inserted. If the disk is single or double density, it has 18 sectors per track, and the physical track and sector numbers are (vsec-1)/18 and (vsec-1)%18+1. If it is enhanced density, it's (vsec-1)/26 and (vsec-1)%26+1. This can't depend on the other tracks or sectors, because the disk drive never even reads them beyond density detection, it simply seeks directly to the requested track and issues a read command to the FDC for the sector.

 

That being said, even real disk drives don't always get this right -- the XF551's problems with double density disks are due to its inadequate density detection strategy. It tries to use enhanced density first, with the unfortunate consequence that directory sector 361 translates to track 13, sector 23. This then causes it to error out with Record Not Found instead of seeing the Lost Data error it wants to switch to double density.

 

For a vanilla, unprotected disk, a simple strategy is simply to partition sectors by their format and size: FM and 256-byte MFM sectors are SD/DD and use 18 sectors per track, while 128-byte MFM sectors use ED and 26 sectors per track. This doesn't work for protected disks, however, where long and short sectors can deliberately be used. Detecting the correct density to use for track/sector translation can be difficult for a few reasons: there are a couple of disk drives that use true 128-byte boot sectors in double density, there are protected disks that only have boot sectors on track 0, and there are copy protections that deliberately issue format commands on a write protected disk to force the disk drive to switch densities.

 

  • Like 4
Link to comment
Share on other sites

Once again I want to say a huge thank you to everyone.

After lengthy battles, I finally managed to load BruceLee.atx

It was undoubtedly an interesting experience.

The system periodically checked phantom sector 17 during load.

And then she caused me slight confusion by requesting a sector outside the floppy disk (3000+)
The log from RespeQt came to the rescue, it turns out it’s enough to send a NACK to SIO and that’s enough. \o/

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...