BASIC Disk Format

for bbc micro/electron hardware, peripherals & programming issues (NOT emulators!)
Post Reply
JannievanZyl
Posts: 188
Joined: Sat Feb 11, 2017 8:56 pm
Location: Cape Town, South Africa
Contact:

BASIC Disk Format

Post by JannievanZyl » Sun Dec 31, 2017 12:00 pm

I've searched through the forum for a BASIC program to format a disk on my model B but all the links I found seems to be broken.

Found this one;

http://www.beebmaster.co.uk/BeebHelp/Format8271.html

Before I type this all in, can someone possibly confirm it'll work in my setup? [-o<

My setup is as follows;

BBC model B
8271 controller
DFS 1.20

I used the first drive from a Z80 Torch dual drive setup. The PSU in the unit is faulty, so I just connected the 1st drive directly to the BBC. My understanding is this is a 80-track, double-sided drive?

If I put a blank, unformatted disk (doubled sided, 96tpi) in and do a *CAT, I get:

"Drive fault 14 at 00/C1" - is this the expected output? Most examples I saw seem to show 'Drive fault 18'?

Basically, will the above linked BASIC program work in this setup?

Thanks!!

JannievanZyl
Posts: 188
Joined: Sat Feb 11, 2017 8:56 pm
Location: Cape Town, South Africa
Contact:

Re: BASIC Disk Format

Post by JannievanZyl » Sun Dec 31, 2017 12:13 pm

Just thought of something.....

Can I connect a 5.25" DS, 80-track drive from a BBC Model B (200KB per side, right?) directly to the BBC Master Compact and format a floppy that way?

That'll save me typing in a 70 line BASIC program on the Model B?

/Added

Just noticed the Compact's floppy interface is a DB25.....

User avatar
1024MAK
Posts: 7551
Joined: Mon Apr 18, 2011 4:46 pm
Location: Looking forward to summer in Somerset, UK...
Contact:

Re: BASIC Disk Format

Post by 1024MAK » Sun Dec 31, 2017 2:21 pm

BeebMaster! Calling BeebMaster!

He must be busy watching TV about the Royal Family again...

Yes, I believe the format program on his site works.

Mark
For a "Complete BBC Games Archive" visit www.bbcmicro.co.uk NOW!
BeebWiki‬ - for answers to many questions...

User avatar
1024MAK
Posts: 7551
Joined: Mon Apr 18, 2011 4:46 pm
Location: Looking forward to summer in Somerset, UK...
Contact:

Re: BASIC Disk Format

Post by 1024MAK » Sun Dec 31, 2017 2:22 pm

JannievanZyl wrote:Just thought of something.....

Can I connect a 5.25" DS, 80-track drive from a BBC Model B (200KB per side, right?) directly to the BBC Master Compact and format a floppy that way?

That'll save me typing in a 70 line BASIC program on the Model B?

/Added

Just noticed the Compact's floppy interface is a DB25.....
Only if you build an adapter cable...

Mark
For a "Complete BBC Games Archive" visit www.bbcmicro.co.uk NOW!
BeebWiki‬ - for answers to many questions...

JannievanZyl
Posts: 188
Joined: Sat Feb 11, 2017 8:56 pm
Location: Cape Town, South Africa
Contact:

Re: BASIC Disk Format

Post by JannievanZyl » Sun Dec 31, 2017 2:34 pm

1024MAK wrote:BeebMaster! Calling BeebMaster!

He must be busy watching TV about the Royal Family again...

Yes, I believe the format program on his site works.

Mark
Tx!

User avatar
jgharston
Posts: 3090
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield
Contact:

Re: BASIC Disk Format

Post by jgharston » Sun Dec 31, 2017 7:38 pm

Here's the code from my site, normally at mdfs.net/BBC:

