MDV Low Level Routines

Anything QL Software or Programming Related.
Post Reply
tcat
Super Gold Card
Posts: 633
Joined: Fri Jan 18, 2013 5:27 pm
Location: Prague, Czech Republic

Re: MDV Low Level Routines

Post by tcat »

Hi,

While I am toying with MAPs and Blocks, that I hopefully have learnt to read and also write.
I now look at Format routine, it seems very complex with many passes and checks.

The media label is written to each sector as the Format routine writes sector headers. As it has many passes I try to avoid reformatting as that stresses the tape unnecessarily.

I keep wondering how to change the label, for simplicity without verifying, possibly in a single pass?
Can I reuse ROM routine for that,somehow?

I realise, arguments about timing loops were sounded here, that timing can be safe in ROM only.

Many thanks.
Tomas


User avatar
tofro
Font of All Knowledge
Posts: 3097
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: MDV Low Level Routines

Post by tofro »

Tomas,

one of the main principles of the microdrive format is that, once a tape has been formatted, the sector headers are never written again (until the next format, of course). The hardware is simply not good enough to be able to "hit" a header so exactly that it is guaranteed that the actual data block after the gap is not garbled.

Actually, the headers are there to be able to "hit" a block precisely (as the gap has a very exact timing). Unfortunately, there's nothing before the sector header that allows the same synchronisation for the header.

You could use the data block to synchronize for the header, but the problem is the loop here - The gap between the "last" (which is actually sector 0) data block and the "first" valid sector header (somewhat like 200) is undefined and can't even be caught with exact timing.

Tobias


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
tcat
Super Gold Card
Posts: 633
Joined: Fri Jan 18, 2013 5:27 pm
Location: Prague, Czech Republic

Re: MDV Low Level Routines

Post by tcat »

Tobias,

Thank you, now I see the logic behind. We usually ever format once, and read/rewrite blocks many times. We may possibly reformat few times in a life of media, to get away of bad blocks appearing due to tape wear.

Sector headers & flags are there, to guide QDOS in reading/writing blocks. There is actually no guiding for writing of sectors. As sectors are only written by Format only once, which puts them onto media in a fixed timing sequence = to time over GAPs, and with no guiding, therefore each time we Format this sequence may appear at different physical point on the tape loop.

It could explain why successive Formating, may give varying stats of free/total blocks on the media.

Am I close?
Tomas


User avatar
tofro
Font of All Knowledge
Posts: 3097
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: MDV Low Level Routines

Post by tofro »

tcat wrote: Am I close?
On the spot.
The sector headers provide the basic synchronisation for all of the microdrive handling.

Tobias


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
tcat
Super Gold Card
Posts: 633
Joined: Fri Jan 18, 2013 5:27 pm
Location: Prague, Czech Republic

Re: MDV Low Level Routines

Post by tcat »

Hi,

I have had another observation, regarding MD Sector MAP. When I Format a Cart, copy a dummy file on it, and then display the MAP. In the MAP I can see,

$FD00 - meaning FREE Block
$FF00 - meaning BAD Block
$[fil][blk] - File / Block Pairs allocated
$FE00 - usually appears once or not at all, not sure what the meaning is?

Many thanks so far.
Tomas


User avatar
tofro
Font of All Knowledge
Posts: 3097
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: MDV Low Level Routines

Post by tofro »

tcat wrote:Hi,

I have had another observation, regarding MD Sector MAP. When I Format a Cart, copy a dummy file on it, and then display the MAP. In the MAP I can see,

$FD00 - meaning FREE Block
$FF00 - meaning BAD Block
$[fil][blk] - File / Block Pairs allocated
$FE00 - usually appears once or not at all, not sure what the meaning is?

Many thanks so far.
Tomas
Actually:

The special file numbers (first byte of the block number) are as follows:

$00 : Directory file block
$FB: Mapping sector
$FC: Block is pending delete - Never seen that other than in the docs, not sure what they're good for
$FD: free (unused) block
$FE: bad (defect) block
$FF: bad (non-existing) block

Everything else is a block belonging to a valid file on tape.

$FE and $FF blocks differ in the way that $FE blocks are there, could be formatted, but simply do not hold the data reliably due to a defect of the tape (i.e. verification failed). As you have seen, they are actually quite rare. You should be able to see $FE blocks existing on the tape, not only in the map. $FF blocks are the ones that didn't fit onto the tape (that is, you won't ever see a $FF block on the tape other than in the map).

Tobias


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
Martin_Head
Aurora
Posts: 970
Joined: Tue Dec 17, 2013 1:17 pm

Re: MDV Low Level Routines

Post by Martin_Head »

tofro wrote:
$FB: Mapping sector

$FC: Block is pending delete - Never seen that other than in the docs, not sure what they're good for
I've noticed that in the map, sector 0 (the map itself) has a file/block number of $F800, but in the block header of sector 0, the file number is $80

I suspect the file number of $FC is only used on the copy of the map kept in memory, while the slave block mechanism is doing its thing in the background during a delete operation.

Martin Head


tcat
Super Gold Card
Posts: 633
Joined: Fri Jan 18, 2013 5:27 pm
Location: Prague, Czech Republic

Re: MDV Low Level Routines

Post by tcat »

Martin,

I sometimes also see $80 instead of $F8 in the Block Header, but it does not seem always.
$80 = 1000 0000
$F8 = 1111 1000

Tomas


tcat
Super Gold Card
Posts: 633
Joined: Fri Jan 18, 2013 5:27 pm
Location: Prague, Czech Republic

Re: MDV Low Level Routines

Post by tcat »

Hi,

I am still toying with maps, I have a new interesting observation.

This is the map of my Cart labeled 'three' formated in drive 2:
Format gives 210/212
Stat gives 208/210
formated in drive 2
formated in drive 2
md2_map.png (5.94 KiB) Viewed 3473 times
This is the map of my Cart labeled 'three' formated in drive 1:
Format gives 212/216
Stat gives 210/212
formated in drive 1
formated in drive 1
md1_map.png (5.93 KiB) Viewed 3473 times
(1) It seems drive 2 format always misses 4 sectors at the loop end?
(2) Why do $FF00 sectors randomly appear inside the map, as I would expect them at the loop end only?

Tomas


Martin_Head
Aurora
Posts: 970
Joined: Tue Dec 17, 2013 1:17 pm

Re: MDV Low Level Routines

Post by Martin_Head »

Working for memory, So I might have this wrong.

The format routine does two writes to each sector, each time with different bit patterns. ($AA55 and $55AA ring a bell)

If the sector fails on the first test, then it is flagged $FF, and if it fails on the second test, then it's flagged $FE

If you look at the data stored in the 'bad sectors' you should see the test patterns used.

One Microdrive unit formatting the same cartridge to different numbers of sectors than another Microdrive unit is common, I don't know exactly why. Motor speed? Manufacturing tolerances?

Back in the 80's, some people recommended formatting cartridges several times to find the highest of sectors you could get out of them. But this could cause problems if you had a suspect sector which just managed to pass the format routine, only to start playing up at a later date.

Martin Head


Post Reply