6809 and FLEX

discussion of beeb/electron applications, languages, utils and educational s/w
User avatar
jgharston
Posts: 2726
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield

Re: 6809 and FLEX

Postby jgharston » Thu Feb 05, 2015 9:56 pm

RobC wrote:I've stuck to the Flex format of having the first 10 sectors on side 0 and the next 10 sectors on side 1.
This change to the disk access code makes it do interleaved access:

Code: Select all

   LDX  #0
DISKTRAK:
   LEAX 1,X
   SUBD #20
   BCC  DISKTRAK      ; Sub loop to divide D by 20
   LEAX -1,X      ; X=track
   ADDD #20      ; D=B=sector, A=0
   CMPB #10
   BCS  DISKSIDE0      ; Track 0-79 are size 0
   ADDA #2         ; A=2 for side 1
   SUBB #10      ; Reduce sector number
DISKSIDE0:
I'm sure that when I'm less tired I can make a cogent argument to use sequential access for Flex disks to be used with the BBC, to match all the other BBC filing systems.

Eg, interleaved disks means it's harder to use single-sided disks - though with Flex it's a lot easier than other systems as all disk sectors are in a linked chain, so you just skip half the sectors in the sector chain - eg ..6-7-8-9-20-21-22... instead of 6-7-8-9-10-11-12-etc. As long as disk addresses 0 (bootblock) to 5 (start of root) are on track 0 side 0, the sector chain can launch off where-ever it wants to go.

Code: Select all

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

RobC
Posts: 1774
Joined: Sat Sep 01, 2007 9:41 pm

Re: 6809 and FLEX

Postby RobC » Fri Feb 06, 2015 7:13 am

I am wondering whether sticking to the Beeb way of doing things might be better. I originally went down the Flex route as that's what OmniFlop does but I now suspect that OmniFlop doesn't handle track 0 properly...

It looks like OmniFlop writes logical sector ids of 1-10 for every track (or 1-20 for double-sided disks as the sector ids on side 1 start at 11 not 1). I think this is correct for all tracks except track 0 as that should have a sector 0 but no sector 1.

[This also has implications for the BBC boot disk but I think that can be dealt with as a special case.]

I'm happy to open this up for wider discussion and go with the consensus.

I'll also mail Jason Wotton to verify what I suspect OmniFlop is doing.

Thanks again,

Rob

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

Re: 6809 and FLEX

Postby danielj » Fri Feb 06, 2015 8:11 am

Rob, it should be quite easy to get the beeb to write flex disks from images no matter what format you decide. It'd be better in my mind to be able to write most of the existing disk images directly without having to reformat them. Plus it's "truer" to the original OS. Omniflop should be easy to rejig for its author, and worrying about single sided users is perhaps something that was an issue in the 80s, but I suspect given the base of about 40 beebs that will be able to run this, it's a non-issue now :) my 2p anyway.

d.

(and yes, Track 0 should be 0,1,3... Sector-wise)

And another 2p whilst I think of it, and these things are marginal - the interleaved format is always going to result in quicker loading times as there will be less track-track movements for the drive, given that a file can occupy 20 sectors before the drive head has to move instead of 10. Apart from giving single sided drives the ability to read half the disc, I honestly can't see any advantage to a sequential format.

*dives for cover*

RobC
Posts: 1774
Joined: Sat Sep 01, 2007 9:41 pm

Re: 6809 and FLEX

Postby RobC » Fri Feb 06, 2015 9:12 pm

Thanks Daniel.

I'll knock up a format routine on the Beeb and see if I can get the boot sector code going.

I think I've sorted out most of the Flex configuration issues now so should be able to release an image once it's working.

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

Re: 6809 and FLEX

Postby jgharston » Sun Feb 08, 2015 9:43 pm

http://mdfs.net/Software/Flex/BBC:

FlexForm / FlexForm.txt
Formats a BBC DFS-style disk and initialises a Flex filesystem on it. Does single or double sided, interleaved or sequential tracks. Only creates a blank filesystem, does not put any boot code in the first two sectors.

BBCDrive.asm
Disk driver routines to access BBC. Accesses single or double sided, interleaved or sequential tracks. It has unimplemented bits of code for double-density and for declared logical track sizes different from physical track sizes. That is, a Flex filesystem stored on a 10-sector DFS-style disk with the filesystem claiming it uses track sizes larger than ten sectors.

A Flex disk image can be copied to a physical disk with, for example, ImgToDisk or similar. An image that claims to have 10 sectors per track should be written as a sequential or single-sided disk (eg -size 200K), an image claiming to have 20 sectors per track should be written as interleaved or double-sided (eg -size 400K Q0)

At the moment, the drivers only support 10 sectors per track (single sided) or 20 sectors per track (double sided) on a DFS-style disk (sectors count up from 0). Another day working at Sellafield next week, so I'll take the laptop and do some more coding.

Code: Select all

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

RobC
Posts: 1774
Joined: Sat Sep 01, 2007 9:41 pm

Re: 6809 and FLEX

Postby RobC » Mon Feb 09, 2015 8:01 am

Hi JGH,

For the moment, I've gone with FLEX style disks so sectors 1-10 not 0-9.

I've got a routine that formats a disk so that track 0 has sectors 0,1, and 3-10 and have working boot code for sector 0.

I've also got a routine that will transfer a FLEX disk created with OmniFlop to my system disk.

However, I think we need to decide which format to go with as there's no point in having two approaches to this. :D

Cheers,

Rob

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

Re: 6809 and FLEX

Postby danielj » Mon Feb 09, 2015 9:54 am

Rob, you're doing the converting so ultimately you can make the decision :D Sticking with the flex format means that in the rather unlikely event anyone ever tried to use a "BeebFLEX" disk on another FLEX system, it'd work.

It's ultimately all fairly academic in the great scheme of things :D

Just out of interest, what's the sector layout on side 1 track 0? Same as side 0? I'd assume it'd have to be...


d.

RobC
Posts: 1774
Joined: Sat Sep 01, 2007 9:41 pm

Re: 6809 and FLEX

Postby RobC » Mon Feb 09, 2015 11:35 am

Thanks Daniel.

The advantage of JGH's approach is that we don't need to make special measures to get DFS to boot the disk. The disk has sectors 0 and 1 on track 0 so DFS will be happy to boot it.

It does mean that genuine FLEX disks can't be used with the system but how likely are we to come across those?

Currently, I've got the disk drivers setup to use the FLEX standard. This means a fair amount of jumping through hoops to get the boot disk in a bespoke format. However, I have written software to do this and have now got FLEX booting off a single disk which is recognised by both DFS and FLEX.

As you say, it's all pretty academic. For me, the only real concern is how easy is it to get FLEX software on the Beeb. Maybe I'll incorporate JGH's drivers and compare both approaches.

I believe the layout of track 0 on side 1 is the same as all other tracks on side 1 so the sectors go: 11,13,15,17,19,12,14,16,18 & 20.

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

Re: 6809 and FLEX

Postby danielj » Mon Feb 09, 2015 12:04 pm

Does FLEX use the physical sector numbers on the track, or does it apply "logical" ones? If it just uses logical numbers then for the most part unless you're sharing disks between systems, then it probably does make more sense to use the 0-9 numbering.. The advantage of using 0-9 sector numbering is that we can use all of the existing utilities on the beeb to write the disc images.

If, on the other hand, FLEX needs to use physical sector numbers > 10 on the other side of the disc, the standard beeb tools aren't going to be able to write things. I guess this can all be sorted out in the drivers though?

d.

RobC
Posts: 1774
Joined: Sat Sep 01, 2007 9:41 pm

Re: 6809 and FLEX

Postby RobC » Mon Feb 09, 2015 12:50 pm

Flex is using logical sectors. As you say though, the drivers can take care of this (and the code JGH posted does).

