Page 1 of 1

Question about FAT12

Posted: Tue Jan 03, 2006 12:00 am
by stafe
Hello,

i have a big problem with my FAT12 driver ... For example: If I try to load a file ( File1.bmp -> 5KB ) everything works fine ... but if I try to load more files ( File1.bmp -> 5KB , File2.bmp -> 250 KB , File3.bmp -> 2kB ,... ) the Fat12 driver couldn't finde the next cluster from any File ...

File1.bmp: Loading is well done.
File2.bmp: The drive loads only the first sektors, then it couldn't finde the next cluster and give me the code for file is ending ( 0x0fff -> 4096 ), but it isn't so .. only the first area from the file was loaded into the memory ...

I hope somebody can help me with this problem ... or somebody know the problem and can solve it ...
Thanks

stafe

Re: Question about FAT12

Posted: Tue Jan 03, 2006 12:00 am
by Da_Maestro
Post code

Re: Question about FAT12

Posted: Tue Jan 03, 2006 12:00 am
by stafe
OK, this is the code to return the startcluster from the files ... If I load more then 3 files into the memory this code returns a bad startcluster ...

Code: Select all

unsigned int cluster( unsigned char filename[11] )
{
	int i,p=0,j;
	unsigned char *root;
	unsigned int cluster;
	
	root = (unsigned char*)malloc( 0x2800 );				// 512 - Bytes speicher reservieren
	Sektor_lesen( root, 19, 14,0 );		// Root-Dir einlesen

	for( i=0;i<224*32;i+=32 )
	{
		p=i;
		for( j=0;j<11;j++ )
		{
			if( root[p] == filename[j] )
			{
				p++;

				if( j==10 )
				{				
					cluster = root[i+26];						
					return cluster;
				}
				
			}
			else
				break;
		}
	}
	
	return 0;
}
stafe