REM > FormDFS
REM Quick Formatter
DIM X% 31,data% 511:Y%=X%DIV256:*DISK
ON ERROR REPORT:PRINT " at line ";ERL:OSCLI"FX180,"+STR$(PAGE/256):END
*FX180,64
INPUT"Drive: "drive%
INPUT"Tracks: "num%
FOR track%=0 TO num%-1
PRINT CHR$13;"Track ";track%;
FOR sector%=0 TO 9
data%!(sector%*4)=track%
data%?(sector%*4+2)=(sector%+track%*7)MOD10
data%?(sector%*4+3)=1
NEXT sector%
X%?0=drive%
X%!1=data%
X%!5=&6305
X%?7=track%
X%!8=&10002A10
A%=127:REPEAT:CALL&FFF1:UNTIL X%?12<>&10
IF X%?12:PRINT" error &";~X%?12
NEXT track%:PRINT
FOR A%=0 TO 511 STEP 4:data%!A%=0:NEXT A%
data%?&107=num%*10
data%?&106=num%/25.6
X%?0=drive%
X%!1=data%
X%!5=&4B03
X%!9=&22
A%=127:REPEAT:CALL&FFF1:UNTIL X%?10<>&10
IF X%?10:PRINT"write error &";~X%?10
OSCLI"FX180,"+STR$(PAGE/256):END

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

JannievanZyl
Posts: 188
Joined: Sat Feb 11, 2017 8:56 pm
Location: Cape Town, South Africa
Contact:

Re: BASIC Disk Format

Post by JannievanZyl » Tue Jan 02, 2018 6:39 pm

jgharston wrote:Here's the code from my site, normally at mdfs.net/BBC:
Tx!!

JannievanZyl
Posts: 188
Joined: Sat Feb 11, 2017 8:56 pm
Location: Cape Town, South Africa
Contact:

Re: BASIC Disk Format

Post by JannievanZyl » Fri Jan 05, 2018 10:19 pm

jgharston wrote:Here's the code from my site, normally at mdfs.net/BBC:

REM > FormDFS
REM Quick Formatter
DIM X% 31,data% 511:Y%=X%DIV256:*DISK
ON ERROR REPORT:PRINT " at line ";ERL:OSCLI"FX180,"+STR$(PAGE/256):END
*FX180,64
INPUT"Drive: "drive%
INPUT"Tracks: "num%
FOR track%=0 TO num%-1
PRINT CHR$13;"Track ";track%;
FOR sector%=0 TO 9
data%!(sector%*4)=track%
data%?(sector%*4+2)=(sector%+track%*7)MOD10
data%?(sector%*4+3)=1
NEXT sector%
X%?0=drive%
X%!1=data%
X%!5=&6305
X%?7=track%
X%!8=&10002A10
A%=127:REPEAT:CALL&FFF1:UNTIL X%?12<>&10
IF X%?12:PRINT" error &";~X%?12
NEXT track%:PRINT
FOR A%=0 TO 511 STEP 4:data%!A%=0:NEXT A%
data%?&107=num%*10
data%?&106=num%/25.6
X%?0=drive%
X%!1=data%
X%!5=&4B03
X%!9=&22
A%=127:REPEAT:CALL&FFF1:UNTIL X%?10<>&10
IF X%?10:PRINT"write error &";~X%?10
OSCLI"FX180,"+STR$(PAGE/256):END
Managed to get this working to format a 40-track disk in my 80-track DS drives. Assume it's the media (HD) stopping me from formatting a 80-track, 200KB disk.

When I run the above program, it formats fine but then ends with a continuous loop of "Mistake at line 40" and I need to Break out of it.

Seems it thinks there is a syntax error at:

ON ERROR REPORT:PRINT " at line ";ERL:OSCLI"FX180,"+STR$(PAGE/256):END

Any ideas?

User avatar
jgharston
Posts: 3090
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield
Contact:

Re: BASIC Disk Format

Post by jgharston » Sat Jan 06, 2018 11:57 am

JannievanZyl wrote:Seems it thinks there is a syntax error at:
ON ERROR REPORT:PRINT " at line ";ERL:OSCLI"FX180,"+STR$(PAGE/256):END
Can't see anything, and the above is a direct *SPOOL of the BASIC program. I've just loaded the code into Edit, and copied and pasted the line directly to here:
ON ERROR REPORT:PRINT " at line ";ERL:OSCLI"FX180,"+STR$(PAGE/256):END
and that's identical. What happens if you remove the line? It's only there to clean up if you abort in the middle of the program.

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