RobC
Posts: 1774
Joined: Sat Sep 01, 2007 9:41 pm

Re: 6809 and FLEX

Postby RobC » Mon Feb 09, 2015 3:03 pm

I've updated my drivers to use sectors 0-9. The attached .dsd file is a bootable FLEX system disk. You'll need to be using v0.25 (or later) of the 6809 co-pro.

It should be written to a double-sided 80-track disk and should be used in drive 0.

For some reason, SHIFT-BREAK doesn't work for me even though *RUN !BOOT does work and *. reports "option 2 (run)". Not sure if this is a problem with the way I've setup the catalogue or if it's a hardware issue. *FLEX will also boot FLEX.

I've added a load of FLEX commands but haven't tested all of them. There are also a few commands to work with the Beeb's VDU system: MODE, BCOL and FCOL. They're fairly self-explanatory :D

As this uses sectors 0-9, FLEX .dsk images need to written to disk as .ssd or .dsd files (i.e. using the normal Beeb conventions).

I'll do some more testing and look at writing a NEWDISK routine soon.
Attachments
BBCFLEX4.zip
BBC FLEX boot disk
(84.86 KiB) Downloaded 42 times

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

Re: 6809 and FLEX

Postby danielj » Mon Feb 09, 2015 3:31 pm

Rob, is that sequential or interleaved?

d.

edit: ignore me...

RobC
Posts: 1774
Joined: Sat Sep 01, 2007 9:41 pm

Re: 6809 and FLEX

Postby RobC » Mon Feb 09, 2015 3:36 pm

Interleaved - i.e. track 0 side 0, track 0 side 1...

OmniFlop writes it correctly. (I can hack it to be sequential if required...)

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

Re: 6809 and FLEX

Postby danielj » Mon Feb 09, 2015 3:57 pm

And lo! It works! :D =D>

Adventure loads and runs. It's a touch slow loading, is that to be expected?

d.

RobC
Posts: 1774
Joined: Sat Sep 01, 2007 9:41 pm

Re: 6809 and FLEX

Postby RobC » Mon Feb 09, 2015 4:50 pm

I suspect it maybe the sector ordering issue you mentioned earlier in the thread.

I'll check the disk layout in ADI and I'll compare the load times with the FLEX format version.

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

Re: 6809 and FLEX

Postby danielj » Mon Feb 09, 2015 5:01 pm

I wrote the discs with the datacentre, so I'm assuming it orders the sectors correctly when it writes out the disc. It might just be that Adventure's fairly large, or just the way FLEX drives floppies isn't very efficient?

Well done though, excellent work - it's fab seeing these archaic things suddenly coming back to life. It really is [like] stepping back into the past.

d.

RobC
Posts: 1774
Joined: Sat Sep 01, 2007 9:41 pm

Re: 6809 and FLEX

Postby RobC » Mon Feb 09, 2015 5:09 pm

Thanks for all your encouragement - I wouldn't have got it done nearly as quickly if you hadn't pointed me in Jerry Davis's direction!

I'll have a look at creating the disk with DC and will compare it to what OmniFlop does. I've also got a routine that will format tracks to whatever sector order I choose so I can do some experimenting...

I've wanted to get FLEX up and running on the Beeb for years - hats off to the guys that did the work on the matchbox co-pro for making it possible. :D

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

Re: 6809 and FLEX

Postby jgharston » Mon Feb 09, 2015 8:31 pm

I've only skimmed the above posts at the mo...

At lunchtime today I updated the drivers to be capable of using disks with sec0 as either 0 or 1, I'll type it up in the few hours. It also has a more flexible format detection, and allows a disk to hold a filesystem that has a different number of logical sectors/track to the number of physical sectors/track on the disk. (Eg, if the filesystem uses 18-sector tracks (like the Dragon), it will transparently recalculate so each logical track is 1.8 physical tracks.)

The formatting program I linked to already has a sec0% variable, so is ready to be updated to allow formatting with sec0=1.

