Question about FAT12

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
stafe
Posts: 22
Joined: Fri Oct 29, 2004 11:00 pm

Question about FAT12

Post 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
Da_Maestro
Member
Member
Posts: 144
Joined: Tue Oct 26, 2004 11:00 pm
Location: Australia

Re: Question about FAT12

Post by Da_Maestro »

Post code
Two things are infinite: The universe and human stupidity. But I'm not quite sure about the universe.
--- Albert Einstein
stafe
Posts: 22
Joined: Fri Oct 29, 2004 11:00 pm

Re: Question about FAT12

Post 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
Post Reply