JannievanZyl
Posts: 188
Joined: Sat Feb 11, 2017 8:56 pm
Location: Cape Town, South Africa
Contact:

Re: BASIC Disk Format

Post by JannievanZyl » Sat Jan 06, 2018 2:27 pm

jgharston wrote:
JannievanZyl wrote:Seems it thinks there is a syntax error at:
ON ERROR REPORT:PRINT " at line ";ERL:OSCLI"FX180,"+STR$(PAGE/256):END
Can't see anything, and the above is a direct *SPOOL of the BASIC program. I've just loaded the code into Edit, and copied and pasted the line directly to here:
ON ERROR REPORT:PRINT " at line ";ERL:OSCLI"FX180,"+STR$(PAGE/256):END
and that's identical. What happens if you remove the line? It's only there to clean up if you abort in the middle of the program.
I'll try that as it does seem to work otherwise.

When I do an 40 track format (on my 80-track drives), does it 'double-step'? Seems so.

JannievanZyl
Posts: 188
Joined: Sat Feb 11, 2017 8:56 pm
Location: Cape Town, South Africa
Contact:

Re: BASIC Disk Format

Post by JannievanZyl » Sat Jan 06, 2018 2:27 pm

Another (related) newbie question I've not been able to find an answer Googling or reading the DFS manuals;

A friend brought me some BBC disks. I believe they're 40-track.

I can *CAT them but cannot load a program. I assume the catalog is on track 0 for both drive types?

Is this inability to load a program a function of trying to read a 40-track disk on a 80-track drive? And, if so, is there a workaround or a simple command I'm missing?

JannievanZyl
Posts: 188
Joined: Sat Feb 11, 2017 8:56 pm
Location: Cape Town, South Africa
Contact:

Re: BASIC Disk Format

Post by JannievanZyl » Sat Jan 06, 2018 2:36 pm

Think Daniel might have found a potential cause here: viewtopic.php?f=3&t=13945#p190656

User avatar
jgharston
Posts: 3090
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield
Contact:

Re: BASIC Disk Format

Post by jgharston » Sat Jan 06, 2018 8:33 pm

JannievanZyl wrote:When I do an 40 track format (on my 80-track drives), does it 'double-step'? Seems so.
If you tell the drive to double-step.

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

Kazzie
Posts: 93
Joined: Sun Oct 15, 2017 7:10 pm
Location: North Wales
Contact:

Re: BASIC Disk Format

Post by Kazzie » Mon Jan 08, 2018 12:13 pm

JannievanZyl wrote:Another (related) newbie question I've not been able to find an answer Googling or reading the DFS manuals;

A friend brought me some BBC disks. I believe they're 40-track.

I can *CAT them but cannot load a program. I assume the catalog is on track 0 for both drive types?

Is this inability to load a program a function of trying to read a 40-track disk on a 80-track drive? And, if so, is there a workaround or a simple command I'm missing?
As jgharston suggests, you need to persuade the 80-track drive to double-step in order to read a 40-track disk in an 80-track drive. There are a three possible methods:
  • A drive that has a physical "40/80" switch to change it's step method.
  • A small circuit in between the beeb and drive that sends two step pulses to the drive for every one it receives from the beeb
  • Software or floppy drive controller that issues two step pulses to the drive when required.
Later controller chips and/or filing systems can do the doublestep for you, but the 8271/DFS 1.20 combo you have (as well as myself) doesn't offer it.

To give a longer explanation of how your disks and drive are currently behaving:

An 80-track drive can step to any one of 80 tracks, 0 to 79. 40-track diskettes only have tracks 0-39, but they are twice as far apart. Because these 40 or 80 tracks fit in the same physical space on the disk, the read/write head on an 80-track drive is effectively half as wide, in order to double the number of tracks. Track 0 will be in the same location on both types of drive, so you will be able to read track 0 (disk catalog - *CAT) of a 40-track disk on an 80 track drive.

