Line 40:
Line 40:
|}
|}
−
Following the header is two FATs, which are FAT16. Each FAT is the size of a sector. The format of the FAT is not regular FAT16, there's unknown flags and values, so it's currently not possible to process cluster chains. Following the FATs is the root [http://en.wikipedia.org/wiki/File_Allocation_Table#Directory_table directory] cluster, 8 sectors long. Following the root cluster is the data "clusters". The data "clusters" have one sector per "cluster". The size of a sector is determined by the following algorithm:
+
Following the header is two FATs, which are FAT16. Each FAT size is determined by the below algo. The format of the FAT is not regular FAT16, there's unknown flags and values, so it's currently not possible to process cluster chains. Following the FATs is the root [http://en.wikipedia.org/wiki/File_Allocation_Table#Directory_table directory] cluster, 0x1000 bytes long. Following the root cluster is the data "clusters". The data "clusters" have are 0x200 bytes long each. The size of the FAT is determined by the following algorithm:
−
u32 base = (filesize / 0x200) - 8;//This algo doesn't work exactly for files over 1MB. To get the correct size, try multiplying the result of this algo with various values.
+
u32 WC24_GetVFF_FATSize(u32 filesize)
−
u32 sectorsz = base;
−
if(base % 0x200)//Should always be executed.
{
{
−
if(base<0x200)
+
if(filesize < 0x100000)
−
{
+
{//This block is executed for filesizes less than 1MB.
−
sectorsz+= (base % 0x200);
+
u32 base = (filesize / 0x200) - 8;
−
}
+
u32 fatsz = base;
−
else
+
if(base % 0x200)//Should always be executed.
−
{
+
{
−
sectorsz++;
+
if(base<0x200)
−
}
+
{
+
fatsz = 0x200;
+
}
+
else
+
{
+
fatsz++;
+
}
+
}
+
return fatsz;
+
}
+
else
+
{
+
return filesize >> 8;//VFF files larger than 1MB must be aligned to a MB, since this algo doesn't work right with filesizes not aligned.
+
}
}
}