The formatter already lets you do single or double sided, interleaved or sequential tracks:
* Tracks: 80, Sides: 2 will give you 80-track double sided interleaved
* Tracks: 80, Sides: 1 will give you 80-track single sided, and a single-sided disk can only be sequential as it is only has one side.
* Tracks: 160, Sides: 1 will give you 80-track double sided sequential, as a sequential disk is effectively just a single-sided disk that continues past the end of one side and onto the other.

Code: Select all

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

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

Re: 6809 and FLEX

Postby jgharston » Thu Feb 12, 2015 9:59 pm

Updated disk I/O drivers: http://mdfs.net/Software/Flex/BBC/

The code will access disks where sectors are counted from 1 instead of from 0, but it doesn't yet examine the disk to decide what starting sector to use, currently, physical sectors count from 0 as with DFS disks.

The code has disk density flags, but currently doesn't yet make double-density disk access calls.

danielj wrote:Just out of interest, what's the sector layout on side 1 track 0? Same as side 0? I'd assume it'd have to be...
The sectors on side 1 are numbered the same as on side 0. The logical sector numbers Flex passes to the disk drivers for an interleaved disk count the sectors on side 1 continue on from the end of side 0.

For instance, Flex would have 20 logical sector per track, logical sectors 1-10 would be physical sectors 1-10 on side 0, logical sectors 11-20 would be physical sectors 1-10 on side 1 (assuming physical sectors are numbers from 1. 0-9 and 0-9 if numbered from 0, etc.).

danielj wrote:Does FLEX use the physical sector numbers on the track, or does it apply "logical" ones?
Flex uses logical sectors counting from 1 upwards and logical tracks counting from 0 upwards. The disk drivers convert these numbers to the physical sector and track numbers on the actual disk. For instance, you could have a single-sided disk with 20 logical sectors per track, but 10 physical sectors per track, so then logical track 0 would be physical track 0 and physical track 1, with logical sectors 1-10 being the ten physical sectors on track 0 and logical sectors 11-20 being the ten physical sectors on track 1. With appropriate drivers, the physical sector numbering can be anything, 0-9, 1-10, even &41-&4A and &C1-&CA as with the Amstrad CPC.

danielj wrote:Adventure loads and runs. It's a touch slow loading, is that to be expected?
Because Flex holds all the disk sectors as a linked list, it has to load sectors one at a time as it has to read a sector to find out what the next sector it is it has to load. That means it loses any ability to optimise disk access by doing multiple-sector transfers. Disk access can be sped up with physical disks by formatting tracks with the sectors interleaved, so instead of formatting 0,1,2,3,4,5,6,7,8,9 the usual layout is to format the sectors 0,7,4,1,8,5,2,9,6,3. So, after reading sector 0 and processing it, by the time sector 1 is wanted it is about to pass the disk read head instead of it having already wizzed past and having to wait for a full disk rotation for it.

Code: Select all

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

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

Re: 6809 and FLEX

Postby jgharston » Sat Feb 14, 2015 11:04 pm

I've been working on implementing double density and hard drive access for the disk drivers, but the code may not be able to squeeze into the 512 bytes allowed. I've started to think about having a 6502.SYS file as on the 80x86 CoPro, loaded from the Flex boot disk when Flex boots and sent over to the host to hook into OSWORD to provide extra functions.

In particular, this solves the problem of accessing double-density disks where the sectors are numbered from 1 to 16 instead of 0 to 15 as the OSWORD &72 API only deals with sectors numbered 0 to 15. To access sectors numbered above 15 you need to talk directly to the hardware which is much easier from the host side where the hardware lives. Also, OSWORD &72 accesses disks sequentially (posts passim) and having all the code in the Flex drivers on the 6809 side is making the code clunky and bulky.

Code: Select all

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

RobC
Posts: 1774
Joined: Sat Sep 01, 2007 9:41 pm

Re: 6809 and FLEX

Postby RobC » Sun Feb 15, 2015 6:39 pm