The physical location of tracks 0,1,2,3... of a 40-track disk correspond to tracks 0,2,4,6... for an 80-track drive. So if the disk catalog says SOMEFILE is on track 3 of a 40-track disk, an 80-track drive will take three single steps and end up trying to read in between tracks 1 and 2 of the 40-track disk.

When you format a disk as 40-track in an 80-track drive without doublestepping, you're only formatting the first half of the diskette. If you open your drive you could see this from how far the read/write head moves across the disk.

These examples show how the different combinations line up with each other:

Code: Select all

Example A:   [00][01][02][03][04][05][06] ... [37][38][39][40][41][42][ ... [74][75][76][77][78][79]

Example B: [--00--][--01--][--02--][--03- ... -][--19--][--20--][--21-- ... -37--][--38--][--39--]

Example C:   [00]    [01]    [02]    [03] ...     [19]    [20]    [21]  ...     [38]    [39]

Example D:   [00][01][02][03][04][05][06] ... [37][38][39]
Example A: Track layout of an 80-track disk formatted in an 80-track drive
Example B: Track layout of a 40-track disk formatted in a 40-track drive
Example C: Track layout of a 40-track disk formatted in an 80-track drive with correct doublestepping
Example D: Track layout of a 40-track disk incorrectly formatted in an 80-track drive with no doublestepping.

As you can see, example C is compatible with example B, but Example D isn't.
Pudsey - BBC Model B 32k issue 7, Sidewise ROM board with 16K RAM
Archimedes 420/1 upgraded to 4MB RAM (mid- restoration)

JannievanZyl
Posts: 188
Joined: Sat Feb 11, 2017 8:56 pm
Location: Cape Town, South Africa
Contact:

Re: BASIC Disk Format

Post by JannievanZyl » Mon Jan 08, 2018 12:27 pm

Kazzie wrote: As jgharston suggests, you need to persuade the 80-track drive to double-step in order to read a 40-track disk in an 80-track drive. There are a three possible methods:
  • A drive that has a physical "40/80" switch to change it's step method.
  • A small circuit in between the beeb and drive that sends two step pulses to the drive for every one it receives from the beeb
  • Software or floppy drive controller that issues two step pulses to the drive when required.
Later controller chips and/or filing systems can do the doublestep for you, but the 8271/DFS 1.20 combo you have (as well as myself) doesn't offer it.
Thanks Kazzie!

I understand the difference between the different formats but was hoping that Track-0 would identify the disk as either a 100KB or 200KB formatted disk and automatically do the double-step or not.

The drives I've got are the 80-track, double-side units in the Z80 Torch Pack: http://chrisacorns.computinghistory.org ... cpack.html

Would an upgrade to a 1770 controller and ADFS be a solution?

Kazzie
Posts: 93
Joined: Sun Oct 15, 2017 7:10 pm
Location: North Wales
Contact:

Re: BASIC Disk Format

Post by Kazzie » Mon Jan 08, 2018 2:03 pm

JannievanZyl wrote:Thanks Kazzie!

I understand the difference between the different formats but was hoping that Track-0 would identify the disk as either a 100KB or 200KB formatted disk and automatically do the double-step or not.

The drives I've got are the 80-track, double-side units in the Z80 Torch Pack: http://chrisacorns.computinghistory.org ... cpack.html

Would an upgrade to a 1770 controller and ADFS be a solution?
The upgraded DFS 2.x supplied by Acorn for use with the 1770 supports doublestepping, but there are also third party DFSes for the 8271 that provide the funcionality, including Watford DFS. (See the advice I was given by number of people at the end of this thread.) You don't need to leap all the way to ADFS to get this to work.
Pudsey - BBC Model B 32k issue 7, Sidewise ROM board with 16K RAM
Archimedes 420/1 upgraded to 4MB RAM (mid- restoration)

User avatar
danielj
Posts: 6269
Joined: Thu Oct 02, 2008 4:51 pm
Location: Manchester
Contact:

Re: BASIC Disk Format

Post by danielj » Mon Jan 08, 2018 2:20 pm

You also don't really want to be writing 40 track discs in 80 track drives :( The double stepping is really a solution for reading, not for writing. :?

d.

Kazzie
Posts: 93
Joined: Sun Oct 15, 2017 7:10 pm
Location: North Wales
Contact:

Re: BASIC Disk Format

Post by Kazzie » Mon Jan 08, 2018 7:59 pm

danielj wrote:You also don't really want to be writing 40 track discs in 80 track drives :( The double stepping is really a solution for reading, not for writing. :?

d.
Overwriting a 40-track disk in an 80 track drive (which was originally written with a 40-track head) is not a good idea if you want to read it later in a 40-track drive, as its wide head will pick up the narrow 80-track data and some of the old wide 40-track data either side at the same time, and give read errors.

Writing to a 40-track-formatted disk in an 80-track drive is fine if it'll only be used in 80-track drives henceforth. Likewise you can write doublestepped 80-track data to a new (or bulk erased) disk and use it in a 40-track drive with no issues. It's the going back and forth writing with different head widths that leads to trouble.
Pudsey - BBC Model B 32k issue 7, Sidewise ROM board with 16K RAM
Archimedes 420/1 upgraded to 4MB RAM (mid- restoration)

JannievanZyl
Posts: 188
Joined: Sat Feb 11, 2017 8:56 pm
Location: Cape Town, South Africa
Contact:

Re: BASIC Disk Format

Post by JannievanZyl » Mon Jan 08, 2018 8:08 pm

danielj wrote:You also don't really want to be writing 40 track discs in 80 track drives :( The double stepping is really a solution for reading, not for writing. :?

d.
Agree, the physical differences in head size and writing current does not make it a great idea to format 40 track disks in an 80 track drive.

I mostly need it for reading existing 40 track disks.

JannievanZyl
Posts: 188
Joined: Sat Feb 11, 2017 8:56 pm
Location: Cape Town, South Africa
Contact:

Re: BASIC Disk Format

Post by JannievanZyl » Mon Jan 08, 2018 8:12 pm

BTW, Mark is sending me some ADT ROMs, would these provide a 4-track Read ability in the 80-track drives?

User avatar
CMcDougall
Posts: 6093
Joined: Wed Feb 02, 2005 3:13 pm
Location: Shadow in a Valley of Scotland
Contact:

Re: BASIC Disk Format

Post by CMcDougall » Mon Jan 08, 2018 8:28 pm

^no, the ADT rom just gives you the *FORM 80(/40) 0 2 1 3 command, so no more typing in your basic prog.

IF you have a 1770FDC (which you dont, hence no *FORM) you could then use *DRIVE 0 40 in DFS2.2x (forces to read a 40T disc in a 80T drive (never used myself, as all my drives have a 40/80 switch at back))
ImageImageImage

crj
Posts: 834
Joined: Thu May 02, 2013 4:58 pm
Contact:

Re: BASIC Disk Format

Post by crj » Tue Jan 09, 2018 1:43 am

A slight digression, but something I've often wondered is whether track N on an 40-track floppy is centred on track 2N of an 80-track floppy, smearing into tracks 2N-1 and 2N+1, or whether it's centred between tracks 2N and 2N+1.

I get the impression the situation is the former, even though the latter would seem to make more sense. But if track N of a 40-track floppy is centred between 2N and 2N+1 of an 80-track floppy, maybe it's possible to do a better job of writing to them with an 80-track drive by performing track-at-once writing twice over?

Kazzie
Posts: 93
Joined: Sun Oct 15, 2017 7:10 pm
Location: North Wales
Contact:

Re: BASIC Disk Format

Post by Kazzie » Tue Jan 09, 2018 7:10 am

Track 0 is located at the same place in either format, as it's location is determined by the drive's track 0 sensor. (Hence why you can read the catalog of a 40-track disk in an 80-only drive.) So it's the former, rather than the latter.

There could be some mileage in erasing odd tracks either side after writing to an even track in an 80-track drive writing to a 40-track disk, but I haven't given it a awful lot of thought. It seems to me that someone would have done this if it did improve things significantly. There's also the time penalty in writing three tracks.

Or maybe a disk-at-once method of rewriting all the even tracks, and erasing the odd tracks, to make the disk “safe” before handing it back to a 40-track drive?
Pudsey - BBC Model B 32k issue 7, Sidewise ROM board with 16K RAM
Archimedes 420/1 upgraded to 4MB RAM (mid- restoration)

User avatar
danielj
Posts: 6269
Joined: Thu Oct 02, 2008 4:51 pm
Location: Manchester
Contact:

Re: BASIC Disk Format

Post by danielj » Tue Jan 09, 2018 7:52 am

That's how the kryoflux does it, it does reduce crosstalk but it's no real substitute for throughly degaussing the disk beforehand.

d.

crj
Posts: 834
Joined: Thu May 02, 2013 4:58 pm
Contact:

Re: BASIC Disk Format

Post by crj » Tue Jan 09, 2018 8:40 am

Kazzie wrote:(Hence why you can read the catalog of a 40-track disk in an 80-only drive.)
To be fair, that would also be the case if 40-track track 0 spanned 80-track tracks 0 and 1.

Also, there's no inherent reason why the track 0 sensor needs to be aligned identically in 40-track and 80-track drives.

Also also, doesn't this way mean discs actually have to be 80.5-track to accommodate the "spillage" of 40-track track 0?

User avatar
danielj
Posts: 6269
Joined: Thu Oct 02, 2008 4:51 pm
Location: Manchester
Contact:

Re: BASIC Disk Format

Post by danielj » Tue Jan 09, 2018 10:02 am

I can get my 80 track 5.25" drive to go up to track 82... :) My 3.5" does 84...

d.

duikkie
Posts: 2867
Joined: Fri Feb 07, 2014 3:28 pm
Contact:

Re: BASIC Disk Format

Post by duikkie » Tue Jan 09, 2018 10:28 am

you can hamer your discdriveto be an alarm bell , repeat seek 0 , seek 100 until your awake :)
danielj wrote:I can get my 80 track 5.25" drive to go up to track 82... :) My 3.5" does 84...

d.

Kazzie
Posts: 93
Joined: Sun Oct 15, 2017 7:10 pm
Location: North Wales
Contact:

Re: BASIC Disk Format

Post by Kazzie » Tue Jan 09, 2018 12:18 pm

crj wrote:
Kazzie wrote:(Hence why you can read the catalog of a 40-track disk in an 80-only drive.)
To be fair, that would also be the case if 40-track track 0 spanned 80-track tracks 0 and 1.

Also, there's no inherent reason why the track 0 sensor needs to be aligned identically in 40-track and 80-track drives.

Also also, doesn't this way mean discs actually have to be 80.5-track to accommodate the "spillage" of 40-track track 0?
For the "spillage" beyond 80 tracks, the whole surface of the disk is magnetic, it doesn't stop suddenly after track 80's position. At an 80-track drive's 96 tracks per inch, it's just an extra 0.26mm toward the spindle.

What I failed to recall last night is that floppy drive heads use tunnel erasure to stop tracks from spilling over each other:
Image

As the head moves over the disk, after the write head writes data to the disk the tunnel erase heads erase the overspill either side of the track. As a result, the data tracks have significant empty space between them - something I didn't illustrate well in my diagrams last night.

Because of this, 40-track and 80-track layouts have to be centre-aligned to be mutually readable. If 40-tracks were centred in between two adjacent 80-tracks, you'd be reading the empty space in between tracks when you swapped drives. (The centre of the track is most important for reading, as magnetic field strength decreases with distance.)
Pudsey - BBC Model B 32k issue 7, Sidewise ROM board with 16K RAM
Archimedes 420/1 upgraded to 4MB RAM (mid- restoration)

crj
Posts: 834
Joined: Thu May 02, 2013 4:58 pm
Contact:

Re: BASIC Disk Format

Post by crj » Wed Jan 10, 2018 1:04 am

Interesting, thanks!

Back in the day, this was sufficiently advanced technology and felt like magic. And then it was obsolete before I was in a position to learn such details so I never got around to it. (-8

One thing I do vividly remember: while most drives used an optical sensor for the write-protect notch, a very few had a mechanical sensor. One day, a friend trashed an important floppy they'd brought in to school from home, because they'd used (clear) Sellotape to write-protect it. Whoops!

Post Reply