First post, by superfury
I'm currently always using 16 heads and 63 sectors per track in UniPCemu, with the cylinder count being adjusted to be within range of the hard disk image, when possible, with a minimum of 1 cylinder.
Of course, this will fail with disk sizes less than 16 heads and 63 SPT.
Is there an official method to convert this?
Edit: This is what I'm currently experimenting with:
OPTINLINE word get_SPT(uint_64 disk_size)
{
return (disk_size>=63)?63:disk_size; //How many sectors use for each track? No more than 63!
}
OPTINLINE word get_heads(uint_64 disk_size)
{
return ((disk_size/get_SPT(disk_size))>=16)?16:((disk_size/get_SPT(disk_size))?(disk_size/get_SPT(disk_size)):1); //1-16 heads!
}
word get_cylinders(uint_64 disk_size)
{
uint_32 cylinders=0;
cylinders = (uint_32)(disk_size / (63 * 16)); //How many cylinders!
return (cylinders>=0x3FFF)?0x3FFF:(cylinders?cylinders:1); //Give the maximum amount of cylinders allowed!
}
So:
It will use the sectors as Sectors per Track with 1 head and cylinder up to 63 sectors large.
It will use 63 sectors per track with 1 cylinder and heads being the maximum quotient up to 1008 sectors large.
Otherwise, it will use 16 heads and 63 sectors per track with cylinders being the maximum quotient possible with 16 heads and 63 sectors per track.
Is this method of calculating the CHS geometry of an emulated harddisk correct(the hard disks can be any amount of sectors)?
Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io