That's sounds promising - I've only been thinking about single density for the moment.

I've added a NEWDISK routine to my FLEX system disk so that we can format disks under FLEX. This either takes no parameters or the drive number (0 or 1). It asks for the drive (if not given on the command line), number of tracks, double or single sided, the volume name and number.

It formats using a modified sector order so that it does 0, 2, 4, 6, 8 and then 1, 3, 5, 7 & 9. On my setup, this speeds up disk access by a factor of 2 when compared to the 0-9 approach.

The disk also includes a version of TSC Extended BASIC which seems to work correctly.

I've downloaded some software from the FLEX user group server so will be trying that out later.

Cheers,

Rob
Attachments
BBCFLEX5.zip
BBC FLEX 6809 system disk including NEWDISK + XBASIC
(134.5 KiB) Downloaded 34 times

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

Re: 6809 and FLEX

Postby jgharston » Sun Feb 15, 2015 7:41 pm

RobC wrote:I've added a NEWDISK routine to my FLEX system disk so that we can format disks under FLEX. (...)
It formats using a modified sector order so that it does 0, 2, 4, 6, 8 and then 1, 3, 5, 7 & 9. On my setup, this speeds up disk access by a factor of 2 when compared to the 0-9 approach.

Updated code at http://mdfs.net/Software/Flex/BBC/.

FlexForm will format a disk with sectors starting at 0 DFS-style or 1 Flex-style, except for track 0 which always starts with sector 0, as allowed for in the Flex disk specs. I was trying to implement sector interleaving as above, but was getting the maths wrong, so decided to post what I've got so far.

Along with 1-based sector formatting, Boot will now also boot from a disk with 0-based sector numbering or 1-based sector numbering by scanning the sector IDs to find out what they actually are. It also transparently supports interleaved or sequential track numbering as a double-sided sequential disk is just functionally a single-sided disk that continues past track 79. Again, it expects to live on a track 0 which starts at physical sector 0. I think there's enough space in the boot code to boot a double-density disk as well.

Actually, the above two bits of code will cope with sector number from any start. If you want you could use a disk formatted Amstrad DOS-stylee with base sector of 193 (&C1)!

I don't think I've done so much floppy-based work in a couple of years, and not such low-down stuff since I wrote the core floppy drivers for HADFS in 1990!

Code: Select all

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

RobC
Posts: 1774
Joined: Sat Sep 01, 2007 9:41 pm

Re: 6809 and FLEX

Postby RobC » Sun Feb 15, 2015 7:51 pm

jgharston wrote:I don't think I've done so much floppy-based work in a couple of years, and not such low-down stuff since I wrote the core floppy drivers for HADFS in 1990!

Me either - at least not since I wrote a routine to write Einstein disk images to real disks!

Apologies but I should have read your earlier post properly. I've now tried the sector order you suggested (0,7,4,1,8,5,2,9,6,3) and it's faster again by a factor of 2 on my machine. Adventure has come down from a 35 second load to a 9 second load.

I've now amended NEWDISK to follow this convention - modified disk image attached.
Attachments
BBCFLEX6.zip
BBC FLEX09 system disk with modified NEWDISK
(134.5 KiB) Downloaded 55 times

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

Re: 6809 and FLEX

Postby jgharston » Sun Feb 15, 2015 8:30 pm

RobC wrote:I've now tried the sector order you suggested (0,7,4,1,8,5,2,9,6,3) and it's faster again by a factor of 2 on my machine. Adventure has come down from a 35 second load to a 9 second load.
Wow, that's impressive - and vividly shows how inefficient Flex's disk access is where it strings sectors together in a linked list, so is forced to load each one by one.

Code: Select all

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

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

Re: 6809 and FLEX

Postby jgharston » Thu Feb 19, 2015 3:08 pm

I worked out I'd implemented CMPY #imm wrong in my 6809 emulator. Fixing that, and RobC's load-from-linked-sector disk images boot! I imported my load-linked-filename boot code and they boot as well! Hurray!
Image

