The str_size= things seem wrong.
How it should read, for example a 1440floppy: 512, 1, 2880, freesize
512 (bytes per sector)
1 (sectors per cluster)
2880 (total sectors, ==80*18*2, 80=cylinders, 18=sectors, 2=heads)
-> total size=512*1*2880= ~1.4mb
and similar for harddisks, just that spc!=1 for them due to their size.
Constraints:
spc between 1 and 254
bps almost always 512, except for cdroms (2048 or 2352 or whatever)
total sectors between 1 and 65535
Stockholm, Sweden, Europe, Earth Interests: Old games & young women
RankModerator
Rank
Moderator
Posts
5128
Joined
2004-01-18, 04:15
Location
Stockholm, Sweden, Europe, Earth Interests: Old games & young women
sectors per cluster?? I understand the cylinders * heads * sectors per tracks => total number of sectors (80 * 2 * 18 = 2880). But why the cluster thing?
Edit: Ahh - or maybe it does. It is one thing to be able to define a disk in terms of C/H/S but it is a different thing if said disk will be fully usable by a FAT16 file system since the FAT works with numbered clusters. And that cluster-number need to fit in a 16 bit number: total clusters between 1 and 65535
So the extra non-CHS parameter probably provides information to DOSBox on how to interpret the File Allocation Table on the image and to calculate the starting point of the first sector in a cluster.
Edit 2: I think that the 127 in the code above means 127 sectors per cluster. With a sector size of 512 bytes, that gives a cluster-size of 35,512, very close to a 32 KB cluster-size which should be okay for a FAT16 file system?
Last edited by MiniMax on 2007-06-29, 20:38. Edited 1 time in total.
c/h/s fully define the geometry of the disk, but being able to reference every
sector would require a very large fat. Thus sectors are grouped into clusters.
The cluster value specified is not used (the "real" value is derived from the
boot sector or so) but only saved to be returned by some dos function (1b/1c).
1/* Show the summary of results */ 2 FormatNumber(byte_count,numformat); 3 WriteOut(MSG_Get("SHELL_CMD_DIR_BYTES_USED"),file_count,numformat); 4 Bit8u drive=dta.GetSearchDrive(); 5 //TODO Free Space 6 Bitu free_space=1024*1024*100; 7 if (Drives[drive]) { 8 Bit16u bytes_sector;Bit8u sectors_cluster;Bit16u total_clusters;Bit16u free_clusters; 9 Drives[drive]->AllocationInfo(&bytes_sector,§ors_cluster,&total_clusters,&free_clusters); 10 [u][b]free_space=bytes_sector*sectors_cluster*free_clusters;[/b][/u] 11 } 12 FormatNumber(free_space,numformat); 13 WriteOut(MSG_Get("SHELL_CMD_DIR_BYTES_FREE"),dir_count,numformat); 14 dos.dta(save_dta); 15}
So we can conclude from the CMD Dir that
free_space=bytes_sector*sectors_cluster*free_clusters;
and that the numbers aren't restricted besides their varsize.
Edit : also the autosize is a neet feature but I guess the size function still exists? Never checked.
But then you need to know how to create an img, this remembers me, I still need to add bochs image creator to D.O.G.'s plugins... So much to add and to do ...
I'm going to fiddle around with it some more, hope I have some results this evening implementing the feature.