von Dietrich » Di 20. Sep 2011, 21:47
Nächste Runde (ist auch diesmal nur ein Auszug):
Lee hat geschrieben:Or to put it more accurately, the type byte value should be the count of extra VTOC sectors used plus 2. With an exception made for the DSDD disk. All in a vain attempt to maintain a 'status quo' that is simply WRONG - it will be corrected in future versions - this is NOT negotiable - it's a bug that must be eradicated and it will be. Even if the existing formula makes sense to you, ramdisks often have the wrong VTOC, why is this acceptable to anyone?
Dietrich hat geschrieben:No, the VTOC of ramdisks is also correct. I tested some ramdisks including 1024K and 1008K. I tested also 360K-DD, 720K-DD, 2MB-SD, 2MB-DD and 16MD-DD ATR images and in all cases the type byte is the number of VTOC blocks + 2 (remember: a VTOC block has 256 bytes, i.e. 1 DD sector resp. 2 SD sectors).
Lee hat geschrieben:According only to your formula - but I don't care the slightest bit about that. I only care about stopping unpredictable overallocation of sectors that will cause problems with exact floppy disk size emulated ramdisks for the moment. Other huge ramdisks of the future will require exact allocations as well.
Hrm, the "overallocation" is precisely predictable: In SD one VTOC sector is unused if and only if #sectors+81 > 2048 and (#sectors+81) mod 2048 < 1024. So on SD disks/ramdisks smaller than 1968 sectors there is no wasted VTOC sector. Where is the problem with exact floppy disk size emulated ramdisks? Please provide a reproducable step by step example, where MyDOS fails due to a "wrong" type byte! Then I'll examine it.
Remark: The "overallocation" of course does not change the total size of disks/ramdisks, i.e. a disk/ramdisk defined with 720 sectors is always 720 sectors, not 719 or 721 or something else.
Lee hat geschrieben:Fill the ramdisk up and look at it again, with normal MyDOS often there will be a wasted sector - how is an exact 720 sector disk supposed to exist starting with the wrong VTOC data? Short answer is, it can't. So the current situation is untenable.
Dietrich hat geschrieben:Yes, 1 VTOC sector is wasted on SD disks/ramdisks if (#sectors+80) mod 2048 < 1024 (explanation see below), but this is intended and not a bug! Whether 1 SD sector is wasted or not, is of course no problem since there are lots of free sectors on a disk.
Lee hat geschrieben:I could care less about the ramdisk space lost - I care only because my 90K emulated floppy ramdisk won't behave as a real one if it's only got 719 sectors. Or worse 721 sectors or sometimes 722. It must run out at 720 EXACTLY.
It IS exactly 720 sectors, I tested it with custom Ramdisks. So where is the problem/bug? Do you have a reproducable example where this is not the case? Or are you only assuming that there is a bug?
Lee hat geschrieben:The munge provides for the 360K disk to work correctly - that's it's original purpose and it works, of course. And to your exact formula - but that doesn't mean it's right. The concept doesn't fit the formula, but the 360K disk does.
Look at the code of MyDOS and you'll find that my formula fits to the code. And forget the comments, there is a lot of nonsense in there, see the examples below. Where do you have the idea from that the type byte must be the number of extra VTOC sectors plus two?
Lee hat geschrieben:I have to make an exception for it in beta5 because otherwise MyDOS wants to allocate two VTOC sectors as being used when there is only the one. Marslett had the same problem until the put the munge into the wrong place and got all DD VTOCs with one extra digit for a type byte. The purpose of the munge is so that Marslett didn't have to write in an exception into the source code like I had to for it to allocate only one extra VTOC sector instead of two extra.
There is "no munge in the wrong place", the code is OK. According to the current MyDOS code, Marslett counts VTOC usage in blocks of 256 bytes, not sectors. This is no bug!
Lee hat geschrieben:It doesn't matter to him if all DD VTOCs are overcounted by one because of it since he is reading/writing VTOCs in pairs anyway - and then this is also the source of overallocation of only some SD ramdisks at unpredicable places as we reserve more and more banks for other purposes. But this is total ruination for my emulated floppy ramdisk(s). MyDOS deserves to have one or as many as wanted. With mixed densities and sizes as well.
No, DD VTOCs aren't overcounted by one. They have the correct size and correct type byte! And VTOCs are read/written in pairs only in SD, not in DD. And every ramdisk has exact the size it is defined, MyDOS doesn't access RAM outside the ramdisk! I wonder if you really tested your statements?
Lee hat geschrieben:... with one glaring exception, the 360K DSDD disk, it has one VTOC but still is a type 3 disk because it's 1,440 sector count is higher than 10 bits can convey which is 1,023 sectors. And that just doesn't fit a simple formula. Even if you've got one pretty darn close.
OK, this might be interesting for others: MyDOS operates on disks/ramdisks in two modes:
a) ATARI mode: If a disk/ramdisk has less than 1024 sectors and needs only one VTOC sector (SD: less than 944 secs, DD: less then 1024 secs), MyDOS uses ATARI mode: There is only one VTOC sector and MyDOS stores files with filenumbers and 10 bit sector links in the data sectors as DOS 2.x does. These files can be accessed by DOS 2.x. The VTOC type byte of such disks/ramdisks is always 2. Examples: 90K-SD, 180K-DD
b) MyDOS mode: Otherwise MyDOS uses MyDOS mode: There may be more than 1 VTOC sector and MyDOS stores files without filenumbers in its data sectors and uses 16 bit sector links. To distinguish these files from DOS 2.x files, MyDOS sets bit 2 in the file type byte. The VTOC type byte is the number of VTOC blocks (256 byte each) plus 2 - thus at least 3. All VTOC blocks are allocated from sector 360 downwards. Examples:
- 130K-SD (=ED) has 1 VTOC block, i.e. 2 VTOC sectors
- 360K-DD has 1 VTOC block, i.e. 1 VTOC sector
- 1024K-SD (1MB-Ramdisk) has 5 VTOC blocks, i.e. 10 VTOC sectors (one is unused)
Lee hat geschrieben:A Ramdisk with $3f banks has seven 'extra' VTOC sectors reserved which is exactly right. The type byte is 6 but should be 9 which means by rights, 16 banks are not going to be ever used since MyDOS will run out of VTOCs to look at 2 VTOC sectors too soon?
Dietrich hat geschrieben:A Ramdisk with $3f banks has 16 KB = 128 SD sectors less than a $40-Ramdisk, i.e. 8192-128 = 8064 sectors. So there are only 4 VTOC blocks needed, giving a type byte of 4+2=6. Furthermore, MyDOS does not run out of VTOC sectors while filling the ramdisk, I just tested it by completely filling the ramdisk. So the type byte and the MyDOS VTOC is OK.
Lee hat geschrieben:But I haven't tested to the depth that I'd like, so I can't say it does or doesn't just yet - either the old math or the new math version. Does MyDOS use the last data sector before the VTOC string and start flipping bits in the file data sectors? Can we make it do that? Scary stuff if it did. Did you look specifically for that? I never have.
No, MyDOS does not use the data sectors before the VTOC sectors, I tested it. There is really no bug in MyDOS concerning the type byte. Or did you find one? If yes, please provide a reproducable example, where MyDOS fails due to the type byte!
Lee hat geschrieben:For my needs, the VTOC overallocation of large SD disks is a bug that needs fixing and it will destroy your formula and it's workings - sorry. But not really, if it gets me a better MyDOS. Granted one that I can NOT mix hard drives with older versions at all, perhaps only in read only mode if that's possible?
As I already said, there is no bug with the type byte. See also my comments in the source below. But if you really want to change the type byte, you can set it e.g. to 128+x, which is currently not used by any MyDOS disk/ramdisk. Thus a check would be very easy.
Lee hat geschrieben:current mydos source
MAPBUF has already been loaded with the default value of 2 for a DOS 2.0s type byte starting value
SHORTS
JSR FNDBIT ; FIND LAST BIT MAP SECTOR
LDA TMP2
BNE GT246 ; IF PAST 256TH MAP BYTE
BIT DLINK ; SINGLE DENSITY?
BMI FDBDEN
CPY #0
BPL FDBDEN
The 'munge' is this part:
GT246
STA MAP2
CLC
ADC #3
STA MAPBUF
FDBDEN
which is setting up the wrong type byte
The comments here are very misleading. Here are my corrections:
SHORTS
JSR FNDBIT ; get index of last sector in the VTOC into y/tmp2 (low/high)
LDA TMP2 ; high byte
BNE GT246 ; not zero, i.e. VTOC is longer than 256 byte (incl. header)
; zero, i.e. VTOC has max. 256 bytes
BIT DLINK ; 125=SD, 253=DD
BMI FDBDEN ; Double density -> 1 VTOC sector needed -> use DOS 2.0 mode
CPY #0 ; low byte
BPL FDBDEN ; SD and VTOC is max. 127 bytes -> 1 VTOC sector needed -> use DOS 2.0 mode
GT246 ; more than 1 VTOC sector needed
STA MAP2 ; high byte of index of last sector in the VTOC = number of VTOC pages above one
CLC
ADC #3 ; +3
STA MAPBUF ; = number of VTOC pages plus 2 (fits again to my formula)
FDBDEN
Lee hat geschrieben:combined with this part:
LDA MAPBUF
SEC
SBC #2 ; GET NUMBER OF SECTORS
BIT DLINK ; (SINGLE DENSITY?)
BMI MPNSD ; IF NOT, M-3
ASL A ; IF SO, M*2-5
MPNSD
which is preparing to over allocate (some) SD VTOC sectors
Where is the minus 5 BTW? Or is that minus 2 times 2 then minus some x amount of change in your pocket? It seems to be minus 3 in the real world only for large SD but I've not checked every possible set up or size to verify that. I don't see where your formula fits M*2-5 but it's not a sticking point for me anyway.
In this case, the comments are simply nonsense. Here are my corrections:
LDA MAPBUF ; number of VTOC pages plus 2
SEC
SBC #2 ; number of VTOC pages
BIT DLINK ; 125=SD, 253=DD
BMI MPNSD ; Double density -> number of VTOC sectors (256 bytes each) = number of VTOC pages
ASL A ; Single density -> number of VTOC sectors (128 bytes each) = number of VTOC pages * 2
MPNSD
With these comments the code fits perfectly in my formula. In all cases the type byte is number of VTOC pages + 2 (for MyDOS type disks). There is no "munge in the wrong place".
OK, in some cases on SD disks the VTOC is one sector longer than really needed, but this happens only if you have at least 1968 SD sectors. So why do you bother if you have e.g. 1951 free sectors or 1950 free sectors? Yes, it's not perfect, but it really doesn't matter! If you change the type byte your new MyDOS will be incompatible to the 20 years used MyDOS 4.53 and thus later problems are predictable. Is an extra free sector (in some cases) worth this trouble?
I suppose, the comments in the current MyDOS source were added later by someone who tried to understand the code, but he failed obviously. Forget the comments (or take mine), look only at the code without using any assumptions about the type byte!