Something still appears to be going wrong somewhere, though:
Image

I've done a bit of tidying and optimising to my Boot code, and am now working on importing my console code: mdfs.net/Software/Flex/BBC/.

Code: Select all

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

User avatar
roland
Posts: 2782
Joined: Thu Aug 29, 2013 8:29 pm
Location: Born (NL)
Contact:

Re: 6809 and FLEX

Postby roland » Fri Feb 20, 2015 9:13 pm

Is there any guide how to use the .dsk images as a disk drive? I still haven't figured out how I do the translation from track + sector to the offset in the dsk-file.

For SS/SD disks I can use the fomula

ptr = (track * 10 + sector - 1) * 256

except for track 0 sector 0, that's just ptr = 0 and sector 1 doesn't exist in track 0. I can use that formula also for DS/SD disks but then the multiplicand is 20 instead of 10. This is the number of sectors per track. 256 is the number of bytes per sector.

My Atom Flex wants to read disk 0, track zero, sector 5 after reading the date. That would be the disk catalog. Calculating the ptr, it would be (0 * 10 + 5 - 1) * 256 = 1024 (hex 400). And yes, that's the position where the catalog starts.

But how do I handle double density disks. In the Flex documentation they say that DD has more sectors per track. I always thought that DD had more tracks (40 vs 80). In the files I got from RobC there is an image of about 1 MB. That would be about 80 tracks with 51 sectors of 256 bytes each.

Any thoughts about that?
256K + 6502 Inside
MAN WOMAN :shock:

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

Re: 6809 and FLEX

Postby jgharston » Fri Feb 20, 2015 10:31 pm

roland wrote:Is there any guide how to use the .dsk images as a disk drive? I still haven't figured out how I do the translation from track + sector to the offset in the dsk-file.
For my emulator, I read the System Information Record (SIR) at &200 bytes into the image to get the "shape" of the disk. &226 and &227 give you the maxtrack and maxsector. Since tracks number from 0 and sectors number from 1 that is also totaltracks-1 and sectorspertrack. For physical disks I scan track 1 for sector IDs and look for the lowest and highest numbered sectors.

For a normal floppy, maxsector will be 10 or 20 for single-sided or double-sided single density disks, or 16 or 32 for SS or DS double-density disks.

Assuming your disk images are interleaved (like dsd images), the formula is them:

sec0=1:REM or the value found by scanning for sector IDs
IF track=0 THEN sec0=0
ptr = (track * maxsec + sector - sec0) * 256

roland wrote:But how do I handle double density disks. In the Flex documentation they say that DD has more sectors per track. I always thought that DD had more tracks (40 vs 80).
No, double density is more data on the track. 40vs80 is 80vs80 regardless of the data density. Density is "width" along the track, 35vs40vs78vs80 is "depth" towards and away from the spindle of the disk.

Flex uses the same single/double density format as BBCs: single density is 10 sectors of 256 bytes (like DFS), double density is 16 sectors of 256 bytes (like ADFS or DDFS). The only difference is that with native Flex disks the sectors number from 1, on BBC disks (or Flex stored on a native BBC disk) they number from 0.

On Flex you handle double density disks by changing the 10 or 20 in all your calculations to 16 or 32 - or, better, use the values read from the SIR. If maxsec>19 then you are using a double-sided disk, is maxsec<20 it is single sided. If it is a double-sided disk, if the sector requested is>=(maxec/2) then select side 1 and subtract (maxsec/2) from the requested sector number.

For instance, if maxsec=20 you are using a double-sided 10-sectors-per-track disk. If sector>10 Then side=1:sector=sector-10 Else side=0. Generalised as:

side=0
If maxsec>19 Then
If sector>(maxsec/2) Then side=1:sector=sector-(maxsec/2)
Endif

roland wrote:In the files I got from RobC there is an image of about 1 MB. That would be about 80 tracks with 51 sectors of 256 bytes each.
That is probably a High Density disk image (eg like a 1440K DOS disk). I think if you look at the SIR at &200 bytes into the image you will find it has something like 72 sectors per track, which is 36 per side, which is twice the 18 per side you would normally be the absolute maximum with a double-density disk.

Code: Select all

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

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

Re: 6809 and FLEX

Postby jgharston » Fri Feb 20, 2015 10:39 pm

This is the code my emulator uses when booting flex to find the disk shape:

Code: Select all

  905 REM           cmd    addr    d s t s n
  910 A%=FNfdc_disk(&53,mem%+&C100,0,0,0,2,1):REM Load System Info Record
  920 d_free%=256*mem%?&C121+mem%?&C122      :REM Number of free sectors
  930 d_trk%=mem%?&C126                      :REM tracks_per_side-1
  940 d_sec%=mem%?&C127                      :REM sectors_per_logical_track
  950 IF d_sec%>19:d_sid%=2 ELSE d_sid%=1    :REM number of sides
  960 d_num%=d_sec% DIV d_sid%               :REM sectors_per_physical_track
  970 d_size% =(d_trk%+1)*d_sec%             :REM Disk size in sectors
  980 d_used%=d_size%-d_free%                :REM Number of used sectors
  990 mem%?&C11B=13:d_title$=FNs($(mem%+&C110))
 1000 PRINT"System Information Record for ";d_title$;":"
 1010 PRINT"Disk shape:";FNd(d_trk%+1,5);" tracks       ";FNd(d_sec%,3);" sectors   ";d_sid%;" sides"
 1020 PRINT"Disk used: ";FNd(d_used%,5);" sectors ";FNd(d_used%*256,8);" bytes ";FNd(d_used%/4,5);"K"
 1030 PRINT"Disk free: ";FNd(d_free%,5);" sectors ";FNd(d_free%*256,8);" bytes ";FNd(d_free%/4,5);"K"
 1040 PRINT"Disk size: ";FNd(d_size%,5);" sectors ";FNd(d_size%*256,8);" bytes ";FNd(d_size%/4,5);"K"
 1050
Edit: added some REMs

Code: Select all

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

RobC
Posts: 1774
Joined: Sat Sep 01, 2007 9:41 pm

Re: 6809 and FLEX

Postby RobC » Sat Feb 21, 2015 5:21 pm

roland wrote:But how do I handle double density disks. In the Flex documentation they say that DD has more sectors per track. I always thought that DD had more tracks (40 vs 80). In the files I got from RobC there is an image of about 1 MB. That would be about 80 tracks with 51 sectors of 256 bytes each.

Any thoughts about that?

Hi Roland,

I wouldn't worry too much about this. There isn't really a standard disk size/layout for FLEX as users were meant to write their own disk drivers. So, they could do whatever they wanted according to their own hardware.

The FloppyMaint.zip file I posted earlier in this thread will allow you to convert between FLEX disk formats as you can export files from one disk image to another.

So, if you wish, you can choose a layout that suits you and then use FloppyMaint to create a DSK file in the right format.

Best wishes,

Rob

User avatar
roland
Posts: 2782
Joined: Thu Aug 29, 2013 8:29 pm
Location: Born (NL)
Contact:

Re: 6809 and FLEX

Postby roland » Sat Feb 21, 2015 7:03 pm

Thanks Jonathan and Rob,

Both approaches are worth investigating. Or maybe using both. Using the information in the SIR will make my system more compatible with other images (although I don't expect many more to follow) but using my own layout would give me the opportunity to build an image with 256 tracks, 256 sectors per track and 256 bytes per sector, totalling of 16 MB => an emulated harddisk 8) That would eliminate the need for a (un)mount command. I just don't know how many files can be placed in the directory.

A combination is also possible, two drives and a harddisk 8)

Wish I had more free time .... =P~
256K + 6502 Inside
MAN WOMAN :shock:


Return to “software: other”

Who is online

Users browsing this forum: duikkie and 2 guests