📄 fat.c
字号:
#pragma sfr
#pragma NOP
#pragma DI
#pragma EI
#include "Common.h"
#include "Define.h"
#include "Ch375.h"
#include "Fat.h"
#include "Hpi.h"
////////////////////////////////////////
extern sreg XXGFLAGS bXXGFlags;
extern SYS_INFO_BLOCK DeviceInfo;
extern FILE_INFO ThisFile;
extern FILE32_INFO ThisFile32;
extern unsigned char DBUF[BUFFER_LENGTH];
extern unsigned char FATBUF[512];
extern unsigned char CurFatSector[512];
extern FREE_FAT_INFO FreeFat;
////////////////////////////////////////
unsigned long FirstSectorofCluster(unsigned int clusterNum)
{
unsigned long temp;
temp=clusterNum-2;
temp=temp*DeviceInfo.BPB_SecPerClus;
temp=temp+DeviceInfo.FirstDataSector;
return temp;
}
unsigned int ThisFatSecNum(unsigned int clusterNum)
{
unsigned int temp;
temp=clusterNum*2;
temp=temp/DeviceInfo.BPB_BytesPerSec;
temp=temp+DeviceInfo.FatStartSector;
return temp;
}
/*unsigned long ThisFatSecNum32(unsigned long clusterNum)
{
unsigned long temp;
temp=clusterNum*2;
temp=temp/DeviceInfo.BPB_BytesPerSec;
temp=temp+DeviceInfo.FatStartSector;
return temp;
}*/
unsigned int ThisFatEntOffset(unsigned int clusterNum)
{
unsigned int temp1,temp2;
temp1=2*clusterNum;
temp2=temp1/DeviceInfo.BPB_BytesPerSec;
temp1=temp1-temp2*DeviceInfo.BPB_BytesPerSec;
return temp1;
}
/*unsigned long ThisFatEntOffset32(unsigned long clusterNum)
{
unsigned long temp1,temp2;
temp1=2*clusterNum;
temp2=temp1/DeviceInfo.BPB_BytesPerSec;
temp1=temp1-temp2*DeviceInfo.BPB_BytesPerSec;
return temp1;
}*/
unsigned int GetNextClusterNum(unsigned int clusterNum)
{
unsigned int xxgFatSecNum,xxgFatEntOffset;
xxgFatSecNum=ThisFatSecNum(clusterNum);
xxgFatEntOffset=ThisFatEntOffset(clusterNum);
//ThisFile.FatSectorPointer=xxgFatSecNum;
if(ThisFile.FatSectorPointer!=xxgFatSecNum)
{
if(!RBC_Read(xxgFatSecNum,1,FATBUF))
return 0xFFFF;
ThisFile.FatSectorPointer=xxgFatSecNum;
}
///////////////////////////////////////////////////
clusterNum=FATBUF[xxgFatEntOffset+1];
clusterNum=clusterNum<<8;
clusterNum+=FATBUF[xxgFatEntOffset];
return clusterNum;
}
/*unsigned long GetNextClusterNum32(unsigned long clusterNum)
{
unsigned long xxgFatSecNum,xxgFatEntOffset;
xxgFatSecNum=ThisFatSecNum32(clusterNum);
xxgFatEntOffset=ThisFatEntOffset32(clusterNum);
if(ThisFile.FatSectorPointer!=xxgFatSecNum)
{
if(!RBC_Read(xxgFatSecNum,1,FATBUF))
return 0xFFFF;
ThisFile.FatSectorPointer=xxgFatSecNum;
}
///////////////////////////////////////////////////
clusterNum=FATBUF[xxgFatEntOffset+1];
clusterNum=clusterNum<<8;
clusterNum+=FATBUF[xxgFatEntOffset];
return clusterNum;
}*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -